Jump to content

  • Log In with Google      Sign In   
  • Create Account

3ds format problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 NMO   Members   -  Reputation: 216

Like
0Likes
Like

Posted 15 July 2012 - 11:39 AM

Hi!

I've written an OpenGL tool to visualize .3ds files. To import a 3ds file I use Assimp (http://assimp.sourceforge.net/). I use Blender to create example 3ds files. The problem is now that when I read a mesh from the .3ds file it's transformation matrix is always identity. However the coordinates of the vertices are in world space.
The source code to load a mesh looks like this.
m is always identity but i don't know why.

[source lang="cpp"]void recursive_render (const struct aiScene *sc, const struct aiNode* nd){ int i; unsigned int n = 0, t; struct aiMatrix4x4 m = nd->mTransformation; // update transform aiTransposeMatrix4(&m); glPushMatrix(); glMultMatrixf((float*)&m); // draw all meshes assigned to this node for (; n < nd->mNumMeshes; ++n) { const struct aiMesh* mesh = scene->mMeshes[nd->mMeshes[n]]; apply_material(sc->mMaterials[mesh->mMaterialIndex]); if(mesh->mNormals == NULL) { glDisable(GL_LIGHTING); } else { glEnable(GL_LIGHTING); } if(mesh->mColors[0] != NULL) { glEnable(GL_COLOR_MATERIAL); } else { glDisable(GL_COLOR_MATERIAL); } for (t = 0; t < mesh->mNumFaces; ++t) { const struct aiFace* face = &mesh->mFaces[t]; glBegin(GL_TRIANGLES); for(i = 0; i < face->mNumIndices; i++) { int index = face->mIndices[i]; if(mesh->mColors[0] != NULL) Color4f(&mesh->mColors[0][index]); if(mesh->mNormals != NULL) glNormal3fv(&mesh->mNormals[index].x); glVertex3fv(&mesh->mVertices[index].x); } glEnd(); } } // draw all children for (n = 0; n < nd->mNumChildren; ++n) { recursive_render(sc, nd->mChildren[n]); } glPopMatrix();}[/source]

Maybe someone could helpt.
Thanks!

Edited by NMO, 15 July 2012 - 12:53 PM.


Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS