Developer Documentation

ArrowNode.cc
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42
43
44
45
46
47
48 //=============================================================================
49 //
50 // CLASS ArrowNode - IMPLEMENTATION
51 //
52 //=============================================================================
53
54 //== INCLUDES =================================================================
55 #include <ACG/GL/acg_glew.hh>
56 #include "ArrowNode.hh"
57 #include <ACG/GL/IRenderer.hh>
58 #include <OpenMesh/Core/Utils/vector_cast.hh>
59
60 //== NAMESPACES ===============================================================
61
62 namespace ACG {
63 namespace SceneGraph {
64
65 //== IMPLEMENTATION ==========================================================
66
67 ArrowNode::ArrowNode(BaseNode* _parent, std::string _name )
68 : MaterialNode(_parent, _name, MaterialNode::BaseColor),
69 numVertices_(0),
70 numIndices_(0),
71 localArrowMin_(0.0f, 0.0f, 0.0f),
72 localArrowMax_(0.0f, 0.0f, 0.0f),
73 invalidateInstanceData_(true),
74 invalidateInstanceBuffer_(true),
75 supportsInstancing_(-1)
76 {
77 drawMode(DrawModes::SOLID_FLAT_SHADED);
78 }
79
80 //----------------------------------------------------------------------------
81
82 ArrowNode::~ArrowNode()
83 {
84
85 }
86 //----------------------------------------------------------------------------
87
88 void ArrowNode::boundingBox(Vec3d& _bbMin, Vec3d& _bbMax)
89 {
90 float radius = std::max(localArrowMax_[1] - localArrowMin_[1], localArrowMax_[2] - localArrowMin_[2]) * 0.5f;
91
92 size_t n = arrows_.size();
93 for (size_t i = 0; i < n; ++i)
94 {
95 const Arrow* a = &arrows_[i];
96
97 // start and end point
98 Vec3f s = a->start;
99 Vec3f e = a->start + a->dir * a->scale[1];
100
101 // conv to double precision
102 Vec3d sd = OpenMesh::vector_cast<Vec3d>(s);
103 Vec3d ed = OpenMesh::vector_cast<Vec3d>(e);
104
105 // enlarge aabb by some amount to account for the volumetric shape
106 Vec3d volEnlargeOffset = OpenMesh::vector_cast<Vec3d>(radius * a->scale);
107
108 _bbMin.minimize(sd - volEnlargeOffset);
109 _bbMin.minimize(ed - volEnlargeOffset);
110
111 _bbMax.maximize(sd + volEnlargeOffset);
112 _bbMax.maximize(ed + volEnlargeOffset);
113 }
114 }
115
116
117 //----------------------------------------------------------------------------
118
119 DrawModes::DrawMode ArrowNode::availableDrawModes() const
120 {
121 return DrawModes::SOLID_FLAT_SHADED;
122 }
123
124 //----------------------------------------------------------------------------
125
126 void ArrowNode::createArrowMesh()
127 {
128 if (!numVertices_)
129 {
130 // arrow mesh data as result from meshcompiler:
131 // interleaved float3 pos, float3 normal
132 float vdata[] =
133 {
134 0.681818f, -0.034091f, -0.068182f, 0.000000f, -1.000000f, 0.000000f,
135 0.681818f, -0.034091f, 0.068182f, 0.000000f, -1.000000f, 0.000000f,
136 0.000000f, -0.034091f, 0.000000f, 0.000000f, -1.000000f, 0.000000f,
137 1.000000f, -0.034091f, 0.000000f, 0.000000f, -1.000000f, 0.000000f,
138 0.681818f, -0.034091f, -0.227273f, 0.000000f, -1.000000f, 0.000000f,
139 0.681818f, -0.034091f, 0.227273f, 0.000000f, -1.000000f, 0.000000f,
140 0.681818f, 0.034091f, -0.068182f, 0.000000f, 1.000000f, -0.000000f,
141 1.000000f, 0.034091f, 0.000000f, 0.000000f, 1.000000f, 0.000000f,
142 0.681818f, 0.034091f, -0.227273f, -0.000000f, 1.000000f, 0.000000f,
143 0.681818f, 0.034091f, 0.068182f, 0.000000f, 1.000000f, -0.000000f,
144 0.000000f, 0.034091f, 0.000000f, 0.000000f, 1.000000f, -0.000000f,
145 0.681818f, 0.034091f, 0.227273f, 0.000000f, 1.000000f, 0.000000f,
146 1.000000f, -0.034091f, 0.000000f, 0.581238f, 0.000000f, -0.813734f,
147 0.681818f, 0.034091f, -0.227273f, 0.581238f, 0.000000f, -0.813734f,
148 1.000000f, 0.034091f, 0.000000f, 0.581238f, 0.000000f, -0.813734f,
149 0.681818f, -0.034091f, -0.227273f, 0.581238f, 0.000000f, -0.813734f,
150 0.681818f, -0.034091f, 0.227273f, 0.581238f, 0.000000f, 0.813734f,
151 1.000000f, 0.034091f, 0.000000f, 0.581238f, 0.000000f, 0.813734f,
152 0.681818f, 0.034091f, 0.227273f, 0.581238f, -0.000000f, 0.813734f,
153 1.000000f, -0.034091f, 0.000000f, 0.581238f, 0.000000f, 0.813734f,
154 0.681818f, -0.034091f, 0.068182f, -1.000000f, -0.000000f, 0.000000f,
155 0.681818f, 0.034091f, 0.227273f, -1.000000f, -0.000000f, 0.000000f,
156 0.681818f, 0.034091f, 0.068182f, -1.000000f, 0.000000f, 0.000000f,
157 0.681818f, -0.034091f, 0.227273f, -1.000000f, -0.000000f, 0.000000f,
158 0.681818f, -0.034091f, -0.227273f, -1.000000f, -0.000000f, 0.000000f,
159 0.681818f, 0.034091f, -0.068182f, -1.000000f, -0.000000f, 0.000000f,
160 0.681818f, 0.034091f, -0.227273f, -1.000000f, 0.000000f, 0.000000f,
161 0.681818f, -0.034091f, -0.068182f, -1.000000f, -0.000000f, 0.000000f,
162 0.000000f, -0.034091f, 0.000000f, -0.099504f, 0.000000f, 0.995037f,
163 0.681818f, 0.034091f, 0.068182f, -0.099504f, 0.000000f, 0.995037f,
164 0.000000f, 0.034091f, 0.000000f, -0.099504f, 0.000000f, 0.995037f,
165 0.681818f, -0.034091f, 0.068182f, -0.099504f, 0.000000f, 0.995037f,
166 0.681818f, -0.034091f, -0.068182f, -0.099504f, -0.000000f, -0.995037f,
167 0.000000f, 0.034091f, 0.000000f, -0.099504f, -0.000000f, -0.995037f,
168 0.681818f, 0.034091f, -0.068182f, -0.099504f, 0.000000f, -0.995037f,
169 0.000000f, -0.034091f, 0.000000f, -0.099504f, -0.000000f, -0.995037f,
170 };
171
172 // indices
173 int idata[] =
174 {
175 0, 1, 2,
176 0, 3, 1,
177 0, 4, 3,
178 1, 3, 5,
179 6, 7, 8,
180 6, 9, 7,
181 6, 10, 9,
182 7, 9, 11,
183 12, 13, 14,
184 13, 12, 15,
185 16, 17, 18,
186 17, 16, 19,
187 20, 21, 22,
188 21, 20, 23,
189 24, 25, 26,
190 25, 24, 27,
191 28, 29, 30,
192 29, 28, 31,
193 32, 33, 34,
194 33, 32, 35,
195 };
196
197 // vertex decl
198 if (!vertexDecl_.getNumElements())
199 {
200 vertexDecl_.addElement(GL_FLOAT, 3, VERTEX_USAGE_POSITION);
201 vertexDecl_.addElement(GL_FLOAT, 3, VERTEX_USAGE_NORMAL);
202 }
203
204 numVertices_ = sizeof(vdata) / vertexDecl_.getVertexStride();
205 numIndices_ = sizeof(idata) / sizeof(idata[0]);
206
207 // vertex + index buffer
208 vertexBuffer_.upload(sizeof(vdata), vdata, GL_STATIC_DRAW);
209 indexBuffer_.upload(sizeof(idata), idata, GL_STATIC_DRAW);
210
211 // compute local aabb
212 localArrowMin_ = Vec3f(vdata[0], vdata[1], vdata[2]);
213 localArrowMax_ = localArrowMin_;
214
215 for (int i = 1; i < numVertices_; ++i)
216 {
217 Vec3f v = Vec3f(vdata[i * 6], vdata[i * 6 + 1], vdata[i * 6 + 2]);
218 localArrowMin_.minimize(v);
219 localArrowMax_.maximize(v);
220 }
221 }
222 }
223
224 //----------------------------------------------------------------------------
225
226 void ArrowNode::draw(GLState& _state, const DrawModes::DrawMode& _drawMode)
227 {
228 createArrowMesh();
229 updateInstanceData();
230
231 vertexBuffer_.bind();
232 indexBuffer_.bind();
233
234 vertexDecl_.activateFixedFunction();
235
236 // save model-view matrix
237 GLMatrixf viewMatrix;
238 glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat*)&viewMatrix);
239
240
241 // GL_COLOR_MATERIAL: multiply the glColor value with the ambient and diffuse term
242 glEnable(GL_COLOR_MATERIAL);
243 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
244
245 for (size_t i = 0; i < arrows_.size(); ++i)
246 {
247 // use transform of the individual arrows
248 GLMatrixf worldView = viewMatrix * readWorldMatrix(i);
249 glLoadMatrixf(worldView.data());
250
251 Vec4uc c = arrows_[i].color;
252 glColor4ub(c[0], c[1], c[2], c[3]);
253
254 glDrawElements(GL_TRIANGLES, numIndices_, GL_UNSIGNED_INT, 0);
255 }
256
257 // restore model-view matrix
258 glLoadMatrixf(viewMatrix.data());
259
260 glDisable(GL_COLOR_MATERIAL);
261 vertexDecl_.deactivateFixedFunction();
262 }
263
264 //----------------------------------------------------------------------------
265
266 void ArrowNode::getRenderObjects(IRenderer* _renderer, GLState& _state , const DrawModes::DrawMode& _drawMode , const ACG::SceneGraph::Material* _mat)
267 {
268 if (arrows_.empty())
269 return;
270
271 createArrowMesh();
272 updateInstanceBuffer();
273
274
275 RenderObject obj;
276 obj.initFromState(&_state);
277 obj.depthTest = true;
278
279 obj.vertexBuffer = vertexBuffer_.id();
280 obj.indexBuffer = indexBuffer_.id();
281
282
283 // check support for instancing if not done yet
284 if (supportsInstancing_ < 0)
285 supportsInstancing_ = checkExtensionSupported("GL_ARB_instanced_arrays") ? 1 : 0;
286
287 // config shader
288 obj.shaderDesc.shadeMode = SG_SHADE_FLAT;
289
290 if (supportsInstancing_)
291 {
292 // render with instancing
293 obj.shaderDesc.vertexColors = true;
294 obj.shaderDesc.vertexTemplateFile = "ArrowNode/instancing_vs.glsl";
295 obj.vertexDecl = &vertexDeclInstanced_;
296 obj.glDrawElementsInstanced(GL_TRIANGLES, numIndices_, GL_UNSIGNED_INT, 0, arrows_.size());
297
298 _renderer->addRenderObject(&obj);
299 }
300 else
301 {
302 // no instancing support
303 // might want to abort after the first few objects to avoid emitting thousands of objects here and overloading the renderer
304
305 obj.shaderDesc.vertexColors = false;
306 obj.vertexDecl = &vertexDecl_;
307
308 GLMatrixf viewMatrix = obj.modelview;
309
310 for (size_t i = 0; i < arrows_.size(); ++i)
311 {
312 const Arrow* a = &arrows_[i];
313
314 obj.modelview = viewMatrix * readWorldMatrix(i);
315 obj.diffuse = Vec3f(a->color[0] / 255.0f, a->color[1] / 255.0f, a->color[2] / 255.0f);
316 obj.alpha = a->color[3] / 255.0f;
317
318 obj.glDrawElements(GL_TRIANGLES, numIndices_, GL_UNSIGNED_INT, 0);
319 _renderer->addRenderObject(&obj);
320 }
321 }
322 }
323
324 //----------------------------------------------------------------------------
325
326 void ArrowNode::reserve(int _n)
327 {
328 arrows_.reserve(_n);
329 }
330
331 //----------------------------------------------------------------------------
332
333 void ArrowNode::clear()
334 {
335 arrows_.clear();
336 }
337
338 //----------------------------------------------------------------------------
339
340 int ArrowNode::n_arrows() const
341 {
342 return int(arrows_.size());
343 }
344
345 //----------------------------------------------------------------------------
346
347 GLMatrixf ArrowNode::computeWorldMatrix(int _arrow) const
348 {
349 const Arrow* a = &arrows_[_arrow];
350
351 GLMatrixf align;
352 align.identity();
353
354 align.translate(a->start);
355
356 // orientation
357 // local mesh stored as: dir in +x, normal in +y
358 Vec3f binormal = a->dir % a->normal;
359 for (int i = 0; i < 3; ++i)
360 {
361 align(i, 0) = a->dir[i];
362 align(i, 1) = a->normal[i];
363 align(i, 2) = binormal[i];
364 }
365
366 // scaling vector: width, length, height
367 align.scale(a->scale[1], a->scale[2], a->scale[0]);
368
369 return align;
370 }
371
372 //----------------------------------------------------------------------------
373
374 int ArrowNode::addArrow(const Vec3f& _start, const Vec3f& _dir, const Vec3f& _normal, const Vec3f& _scale, const Vec4uc& _color)
375 {
376 Arrow a;
377 a.start = _start;
378 a.dir = _dir;
379 a.scale = _scale;
380 a.color = _color;
381 a.normal = _normal;
382
383 a.orthonormalize();
384
385 arrows_.push_back(a);
386
387 invalidateInstanceData_ = true;
388 invalidateInstanceBuffer_ = true;
389
390 return int(arrows_.size()) - 1;
391 }
392
393 //----------------------------------------------------------------------------
394
395 int ArrowNode::addArrow(const Vec3f& _start, const Vec3f& _dir, const Vec3f& _normal, const Vec3f& _scale, const Vec4f& _color)
396 {
397 Vec4uc c;
398 for (int i = 0; i < 4; ++i)
399 c[i] = std::min(std::max(int(_color[i] * 255.0f), 0), 255);
400 return addArrow(_start, _dir, _normal, _scale, c);
401 }
402
403 //----------------------------------------------------------------------------
404
405 void ArrowNode::Arrow::orthonormalize()
406 {
407 dir.normalize();
408
409 // make sure dir and normal are linearly independent
410 if (normal.sqrnorm() < 1e-6f)
411 normal = Vec3f(0.0f, 1.0f, 0.0f);
412
413 normal.normalize();
414
415 while (std::fabs(dir | normal) > 0.99f || normal.sqrnorm() < 0.01f)
416 {
417 for (int i = 0; i < 3; ++i)
418 normal[i] = float(rand()) / float(RAND_MAX) * 2.0f - 1.0f;
419 normal.normalize();
420 }
421 // orthogonalize normal dir
422 Vec3f binormal = dir % normal;
423 normal = (binormal % dir).normalized();
424 }
425
426 //----------------------------------------------------------------------------
427
428 int ArrowNode::addArrow(const Vec3d& _start, const Vec3d& _dir, const Vec3d& _normal, const Vec3d& _scale, const Vec4uc& _color)
429 {
430 return addArrow(OpenMesh::vector_cast<Vec3f>(_start), OpenMesh::vector_cast<Vec3f>(_dir), OpenMesh::vector_cast<Vec3f>(_normal), OpenMesh::vector_cast<Vec3f>(_scale), _color);
431 }
432
433 //----------------------------------------------------------------------------
434
435 int ArrowNode::addArrow(const Vec3d& _start, const Vec3d& _dir, const Vec3d& _normal, const Vec3d& _scale, const Vec4f& _color)
436 {
437 Vec4uc c;
438 for (int i = 0; i < 4; ++i)
439 c[i] = std::min(std::max(int(_color[i] * 255.0f), 0), 255);
440 return addArrow(_start, _dir, _normal, _scale, c);
441 }
442
443 //----------------------------------------------------------------------------
444
445 void ArrowNode::updateInstanceData()
446 {
447 if (invalidateInstanceData_)
448 {
449 const int numArrows = arrows_.size();
450
451 // size in dwords of data for one instance
452 const int instanceSize = instanceDataSize();
453
454 instanceData_.resize(numArrows * instanceSize);
455
456 for (int i = 0; i < numArrows; ++i)
457 {
458 // compute and store 4x3 world matrix
459 GLMatrixf m = computeWorldMatrix(i);
460 int offset = instanceDataOffset(i);
461
462 // linearize matrix and store in row-major
463 for (int r = 0; r < 3; ++r)
464 for (int c = 0; c < 4; ++c)
465 instanceData_[offset + r*4 + c] = m(r,c);
466
467 // store inverse transpose to support lighting with non-uniform scaling
468 m.invert();
469 for (int r = 0; r < 3; ++r)
470 for (int c = 0; c < 3; ++c)
471 instanceData_[offset + 4 * 3 + r * 3 + c] = m(c, r);
472
473 // store color in last dword as rgba8_unorm
474 // instanceData_[offset + 4 * 3] = *(float*)(arrows_[i].color.data());
475 memcpy(&instanceData_[offset + 4*3 + 3*3], arrows_[i].color.data(), 4);
476
477 // append more data here as needed
478 }
479
480 invalidateInstanceData_ = false;
481 }
482 }
483
484 //----------------------------------------------------------------------------
485
486 ACG::GLMatrixf ArrowNode::readWorldMatrix( int _arrow ) const
487 {
488 int offset = instanceDataOffset(_arrow);
489 GLMatrixf m;
490
491 for (int r = 0; r < 3; ++r)
492 for (int c = 0; c < 4; ++c)
493 m(r,c) = instanceData_[offset + r*4 + c];
494
495 // last row not explicitly stored
496 m(3,0) = 0.0f; m(3,1) = 0.0f; m(3,2) = 0.0f; m(3,3) = 1.0f;
497
498 return m;
499 }
500
501 //----------------------------------------------------------------------------
502
503 void ArrowNode::updateInstanceBuffer()
504 {
505 if (invalidateInstanceBuffer_ || invalidateInstanceData_)
506 {
507 updateInstanceData();
508
509 if (!instanceData_.empty())
510 instanceBuffer_.upload(4 * instanceData_.size(), &instanceData_[0], GL_STATIC_DRAW);
511
512 if (!vertexDeclInstanced_.getNumElements())
513 {
514 // position and normal from static mesh vbo
515 vertexDeclInstanced_.addElement(GL_FLOAT, 3, VERTEX_USAGE_POSITION);
516 vertexDeclInstanced_.addElement(GL_FLOAT, 3, VERTEX_USAGE_NORMAL);
517
518 // world matrix and color from instance data vbo
519 vertexDeclInstanced_.addElement(GL_FLOAT, 4, VERTEX_USAGE_SHADER_INPUT, size_t(0), "inWorld0", 1, instanceBuffer_.id());
520 vertexDeclInstanced_.addElement(GL_FLOAT, 4, VERTEX_USAGE_SHADER_INPUT, size_t(0), "inWorld1", 1, instanceBuffer_.id());
521 vertexDeclInstanced_.addElement(GL_FLOAT, 4, VERTEX_USAGE_SHADER_INPUT, size_t(0), "inWorld2", 1, instanceBuffer_.id());
522 vertexDeclInstanced_.addElement(GL_FLOAT, 3, VERTEX_USAGE_SHADER_INPUT, size_t(0), "inWorldIT0", 1, instanceBuffer_.id());
523 vertexDeclInstanced_.addElement(GL_FLOAT, 3, VERTEX_USAGE_SHADER_INPUT, size_t(0), "inWorldIT1", 1, instanceBuffer_.id());
524 vertexDeclInstanced_.addElement(GL_FLOAT, 3, VERTEX_USAGE_SHADER_INPUT, size_t(0), "inWorldIT2", 1, instanceBuffer_.id());
525 vertexDeclInstanced_.addElement(GL_UNSIGNED_BYTE, 4, VERTEX_USAGE_COLOR, size_t(0), 0, 1, instanceBuffer_.id());
526 }
527
528 invalidateInstanceBuffer_ = false;
529 }
530 }
531
532 //----------------------------------------------------------------------------
533
534 Vec3f ArrowNode::arrowStart(int _arrowID) const
535 {
536 return arrows_[_arrowID].start;
537 }
538
539 void ArrowNode::arrowStart(int _arrowID, const Vec3f& _start)
540 {
541 arrows_[_arrowID].start = _start;
542 invalidateInstanceData_ = true;
543 }
544
545 Vec3f ArrowNode::arrowDir(int _arrowID) const
546 {
547 return arrows_[_arrowID].dir;
548 }
549
550 void ArrowNode::arrowDir(int _arrowID, const Vec3f& _dir)
551 {
552 arrows_[_arrowID].dir = _dir;
553 arrows_[_arrowID].orthonormalize();
554 invalidateInstanceData_ = true;
555 }
556
557 Vec3f ArrowNode::arrowNormal(int _arrowID) const
558 {
559 return arrows_[_arrowID].normal;
560 }
561
562 void ArrowNode::arrowNormal(int _arrowID, const Vec3f& _normal)
563 {
564 arrows_[_arrowID].normal = _normal;
565 arrows_[_arrowID].orthonormalize();
566 invalidateInstanceData_ = true;
567 }
568
569 Vec3f ArrowNode::arrowScale(int _arrowID) const
570 {
571 return arrows_[_arrowID].scale;
572 }
573
574 void ArrowNode::arrowScale(int _arrowID, const Vec3f& _scale)
575 {
576 arrows_[_arrowID].scale = _scale;
577 invalidateInstanceData_ = true;
578 }
579
580 Vec4uc ArrowNode::arrowColor(int _arrowID) const
581 {
582 return arrows_[_arrowID].color;
583 }
584
585 void ArrowNode::arrowColor(int _arrowID, const Vec4uc& _color)
586 {
587 arrows_[_arrowID].color = _color;
588 invalidateInstanceData_ = true;
589 }
590
591
592 //=============================================================================
593
594
595 } // namespace SceneGraph
596 } // namespace ACG
597 //=============================================================================
ACG::Matrix4x4T::invert
bool invert()
matrix inversion (returns true on success)
Definition: Matrix4x4T_impl.hh:291
ACG::SceneGraph::ArrowNode::reserve
void reserve(int _n)
reserve mem for _n arrows
Definition: ArrowNode.cc:326
OpenMesh::VectorT::maximize
vector_type & maximize(const vector_type &_rhs)
maximize values: same as *this = max(*this, _rhs), but faster
Definition: Vector11T.hh:563
OpenMesh::vector_cast
void vector_cast(const src_t &_src, dst_t &_dst, GenProg::Int2Type< n >)
Cast vector type to another vector type by copying the vector elements.
Definition: vector_cast.hh:81
ACG
Namespace providing different geometric functions concerning angles.
Definition: BaseObjectData.hh:68
ACG::SceneGraph::ArrowNode::arrowColor
Vec4uc arrowColor(int _arrowID) const
Return the color of an arrow.
Definition: ArrowNode.cc:580
ACG::SceneGraph::ArrowNode::addArrow
int addArrow(const Vec3f &_start, const Vec3f &_dir, const Vec3f &_normal=Vec3f(0.0f, 1.0f, 0.0f), const Vec3f &_scale=Vec3f(1.0f, 1.0f, 1.0f), const Vec4uc &_color=Vec4uc(82, 82, 82, 255))
Add an arrow to the node.
Definition: ArrowNode.cc:374
ACG::SceneGraph::ArrowNode::arrowDir
Vec3f arrowDir(int _arrowID) const
Return the direction of an arrow.
Definition: ArrowNode.cc:545
ACG::SceneGraph::ArrowNode::ArrowNode
ArrowNode(BaseNode *_parent=0, std::string _name="<ArrowNode>")
default constructor
Definition: ArrowNode.cc:67
ACG::SceneGraph::ArrowNode::arrowStart
Vec3f arrowStart(int _arrowID) const
Return the start position of an arrow.
Definition: ArrowNode.cc:534
ACG::Vec3f
VectorT< float, 3 > Vec3f
Definition: VectorT.hh:119
ACG::SceneGraph::ArrowNode::draw
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode)
draw arrows
Definition: ArrowNode.cc:226
ACG::SceneGraph::ACG::SceneGraph::BaseNode::drawMode
DrawModes::DrawMode drawMode() const
Return the own draw modes of this node.
Definition: MeshNode2T_impl.hh:430
ACG::VERTEX_USAGE_SHADER_INPUT
defined by user via VertexElement::shaderInputName_
Definition: VertexDeclaration.hh:71
ACG::RenderObject::initFromState
void initFromState(GLState *_glState)
Initializes a RenderObject instance.
Definition: RenderObject.cc:61
ACG::SceneGraph::ArrowNode::arrowNormal
Vec3f arrowNormal(int _arrowID) const
Return the normal of an arrow.
Definition: ArrowNode.cc:557
ACG::RenderObject::modelview
GLMatrixd modelview
Modelview transform.
Definition: RenderObject.hh:138
OpenMesh::VectorT::normalize
auto normalize() -> decltype(*this/=std::declval< VectorT< S, DIM >>().norm())
Definition: Vector11T.hh:429
ACG::SceneGraph::ArrowNode::~ArrowNode
~ArrowNode()
destructor
Definition: ArrowNode.cc:82
ACG::VertexDeclaration::getNumElements
unsigned int getNumElements() const
Definition: VertexDeclaration.cc:309
ACG::VERTEX_USAGE_COLOR
"inColor"
Definition: VertexDeclaration.hh:68
ACG::SceneGraph::MaterialNode
Definition: MaterialNode.hh:338
ACG::RenderObject
Interface class between scenegraph and renderer.
Definition: RenderObject.hh:98
ACG::VertexDeclaration::getVertexStride
unsigned int getVertexStride(unsigned int i=0) const
Definition: VertexDeclaration.cc:545
ACG::RenderObject::diffuse
Vec3f diffuse
material definitions
Definition: RenderObject.hh:274
ACG::SceneGraph::ArrowNode::n_arrows
int n_arrows() const
number of arrows
Definition: ArrowNode.cc:340
ACG::SceneGraph::ArrowNode::boundingBox
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax)
update bounding box
Definition: ArrowNode.cc:88
ACG::VertexDeclaration::activateFixedFunction
void activateFixedFunction() const
Definition: VertexDeclaration.cc:361
ACG::GLState
Definition: GLState.hh:213
ACG::SceneGraph::ArrowNode::availableDrawModes
DrawModes::DrawMode availableDrawModes() const
return available draw modes
Definition: ArrowNode.cc:119
ACG::VertexDeclaration::addElement
void addElement(const VertexElement *_pElement)
Definition: VertexDeclaration.cc:115
ACG::GLMatrixT::scale
void scale(Scalar _x, Scalar _y, Scalar _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with scaling matrix (x,y,z)
Definition: GLMatrixT_impl.hh:75
ACG::VertexDeclaration::deactivateFixedFunction
void deactivateFixedFunction() const
Definition: VertexDeclaration.cc:407
ACG::GLMatrixT< float >
ACG::RenderObject::vertexBuffer
GLuint vertexBuffer
VBO, IBO ids, ignored if VAO is provided.
Definition: RenderObject.hh:162
ACG::SceneGraph::ArrowNode::arrowScale
Vec3f arrowScale(int _arrowID) const
Return the scale of an arrow.
Definition: ArrowNode.cc:569
ACG::SceneGraph::DrawModes::DrawMode
Specifies a DrawMode.
Definition: DrawModes.hh:288
ACG::IRenderer::addRenderObject
virtual void addRenderObject(RenderObject *_renderObject)
Callback for the scenegraph nodes, which send new render objects via this function.
Definition: IRenderer.cc:104
ACG::SceneGraph::Material
Definition: MaterialNode.hh:79
align
Definition: AlignT.hh:2
SceneGraph
Definition: QtPrincipalAxisDialog.hh:67
ACG::RenderObject::shaderDesc
ShaderGenDesc shaderDesc
Drawmode and other shader params.
Definition: RenderObject.hh:225
OpenMesh::VectorT::minimize
vector_type & minimize(const vector_type &_rhs)
minimize values: same as *this = min(*this, _rhs), but faster
Definition: Vector11T.hh:535
ACG::SceneGraph::BaseNode
Definition: BaseNode.hh:104
ACG::RenderObject::indexBuffer
GLuint indexBuffer
Use vertex array object.
Definition: RenderObject.hh:162
OpenMesh::VectorT
Definition: Vector11T.hh:83
ACG::Matrix4x4T::identity
void identity()
setup an identity matrix
Definition: Matrix4x4T_impl.hh:250
ACG::SceneGraph::DrawModes::SOLID_FLAT_SHADED
DrawMode SOLID_FLAT_SHADED
draw flat shaded faces (requires face normals)
Definition: DrawModes.cc:81
ACG::checkExtensionSupported
bool checkExtensionSupported(const std::string &_extension)
Definition: gl.cc:107
ACG::IRenderer
Definition: IRenderer.hh:78
ACG::VERTEX_USAGE_NORMAL
"inNormal"
Definition: VertexDeclaration.hh:66
ACG::SceneGraph::ArrowNode::getRenderObjects
void getRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const ACG::SceneGraph::Material *_mat)
Add the objects to the given renderer.
Definition: ArrowNode.cc:266
ACG::SceneGraph::ArrowNode::clear
void clear()
clear arrows
Definition: ArrowNode.cc:333
ACG::VERTEX_USAGE_POSITION
"inPosition"
Definition: VertexDeclaration.hh:65
ACG::SceneGraph::ArrowNode::Arrow
Definition: ArrowNode.hh:251
ACG::RenderObject::vertexDecl
const VertexDeclaration * vertexDecl
Defines the vertex buffer layout, ignored if VAO is provided.
Definition: RenderObject.hh:208
ACG::GLMatrixT::translate
void translate(Scalar _x, Scalar _y, Scalar _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with translation matrix (x,y,z)
Definition: GLMatrixT_impl.hh:96