----TUTORIAL 13---
Loading and
Rendering Quake 3 (.md3) Models You
will Need The NemoX engine Get it Here
download the Visual Basic Source code here
Summary
1.
InitEngine modification
2.
How to Load Quake 3 (.md3) Models
3.
Game Loop Modification
4.
Collision Detection
Code
1. InitEngine modification
In this tutorial we will use
New Classes cNemo_MD3 for managing Quake 3 Model..
For objects declaration we use
vb classic class declaration for 3 Objects:
Dim Q3model
As cNemo_MD3
InitEngine()
Sub InitEngine()
Set Nemo =
New NemoX
Set Tool =
New cNemo_Tools
Set Mesh =
New cNemo_Mesh
Set Q3model =
New cNemo_MD3
Set KAMERA =
New cNemo_Camera
Set KEY =
New cNemo_Input
If Not
(Nemo.INIT_ShowDeviceDLG(Form1.hWnd))
Then
End
End If
Nemo.BackBuffer_ClearCOLOR = RGB(80, 80, 80)
Nemo.Set_ViewFrustum 10, 5000, 3.14 / 4, 1.01
Nemo.Set_light True
KAMERA.Set_YRotation 45
KAMERA.Set_EYE Tool.Vector(200, 50, -250)
End
Sub
|
2.
Loading Quake 3 (.md3) Models
Sub Load_Meshes()
Q3model.LoadModel App.Path + "\reaper\"
Q3model.Set_Position -100, 100, 0
Q3model.Set_Scale 4, 4, 4
Q3model.Set_LowerAnimation LEGS_IDLE
Q3model.Set_UpperAnimation TORSO_STAND
End Sub
LoadModel
|
3.
Game Loop Modification
Sub gameLoop()
Nemo.Set_EngineRenderState D3DRS_ZENABLE, 1
Nemo.Set_light 1
Do
Call GetKey
DoEvents
CheckCollision
Nemo.Begin3D
Mesh.Render
Q3model.Render
Nemo.Draw_Text "FPS:" + Str(Nemo.Framesperseconde), 5, 10, &HFFFFFFFF
Nemo.End3D
Loop Until KEY.Get_KeyBoardKeyPressed(NEMO_KEY_ESCAPE)
Call EndGame
End Sub
|
4. Collision Detection Code
In this code we're checking if
a collision occurs between the player camera postion and Our world and 3DS
meshes
Sub CheckCollision()
Dim Dest As D3DVECTOR
If Mesh.CheckCollisionSliding(KAMERA.Get_position, Dest, 40) Then
KAMERA.Set_EYE Dest
End If
If Q3model.BBox.CheckCollisionSliding(KAMERA.Get_position, Dest, 40) Then
KAMERA.Set_EYE KAMERA.Get_LastPosition
End If
End Sub
We use this function:CheckCollisionSliding
PointVec : the point coordonates to test
RetPos: A Point (D3DVECTOR) to receive the collision
response
Radius: The radius of the Sphere to be collided with Mesh
Polygons
|
Here is a screenshot for our tutorial project
download the Visual
Basic Source code here
See you in the next Tutorial.....sincerly Polaris..Don't
forget Any Bugs detect
The Next: Tutorial 14 :Basic
Particle System Effect
The Previous:
Tutorial 12
:Loading and Rendering Quake 2 (.md2) Models
Tutorial Written on April, 28 th 2003 by Polaris:
johna_pop@yahoo.fr |