Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


scale first or translate? that is the big question.

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


         glScalef(scale, scale, scale);
         glTranslatef(x, y, z);
i believe im doing something wrong with not using loadidentity (because nehe uses it before every time a new glCallList is called within a loop in the display list tutorial). anyway, scaling and translating, or translating and scaling...either way i get incorrect resulsts. i want objects in the display list to appear at 3d coordinates i pass in. when Translated and scaled (in that order) i get something close, but the obects are rendered offset, some of them. when i scale and then translate, which seems to be the right order, then everything is clumped together near the origin. can anyone please help..?

Share this post

Link to post
Share on other sites
The object is scaled from 0,0,0.
So if you have a cube (1x1x1) at 2,2,2 pos.
After scale 2x2x2 it will be from 2,2,2 to 4,4,4.
You have to move it to the 0,0,0 point.
Then scale, and then translate.

For example: object at Lx,Ly,Lz pos. Scale Sx,Sy,Sz, target pos Tx,Ty,Tz.

I''m not sure, because I don''t use scale, because I want matrix ortonormal.

PS:sorry for my english

Share this post

Link to post
Share on other sites
From what I know, because of OpenGL's weird matrix convention, the transformations you apply are performed in reverse order. For example, if you want to scale, and then translate the object, in OpenGL you first have to apply translate and then scale.
glTranslate, glScale and glRotate functions multiply the transformations to the current MODELVIEW matrix. All these transformations are thus acummulated in the matrix. glLoadIdentity is the function that resets the matrix. If the MODELVIEW wasn't the identity matrix when you apply your transformations, then any transformation that was in it will also apply to your data.
Scale, as someone noted before, scales each vertex from point (0, 0, 0). Usually, when you scale, you want to scale in respect to the center of the object, so you should first translate the center of the object to the origin. Then scale. Then you want to translate it back where it was plus where you want it to be.
BUT since your objects in the call list should be defined around point (0, 0, 0)(the origin) anyway, so that this is the aproximate center of the object, then you don't have to perform the first step anymore. So you would just want to scale and then translate where you want it to be. So you would translate first and then scale... because of OpenGL's matrix order as noted before.
At least that's what i think. Didn't try it. Why doesn't it work when you apply glLoadIdentity?

[edited by - madu on September 24, 2003 8:05:03 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!