Hi-o,
![Posted Image]()
I'm in a bit of a pickle. I've been at this for a few hours now and am having trouble getting my cube faces flat.
I've noticed when I change the base vertex location on d3d11DevCon->DrawIndexed(gameObject[i].indicesCount, gameObject[i].indicesStart, 0), from 0 to 2, the front faces of my cubes are perfectly flat as they should be, but this further distorts all other faces.
I believe that's everything that could be possibly related to the problem.

I'm in a bit of a pickle. I've been at this for a few hours now and am having trouble getting my cube faces flat.
I've noticed when I change the base vertex location on d3d11DevCon->DrawIndexed(gameObject[i].indicesCount, gameObject[i].indicesStart, 0), from 0 to 2, the front faces of my cubes are perfectly flat as they should be, but this further distorts all other faces.
int InitObjects()
{
gameObject[0].indicesCount = 36; //ARRAYSIZE(indices);
gameObject[0].zPosition =-0.5f;
gameObject[0].TexturePath = L"texture.jpg";
gameObject[0].Origin = XMVectorSet(0.0f, 0.1f, 0.0f, 0.0f);
gameObject[0].rotationSpeed = 0.00006;
gameObject[1].indicesCount = 36; //ARRAYSIZE(indices);
gameObject[1].xPosition = -3.0f;
gameObject[1].zPosition =-0.5f;
gameObject[1].TexturePath = L"texture2test.jpg";
gameObject[1].Origin = XMVectorSet(0.0f, 0.0f, 1.0f, 0.0);
gameObject[1].rotationSpeed = 0.00012;
gameObject[2].indicesCount = 36; //ARRAYSIZE(indices);
gameObject[2].xPosition = 3.0f;
gameObject[2].zPosition =-0.5f;
gameObject[2].TexturePath = L"StoneBlock.jpg";
gameObject[2].Origin = XMVectorSet(0.0f, 0.0f, 1.0f, 0.0);
gameObject[2].rotationSpeed = 0.00012;
return 1;
}
Draw()
{
//Clear our backbuffer
float bgColor[4] = {(0.0f, 0.0f, 0.0f, 0.0f)};
d3d11DevCon->ClearRenderTargetView(renderTargetView, bgColor);
//Refresh the Depth/Stencil view
d3d11DevCon->ClearDepthStencilView(depthStencilView, D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL, 1.0f, 0);
for(int i = 0; i < gameObject.size(); i++)
{
WVP = gameObject[i].xmmatrix * camView * camProjection;
cbPerObj.WVP = XMMatrixTranspose(WVP);
d3d11DevCon->UpdateSubresource( cbPerObjectBuffer, 0, NULL, &cbPerObj, 0, 0 );
d3d11DevCon->VSSetConstantBuffers( 0, 1, &cbPerObjectBuffer );
d3d11DevCon->PSSetShaderResources( 0, 1, &gameObject[i].CubesTexture);
d3d11DevCon->PSSetSamplers( 0, 1, &CubesTexSamplerState );
////base version location = number of triangles used per object
d3d11DevCon->DrawIndexed(gameObject[i].indicesCount, gameObject[i].indicesStart, 0);
}
SwapChain->Present(0, 0);
}
struct Vertex //Overloaded Vertex Structure
{
Vertex(){}
Vertex(float x, float y, float z, float u, float v) : pos(x,y,z), texCoord(u, v){}
XMFLOAT3 pos;
XMFLOAT2 texCoord;
};
Vertex v[] =
{
#pragma region pallette
// Front Face
Vertex(-1.0f, -1.0f, -1.0f, 0.0f, 1.0f),
Vertex(-1.0f, 1.0f, -1.0f, 0.0f, 0.0f),
Vertex( 1.0f, 1.0f, -1.0f, 1.0f, 0.0f),
Vertex( 1.0f, -1.0f, -1.0f, 1.0f, 1.0f),
// Back Face
Vertex(-1.0f, -1.0f, 1.0f, 1.0f, 1.0f),
Vertex( 1.0f, -1.0f, 1.0f, 0.0f, 1.0f),
Vertex( 1.0f, 1.0f, 1.0f, 0.0f, 0.0f),
Vertex(-1.0f, 1.0f, 1.0f, 1.0f, 0.0f),
// Top Face
Vertex(-1.0f, 1.0f, -1.0f, 0.0f, 1.0f),
Vertex(-1.0f, 1.0f, 1.0f, 0.0f, 0.0f),
Vertex( 1.0f, 1.0f, 1.0f, 1.0f, 0.0f),
Vertex( 1.0f, 1.0f, -1.0f, 1.0f, 1.0f),
// Bottom Face
Vertex(-1.0f, -1.0f, -1.0f, 1.0f, 1.0f),
Vertex( 1.0f, -1.0f, -1.0f, 0.0f, 1.0f),
Vertex( 1.0f, -1.0f, 1.0f, 0.0f, 0.0f),
Vertex(-1.0f, -1.0f, 1.0f, 1.0f, 0.0f),
// Left Face
Vertex(-1.0f, -1.0f, 1.0f, 0.0f, 1.0f),
Vertex(-1.0f, 1.0f, 1.0f, 0.0f, 0.0f),
Vertex(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f),
Vertex(-1.0f, -1.0f, -1.0f, 1.0f, 1.0f),
// Right Face
Vertex( 1.0f, -1.0f, -1.0f, 0.0f, 1.0f),
Vertex( 1.0f, 1.0f, -1.0f, 0.0f, 0.0f),
Vertex( 1.0f, 1.0f, 1.0f, 1.0f, 0.0f),
Vertex( 1.0f, -1.0f, 1.0f, 1.0f, 1.0f),
#pragma endregion
};
DWORD indices[] =
{
#pragma region pallette
// Front Face
0, 1, 2,
0, 2, 3,
// Back Face
4, 5, 6,
4, 6, 7,
// Top Face
8, 9, 10,
8, 10, 11,
// Bottom Face
12, 13, 14,
12, 14, 15,
// Left Face
16, 17, 18,
16, 18, 19,
// Right Face
20, 21, 22,
20, 22, 23
#pragma endregion
};
InitObjects();
...
indexBufferDesc.ByteWidth = sizeof(DWORD) * 12 * 3;
...
vertexBufferDesc.ByteWidth = sizeof( Vertex ) * ARRAYSIZE(v);
...
d3d11DevCon->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
I believe that's everything that could be possibly related to the problem.