Results 1 to 8 of 8

Thread: check if an object is behind another

  1. #1

    check if an object is behind another

    Hi! i'd like to see if an object is behind another (from the camera point of view). I'd like, if the protagonist is hidden, to draw the hiding object as blend, to let the player see the character.

    Thanks!
    If you save your data in a proprietary format, the owner of the format owns your data.
    <br /><A href="http://msx80.blogspot.com">http://msx80.blogspot.com</A>

  2. #2

    check if an object is behind another

    trace a few rays from eye position to some points on youre charaters bounding box. Objects which rays hit before the charater are hiding him.

  3. #3

    check if an object is behind another

    if you're doing opegl rendering then just use the hp_occlusion_test to test if the character is completely hidden. first draw the occluder. then disable color writes and draw the ocharacter. if the test tells he's hidden then enable color writes and draw the character then draw the occluder with some blending.

    if i figured this out right then the character in front of the character should be blended with the character. if this should work then it probably could be done in a better way

    happy coding
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  4. #4

    check if an object is behind another

    Yes, but not having to constantly synchronize CPU with GPU is always better

  5. #5

    check if an object is behind another

    Thanks!
    Paulius, can you tell me something more about casting a ray? I've never done it
    I use sphere as approximation, so i should have sphere-ray collisioni guess.
    If you've some code it would be nice

    Thanks!
    If you save your data in a proprietary format, the owner of the format owns your data.
    <br /><A href="http://msx80.blogspot.com">http://msx80.blogspot.com</A>

  6. #6

    check if an object is behind another

    My Ray sphere intersection test:

    t1:= Infinity;
    t2:= Infinity;
    DistX:= RayOrigin[X] - Sphere[X];
    DistY:= RayOrigin[Y] - Sphere[Y];
    DistZ:= RayOrigin[Z] - Sphere[Z];
    b:= RayDirection[X]*DistX + RayDirection[Y]*DistY + RayDirection[Z]*DistZ;
    c:= DistX*DistX + DistY*DistY + DistZ*DistZ - Radius*Radius;
    d:= b * b - c;
    if d >= 0.0 then
    begin
    sq:= sqrt(d);
    t1:= -b - sq;
    t2:= -b + sq;
    end;
    t1 - distance to the 1st hit, t2 - the 2nd. Infinity is a no hit constant. RayDirection must be normalized.

  7. #7

    check if an object is behind another

    thanks, great piece of code!

    now as ray i can take the vector from camera position to camera target, right ?
    I'm tring it
    If you save your data in a proprietary format, the owner of the format owns your data.
    <br /><A href="http://msx80.blogspot.com">http://msx80.blogspot.com</A>

  8. #8

    check if an object is behind another

    You should direct a ray not to camera target but to the position of you?¢_Tre characters bounding sphere. And to take into account objects that partially obstruct the character but not its center, trace a few more rays with direction jittered around characters bounding sphere

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •