.B3D: How to make character body out of several parts

Post your questions, suggestions and experiences regarding to Image manipulation, 3d modeling and level editing for the Irrlicht engine here.
sunnystormy
Posts: 105
Joined: Mon Jun 02, 2014 2:32 am
Location: Washington, D.C.
Contact:

Re: .B3D: How to make character body out of several parts

Post by sunnystormy »

@Mel

Everything you just said is what I figured I'd have to end up doing. :/

Would you mind telling me which classes I should look into in order to implement this approach?

Thanks.
My blog: http://fsgdp.wordpress.com "The Free Software Game Development Pipeline"
Alopex
Posts: 41
Joined: Sat Sep 12, 2015 10:12 pm

Re: .B3D: How to make character body out of several parts

Post by Alopex »

@Mel

Edit: I misunderstood you, at first. Is it necessary for the "all animations" file to even have a mesh. Could it just be the skeleton?

Either way, I'm still trying to get useAnimationFrom to even work.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: .B3D: How to make character body out of several parts

Post by CuteAlien »

@Alopex: You can split animations nodes from mesh nodes on export. So the animations don't need Texture Nodes, Brush Nodes and Mesh Nodes while the base mesh doesn't need animation nodes.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Alopex
Posts: 41
Joined: Sat Sep 12, 2015 10:12 pm

Re: .B3D: How to make character body out of several parts

Post by Alopex »

@CuteAlien

Edit: Had a brainfart. I'll get back to you once I emerge from my admittedly self-induced confusion.
Alopex
Posts: 41
Joined: Sat Sep 12, 2015 10:12 pm

Re: .B3D: How to make character body out of several parts

Post by Alopex »

Code: Select all

    IAnimatedMesh* maletorsomesh = smgr->getMesh("C:/Users/James/Documents/Psychophagus/Assets/Male/Male_Chest.b3d"); 
    IAnimatedMesh* maleheadmesh = smgr->getMesh("C:/Users/James/Documents/Psychophagus/Assets/Male/Male_Head.b3d"); 
    IAnimatedMesh* malehandsmesh = smgr->getMesh("C:/Users/James/Documents/Psychophagus/Assets/Male/Male_Hands.b3d"); 
    IAnimatedMesh* malelegsmesh = smgr->getMesh ("C:/Users/James/Documents/Psychophagus/Assets/Male/Male_Legs.b3d"); 
    IAnimatedMesh* malefeetmesh = smgr->getMesh ("C:/Users/James/Documents/Psychophagus/Assets/Male/Male_Feet.b3d"); 
    IAnimatedMesh* anim = smgr->getMesh ("C:/Users/James/Documents/Psychophagus/Assets/Male/Male_Player_Animations.b3d"); //animated full-body mesh
    ISkinnedMesh* skinmaletorsomesh = (ISkinnedMesh*) maletorsomesh;
    ISkinnedMesh* skinmaleheadmesh = (ISkinnedMesh*) maletorsomesh;
    ISkinnedMesh* skinmalehandsmesh = (ISkinnedMesh*) maletorsomesh;
    ISkinnedMesh* skinmalelegsmesh = (ISkinnedMesh*) maletorsomesh;
    ISkinnedMesh* skinmalefeetmesh = (ISkinnedMesh*) maletorsomesh;
    ISkinnedMesh* skinanim = (ISkinnedMesh*) anim;
    IAnimatedMeshSceneNode* maletorsonode = smgr->addAnimatedMeshSceneNode(maletorsomesh);
    IAnimatedMeshSceneNode* maleheadnode = smgr->addAnimatedMeshSceneNode(maleheadmesh);
    IAnimatedMeshSceneNode* malehandsnode = smgr->addAnimatedMeshSceneNode (malehandsmesh);
    IAnimatedMeshSceneNode* malelegsnode = smgr->addAnimatedMeshSceneNode (malelegsmesh);
    IAnimatedMeshSceneNode* malefeetnode = smgr->addAnimatedMeshSceneNode (malefeetmesh);
 
    maletorsonode->setMaterialFlag(EMF_LIGHTING, false);
 
    maleheadnode->setMaterialFlag (EMF_LIGHTING, false);
    maleheadnode->setParent(maletorsonode);
 
    malehandsnode->setMaterialFlag (EMF_LIGHTING, false);
    malehandsnode->setParent (maletorsonode);
 
    malelegsnode->setMaterialFlag (EMF_LIGHTING, false);
    malelegsnode->setParent (maletorsonode);
 
    malefeetnode->setMaterialFlag (EMF_LIGHTING, false);
    malefeetnode->setParent (malelegsnode);
 
    skinmaletorsomesh->useAnimationFrom(skinanim);
    skinmaleheadmesh->useAnimationFrom(skinanim);
    skinmalehandsmesh->useAnimationFrom(skinanim);
    skinmalelegsmesh->useAnimationFrom(skinanim);
    skinmalefeetmesh->useAnimationFrom(skinanim);
