Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25

Thread: Collision detection in 3D for obstacles, sword fighting...

  1. #11

    Collision detection in 3D for obstacles, sword fighting...

    I have missed one important thing. The dotProduct(v1,v2) returns an cosine of an angle between vectors v1 and v2 when v1 and v2 are normalised. So before calculating dot product normalize both vectors.

    Sorry about that.

    About rotations. You have mixed somewhere radians and degrees.
    7 is allmost equal to 2*pi = 6.28 - full 360 degree turn.

    To get the < and > chars check the "Disable HTML in this post" option.

  2. #12

    Collision detection in 3D for obstacles, sword fighting...

    Hello grudzio,

    thanks a lot again

    I'll try that when I am home.

    Firle

  3. #13
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Collision detection in 3D for obstacles, sword fighting...

    Hey Eric, try posting with HTML disabled. sometimes the > and < characters are assumed to be tags.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  4. #14

    Collision detection in 3D for obstacles, sword fighting...

    Yes, grudzio also told me, thanks for the clue.

    Just a funny picture, me in 3D, this will be one of our playable heroes:



    Firle

  5. #15

    Collision detection in 3D for obstacles, sword fighting...

    Nice picture

  6. #16

    Collision detection in 3D for obstacles, sword fighting...

    Nice underwear

    grudzio, one question:

    I also need a function which tells me the position of two points in height (The same as before but for higher and lower on terrain).

    Can you help me with it?

    Greetings,
    Dirk
    <a href="http://www.greatgamesexperiment.com/game/Valgard/?utm_source=gge&amp;utm_medium=badge_game"><img border="0" alt="GGE" title="GGE" src="http://static.greatgamesexperiment.com/badge/game/valgard/gge400x56.png"></a>

  7. #17

    Collision detection in 3D for obstacles, sword fighting...

    I am not sure if I understand you correctly. Do you want to check if the object A is behind or in front of object B and they are on different heights?

    If so, just ignore the Y coordinate (height) or set it equal to zero.

    Code:
    v &#58;= ObjectB.Pos - ObjectA.Pos;
    v.y &#58;= 0;
    normalize&#40;v&#41;;
    dir &#58;= ObjectA.Dir;
    dir.y &#58;= 0;
    normalize&#40;dir&#41;;
    d &#58;= dotProduct&#40;v,dir&#41;;

  8. #18

    Collision detection in 3D for obstacles, sword fighting...

    This tells me if an object is left or right of my viewing direction.
    I need to know if it is over or under my view direction. So I cannot ignore y, because y stores height and thats exactly what I need. The angle between my height and the height of object xy.

    I use this functionality for a check if object is in my frustrum. Then I decide if I draw it or not. I know how to check if the object is left or right of me and if it is out of my angle of view I don't draw it.

    To speed up things now, I also want to know if it is over or under the camera view. That's what I need the function for.

    Greetings,
    Dirk
    <a href="http://www.greatgamesexperiment.com/game/Valgard/?utm_source=gge&amp;utm_medium=badge_game"><img border="0" alt="GGE" title="GGE" src="http://static.greatgamesexperiment.com/badge/game/valgard/gge400x56.png"></a>

  9. #19

    Collision detection in 3D for obstacles, sword fighting...

    Now I understand .

    First check if the object is in front of the camera. (like in my post above).
    If the test is passed then:
    1. calculate vector between object and camera position:
    Code:
    v &#58;= Object.Pos - Camera.Pos;
    2. Project v on the camera direction:
    Code:
    oz &#58;= dotProduct&#40;v,camera.Dir&#41;;
    3. Test if object is over or under camera view:
    Code:
    //Pascal does not have tangent function 
    tan &#58;= sin&#40;CameraViewAngle*0.5&#41; / cos&#40;CameraViewAngle*0.5&#41;;
    
    if &#40;v.y < oz*tan&#41; and &#40;v.y > -oz*tan&#41; then
     // object is visible
    In 3. I assume that camera is not rotated along z axis.

    Just in case here is a link to a good general Frustum Culling tutorial
    http://www.lighthouse3d.com/opengl/v...ndex.php?intro.

  10. #20

    Collision detection in 3D for obstacles, sword fighting...

    Thank you very much. I will try it tomorrow....
    <a href="http://www.greatgamesexperiment.com/game/Valgard/?utm_source=gge&amp;utm_medium=badge_game"><img border="0" alt="GGE" title="GGE" src="http://static.greatgamesexperiment.com/badge/game/valgard/gge400x56.png"></a>

Page 2 of 3 FirstFirst 123 LastLast

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
  •