How to make movement by the parabollyc trajection?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
varnie
Posts: 31
Joined: Wed Jul 19, 2006 8:27 pm
Location: Russia, Ural

How to make movement by the parabollyc trajection?

Post by varnie »

hello!

could ayou give me short info how i can make an animator, which will move node by the parabollyc trajection?


i know i have to apply
x = (v0* cosα )*t;
y = (v0*sinα)*t - g*t2 / 2
formulas to my node's coordinates depending on the elapsed time, but i have no success with it on this moment.

here's what i have:

Code: Select all

class CSceneNodeAnimatorParabollycFlight : public ISceneNodeAnimator
{
   //...

   //! animates a scene node
		void animateNode(ISceneNode* node, u32 timeMs);

   //...
}

void CSceneNodeAnimatorParabollycFlight::animateNode(ISceneNode* node, u32 timeMs)
{
    if (!node)
	 return;
	 
    static f32 angle = 0.5; 
    static u32 v0 = 3;

    u32 t = timeMs-StartTime;
  
      
    core::vector3df newPos = Start; //take start's position

    if (!Loop && t >= TimeForWay)
    {	
           newPos = End;      
    }
    else
    { 	
             
      newPos.X = (v0 * cos(angle) )*t;   
      newPos.Y = ( v0 * sin(angle) )*t + 9.8*t*t / 2;
      printf("new vector: %f32 %f32 %f32\n",newPos.X, newPos.Y,newPos.Z);
    
    }
		
    node->setPosition(newPos);
}
it gives me strange coordinates. where're my mistakes there?
thanks for attention!
Post Reply