Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / orbit camera

Author
Message
Dimension
20
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 2nd Sep 2010 02:26
I've been working on a function that will orbit the camera around a certain point using a little math. It seems to work except I don't think I am getting the proper rotating the x angle of the camera right. Does anybody know how to fix this so that it gets the proper angle of x?

Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 2nd Sep 2010 03:50
why waste your time on this, you can simply make GDK handle all the math for you


simply call this function every loop, parameters are: pivot x/y/z are the pivot (the center), fYaw is the angle to turn (angle Y), fPitch is the angle to pitch (up - down), fDistance is the distance from the pivot

very simple and works fine

hope this helps, sorry if you know this but want to use some math

Dimension
20
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 2nd Sep 2010 06:54
This way is more flexible that code is basically what I have now. Also when using that it seems to rotate the camera upside down somehow. I also need flexibility because I'm trying to add this to other parts of my program.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 3rd Sep 2010 04:48
I dont know what you are talking about, but for the upside down thing, im not sure, but maybe changing dbPitchCameraDown to dbPitchCameraUp would suit you better..

and as i see, this simple function does all what you need, and in case you dont know, there already is a camera pointing function (dbPointCamera)

Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 3rd Sep 2010 20:22 Edited at: 3rd Sep 2010 20:25
Mouse X and Y coordinates are not angles, they are pixels on the screen. You cannot receive a correct result if you are directly using pixels as angles. Especially not if you are trying to calculate all three coordinates from the 2D position of the mouse.

I can imagine a program which determines the pitch of the camera from how far the mouse is from the center of the screen, but then you need at least to calculate a difference or a percentage ratio between the mouse coordinates and the center of the screen, and apply that percentage to the camera angle.

The other possibility is that you will use the mouse movement values (movement, not current coordinates) as the speed of the camera. Then you can use dbMouseMoveX() and dbMouseMoveY() as "angles" (well, sort of), which determine how much you need to turn the camera to the side or up/down in the current loop. But the camera position or distance from the selected point will not be directly determined from the mouse coordinates, only the speed of rotation.

If you explain more exactly how you wish the camera to react to mouse movement, maybe I can help you more with correcting that function. Keep in mind that it is possible to implement orbiting using only Dark GDK functions and very little math, as Hassan demonstrated.

Login to post a reply

Server time is: 2024-11-19 18:26:38
Your offset time is: 2024-11-19 18:26:38