I've try to add a zoom function but i have an auto rotation around the Z axis, is it a bug ?
And there is a limitation about the texture size, do you know a work around to avoid that ?
Code: Select all
EnableExplicit
UseJPEGImageDecoder()
UsePNGImageDecoder()
UseTGAImageDecoder()
Define.i w,h,d,MouseX.f,MouseY.f,file$=Trim(ProgramParameter(0)),Engine3Ddll$,ok,ev
Define.i tick, LB, RB
Engine3Ddll$=GetCurrentDirectory() + "Engine3D.dll"
If FileSize(Engine3Ddll$) = -1
Engine3Ddll$=#PB_Compiler_Home + "Compilers\Engine3D.dll"
ElseIf FileSize(Engine3Ddll$) = -1
MessageRequester("Attention","Engine3D.dll is missing.",#PB_MessageRequester_Warning)
End
EndIf
file$=OpenFileRequester("Open Picture 360",GetCurrentDirectory(),"*.*",0)
If file$
ok=InitEngine3D(#PB_Engine3D_DebugLog,Engine3Ddll$)
If ok=0
Debug "Problem with 3D"
MessageRequester("Attention","Problem with 3D.",#PB_MessageRequester_Warning)
End
EndIf
ok=ok+InitSprite()
If ok=0
Debug "Problem with sprites"
MessageRequester("Attention","Problem with sprites.",#PB_MessageRequester_Warning)
End
EndIf
ok=ok+InitKeyboard()
If ok=0
Debug "Problem with keyboard"
MessageRequester("Attention","Problem with keyboard.",#PB_MessageRequester_Warning)
End
EndIf
ok=ok+InitMouse()
If ok=0
Debug "Problem with mouse"
MessageRequester("Attention","Problem with mouse.",#PB_MessageRequester_Warning)
End
EndIf
If ok <> 0
If ExamineDesktops()
OpenWindow(0, 0, 0, DesktopWidth(0), DesktopHeight(0),"Panorama: Zoom = mousewheel or UP/DOWN, Rotation Z = Left Button/Rigth button",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If OpenWindowedScreen(WindowID(0),0,0,DesktopWidth(0), DesktopHeight(0),0,0,0,#PB_Screen_SmartSynchronization)
CreateCamera(0,0,0,100,100)
CameraFOV(0,90)
Add3DArchive(GetPathPart(file$),#PB_3DArchive_FileSystem)
;TODO Problems with big texture
CreateMaterial(0,LoadTexture(0,file$))
DisableMaterialLighting(0,#True)
MaterialFilteringMode(0,#PB_Material_Trilinear)
RotateMaterial(0,180,#PB_Material_Fixed)
CreateSphere(0,-10,32,32)
CreateEntity(0,MeshID(0),MaterialID(0))
;-Node because there something wrong without node when we make a zoom
CreateNode(0, 0, 0, 0)
AttachNodeObject(0, CameraID(0))
Repeat
Repeat
ev = WindowEvent()
Until ev = 0
If ExamineMouse()
Mousex=-MouseDeltaX()/4.0
Mousey=-MouseDeltaY()/4.0
tick=MouseWheel()
LB=MouseButton(#PB_MouseButton_Left)
RB=MouseButton(#PB_MouseButton_Right)
;zoom with mouse
If tick > 0
MoveCamera(0,0,0,-0.1, #PB_Relative)
ElseIf tick < 0
MoveCamera(0,0,0,0.1, #PB_Relative)
EndIf
;Debug CameraDirectionX(0,#PB_Absolute)
; To avoid auto rotation aound the Z axis: a BUG ?
If LB <> 0
RotateNode(0,0,0,-0.5, #PB_Relative)
EndIf
If RB <> 0
RotateNode(0,0,0,0.5, #PB_Relative)
EndIf
EndIf
If ExamineKeyboard()
; zoom with keyboard
If KeyboardPushed(#PB_Key_Up)
MoveCamera(0,0,0,-0.1, #PB_Relative)
ElseIf KeyboardPushed(#PB_Key_Down)
MoveCamera(0,0,0,0.1, #PB_Relative)
EndIf
EndIf
RotateNode(0, MouseY, MouseX, 0, #PB_Relative)
;RotateEntity(0, MouseY, MouseX, 0, #PB_Relative);
;RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
;
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
EndIf
EndIf
EndIf
EndIf
Mesa.