Sign in to follow this  
sakky

simple camera movement for demos

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 this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this