View Full Version : Camera System and View Stationary Objects
I have a small problem I am trying to work out in regard to OpenGL.
I have a simple camera system which uses gluLookAt for its basic functionality. This allows me to move the mouse and the view will move around world.
However, what I would like to do is create a cube object and have it in the bottom right of the view constantly. Even when the view is changed using the mouse.
Does anyone have any hints/tips or pseudo code for this? Could someone give me an explanation of how to achieve this?
Put the cube in a way it is in the position you want using a identity modelview-matrix.
After you draw your world, do a LoadIdentity.
This will put the cube where it should be. There is the problem you have to place it very carefully (projection matrix still applies) but it should not be a problem.
Got the idea?
Ok I have my desired effect using:
1) Update Camera
2) Draw Scene
3) Push and Load Identity
4) Draw Cube
And I have worked out how to rotate the cube too http://www.opengl.org/discussion_boards/ubb/smile.gif
After Loading Identity:
[3) Scale if required]
Quick question: I thought I would have had to rotate and then translate? (So rotation was around origin and then translate away) Why did this make the cube spin around in a large circle?
Thanks very much for you help.
[3) Scale if required]...
The forum rules (blah blah and blah) pretend me to discurage you to do this http://www.opengl.org/discussion_boards/ubb/wink.gif
Quick question: I thought I would have had to rotate and then translate? (So rotation was around origin and then translate away) Why did this make the cube spin around in a large circle?...
Because, of curse, you translate on a new coordinate system which is defined as a rotation of the original one.
So, if your coordinate system looked like '+' and you rotate it 45 degrees counter clockwise you get 'X'. Now, in '+', the +y axis is "straight up". After the rotation, the new +y axis is the upper left part of the 'X', so it will translate in that direction.
Think about it a while and you'll figure out that the natural conseguence of this is a cube that rotates as you described.
Instead, if you first place the cube where you need it and then rotate it you get the right effect. Think like the rotation is getting "amplified" by successive transforms.
EDIT: big typo fixed.
[This message has been edited by Obli (edited 07-23-2003).]
OK I just about understood your explanation and then looked at the Red Book again. There is actually q really good explanation in that - well my brain seems to understand it http://www.opengl.org/discussion_boards/ubb/smile.gif
The reference is (3rd edition): Page 106 Viewing and Modelling Transformations until page 110.
Hope that helps some other people http://www.opengl.org/discussion_boards/ubb/smile.gif
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.