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.

DarkBASIC Professional Discussion / Rotating Camera and Retaining Old Values

Author
Message
Rims Flames
12
Years of Service
User Offline
Joined: 5th Apr 2014
Location:
Posted: 15th Aug 2014 16:58
Hello Community,

I have this basic code for rotating the camera when i press right mouse button, but when i want to click to rotate the camera it goes instantly where i am pressing on the screen. I want for the camera to move just when i am moving the mouse after clicking the right mouse button. Instead the camera moves instantly where the pointer is.

Thank You!



Rims Flames
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 15th Aug 2014 17:22


Rims Flames
12
Years of Service
User Offline
Joined: 5th Apr 2014
Location:
Posted: 15th Aug 2014 17:39
Hey TheComet,

I didn't meant this. I meant that when i press right click, and move the mouse i want to move the camera from its old position to the new position. I don't want when clicking on a part of the screen for the camera to instantly rotate to that part.

Rims Flames
JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 15th Aug 2014 17:57 Edited at: 15th Aug 2014 18:00
Rims Flames, I think I understand what you're wanting. Its known as STATES. You have to design a state or what some call it, a conditional system. ( Think of a STATE or FLAG as a Boolean [ True|False].)

Example : If the loop detects the right mouse button is in the down position, then it would set the flag or STATE to a one. If not it would set it to a zero.

Then in the camera code, IF it detects that you have a 1, THEN it would be ready for X and Y input from the mouse, otherwise, X and Y from the mouse wouldn't do anything if that flag or state is not set as a 1.

However, once that DOWN flag is a 1, then you would use the X and Y mouse movements ALSO as a state. ( If mouse moves X, then set it as a flag or state as 1 ) then from there it can know if it needs to move the mouse or not.

This solves several problems. It also allows you more control over what the mouse does to your camera.
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 15th Aug 2014 20:59 Edited at: 15th Aug 2014 21:13
Something like this?



666GO†O666
Rims Flames
12
Years of Service
User Offline
Joined: 5th Apr 2014
Location:
Posted: 15th Aug 2014 21:40
No not really. Look, if my camera is looking at a corner and i am placing my cursor on the other corner, the camera will point instantly to that corner. I want to drag the camera to rotate it to that respective corner. I have an example on how unreal engine has its camera rotation. Really I don't know how to explain it more detailed

https://www.youtube.com/watch?v=I8WBF4AyAX4

A BIG Thank You!

Rims Flames
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 15th Aug 2014 22:56
You want to click and drag the mouse to rotate? That's what my first snippet does.

Rims Flames
12
Years of Service
User Offline
Joined: 5th Apr 2014
Location:
Posted: 15th Aug 2014 22:58
I will put up a video with my problem tomorrow and i will show what i meant

Rims Flames
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 16th Aug 2014 01:26
Hi there
@Rims Flames
What I can see in the video at the direcction you pointed out , the camera moves free like flying, but you rotate it only when you right-click. Most programs do it like that instead of rotating camera by pressing left/right cursor. Something like this:



Cheers.

I'm not a grumpy grandpa
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 16th Aug 2014 04:28
So you also wanted the camera to move its position?

(I used your code and changed it, Chafari.)



666GO†O666
Rims Flames
12
Years of Service
User Offline
Joined: 5th Apr 2014
Location:
Posted: 16th Aug 2014 11:17
Thank You Chafari this is exactly what i was looking for!

Rims Flames

Login to post a reply

Server time is: 2026-07-05 17:32:49
Your offset time is: 2026-07-05 17:32:49