About Store Forum Documentation Contact
Donations:
227$/mo



Post Reply 
Animatable props
Author Message
gordon13 Offline
Member

Post: #1
Animatable props
Hello,
I am very new to this and am having a hard time understanding how the programming and world editor work together.
I am trying to add some basic animated props. While dragging and dropping the fbx seems to work, and the animation is correctly displayed when I hover the mouse over the animation file, the animation is not visible when I play the game.
I've been looking around and saw a few examples of people doing it programmatically, but to me this seems over complicating things since a level might have loads of animated meshes.

Do we need to add a bit of code to play animations for all animated props or am I misunderstanding?
01-31-2014 11:26 PM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #2
RE: Animatable props
http://www.esenthel.com/community/showth...p?tid=6362

Ozy made a tutorial that may help you understand what needs to be done.
01-31-2014 11:50 PM
Find all posts by this user Quote this message in a reply
gordon13 Offline
Member

Post: #3
RE: Animatable props
Thanks! Unfortunately I've already come across this tutorial but it doesn't really help me since its done programmatically. I want to be able to add an animated prop without having to add more lines of code for each animated prop in my map.
02-01-2014 12:10 AM
Find all posts by this user Quote this message in a reply
Ozmodian Offline
Member

Post: #4
RE: Animatable props
Hi Gordon,

I only modified code because the tutorial i edited did not have a "world". If I had a world and the object was of a common type (like animated prop) could just just drag and drop it into any world.
02-01-2014 01:40 AM
Find all posts by this user Quote this message in a reply
gordon13 Offline
Member

