C4 Engine
C4 Engine API Documentation

class ModelRegistration

Defined in:  C4Models.h
The ModelRegistration class contains information about an application-defined model type.
Definition

class ModelRegistration : public MapElement<ModelRegistration>

Member Functions
ModelRegistration::GetModelType Returns the registered model type.
ModelRegistration::GetModelFlags Returns the model registration flags.
ModelRegistration::GetModelName Returns the model name.
ModelRegistration::GetResourceName Returns the name of the model resource.
Constructor

ModelRegistration(ModelType type, const char *name, const char *path, uint32 flags = 0,

ControllerType cntrlType = 0, int32 propCount = 0, const PropertyType *propTypeArray = nullptr);

Parameters
type The model type.
name The model name.
path The resource name for the model.
flags Flags pertaining to the model type.
cntrlType The model's default controller type.
propCount The number of default property types.
propTypeArray A pointer to an array containing the model's default property types.
Description
The ModelRegistration class is used to register an application-defined model type so that instances of the model can easily be cloned and so that they can be placed in a world using the World Editor. The act of instantiating an ModelRegistration object automatically registers the corresponding model type. The model type is unregistered when the ModelRegistration object is destroyed.

Each model type must have a unique 32-bit identifier which is usually a four-character code. This identifier is specified in the type parameter in the model registration, and is later passed to the Model::GetModel function to create instances of the specific type of model.

The name parameter specifies the human-readable model name that is displayed in the World Editor. If the kModelPrivate flag is specified in the flags parameter, then the name parameter may be nullptr.

The path parameter specifies the name of the model resource corresponding to the model type.

The flags parameter is optional and assigns special properties to the model registration. It can be a combination (through logical OR) of the following constants.
kModelPrecache Precache the model resource.
kModelPrivate Do not display the model type in the World Editor.
If the kModelPrivate flag is specified, then the model type cannot be placed in a world using the World Editor, but the Model::GetModel function still produces instances of the model.

The cntrlType parameter is optional and identifies the type of controller that should be automatically assigned to a model of the registration's type when it is placed in a world using the World Editor. The type of the controller specified should be registered using the ControllerRegistration class so that the controller's settings are accessible in the World Editor. The default value of 0 means that no controller is assigned.

The propCount and propTypeArray parameters are optional and identify the number and type of properties that should be automatically assigned to a model of the registration's type when it is placed in a world using the World Editor. The types of the properties specified should be registered using the PropertyRegistration class so that each property's settings are accessible in the World Editor. The data referenced by the propTypeArray parameter must persist for the lifetime of the model registration—it is not copied.
Base Classes
MapElement<ModelRegistration> Used internally by the World Manager.
See Also

Model