Developer Documentation
LightNode.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// CLASS LightNode - IMPLEMENTATION
50//
51//=============================================================================
52
53
54//== INCLUDES =================================================================
55
56
57#include "LightNode.hh"
58#include <ACG/GL/IRenderer.hh>
59
60#ifndef M_PI
61#define M_PI 3.14159265358979323846
62#endif
63
64//== NAMESPACES ===============================================================
65
66namespace ACG {
67namespace SceneGraph {
68
69//== IMPLEMENTATION ==========================================================
70
71static LightSourceHandle* lightSourceHandle = 0;
72
73//default Constructor
75{
76 // set OpenGL defaults
77 enabled_ = false;
78 fixedPosition_ = false;
79
80 ambientColor_ = Vec4f(0.1f,0.1f,0.1f,1.f);
81 diffuseColor_ = Vec4f(1.f,1.f,1.f,1.f);
82 specularColor_ = Vec4f(1.f,1.f,1.f,1.f);
83
84 position_ = Vec4f(0.f,0.f,1.f,0.f);
85 realPosition_ = Vec4f(0.f,0.f,1.f,0.f);
86
87 spotDirection_ = Vec3d(0.0,0.0,-1.0);
88 realSpotDirection_ = Vec3d(0.0,0.0,-1.0);
89
90 // Holds initial light source position
91 // converted to camera coordinates
92 initialPosition_ = Vec4f(0.f, 0.f, 0.f, 0.f);
93 initialSpotDirection_ = Vec3d(0.0, 0.0, -1.0);
94 initialPositionInit_ = false;
95
96 spotExponent_ = 0;
97 spotCutoff_ = 180;
98
99 constantAttenuation_ = 1;
100 linearAttenuation_ = 0;
101 quadraticAttenuation_ = 0;
102
103 brightness_ = 1.0f;
104
105 radius_ = 0.1f;
106}
107
109 // Set homogeneous coordinte to 1.0 to get a positional light source
110 position_ = Vec4d( _pos[0],_pos[1],_pos[2],1.0);
111}
112
114 return Vec3d( position_[0], position_[1], position_[2]);
115}
116
118 // Set homogeneous coordinate of position to 0.0 to tell OpenGL
119 // that this is a directional light source
120 position_ = Vec4d( _pos[0],_pos[1],_pos[2],0.0);
121}
122
124 return Vec3d(position_[0], position_[1], position_[2]);
125}
126
128 return ( position_[3] == 0.0 );
129}
130
132{ enabled_ = true; }
133
135{ enabled_ = false; }
136
138 return enabled_;
139}
140
142{ spotDirection_ = _pos; }
143
145 return Vec3d(spotDirection_[0],spotDirection_[1],spotDirection_[2]);
146}
147
149{ ambientColor_ = _color; }
150
152{ return ambientColor_; }
153
155{ diffuseColor_ = _color; }
156
158{ return diffuseColor_; }
159
161{ specularColor_ = _color; }
162
164{ return specularColor_; }
165
166void LightSource::setColor(const Vec4f& _ambient, const Vec4f& _diffuse, const Vec4f& _specular) {
167 ambientColor_ = _ambient;
168 diffuseColor_ = _diffuse;
169 specularColor_ = _specular;
170}
171
172void LightSource::fixedPosition( bool _state)
173{ fixedPosition_ = _state; }
174
175bool LightSource::fixedPosition() const {
176 return fixedPosition_;
177}
178
179void LightSource::spotExponent(float _exponent) {
180 spotExponent_ = _exponent;
181}
182
183float LightSource::spotExponent() const {
184 return spotExponent_;
185}
186
187void LightSource::spotCutoff(float _cutoff) {
188 spotCutoff_ = _cutoff;
189}
190
191float LightSource::spotCutoff() const {
192 return spotCutoff_;
193}
194
195void LightSource::constantAttenuation(float _constantAttenuation) {
196 constantAttenuation_ = _constantAttenuation;
197}
198
199float LightSource::constantAttenuation() const {
200 return constantAttenuation_;
201}
202
203void LightSource::linearAttenuation(float _linearAttenuation) {
204 linearAttenuation_ = _linearAttenuation;
205}
206
207float LightSource::linearAttenuation() const {
208 return linearAttenuation_;
209}
210
211void LightSource::quadraticAttenuation(float _quadraticAttenuation) {
212 quadraticAttenuation_ = _quadraticAttenuation;
213}
214
215float LightSource::quadraticAttenuation() const {
216 return quadraticAttenuation_;
217}
218
219void LightSource::brightness(float _brightness) {
220 brightness_ = _brightness;
221}
222
223float LightSource::brightness() const {
224 return brightness_;
225}
226
228 const std::string& _name)
229 : BaseNode(_parent, _name),
230 visualize_(false),
231 lightId_(GL_INVALID_ENUM) {
232
233 if(lightSourceHandle == 0) {
234 lightSourceHandle = new LightSourceHandle();
235 }
236
237 sphere_ = new ACG::GLSphere(10, 10);
238 cone_ = new ACG::GLCone(10, 10, 1.0f, 1.0f, false, true);
239}
240
241//----------------------------------------------------------------------------
242
244 if (sphere_)
245 delete sphere_;
246
247 if (cone_)
248 delete cone_;
249}
250
251//----------------------------------------------------------------------------
252
254{
255 memcpy(_light, &light_, sizeof(LightSource));
256}
257
258//----------------------------------------------------------------------------
259
261{
262 memcpy(_light, &transformedLight_, sizeof(LightSource));
263}
264
265//----------------------------------------------------------------------------
266
268
269 if( visualize_ && !light_.directional() ) {
270 ACG::Vec3d r;
272 r = ACG::Vec3d((double)light_.realPosition_[0],
273 (double)light_.realPosition_[1],
274 (double)light_.realPosition_[2]);
275 else
276 r = light_.position();
277 _bbMin.minimize( r - Vec3d(light_.radius()*3) );
278 _bbMax.maximize( r + Vec3d(light_.radius()*3) );
279 }
280}
281
282//----------------------------------------------------------------------------
283
284void LightNode::draw(GLState& _state, const DrawModes::DrawMode& /*_drawMode*/) {
285
286 // Visualize light node
287 if(visualize_ && !light_.directional()) {
288
289 // Get initial camera coords of light if in fixed
290 // mode and if they haven't been computed yet
291 if(light_.fixedPosition_ && !light_.initialPositionInit_) {
292 light_.initialPosition_ = _state.modelview() * light_.position_;
293 light_.initialSpotDirection_ = _state.modelview().transform_vector(light_.spotDirection());
294 light_.initialPositionInit_ = true;
295 }
296
297 if(light_.fixedPosition_) {
298 light_.realPosition_ = _state.inverse_modelview() * light_.initialPosition_;
299 light_.realSpotDirection_ = _state.inverse_modelview().transform_vector(light_.initialSpotDirection_);
300 } else {
301 light_.realPosition_ = light_.position_;
302 light_.realSpotDirection_ = light_.spotDirection_;
303 }
304
305 ACG::Vec3f p = ACG::Vec3f(light_.realPosition_[0],
306 light_.realPosition_[1],
307 light_.realPosition_[2]);
308 ACG::Vec3d spotDir = light_.realSpotDirection_;
309
313
314 // Make light sources appear as bright as possible
315 float max = 0;
316 for(int i = 0; i < 3; ++i) {
317 if(ac[i] > max) max = ac[i];
318 }
319 ac += ACG::Vec4f(1.0f - max);
320 max = 0;
321 for(int i = 0; i < 3; ++i) {
322 if(dc[i] > max) max = dc[i];
323 }
324 dc += ACG::Vec4f(1.0f - max);
325 max = 0;
326 for(int i = 0; i < 3; ++i) {
327 if(sc[i] > max) max = sc[i];
328 }
329 sc += ACG::Vec4f(1.0f - max);
330
331 // Backup variables
332 GLboolean lighting_backup;
333
334 // Origin
335 _state.push_modelview_matrix();
336 // Transform to light origin and direction
337 _state.translate(p[0], p[1], p[2]);
338
339 // Set lighting
340 glGetBooleanv(GL_LIGHTING, &lighting_backup);
341 ACG::GLState::enable(GL_LIGHTING);
342
343 // Make light directional just for the drawing
344 // of itself
345 bool backup_directional = light_.directional();
346 ACG::Vec3d backup_position = light_.position();
347
348 // Get light id
349 lightId_ = lightSourceHandle->getLight(this);
350
351 // Return if we don't have a valid light source
352 if(lightId_ == GL_INVALID_ENUM) {
353
354 // Reset all stored attributes before returning
355 if(!lighting_backup) ACG::GLState::disable(GL_LIGHTING);
356
357 _state.pop_modelview_matrix();
358
359 return;
360 }
361
362 glLightf(lightId_, GL_SPOT_EXPONENT, 0.0f);
363 float pos[4];
364 pos [0] = backup_position[0];
365 pos [1] = backup_position[1];
366 pos [2] = backup_position[2];
367 pos [3] = 0.0f;
368
369 glLightfv(lightId_, GL_POSITION, pos);
370
371 // Set colors
372 float gl_ac[] = {ac[0], ac[1], ac[2], ac[3]};
373 glLightfv(lightId_, GL_AMBIENT, gl_ac);
374 float gl_dc[] = {dc[0], dc[1], dc[2], dc[3]};
375 glLightfv(lightId_, GL_DIFFUSE, gl_dc);
376 float gl_sc[] = {sc[0], sc[1], sc[2], sc[3]};
377 glLightfv(lightId_, GL_SPECULAR, gl_sc);
378
380
381 sphere_->draw(_state, light_.radius());
382
383 // Visualize spot cone (or direction)
384 if(light_.spotCutoff() < 180.0f) {
385 // Note: if the cutoff angle is 180, the light source
386 // is a point light emitting light into all directions equally
387
388 // Rotate into light direction
389 ACG::Vec3d z = ACG::Vec3d(0.0f, 0.0f, 1.0f);
390 ACG::Vec3d spot = spotDir;
391 float angle = acos((z | spot)/(z.norm()*spot.norm()));
392 angle = angle*360/(2*M_PI);
393 ACG::Vec3d rA = z % spot;
394 _state.rotate(angle, rA[0], rA[1], rA[2]);
395
396 // Inverse normal orientation
397 cone_->setNormalOrientation(ACG::GLPrimitive::INSIDE);
398 cone_->setBottomRadius(light_.radius()/6.0f);
399 cone_->setTopRadius(light_.radius()/6.0f);
400 cone_->draw(_state, light_.radius()*2.0f);
401 _state.translate(0.0, 0.0, light_.radius()*2);
402 // Draw arrow tip
403 cone_->setBottomRadius(light_.radius()/2.0f);
404 cone_->setTopRadius(0.0f);
405 cone_->draw(_state, light_.radius());
406 }
407
408 // Free light id
409 lightSourceHandle->removeLight(this);
410
411 // Undo state changes
412
413 if(!backup_directional) {
414 light_.position(backup_position);
415 }
416
417 // Lighting
418 if(!lighting_backup) ACG::GLState::disable(GL_LIGHTING);
419
420 _state.pop_modelview_matrix();
421 }
422
423}
424
425void LightNode::pick(GLState& _state, PickTarget _target) {
426
427 GLenum prev_depth = _state.depthFunc();
428
429 if (_target == PICK_FACE ||
430 _target == PICK_ANYTHING) {
431
432 // Visualize light node
433 if(visualize_ && !light_.directional()) {
434
435 // Get initial camera coords of light if in fixed
436 // mode and if they haven't been computed yet
437 if(light_.fixedPosition_ && !light_.initialPositionInit_) {
438 light_.initialPosition_ = _state.modelview() * light_.position_;
439 light_.initialSpotDirection_ = _state.modelview().transform_vector(light_.spotDirection());
440 light_.initialPositionInit_ = true;
441 }
442
443 if(light_.fixedPosition_) {
444 light_.realPosition_ = _state.inverse_modelview() * light_.initialPosition_;
445 light_.realSpotDirection_ = _state.inverse_modelview().transform_vector(light_.initialSpotDirection_);
446 } else {
447 light_.realPosition_ = light_.position_;
448 light_.realSpotDirection_ = light_.spotDirection_;
449 }
450
451 // Enable depth test but store original status
452 glPushAttrib(GL_DEPTH_BUFFER_BIT);
453 ACG::GLState::enable(GL_DEPTH_TEST);
454 ACG::GLState::depthFunc(GL_LEQUAL);
455
456 _state.pick_set_maximum(1);
457 _state.pick_set_name(0);
458
459 ACG::Vec3f p = ACG::Vec3f(light_.realPosition_[0],
460 light_.realPosition_[1],
461 light_.realPosition_[2]);
462 ACG::Vec3d spotDir = light_.realSpotDirection_;
463
464 // Origin
465 _state.push_modelview_matrix();
466 // Transform to light origin and direction
467 _state.translate(p[0], p[1], p[2]);
468
469 sphere_->draw(_state, light_.radius());
470
471 // Visualize spot cone (or direction)
472 if(light_.spotCutoff() < 180.0f) {
473 // Note: if the cutoff angle is 180, the light source
474 // is a point light emitting light into all directions equally
475
476 // Rotate into light direction
477 ACG::Vec3d z = ACG::Vec3d(0.0f, 0.0f, 1.0f);
478 ACG::Vec3d spot = spotDir;
479 float angle = acos((z | spot)/(z.norm()*spot.norm()));
480 angle = angle*360/(2*M_PI);
481 ACG::Vec3d rA = z % spot;
482 _state.rotate(angle, rA[0], rA[1], rA[2]);
483
484 cone_->setNormalOrientation(ACG::GLPrimitive::OUTSIDE);
485 cone_->setBottomRadius(light_.radius()/6.0f);
486 cone_->setTopRadius(light_.radius()/6.0f);
487 cone_->draw(_state, light_.radius()*2.0f);
488 _state.translate(0.0, 0.0, light_.radius()*2);
489 // Draw arrow tip
490 cone_->setBottomRadius(light_.radius()/2.0f);
491 cone_->setTopRadius(0.0f);
492 cone_->draw(_state, light_.radius());
493 }
494
495 _state.pop_modelview_matrix();
496
497 ACG::GLState::depthFunc(prev_depth);
498 }
499 }
500}
501
502void LightNode::enter(GLState& _state, const DrawModes::DrawMode& /* _drawmode */ )
503{
504 if(visualize_) return;
505
506 // Get initial camera coords of light if in fixed
507 // mode and if they haven't been computed yet
508 if(light_.fixedPosition_ && !light_.initialPositionInit_) {
509 light_.initialPosition_ = _state.modelview() * light_.position_;
510 light_.initialSpotDirection_ = _state.modelview().transform_vector(light_.spotDirection());
511 light_.initialPositionInit_ = true;
512 }
513
514 // Get light id
515 lightId_ = lightSourceHandle->getLight(this);
516
517 // Return if we don't have a valid light source
518 if(lightId_ == GL_INVALID_ENUM) return;
519
522
523 if(_state.compatibilityProfile())
524 {
525 // save old light
526 lightSave_.enabled_ = glIsEnabled(lightId_);
527 }
528
529 if(light_.enabled_ ) {
530 // correct Position for fixed Lights
531 if(light_.fixedPosition_) {
532 light_.realPosition_ = _state.inverse_modelview() * light_.initialPosition_;
533 light_.realSpotDirection_ = _state.inverse_modelview().transform_vector(light_.initialSpotDirection_);
534 //std::cerr << "New Light pos :" << _state.inverse_modelview().transform_vector(light_.position) << std::endl;
535 } else {
536 light_.realPosition_ = light_.position_;
537 light_.realSpotDirection_ = light_.spotDirection_;
538 //std::cerr << "New Light pos :" << light_.position << std::endl;
539 }
540
541 // transform to view space for shader pipeline
543 transformedLight_.position_ = _state.modelview() * light_.realPosition_;
544 transformedLight_.spotDirection_ = _state.modelview().transform_vector(light_.realSpotDirection_);
545
546 if (_state.compatibilityProfile()) {
548 setParameters(_state, lightId_, light_);
549 }
550 } else {
551 if (_state.compatibilityProfile())
553 }
554}
555
556
557//----------------------------------------------------------------------------
558
559
560void LightNode::leave(GLState& _state , const DrawModes::DrawMode& /* _drawmode*/ )
561{
562 if(visualize_) return;
563
564 // Return if we don't have a valid light source
565 if(lightId_ == GL_INVALID_ENUM) return;
566
567 if (_state.compatibilityProfile()) {
568 // restore old enabled light
569 if (lightSave_.enabled_) {
572 }
573 else {
575 }
576 }
577
578 // Free light id
579 lightSourceHandle->removeLight(this);
580}
581
582//----------------------------------------------------------------------------
583
584void LightNode::setParameters(GLState& _state, GLenum _index, LightSource& _light)
585{
586 if (_state.compatibilityProfile()) {
587
588 // Multiply colors by brightness
589 Vec4f& a = _light.ambientColor_;
590 GLfloat ambient[4] = { a[0] * _light.brightness_,
591 a[1] * _light.brightness_,
592 a[2] * _light.brightness_,
593 a[3] * _light.brightness_ };
594
595 Vec4f& d = _light.diffuseColor_;
596 GLfloat diffuse[4] = { d[0] * _light.brightness_,
597 d[1] * _light.brightness_,
598 d[2] * _light.brightness_,
599 d[3] * _light.brightness_ };
600
601 Vec4f& s = _light.specularColor_;
602 GLfloat specular[4] = { s[0] * _light.brightness_,
603 s[1] * _light.brightness_,
604 s[2] * _light.brightness_,
605 s[3] * _light.brightness_ };
606
607
608
609 bool directional = _light.directional();
610
611 Vec4f& p = _light.realPosition_;
612 GLfloat realPos[4] = { (float)p[0], (float)p[1], (float)p[2], (directional ? 0.0f : 1.0f) };
613
614 // set preferences of _light for GL_LIGHT#_index
615 glLightfv(_index, GL_AMBIENT, ambient);
616 glLightfv(_index, GL_DIFFUSE, diffuse);
617 glLightfv(_index, GL_SPECULAR, specular);
618
619 glLightfv(_index, GL_POSITION, realPos);
620
621 if (!directional) {
622 Vec3d& sd = _light.realSpotDirection_;
623
624 GLfloat dir[3] = { (float)sd[0], (float)sd[1], (float)sd[2] };
625 glLightfv(_index, GL_SPOT_DIRECTION, dir);
626 glLightf(_index, GL_SPOT_EXPONENT, _light.spotExponent_);
627 glLightf(_index, GL_SPOT_CUTOFF, _light.spotCutoff_);
628 }
629
630 glLightf(_index, GL_CONSTANT_ATTENUATION, _light.constantAttenuation_);
631 glLightf(_index, GL_LINEAR_ATTENUATION, _light.linearAttenuation_);
632 glLightf(_index, GL_QUADRATIC_ATTENUATION, _light.quadraticAttenuation_);
633 }
634}
635
636//----------------------------------------------------------------------------
637
638void LightNode::getParameters(GLState& _state, GLenum _index, LightSource& _light)
639{
640 if (_state.compatibilityProfile()) {
641 // get preferences of GL_LIGHT#_index and store them in _light
642 glGetLightfv(_index, GL_AMBIENT, (GLfloat *)_light.ambientColor_.data());
643 glGetLightfv(_index, GL_DIFFUSE, (GLfloat *)_light.diffuseColor_.data());
644 glGetLightfv(_index, GL_SPECULAR, (GLfloat *)_light.specularColor_.data());
645 glGetLightfv(_index, GL_POSITION, (GLfloat *)_light.position_.data());
646 glGetLightfv(_index, GL_SPOT_DIRECTION, (GLfloat *)_light.spotDirection_.data());
647
648 glGetLightfv(_index, GL_SPOT_EXPONENT, &_light.spotExponent_);
649 glGetLightfv(_index, GL_SPOT_CUTOFF, &_light.spotCutoff_);
650 glGetLightfv(_index, GL_CONSTANT_ATTENUATION, &_light.constantAttenuation_);
651 glGetLightfv(_index, GL_LINEAR_ATTENUATION, &_light.linearAttenuation_);
652 glGetLightfv(_index, GL_QUADRATIC_ATTENUATION, &_light.quadraticAttenuation_);
653 }
654}
655
656
657void LightNode::getRenderObjects( IRenderer* _renderer, GLState& _state , const DrawModes::DrawMode& _drawMode , const Material* _mat )
658{
659
660 // fill IRenderer light struct with light data in view-space
662
664 light.ltype = ACG::SG_LIGHT_DIRECTIONAL;
665 else if (transformedLight_.spotCutoff() > 179.5f)
666 light.ltype = ACG::SG_LIGHT_POINT;
667 else
668 light.ltype = ACG::SG_LIGHT_SPOT;
669
670#define V4toV3(v) (ACG::Vec3f(v[0], v[1], v[2]))
671
672 light.diffuse = V4toV3(transformedLight_.diffuseColor());
673 light.ambient = V4toV3(transformedLight_.ambientColor());
674 light.specular = V4toV3(transformedLight_.specularColor());
675
676 light.pos = V4toV3(transformedLight_.position());
677 light.dir = V4toV3(transformedLight_.direction());
678
679 light.atten[0] = transformedLight_.constantAttenuation();
680 light.atten[1] = transformedLight_.linearAttenuation();
681 light.atten[2] = transformedLight_.quadraticAttenuation();
682
683 light.spotCutoffExponent[0] = transformedLight_.spotCutoff();
684 light.spotCutoffExponent[1] = transformedLight_.spotExponent();
685
686 _renderer->addLight(light);
687
688}
689
690//=============================================================================
691} // namespace SceneGraph
692} // namespace ACG
693//=============================================================================
void pop_modelview_matrix()
pop modelview matrix
Definition: GLState.cc:1026
static void enable(GLenum _cap, bool _warnRemoved=true)
replaces glEnable, but supports locking
Definition: GLState.cc:1507
const GLMatrixd & modelview() const
get modelview matrix
Definition: GLState.hh:816
void pick_set_name(size_t _idx)
sets the current name/color (like glLoadName(_idx))
Definition: GLState.cc:1061
bool pick_set_maximum(size_t _idx)
Set the maximal number of primitives/components of your object.
Definition: GLState.cc:1051
void translate(double _x, double _y, double _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
translate by (_x, _y, _z)
Definition: GLState.cc:533
static void disable(GLenum _cap, bool _warnRemoved=true)
replaces glDisable, but supports locking
Definition: GLState.cc:1527
void rotate(double _angle, double _x, double _y, double _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
rotate around axis (_x, _y, _z) by _angle
Definition: GLState.cc:564
const GLMatrixd & inverse_modelview() const
get inverse modelview matrix
Definition: GLState.hh:836
const GLenum & depthFunc() const
get glDepthFunc() that is supposed to be active
Definition: GLState.cc:941
void push_modelview_matrix()
push modelview matrix
Definition: GLState.cc:1010
virtual void addLight(const LightData &_light)
Callback for the scenegraph nodes, which send new lights to the renderer via this function.
Definition: IRenderer.cc:1173
VectorT< T, 3 > transform_vector(const VectorT< T, 3 > &_v) const
transform vector (x',y',z',0) = A * (x,y,z,0)
bool visualize_
Indicates whether light node should be visualized or not.
Definition: LightNode.hh:320
LightSource lightSave_
save old LightSources
Definition: LightNode.hh:317
void getRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat) override
Add this light to shader render interface.
Definition: LightNode.cc:657
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode) override
Draw light source node.
Definition: LightNode.cc:284
void getParameters(GLState &_state, GLenum _index, LightSource &_light)
get _light Options in OpenGL for GL_LIGHT::_index
Definition: LightNode.cc:638
LightSource transformedLight_
pretransformed light position and direction in view space
Definition: LightNode.hh:314
void enter(GLState &_state, const DrawModes::DrawMode &_drawmode) override
set current Light Sources
Definition: LightNode.cc:502
void getLightSource(LightSource *_light) const
Get the light source parameters.
Definition: LightNode.cc:253
LightSource light_
store LightSources of this node
Definition: LightNode.hh:311
void boundingBox(ACG::Vec3d &, ACG::Vec3d &) override
Get bounding box (for visualization purposes)
Definition: LightNode.cc:267
void leave(GLState &_state, const DrawModes::DrawMode &_drawmode) override
restores original Light Sources
Definition: LightNode.cc:560
virtual ~LightNode()
Destructor.
Definition: LightNode.cc:243
LightNode(BaseNode *_parent=0, const std::string &_name="<LightNode>")
Default constructor. Applies all properties.
Definition: LightNode.cc:227
void getLightSourceViewSpace(LightSource *_light) const
Definition: LightNode.cc:260
void pick(GLState &_state, PickTarget _target) override
Picking.
Definition: LightNode.cc:425
GLenum lightId_
Internal light id.
Definition: LightNode.hh:323
void setParameters(GLState &_state, GLenum _index, LightSource &_light)
set _light Options in OpenGL for GL_LIGHT::_index
Definition: LightNode.cc:584
Structure to hold options for one LightSource.
Definition: LightNode.hh:86
LightSource()
Default Constructor.
Definition: LightNode.cc:74
void fixedPosition(bool _state)
make LightSource fixed or moveable with ModelViewMatrix
Definition: LightNode.cc:172
Vec4f ambientColor() const
get Ambient color for LightSource
Definition: LightNode.cc:151
Vec3d direction() const
Get direction of the light source.
Definition: LightNode.cc:123
float radius() const
Get light source radius.
Definition: LightNode.hh:206
void disable()
disable LightSource
Definition: LightNode.cc:134
void enable()
enable LightSource
Definition: LightNode.cc:131
void specularColor(Vec4f _color)
set Specular color for LightSource
Definition: LightNode.cc:160
void diffuseColor(Vec4f _color)
set Diffuse color for LightSource
Definition: LightNode.cc:154
Vec4f diffuseColor() const
get Diffuse color for LightSource
Definition: LightNode.cc:157
Vec3d position() const
Get the position of the LightSource.
Definition: LightNode.cc:113
void position(Vec3d _pos)
Set position for LightSource.
Definition: LightNode.cc:108
bool enabled() const
Get light source status.
Definition: LightNode.cc:137
Vec3d spotDirection() const
get spot direction
Definition: LightNode.cc:144
void ambientColor(Vec4f _color)
set Ambient color for LightSource
Definition: LightNode.cc:148
Vec4f specularColor() const
get Specular color for LightSource
Definition: LightNode.cc:163
bool directional() const
Check if the light source is a directional light source.
Definition: LightNode.cc:127
void spotDirection(Vec3d _pos)
Set spot direction.
Definition: LightNode.cc:141
Scalar * data()
access to Scalar array
Definition: Vector11T.hh:201
vector_type & maximize(const vector_type &_rhs)
maximize values: same as *this = max(*this, _rhs), but faster
Definition: Vector11T.hh:588
vector_type & minimize(const vector_type &_rhs)
minimize values: same as *this = min(*this, _rhs), but faster
Definition: Vector11T.hh:560
auto norm() const -> decltype(std::sqrt(std::declval< VectorT< S, DIM > >().sqrnorm()))
compute euclidean norm
Definition: Vector11T.hh:434
PickTarget
What target to use for picking.
Definition: PickTarget.hh:74
@ PICK_ANYTHING
pick any of the prior targets (should be implemented for all nodes)
Definition: PickTarget.hh:84
@ PICK_FACE
picks faces (should be implemented for all nodes)
Definition: PickTarget.hh:78
Namespace providing different geometric functions concerning angles.
VectorT< double, 4 > Vec4d
Definition: VectorT.hh:140
VectorT< float, 4 > Vec4f
Definition: VectorT.hh:138
VectorT< float, 3 > Vec3f
Definition: VectorT.hh:119
VectorT< double, 3 > Vec3d
Definition: VectorT.hh:121