LOD implementation in OGL
-
ich habe mir mal überlegt, wie ich ein lod machen könnte, und da habe ich meine karte in blöcke unterteilt und teste für jeden block die entfernung. danach wird mit einer passenden genauigkeit gerendert.
allerdings entstehen an den kanten der blöcke ganz schmale streifen, weil die quads nicht mehr passen.
ich würde gerne wissen, wie ich diese kanten trotzdem verbinde.http://img98.imageshack.us/my.php?image=sratchmf7.png
void Map::drawHmap(bool bRenderQuads = 1) { // karte in 16 blöcke unterteilen int blockK = 16; int stretchF = 1; int blockSizeH = iLengthMap/blockK; int blockSizeW = iWidthMap/blockK; Point3f svP1, svP2, svP3, svP4; for(int i = 0; i < blockK; i++) { for(int j = 0; j < blockK; j++) { Point3f pt; pt.x = j*blockSizeW; pt.z = i*blockSizeH; pt.y = 0; Point3f ct; ct.x = -cam->getPos().x; ct.z = cam->getPos().z; ct.y = 0; float dis = calcDistance(ct, pt); if(dis > 750) iStepSize = 10; else if(dis > 500 && dis <= 750) iStepSize = 8; else if(dis > 200 && dis <= 500) iStepSize = 6; else iStepSize = 2; for ( int Y = i*blockSizeH; Y < blockSizeH*(i+1); Y += iStepSize ) for ( int X = j*blockSizeW; X < blockSizeW*(j+1); X += iStepSize ) { if(Y >= blockSizeH*blockK-iStepSize || X >= blockSizeW*blockK-iStepSize) break; // Punkte der Fläche berechnen: // Get The (X, Y, Z) Value For The Bottom Left Vertex svP1.x = X; svP1.y = fHeightMap[Y][X].y; svP1.z = -Y; // Get The (X, Y, Z) Value For The Top Left Vertex svP2.x = X; svP2.y = fHeightMap[Y+iStepSize][X].y; svP2.z = -Y - iStepSize; // Get The (X, Y, Z) Value For The Top Right Vertex svP3.x = X + iStepSize; svP3.y = fHeightMap[Y+iStepSize][X+iStepSize].y; svP3.z = -Y - iStepSize; // Get The (X, Y, Z) Value For The Bottom Right Vertex svP4.x = X + iStepSize; svP4.y = fHeightMap[Y][X+iStepSize].y; svP4.z = -Y; // svP1 = svP1 * stretchF; svP2 = svP2 * stretchF; svP3 = svP3 * stretchF; svP4 = svP4 * stretchF; if(bRenderQuads) // What We Want To Render glBegin( GL_QUADS ); // Render Polygons else glBegin( GL_LINE_LOOP ); // Render Lines Instead // Get The (X, Y, Z) Value For The Bottom Left Vertex glNormal3f(vNormals[Y][X].x, vNormals[Y][X].y, vNormals[Y][X].z); if(gHMapTextures[Y][X] > 0) glTexCoord2f(0.0f, 1.0f); glVertex3i(svP1.x, svP1.y, svP1.z); // Get The (X, Y, Z) Value For The Top Left Vertex glNormal3f(vNormals[Y + iStepSize][X].x, vNormals[Y + iStepSize][X].y, vNormals[Y + iStepSize][X].z); if(gHMapTextures[Y][X] > 0) glTexCoord2f(0.0f, 0.0f); glVertex3i(svP2.x, svP2.y, svP2.z); // Get The (X, Y, Z) Value For The Top Right Vertex glNormal3f(vNormals[Y + iStepSize][X + iStepSize].x, vNormals[Y + iStepSize][X + iStepSize].y, vNormals[Y + iStepSize][X + iStepSize].z); if(gHMapTextures[Y][X] > 0) glTexCoord2f(1.0f, 0.0f); glVertex3i(svP3.x, svP3.y, svP3.z); // Get The (X, Y, Z) Value For The Top Right Vertex glNormal3f(vNormals[Y][X + iStepSize].x, vNormals[Y][X + iStepSize].y, vNormals[Y][X + iStepSize].z); if(gHMapTextures[Y][X] > 0) glTexCoord2f(1.0f, 1.0f); glVertex3i(svP4.x, svP4.y, svP4.z); glEnd(); } } } }
-
wird zum beispiel hier drin beschrieben: http://tu-testbed.svn.sourceforge.net/viewvc/*checkout*/tu-testbed/trunk/tu-testbed/docs/sig-notes.pdf
-
das finde ich nicht so hilfreich. ich meine, dort steht genau das drinne, was ich vorhabe. nur nicht wie.
wenn ich meinetwegen ne konstante zum weiterrendern einsetze entstehen häsliche kleine überlagerungen.
also bleibt nur dass ich jede lücke selbst auffülle. ich dachte sowas hätte nur schon einer gemacht.
-
es steht doch da drin beschrieben, du kannst das Problem zum Beispiel mit vertikalen Quads machen, die die Lücken ausfüllen. Wenn du nicht weißt, wie du das machen sollst: Es gibt auch noch eine Referenzimplementierung zu Chunked LOD auf der Seite (inklusive dem Crack-filling, wonach du suchst): http://tulrich.com/geekstuff/chunklod.html#downloads