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
formulas to my node's coordinates depending on the elapsed time, but i have no success with it on this moment.x = (v0* cosα )*t;
y = (v0*sinα)*t - g*t2 / 2
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);
}
thanks for attention!