Hello,
I am using ISceneCollisionManager::getSceneNodeAndCollisionPointFromRay for getting triangles under mouse cursor. The problem is, that this method returns also triangles, which are invisible (viewed from backside). Is there some way to ignore theese triangles?
Thank you...
Collision with "invisible" triangles
-
speculatius
- Posts: 15
- Joined: Wed Nov 28, 2007 12:49 pm
Ok, I found acceptable solution:
Code: Select all
ISceneNode* Navigator::getPointedNode() const {
line3df ray = collManager->getRayFromScreenCoordinates(cursor->getPosition() + position2d<s32>(3, 22), camera);
vector3df intersection;
triangle3df triangle;
ISceneNode* node;
while(true) {
node = collManager->getSceneNodeAndCollisionPointFromRay(ray, intersection, triangle);
if(node == NULL || triangle.isFrontFacing(ray.getVector())) {
return node;
}
ray.start = intersection + ray.getVector().setLength(EPSILON); // EPSILON should be number small enough (0.01f)
}
}