how to control animation

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
green_algae
Posts: 7
Joined: Wed Sep 14, 2005 12:20 pm

how to control animation

Post by green_algae »

Hi,

i have implemented click n run concept like in a rpg game using the createFlyStraightAnimator function.
is there another method of animation other than createFlyStraightAnimator???
i have no control over this animation. so i have no idea when it gets played or at what particular condition does it end. i heard that people normally create their own animation functions. is this true n will i have to do the same.
if so can anyone plz help me out...

Thnx
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

Post by pfo »

You can't control a fly straight animator, once it's off it's off until it's destroyed. Instead, try saving the point that you want your person to move to, and have them move each frame towards that point, this way if you click another position, your character will change course towards that position.
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

You can check your condition here in animateNode(ISceneNode* node, u32 timeMs) function:

Code: Select all

	if (!Loop && t >= TimeForWay)
		pos = End;
If you want to control parameters as runtime, you can add set and get methods. Since I know Spintz was started implementation of these methods, but don't know whether these things are yet uploaded. So, can post how you can make it for yourself:

In ISceneNodeAnimatorFlyStraight.h

Code: Select all

        virtual core::vector3df getStartPoint() =0;
        virtual core::vector3df getEndPoint() =0;
        virtual core::vector3df getVector() =0;
        virtual f32 getWayLength() =0;
        virtual f32 getTimeFactor() =0;
        virtual u32 getStartTime() =0;
        virtual u32 getEndTime() =0;
        virtual u32 getTimeForWay() =0;
        virtual bool getLoop() =0;

        virtual void setStartPoint(core::vector3df start) =0;
        virtual void  setEndPoint(core::vector3df end) =0;
        virtual void  setVector(core::vector3df vector) =0;
        virtual void  setWayLength(f32 wayLength) =0;
        virtual void  setTimeFactor(f32 timeFactor) =0;
        virtual void  setStartTime(u32 startTime) =0;
        virtual void  setEndTime(u32 endTime) =0;
        virtual void  setTimeForWay(u32 timeForWay) =0;
        virtual void  setLoop(bool loop) =0;
In CSceneNodeAnimatorFlyStraight.h

Code: Select all

        virtual core::vector3df getStartPoint();
        virtual core::vector3df getEndPoint();
        virtual core::vector3df getVector();
        virtual f32 getWayLength();
        virtual f32 getTimeFactor();
        virtual u32 getStartTime();
        virtual u32 getEndTime();
        virtual u32 getTimeForWay();
        virtual bool getLoop();

        virtual void setStartPoint(core::vector3df start);
        virtual void  setEndPoint(core::vector3df end);
        virtual void  setVector(core::vector3df vector);
        virtual void  setWayLength(f32 wayLength);
        virtual void  setTimeFactor(f32 timeFactor);
        virtual void  setStartTime(u32 startTime);
        virtual void  setEndTime(u32 endTime);
        virtual void  setTimeForWay(u32 timeForWay);
        virtual void  setLoop(bool loop);
In CSceneNodeAnimatorFlyStraight.cpp

Code: Select all

  core::vector3df CSceneNodeAnimatorFlyStraight::getStartPoint()
  {
   return Start;
  }
  core::vector3df CSceneNodeAnimatorFlyStraight::getEndPoint()
  {
   return End;
  }
  core::vector3df CSceneNodeAnimatorFlyStraight::getVector()
  {
    return Vector;
  }
  f32 CSceneNodeAnimatorFlyStraight::getWayLength()
  {
   return WayLength;
  }
  f32 CSceneNodeAnimatorFlyStraight::getTimeFactor()
  {
   return TimeFactor;
  }
  u32 CSceneNodeAnimatorFlyStraight::getStartTime()
  {
   return StartTime;
  }
  u32 CSceneNodeAnimatorFlyStraight::getEndTime()
  {
   return EndTime;
  }
  u32 CSceneNodeAnimatorFlyStraight::getTimeForWay()
  {
   return TimeForWay;
  }
  bool CSceneNodeAnimatorFlyStraight::getLoop()
  {
   return Loop;
  }


void CSceneNodeAnimatorFlyStraight::setStartPoint(core::vector3df start)
{
    Start = start;
	Vector = End - Start;
	WayLength = (f32)Vector.getLength();
	Vector.normalize();

	TimeFactor = WayLength / TimeForWay;
}
void  CSceneNodeAnimatorFlyStraight::setEndPoint(core::vector3df end)
{
    End = end;
	Vector = End - Start;
	WayLength = (f32)Vector.getLength();
	Vector.normalize();

	TimeFactor = WayLength / TimeForWay;
}
void  CSceneNodeAnimatorFlyStraight::setVector(core::vector3df vector)
{
    Vector = vector;
}
void  CSceneNodeAnimatorFlyStraight::setWayLength(f32 wayLength)
{
    WayLength = wayLength;
}
void  CSceneNodeAnimatorFlyStraight::setTimeFactor(f32 timeFactor)
{
    TimeFactor = timeFactor;
}
void  CSceneNodeAnimatorFlyStraight::setStartTime(u32 startTime)
{
    StartTime = startTime;
}
void  CSceneNodeAnimatorFlyStraight::setEndTime(u32 endTime)
{
    EndTime = endTime;
}
void  CSceneNodeAnimatorFlyStraight::setTimeForWay(u32 timeForWay)
{
    TimeForWay = timeForWay;
}
void  CSceneNodeAnimatorFlyStraight::setLoop(bool loop)
{
    Loop = loop;
}
Hope this will help.
ImageImage
Site development -Rock and metal online
--- etcaptor.com ------freenetlife.com
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

Did the code posted above made it to 1.4Beta?

I think CSceneNodeAnimatorFlyStraight should have a method for triggering it and also setting the start and end during runtime.

let me know if i missed something.

thanks.
Post Reply