Leviathan  0.8.0.0
Leviathan game engine
Leviathan::Renderable Class Reference

Implements a basic renderable rendering a Mesh with a Material. More...

#include <Renderable.h>

+ Inheritance diagram for Leviathan::Renderable:

Public Member Functions

DLLEXPORT void SetMaterial (const Material::pointer &material)
 
DLLEXPORT void SetMesh (const Mesh::pointer &mesh)
 
 REFERENCE_COUNTED_PTR_TYPE (Renderable)
 
- Public Member Functions inherited from Leviathan::SceneAttachable
DLLEXPORT ~SceneAttachable ()
 
DLLEXPORT void DetachFromParent ()
 Detaches this from parent if attached. More...
 
SceneNodeGetParent () const
 
bool HasParent () const
 
 REFERENCE_COUNTED_PTR_TYPE (SceneAttachable)
 
- Public Member Functions inherited from Leviathan::ReferenceCounted
 ReferenceCounted (const ReferenceCounted &other)=delete
 
ReferenceCountedoperator= (const ReferenceCounted &other)=delete
 
FORCE_INLINE void AddRef () const
 
FORCE_INLINE void Release () const
 removes a reference and deletes the object if reference count reaches zero More...
 
FORCE_INLINE void AddRef ()
 
FORCE_INLINE void Release ()
 
int32_t GetRefCount () const
 Returns the reference count. More...
 

Protected Member Functions

DLLEXPORT Renderable (SceneNode &parent)
 
virtual DLLEXPORT void OnAttachedToParent (SceneNode &parent) override
 
virtual DLLEXPORT void OnDetachedFromParent (SceneNode &oldparent) override
 
- Protected Member Functions inherited from Leviathan::SceneAttachable
DLLEXPORT void NotifyDetachParent (SceneNode &oldparent)
 
DLLEXPORT void NotifyAttachParent (SceneNode &parent)
 
virtual DLLEXPORT void PrepareToRender ()
 
- Protected Member Functions inherited from Leviathan::ReferenceCounted
DLLEXPORT ReferenceCounted ()
 
virtual DLLEXPORT ~ReferenceCounted ()
 

Protected Attributes

friend ReferenceCounted
 

Additional Inherited Members

- Public Types inherited from Leviathan::ReferenceCounted
using basepointer = boost::intrusive_ptr< ReferenceCounted >
 
using refcountedpointer = boost::intrusive_ptr< ReferenceCounted >
 
- Static Public Member Functions inherited from Leviathan::ReferenceCounted
template<class ActualType >
static boost::intrusive_ptr< ActualType > WrapPtr (ActualType *ptr)
 Creates an intrusive_ptr from raw pointer. More...
 
template<class ActualType , class... Args>
static boost::intrusive_ptr< ActualType > MakeShared (Args &&... args)
 Constructs a new instance and wraps it. More...
 

Detailed Description

Implements a basic renderable rendering a Mesh with a Material.

Definition at line 13 of file Renderable.h.

Constructor & Destructor Documentation

◆ Renderable()

DLLEXPORT Renderable::Renderable ( SceneNode parent)
protected

Definition at line 10 of file Renderable.cpp.

11 {
12  parent.AttachObject(this);
13 
14  LEVIATHAN_ASSERT(GraphicalObject, "GraphicalObject didn't get initialized");
15 }
#define LEVIATHAN_ASSERT(x, msg)
Definition: Define.h:100
DLLEXPORT void AttachObject(const SceneAttachable::pointer &object)
Attaches an object to this SceneNode.
Definition: SceneNode.cpp:68

Member Function Documentation

◆ OnAttachedToParent()

DLLEXPORT void Renderable::OnAttachedToParent ( SceneNode parent)
overrideprotectedvirtual

Reimplemented from Leviathan::SceneAttachable.

Definition at line 17 of file Renderable.cpp.

18 {
19  GraphicalObject = parent.GetInternal()->addComponent<bs::CRenderable>();
20  GraphicalObject->setLayer(1 << parent.GetScene()->GetInternal());
21 }
Scene * GetScene() const
Definition: SceneNode.h:158
int GetInternal()
Definition: Scene.h:38
bs::HSceneObject GetInternal()
Definition: SceneNode.h:171

◆ OnDetachedFromParent()

DLLEXPORT void Renderable::OnDetachedFromParent ( SceneNode oldparent)
overrideprotectedvirtual

Reimplemented from Leviathan::SceneAttachable.

Definition at line 23 of file Renderable.cpp.

24 {
25  if(GraphicalObject)
26  GraphicalObject->destroy();
27 
28  GraphicalObject = nullptr;
29 }

◆ REFERENCE_COUNTED_PTR_TYPE()

Leviathan::Renderable::REFERENCE_COUNTED_PTR_TYPE ( Renderable  )

◆ SetMaterial()

DLLEXPORT void Renderable::SetMaterial ( const Material::pointer &  material)

Definition at line 31 of file Renderable.cpp.

32 {
33  _Material = material;
34 
35  if(!GraphicalObject)
36  return;
37 
38  if(!_Material || !_Material->GetInternal()) {
39  GraphicalObject->setMaterial(nullptr);
40  } else {
41  GraphicalObject->setMaterial(_Material->GetInternal());
42  }
43 }

◆ SetMesh()

DLLEXPORT void Renderable::SetMesh ( const Mesh::pointer &  mesh)

Definition at line 45 of file Renderable.cpp.

46 {
47  _Mesh = mesh;
48 
49  if(!GraphicalObject)
50  return;
51 
52  if(!_Mesh || !_Mesh->GetInternal()) {
53  GraphicalObject->setMesh(nullptr);
54  } else {
55  GraphicalObject->setMesh(_Mesh->GetInternal());
56  }
57 }

Member Data Documentation

◆ ReferenceCounted

friend Leviathan::Renderable::ReferenceCounted
protected

Definition at line 17 of file Renderable.h.


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