Visual Computing Library
Loading...
Searching...
No Matches
vcl::DrawableObject Class Referenceabstract

The DrawableObject class is the base class for all the objects that can be drawn in a 3D viewer. More...

#include <vclib/render/drawable/drawable_object.h>

Inheritance diagram for vcl::DrawableObject:

Public Member Functions

 DrawableObject ()=default
 Empty constructor.
 
virtual void init ()
 This member function is called after the initialization of the Context. It must initialize and bind data to the GPU like buffers and textures.
 
virtual void draw (uint viewId=0) const =0
 This member function must draw the object. It will be called at every frame.
 
virtual vcl::Box3d boundingBox () const =0
 This member function is used to find a good camera position to render object. It should return the the bounding box of the object. Return a null bounding box if the object shouldn't influence the position of the camera.
 
virtual std::shared_ptr< DrawableObjectclone () const &=0
 This member function is used to create a new copy of the DrawableObject. Each derived class must implement this member function, that returns a shared pointer pointing to a copy of the current one. for more details about this paradigm, check polimorphism clone in modern c++: https://www.fluentcpp.com/2017/09/08/make-polymorphic-copy-modern-cpp/.
 
virtual std::shared_ptr< DrawableObjectclone () &&=0
 This member function is used to create a new DrawableObject that is a moved from the current one. This object will be destroyed after the call of this function. Each derived class must implement this member function, that returns a shared pointer pointing to the moved object. For more details about this paradigm, check polimorphism clone in modern c++: https://www.fluentcpp.com/2017/09/08/make-polymorphic-copy-modern-cpp/.
 
virtual bool isVisible () const =0
 This member function is used to check if the object is visible.
 
virtual void setVisibility (bool vis)=0
 This member function is used to set the visibility of the object.
 
virtual const std::string & name () const
 Returns the name of the object.
 
virtual std::string & name ()
 Returns a reference of the name of the object, that allows to modify it.
 
const std::string & info () const
 Returns the info of the object.
 
std::string & info ()
 Returns a reference of the info of the object, that allows to modify it.
 

Protected Member Functions

void swap (DrawableObject &other)
 Utility swap function that allows to swap the content of two DrawableObject instances.
 

Private Attributes

std::string mName
 Name of the object.
 
std::string mInfo
 Info about the object.
 

Detailed Description

The DrawableObject class is the base class for all the objects that can be drawn in a 3D viewer.

The DrawableObject class stores only an attribute that represents the name of the object, that will be used to identify it in the viewer.

A class that inherits from DrawableObject must implement the following member functions:

There is also a member function that can be implemented, but it is not mandatory:

For more details about these member functions, check the documentation of each one.

Constructor & Destructor Documentation

◆ DrawableObject()

vcl::DrawableObject::DrawableObject ( )
default

Empty constructor.

<

Member Function Documentation

◆ boundingBox()

virtual vcl::Box3d vcl::DrawableObject::boundingBox ( ) const
pure virtual

This member function is used to find a good camera position to render object. It should return the the bounding box of the object. Return a null bounding box if the object shouldn't influence the position of the camera.

Returns
The bounding box of the object.

Implemented in vcl::DrawableObjectVector, vcl::DrawableAxis, vcl::DrawableDirectionalLight, vcl::DrawableMeshBGFX< MeshType >, vcl::DrawableTrackBall, and vcl::DrawableMeshOpenGL2< MeshType >.

◆ clone() [1/2]

virtual std::shared_ptr< DrawableObject > vcl::DrawableObject::clone ( ) &&
pure virtual

This member function is used to create a new DrawableObject that is a moved from the current one. This object will be destroyed after the call of this function. Each derived class must implement this member function, that returns a shared pointer pointing to the moved object. For more details about this paradigm, check polimorphism clone in modern c++: https://www.fluentcpp.com/2017/09/08/make-polymorphic-copy-modern-cpp/.

Generally, if your class that inherits from DrawableObject is called MyObject, the clone member function should be implemented as follows:

std::shared_ptr<DrawableObject> MyObject::clone() &&
{
return std::make_shared<MyObject>(std::move(*this));
}
Returns
A shared pointers that points to a new DrawableObject that is a moved from the current one.

