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
13 # include <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
33 # include <BALL/COMMON/exception.h>
34 #endif
35 
36 #ifndef BALL_VIEW_RENDERING_CAMERA_H
38 #endif
39 
40 namespace 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 
158  Index getType() const
159  { return type_;}
160 
164  void setType(Types type)
165  { type_ = type;}
166 
168  void setRelativeToCamera(bool state)
169  { relative_ = state;}
170 
172  bool isRelativeToCamera() const
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
220  float intensity_;
221 
222  //_ Color of the light
224 
225  //_ Enumeration of types for further usage
227 
228  //_ Relative to camera
229  bool relative_;
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 
298  Stage();
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 
404  bool swapSideBySideStereo() const
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
BALL::VIEW::Stage::dump
virtual void dump(std::ostream &s=std::cout, Size depth=0) const
BALL::VIEW::Stage::eye_distance_
float eye_distance_
Definition: stage.h:474
BALL::VIEW::Stage::info_color_
ColorRGBA info_color_
Definition: stage.h:459
BALL::TAngle< float >
BALL::VIEW::Stage::getMaterial
const Material & getMaterial() const
Gives access to the default material parameters, const version.
Definition: stage.h:451
BALL::VIEW::LightSource::setRelativeToCamera
void setRelativeToCamera(bool state)
If set to true, the LightSource will move with the Camera.
Definition: stage.h:168
BALL::VIEW::LightSource::LightSource
LightSource(const LightSource &light_source)
BALL::VIEW::Stage::swap_side_by_side_stereo_
bool swap_side_by_side_stereo_
Definition: stage.h:480
BALL::VIEW::LightSource::getAttenuation
const Vector3 & getAttenuation() const
Get the attenuation parameters of the light.
Definition: stage.h:115
BALL::VIEW::LightSource::getDirection
const Vector3 & getDirection() const
Get the direction vector of the light.
Definition: stage.h:107
BALL::VIEW::Stage::getBackgroundColor
virtual const ColorRGBA & getBackgroundColor() const
Get the background color.
Definition: stage.h:360
BALL::VIEW::Stage::swapSideBySideStereo
bool swapSideBySideStereo() const
Get settings for side by side stereo side swapping.
Definition: stage.h:404
BALL::VIEW::Stage::setBackgroundColor
virtual void setBackgroundColor(const ColorRGBA &color)
Set the background color.
Definition: stage.h:364
angle.h
BALL::VIEW::LightSource::setAngle
void setAngle(const Angle &angle)
Set the angle of the light cone.
Definition: stage.h:128
BALL::VIEW::LightSource::relative_
bool relative_
Definition: stage.h:229
BALL::VIEW::LightSource::getIntensity
float getIntensity() const
Definition: stage.h:134
BALL::VIEW::Stage::getFogIntensity
float getFogIntensity() const
Definition: stage.h:408
BALL::VIEW::LightSource::r_direction_
Vector3 r_direction_
Definition: stage.h:214
BALL::VIEW::LightSource::setIntensity
void setIntensity(float intensity)
Definition: stage.h:140
BALL::VIEW::LightSource::POSITIONAL
@ POSITIONAL
Definition: stage.h:70
vector3.h
BALL::operator<
BALL_EXPORT bool operator<(const String &s1, const String &s2)
BALL::VIEW::LightSource::color_
ColorRGBA color_
Definition: stage.h:223
BALL::VIEW::Stage::focal_distance_
float focal_distance_
Definition: stage.h:477
BALL::VIEW::LightSource::getAngle
const Angle & getAngle() const
Get the angle of the light cone.
Definition: stage.h:124
BALL::VIEW::Camera
Definition: camera.h:24
BALL::PersistenceManager
Definition: persistenceManager.h:73
BALL::VIEW::Stage::getLightSources
virtual const std::list< LightSource > & getLightSources() const
Get the light sources (const)
Definition: stage.h:315
BALL::VIEW::LightSource::Types
Types
Enumeration of different types of lights.
Definition: stage.h:59
BALL::VIEW::LightSource::getPosition
const Vector3 & getPosition() const
Get position.
Definition: stage.h:99
BALL::VIEW::Stage::calculateRelativeCoordinates
Vector3 calculateRelativeCoordinates(Vector3 pos) const
BALL::VIEW::LightSource::LightSource
LightSource()
BALL::VIEW::Stage::setInfoColor
virtual void setInfoColor(const ColorRGBA &color)
Set the background color.
Definition: stage.h:372
BALL::VIEW::LightSource::attenuation_
Vector3 attenuation_
Definition: stage.h:208
BALL::VIEW::LightSource::setDirection
void setDirection(const Vector3 &direction)
Set the direction vector of the light.
Definition: stage.h:111
BALL::VIEW::Stage::material_
Material material_
Definition: stage.h:483
BALL::VIEW::LightSource::dump
virtual void dump(std::ostream &s=std::cout, Size depth=0) const
BALL::VIEW::Stage::setFocalDistance
void setFocalDistance(float value)
Set the focal distance for the stereo view.
Definition: stage.h:392
BALL::VIEW::LightSource::type_
Index type_
Definition: stage.h:226
representation.h
BALL::VIEW::Stage::light_sources_
std::list< LightSource > light_sources_
Definition: stage.h:462
BALL::VIEW::LightSource::setColor
void setColor(const ColorRGBA &color)
Definition: stage.h:152
BALL
Definition: constants.h:13
BALL::VIEW::LightSource::setType
void setType(Types type)
Definition: stage.h:164
BALL::VIEW::Stage::Stage
Stage(const Stage &stage)
Copy constructor.
BALL::VIEW::LightSource::getType
Index getType() const
Definition: stage.h:158
quaternion.h
BALL::VIEW::Stage::getFocalDistance
float getFocalDistance() const
Get the focal distance for the stereo view.
Definition: stage.h:396
BALL::VIEW::LightSource::angle_
Angle angle_
Definition: stage.h:217
BALL::VIEW::Stage::addLightSource
virtual void addLightSource(const LightSource &light_source)
Add a light source.
BALL::VIEW::Stage::Material
Definition: stage.h:246
BALL::VIEW::LightSource::r_position_
Vector3 r_position_
Definition: stage.h:211
BALL::VIEW::Stage::Stage
Stage()
BALL::VIEW::ColorRGBA
Definition: colorRGBA.h:32
BALL::VIEW::LightSource::~LightSource
virtual ~LightSource()
Definition: stage.h:91
BALL::VIEW::LightSource
Definition: stage.h:54
BALL_INDEX_TYPE
BALL::VIEW::Stage::showCoordinateSystem
void showCoordinateSystem(bool state)
Show coordinate system.
Definition: stage.h:376
BALL_SIZE_TYPE
BALL::TVector3< float >
BALL_VIEW_EXPORT
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52
camera.h
BALL::VIEW::Stage::~Stage
virtual ~Stage()
Destructor.
Definition: stage.h:304
BALL::VIEW::Stage::clearLightSources
void clearLightSources()
BALL::VIEW::Stage::clear
virtual void clear()
Explicit default initialization.
BALL::VIEW::LightSource::setAttenuation
void setAttenuation(const Vector3 &attenuation)
Set the attenuation parameters of the light.
Definition: stage.h:119
BALL::PersistentObject
Definition: persistentObject.h:29
BALL::VIEW::Stage::getCamera
virtual const Camera & getCamera() const
Get the camera (const)
Definition: stage.h:351
exception.h
BALL::VIEW::Stage::getLightSource
virtual LightSource & getLightSource(Position i)
Get a reference to the i-th light source.
Definition: stage.h:319
BALL::VIEW::LightSource::intensity_
float intensity_
Definition: stage.h:220
BALL::VIEW::Stage::getCamera
virtual Camera & getCamera()
Get the camera.
Definition: stage.h:347
BALL::VIEW::Stage::show_coordinate_system_
bool show_coordinate_system_
Definition: stage.h:468
BALL::operator==
BALL_EXPORT bool operator==(const String &s1, const String &s2)
colorRGBA.h
BALL::VIEW::Stage::getInfoColor
virtual const ColorRGBA & getInfoColor() const
Get the background color.
Definition: stage.h:368
matrix44.h
BALL::VIEW::Stage::camera_
Camera camera_
Definition: stage.h:465
BALL::VIEW::Stage::removeLightSource
virtual void removeLightSource(const LightSource &light_source)
Remove a light source.
BALL::VIEW::Stage::setFogIntensity
void setFogIntensity(float value)
Definition: stage.h:412
BALL::VIEW::Stage::setSwapSideBySideStereo
void setSwapSideBySideStereo(bool state)
Settings for side by side stereo side swapping.
Definition: stage.h:400
BALL::VIEW::Stage::getMaterial
Material & getMaterial()
Gives access to the default material parameters.
Definition: stage.h:448
BALL::VIEW::LightSource::direction_
Vector3 direction_
Definition: stage.h:205
BALL::VIEW::LightSource::setPosition
void setPosition(const Vector3 &position)
Set position.
Definition: stage.h:103
BALL::VIEW::Stage::RaytracingMaterial
Definition: stage.h:286
BALL::VIEW::LightSource::getColor
const ColorRGBA & getColor() const
Definition: stage.h:146
BALL_CREATE
#define BALL_CREATE(name)
Definition: create.h:62
BALL::VIEW::Stage::calculateAbsoluteCoordinates
Vector3 calculateAbsoluteCoordinates(Vector3 pos) const
BALL::VIEW::Stage::background_color_
ColorRGBA background_color_
Definition: stage.h:456
BALL::VIEW::LightSource::isRelativeToCamera
bool isRelativeToCamera() const
Test if a LightSource will move with the Camera.
Definition: stage.h:172
BALL::VIEW::Stage::setCamera
virtual void setCamera(const Camera &camera)
Definition: stage.h:356
BALL::VIEW::Stage::getEyeDistance
float getEyeDistance() const
Get the eye distance for the stereo view.
Definition: stage.h:388
BALL::VIEW::Stage::coordinateSystemEnabled
bool coordinateSystemEnabled() const
Shows coordinate system.
Definition: stage.h:380
BALL::VIEW::Stage::setEyeDistance
void setEyeDistance(float value)
Set the eye distance for the stereo view.
Definition: stage.h:384
BALL::VIEW::Stage
Definition: stage.h:239
BALL::VIEW::LightSource::position_
Vector3 position_
Definition: stage.h:202
BALL::Exception::OutOfRange
Definition: COMMON/exception.h:219
BALL::VIEW::Stage::fog_intensity_
float fog_intensity_
Definition: stage.h:471