Skylicht Engine
Loading...
Searching...
No Matches
Skylicht::CRenderMeshInstancing Class Reference

This object class is similar to CRenderMesh but is designed for optimized instanced rendering. More...

#include <RenderMesh/CRenderMeshInstancing.h>

Inheritance diagram for Skylicht::CRenderMeshInstancing:
Skylicht::CEntityHandler Skylicht::CComponentSystem Skylicht::IActivatorObject Skylicht::CRenderMeshInstancingVAT Skylicht::CRenderSkinnedInstancing

Public Member Functions

virtual void initComponent ()
virtual void updateComponent ()
virtual CObjectSerializablecreateSerializable ()
virtual void loadSerializable (CObjectSerializable *object)
virtual void refreshModelAndMaterial ()
virtual void initFromPrefab (CEntityPrefab *prefab)
virtual CEntityspawn ()
virtual CEntityspawn (const core::matrix4 &transform)
const std::string & getMeshResource ()
const std::string & getMaterialResource ()
void initFromMeshFile (const char *path, bool loadNormalMap=true, bool loadTexcoord2=false)
void initMaterialFromFile (const char *material)
void initMaterial (ArrayMaterial &materials, bool cloneMaterial=false)
void applyShareTransformBuffer ()
void applyShareMaterialBuffer ()
int getMaterialCount ()
CMaterialgetMaterial (int i)
core::array< CEntity * > & getBaseEntities ()
std::vector< CRenderMeshData * > & getRenderers ()
std::vector< CWorldTransformData * > & getRenderTransforms ()
std::vector< CWorldTransformData * > & getAllTransforms ()
Public Member Functions inherited from Skylicht::CEntityHandler
virtual void onUpdateCullingLayer (u32 mask)
CEntitysearchEntityByID (const char *id)
virtual CEntitycreateEntity ()
virtual CEntitycreateEntity (CEntity *parent)
virtual void removeEntity (CEntity *entity)
virtual void removeAllEntities ()
void regenerateEntityId ()
core::array< CEntity * > & getEntities ()
int getEntityCount ()
void getEntitiesTransforms (core::array< core::matrix4 > &result)
void setShadowCasting (bool b)
bool isShadowCasting ()
Public Member Functions inherited from Skylicht::CComponentSystem
const char * getName ()
virtual void reset ()
virtual void startComponent ()
virtual void endUpdate ()
virtual void onEnable (bool b)
void setEnable (bool b)
bool isEnable ()
CGameObject * getGameObject ()
void setEnableSerializable (bool b)
bool isSerializable ()
void addLinkComponent (CComponentSystem *comp)
void removeAllLink ()
Public Member Functions inherited from Skylicht::IActivatorObject
virtual ~IActivatorObject ()
 Virtual destructor for polymorphic activator objects.

Protected Member Functions

virtual void releaseMaterial ()
virtual void releaseEntities ()
virtual void releaseBaseEntities ()
void addRendererInstancing (CEntity *entity, CRenderMeshData *baseRenderMesh, CWorldTransformData *baseTransform)
void addMaterial (CMaterial *material)
Protected Member Functions inherited from Skylicht::CEntityHandler
void setEntities (CEntity **entities, u32 count)
void removeChilds (CEntity *entity)
Protected Member Functions inherited from Skylicht::CComponentSystem
void setOwner (CGameObject *obj)

Protected Attributes

CEntitym_root
core::array< CEntity * > m_baseEntities
std::vector< CWorldTransformData * > m_renderTransforms
std::vector< CWorldTransformData * > m_transforms
std::vector< CRenderMeshData * > m_renderers
ArrayMaterial m_materials
std::string m_meshFile
std::string m_materialFile
bool m_loadTexcoord2
bool m_loadNormal
bool m_fixInverseNormal
IVertexBufferm_instancingMaterials
IVertexBufferm_instancingTransform
IVertexBufferm_instancingLighting
int m_shareDataTransform
int m_shareDataMaterials
Protected Attributes inherited from Skylicht::CEntityHandler
core::array< CEntity * > m_entities
bool m_shadowCasting
Protected Attributes inherited from Skylicht::CComponentSystem
CGameObject * m_gameObject
bool m_enable
bool m_serializable
std::vector< CComponentSystem * > m_linkComponent

Additional Inherited Members

Static Public Member Functions inherited from Skylicht::CComponentSystem
static int useComponent (CComponentSystem *used)

Detailed Description

This object class is similar to CRenderMesh but is designed for optimized instanced rendering.

Instead of creating multiple game objects, CRenderMeshInstancing limits this to optimize the number of update calls and the total number of entities by using a single game object.

Instead, a model becomes a child entity that stores its transform data.

CMeshManager* meshManager = CMeshManager::getInstance();
std::vector<std::string> searchTextureFolders;
ArrayMaterial envMaterials = CMaterialManager::getInstance()->loadMaterial("SampleBoids/Environment/Environment.mat", true, searchTextureFolders);
CEntityPrefab* groundPrefab = meshManager->loadModel("SampleBoids/Environment/1_Ground_1.fbx", NULL, true);
if (groundPrefab)
{
CGameObject* plane = zone->createEmptyObject();
CRenderMeshInstancing* meshInstancing = plane->addComponent<CRenderMeshInstancing>();
meshInstancing->initFromPrefab(groundPrefab);
meshInstancing->initMaterial(envMaterials);
for (int i = minBound; i <= maxBound; i++)
{
for (int j = minBound; j <= maxBound; j++)
{
CEntity* entity = meshInstancing->spawn();
CWorldTransformData* transform = GET_ENTITY_DATA(entity, CWorldTransformData);
transform->Relative.setTranslation(core::vector3df(i * space, 0.0f, j * space));
transform->Relative.setScale(scaleVector);
}
}
meshInstancing->applyShareTransformBuffer();
meshInstancing->applyShareMaterialBuffer();
plane->addComponent<CIndirectLighting>();
}
This is the object class that describes an entity.
Definition CEntity.h:58
This object class is created to store data in an array of multiple CEntities.
Definition CEntityPrefab.h:38
This object class stores information for a GameObject.
Definition CGameObject.h:52
This object class manages, load and converts model resources like .fbx, .dae, and ....
Definition CMeshManager.h:47
Definition CWorldTransformData.h:32
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445

Member Function Documentation

◆ createSerializable()

virtual CObjectSerializable * Skylicht::CRenderMeshInstancing::createSerializable ( )
virtual

Reimplemented from Skylicht::CComponentSystem.

◆ initComponent()

virtual void Skylicht::CRenderMeshInstancing::initComponent ( )
virtual

Reimplemented from Skylicht::CEntityHandler.

◆ loadSerializable()

virtual void Skylicht::CRenderMeshInstancing::loadSerializable ( CObjectSerializable * object)
virtual

Reimplemented from Skylicht::CComponentSystem.

◆ spawn()

virtual CEntity * Skylicht::CRenderMeshInstancing::spawn ( )
virtual

Reimplemented from Skylicht::CEntityHandler.

◆ updateComponent()

virtual void Skylicht::CRenderMeshInstancing::updateComponent ( )
virtual

Reimplemented from Skylicht::CEntityHandler.


The documentation for this class was generated from the following file: