I want to be able to pick different parts on an animated mesh. What is the easiest way to do this?
I tried to use the bounding boxes of the scene::IBoneSceneNode in combination with ISceneManager::getSceneNodeFromScreenCoordinatesBB to pick arms legs etc.
It seems like the bounding boxes are not updated when the mesh is loaded. They all have values like: xmin=-1, ymin=-1, zmin=-1, xmax=1, ymax=1,zmax=1. It is only the bounding box for the actual mesh that is updated during loading.
Is there something I need to do to update the bounding boxes of the bones?
please tell me if my question is unclear.
BR
pir
How do I pick different parts of a animated mesh?
-
- Competition winner
- Posts: 1123
- Joined: Sun Jun 10, 2007 11:14 pm
No, it is only one big skinned mesh. For example, the dwarf model that is included in the Irrlicht examples.
I've found that it is possible to get the uppdated bounding boxes by using
irr::scene::IBoneSceneNodegetTransformedBoundingBox(). But I'm not sure that these are the bounding boxes that are used during the collision detection. Will check this tomorrow. But if anyone has any suggestions on how to solve my problem in a bettter way, please tell me.
I've found that it is possible to get the uppdated bounding boxes by using
irr::scene::IBoneSceneNodegetTransformedBoundingBox(). But I'm not sure that these are the bounding boxes that are used during the collision detection. Will check this tomorrow. But if anyone has any suggestions on how to solve my problem in a bettter way, please tell me.
-
- Competition winner
- Posts: 1123
- Joined: Sun Jun 10, 2007 11:14 pm
-
- Competition winner
- Posts: 1123
- Joined: Sun Jun 10, 2007 11:14 pm
Well, I thought that I had done it... but I have problems finding the correct bone. I think that it is caused by different transformation spaces... maybe. Thats only speculation. Here is my code for finding the closest bone:
The code is quick and dirty and only uses one point in the triangle.
I think that the triangle and the animated point from the current joint is in different transformation spaces, causing the false distances. But I'm not sure which transformation space to use, if this is the case.
Code: Select all
scene::IAnimatedMesh* animMesh = m_mesh->getMesh( );
assert( animMesh->getMeshType() == scene::EAMT_SKINNED);
ISkinnedMesh* skinnedMesh = reinterpret_cast< ISkinnedMesh*>( animMesh);
core::array< ISkinnedMesh::SJoint*>& allJoints = skinnedMesh->getAllJoints( );
float tmpDistance;
float minDistance;
u32 minIndex;
core::vector3df animatedPos;
for( u32 j = 0; j < allJoints.size( ); j++)
{
animatedPos = allJoints[ j]->Animatedposition;
tmpDistance = fabs( animatedPos.getDistanceFrom( tri.pointA));
if( ( tmpDistance < minDistance) || ( j == 0))
{
minDistance = tmpDistance;
minIndex = j;
}
}// for j
I think that the triangle and the animated point from the current joint is in different transformation spaces, causing the false distances. But I'm not sure which transformation space to use, if this is the case.