----TUTORIAL 8---
Polygons
Collision Detection with Response You
will Need The NemoX engine Get it Here
download the Visual Basic Source code here
Summary
1.
InitEngine modification
2.
Collision Detection
Code
1. InitEngine modification
In this sub we will add one
Object for Drawing a SplashScreen picture during the Polygon buffering
process. To Perform that we have to allocate memory for a new Class
: cNemo_Screen it allows to draw over the Screen at any portion.
InitEngine()
Dim SCREEN2D As
cNemo_Screen
Sub InitEngine()
Set Nemo =
New NemoX
Set Tool =
New cNemo_Tools
Set SCREEN2D =
New cNemo_Screen
If
Not (Nemo.INIT_ShowDeviceDLG(Form1.hwnd))
Then
End
End
If
Nemo.BackBuffer_ClearCOLOR = RGB(125, 125, 125)
Nemo.Set_ViewFrustum 10, 16500, 3.14 / 4
Nemo.Set_light True
Nemo.Camera_set_EYE Tool.Vector(0, 15, 0)
SCREEN2D.Add_Texture App.Path + "\Splash.jpg"
'Here is the code for Screen Splashing
Nemo.Begin3D
SCREEN2D.DrawTextureScreenScaled 0
Nemo.End3D
End
Sub
|
2. Collision Detection Code
In this code we're checking if
a collision occurs between the player camera postion and Our world
Sub CheckCollision()
Dim
Dest As D3DVECTOR
If
Mesh.CheckCollisionSliding(Nemo.Camera_GetPosition, Dest, 20)
Then
Nemo.Camera_set_EYE Dest
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 detected mailMe
The Next: Tutorial 9 :Loading
3D studio Models The Previous:
Tutorial 7
:Adding More Polygons to our Scene
Tutorial Written on December, 22 th 2002 |