Sign in to follow this  

[Assimp/Direct3D] 3DS Models

Recommended Posts


I have a problem with Assimp and Direct3D.

I tried with OBJ and 3DS models. The OBJ models has loaded without problems but some 3DS models loaded wrong.

Like this:



This is de code for the load of the model.

const struct aiScene* scene = NULL;

Assimp::Importer importer;

scene = importer.ReadFile( fileName,
aiProcess_CalcTangentSpace |
aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices |
aiProcess_SortByPType |
aiProcess_CalcTangentSpace |
aiProcess_JoinIdenticalVertices |
aiProcess_GenSmoothNormals |
aiProcess_LimitBoneWeights |
aiProcess_RemoveRedundantMaterials |

aiMesh** meshes = scene->mMeshes;

UINT numVertices = 0;
UINT numFaces = 0;
UINT inx_vertex = 0;
UINT inx_faces = 0;
UINT startIndex = 0;

for(int nMeshes = 0; nMeshes < scene->mNumMeshes; nMeshes++)
numVertices += meshes[nMeshes]->mNumVertices;
numFaces += meshes[nMeshes]->mNumFaces;

VERTEX::PositionNormalColor *vertices = new VERTEX::PositionNormalColor[numVertices];
USHORT *indices = new USHORT[numFaces*3];

for(int nMeshes = 0; nMeshes < scene->mNumMeshes; nMeshes++)
startIndex = inx_vertex;

for(int nVertex = 0; nVertex < meshes[nMeshes]->mNumVertices; nVertex++)
vertices[inx_vertex].X = meshes[nMeshes]->mVertices[nVertex].x;
vertices[inx_vertex].Y = meshes[nMeshes]->mVertices[nVertex].y;
vertices[inx_vertex].Z = meshes[nMeshes]->mVertices[nVertex].z;
vertices[inx_vertex].Nx = meshes[nMeshes]->mNormals[nVertex].x;
vertices[inx_vertex].Ny = meshes[nMeshes]->mNormals[nVertex].y;
vertices[inx_vertex].Nz = meshes[nMeshes]->mNormals[nVertex].z;
vertices[inx_vertex].Color = D3DCOLOR_XRGB(255,255,255);


for(int nFaces = 0; nFaces < meshes[nMeshes]->mNumFaces; nFaces++)
indices[inx_faces++] = meshes[nMeshes]->mFaces[nFaces].mIndices[0] + startIndex;
indices[inx_faces++] = meshes[nMeshes]->mFaces[nFaces].mIndices[1] + startIndex;
indices[inx_faces++] = meshes[nMeshes]->mFaces[nFaces].mIndices[2] + startIndex;

model->CreateModel(pDevice, numVertices, vertices);
model->SetIndices(pDevice, numFaces*3, indices);

someone can help me???


Share this post

Link to post
Share on other sites
Hi Ripiz,

Well, I have noticed that the nmbers of the vertices and faces are differents with respect to the viewer and if I modify the flags for the importer this numbers changes.

I don't understand this. :blink:

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this