Thread: Camera (Wall Alpha-ing)

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    31

    Camera (Wall Alpha-ing)

    Hello everyone,

    I've built a third person camera in C++ using DirectX that attaches itself to game objects such as the player. My walls are planes and I am utilizing line segment to plane intersection to know which walls I should alpha. The line segment is between my camera and the object I am attached to.

    Here's the problem:
    I can angle my camera to have a wall block half my view before rotating it enough for the line segment to plane intersection collision to detect that I am should alpha a certain wall.

    Here's what I tried:
    I get the magnitude of the point on the plane and the closest point on the line to the plane, subtract the two, and compare it to a distance to check wall alpha-ing.

    Code:
    vector3 vPtOnPlane = fPlaneOffset * vPlaneNormal;
    vector3 a= vector3(vCameraPosition);
    vector3 b= vector3(vTargetPosition);
    vector3 line = b - a;
    
    vector3 linePt = ClosestPtToPlane(vector3 start, vector3 end, vector3 ptOnePlane);
    
    if( fabs(DotProduct(linePt, linePt) - DotProduct(vPtOnPlane, vPtOnPlane) < 50)
        AlphaOutWall();
    The code doesn't seem to work so I'm looking for alternative solutions.

  2. #2
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Have a bounding box around your game object (you probably already have this if you're doing collision detection). Draw 8 lines from your camera to each corner of the bounding box, if any of those lines intersect a wall alpha that wall.

  3. #3
    Registered User
    Join Date
    Jan 2011
    Posts
    31
    That sounds like it will work but also fairly expensive. I've consulted with my teacher and he told me to send collision information to the vertex shader and alpha out part of the wall in the fragment/pixel shader. Making the GPU do the work seems to be the optimal thing to do.

  4. #4
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    You're still going to have to determine which part of the wall intersects the view to the object (the collision information you're sending to the GPU). 8 tests of a line intersecting a plane will not have any noticeable performance effects. That's a rather simple computation.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Camera problem
    By VirtualAce in forum Game Programming
    Replies: 1
    Last Post: 08-14-2010, 01:23 PM
  2. camera rotation matrix
    By Vick jr in forum Game Programming
    Replies: 5
    Last Post: 05-26-2009, 08:16 AM
  3. LNK2001 ERROR!!! need help
    By lifeafterdeath in forum C++ Programming
    Replies: 7
    Last Post: 05-27-2008, 05:05 PM
  4. Replies: 23
    Last Post: 07-09-2007, 04:49 AM
  5. Camera rotation/movement in 3D world
    By tegwin in forum Game Programming
    Replies: 11
    Last Post: 01-24-2003, 01:43 PM