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 / Mouse drag camera movement

Author
Message
Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 28th Jan 2013 16:30 Edited at: 28th Jan 2013 16:30
Hey everybody,

Like the title said, I'm building a level editor and got my camera's all setup. I have the movement of the different camera modes all working with hotkeys but now I wish to implement camera movement by simply holding the middle mouse and drag, like in worldcraft, mapscape, 3D world studio, etc.

I figured I record the camera movement and reposition the camera but it doesn't really work as I'd like to. The camera jumps around and isn't very accurate...

Here's a snippet:


Any help is much appreciated!

Regards Sph!nx
www.mental-image.net
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 28th Jan 2013 16:57
have a search in code snippets subforum, somebody posted camera movement code which is suitable for level editor

Le Verdier
14
Years of Service
User Offline
Joined: 10th Jan 2012
Location: In the mosh-pit
Posted: 28th Jan 2013 17:56
Maybe this...

Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 28th Jan 2013 20:12 Edited at: 28th Jan 2013 20:13
I've searched the snippets board but couldn't find anything I need...

Regards Sph!nx
www.mental-image.net
29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 28th Jan 2013 21:24
This is how I've done this. Use the middle mouse button to pan the camera and you can use the scroll wheel to zoom (if that's something you want to do).



one of these days I'll come up with a better signature
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 28th Jan 2013 22:17 Edited at: 28th Jan 2013 22:18
29 games has sort of got it but the panning is moving up(-+) and or right(-+) of the viewing angle. Easy way to do this is get the up and right vectors of the camera and scale them by the amount you want to move. Then add these scaled vectors to the camera position (or offset position if the camera always zooms to a point in space then add it to that position) and that's it!
Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 10th Feb 2013 22:57
I'm a bit late with the reply, but had to say thanks. I've devised a method similar to 29 games suggestion. It works like a charm.

Regards Sph!nx
www.mental-image.net

Login to post a reply

Server time is: 2026-07-07 13:39:26
Your offset time is: 2026-07-07 13:39:26