Test yourself in PB6.20b2. It works as expected when rotating the camera, but it does not work when rotating the node where the cam is attached to:
Code: Select all
#CameraSpeed = 0.05
InitEngine3D(#PB_Engine3D_NoLog,#PB_Compiler_Home+"Compilers\Engine3d.dll")
InitSprite()
InitKeyboard()
InitMouse()
ExamineDesktops():dx=800:dy=600
OpenWindow(0,0,0,dx,dy, " ConvertLocalToWorldPosition - [Esc] quit",#PB_Window_ScreenCentered|#PB_Window_BorderLess)
OpenWindowedScreen(WindowID(0), 0, 0, dx, dy, 0, 0, 0)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Models", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Packs/skybox.zip", #PB_3DArchive_Zip)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Scripts", #PB_3DArchive_FileSystem)
Parse3DScripts()
CreateCube(0, 5)
CreateMaterial(0, LoadTexture(0, "Dirt.jpg"))
CreateEntity(0, MeshID(0), MaterialID(0)):Pitch(EntityID(0),30,#PB_Relative|#PB_World)
SkyBox("stevecube.jpg")
CreateCamera(0,0,0,100,100)
CreateNode(0):AttachNodeObject(0,CameraID(0))
MoveCamera(0,0,0,30, #PB_Absolute)
Repeat
While WindowEvent():Wend
ExamineKeyboard():ExamineMouse()
If KeyboardPushed(#PB_Key_Right)
If KeyboardPushed(#PB_Key_LeftShift)
RotateCamera(0,0,0.1,0,#PB_Relative)
Else
RotateNode(0,0,0.1,0,#PB_Relative)
EndIf
ElseIf KeyboardPushed(#PB_Key_Left)
If KeyboardPushed(#PB_Key_LeftShift)
RotateCamera(0,0,-0.1,0,#PB_Relative)
Else
RotateNode(0,0,-0.1,0,#PB_Relative)
EndIf
ElseIf KeyboardPushed(#PB_Key_Up)
If KeyboardPushed(#PB_Key_LeftShift)
RotateCamera(0,-0.1,0,0,#PB_Relative)
Else
RotateNode(0,-0.1,0,0,#PB_Relative)
EndIf
ElseIf KeyboardPushed(#PB_Key_Down)
If KeyboardPushed(#PB_Key_LeftShift)
RotateCamera(0,0.1,0,0,#PB_Relative)
Else
RotateNode(0,0.1,0,0,#PB_Relative)
EndIf
ElseIf KeyboardPushed(#PB_Key_PageUp)
If KeyboardPushed(#PB_Key_LeftShift)
RotateCamera(0,0,0,0.1,#PB_Relative)
Else
RotateNode(0,0,0,0.1,#PB_Relative)
EndIf
ElseIf KeyboardPushed(#PB_Key_PageDown)
If KeyboardPushed(#PB_Key_LeftShift)
RotateCamera(0,0,0,-0.1,#PB_Relative)
Else
RotateNode(0,0,0,-0.1,#PB_Relative)
EndIf
EndIf
MouseX.f = -MouseDeltaX() * #CameraSpeed
MouseY.f = -MouseDeltaY() * #CameraSpeed
ConvertLocalToWorldPosition(CameraID(0),0,0,-30); <- GetZ() should be 0.0
debug StrF(GetX(),2)+","+StrF(GetY(),2)+","+StrF(GetZ(),2); <- GetZ() should be 0.0
;MoveEntity(0,GetX(),GetY(),GetZ(),#PB_Absolute)
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)