1 // const.h
2 //
3 // Copyright (C) 2003, 2004 Jason Bevins
4 //
5 // This library is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation; either version 2.1 of the License, or (at
8 // your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
13 // License (COPYING.txt) for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation,
17 // Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 //
19 // The developer's email is jlbezigvins@gmzigail.com (for great email, take
20 // off every 'zig'.)
21 //
22 
23 #ifndef NOISE_MODULE_CONST_H
24 #define NOISE_MODULE_CONST_H
25 
26 #include "modulebase.h"
27 
28 namespace noise
29 {
30 
31   namespace module
32   {
33 
34     /// @addtogroup libnoise
35     /// @{
36 
37     /// @addtogroup modules
38     /// @{
39 
40     /// @defgroup generatormodules Generator Modules
41     /// @addtogroup generatormodules
42     /// @{
43 
44     /// Default constant value for the noise::module::Const noise module.
45     const double DEFAULT_CONST_VALUE = 0.0;
46 
47     /// Noise module that outputs a constant value.
48     ///
49     /// @image html moduleconst.png
50     ///
51     /// To specify the constant value, call the SetConstValue() method.
52     ///
53     /// This noise module is not useful by itself, but it is often used as a
54     /// source module for other noise modules.
55     ///
56     /// This noise module does not require any source modules.
57     class Const: public Module
58     {
59 
60       public:
61 
62         /// Constructor.
63         ///
64         /// The default constant value is set to
65         /// noise::module::DEFAULT_CONST_VALUE.
66         Const ();
67 
68         /// Returns the constant output value for this noise module.
69         ///
70         /// @returns The constant output value for this noise module.
GetConstValue()71         double GetConstValue () const
72         {
73           return m_constValue;
74         }
75 
GetSourceModuleCount()76         virtual int GetSourceModuleCount () const
77         {
78           return 0;
79         }
80 
GetValue(double x,double y,double z)81         virtual double GetValue (double x, double y, double z) const
82         {
83           return m_constValue;
84         }
85 
86         /// Sets the constant output value for this noise module.
87         ///
88         /// @param constValue The constant output value for this noise module.
SetConstValue(double constValue)89         void SetConstValue (double constValue)
90         {
91           m_constValue = constValue;
92         }
93 
94       protected:
95 
96         /// Constant value.
97         double m_constValue;
98 
99     };
100 
101     /// @}
102 
103     /// @}
104 
105     /// @}
106 
107   }
108 
109 }
110 
111 #endif
112