I was wondering how you can achieve an always centered mouse when implementing a freelook or mouse look camera.
This works with equivalent B3D code but not with OpenB3D. Somehow it locks the mouse controls while trying to do cursor centering..
Framework Openb3d.B3dglgraphics
Import Brl.Random
Graphics3D 800, 600, 0, 2
light=CreateLight()
camera = CreateCamera()
CameraRange camera, .1, 1000
For i = 1 To 100
cube = CreateCube()
PositionMesh cube, Rnd(100), 0, Rnd(100)
Next
PositionEntity light,-500,-500,-500
PointEntity light, cube
MoveMouse 400,300
While Not KeyDown(KEY_ESCAPE)
UpdateWorld
RotateEntity camera, EntityPitch(camera) + MouseYSpeed()/2, EntityYaw(camera) - MouseXSpeed()/2, 0
If KeyDown(KEY_S) Then MoveEntity camera, 0, 0, -.1
If KeyDown(KEY_W) Then MoveEntity camera, 0, 0, .1
If KeyDown(KEY_A) Then MoveEntity camera, -.1, 0, 0
If KeyDown(KEY_D) Then MoveEntity camera , .1 , 0 , 0
MoveMouse 400,300
RenderWorld
Flip True
Wend
End
|