Help with Bone manipulations
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...
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...
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
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.
Tommorow I`ll try putting it into "action". Hope everythng will be fine.
Once again: Thanks a lot!
PS: Ah, and you bet I can use the PhysX raycast function. I spend almost all day today, doing that...(sad, but true)
Tommorow I`ll try putting it into "action". Hope everythng will be fine.
Once again: Thanks a lot!
PS: Ah, and you bet I can use the PhysX raycast function. I spend almost all day today, doing that...(sad, but true)
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
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.
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:
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..,
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);
Code: Select all
scene::ISceneNode* R_hand = Smgr->getSceneNodeFromName("R_hand");
core::vector3df HandPos=R_hand->getPosition();
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..."
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
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?
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:
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:
mean?and is now removed IIRC
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
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'
The arm should be rotated by the animation, or not?! Do you want to animate the node manually?
IIRC means 'If I remember correctly'
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
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?
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?
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
Damn... I tried to follow the wiki tutorial about Joint control. SO I do this:
And it gives me this error:
I looked at two snippets, calling this function and everything is done this way. What am I doin` wrong?
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");
(...)
}
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)
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
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:
Call:
which is equivalent to setJointMode(2);
Create my object to be attached and assign bones:
After a while I call:
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...
So, I put my bones in the class:
Code: Select all
scene::IBoneSceneNode* R_UpperArm;
scene::IBoneSceneNode* R_Hand;
Code: Select all
char_node->setJointMode(irr::scene::EJUOR_CONTROL);
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
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..."