uberglitch
04-11-2007 06:37:04
Hey folks, I apologize if my search-fu is weak on this, but I couldn't find a previous thread talking about it.
In my current project I have some Characters that can fly, now that I've got them immune to gravity I need a way of changing their pitch (local rotation about X) so that DR_Forward movements can involve a bit of up or down.
What I'm currently trying is to set the character's 3D rotation with a Quaternion:
This code attempts to pitch the character up and down based on the Y movements of the mouse, so that but I feel like there's something fundamental I might be missing.
If it helps, here is the movement controller I'm using for the player:
Thanks in advance,
Uberglitch
In my current project I have some Characters that can fly, now that I've got them immune to gravity I need a way of changing their pitch (local rotation about X) so that DR_Forward movements can involve a bit of up or down.
What I'm currently trying is to set the character's 3D rotation with a Quaternion:
(in MouseMoved)
if(isFlying){
Ogre::Quaternion q = player->getGlobalOrientation();
Ogre::Quaternion r = Quaternion(mPitch += Ogre::Radian(mMouseSensitivity * evt.state.Y.rel), Vector3::UNIT_X);
player->setDirection(q * r);
}
This code attempts to pitch the character up and down based on the Y movements of the mouse, so that but I feel like there's something fundamental I might be missing.
If it helps, here is the movement controller I'm using for the player:
class PlayerMovementController : public NxOgre::CharacterMovementVectorController {
public:
void move(NxVec3 &out, NxVec3 &moveVector, NxQuat &direction, NxVec3 &g, float t, NxOgre::Character*) {
if(flying)
out = (direction.rot(moveVector) * mySpeed) * t;
else
out = ((direction.rot(moveVector) * mySpeed) + g) * t;
}
void setFlying(bool fly) { flying = fly; };
bool isFlying() { return flying; }
void setMoveSpeed(NxReal speed) { mySpeed = speed; }
NxReal getMoveSpeed() { return mySpeed; }
bool flying;
NxReal mySpeed;
};
Thanks in advance,
Uberglitch