About Store Forum Documentation Contact



Post Reply 
Animation does not work
Author Message
Babulesnik Offline
Member

Post: #1
Animation does not work
In WE created the scene and the object type assigned OBJ_ANIMATABLE,load mesh and cskel. Uploaded the world and try to start the animation:
Code:
Game::ObjMemx<Game::Animatable>ObjAnimatable;
...
Motion Anim_Man;
...
Bool Init()
{
..
ObjAnimatable[0].cskel.animate(Anim_Man,true);
}
Bool Update()
{
...
    if(Kb.b(KB_LEFT))
   {
       Anim_Man.set(ObjAnimatable[0].cskel,"Animation/1.anim");
       Anim_Man.updateAuto(3,3);
   }
}

But,no work...
04-15-2011 09:18 PM
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #2
RE: Animation does not work
You need to clear the skeleton first before you can animate it.

cskel.clear();

There is always evil somewhere, you just have to look for it properly.
04-15-2011 09:45 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
RE: Animation does not work
the animatable plays animation automatically, just setup skeleton/animation/mesh and rest should be handled automatically
04-15-2011 10:20 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #4
RE: Animation does not work
(04-15-2011 09:45 PM)Dynad Wrote:  You need to clear the skeleton first before you can animate it.

cskel.clear();

Thanks, but no avail.
Code:
ObjAnimatable[0].cskel.clear();
   ObjAnimatable[0].cskel.animate(Anim_Man,true);


(04-15-2011 10:20 PM)Esenthel Wrote:  the animatable plays animation automatically, just setup skeleton/animation/mesh and rest should be handled automatically
I know I put your code, you can specify in my code where I go wrong?


(04-15-2011 10:20 PM)Esenthel Wrote:  the animatable plays animation automatically, just setup skeleton/animation/mesh and rest should be handled automatically
I know I put your code, you can specify in my code where I go wrong?
(This post was last modified: 04-16-2011 07:08 PM by Babulesnik.)
04-16-2011 07:06 PM
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #5
RE: Animation does not work
You need to update your animation with a Timer and update its matrix afterwards.

PHP Code:
ObjAnimatable[0].cskel.clear().animate(Anim_Man,Time.time()).updateMatrix(matrix).updateVelocities(false); 

There is always evil somewhere, you just have to look for it properly.
04-16-2011 07:34 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Animation does not work
no, you don't need to manually animate the Animatable class.
You have its sources so you can investiage them - http://www.esenthel.com/community/showth...p?tid=2620
Where's the problem?
In the Anmatable::create
you can see that there's:

if(skel)if(Param *param=obj.findParam("animation"))skel_anim=&cskel.getSkelAnim(param->asText());

so you need to provide parameter with path to animation.
04-16-2011 08:02 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #7
RE: Animation does not work
(04-16-2011 07:34 PM)Dynad Wrote:  You need to update your animation with a Timer and update its matrix afterwards.

PHP Code:
ObjAnimatable[0].cskel.clear().animate(Anim_Man,Time.time()).updateMatrix(matrix).updateVelocities(false); 

Thank you very much. But by pressing a button is activated only endpoint animation. Reducing the time did not react. Anim_Man.updateAuto (3,3,0.001);


(04-16-2011 08:02 PM)Esenthel Wrote:  no, you don't need to manually animate the Animatable class.
You have its sources so you can investiage them - http://www.esenthel.com/community/showth...p?tid=2620
Where's the problem?
In the Anmatable::create
you can see that there's:

if(skel)if(Param *param=obj.findParam("animation"))skel_anim=&cskel.getSkelAnim(param->asText());

so you need to provide parameter with path to animation.

ObjAnimatable[0].cskel.getSkelAnim("C:/1.anim");

Thanks, but does not work.
(This post was last modified: 04-16-2011 08:25 PM by Babulesnik.)
04-16-2011 08:09 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #8
RE: Animation does not work
Tried different options but the animation does not fire at the touch of a button. Help please.
04-17-2011 02:51 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #9
RE: Animation does not work
getSkelAnim does not set the animation,

