move node "forward" regarding direction
Posted: Mon Dec 18, 2006 9:28 pm
Hi
I have spaceships like seen below. What would be a smart way to update their position in the world given i have a velocity and a direction? I can rotate the node according to the turn-speeds (turn,pitch,bank) but how would i thrust the node "forward", if this direction is defined by the current rotation?
Thanks for any tips
Erik
I have spaceships like seen below. What would be a smart way to update their position in the world given i have a velocity and a direction? I can rotate the node according to the turn-speeds (turn,pitch,bank) but how would i thrust the node "forward", if this direction is defined by the current rotation?
Thanks for any tips
Erik
Code: Select all
class craft{
public:
float vel;
float fallSpeed;
float turn;
float pitch;
float bank;
vect3d pos;
irr::scene::IAnimatedMeshSceneNode* node;
void control();
craft(){
vel=0;
fallSpeed=0;
turn=0;
pitch=0;
bank=0;
}
};
void craft::control(){
float acc=0.001f;
float turnSpeed=1.0f;
mydraw(0,10,30,"Vel : %.2f",vel);
mydraw(0,10,50,"Turn : %.1f",turn);
if(kh.keyDown(KEY_UP))
vel+=acc;
if(kh.keyDown(KEY_DOWN))
vel-=acc;
if(kh.keyDown(KEY_LEFT))
turn-=turnSpeed;
if(kh.keyDown(KEY_RIGHT))
turn+=turnSpeed;
//move
howTo?
};