I know exactly what you mean (the camera can even move by itself!!), I confirmed the method given above by amazing Comtois:
Code: Select all
; create a node that will handle camera
CreateNode(0)
; create a node that will handle pitch
CreateNode(1)
AttachNodeObject(0, NodeID(1)) ; attach pitchnode to the cameranode
AttachNodeObject(1, CameraID(0)) ; attach camera to the pitchnode
MouseX = 0
MouseY = 0
Repeat
Screen3DEvents()
If ExamineMouse()
MouseX - MouseDeltaX() * #CameraSpeed * 0.05
MouseY - MouseDeltaY() * #CameraSpeed * 0.05
EndIf
; this will cause any value to wrap around.
While MouseX > 180 : MouseX - 360 : Wend
While MouseX < -180 : MouseX + 360 : Wend
While MouseY > 180 : MouseY - 360 : Wend
While MouseY < -180 : MouseY + 360 : Wend
RotateNode(0, 0, MouseX, 0, #PB_Local) ; yaw: camera node
RotateNode(1, MouseY, 0, 0, #PB_Local) ; pitch: pitch node
MoveNode(0, KeyX, 0, KeyY, #PB_Local)
Debug StrF(MouseX) + " = " + StrF(NodeYaw(0))
Debug StrF(MouseY) + " = " + StrF(NodePitch(1))
This finally gives results I can work with, just don't exceed -180/+180 and you will get 100% accurate yaw/pitch/roll that does not break your custom rotations!
[update] made a simple wrapper that ensures the above is always true.
A big thanks Comtois, it's a little workaround but a great technique!
Are you sure however, you wish everyone to build this workaround? Perhaps a flag for "stable yaw pitch roll", I am just mumbling here but this gets too confusing for beginners..
Code: Select all
local y, p, r = game.camera:rotation()
game.camera:rotation(y + -glue.input.mouseDX() * 0.25, p + -glue.input.mouseDY() * 0.25, r)
(this is in lua) however that should also be what PureBasic is supposed to do, logical math.
[update]
If you use this method please don't use CameraYaw/CameraPitch/CameraRoll as they will return garbage, only get them from NodeYaw and NodePitch.