Add texture loading
Add uv mapping Add lighting
This commit is contained in:
+15
-7
@@ -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 += 0.5f * dt;
|
||||
rotZ += 0.0f * dt;
|
||||
|
||||
float move = 1.0f * dt;
|
||||
@@ -39,11 +41,11 @@ void Mesh::update(FLOAT dt)
|
||||
if (GetAsyncKeyState(VK_RIGHT) & 0x8000) x += move;
|
||||
if (GetAsyncKeyState(VK_DOWN) & 0x8000) y -= move;
|
||||
if (GetAsyncKeyState(VK_UP) & 0x8000) y += move;
|
||||
if (GetAsyncKeyState(VK_SUBTRACT) & 0x8000) z -= move;
|
||||
if (GetAsyncKeyState(VK_ADD) & 0x8000) z += move;
|
||||
if ((GetAsyncKeyState(VK_SUBTRACT) & 0x8000) || (GetAsyncKeyState('Q') & 0x8000)) z -= move;
|
||||
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);
|
||||
|
||||
XMStoreFloat4x4(reinterpret_cast<XMFLOAT4X4*>(&_worldMatrix), scale * rotation * translation);
|
||||
@@ -111,10 +113,16 @@ UINT Mesh::createVertexBuffer(IDirect3DDevice9* pD3DDevice)
|
||||
//pVertices[3] = Vertex(-0.5f, -0.5f, 0.0f);
|
||||
|
||||
// quad with color
|
||||
pVertices[0] = Vertex(-0.5f, 0.5f, 0.0f, 255, 0, 0);
|
||||
pVertices[1] = Vertex(0.5f, 0.5f, 0.0f, 0, 255, 0);
|
||||
pVertices[2] = Vertex(0.5f, -0.5f, 0.0f, 255, 0, 255);
|
||||
pVertices[3] = Vertex(-0.5f, -0.5f, 0.0f, 0, 0, 255);
|
||||
//pVertices[0] = Vertex(-0.5f, 0.5f, 0.0f, 255, 0, 0);
|
||||
//pVertices[1] = Vertex(0.5f, 0.5f, 0.0f, 0, 255, 0);
|
||||
//pVertices[2] = Vertex(0.5f, -0.5f, 0.0f, 255, 0, 255);
|
||||
//pVertices[3] = Vertex(-0.5f, -0.5f, 0.0f, 0, 0, 255);
|
||||
|
||||
// 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);
|
||||
|
||||
Reference in New Issue
Block a user