NTrace
GPU ray tracing framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Mesh.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2011, NVIDIA Corporation
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of NVIDIA Corporation nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #pragma once
29 #include "3d/Texture.hpp"
30 #include "gpu/GLContext.hpp"
31 
32 namespace FW
33 {
34 //------------------------------------------------------------------------
35 
36 class MeshBase
37 {
38 public:
39  enum AttribType // allows arbitrary values
40  {
41  AttribType_Position = 0, // (x, y, z) or (x, y, z, w)
42  AttribType_Normal, // (x, y, z)
43  AttribType_Color, // (r, g, b) or (r, g, b, a)
44  AttribType_TexCoord, // (u, v) or (u, v, w)
45 
46  AttribType_AORadius, // (min, max)
47 
49  };
50 
52  {
56 
58  };
59 
61  {
62  TextureType_Diffuse = 0, // Diffuse color map.
63  TextureType_Alpha, // Alpha map (green = opacity).
64  TextureType_Displacement, // Displacement map (green = height).
65  TextureType_Normal, // Tangent-space normal map.
66  TextureType_Environment, // Environment map (spherical coordinates).
67 
69  };
70 
71  struct AttribSpec
72  {
78  };
79 
80  struct Material
81  {
85  F32 displacementCoef; // height = texture/255 * coef + bias
87  F32 emissivity; // Material emissive light coefficient
88  F32 reflectivity; // Material reflectivity coefficient
89  F32 refractivity; // Material refractivity coefficient
90  F32 indexOfRefraction; // Index of refraction for material
91 
93 
94  Material(void)
95  {
96  diffuse = Vec4f(0.75f, 0.75f, 0.75f, 1.0f);
97  specular = 0.5f;
98  glossiness = 32.0f;
99  displacementCoef = 1.0f;
100  displacementBias = 0.0f;
101 
102  emissivity = 0.0f;
103  reflectivity = 0.0f;
104  refractivity = 0.0f;
105  indexOfRefraction = 1.0f;
106  }
107  };
108 
109 private:
110  struct Submesh
111  {
114  S32 ofsInVBO;
115  S32 sizeInVBO;
116  };
117 
118 public:
119  MeshBase (void) { init(); }
120  MeshBase (const MeshBase& other) { init(); addAttribs(other); set(other); }
121  ~MeshBase (void) { clear(); }
122 
124  void addAttribs (const MeshBase& other);
125  int numAttribs (void) const { return m_attribs.getSize(); }
126  const AttribSpec& attribSpec (int attrib) const { return m_attribs[attrib]; }
127  int findAttrib (AttribType type) const { return findNextAttrib(type, -1); }
128  int findNextAttrib (AttribType type, int prevAttrib) const;
129  bool isCompatible (const MeshBase& other) const;
130 
131  void clear (void) { m_isInMemory = true; clearVertices(); clearSubmeshes(); }
132  void set (const MeshBase& other);
133  void append (const MeshBase& other);
134  void compact (void);
135 
136  int numVertices (void) const { return m_numVertices; }
137  int vertexStride (void) const { return m_stride; }
138  void resetVertices (int num);
139  void clearVertices (void) { resizeVertices(0); }
140  void resizeVertices (int num);
141  const U8* getVertexPtr (int idx = 0) const { FW_ASSERT(isInMemory() && idx >= 0 && idx <= numVertices()); return m_vertices.getPtr() + idx * m_stride; }
142  U8* getMutableVertexPtr (int idx = 0) { FW_ASSERT(isInMemory() && idx >= 0 && idx <= numVertices()); freeVBO(); return m_vertices.getPtr() + idx * m_stride; }
143  const U8* vertex (int idx) const { FW_ASSERT(isInMemory() && idx >= 0 && idx < numVertices()); return getVertexPtr(idx); }
144  U8* mutableVertex (int idx) { FW_ASSERT(isInMemory() && idx >= 0 && idx < numVertices()); return getMutableVertexPtr(idx); }
145  void setVertex (int idx, const void* ptr) { setVertices(idx, ptr, 1); }
146  void setVertices (int idx, const void* ptr, int num) { FW_ASSERT(ptr && num >= 0 && idx + num <= numVertices()); memcpy(getMutableVertexPtr(idx), ptr, num * m_stride); }
147  U8* addVertex (const void* ptr = NULL) { return addVertices(ptr, 1); }
148  U8* addVertices (const void* ptr, int num) { FW_ASSERT(isInMemory() && num >= 0); freeVBO(); m_numVertices += num; U8* slot = m_vertices.add(NULL, num * m_stride); if (ptr) memcpy(slot, ptr, num * m_stride); return slot; }
149  Vec4f getVertexAttrib (int idx, int attrib) const;
150  void setVertexAttrib (int idx, int attrib, const Vec4f& v);
151 
152  int numSubmeshes (void) const { return m_submeshes.getSize(); }
153  int numTriangles (void) const { int res = 0; for (int i = 0; i < m_submeshes.getSize(); i++) res += m_submeshes[i].indices->getSize(); return res; }
154  void resizeSubmeshes (int num);
155  void clearSubmeshes (void) { resizeSubmeshes(0); }
156  const Array<Vec3i>& indices (int submesh) const { FW_ASSERT(isInMemory()); return *m_submeshes[submesh].indices; }
157  Array<Vec3i>& mutableIndices (int submesh) { FW_ASSERT(isInMemory()); freeVBO(); return *m_submeshes[submesh].indices; }
158  void setIndices (int submesh, const Vec3i* ptr, int size) { mutableIndices(submesh).set(ptr, size); }
159  void setIndices (int submesh, const S32* ptr, int size) { FW_ASSERT(size % 3 == 0); mutableIndices(submesh).set((const Vec3i*)ptr, size / 3); }
160  void setIndices (int submesh, const Array<Vec3i>& v) { mutableIndices(submesh).set(v); }
161  const Material& material (int submesh) const { return m_submeshes[submesh].material; }
162  Material& material (int submesh) { return m_submeshes[submesh].material; }
163  int addSubmesh (void) { int num = numSubmeshes(); resizeSubmeshes(num + 1); return num; }
164 
165  Buffer& getVBO (void);
166  int vboAttribOffset (int attrib) { getVBO(); return attribSpec(attrib).offset; }
167  int vboAttribStride (int attrib) { getVBO(); FW_ASSERT(attrib >= 0 && attrib < m_attribs.getSize()); FW_UNREF(attrib); return vertexStride(); }
168  int vboIndexOffset (int submesh) { getVBO(); return m_submeshes[submesh].ofsInVBO; }
169  int vboIndexSize (int submesh) { getVBO(); return m_submeshes[submesh].sizeInVBO; }
170 
171  void setGLAttrib (GLContext* gl, int attrib, int loc);
172  void draw (GLContext* gl, const Mat4f& posToCamera, const Mat4f& projection, GLContext::Program* prog = NULL, bool gouraud = false);
173 
174  bool isInMemory (void) const { return m_isInMemory; }
175  void freeMemory (void);
176  bool isInVBO (void) const { return m_isInVBO; }
177  void freeVBO (void) { m_vbo.reset(); m_isInVBO = false; }
178 
179  void xformPositions (const Mat4f& mat);
180  void xformNormals (const Mat3f& mat, bool normalize = true);
181  void xform (const Mat4f& mat) { xformPositions(mat); xformNormals(mat.getXYZ().transposed().inverted()); }
182 
183  void getBBox (Vec3f& lo, Vec3f& hi) const;
184  void recomputeNormals (void);
185  void flipTriangles (void);
186  void clean (void); // Remove empty submeshes, degenerate triangles, and unreferenced vertices.
187  void collapseVertices (void); // Collapse duplicate vertices.
188  void dupVertsPerSubmesh (void); // If a vertex is shared between multiple submeshes, duplicate it for each.
189  void fixMaterialColors (void); // If a material is textured, override diffuse color with average over texels.
190  void simplify (F32 maxError); // Collapse short edges. Do not allow vertices to drift more than maxError.
191 
192  const U8* operator[] (int vidx) const { return vertex(vidx); }
193  U8* operator[] (int vidx) { return mutableVertex(vidx); }
194  MeshBase& operator= (const MeshBase& other) { set(other); return *this; }
195  MeshBase& operator+= (const MeshBase& other) { append(other); return *this; }
196 
197 private:
198  void init (void) { m_stride = 0; m_numVertices = 0; m_isInMemory = true; m_isInVBO = false; }
199 
200 private:
201  S32 m_stride; // Bytes per vertex in m_vertices and m_vbo.
202  S32 m_numVertices; // Total number of vertices.
203  bool m_isInMemory; // Whether m_vertices and m_submeshes[].indices are valid.
204  bool m_isInVBO; // Whether m_vbo is valid.
205 
206  Array<AttribSpec> m_attribs;
207  Array<U8> m_vertices;
208  Array<Submesh> m_submeshes;
209  Buffer m_vbo;
210 };
211 
212 //------------------------------------------------------------------------
213 
214 template <class V> class Mesh : public MeshBase
215 {
216 public:
217  Mesh (void) { V::listAttribs(*this); FW_ASSERT(vertexStride() == sizeof(V)); }
218  Mesh (const MeshBase& other) { V::listAttribs(*this); FW_ASSERT(vertexStride() == sizeof(V)); set(other); }
219  ~Mesh (void) {}
220 
221  const V* getVertexPtr (int idx = 0) const { return (V*)MeshBase::getVertexPtr(idx); }
222  V* getMutableVertexPtr (int idx = 0) { return (V*)MeshBase::getMutableVertexPtr(idx); }
223  const V& vertex (int idx) const { return *getVertexPtr(idx); }
224  V& mutableVertex (int idx) { return *getMutableVertexPtr(idx); }
225  void setVertex (int idx, const V& value) { setVertices(idx, &value, 1); }
226  void setVertices (int idx, const V* ptr, int num) { FW_ASSERT(ptr && num >= 0 && idx + num <= numVertices()); V* slot = getMutableVertexPtr(idx); for (int i = 0; i < num; i++) slot[i] = ptr[i]; }
227  V& addVertex (const V& value) { V* slot = (V*)MeshBase::addVertex(NULL); *slot = value; return *slot; }
228  V& addVertex (void) { return *(V*)MeshBase::addVertex(NULL); }
229  V* addVertices (const V* ptr, int num) { V* slot = (V*)MeshBase::addVertices(ptr, num); if (ptr) for (int i = 0; i < num; i++) slot[i] = ptr[i]; return slot; }
230 
231  const V& operator[] (int vidx) const { return vertex(vidx); }
232  V& operator[] (int vidx) { return mutableVertex(vidx); }
233  Mesh& operator= (const Mesh& other) { set(other); return *this; }
234 };
235 
236 //------------------------------------------------------------------------
237 
238 struct VertexP
239 {
241 
242  VertexP(void) {}
243  VertexP(const Vec3f& pp) : p(pp) {}
244 
245  static void listAttribs(MeshBase& mesh)
246  {
248  }
249 };
250 
251 //------------------------------------------------------------------------
252 
253 struct VertexPN
254 {
257 
258  VertexPN(void) {}
259  VertexPN(const Vec3f& pp, const Vec3f& nn) : p(pp), n(nn) {}
260 
261  static void listAttribs(MeshBase& mesh)
262  {
265  }
266 };
267 
268 //------------------------------------------------------------------------
269 
270 struct VertexPNC
271 {
275 
276  VertexPNC(void) {}
277  VertexPNC(const Vec3f& pp, const Vec3f& nn, const Vec4f& cc) : p(pp), n(nn), c(cc) {}
278 
279  static void listAttribs(MeshBase& mesh)
280  {
284  }
285 };
286 
287 //------------------------------------------------------------------------
288 
289 struct VertexPNT
290 {
294 
295  VertexPNT(void) {}
296  VertexPNT(const Vec3f& pp, const Vec3f& nn, const Vec2f& tt) : p(pp), n(nn), t(tt) {}
297 
298  static void listAttribs(MeshBase& mesh)
299  {
303  }
304 };
305 
306 //------------------------------------------------------------------------
307 
308 MeshBase* importMesh (const String& fileName);
309 void exportMesh (const String& fileName, const MeshBase* mesh);
310 String getMeshImportFilter (void);
311 String getMeshExportFilter (void);
312 
313 void addCubeToMesh (Mesh<VertexPNC>& mesh, int submesh, const Vec3f& lo, const Vec3f& hi, const Vec4f& color, bool forceNormal = false, const Vec3f& normal = Vec3f(0.0f));
314 
315 //------------------------------------------------------------------------
316 }
V * addVertices(const V *ptr, int num)
Definition: Mesh.hpp:229
String getMeshExportFilter(void)
Definition: Mesh.cpp:1224
MeshBase * importMesh(const String &fileName)
Definition: Mesh.cpp:1185
MeshBase & operator=(const MeshBase &other)
Definition: Mesh.hpp:194
#define FW_UNREF(X)
Definition: Defs.hpp:78
void collapseVertices(void)
Definition: Mesh.cpp:759
Vec4f c
Definition: Mesh.hpp:274
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void ** pp
Definition: DLLImports.inl:114
FW_CUDA_FUNC T length(const VectorBase< T, L, S > &v)
Definition: Math.hpp:459
VertexPNT(void)
Definition: Mesh.hpp:295
#define NULL
Definition: Defs.hpp:39
MeshBase & operator+=(const MeshBase &other)
Definition: Mesh.hpp:195
int vboIndexSize(int submesh)
Definition: Mesh.hpp:169
void setIndices(int submesh, const Array< Vec3i > &v)
Definition: Mesh.hpp:160
Vec3f p
Definition: Mesh.hpp:240
void xform(const Mat4f &mat)
Definition: Mesh.hpp:181
void addCubeToMesh(Mesh< VertexPNC > &mesh, int submesh, const Vec3f &lo, const Vec3f &hi, const Vec4f &color, bool forceNormal=false, const Vec3f &normal=Vec3f(0.0f))
Definition: Mesh.cpp:1127
Mesh(const MeshBase &other)
Definition: Mesh.hpp:218
void append(const MeshBase &other)
Definition: Mesh.cpp:135
void getBBox(Vec3f &lo, Vec3f &hi) const
Definition: Mesh.cpp:597
void set(const MeshBase &other)
Definition: Mesh.cpp:105
const AttribSpec & attribSpec(int attrib) const
Definition: Mesh.hpp:126
void freeVBO(void)
Definition: Mesh.hpp:177
void ** ptr
Definition: DLLImports.cpp:74
const U8 * vertex(int idx) const
Definition: Mesh.hpp:143
int numSubmeshes(void) const
Definition: Mesh.hpp:152
void clearSubmeshes(void)
Definition: Mesh.hpp:155
void xformNormals(const Mat3f &mat, bool normalize=true)
Definition: Mesh.cpp:579
void recomputeNormals(void)
Definition: Mesh.cpp:623
const V & operator[](int vidx) const
Definition: Mesh.hpp:231
void exportMesh(const String &fileName, const MeshBase *mesh)
Definition: Mesh.cpp:1200
const Material & material(int submesh) const
Definition: Mesh.hpp:161
void draw(GLContext *gl, const Mat4f &posToCamera, const Mat4f &projection, GLContext::Program *prog=NULL, bool gouraud=false)
Definition: Mesh.cpp:367
AttribFormat format
Definition: Mesh.hpp:74
V & addVertex(const V &value)
Definition: Mesh.hpp:227
Vec3f p
Definition: Mesh.hpp:291
void addAttribs(const MeshBase &other)
Definition: Mesh.cpp:66
int vboIndexOffset(int submesh)
Definition: Mesh.hpp:168
static void listAttribs(MeshBase &mesh)
Definition: Mesh.hpp:261
float F32
Definition: Defs.hpp:89
void clearVertices(void)
Definition: Mesh.hpp:139
U8 * getMutableVertexPtr(int idx=0)
Definition: Mesh.hpp:142
U8 * addVertices(const void *ptr, int num)
Definition: Mesh.hpp:148
void setIndices(int submesh, const Vec3i *ptr, int size)
Definition: Mesh.hpp:158
Mesh & operator=(const Mesh &other)
Definition: Mesh.hpp:233
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v
Definition: DLLImports.inl:329
~Mesh(void)
Definition: Mesh.hpp:219
void dupVertsPerSubmesh(void)
Definition: Mesh.cpp:802
void setIndices(int submesh, const S32 *ptr, int size)
Definition: Mesh.hpp:159
Array< Vec3i > & mutableIndices(int submesh)
Definition: Mesh.hpp:157
VertexP(const Vec3f &pp)
Definition: Mesh.hpp:243
int addAttrib(AttribType type, AttribFormat format, int length)
Definition: Mesh.cpp:39
void setVertexAttrib(int idx, int attrib, const Vec4f &v)
Definition: Mesh.cpp:262
static void listAttribs(MeshBase &mesh)
Definition: Mesh.hpp:245
FW_CUDA_FUNC S transposed(void) const
Definition: Math.hpp:953
void resetVertices(int num)
Definition: Mesh.cpp:213
void simplify(F32 maxError)
Definition: Mesh.cpp:862
MeshBase(void)
Definition: Mesh.hpp:119
Vec3f p
Definition: Mesh.hpp:255
const V & vertex(int idx) const
Definition: Mesh.hpp:223
void resizeSubmeshes(int num)
Definition: Mesh.cpp:281
const V * getVertexPtr(int idx=0) const
Definition: Mesh.hpp:221
#define FW_ASSERT(X)
Definition: Defs.hpp:67
signed int S32
Definition: Defs.hpp:88
String getMeshImportFilter(void)
Definition: Mesh.cpp:1215
int numAttribs(void) const
Definition: Mesh.hpp:125
VertexPN(void)
Definition: Mesh.hpp:258
int findAttrib(AttribType type) const
Definition: Mesh.hpp:127
VertexPNC(void)
Definition: Mesh.hpp:276
void resizeVertices(int num)
Definition: Mesh.cpp:227
void clean(void)
Definition: Mesh.cpp:681
Vec3f n
Definition: Mesh.hpp:292
T & add(void)
Definition: Array.hpp:384
void fixMaterialColors(void)
Definition: Mesh.cpp:846
VertexP(void)
Definition: Mesh.hpp:242
void setVertices(int idx, const void *ptr, int num)
Definition: Mesh.hpp:146
Vec4f getVertexAttrib(int idx, int attrib) const
Definition: Mesh.cpp:241
int numVertices(void) const
Definition: Mesh.hpp:136
Vec2f t
Definition: Mesh.hpp:293
Material & material(int submesh)
Definition: Mesh.hpp:162
void setVertex(int idx, const void *ptr)
Definition: Mesh.hpp:145
Vec3f n
Definition: Mesh.hpp:256
VertexPNC(const Vec3f &pp, const Vec3f &nn, const Vec4f &cc)
Definition: Mesh.hpp:277
int vertexStride(void) const
Definition: Mesh.hpp:137
bool isInVBO(void) const
Definition: Mesh.hpp:176
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction f
Definition: DLLImports.inl:88
void flipTriangles(void)
Definition: Mesh.cpp:669
void clear(void)
Definition: Mesh.hpp:131
const Array< Vec3i > & indices(int submesh) const
Definition: Mesh.hpp:156
V & mutableVertex(int idx)
Definition: Mesh.hpp:224
int addSubmesh(void)
Definition: Mesh.hpp:163
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value
Definition: DLLImports.inl:84
void setGLAttrib(GLContext *gl, int attrib, int loc)
Definition: Mesh.cpp:342
int findNextAttrib(AttribType type, int prevAttrib) const
Definition: Mesh.cpp:78
int vboAttribStride(int attrib)
Definition: Mesh.hpp:167
Texture textures[TextureType_Max]
Definition: Mesh.hpp:92
FW_CUDA_FUNC S normalize(const VectorBase< T, L, S > &v, T len=(T) 1)
Definition: Math.hpp:460
MeshBase(const MeshBase &other)
Definition: Mesh.hpp:120
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei GLsizei height GLenum GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: DLLImports.inl:349
static void listAttribs(MeshBase &mesh)
Definition: Mesh.hpp:298
unsigned char U8
Definition: Defs.hpp:83
U8 * addVertex(const void *ptr=NULL)
Definition: Mesh.hpp:147
int numTriangles(void) const
Definition: Mesh.hpp:153
void freeMemory(void)
Definition: Mesh.cpp:545
~MeshBase(void)
Definition: Mesh.hpp:121
Vec3f n
Definition: Mesh.hpp:273
U8 * mutableVertex(int idx)
Definition: Mesh.hpp:144
Vec3f p
Definition: Mesh.hpp:272
static void listAttribs(MeshBase &mesh)
Definition: Mesh.hpp:279
Mesh(void)
Definition: Mesh.hpp:217
V * getMutableVertexPtr(int idx=0)
Definition: Mesh.hpp:222
void setVertex(int idx, const V &value)
Definition: Mesh.hpp:225
V & addVertex(void)
Definition: Mesh.hpp:228
void compact(void)
Definition: Mesh.cpp:200
VertexPNT(const Vec3f &pp, const Vec3f &nn, const Vec2f &tt)
Definition: Mesh.hpp:296
void setVertices(int idx, const V *ptr, int num)
Definition: Mesh.hpp:226
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type
Definition: DLLImports.inl:323
int vboAttribOffset(int attrib)
Definition: Mesh.hpp:166
const T * getPtr(S idx=0) const
Definition: Array.hpp:202
bool isInMemory(void) const
Definition: Mesh.hpp:174
VertexPN(const Vec3f &pp, const Vec3f &nn)
Definition: Mesh.hpp:259
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr size
Definition: DLLImports.inl:319
void reset(U32 hints, int align)
Definition: Buffer.hpp:76
const U8 * getVertexPtr(int idx=0) const
Definition: Mesh.hpp:141
S getSize(void) const
Definition: Array.hpp:188
Mat3f getXYZ(void) const
Definition: Math.cpp:56
void xformPositions(const Mat4f &mat)
Definition: Mesh.cpp:561
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei GLsizei height GLenum GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid pixels GLint GLsizei const GLfloat value GLint GLfloat GLfloat v1 GLint GLfloat GLfloat GLfloat v2 GLint GLsizei const GLfloat value GLint GLsizei GLboolean const GLfloat value GLuint program GLuint GLfloat GLfloat GLfloat z GLuint GLint GLenum GLboolean GLsizei const GLvoid pointer GLuint GLuint color
Definition: DLLImports.inl:367
Buffer & getVBO(void)
Definition: Mesh.cpp:310
bool isCompatible(const MeshBase &other) const
Definition: Mesh.cpp:88
const U8 * operator[](int vidx) const
Definition: Mesh.hpp:192