AnimControl – one for many objects

hello!



i just need simple advise:

since i have character in parts(head,torso,arms,legs) do i need to have AnimControl for each of them and play animations on them separately?

or:

is there a way to join AnimControls and have one for all of them?(i see it have “Mesh[] targets” - but don’t know if it is what i think.).



it would be good to have one AnimControl for all of parts. I just need advise before “trying”, to know if this is possible.



Thanks for help!



@memonick:



you said you did it, but i dont know if via Geometries, or via Objects.



i could do it via Geometries(many materials in blender), but for example i want to have 2 Geometries in hand objects and it is impossible to have all armors/heads in blender as one object(it’s not clear…).

Well the usual way is to have a skeleton for the character and use one or multiple channels that modify different bones, resulting in a combined animation. Then you would define attchment points for different objects, that can be accesed programmtical. (eg one for the shield, that gets rotated ect correctly in the animations, so you only need to attach the shield geometry to it) Think of the attachment points kinda like Nodes for subcomponents.



Since you use different geometrys for the objects node animations would be the standart ogre way of doing them. However jme3 cannot load those as far as I know. So you probably need to come up with a own system, or convert to the supported ones(wichever is simpler).

1 Like

Hey oxplay2. Strange that I wasn’t told about the mention. But anyway, I’ll use an AnimControl for each part. I don’t know whether or not it’s possible to use just one AnimControl since all the different parts will be different models (spatials).



That’s as far as I can help - but I hope someone can help you more. Sorry.

1 Like

@memonick: i afraid i will need to do the same.



every part can be assigned to 2-3 bones, so assign them to one bone will result in ugly animations.



BTW about one bone assign(weapons/shields):

i never assigned object to a bone, if someone could tell me how to exacly do it, it would be greatful.

otherwise, i will look alone.

What do you use? 3DS Max? If yes, I can help. If not, maybe try this: Animation Workflow.pdf - Google Drive



Good luck buddy :slight_smile:

1 Like

thank you



blender

i know how to export

BTW this document is obsolete imo.

Actually this works fine if you attach the AnimControl and the SkeletonControl to the parent node.

The SkeletonControl has an array of target meshes and is able to gather them when you attach it to the parent node.



Sinbad model works like that, it has 7 different geometries working with the same animControl and the same SkeletonControl.

try to transform it to j3o and inspect the model.



From blender it’s pretty easy, your objects only have to share the same armature.

1 Like

nehon:



when i export via ogreMesh, i have many separate models with their own AnimControl.(and it work but only when i have one AnimControl for one element)



When i try to get all Nodes under one AnimControl, then it dont work(i tried in SceneComposer - do i need do it in code?).



Maybe you say about blend2j3o(directly from blender), but i have exception:

java.lang.IllegalStateException: Cannot find track for: belt bone
at com.jme3.scene.plugins.blender.constraints.Constraint.getTrack(Constraint.java:109)

so i will need to remove constrains from skeleton, and see how JMP export it directly from blender.

edit:
and to be clear:
i don't want to have Geometries with one shared AnimControl
i want to have many Nodes(with their Geometries) sharing one AnimControl.
@oxplay2 said:
and to be clear:
i don't want to have Geometries with one shared AnimControl
i want to have many Nodes(with their Geometries) sharing one AnimControl.

oh....why?
1 Like

nehon:



becouse i want to be able for example to “cut arms” / “cut legs” / “cut head” AND sometimes head can have a helmet, or arm can have ring or something. and its not all. arms/head/legs/torso is splitted into 2 materials, where one is texture and second is “flesh”(where flesh material is used for all cutted parts).



i think this 2 main reasons is enough :wink:



edit: there is a good reason too:

its very bad to have 999(example) materials in one blender file with one object. i know i can hide material elements, but its not handy.



i need to have some of heads, some of arms/arm armors, some of torso/armors, some of hairs/helmets, etc…

its very not handy to have it all in one object in blender.



and it’s hard to change parts with working AnimControl in Character Creator i am making.



that is why i need Nodes with their Geometries.

How about using a UEBER shader and a textureatlas + uv mapping in blender?

One material for everythig.

1 Like

there is UV mapping, ofc…

i think textureatlas can’t contain 999(again example) textures…



BTW: then still other reasons are unchanged.

@oxplay2 said:
nehon:

becouse i want to be able for example to "cut arms" / "cut legs" / "cut head" AND sometimes head can have a helmet, or arm can have ring or something. and its not all. arms/head/legs/torso is splitted into 2 materials, where one is texture and second is "flesh"(where flesh material is used for all cutted parts).

i think this 2 main reasons is enough ;)

