Collision shape
int CollisionShape_Create_Sphere(float Radius);
This collision shape can not use non uniform local scaling.
Radius ≥ 0.
Returns the ID to the new collision shape.
int CollisionShape_Create_Capsule(float Radius,float HalfHeight);
Radius ≥ 0 and HalfHeight ≥ 0.
Returns the ID to the new collision shape.
int CollisionShape_Create_Cone(float Radius,float HalfHeight);
Radius ≥ 0 and HalfHeight ≥ 0.
Returns the ID to the new collision shape.
int CollisionShape_Create_Box(float HalfWidth,float HalfHeight,float HalfDepth);
HalfWidth ≥ 0, HalfHeight ≥ 0 and HalfDepth ≥ 0.
Returns the ID to the new collision shape.
int CollisionShape_Create_Cylinder(float HalfWidth,float HalfHeight,float HalfDepth);
HalfWidth ≥ 0, HalfHeight ≥ 0 and HalfDepth ≥ 0.
Returns the ID to the new collision shape.
int CollisionShape_Create_StaticPlane(float NX,float NY,float NZ,float D);
The static plane shape is static and infinite.
This shape can not be used by compound shapes or dynamic rigid bodies because infinite shapes have no center of mass.
You can use one plane shape for every rigid body that need a plane shape by giving different transformations to the rigid bodies.
(NX,NY,NZ) is automatically normalized before it is used.
Given that (NX,NY,NZ) is already normalized:
P is inside of the plane if (P x (NX,NY,NZ)) < D.
P is on the plane if (P x (NX,NY,NZ)) = D.
P is outside of the plane if (P x (NX,NY,NZ)) > D.
Returns the ID to the new collision shape.
int CollisionShape_Create_HeightField_UsingCPUSurface(int CPUSurface,int UpDimension,int ChannelIndex,float HalfBoundHeight,bool FlipQuadEdges,bool DiamondPattern);
The height field shape is static because it is made out of flat triangles with no volume.
This shape can not be used by dynamic rigid bodies because concave triangle shapes can not collide with each other.
This shape can not be used by compound shapes because that would make the compound hard to serialize for no reason.
The returned collision shape have to be deleted before you can delete CPUSurface.
The CPU buffer in channel ChannelIndex may not contain values below -HalfBoundHeight / 2 or above HalfBoundHeight / 2 because that is the bound that you give the height field.
The height field is centered around the shape's origin and each quad between 4 values in the height map takes 1x1 length units. Set the local scaling for the collision shape if you need another resolution.
UpDimension should be an integer from 0 to 2 for X, Y or Z. For a regular ground, use 1 to use Y as the up axis.
CPUSurface is a valid CPU surface, 0 ≤ UpDimension ≤ 2 for [X,Y,Z], 0 ≤ ChannelIndex ≤ 3 for [Red, Green, Blue, Alpha] and HalfBoundHeight ≥ 0.
Returns the ID to the new height field collision shape using CPUSurface.
int CollisionShape_Create_Compound(void);
Compound shapes can not contain other compound shapes because that would make it hard for non recursive languages to get all children.
Any child given to the compound shape should be treated as if it was consumed by the compound since the child shape will inherit properties from the compound shape.
Returns the ID to an empty compound collision shape.
int CollisionShape_Create_ConvexHull(void);
Returns the ID to an empty convex hull collision shape.
int CollisionShape_Create_ConvexHull_FromModel(int Model,int DetailLevel,int Quality,float WeldingTreshold,bool UseVertexSelection);
See CollisionShape_ConvexHull_Optimize for more information about how the convex hull is optimized.
Model is a valid visual model, 0 ≤ DetailLevel ≤ 2 for low to high, 1 ≤ Quality ≤ 32 for extremely low to extremely high and WeldingTreshold > 0.0001.
Returns the ID to a new convex hull collision shape generated and optimized from the parts in Model that are visible at DetailLevel.
int CollisionShape_ConvexHull_MakeCopy(int OldConvexHullShape);
No optimization is made.
OldConvexHullShape is a valid convex hull collision shape.
Returns the ID to a new convex hull collision shape with the same points and local scaling as OldConvexHullShape.
void CollisionShape_Delete(int CollisionShape);
CollisionShape is a valid collision shape.
Removes CollisionShape and any of it's children that aren't used by anything else.
void CollisionShape_SetLocalScaling(int CollisionShape,float X,float Y,float Z);
The local scaling is used to scale the shape and tell the connected visual instance what size it should have. Before applying local scaling, the shape should overlap it's visual model in object space.
Any children will be affected recursively by the scale.
CollisionShape is a valid collision shape.
CollisionShape's local scaling is set to (X,Y,Z).
void CollisionShape_GetLocalScaling_OutV3(int CollisionShape);
CollisionShape is a valid collision shape.
Writes CollisionShape's local scaling to (X1,Y1,Z1) in the matrix buffer.
void CollisionShape_GetLocalInertiaPerMass_OutV3(int CollisionShape);
CollisionShape is a valid collision shape.
Returns CollisionShape local inertia per mass that is automatically calculated when needed.
void CollisionShape_Compound_AddChild(int CompoundShape,int ChildShape,float Pos_X,float Pos_Y,float Pos_Z,float XAxis_X,float XAxis_Y,float XAxis_Z,float YAxis_X,float YAxis_Y,float YAxis_Z);
CompoundShape is a compound collision shape, ChildShape is a non compound collision shape, ChildShape is not static or infinite and ChildShape is not a child of another compound shape.
Adds ChildShape to CompoundShape as a child shape as (Pos_X,Pos_Y,Pos_Z) with an axis system orthogonalized from (XAxis_X,XAxis_Y,XAxis_Z) and (YAxis_X,YAxis_Y,YAxis_Z).
void int CollisionShape_GetNumberOfChildren(int CollisionShape);
This method will tell if CollisionShape is a compound shape and if so, how many children it has.
Giving a non compound shape is allowed and will not give any error message but CollisionShape must be a collision shape.
CollisionShape is a valid collision shape.
Returns CollisionShape's number of children if CollisionShape is a compound shape, -1 if CollisionShape is not a compound shape and -2 together with an error message if CollisionShape is not a collision shape.
int CollisionShape_Compound_GetChild_OutM4(int CompoundShape,int Index);
CollisionShape is a compound collision shape, 0 ≤ Index < number of children in CompoundShape.
Writes the internal transformation of CompoundShape's child at Index that was given when the child shape was added to the compound shape to the matrix buffer.
Returns the ID of CompoundShape's child at Index. -1 is returned when a precondition was broken.
void CollisionShape_ConvexHull_AddPoint(int ConvexHullShape,float X,float Y,float Z);
Don't forget to call CollisionShape_ConvexHull_Optimize after adding all your points to the convex hull to remove duplicate and internal points.
ConvexHullShape is a convex hull shape.
Adds (X,Y,Z) to the end of ConvexHullShape.
int CollisionShape_ConvexHull_GetNumberOfPoints(int ConvexHullShape);
ConvexHullShape is a convex hull shape.
Returns the number of points in ConvexHullShape.
void CollisionShape_ConvexHull_GetPoint_OutV3(int ConvexHullShape,int Index);
ConvexHullShape is a convex hull shape and 0 ≤ Index < number of points in ConvexHullShape.
Writes the position of the point in ConvexHullShape at Index to (X1,Y1,Z1) in the matrix buffer.
void CollisionShape_ConvexHull_Optimize(int ConvexHullShape,int Quality,float WeldingTreshold);
Quality decide how many vertices that will be used in the convex hull. It is recomended to use a quality from 4 to 16 since less than 4 may remove too many vertices and more than 16 might slow down the physical simulation.
The welding that remove points at almost the same position works by keeping all vertices that are not within WeldingTreshold from a previously added vertice.
The method that remove internal points and reduce detail level works by generating 3 * Quality² normals by subdividing a normalized cube, taking the dot product of each point from the welded result and the current normal from the subdivided cube, and keeping the vertices with the minimum and maximum dot products who are more than 0.0001 from the closest result.
ConvexHullShape is a convex hull shape, 1 ≤ Quality ≤ 32 for extremely low to extremely high and WeldingTreshold > 0.0001.
Optimizes ConvexHullShape by removing unsignificant points.
float CollisionShape_GetRadius(int CollisionShape);
CollisionShape is a sphere or capsule.
Returns the radius from CollisionShape. Returns -1.0 if the precondition is broken.
float CollisionShape_GetHalfWidth(int CollisionShape);
CollisionShape is a box, cone or cylinder.
Returns the half width from CollisionShape. Returns -1.0 if the precondition is broken.
float CollisionShape_GetHalfHeight(int CollisionShape);
CollisionShape is a box, cone, cylinder or capsule.
Returns the half height from CollisionShape. Returns -1.0 if the precondition is broken.
float CollisionShape_GetHalfDepth(int CollisionShape);
CollisionShape is a box, cone or cylinder.
Returns the half depth from CollisionShape. Returns -1.0 if the precondition is broken.