1 // translatepoint.h 2 // 3 // Copyright (C) 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.translatepoint; 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 translation factor applied to the @a x coordinate for the 38 /// module::TranslatePoint noise module. 39 const double DEFAULT_TRANSLATE_POINT_X = 0.0; 40 41 /// Default translation factor applied to the @a y coordinate for the 42 /// module::TranslatePoint noise module. 43 const double DEFAULT_TRANSLATE_POINT_Y = 0.0; 44 45 /// Default translation factor applied to the @a z coordinate for the 46 /// module::TranslatePoint noise module. 47 const double DEFAULT_TRANSLATE_POINT_Z = 0.0; 48 49 /// Noise module that moves the coordinates of the input value before 50 /// returning the output value from a source module. 51 /// 52 /// @image html moduletranslatepoint.png 53 /// 54 /// The GetValue() method moves the ( @a x, @a y, @a z ) coordinates of 55 /// the input value by a translation amount before returning the output 56 /// value from the source module. To set the translation amount, call 57 /// the SetTranslation() method. To set the translation amount to 58 /// apply to the individual @a x, @a y, or @a z coordinates, call the 59 /// SetXTranslation(), SetYTranslation() or SetZTranslation() methods, 60 /// respectively. 61 /// 62 /// This noise module requires one source module. 63 class TranslatePoint : Mod 64 { 65 66 public: 67 68 /// Constructor. 69 /// 70 /// The default translation amount to apply to the @a x coordinate is 71 /// set to module::DEFAULT_TRANSLATE_POINT_X. 72 /// 73 /// The default translation amount to apply to the @a y coordinate is 74 /// set to module::DEFAULT_TRANSLATE_POINT_Y. 75 /// 76 /// The default translation amount to apply to the @a z coordinate is 77 /// set to module::DEFAULT_TRANSLATE_POINT_Z. 78 this() 79 { 80 super(this.GetSourceModCount ()); 81 m_xTranslation = DEFAULT_TRANSLATE_POINT_X; 82 m_yTranslation = DEFAULT_TRANSLATE_POINT_Y; 83 m_zTranslation = DEFAULT_TRANSLATE_POINT_Z; 84 } 85 86 override int GetSourceModCount () const 87 { 88 return 1; 89 } 90 91 override double GetValue (double x, double y, double z) const 92 { 93 assert (m_pSourceMod[0] !is null); 94 95 return m_pSourceMod[0].GetValue (x + m_xTranslation, y + m_yTranslation, 96 z + m_zTranslation); 97 } 98 99 /// Returns the translation amount to apply to the @a x coordinate of 100 /// the input value. 101 /// 102 /// @returns The translation amount to apply to the @a x coordinate. 103 double GetXTranslation () const 104 { 105 return m_xTranslation; 106 } 107 108 /// Returns the translation amount to apply to the @a y coordinate of 109 /// the input value. 110 /// 111 /// @returns The translation amount to apply to the @a y coordinate. 112 double GetYTranslation () const 113 { 114 return m_yTranslation; 115 } 116 117 /// Returns the translation amount to apply to the @a z coordinate of 118 /// the input value. 119 /// 120 /// @returns The translation amount to apply to the @a z coordinate. 121 double GetZTranslation () const 122 { 123 return m_zTranslation; 124 } 125 126 /// Sets the translation amount to apply to the input value. 127 /// 128 /// @param translation The translation amount to apply. 129 /// 130 /// The GetValue() method moves the ( @a x, @a y, @a z ) coordinates 131 /// of the input value by a translation amount before returning the 132 /// output value from the source module 133 void SetTranslation (double translation) 134 { 135 m_xTranslation = translation; 136 m_yTranslation = translation; 137 m_zTranslation = translation; 138 } 139 140 /// Sets the translation amounts to apply to the ( @a x, @a y, @a z ) 141 /// coordinates of the input value. 142 /// 143 /// @param xTranslation The translation amount to apply to the @a x 144 /// coordinate. 145 /// @param yTranslation The translation amount to apply to the @a y 146 /// coordinate. 147 /// @param zTranslation The translation amount to apply to the @a z 148 /// coordinate. 149 /// 150 /// The GetValue() method moves the ( @a x, @a y, @a z ) coordinates 151 /// of the input value by a translation amount before returning the 152 /// output value from the source module 153 void SetTranslation (double xTranslation, double yTranslation, 154 double zTranslation) 155 { 156 m_xTranslation = xTranslation; 157 m_yTranslation = yTranslation; 158 m_zTranslation = zTranslation; 159 } 160 161 /// Sets the translation amount to apply to the @a x coordinate of the 162 /// input value. 163 /// 164 /// @param xTranslation The translation amount to apply to the @a x 165 /// coordinate. 166 /// 167 /// The GetValue() method moves the ( @a x, @a y, @a z ) coordinates 168 /// of the input value by a translation amount before returning the 169 /// output value from the source module 170 void SetXTranslation (double xTranslation) 171 { 172 m_xTranslation = xTranslation; 173 } 174 175 /// Sets the translation amount to apply to the @a y coordinate of the 176 /// input value. 177 /// 178 /// @param yTranslation The translation amount to apply to the @a y 179 /// coordinate. 180 /// 181 /// The GetValue() method moves the ( @a x, @a y, @a z ) coordinates 182 /// of the input value by a translation amount before returning the 183 /// output value from the source module 184 void SetYTranslation (double yTranslation) 185 { 186 m_yTranslation = yTranslation; 187 } 188 189 /// Sets the translation amount to apply to the @a z coordinate of the 190 /// input value. 191 /// 192 /// @param zTranslation The translation amount to apply to the @a z 193 /// coordinate. 194 /// 195 /// The GetValue() method moves the ( @a x, @a y, @a z ) coordinates 196 /// of the input value by a translation amount before returning the 197 /// output value from the source module 198 void SetZTranslation (double zTranslation) 199 { 200 m_zTranslation = zTranslation; 201 } 202 203 protected: 204 205 /// Translation amount applied to the @a x coordinate of the input 206 /// value. 207 double m_xTranslation; 208 209 /// Translation amount applied to the @a y coordinate of the input 210 /// value. 211 double m_yTranslation; 212 213 /// Translation amount applied to the @a z coordinate of the input 214 /// value. 215 double m_zTranslation; 216 217 } 218 219 /// @} 220 221 /// @} 222 223 /// @}