Add lighting

This commit is contained in:
2026-11-20 12:12:50 +01:00
parent 491367dfa8
commit 7aad3c6292
6 changed files with 60 additions and 15 deletions
+8 -6
View File
@@ -29,8 +29,10 @@ void Mesh::update(FLOAT dt)
static float x = 0.0f;
static float y = 0.0f;
static float z = 0.0f;
static float rotY = 0.0f;
static float rotZ = 0.0f;
rotY += 1.0f * dt;
rotZ += 0.0f * dt;
float move = 1.0f * dt;
@@ -43,7 +45,7 @@ void Mesh::update(FLOAT dt)
if ((GetAsyncKeyState(VK_ADD) & 0x8000) || (GetAsyncKeyState('E') & 0x8000)) z += move;
XMMATRIX translation = XMMatrixTranslation(x, y, z);
XMMATRIX rotation = XMMatrixRotationRollPitchYaw(0.0f, 0.0f, rotZ);
XMMATRIX rotation = XMMatrixRotationRollPitchYaw(0.0f, rotY, rotZ);
XMMATRIX scale = XMMatrixScaling(1.0f, 1.0f, 1.0f);
XMFLOAT4X4 w;
@@ -119,11 +121,11 @@ UINT Mesh::createVertexBuffer(IDirect3DDevice9* pD3DDevice)
//pVertices[2] = Vertex(0.5f, -0.5f, 0.0f, 0, 0, 255);
//pVertices[3] = Vertex(-0.5f, -0.5f, 0.0f, 255, 255, 0);
// quad with uvs
pVertices[0] = Vertex(-0.5f, 0.5f, 0.0f, 0.0f, 0.0f);
pVertices[1] = Vertex(0.5f, 0.5f, 0.0f, 1.0f, 0.0f);
pVertices[2] = Vertex(0.5f, -0.5f, 0.0f, 1.0f, 1.0f);
pVertices[3] = Vertex(-0.5f, -0.5f, 0.0f, 0.0f, 1.0f);
// quad with uvs & normals
pVertices[0] = Vertex(-0.5f, 0.5f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f);
pVertices[1] = Vertex(0.5f, 0.5f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f);
pVertices[2] = Vertex(0.5f, -0.5f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f);
pVertices[3] = Vertex(-0.5f, -0.5f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f);
hr = _pVertexBuffer->Unlock();
CheckFailed(hr, 320);