Sign in to follow this  

Need help:D

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

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(); }

Share this post


Link to post
Share on other sites
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();
}

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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