Leviathan game engine
Leviathan::Model Class Reference

Entity has a model. More...

#include <Components.h>

+ Inheritance diagram for Leviathan::Model:

Public Member Functions

DLLEXPORT Model (bs::Scene *scene, RenderNode &parent, const std::string &meshname, const bs::HMaterial &material)
DLLEXPORT void Release ()
DLLEXPORT void ApplyMeshName ()
- Public Member Functions inherited from Leviathan::Component
 Component (COMPONENT_TYPE type)
 Component (const Component &)=delete
Componentoperator= (const Component &)=delete

Public Attributes

bs::HRenderable GraphicalObject
 The entity that has this model's mesh loaded. More...
std::string MeshName
bs::HMaterial Material
 Material set on the object. More...
- Public Attributes inherited from Leviathan::Component
bool Marked
 Type of this component, used for network serialization. More...

Static Public Attributes

static constexpr auto TYPE = COMPONENT_TYPE::Model

Detailed Description

Entity has a model.

Definition at line 232 of file Components.h.

Constructor & Destructor Documentation

◆ Model()

DLLEXPORT Model::Model ( bs::Scene scene,
RenderNode parent,
const std::string &  meshname,
const bs::HMaterial &  material 

Definition at line 294 of file Components.cpp.

295  :
296  Component(TYPE),
297  MeshName(meshname), Material(material)
298 {
299  Marked = false;
301  // Skip if no graphics
302  if(!parent.Node)
303  return;
305  GraphicalObject = parent.Node->addComponent<bs::CRenderable>();
307  // GraphicalObject->setLayer(1 << *parent.Scene);
308  GraphicalObject->setLayer(1 << *scene);
310  ApplyMeshName();
312  GraphicalObject->setMaterial(Material);
313 }
bs::HRenderable GraphicalObject
The entity that has this model's mesh loaded.
Definition: Components.h:244
Component(COMPONENT_TYPE type)
Definition: Component.h:54
std::string MeshName
Definition: Components.h:247
bs::HMaterial Material
Material set on the object.
Definition: Components.h:250
bs::HSceneObject Node
Definition: Components.h:91
static constexpr auto TYPE
Definition: Components.h:252
DLLEXPORT void ApplyMeshName()
Definition: Components.cpp:321

Member Function Documentation

◆ ApplyMeshName()

DLLEXPORT void Model::ApplyMeshName ( )

Definition at line 321 of file Components.cpp.

322 {
323  if(MeshName.empty()) {
324  GraphicalObject->setMesh(nullptr);
325  return;
326  }
328  // Find the mesh
329  auto mesh = Engine::Get()->GetGraphics()->LoadMeshByName(MeshName);
331  GraphicalObject->setMesh(mesh);
332 }
DLLEXPORT bs::HMesh LoadMeshByName(const std::string &name)
Works the same as LoadShaderByName.
Definition: Graphics.cpp:610
bs::HRenderable GraphicalObject
The entity that has this model's mesh loaded.
Definition: Components.h:244
std::string MeshName
Definition: Components.h:247
Graphics * GetGraphics()
Definition: Engine.h:185
static DLLEXPORT Engine * Get()
Definition: Engine.cpp:86



◆ Release()

DLLEXPORT void Model::Release ( )

Definition at line 315 of file Components.cpp.

316 {
317  if(GraphicalObject)
318  GraphicalObject->destroy();
319 }
bs::HRenderable GraphicalObject
The entity that has this model's mesh loaded.
Definition: Components.h:244

Member Data Documentation

◆ GraphicalObject

bs::HRenderable Leviathan::Model::GraphicalObject

The entity that has this model's mesh loaded.

Definition at line 244 of file Components.h.

◆ Material

bs::HMaterial Leviathan::Model::Material

Material set on the object.

Definition at line 250 of file Components.h.

◆ MeshName

std::string Leviathan::Model::MeshName
Changing this currently does nothing

Definition at line 247 of file Components.h.


constexpr auto Leviathan::Model::TYPE = COMPONENT_TYPE::Model

Definition at line 252 of file Components.h.

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