Gameobject

API for manipulating game objects

ComponentIterProperties(pit, node)

Callback when iterating over the properties for a ...

Callback when iterating over the properties for a component.

PARAMETERS

pit - the property iterator

node - the scene node


ComponentTypeGetTypeIndex(type)

Get the component type index. Used for with e.g. d...

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

PARAMETERS

type - the type

RETURN

type_index - The type index.


ComponentTypeSetNewWorldFn(type, fn)

set the new world callback

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

PARAMETERS

type - the type

fn - callback


ComponentTypeSetDeleteWorldFn(type, fn)

set the world destroy callback

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

PARAMETERS

type - the type

fn - callback


ComponentTypeSetCreateFn(type, fn)

set the component create callback

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

PARAMETERS

type - the type

fn - callback


ComponentTypeSetDestroyFn(type, fn)

set the component destroy callback

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

PARAMETERS

type - the type

fn - callback


ComponentTypeSetInitFn(type, fn)

set the component init callback

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

PARAMETERS

type - the type

fn - callback


ComponentTypeSetFinalFn(type, fn)

set the component finalize callback

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

PARAMETERS

type - the type

fn - callback


ComponentTypeSetAddToUpdateFn(type, fn)

set the component add-to-update callback

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

PARAMETERS

type - the type

fn - callback


ComponentTypeSetGetFn(type, fn)

set the component get callback

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

PARAMETERS

type - the type

fn - callback


ComponentTypeSetRenderFn(type, fn)

set the component render callback

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

PARAMETERS

type - the type

fn - callback


ComponentTypeSetUpdateFn(type, fn)

set the component update callback

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

PARAMETERS

type - the type

fn - callback


ComponentTypeSetFixedUpdateFn(type, fn)

set the component update callback

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

PARAMETERS

type - the type

fn - callback


ComponentTypeSetPostUpdateFn(type, fn)

set the component post update callback

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

PARAMETERS

type - the type

fn - callback


ComponentTypeSetOnMessageFn(type, fn)

set the component on-message callback

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

PARAMETERS

type - the type

fn - callback


ComponentTypeSetOnInputFn(type, fn)

set the component on-input callback

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

PARAMETERS

type - the type

fn - callback


ComponentTypeSetOnReloadFn(type, fn)

set the component on-reload callback

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

PARAMETERS

type - the type

fn - callback


ComponentTypeSetSetPropertiesFn(type, fn)

set the component set properties callback

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

PARAMETERS

type - the type

fn - callback


ComponentTypeSetGetPropertyFn(type, fn)

set the component get property callback

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

PARAMETERS

type - the type

fn - callback


ComponentTypeSetSetPropertyFn(type, fn)

set the component set property callback

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

PARAMETERS

type - the type

fn - callback


ComponentTypeSetContext(type, context)

set the component type global context

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

PARAMETERS

type - the type

context - component type global context


ComponentTypeGetContext(type)

get the component type global context

get the component type global context

PARAMETERS

type - the type

RETURN

context - component type global context


ComponentTypeSetReadsTransforms(type, reads_transforms)

set the component type transform dependency flag

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

PARAMETERS

type - the type

reads_transforms - transform dependency flag


ComponentTypeSetPrio(type, prio)

set the component type prio order

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

PARAMETERS

type - the type

prio - prio order


ComponentTypeSetHasUserData(type, has_user_data)

set the component type need for a per component instance user data

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

PARAMETERS

type - the type

has_user_data - does each component instance need user data


ComponentTypeSetChildIteratorFn(type, fn)

set the component child iterator function

set the component child iterator function. Called during inspection

PARAMETERS

type - the type

fn - child iterator function


ComponentTypeSetPropertyIteratorFn(type, fn)

set the component property iterator function

set the component property iterator function. Called during inspection

PARAMETERS

type - the type

fn - property iterator function


ComponentTypeCreateCtx()

Context used when registering a new component type

Context used when registering a new component type

MEMBERS

m_Config - The config file

m_Factory - The resource factory

m_Register - The game object registry

m_Script - The shared script context

m_Contexts - Mappings between names and contextx


dmScript::PostDDF(message, sender, receiver, function_ref, unref_function_after_call)

Sends a script message

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

PARAMETERS

message - The ddf message to send

sender - The sender

receiver - The receiver

function_ref - The function ref. 0 wil cause the "on_message" to be called

unref_function_after_call - call dmScript::UnrefInInstance on the function_ref after the dmScript::PCall is made

RETURN

success - true if successful


INVALID_INSTANCE_POOL_INDEX()

