NAP
boxmesh.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // Local Includes
8 #include "mesh.h"
9 
10 // External Includes
11 #include <box.h>
12 #include <color.h>
13 
14 namespace nap
15 {
16  class RenderService;
17 
23  class NAPAPI BoxMesh : public IMesh
24  {
25  RTTI_ENABLE(IMesh)
26  public:
27 
28  BoxMesh(Core& core);
29 
35  virtual bool init(utility::ErrorState& errorState) override;
36 
42  void setup();
43 
47  virtual MeshInstance& getMeshInstance() override { return *mMeshInstance; }
48 
52  virtual const MeshInstance& getMeshInstance() const override { return *mMeshInstance; }
53 
57  const math::Box& getBox() const { return mBox; }
58 
59  public:
60  glm::vec3 mSize = { 1.0f, 1.0f, 1.0f };
61  glm::vec3 mPosition = { 0.0f, 0.0f, 0.0f };
62  RGBAColorFloat mColor = { 1.0f, 1.0f, 1.0f, 1.0f };
64  ECullMode mCullMode = ECullMode::Back;
66  bool mFlipNormals = false;
67 
68  protected:
74  void constructBox(const math::Box& box, nap::MeshInstance& mesh);
75 
76  private:
77  RenderService* mRenderService;
78  std::unique_ptr<MeshInstance> mMeshInstance;
79  math::Box mBox = { 1.0f, 1.0f, 1.0f };
80  };
81 }
nap::BoxMesh::getMeshInstance
virtual MeshInstance & getMeshInstance() override
Definition: boxmesh.h:47
nap::BoxMesh::getMeshInstance
virtual const MeshInstance & getMeshInstance() const override
Definition: boxmesh.h:52
nap::math::Box
Definition: box.h:20
nap::EMemoryUsage::Static
@ Static
Buffer data is uploaded only once from the CPU to the GPU.
nap::EPolygonMode
EPolygonMode
Definition: mesh.h:55
nap::RGBAColor< float >
nap::ECullMode
ECullMode
Definition: mesh.h:43
nap::EMemoryUsage
EMemoryUsage
Definition: gpubuffer.h:41
nap::utility::ErrorState
Definition: errorstate.h:19
nap::BoxMesh::getBox
const math::Box & getBox() const
Definition: boxmesh.h:57
nap::IMesh
Definition: mesh.h:394
nap::RenderService
Definition: renderservice.h:275
nap::Core
Definition: core.h:82
nap::ECullMode::Back
@ Back
Cull back facing triangles.
nap::EPolygonMode::Fill
@ Fill
Polygons are interpreted and rendered using the specified 'EDrawMode'.
nap
Definition: templateapp.h:17
nap::BoxMesh
Definition: boxmesh.h:23
nap::MeshInstance
Definition: mesh.h:196