Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
int iNumVertices; int iNumIndices; WORD wIndex; SHeightmapVertex Vertex; tbVector3 vPosition; LoadRawFile("Terrain.raw", 128 * 128, g_HeightMap); iNumVertices = 128*128; g_pHeightmapVB = new tbVertexBuffer; if(g_pHeightmapVB->Init(iNumVertices * sizeof(SHeightmapVertex), sizeof(SHeightmapVertex), HEIGHTMAP_VERTEX_FVF, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DPOOL_DEFAULT)) { // Fehler! return TB_ERROR; } iNumIndices = (127) * (127) * 6; g_pHeightmapIB = new tbIndexBuffer; if(g_pHeightmapIB->Init(iNumIndices * sizeof(WORD), sizeof(WORD), D3DFMT_INDEX16)) { // Fehler! return TB_ERROR; } for(int Xa = 0; Xa <= 127; Xa++) { for(int Ya = 0; Ya <= 128;Ya++) { //Vertizes vPosition.x = (float) Xa; vPosition.y = (float) Height(g_HeightMap, Xa,Ya); vPosition.z = (float) Ya; vPosition.x /= 100; vPosition.y /= 1024; vPosition.z /= 100; // Rückruffunktionen aufrufen Vertex.vPosition = vPosition; Vertex.dwColor = (DWORD)(tbColor(1.0f, 1.0f, 0.0f)); Vertex.vTexture = TextureProc(tbVector2(vPosition.x, vPosition.z)); // Den Vertex setzen g_pHeightmapVB->SetVertex(GetVertexIndex(Xa, Ya), &Vertex); } } if(g_pHeightmapVB->Update()) return TB_ERROR; for(int Xb = 0; Xb < 127; Xb++) { for(int Yb = 0; Yb < 127; Yb++) { // Erstes Dreieck erzeugen, bei dem der Vertex (x, y) links oben ist // (x,y) _______ (x+1,y) // 1 | / 2 // | / // | / // | / // | / // |/ // (x,y+1) // 3 wIndex = GetVertexIndex(Xb, Yb); g_pHeightmapIB->AddIndex(&wIndex); wIndex = GetVertexIndex((Xb+1), Yb); g_pHeightmapIB->AddIndex(&wIndex); wIndex = GetVertexIndex(Xb, (Yb + 1)); g_pHeightmapIB->AddIndex(&wIndex); // Zweites Dreieck wIndex = GetVertexIndex(Xb, Yb+1); g_pHeightmapIB->AddIndex(&wIndex); wIndex = GetVertexIndex(Xb+1, Yb); g_pHeightmapIB->AddIndex(&wIndex); wIndex = GetVertexIndex(Xb+1,Yb+1); g_pHeightmapIB->AddIndex(&wIndex); }; }; if(g_pHeightmapIB->Update()) return TB_ERROR; // ------------------------------------------------------------------ g_pHeightmapTexture = tbTextureManager::GetTexture("Terrain.bmp"); if(g_pHeightmapTexture == NULL) return TB_ERROR; return TB_OK; } |
Anonymous
unregistriert
C-/C++-Quelltext |
|
1 |
for(int Xa = 0; Xa < 128; Xa+=16) |
C-/C++-Quelltext |
|
1 |
#define HEIGHTMAP_VERTEX_FVF (D3DFVF_XYZ | D3DFVF_TEX1)
|
Werbeanzeige