Post: #5
RE: Animatable props
But what if you have lots of unique animated props (I'm thinking animated wall details etc). Looking at your tutorial you added the character and the animations files directly in the code.
I'm looking for a way that will update every instance of an animated prop object without having to specific references objects or animations in the code.

I saw something called OBJ_ANIMATABLE in the engine files. Somehow, if I could make objects take on the ANIMATABLE property maybe they would animate automaticaly without being individually referred to the code?

Somehow defining a default animation for each object you want animated, in the editor, and then in the code, detecting all OBJ_ANIMATABLE in the world and updating them?
It seems strange that the OBJ_ANIMATABLE thing exists, yet there are no examples (that I know of) for using it.
(This post was last modified: 02-01-2014 01:16 PM by gordon13.)
02-01-2014 01:15 PM
Find all posts by this user Quote this message in a reply
Pixel Perfect Offline
Member

Post: #6
RE: Animatable props
Hi Gordon, yes you can do exactly what you're suggesting as I've done just that ... so I can drop items into the scene with a default animation passed as a parameter which is played automatically. No reference is ever made to these items in the game code, the automatic calling of their update proc takes care of it all.

Just modify which ever class you need to base it on to provide this functionality, I have used both the Chr class and the Animatable class depending on what I was wanting to do and assign my new classes to the objects in the editor.

You can use the same mechanism to attach default sounds too where needed.
02-01-2014 01:46 PM
Find all posts by this user Quote this message in a reply
gordon13 Offline
Member

Post: #7
RE: Animatable props
From what I understand I need to read the custom parameters in my new animated_object class (as shown in one of the tutorials). This is what I have so far to read the mesh and animation parameters from the editor however I haven't got it to work yet. I get this error:

"Can't load ObjParam " lots of random characters" "

Here's the code:

class Animated_Model : Game.Animatable// Game Animatable Object
{
Game.ObjParamsPtr model;
Game.ObjParamsPtr idle_animation;

virtual void create(Game.ObjParams &obj)
{
super.create(obj);

if(Param *par=obj.findParam("mesh" ))model =par.asID();
if(Param *par=obj.findParam("idle" ))idle_animation=par.asID();

if(!chr->mesh())Exit("Object has no mesh");
cskel.create(model->mesh()->skeleton(), 1.0);
}

virtual bool update()
{
cskel.clear(); // clear controlled skeleton animation

cskel.animate(idle_animation.id(), Time.time());
cskel.updateMatrix (MatrixIdentity);
cskel.updateVelocities( );

return true;
}

}

Any ideas?
(This post was last modified: 02-01-2014 08:00 PM by gordon13.)
02-01-2014 07:59 PM
Find all posts by this user Quote this message in a reply
Pixel Perfect Offline
Member

Post: #8
RE: Animatable props
par.asID() returns a UID type not a ObjParamsPtr, hence the error
02-01-2014 08:36 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #9
RE: Animatable props
(02-01-2014 08:36 PM)Pixel Perfect Wrote:  par.asID() returns a UID type not a ObjParamsPtr, hence the error
ObjParamsPtr can be loaded from UID, so it's not an issue.

Based from the code:
Game.ObjParamsPtr idle_animation;
idle_animation=id;

you're trying to load an animation as a game object?

Try
SkelAnim *anim=null;
anim=cskel.findSkelAnim(id);
after creating the cskeleton

Source for this is already included in the "Game.Animatable" class, to which you get sources after purchasing the 2.0 license which I highly recommend smile
02-01-2014 10:17 PM
Find all posts by this user Quote this message in a reply
gordon13 Offline
Member

Post: #10
RE: Animatable props
Thanks for the replies. What I'm trying to do is make a reusable animatable object that I can setup from the editor.
I am avoiding the use of IDs directly in code and using the "findparam" function to find the id (for the imported fbx object and it's animation) of each parameter in the object_class (refered to as model and idle in the code).

So essentially I am attempting to retrieve the ID dynamically from the object_class assigned to the animated mesh object I want to import. the model and idle_animation variables are the things I want to contain the IDs to the respective files and pass those to the rest of the code to do whatever it needs to display an animated mesh.

I actually do have a 2.0 License smile I found a struct class called Animatable but there doesn't seem to be any examples using it. Maybe I'm over looking something? Here's what I have after attempting to apply what you mentioned Esenthel. I think I found a few things that were wrong before and fixed them but the game crashes with no error message:

class Animated_Model : Game.Animatable// Game Animatable Object
{
SkelAnim *skel_anim=null;

Game.ObjParamsPtr model;
Game.ObjParamsPtr idle_animation;

virtual void create(Game.ObjParams &obj) // extend default creation
{
super.create(obj); // default create

if(Param *par=obj.findParam("mesh" ))model.id() =par.asID();
if(Param *par=obj.findParam("idle" ))idle_animation.id()=par.asID();

if(!model->mesh())Exit("Object has no mesh");
cskel.create(model->mesh()->skeleton(), 1.0);
skel_anim=cskel.findSkelAnim(idle_animation.id());
}

virtual bool update()
{
cskel.clear(); // clear controlled skeleton animation

cskel.animate(skel_anim, Time.time()); // animate with "walk" animation and current time position
cskel.updateMatrix (MatrixIdentity); // update controlled skeleton animation matrixes
cskel.updateVelocities( ); // update controlled skeleton bone velocities (this is needed for Motion Blur effect)

return true;
}


}
(This post was last modified: 02-02-2014 01:25 AM by gordon13.)
02-02-2014 01:24 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #11
RE: Animatable props
Hi,

the problem is here:
Code:
(Param *par=obj.findParam("idle" ))idle_animation.id()=par.asID();

if(!model->mesh())Exit("Object has no mesh");
cskel.create(model->mesh()->skeleton(), 1.0);
skel_anim=cskel.findSkelAnim(idle_animation.id());
it should be something like this:
Code:
if(!model->mesh())Exit("Object has no mesh");
cskel.create(model->mesh()->skeleton(), 1.0);
if(Param *par=obj.findParam("idle"))skel_anim=cskel.findSkelAnim(par.asID());


This is included in the Game.Animatable source:
line:
Code:
if(cskel.skeleton())skel_anim=GetAnim(cskel, &obj, "animation");
and the function 'static SkelAnim* GetAnim' in the 'Animatable.cpp' file

Also you may want to use F8 to open the project in VS and debug there, to see the line which causes the crash.
02-02-2014 02:00 AM
Find all posts by this user Quote this message in a reply
gordon13 Offline
Member

Post: #12
RE: Animatable props
Same issue happens after changing it.
I didn't know you could open it in visual studio! Debug mode is pretty useful. At the moment it says:

Unhandled exception at 0x0165dc81 in test.exe: 0xC0000005: Access violation reading location 0x000000080.

The call Stack is pointing to:
> test.exe!EE::CacheElmPtr<EE::Mesh,EE::_Meshes>::operator bool() Line 161 + 0x11 bytes C++

Something is wrong when loading the mesh?

Where can I find the Game.Animatable file? The only one I have is under Esenthel Engine>Game>Animatable and that only has empty methods and variables.
http://grab.by/u1E0
02-02-2014 11:02 AM
Find all posts by this user Quote this message in a reply
Pixel Perfect Offline
Member

Post: #13
RE: Animatable props
As a Esenthel 2.0 licensed developer you can download the 'Game Object Classes Source Code' from the same location that you download the engine.
02-02-2014 01:02 PM
Find all posts by this user Quote this message in a reply
gordon13 Offline
Member

Post: #14
RE: Animatable props
Ah I was wondering where the code was found! The Animatable source code worked perfectly thank you!
I kinda wish I understood what I was doing wrong in my code though.
02-02-2014 04:13 PM
Find all posts by this user Quote this message in a reply
Post Reply