00001 // 00002 // Redistribution and use in source and binary forms, with or without 00003 // modification, are permitted provided that the following conditions 00004 // are met: 00005 // * Redistributions of source code must retain the above copyright 00006 // notice, this list of conditions and the following disclaimer. 00007 // * Redistributions in binary form must reproduce the above copyright 00008 // notice, this list of conditions and the following disclaimer in the 00009 // documentation and/or other materials provided with the distribution. 00010 // * Neither the name of NVIDIA CORPORATION nor the names of its 00011 // contributors may be used to endorse or promote products derived 00012 // from this software without specific prior written permission. 00013 // 00014 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 00015 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00016 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00017 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 00018 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00019 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00020 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00021 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00022 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00023 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00024 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00025 // 00026 // Copyright (c) 2018 NVIDIA Corporation. All rights reserved. 00027 00028 00029 00030 #ifndef MODIFIER_H 00031 #define MODIFIER_H 00032 00033 #include "Apex.h" 00034 #include "Curve.h" 00035 #include "IofxAsset.h" 00036 #include "IofxRenderCallback.h" 00037 00038 #include "ModifierDefs.h" 00039 00040 namespace nvidia 00041 { 00042 namespace apex 00043 { 00044 00045 PX_PUSH_PACK_DEFAULT 00046 00048 inline uint32_t ModifierUsageFromStage(ModifierStage stage) 00049 { 00050 return 1u << stage; 00051 } 00052 00053 // Disable the unused arguments warning for this header. 00054 #pragma warning( disable: 4100 ) 00055 00062 class Modifier 00063 { 00064 public: 00065 00067 virtual ModifierTypeEnum getModifierType() const = 0; 00068 00070 virtual uint32_t getModifierUsage() const = 0; 00071 00073 virtual uint32_t getModifierSpriteSemantics() 00074 { 00075 return 0; 00076 } 00077 00079 virtual uint32_t getModifierMeshSemantics() 00080 { 00081 return 0; 00082 } 00083 00084 virtual ~Modifier() { } 00085 00086 }; 00087 00094 template <typename T> 00095 class ModifierT : public Modifier 00096 { 00097 public: 00098 00100 virtual ModifierTypeEnum getModifierType() const 00101 { 00102 return T::ModifierType; 00103 } 00104 00106 virtual uint32_t getModifierUsage() const 00107 { 00108 return T::ModifierUsage; 00109 } 00110 }; 00111 00112 00116 class RotationModifier : public ModifierT<RotationModifier> 00117 { 00118 public: 00119 00121 static const ModifierTypeEnum ModifierType = ModifierType_Rotation; 00122 00124 static const uint32_t ModifierUsage = ModifierUsage_Spawn | ModifierUsage_Continuous 00125 | ModifierUsage_Mesh; 00126 00127 00129 virtual ApexMeshParticleRollType::Enum getRollType() const = 0; 00130 00132 virtual void setRollType(ApexMeshParticleRollType::Enum rollType) = 0; 00133 00135 virtual float getMaxSettleRate() const = 0; 00136 00138 virtual void setMaxSettleRate(float settleRate) = 0; 00139 00141 virtual float getMaxRotationRate() const = 0; 00142 00144 virtual void setMaxRotationRate(float rotationRate) = 0; 00145 00146 }; 00147 00152 class SimpleScaleModifier : public ModifierT<SimpleScaleModifier> 00153 { 00154 public: 00155 00157 static const ModifierTypeEnum ModifierType = ModifierType_SimpleScale; 00158 00160 static const uint32_t ModifierUsage = ModifierUsage_Spawn | ModifierUsage_Continuous 00161 | ModifierUsage_Sprite | ModifierUsage_Mesh; 00162 00163 00165 virtual PxVec3 getScaleFactor() const = 0; 00166 00168 virtual void setScaleFactor(const PxVec3& s) = 0; 00169 }; 00170 00174 class ScaleByMassModifier : public ModifierT<ScaleByMassModifier> 00175 { 00176 public: 00177 00179 static const ModifierTypeEnum ModifierType = ModifierType_ScaleByMass; 00180 00182 static const uint32_t ModifierUsage = ModifierUsage_Spawn | ModifierUsage_Continuous 00183 | ModifierUsage_Sprite | ModifierUsage_Mesh; 00184 }; 00185 00190 class RandomScaleModifier : public ModifierT<RandomScaleModifier> 00191 { 00192 public: 00193 00195 static const ModifierTypeEnum ModifierType = ModifierType_RandomScale; 00196 00198 static const uint32_t ModifierUsage = ModifierUsage_Spawn 00199 | ModifierUsage_Sprite | ModifierUsage_Mesh; 00200 00201 00203 virtual Range<float> getScaleFactor() const = 0; 00204 00206 virtual void setScaleFactor(const Range<float>& s) = 0; 00207 }; 00208 00213 class ColorVsLifeModifier : public ModifierT<ColorVsLifeModifier> 00214 { 00215 public: 00216 00218 static const ModifierTypeEnum ModifierType = ModifierType_ColorVsLife; 00219 00221 static const uint32_t ModifierUsage = ModifierUsage_Spawn | ModifierUsage_Continuous 00222 | ModifierUsage_Sprite | ModifierUsage_Mesh; 00223 00224 00226 virtual ColorChannel getColorChannel() const = 0; 00227 00229 virtual void setColorChannel(ColorChannel colorChannel) = 0; 00230 00232 virtual const Curve* getFunction() const = 0; 00233 00235 virtual void setFunction(const Curve* f) = 0; 00236 }; 00237 00242 class ColorVsDensityModifier : public ModifierT<ColorVsDensityModifier> 00243 { 00244 public: 00245 00247 static const ModifierTypeEnum ModifierType = ModifierType_ColorVsDensity; 00248 00250 static const uint32_t ModifierUsage = ModifierUsage_Continuous 00251 | ModifierUsage_Sprite | ModifierUsage_Mesh; 00252 00253 00255 virtual ColorChannel getColorChannel() const = 0; 00256 00258 virtual void setColorChannel(ColorChannel colorChannel) = 0; 00259 00261 virtual const Curve* getFunction() const = 0; 00262 00264 virtual void setFunction(const Curve* f) = 0; 00265 }; 00266 00272 class SubtextureVsLifeModifier : public ModifierT<SubtextureVsLifeModifier> 00273 { 00274 public: 00275 00277 static const ModifierTypeEnum ModifierType = ModifierType_SubtextureVsLife; 00278 00280 static const uint32_t ModifierUsage = ModifierUsage_Continuous 00281 | ModifierUsage_Sprite; 00282 00283 00285 virtual const Curve* getFunction() const = 0; 00286 00288 virtual void setFunction(const Curve* f) = 0; 00289 }; 00290 00294 class OrientAlongVelocityModifier : public ModifierT<OrientAlongVelocityModifier> 00295 { 00296 public: 00297 00299 static const ModifierTypeEnum ModifierType = ModifierType_OrientAlongVelocity; 00300 00302 static const uint32_t ModifierUsage = ModifierUsage_Continuous 00303 | ModifierUsage_Mesh; 00304 00305 00307 virtual PxVec3 getModelForward() const = 0; 00308 00310 virtual void setModelForward(const PxVec3& s) = 0; 00311 }; 00312 00313 00319 class ScaleAlongVelocityModifier : public ModifierT<ScaleAlongVelocityModifier> 00320 { 00321 public: 00322 00324 static const ModifierTypeEnum ModifierType = ModifierType_ScaleAlongVelocity; 00325 00327 static const uint32_t ModifierUsage = ModifierUsage_Continuous 00328 | ModifierUsage_Mesh; 00329 00330 00332 virtual float getScaleFactor() const = 0; 00333 00335 virtual void setScaleFactor(const float& s) = 0; 00336 }; 00337 00341 class RandomSubtextureModifier : public ModifierT<RandomSubtextureModifier> 00342 { 00343 public: 00344 00346 static const ModifierTypeEnum ModifierType = ModifierType_RandomSubtexture; 00347 00349 static const uint32_t ModifierUsage = ModifierUsage_Spawn 00350 | ModifierUsage_Sprite; 00351 00352 00354 virtual Range<float> getSubtextureRange() const = 0; 00355 00357 virtual void setSubtextureRange(const Range<float>& s) = 0; 00358 }; 00359 00365 class RandomRotationModifier : public ModifierT<RandomRotationModifier> 00366 { 00367 public: 00368 00370 static const ModifierTypeEnum ModifierType = ModifierType_RandomRotation; 00371 00373 static const uint32_t ModifierUsage = ModifierUsage_Spawn 00374 | ModifierUsage_Sprite; 00375 00376 00378 virtual Range<float> getRotationRange() const = 0; 00379 00381 virtual void setRotationRange(const Range<float>& s) = 0; 00382 }; 00383 00387 class ScaleVsLifeModifier : public ModifierT<ScaleVsLifeModifier> 00388 { 00389 public: 00390 00392 static const ModifierTypeEnum ModifierType = ModifierType_ScaleVsLife; 00393 00395 static const uint32_t ModifierUsage = ModifierUsage_Continuous 00396 | ModifierUsage_Sprite | ModifierUsage_Mesh; 00397 00398 00400 virtual ScaleAxis getScaleAxis() const = 0; 00401 00403 virtual void setScaleAxis(ScaleAxis a) = 0; 00404 00406 virtual const Curve* getFunction() const = 0; 00407 00409 virtual void setFunction(const Curve* f) = 0; 00410 }; 00411 00415 class ScaleVsDensityModifier : public ModifierT<ScaleVsDensityModifier> 00416 { 00417 public: 00418 00420 static const ModifierTypeEnum ModifierType = ModifierType_ScaleVsDensity; 00421 00423 static const uint32_t ModifierUsage = ModifierUsage_Continuous 00424 | ModifierUsage_Sprite | ModifierUsage_Mesh; 00425 00426 00428 virtual ScaleAxis getScaleAxis() const = 0; 00429 00431 virtual void setScaleAxis(ScaleAxis a) = 0; 00432 00434 virtual const Curve* getFunction() const = 0; 00435 00437 virtual void setFunction(const Curve* f) = 0; 00438 }; 00439 00443 class ScaleVsCameraDistanceModifier : public ModifierT<ScaleVsCameraDistanceModifier> 00444 { 00445 public: 00446 00448 static const ModifierTypeEnum ModifierType = ModifierType_ScaleVsCameraDistance; 00449 00451 static const uint32_t ModifierUsage = ModifierUsage_Continuous 00452 | ModifierUsage_Sprite | ModifierUsage_Mesh; 00453 00454 00456 virtual ScaleAxis getScaleAxis() const = 0; 00457 00459 virtual void setScaleAxis(ScaleAxis a) = 0; 00460 00462 virtual const Curve* getFunction() const = 0; 00463 00465 virtual void setFunction(const Curve* f) = 0; 00466 }; 00467 00471 class ViewDirectionSortingModifier : public ModifierT<ViewDirectionSortingModifier> 00472 { 00473 public: 00474 00476 static const ModifierTypeEnum ModifierType = ModifierType_ViewDirectionSorting; 00477 00479 static const uint32_t ModifierUsage = ModifierUsage_Continuous 00480 | ModifierUsage_Sprite; 00481 00482 }; 00483 00487 class RotationRateModifier : public ModifierT<RotationRateModifier> 00488 { 00489 public: 00490 00492 static const ModifierTypeEnum ModifierType = ModifierType_RotationRate; 00493 00495 static const uint32_t ModifierUsage = ModifierUsage_Continuous 00496 | ModifierUsage_Sprite; 00497 00498 00500 virtual float getRotationRate() const = 0; 00501 00503 virtual void setRotationRate(const float& rate) = 0; 00504 }; 00505 00509 class RotationRateVsLifeModifier : public ModifierT<RotationRateVsLifeModifier> 00510 { 00511 public: 00512 00514 static const ModifierTypeEnum ModifierType = ModifierType_RotationRateVsLife; 00515 00517 static const uint32_t ModifierUsage = ModifierUsage_Continuous 00518 | ModifierUsage_Sprite; 00519 00520 00522 virtual const Curve* getFunction() const = 0; 00523 00525 virtual void setFunction(const Curve* f) = 0; 00526 }; 00527 00531 class OrientScaleAlongScreenVelocityModifier : public ModifierT<OrientScaleAlongScreenVelocityModifier> 00532 { 00533 public: 00534 00536 static const ModifierTypeEnum ModifierType = ModifierType_OrientScaleAlongScreenVelocity; 00537 00539 static const uint32_t ModifierUsage = ModifierUsage_Continuous 00540 | ModifierUsage_Sprite; 00541 00542 00544 virtual float getScalePerVelocity() const = 0; 00545 00547 virtual void setScalePerVelocity(const float& s) = 0; 00548 00550 virtual float getScaleChangeLimit() const = 0; 00551 00553 virtual void setScaleChangeLimit(const float& s) = 0; 00554 00556 virtual float getScaleChangeDelay() const = 0; 00557 00559 virtual void setScaleChangeDelay(const float& s) = 0; 00560 }; 00561 00566 class ColorVsVelocityModifier : public ModifierT<ColorVsVelocityModifier> 00567 { 00568 public: 00569 00571 static const ModifierTypeEnum ModifierType = ModifierType_ColorVsVelocity; 00572 00574 static const uint32_t ModifierUsage = ModifierUsage_Spawn | ModifierUsage_Continuous 00575 | ModifierUsage_Sprite | ModifierUsage_Mesh; 00576 00577 00579 virtual ColorChannel getColorChannel() const = 0; 00580 00582 virtual void setColorChannel(ColorChannel colorChannel) = 0; 00583 00585 virtual const Curve* getFunction() const = 0; 00586 00588 virtual void setFunction(const Curve* f) = 0; 00589 00591 virtual float getVelocity0() const = 0; 00592 00594 virtual void setVelocity0(float value) = 0; 00595 00597 virtual float getVelocity1() const = 0; 00598 00600 virtual void setVelocity1(float value) = 0; 00601 }; 00602 00603 #pragma warning( default: 4100 ) 00604 00605 PX_POP_PACK 00606 00607 } 00608 } // namespace nvidia 00609 00610 #endif // MODIFIER_H