Okay, I would try to post a screenshot of my character, but I haven't quite figured out how to do that. This is the portion of my code where I declare my animated meshes, skinned meshes, and nodes, as well as use useAnimationFrom(). My character is just standing in a static pose (but a seemingly different pose from the one my unanimated body pieces used). I have a feeling that there is some obvious omission or error, but I can't find it.
Last edited by Alopex on Sun Sep 20, 2015 10:56 pm, edited 2 times in total.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: .B3D: How to make character body out of several parts

Post by CuteAlien »

Been a while since I worked with that stuff... maybe you have to use setFrameLoop to set the animation range in this case.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Alopex
Posts: 41
Joined: Sat Sep 12, 2015 10:12 pm

Re: .B3D: How to make character body out of several parts

Post by Alopex »

Fair enough. But, I have tried creating a scene node for the animations (which just placed a new mesh in the same place as my other one) and also using setFrameLoop for each of the scene nodes (which did absolutely nothing, it seems).
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: .B3D: How to make character body out of several parts

Post by CuteAlien »

Sorry, no idea then without a test-case. It's something I would have to debug.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
sunnystormy
Posts: 105
Joined: Mon Jun 02, 2014 2:32 am
Location: Washington, D.C.
Contact:

Re: .B3D: How to make character body out of several parts

Post by sunnystormy »

@Alopex

I think your "anim" variable needs to be an IAnimatedMeshSceneNode... that's the only way you can get it to animate properly with the "setFrameLoop()" method. Then the child nodes can point to the ISkinnedMesh property of that particular node for each "useAnimationFrom()" method call.
My blog: http://fsgdp.wordpress.com "The Free Software Game Development Pipeline"
Alopex
Posts: 41
Joined: Sat Sep 12, 2015 10:12 pm

Re: .B3D: How to make character body out of several parts

Post by Alopex »

@SunnyStormy

I've implemented your suggestions, but something is still...off.

