Back to main page

Model

Go to bone child interface

Go to shape child interface

Go to part child interface

Go to vertice child interface

Most of these methods are for advanced users. Beginners only need to look at Model_LoadFromFile_InSB since models can be made in the editor and deleting is done automatically when the engine is closed.

int Model_LoadFromFile_InSB(void);

The string buffer must contain an extensionless filename with less than 256 characters refering to a valid model file according to David's model format. ".dmf" is included automatically to the filename and any given extension will be ignored.

Returns the ID to the new model loaded with the string buffer's content as the filename. If loading fails, -1 is returned.

int Model_CreateEmpty(void);

Returns the ID to a new model without any parts or triangles.

Creates a new model.

int Model_CreateCopy(int SourceModel);

Vertex selection data is duplicated with this method.

SourceModel is a valid model.

Returns the ID to a new copy of SourceModel. -1 is returned if the precondition is broken.

Creates a copy of SourceModel.

void Model_CopyAllParts(int SourceModel, int DestModel);

Like Model_CreateCopy but without creating a new model so that you can merge 2 models and keep the global properties from the destination model.

SourceModel and DestModel are valid models and not the same.

Each part in SourceModel is duplicated to DestModel.

int Model_SaveToFile_InSB(int Model);

Vertex selection data is not stored in the model file.

Model is a valid model and the string buffer is a valid extensionless filename with less than 256 characters for the new model. ".dmf" is included automatically to the filename and any given extension will be ignored.

Saves Model to the filename given in the string buffer.

Returns 1 if saving worked and 0 if saving failed.

void Model_Delete(int Model);

Model is a valid model. All instances using the model must be deleted before it. The safest thing to do is to allocate all models when loading and let the engine release all models when terminating.

Removes Model.

void Model_SetFilterUsingName_InSB(int Model);

Valid filter names are "None" and "Alpha"

"None" don't use the alpha channel returned by the material shader.

"Alpha" is using the alpha channel returned by the material shader as opacity.

Model is a valid model and the string buffer contains a valid filter name.

Model's filter type is changed using the filter name in the string buffer.

void Model_GetFilterName_OutSB(int Model);

Model is a valid model.

Writes Model's filter name to the string buffer.

void Model_SetCullingUsingName_InSB(int Model);

Valid culling names:

"None" does not hide the model.

+ No extra CPU cost for visible items.

+ Allowing special vertex shaders to animate the model outside of the static bounds.

- Extra GPU cost for culling per triangle after the vertex shader.

"AABB" hides the model when it's axis aligned bounding box has all it's 8 points outside of any plane in the camera's view frustum.

+ The model may be completely off center.

+ It gives a tight bound for for long axis aligned items like doors and light poles.

+ Any axis system is accepted for the instances.

- The CPU cost is about twice as much as the radius method.

"Radius" hides the model if the sphere from the object space center is outside of any plane in the camera's view frustum.

+ It costs less CPU time than the AABB method and is therefor good for small items.

- The model must be close to (0,0,0) to give a tight bound.

- Only orthogonal axis systems are accepted because the radius is measured in object space and converted to world space by multiplying with the length of the longest axis. Allowing tilting of a sphere would take more time than using AABB.

Model is a valid model and the string buffer contains a valid culling name.

Model's culling method is changed using the culling name in the string buffer.

void Model_GetCullingName_OutSB(int Model);

Model is a valid model.

Writes Model's culling name to the string buffer.

void Model_SetBoundMultiplier(int Model, float Multiplier);

The bound multiplier is used to scale any measured bounding shape from the center of the object space.

1.0 (default) will use the original bounding shape as it is measured for static models.

1.2 will increase the size of any bounding shape with 20% to give more room for animation.

Model is a valid model.

Sets Model's bound multiplier to Multiplier.

float Model_GetBoundMultiplier(int Model);

Model is a valid model.

Returns the bound multiplier from Model.

float Model_GetBoundingSphereRadius(int Model);

Multiply the result with the bound multiplier to get the radius used for culling by the engine when radius culling is used.

Model is a valid model.

Returns the measured radius from Model.

void Model_GetBoundingBoxMinimum_OutV3(int Model);

Multiply the result with the bound multiplier to get the bound used for culling by the engine when AABB culling is used.

Model is a valid model.

Writes the minimum values of Model's measured bounding box.

void Model_GetBoundingBoxMaximum_OutV3(int Model);

Multiply the result with the bound multiplier to get the bound used for culling by the engine when AABB culling is used.

Model is a valid model.

Writes the maximum values of Model's measured bounding box.

int Model_GetNumberOfParts(int Model);

Model is a valid model.

Returns the number of parts in model. -1 is returned if the precondition is broken.