Author Message

Hi,

The culling changes if your observer walk across a triangle.  In other word, the sign of the scalar
product of the two vectors will change (or one vector will be (0 0 0) ).

Which two vectors?  One is the normal of the triangle, the other is the difference between the
position of the observer and a given point in the triangle.  If you prefer, just, compute:

(px-tx)*nx  +  (py-ty)*ny  + (pz-tz)*nz

where P  (px, py, pz)  is the position of the observer
T (tx, ty, tz)   is a point in the triangle ( the mean of the three vertex, is fine)
N (nx, ny, nz)  is the normal of the triangle.

If the computed result turns to zero or changes sign (with respect to the previously computed
result using the previous position of the observer), your observer has walked through the triangle.

Try to allow room for numerical imprecision, mainly if the vector  P-T   is almost parallel to the
vector N. If this can be a problem, define a thickness of the wall and if the observer is "in" the
thickness of the wall, put it back outside the wall. Having such a non zero wall thickness should
help to correct numerical imprecision (but may increase inadequately the number of triangles in

Hoping it may help,
Vanderghast, Access MVP

Quote:

> Hello there everyone, )
>   I am extremely new to DirectX, and also quite lost.. Using
> DirextX8/Direct3D, I had managed to build a nice little world and import
> some 3D houses and a landscape using 3DS. However, I don't like the fact
> that I can walk through walls.. ))   With that in mind I decided to do
> something about it.. Well, It didn't work out so good as you can see by the
> SAMPLE below.. The sample only detects the general area of the object. My
> goal is to find some way to actually detect the walls of  house, inside and
> out.. I am sure once I get past this one dilemma, gravity should be fairly
> easy(I hope)...  I just have no idea what to do from here.. If anyone could

> '####################################### SAMPLE
> #####################################

> Public Function DETECT_COLLISION(CAM_POS As D3DVECTOR, OBJ_POS As D3DVECTOR,
> _
> AREA As Integer) As Boolean

> If CAM_POS.X >= OBJ_POS.X - AREA And CAM_POS.X <= OBJ_POS.X + AREA _
>       And CAM_POS.Z >= OBJ_POS.Z - AREA And CAM_POS.Z <= OBJ_POS.Z + AREA _
>       Or CAM_POS.X >= OBJ_POS.X + AREA And CAM_POS.X <= OBJ_POS.X - AREA _
>       And CAM_POS.Z >= OBJ_POS.Z + AREA And CAM_POS.Z <= OBJ_POS.Z - AREA
> Then
>   DETECT_COLLISION = True
> Else
>   DETECT_COLLISION = False
> End If

> End Function

> '###########################################################################
> #########

Tue, 15 Feb 2005 19:19:36 GMT

 Page 1 of 1 [ 1 post ]

Relevant Pages