Page 1 of 1

Having trouble attaching a weapon to the hand

Posted: Wed Dec 13, 2017 4:41 pm
by Pattoh
Hi there, having a issue with attaching my weapon to the hand. I am getting a "No mesh, or mesh not of skinned mesh type" error in log, kind of stumped on it, any help will be appreciated. This is my code and I have narrowed it down to the offender ( I will comment), I have also tried 3 different models to see if it was a problem there and google searches.

Code: Select all

 
    scene::IAnimatedMesh* wep_mesh = (scene::IAnimatedMesh*)smgr->getMesh("../../media/AK47_Free/ak_body/aknewlow.obj");
    scene::IAnimatedMeshSceneNode* weP = smgr->addAnimatedMeshSceneNode(wep_mesh);
    scene::ISkinnedMesh* char_mesh = (scene::ISkinnedMesh*) smgr->getMesh("../../media/Hand/Hand/Hand.obj");
    scene::IAnimatedMeshSceneNode* boneS = smgr->addAnimatedMeshSceneNode(char_mesh); 
    irr::scene::IBoneSceneNode* handZ = boneS->getJointNode("Left_Hand"); //this line here seems to be the problem
    handZ->addChild(weP);
    handZ->setPosition(core::vector3df(-12.f,2.f,42.f));    
 
Unhandled exception at 0x00007ff66b422e97 in irrliuchtconsolegood.exe: 0xC0000005: Access violation reading location 0x0000000000000000. as well

Re: Having trouble attaching a weapon to the hand

Posted: Wed Dec 13, 2017 5:37 pm
by kklouzal
You need to make sure your hand model has bones in it and has a bone named "Left_Hand"; being of type .obj (which doesn't support animations) I don't think it contains any bones, it's just a simple model.

Re: Having trouble attaching a weapon to the hand

Posted: Wed Dec 13, 2017 8:46 pm
by Seven
I like to ensure that a pointer is valid before using it. I also display a log if something failed.

Code: Select all

 
irr::scene::IBoneSceneNode* handZ = boneS->getJointNode("Left_Hand"); //this line here seems to be the problem
if (handZ)
{
    handZ->addChild(weP);
    handZ->setPosition(core::vector3df(-12.f,2.f,42.f));  
}
else
{
   printf("ERROR!   bones->getJointNode("LeftHand") failed to find node \n");
}
 
in addition, you can set a breakpoint at this line and then follow the program through the code to see what bones actually exist.

Re: Having trouble attaching a weapon to the hand

Posted: Thu Dec 14, 2017 1:24 am
by Mel
Notice though that OBJ models don't have bones, so you can't use them as skinned meshes, BUT as any other node, you can attach children nodes to them, so you can attach the weapon model to the hand model, i.e. you can attach weP to boneS directly (boneS->addChildNode(weP); or the like)

Re: Having trouble attaching a weapon to the hand

Posted: Thu Dec 14, 2017 1:53 am
by Pattoh
Thanks guys, sorted now. The models I think I was using didn't have bones. My reference was with a blender file that did have bones but the .obj file I was using in game didn't.