Leviathan  0.8.0.0
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 (const Scene::pointer &scene, RenderNode &parent, const std::string &meshname, const Material::pointer &material)
 
DLLEXPORT void Release ()
 
DLLEXPORT void ApplyMeshName ()
 
 REFERENCE_HANDLE_UNCOUNTED_TYPE (Model)
 
- Public Member Functions inherited from Leviathan::Component
 Component (COMPONENT_TYPE type)
 
 Component (const Component &)=delete
 
Componentoperator= (const Component &)=delete
 

Public Attributes

Renderable::pointer GraphicalObject
 The rendebale that has this model's mesh loaded. More...
 
std::string MeshName
 Changing this loads a different mesh. More...
 
Material::pointer ObjectMaterial
 Material set on the object. More...
 
- Public Attributes inherited from Leviathan::Component
bool Marked
 
const COMPONENT_TYPE Type
 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 233 of file Components.h.

Constructor & Destructor Documentation

◆ Model()

DLLEXPORT Model::Model ( const Scene::pointer &  scene,
RenderNode parent,
const std::string &  meshname,
const Material::pointer &  material 
)

Definition at line 287 of file Components.cpp.

288  :
289  Component(TYPE),
290  MeshName(meshname), ObjectMaterial(material)
291 {
292  Marked = false;
293 
294  // Skip if no graphics
295  if(!parent.Node)
296  return;
297 
298  GraphicalObject = Renderable::MakeShared<Renderable>(*parent.Node);
299 
300  ApplyMeshName();
301 
302  GraphicalObject->SetMaterial(ObjectMaterial);
303 }
Material::pointer ObjectMaterial
Material set on the object.
Definition: Components.h:251
Component(COMPONENT_TYPE type)
Definition: Component.h:54
std::string MeshName
Changing this loads a different mesh.
Definition: Components.h:248
Renderable::pointer GraphicalObject
The rendebale that has this model's mesh loaded.
Definition: Components.h:245
SceneNode::pointer Node
Definition: Components.h:94
static constexpr auto TYPE
Definition: Components.h:253
DLLEXPORT void ApplyMeshName()
Definition: Components.cpp:311

Member Function Documentation

◆ ApplyMeshName()

DLLEXPORT void Model::ApplyMeshName ( )

Definition at line 311 of file Components.cpp.

312 {
313  if(MeshName.empty()) {
314  GraphicalObject->SetMesh(nullptr);
315  return;
316  }
317 
318  // Find the mesh
319  auto mesh = Engine::Get()->GetGraphics()->LoadMeshByName(MeshName);
320 
321  GraphicalObject->SetMesh(Mesh::MakeShared<Mesh>(mesh));
322 }
DLLEXPORT bs::HMesh LoadMeshByName(const std::string &name)
Works the same as LoadShaderByName.
Definition: Graphics.cpp:611
std::string MeshName
Changing this loads a different mesh.
Definition: Components.h:248
Renderable::pointer GraphicalObject
The rendebale that has this model's mesh loaded.
Definition: Components.h:245
Graphics * GetGraphics()
Definition: Engine.h:185
static DLLEXPORT Engine * Get()
Definition: Engine.cpp:86

◆ REFERENCE_HANDLE_UNCOUNTED_TYPE()

Leviathan::Model::REFERENCE_HANDLE_UNCOUNTED_TYPE ( Model  )

◆ Release()

DLLEXPORT void Model::Release ( )

Definition at line 305 of file Components.cpp.

306 {
307  if(GraphicalObject)
308  GraphicalObject->DetachFromParent();
309 }
Renderable::pointer GraphicalObject
The rendebale that has this model's mesh loaded.
Definition: Components.h:245

Member Data Documentation

◆ GraphicalObject

Renderable::pointer Leviathan::Model::GraphicalObject

The rendebale that has this model's mesh loaded.

Definition at line 245 of file Components.h.

◆ MeshName

std::string Leviathan::Model::MeshName

Changing this loads a different mesh.

Definition at line 248 of file Components.h.

◆ ObjectMaterial

Material::pointer Leviathan::Model::ObjectMaterial

Material set on the object.

Definition at line 251 of file Components.h.

◆ TYPE

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

Definition at line 253 of file Components.h.


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