Jump to content
  • Advertisement
Sign in to follow this  
NMO

3ds format problem

This topic is 2259 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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;
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

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!