Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Terrain and path intersection

Author
Message
bitblitt
16
Years of Service
User Offline
Joined: 20th Jan 2008
Location:
Posted: 20th Jan 2008 21:31
I'm a software engineer, but not a game developer. I stumbled across DarkGDK, started playing with it, and now I'm working on my first game. I'm still learning the API, and have a couple questions.

Is there a function whereby I can pass a parameterized vector to determine if and where it intersects with my terrain? I'm using a height map and terrain texture, which works great. I'm applying my own physics engine to everything, including gun shots, and I don't want to have to render the bullet as an object just to test for collision. I'd rather compute continuous path and test for terrain intersection. Is there a function for this, or do I have to do this myself?

If I have to do this myself, can I get to the mathematical representation of the terrain? I assume its just a matrix, so I can test each square/triangle for intersection.
bitblitt
16
Years of Service
User Offline
Joined: 20th Jan 2008
Location:
Posted: 21st Jan 2008 02:17
I came up with an algorithm to calculate intersection points of balistic trajectories on terrain. However, I need some information from the terrain matrix. I need at least the 4 corner points for each surface, assuming their all coplanar. It would be nice if I didn't have to calculate the normal vector either.
tparkin
17
Years of Service
User Offline
Joined: 28th Mar 2007
Location:
Posted: 21st Jan 2008 06:58 Edited at: 21st Jan 2008 06:59
Hi,

Check out dbIntersectObject() under the "Basic3D" section in the help file. It's what you're looking for.
bitblitt
16
Years of Service
User Offline
Joined: 20th Jan 2008
Location:
Posted: 21st Jan 2008 16:48
That works better for the next algorithm, projectile collision with object. I'm not sure how to apply it to terrain. It appears to only return a distance between the object (I assume the object origin) and the point of intersection. I need to know the point, not distance to, the intersection. dbIntersectObject only returns a float. I need 3 floats (x,y,z).

I put together some equations and tested them in Excel, but I need the mathematical description of the terrain. Basically, it calculates a path due to gravity, air friction, and windage with position in respect to time. I can probably use the dbIntersectObject to determine which processing frame the projectile intersects, but my algorithm determines the exact position on the terrain where the impact occurs.

I assume the terrain is a 3d mesh of squares or triangles. My algorithm would iterate through each square or triangle and determine the impact point of the plane. To do this, I need either the equation of the plane, 1 point and the normal vector, or 3 points. Then it tests whether the impact point is within the bounded square or triangle, which requires all bounding points or lines (3 for triangle, 4 for square). Lastly, it returns the world coordinates of the impact point.

The problem is, I need access to the matrix. Does anybody know how to do this? It doesn't appear that DarkGDK is very object oriented.
tparkin
17
Years of Service
User Offline
Joined: 28th Mar 2007
Location:
Posted: 22nd Jan 2008 02:41 Edited at: 22nd Jan 2008 02:50
Hi,

I think you overlooked what the dbIntersectObject() returns. Yes, it returns a distance but this distance is from a given point until the intersection. Because of this, to get the point of intersection you just take the point of origin and add the distance.

For example:

float fDistance = dbIntersectObject( terrainID, 10, 1000, 10, 10, -1000, 10 );

Now the intersection point is X,Y,Z of ( 10, 1000 - fDistance, 10 )

Something along those lines.


Edit: DarkGDK is an API and is not object-oriented at all. There are other threads on how to access the vertices of a terrain object (or make your own). Try searching for "vertexdata" or "vertex data" with terrain possibly as a keyword. I still believe that dbIntersectObject() is all you need for the problem you're trying to solve - no sense in making it more complex than it really is.

Login to post a reply

Server time is: 2024-09-29 09:27:38
Your offset time is: 2024-09-29 09:27:38