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 |
for(int y=0; y<m_iResolution; y++) { for(int x=0; x<m_iResolution; x++) { // Umliegende Verts holen STerrainVertex Vertex1, Vertex2, Vertex3, Vertex4, Vertex5; m_pVertexBuffer->GetVertex(GetVertexIndex(x, y), &Vertex1); if(x-1>=0) m_pVertexBuffer->GetVertex(GetVertexIndex(x-1, y), &Vertex2); if(y-1>=0) m_pVertexBuffer->GetVertex(GetVertexIndex(x, y-1), &Vertex3); if(x+1<m_iResolution) m_pVertexBuffer->GetVertex(GetVertexIndex(x+1, y), &Vertex4); if(y+1<m_iResolution) m_pVertexBuffer->GetVertex(GetVertexIndex(x, y+1), &Vertex5); // Umliegende Normalen berechnen bool b1 = false; bool b2 = false; bool b3 = false; bool b4 = false; short sNumTriagles = 0; gve::Vector3 vNorm1, vNorm2, vNorm3, vNorm4; if(y+1<m_iResolution && x+1<m_iResolution) { vNorm1 = gve::ComputeTriangleNormal(Vertex1.vPosition, Vertex4.vPosition, Vertex5.vPosition); b1 = true; sNumTriagles++; } if(x-1>=0 && y+1<m_iResolution) { vNorm2 = gve::ComputeTriangleNormal(Vertex1.vPosition, Vertex2.vPosition, Vertex5.vPosition); b2 = true; sNumTriagles++; } if(x-1>=0 && y-1>=0) { vNorm3 = gve::ComputeTriangleNormal(Vertex1.vPosition, Vertex2.vPosition, Vertex3.vPosition); b3 = true; sNumTriagles++; } if(y-1>=0 && x+1<m_iResolution) { vNorm4 = gve::ComputeTriangleNormal(Vertex1.vPosition, Vertex3.vPosition, Vertex4.vPosition); b4 = true; sNumTriagles++; } // Durchschnitt berechnen gve::Vector3 NewNormal = gve::Vector3(0.0f); if(b1) NewNormal += vNorm1; if(b2) NewNormal += vNorm2; if(b3) NewNormal += vNorm3; if(b4) NewNormal += vNorm4; NewNormal /= sNumTriagles; Vertex1.vNormal = NewNormal; m_pVertexBuffer->SetVertex(GetVertexIndex(x, y), &Vertex1); } } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
D3DLIGHT9 Light; ZeroMemory(&Light, sizeof(D3DLIGHT9)); Light.Type = D3DLIGHT_DIRECTIONAL; Light.Diffuse = gve::Color(1.0f, 1.0f, 1.0f); Light.Ambient = gve::Color(1.0f, 1.0f, 1.0f); Light.Specular = gve::Color(1.0f, 1.0f, 1.0f); Light.Direction = gve::Vector3(-1.0f); D3D->SetLight(0, &Light); D3DMATERIAL9 Mat; Mat.Ambient = gve::Color(0.1f); Mat.Diffuse = gve::Color(1.0f); Mat.Emissive = gve::Color(0.1f); Mat.Power = 0.0f; Mat.Specular = gve::Color(0.0f); D3D->SetMaterial(&Mat); |
Werbeanzeige