Collection factory

API for spawning collections from a collection factory component.

Namespace: dmGameSystem
Include: #include <dmsdk/gamesys/components/comp_collection_factory.h>
TYPES
CompGetConstantCallback Used in GetMaterialConstant to resolve a render co...
CompSetConstantCallback Used in SetMaterialConstant to set a render consta...
GuiNodeTypeCreateFunction
GuiNodeTypeDestroyFunction
HashState32 Found in hash.h
HComponentRenderConstants Render constants handle
CONSTANTS
SDF_EDGE_VALUE The edge value of an sdf glyph bitmap
ENUMS
FontGlyphCompression Describes what compression is used for the glyph i...
STRUCTS
struct CompGuiNodeTypeCtx Gui component node type create/destroy context
struct FontGlyph Represents a glyph
struct FontInfo Used to retrieve the information of a font.
struct FontResource Handle to font resource
struct GuiNodeType Gui component node type
struct PropVector3
struct PropVector4
FUNCTIONS
int AreRenderConstantsUpdated(dmGameSystem::HComponentRenderConstants constants) check if the constants have changed
int ClearRenderConstant(dmGameSystem::HComponentRenderConstants constants, dmhash_t name_hash) Removes a render constant from the container
dmGameObject::Result CompCollectionFactorySpawn(HCollectionFactoryWorld world, HCollectionFactoryComponent component, HCollection collection, const char* id_prefix, dmVMath::Point3 position, dmVMath::Quat rotation, dmVMath::Vector3 scale, dmGameObject::InstancePropertyContainers properties, dmGameObject::InstanceIdMap out_instances) Spawns a collection of gameobjects in a collection...
dmGameObject::Result CompFactorySpawn(HFactoryWorld world, HFactoryComponent component, HCollection collection, dmhash_t id, dmVMath::Point3 position, dmVMath::Quat rotation, dmVMath::Vector3 scale, dmGameObject::HPropertyContainer properties, dmGameObject::HInstance out_instance) Spawns a new gameobject instance in a collection u...
dmGameSystem::HComponentRenderConstants CreateRenderConstants() Create a new HComponentRenderConstants container
void DestroyRenderConstants(dmGameSystem::HComponentRenderConstants constants) Destroys a render constants container
void EnableRenderObjectConstants(dmRender::RenderObject* ro, dmGameSystem::HComponentRenderConstants constants) set the constants of a render object
bool GetRenderConstant(dmGameSystem::HComponentRenderConstants constants, dmhash_t name_hash, dmRender::Constant** out_constant) Destroys a render constants container
dmRender::HConstant GetRenderConstant(dmGameSystem::HComponentRenderConstants constants, uint32_t index) Get a render constant by index
uint32_t GetRenderConstantCount(dmGameSystem::HComponentRenderConstants constants) Get the number of render constants
dmGameObject::PropertyResult GetResourceProperty(const PropVector4& property, void* resource, dmGameObject::PropertyDesc& out_value) Gets the resource path hash
void HashRenderConstants(dmGameSystem::HComponentRenderConstants constants, HashState32* state) Hashes the constants
bool IsReferencingProperty(const PropVector3& property, dmhash_t query) Checks if the name matches any field in the proper...
bool IsReferencingProperty(const PropVector4& property, dmhash_t query) Checks if the name matches any field in the proper...
bool IsWhiteSpace(uint32_t c) Checks if a codepoint is a whitespace
dmResource::Result ResFontAddGlyph(FontResource* font, uint32_t codepoint, FontGlyph* glyph, void* imagedata)
dmResource::Result ResFontAddGlyphSource(dmResource::HFactory factory, dmhash_t fontc_hash, dmhash_t ttf_hash, uint32_t codepoint_min, uint32_t codepoint_max) add a new glyph range
dmRender::HFont ResFontGetHandle(FontResource* font)
dmResource::Result ResFontGetInfo(FontResource* font, FontInfo* info)
TTFResource* ResFontGetTTFResourceFromCodepoint(FontResource* font, uint32_t codepoint)
dmResource::Result ResFontRemoveGlyph(FontResource* font, uint32_t codepoint)
dmResource::Result ResFontRemoveGlyphSource(dmResource::HFactory factory, dmhash_t fontc_hash, dmhash_t ttf_hash) removes all glyph ranges associated with a ttfresource
void SetRenderConstant(dmGameSystem::HComponentRenderConstants constants, dmRender::HMaterial material, dmhash_t name_hash, uint32_t value_index, uint32_t* element_index, const dmGameObject::PropertyVar& var) Set a render constant by name. The constant must e...
void SetRenderConstant(dmGameSystem::HComponentRenderConstants constants, dmhash_t name_hash, dmVMath::Vector4* values, uint32_t num_values) Set a render constant by name. The constant must e...
dmGameObject::PropertyResult SetResourceProperty(dmGameObject::HFactory factory, const dmGameObject::PropertyVar& value, dmhash_t ext, void** out_resource) Updates the reference count of the resources, and ...
MACROS
DM_DECLARE_COMPGUI_TYPE(symbol, name, type_create_fn, type_destroy_fn) Registers a new gui node type to the Gui component

