add texture mapping

This commit is contained in:
2025-11-12 15:08:57 +01:00
parent a39f37ac4e
commit 4910894bef
3 changed files with 34 additions and 18 deletions
+17 -17
View File
@@ -31,12 +31,12 @@ void Mesh::update(FLOAT dt)
static FLOAT x = 0.0f;
static FLOAT y = 0.0f;
static FLOAT z = 0.0f;
static FLOAT pitch = XM_PIDIV4;
static FLOAT pitch = 0.0f;
static FLOAT yaw = 0.0f;
static FLOAT roll = XM_PIDIV4;
static FLOAT roll = 0.0f;
static FLOAT scale = 1.0f;
yaw += 1.0f * dt;
//yaw += 1.0f * dt;
FLOAT move = 1.0f * dt;
@@ -123,10 +123,10 @@ UINT Mesh::createVertexBuffer(IDirect3DDevice9* pD3DDevice)
//// quad with trianglefan
//// quad with trianglelist & index buffer
//pVertices[0] = Vertex(-0.5f, 0.5f, 0.0f);
//pVertices[1] = Vertex(0.5f, 0.5f, 0.0f);
//pVertices[2] = Vertex(0.5f, -0.5f, 0.0f);
//pVertices[3] = Vertex(-0.5f, -0.5f, 0.0f);
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);
//// cube with color
//// front
@@ -142,17 +142,17 @@ UINT Mesh::createVertexBuffer(IDirect3DDevice9* pD3DDevice)
//pVertices[7] = Vertex(0.5f, -0.5f, 0.5f, 200, 200, 200);
// cube with uv
// front
pVertices[0] = Vertex(-0.5f, 0.5f, -0.5f, 0.0f, 0.0f);
pVertices[1] = Vertex(0.5f, 0.5f, -0.5f, 1.0f, 0.0f);
pVertices[2] = Vertex(0.5f, -0.5f, -0.5f, 1.0f, 1.0f);
pVertices[3] = Vertex(-0.5f, -0.5f, -0.5f, 0.0f, 1.0f);
//// front
//pVertices[0] = Vertex(-0.5f, 0.5f, -0.5f, 0.0f, 0.0f);
//pVertices[1] = Vertex(0.5f, 0.5f, -0.5f, 1.0f, 0.0f);
//pVertices[2] = Vertex(0.5f, -0.5f, -0.5f, 1.0f, 1.0f);
//pVertices[3] = Vertex(-0.5f, -0.5f, -0.5f, 0.0f, 1.0f);
// back
pVertices[4] = Vertex(0.5f, 0.5f, 0.5f, 0.0f, 0.0f);
pVertices[5] = Vertex(-0.5f, 0.5f, 0.5f, 1.0f, 0.0f);
pVertices[6] = Vertex(-0.5f, -0.5f, 0.5f, 1.0f, 1.0f);
pVertices[7] = Vertex(0.5f, -0.5f, 0.5f, 0.0f, 1.0f);
//// back
//pVertices[4] = Vertex(0.5f, 0.5f, 0.5f, 0.0f, 0.0f);
//pVertices[5] = Vertex(-0.5f, 0.5f, 0.5f, 1.0f, 0.0f);
//pVertices[6] = Vertex(-0.5f, -0.5f, 0.5f, 1.0f, 1.0f);
//pVertices[7] = Vertex(0.5f, -0.5f, 0.5f, 0.0f, 1.0f);
hr = _pVertexBuffer->Unlock();
CheckFailed(hr, 320);