Actually....what would prevent your to do all of that with geometries only? i mean you can have the character node and all the geometries below it, (head geom, helmet geom, ring geom , w/e geom ...) all attached to the character node...
What makes you think it's gonna be easier if you have nodes?

Really look at Sinbad's model it works just fine and it's built like that.
1 Like

@nehon:



yes, but simbad don’t have multi versions of his hands/armor/head/legs/torso AND i have. he have only one version of hands/head/etc.



if i make as you say, then in blender i will have no possibility of using layers/etc… and it will be hard to modify/add more elements.

Ok i get that you want to switch parts of the model.

So I made a small test case to demonstrate what I mean.

I think you are over complicating something that is already fairly complicated…



[java]

package mygame;



import com.jme3.animation.AnimChannel;

import com.jme3.animation.AnimControl;

import com.jme3.animation.LoopMode;

import com.jme3.animation.SkeletonControl;

import com.jme3.app.SimpleApplication;

import com.jme3.input.KeyInput;

import com.jme3.input.controls.ActionListener;

import com.jme3.input.controls.KeyTrigger;

import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.scene.Geometry;

import com.jme3.scene.Node;



/**

  • test
  • @author Nehon

    */

    public class Main extends SimpleApplication {



    public static void main(String[] args) {

    Main app = new Main();

    app.start();

    }



    @Override

    public void simpleInitApp() {



    viewPort.setBackgroundColor(ColorRGBA.DarkGray);

    flyCam.setMoveSpeed(100);



    //loading the model

    final Node model = (Node) assetManager.loadModel(“Models/Sinbad/Sinbad.j3o”);

    rootNode.attachChild(model);



    //keeping the pants geometry in a variable

    final Geometry origPants = (Geometry) model.getChild(“Sinbad-geom-7”);



    //creating a clone (just for conveniance of the example, but this can be someting else

    //imported from blender that has bone index and bone weight for this skeleton

    final Geometry newPants = (Geometry) model.getChild(“Sinbad-geom-7”).clone(false);

    //setting a basic lighting material

    newPants.setMaterial(new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”));



    //fetching the skeleton control on the model

    final SkeletonControl skeletonControl = model.getControl(SkeletonControl.class);

    //removing it

    model.removeControl(skeletonControl);



    //removing the original pants from the model

    origPants.removeFromParent();

    //attaching the new pants to the model

    model.attachChild(newPants);



    //re-adding the control so that it gathers the geoms

    model.addControl(skeletonControl);



    //setting an animation to demostrate that the anim is not messed up…

    AnimChannel channel = model.getControl(AnimControl.class).createChannel();

    channel.setAnim(“Dance”);

    channel.setLoopMode(LoopMode.Loop);





    //even adding a key binding to switch pants at runtime

    inputManager.addListener(new ActionListener() {



    public void onAction(String name, boolean isPressed, float tpf) {

    if (name.equals(“switchPants”) && isPressed) {

    model.removeControl(skeletonControl);

    if (origPants.getParent() != null) {

    origPants.removeFromParent();

    model.attachChild(newPants);

    } else {

    newPants.removeFromParent();

    model.attachChild(origPants);

    }

    model.addControl(skeletonControl);

    }

    }

    }, “switchPants”);



    inputManager.addMapping(“switchPants”, new KeyTrigger(KeyInput.KEY_SPACE));



    }



    }



    [/java]



    Screenshot :

    http://i.imgur.com/aHlsX.png

    Now if you want to change the pants with another model, it just have to fit to the same skeleton. So you can have plenty different blender files (one for each armor set for example) has long as you use the same skeleton in those files.
5 Likes

@nehon, performance-wise, is it better to use this method?

indeed it is, why not? it contain much less data, and update loops are merged. even onAnimationCycleDone/etc will no need ingerence since its only one AnimControl.



I really don’t know that it’s so easy.



and indeed, it is good idea. (if there will be not problem in appending/importing skeleton to other blend files).

i hope it’s true it will work for more “sets”.



the problem of 2 materials i will solve by merging flesh texture and element texture.(like Empire Phoenix said)

also i will need to name geometries, but as i good remember: material name → geometry name(so there should not be problem of manual changing names in SceneComposer)



@memonick:

don’t know if you will make one control now, but i think we should really thank nehon guru :slight_smile:

Better than what? having nodes for each part? I think it does not make any difference…

It’s just a lot more convenient and allow you to have only one AniCcontrol



Edit : I was answering to memonick

3 Likes

i just wanted to thank you so much nehon. you shared your time to make solution + example :slight_smile:



edit: even if many AnimControls worked, one AnimControl is much better.

1 Like
@oxplay2 said:
i just wanted to thank you so much nehon. you shared your time to make solution + example :)

You're welcome ;)
1 Like