CFog.h
Go to the documentation of this file.
1 //==============================================================================
2 /*
3  Software License Agreement (BSD License)
4  Copyright (c) 2003-2016, CHAI3D.
5  (www.chai3d.org)
6 
7  All rights reserved.
8 
9  Redistribution and use in source and binary forms, with or without
10  modification, are permitted provided that the following conditions
11  are met:
12 
13  * Redistributions of source code must retain the above copyright
14  notice, this list of conditions and the following disclaimer.
15 
16  * Redistributions in binary form must reproduce the above
17  copyright notice, this list of conditions and the following
18  disclaimer in the documentation and/or other materials provided
19  with the distribution.
20 
21  * Neither the name of CHAI3D nor the names of its contributors may
22  be used to endorse or promote products derived from this software
23  without specific prior written permission.
24 
25  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  POSSIBILITY OF SUCH DAMAGE.
37 
38  \author <http://www.chai3d.org>
39  \author Francois Conti
40  \version 3.2.0 $Rev: 1869 $
41 */
42 //==============================================================================
43 
44 //------------------------------------------------------------------------------
45 #ifndef CFogH
46 #define CFogH
47 //------------------------------------------------------------------------------
48 #include "graphics/CColor.h"
50 //------------------------------------------------------------------------------
51 
52 //------------------------------------------------------------------------------
53 namespace chai3d {
54 //------------------------------------------------------------------------------
55 
56 //==============================================================================
63 //==============================================================================
64 
65 //==============================================================================
80 //==============================================================================
81 class cFog
82 {
83  //--------------------------------------------------------------------------
84  // CONSTRUCTOR & DESTRUCTOR:
85  //--------------------------------------------------------------------------
86 
87 public:
88 
90  cFog();
91 
93  virtual ~cFog() {};
94 
95 
96  //-----------------------------------------------------------------------
97  // PUBLIC METHODS:
98  //--------------------------------------------------------------------------
99 
100 public:
101 
103  virtual void render(cRenderOptions& a_options);
104 
106  void setEnabled(const bool a_enabled) { m_enabled = a_enabled; }
107 
109  bool getEnabled() const { return(m_enabled); }
110 
112  void setFogMode(const GLint a_fogMode) { m_fogMode = a_fogMode; }
113 
115  void setFogModeLINEAR() { m_fogMode = GL_LINEAR; }
116 
118  void setFogModeEXP() { m_fogMode = GL_EXP; }
119 
121  void setFogModeEXP2() { m_fogMode = GL_EXP2; }
122 
124  GLint getFogMode() { return (m_fogMode); }
125 
127  void setProperties(const double a_start,
128  const double a_end,
129  const double a_density);
130 
131 
132  //-----------------------------------------------------------------------
133  // PUBLIC MEMBERS:
134  //--------------------------------------------------------------------------
135 
136 public:
137 
140 
141 
142  //-----------------------------------------------------------------------
143  // PROTECTED MEMBERS:
144  //--------------------------------------------------------------------------
145 
146 protected:
147 
149  bool m_enabled;
150 
152  GLint m_fogMode;
153 
155  float m_start;
156 
158  float m_end;
159 
161  float m_density;
162 };
163 
164 //------------------------------------------------------------------------------
165 } // namespace chai3d
166 //------------------------------------------------------------------------------
167 
168 //------------------------------------------------------------------------------
169 #endif
170 //------------------------------------------------------------------------------
171 
This structures provide a containers for storing rendering options that are passed through the sceneg...
Definition: CRenderOptions.h:82
bool getEnabled() const
This method returns true if fog is enabled, false otherwise.
Definition: CFog.h:109
bool m_enabled
If true, then fog is enabled, false otherwise.
Definition: CFog.h:149
float m_end
Fog end distance.
Definition: CFog.h:158
float m_density
Fog density.
Definition: CFog.h:161
GLint m_fogMode
Fog mode. (GL_LINEAR, GL_EXP, GL_EXP2).
Definition: CFog.h:152
void setFogModeEXP()
This method sets the fog mode to GL_EXP.
Definition: CFog.h:118
GLint getFogMode()
This method returns the current fog mode.
Definition: CFog.h:124
cFog()
Constructor of cFog.
Definition: CFog.cpp:57
float m_start
Fog start distance.
Definition: CFog.h:155
void setEnabled(const bool a_enabled)
This method enables of disables fog.
Definition: CFog.h:106
void setFogModeLINEAR()
This method sets the fog mode to GL_LINEAR.
Definition: CFog.h:115
Implements a structure to store rendering options.
void setFogModeEXP2()
This method sets the fog mode to GL_EXP2.
Definition: CFog.h:121
This class implements fog inside the world.
Definition: CFog.h:81
This class defines a color using a GLfloat representation for each component.
Definition: CColor.h:138
Implements color properties.
virtual ~cFog()
Destructor of cFog.
Definition: CFog.h:93
void setFogMode(const GLint a_fogMode)
This method sets the fog mode by passing the OpenGL fog mode constant as parameter (GL_LINEAR...
Definition: CFog.h:112
Definition: CAudioBuffer.cpp:56
cColorf m_color
Fog color.
Definition: CFog.h:139
virtual void render(cRenderOptions &a_options)
This method renders the fog using OpenGL.
Definition: CFog.cpp:97
void setProperties(const double a_start, const double a_end, const double a_density)
This method sets the fog properties.
Definition: CFog.cpp:82