simple camera movement for demos

Started by
1 comment, last by sakky 19 years, 8 months ago
Okay, I’m not too great with math so I need a little help. I’m making a demo that will need that mouse to move and rotate the objects. This is my algorithm. 1. Find center of window using client to screen conversion for mouse co-ordinates 2. Subtract the mouse co-ordinates from the center-of-window position (step 1) 3. Find the angle of the sum 4. Find magnitude of angle 5. Perform optional scalar on angle 6. Rotate world in the direction of the angle magnitude degrees Of I can use the Pythagorean Theorem in this algorithm 1. Find center of window using client to screen conversion for mouse co-ordinates 2. Subtract the mouse co-ordinates from the center-of-window position (step 1) 3. Calculate distance between points 4. Rotate world X by 1 / mouse X * magnitude 5. Rotate world Y by 1 / mouse Y * magnitude I’m trying to get 1 or -1 from the mouse co-ordinates and the screen position. If the sum of steps 1 and 2 are negative then -1 is used else 1 is used. Then the formula would be (-1 ? 1) * magnitude on the x and y planes. I think it would be better to make the origin every time the use clicks on the window. Then that position where they clicked is used as the origin in the distance formulas.
Take back the internet with the most awsome browser around, FireFox
Advertisement
Go to http://www.gametutorials.com, they have 4 tutorials on camera movement.
Author Freeworld3Dhttp://www.freeworld3d.org
Yes, I forgot to even look there, thank you! Although the tutorials are in the source code, they are pretty good. I haven't got the chance to read them yet, I've only downloaded them. I need to be a work in a half hour.

My method seems to work alright. Every time I click on the window the, the identity matrix is reset so you see the figure jump back. So I uses the GetTransformation method and mulitpled the all the rotation matricies with the result. Now it dosn't jump, but it keeps rotating as long as you have the mouse down. It looks pretty cool though when you move the mouse around in small circles. The shape looks like its dancing.
Take back the internet with the most awsome browser around, FireFox

This topic is closed to new replies.

Advertisement