Skip to main content
gamedev.net
🔒 Locked

about viewing

Started by sunmozhou Sep 1, 2005 at 10:12 AM 0 replies 400+ views
Original Post
sunmozhou
sunmozhou
i have two problems: 1."the viewing transformation commands must be called before any modeling transformation are performed,so the modeling transformation take effect on the objects first" i think that if the viewing transformation take the effect first,the object coodinates will change into eye coodinate,so the original position will be changed,so the command glRotated(...)will lead to the wrong result,but the glTranslated(...)and glScaled(...)is right. is it right? 2.i know how to use the pair glPushMatrix()/glPopMatrix();but i don't know how to work?for example: glPushMatrix(); glTranslated(...); glPushMatrix(); glTranslated(...); glRotated(...); glPopMatrix(); glPopMatrix(); please explain the stack how to work in detail thanks!
Gorax
Gorax
1. When setting up your viewpoint, translate, rotate, then scale. Don't forget that the translated point must be the inverse of the point you're trying to get to, since you have to move the world away from that point to get it in the middle.

2. Forget trying to visualise it in any way other than boxes, 'cause they're the easiest to picture. You have your box (matrix), on the top of your stack of boxes (matrix stack), you add another box to the stack (push the stack down, add another matrix), then when you're done with the new top box, you remove it (pop the matrix). The boxes get stacked directly on top of eachother (same rotation, scale, and translation), so anything you do with the top one will affect the next one you push onto the stack, but it's only the top box that changes, so you can completely destroy the top box, but the one underneath it will be fine.

Now thing of the objects you render as apples that go in the boxes. If you want to move one apple without moving all of the others, you just put an extra box on the stack, then throw the apple in that, then move the apple and box around as necessary. If you need the apple centered at some point, you can move the box, then put the apple in it.

That's obviously over-simplified, but it should help to clear it up...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.