ahtm80
05-01-2010 20:57:49
Hi guys,
My problem turn OGRE3DBody. As follows define Body.
PlayerBody = PhysicsRenderSystem->createBody(new NxOgre::Sphere(20),NxOgre::Vec3(0,100,0),"Sphere01.mesh");
But i dont know how turn. "rotate" as there is code? For example this objects turn 90degree. Pls help me.
sorry for my bad english.
betajaen
05-01-2010 21:06:39
Add some torque, or either calculate the 90 degree quaternion then setOrientation with it.
ahtm80
05-01-2010 21:51:57
Thanks for question,
complicated quaternion, Because of this reason use want addTorque. But dont know this function parameters.
PlayerBody->addTorque(NxOgre::Vec3(0,90,0),NxOgre::Enums::ForceMode_Force,true);
What should be written "NxOgre::Enums::ForceMode_Force" instead.
ShUr1k3n
06-01-2010 13:19:48
I use it like this:
Real value = 1000.0f;
NxOgre::Vec3 torque = NxOgre::Vec3(0,0,value); // Rotate on Axis "Z"
// Apply the torque
mBody()->addTorque(torque);
When you apply the torque, the Body will start rotating.
So, if you want to rotate the body 90 deg. "instantly" you should not use "addTorque". Use "setGlobalOrientation" or something like that.
ahtm80
06-01-2010 15:29:22
thanks ShUr1k3n, work but i want change rotate axis. dont turn. Anyway wait for publication nxogre character control.
betajaen
06-01-2010 17:21:33
If you don't want to turn but instantly appear 90degrees then use a quaternion. The quaternion primer on the Ogre Wiki will help.
ahtm80
20-01-2010 11:34:10
if(mKeyboard->isKeyDown(OIS::KC_C))
{
NxOgre::Quat q = CalculateQuaternion(1) * CurrPlayer->getGlobalOrientationQuat();
CurrPlayer->setGlobalOrientationQuat(q);
}
////////////////////////////////
NxOgre::Quat CalculateQuaternion(Real TurnDegree)
{
NxOgre::Quat QuatP;
QuatP.x = QuatP.z = 0;
QuatP.y = Ogre::Math::Sin(Degree(TurnDegree / 2));
QuatP.w = Ogre::Math::Cos(Degree(TurnDegree / 2));
return QuatP;
}
quaternion do with, just visual turn. But not change rotation and xyz axis. Help me please.
deshan
20-01-2010 16:29:15
Hi
setGlobalOrientationQuat(); do the rotation. I am also using that.
Ogre::Quaternion quat(Ogre::Radian(some_degree),Ogre::Vector3::UNIT_Y);
urrPlayer->setGlobalOrientationQuat(quat);
If you need smooth rotation it is also their in the page which betajaen mention above