Game object property container

API for game object property container

Namespace: dmGameObject
Include: #include <dmsdk/gameobject/gameobject_props.h>
TYPES
ComponentAddToUpdate Component add to update function. Only components ...
ComponentCreate Component create function. Should allocate all nec...
ComponentDeleteWorld Component world destroy function
ComponentDestroy Component destroy function. Should deallocate all ...
ComponentFinal Component finalize function. Should clean up as it...
ComponentGet A simple way to get the component instance from th...
ComponentGetProperty Callback for retrieving a property value of the co...
ComponentInit Component init function. Should set the components...
ComponentIterProperties Callback when iterating over the properties for a ...
ComponentNewWorld Component world create function
ComponentOnInput Component on-input function. Called when input is ...
ComponentOnMessage Component on-message function. Called when message...
ComponentSetProperties Set a property set for the component.
ComponentSetProperty Callback for setting a property value of the compo...
ComponentsFixedUpdate Component fixed update function. Updates all compo...
ComponentsPostUpdate Component post update function. The component stat...
ComponentsRender Component render function.
ComponentsUpdate Component update function. Updates all component o...
HCollection Gameobject collection handle
HComponent Opaque handle to component instance
HComponentInternal Opaque handle to internal representation of a comp...
HComponentType Component type handle. It holds the life time func...
HComponentWorld Opaque handle to a component world
HInstance Gameobject instance handle
HProperties Gameobject properties handle
HPropertyContainer Handle to a list of properties (gameobject_props.h...
HPropertyContainer Opaque handle to a list of properties
HPropertyContainerBuilder Opaque handle to a property container builder
HPrototype Gameobject prototype handle
HRegister Collection register.
HScript Script handle
HScriptInstance Script instance handle
ENUMS
CreateResult Create result enum
InputResult Input result enum
Playback Playback type enum
PropertyResult property result
PropertyType property types
PropertyValueType Type of property value
Result result enumeration
SceneNodePropertyType scene node property types
UpdateResult Update result enum
STRUCTS
struct ComponentAddToUpdateParams Parameters to ComponentAddToUpdate callback.
struct ComponentCreateParams Parameters to ComponentCreate callback.
struct ComponentDeleteWorldParams Parameters to ComponentDeleteWorld callback.
struct ComponentDestroyParams Parameters to ComponentDestroy callback.
struct ComponentFinalParams Parameters to ComponentFinal callback.
struct ComponentGetParams Parameters to ComponentGet callback.
struct ComponentGetPropertyParams Parameters to ComponentGetProperty callback.
struct ComponentInitParams Parameters to ComponentInit callback.
struct ComponentNewWorldParams Parameters to ComponentNewWorld callback.
struct ComponentOnInputParams Parameters to ComponentOnInput callback.
struct ComponentOnMessageParams Parameters to ComponentOnMessage callback.
struct ComponentOnReloadParams Parameters to ComponentOnReload callback.
struct ComponentSetPropertiesParams Parameters to ComponentSetProperties callback.
struct ComponentSetPropertyParams Parameters to ComponentSetProperty callback.
struct ComponentsPostUpdateParams Parameters for ComponentsPostUpdate callback.
struct ComponentsRenderParams Parameters to ComponentsRender callback.
struct ComponentsUpdateParams Parameters to ComponentsUpdate callback.
struct ComponentsUpdateResult Parameters to ComponentsUpdate callback.
struct ComponentTypeCreateCtx Context used when registering a new component type
struct InputAction Container of input related information.
struct m_BoolCount [type:int32_t] Number of items of type bool PropertyContainerBuilderParams
struct PropertyDesc Description of a property
struct PropertyOptions Property Options
struct PropertyVar property variant
struct SceneNode scene graph traversal node
struct SceneNodeIterator scene graph traversal iterator
struct SceneNodeProperty scene traversal node property
struct SceneNodePropertyIterator scene traversal node property
struct UpdateContext Update context
FUNCTIONS
uint32_t AcquireInstanceIndex(dmGameObject::HColleciton collection) Retrieve an instance index from the index pool for...
void AssignInstanceIndex(uint32_t index, dmGameObject::HInstance instance) Assign an index to the instance, only if the insta...
void ComponentOnReload(const dmGameObject::ComponentOnReloadParams& params) Called when the resource the component is based on...
void* ComponentTypeGetContext(HComponentType type) get the component type global context
uint32_t ComponentTypeGetTypeIndex(HComponentType type) Get the component type index. Used for with e.g. d...
void ComponentTypeSetAddToUpdateFn(HComponentType type, ComponentAddToUpdate fn) set the component add-to-update callback
void ComponentTypeSetChildIteratorFn(HComponentType type, FIteratorChildren fn) set the component child iterator function
void ComponentTypeSetContext(HComponentType type, void* context) set the component type global context
void ComponentTypeSetCreateFn(HComponentType type, ComponentCreate fn) set the component create callback
void ComponentTypeSetDeleteWorldFn(HComponentType type, ComponentDeleteWorld fn) set the world destroy callback
void ComponentTypeSetDestroyFn(HComponentType type, ComponentDestroy fn) set the component destroy callback
void ComponentTypeSetFinalFn(HComponentType type, ComponentFinal fn) set the component finalize callback
void ComponentTypeSetFixedUpdateFn(HComponentType type, ComponentsFixedUpdate fn) set the component update callback
void ComponentTypeSetGetFn(HComponentType type, ComponentGet fn) set the component get callback
void ComponentTypeSetGetPropertyFn(HComponentType type, ComponentGetProperty fn) set the component get property callback
void ComponentTypeSetHasUserData(HComponentType type, bool has_user_data) set the component type need for a per component instance user data
void ComponentTypeSetInitFn(HComponentType type, ComponentInit fn) set the component init callback
void ComponentTypeSetNewWorldFn(HComponentType type, ComponentNewWorld fn) set the new world callback
void ComponentTypeSetOnInputFn(HComponentType type, ComponentOnInput fn) set the component on-input callback
void ComponentTypeSetOnMessageFn(HComponentType type, ComponentOnMessage fn) set the component on-message callback
void ComponentTypeSetOnReloadFn(HComponentType type, ComponentOnReload fn) set the component on-reload callback
void ComponentTypeSetPostUpdateFn(HComponentType type, ComponentsPostUpdate fn) set the component post update callback
void ComponentTypeSetPrio(HComponentType type, uint16_t prio) set the component type prio order
void ComponentTypeSetPropertyIteratorFn(HComponentType type, FIteratorProperties fn) set the component property iterator function
void ComponentTypeSetReadsTransforms(HComponentType type, bool reads_transforms) set the component type transform dependency flag
void ComponentTypeSetRenderFn(HComponentType type, ComponentsRender fn) set the component render callback
void ComponentTypeSetSetPropertiesFn(HComponentType type, ComponentSetProperties fn) set the component set properties callback
void ComponentTypeSetSetPropertyFn(HComponentType type, ComponentSetProperty fn) set the component set property callback
void ComponentTypeSetUpdateFn(HComponentType type, ComponentsUpdate fn) set the component update callback
dmhash_t ConstructInstanceId(uint32_t index) Construct a hash of an instance id based on the in...
void Delete(dmGameObject::HCollection collection, dmGameObject::HInstance instance, bool recursive) Delete gameobject instance
void DeleteBones(HInstance parent) Recursively delete all instances flagged as bones ...
bool dmScript::PostDDF(TDDFType* message, dmMessage::Message* sender, dmMessage::Message* receiver, int function_ref, bool unref_function_after_call) Sends a script message
dmGameObject::HInstance GetCollection(dmGameObject::HInstance instance) Retrieve a collection from the specified instance
dmGameObject::Result GetComponentId(dmGameObject::HInstance instance, uint16_t component_index, dmhash_t* component_id) Get component id from component index.
uint32_t GetComponentTypeIndex( collection, dhmash_t type_hash) Get the component type index
dmhash_t GetIdentifier(dmGameObject::HInstance instance) Get instance identifier
dmMessage::HSocket GetMessageSocket(dmGameObject::HCollection collection) Retrieve the message socket for the specified coll...
dmGameObject::Point3 GetPosition(dmGameObject::HInstance instance) get position
dmGameObject::Quat GetRotation(dmGameObject::HInstance instance) get rotation
dmGameObject::Vector3 GetScale(dmGameObject::HInstance instance) get scale
float GetUniformScale(dmGameObject::HInstance instance) get uniform scale
dmGameObject::MAtrix4 GetWorldMatrix(dmGameObject::HInstance instance) get world matrix
dmGameObject::Point3 GetWorldPosition(dmGameObject::HInstance instance) get world position
dmGameObject::Quat GetWorldRotation(dmGameObject::HInstance instance) get world rotation
dmGameObject::Vector3 GetWorldScale(dmGameObject::HInstance instance) get world scale
dmTransform::Transform GetWorldTransform(dmGameObject::HInstance instance) get world transform
float GetWorldUniformScale(dmGameObject::HInstance instance) get world uniform scale
void INVALID_INSTANCE_POOL_INDEX() Value for an invalid instance index, this must be ...
bool IsBone(HImstance instance) Check whether the instance is flagged as a bone.
dmGameObject::HInstance New(dmGameObject::HCollection collection,  prototype_name) Create a new gameobject instance
HPropertyContainer PropertyContainerCopy(HPropertyContainer original) Allocates and copies a property container
HPropertyContainer PropertyContainerCreate(HPropertyContainerBuilder builder) Creates the final property container
HPropertyContainerBuilder PropertyContainerCreateBuilder(PropertyContainerBuilderParams params) Create a property container builder with memory pr...
void PropertyContainerDestroy(HPropertyContainer container) Deallocates a property container
HPropertyContainer PropertyContainerMerge(HPropertyContainer original, HPropertyContainer overrides) Merges two containers into a newly allocated conta...
void PropertyContainerPushBool(HPropertyContainerBuilder builder, dmhash_t id, bool value) Add a property of type bool to the container
void PropertyContainerPushFloat(HPropertyContainerBuilder builder, dmhash_t id, float value) Add a property of type float to the container
void PropertyContainerPushHash(HPropertyContainerBuilder builder, dmhash_t id, dmhash_t value) Add a property of type dmhash_t to the container
void PropertyContainerPushQuat(HPropertyContainerBuilder builder, dmhash_t id, float* values) Add a property of type float4 to the container
void PropertyContainerPushURL(HPropertyContainerBuilder builder, dmhash_t id, dmMessage::URL value) Add a property of type dmMessage::URL to the conta...
void PropertyContainerPushURLString(HPropertyContainerBuilder builder, dmhash_t id, const char* value) Add a property of type (url) string to the contain...
void PropertyContainerPushVector3(HPropertyContainerBuilder builder, dmhash_t id, float* values) Add a property of type float3 to the container
void PropertyContainerPushVector4(HPropertyContainerBuilder builder, dmhash_t id, float* values) Add a property of type float4 to the container
void SetBone(HImstance instance, bool bone) Set whether the instance should be flagged as a bo...
 SetBoneTransforms(HImstance instance, dmTransform::Transform component_transform,  transforms,  transform_count) Set the local transforms recursively of all instan...
dmGameObject::Result SetIdentifier(dmGameObject::HCollection collection, dmGameObject::HInstance instance, dmhash_t identifier) Set instance identifier. Must be unique within the...
void SetPosition(dmGameObject::HInstance instance, dmGameObject::Point3 position) set position
void SetRotation(dmGameObject::HInstance instance,  position) set rotation
void SetScale(dmGameObject::HInstance instance,  scale) set uniform scale
void SetScale(dmGameObject::HInstance instance,  scale) set scale
void Spawn(HCollection collection, HPrototype prototype, const char* prototype_name, dmhash_t id, HPropertyContainer properties, dmVMath::Vector3 position, dmVMath::Quat rotation, dmVMath::Vector3 scale) spawn a new game object
bool TraverseGetRoot(dmGameObject::HRegister regist, dmGameObject::HRegister node) Gets the top node of the whole game (the main coll...
dmGameObject::SceneNodeIterator TraverseIterateChildren(dmGameObject::SceneNode* node) Get a scene node iterator for the nodes' children
bool TraverseIterateNext(dmGameObject::SceneNodeIterator* it) Step a scene node iterator to the next sibling
dmGameObject::SceneNodePropertyIterator TraverseIterateProperties(dmGameObject::SceneNode* node) Create a scene node traversal property iterator
bool TraverseIteratePropertiesNext(dmGameObject::SceneNodePropertyIterator* it) Steps the scene node traversal property iterator t...

Functions

AcquireInstanceIndex

uint32_t AcquireInstanceIndex(dmGameObject::HColleciton collection)

Retrieve an instance index from the index pool for the collection.

PARAMETERS

dmGameObject::HColleciton collection Collection from which to retrieve the instance index.

RETURNS

uint32_t index from the index pool of collection.

AssignInstanceIndex

void AssignInstanceIndex(uint32_t index, dmGameObject::HInstance instance)

Assign an index to the instance, only if the instance is not null.

PARAMETERS

uint32_t index The index to assign.
dmGameObject::HInstance instance The instance that should be assigned the index.

ComponentOnReload

void ComponentOnReload(const dmGameObject::ComponentOnReloadParams& params)

Called when the resource the component is based on has been reloaded.

PARAMETERS

const dmGameObject::ComponentOnReloadParams& params the parameters

ComponentTypeGetContext

void* ComponentTypeGetContext(HComponentType type)

get the component type global context

PARAMETERS

HComponentType type the type

RETURNS

void* component type global context

ComponentTypeGetTypeIndex

uint32_t ComponentTypeGetTypeIndex(HComponentType type)

Get the component type index. Used for with e.g. dmGameObject::GetWorld()/GetContext()

PARAMETERS

HComponentType type the type

RETURNS

uint32_t The type index.

ComponentTypeSetAddToUpdateFn

void ComponentTypeSetAddToUpdateFn(HComponentType type, ComponentAddToUpdate fn)

Set the component add-to-update callback. Called for each component instal, when the game object is spawned.

PARAMETERS

HComponentType type the type
ComponentAddToUpdate fn callback

ComponentTypeSetChildIteratorFn

void ComponentTypeSetChildIteratorFn(HComponentType type, FIteratorChildren fn)

set the component child iterator function. Called during inspection

PARAMETERS

HComponentType type the type
FIteratorChildren fn child iterator function

ComponentTypeSetContext

void ComponentTypeSetContext(HComponentType type, void* context)

Set the component type global context. Usually set when registering the component type.

PARAMETERS

HComponentType type the type
void* context component type global context

ComponentTypeSetCreateFn

void ComponentTypeSetCreateFn(HComponentType type, ComponentCreate fn)

Set the component create callback. Called when a component instance is created.

PARAMETERS

HComponentType type the type
ComponentCreate fn callback

ComponentTypeSetDeleteWorldFn

void ComponentTypeSetDeleteWorldFn(HComponentType type, ComponentDeleteWorld fn)

Set the world destroy callback. Called when a collection (i.e. a "world") is destroyed.

PARAMETERS

HComponentType type the type
ComponentDeleteWorld fn callback

ComponentTypeSetDestroyFn

void ComponentTypeSetDestroyFn(HComponentType type, ComponentDestroy fn)

Set the component destroy callback. Called when a component instance is destroyed.

PARAMETERS

HComponentType type the type
ComponentDestroy fn callback

ComponentTypeSetFinalFn

void ComponentTypeSetFinalFn(HComponentType type, ComponentFinal fn)

Set the component finalize callback. Called on each gameobject's components, during a gameobject's finalization.

PARAMETERS

HComponentType type the type
ComponentFinal fn callback

ComponentTypeSetFixedUpdateFn

void ComponentTypeSetFixedUpdateFn(HComponentType type, ComponentsFixedUpdate fn)

Set the component update callback. Called when it's time to update all component instances.

PARAMETERS

HComponentType type the type
ComponentsFixedUpdate fn callback

ComponentTypeSetGetFn

void ComponentTypeSetGetFn(HComponentType type, ComponentGet fn)

Set the component get callback. Called when the scripts want to retrieve the individual component user data given an url.

PARAMETERS

HComponentType type the type
ComponentGet fn callback

ComponentTypeSetGetPropertyFn

void ComponentTypeSetGetPropertyFn(HComponentType type, ComponentGetProperty fn)

Set the component get property callback. Called when accessing a property via go.get()

PARAMETERS

HComponentType type the type
ComponentGetProperty fn callback

ComponentTypeSetHasUserData

void ComponentTypeSetHasUserData(HComponentType type, bool has_user_data)

Set the component type need for a per component instance user data. Defaults to true.

PARAMETERS

HComponentType type the type
bool has_user_data does each component instance need user data

ComponentTypeSetInitFn

void ComponentTypeSetInitFn(HComponentType type, ComponentInit fn)

Set the component init callback. Called on each gameobject's components, during a gameobject's initialization.

PARAMETERS

HComponentType type the type
ComponentInit fn callback

ComponentTypeSetNewWorldFn

void ComponentTypeSetNewWorldFn(HComponentType type, ComponentNewWorld fn)

Set the new world callback. Called when a collection (i.e. a "world") is created.

PARAMETERS

HComponentType type the type
ComponentNewWorld fn callback

ComponentTypeSetOnInputFn

void ComponentTypeSetOnInputFn(HComponentType type, ComponentOnInput fn)

Set the component on-input callback. Called once per frame, before the Update function.

PARAMETERS

HComponentType type the type
ComponentOnInput fn callback

ComponentTypeSetOnMessageFn

void ComponentTypeSetOnMessageFn(HComponentType type, ComponentOnMessage fn)

Set the component on-message callback. Called multiple times per frame, to flush messages.

PARAMETERS

HComponentType type the type
ComponentOnMessage fn callback

ComponentTypeSetOnReloadFn

void ComponentTypeSetOnReloadFn(HComponentType type, ComponentOnReload fn)

Set the component on-reload callback. Called when the resource of a component instance is reloaded.

PARAMETERS

HComponentType type the type
ComponentOnReload fn callback

ComponentTypeSetPostUpdateFn

void ComponentTypeSetPostUpdateFn(HComponentType type, ComponentsPostUpdate fn)

Set the component post update callback. Called for each collection after the update, before the render.

PARAMETERS

HComponentType type the type
ComponentsPostUpdate fn callback

ComponentTypeSetPrio

void ComponentTypeSetPrio(HComponentType type, uint16_t prio)

Set the component type prio order. Defines the update order of the component types.

PARAMETERS

HComponentType type the type
uint16_t prio prio order

ComponentTypeSetPropertyIteratorFn

void ComponentTypeSetPropertyIteratorFn(HComponentType type, FIteratorProperties fn)

set the component property iterator function. Called during inspection

PARAMETERS

HComponentType type the type
FIteratorProperties fn property iterator function

ComponentTypeSetReadsTransforms

void ComponentTypeSetReadsTransforms(HComponentType type, bool reads_transforms)

Set the component type transform dependency flag. If this flag is set, it might trigger an dmGameObject::UpdateTransforms() (if there are dirty transforms)

PARAMETERS

HComponentType type the type
bool reads_transforms transform dependency flag

ComponentTypeSetRenderFn

void ComponentTypeSetRenderFn(HComponentType type, ComponentsRender fn)

Set the component render callback. Called when it's time to render all component instances.

PARAMETERS

HComponentType type the type
ComponentsRender fn callback

ComponentTypeSetSetPropertiesFn

void ComponentTypeSetSetPropertiesFn(HComponentType type, ComponentSetProperties fn)

Set the component set properties callback. Called when the component instance is being spwned.

PARAMETERS

HComponentType type the type
ComponentSetProperties fn callback

ComponentTypeSetSetPropertyFn

void ComponentTypeSetSetPropertyFn(HComponentType type, ComponentSetProperty fn)

Set the component set property callback. Called when accessing a property via go.set()

PARAMETERS

HComponentType type the type
ComponentSetProperty fn callback

ComponentTypeSetUpdateFn

void ComponentTypeSetUpdateFn(HComponentType type, ComponentsUpdate fn)

Set the component update callback. Called when it's time to update all component instances.

PARAMETERS

HComponentType type the type
ComponentsUpdate fn callback

ConstructInstanceId

dmhash_t ConstructInstanceId(uint32_t index)

Construct a hash of an instance id based on the index provided.

PARAMETERS

uint32_t index The index to base the id off of.

RETURNS

dmhash_t hash of the instance id constructed.

Delete

void Delete(dmGameObject::HCollection collection, dmGameObject::HInstance instance, bool recursive)

Delete gameobject instance

PARAMETERS

dmGameObject::HCollection collection Gameobject collection
dmGameObject::HInstance instance Gameobject instance
bool recursive If true, delete child hierarchy recursively in child to parent order (leaf first)

DeleteBones

void DeleteBones(HInstance parent)

Recursively delete all instances flagged as bones under the given parent instance. The order of deletion is depth-first, so that the children are deleted before the parents.

PARAMETERS

HInstance parent Parent instance of the hierarchy

dmScript::PostDDF

bool dmScript::PostDDF(TDDFType* message, dmMessage::Message* sender, dmMessage::Message* receiver, int function_ref, bool unref_function_after_call)

Sends a script message. Wraps the message in a dmGameSystemDDF::ScriptMessage struct.

PARAMETERS

TDDFType* message The ddf message to send
dmMessage::Message* sender The sender
dmMessage::Message* receiver The receiver
int function_ref The function ref. 0 wil cause the "on_message" to be called
bool unref_function_after_call call dmScript::UnrefInInstance on the function_ref after the dmScript::PCall is made

RETURNS

bool true if successful

GetCollection

dmGameObject::HInstance GetCollection(dmGameObject::HInstance instance)

Retrieve a collection from the specified instance

PARAMETERS

dmGameObject::HInstance instance Game object instance

RETURNS

dmGameObject::HInstance The collection the specified instance belongs to

GetComponentId

dmGameObject::Result GetComponentId(dmGameObject::HInstance instance, uint16_t component_index, dmhash_t* component_id)

Get component id from component index.

PARAMETERS

dmGameObject::HInstance instance Instance
uint16_t component_index Component index
dmhash_t* component_id Component id as out-argument

RETURNS

dmGameObject::Result RESULT_OK if the component was found

GetComponentTypeIndex

uint32_t GetComponentTypeIndex( collection, dhmash_t type_hash)

Get the component type index

PARAMETERS

collection Collection handle
dhmash_t type_hash The hashed name of the registered component type (e.g. dmHashString("guic"))

RETURNS

uint32_t The component type index. 0xFFFFFFFF if not found

GetIdentifier

dmhash_t GetIdentifier(dmGameObject::HInstance instance)

Get instance identifier

PARAMETERS

dmGameObject::HInstance instance Gameobject instance

RETURNS

dmhash_t Identifier. dmGameObject::UNNAMED_IDENTIFIER if not set.

GetMessageSocket

dmMessage::HSocket GetMessageSocket(dmGameObject::HCollection collection)

Retrieve the message socket for the specified collection.

PARAMETERS

dmGameObject::HCollection collection Collection handle

RETURNS

dmMessage::HSocket The message socket of the specified collection

GetPosition

dmGameObject::Point3 GetPosition(dmGameObject::HInstance instance)

Get gameobject instance position

PARAMETERS

dmGameObject::HInstance instance Gameobject instance

RETURNS

dmGameObject::Point3 Position

GetRotation

dmGameObject::Quat GetRotation(dmGameObject::HInstance instance)

Get gameobject instance rotation

PARAMETERS

dmGameObject::HInstance instance Gameobject instance

RETURNS

dmGameObject::Quat rotation

GetScale

dmGameObject::Vector3 GetScale(dmGameObject::HInstance instance)

Get gameobject instance scale

PARAMETERS

dmGameObject::HInstance instance Gameobject instance

RETURNS

dmGameObject::Vector3 Non-uniform scale

GetUniformScale

float GetUniformScale(dmGameObject::HInstance instance)

Get gameobject instance uniform scale

PARAMETERS

dmGameObject::HInstance instance Gameobject instance

RETURNS

float Uniform scale

GetWorldMatrix

dmGameObject::MAtrix4 GetWorldMatrix(dmGameObject::HInstance instance)

Get game object instance world transform as Matrix4.

PARAMETERS

dmGameObject::HInstance instance Gameobject instance

RETURNS

dmGameObject::MAtrix4 World transform matrix.

GetWorldPosition

dmGameObject::Point3 GetWorldPosition(dmGameObject::HInstance instance)

Get gameobject instance world position

PARAMETERS

dmGameObject::HInstance instance Gameobject instance

RETURNS

dmGameObject::Point3 World position

GetWorldRotation

dmGameObject::Quat GetWorldRotation(dmGameObject::HInstance instance)

Get gameobject instance world rotation

PARAMETERS

dmGameObject::HInstance instance Gameobject instance

RETURNS

dmGameObject::Quat World rotation

GetWorldScale

dmGameObject::Vector3 GetWorldScale(dmGameObject::HInstance instance)

Get game object instance world transform

PARAMETERS

dmGameObject::HInstance instance Gameobject instance

RETURNS

dmGameObject::Vector3 World scale

GetWorldTransform

dmTransform::Transform GetWorldTransform(dmGameObject::HInstance instance)

Get game object instance world transform

PARAMETERS

dmGameObject::HInstance instance Gameobject instance

RETURNS

dmTransform::Transform World transform

GetWorldUniformScale

float GetWorldUniformScale(dmGameObject::HInstance instance)

Get game object instance uniform scale

PARAMETERS

dmGameObject::HInstance instance Gameobject instance

RETURNS

float World uniform scale

INVALID_INSTANCE_POOL_INDEX

void INVALID_INSTANCE_POOL_INDEX()

Value for an invalid instance index, this must be the same as defined in gamesys_ddf.proto for Create#index.

PARAMETERS


IsBone

bool IsBone(HImstance instance)

Check whether the instance is flagged as a bone.

PARAMETERS

HImstance instance Instance

RETURNS

bool True if flagged as a bone

New

dmGameObject::HInstance New(dmGameObject::HCollection collection,  prototype_name)

Create a new gameobject instance

PARAMETERS

dmGameObject::HCollection collection Gameobject collection
prototype_name |type: const char*] Prototype file name. May be 0.

RETURNS

dmGameObject::HInstance New gameobject instance. NULL if any error occured

PropertyContainerCopy

HPropertyContainer PropertyContainerCopy(HPropertyContainer original)

Allocates and copies a property container

PARAMETERS

HPropertyContainer original The original property container

RETURNS

HPropertyContainer The new property container

PropertyContainerCreate

HPropertyContainer PropertyContainerCreate(HPropertyContainerBuilder builder)

Creates the final property container

PARAMETERS

HPropertyContainerBuilder builder The property container builder

RETURNS

HPropertyContainer The property container

PropertyContainerCreateBuilder

HPropertyContainerBuilder PropertyContainerCreateBuilder(PropertyContainerBuilderParams params)

Create a property container builder with memory preallocated

PARAMETERS

PropertyContainerBuilderParams params The params holding the memory requirements

RETURNS

HPropertyContainerBuilder The builder

PropertyContainerDestroy

void PropertyContainerDestroy(HPropertyContainer container)

Deallocates a property container

PARAMETERS

HPropertyContainer container The property container

PropertyContainerMerge

HPropertyContainer PropertyContainerMerge(HPropertyContainer original, HPropertyContainer overrides)

Merges two containers into a newly allocated container The properties in the overrides container will take presedence.

PARAMETERS

HPropertyContainer original The original property container
HPropertyContainer overrides The container with override properties

RETURNS

HPropertyContainer The merged property container

PropertyContainerPushBool

void PropertyContainerPushBool(HPropertyContainerBuilder builder, dmhash_t id, bool value)

Add a property of type bool to the container

PARAMETERS

HPropertyContainerBuilder builder The container builder
dmhash_t id The id of the property
bool value The value of the property

PropertyContainerPushFloat

void PropertyContainerPushFloat(HPropertyContainerBuilder builder, dmhash_t id, float value)

Add a property of type float to the container

PARAMETERS

HPropertyContainerBuilder builder The container builder
dmhash_t id The id of the property
float value The value of the property

PropertyContainerPushHash

void PropertyContainerPushHash(HPropertyContainerBuilder builder, dmhash_t id, dmhash_t value)

Add a property of type dmhash_t to the container

PARAMETERS

HPropertyContainerBuilder builder The container builder
dmhash_t id The id of the property
dmhash_t value The value of the property

PropertyContainerPushQuat

void PropertyContainerPushQuat(HPropertyContainerBuilder builder, dmhash_t id, float* values)

Add a property of type float4 to the container

PARAMETERS

HPropertyContainerBuilder builder The container builder
dmhash_t id The id of the property
float* values The value of the property (4 floats)

PropertyContainerPushURL

void PropertyContainerPushURL(HPropertyContainerBuilder builder, dmhash_t id, dmMessage::URL value)

Add a property of type dmMessage::URL to the container

PARAMETERS

HPropertyContainerBuilder builder The container builder
dmhash_t id The id of the property
dmMessage::URL value The value of the property

PropertyContainerPushURLString

void PropertyContainerPushURLString(HPropertyContainerBuilder builder, dmhash_t id, const char* value)

Add a property of type (url) string to the container

PARAMETERS

HPropertyContainerBuilder builder The container builder
dmhash_t id The id of the property
const char* value The value of the property

PropertyContainerPushVector3

void PropertyContainerPushVector3(HPropertyContainerBuilder builder, dmhash_t id, float* values)

Add a property of type float3 to the container

PARAMETERS

HPropertyContainerBuilder builder The container builder
dmhash_t id The id of the property
float* values The value of the property (3 floats)

PropertyContainerPushVector4

void PropertyContainerPushVector4(HPropertyContainerBuilder builder, dmhash_t id, float* values)

Add a property of type float4 to the container

PARAMETERS

HPropertyContainerBuilder builder The container builder
dmhash_t id The id of the property
float* values The value of the property (4 floats)

SetBone

void SetBone(HImstance instance, bool bone)

Set whether the instance should be flagged as a bone. Instances flagged as bones can have their transforms updated in a batch through SetBoneTransforms. Used for animated skeletons.

PARAMETERS

HImstance instance Instance
bool bone true if the instance is a bone

SetBoneTransforms

 SetBoneTransforms(HImstance instance, dmTransform::Transform component_transform,  transforms,  transform_count)

Set the local transforms recursively of all instances flagged as bones, starting with component with id. The order of the transforms is depth-first.

PARAMETERS

HImstance instance First Instance of the hierarchy to set
dmTransform::Transform component_transform the transform for component root
transforms Array of transforms to set depth-first for the bone instances
transform_count Size of the transforms array

RETURNS

of instances found

SetIdentifier

dmGameObject::Result SetIdentifier(dmGameObject::HCollection collection, dmGameObject::HInstance instance, dmhash_t identifier)

Set instance identifier. Must be unique within the collection.

PARAMETERS

dmGameObject::HCollection collection Collection
dmGameObject::HInstance instance Instance
dmhash_t identifier Identifier

RETURNS

dmGameObject::Result RESULT_OK on success

SetPosition

void SetPosition(dmGameObject::HInstance instance, dmGameObject::Point3 position)

Set gameobject instance position

PARAMETERS

dmGameObject::HInstance instance Gameobject instance
dmGameObject::Point3 position New Position

SetRotation

void SetRotation(dmGameObject::HInstance instance,  position)

Set gameobject instance rotation

PARAMETERS

dmGameObject::HInstance instance Gameobject instance
position New Position

SetScale

void SetScale(dmGameObject::HInstance instance,  scale)

Set gameobject instance uniform scale

PARAMETERS

dmGameObject::HInstance instance Gameobject instance
scale New uniform scale

SetScale

void SetScale(dmGameObject::HInstance instance,  scale)

Set gameobject instance non-uniform scale

PARAMETERS

dmGameObject::HInstance instance Gameobject instance
scale New uniform scale

Spawn

void Spawn(HCollection collection, HPrototype prototype, const char* prototype_name, dmhash_t id, HPropertyContainer properties, dmVMath::Vector3 position, dmVMath::Quat rotation, dmVMath::Vector3 scale)

Spawns a new gameobject instance. The actual creation is performed after the update is completed.

PARAMETERS

HCollection collection Gameobject collection
HPrototype prototype Prototype
const char* prototype_name Prototype file name (.goc)
dmhash_t id Id of the spawned instance
HPropertyContainer properties Container with override properties
dmVMath::Vector3 position Position of the spawed object
dmVMath::Quat rotation Rotation of the spawned object
dmVMath::Vector3 scale Scale of the spawned object return instance HInstance the spawned instance, 0 at failure

TraverseGetRoot

bool TraverseGetRoot(dmGameObject::HRegister regist, dmGameObject::HRegister node)

Gets the top node of the whole game (the main collection)

PARAMETERS

dmGameObject::HRegister regist the full gameobject register
dmGameObject::HRegister node the node to inspect

RETURNS

bool True if successful

EXAMPLES

The following examples show how to iterate over currently loaded scene graph
void OutputNode(dmGameObject::SceneNode* node) {
    dmGameObject::SceneNodeIterator it = dmGameObject::TraverseIterateChildren(node);
    while(dmGameObject::TraverseIterateNext(&it))
    {
        OutputProperties(&it.m_Node); // see dmGameObject::TraverseIterateProperties()
        OutputNode(&it.m_Node);
    }
}

bool OutputScene(HRegister regist) {
    dmGameObject::SceneNode root;
    if (!dmGameObject::TraverseGetRoot(regist, &root))
        return false;
    OutputNode(&node);
}

TraverseIterateChildren

dmGameObject::SceneNodeIterator TraverseIterateChildren(dmGameObject::SceneNode* node)

Get a scene node iterator for the nodes' children

PARAMETERS

dmGameObject::SceneNode* node the parent node

RETURNS

dmGameObject::SceneNodeIterator the iterator

TraverseIterateNext

bool TraverseIterateNext(dmGameObject::SceneNodeIterator* it)

Step a scene node iterator to the next sibling

PARAMETERS

dmGameObject::SceneNodeIterator* it the iterator

RETURNS

bool true if successful. false if the iterator is finished

TraverseIterateProperties

dmGameObject::SceneNodePropertyIterator TraverseIterateProperties(dmGameObject::SceneNode* node)

Create a scene node traversal property iterator

PARAMETERS

dmGameObject::SceneNode* node the node to inspect

RETURNS

dmGameObject::SceneNodePropertyIterator the property iterator

EXAMPLES

The following examples show how to iterate over the properties of a node
dmGameObject::SceneNodePropertyIterator pit = TraverseIterateProperties(node);
while(dmGameObject::TraverseIteratePropertiesNext(&pit))
{
    const char* name = dmHashReverseSafe64(pit.m_Property.m_NameHash);
    switch(pit.m_Property.m_Type)
    {
    case dmGameObject::SCENE_NODE_PROPERTY_TYPE_NUMBER: ...
    ...
    }
}

TraverseIteratePropertiesNext

bool TraverseIteratePropertiesNext(dmGameObject::SceneNodePropertyIterator* it)

Steps the scene node traversal property iterator to the next property

PARAMETERS

dmGameObject::SceneNodePropertyIterator* it the iterator

RETURNS

bool True if the iterator it valid, false if the iterator is finished.

Structs

ComponentAddToUpdateParams

TYPE

struct ComponentAddToUpdateParams

Parameters to ComponentAddToUpdate callback.

MEMBERS

HCollection m_Collection Collection handle
HInstance m_Instance Game object instance
void* m_World Component world
void* m_Context User context
uintptr_t* m_UserData User data storage pointer


ComponentCreateParams

TYPE

struct ComponentCreateParams

Parameters to ComponentCreate callback.

MEMBERS

HInstance m_Instance Game object instance
dmVMath::Point3 m_Position Local component position
dmVMath::Quat m_Rotation Local component rotation
dmVMath::Vector3 m_Scale Local component scale
PropertySet m_PropertySet Set of properties
void* m_Resource Component resource
void* m_World Component world, as created in the ComponentNewWorld callback
void* m_Context User context
uintptr_t* m_UserData User data storage pointer
uint16_t m_ComponentIndex Index of the component type being created (among all component types)


ComponentDeleteWorldParams

TYPE

struct ComponentDeleteWorldParams

Parameters to ComponentDeleteWorld callback.

MEMBERS

m_Context [type void*] Context for the component type
m_World [type void*] The pointer to the world to destroy


ComponentDestroyParams

TYPE

struct ComponentDestroyParams

Parameters to ComponentDestroy callback.

MEMBERS

HCollection m_Collection Collection handle
HInstance m_Instance Game object instance
void* m_World Component world
void* m_Context User context
uintptr_t* m_UserData User data storage pointer


ComponentFinalParams

TYPE

struct ComponentFinalParams

Parameters to ComponentFinal callback.

MEMBERS

HCollection m_Collection Collection handle
HInstance m_Instance Game object instance
void* m_World Component world
void* m_Context User context
uintptr_t* m_UserData User data storage pointer


ComponentGetParams

TYPE

struct ComponentGetParams

Parameters to ComponentGet callback.

MEMBERS

HComponentWorld m_World Component world
HComponentInternal m_UserData Component internal representation


ComponentGetPropertyParams

TYPE

struct ComponentGetPropertyParams

Parameters to ComponentGetProperty callback.

MEMBERS

void* m_Context Context for the component type
void* m_World Component world
HInstance m_Instance Game object instance
dmhash_t m_PropertyId Id of the property
uintptr_t* m_UserData User data storage pointer
PropertyOptions m_Options Options for getting the property


ComponentInitParams

TYPE

struct ComponentInitParams

Parameters to ComponentInit callback.

MEMBERS

HCollection m_Collection Collection handle
HInstance m_Instance Game object instance
void* m_World Component world
void* m_Context User context
uintptr_t* m_UserData User data storage pointer


ComponentNewWorldParams

TYPE

struct ComponentNewWorldParams

Parameters to ComponentNewWorld callback.

MEMBERS

void* m_Context Context for the component type
uint8_t m_ComponentIndex Component type index that can be used later with GetWorld()
uint32_t m_MaxInstances Max component game object instance count (if applicable)
void** m_World Out-parameter of the pointer in which to store the created world
uint32_t m_MaxComponentInstances Max components count of this type in current collection counted at the build stage. If component in factory then value is 0xFFFFFFFF


ComponentOnInputParams

TYPE

struct ComponentOnInputParams

Parameters to ComponentOnInput callback.

MEMBERS

HInstance m_Instance Instance handle
const InputAction* m_InputAction Information about the input that occurred (note that input being released is also treated as input)
void* m_Context User context
uintptr_t* m_UserData User data storage pointer


ComponentOnMessageParams

TYPE

struct ComponentOnMessageParams

Parameters to ComponentOnMessage callback.

MEMBERS

HInstance m_Instance Instance handle
void* m_World World
void* m_Context User context
uintptr_t* m_UserData User data storage pointer
dmMessage::Message* m_Message Message


ComponentOnReloadParams

TYPE

struct ComponentOnReloadParams

Parameters to ComponentOnReload callback.

MEMBERS

HInstance m_Instance Instance handle
void* m_Resource Resource that was reloaded
void* m_World Component world
void* m_Context User context
uintptr_t* m_UserData User data storage pointer


ComponentSetPropertiesParams

TYPE

struct ComponentSetPropertiesParams

Parameters to ComponentSetProperties callback.

MEMBERS

HInstance m_Instance Instance handle
PropertySet m_PropertySet Property set to use
uintptr_t* m_UserData User data storage pointer


ComponentSetPropertyParams

TYPE

struct ComponentSetPropertyParams

Parameters to ComponentSetProperty callback.

MEMBERS

void* m_Context Context for the component type
void* m_World Component world
HInstance m_Instance Game object instance
dmhash_t m_PropertyId Id of the property
uintptr_t* m_UserData User data storage pointer
PropertyVar m_Value New value of the property
PropertyOptions m_Options Options for setting the property


ComponentsPostUpdateParams

TYPE

struct ComponentsPostUpdateParams

Parameters for ComponentsPostUpdate callback.

MEMBERS

HCollection m_Collection Collection handle
void* m_World Component world
void* m_Context User context


ComponentsRenderParams

TYPE

struct ComponentsRenderParams

Parameters to ComponentsRender callback.

MEMBERS

HCollection m_Collection Collection handle
void* m_World Component world
void* m_Context User context


ComponentsUpdateParams

TYPE

struct ComponentsUpdateParams

Parameters to ComponentsUpdate callback.

MEMBERS

HCollection m_Collection Collection handle
const UpdateContext* m_UpdateContext Update context
void* m_World Component world
void* m_Context User context


ComponentsUpdateResult

TYPE

struct ComponentsUpdateResult

Parameters to ComponentsUpdate callback.

MEMBERS

bool m_TransformsUpdated True if a component type updated any game object transforms


ComponentTypeCreateCtx

TYPE

struct ComponentTypeCreateCtx

Context used when registering a new component type

MEMBERS

dmConfigFile::HConfig m_Config The config file
dmResource::HFactory m_Factory The resource factory
dmGameObject::HRegister m_Register The game object registry
dmScript::HContext m_Script The shared script context
dmHashTable64 m_Contexts Mappings between names and contextx


InputAction

TYPE

struct InputAction

Container of input related information.


m_BoolCount [type:int32_t] Number of items of type bool

TYPE

struct m_BoolCount [type:int32_t] Number of items of type bool

Helper struct to create a property container builder. It is required to fill out how many items of each type that is wanted.


PropertyDesc

TYPE

struct PropertyDesc

Description of a property. If the property is externally mutable, m_ValuePtr points to the value and its length is m_ElementCount. m_Variant always reflects the value.

MEMBERS

dmhash_t m_ElementIds For composite properties (float arrays), these ids name each element
PropertyVar m_Variant Variant holding the value
float* m_ValuePtr Pointer to the value, only set for mutable values. The actual data type is described by the variant.
uint16_t m_ReadOnly Determines whether we are permitted to write to this property.
uint16_t m_ValueType Indicates type of the property (of type PropertyValueType).
uint16_t m_ArrayLength Number of array entries, if the property is an array and zero otherwise. Max supported length is 2^14 (16384 elements)


PropertyOptions

TYPE

struct PropertyOptions

Parameters variant that holds key or index for a propertys data structure.

MEMBERS

int32_t m_Index The index of the property to set, only applicable if property is array.
dmhash_t m_Key The key of the property to set, only applicable if property is hashtable.
uint8_t m_HasKey A flag if structure contain m_Key value (it can't contain both)


PropertyVar

TYPE

struct PropertyVar

Property variant that holds the data for a variable

MEMBERS

dmGameObject::PropertyType m_Type property type
double m_Number A floating point value (union)
dmhash_t m_Hash A hash value (union)
const uin8_t* m_Url An URL value (union)
float m_V4 A vector4 value (union)
bool m_Bool A boolean value (union)


SceneNode

TYPE

struct SceneNode

Opaque struct that holds info about the current node


SceneNodeIterator

TYPE

struct SceneNodeIterator

Opaque struct that holds info about the current position when traversing the scene


SceneNodeProperty

TYPE

struct SceneNodeProperty

Struct that holds info about the current position when traversing the scene

MEMBERS

dmhash_t m_NameHash name
dmGameObject::SceneNodePropertyType m_Type type
union m_Value value
m_Number
double floating point number
m_Hash
dmhash_t The hashed value.
m_URL
char[1024] The text representation of the url (if reverse hashes are enabled)
m_V4
float[4] Used for Vector3, Vector4 and Quat
m_Bool
bool A boolean value
m_Text
const char* Text from a text property


SceneNodePropertyIterator

TYPE

struct SceneNodePropertyIterator

Holds the property

MEMBERS

dmGameObject::SceneNodeProperty m_Property property


UpdateContext

TYPE

struct UpdateContext

Update context

MEMBERS

float m_TimeScale the scaling factor what was applied on the dt (i.e. the collection update time scale)
float m_DT the delta time elapsed since last frame (seconds)
uint32_t m_FixedUpdateFrequency Number of of calls per second to the FixedUpdate of each component


Types

ComponentAddToUpdate

Component add to update function. Only components called with this function should be included in the update passes.


ComponentCreate

Component create function. Should allocate all necessary resources for the component. The game object instance is guaranteed to have its id, scene hierarchy and transform data updated when this is called.


ComponentDeleteWorld

Component world destroy function


ComponentDestroy

Component destroy function. Should deallocate all necessary resources.


ComponentFinal

Component finalize function. Should clean up as it is called when the component is disabled.


ComponentGet

A simple way to get the component instance from the user_data (which was set during creation)


ComponentGetProperty

Callback for retrieving a property value of the component.


ComponentInit

Component init function. Should set the components initial state as it is called when the component is enabled.


ComponentIterProperties

Callback when iterating over the properties for a component.


ComponentNewWorld

Component world create function


ComponentOnInput

Component on-input function. Called when input is sent to this component


ComponentOnMessage

Component on-message function. Called when message is sent to this component


ComponentSetProperties

Set a property set for the component.


ComponentSetProperty

Callback for setting a property value of the component.


ComponentsFixedUpdate

Component fixed update function. Updates all component of this type for all game objects


ComponentsPostUpdate

Component post update function. The component state should never be modified in this function.


ComponentsRender

Component render function.


ComponentsUpdate

Component update function. Updates all component of this type for all game objects


HCollection

Gameobject collection handle


HComponent

Opaque handle to component instance


HComponentInternal

Opaque handle to internal representation of a component instance


HComponentType

Component type handle. It holds the life time functions for a type.


HComponentWorld

Opaque handle to a component world


HInstance

Gameobject instance handle


HProperties

Gameobject properties handle


HPropertyContainer

Handle to a list of properties (gameobject_props.h)


HPropertyContainer

Opaque handle to a list of properties


HPropertyContainerBuilder

Opaque handle to a property container builder


HPrototype

Gameobject prototype handle


HRegister

Collection register.


HScript

Script handle


HScriptInstance

Script instance handle


Enums

CreateResult

Create result enum.

dmGameObject::CREATE_RESULT_OK
dmGameObject::CREATE_RESULT_UNKNOWN_ERROR

InputResult

Input result enum

INPUT_RESULT_IGNORED = 0
INPUT_RESULT_CONSUMED = 1
INPUT_RESULT_UNKNOWN_ERROR = -1000

Playback

Playback type enum


PropertyResult

Property result.

dmGameObject::PROPERTY_RESULT_OK
dmGameObject::PROPERTY_RESULT_NOT_FOUND
dmGameObject::PROPERTY_RESULT_INVALID_FORMAT
dmGameObject::PROPERTY_RESULT_UNSUPPORTED_TYPE
dmGameObject::PROPERTY_RESULT_TYPE_MISMATCH
dmGameObject::PROPERTY_RESULT_COMP_NOT_FOUND
dmGameObject::PROPERTY_RESULT_INVALID_INSTANCE
dmGameObject::PROPERTY_RESULT_BUFFER_OVERFLOW
dmGameObject::PROPERTY_RESULT_UNSUPPORTED_VALUE
dmGameObject::PROPERTY_RESULT_UNSUPPORTED_OPERATION
dmGameObject::PROPERTY_RESULT_RESOURCE_NOT_FOUND
dmGameObject::PROPERTY_RESULT_INVALID_INDEX
dmGameObject::PROPERTY_RESULT_INVALID_KEY
dmGameObject::PROPERTY_RESULT_READ_ONLY

PropertyType

Property types.

dmGameObject::PROPERTY_TYPE_NUMBER
dmGameObject::PROPERTY_TYPE_HASH
dmGameObject::PROPERTY_TYPE_URL
dmGameObject::PROPERTY_TYPE_VECTOR3
dmGameObject::PROPERTY_TYPE_VECTOR4
dmGameObject::PROPERTY_TYPE_QUAT
dmGameObject::PROPERTY_TYPE_BOOLEAN
dmGameObject::PROPERTY_TYPE_COUNT

PropertyValueType

Type of property value

dmGameObject::PROP_VALUE_ARRAY
dmGameObject::PROP_VALUE_HASHTABLE

Result

Result enumeration.

dmGameObject::RESULT_OK
dmGameObject::RESULT_OUT_OF_RESOURCES
dmGameObject::RESULT_ALREADY_REGISTERED
dmGameObject::RESULT_IDENTIFIER_IN_USE
dmGameObject::RESULT_IDENTIFIER_ALREADY_SET
dmGameObject::RESULT_COMPONENT_NOT_FOUND
dmGameObject::RESULT_MAXIMUM_HIEARCHICAL_DEPTH
dmGameObject::RESULT_INVALID_OPERATION
dmGameObject::RESULT_RESOURCE_TYPE_NOT_FOUND
dmGameObject::RESULT_BUFFER_OVERFLOW
dmGameObject::RESULT_UNKNOWN_ERROR

SceneNodePropertyType

scene node property types

dmGameObject::SCENE_NODE_PROPERTY_TYPE_NUMBER
dmGameObject::SCENE_NODE_PROPERTY_TYPE_HASH
dmGameObject::SCENE_NODE_PROPERTY_TYPE_URL
dmGameObject::SCENE_NODE_PROPERTY_TYPE_VECTOR3
dmGameObject::SCENE_NODE_PROPERTY_TYPE_VECTOR4
dmGameObject::SCENE_NODE_PROPERTY_TYPE_QUAT
dmGameObject::SCENE_NODE_PROPERTY_TYPE_BOOLEAN
dmGameObject::SCENE_NODE_PROPERTY_TYPE_TEXT
dmGameObject::SCENE_NODE_PROPERTY_TYPE_COUNT

UpdateResult

Update result enum.

dmGameObject::UPDATE_RESULT_OK
dmGameObject::UPDATE_RESULT_UNKNOWN_ERROR