# How can i write the get terrain height function?

zckczy

07-05-2010 08:46:29

Hello:
I used a mesh as the terrain in my program,but the question is coming.The function of the get terriain height doesn't work. I rewrite it but I found that the efficiency is so low that my program is not responsing. I have not good idea about it , I try write the height data about the mesh into a binary file in order to not computing the height in real time.
But the file is so big that at the beginning of the program I have to cost much time to read it.
Do you have some good idea about it? if you have some,please enlighten me.
Thank you!

stealth977

07-05-2010 10:05:57

Assuming your mesh is not a plane, you need to use polygon level picking algorithms to calculate the HITPOSITION of the ray to get height (Y component) at that point.

That said, it will be while(true) print("VERY") MUCH INEFFICIENT So, if you REALLY HAVE TO use a non-planar mesh as terrain, create a very low poly approximation of that mesh, making sure that the original mesh INCLUDES the low poly mesh (low poly mesh should never stick out of original mesh at any point) and use that low poly mesh for HITPOINT calculation. Since your low poly mesh is equal to or below the original mesh's surface, the worst case would be your grass/trees will be just a bit sunken into the mesh which is way better than having them float above the original mesh And that technique would be magnitudes faster (efficient) than using original mesh to calculate heights, depending on how much you can optimize the low poly mesh...

zckczy

07-05-2010 11:44:57

Thank you!
I can understand the idea you wrote.Ｉhave to use a non-planar mesh as terrain.Though i understand your idea,i don't have idea about how create a low poly mesh.Could you please explain more about it .
Thank you!!

Fish

07-05-2010 12:25:22

Are you able to use the Terrain Component in Ogre 1.7.1 instead of a mesh?

- Fish

stealth977

07-05-2010 15:44:44

Thank you!
I can understand the idea you wrote.Ｉhave to use a non-planar mesh as terrain.Though i understand your idea,i don't have idea about how create a low poly mesh.Could you please explain more about it .
Thank you!!

I assume you are creating your TERRAIN MESH MODEL in a modelling application. You just need to use "Simplfy Mesh" or something like that, function of your modelling application, then save and use that mesh for RAYCASTING to find the HITPOSITION (or height)...