Blitz3D MD3 Library Tutorial on how to use it.
Introduction:
Welcome to my Small Tutorial/Example of my MD3 Library for Blitz.
At the moment it is just a commented piece of code which is the sample program.
I will add to this as I develop it.
the Library commands are in THIS!! colour.
Tutorial Code:
; Md3 loader Sample Code, this loads in a specified file and then show the selected anims
; Include The MD3 Lib.
Include "MD3LIB.BB"
; Setup a 3d screen
Graphics3D 640,480,32,2
AppTitle "Md3LIB sample Code."
; Load in a md3 model.
doom.md3model=md3_open("doom")
; Setup the camera and backbuffer
Global camera=CreateCamera()
SetBuffer BackBuffer()
CameraRange camera,1,1000
PositionEntity camera,0,0,-100
light=CreateLight()
; set the anim to be the first anim for the model
md3_setanim(doom,0)
; Start of a while loop which loop untill escape is pressed
While Not KeyDown(1)
; The following four lines check if the left mouse button is pressed, then if it is increases which anim is shown.
If MouseHit(1)
fg=fg+1
If fg>24 fg=0
; increases the frame.
md3_setanim(doom,fg)
EndIf
; if the right mouse button is pressed it toggles between the fast an smooth interpolation method.
If MouseHit(2) quick=Not quick
; Frames per second Calculation Code
curTime = MilliSecs()
If curTime > checkTime Then
checkTime = curTime + 1000
curFPS = fpscounter
fpscounter = 0
Else
fpscounter = fpscounter + 1
End If
; Code that rotates the model and can move the camera around
If KeyDown(203) TurnEntity doom\entity,0,-1,0
If KeyDown(205) TurnEntity doom\entity,0,1,0
If KeyDown(200) TurnEntity doom\entity,0,0,1
If KeyDown(208) TurnEntity doom\entity,0,0,-1
If KeyDown(12) MoveEntity camera,0,0,-5
If KeyDown(13) MoveEntity camera,0,0,5
; these following 3 lines turn on/off Wireframe,VSync, and Antialias.
If KeyHit(17) WireFrame enable : enable=Not enable
If KeyHit(33) sync=Not sync
If KeyHit(31) AntiAlias alias : alias=Not alias
UpdateWorld(curfps)
; Checks if the boolean Quick is set to false, if it is, it uses the normal, update routine, if not, it uses the Faster update.
If quick=False
md3_updateanim(doom)
Else
md3_qupdateanim(doom)
End If
; Render the world.
RenderWorld()
Text 0,0,"FPS:"+curfps
; Flip the screen with Vsync or not vSync dependant on the Sync Varible
Flip sync
Wend