Jump to content
  • Advertisement
Sign in to follow this  


This topic is 3817 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

hi i am trying to build a terrain using a raw file. i have created the height map and the mesh. but i want to render only those triangles which are in the view currently. i dont want to render all the triangles at one go. how do i go about it?

Share this post

Link to post
Share on other sites
Check every triangle one by one if it is inside the view is not efficient.
You should partition your triangles into groups,like patches.
For example if you terrain has 256x256 vertices you can make 32x32 patches that would make 8x8=64 patches.Then you can check if a patch is inside the view and draw it or not.You should calculate the bounding box or sphere of each patch from the vertices in it,also you might want to look into quadtrees.

Share this post

Link to post
Share on other sites
Instead of making one large mesh for the entire height-map, make several smaler meshes.
E.g. if the heightmap is originally 1024x1024, then you could make (a 16*16 grid of small) 65*65 meshes.

You could then organise these smaller meshes into a quad-tree (etc) for easier culling.

[EDIT] Black Knight beat me to it ;)
N.B. If you split the main mesh into sub-meshes, these sub-meshes require the edge vertices to be duplicated. (remember the +1!)
E.g. Width = 1024
NumSubMeshes = 16
SubMeshWidth = 1024/16 + 1

Share this post

Link to post
Share on other sites
thanks for the reply

following is the code which creates the mesh:

void DisplayHeightMap (void) {
int Height;
int numtri=0;

for (mapX = 1; mapX < MapWidth; mapX +=4){
for (mapZ = 1; mapZ < MapHeight*4; mapZ+=4){

Height = HeightMap[mapX][mapZ];

Height = HeightMap[mapX][mapZ+4];

Height = HeightMap[mapX+4][mapZ];

Height = HeightMap[mapX+4][mapZ+4];
not able to make out if it is creating a single mesh??

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!