Camera Panning Using Mouse

Blitz3D Forums/Blitz3D Programming/Camera Panning Using Mouse

RustyKristi(Posted 2015) [#1]
Hi, I was wondering how would I go about in panning my camera using mouse so the object retains its view like 2D panning.

I'm doing something like this:

If MouseDown(2) Then 
  MoveEntity(camPivot, MouseXSpeed()/2,MouseYSpeed()/2,0)


I would just like the screen to pan X and Y


Matty(Posted 2015) [#2]
Use translateentity rather than moveentity.

If it was an rts I'd detect when the mouse is near the edge of the screen.

How do you want it to behave?


RustyKristi(Posted 2015) [#3]
Thanks Matty. Basically I'm trying to do something very similar to Blender's mouse panning (Hold Shift + Middle Mouse Drag). I haven't thought about the limitation yet.

Also, how do you pan it smoothly like in Blender?


Matty(Posted 2015) [#4]
Ok. Detect when relevant buttons are held down (easy bit) and set a flag on indicating you want to pan 'pan mode on/off'

If in pan mode translate the camera in the relevant direction by an amount proportional to the distance moved by the mouse raised to the power 'm'. You will need to play around with the values until you get a smooth feel you and your users are happy with.


Edit:
Move distance = k * abs ( mousemovement ) ^ m


RustyKristi(Posted 2015) [#5]
Thanks, working ok now. That translateentity really did the trick too!