Game object functions

API for manipulating game objects

Namespace: dmGameObject
Include: #include <dmsdk/gameobject/gameobject.h>
ENUMS
Result result enumeration
PropertyType property types
PropertyResult property result
SceneNodePropertyType scene node property types
STRUCTS
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
FUNCTIONS
dmhash_t GetIdentifier(dmGameObject::HInstance instance) Get instance identifier
void SetPosition(dmGameObject::HInstance instance, dmGameObject::Point3 position) set position
dmGameObject::Point3 GetPosition(dmGameObject::HInstance instance) get position
void SetRotation(dmGameObject::HInstance instance,  position) set rotation
dmGameObject::Quat GetRotation(dmGameObject::HInstance instance) get rotation
void SetScale(dmGameObject::HInstance instance,  scale) set uniform scale
void SetScale(dmGameObject::HInstance instance,  scale) set scale
float GetUniformScale(dmGameObject::HInstance instance) get uniform scale
dmGameObject::Vector3 GetScale(dmGameObject::HInstance instance) get scale
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
float GetWorldUniformScale(dmGameObject::HInstance instance) get world uniform scale
dmGameObject::MAtrix4 GetWorldMatrix(dmGameObject::HInstance instance) get world matrix
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

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.

SetPosition

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

Set gameobject instance position

PARAMETERS

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

GetPosition

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

Get gameobject instance position

PARAMETERS

dmGameObject::HInstance instance Gameobject instance

RETURNS

dmGameObject::Point3 Position

SetRotation

void SetRotation(dmGameObject::HInstance instance,  position)

Set gameobject instance rotation

PARAMETERS

dmGameObject::HInstance instance Gameobject instance
position New Position

GetRotation

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

Get gameobject instance rotation

PARAMETERS

dmGameObject::HInstance instance Gameobject instance

RETURNS

dmGameObject::Quat rotation

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

GetUniformScale

float GetUniformScale(dmGameObject::HInstance instance)

Get gameobject instance uniform scale

PARAMETERS

dmGameObject::HInstance instance Gameobject instance

RETURNS

float Uniform scale

GetScale

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

Get gameobject instance scale

PARAMETERS

dmGameObject::HInstance instance Gameobject instance

RETURNS

dmGameObject::Vector3 Non-uniform scale

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

GetWorldUniformScale

float GetWorldUniformScale(dmGameObject::HInstance instance)

Get game object instance uniform scale

PARAMETERS

dmGameObject::HInstance instance Gameobject instance

RETURNS

float World 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.

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

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


Enums

Result

result enumeration

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

PropertyType

property types

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

PropertyResult

property result

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

SceneNodePropertyType

scene node property types

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