1 /* 2 Copyright (c) 2008-2009 NetAllied Systems GmbH 3 4 This file is part of MayaDataModel. 5 6 Licensed under the MIT Open Source License, 7 for details please see LICENSE file or the website 8 http://www.opensource.org/licenses/mit-license.php 9 */ 10 #ifndef __MayaDM_OCEAN_H__ 11 #define __MayaDM_OCEAN_H__ 12 #include "MayaDMTypes.h" 13 #include "MayaDMConnectables.h" 14 #include "MayaDMTexture2d.h" 15 namespace MayaDM 16 { 17 class Ocean : public Texture2d 18 { 19 public: 20 struct WaveHeight{ 21 float waveHeight_Position; 22 float waveHeight_FloatValue; 23 unsigned int waveHeight_Interp; writeWaveHeight24 void write(FILE* file) const 25 { 26 fprintf(file,"%f ", waveHeight_Position); 27 fprintf(file,"%f ", waveHeight_FloatValue); 28 fprintf(file,"%i", waveHeight_Interp); 29 } 30 }; 31 struct WaveTurbulence{ 32 float waveTurbulence_Position; 33 float waveTurbulence_FloatValue; 34 unsigned int waveTurbulence_Interp; writeWaveTurbulence35 void write(FILE* file) const 36 { 37 fprintf(file,"%f ", waveTurbulence_Position); 38 fprintf(file,"%f ", waveTurbulence_FloatValue); 39 fprintf(file,"%i", waveTurbulence_Interp); 40 } 41 }; 42 struct WavePeaking{ 43 float wavePeaking_Position; 44 float wavePeaking_FloatValue; 45 unsigned int wavePeaking_Interp; writeWavePeaking46 void write(FILE* file) const 47 { 48 fprintf(file,"%f ", wavePeaking_Position); 49 fprintf(file,"%f ", wavePeaking_FloatValue); 50 fprintf(file,"%i", wavePeaking_Interp); 51 } 52 }; 53 public: 54 Ocean()55 Ocean():Texture2d(){} 56 Ocean(FILE* file,const std::string& name,const std::string& parent="",bool shared=false,bool create=true) 57 :Texture2d(file, name, parent, "ocean", shared, create){} ~Ocean()58 virtual ~Ocean(){} 59 setTime(float ti)60 void setTime(float ti) 61 { 62 if(ti == 0.0) return; 63 fprintf(mFile,"\tsetAttr \".ti\" %f;\n", ti); 64 } setScale(float sc)65 void setScale(float sc) 66 { 67 if(sc == 10.0) return; 68 fprintf(mFile,"\tsetAttr \".sc\" %f;\n", sc); 69 } setWindUV(const float2 & wi)70 void setWindUV(const float2& wi) 71 { 72 if(wi == float2(1.0f,0.0f)) return; 73 fprintf(mFile,"\tsetAttr \".wi\" -type \"float2\" "); 74 wi.write(mFile); 75 fprintf(mFile,";\n"); 76 } setWindU(float wiu)77 void setWindU(float wiu) 78 { 79 if(wiu == 0.0) return; 80 fprintf(mFile,"\tsetAttr \".wi.wiu\" %f;\n", wiu); 81 } setWindV(float wiv)82 void setWindV(float wiv) 83 { 84 if(wiv == 0.0) return; 85 fprintf(mFile,"\tsetAttr \".wi.wiv\" %f;\n", wiv); 86 } setObserverSpeed(float os)87 void setObserverSpeed(float os) 88 { 89 if(os == 0.0) return; 90 fprintf(mFile,"\tsetAttr \".os\" %f;\n", os); 91 } setWaveDirSpread(float wd)92 void setWaveDirSpread(float wd) 93 { 94 if(wd == 0.2) return; 95 fprintf(mFile,"\tsetAttr \".wd\" %f;\n", wd); 96 } setNumFrequencies(float nf)97 void setNumFrequencies(float nf) 98 { 99 if(nf == 3.0) return; 100 fprintf(mFile,"\tsetAttr \".nf\" %f;\n", nf); 101 } setWaveLengthMin(float wlm)102 void setWaveLengthMin(float wlm) 103 { 104 if(wlm == 0.3) return; 105 fprintf(mFile,"\tsetAttr \".wlm\" %f;\n", wlm); 106 } setWaveLengthMax(float wlx)107 void setWaveLengthMax(float wlx) 108 { 109 if(wlx == 4.0) return; 110 fprintf(mFile,"\tsetAttr \".wlx\" %f;\n", wlx); 111 } setWaveHeight(size_t wh_i,const WaveHeight & wh)112 void setWaveHeight(size_t wh_i,const WaveHeight& wh) 113 { 114 fprintf(mFile,"\tsetAttr \".wh[%i]\" ",wh_i); 115 wh.write(mFile); 116 fprintf(mFile,";\n"); 117 } setWaveHeight(size_t wh_start,size_t wh_end,WaveHeight * wh)118 void setWaveHeight(size_t wh_start,size_t wh_end,WaveHeight* wh) 119 { 120 fprintf(mFile,"\tsetAttr \".wh[%i:%i]\" ", wh_start,wh_end); 121 size_t size = (wh_end-wh_start)*1+1; 122 for(size_t i=0;i<size;++i) 123 { 124 wh[i].write(mFile); 125 fprintf(mFile,"\n"); 126 } 127 fprintf(mFile,";\n"); 128 } startWaveHeight(size_t wh_start,size_t wh_end)129 void startWaveHeight(size_t wh_start,size_t wh_end)const 130 { 131 fprintf(mFile,"\tsetAttr \".wh[%i:%i]\"",wh_start,wh_end); 132 fprintf(mFile," -type \"WaveHeight\" "); 133 } appendWaveHeight(const WaveHeight & wh)134 void appendWaveHeight(const WaveHeight& wh)const 135 { 136 fprintf(mFile," "); 137 wh.write(mFile); 138 } endWaveHeight()139 void endWaveHeight()const 140 { 141 fprintf(mFile,";\n"); 142 } setWaveHeight_Position(size_t wh_i,float whp)143 void setWaveHeight_Position(size_t wh_i,float whp) 144 { 145 if(whp == 0.0) return; 146 fprintf(mFile,"\tsetAttr \".wh[%i].whp\" %f;\n", wh_i,whp); 147 } setWaveHeight_FloatValue(size_t wh_i,float whfv)148 void setWaveHeight_FloatValue(size_t wh_i,float whfv) 149 { 150 if(whfv == 0.0) return; 151 fprintf(mFile,"\tsetAttr \".wh[%i].whfv\" %f;\n", wh_i,whfv); 152 } setWaveHeight_Interp(size_t wh_i,unsigned int whi)153 void setWaveHeight_Interp(size_t wh_i,unsigned int whi) 154 { 155 if(whi == 0) return; 156 fprintf(mFile,"\tsetAttr \".wh[%i].whi\" %i;\n", wh_i,whi); 157 } setWaveTurbulence(size_t wtb_i,const WaveTurbulence & wtb)158 void setWaveTurbulence(size_t wtb_i,const WaveTurbulence& wtb) 159 { 160 fprintf(mFile,"\tsetAttr \".wtb[%i]\" ",wtb_i); 161 wtb.write(mFile); 162 fprintf(mFile,";\n"); 163 } setWaveTurbulence(size_t wtb_start,size_t wtb_end,WaveTurbulence * wtb)164 void setWaveTurbulence(size_t wtb_start,size_t wtb_end,WaveTurbulence* wtb) 165 { 166 fprintf(mFile,"\tsetAttr \".wtb[%i:%i]\" ", wtb_start,wtb_end); 167 size_t size = (wtb_end-wtb_start)*1+1; 168 for(size_t i=0;i<size;++i) 169 { 170 wtb[i].write(mFile); 171 fprintf(mFile,"\n"); 172 } 173 fprintf(mFile,";\n"); 174 } startWaveTurbulence(size_t wtb_start,size_t wtb_end)175 void startWaveTurbulence(size_t wtb_start,size_t wtb_end)const 176 { 177 fprintf(mFile,"\tsetAttr \".wtb[%i:%i]\"",wtb_start,wtb_end); 178 fprintf(mFile," -type \"WaveTurbulence\" "); 179 } appendWaveTurbulence(const WaveTurbulence & wtb)180 void appendWaveTurbulence(const WaveTurbulence& wtb)const 181 { 182 fprintf(mFile," "); 183 wtb.write(mFile); 184 } endWaveTurbulence()185 void endWaveTurbulence()const 186 { 187 fprintf(mFile,";\n"); 188 } setWaveTurbulence_Position(size_t wtb_i,float wtbp)189 void setWaveTurbulence_Position(size_t wtb_i,float wtbp) 190 { 191 if(wtbp == 0.0) return; 192 fprintf(mFile,"\tsetAttr \".wtb[%i].wtbp\" %f;\n", wtb_i,wtbp); 193 } setWaveTurbulence_FloatValue(size_t wtb_i,float wtbfv)194 void setWaveTurbulence_FloatValue(size_t wtb_i,float wtbfv) 195 { 196 if(wtbfv == 0.0) return; 197 fprintf(mFile,"\tsetAttr \".wtb[%i].wtbfv\" %f;\n", wtb_i,wtbfv); 198 } setWaveTurbulence_Interp(size_t wtb_i,unsigned int wtbi)199 void setWaveTurbulence_Interp(size_t wtb_i,unsigned int wtbi) 200 { 201 if(wtbi == 0) return; 202 fprintf(mFile,"\tsetAttr \".wtb[%i].wtbi\" %i;\n", wtb_i,wtbi); 203 } setWavePeaking(size_t wp_i,const WavePeaking & wp)204 void setWavePeaking(size_t wp_i,const WavePeaking& wp) 205 { 206 fprintf(mFile,"\tsetAttr \".wp[%i]\" ",wp_i); 207 wp.write(mFile); 208 fprintf(mFile,";\n"); 209 } setWavePeaking(size_t wp_start,size_t wp_end,WavePeaking * wp)210 void setWavePeaking(size_t wp_start,size_t wp_end,WavePeaking* wp) 211 { 212 fprintf(mFile,"\tsetAttr \".wp[%i:%i]\" ", wp_start,wp_end); 213 size_t size = (wp_end-wp_start)*1+1; 214 for(size_t i=0;i<size;++i) 215 { 216 wp[i].write(mFile); 217 fprintf(mFile,"\n"); 218 } 219 fprintf(mFile,";\n"); 220 } startWavePeaking(size_t wp_start,size_t wp_end)221 void startWavePeaking(size_t wp_start,size_t wp_end)const 222 { 223 fprintf(mFile,"\tsetAttr \".wp[%i:%i]\"",wp_start,wp_end); 224 fprintf(mFile," -type \"WavePeaking\" "); 225 } appendWavePeaking(const WavePeaking & wp)226 void appendWavePeaking(const WavePeaking& wp)const 227 { 228 fprintf(mFile," "); 229 wp.write(mFile); 230 } endWavePeaking()231 void endWavePeaking()const 232 { 233 fprintf(mFile,";\n"); 234 } setWavePeaking_Position(size_t wp_i,float wpp)235 void setWavePeaking_Position(size_t wp_i,float wpp) 236 { 237 if(wpp == 0.0) return; 238 fprintf(mFile,"\tsetAttr \".wp[%i].wpp\" %f;\n", wp_i,wpp); 239 } setWavePeaking_FloatValue(size_t wp_i,float wpfv)240 void setWavePeaking_FloatValue(size_t wp_i,float wpfv) 241 { 242 if(wpfv == 0.0) return; 243 fprintf(mFile,"\tsetAttr \".wp[%i].wpfv\" %f;\n", wp_i,wpfv); 244 } setWavePeaking_Interp(size_t wp_i,unsigned int wpi)245 void setWavePeaking_Interp(size_t wp_i,unsigned int wpi) 246 { 247 if(wpi == 0) return; 248 fprintf(mFile,"\tsetAttr \".wp[%i].wpi\" %i;\n", wp_i,wpi); 249 } setFoamEmission(float fme)250 void setFoamEmission(float fme) 251 { 252 if(fme == 0.0) return; 253 fprintf(mFile,"\tsetAttr \".fme\" %f;\n", fme); 254 } setFoamThreshold(float fmt)255 void setFoamThreshold(float fmt) 256 { 257 if(fmt == 0.51) return; 258 fprintf(mFile,"\tsetAttr \".fmt\" %f;\n", fmt); 259 } setColorMode(unsigned int cmd)260 void setColorMode(unsigned int cmd) 261 { 262 if(cmd == 0) return; 263 fprintf(mFile,"\tsetAttr \".cmd\" %i;\n", cmd); 264 } getTime()265 void getTime()const 266 { 267 fprintf(mFile,"\"%s.ti\"",mName.c_str()); 268 } getScale()269 void getScale()const 270 { 271 fprintf(mFile,"\"%s.sc\"",mName.c_str()); 272 } getWindUV()273 void getWindUV()const 274 { 275 fprintf(mFile,"\"%s.wi\"",mName.c_str()); 276 } getWindU()277 void getWindU()const 278 { 279 fprintf(mFile,"\"%s.wi.wiu\"",mName.c_str()); 280 } getWindV()281 void getWindV()const 282 { 283 fprintf(mFile,"\"%s.wi.wiv\"",mName.c_str()); 284 } getObserverSpeed()285 void getObserverSpeed()const 286 { 287 fprintf(mFile,"\"%s.os\"",mName.c_str()); 288 } getWaveDirSpread()289 void getWaveDirSpread()const 290 { 291 fprintf(mFile,"\"%s.wd\"",mName.c_str()); 292 } getNumFrequencies()293 void getNumFrequencies()const 294 { 295 fprintf(mFile,"\"%s.nf\"",mName.c_str()); 296 } getWaveLengthMin()297 void getWaveLengthMin()const 298 { 299 fprintf(mFile,"\"%s.wlm\"",mName.c_str()); 300 } getWaveLengthMax()301 void getWaveLengthMax()const 302 { 303 fprintf(mFile,"\"%s.wlx\"",mName.c_str()); 304 } getWaveHeight(size_t wh_i)305 void getWaveHeight(size_t wh_i)const 306 { 307 fprintf(mFile,"\"%s.wh[%i]\"",mName.c_str(),wh_i); 308 } getWaveHeight()309 void getWaveHeight()const 310 { 311 312 fprintf(mFile,"\"%s.wh\"",mName.c_str()); 313 } getWaveHeight_Position(size_t wh_i)314 void getWaveHeight_Position(size_t wh_i)const 315 { 316 fprintf(mFile,"\"%s.wh[%i].whp\"",mName.c_str(),wh_i); 317 } getWaveHeight_Position()318 void getWaveHeight_Position()const 319 { 320 321 fprintf(mFile,"\"%s.wh.whp\"",mName.c_str()); 322 } getWaveHeight_FloatValue(size_t wh_i)323 void getWaveHeight_FloatValue(size_t wh_i)const 324 { 325 fprintf(mFile,"\"%s.wh[%i].whfv\"",mName.c_str(),wh_i); 326 } getWaveHeight_FloatValue()327 void getWaveHeight_FloatValue()const 328 { 329 330 fprintf(mFile,"\"%s.wh.whfv\"",mName.c_str()); 331 } getWaveHeight_Interp(size_t wh_i)332 void getWaveHeight_Interp(size_t wh_i)const 333 { 334 fprintf(mFile,"\"%s.wh[%i].whi\"",mName.c_str(),wh_i); 335 } getWaveHeight_Interp()336 void getWaveHeight_Interp()const 337 { 338 339 fprintf(mFile,"\"%s.wh.whi\"",mName.c_str()); 340 } getWaveTurbulence(size_t wtb_i)341 void getWaveTurbulence(size_t wtb_i)const 342 { 343 fprintf(mFile,"\"%s.wtb[%i]\"",mName.c_str(),wtb_i); 344 } getWaveTurbulence()345 void getWaveTurbulence()const 346 { 347 348 fprintf(mFile,"\"%s.wtb\"",mName.c_str()); 349 } getWaveTurbulence_Position(size_t wtb_i)350 void getWaveTurbulence_Position(size_t wtb_i)const 351 { 352 fprintf(mFile,"\"%s.wtb[%i].wtbp\"",mName.c_str(),wtb_i); 353 } getWaveTurbulence_Position()354 void getWaveTurbulence_Position()const 355 { 356 357 fprintf(mFile,"\"%s.wtb.wtbp\"",mName.c_str()); 358 } getWaveTurbulence_FloatValue(size_t wtb_i)359 void getWaveTurbulence_FloatValue(size_t wtb_i)const 360 { 361 fprintf(mFile,"\"%s.wtb[%i].wtbfv\"",mName.c_str(),wtb_i); 362 } getWaveTurbulence_FloatValue()363 void getWaveTurbulence_FloatValue()const 364 { 365 366 fprintf(mFile,"\"%s.wtb.wtbfv\"",mName.c_str()); 367 } getWaveTurbulence_Interp(size_t wtb_i)368 void getWaveTurbulence_Interp(size_t wtb_i)const 369 { 370 fprintf(mFile,"\"%s.wtb[%i].wtbi\"",mName.c_str(),wtb_i); 371 } getWaveTurbulence_Interp()372 void getWaveTurbulence_Interp()const 373 { 374 375 fprintf(mFile,"\"%s.wtb.wtbi\"",mName.c_str()); 376 } getWavePeaking(size_t wp_i)377 void getWavePeaking(size_t wp_i)const 378 { 379 fprintf(mFile,"\"%s.wp[%i]\"",mName.c_str(),wp_i); 380 } getWavePeaking()381 void getWavePeaking()const 382 { 383 384 fprintf(mFile,"\"%s.wp\"",mName.c_str()); 385 } getWavePeaking_Position(size_t wp_i)386 void getWavePeaking_Position(size_t wp_i)const 387 { 388 fprintf(mFile,"\"%s.wp[%i].wpp\"",mName.c_str(),wp_i); 389 } getWavePeaking_Position()390 void getWavePeaking_Position()const 391 { 392 393 fprintf(mFile,"\"%s.wp.wpp\"",mName.c_str()); 394 } getWavePeaking_FloatValue(size_t wp_i)395 void getWavePeaking_FloatValue(size_t wp_i)const 396 { 397 fprintf(mFile,"\"%s.wp[%i].wpfv\"",mName.c_str(),wp_i); 398 } getWavePeaking_FloatValue()399 void getWavePeaking_FloatValue()const 400 { 401 402 fprintf(mFile,"\"%s.wp.wpfv\"",mName.c_str()); 403 } getWavePeaking_Interp(size_t wp_i)404 void getWavePeaking_Interp(size_t wp_i)const 405 { 406 fprintf(mFile,"\"%s.wp[%i].wpi\"",mName.c_str(),wp_i); 407 } getWavePeaking_Interp()408 void getWavePeaking_Interp()const 409 { 410 411 fprintf(mFile,"\"%s.wp.wpi\"",mName.c_str()); 412 } getFoamEmission()413 void getFoamEmission()const 414 { 415 fprintf(mFile,"\"%s.fme\"",mName.c_str()); 416 } getFoamThreshold()417 void getFoamThreshold()const 418 { 419 fprintf(mFile,"\"%s.fmt\"",mName.c_str()); 420 } getColorMode()421 void getColorMode()const 422 { 423 fprintf(mFile,"\"%s.cmd\"",mName.c_str()); 424 } getOutFoam()425 void getOutFoam()const 426 { 427 fprintf(mFile,"\"%s.ofm\"",mName.c_str()); 428 } 429 protected: 430 Ocean(FILE* file,const std::string& name,const std::string& parent,const std::string& nodeType,bool shared=false,bool create=true) Texture2d(file,name,parent,nodeType,shared,create)431 :Texture2d(file, name, parent, nodeType, shared, create) {} 432 433 }; 434 }//namespace MayaDM 435 #endif//__MayaDM_OCEAN_H__ 436