Need help:D

Started by
4 comments, last by xxxyyyzzz 16 years, 3 months ago
First of all :) sorry for my bad English . I have several obj files and have to import the files so that the relative position between objects remains the same. I'll post some code maybe it helps: void drawModel(GLMmodel *mod,char *obj) { if (!mod) { mod=glmReadOBJ(obj); glmUnitize(mod); glmFacetNormals(mod); glmVertexNormals(mod,90); } glmDraw(mod,GLM_SMOOTH | GLM_TEXTURE); } Than there is the Display function: :| But both objects are at coordinate(0,0):-s Why? void Display(void) { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glPopMatrix(); drawModel(mod1,"x2.obj"); drawModel(mod2,"x3.obj"); glPushMatrix(); glFlush(); glutSwapBuffers(); }
Advertisement
glPushMatrix() needs to come before glPopMatrix(), and you have it backwards. Also, you're not applying any transformations, so the objects don't move.

You might do something like this:

void Display() {    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);    glLoadIdentity();    glPushMatrix();        // Move the first object two units along the negative Z-axis        glTranslatef(-2, 0, 0);        drawModel(mod1,"x2.obj");    glPopMatrix();    glPushMatrix();        // Move the second object two units along the positive Z-axis        glTranslatef(2, 0, 0);        drawModel(mod2,"x3.obj");    glPopMatrix();    glFlush();    glutSwapBuffers();}
that`s not it, there should be an easier way.
I understand I can translate/rotate/scale my objects but my 3ds max scene is composed of several objects: a head,eyes,hat etc.I exported them as obj files and when I import them in opengl I want the position of each obj to remain the same as it was in 3ds:D
and there is a way because I've seen it a couple of months ago :-s too bad I haven't seen the code:D
The models positions should be relative to the origin when they were made. The only thing I can think of causing this is that maybe 3ds max centers models before exporting as obj? I can't think why they would do this, maybe you are modelling each model individually as centered and them position them as separate models in max rather then as geometry? Sorry if that doesn't make sense but I don't have much experience with how max works.
Answer:P :

Because of glmUnitize(mod) the objects are shown in the same point.

This topic is closed to new replies.

Advertisement