Attaching weapon

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
Sigutis
Posts: 10
Joined: Thu May 01, 2008 8:51 am
Location: Lithuania

Attaching weapon

Post by Sigutis »

I am trying to attach weapon to a characters hand.
So I have this ISceneNode sword and IAnimatedMeshSceneNode node (character)
Both are x format
Obviously I need to make node hold the sword
As far as I figured out I did this in my init fuction, after loading meshes

Code: Select all

	ISceneNode hand = node->getJointNode("Bone10");
		hand->addChild(sword);
Eventually it compiles fine but I still cant see no sword.I assume I have to do something in the main loop. Its my first experience with bones though.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Can you show your code for loading the sword?

Try sword->setPosition(vector3df(0,0,0); and see if that helps. Also, can you see the sword if you don't parent it to the hand? Maybe it's scaled really small or really big.
Image Image Image
Sigutis
Posts: 10
Joined: Thu May 01, 2008 8:51 am
Location: Lithuania

attatch

Post by Sigutis »

After copying sword loading code I noticed that

Code: Select all

sword = smgr->addAnimatedMeshSceneNode( mesh_sword);
was missing :D
now I can see it. it follows the hand but its in wrong angle and position. Do you think I should just rotate/reposition it manually until I get it right?
Mag-got
Posts: 42
Joined: Tue Dec 04, 2007 5:53 pm

Post by Mag-got »

Yes. Irrlicht does not read your mind and set the rotation automatically. :lol:
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Hehe if only it did!

Remember that setPosition should take a position relative to the parent when it's made a child.
Image Image Image
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Mag-got wrote:Yes. Irrlicht does not read your mind and set the rotation automatically. :lol:
I hear the latest version of Ogre does that though.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

you have to rotate this in the model.
in the player model, the line from "bone10" and the "bone 11" will be the angle of the sword.
and then, in the sword's model, you have to put it into 0,0,0, and rotate to 0,0,0

and it will be cool xD
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Not if he doesn't have a bone 11 :p

Nor does he need one though, just bone 10 will do the trick.
Image Image Image
Sigutis
Posts: 10
Joined: Thu May 01, 2008 8:51 am
Location: Lithuania

attach

Post by Sigutis »

Works like charm now. Thanks everyone
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

yeah, but for example for a sword, it's hard to do it with just one bone xD
because it's hard to animate
Post Reply