Value for an invalid instance index, this must be ...

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


HInstance

Gameobject instance handle

Gameobject instance handle


HScript

Script handle

Script handle


HScriptInstance

Script instance handle

Script instance handle


HRegister

Collection register.

Collection register.


HCollection

Gameobject collection handle

Gameobject collection handle


HPrototype

Gameobject prototype handle

Gameobject prototype handle


HProperties

Gameobject properties handle

Gameobject properties handle


Result

result enumeration

Result enumeration.

MEMBERS

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 -


PropertyType

property types

Property types.

MEMBERS

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 -


PropertyResult

property result

Property result.

MEMBERS

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 -


Playback

Playback type enum

Playback type enum


CreateResult

Create result enum

Create result enum.

MEMBERS

dmGameObject::CREATE_RESULT_OK -

dmGameObject::CREATE_RESULT_UNKNOWN_ERROR -


UpdateResult

Update result enum

Update result enum.

MEMBERS

dmGameObject::UPDATE_RESULT_OK -

dmGameObject::UPDATE_RESULT_UNKNOWN_ERROR -


PropertyValueType

Type of property value

Type of property value

MEMBERS

dmGameObject::PROP_VALUE_ARRAY -

dmGameObject::PROP_VALUE_HASHTABLE -


PropertyOptions()

Property Options

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

MEMBERS

m_Index - The index of the property to set, only applicable if property is array.

m_Key - The key of the property to set, only applicable if property is hashtable.

m_HasKey - A flag if structure contain m_Key value (it can't contain both)


PropertyVar()

property variant

Property variant that holds the data for a variable

MEMBERS

m_Type - property type

m_Number - A floating point value (union)

m_Hash - A hash value (union)

m_Url - An URL value (union)

m_V4 - A vector4 value (union)

m_Bool - A boolean value (union)


PropertyDesc()

Description of a property

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

m_ElementIds - For composite properties (float arrays), these ids name each element

m_Variant - Variant holding the value

m_ValuePtr - Pointer to the value, only set for mutable values. The actual data type is described by the variant.

m_ReadOnly - Determines whether we are permitted to write to this property.

m_ValueType - Indicates type of the property (of type PropertyValueType).

m_ArrayLength - Number of array entries, if the property is an array and zero otherwise. Max supported length is 2^14 (16384 elements)


UpdateContext()

Update context

Update context

MEMBERS

m_TimeScale - the scaling factor what was applied on the dt (i.e. the collection update time scale)

m_DT - the delta time elapsed since last frame (seconds)

m_FixedUpdateFrequency - Number of of calls per second to the FixedUpdate of each component


InputAction()

Container of input related information.

Container of input related information.


InputResult

Input result enum

Input result enum

MEMBERS

INPUT_RESULT_IGNORED - = 0

INPUT_RESULT_CONSUMED - = 1

INPUT_RESULT_UNKNOWN_ERROR - = -1000


GetMessageSocket(collection)

Retrieve the message socket for the specified coll...

Retrieve the message socket for the specified collection.

PARAMETERS

collection - Collection handle

RETURN

socket - The message socket of the specified collection


GetCollection(instance)

Retrieve a collection from the specified instance

Retrieve a collection from the specified instance

PARAMETERS

instance - Game object instance

RETURN

collection - The collection the specified instance belongs to


New(collection, prototype_name)

Create a new gameobject instance

Create a new gameobject instance

PARAMETERS

collection - Gameobject collection

prototype_name - |type: const char*] Prototype file name. May be 0.

RETURN

instance - New gameobject instance. NULL if any error occured


Delete(collection, instance, recursive)

Delete gameobject instance

Delete gameobject instance

PARAMETERS

collection - Gameobject collection

instance - Gameobject instance

recursive - If true, delete child hierarchy recursively in child to parent order (leaf first)


ConstructInstanceId(index)

Construct a hash of an instance id based on the in...

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

PARAMETERS

index - The index to base the id off of.

RETURN

id - hash of the instance id constructed.


AcquireInstanceIndex(collection)

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

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

PARAMETERS

collection - Collection from which to retrieve the instance index.

RETURN

instance - index from the index pool of collection.


AssignInstanceIndex(index, instance)

Assign an index to the instance, only if the insta...

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

PARAMETERS

index - The index to assign.

instance - The instance that should be assigned the index.


GetIdentifier(instance)

Get instance identifier

Get instance identifier

PARAMETERS

instance - Gameobject instance

RETURN

- Identifier. dmGameObject::UNNAMED_IDENTIFIER if not set.


