Pub.ColDet: Functions Types Modinfo Source  

ColDet Collision Library

Functions

Function SphereRayCollision:Int(center:Float Ptr,radius:Float,origin:Float Ptr,direction:Float Ptr,point:Float Ptr)
ReturnsTrue if collision.
DescriptionChecks for intersection between a ray and a sphere.
InformationCenter, radius define the sphere origin
Direction defines the ray
Point will contain point of intersection, if one is found.

Function SphereSphereCollision:Int(center1:Float Ptr,radius1:Float,center2:Float Ptr,radius2:Float,point:Float Ptr)
ReturnsTrue if collision.
DescriptionChecks for intersection between 2 spheres.
InformationPoint will contain the point of collision if one is found.

Types

Type TCollisionModel3D
DescriptionCollision Model.
InformationRepresents the mesh to be tested for collisions. It has to be notified of all triangles, via addTriangle(). After all triangles are added, a call to finalize() will process the information and prepare for collision tests. Call collision() to check for a collision.

Note: Transformations must not contain scaling.
Method addTriangle(x1:Float,y1:Float,z1:Float,x2:Float,y2:Float,z2:Float,x3:Float,y3:Float,z3:Float)
DescriptionAdds the coordinates of one of the model's triangles.
Method collision:Int(other:TCollisionModel3D,AccuracyDepth:Int=-1,MaxProcessingTime:Int=0,other_transform:Float Ptr=Null)
ReturnsTrue if a collision occurred.
DescriptionCheck For collision with another model.
Information
  • Do Not mix model types here.
  • MaxProcessingTime determines the maximum time in milliseconds To check For collision. If a rejection is Not found by that time, the Function will Return true.
  • AccuracyDepth is Not yet supported
  • other_transform allows overriding the other model's transform, by supplying an alternative one. This can be useful when testing a model against itself with different orientations.
Method finalize()
DescriptionAll triangles have been added, process model.
Method getCollidingTriangles:Int(t1:Float Ptr,t2:Float Ptr,bModelSpace:Int=True) ' tri1[9], tri2[9]
ReturnsTrue if triangles were returned.
DescriptionRetrieve the pair of triangles that collided.
InformationOnly valid after a call To collision() that returned true. t1 is this model's triangle and t2 is the other one. In case of ray or sphere collision, only t1 will be valid. The coordinates will be in _this_ model's coordinate space, unless ModelSpace is false, in which case, coordinates will be transformed by the model's current transform to world space.
Method getCollisionPoint:Int(point:Float Ptr,bModelSpace:Int=True) ' point[3]
ReturnsTrue if a point was returned.
DescriptionRetrieve the detected collision point.
InformationOnly valid after a call To collision() that returned true. The coordinates will be in _this_ model's coordinate space, unless ModelSpace is false, in which case, coordinates will be transformed by the model's current transform to world space.
Method rayCollision:Int(origin:Float Ptr,direction:Float Ptr,bClosest:Int=False,segmin:Float=0.0,segmax:Float=3.4e+38) ' origin[3], direction[3]
ReturnsTrue if a collision occurred.
DescriptionCheck For collision with the ray given in world space coordinates.
InformationgetCollidingTriangles() And getCollisionPoint() can be used To retrieve information about a collision. If closest If False, the first triangle that collides with the ray is used. Otherwise the closest one will be used. Closest triangle searching will slow the test considerably. The Default ray is a standard infinite ray. However, using segmin And segmax you can define a line segment along the ray.
Method SetTransform(matrix:Float Ptr) ' matrix[16]
DescriptionThe the current affine matrix For the model.
Information
The matrices used to describe model transformations are affine 4x4 matrices
which are D3D style, row major with translations in the 4th row.

1  2  3  4
5  6  7  8
9 10 11 12
13 14 15 16

The translation vector Tx,Ty,Tz is in elements 13,14,15

If you use the transposed scheme, which is:
1 5  9 13
2 6 10 14
3 7 11 15
4 8 12 16

With the translation vector in elements 13,14,15 you can use
this matrix without any conversion.

It is also important to note that the transformations should include
no scaling, as it disrupts the consistency of the collision model.
Method setTriangleNumber(num:Int)
DescriptionOptional: Optimization For construction speed if you know the number of triangles.
Method sphereCollision:Int(origin:Float Ptr,radius:Float) ' origin[3]
ReturnsTrue if a collision occurred.
DescriptionCheck For collision with the given sphere.
InformationgetCollidingTriangles() And getCollisionPoint() can be used To retrieve information about a collision.

Module Information

NamePub.ColDet
Version1.01
DescriptionColDet collision library wrapper
LicensePublic Domain
Authorgman
CreditPhotonEffect, author of ColDet. http://www.photoneffect.com/coldet/
History2006/7/14 - Initial Release
History2006/7/14 - Migrated to a DLL