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.

Newcomers DBPro Corner / [DBPro] Camera Angle Issues

Author
Message
Oolite
19
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Middle of the West
Posted: 17th May 2006 22:18 Edited at: 17th May 2006 22:19
Hi

i'm having some trouble with my camera rotation, the camera should rotate around this box when i press the mouse button,
fine, it does that, but when i click, it positions the camera to a completely different angle and starts rotating from there,
i want it to keep the same angle when i click the mouse and then rotate from the same point, its really confusing rotating the camera this way.

Any Ideas on how to do this?
I have looked all over the forums, and its where i found this way of doing rotation, because my mouse will be used to do different things, not just rotate i need it to keep the angle before rotation else it will be extremely frustrating to use.


Cheers

Adam
D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 18th May 2006 03:44 Edited at: 18th May 2006 04:03
I looked at your code for a bit. I think I may have a solution for your problem. Just in case, I believe you wanted to be able to rotate your object along the X and Y axis by using the mouse to manipulate it. You also wanted the angle rotation to begin where it left off on the next mouse click and drag proceedure. Am I correct in saying so?

I had to extensively modify your mouse click routine to do this.

Here is my mods:



If you need an in depth explaination of how the code works, just let me know and I'll try and post one. Hopefully it works for you.

<Edit>

If you don't like how each axis is rotated by the mouse, you can just flip flop the angle variables. This way if you drag the mouse along X or Y, it rotates the opposite axis. I just made it effect the same axis as the mouse. My bag...
Oolite
19
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Middle of the West
Posted: 18th May 2006 11:37
Thank you, that works perfectly.

Sure explain away, i think i see what you are doing, but please, feel free.

Cheers Again
D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 19th May 2006 01:15
Before I explain what's going on with the code above, I want to quickly explain the mouse functions in DBPro.

If you don't already know, both mousex() and mousey() functions return the actual current position of the mouse. The mousemovex() and mousemovey() functions return the difference between the last position and the current position.

Keep that in mind. Here's my explaination:

I built the subroutine to work on a cartesian coordinate system. While the mouse click is zero, the mouse coordinates are constantly being stored in temporary variables, and the values would be updated according to mouse movement. These variables can be considered the origin or intersection (0,0) of the cartesian system once the mouse button is clicked. I'm speaking in terms of where the origin is and not the actual XY position of the mouse on the screen. From there the origin is compared to the new current position to see what direction the mouse has traveled since the spawning of the origin. If there is no difference, then do nothing with the object angle. If the value is less than the origin, then decrease the object angle by the difference. If the value is greater than the origin, then increase the object angle by the difference. In order to keep the object angle values from ever increasing or decreasing beyond 360 degrees, I limited their range from 0 to 360 with the wrapvalue() function. Once the mouse button is released, the angle variables retain there values until the next time the mouse button is pressed.

Wow, what a mouth full! Is this a satisfactory explaination?
I hope this helps you.
Oolite
19
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Middle of the West
Posted: 19th May 2006 12:19
nice one, yeah it registered!

There are some issues like when you rotate all the way around it inverts the way its rotating, but i understand it enough to fix it!

Cheers.
D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 19th May 2006 22:10
That's great. I'm glad I could be of assistance. I did't thoroughly test the code for stablity. Yeah, if you can fix it on your own, why not post the results of your work. This way others can see it too. It may help someone else with a project they might be working on. Just a suggestion. It's up to you.

Login to post a reply

Server time is: 2024-11-26 19:45:22
Your offset time is: 2024-11-26 19:45:22