SetIdentifier(collection, instance, identifier)

Set instance identifier. Must be unique within the...

Set instance identifier. Must be unique within the collection.

PARAMETERS

collection - Collection

instance - Instance

identifier - Identifier

RETURN

result - RESULT_OK on success


GetComponentId(instance, component_index, component_id)

Get component id from component index.

Get component id from component index.

PARAMETERS

instance - Instance

component_index - Component index

component_id - [type: dmhash_t* Component id as out-argument

RETURN

result - RESULT_OK if the component was found


SetPosition(instance, position)

set position

Set gameobject instance position

PARAMETERS

instance - Gameobject instance

position - New Position


GetPosition(instance)

get position

Get gameobject instance position

PARAMETERS

instance - Gameobject instance

RETURN

- Position


SetRotation(instance, position)

set rotation

Set gameobject instance rotation

PARAMETERS

instance - Gameobject instance

position - New Position


GetRotation(instance)

get rotation

Get gameobject instance rotation

PARAMETERS

instance - Gameobject instance

RETURN

- rotation


SetScale(instance, scale)

set uniform scale

Set gameobject instance uniform scale

PARAMETERS

instance - Gameobject instance

scale - New uniform scale


SetScale(instance, scale)

set scale

Set gameobject instance non-uniform scale

PARAMETERS

instance - Gameobject instance

scale - New uniform scale


GetUniformScale(instance)

get uniform scale

Get gameobject instance uniform scale

PARAMETERS

instance - Gameobject instance

RETURN

- Uniform scale


GetScale(instance)

get scale

Get gameobject instance scale

PARAMETERS

instance - Gameobject instance

RETURN

- Non-uniform scale


GetWorldPosition(instance)

get world position

Get gameobject instance world position

PARAMETERS

instance - Gameobject instance

RETURN

- World position


GetWorldRotation(instance)

get world rotation

Get gameobject instance world rotation

PARAMETERS

instance - Gameobject instance

RETURN

- World rotation


GetWorldScale(instance)

get world scale

Get game object instance world transform

PARAMETERS

instance - Gameobject instance

RETURN

- World scale


GetWorldUniformScale(instance)

get world uniform scale

Get game object instance uniform scale

PARAMETERS

instance - Gameobject instance

RETURN

- World uniform scale


GetWorldMatrix(instance)

get world matrix

Get game object instance world transform as Matrix4.

PARAMETERS

instance - Gameobject instance

RETURN

- World transform matrix.


GetWorldTransform(instance)

get world transform

Get game object instance world transform

PARAMETERS

instance - Gameobject instance

RETURN

- World transform


SetBone(instance, bone)

Set whether the instance should be flagged as a bo...

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

instance - Instance

bone - true if the instance is a bone


IsBone(instance)

Check whether the instance is flagged as a bone.

Check whether the instance is flagged as a bone.

PARAMETERS

instance - Instance

RETURN

result - True if flagged as a bone


SetBoneTransforms(instance, component_transform, transforms, transform_count)

Set the local transforms recursively of all instan...

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

instance - First Instance of the hierarchy to set

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

RETURN

Number - of instances found


DeleteBones(parent)

Recursively delete all instances flagged as bones ...

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

parent - Parent instance of the hierarchy


SceneNode()

scene graph traversal node

Opaque struct that holds info about the current node


SceneNodeIterator()

scene graph traversal iterator

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


TraverseGetRoot(regist, node)

Gets the top node of the whole game (the main coll...

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

PARAMETERS

regist - the full gameobject register

node - the node to inspect

RETURN

result - 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(node)

Get a scene node iterator for the nodes' children

Get a scene node iterator for the nodes' children

PARAMETERS

node - the parent node

RETURN

iterator - the iterator


TraverseIterateNext(it)

Step a scene node iterator to the next sibling

Step a scene node iterator to the next sibling

PARAMETERS

it - the iterator

RETURN

result - true if successful. false if the iterator is finished


SceneNodePropertyType

scene node property types

scene node property types

MEMBERS

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 -


SceneNodeProperty()

scene traversal node property

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

MEMBERS

m_NameHash - name

m_Type - type

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()

scene traversal node property

Holds the property

MEMBERS

m_Property - property


TraverseIterateProperties(node)

Create a scene node traversal property iterator

Create a scene node traversal property iterator

PARAMETERS

node - the node to inspect

RETURN

iterator - 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(it)

Steps the scene node traversal property iterator t...

Steps the scene node traversal property iterator to the next property

PARAMETERS

it - the iterator

RETURN

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