Page 2 of 3

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

Posted: Sat Sep 19, 2015 3:57 pm
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.

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

Posted: Sat Sep 19, 2015 9:58 pm
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.

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

Posted: Sun Sep 20, 2015 10:47 am
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.

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

Posted: Sun Sep 20, 2015 1:54 pm
by Alopex
@CuteAlien

Edit: Had a brainfart. I'll get back to you once I emerge from my admittedly self-induced confusion.

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

Posted: Sun Sep 20, 2015 10:47 pm
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.

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

Posted: Sun Sep 20, 2015 10:51 pm
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.

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

Posted: Sun Sep 20, 2015 11:00 pm
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).

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

Posted: Sun Sep 20, 2015 11:11 pm
by CuteAlien
Sorry, no idea then without a test-case. It's something I would have to debug.

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

Posted: Mon Sep 21, 2015 12:17 am
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.

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

Posted: Mon Sep 21, 2015 12:50 am
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.

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

Posted: Mon Sep 21, 2015 1:44 am
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.

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

Posted: Mon Sep 21, 2015 2:13 am
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();
    }
 

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

Posted: Mon Sep 21, 2015 2:56 am
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. >_>

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

Posted: Mon Sep 21, 2015 5:26 pm
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)) ===|

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

Posted: Mon Sep 21, 2015 7:50 pm
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...