Code: Select all

 
    IAnimatedMesh* maletorsomesh = smgr->getMesh("C:/Users/James/Documents/Psychophagus/Assets/Male/Male_Chest.b3d");
    IAnimatedMesh* maleheadmesh = smgr->getMesh("C:/Users/James/Documents/Psychophagus/Assets/Male/Male_Head.b3d");
    IAnimatedMesh* malehandsmesh = smgr->getMesh("C:/Users/James/Documents/Psychophagus/Assets/Male/Male_Hands.b3d");
    IAnimatedMesh* malelegsmesh = smgr->getMesh ("C:/Users/James/Documents/Psychophagus/Assets/Male/Male_Legs.b3d");
    IAnimatedMesh* malefeetmesh = smgr->getMesh ("C:/Users/James/Documents/Psychophagus/Assets/Male/Male_Feet.b3d");
    IAnimatedMesh* anim = smgr->getMesh ("C:/Users/James/Documents/Psychophagus/Assets/Male/Male_Player_Animations.b3d");
    ISkinnedMesh* skinmaletorsomesh = (ISkinnedMesh*) maletorsomesh;
    ISkinnedMesh* skinmaleheadmesh = (ISkinnedMesh*) maletorsomesh;
    ISkinnedMesh* skinmalehandsmesh = (ISkinnedMesh*) maletorsomesh;
    ISkinnedMesh* skinmalelegsmesh = (ISkinnedMesh*) maletorsomesh;
    ISkinnedMesh* skinmalefeetmesh = (ISkinnedMesh*) maletorsomesh;
    ISkinnedMesh* skinanim = (ISkinnedMesh*) anim;
    IAnimatedMeshSceneNode* maletorsonode = smgr->addAnimatedMeshSceneNode(maletorsomesh);
    IAnimatedMeshSceneNode* maleheadnode = smgr->addAnimatedMeshSceneNode(maleheadmesh);
    IAnimatedMeshSceneNode* malehandsnode = smgr->addAnimatedMeshSceneNode (malehandsmesh);
    IAnimatedMeshSceneNode* malelegsnode = smgr->addAnimatedMeshSceneNode (malelegsmesh);
    IAnimatedMeshSceneNode* malefeetnode = smgr->addAnimatedMeshSceneNode (malefeetmesh);
    IAnimatedMeshSceneNode* animnode= smgr->addAnimatedMeshSceneNode (anim);
 
    maletorsonode->setMaterialFlag(EMF_LIGHTING, false);
 
    maleheadnode->setMaterialFlag (EMF_LIGHTING, false);
    maleheadnode->setParent(maletorsonode);
 
    malehandsnode->setMaterialFlag (EMF_LIGHTING, false);
    malehandsnode->setParent (maletorsonode);
 
    malelegsnode->setMaterialFlag (EMF_LIGHTING, false);
    malelegsnode->setParent (maletorsonode);
 
    malefeetnode->setMaterialFlag (EMF_LIGHTING, false);
    malefeetnode->setParent (malelegsnode);
 
    animnode ->setFrameLoop(0,1262);
 
    skinmaletorsomesh->useAnimationFrom(skinanim);
    skinmaleheadmesh->useAnimationFrom(skinanim);
    skinmalehandsmesh->useAnimationFrom(skinanim);
    skinmalelegsmesh->useAnimationFrom(skinanim);
    skinmalefeetmesh->useAnimationFrom(skinanim);
 
Result: My piece-by-piece character stands in a static pose while the mesh holding the animations goes through its loops. The animated mesh and the static mesh are in the same spot.
sunnystormy
Posts: 105
Joined: Mon Jun 02, 2014 2:32 am
Location: Washington, D.C.
Contact:

Re: .B3D: How to make character body out of several parts

Post by sunnystormy »

@Alopex

Do me a favor and comment everything out except for the mesh code that's supposed to be animated.

For example, try:

Code: Select all

 
IAnimatedMeshSceneNode* animnode = smgr->addAnimatedMeshSceneNode(smgr->getMesh("C:/Users/James/Documents/Psychophagus/Assets/Male/Male_Player_Animations.b3d"));
animnode->setLoopMode(true);
animnode->setFrameLoop(0,1262);
animnode->setAnimationSpeed(30);
 
Just to check to make sure the animation is even working. Also, are you calling your "drawAll()" method from inside of an update loop? Those animations are dependent upon the ISceneManager being updated. If this works, we can take it step by step from here.
My blog: http://fsgdp.wordpress.com "The Free Software Game Development Pipeline"
Alopex
Posts: 41
Joined: Sat Sep 12, 2015 10:12 pm

Re: .B3D: How to make character body out of several parts

Post by Alopex »

@SunnyStormy

I implemented your changes again. The animated mesh in animnode is doing exactly what it is supposed to.

Here is my device loop:

Code: Select all

 
while(device->run())
    {
        driver->beginScene(true, true, SColor(0,200,200,200));
 
        smgr->drawAll();
        guienv->drawAll();
 
        driver->endScene();
    }
 
sunnystormy
Posts: 105
Joined: Mon Jun 02, 2014 2:32 am
Location: Washington, D.C.
Contact:

Re: .B3D: How to make character body out of several parts

Post by sunnystormy »

Good! :)

Try this and let me know if it works:

Code: Select all

 
IAnimatedMeshSceneNode* animnode = smgr->addAnimatedMeshSceneNode(smgr->getMesh("C:/Users/James/Documents/Psychophagus/Assets/Male/Male_Player_Animations.b3d"));
animnode->setLoopMode(true);
animnode->setFrameLoop(0,1262);
animnode->setAnimationSpeed(30);
 
