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 
251  Material();
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 
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 
344  void clearLightSources();
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  float getSpecularIntensity() const
417  { return specular_;}
418 
420  void setSpecularIntensity(float value)
421  { specular_ = value;}
422 
424  float getDiffuseIntensity() const
425  { return diffuse_;}
426 
428  void setDiffuseIntensity(float value)
429  { diffuse_ = value;}
430 
432  float getAmbientIntensity() const
433  { return ambient_;}
434 
436  void setAmbientIntensity(float value)
437  { ambient_ = value;}
438 
440  float getShininess() const
441  { return shininess_;}
442 
444  void setShininess(float value)
445  { shininess_ = value;}
446 
447 
449 
452 
454  bool operator == (const Stage& stage) const;
455 
463  Vector3 calculateRelativeCoordinates(Vector3 pos) const;
464 
468  Vector3 calculateAbsoluteCoordinates(Vector3 pos) const;
469 
471 
478  virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
479 
481  Material& getMaterial() { return material_; }
482 
484  const Material& getMaterial() const { return material_; }
485 
486  protected:
487 
488  //_
490 
491  //_
493 
494  //_
495  std::list<LightSource> light_sources_;
496 
497  //_
499 
500  //_
502 
503  //_
505 
506  //_
508 
509  //_
511 
512  //_
514 
515  float specular_;
516  float diffuse_;
517  float ambient_;
518  float shininess_;
519 
520  // the current default materials used for raytracing
522  };
523 
524  } // namespace VIEW
525 } // namespace BALL
526 
527 #endif // BALL_VIEW_KERNEL_STAGE_H
void setAmbientIntensity(float value)
Definition: stage.h:436
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:513
std::list< LightSource > light_sources_
Definition: stage.h:495
ColorRGBA background_color_
Definition: stage.h:489
void setColor(const ColorRGBA &color)
Definition: stage.h:152
virtual void setBackgroundColor(const ColorRGBA &color)
Set the background color.
Definition: stage.h:364
void setAttenuation(const Vector3 &attenuation)
Set the attenuation parameters of the light.
Definition: stage.h:119
bool swapSideBySideStereo() const
Get settings for side by side stereo side swapping.
Definition: stage.h:404
float diffuse_
Definition: stage.h:516
virtual Camera & getCamera()
Get the camera.
Definition: stage.h:347
float eye_distance_
Definition: stage.h:507
virtual void setCamera(const Camera &camera)
Definition: stage.h:356
Material & getMaterial()
Gives access to the default material parameters.
Definition: stage.h:481
void setRelativeToCamera(bool state)
If set to true, the LightSource will move with the Camera.
Definition: stage.h:168
ColorRGBA reflective_color
Definition: stage.h:277
void setEyeDistance(float value)
Set the eye distance for the stereo view.
Definition: stage.h:384
virtual const Camera & getCamera() const
Get the camera (const)
Definition: stage.h:351
virtual const ColorRGBA & getBackgroundColor() const
Get the background color.
Definition: stage.h:360
Vector3 attenuation_
Definition: stage.h:208
Index getType() const
Definition: stage.h:158
Camera camera_
Definition: stage.h:498
const Angle & getAngle() const
Get the angle of the light cone.
Definition: stage.h:124
bool isRelativeToCamera() const
Test if a LightSource will move with the Camera.
Definition: stage.h:172
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52
bool coordinateSystemEnabled() const
Shows coordinate system.
Definition: stage.h:380
float getShininess() const
Definition: stage.h:440
float getDiffuseIntensity() const
Definition: stage.h:424
virtual void setInfoColor(const ColorRGBA &color)
Set the background color.
Definition: stage.h:372
float specular_
Definition: stage.h:515
void setSpecularIntensity(float value)
Definition: stage.h:420
const Vector3 & getAttenuation() const
Get the attenuation parameters of the light.
Definition: stage.h:115
float getFocalDistance() const
Get the focal distance for the stereo view.
Definition: stage.h:396
float getIntensity() const
Definition: stage.h:134
virtual LightSource & getLightSource(Position i)
Get a reference to the i-th light source.
Definition: stage.h:319
void setIntensity(float intensity)
Definition: stage.h:140
Types
Enumeration of different types of lights.
Definition: stage.h:58
ColorRGBA info_color_
Definition: stage.h:492
BALL_EXPORT bool operator==(const String &s1, const String &s2)
Material material_
Definition: stage.h:521
void setDiffuseIntensity(float value)
Definition: stage.h:428
float getAmbientIntensity() const
Definition: stage.h:432
const ColorRGBA & getColor() const
Definition: stage.h:146
ColorRGBA color_
Definition: stage.h:223
virtual ~Stage()
Destructor.
Definition: stage.h:304
const Material & getMaterial() const
Gives access to the default material parameters, const version.
Definition: stage.h:484
void setShininess(float value)
Definition: stage.h:444
void setAngle(const Angle &angle)
Set the angle of the light cone.
Definition: stage.h:128
bool show_coordinate_system_
Definition: stage.h:501
const Vector3 & getPosition() const
Get position.
Definition: stage.h:99
-*- Mode: C++; tab-width: 2; -*-
Definition: constants.h:12
virtual const std::list< LightSource > & getLightSources() const
Get the light sources (const)
Definition: stage.h:315
float focal_distance_
Definition: stage.h:510
float fog_intensity_
Definition: stage.h:504
float ambient_
Definition: stage.h:517
ColorRGBA specular_color
Definition: stage.h:274
float shininess_
Definition: stage.h:518
virtual const ColorRGBA & getInfoColor() const
Get the background color.
Definition: stage.h:368
void showCoordinateSystem(bool state)
Show coordinate system.
Definition: stage.h:376
float getEyeDistance() const
Get the eye distance for the stereo view.
Definition: stage.h:388
void setType(Types type)
Definition: stage.h:164
void setFogIntensity(float value)
Definition: stage.h:412
virtual ~LightSource()
Definition: stage.h:91
const Vector3 & getDirection() const
Get the direction vector of the light.
Definition: stage.h:107
float getSpecularIntensity() const
Definition: stage.h:416
Vector3 r_direction_
Definition: stage.h:214
float getFogIntensity() const
Definition: stage.h:408
void setFocalDistance(float value)
Set the focal distance for the stereo view.
Definition: stage.h:392
void setSwapSideBySideStereo(bool state)
Settings for side by side stereo side swapping.
Definition: stage.h:400
BALL_EXPORT bool operator<(const String &s1, const String &s2)