Functions

AreRenderConstantsUpdated

int AreRenderConstantsUpdated(dmGameSystem::HComponentRenderConstants constants)

check if the constants have changed

PARAMETERS

dmGameSystem::HComponentRenderConstants constants the constants

RETURNS

int non zero if the constants were changed

ClearRenderConstant

int ClearRenderConstant(dmGameSystem::HComponentRenderConstants constants, dmhash_t name_hash)

Removes a render constant from the container

PARAMETERS

dmGameSystem::HComponentRenderConstants constants the constants
dmhash_t name_hash the hashed name of the constant

RETURNS

int non zero if the constant was removed

CompCollectionFactorySpawn

dmGameObject::Result CompCollectionFactorySpawn(HCollectionFactoryWorld world, HCollectionFactoryComponent component, HCollection collection, const char* id_prefix, dmVMath::Point3 position, dmVMath::Quat rotation, dmVMath::Vector3 scale, dmGameObject::InstancePropertyContainers properties, dmGameObject::InstanceIdMap out_instances)

Spawns a collection of gameobjects in a collection using a collection factory component.

PARAMETERS

HCollectionFactoryWorld world Collection factory world
HCollectionFactoryComponent component Collection factory component
HCollection collection Gameobject collection to spawn into
const char* id_prefix Prefix for the spawned instance identifiers. Must start with a forward slash (/). Must be unique within the collection. Pass nullptr to automatically generate a unique identifier prefix (e.g. /collection1, /collection2 etc.).
dmVMath::Point3 position Position of the spawned objects
dmVMath::Quat rotation Rotation of the spawned objects
dmVMath::Vector3 scale Scale of the spawned objects
dmGameObject::InstancePropertyContainers properties Property containers with override properties
dmGameObject::InstanceIdMap out_instances A map with the spawned instance id's

RETURNS

dmGameObject::Result Result of the operation

CompFactorySpawn

dmGameObject::Result CompFactorySpawn(HFactoryWorld world, HFactoryComponent component, HCollection collection, dmhash_t id, dmVMath::Point3 position, dmVMath::Quat rotation, dmVMath::Vector3 scale, dmGameObject::HPropertyContainer properties, dmGameObject::HInstance out_instance)

Spawns a new gameobject instance in a collection using a factory component.

PARAMETERS

HFactoryWorld world Factory world
HFactoryComponent component Factory component
HCollection collection Gameobject collection to spawn into
dmhash_t id Identifier for the new instance. Must be unique within the collection. Pass 0 to automatically generate a unique identifier (e.g. /instance1, /instance2 etc.).
dmVMath::Point3 position Position of the spawned object
dmVMath::Quat rotation Rotation of the spawned object
dmVMath::Vector3 scale Scale of the spawned object
dmGameObject::HPropertyContainer properties Property container with override properties
dmGameObject::HInstance out_instance Output parameter for the new instance

RETURNS

dmGameObject::Result Result of the operation

CreateRenderConstants

dmGameSystem::HComponentRenderConstants CreateRenderConstants()

Create a new HComponentRenderConstants container

PARAMETERS

RETURNS

dmGameSystem::HComponentRenderConstants

DestroyRenderConstants

void DestroyRenderConstants(dmGameSystem::HComponentRenderConstants constants)

Destroys a render constants container

PARAMETERS

dmGameSystem::HComponentRenderConstants constants (must not be 0)

EnableRenderObjectConstants

void EnableRenderObjectConstants(dmRender::RenderObject* ro, dmGameSystem::HComponentRenderConstants constants)

set the constants of a render object

PARAMETERS

dmRender::RenderObject* ro the render object
dmGameSystem::HComponentRenderConstants constants the constants

GetRenderConstant

bool GetRenderConstant(dmGameSystem::HComponentRenderConstants constants, dmhash_t name_hash, dmRender::Constant** out_constant)

Destroys a render constants container

PARAMETERS

dmGameSystem::HComponentRenderConstants constants the constants
dmhash_t name_hash the hashed name of the property
dmRender::Constant** out_constant the pointer where to store the constant

