Jump to content
  • Advertisement

Archived

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

Etnu

Height map

This topic is 6931 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 am trying to impliment a height map In D3D. I want to generate a new map each time the level starts, but the problem that Im having is setting up the vectors properly to make triangles. Does anybody know a good algo?? I need the clockwise vertices. Any help is appreciated. Etnu I am god?

Share this post


Link to post
Share on other sites
Advertisement
I'm doing something similar in the game I'm working on. Here's what I did initially:

for(WORD iz=0; iz < terrDepth; iz++){
for(WORD ix=0; ix < terrWidth; ix++){
// Get the untransformed vertex position
WORD x = ix * TERR_SCALE;
// terrCoords is basically my height map, initialized earlier
WORD y = terrCoords[ iz * terrWidth + ix ].height;
WORD z = iz * TERR_SCALE;

// go from world space to screen space and store in vert array
terrVertices[ iz * terrWidth + ix ] =
ProjectCoord( x, y, z,
terrCoords[ iz * terrWidth + ix ].lightIndex,
matSet, dwClipWidth, dwClipHeight );

if( iz < terrDepth-1 && ix < terrWidth-1 ){
// each 'square' between height-map coords is filled with two right triangles

// Etnu, I'm using counter-clockwise here

// triangle 1
terrIndices[ numIndices ] = iz * terrWidth + ix;
terrIndices[ numIndices + 1 ] = ( iz + 1 ) * terrWidth + ix;
terrIndices[ numIndices + 2 ] = ( iz + 1 ) * terrWidth + ( ix + 1 );

// triangle 2
terrIndices[ numIndices + 3 ] = iz * terrWidth + ix;
terrIndices[ numIndices + 4 ] = ( iz + 1 ) * terrWidth + ( ix + 1 );
terrIndices[ numIndices + 5 ] = iz * terrWidth + ( ix + 1 );
}
numIndices += 6;
}
}

// later, I call this, which will render all the terrain
m_pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, terrVertexTypeDesc, terrVertices, terrArea, terrIndices, numIndices, NULL );

BTW, My game won't actually use this method of rendering the height map. I've devised an adjustable-LOD algorithm based on this article by Bryan Turner.


Edited by - Eric on 4/26/00 2:01:31 AM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Thanks for the help I appreciate it.

Share this post


Link to post
Share on other sites

  • 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!