Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - Mesh (Skeleton Animation)
;
; (c) 2002 - Fantaisie Software
;
; ------------------------------------------------------------
;
; Modified by DarkDragon for TomS
Define.f KeyX, KeyY, MouseX, MouseY
#RobotTexture = 0
#Robot = 0
If InitEngine3D()
Add3DArchive(#PB_Compiler_Home + "Examples/Sources/Data", #PB_3DArchive_FileSystem)
InitSprite()
InitKeyboard()
InitMouse()
If OpenWindow(0, #PB_Ignore, #PB_Ignore, 800, 600, "Test", #PB_Window_TitleBar)
If OpenWindowedScreen(WindowID(0), 0, 0, 800, 600, 1, 0, 0)
CreateCube(#Robot, 10.0)
LoadTexture(#RobotTexture, "clouds.jpg")
CreateMaterial(0, TextureID(#RobotTexture))
CreateEntity(#Robot, MeshID(#Robot), MaterialID(0))
CreateLight(0, RGB(0,0,255), 100.0, 50.0, 100.0)
LightSpecularColor(0, RGB(255, 0, 0))
CreateCamera(0, 0, 0, 100, 100)
CameraLocate(0, 50, 100, 100)
CameraLookAt(0, 0, 0, 0)
Repeat
WindowEvent()
ClearScreen(RGB(0, 0, 0))
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = -1
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = 1
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -1
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = 1
Else
KeyY = 0
EndIf
If KeyboardPushed(#PB_Key_PageUp)
RollZ = 3
Else
RollZ = 0
EndIf
If KeyboardPushed(#PB_Key_Add)
Frame.f+0.005
EndIf
EndIf
If ExamineMouse()
MouseX = -MouseDeltaX()/10
MouseY = -MouseDeltaY()/10
EndIf
RotateEntity(#Robot, 0.0, 1.0, 0.0, #PB_Relative)
RotateCamera(0, MouseY, MouseX, RollZ, #PB_Relative)
MoveCamera (0, KeyX, 0, KeyY)
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End