RETURNS

bool returns true if the constant exists

GetRenderConstant

dmRender::HConstant GetRenderConstant(dmGameSystem::HComponentRenderConstants constants, uint32_t index)

Get a render constant by index

PARAMETERS

dmGameSystem::HComponentRenderConstants constants the constants
uint32_t index the index

RETURNS

dmRender::HConstant the pointer where to store the constant

GetRenderConstantCount

uint32_t GetRenderConstantCount(dmGameSystem::HComponentRenderConstants constants)

Get the number of render constants

PARAMETERS

dmGameSystem::HComponentRenderConstants constants the constants

RETURNS

uint32_t returns the number of set constants

GetResourceProperty

dmGameObject::PropertyResult GetResourceProperty(const PropVector4& property, void* resource, dmGameObject::PropertyDesc& out_value)

Gets the resource path hash

PARAMETERS

const PropVector4& property the property
void* resource the resource to get the
dmGameObject::PropertyDesc& out_value the out property

RETURNS

dmGameObject::PropertyResult RESULT_OK if successful

HashRenderConstants

void HashRenderConstants(dmGameSystem::HComponentRenderConstants constants, HashState32* state)

Hashes the constants

PARAMETERS

dmGameSystem::HComponentRenderConstants constants the constants
HashState32* state the hash state to update

IsReferencingProperty

bool IsReferencingProperty(const PropVector3& property, dmhash_t query)

Checks if the name matches any field in the property

PARAMETERS

const PropVector3& property the property
dmhash_t query the name to look for (e.g. hash("pos.x"))

RETURNS

bool true if the property contains the name

IsReferencingProperty

bool IsReferencingProperty(const PropVector4& property, dmhash_t query)

Checks if the name matches any field in the property

PARAMETERS

const PropVector4& property the property
dmhash_t query the name to look for (e.g. hash("pos.x"))

RETURNS

bool true if the property contains the name

IsWhiteSpace

bool IsWhiteSpace(uint32_t c)

Checks if a codepoint is a whitespace

PARAMETERS

uint32_t c the codepoint

RETURNS

bool true if it's a whitespace

ResFontAddGlyph

dmResource::Result ResFontAddGlyph(FontResource* font, uint32_t codepoint, FontGlyph* glyph, void* imagedata)

PARAMETERS

FontResource* font The font resource to modify
uint32_t codepoint The glyph codepoint
FontGlyph* glyph The glyph meta data
void* imagedata The bitmap or sdf data. May be null for e.g. white space characters. The font will now own this data.

RETURNS

dmResource::Result RESULT_OK if successful

ResFontAddGlyphSource

dmResource::Result ResFontAddGlyphSource(dmResource::HFactory factory, dmhash_t fontc_hash, dmhash_t ttf_hash, uint32_t codepoint_min, uint32_t codepoint_max)

Add a new glyph range

PARAMETERS

dmResource::HFactory factory The factory
dmhash_t fontc_hash The font path hash (.fontc)
dmhash_t ttf_hash The ttf path hash (.ttf)
uint32_t codepoint_min The glyph minimum codepoint (inclusive)
uint32_t codepoint_max The glyph maximum codepoint (inclusive)

RETURNS

dmResource::Result RESULT_OK if successful

ResFontGetHandle

dmRender::HFont ResFontGetHandle(FontResource* font)

PARAMETERS

FontResource* font The font resource

RETURNS

dmRender::HFont Handle to a font if successful. 0 otherwise.

ResFontGetInfo

dmResource::Result ResFontGetInfo(FontResource* font, FontInfo* info)

PARAMETERS

FontResource* font The font resource to modify
FontInfo* info The output info

RETURNS

dmResource::Result RESULT_OK if successful

ResFontGetTTFResourceFromCodepoint

TTFResource* ResFontGetTTFResourceFromCodepoint(FontResource* font, uint32_t codepoint)

PARAMETERS

FontResource* font The font resource
uint32_t codepoint The codepoint to query

RETURNS

TTFResource* The ttfresource if successful. 0 otherwise.

ResFontRemoveGlyph

dmResource::Result ResFontRemoveGlyph(FontResource* font, uint32_t codepoint)

PARAMETERS

FontResource* font The font resource
uint32_t codepoint The glyph codepoint

RETURNS

dmResource::Result RESULT_OK if successful

ResFontRemoveGlyphSource

dmResource::Result ResFontRemoveGlyphSource(dmResource::HFactory factory, dmhash_t fontc_hash, dmhash_t ttf_hash)

Removes all glyph ranges associated with a ttfresource

PARAMETERS

