Nebula
Loading...
Searching...
No Matches
rendershape.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
20#include "math/mat4.h"
21#include "math/vec4.h"
24#include "io/memorystream.h"
25#include "threading/threadid.h"
26#include "mesh.h"
27
28//------------------------------------------------------------------------------
29namespace CoreGraphics
30{
32{
33public:
50
59
67
73 bool IsValid() const;
78 , const Math::vec4& color
80 , float lineThickness = 1.0f);
81
83 void SetupPrimitives(
84 const RenderShape::RenderShapeVertex* vertices
88 , const Math::mat4 transform = Math::mat4::identity
89 , float lineThickness = 1.0f
90 );
91
93 void SetupPrimitives(
97 , const Math::mat4 transform = Math::mat4::identity
98 , float lineThickness = 1.0f
99 );
100
103 const RenderShape::RenderShapeVertex* vertices
105 , const void* indices
110 , const Math::mat4 transform = Math::mat4::identity
111 , float lineThickness = 1.0f
112 );
113
117 , const Util::Array<uint16> indices
120 , const Math::mat4 transform = Math::mat4::identity
121 , float lineThickness = 1.0f
122 );
123
127 , const Util::Array<uint32> indices
130 , const Math::mat4 transform = Math::mat4::identity
131 , float lineThickness = 1.0f
132 );
133
135 void SetupMesh(
136 const MeshId mesh
137 , const IndexT groupIndex
138 , const Math::vec4& color
141 , float lineThickness = 1.0f
142 );
143
145 Type GetShapeType() const;
147 RenderFlag GetDepthFlag() const;
149 const Math::mat4& GetModelTransform() const;
153 SizeT GetNumVertices() const;
155 SizeT GetNumIndices() const;
157 const void* GetVertexData() const;
159 const void* GetIndexData() const;
163 const Math::vec4& GetColor() const;
165 const VertexLayoutId GetVertexLayout() const;
167 const MeshId GetMesh() const;
169 const IndexT& GetPrimitiveGroupIndex() const;
171 const float GetLineThickness() const;
172
173private:
183
187 Ptr<IO::MemoryStream> dataStream; // contains vertex/index data
188};
189
190//------------------------------------------------------------------------------
193inline bool
195{
196 return (InvalidShapeType != this->shapeType);
197}
198
199//------------------------------------------------------------------------------
204{
205 return this->shapeType;
206}
207
208//------------------------------------------------------------------------------
213{
214 return this->depthFlag;
215}
216
217//------------------------------------------------------------------------------
220inline const Math::mat4&
222{
223 return this->modelTransform;
224}
225
226//------------------------------------------------------------------------------
231{
232 n_assert((Primitives == this->shapeType) || (IndexedPrimitives == this->shapeType));
233 return this->topology;
234}
235
236//------------------------------------------------------------------------------
239inline SizeT
241{
242 n_assert((Primitives == this->shapeType) || (IndexedPrimitives == this->shapeType));
243 return this->numVertices;
244}
245
246//------------------------------------------------------------------------------
249inline SizeT
251{
253 return this->numIndices;
254}
255
256//------------------------------------------------------------------------------
259inline const void*
261{
262 n_assert((Primitives == this->shapeType) || (IndexedPrimitives == this->shapeType));
263 const void* ptr = ((uchar*)this->dataStream->GetRawPointer()) + this->vertexDataOffset;
264 return ptr;
265}
266
267//------------------------------------------------------------------------------
270inline const void*
272{
274 const void* ptr = this->dataStream->GetRawPointer();
275 return ptr;
276}
277
278//------------------------------------------------------------------------------
281inline IndexType::Code
283{
285 return this->indexType;
286}
287
288//------------------------------------------------------------------------------
291inline const Math::vec4&
293{
294 return this->color;
295}
296
297//------------------------------------------------------------------------------
300inline const VertexLayoutId
302{
303 return this->vertexLayout;
304}
305
306//------------------------------------------------------------------------------
309inline const MeshId
311{
312 return this->mesh;
313}
314
315//------------------------------------------------------------------------------
318inline const IndexT&
320{
321 return this->groupIndex;
322}
323
324//------------------------------------------------------------------------------
327inline const float
329{
330 return this->lineThickness;
331}
332
333} // namespace CoreGraphics
334//------------------------------------------------------------------------------
335
Code
index types enum
Definition indextype.h:22
Code
enumeration
Definition primitivetopology.h:23
Describes a shape which is rendered through the ShapeRenderer singleton.
Definition rendershape.h:32
Math::vec4 color
Definition rendershape.h:181
SizeT numIndices
Definition rendershape.h:178
bool IsValid() const
return true if object has been setup
Definition rendershape.h:194
RenderFlag
Definition rendershape.h:52
@ Wireframe
Definition rendershape.h:55
@ CheckDepth
Definition rendershape.h:53
@ NumDepthFlags
Definition rendershape.h:57
@ AlwaysOnTop
Definition rendershape.h:54
Ptr< IO::MemoryStream > dataStream
Definition rendershape.h:187
IndexType::Code GetIndexType() const
get the index type (16 or 32 bit)
Definition rendershape.h:282
const Math::vec4 & GetColor() const
get shape color
Definition rendershape.h:292
IndexT groupIndex
Definition rendershape.h:184
MeshId mesh
Definition rendershape.h:185
const float GetLineThickness() const
Get line thickness.
Definition rendershape.h:328
Type
shape types
Definition rendershape.h:36
@ Cylinder
Definition rendershape.h:39
@ Box
Definition rendershape.h:37
@ IndexedPrimitives
Definition rendershape.h:44
@ NumShapeTypes
Definition rendershape.h:47
@ Sphere
Definition rendershape.h:38
@ Primitives
Definition rendershape.h:43
@ Cone
Definition rendershape.h:41
@ InvalidShapeType
Definition rendershape.h:48
@ Torus
Definition rendershape.h:40
@ RenderMesh
Definition rendershape.h:45
@ Arrow
Definition rendershape.h:42
SizeT GetNumVertices() const
get number of vertices
Definition rendershape.h:240
Type GetShapeType() const
get shape type
Definition rendershape.h:203
const MeshId GetMesh() const
get mesh
Definition rendershape.h:310
IndexType::Code indexType
Definition rendershape.h:180
PrimitiveTopology::Code topology
Definition rendershape.h:177
const IndexT & GetPrimitiveGroupIndex() const
get primitive group
Definition rendershape.h:319
RenderFlag GetDepthFlag() const
get depth flag
Definition rendershape.h:212
VertexLayoutId vertexLayout
Definition rendershape.h:186
SizeT numVertices
Definition rendershape.h:178
const void * GetIndexData() const
get index data (returns 0 if none exists)
Definition rendershape.h:271
SizeT GetNumIndices() const
get number of indices
Definition rendershape.h:250
const void * GetVertexData() const
get pointer to vertex data (returns 0 if none exist)
Definition rendershape.h:260
void SetupSimpleShape(Type shapeType, RenderFlag depthFlag, const Math::vec4 &color, const Math::mat4 &modelTransform=Math::mat4::identity, float lineThickness=1.0f)
setup simple shape
Definition rendershape.cc:59
PrimitiveTopology::Code GetTopology() const
get primitive topology
Definition rendershape.h:230
RenderShape()
default constructor
Definition rendershape.cc:19
RenderFlag depthFlag
Definition rendershape.h:175
Math::mat4 modelTransform
Definition rendershape.h:176
void SetupIndexPrimitives(const RenderShape::RenderShapeVertex *vertices, SizeT numVertices, const void *indices, SizeT numIndices, IndexType::Code indexType, PrimitiveTopology::Code topology, RenderFlag depthFlag, const Math::mat4 transform=Math::mat4::identity, float lineThickness=1.0f)
Setup indexed primitives draw.
Definition rendershape.cc:136
const Math::mat4 & GetModelTransform() const
get model transform
Definition rendershape.h:221
Type shapeType
Definition rendershape.h:174
SizeT vertexDataOffset
Definition rendershape.h:179
float lineThickness
Definition rendershape.h:182
const VertexLayoutId GetVertexLayout() const
get vertex layout, returns NULL if none exist
Definition rendershape.h:301
void SetupPrimitives(const RenderShape::RenderShapeVertex *vertices, SizeT numVertices, PrimitiveTopology::Code topology, RenderFlag depthFlag, const Math::mat4 transform=Math::mat4::identity, float lineThickness=1.0f)
Setup primitives draw.
Definition rendershape.cc:74
void SetupMesh(const MeshId mesh, const IndexT groupIndex, const Math::vec4 &color, RenderFlag depthFlag, const Math::mat4 &modelTransform=Math::mat4::identity, float lineThickness=1.0f)
setup mesh
Definition rendershape.cc:244
void * GetRawPointer() const
get a direct "raw" pointer to the data
Definition memorystream.cc:357
Nebula's smart pointer class which manages the life time of RefCounted objects.
Definition ptr.h:38
Nebula's dynamic array class.
Definition array.h:60
#define n_assert(exp)
Definition debug.h:50
Acceleration structures are used to enable ray tracing on the GPU by dividing the scene into a BVH.
Definition accelerationstructure.h:24
Half precision (16 bit) float implementation.
Definition angularpfeedbackloop.h:17
Definition mesh.h:29
Math::vec4 pos
Definition rendershape.h:62
Math::vec4 color
Definition rendershape.h:63
RenderShapeVertex()
Definition rendershape.h:65
Definition vertexlayout.h:16
A 4x4 single point precision float matrix.
Definition mat4.h:47
static const mat4 identity
Definition mat4.h:140
A 4D vector.
Definition vec4.h:24
unsigned char uchar
Definition types.h:33
int SizeT
Definition types.h:49
int IndexT
Definition types.h:48