Help with Bone manipulations

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.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Well it's probably a question for the Physx forum really isn't it?

What information do you know? Are you wanting to point it at a specific point on the screen?
Image Image Image
gheft
Posts: 34
Joined: Mon Jul 30, 2007 4:11 am

Post by gheft »

you can use irrlichts getRayFromScreenCoordinates to get a ray for raycasting in physx, I think this is what you mean?

try something like this

position2d<s32> mpos = device->getCursorControl()->getPosition();
line3d<f32> line = smgr->getSceneCollisionManager()->getRayFromScreenCoordinates(mpos,camera);
line.end -= line.start;
line.end.normalize();
NxRay ray = NxRay(vCast(line.start),vCast(line.end));

where vCast is a simple function to convert between NxVec3 and vector3df(I have to do it many times in my game)

vector3df vCast(NxVec3 vect)
{
return vector3df(vect.x,vect.y,vect.z);
}
NxVec3 vCast(vector3df vect)
{
return NxVec3(vect.X,vect.Y,vect.Z);
}

if you don't know how to use this ray, search physx docs...
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

Actually I wanted to cast a ray fully orthagonal to the screen plane on a fixed point of the screen. And you`re right- it`s for the PhysX forum, but as long as I use Irrlicht, I want to stick with it as much as I can. What I was looking for was exactly what gheft posted. :D

Tommorow I`ll try putting it into "action". Hope everythng will be fine.
Once again: Thanks a lot! 8)

PS: Ah, and you bet I can use the PhysX raycast function. I spend almost all day today, doing that...(sad, but true) :wink:
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

Now I have probs with the bone manipulations. In the beginning I create my character (char_node), then I get the hand bone using this code, and attach an object ( in this case a baseball bat ), using the hand bone as a parent.

Code: Select all

scene::ISceneNode* R_hand = char_node->getXJointNode("Bip01_R_Hand");
		R_hand->setName("R_hand");
		scene::IAnimatedMesh* batmesh = Smgr->getMesh("Media/bat.x");
		scene::ISceneNode* bat_node =   Smgr->addMeshSceneNode(batmesh, R_hand, -1);
From now on the bat is attached to the hand. Through the game loop I want to get the position and orientation of the hand bone and the same for the baseball bat to deal some stuff with the values. I use this:

Code: Select all

 scene::ISceneNode* R_hand = Smgr->getSceneNodeFromName("R_hand");
		  core::vector3df HandPos=R_hand->getPosition();
to acess the node, calling its previously set name, but it always returns a null vector. Using IDs gives the same result.

So how can I get and set bone positions and rotations in game properly? To set the realtime head rotation and so on..,
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

Anyone? :cry:
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Which version of Irrlicht do you use? The getXJointNode was deprecated in Irrlicht 1.4, and is now removed IIRC. The getPosition returns a relative position. The joint node is proabably parented, hence it won't be moved on itself, but the parent moves. Try getAbsolutePosition or query the parent.
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

I`m using the final Irllicht 1.4 found in:irrlicht-1.4\bin\Win32-VisualStudio. 2.01 MB. Running on VisualStudio2008 express edition. I saw there`s another one dll-4.83 Mb for gcc. Am I using wrong(old) version? :shock:

SO, the getAbsolutePosition did the job on finding the hand node position, but how am I supposed to rotate the arm for example in realtime?

PS: What does this:
and is now removed IIRC
mean?
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You should use getJointNode instead (same parameters), because it works for every skinned mesh type. The old methods shouldn't be used anymore, even if they still exist (and no, the dll just depends on the compiler you use, the contents is the same from an API level).
The arm should be rotated by the animation, or not?! Do you want to animate the node manually?

IIRC means 'If I remember correctly'
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

It is sth like the good old effect of having the character animated-run, idle or whatever and whenn you need just to call a function that will rotate his head to look at something. It`s similar as in TR2, but there is used a segmented mesh, which makes things pretty different. I used the same in my old project made on GM+U3d, where you get the bone`s index and do whatever you want, ignoring the animation for it, and you may choose whether to affect the child bones or not. Can we have sth similar here?

I saw one nice example for realtime humanoid skeleton animation, but I cannot run it. It gives me an error. Even if I meke it run properly, I think this way will be too CPU intensive. Am I wrong? :roll:
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, you can. Please check the Wiki for a short description on how the new animation system works.
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

:shock:
WOW!

What we have here... This is awsome! Thanks a lot!!! :wink:
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

Damn... I tried to follow the wiki tutorial about Joint control. SO I do this:

Code: Select all

scene::IAnimatedMeshSceneNode* char_node = 0;
	scene::IAnimatedMesh* char_mesh = Smgr->getMesh("Media/skeleton.x");

	if (char_mesh)
	{
		char_node = Smgr->addAnimatedMeshSceneNode(char_mesh);
	    
		char_node->setJointMode(2);
		char_node->setName("Character");
(...)
}
And it gives me this error:

Code: Select all

d:\gamemaker\irrlicht\irr projects\TP\TP\main.cpp(111) : error C2664: 'irr::scene::IAnimatedMeshSceneNode::setJointMode' : cannot convert parameter 1 from 'int' to 'irr::scene::E_JOINT_UPDATE_ON_RENDER'
        Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
I looked at two snippets, calling this function and everything is done this way. What am I doin` wrong? :?
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
Mag-got
Posts: 42
Joined: Tue Dec 04, 2007 5:53 pm

Post by Mag-got »

I assume, ASSUME it works like this, compiles, doesn't complain, doesn't crash, doesn't animate though but I bet it's ment to be like that or I didn't add something, just took the code into my scene node with joints.


node->setJointMode(irr::scene::E_JOINT_UPDATE_ON_RENDER(2));
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

Thanks Mag-got :wink:
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

I`m really sorry, but I spent the last 5 hours trying differnt combinations and still have probs with these bone rotations.

So, I put my bones in the class:

Code: Select all

scene::IBoneSceneNode* R_UpperArm;
scene::IBoneSceneNode* R_Hand;
Call:

Code: Select all

char_node->setJointMode(irr::scene::EJUOR_CONTROL);
which is equivalent to setJointMode(2);

Create my object to be attached and assign bones:

Code: Select all

scene::IAnimatedMesh* batmesh = Smgr->getMesh("media/bat.x");
		scene::ISceneNode* bat_node = Smgr->addMeshSceneNode(batmesh);
        bat_node->setName("bat");
		

R_UpperArm = char_node->getJointNode("Bip01_R_UpperArm");
R_Hand     = char_node->getJointNode("Bip01_R_Hand");

After a while I call:


Code: Select all

char_node->animateJoints();
	 R_UpperArm->setRotation(core::vector3df(0,90,0));//just some static vector as an example
	 R_Hand->setRotation(core::vector3df(0,0,-45));// here too
	 
	 
	 bat_node->setParent(R_Hand);//remind the buddy who`s the boss, in case it has forgotten
My bones are visible. This way I get absolute mess of the bones, but I can see the ones I rotated poiting forward as i want. The prob is, that the baseball bat is following the R_Hand node in the pure animation. I need the bones to point where I want, ignore the animation made in 3dMax and the baseball bat to be attached at the actual R_Hand bone node. Let`s assume the bat is a pistol... :cry:

Image
Last edited by shadowslair on Wed Apr 30, 2008 7:24 am, edited 2 times in total.
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
Post Reply