BALL  1.4.79
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 
83  LightSource();
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 
260  virtual void persistentWrite(PersistenceManager& pm, const char* name = 0) const
262 
266  virtual void persistentRead(PersistenceManager& pm)
268 
270 
273 
276 
279 
280  float shininess;
282  };
283 
287 
290  Stage();
291 
293  Stage(const Stage& stage);
294 
296  virtual ~Stage(){}
297 
299  virtual void clear();
300 
302 
305 
307  virtual const std::list<LightSource>& getLightSources() const
308  { return light_sources_;}
309 
312  {
313  if (i >= light_sources_.size())
314  {
315  Exception::OutOfRange e(__FILE__, __LINE__);
316  throw(e);
317  }
318 
319  std::list<LightSource>::iterator l_it;
320 
321  Position current_light = 0;
322  for (l_it = light_sources_.begin();
323  (current_light < i) && (l_it != light_sources_.end());
324  ++l_it, ++current_light)
325  { }
326 
327  return *l_it;
328  }
330  virtual void addLightSource(const LightSource& light_source);
331 
333  virtual void removeLightSource(const LightSource& light_source) ;
334 
336  void clearLightSources();
337 
339  virtual Camera& getCamera()
340  { return camera_;}
341 
343  virtual const Camera& getCamera() const
344  { return camera_;}
345 
348  virtual void setCamera(const Camera& camera)
349  { camera_ = camera;}
350 
352  virtual const ColorRGBA& getBackgroundColor() const
353  { return background_color_;}
354 
356  virtual void setBackgroundColor(const ColorRGBA& color)
357  { background_color_ = color;}
358 
360  virtual const ColorRGBA& getInfoColor() const
361  { return info_color_;}
362 
364  virtual void setInfoColor(const ColorRGBA& color)
365  { info_color_ = color;}
366 
368  void showCoordinateSystem(bool state)
369  { show_coordinate_system_ = state;}
370 
373  { return show_coordinate_system_;}
374 
376  void setEyeDistance(float value)
377  { eye_distance_ = value;}
378 
380  float getEyeDistance() const
381  { return eye_distance_;}
382 
384  void setFocalDistance(float value)
385  { focal_distance_ = value;}
386 
388  float getFocalDistance() const
389  { return focal_distance_;}
390 
392  void setSwapSideBySideStereo(bool state)
393  { swap_side_by_side_stereo_ = state;}
394 
396  bool swapSideBySideStereo() const
397  { return swap_side_by_side_stereo_;}
398 
400  float getFogIntensity() const
401  { return fog_intensity_;}
402 
404  void setFogIntensity(float value)
405  { fog_intensity_ = value;}
406 
408  float getSpecularIntensity() const
409  { return specular_;}
410 
412  void setSpecularIntensity(float value)
413  { specular_ = value;}
414 
416  float getDiffuseIntensity() const
417  { return diffuse_;}
418 
420  void setDiffuseIntensity(float value)
421  { diffuse_ = value;}
422 
424  float getAmbientIntensity() const
425  { return ambient_;}
426 
428  void setAmbientIntensity(float value)
429  { ambient_ = value;}
430 
432  float getShininess() const
433  { return shininess_;}
434 
436  void setShininess(float value)
437  { shininess_ = value;}
438 
439 
441 
444 
446  bool operator == (const Stage& stage) const;
447 
455  Vector3 calculateRelativeCoordinates(Vector3 pos) const;
456 
460  Vector3 calculateAbsoluteCoordinates(Vector3 pos) const;
461 
463 
470  virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
471 
473  RaytracingMaterial& getRTMaterial() { return rt_material_; }
474 
476  const RaytracingMaterial& getRTMaterial() const { return rt_material_; }
477 
478  protected:
479 
480  //_
482 
483  //_
485 
486  //_
487  std::list<LightSource> light_sources_;
488 
489  //_
491 
492  //_
494 
495  //_
497 
498  //_
500 
501  //_
503 
504  //_
506 
507  float specular_;
508  float diffuse_;
509  float ambient_;
510  float shininess_;
511 
512  // the current default materials used for raytracing
514  };
515 
516  } // namespace VIEW
517 } // namespace BALL
518 
519 #endif // BALL_VIEW_KERNEL_STAGE_H
void setAmbientIntensity(float value)
Definition: stage.h:428
virtual const Camera & getCamera() const
Get the camera (const)
Definition: stage.h:343
const Angle & getAngle() const
Get the angle of the light cone.
Definition: stage.h:124
float getShininess() const
Definition: stage.h:432
void setPosition(const Vector3 &position)
Set position.
Definition: stage.h:103
#define BALL_CREATE(name)
Definition: create.h:62
void setDirection(const Vector3 &direction)
Set the direction vector of the light.
Definition: stage.h:111
bool swap_side_by_side_stereo_
Definition: stage.h:505
std::list< LightSource > light_sources_
Definition: stage.h:487
const Vector3 & getDirection() const
Get the direction vector of the light.
Definition: stage.h:107
float getEyeDistance() const
Get the eye distance for the stereo view.
Definition: stage.h:380
ColorRGBA background_color_
Definition: stage.h:481
void setColor(const ColorRGBA &color)
Definition: stage.h:152
virtual void setBackgroundColor(const ColorRGBA &color)
Set the background color.
Definition: stage.h:356
float getSpecularIntensity() const
Definition: stage.h:408
Types
Enumeration of different types of lights.
Definition: stage.h:58
Index getType() const
Definition: stage.h:158
virtual const ColorRGBA & getInfoColor() const
Get the background color.
Definition: stage.h:360
void setAttenuation(const Vector3 &attenuation)
Set the attenuation parameters of the light.
Definition: stage.h:119
RaytracingMaterial & getRTMaterial()
Gives access to the default material parameters.
Definition: stage.h:473
float diffuse_
Definition: stage.h:508
virtual Camera & getCamera()
Get the camera.
Definition: stage.h:339
float eye_distance_
Definition: stage.h:499
virtual void setCamera(const Camera &camera)
Definition: stage.h:348
void setRelativeToCamera(bool state)
If set to true, the LightSource will move with the Camera.
Definition: stage.h:168
void setEyeDistance(float value)
Set the eye distance for the stereo view.
Definition: stage.h:376
float getAmbientIntensity() const
Definition: stage.h:424
Vector3 attenuation_
Definition: stage.h:208
Camera camera_
Definition: stage.h:490
const ColorRGBA & getColor() const
Definition: stage.h:146
float getIntensity() const
Definition: stage.h:134
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52
bool swapSideBySideStereo() const
Get settings for side by side stereo side swapping.
Definition: stage.h:396
bool isRelativeToCamera() const
Test if a LightSource will move with the Camera.
Definition: stage.h:172
virtual void setInfoColor(const ColorRGBA &color)
Set the background color.
Definition: stage.h:364
float specular_
Definition: stage.h:507
void setSpecularIntensity(float value)
Definition: stage.h:412
const Vector3 & getPosition() const
Get position.
Definition: stage.h:99
virtual LightSource & getLightSource(Position i)
Get a reference to the i-th light source.
Definition: stage.h:311
float getFogIntensity() const
Definition: stage.h:400
const RaytracingMaterial & getRTMaterial() const
Gives access to the default material parameters, const version.
Definition: stage.h:476
void setIntensity(float intensity)
Definition: stage.h:140
ColorRGBA info_color_
Definition: stage.h:484
const Vector3 & getAttenuation() const
Get the attenuation parameters of the light.
Definition: stage.h:115
void setDiffuseIntensity(float value)
Definition: stage.h:420
ColorRGBA color_
Definition: stage.h:223
virtual ~Stage()
Destructor.
Definition: stage.h:296
void setShininess(float value)
Definition: stage.h:436
void setAngle(const Angle &angle)
Set the angle of the light cone.
Definition: stage.h:128
bool coordinateSystemEnabled() const
Shows coordinate system.
Definition: stage.h:372
bool show_coordinate_system_
Definition: stage.h:493
-*- Mode: C++; tab-width: 2; -*-
Definition: constants.h:12
float focal_distance_
Definition: stage.h:502
float fog_intensity_
Definition: stage.h:496
float ambient_
Definition: stage.h:509
float shininess_
Definition: stage.h:510
float getDiffuseIntensity() const
Definition: stage.h:416
void showCoordinateSystem(bool state)
Show coordinate system.
Definition: stage.h:368
float getFocalDistance() const
Get the focal distance for the stereo view.
Definition: stage.h:388
void setType(Types type)
Definition: stage.h:164
virtual const std::list< LightSource > & getLightSources() const
Get the light sources (const)
Definition: stage.h:307
virtual const ColorRGBA & getBackgroundColor() const
Get the background color.
Definition: stage.h:352
void setFogIntensity(float value)
Definition: stage.h:404
virtual ~LightSource()
Definition: stage.h:91
Vector3 r_direction_
Definition: stage.h:214
void setFocalDistance(float value)
Set the focal distance for the stereo view.
Definition: stage.h:384
RaytracingMaterial rt_material_
Definition: stage.h:513
void setSwapSideBySideStereo(bool state)
Settings for side by side stereo side swapping.
Definition: stage.h:392