imesh/particles.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2006 by Marten Svanfeldt 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_IMESH_PARTICLES_H__ 00020 #define __CS_IMESH_PARTICLES_H__ 00021 00022 #include "csutil/scf_interface.h" 00023 00024 #include "csgeom/obb.h" 00025 #include "csgeom/vector2.h" 00026 #include "csgeom/vector3.h" 00027 #include "csgeom/quaternion.h" 00028 #include "csutil/array.h" 00029 #include "csutil/cscolor.h" 00030 #include "csutil/ref.h" 00031 00036 struct iParticleSystemBase; 00037 00044 enum csParticleSortMode 00045 { 00047 CS_PARTICLE_SORT_NONE, 00049 CS_PARTICLE_SORT_DISTANCE, 00051 CS_PARTICLE_SORT_DOT 00052 }; 00053 00059 enum csParticleRenderOrientation 00060 { 00065 CS_PARTICLE_CAMERAFACE, 00072 CS_PARTICLE_CAMERAFACE_APPROX, 00077 CS_PARTICLE_ORIENT_COMMON, 00084 CS_PARTICLE_ORIENT_COMMON_APPROX, 00090 CS_PARTICLE_ORIENT_VELOCITY, 00096 CS_PARTICLE_ORIENT_SELF, 00104 CS_PARTICLE_ORIENT_SELF_FORWARD 00105 }; 00106 00111 enum csParticleRotationMode 00112 { 00114 CS_PARTICLE_ROTATE_NONE, 00116 CS_PARTICLE_ROTATE_TEXCOORD, 00118 CS_PARTICLE_ROTATE_VERTICES 00119 }; 00120 00126 enum csParticleIntegrationMode 00127 { 00129 CS_PARTICLE_INTEGRATE_NONE, 00131 CS_PARTICLE_INTEGRATE_LINEAR, 00136 CS_PARTICLE_INTEGRATE_BOTH 00137 }; 00138 00144 enum csParticleTransformMode 00145 { 00150 CS_PARTICLE_LOCAL_MODE, 00158 CS_PARTICLE_LOCAL_EMITTER, 00163 CS_PARTICLE_WORLD_MODE 00164 }; 00165 00169 struct csParticle 00170 { 00176 csVector3 position; 00177 00181 float mass; 00182 00189 csQuaternion orientation; 00190 00196 csVector3 linearVelocity; 00197 00201 float timeToLive; 00202 00206 csVector3 angularVelocity; 00207 00208 // Pad to make this struct 64 bytes 00209 float pad; 00210 }; 00211 00215 struct csParticleAux 00216 { 00220 csColor4 color; 00221 00226 csVector2 particleSize; 00227 00228 // Pad to make this 32 bytes 00229 float pad[2]; 00230 }; 00231 00235 struct csParticleBuffer 00236 { 00238 csParticle* particleData; 00239 00241 csParticleAux* particleAuxData; 00242 00244 size_t particleCount; 00245 }; 00246 00251 struct iParticleEmitter : public virtual iBase 00252 { 00253 SCF_INTERFACE(iParticleEmitter,1,0,0); 00254 00259 virtual void SetEnabled (bool enabled) = 0; 00260 00264 virtual bool GetEnabled () const = 0; 00265 00272 virtual void SetStartTime (float time) = 0; 00273 00277 virtual float GetStartTime () const = 0; 00278 00286 virtual void SetDuration (float time) = 0; 00287 00291 virtual float GetDuration () const = 0; 00292 00296 virtual void SetEmissionRate (float particlesPerSecond) = 0; 00297 00301 virtual float GetEmissionRate () const = 0; 00302 00307 virtual void SetInitialTTL (float min, float max) = 0; 00308 00312 virtual void GetInitialTTL (float& min, float& max) const= 0; 00313 00318 virtual void SetInitialMass (float min, float max) = 0; 00319 00323 virtual void GetInitialMass (float& min, float& max) const = 0; 00324 00328 virtual csPtr<iParticleEmitter> Clone () const = 0; 00329 00333 virtual size_t ParticlesToEmit (iParticleSystemBase* system, 00334 float dt, float totalTime) = 0; 00335 00339 virtual void EmitParticles (iParticleSystemBase* system, 00340 const csParticleBuffer& particleBuffer, float dt, float totalTime, 00341 const csReversibleTransform* const emitterToParticle = 0) = 0; 00342 00343 }; 00344 00350 struct iParticleEffector : public virtual iBase 00351 { 00352 SCF_INTERFACE(iParticleEffector,1,0,0); 00353 00357 virtual csPtr<iParticleEffector> Clone () const = 0; 00358 00362 virtual void EffectParticles (iParticleSystemBase* system, 00363 const csParticleBuffer& particleBuffer, float dt, float totalTime) = 0; 00364 }; 00365 00366 00373 struct iParticleSystemBase : public virtual iBase 00374 { 00375 SCF_INTERFACE(iParticleSystemBase, 1,0,0); 00376 00378 virtual void SetParticleRenderOrientation (csParticleRenderOrientation o) = 0; 00379 00381 virtual csParticleRenderOrientation GetParticleRenderOrientation () const = 0; 00382 00384 virtual void SetRotationMode (csParticleRotationMode mode) = 0; 00385 00387 virtual csParticleRotationMode GetRotationMode () const = 0; 00388 00390 virtual void SetSortMode (csParticleSortMode mode) = 0; 00391 00393 virtual csParticleSortMode GetSortMode () const = 0; 00394 00396 virtual void SetIntegrationMode (csParticleIntegrationMode mode) = 0; 00397 00399 virtual csParticleIntegrationMode GetIntegrationMode () = 0; 00400 00402 virtual void SetCommonDirection (const csVector3& direction) = 0; 00403 00405 virtual const csVector3& GetCommonDirection () const = 0; 00406 00408 virtual void SetTransformMode (csParticleTransformMode mode) = 0; 00409 00411 virtual csParticleTransformMode GetTransformMode () const = 0; 00412 00414 virtual void SetUseIndividualSize (bool individual) = 0; 00415 00417 virtual bool GetUseIndividualSize () const = 0; 00418 00420 virtual void SetParticleSize (const csVector2& size) = 0; 00421 00423 virtual const csVector2& GetParticleSize () const = 0; 00424 00426 virtual void SetMinBoundingBox (const csBox3& box) = 0; 00427 00429 virtual const csBox3& GetMinBoundingBox () const = 0; 00430 00432 virtual void AddEmitter (iParticleEmitter* emitter) = 0; 00433 00435 virtual iParticleEmitter* GetEmitter (size_t index) const = 0; 00436 00438 virtual void RemoveEmitter (size_t index) = 0; 00439 00441 virtual size_t GetEmitterCount () const = 0; 00442 00444 virtual void AddEffector (iParticleEffector* effector) = 0; 00445 00447 virtual iParticleEffector* GetEffector (size_t index) const = 0; 00448 00450 virtual void RemoveEffector (size_t index) = 0; 00451 00453 virtual size_t GetEffectorCount () const = 0; 00454 00455 }; 00456 00457 00461 struct iParticleSystemFactory : public iParticleSystemBase 00462 { 00463 SCF_INTERFACE(iParticleSystemFactory,1,0,0); 00464 00469 virtual void SetDeepCreation (bool deep) = 0; 00470 00472 virtual bool GetDeepCreation () const = 0; 00473 }; 00474 00475 00479 struct iParticleSystem : public iParticleSystemBase 00480 { 00481 SCF_INTERFACE(iParticleSystem,1,0,1); 00482 00484 virtual size_t GetParticleCount () const = 0; 00485 00487 virtual csParticle* GetParticle (size_t index) = 0; 00488 00490 virtual csParticleAux* GetParticleAux (size_t index) = 0; 00491 00496 virtual csParticleBuffer* LockForExternalControl (size_t maxParticles) = 0; 00497 00505 virtual void Advance (csTicks time) = 0; 00506 }; 00507 00508 00514 00515 enum csParticleBuiltinEmitterPlacement 00516 { 00518 CS_PARTICLE_BUILTIN_CENTER, 00520 CS_PARTICLE_BUILTIN_VOLUME, 00522 CS_PARTICLE_BUILTIN_SURFACE 00523 }; 00524 00525 struct iParticleBuiltinEmitterBase : public iParticleEmitter 00526 { 00527 SCF_INTERFACE(iParticleBuiltinEmitterBase,1,0,0); 00528 00534 virtual void SetPosition (const csVector3& position) = 0; 00535 00537 virtual const csVector3& GetPosition () const = 0; 00538 00540 virtual void SetParticlePlacement (csParticleBuiltinEmitterPlacement place) = 0; 00541 00543 virtual csParticleBuiltinEmitterPlacement GetParticlePlacement () const = 0; 00544 00557 virtual void SetUniformVelocity (bool uniform) = 0; 00558 00560 virtual bool GetUniformVelocity () const = 0; 00561 00563 virtual void SetInitialVelocity (const csVector3& linear, 00564 const csVector3& angular) = 0; 00565 00567 virtual void GetInitialVelocity (csVector3& linear, 00568 csVector3& angular) const = 0; 00569 }; 00570 00571 struct iParticleBuiltinEmitterSphere : public iParticleBuiltinEmitterBase 00572 { 00573 SCF_INTERFACE(iParticleBuiltinEmitterSphere,1,0,0); 00574 00576 virtual void SetRadius (float radius) = 0; 00577 00579 virtual float GetRadius () const = 0; 00580 }; 00581 00582 struct iParticleBuiltinEmitterCone : public iParticleBuiltinEmitterBase 00583 { 00584 SCF_INTERFACE(iParticleBuiltinEmitterCone,1,0,0); 00585 00587 virtual void SetExtent (const csVector3& extent) = 0; 00588 00590 virtual const csVector3& GetExtent () const = 0; 00591 00596 virtual void SetConeAngle (float angle) = 0; 00597 00599 virtual float GetConeAngle () const = 0; 00600 }; 00601 00602 struct iParticleBuiltinEmitterBox : public iParticleBuiltinEmitterBase 00603 { 00604 SCF_INTERFACE(iParticleBuiltinEmitterBox,1,0,0); 00605 00607 virtual void SetBox (const csOBB& box) = 0; 00608 00610 virtual const csOBB& GetBox () const = 0; 00611 }; 00612 00613 struct iParticleBuiltinEmitterCylinder : public iParticleBuiltinEmitterBase 00614 { 00615 SCF_INTERFACE(iParticleBuiltinEmitterCylinder,1,0,0); 00616 00618 virtual void SetRadius (float radius) = 0; 00619 00621 virtual float GetRadius () const = 0; 00622 00624 virtual void SetExtent (const csVector3& extent) = 0; 00625 00627 virtual const csVector3& GetExtent () const = 0; 00628 }; 00629 00633 struct iParticleBuiltinEmitterFactory : public virtual iBase 00634 { 00635 SCF_INTERFACE(iParticleBuiltinEmitterFactory,1,0,0); 00636 00637 virtual csPtr<iParticleBuiltinEmitterSphere> CreateSphere () const = 0; 00638 virtual csPtr<iParticleBuiltinEmitterCone> CreateCone () const = 0; 00639 virtual csPtr<iParticleBuiltinEmitterBox> CreateBox () const = 0; 00640 virtual csPtr<iParticleBuiltinEmitterCylinder> CreateCylinder () const = 0; 00641 }; 00642 00661 struct iParticleBuiltinEffectorForce : public iParticleEffector 00662 { 00663 SCF_INTERFACE(iParticleBuiltinEffectorForce,2,0,0); 00664 00666 virtual void SetAcceleration (const csVector3& acceleration) = 0; 00667 00669 virtual const csVector3& GetAcceleration () const = 0; 00670 00672 virtual void SetForce (const csVector3& force) = 0; 00673 00675 virtual const csVector3& GetForce () const = 0; 00676 00678 virtual void SetRandomAcceleration (const csVector3& magnitude) = 0; 00679 00681 virtual const csVector3& GetRandomAcceleration () const = 0; 00682 }; 00683 00692 struct iParticleBuiltinEffectorLinColor : public iParticleEffector 00693 { 00694 SCF_INTERFACE(iParticleBuiltinEffectorLinColor,1,0,0); 00695 00700 virtual size_t AddColor (const csColor4& color, float endTTL) = 0; 00701 00705 virtual void SetColor (size_t index, const csColor4& color) = 0; 00706 00710 virtual void GetColor (size_t index, csColor4& color, float& endTTL) const = 0; 00711 00715 virtual size_t GetColorCount () const = 0; 00716 }; 00717 00723 enum csParticleBuiltinEffectorVFType 00724 { 00732 CS_PARTICLE_BUILTIN_SPIRAL, 00733 00740 CS_PARTICLE_BUILTIN_RADIALPOINT 00741 }; 00742 00754 struct iParticleBuiltinEffectorVelocityField : public iParticleEffector 00755 { 00756 SCF_INTERFACE(iParticleBuiltinEffectorVelocityField,1,0,0); 00757 00761 virtual void SetType (csParticleBuiltinEffectorVFType type) = 0; 00762 00766 virtual csParticleBuiltinEffectorVFType GetType () const = 0; 00767 00771 virtual void SetFParameter (size_t parameterNumber, float value) = 0; 00772 00776 virtual float GetFParameter (size_t parameterNumber) const = 0; 00777 00781 virtual size_t GetFParameterCount () const = 0; 00782 00786 virtual void SetVParameter (size_t parameterNumber, const csVector3& value) = 0; 00787 00791 virtual csVector3 GetVParameter (size_t parameterNumber) const = 0; 00792 00796 virtual size_t GetVParameterCount () const = 0; 00797 }; 00798 00802 struct iParticleBuiltinEffectorFactory : public virtual iBase 00803 { 00804 SCF_INTERFACE(iParticleBuiltinEffectorFactory,1,0,0); 00805 00806 virtual csPtr<iParticleBuiltinEffectorForce> CreateForce () const = 0; 00807 virtual csPtr<iParticleBuiltinEffectorLinColor> CreateLinColor () const = 0; 00808 virtual csPtr<iParticleBuiltinEffectorVelocityField> CreateVelocityField () const = 0; 00809 }; 00810 00814 #endif // __CS_IMESH_PARTICLES_H__
Generated for Crystal Space by doxygen 1.4.7