Back to main page

Model_Shape

Back to model interface

The model's collection of shapes is a persistent database of 3D shapes.

The model editor let you handle this data in a way that is useful for creating compound collision shapes in the physics engine.

The X, Y and Z axis make an orthogonal normalized axis system.

Do not use it for scaling since the physics engine do not allow it.

Use the radius, points and half dimensions to define the size of a shape.

Shape types:

Box = 0

The box is defined by half width, half height and half depth.

Sphere = 1

The sphere is defined by radius.

StaticPlane = 2 (Can't be placed in models because it is infinite)

Cylinder = 3

The cylinder is defined by half width, half height and half depth.

Capsule = 4

The capsule is defined by radius and half height.

Cone = 5

The cone is defined by radius and half height.

HeightField = 6 (Can't be placed in models because it use a non persistent buffer)

Compound = 7 (Can't be placed in other compounds because of non recursive programming languages)

ConvexHull = 8

The convex hull is defined by the collection of points

It is useful for manual convex decomposition of shapes that are otherwise hard to approximate.

int Model_Shape_Create_InSB(int Model, int ShapeType);

Model is a valid model and the name in the string buffer is a "SimpleString" in model format specification.

Returns the index to the new shape in Model.

void Model_Shape_Delete(int Model, int ShapeIndex);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Removes the shape in Model at ShapeIndex and fills the hole with the last shape.

void Model_Shape_Delete_PreserveOrder(int Model, int ShapeIndex);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Removes the shape in Model at ShapeIndex and fills the hole by shifting every shape with a higher index.

int Model_GetNumberOfShapes(int Model);

Model is a valid model.

Returns the number of shapes in Model.

void Model_Shape_SwapOrder(int Model, int ShapeIndexA, int ShapeIndexB);

Model is a valid model, 0 <= ShapeIndexA < number of shapes in Model and 0 <= ShapeIndexB < number of shapes in Model.

Swaps place between the shapes at ShapeIndexA and ShapeIndexB in Model.

void Model_Shape_SetName_InSB(int Model, int ShapeIndex);

Model is a valid model, 0 <= ShapeIndex < number of shapes in Model and the name in the string buffer is a "SimpleString" in model format specification.

Sets the name of the shape in Model at ShapeIndex to the content of the string buffer.

void Model_Shape_GetName_OutSB(int Model, int ShapeIndex);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Writes the name of the shape in Model at ShapeIndex to the string buffer.

void Model_Shape_SetPos(int Model, int ShapeIndex, float X, float Y, float Z);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Sets the object space position of the shape in Model at ShapeIndex to (X,Y,Z).

void Model_Shape_GetPos_OutV3(int Model, int ShapeIndex);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Writes the object space position of the shape in Model to (X1,Y1,Z1).

void Model_Shape_SetXAxis(int Model, int ShapeIndex, float X, float Y, float Z);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Sets the X axis of the shape in Model at ShapeIndex to (X,Y,Z).

void Model_Shape_GetXAxis_OutV3(int Model, int ShapeIndex);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Writes the X axis of the shape in Model to (X1,Y1,Z1).

void Model_Shape_SetYAxis(int Model, int ShapeIndex, float X, float Y, float Z);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Sets the Y axis of the shape in Model at ShapeIndex to (X,Y,Z).

void Model_Shape_GetYAxis_OutV3(int Model, int ShapeIndex);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Writes the Y axis of the shape in Model to (X1,Y1,Z1).

void Model_Shape_SetZAxis(int Model, int ShapeIndex, float X, float Y, float Z);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Sets the Z axis position of the shape in Model at ShapeIndex to (X,Y,Z).

void Model_Shape_GetZAxis_OutV3(int Model, int ShapeIndex);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Writes the Z axis of the shape in Model to (X1,Y1,Z1).

void Model_Shape_SetShapeType(int Model, int ShapeIndex, int ShapeType);

Usable shape types:

ShapeType_Box = 0

ShapeType_Sphere = 1

ShapeType_Cylinder = 3

ShapeType_Capsule = 4

ShapeType_Cone = 5

ShapeType_ConvexHull = 8

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Sets the shape type of the shape in Model at ShapeIndex to ShapeType.

int Model_Shape_GetShapeType(int Model, int ShapeIndex);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Returns the shape type of the shape in Model at ShapeIndex.

void Model_Shape_SetCollisionType(int Model, int ShapeIndex, int CollisionType);

Collision type 0 is default and used for physics. All other numbers are defined by the user for particle emitters, triggers, climbing boxes...

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Sets the shape type of the shape in Model at ShapeIndex to CollisionType.

int Model_Shape_GetCollisionType(int Model, int ShapeIndex);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Returns the collision type of the shape in Model at ShapeIndex.

void Model_Shape_SetRadius(int Model, int ShapeIndex, float Radius);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Sets the radius of the shape in Model at ShapeIndex to Radius.

float Model_Shape_GetRadius(int Model, int ShapeIndex);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Returns the radius of the shape in Model at ShapeIndex or -1 as error code.

void Model_Shape_SetHalfWidth(int Model, int ShapeIndex, float HalfWidth);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Sets the half width of the shape in Model at ShapeIndex to HalfWidth.

float Model_Shape_GetHalfWidth(int Model, int ShapeIndex);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Returns the half width of the shape in Model at ShapeIndex or -1 as error code.

void Model_Shape_SetHalfHeight(int Model, int ShapeIndex, float HalfHeight);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Sets the half height of the shape in Model at ShapeIndex to HalfHeight.

float Model_Shape_GetHalfHeight(int Model, int ShapeIndex);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Returns the half height of the shape in Model at ShapeIndex or -1 as error code.

void Model_Shape_SetHalfDepth(int Model, int ShapeIndex, float HalfDepth);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Sets the half depth of the shape in Model at ShapeIndex to HalfDepth.

float Model_Shape_GetHalfDepth(int Model, int ShapeIndex);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Returns the half depth of the shape in Model at ShapeIndex or -1 as error code.

int Model_Shape_GetNumberOfPoints(int Model, int ShapeIndex);

The points are used for defining the bounds of convex hulls.

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Returns the number of points in Model at ShapeIndex.

int Model_Shape_InsertPoint(int Model, int ShapeIndex, float X, float Y, float Z);

Model is a valid model and 0 <= ShapeIndex < number of shapes in Model.

Inserts the point (X,Y,Z) into the shape's collection of points.

void Model_Shape_DeletePoint(int Model, int ShapeIndex, int PointIndex);

Model is a valid model, 0 <= ShapeIndex < number of shapes in Model and 0 <= PointIndex < number of points in the shape at ShapeIndex.

Removes the point at PointIndex and fills the hole with the last point.

void Model_Shape_DeletePoint_PreserveOrder(int Model, int ShapeIndex, int PointIndex);

Model is a valid model, 0 <= ShapeIndex < number of shapes in Model and 0 <= PointIndex < number of points in the shape at ShapeIndex.

Removes the point at PointIndex and fills the hole by shifting every point with a higher index.

void Model_Shape_SwapPointOrder(int Model, int ShapeIndex, int PointIndexA, int PointIndexB);

Model is a valid model, 0 <= ShapeIndex < number of shapes in Model, 0 <= PointIndexA < number of points in the shape at ShapeIndex and 0 <= PointIndexB < number of points in the shape at ShapeIndex.

Swaps place between the points at PointIndexA and PointIndexB in the shape at ShapeIndex in Model.

void Model_Shape_SetPoint(int Model, int ShapeIndex, int PointIndex, float X, float Y, float Z);

Model is a valid model, 0 <= ShapeIndex < number of shapes in Model and 0 <= PointIndex < number of points in the shape at ShapeIndex.

Moves the point at PointIndex in the shape at ShapeIndex in Model to (X,Y,Z).

void Model_Shape_GetPoint_OutV3(int Model, int ShapeIndex, int PointIndex);

Model is a valid model, 0 <= ShapeIndex < number of shapes in Model and 0 <= PointIndex < number of points in the shape at ShapeIndex.

Writes the position of the point at PointIndex in the shape at ShapeIndex in Model to (X1,Y1,Z1).

void Model_Shape_SetPointDir(int Model, int ShapeIndex, int PointIndex, float X, float Y, float Z);

The Bullet physics engine dilates convex hulls to better know the direction of an impact and thereby know the direction of the force to apply at the point. To compensate for the dilation, the corners can be eroded by being placed at a certain distance from each connected plane. How much to compensate is stored in the model as a direction but it is not a normalized so that sharp corners can compensate more than dull corners.

Model is a valid model, 0 <= ShapeIndex < number of shapes in Model and 0 <= PointIndex < number of points in the shape at ShapeIndex.

Directs the point at PointIndex in the shape at ShapeIndex in Model to (X,Y,Z).

void Model_Shape_GetPointDir_OutV3(int Model, int ShapeIndex, int PointIndex);

Get the direction of erosion that can be used to compensate for dilation of convex hulls in physics engines. Convex hulls generated with the model editor should include the direction data automatically. When giving the corner points to the physics engine, you can then use the direction multipled by how much you want to compensate divided by the scale of the instance so that compensation is done relative to world space. With Bullet physics engine, you can compensate 0.04 divided by the scale factor but it will slightly affect line intersections too unless you base your intersections on another data structure.

Model is a valid model, 0 <= ShapeIndex < number of shapes in Model and 0 <= PointIndex < number of points in the shape at ShapeIndex.

Writes the direction of the point at PointIndex in the shape at ShapeIndex in Model to (X1,Y1,Z1).