BALL 1.5.0
stage.h
Go to the documentation of this file.
1// -*- Mode: C++; tab-width: 2; -*-
2// vi: set ts=2:
3//
4
5#ifndef BALL_VIEW_KERNEL_STAGE_H
6#define BALL_VIEW_KERNEL_STAGE_H
7
8#ifndef BALL_MATHS_VECTOR3_H
9# include <BALL/MATHS/vector3.h>
10#endif
11
12#ifndef BALL_MATHS_QUATERNION_H
14#endif
15
16#ifndef BALL_MATHS_MATRIX44_H
17# include <BALL/MATHS/matrix44.h>
18#endif
19
20#ifndef BALL_MATHS_ANGLE_H
21# include <BALL/MATHS/angle.h>
22#endif
23
24#ifndef BALL_VIEW_DATATYPE_COLORRGBA_H
26#endif
27
28#ifndef BALL_VIEW_KERNEL_REPRESENTATION_H
30#endif
31
32#ifndef BALL_COMMON_EXCEPTION_H
34#endif
35
36#ifndef BALL_VIEW_RENDERING_CAMERA_H
38#endif
39
40namespace BALL
41{
42 namespace VIEW
43 {
54 {
55 public:
56
58 enum Types
59 {
60
64 AMBIENT = 0,
65
71
74 DIRECTIONAL
75 };
76
80
84
87 LightSource(const LightSource& light_source);
88
91 virtual ~LightSource(){}
92
94
97
99 const Vector3& getPosition() const
100 { return position_;}
101
103 void setPosition(const Vector3& position)
104 { position_ = position; }
105
107 const Vector3& getDirection() const
108 { return direction_;}
109
111 void setDirection(const Vector3& direction)
112 { direction_ = direction;}
113
115 const Vector3& getAttenuation() const
116 { return attenuation_;}
117
119 void setAttenuation(const Vector3& attenuation)
120 { attenuation_ = attenuation;}
121
122
124 const Angle& getAngle() const
125 { return angle_;}
126
128 void setAngle(const Angle& angle)
129 { angle_ = angle;}
130
134 float getIntensity() const
135 { return intensity_;}
136
140 void setIntensity(float intensity)
141 { intensity_ = intensity;}
142
146 const ColorRGBA& getColor() const
147 { return color_;}
148
152 void setColor(const ColorRGBA& color)
153 { color_ = color;}
154
159 { return type_;}
160
164 void setType(Types type)
165 { type_ = type;}
166
168 void setRelativeToCamera(bool state)
169 { relative_ = state;}
170
173 { return relative_;}
174
176 LightSource& operator = (const LightSource& light);
177
179 bool operator < (const LightSource& light) const;
180
182
185
187 bool operator == (const LightSource& light_source) const;
188
190
197 virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
198
199 protected:
200
201 //_ Position of the light source
203
204 //_ Direction of the light cone
206
207 //_ Attenuation parameters of the light
209
210 //_
212
213 //_
215
216 //_ Angle of the light cone
218
219 //_ Intensity of the light
221
222 //_ Color of the light
224
225 //_ Enumeration of types for further usage
227
228 //_ Relative to camera
230 };
231
232
239 {
240 public:
241
245 : public PersistentObject
246 {
247 public:
248
250
252
256
261 virtual void persistentWrite(PersistenceManager& pm, const char* name = 0) const;
262
267 virtual void persistentRead(PersistenceManager& pm);
268
270
271 ColorRGBA ambient_color;
272 float ambient_intensity;
273
274 ColorRGBA specular_color;
275 float specular_intensity;
276
277 ColorRGBA reflective_color;
278 float reflective_intensity;
279
280 float shininess;
281 float transparency;
282 };
283
284 // needed for backwards compatibilty of project files
286 {
287 public:
288
290 };
291
295
299
301 Stage(const Stage& stage);
302
304 virtual ~Stage(){}
305
307 virtual void clear();
308
310
313
315 virtual const std::list<LightSource>& getLightSources() const
316 { return light_sources_;}
317
320 {
321 if (i >= light_sources_.size())
322 {
323 Exception::OutOfRange e(__FILE__, __LINE__);
324 throw(e);
325 }
326
327 std::list<LightSource>::iterator l_it;
328
329 Position current_light = 0;
330 for (l_it = light_sources_.begin();
331 (current_light < i) && (l_it != light_sources_.end());
332 ++l_it, ++current_light)
333 { }
334
335 return *l_it;
336 }
338 virtual void addLightSource(const LightSource& light_source);
339
341 virtual void removeLightSource(const LightSource& light_source) ;
342
345
347 virtual Camera& getCamera()
348 { return camera_;}
349
351 virtual const Camera& getCamera() const
352 { return camera_;}
353
356 virtual void setCamera(const Camera& camera)
357 { camera_ = camera;}
358
360 virtual const ColorRGBA& getBackgroundColor() const
361 { return background_color_;}
362
364 virtual void setBackgroundColor(const ColorRGBA& color)
365 { background_color_ = color;}
366
368 virtual const ColorRGBA& getInfoColor() const
369 { return info_color_;}
370
372 virtual void setInfoColor(const ColorRGBA& color)
373 { info_color_ = color;}
374
376 void showCoordinateSystem(bool state)
377 { show_coordinate_system_ = state;}
378
381 { return show_coordinate_system_;}
382
384 void setEyeDistance(float value)
385 { eye_distance_ = value;}
386
388 float getEyeDistance() const
389 { return eye_distance_;}
390
392 void setFocalDistance(float value)
393 { focal_distance_ = value;}
394
396 float getFocalDistance() const
397 { return focal_distance_;}
398
400 void setSwapSideBySideStereo(bool state)
401 { swap_side_by_side_stereo_ = state;}
402
405 { return swap_side_by_side_stereo_;}
406
408 float getFogIntensity() const
409 { return fog_intensity_;}
410
412 void setFogIntensity(float value)
413 { fog_intensity_ = value;}
414
416
419
421 bool operator == (const Stage& stage) const;
422
431
436
438
445 virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
446
448 Material& getMaterial() { return material_; }
449
451 const Material& getMaterial() const { return material_; }
452
453 protected:
454
455 //_
457
458 //_
460
461 //_
462 std::list<LightSource> light_sources_;
463
464 //_
466
467 //_
469
470 //_
472
473 //_
475
476 //_
478
479 //_
481
482 // the current default materials used for raytracing
484 };
485
486 } // namespace VIEW
487} // namespace BALL
488
489#endif // BALL_VIEW_KERNEL_STAGE_H
#define BALL_CREATE(name)
Definition: create.h:62
Definition: constants.h:13
BALL_EXPORT bool operator<(const String &s1, const String &s2)
BALL_EXPORT bool operator==(const String &s1, const String &s2)
const Vector3 & getPosition() const
Get position.
Definition: stage.h:99
Index getType() const
Definition: stage.h:158
const Angle & getAngle() const
Get the angle of the light cone.
Definition: stage.h:124
void setAngle(const Angle &angle)
Set the angle of the light cone.
Definition: stage.h:128
void setColor(const ColorRGBA &color)
Definition: stage.h:152
void setDirection(const Vector3 &direction)
Set the direction vector of the light.
Definition: stage.h:111
Vector3 r_direction_
Definition: stage.h:214
ColorRGBA color_
Definition: stage.h:223
const ColorRGBA & getColor() const
Definition: stage.h:146
float getIntensity() const
Definition: stage.h:134
const Vector3 & getDirection() const
Get the direction vector of the light.
Definition: stage.h:107
void setRelativeToCamera(bool state)
If set to true, the LightSource will move with the Camera.
Definition: stage.h:168
LightSource(const LightSource &light_source)
void setType(Types type)
Definition: stage.h:164
virtual void dump(std::ostream &s=std::cout, Size depth=0) const
void setIntensity(float intensity)
Definition: stage.h:140
void setPosition(const Vector3 &position)
Set position.
Definition: stage.h:103
const Vector3 & getAttenuation() const
Get the attenuation parameters of the light.
Definition: stage.h:115
void setAttenuation(const Vector3 &attenuation)
Set the attenuation parameters of the light.
Definition: stage.h:119
virtual ~LightSource()
Definition: stage.h:91
Types
Enumeration of different types of lights.
Definition: stage.h:59
bool isRelativeToCamera() const
Test if a LightSource will move with the Camera.
Definition: stage.h:172
Vector3 attenuation_
Definition: stage.h:208
void setFogIntensity(float value)
Definition: stage.h:412
bool coordinateSystemEnabled() const
Shows coordinate system.
Definition: stage.h:380
void setSwapSideBySideStereo(bool state)
Settings for side by side stereo side swapping.
Definition: stage.h:400
Material & getMaterial()
Gives access to the default material parameters.
Definition: stage.h:448
bool swapSideBySideStereo() const
Get settings for side by side stereo side swapping.
Definition: stage.h:404
float getFocalDistance() const
Get the focal distance for the stereo view.
Definition: stage.h:396
float eye_distance_
Definition: stage.h:474
virtual Camera & getCamera()
Get the camera.
Definition: stage.h:347
const Material & getMaterial() const
Gives access to the default material parameters, const version.
Definition: stage.h:451
Stage(const Stage &stage)
Copy constructor.
void setFocalDistance(float value)
Set the focal distance for the stereo view.
Definition: stage.h:392
virtual LightSource & getLightSource(Position i)
Get a reference to the i-th light source.
Definition: stage.h:319
Material material_
Definition: stage.h:483
virtual const Camera & getCamera() const
Get the camera (const)
Definition: stage.h:351
ColorRGBA background_color_
Definition: stage.h:456
virtual const ColorRGBA & getBackgroundColor() const
Get the background color.
Definition: stage.h:360
bool show_coordinate_system_
Definition: stage.h:468
virtual void setInfoColor(const ColorRGBA &color)
Set the background color.
Definition: stage.h:372
virtual void clear()
Explicit default initialization.
ColorRGBA info_color_
Definition: stage.h:459
Camera camera_
Definition: stage.h:465
virtual void setCamera(const Camera &camera)
Definition: stage.h:356
float focal_distance_
Definition: stage.h:477
virtual const ColorRGBA & getInfoColor() const
Get the background color.
Definition: stage.h:368
float fog_intensity_
Definition: stage.h:471
Vector3 calculateAbsoluteCoordinates(Vector3 pos) const
virtual void setBackgroundColor(const ColorRGBA &color)
Set the background color.
Definition: stage.h:364
float getFogIntensity() const
Definition: stage.h:408
Vector3 calculateRelativeCoordinates(Vector3 pos) const
virtual void removeLightSource(const LightSource &light_source)
Remove a light source.
virtual const std::list< LightSource > & getLightSources() const
Get the light sources (const)
Definition: stage.h:315
virtual void dump(std::ostream &s=std::cout, Size depth=0) const
virtual ~Stage()
Destructor.
Definition: stage.h:304
float getEyeDistance() const
Get the eye distance for the stereo view.
Definition: stage.h:388
virtual void addLightSource(const LightSource &light_source)
Add a light source.
void setEyeDistance(float value)
Set the eye distance for the stereo view.
Definition: stage.h:384
void showCoordinateSystem(bool state)
Show coordinate system.
Definition: stage.h:376
bool swap_side_by_side_stereo_
Definition: stage.h:480
void clearLightSources()
std::list< LightSource > light_sources_
Definition: stage.h:462
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52