Sign in to follow this  

lib3ds little problem

This topic is 3597 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

Hello! I'm new to lib3ds, but I've menaged somehow to overcome pointers etc. etc.... the only thing that doesn't seem to work is animation of the object. Maybe someone could help me? void displaymodel() { checkkeys(); glPushMatrix(); glScalef(0.16f,0.16f,0.16f); glRotatef(-90,1,0,0); glColor3f(1,0,0); lib3ds_file_eval(file,frame); frame++; if (frame==file->frames) frame=0; Lib3dsMesh *m; for (m=file->meshes;m!=0;m=m->next) { for(int p=0;p<m->faces;p++) { Lib3dsFace *f=&m->faceL[p]; glBegin(GL_TRIANGLES); glNormal3fv(f->normal); for (int i=0; i<3; ++i) { glVertex3fv(m->pointL[f->points[i]].pos); } glEnd(); } } glPopMatrix(); }

Share this post


Link to post
Share on other sites
mmhm. In 3dsmax I've created animation for one object - box01. Other are not transformed in any way.

I thought that lib3ds_file_eval will animate all objects...

Share this post


Link to post
Share on other sites
Sorry what I mean is - are you trying to do things like alter the model, or just move it about?

• If you are merely trying to move it about the safest thing to do is make the model in the modelling software, export it then do the animation from your software.
• If you are trying to move components of model about such as a human - the easiest is to load the limbs all separately and again put the movement instructions in your own software.

Exporting the animation information of a .max file into a .3ds one is problematic to start with. Then loading it into other software increases them several fold!

To really get to the bottom of it you need to look through the .3ds file your are loading and compare it with the specification, then see whether the animation bits are filled in, and if they are that your software is calling them (correctly).

Hope that helps.

Share this post


Link to post
Share on other sites
Mmmmhm. I'm trying to move it about, or at least in think so :-)
Maybe I will explain shortly what I'm trying to do, maybe this will claryfy my plans.

I created throught 3ds max 9 three meshes - sphere01, box01, cube01. Then I created animation. I pushed the auto key, and slid the slider to 100th frame. After that I moved the box01 along the x axis.

Then I've exported the whole thing to the .3ds file

I've got the glut application with lib3ds, that I found in sourceforge.net; so I've adopted the code of lib3ds. Oryginally it didn't work on my dev-cpp compiler that I'm using. After few changes everything seems ok.

Only if I made the box01 to move in my glut application it would be great.

I know I can do that with glTranslatef... but I want to learn how to do this by the lib3ds code....

Share this post


Link to post
Share on other sites
OK. Delving into the 3ds file format is a whole load of fun (read misery). As I said before the easiest means of using 3ds models is to make 'em, load 'em and move 'em about as whole entities. If you start playing with the verts et al you will need to know about how they (3ds files) really work.

As far as exporting animations is concerned, it's not that reliable. There are some pieces of demo software out on t'interweb for loading animations and some may even have source that you can step through.
- That said you're still best to do the manipulations from your own code, not load in previously made animations. Besides unless you made the animation in max-script, you've got loads more control when using cpp/ogl; and if you did copy over the code and correct the language differences!

For 3ds info there are bits and pieces on how to work with the file format on what use to be the Sparks website, now hosted at "area.autodesk.com". You should be able to get a copy of the file specifications online, which should help you interact with the objects you import.

Share this post


Link to post
Share on other sites
Mmmhm. OK. In that case it will be better probably to export data to .obj which is in human-readable format.

However I found solution to importing .3ds files at
http://csourcesearch.net/package/boson/0.10/boson-all-0.10/boson/bo3dsload.cpp

Thanks for help!

Share this post


Link to post
Share on other sites
http://www.flykestrel.com/Programming/3dsViewer.html

Its not pretty but it shows that you can view 3ds animations with lib3ds.
Lib3ds stores a copy of the mesh's verties and animates by moving the pivot point of each mesh.

for each mesh
{
Lib3dsNode* node=lib3ds_file_node_by_name(aniDat,meshName,LIB3DS_OBJECT_NODE);
Lib3dsObjectData *d=&node->data.object;
glMultMatrixf(&node->matrix[0][0]);
glTranslatef(-d->pivot[0], -d->pivot[1], -d->pivot[2]);

DrawMesh;
}

Share this post


Link to post
Share on other sites

This topic is 3597 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.

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