NAP
planemesh.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 <rect.h>
12 #include <color.h>
13 #include <nap/numeric.h>
14 
15 namespace nap
16 {
17  // Forward Declares
18  class Core;
19  class RenderService;
20 
26  class NAPAPI PlaneMesh : public IMesh
27  {
28  RTTI_ENABLE(IMesh)
29  public:
30  PlaneMesh(Core& core);
31 
37  virtual bool init(utility::ErrorState& errorState) override;
38 
46  bool setup(utility::ErrorState& error);
47 
51  virtual MeshInstance& getMeshInstance() override { return *mMeshInstance; }
52 
56  virtual const MeshInstance& getMeshInstance() const override { return *mMeshInstance; }
57 
61  const math::Rect& getRect() { return mRect; }
62 
63  // property: the size of the plane
64  glm::vec2 mSize = { 1.0, 1.0 };
65  glm::vec2 mPosition = { 0.0,0.0 };
66  RGBAColorFloat mColor = { 1.0f, 1.0f, 1.0f, 1.0f };
67  uint mRows = 1;
68  uint mColumns = 1;
70  ECullMode mCullMode = ECullMode::None;
72 
73  private:
74  RenderService* mRenderService;
75  std::unique_ptr<MeshInstance> mMeshInstance;
76  math::Rect mRect;
77 
83  void constructPlane(const math::Rect& planeRect, nap::MeshInstance& mesh);
84  };
85 }
nap::uint
unsigned int uint
Definition: numeric.h:23
nap::EMemoryUsage::Static
@ Static
Buffer data is uploaded only once from the CPU to the GPU.
nap::PlaneMesh::getRect
const math::Rect & getRect()
Definition: planemesh.h:61
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::PlaneMesh::getMeshInstance
virtual const MeshInstance & getMeshInstance() const override
Definition: planemesh.h:56
nap::math::Rect
Definition: rect.h:19
nap::utility::ErrorState
Definition: errorstate.h:19
nap::IMesh
Definition: mesh.h:394
nap::RenderService
Definition: renderservice.h:275
nap::Core
Definition: core.h:82
nap::EPolygonMode::Fill
@ Fill
Polygons are interpreted and rendered using the specified 'EDrawMode'.
nap
Definition: templateapp.h:17
nap::MeshInstance
Definition: mesh.h:196
nap::PlaneMesh::getMeshInstance
virtual MeshInstance & getMeshInstance() override
Definition: planemesh.h:51
nap::ECullMode::None
@ None
No culling.
nap::PlaneMesh
Definition: planemesh.h:26