Having trouble attaching a weapon to the hand

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Pattoh
Posts: 2
Joined: Wed Dec 13, 2017 3:18 pm

Having trouble attaching a weapon to the hand

Post 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
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Re: Having trouble attaching a weapon to the hand

Post 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.
Dream Big Or Go Home.
Help Me Help You.
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Re: Having trouble attaching a weapon to the hand

Post 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.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Having trouble attaching a weapon to the hand

Post 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)
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Pattoh
Posts: 2
Joined: Wed Dec 13, 2017 3:18 pm

Re: Having trouble attaching a weapon to the hand

Post 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.
Post Reply