IAnimatedMeshSceneNode* maletorsonode = smgr->addAnimatedMeshSceneNode(smgr->getMesh("C:/Users/James/Documents/Psychophagus/Assets/Male/Male_Chest.b3d"));
maletorsonode->getMesh()->useAnimationFrom(animNode->getMesh());
maletorsonode->setMaterialFlag(EMF_LIGHTING, false);
 
IAnimatedMeshSceneNode* maleheadnode = smgr->addAnimatedMeshSceneNode(smgr->getMesh("C:/Users/James/Documents/Psychophagus/Assets/Male/Male_Head.b3d"));
maleheadnode->getMesh()->useAnimationFrom(animNode->getMesh());
maleheadnode->setMaterialFlag(EMF_LIGHTING, false);
maleheadnode->setParent(maletorsonode);
 
IAnimatedMeshSceneNode* malehandsnode = smgr->addAnimatedMeshSceneNode(smgr->getMesh("C:/Users/James/Documents/Psychophagus/Assets/Male/Male_Hands.b3d"));
malehandsnode->getMesh()->useAnimationFrom(animNode->getMesh());
malehandsnode->setMaterialFlag(EMF_LIGHTING, false);
malehandsnode->setParent(maletorsonode);
 
IAnimatedMeshSceneNode* malelegsnode = smgr->addAnimatedMeshSceneNode(smgr->getMesh("C:/Users/James/Documents/Psychophagus/Assets/Male/Male_Legs.b3d"));
malelegsnode->getMesh()->useAnimationFrom(animNode->getMesh());
malelegsnode->setMaterialFlag(EMF_LIGHTING, false);
malelegsnode->setParent(maletorsonode);
 
IAnimatedMeshSceneNode* malefeetnode = smgr->addAnimatedMeshSceneNode(smgr->getMesh("C:/Users/James/Documents/Psychophagus/Assets/Male/Male_Feet.b3d"));
malefeetnode->getMesh()->useAnimationFrom(animNode->getMesh());
malefeetnode->setMaterialFlag(EMF_LIGHTING, false);
malefeetnode->setParent(malelegsnode);
 
Something along those lines... I think. >_>
My blog: http://fsgdp.wordpress.com "The Free Software Game Development Pipeline"
Alopex
Posts: 41
Joined: Sat Sep 12, 2015 10:12 pm

Re: .B3D: How to make character body out of several parts

Post by Alopex »

Returns 5 errors trying to build.


||=== Build: Debug in Psychophagus (compiler: GNU GCC Compiler) ===|
C:\Users\James\Documents\Psychophagus\main.cpp||In function 'int main(int, char**)':|
C:\Users\James\Documents\Psychophagus\main.cpp|55|error: 'class irr::scene::IAnimatedMesh' has no member named 'useAnimationFrom'|
C:\Users\James\Documents\Psychophagus\main.cpp|59|error: 'class irr::scene::IAnimatedMesh' has no member named 'useAnimationFrom'|
C:\Users\James\Documents\Psychophagus\main.cpp|64|error: 'class irr::scene::IAnimatedMesh' has no member named 'useAnimationFrom'|
C:\Users\James\Documents\Psychophagus\main.cpp|69|error: 'class irr::scene::IAnimatedMesh' has no member named 'useAnimationFrom'|
C:\Users\James\Documents\Psychophagus\main.cpp|74|error: 'class irr::scene::IAnimatedMesh' has no member named 'useAnimationFrom'|
||=== Build failed: 5 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
sunnystormy
Posts: 105
Joined: Mon Jun 02, 2014 2:32 am
Location: Washington, D.C.
Contact:

Re: .B3D: How to make character body out of several parts

Post by sunnystormy »

@Alopex

Hmm... you may need to actually split the "useAnimationFrom()" line into two separate statements. One where you grab the mesh and typecast it to ISkinnedMesh, and another where you point to the animation of "animnode".

I'm wondering, though, if that's even necessary? Try only setting the children nodes (and not grabbing the animation of the "animnode"), and see if anything happens. I'm wondering if there's some redundancy here...
My blog: http://fsgdp.wordpress.com "The Free Software Game Development Pipeline"
Post Reply