Archived

This topic is now archived and is closed to further replies.

Floor Collision Detection Problem

This topic is 5603 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I might just be being stupid, if this is a case, please feel free to form an orderly queue to hit me with a large stick. Any the Problem! I have created a 3D terrain with various hills and want my player (the camera) to maintain an height above the hilly surface as you move using the keys etc. To do this, which may or may not be the best way...if not someone say a better. As I plotted my vertices forming a grid like matrix, I grab every other four set of vertices and get the average Y (height) coordinate and stuff them into a member variable (using classes). The Grid is formed of 10 colums by 10 rows each tile (cell) is 10 world units. These values are variables and can be changed. The camera moves 0.5 world units per frame in the selected direction if any. Sounds logical..so far dont it? Right, I then created a metho to which takes two arguments of type float, which are the X and Z coordinates of the camera. From this I need to determine, which element of my array containing the surface elements should be used. Note that there is not a one to one relationship here. As there are like 10 world units per cell the player can move like 20 (0.5 world units per movement) and still be on the same cell. I have been trying for like 3 days on what at first seemed like a simple problem. I have now pulled out all of my hair....someone please help......

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
why don''t you just make some kind of scene graph (in a quadtree form) and then search for the exact tri the cams on and then taking the exact height (as you know the exact tri) just add the difference. If you can access all the data of the grid directly then you don''t even need to worry about the scene graph...

Share this post


Link to post
Share on other sites
What''s the problem? Is it you can''t find what cell your over or you can''t find the height once you''re over it?

If you can''t find the tile:
Since all your tiles are the same size (10 units) dividing your player''s x and z coodinates by 10 should give you the correct tile unless you''ve performed some scaling in between drawing them. Make sure you tank the integer of the result.

There''s 2 methods I can think of to get the height after that.

The first is to interpolate along 2 opposite sides of the cell and them interpolate between the results to get the point where your player/camera is above.

The second is to shoot a ray from your position straight down the Y-axis and perform a ray/plane intersection for the polygon you are above.

Share this post


Link to post
Share on other sites
quote:
Original post by siaspete
The post was moved to the right forum.




And what forum was it in before it was moved?

Anyway, this a cross-post. It''s already in the Maths-Physics forum. See here.

Cédric

Share this post


Link to post
Share on other sites