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... |
FontInfo | Used to retrieve the information of a font. |
GuiNodeTypeCreateFunction | |
GuiNodeTypeDestroyFunction | |
HashState32 | Found in hash.h |
HComponentRenderConstants | Render constants handle |
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 FontResource | Handle to font resource |
struct GuiNodeType | Gui component node type |
struct PropVector3 | |
struct PropVector4 |
MACROS | |
---|---|
DM_DECLARE_COMPGUI_TYPE(symbol, name, type_create_fn, type_destroy_fn) | Registers a new gui node type to the Gui component |
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 |
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 |
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 |
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 |
dmGameSystem::HComponentRenderConstants CreateRenderConstants()
Create a new HComponentRenderConstants container
PARAMETERS
RETURNS
dmGameSystem::HComponentRenderConstants |
void DestroyRenderConstants(dmGameSystem::HComponentRenderConstants constants)
Destroys a render constants container
PARAMETERS
dmGameSystem::HComponentRenderConstants |
constants |
(must not be 0) |
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 |
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 |
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 |
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 |
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 |
void HashRenderConstants(dmGameSystem::HComponentRenderConstants constants, HashState32* state)
Hashes the constants
PARAMETERS
dmGameSystem::HComponentRenderConstants |
constants |
the constants |
HashState32* |
state |
the hash state to update |
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 |
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 |
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 |
dmResource::Result ResFontGetCacheCellSize(FontResource* font, uint32_t* width, uint32_t* height, uint32_t* max_ascent)
PARAMETERS
FontResource* |
font |
The font resource to modify |
uint32_t* |
width |
The cache cell width |
uint32_t* |
height |
The cache cell height |
uint32_t* |
max_ascent |
The distance from the top of the cell to the baseline. |
RETURNS
dmResource::Result |
RESULT_OK if successful |
dmRender::HFont ResFontGetHandle(FontResource* font)
PARAMETERS
FontResource* |
font |
The font resource to modify |
RETURNS
dmRender::HFont |
Handle to a font if successful. 0 otherwise. |
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 |
dmResource::Result ResFontGetLineHeight(FontResource* font, float* max_ascent, float* max_descent)
Get the font line height (max_ascent + max_descent)
PARAMETERS
FontResource* |
font |
The font resource to modify |
float* |
max_ascent |
The max distance above the base line of any glyph |
float* |
max_descent |
The max distance below the base line of any glyph |
RETURNS
dmResource::Result |
RESULT_OK if successful |
bool ResFontHasGlyph(FontResource* font, uint32_t codepoint)
PARAMETERS
FontResource* |
font |
The font resource |
uint32_t |
codepoint |
The glyph codepoint |
RETURNS
bool |
true if the glyph already exists |
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 |
dmResource::Result ResFontSetCacheCellSize(FontResource* font, uint32_t cell_width, uint32_t cell_height, uint32_t max_ascent)
Resets the glyph cache and sets the cell size.
PARAMETERS
FontResource* |
font |
The font resource to modify |
uint32_t |
cell_width |
The width of a glyph cache cell |
uint32_t |
cell_height |
The height of a glyph cache cell |
uint32_t |
max_ascent |
The height of a glyph cache cell |
RETURNS
dmResource::Result |
RESULT_OK if successful |
dmResource::Result ResFontSetLineHeight(FontResource* font, float max_ascent, float max_descent)
Set the font line height, by specifying the max ascent and descent
PARAMETERS
FontResource* |
font |
The font resource to modify |
float |
max_ascent |
The max distance above the base line of any glyph |
float |
max_descent |
The max distance below the base line of any glyph |
RETURNS
dmResource::Result |
RESULT_OK if successful |
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 |
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 |
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 |
TYPE
struct CompGuiNodeTypeCtx
Gui component node type create/destroy context
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) |
TYPE
struct FontResource
Handle to font resource
TYPE
struct GuiNodeType
Gui component node type
TYPE
struct PropVector3
TYPE
struct PropVector4
Used in GetMaterialConstant to resolve a render constant's value
Used in SetMaterialConstant to set a render constant's value
Used to retrieve the information of a font.
Found in hash.h
Render constants handle
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 |
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 |