NAP
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
BoxMesh Class Reference

#include <boxmesh.h>

Public Member Functions

 BoxMesh (Core &core)
 
virtual bool init (utility::ErrorState &errorState) override
 
void setup ()
 
virtual MeshInstancegetMeshInstance () override
 
virtual const MeshInstancegetMeshInstance () const override
 
const math::BoxgetBox () const
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Public Attributes

glm::vec3 mSize = { 1.0f, 1.0f, 1.0f }
 Property: 'Dimensions' of the box. More...
 
glm::vec3 mPosition = { 0.0f, 0.0f, 0.0f }
 Property: 'Position' of the box. More...
 
RGBAColorFloat mColor = { 1.0f, 1.0f, 1.0f, 1.0f }
 Property: 'Color' color of the box. More...
 
EMemoryUsage mUsage = EMemoryUsage::Static
 Property: 'Usage' If the mesh is uploaded once or frequently updated. More...
 
ECullMode mCullMode = ECullMode::Back
 Property: 'CullMode' controls which triangles are culled, back facing, front facing etc. More...
 
EPolygonMode mPolygonMode = EPolygonMode::Fill
 Property: 'PolygonMode' Polygon rasterization mode (fill, line, points) More...
 
bool mFlipNormals = false
 Property: 'FlipNormals' Whether to flip the box normals such that they point inwards. More...
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Protected Member Functions

void constructBox (const math::Box &box, nap::MeshInstance &mesh)
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 

Description

Predefined box mesh with additional uv, color and normal vertex attributes. The UV coordinates are always 0-1. The box consists of 6 planes. The vertices of the individual planes are not shared.

Inheritance diagram for BoxMesh:
[legend]
Collaboration diagram for BoxMesh:
[legend]

Constructor & Destructor Documentation

◆ BoxMesh()

BoxMesh ( Core core)

Member Function Documentation

◆ constructBox()

void constructBox ( const math::Box box,
nap::MeshInstance mesh 
)
protected

Constructs the mesh based on the given dimensions

Parameters
boxthe box to build the mesh from
meshthe mesh that is constructed

◆ getBox()

const math::Box& getBox ( ) const
Returns
the box that wraps the mesh

◆ getMeshInstance() [1/2]

virtual const MeshInstance& getMeshInstance ( ) const
overridevirtual
Returns
the mesh instance that can be rendered to screen

Implements IMesh.

◆ getMeshInstance() [2/2]

virtual MeshInstance& getMeshInstance ( )
overridevirtual
Returns
the mesh instance that can be rendered to screen

Implements IMesh.

◆ init()

virtual bool init ( utility::ErrorState errorState)
overridevirtual

Sets up and initializes the box as a mesh based on the provided parameters.

Parameters
errorStatecontains the error message if the mesh could not be created.
Returns
if the mesh was successfully created and initialized.

Reimplemented from Object.

◆ setup()

void setup ( )

Creates and prepares the mesh but doesn't initialize it. Call this when you want to prepare a box without creating the GPU representation. You have to manually call init() on the mesh instance afterwards.

Member Data Documentation

◆ mColor

RGBAColorFloat mColor = { 1.0f, 1.0f, 1.0f, 1.0f }

Property: 'Color' color of the box.

◆ mCullMode

Property: 'CullMode' controls which triangles are culled, back facing, front facing etc.

◆ mFlipNormals

bool mFlipNormals = false

Property: 'FlipNormals' Whether to flip the box normals such that they point inwards.

◆ mPolygonMode

Property: 'PolygonMode' Polygon rasterization mode (fill, line, points)

◆ mPosition

glm::vec3 mPosition = { 0.0f, 0.0f, 0.0f }

Property: 'Position' of the box.

◆ mSize

glm::vec3 mSize = { 1.0f, 1.0f, 1.0f }

Property: 'Dimensions' of the box.

◆ mUsage

Property: 'Usage' If the mesh is uploaded once or frequently updated.