I don't know what is your request, but as i understand, you refer to orbitate and control the camera distance to the object. So, if is this, i use something like this:
Code: Select all
InitEngine3D(#PB_Engine3D_NoLog,#PB_Compiler_Home+"Compilers\Engine3d.dll"):InitSprite():InitKeyboard():InitMouse()
OpenWindowedScreen(OpenWindow(0,0,0,1024,768,"t",#PB_Window_BorderLess|#PB_Window_ScreenCentered),0,0,1024,768,1,0,0,#PB_Screen_WaitSynchronization)
CreateLight(0,$EEEEEE,-1,1,6,#PB_Light_Point)
CreateCamera(0,0,0,100,100)
CreateNode(0,0,0,0):AttachNodeObject(0,CameraID(0))
MoveCamera(0,0,0,4,#PB_Absolute)
CreateMaterial(0,0,$55DDEE)
CreateSphere(0,1,3,2)
CreateEntity(0,MeshID(0),MaterialID(0),0,0,0)
Procedure.b KeyEdgeDetection(key.a)
Static pka.a
If KeyboardPushed(key);<-if current key status is PUSHED
If pka=0:pka=key:ProcedureReturn 1:EndIf;<-if previous key status was NOT PUSHED, then assign previous state to current one, and EXIT.
ElseIf pka=key;<-else (if previous key status was PUSHED and current key status is NOT PUSHED):
pka=0;:ProcedureReturn -1;<-set previous key status to NOT PUSHED.
EndIf
ProcedureReturn 0
EndProcedure
Macro TeclaControldecamara(tecla=LeftControl)
If KeyEdgeDetection(#PB_Key_#tecla#); <- inicia control camara
pasocam.f=0.01:pasocamincr.f=0.001
ElseIf KeyboardReleased(#PB_Key_#tecla#)
ElseIf KeyboardPushed(#PB_Key_#tecla#); <- mover el punto de vista
;para desplazar la camara hacia delante, atras, arriba, abajo, izq o der
If mdx Or mdy Or mdz
If mmb.b
MoveNode(0,mdx,-mdy,0,#PB_Local); o MoveCamera(0,mdx,-mdy,0,#PB_Local) o MoveCamera(0,mdx,-mdy,0,#PB_Relative)
Else
RotateNode(0,-mdy*60,-mdx*60,0,#PB_Relative)
If mdz
MoveCamera(0,0,0,-mdz,#PB_Relative)
EndIf
EndIf
ElseIf KeyboardPushed(#PB_Key_Add)
MoveCamera(0,0,0,-pasocam,#PB_Relative)
pasocam+pasocamincr
ElseIf KeyboardPushed(#PB_Key_Subtract)
MoveCamera(0,0,0,pasocam,#PB_Relative)
pasocam+pasocamincr
ElseIf KeyboardPushed(#PB_Key_Pad8)
MoveCamera(0,0,pasocam,0,#PB_Relative)
pasocam+pasocamincr
ElseIf KeyboardPushed(#PB_Key_Pad2)
MoveCamera(0,0,-pasocam,0,#PB_Relative)
pasocam+pasocamincr
ElseIf KeyboardPushed(#PB_Key_Pad6)
MoveCamera(0,pasocam,0,0,#PB_Relative)
pasocam+pasocamincr
ElseIf KeyboardPushed(#PB_Key_Pad4)
MoveCamera(0,-pasocam,0,0,#PB_Relative)
pasocam+pasocamincr
ElseIf KeyboardPushed(#PB_Key_Pad1)
RotateNode(0,0,-0.5,0,#PB_Relative)
ElseIf KeyboardPushed(#PB_Key_Pad7)
RotateNode(0,0,0.5,0,#PB_Relative)
ElseIf KeyboardPushed(#PB_Key_Pad3) Or lmb.b
RotateNode(0,0,0,-0.5,#PB_Relative)
ElseIf KeyboardPushed(#PB_Key_Pad9) Or rmb.b
RotateNode(0,0,0,0.5,#PB_Relative)
EndIf
EndMacro
Repeat:While WindowEvent()<>#PB_Event_None:Wend
ExamineMouse():ExamineKeyboard()
lmb.b=MouseButton(#PB_MouseButton_Left):rmb.b=MouseButton(#PB_MouseButton_Right):mmb.b=MouseButton(#PB_MouseButton_Middle)
mdx.f=MouseDeltaX()/200:mdy.f=MouseDeltaY()/200:mdz.f=MouseWheel()/20
TeclaControldecamara()
EndIf
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)