1 // scalepoint.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 module noise.mod.scalepoint; 23 24 private { 25 import noise.mod.modulebase; 26 } 27 28 /// @addtogroup libnoise 29 /// @{ 30 31 /// @addtogroup modules 32 /// @{ 33 34 /// @addtogroup transformermodules 35 /// @{ 36 37 /// Default scaling factor applied to the @a x coordinate for the 38 /// module::ScalePoint noise module. 39 const double DEFAULT_SCALE_POINT_X = 1.0; 40 41 /// Default scaling factor applied to the @a y coordinate for the 42 /// module::ScalePoint noise module. 43 const double DEFAULT_SCALE_POINT_Y = 1.0; 44 45 /// Default scaling factor applied to the @a z coordinate for the 46 /// module::ScalePoint noise module. 47 const double DEFAULT_SCALE_POINT_Z = 1.0; 48 49 /// Noise module that scales the coordinates of the input value before 50 /// returning the output value from a source module. 51 /// 52 /// @image html modulescalepoint.png 53 /// 54 /// The GetValue() method multiplies the ( @a x, @a y, @a z ) coordinates 55 /// of the input value with a scaling factor before returning the output 56 /// value from the source module. To set the scaling factor, call the 57 /// SetScale() method. To set the scaling factor to apply to the 58 /// individual @a x, @a y, or @a z coordinates, call the SetXScale(), 59 /// SetYScale() or SetZScale() methods, respectively. 60 /// 61 /// This noise module requires one source module. 62 class ScalePoint : Mod 63 { 64 65 public: 66 67 /// Constructor. 68 /// 69 /// The default scaling factor applied to the @a x coordinate is set 70 /// to module::DEFAULT_SCALE_POINT_X. 71 /// 72 /// The default scaling factor applied to the @a y coordinate is set 73 /// to module::DEFAULT_SCALE_POINT_Y. 74 /// 75 /// The default scaling factor applied to the @a z coordinate is set 76 /// to module::DEFAULT_SCALE_POINT_Z. 77 this() 78 { 79 super(this.GetSourceModCount ()); 80 m_xScale = DEFAULT_SCALE_POINT_X; 81 m_yScale = DEFAULT_SCALE_POINT_Y; 82 m_zScale = DEFAULT_SCALE_POINT_Z; 83 } 84 85 override int GetSourceModCount () const 86 { 87 return 1; 88 } 89 90 override double GetValue (double x, double y, double z) const 91 { 92 assert (m_pSourceMod[0] !is null); 93 94 return m_pSourceMod[0].GetValue (x * m_xScale, y * m_yScale, 95 z * m_zScale); 96 } 97 98 /// Returns the scaling factor applied to the @a x coordinate of the 99 /// input value. 100 /// 101 /// @returns The scaling factor applied to the @a x coordinate. 102 double GetXScale () const 103 { 104 return m_xScale; 105 } 106 107 /// Returns the scaling factor applied to the @a y coordinate of the 108 /// input value. 109 /// 110 /// @returns The scaling factor applied to the @a y coordinate. 111 double GetYScale () const 112 { 113 return m_yScale; 114 } 115 116 /// Returns the scaling factor applied to the @a z coordinate of the 117 /// input value. 118 /// 119 /// @returns The scaling factor applied to the @a z coordinate. 120 double GetZScale () const 121 { 122 return m_zScale; 123 } 124 125 /// Sets the scaling factor to apply to the input value. 126 /// 127 /// @param scale The scaling factor to apply. 128 /// 129 /// The GetValue() method multiplies the ( @a x, @a y, @a z ) 130 /// coordinates of the input value with a scaling factor before 131 /// returning the output value from the source module. 132 void SetScale (double scale) 133 { 134 m_xScale = scale; 135 m_yScale = scale; 136 m_zScale = scale; 137 } 138 139 /// Sets the scaling factor to apply to the ( @a x, @a y, @a z ) 140 /// coordinates of the input value. 141 /// 142 /// @param xScale The scaling factor to apply to the @a x coordinate. 143 /// @param yScale The scaling factor to apply to the @a y coordinate. 144 /// @param zScale The scaling factor to apply to the @a z coordinate. 145 /// 146 /// The GetValue() method multiplies the ( @a x, @a y, @a z ) 147 /// coordinates of the input value with a scaling factor before 148 /// returning the output value from the source module. 149 void SetScale (double xScale, double yScale, double zScale) 150 { 151 m_xScale = xScale; 152 m_yScale = yScale; 153 m_zScale = zScale; 154 } 155 156 /// Sets the scaling factor to apply to the @a x coordinate of the 157 /// input value. 158 /// 159 /// @param xScale The scaling factor to apply to the @a x coordinate. 160 /// 161 /// The GetValue() method multiplies the ( @a x, @a y, @a z ) 162 /// coordinates of the input value with a scaling factor before 163 /// returning the output value from the source module. 164 void SetXScale (double xScale) 165 { 166 m_xScale = xScale; 167 } 168 169 /// Sets the scaling factor to apply to the @a y coordinate of the 170 /// input value. 171 /// 172 /// @param yScale The scaling factor to apply to the @a y coordinate. 173 /// 174 /// The GetValue() method multiplies the ( @a x, @a y, @a z ) 175 /// coordinates of the input value with a scaling factor before 176 /// returning the output value from the source module. 177 void SetYScale (double yScale) 178 { 179 m_yScale = yScale; 180 } 181 182 /// Sets the scaling factor to apply to the @a z coordinate of the 183 /// input value. 184 /// 185 /// @param zScale The scaling factor to apply to the @a z coordinate. 186 /// 187 /// The GetValue() method multiplies the ( @a x, @a y, @a z ) 188 /// coordinates of the input value with a scaling factor before 189 /// returning the output value from the source module. 190 void SetZScale (double zScale) 191 { 192 m_zScale = zScale; 193 } 194 195 protected: 196 197 /// Scaling factor applied to the @a x coordinate of the input value. 198 double m_xScale; 199 200 /// Scaling factor applied to the @a y coordinate of the input value. 201 double m_yScale; 202 203 /// Scaling factor applied to the @a z coordinate of the input value. 204 double m_zScale; 205 206 }; 207 208 /// @} 209 210 /// @} 211 212 /// @}