Implemented in vcl::DrawableObjectVector, vcl::DrawableAxis, vcl::DrawableDirectionalLight, vcl::DrawableMeshBGFX< MeshType >, vcl::DrawableTrackBall, and vcl::DrawableMeshOpenGL2< MeshType >.

◆ clone() [2/2]

virtual std::shared_ptr< DrawableObject > vcl::DrawableObject::clone ( ) const &
pure virtual

This member function is used to create a new copy of the DrawableObject. Each derived class must implement this member function, that returns a shared pointer pointing to a copy of the current one. for more details about this paradigm, check polimorphism clone in modern c++: https://www.fluentcpp.com/2017/09/08/make-polymorphic-copy-modern-cpp/.

Generally, if your class that inherits from DrawableObject is called MyObject, the clone member function should be implemented as follows:

std::shared_ptr<DrawableObject> MyObject::clone() const&
{
return std::make_shared<MyObject>(*this);
}
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
Returns
A shared pointers that points to a new DrawableObject that is a copy of the current one.

Implemented in vcl::DrawableObjectVector, vcl::DrawableAxis, vcl::DrawableDirectionalLight, vcl::DrawableMeshBGFX< MeshType >, vcl::DrawableTrackBall, and vcl::DrawableMeshOpenGL2< MeshType >.

◆ draw()

virtual void vcl::DrawableObject::draw ( uint  viewId = 0) const
pure virtual

This member function must draw the object. It will be called at every frame.

Parameters
viewIdThe ID of the view to draw. It may be used depending on the rendering engine.

Implemented in vcl::DrawableObjectVector, vcl::DrawableAxis, vcl::DrawableDirectionalLight, vcl::DrawableMeshBGFX< MeshType >, vcl::DrawableTrackBall, and vcl::DrawableMeshOpenGL2< MeshType >.

◆ info() [1/2]

std::string & vcl::DrawableObject::info ( )
inline

Returns a reference of the info of the object, that allows to modify it.

Parameters
[in]infoThe info of the object.

◆ info() [2/2]

const std::string & vcl::DrawableObject::info ( ) const
inline

Returns the info of the object.

Returns
The info of the object.

◆ init()

virtual void vcl::DrawableObject::init ( )
inlinevirtual

This member function is called after the initialization of the Context. It must initialize and bind data to the GPU like buffers and textures.

Reimplemented in vcl::DrawableObjectVector, vcl::DrawableMeshBGFX< MeshType >, and vcl::DrawableMeshOpenGL2< MeshType >.

◆ isVisible()

virtual bool vcl::DrawableObject::isVisible ( ) const
pure virtual

This member function is used to check if the object is visible.

Returns
true if the object is visible;

Implemented in vcl::AbstractDrawableMesh, vcl::DrawableObjectVector, vcl::DrawableAxis, vcl::DrawableDirectionalLight, and vcl::DrawableTrackBall.

◆ name() [1/2]

virtual std::string & vcl::DrawableObject::name ( )
inlinevirtual

Returns a reference of the name of the object, that allows to modify it.

Parameters
[in]nameThe name of the object.

Reimplemented in vcl::DrawableMeshBGFX< MeshType >, and vcl::DrawableMeshOpenGL2< MeshType >.

◆ name() [2/2]

virtual const std::string & vcl::DrawableObject::name ( ) const
inlinevirtual

Returns the name of the object.

Returns
The name of the object.

Reimplemented in vcl::DrawableMeshBGFX< MeshType >, and vcl::DrawableMeshOpenGL2< MeshType >.

◆ setVisibility()

virtual void vcl::DrawableObject::setVisibility ( bool  vis)
pure virtual

This member function is used to set the visibility of the object.

Parameters
[in]vistrue if the object should be visible;

Implemented in vcl::AbstractDrawableMesh, vcl::DrawableObjectVector, vcl::DrawableAxis, vcl::DrawableDirectionalLight, vcl::DrawableMeshBGFX< MeshType >, and vcl::DrawableTrackBall.

◆ swap()

void vcl::DrawableObject::swap ( DrawableObject other)
inlineprotected

Utility swap function that allows to swap the content of two DrawableObject instances.

It is meant to be used by the derived classes to implement the swap member function (see the copy and swap idiom).

Parameters
[in]otherThe other DrawableObject to swap with.

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