# simple camera movement for demos

This topic is 5220 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
Go to http://www.gametutorials.com, they have 4 tutorials on camera movement.

##### Share on other sites
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.

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633768
• Total Posts
3013747
×