Character and equipment – ANIMATION FOR MANY NODES USING ONLY 1 SKELETON

Hello,

I need help with creating ANIMATION FOR MANY NODES USING ONLY 1 SKELETON

to do character and its equipment

I have objects exported via ogre meshes

this objects using same skeleton in blender

i know how to do animation for 1 skeleton with 1 node/spatial assigned

[java]

control = myobject.getControl(AnimControl.class);

control.addListener(this);

channel = control.createChannel();

channel.setAnim("wait");

channel.setLoopMode(LoopMode.Loop);

[/java]

i would like to know how to do somethin like

[java]

for (int i = 0; i < ObjectList.size(); i++) {

control.addSpatial(THERE MY SPATIAL/NODE);

}

[/java]

or just how to do animation for many objects using 1 skeleton(no duplicate)



i dont know how to external load only skeleton from xml file too



Please help me :slight_smile:

each object should have an animcontrol, just create a method that loops through all your objects and starts the animation.

tnx for fast reply, i dont know if it is good idea, some of objects could be “Back in time”

or not?

No

so i do somethin like:





[java]

for (int i = 0; i < ObjectList.size(); i++) {

ObjectList.get(i).control = ObjectList.get(i).getControl(AnimControl.class);

ObjectList.get(i).control.addListener(this);

ObjectList.get(i).channel = ObjectList.get(i).control.createChannel();

ObjectList.get(i).channel.setLoopMode(LoopMode.Loop);

}

[/java]

and procedure fo start anime all objects like:

[java]

for (int i = 0; i < ObjectList.size(); i++) {

ObjectList.get(i).channel.setAnim(ANIMATION NAME);

}

[/java]



And question how it work if there will not be “back in time”

is it (many threads) or (one thread for all animations) or (main renderthread loop)?

just tell me, i dont know too many about this anim system

I told you already, it will not be back in time. If you don’t understand why, read the wiki and meditate a bit about the update loop.

1 Like

ok so if it will work, then Thank u very much :slight_smile:

meditate a bit
lol ... but it does work, after reading the wiki and looking at source, just thinking will more often that not results in an answer.

i have one addon question:

U are good people, and i dont find answer(maybe it is somewhere but hard to find).

When i export via ogre meshes

[java]

Node node = (Node) assetManager.loadModel(src);

[/java]

i have always “NODE POSITION LOCAL: (0.0, 0.0, 0.0), WORLD: (0.0, 0.0, 0.0)”, but in blender i have it in other position.locally and global.

and it is possible to get same position as in blender?

I think ctrl+a apply scale and translation or something should work.

if thats true it would be a big problem, especially in having multiple parts. I mean how will you find weapon position if everything goes to (0,0,0) ?



Edit: is this a theoritical error ? the methods getWorldTranslation may return (0,0,0) but is the Part X of the weapon at the right place ?

Maybe getWorldTranslation asks where its center is ?

yea its very bad, Addez what u mean by ctrl+a?

In ogre meshes i can select only one object and there are no option to apply position(there are used auto location there is manual but dont know how to use it)

edit up: i just use this code i writed and after this 1 line code, it have position i writed.

[java]

Node node = (Node) assetManager.loadModel(src);

System.out.println("NODE POSITION LOCAL: "+node.getLocalTranslation()+" WORLD: "+node.getWorldTranslation());

[/java]

You can get the position of the bone that the weapon is attached to by doing:

control.getSkeleton().getBone(“BoneName”).getLocalPosition();

or

control.getSkeleton().getBone(“BoneName”).getLocalPosition();

control.getSkeleton().getBone(“BoneName”).getWorldBindInversePosition();



same goes for rotation and scale.

tralala said:
if thats true it would be a big problem, especially in having multiple parts. I mean how will you find weapon position if everything goes to (0,0,0) ?

Edit: is this a theoritical error ? the methods getWorldTranslation may return (0,0,0) but is the Part X of the weapon at the right place ?
Maybe getWorldTranslation asks where its center is ?


I doubt it recenters the object before export. But of course this also means it will always say 0 because it doesn't know where the arbitrary center is.

oxplay2 said:
yea its very bad, Addez what u mean by ctrl+a?
In ogre meshes i can select only one object and there are no option to apply position(there are used auto location there is manual but dont know how to use it)


Scale and rotation done in object view is not automatically applied to object data.

when I export mesh with armature from blender they usually gets messed up

because I have not set the scale and rotation and translation to 0



To do this, select the mesh in blender, click ctrl+a and take the first option.

This is what usually solves all my problems :stuck_out_tongue:

1 Like

hi i tried it.

I put my blender object translation really really far. When i imported my mesh in jme it was invisible, which means that jme doesnt mess with the translation/rotation/scale and it reads them normally.

Note that node.getLocalTranslation() and node.getWorldTranslation() lies because it represents another thing (not the model).

Addez said:
when I export mesh with armature from blender they usually gets messed up
because I have not set the scale and rotation and translation to 0
To do this, select the mesh in blender, click ctrl+a and take the first option.
This is what usually solves all my problems :P

Yea it fixed rotation and scale, but position is still bad. U solved 2 of 3 problems :) rotation ok, scale ok, position BAD
Thank u :) only position left
tralala said:
hi i tried it.
I put my blender object translation really really far. When i imported my mesh in jme it was invisible, which means that jme doesnt mess with the translation/rotation/scale and it reads them normally.
Note that node.getLocalTranslation() and node.getWorldTranslation() lies because it represents another thing (not the model).

Dont know, why it have bad position then?
i will prepare some screens now, maybe it will help

OMG oxplay2 is right, i tried it again and it messed with rotation / translation / scale.

I had a small hand (Smaller than cube), above the cube !!!



Look how it got imported in Jme :



JME import



Which means jme’s importing is bugged !!!



GG now we will have to create an extra file for each model that is created by hand and holds the position/scale/rotation.

http://i.imgur.com/7DjGp.jpg

http://i.imgur.com/nm4GL.gif

http://i.imgur.com/rc0U0.gif

http://i.imgur.com/WBlbE.gif

http://i.imgur.com/XL22m.jpg

i must add that with armature or not, it is in same position in blender(on 1 frame)

kidneytrader said:
I doubt it recenters the object before export. But of course this also means it will always say 0 because it doesn't know where the arbitrary center is.
Scale and rotation done in object view is not automatically applied to object data.

yea but how to fix position?(rotation and scale fixed - tnx to Addez)

i guess from what others said you will have to do it with the crappy way :



control.getSkeleton().getBone(“HeadAttachment”).getLocalPosition();



Where HeadAttachment is a 0 size bone that you will position at the center of the head with blender.

1 Like