How to prevent seeing through walls at all costs

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
squisher
Competition winner
Posts: 91
Joined: Sat May 17, 2008 2:23 am
Contact:

How to prevent seeing through walls at all costs

Post by squisher »

I noticed when my character's back was up to the wall, I could see behind the wall into the room behind me. That was an easy fix: I use getSceneNodeAndCollisionPointFromRay to move my camera up closer to my character if the character's back is up to the wall.

My problem now is if I am standing with the wall to my left or right side. I can still see through the wall into the room next to me. It doesn't matter how thick I make the wall because the entire thing isn't drawn. It doesn't matter how close my camera is to my character, since it doesn't change the camera's distance from the wall. In fact my camera can be at my character's position and I still see thru the wall. Bumping the camera to the left or right wouldn't make any difference either, if I were in a narrow hallway with walls on my left and right.

I'm able to detect when this is happening with the following code in my camera's update loop:

Code: Select all

    const irr::scene::SViewFrustum* f = camera->getViewFrustum();
 
    vector3df ul, lr, ll, ur;
    f->planes[irr::scene::SViewFrustum::VF_NEAR_PLANE].getIntersectionWithPlanes(
    f->planes[irr::scene::SViewFrustum::VF_TOP_PLANE],
    f->planes[irr::scene::SViewFrustum::VF_LEFT_PLANE], ul);
    f->planes[irr::scene::SViewFrustum::VF_NEAR_PLANE].getIntersectionWithPlanes(
    f->planes[irr::scene::SViewFrustum::VF_BOTTOM_PLANE],
    f->planes[irr::scene::SViewFrustum::VF_RIGHT_PLANE], lr);
    f->planes[irr::scene::SViewFrustum::VF_NEAR_PLANE].getIntersectionWithPlanes(
    f->planes[irr::scene::SViewFrustum::VF_TOP_PLANE],
    f->planes[irr::scene::SViewFrustum::VF_RIGHT_PLANE], ur);
    f->planes[irr::scene::SViewFrustum::VF_NEAR_PLANE].getIntersectionWithPlanes(
    f->planes[irr::scene::SViewFrustum::VF_BOTTOM_PLANE],
    f->planes[irr::scene::SViewFrustum::VF_LEFT_PLANE], ll);
 
    if (collisionMgr->getSceneNodeAndCollisionPointFromRay(irr::core::line3df(ul, lr),
        outCollisionPoint, outTriangle, ESceneNodeFlag::wall) || 
        collisionMgr->getSceneNodeAndCollisionPointFromRay(irr::core::line3df(ll, ur),
        outCollisionPoint, outTriangle, ESceneNodeFlag::wall))
    {
        cout << "Looking thru a wall!" << endl;
    }
If I could just find a way to force the detected scene node to draw, even though the video driver thinks it's off screen, I would have my solution.

Any ideas? This has to be a problem with any 3D irrlicht application, somebody has to have solved it..
Current project: StarDust. A single player galactic conquest game.
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: How to prevent seeing through walls at all costs

Post by REDDemon »

you can just include the "near plane" face of the frustum inside your collision ellipsoid for the camera..

Or you can also add a portal engine so that if you are not in a room , the room is not drawn at all.

probably there are other solutions
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: How to prevent seeing through walls at all costs

Post by mongoose7 »

So, the four vertices ofthe plane are out of view so the plane is not rendered? Tesselate the plane.
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: How to prevent seeing through walls at all costs

Post by REDDemon »

mongoose7 wrote:So, the four vertices ofthe plane are out of view so the plane is not rendered? Tesselate the plane.
No the plane is rendered. But since walls will collide with the ellipsoid walls will not be "cutted" by the near plane. simply because camera will not be allowed to move too near to walls.
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
teto
Posts: 159
Joined: Thu Dec 03, 2009 9:37 pm
Location: /home
Contact:

Re: How to prevent seeing through walls at all costs

Post by teto »

I am not sure I understand though I think you could try disabling culling for your node with ISceneNode: setAutomaticCulling(EAC_OFF)
Using trunk with mingw/gcc 4.6, Windows 7 64 bits driver opengl
Post Reply