NTrace
GPU ray tracing framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Mesh.cpp
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 #include "3d/Mesh.hpp"
29 #include "io/File.hpp"
30 #include "io/MeshBinaryIO.hpp"
31 #include "io/MeshWavefrontIO.hpp"
32 #include "base/UnionFind.hpp"
33 #include "base/BinaryHeap.hpp"
34 
35 using namespace FW;
36 
37 //------------------------------------------------------------------------
38 
40 {
41  FW_ASSERT(format >= 0 && format < AttribFormat_Max);
42  FW_ASSERT(length >= 1 && length <= 4);
44 
45  AttribSpec spec;
46  spec.type = type;
47  spec.format = format;
48  spec.length = length;
49  spec.offset = m_stride;
50 
51  switch (format)
52  {
53  case AttribFormat_U8: spec.bytes = length * sizeof(U8); break;
54  case AttribFormat_S32: spec.bytes = length * sizeof(S32); break;
55  case AttribFormat_F32: spec.bytes = length * sizeof(F32); break;
56  default: FW_ASSERT(false); break;
57  }
58 
59  m_attribs.add(spec);
60  m_stride += spec.bytes;
61  return m_attribs.getSize() - 1;
62 }
63 
64 //------------------------------------------------------------------------
65 
66 void MeshBase::addAttribs(const MeshBase& other)
67 {
68  int num = other.numAttribs();
69  for (int i = 0; i < num; i++)
70  {
71  const AttribSpec& spec = other.attribSpec(i);
72  addAttrib(spec.type, spec.format, spec.length);
73  }
74 }
75 
76 //------------------------------------------------------------------------
77 
78 int MeshBase::findNextAttrib(AttribType type, int prevAttrib) const
79 {
80  for (int i = prevAttrib + 1; i < numAttribs(); i++)
81  if (attribSpec(i).type == type)
82  return i;
83  return -1;
84 }
85 
86 //------------------------------------------------------------------------
87 
88 bool MeshBase::isCompatible(const MeshBase& other) const
89 {
90  if (numAttribs() != other.numAttribs())
91  return false;
92 
93  for (int i = 0; i < numAttribs(); i++)
94  {
95  const AttribSpec& a = attribSpec(i);
96  const AttribSpec& b = other.attribSpec(i);
97  if (a.type != b.type || a.format != b.format || a.length != b.length)
98  return false;
99  }
100  return true;
101 }
102 
103 //------------------------------------------------------------------------
104 
105 void MeshBase::set(const MeshBase& other)
106 {
107  if (&other == this)
108  return;
109 
110  FW_ASSERT(other.isInMemory());
111  clear();
112 
113  if (!isCompatible(other))
114  {
115  append(other);
116  compact();
117  return;
118  }
119 
120  m_stride = other.m_stride;
121  m_numVertices = other.m_numVertices;
122  m_attribs = other.m_attribs;
123  m_vertices = other.m_vertices;
124 
125  resizeSubmeshes(other.m_submeshes.getSize());
126  for (int i = 0; i < m_submeshes.getSize(); i++)
127  {
128  *m_submeshes[i].indices = *other.m_submeshes[i].indices;
129  m_submeshes[i].material = other.m_submeshes[i].material;
130  }
131 }
132 
133 //------------------------------------------------------------------------
134 
135 void MeshBase::append(const MeshBase& other)
136 {
137  FW_ASSERT(&other != this);
139  FW_ASSERT(other.isInMemory());
140 
141  Array<bool> dstAttribUsed(NULL, numAttribs());
142  for (int i = 0; i < numAttribs(); i++)
143  dstAttribUsed[i] = false;
144 
145  Array<Vec2i> copy;
146  Array<Vec2i> convert;
147  for (int i = 0; i < other.numAttribs(); i++)
148  {
149  const AttribSpec& src = other.attribSpec(i);
150  for (int j = 0; j < numAttribs(); j++)
151  {
152  const AttribSpec& dst = attribSpec(j);
153  if (src.type != dst.type || dstAttribUsed[j])
154  continue;
155 
156  if (src.format != dst.format || src.length != dst.length)
157  convert.add(Vec2i(i, j));
158  else
159  {
160  for (int k = 0; k < src.bytes; k++)
161  copy.add(Vec2i(src.offset + k, dst.offset + k));
162  }
163  dstAttribUsed[j] = true;
164  break;
165  }
166  }
167 
168  int oldNumVertices = m_numVertices;
169  resizeVertices(oldNumVertices + other.m_numVertices);
170  for (int i = 0; i < other.m_numVertices; i++)
171  {
172  if (copy.getSize())
173  {
174  const U8* src = &other.m_vertices[i * other.m_stride];
175  U8* dst = &m_vertices[(i + oldNumVertices) * m_stride];
176  for (int j = 0; j < copy.getSize(); j++)
177  dst[copy[j].y] = src[copy[j].x];
178  }
179  for (int j = 0; j < convert.getSize(); j++)
180  setVertexAttrib(i + oldNumVertices, convert[j].y,
181  other.getVertexAttrib(i, convert[j].x));
182  }
183 
184  int oldNumSubmeshes = numSubmeshes();
185  resizeSubmeshes(oldNumSubmeshes + other.numSubmeshes());
186  for (int i = 0; i < other.numSubmeshes(); i++)
187  {
188  const Submesh& src = other.m_submeshes[i];
189  Submesh& dst = m_submeshes[i + oldNumSubmeshes];
190 
191  dst.indices->reset(src.indices->getSize());
192  for (int j = 0; j < src.indices->getSize(); j++)
193  dst.indices->set(j, src.indices->get(j) + oldNumVertices);
194  dst.material = src.material;
195  }
196 }
197 
198 //------------------------------------------------------------------------
199 
201 {
202  m_attribs.compact();
203  m_vertices.compact();
204  m_submeshes.compact();
205 
206  for (int i = 0; i < m_submeshes.getSize(); i++)
207  if (m_isInMemory)
208  m_submeshes[i].indices->compact();
209 }
210 
211 //------------------------------------------------------------------------
212 
214 {
215  FW_ASSERT(num >= 0);
217 
218  m_vertices.reset(num * m_stride);
219  if (num > m_numVertices)
220  memset(m_vertices.getPtr(m_numVertices * m_stride), 0, (num - m_numVertices) * m_stride);
221  m_numVertices = num;
222  freeVBO();
223 }
224 
225 //------------------------------------------------------------------------
226 
228 {
229  FW_ASSERT(num >= 0);
231 
232  m_vertices.resize(num * m_stride);
233  if (num > m_numVertices)
234  memset(m_vertices.getPtr(m_numVertices * m_stride), 0, (num - m_numVertices) * m_stride);
235  m_numVertices = num;
236  freeVBO();
237 }
238 
239 //------------------------------------------------------------------------
240 
241 Vec4f MeshBase::getVertexAttrib(int idx, int attrib) const
242 {
243  const AttribSpec& spec = attribSpec(attrib);
244  const U8* ptr = vertex(idx) + spec.offset;
245  Vec4f v(0.0f, 0.0f, 0.0f, 1.0f);
246 
247  for (int i = 0; i < spec.length; i++)
248  {
249  switch (spec.format)
250  {
251  case AttribFormat_U8: v[i] = (F32)ptr[i]; break;
252  case AttribFormat_S32: v[i] = (F32)((S32*)ptr)[i]; break;
253  case AttribFormat_F32: v[i] = ((F32*)ptr)[i]; break;
254  default: FW_ASSERT(false); break;
255  }
256  }
257  return v;
258 }
259 
260 //------------------------------------------------------------------------
261 
262 void MeshBase::setVertexAttrib(int idx, int attrib, const Vec4f& v)
263 {
264  const AttribSpec& spec = attribSpec(attrib);
265  U8* ptr = mutableVertex(idx) + spec.offset;
266 
267  for (int i = 0; i < spec.length; i++)
268  {
269  switch (spec.format)
270  {
271  case AttribFormat_U8: ptr[i] = (U8)v[i]; break;
272  case AttribFormat_S32: ((S32*)ptr)[i] = (S32)v[i]; break;
273  case AttribFormat_F32: ((F32*)ptr)[i] = v[i]; break;
274  default: FW_ASSERT(false); break;
275  }
276  }
277 }
278 
279 //------------------------------------------------------------------------
280 
282 {
284  int old = m_submeshes.getSize();
285  if (old == num)
286  return;
287 
288  for (int i = num; i < old; i++)
289  {
290  Submesh& sm = m_submeshes[i];
291  delete sm.indices;
292  for (int j = 0; j < TextureType_Max; j++)
293  sm.material.textures[j].clear();
294  }
295 
296  m_submeshes.resize(num);
297  freeVBO();
298 
299  for (int i = old; i < num; i++)
300  {
301  Submesh& sm = m_submeshes[i];
302  sm.indices = new Array<Vec3i>;
303  sm.ofsInVBO = 0;
304  sm.sizeInVBO = 0;
305  }
306 }
307 
308 //------------------------------------------------------------------------
309 
311 {
312  if (m_isInVBO)
313  return m_vbo;
314 
315  FW_ASSERT(m_isInMemory);
316  int ofs = m_vertices.getSize();
317  for (int i = 0; i < m_submeshes.getSize(); i++)
318  {
319  m_submeshes[i].ofsInVBO = ofs;
320  m_submeshes[i].sizeInVBO = m_submeshes[i].indices->getSize() * 3;
321  ofs += m_submeshes[i].indices->getNumBytes();
322  }
323 
324  m_vbo.resizeDiscard(ofs);
325  memcpy(m_vbo.getMutablePtr(), m_vertices.getPtr(), m_vertices.getSize());
326  for (int i = 0; i < m_submeshes.getSize(); i++)
327  {
328  memcpy(
329  m_vbo.getMutablePtr(m_submeshes[i].ofsInVBO),
330  m_submeshes[i].indices->getPtr(),
331  m_submeshes[i].indices->getNumBytes());
332  }
333 
334  m_vbo.setOwner(Buffer::GL, false);
335  m_vbo.free(Buffer::CPU);
336  m_isInVBO = true;
337  return m_vbo;
338 }
339 
340 //------------------------------------------------------------------------
341 
342 void MeshBase::setGLAttrib(GLContext* gl, int attrib, int loc)
343 {
344  const AttribSpec& spec = attribSpec(attrib);
345  FW_ASSERT(gl);
346 
347  GLenum glFormat;
348  switch (spec.format)
349  {
350  case AttribFormat_U8: glFormat = GL_UNSIGNED_BYTE; break;
351  case AttribFormat_S32: glFormat = GL_INT; break;
352  case AttribFormat_F32: glFormat = GL_FLOAT; break;
353  default: FW_ASSERT(false); return;
354  }
355 
356  gl->setAttrib(
357  loc,
358  spec.length,
359  glFormat,
360  vboAttribStride(attrib),
361  getVBO(),
362  vboAttribOffset(attrib));
363 }
364 
365 //------------------------------------------------------------------------
366 
367 void MeshBase::draw(GLContext* gl, const Mat4f& posToCamera, const Mat4f& projection, GLContext::Program* prog, bool gouraud)
368 {
369  FW_ASSERT(gl);
370  const char* progId = (!gouraud) ? "MeshBase::draw_generic" : "MeshBase::draw_gouraud";
371  if (!prog)
372  prog = gl->getProgram(progId);
373 
374  // Generic shading.
375 
376  if (!prog && !gouraud)
377  {
378  prog = new GLContext::Program(
379  "#version 120\n"
381  uniform mat4 posToClip;
382  uniform mat4 posToCamera;
383  uniform mat3 normalToCamera;
384  attribute vec3 positionAttrib;
385  attribute vec3 normalAttrib;
386  attribute vec4 colorAttrib;
387  attribute vec2 texCoordAttrib;
388  centroid varying vec3 positionVarying;
389  centroid varying vec3 normalVarying;
390  centroid varying vec4 colorVarying;
391  varying vec2 texCoordVarying;
392 
393  void main()
394  {
395  vec4 pos = vec4(positionAttrib, 1.0);
396  gl_Position = posToClip * pos;
397  positionVarying = (posToCamera * pos).xyz;
398  normalVarying = normalToCamera * normalAttrib;
399  colorVarying = colorAttrib;
400  texCoordVarying = texCoordAttrib;
401  }
402  ),
403  "#version 120\n"
405  uniform bool hasNormals;
406  uniform bool hasDiffuseTexture;
407  uniform bool hasAlphaTexture;
408  uniform vec4 diffuseUniform;
409  uniform vec3 specularUniform;
410  uniform float glossiness;
411  uniform sampler2D diffuseSampler;
412  uniform sampler2D alphaSampler;
413  centroid varying vec3 positionVarying;
414  centroid varying vec3 normalVarying;
415  centroid varying vec4 colorVarying;
416  varying vec2 texCoordVarying;
417 
418  void main()
419  {
420  vec4 diffuseColor = diffuseUniform * colorVarying;
421  vec3 specularColor = specularUniform;
422 
423  if (hasDiffuseTexture)
424  diffuseColor.rgb = texture2D(diffuseSampler, texCoordVarying).rgb;
425 
426  if (hasAlphaTexture)
427  diffuseColor.a = texture2D(alphaSampler, texCoordVarying).g;
428 
429  if (diffuseColor.a <= 0.5)
430  discard;
431 
432  vec3 I = normalize(positionVarying);
433  vec3 N = normalize(normalVarying);
434  float diffuseCoef = (hasNormals) ? max(-dot(I, N), 0.0) * 0.75 + 0.25 : 1.0;
435  float specularCoef = (hasNormals) ? pow(max(-dot(I, reflect(I, N)), 0.0), glossiness) : 0.0;
436  gl_FragColor = vec4(diffuseColor.rgb * diffuseCoef + specularColor * specularCoef, diffuseColor.a);
437  }
438  ));
439  }
440 
441  // Gouraud shading.
442 
443  if (!prog && gouraud)
444  {
445  prog = new GLContext::Program(
446  "#version 120\n"
448  uniform mat4 posToClip;
449  uniform mat4 posToCamera;
450  uniform mat3 normalToCamera;
451  uniform bool hasNormals;
452  uniform vec4 diffuseUniform;
453  uniform vec3 specularUniform;
454  uniform float glossiness;
455  attribute vec3 positionAttrib;
456  attribute vec3 normalAttrib;
457  attribute vec4 colorAttrib;
458  centroid varying vec4 colorVarying;
459 
460  void main()
461  {
462  vec4 pos = vec4(positionAttrib, 1.0);
463  gl_Position = posToClip * pos;
464  vec3 I = normalize((posToCamera * pos).xyz);
465  vec3 N = normalize(normalToCamera * normalAttrib);
466  float diffuseCoef = (hasNormals) ? max(-dot(I, N), 0.0) * 0.75 + 0.25 : 1.0;
467  float specularCoef = (hasNormals) ? pow(max(-dot(I, reflect(I, N)), 0.0), glossiness) : 0.0;
468  vec4 diffuseColor = diffuseUniform * colorAttrib;
469  colorVarying = vec4(diffuseColor.rgb * diffuseCoef + specularUniform * specularCoef, diffuseColor.a);
470  }
471  ),
472  "#version 120\n"
474  centroid varying vec4 colorVarying;
475  void main()
476  {
477  gl_FragColor = colorVarying;
478  }
479  ));
480  }
481 
482  // Find mesh attributes.
483 
484  int posAttrib = findAttrib(AttribType_Position);
485  int normalAttrib = findAttrib(AttribType_Normal);
486  int colorAttrib = findAttrib(AttribType_Color);
487  int texCoordAttrib = findAttrib(AttribType_TexCoord);
488  if (posAttrib == -1)
489  return;
490 
491  // Setup uniforms.
492 
493  gl->setProgram(progId, prog);
494  prog->use();
495  gl->setUniform(prog->getUniformLoc("posToClip"), projection * posToCamera);
496  gl->setUniform(prog->getUniformLoc("posToCamera"), posToCamera);
497  gl->setUniform(prog->getUniformLoc("normalToCamera"), posToCamera.getXYZ().inverted().transposed());
498  gl->setUniform(prog->getUniformLoc("hasNormals"), (normalAttrib != -1));
499  gl->setUniform(prog->getUniformLoc("diffuseSampler"), 0);
500  gl->setUniform(prog->getUniformLoc("alphaSampler"), 1);
501 
502  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, getVBO().getGLBuffer());
503  setGLAttrib(gl, posAttrib, prog->getAttribLoc("positionAttrib"));
504 
505  if (normalAttrib != -1)
506  setGLAttrib(gl, normalAttrib, prog->getAttribLoc("normalAttrib"));
507  else
508  glVertexAttrib3f(prog->getAttribLoc("normalAttrib"), 0.0f, 0.0f, 0.0f);
509 
510  if (colorAttrib != -1)
511  setGLAttrib(gl, colorAttrib, prog->getAttribLoc("colorAttrib"));
512  else
513  glVertexAttrib4f(prog->getAttribLoc("colorAttrib"), 1.0f, 1.0f, 1.01f, 1.0f);
514 
515  if (texCoordAttrib != -1)
516  setGLAttrib(gl, texCoordAttrib, prog->getAttribLoc("texCoordAttrib"));
517  else
518  glVertexAttrib2f(prog->getAttribLoc("texCoordAttrib"), 0.0f, 0.0f);
519 
520  // Render each submesh.
521 
522  for (int i = 0; i < numSubmeshes(); i++)
523  {
524  const Material& mat = material(i);
525  gl->setUniform(prog->getUniformLoc("diffuseUniform"), mat.diffuse);
526  gl->setUniform(prog->getUniformLoc("specularUniform"), mat.specular * 0.5f);
527  gl->setUniform(prog->getUniformLoc("glossiness"), mat.glossiness);
528 
530  glBindTexture(GL_TEXTURE_2D, mat.textures[TextureType_Diffuse].getGLTexture());
531  gl->setUniform(prog->getUniformLoc("hasDiffuseTexture"), mat.textures[TextureType_Diffuse].exists());
532 
534  glBindTexture(GL_TEXTURE_2D, mat.textures[TextureType_Alpha].getGLTexture());
535  gl->setUniform(prog->getUniformLoc("hasAlphaTexture"), mat.textures[TextureType_Alpha].exists());
536 
537  glDrawElements(GL_TRIANGLES, vboIndexSize(i), GL_UNSIGNED_INT, (void*)(UPTR)vboIndexOffset(i));
538  }
539 
540  gl->resetAttribs();
541 }
542 
543 //------------------------------------------------------------------------
544 
546 {
547  if (!m_isInMemory)
548  return;
549 
550  m_isInMemory = false;
551  m_vertices.reset();
552  for (int i = 0; i < m_submeshes.getSize(); i++)
553  {
554  delete m_submeshes[i].indices;
555  m_submeshes[i].indices = NULL;
556  }
557 }
558 
559 //------------------------------------------------------------------------
560 
562 {
563  int posAttrib = findAttrib(AttribType_Position);
564  if (posAttrib == -1)
565  return;
566 
567  for (int i = 0; i < numVertices(); i++)
568  {
569  Vec4f pos = getVertexAttrib(i, posAttrib);
570  pos = mat * pos;
571  if (pos.w != 0.0f)
572  pos *= 1.0f / pos.w;
573  setVertexAttrib(i, posAttrib, pos);
574  }
575 }
576 
577 //------------------------------------------------------------------------
578 
579 void MeshBase::xformNormals(const Mat3f& mat, bool normalize)
580 {
581  int normalAttrib = findAttrib(AttribType_Normal);
582  if (normalAttrib == -1)
583  return;
584 
585  for (int i = 0; i < numVertices(); i++)
586  {
587  Vec3f normal = getVertexAttrib(i, normalAttrib).getXYZ();
588  normal = mat * normal;
589  if (normalize)
590  normal = normal.normalized();
591  setVertexAttrib(i, normalAttrib, Vec4f(normal, 0.0f));
592  }
593 }
594 
595 //------------------------------------------------------------------------
596 
597 void MeshBase::getBBox(Vec3f& lo, Vec3f& hi) const
598 {
599  lo = Vec3f(+FW_F32_MAX);
600  hi = Vec3f(-FW_F32_MAX);
601 
602  int posAttrib = -1;
603  for (int i = 0; i < numAttribs(); i++)
605  posAttrib = i;
606 
607  if (posAttrib == -1)
608  return;
609 
610  for (int i = 0; i < numVertices(); i++)
611  {
612  Vec4f pos = getVertexAttrib(i, posAttrib);
613  for (int j = 0; j < 3; j++)
614  {
615  lo[j] = min(lo[j], pos[j]);
616  hi[j] = max(hi[j], pos[j]);
617  }
618  }
619 }
620 
621 //------------------------------------------------------------------------
622 
624 {
625  int posAttrib = findAttrib(AttribType_Position);
626  int normalAttrib = findAttrib(AttribType_Normal);
627  if (posAttrib == -1 || normalAttrib == -1)
628  return;
629 
630  // Calculate average normal for each vertex position.
631 
632  Hash<Vec3f, Vec3f> posToNormal;
633  Vec3f v[3];
634 
635  for (int i = 0; i < numSubmeshes(); i++)
636  {
637  const Array<Vec3i>& tris = indices(i);
638  for (int j = 0; j < tris.getSize(); j++)
639  {
640  const Vec3i& tri = tris[j];
641  for (int k = 0; k < 3; k++)
642  v[k] = getVertexAttrib(tri[k], posAttrib).getXYZ();
643 
644  Vec3f triNormal = (v[1] - v[0]).cross(v[2] - v[0]);
645  for (int k = 0; k < 3; k++)
646  {
647  Vec3f* vertNormal = posToNormal.search(v[k]);
648  if (vertNormal)
649  *vertNormal += triNormal;
650  else
651  posToNormal.add(v[k], triNormal);
652  }
653  }
654  }
655 
656  // Output normals.
657 
658  for (int i = 0; i < numVertices(); i++)
659  {
660  Vec3f pos = getVertexAttrib(i, posAttrib).getXYZ();
661  Vec3f* normal = posToNormal.search(pos);
662  if (normal)
663  setVertexAttrib(i, normalAttrib, Vec4f((*normal).normalized(), 0.0f));
664  }
665 }
666 
667 //------------------------------------------------------------------------
668 
670 {
671  for (int i = 0; i < numSubmeshes(); i++)
672  {
673  Array<Vec3i>& tris = mutableIndices(i);
674  for (int j = 0; j < tris.getSize(); j++)
675  swap(tris[j].x, tris[j].y);
676  }
677 }
678 
679 //------------------------------------------------------------------------
680 
681 void MeshBase::clean(void)
682 {
683  // Remove degenerate triangles and empty submeshes.
684 
685  int submeshOut = 0;
686  for (int submeshIn = 0; submeshIn < numSubmeshes(); submeshIn++)
687  {
688  Array<Vec3i>& inds = mutableIndices(submeshIn);
689  int indOut = 0;
690  for (int i = 0; i < inds.getSize(); i++)
691  {
692  const Vec3i& v = inds[i];
693  if (v.x != v.y && v.x != v.z && v.y != v.z)
694  inds[indOut++] = v;
695  }
696 
697  if (indOut)
698  {
699  inds.resize(indOut);
700  if (submeshOut != submeshIn)
701  {
702  material(submeshOut) = material(submeshIn);
703  mutableIndices(submeshOut) = inds;
704  }
705  mutableIndices(submeshOut).compact();
706  submeshOut++;
707  }
708  }
709  resizeSubmeshes(submeshOut);
710 
711  // Tag referenced vertices.
712 
713  Array<U8> vertUsed;
714  vertUsed.reset(numVertices());
715  memset(vertUsed.getPtr(), 0, vertUsed.getNumBytes());
716 
717  for (int submeshIn = 0; submeshIn < numSubmeshes(); submeshIn++)
718  {
719  const Array<Vec3i>& inds = indices(submeshIn);
720  for (int i = 0; i < inds.getSize(); i++)
721  for (int j = 0; j < 3; j++)
722  vertUsed[inds[i][j]] = 1;
723  }
724 
725  // Compact vertex array.
726 
727  Array<S32> vertRemap;
728  vertRemap.reset(numVertices());
729  memset(vertRemap.getPtr(), -1, vertRemap.getNumBytes());
730  U8* vertPtr = getMutableVertexPtr();
731  int vertStride = vertexStride();
732 
733  int vertOut = 0;
734  for (int vertIn = 0; vertIn < vertUsed.getSize(); vertIn++)
735  {
736  if (!vertUsed[vertIn])
737  continue;
738 
739  vertRemap[vertIn] = vertOut;
740  if (vertOut != vertIn)
741  memcpy(vertPtr + vertOut * vertStride, vertPtr + vertIn * vertStride, vertStride);
742  vertOut++;
743  }
744  resizeVertices(vertOut);
745 
746  // Remap indices.
747 
748  for (int submeshIdx = 0; submeshIdx < numSubmeshes(); submeshIdx++)
749  {
750  Array<Vec3i>& inds = mutableIndices(submeshIdx);
751  for (int i = 0; i < inds.getSize(); i++)
752  for (int j = 0; j < 3; j++)
753  inds[i][j] = vertRemap[inds[i][j]];
754  }
755 }
756 
757 //------------------------------------------------------------------------
758 
760 {
761  // Collapse vertices.
762 
763  int num = numVertices();
764  U8* vertPtr = getMutableVertexPtr();
765  int vertStride = vertexStride();
766 
768  Array<S32> remap;
769  hash.setCapacity(num);
770  remap.reset(num);
771 
772  for (int i = 0; i < num; i++)
773  {
774  GenericHashKey key(vertPtr + i * vertStride, vertStride);
775  S32* found = hash.search(key);
776  if (found)
777  remap[i] = *found;
778  else
779  {
780  remap[i] = hash.getSize();
781  hash.add(key, remap[i]);
782  if (remap[i] != i)
783  memcpy(vertPtr + remap[i] * vertStride, vertPtr + i * vertStride, vertStride);
784  }
785  }
786 
787  resizeVertices(hash.getSize());
788 
789  // Remap indices.
790 
791  for (int submeshIdx = 0; submeshIdx < numSubmeshes(); submeshIdx++)
792  {
793  Array<Vec3i>& inds = mutableIndices(submeshIdx);
794  for (int i = 0; i < inds.getSize(); i++)
795  for (int j = 0; j < 3; j++)
796  inds[i][j] = remap[inds[i][j]];
797  }
798 }
799 
800 //------------------------------------------------------------------------
801 
803 {
804  // Find shared vertices and remap indices.
805 
806  int num = numVertices();
807  Array<Vec2i> remap;
808  Array<S32> dup;
809  remap.reset(num);
810  memset(remap.getPtr(), -1, remap.getNumBytes());
811 
812  for (int submeshIdx = 0; submeshIdx < numSubmeshes(); submeshIdx++)
813  {
814  Array<Vec3i>& inds = mutableIndices(submeshIdx);
815  for (int i = 0; i < inds.getSize(); i++)
816  for (int j = 0; j < 3; j++)
817  {
818  int v = inds[i][j];
819  if (remap[v].x != submeshIdx)
820  {
821  remap[v].x = submeshIdx;
822  if (remap[v].y == -1)
823  remap[v].y = v;
824  else
825  {
826  remap[v].y = num + dup.getSize();
827  dup.add(v);
828  }
829  }
830  inds[i][j] = remap[v].y;
831  }
832  }
833 
834  // Duplicate vertices.
835 
836  resizeVertices(num + dup.getSize());
837  U8* vertPtr = getMutableVertexPtr();
838  int vertStride = vertexStride();
839 
840  for (int i = 0; i < dup.getSize(); i++)
841  memcpy(vertPtr + (num + i) * vertStride, vertPtr + dup[i] * vertStride, vertStride);
842 }
843 
844 //------------------------------------------------------------------------
845 
847 {
848  for (int submeshIdx = 0; submeshIdx < numSubmeshes(); submeshIdx++)
849  {
850  Material& mat = material(submeshIdx);
852  if (tex.exists())
853  {
854  Vec4f avg = tex.getMipLevel(64).getImage()->getVec4f(0);
855  mat.diffuse = Vec4f(avg.getXYZ(), mat.diffuse.w);
856  }
857  }
858 }
859 
860 //------------------------------------------------------------------------
861 
862 void MeshBase::simplify(F32 maxError)
863 {
864  struct Vertex
865  {
866  Vec3f pos;
867  F32 error;
868  F32 posWeight;
869  F32 outWeight;
870  S32 firstEdge;
871  S32 timeStamp;
872  S32 outIdx;
873  };
874 
875  struct Edge
876  {
877  Vec2i verts;
878  Vec2i next;
879  };
880 
881  // Find attributes.
882 
883  int posAttrib = findAttrib(MeshBase::AttribType_Position);
884  int normalAttrib = findAttrib(MeshBase::AttribType_Normal);
885  if (posAttrib == -1)
886  return;
887 
888  // Group vertices.
889 
890  Array<Vertex> verts(NULL, numVertices());
891  UnionFind posGroups(numVertices()); // by position
892  UnionFind outGroups(numVertices()); // by all attributes
893  {
894  Hash<Vec3f, S32> posHash;
896  for (int i = 0; i < verts.getSize(); i++)
897  {
898  Vertex& v = verts[i];
899  v.pos = getVertexAttrib(i, posAttrib).getXYZ();
900  v.error = 0.0f;
901  v.posWeight = 0.0f;
902  v.outWeight = 0.0f;
903  v.firstEdge = -1;
904  v.timeStamp = -1;
905  v.outIdx = -1;
906 
907  S32* group = posHash.search(v.pos);
908  posGroups.unionSets(i, (group) ? *group : posHash.add(v.pos, i));
909 
911  group = outHash.search(outKey);
912  outGroups.unionSets(i, (group) ? *group : outHash.add(outKey, i));
913  }
914  }
915 
916  // Collect edges and accumulate weights.
917 
918  Array<Edge> edges;
919  {
920  Set<Vec2i> edgeSet;
921  for (int submeshIdx = 0; submeshIdx < numSubmeshes(); submeshIdx++)
922  {
923  const Array<Vec3i>& tris = indices(submeshIdx);
924  for (int triIdx = 0; triIdx < tris.getSize(); triIdx++)
925  {
926  const Vec3i& tri = tris[triIdx];
927  F32 area = max(length(cross(verts[tri.y].pos - verts[tri.x].pos, verts[tri.z].pos - verts[tri.x].pos)), 1.0e-8f);
928  for (int i = 0; i < 3; i++)
929  {
930  Vec2i vi = Vec2i(posGroups[tri[i]], posGroups[tri[(i == 2) ? 0 : (i + 1)]]);
931  verts[vi.x].posWeight += area;
932  verts[outGroups[tri[i]]].outWeight += area;
933 
934  if (vi.x > vi.y)
935  swap(vi.x, vi.y);
936  if (vi.x == vi.y || edgeSet.contains(vi))
937  continue;
938 
939  edgeSet.add(vi);
940  int ei = edges.getSize();
941  Edge& e = edges.add();
942  e.verts = vi;
943 
944  for (int j = 0; j < 2; j++)
945  {
946  S32* prevSlot = &verts[vi[j]].firstEdge;
947  if (*prevSlot == -1)
948  e.next[j] = ei;
949  else
950  {
951  prevSlot = &edges[*prevSlot].next[(edges[*prevSlot].verts.x == vi[j]) ? 0 : 1];
952  e.next[j] = *prevSlot;
953  }
954  *prevSlot = ei;
955  }
956  }
957  }
958  }
959  }
960 
961  // Create binary heap of edges.
962 
963  BinaryHeap<F32> edgeHeap;
964  for (int i = 0; i < edges.getSize(); i++)
965  {
966  const Vertex& va = verts[edges[i].verts.x];
967  const Vertex& vb = verts[edges[i].verts.y];
968  F32 error = max(va.posWeight, vb.posWeight) * length(va.pos - vb.pos) / (va.posWeight + vb.posWeight);
969  if (error <= maxError)
970  edgeHeap.add(i, error);
971  }
972 
973  // Collapse edges.
974 
975  for (int timeStamp = 0; !edgeHeap.isEmpty(); timeStamp++)
976  {
977  // Group removed vertices to form a new one.
978 
979  int removedEdge = edgeHeap.getMinIndex();
980  const Vec2i& removedVerts = edges[removedEdge].verts;
981  const Vertex& va = verts[removedVerts.x];
982  const Vertex& vb = verts[removedVerts.y];
983 
984  int vi = posGroups.unionSets(removedVerts.x, removedVerts.y);
985  Vertex& v = verts[vi];
986  v.pos = (va.pos * va.posWeight + vb.pos * vb.posWeight) / (va.posWeight + vb.posWeight);
987  v.error = edgeHeap.remove(removedEdge);
988  v.posWeight = va.posWeight + vb.posWeight;
989  v.firstEdge = -1;
990 
991  // Update connected edges.
992 
993  for (int i = 0; i < 2; i++)
994  {
995  int nextEdge = edges[removedEdge].next[i];
996  while (nextEdge != removedEdge)
997  {
998  int currEdge = nextEdge;
999  Edge& e = edges[currEdge];
1000  int c = (e.verts.x == removedVerts[i]) ? 0 : 1;
1001  nextEdge = e.next[c];
1002  edgeHeap.remove(currEdge);
1003 
1004  // Duplicate => discard.
1005 
1006  int otherVertex = e.verts[1 - c];
1007  if (otherVertex == -1 || verts[otherVertex].timeStamp == timeStamp)
1008  {
1009  e.verts[c] = -1;
1010  continue;
1011  }
1012 
1013  // Update the edge.
1014 
1015  Vertex& vo = verts[otherVertex];
1016  vo.timeStamp = timeStamp;
1017  e.verts[c] = vi;
1018 
1019  S32* prevSlot = &v.firstEdge;
1020  if (*prevSlot == -1)
1021  e.next[c] = currEdge;
1022  else
1023  {
1024  prevSlot = &edges[*prevSlot].next[(edges[*prevSlot].verts.x == vi) ? 0 : 1];
1025  e.next[c] = *prevSlot;
1026  }
1027  *prevSlot = currEdge;
1028 
1029  // Add to the heap.
1030 
1031  F32 coef = length(v.pos - vo.pos) / (v.posWeight + vo.posWeight);
1032  F32 error = max(v.error + vo.posWeight * coef, vo.error + v.posWeight * coef);
1033  if (error <= maxError)
1034  edgeHeap.add(currEdge, error);
1035  }
1036  }
1037  }
1038 
1039  // For each degenerate edge, remove triangle and group vertices.
1040 
1041  for (int submeshIdx = 0; submeshIdx < numSubmeshes(); submeshIdx++)
1042  {
1043  Array<Vec3i>& tris = mutableIndices(submeshIdx);
1044  for (int triIdx = tris.getSize() - 1; triIdx >= 0; triIdx--)
1045  {
1046  const Vec3i& tri = tris[triIdx];
1047  bool degen = false;
1048  for (int i = 0; i < 3; i++)
1049  {
1050  int j = (i == 2) ? 0 : (i + 1);
1051  if (posGroups[tri[i]] != posGroups[tri[j]])
1052  continue;
1053  degen = true;
1054  outGroups.unionSets(tri[i], tri[j]);
1055  }
1056  if (degen)
1057  tris.removeSwap(triIdx);
1058  }
1059  tris.compact();
1060  }
1061 
1062  // Assign output vertices.
1063 
1064  int numOutVerts = 0;
1065  for (int submeshIdx = 0; submeshIdx < numSubmeshes(); submeshIdx++)
1066  {
1067  Array<Vec3i>& tris = mutableIndices(submeshIdx);
1068  for (int triIdx = 0; triIdx < tris.getSize(); triIdx++)
1069  {
1070  Vec3i& tri = tris[triIdx];
1071  for (int i = 0; i < 3; i++)
1072  {
1073  S32& idx = verts[outGroups[tri[i]]].outIdx;
1074  if (idx == -1)
1075  idx = numOutVerts++;
1076  tri[i] = idx;
1077  }
1078  }
1079  }
1080 
1081  // Initialize output vertices.
1082 
1083  int numAttrib = numAttribs();
1084  Array<Vec4f> outAttribs(NULL, numOutVerts * numAttrib);
1085  Array<F32> outDenom(NULL, numOutVerts);
1086  memset(outAttribs.getPtr(), 0, outAttribs.getNumBytes());
1087  memset(outDenom.getPtr(), 0, outDenom.getNumBytes());
1088 
1089  // Accumulate vertex attributes.
1090 
1091  for (int i = 0; i < verts.getSize(); i++)
1092  {
1093  const Vertex& v = verts[outGroups[i]];
1094  if (v.outIdx == -1 || v.outWeight == 0.0f)
1095  continue;
1096 
1097  Vec4f* ptr = outAttribs.getPtr(v.outIdx * numAttrib);
1098  for (int j = 0; j < numAttrib; j++)
1099  if (j == posAttrib)
1100  ptr[j] = Vec4f(verts[posGroups[i]].pos, 1.0f);
1101  else
1102  ptr[j] += getVertexAttrib(i, j) * v.outWeight;
1103  outDenom[v.outIdx] += v.outWeight;
1104  }
1105 
1106  // Output vertices.
1107 
1108  resetVertices(numOutVerts);
1109  for (int i = 0; i < numOutVerts; i++)
1110  {
1111  const Vec4f* ptr = outAttribs.getPtr(i * numAttrib);
1112  F32 coef = 1.0f / outDenom[i];
1113  for (int j = 0; j < numAttrib; j++)
1114  {
1115  Vec4f v = ptr[j];
1116  if (j == normalAttrib)
1117  v = Vec4f(normalize(v.getXYZ()), 0.0f);
1118  else if (j != posAttrib)
1119  v *= coef;
1120  setVertexAttrib(i, j, v);
1121  }
1122  }
1123 }
1124 
1125 //------------------------------------------------------------------------
1126 
1127 void FW::addCubeToMesh(Mesh<VertexPNC>& mesh, int submesh, const Vec3f& lo, const Vec3f& hi, const Vec4f& color, bool forceNormal, const Vec3f& normal)
1128 {
1129  VertexPNC vertexArray[] =
1130  {
1131  VertexPNC(Vec3f(lo.x, lo.y, hi.z), Vec3f(-1.0f, 0.0f, 0.0f), color),
1132  VertexPNC(Vec3f(lo.x, hi.y, lo.z), Vec3f(-1.0f, 0.0f, 0.0f), color),
1133  VertexPNC(Vec3f(lo.x, hi.y, hi.z), Vec3f(-1.0f, 0.0f, 0.0f), color),
1134  VertexPNC(Vec3f(lo.x, lo.y, lo.z), Vec3f(-1.0f, 0.0f, 0.0f), color),
1135 
1136  VertexPNC(Vec3f(hi.x, lo.y, hi.z), Vec3f(+1.0f, 0.0f, 0.0f), color),
1137  VertexPNC(Vec3f(hi.x, hi.y, lo.z), Vec3f(+1.0f, 0.0f, 0.0f), color),
1138  VertexPNC(Vec3f(hi.x, hi.y, hi.z), Vec3f(+1.0f, 0.0f, 0.0f), color),
1139  VertexPNC(Vec3f(hi.x, lo.y, lo.z), Vec3f(+1.0f, 0.0f, 0.0f), color),
1140 
1141  VertexPNC(Vec3f(lo.x, lo.y, hi.z), Vec3f( 0.0f, -1.0f, 0.0f), color),
1142  VertexPNC(Vec3f(hi.x, lo.y, lo.z), Vec3f( 0.0f, -1.0f, 0.0f), color),
1143  VertexPNC(Vec3f(hi.x, lo.y, hi.z), Vec3f( 0.0f, -1.0f, 0.0f), color),
1144  VertexPNC(Vec3f(lo.x, lo.y, lo.z), Vec3f( 0.0f, -1.0f, 0.0f), color),
1145 
1146  VertexPNC(Vec3f(lo.x, hi.y, hi.z), Vec3f( 0.0f, +1.0f, 0.0f), color),
1147  VertexPNC(Vec3f(hi.x, hi.y, lo.z), Vec3f( 0.0f, +1.0f, 0.0f), color),
1148  VertexPNC(Vec3f(hi.x, hi.y, hi.z), Vec3f( 0.0f, +1.0f, 0.0f), color),
1149  VertexPNC(Vec3f(lo.x, hi.y, lo.z), Vec3f( 0.0f, +1.0f, 0.0f), color),
1150 
1151  VertexPNC(Vec3f(lo.x, hi.y, lo.z), Vec3f( 0.0f, 0.0f, -1.0f), color),
1152  VertexPNC(Vec3f(hi.x, lo.y, lo.z), Vec3f( 0.0f, 0.0f, -1.0f), color),
1153  VertexPNC(Vec3f(hi.x, hi.y, lo.z), Vec3f( 0.0f, 0.0f, -1.0f), color),
1154  VertexPNC(Vec3f(lo.x, lo.y, lo.z), Vec3f( 0.0f, 0.0f, -1.0f), color),
1155 
1156  VertexPNC(Vec3f(lo.x, hi.y, hi.z), Vec3f( 0.0f, 0.0f, +1.0f), color),
1157  VertexPNC(Vec3f(hi.x, lo.y, hi.z), Vec3f( 0.0f, 0.0f, +1.0f), color),
1158  VertexPNC(Vec3f(hi.x, hi.y, hi.z), Vec3f( 0.0f, 0.0f, +1.0f), color),
1159  VertexPNC(Vec3f(lo.x, lo.y, hi.z), Vec3f( 0.0f, 0.0f, +1.0f), color)
1160  };
1161 
1162  static const Vec3i indexArray[] =
1163  {
1164  Vec3i(0, 1, 3), Vec3i(2, 1, 0),
1165  Vec3i(6, 4, 5), Vec3i(5, 4, 7),
1166  Vec3i(8, 11, 9), Vec3i(10, 8, 9),
1167  Vec3i(15, 12, 13), Vec3i(12, 14, 13),
1168  Vec3i(16, 17, 19), Vec3i(18, 17, 16),
1169  Vec3i(23, 21, 20), Vec3i(20, 21, 22)
1170  };
1171 
1172  int base = mesh.numVertices();
1173  VertexPNC* vertexPtr = mesh.addVertices(vertexArray, FW_ARRAY_SIZE(vertexArray));
1174  if (forceNormal)
1175  for (int i = 0; i < (int)FW_ARRAY_SIZE(vertexArray); i++)
1176  vertexPtr[i].n = normal;
1177 
1178  Array<Vec3i>& indices = mesh.mutableIndices(submesh);
1179  for (int i = 0; i < (int)FW_ARRAY_SIZE(indexArray); i++)
1180  indices.add(indexArray[i] + base);
1181 }
1182 
1183 //------------------------------------------------------------------------
1184 
1185 MeshBase* FW::importMesh(const String& fileName)
1186 {
1187  String lower = fileName.toLower();
1188 
1189 #define STREAM(CALL) { File file(fileName, File::Read); BufferedInputStream stream(file); return CALL; }
1190  if (lower.endsWith(".bin")) STREAM(importBinaryMesh(stream))
1191  if (lower.endsWith(".obj")) STREAM(importWavefrontMesh(stream, fileName))
1192 #undef STREAM
1193 
1194  setError("importMesh(): Unsupported file extension '%s'!", fileName.getPtr());
1195  return NULL;
1196 }
1197 
1198 //------------------------------------------------------------------------
1199 
1200 void FW::exportMesh(const String& fileName, const MeshBase* mesh)
1201 {
1202  FW_ASSERT(mesh);
1203  String lower = fileName.toLower();
1204 
1205 #define STREAM(CALL) { File file(fileName, File::Create); BufferedOutputStream stream(file); CALL; stream.flush(); return; }
1206  if (lower.endsWith(".bin")) STREAM(exportBinaryMesh(stream, mesh))
1207  if (lower.endsWith(".obj")) STREAM(exportWavefrontMesh(stream, mesh, fileName))
1208 #undef STREAM
1209 
1210  setError("exportMesh(): Unsupported file extension '%s'!", fileName.getPtr());
1211 }
1212 
1213 //------------------------------------------------------------------------
1214 
1216 {
1217  return
1218  "obj:Wavefront Mesh,"
1219  "bin:Binary Mesh";
1220 }
1221 
1222 //------------------------------------------------------------------------
1223 
1225 {
1226  return
1227  "obj:Wavefront Mesh,"
1228  "bin:Binary Mesh";
1229 }
1230 
1231 //------------------------------------------------------------------------
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
void collapseVertices(void)
Definition: Mesh.cpp:759
FW_CUDA_FUNC T length(const VectorBase< T, L, S > &v)
Definition: Math.hpp:459
#define NULL
Definition: Defs.hpp:39
#define FW_F32_MAX
Definition: Defs.hpp:118
int vboIndexSize(int submesh)
Definition: Mesh.hpp:169
bool endsWith(const String &str) const
Definition: String.cpp:273
const char * getPtr(void) const
Definition: String.hpp:51
__w64 U32 UPTR
Definition: Defs.hpp:106
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 glBindBuffer
Definition: DLLImports.inl:315
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
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
Definition: Hash.hpp:37
const Image * getImage(void) const
Definition: Texture.hpp:64
const AttribSpec & attribSpec(int attrib) const
Definition: Mesh.hpp:126
void freeVBO(void)
Definition: Mesh.hpp:177
void setError(const char *fmt,...)
Definition: Defs.cpp:253
void ** ptr
Definition: DLLImports.cpp:74
void setUniform(int loc, S32 v)
Definition: GLContext.hpp:160
const U8 * vertex(int idx) const
Definition: Mesh.hpp:143
int numSubmeshes(void) const
Definition: Mesh.hpp:152
FW_CUDA_FUNC F64 pow(F64 a, F64 b)
Definition: Math.hpp:45
void xformNormals(const Mat3f &mat, bool normalize=true)
Definition: Mesh.cpp:579
#define STREAM(CALL)
void recomputeNormals(void)
Definition: Mesh.cpp:623
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
Definition: DLLImports.inl:132
U32 hash(const T &value)
Definition: Hash.hpp:199
void exportMesh(const String &fileName, const MeshBase *mesh)
Definition: Mesh.cpp:1200
FW_CUDA_FUNC Vec3f getXYZ(void) const
Definition: Math.hpp:365
const Material & material(int submesh) const
Definition: Mesh.hpp:161
void setProgram(const String &id, Program *prog)
Definition: GLContext.cpp:875
void draw(GLContext *gl, const Mat4f &posToCamera, const Mat4f &projection, GLContext::Program *prog=NULL, bool gouraud=false)
Definition: Mesh.cpp:367
void clear(void)
Definition: Array.hpp:359
GLuint getGLTexture(const ImageFormat::ID desiredFormat=ImageFormat::ID_Max, bool generateMipmaps=true) const
Definition: Texture.cpp:82
String toLower(void) const
Definition: String.cpp:245
#define GL_ELEMENT_ARRAY_BUFFER
Definition: DLLImports.hpp:159
T & add(const T &value)
Definition: Hash.hpp:72
void setOwner(Module module, bool modify, bool async=false, CUstream cudaStream=NULL, S64 validSize=-1)
Definition: Buffer.cpp:220
S getNumBytes(void) const
Definition: Array.hpp:225
FW_CUDA_FUNC T dot(const VectorBase< T, L, S > &a, const VectorBase< T, L, V > &b)
Definition: Math.hpp:477
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 x
Definition: DLLImports.inl:363
void exportWavefrontMesh(BufferedOutputStream &stream, const MeshBase *mesh, const String &fileName)
AttribFormat format
Definition: Mesh.hpp:74
Mesh< VertexPNT > * importWavefrontMesh(BufferedInputStream &stream, const String &fileName)
void addAttribs(const MeshBase &other)
Definition: Mesh.cpp:66
Texture getMipLevel(int level) const
Definition: Texture.cpp:104
void reset(S size=0)
Definition: Array.hpp:317
GLint getUniformLoc(const String &name) const
Definition: GLContext.cpp:95
int getMinIndex(void)
Definition: BinaryHeap.hpp:195
int vboIndexOffset(int submesh)
Definition: Mesh.hpp:168
float F32
Definition: Defs.hpp:89
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 y
Definition: DLLImports.inl:363
Program * getProgram(const String &id) const
Definition: GLContext.cpp:867
void add(int idx, const T &value)
Definition: BinaryHeap.hpp:94
U8 * getMutableVertexPtr(int idx=0)
Definition: Mesh.hpp:142
bool contains(const T &value) const
Definition: Hash.hpp:60
int main(int argc, char *argv[])
Definition: Main.cpp:51
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
GLint getAttribLoc(const String &name) const
Definition: GLContext.cpp:88
void dupVertsPerSubmesh(void)
Definition: Mesh.cpp:802
Array< Vec3i > & mutableIndices(int submesh)
Definition: Mesh.hpp:157
void setAttrib(int loc, int size, GLenum type, int stride, Buffer *buffer, const void *pointer)
Definition: GLContext.cpp:310
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
U8 * getMutablePtr(S64 ofs=0)
Definition: Buffer.hpp:110
FW_CUDA_FUNC T min(const VectorBase< T, L, S > &v)
Definition: Math.hpp:461
Vec4f getVec4f(const Vec2i &pos) const
Definition: Image.cpp:369
void resetVertices(int num)
Definition: Mesh.cpp:213
FW_CUDA_FUNC T max(const VectorBase< T, L, S > &v)
Definition: Math.hpp:462
void simplify(F32 maxError)
Definition: Mesh.cpp:862
void free(Module module)
Definition: Buffer.cpp:80
void resizeSubmeshes(int num)
Definition: Mesh.cpp:281
#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
int findAttrib(AttribType type) const
Definition: Mesh.hpp:127
FW_CUDA_FUNC S inverted(void) const
Definition: Math.hpp:964
void resizeVertices(int num)
Definition: Mesh.cpp:227
void clean(void)
Definition: Mesh.cpp:681
bool exists(void) const
Definition: Texture.hpp:62
void fixMaterialColors(void)
Definition: Mesh.cpp:846
void resetAttribs(void)
Definition: GLContext.cpp:323
Vec4f getVertexAttrib(int idx, int attrib) const
Definition: Mesh.cpp:241
int getSize(void) const
Definition: Hash.hpp:122
V & add(const K &key, const V &value)
Definition: Hash.hpp:143
int numVertices(void) const
Definition: Mesh.hpp:136
int vertexStride(void) const
Definition: Mesh.hpp:137
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
FW_CUDA_FUNC F32 cross(const Vec2f &a, const Vec2f &b)
Definition: Math.hpp:481
const Array< Vec3i > & indices(int submesh) const
Definition: Mesh.hpp:156
void setGLAttrib(GLContext *gl, int attrib, int loc)
Definition: Mesh.cpp:342
void exportBinaryMesh(OutputStream &stream, const MeshBase *mesh)
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 n
Definition: DLLImports.inl:325
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 glVertexAttrib3f
Definition: DLLImports.inl:363
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
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
#define FW_ARRAY_SIZE(X)
Definition: Defs.hpp:79
unsigned char U8
Definition: Defs.hpp:83
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 glActiveTexture
Definition: DLLImports.inl:313
void freeMemory(void)
Definition: Mesh.cpp:545
int unionSets(int idxA, int idxB)
Definition: UnionFind.cpp:34
FW_CUDA_FUNC S normalized(T len=(T) 1) const
Definition: Math.hpp:144
void compact(void)
Definition: Array.hpp:335
U8 * mutableVertex(int idx)
Definition: Mesh.hpp:144
FW_CUDA_FUNC void swap(T &a, T &b)
Definition: Defs.hpp:183
bool isEmpty(void) const
Definition: BinaryHeap.hpp:52
const V * search(const K &key) const
Definition: Hash.hpp:128
void compact(void)
Definition: Mesh.cpp:200
#define FW_GL_SHADER_SOURCE(CODE)
Definition: GLContext.hpp:43
void setCapacity(int numItems)
Definition: Hash.hpp:139
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
void resizeDiscard(S64 size)
Definition: Buffer.hpp:83
bool isInMemory(void) const
Definition: Mesh.hpp:174
#define GL_TEXTURE0
Definition: DLLImports.hpp:180
T remove(int idx)
Definition: BinaryHeap.hpp:154
const U8 * getVertexPtr(int idx=0) const
Definition: Mesh.hpp:141
void resize(S size)
Definition: Array.hpp:366
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
MeshBase * importBinaryMesh(InputStream &stream)
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
#define GL_TEXTURE1
Definition: DLLImports.hpp:181