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

The object class helps to initialize a model from a path or prefab, and gets the model's material to draw it on the screen. More...

#include <RenderMesh/CRenderMesh.h>

Inheritance diagram for Skylicht::CRenderMesh:
Skylicht::CEntityHandler Skylicht::CComponentSystem Skylicht::IActivatorObject

Public Member Functions

virtual void initComponent ()
virtual void updateComponent ()
virtual CObjectSerializablecreateSerializable ()
virtual void loadSerializable (CObjectSerializable *object)
void refreshModelAndMaterial (bool reloadModel=true)
void initFromPrefab (CEntityPrefab *prefab)
void initFromMeshFile (const char *path, bool loadNormalMap=true, bool loadTexcoord2=false)
void initMaterialFromFile (const char *material)
void changeMaterialFromFile (const char *material)
void changeShaderForAllMaterials (const char *shader)
void initMaterial (ArrayMaterial &materials, bool cloneMaterial=false)
void enableOptimizeForRender (bool b)
void enableInstancing (bool b)
void enableInstancingMaterialForEntity (bool b)
void setShadowCasting (bool b)
bool isShadowCasting ()
void setLightLayers (u32 layers)
u32 getLightLayers ()
void removeRenderMeshName (const char *name)
void removeRenderMesh (CRenderMeshData *renderMesh)
void removeMaterials (ArrayMaterial &materials)
void attachMeshFromPrefab (CEntityPrefab *prefab, std::vector< std::string > &names, ArrayMaterial &materials, bool cloneMaterial=false, bool resetBoneTransform=false)
void resetDefaultTransform (CEntityPrefab *prefab, std::vector< std::string > &transformsName)
int getMaterialCount ()
const std::string & getMeshResource ()
const std::string & getMaterialResource ()
CMaterialgetMaterial (int i)
std::vector< CRenderMeshData * > & getRenderers ()
std::vector< CWorldTransformData * > & getRenderTransforms ()
std::vector< CWorldTransformData * > & getAllTransforms ()
core::aabbox3df getBounds ()
void printEntites ()
CWorldTransformDatagetChildTransform (const char *name)
int getChildTransforms (const char *name, std::vector< CWorldTransformData * > &childs)
int getChildTransforms (CWorldTransformData *transform, std::vector< CWorldTransformData * > &childs, size_t from=0)
Public Member Functions inherited from Skylicht::CEntityHandler
virtual void onUpdateCullingLayer (u32 mask)
CEntitysearchEntityByID (const char *id)
virtual CEntitycreateEntity ()
virtual CEntitycreateEntity (CEntity *parent)
virtual CEntityspawn ()
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

void initNoOptimizeFromPrefab (CEntityPrefab *prefab)
void initOptimizeFromPrefab (CEntityPrefab *prefab)
void releaseMaterial ()
void releaseEntities ()
bool 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
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_optimizeForRender
bool m_loadTexcoord2
bool m_loadNormal
bool m_fixInverseNormal
bool m_enableInstancing
u32 m_lightLayers
bool m_shadowCasting
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

The object class helps to initialize a model from a path or prefab, and gets the model's material to draw it on the screen.

CRenderMesh can handle both static and skinned meshes. To ensure it renders properly, you need to use the right shader for the specific mesh type. You'll need to check if the input model has attributes like normals or texcoord2.

CRenderMesh supports instancing multiple objects, but the shader from the material must be linked to an instancing shader.

High-level component for rendering standard 3D models.

If not, the model will not render. You can find more information in CShader, or in some example shaders in BuiltIn\Shader\Toon, BuiltIn\Shader\SpecularGlossiness\Deferred

You can initialize CRenderMesh using either the Editor or code

std::string folder = "SampleModels/BlendShape/";
std::string modelPath = "SampleModels/BlendShape/Cat.fbx";
std::string materialPath = "SampleModels/BlendShape/Cat.mat";
CEntityPrefab* model = CMeshManager::getInstance()->loadModel(modelPath.c_str(), folder.c_str());
if (model)
{
CGameObject* renderObj = scene->createEmptyObject();
CRenderMesh* renderer = renderObj->addComponent<CRenderMesh>();
renderer->initFromPrefab(model);
std::vector<std::string> folders;
ArrayMaterial& materials = CMaterialManager::getInstance()->loadMaterial(
materialPath.c_str(),
true,
folders);
renderer->initMaterial(materials);
renderObj->addComponent<CIndirectLighting>();
}
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 holds the parameters for indirect lighting like SH or AmbientColor or Lightmap.
Definition CIndirectLighting.h:47
All scene management can be found in this namespace: Mesh loading, special scene nodes like octrees a...
Definition CIndexBuffer.h:13
See also
CEntityPrefab, CMaterial, CMeshManager, CMaterialManager

Member Function Documentation

◆ createSerializable()

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

Reimplemented from Skylicht::CComponentSystem.

◆ initComponent()

virtual void Skylicht::CRenderMesh::initComponent ( )
virtual

Reimplemented from Skylicht::CEntityHandler.

◆ loadSerializable()

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

Reimplemented from Skylicht::CComponentSystem.

◆ updateComponent()

virtual void Skylicht::CRenderMesh::updateComponent ( )
virtual

Reimplemented from Skylicht::CEntityHandler.


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