Example. Here I use only
QCube()(create a cube..). Don't ask me what else the
librarys does, I don't use it...
This is a result of 2 minutes of reading through the code..
As he (Erlend) say at the top of the source:
Best way to learn/understand is to test and modify
Code: Select all
;Example for the QMesh Lib.
;Best way to learn/understand is to test and modify, so enjoy......
; Erlend "Preacher" Rovik
;Simplified to show QCube() by olejr
;textures are in the original QMesh archive..
image.s="qmesh_texture.jpg"; remember sizes 64*64 128*128 etc.
earth.s="earth.jpg"
cube.s="cube.jpg"
#CameraSpeed = 1
DefType.f KeyX, KeyY, MouseX, MouseY
If InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
If OpenWindow(0,0,0,300,300,#PB_Window_SystemMenu,"Example")
OpenWindowedScreen(WindowID(), 0, 0, 300,300, 0, 0, 0)
;These 3 lines are for createing the Cube
QCube()
QObject(5)
CreateEntity(5, MeshID(5), CreateMaterial(5, LoadTexture(5,cube)))
; Then setup Camera and put it in place
CreateCamera(0, 0, 0, 100, 100)
CameraLocate(0,0,0,20)
Repeat
;Everything here is for rotating mesh (cube)/ Moving Camera
ClearScreen(0, 0, 0)
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = #CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = #CameraSpeed
Else
KeyY = 0
EndIf
EndIf
If ExamineMouse()
MouseX = -(MouseDeltaX()/10)*#CameraSpeed/2
MouseY = -(MouseDeltaY()/10)*#CameraSpeed/2
EndIf
RotateEntity(5, 0.4, 0.4, 0.4)
RotateCamera(0, MouseX, MouseY, RollZ)
MoveCamera (0, KeyX, 0, KeyY)
;Here we render (draw) the world
RenderWorld()
FlipBuffers()
Delay(3)
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
EndIf