you need to study programming bit better,

the line I posted is important:
if(skel)if(Param *param=obj.findParam("animation"))skel_anim=&cskel.getSkelAnim(param->asText());

there are tutorials for custom parameters (SDK\tutorials\game basics\custom parameters)
also world - sdk\data\world\custom params
check objects there (you will see it has parameters)
04-17-2011 02:53 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #10
RE: Animation does not work
you should:
study all game tutorials from SDK
experiment on your own
read the documentation (game objects, parameters)
04-17-2011 02:55 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #11
RE: Animation does not work
Thank you. I redefined virtual functions, but do not know how to change the value of parameter name and value by pressing a button. I need to change the animations dynamically.

Code:
STRUCT(Anim,Game::Animatable)
//{
virtual void create(Game::ObjParams &obj);
};

void Anim::create(Game::ObjParams &obj)
{
if(Param *param=obj.findParam("animation"))skel_anim=&cskel.getSkelAnim(param->asText());
}
If you try this way does not work...
Code:
void Anim::create(Game::ObjParams &obj)
{
    Param param;
    super::create(obj);
    param.name="animation";
    param.value.s="Anim/1.anim";
    obj.params.add(param);
}

How to do would be for different button presses to run different animation?[/align]
04-17-2011 04:48 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #12
RE: Animation does not work
void Anim::update()
{
if(..)skel_anim=&cskel.getSkelAnim(..);
}
04-17-2011 05:02 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #13
RE: Animation does not work
Does not work (((
Code:
STRUCT(Anim,Game::Animatable)
//{
virtual void create(Game::ObjParams &obj);
virtual bool update();
};

void Anim::create(Game::ObjParams &obj)
{
    Param param;
    super::create(obj);
    if(Param *param=obj.findParam("animation")){param->value.s="Anim/1.anim"; skel_anim=&cskel.getSkelAnim(param->asText());}
}

bool Anim::update()
{
    Game::ObjParams obj;
    if(Param *param=obj.findParam("animation"))
    {
      if(Kb.b(KB_LEFT))param->value.s="Anim/2.anim";
      skel_anim=&cskel.getSkelAnim(param->asText());
      i=param->asText(); //Created a variable to view the value of param, but for some reason it is empty.
    }
    return true;
};
(This post was last modified: 04-17-2011 06:05 PM by Babulesnik.)
04-17-2011 06:04 PM
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #14
RE: Animation does not work
The param function doesn't belong in the update function... it only works in the create(Game::ObjParams &obj) function.. so you need to save your params there.

There is always evil somewhere, you just have to look for it properly.
04-17-2011 06:29 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #15
RE: Animation does not work
(04-17-2011 06:29 PM)Dynad Wrote:  The param function doesn't belong in the update function... it only works in the create(Game::ObjParams &obj) function.. so you need to save your params there.


Code:
STRUCT(Anim,Game::Animatable)
//{
Str name;
Str value;

virtual void create(Game::ObjParams &obj);
virtual bool update();

Anim();

virtual void save(File &f);
virtual Bool load(File &f);
};

void Anim::create(Game::ObjParams &obj)
{
    Param param;
    super::create(obj);
    if(Param *param=obj.findParam("animation")){param->value.s="Anim/1.anim"; skel_anim=&cskel.getSkelAnim(param->asText());}
}

bool Anim::update()
{
    Game::ObjParams obj;
    if(Param *param=obj.findParam("animation"))
    {
      if(Kb.b(KB_LEFT))value="Anim/2.anim";
     // skel_anim=&cskel.getSkelAnim(param->asText());
      i=name;
    }
    return true;
};
void Anim::save(File &f)
{
   super::save(f);

   f<<name<<value;
}
Bool Anim::load(File &f)
{
   if(super::load(f))
   {
      f>>name>>value;
      return true;
   }
   return false;
}

Does not work all the changes are ignored.
Surely for something to just change the animation to write such a great code?
(This post was last modified: 04-17-2011 07:05 PM by Babulesnik.)
04-17-2011 07:04 PM
Find all posts by this user Quote this message in a reply
Post Reply