Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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