If there's more indices loaded - does the shader need to have more bytes?
#1 Members - Reputation: 328
Posted 09 August 2012 - 01:33 AM
Thanks for awesome input!
#3 Members - Reputation: 328
Posted 09 August 2012 - 01:47 AM
#4 Moderators - Reputation: 13558
Posted 09 August 2012 - 01:54 AM
Input layouts are stored in input layout objects, not in constant buffers! An input layout is valid for any number of primitives (if it works for 100 verts, it will also work for 1000 verts).the Constant Buffer that has the input element layout for the shader
What are you putting in this constant buffer, and where does the magic number of 178 come from?
It's the size of the buffer in bytes. For a constant buffer, this should be the size of the cbuffer structure defined in the HLSL code. For an index or vertex buffer, it's based on the maximum amount of vertices/indices you want to be able to put in the buffer times the size of a vertex/index.in the Buffer Description that a ByteWidth represents width of bytes returned
Edited by Hodgman, 09 August 2012 - 02:15 AM.
#5 Members - Reputation: 328
Posted 09 August 2012 - 05:01 AM
So, regarless the mesh should load property right?
#6 Members - Reputation: 521
Posted 09 August 2012 - 05:28 AM
Edit:
Maybe you'd like to show how you load that heart model?
Edited by Ripiz, 09 August 2012 - 05:31 AM.
#8 Members - Reputation: 328
Posted 09 August 2012 - 06:13 AM
http://www.youtube.com/watch?v=2flX9yNlzoc&feature=youtu.be
#10 Members - Reputation: 328
Posted 09 August 2012 - 06:31 AM
#11 Members - Reputation: 521
Posted 09 August 2012 - 06:38 AM
Your operating system looks like Windows Vista either Windows 7, you could use PIX from DirectX SDK to analyse whether your buffers were created, see how mesh looks like before and after vertex shader, etc.
#12 Members - Reputation: 328
Posted 09 August 2012 - 06:40 AM
Namespace ModelManger - Class Model. Native Class code MESH. Native Class just has declarations for VertexCount and Indices.
This is part of the Loading Custom Mesh.
D3D11_BUFFER_DESC indexBufferDesc;
ZeroMemory( &indexBufferDesc, sizeof(indexBufferDesc) );
indexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
indexBufferDesc.ByteWidth = sizeof(unsigned long) * MESH->IndexCount;
indexBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
indexBufferDesc.CPUAccessFlags = 0;
indexBufferDesc.MiscFlags = 0;
D3D11_SUBRESOURCE_DATA iinitData;
iinitData.pSysMem = indices;
dev->CreateBuffer(&indexBufferDesc, &iinitData, &pIBuffer);
devcon->IASetIndexBuffer( pIBuffer, DXGI_FORMAT_R32_UINT, 0);
D3D11_BUFFER_DESC vertexBufferDesc;
ZeroMemory( &vertexBufferDesc, sizeof(vertexBufferDesc) );
vertexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
vertexBufferDesc.ByteWidth = sizeof(Mesh::VERTEX) * MESH->VertexCount;
vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
vertexBufferDesc.CPUAccessFlags = 0;
vertexBufferDesc.MiscFlags = 0;
D3D11_SUBRESOURCE_DATA vertexBufferData;
ZeroMemory( &vertexBufferData, sizeof(vertexBufferData) );
vertexBufferData.pSysMem = OBJVertices;
HR( dev->CreateBuffer( &vertexBufferDesc, &vertexBufferData, &pVBuffer));
D3DX11CreateShaderResourceViewFromFile(dev, // the Direct3D device
L"Wood.png", // load Wood.png in the local folder
NULL, // no additional information
NULL, // no multithreading
&pTexture, // address of the shader-resource-view
NULL); // no multithreading
this loads the SGM file and sorts through everything. Making sure it's X,Y,Z, Normals, and U, Vs.
bool result;
char input;
char input2;
ifstream fin;
MESH->VertexCount = 0;
MESH->IndexCount = 0;
// VertexIndex *verIndex;
unsigned long * indices;
fin.open(filename);
if(fin.fail() == true) {
return false;
}
fin.get(input);
while(input != ':') {
fin.get(input);
}
fin >> MESH->VertexCount;
MESH->IndexCount = MESH->VertexCount;
indices = new unsigned long[MESH->IndexCount];
Mesh::VERTEX *OBJVertices;
OBJVertices = new Mesh::VERTEX[MESH->VertexCount];
fin.get(input);
while(input != ':') {
fin.get(input);
}
fin.get(input);
fin.get(input);
for(int i = 0; i<MESH->VertexCount; i++) {
int normx, normy, normz;
fin >> OBJVertices[i].x >> OBJVertices[i].y >> OBJVertices[i].z >> normx >> normy >> normz >> OBJVertices[i].U >> OBJVertices[i].V;
OBJVertices[i].Normal = D3DXVECTOR3(normx,normy,normz);
indices[i] = i;
}
fin.close();
INside the converter the program loads the OBJ values and when converting sorts them out through their indices. So, there's no need to worry about figuring out the indices. This is where the Indices[i] come into play because there's no Indices to worry about. Additionally, when converted the SGM model format is already indexed flipped and minutes Z's for texture coord, normals, and vertices.
This is the draw call inside the engine.
void Draw() {
cBuffer.LightVector = D3DXVECTOR4(1.0f, 4.0f, -2.0f,0.0f);
cBuffer.LightColor = D3DXCOLOR(0.5f, 0.5f, 0.5f, 1.0f);
cBuffer.AmbientColor = D3DXCOLOR(0.2f, 0.2f, 0.2f, 1.0f);
// select which vertex buffer to display
UINT stride = sizeof(Mesh::VERTEX);
UINT offset = 0;
devcon->IASetVertexBuffers(0, 1, &pVBuffer, &stride, &offset);
devcon->IASetIndexBuffer(pIBuffer, DXGI_FORMAT_R32_UINT, 0);
// select which primtive type we are using
devcon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
// draw the Hypercraft
devcon->UpdateSubresource(pCBuffer, 0, 0, &cBuffer, 0, 0);
devcon->PSSetShaderResources(0, 1, &pTexture);
devcon->DrawIndexed(MESH->VertexCount, 0, 0);
}
This function updates the matrixes.
void update_Matrixes() {
//--- Let's see if we need to move camera anywehere important.
MESH->worldMatrix = MESH->rotation_Matrix * MESH->translation_Matrix;
cBuffer.final = MESH->worldMatrix * viewMatrix * projectionMatrix;
cBuffer.Rotation = MESH->rotation_Matrix;
}
The position and rotations are both set in the editor.
I didn't mean to get all hasty but minus a point for trying to show a video on what I'm talking about. Just doesn't make sense.
#17 Moderators - Reputation: 13558
Posted 09 August 2012 - 07:08 AM
* Every D3D function that returns a HRESULT expects you to capture that return value and check for success. There's a lot of missing error checking in your code, where if something is going wrong, you'll continue on anyway and silently ignore the error.
* Whenever something unknown/weird is happening in D3D, change your device creation code to add in the debug-device flag -- this will print out error messages if you're doing anything suss with the API.
* If the above don't catch an error, then launch PIX and use it to capture a frame from your game. You can then inspect what's happening during the offending draw-call, such as whether there's actually any vertices in your vertex buffer, or if pixels are being rejected by back-face culling, etc...
#18 Members - Reputation: 328
Posted 09 August 2012 - 08:44 AM
#20 Members - Reputation: 328
Posted 09 August 2012 - 09:33 AM






