Advertisement Jump to content
Sign in to follow this  

About viewing and model transformation

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

i have two problems: 1.if i want to change the default viewpoint position,then when i draw some objects,i also take some model transformations(translate,rotate and scale and so on)the code like this: glLoadIdentity(); gluLookAt(......); // position (x,y,z) glTranslated(...); glRotated(....); drawobject1(); ..... glLoadIdentity(); gluLookAt(......);// the same position glTranslated(...); glRotated(....); drawobject2(); Is this code right? 2.the model transformation and view transformation are equivalent,but i read a lot of codes using default viewpoint position.if i want change the viewpoint instead of changing the model,is the following code right? glLoadIdentity(); gluLookAt(......); // position (x1,y1,z1) drawobject1(); // draw object1 ..... glLoadIdentity(); gluLookAt(......); // position (x2,y2,z2) drawobject2(); // draw object2 thanks

Share this post

Link to post
Share on other sites
1)It seems right; GL matrices are transposed respect standard math notation and the matrix multiplications are reversed accordingly (final result must be the same!)
The basic idea is to load the view matrix (camera, ortho, trackball,...) then apply the transformations as you have done.

2)The second question you posted can be used but it's more difficult!!! In practice you can use the matrix you want but the final result must be the same.
Yes, you can move your observer to 'simulate' an object position but this is not simple/usefull! It's more simple to say:

my observer is here -> LookAt
my object 1 is here -> translate1, rotate1
my object 2 is there -> translate2, rotate2

something like this

for each object{

I suggest you also to implement your own matrix math : you can find a lot of tutorials (google for matrix faq). And you can 'look at' the glu code provided in the Mesa library if you are interested (so you can see how OpenGL project the points you pass)

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!