I'm not that experienced with 3d programming yet, so maybe there's a simple solution to my problem. Maybe it's rendered far away somewhere outside my frustum even. The model I'm trying to render is simple, and has one aiMesh and 24 vertices.
My shaders take pos, texCoord, normal and tangents. I also have a light that illuminates the whole texture. The shader is rendered with DrawIndexed(indexCount, 0, 0). I can provide some more code if necessary.
Any ideas?
This is the code is use for loading the model with Assimp:
[source lang="cpp"]struct VertexType{ XMFLOAT3 position; XMFLOAT2 texture; XMFLOAT3 normal;};struct Mesh{ ID3D11Buffer* vertexBuffer; ID3D11Buffer* indexBuffer; Texture* texture; int indexCount;};bool Model::LoadModel(ID3D11Device* device, std::string filename){ HRESULT result;Assimp::Importer importer;const aiScene* scene = importer.ReadFile(filename, aiProcess_Triangulate | aiProcess_MakeLeftHanded | aiProcess_JoinIdenticalVertices | aiProcess_SortByPType | aiProcess_JoinIdenticalVertices | aiProcess_GenSmoothNormals | aiProcess_LimitBoneWeights | aiProcess_RemoveRedundantMaterials | aiProcess_OptimizeMeshes | aiProcess_GenUVCoords | aiProcess_TransformUVCoords);if(!scene){ MessageBoxA(nullptr, importer.GetErrorString(), "Error", MB_OK); return false;}meshes.reserve(scene->mNumMeshes);for( unsigned int m=0; m<scene->mNumMeshes; ++m ){ aiMesh* aiMesh = scene->mMeshes[m]; if(!aiMesh->HasNormals() || !aiMesh->HasTextureCoords(0)) { MessageBox(NULL, L"Model is missing normals or texture coordinates.", L"Error", MB_OK); return false; } Mesh mesh; D3D11_SUBRESOURCE_DATA vertexData, indexData; int vertexCount = aiMesh->mNumVertices; vector<VertexType> vertices(vertexCount); for(unsigned int i=0;i < (unsigned)vertexCount;++i) { vertices[i].position = XMFLOAT3(aiMesh->mVertices->x, aiMesh->mVertices->y, aiMesh->mVertices->z); vertices[i].normal = XMFLOAT3(aiMesh->mNormals->x, aiMesh->mNormals->y, aiMesh->mNormals->z); vertices[i].texture = XMFLOAT2(aiMesh->mTextureCoords[0][i].x, aiMesh->mTextureCoords[0][i].y); } mesh.indexCount = aiMesh->mNumFaces*3; vector<unsigned int> indices(aiMesh->mNumFaces); for (unsigned int i = 0; i < aiMesh->mNumFaces;++i) { const aiFace& Face = aiMesh->mFaces[i]; assert(Face.mNumIndices == 3); indices.push_back(Face.mIndices[0]); indices.push_back(Face.mIndices[1]); indices.push_back(Face.mIndices[2]); } int materialid = aiMesh->mMaterialIndex; aiMaterial* mat = scene->mMaterials[materialid]; aiString szPath; char diffuseName[150]; //diffuse texture if(AI_SUCCESS == aiGetMaterialString(mat, AI_MATKEY_TEXTURE_DIFFUSE(0), &szPath)) { strcpy(diffuseName, "../../Media/md5/"); strcat(diffuseName, szPath.data); } else { strcpy(diffuseName, "DEFAULTTEX"); } if(!(mesh.texture = LoadTexture(device, diffuseName))) { MessageBox(NULL, L"Could not load texture", L"Error", MB_OK); return false; }// Directx 11 code for creating vertex and index buffers etc[/source]
Edit: Removed tangents and some other code that was just there for testing.
Edited by Corvwyn, 08 October 2012 - 04:43 AM.