dmResource::HFactory factory The factory
dmhash_t fontc_hash The font path hash (.fontc)
dmhash_t ttf_hash The ttf path hash (.ttf)

RETURNS

dmResource::Result RESULT_OK if successful

SetRenderConstant

void SetRenderConstant(dmGameSystem::HComponentRenderConstants constants, dmRender::HMaterial material, dmhash_t name_hash, uint32_t value_index, uint32_t* element_index, const dmGameObject::PropertyVar& var)

Set a render constant by name. The constant must exist in the material

PARAMETERS

dmGameSystem::HComponentRenderConstants constants the render constants buffer
dmRender::HMaterial material the material to get default values from if constant didn't already exist in the render constants buffer
dmhash_t name_hash the hashed name of the constant
uint32_t value_index index of the constant value to set, if the constant is an array
uint32_t* element_index pointer to the index of the element (in range [0,3]). May be 0
const dmGameObject::PropertyVar& var the constant value

SetRenderConstant

void SetRenderConstant(dmGameSystem::HComponentRenderConstants constants, dmhash_t name_hash, dmVMath::Vector4* values, uint32_t num_values)

Set a render constant by name. The constant must exist in the material

PARAMETERS

dmGameSystem::HComponentRenderConstants constants the constants
dmhash_t name_hash the hashed name of the constant
dmVMath::Vector4* values the values
uint32_t num_values number of values in the array

SetResourceProperty

dmGameObject::PropertyResult SetResourceProperty(dmGameObject::HFactory factory, const dmGameObject::PropertyVar& value, dmhash_t ext, void** out_resource)

Updates the reference count of the resources, and returns the new resource.

PARAMETERS

dmGameObject::HFactory factory the factory
const dmGameObject::PropertyVar& value the property containing the hash of the resources to get
dmhash_t ext the hash of the resource file suffix (without the "."). E.g. hash("spritec")
void** out_resource pointer to the current resource. Will also get the pointer to the new resource.

RETURNS

dmGameObject::PropertyResult RESULT_OK if successful

Structs

CompGuiNodeTypeCtx

TYPE

struct CompGuiNodeTypeCtx

Gui component node type create/destroy context


FontGlyph

TYPE

struct FontGlyph

Represents a glyph. If there's an associated image, it is of size width * height * channels.

MEMBERS

float m_Width The glyph bounding width
float m_Height The glyph bounding height
int16_t m_ImageWidth The glyph image width
int16_t m_ImageHeight The glyph image height
int16_t m_Channels The glyph image height
float m_Advance The advance step of the glyph (in pixels)
float m_LeftBearing The left bearing of the glyph (in pixels)
float m_Ascent The ascent of the glyph. (in pixels)
float m_Descent The descent of the glyph. Positive! (in pixels)


FontInfo

TYPE

struct FontInfo

Used to retrieve the information of a font.

MEMBERS

uint32_t m_Size The size of the font (in points)
float m_ShadowX The shadow distance in X-axis (in pixels)
float m_ShadowY The shadow distance in Y-axis (in pixels)
uint32_t m_ShadowBlur The shadow blur spread [0.255] (in pixels)
float m_ShadowAlpha The shadow alpha value [0..255]
float m_Alpha The alpha value [0..255]
float m_OutlineAlpha The outline alpha value [0..255]
float m_OutlineWidth The outline size (in pixels)
dmRenderDDF::FontTextureFormat m_OutputFormat The type of font (bitmap or distance field)
dmRenderDDF::FontRenderMode m_RenderMode Single or multi channel


FontResource

TYPE

struct FontResource

Handle to font resource


GuiNodeType

TYPE

struct GuiNodeType

Gui component node type


PropVector3

TYPE

struct PropVector3


PropVector4

TYPE

struct PropVector4


Constants

SDF_EDGE_VALUE

The edge value of an sdf glyph bitmap


Types

CompGetConstantCallback

Used in GetMaterialConstant to resolve a render constant's value


CompSetConstantCallback

Used in SetMaterialConstant to set a render constant's value


GuiNodeTypeCreateFunction


GuiNodeTypeDestroyFunction


HashState32

Found in hash.h


HComponentRenderConstants

Render constants handle


Enums

FontGlyphCompression

Describes what compression is used for the glyph image

FONT_GLYPH_COMPRESSION_NONE No compression
FONT_GLYPH_COMPRESSION_DEFLATE Data is compressed using the deflate() algorithm

Macros

DM_DECLARE_COMPGUI_TYPE

Registers a new gui node type to the Gui component

symbol The unique C++ symbol name
name The name of the node type
type_create_fn the create function
type_destroy_fn the destroy function. May be 0