MeshTerrainY

Blitz3D Forums/Blitz3D Programming/MeshTerrainY

ringwraith(Posted 2008) [#1]
I've been working on a terrain editor for a while now and I decided to use mesh terrains from the beginning for a number of reasons. But now I'm wondering how it might be possible to find the terrain height of a mesh terrain without using linepick which might cause slowdown?


jfk EO-11110(Posted 2008) [#2]
Maybe there is already something in the code archives. Probably one of the line-intersect-whatever routines.


ringwraith(Posted 2008) [#3]
Yes, I have tested out one of those and it seems to kill my framerate. I'm not sure why that is, but I think it has something to do with the fact that it has to use a PointInTriangle check for every triangle in the mesh terrain every frame. I think it might work well if there was a quicker way of doing this check, but I haven't been able to find one.


ringwraith(Posted 2008) [#4]
Also, another, somewhat related problem I've encountered is that Blitz seems to handle collisions way too sensitively. For example, if I try to test out one of my terrains, my character gets stopped on the slopes that could pretty easily be walked up in real life (roughly 30 or 40 degrees). I'm not sure if this is a bug in Blitz or if it has something to do with my code, but I don't think its in my code because I'm not currently using any kind of gravity and I'm using
Collisions player_collide,terrain_collide,2,3. Also, if I use Collisions player_collide,terrain_collide,2,2, the character doesn't even slide down extremely steep slopes sometimes (close to 90 degrees).


Ross C(Posted 2008) [#5]
You'll need to set some other things up behind the scenes to handle slope angle collisions.

As for the mesh height, you can use mesh height i believe to get the height of a mesh. OR, loop through every vertex, find the lowest, find the height vertex then do a simple calculation :o)


ringwraith(Posted 2008) [#6]
Are you sure I would have to handle the collision angles on my own? I thought Blitz was supposed to do that for you when you set the response settings for collisions, of course I could be wrong.

Also, mesh height returns the total height of the mesh, not the height at a specific point. And I'm not quite sure I understand your second method, if you could explain it a little more.


Stevie G(Posted 2008) [#7]
If your terrain is uniform in the x and z scale then the calculations are quite easy and fast otherwise you'll always have to iterate through all tri's to get the point of intersection so quicker to use linepick.

Which is it?


ringwraith(Posted 2008) [#8]
It's uniform in the x-z plane.


Ross C(Posted 2008) [#9]
Well, what i mean by your own collisions, is get the normals from the collision and check them. If they are too steep then don't allow the player to keep walking. I use a linepick downwards and gather all the pick collision information and work with that.

As for my second suggestion, i thought you were only wanting the terrain height. Sorry about that ^_^. As stevie says, linepick is probably the best.


Stevie G(Posted 2008) [#10]
See here then ...

http://www.blitzbasic.co.nz/Community/posts.php?topic=45525#506330


ringwraith(Posted 2008) [#11]
Thanks for the replies Stevie and Ross. I think Stevie's method of finding the height on a quad will probably work well for my situation. Ross, you're right about having to handle my own collisions in this case. I've come across a whole bunch of buggy wierd things like my player just walking right through the terrain or not being able to walk down a smooth gentle slope. I guess I'll have to check the steepness of the triangles manually then.

Thanks all.