Nebula
Loading...
Searching...
No Matches
nvx2streamreader.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
15#include "core/config.h"
16#if NEBULA_LEGACY_SUPPORT
17#include "io/streamreader.h"
18#include "coregraphics/buffer.h"
20
21//------------------------------------------------------------------------------
22namespace Legacy
23{
25{
27public:
31 virtual ~Nvx2StreamReader();
32
34 void SetRawMode(bool b);
36 bool IsRawMode() const;
38 void SetUsage(CoreGraphics::GpuBufferTypes::Usage usage);
42 void SetAccess(CoreGraphics::GpuBufferTypes::Access access);
46 void SetBuffersCopySource(bool b);
48 bool Open(const Resources::ResourceName& name);
50 void Close();
56 const Util::Array<CoreGraphics::PrimitiveGroup>& GetPrimitiveGroups() const;
58 float* GetVertexData() const;
60 ushort* GetIndexData() const;
62 SizeT GetNumVertices() const;
64 SizeT GetNumIndices() const;
66 SizeT GetVertexWidth() const;
68 SizeT GetNumEdges() const;
70 SizeT GetBaseVertexOffset() const;
72 SizeT GetBaseIndexOffset() const;
74 const Util::Array<CoreGraphics::VertexComponent>& GetVertexComponents() const;
75
77 static void ConvertVertexBufferEndianess(void* vertexPtr, SizeT numVertices, const Util::Array<CoreGraphics::VertexComponent>& vertexComps);
78
79private:
81 void ReadHeaderData();
83 void ReadPrimitiveGroups();
85 void SetupVertexComponents();
87 void UpdateGroupBoundingBoxes();
89 void SetupVertexBuffer(const Resources::ResourceName& name);
91 void SetupIndexBuffer(const Resources::ResourceName& name);
92
94 enum N2VertexComponent
95 {
96 N2Coord = (1<<0), // 3 floats
97 N2Normal = (1<<1), // 3 floats
98 N2NormalB4N = (1<<2), // 4 unsigned bytes, normalized
99 N2Uv0 = (1<<3), // 2 floats
100 N2Uv0S2 = (1<<4), // 2 shorts, 4.12 fixed point
101 N2Uv1 = (1<<5), // 2 floats
102 N2Uv1S2 = (1<<6), // 2 shorts, 4.12 fixed point
103 N2Uv2 = (1<<7), // 2 floats
104 N2Uv2S2 = (1<<8), // 2 shorts, 4.12 fixed point
105 N2Uv3 = (1<<9), // 2 floats
106 N2Uv3S2 = (1<<10), // 2 shorts, 4.12 fixed point
107 N2Tangent = (1<<11), // 3 floats
108 N2TangentB4N = (1<<12), // 4 unsigned bytes, normalized
109 N2Binormal = (1<<13), // 3 floats
110 N2BinormalB4N = (1<<14), // 4 unsigned bytes, normalized
111 N2Color = (1<<15), // 4 floats
112 N2ColorUB4N = (1<<16), // 4 unsigned bytes, normalized
113 N2Weights = (1<<17), // 4 floats
114 N2WeightsUB4N = (1<<18), // 4 unsigned bytes, normalized
115 N2JIndices = (1<<19), // 4 floats
116 N2JIndicesUB4 = (1<<20), // 4 unsigned bytes
117
118 N2NumVertexComponents = 21,
119 N2AllComponents = ((1<<N2NumVertexComponents) - 1),
120 };
121
124
125 bool rawMode;
131 bool copySourceFlag;
132
134 void* mapPtr;
135 void* groupDataPtr;
136 void* vertexDataPtr;
137 void* indexDataPtr;
138
139 SizeT groupDataSize;
140 SizeT vertexDataSize;
141 SizeT indexDataSize;
142
143 uint numGroups;
144 uint numVertices;
145 uint vertexWidth;
146 uint numIndices;
147 uint numEdges;
148 uint vertexComponentMask;
149 CoreGraphics::VertexAlloc vertexAllocation, indexAllocation;
151};
152
153//------------------------------------------------------------------------------
156inline void
157Nvx2StreamReader::SetRawMode(bool b)
158{
159 this->rawMode = b;
160}
161
162//------------------------------------------------------------------------------
165inline bool
166Nvx2StreamReader::IsRawMode() const
167{
168 return this->rawMode;
169}
170
171//------------------------------------------------------------------------------
174inline const CoreGraphics::BufferId
175Nvx2StreamReader::GetVertexBuffer() const
176{
177 return this->vbo;
178}
179
180//------------------------------------------------------------------------------
183inline const CoreGraphics::BufferId
184Nvx2StreamReader::GetIndexBuffer() const
185{
186 return this->ibo;
187}
188
189//------------------------------------------------------------------------------
193Nvx2StreamReader::GetPrimitiveGroups() const
194{
195 return this->primGroups;
196}
197
198//------------------------------------------------------------------------------
201inline float*
202Nvx2StreamReader::GetVertexData() const
203{
204 return (float*) this->vertexDataPtr;
205}
206
207//------------------------------------------------------------------------------
210inline ushort*
211Nvx2StreamReader::GetIndexData() const
212{
213 return (ushort*) this->indexDataPtr;
214}
215
216//------------------------------------------------------------------------------
219inline SizeT
220Nvx2StreamReader::GetNumVertices() const
221{
222 return this->numVertices;
223}
224
225//------------------------------------------------------------------------------
228inline SizeT
229Nvx2StreamReader::GetNumIndices() const
230{
231 return this->numIndices;
232}
233
234//------------------------------------------------------------------------------
237inline SizeT
238Nvx2StreamReader::GetVertexWidth() const
239{
240 return this->vertexWidth;
241}
242
243//------------------------------------------------------------------------------
246inline SizeT
247Nvx2StreamReader::GetNumEdges() const
248{
249 return this->numEdges;
250}
251
252//------------------------------------------------------------------------------
255inline SizeT
256Nvx2StreamReader::GetBaseVertexOffset() const
257{
258 return this->vertexAllocation.offset;
259}
260
261//------------------------------------------------------------------------------
264inline SizeT
265Nvx2StreamReader::GetBaseIndexOffset() const
266{
267 return this->indexAllocation.offset;
268}
269
270//------------------------------------------------------------------------------
274Nvx2StreamReader::GetVertexComponents() const
275{
276 return this->vertexComponents;
277}
278
279//------------------------------------------------------------------------------
282inline void
283Nvx2StreamReader::SetUsage(CoreGraphics::GpuBufferTypes::Usage usage_)
284{
285 this->usage = usage_;
286}
287
288//------------------------------------------------------------------------------
292Nvx2StreamReader::GetUsage() const
293{
294 return this->usage;
295}
296
297//------------------------------------------------------------------------------
300inline void
301Nvx2StreamReader::SetAccess(CoreGraphics::GpuBufferTypes::Access access_)
302{
303 this->access = access_;
304}
305
306//------------------------------------------------------------------------------
310Nvx2StreamReader::GetAccess() const
311{
312 return this->access;
313}
314
315//------------------------------------------------------------------------------
318inline void
319Nvx2StreamReader::SetBuffersCopySource(bool b)
320{
321 this->copySourceFlag = b;
322}
323
324} // namespace Legacy
325//------------------------------------------------------------------------------
326#endif // NEBULA_LEGACY_SUPPORT
Stream reader classes provide a specialized read-interface for a stream.
Definition streamreader.h:24
A stream reader which reads legacy nvx2 binary mesh files.
Nebula's dynamic array class.
Definition array.h:60
A StringAtom.
Definition stringatom.h:22
Nebula compiler specific defines and configuration.
Usage
resource usage flags
Definition gpubuffertypes.h:20
Access
Definition gpubuffertypes.h:28
const CoreGraphics::BufferId GetVertexBuffer()
Get vertex buffer.
Definition vkgraphicsdevice.cc:2152
const CoreGraphics::BufferId GetIndexBuffer()
Get index buffer.
Definition vkgraphicsdevice.cc:2200
CoreGraphics::VertexLayoutId layout
Definition particlecontext.cc:51
#define __DeclareClass(type)
Definition buffer.h:23
Definition mesh.h:23
Definition vertexlayout.h:16
int SizeT
Definition types.h:49
unsigned int uint
Definition types.h:31
unsigned short ushort
Definition types.h:32