Collision with "invisible" triangles

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.
Post Reply
speculatius
Posts: 15
Joined: Wed Nov 28, 2007 12:49 pm

Collision with "invisible" triangles

Post by speculatius »

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...
speculatius
Posts: 15
Joined: Wed Nov 28, 2007 12:49 pm

Post by speculatius »

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)
    }
}
Post Reply