Collision detection with a mesh with transformation

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Reiko
Posts: 105
Joined: Sun Aug 16, 2009 7:06 am
Location: Australia

Collision detection with a mesh with transformation

Post by Reiko »

Not 100% sure if this is a bug or if maybe there's a step I'm missing.

Basically my program uses models that are in a custom format.

When loading them, firstly I create a ISkinnedMesh using sceneManager->createSkinnedMesh().
Then I call skinnedmesh->addMeshBuffer() to get an SSkinMeshBuffer.
To this mesh buffer I add the vertices, indices, material colours and so on. For the transformation (if applicable) I set the transformation using meshbuffer->Transformation. When I say if applicable, some models have a transformation, and some dont.
After I'm done adding all the needed mesh buffers, I call skinnedmesh->finalize().
And then turn it into a scene node using sceneManager->addAnimationMeshSceneNode(skinnedmesh).

The rendered result is fine, but now I wanna add collision detection with this node.

So I create a triangle selector using scenemanager->createTriangleSelector(node)
And then call node->setTriangleSelector(selector)
Then I drop the selector (basically the steps from the collision tutorial).

Now in my program I wanna check if I mouse over a node, I'm using CollisionManager->getRayFromScreenCoordinates() and CollisionManager->getSceneNodeAndCollisionPointFromRay() to check for collision, and its working perfectly for models that didnt have a transformation. However for the models that do have a transformation, when I mouse over where the node is drawn, it doesn't detect it. But if I put my mouse where it would've been without the transformation (or just comment out the transformation in the code and then run the program and mouse over the node, since I can see it in its "wrong" position) then it works fine.

So basically somewhere within the collision detection (I'm not too familiar with this part of Irrlicht) it isnt taking into account the transformation that I put in the SSkinMeshBuffer.

Is there a step in the process that I missed, or is this a bug?


edit: Just to add, I'm using the trunk rev. 3988.
Reiko
Posts: 105
Joined: Sun Aug 16, 2009 7:06 am
Location: Australia

Re: Collision detection with a mesh with transformation

Post by Reiko »

Well I thought of a work around for now:

Instead of setting the translation in the SSkinMeshBuffer, I'm applying the translation to the node after creating it. Like this:

Code: Select all

node->setScale(obj->localTransformationMatrix.getScale());
node->setRotation(obj->localTransformationMatrix.getRotationDegrees());
node->setPosition(obj->localTransformationMatrix.getTranslation());
node->updateAbsolutePosition();
where obj->localTransformationMatrix is a core::matrix4 containing the transformation read from the file

The model is being rendered correctly, and the collision detection is working too. So it solves the problem for me, but in my case all of the SSkinMeshBuffers are using the same transformation, hence I could just apply it to the node at the end. If all buffers needed different transformations this wouldnt solve it (if my understanding is right).
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Collision detection with a mesh with transformation

Post by hybrid »

Yes, there's still a bug in the skinned mesh system, or a limitation so to say. I was under the impression that a getMesh() call would return a properly transformed mesh and hence lead to correct collision. But a report a few weeks ago mentioned a simple test with example 7 which shows problems with collision on skinned meshes, too. So right now the skinned mesh collision is not working correctly.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Collision detection with a mesh with transformation

Post by hybrid »

So maybe it's indeed a problem that lies in the current handling of the local matrices of the skinned mesh and an incomplete transformation of the mesh. Would help a lot if you could reproduce this with a standard mesh format, though.
Post Reply