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

Base class for primitive shape components (Cube, Sphere, Plane). Supports multi-instance rendering within a single component, custom materials, and hardware instancing. More...

#include <Primitive/CPrimitive.h>

Inheritance diagram for Skylicht::CPrimitive:
Skylicht::CEntityHandler Skylicht::CComponentSystem Skylicht::IActivatorObject Skylicht::CCube Skylicht::CPlane Skylicht::CSphere

Public Member Functions

CEntityaddPrimitive (const core::vector3df &pos, const core::vector3df &rotDeg, const core::vector3df &scale)
 Add a primitive instance to this component.
CMaterialgetMaterial ()
 Get the active material.
CMeshgetMesh ()
 Get the internal mesh used for rendering.
const SColorgetColor ()
 Get the default material color.
void setColor (const SColor &color)
 Set the default material color.
void setCustomMaterial (CMaterial *material)
 Set a custom material for all instances.
void setInstancing (bool b)
 Enable or disable hardware instancing.
bool isInstancing ()
 Check if hardware instancing is enabled.
void setEnableNormalMap (bool b)
 Enable or disable normal map support (uses tangent vertices).
bool isUseNormalMap ()
 Check if normal map is enabled.
CPrimiviteData::EPrimitive getType ()
 Get the primitive type.
Public Member Functions inherited from Skylicht::CEntityHandler
virtual void updateComponent ()
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 initComponent ()
virtual CObjectSerializablecreateSerializable ()
virtual void loadSerializable (CObjectSerializable *object)
virtual CEntityspawn ()
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

CPrimiviteData::EPrimitive m_type
SColor m_color
bool m_instancing
bool m_useCustomMaterial
bool m_useNormalMap
CMaterialm_material
CMaterialm_customMaterial
std::string m_materialPath
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

Base class for primitive shape components (Cube, Sphere, Plane). Supports multi-instance rendering within a single component, custom materials, and hardware instancing.

Note
By default, primitives use Deferred shaders, which means they will only render on a Deferred Pipeline. If you are using a Forward Pipeline (common on mobile), you must call setCustomMaterial() with a material that uses a forward-compatible shader.

Example

// Create a component that manages multiple cube instances
CGameObject* cubeManager = zone->createEmptyObject();
CCube* cubes = cubeManager->addComponent<CCube>();
cubes->setInstancing(true); // Enable hardware instancing for performance
// Add individual primitives at different positions/rotations
cubes->addPrimitive(core::vector3df(0, 0, 0), core::vector3df(0, 0, 0), core::vector3df(1, 1, 1));
cubes->addPrimitive(core::vector3df(2, 0, 0), core::vector3df(45, 45, 0), core::vector3df(1, 2, 1));
Component for rendering cube primitives.
Definition CCube.h:44
This object class stores information for a GameObject.
Definition CGameObject.h:52
void setInstancing(bool b)
Enable or disable hardware instancing.
CEntity * addPrimitive(const core::vector3df &pos, const core::vector3df &rotDeg, const core::vector3df &scale)
Add a primitive instance to this component.
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445

Member Function Documentation

◆ addPrimitive()

CEntity * Skylicht::CPrimitive::addPrimitive ( const core::vector3df & pos,
const core::vector3df & rotDeg,
const core::vector3df & scale )

Add a primitive instance to this component.

Parameters
posRelative position.
rotDegRelative rotation in degrees.
scaleRelative scale.
Returns
Pointer to the created entity.

◆ createSerializable()

virtual CObjectSerializable * Skylicht::CPrimitive::createSerializable ( )
protectedvirtual

Reimplemented from Skylicht::CComponentSystem.

◆ getColor()

const SColor & Skylicht::CPrimitive::getColor ( )
inline

Get the default material color.

Returns
SColor value.

◆ getMaterial()

CMaterial * Skylicht::CPrimitive::getMaterial ( )

Get the active material.

Returns
Pointer to CMaterial.
Note
By default, this returns the internal material which is loaded with a Deferred shader. It will not render correctly on a Forward Pipeline unless a custom material is set.

◆ getMesh()

CMesh * Skylicht::CPrimitive::getMesh ( )

Get the internal mesh used for rendering.

Returns
Pointer to CMesh.

◆ getType()

CPrimiviteData::EPrimitive Skylicht::CPrimitive::getType ( )
inline

Get the primitive type.

Returns
EPrimitive value.

◆ initComponent()

virtual void Skylicht::CPrimitive::initComponent ( )
protectedvirtual

Reimplemented from Skylicht::CEntityHandler.

◆ isInstancing()

bool Skylicht::CPrimitive::isInstancing ( )
inline

Check if hardware instancing is enabled.

Returns
True if enabled.

◆ isUseNormalMap()

bool Skylicht::CPrimitive::isUseNormalMap ( )
inline

Check if normal map is enabled.

Returns
True if enabled.

◆ loadSerializable()

virtual void Skylicht::CPrimitive::loadSerializable ( CObjectSerializable * object)
protectedvirtual

Reimplemented from Skylicht::CComponentSystem.

◆ setColor()

void Skylicht::CPrimitive::setColor ( const SColor & color)

Set the default material color.

Parameters
colorNew color.

◆ setCustomMaterial()

void Skylicht::CPrimitive::setCustomMaterial ( CMaterial * material)

Set a custom material for all instances.

Parameters
materialPointer to CMaterial.

◆ setEnableNormalMap()

void Skylicht::CPrimitive::setEnableNormalMap ( bool b)
inline

Enable or disable normal map support (uses tangent vertices).

Parameters
bTrue to enable.

◆ setInstancing()

void Skylicht::CPrimitive::setInstancing ( bool b)

Enable or disable hardware instancing.

Parameters
bTrue to enable instancing.

◆ spawn()

virtual CEntity * Skylicht::CPrimitive::spawn ( )
protectedvirtual

Reimplemented from Skylicht::CEntityHandler.


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