## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# imesh/particles.h

Go to the documentation of this file.

    00001 /*
    00002     Copyright (C) 2003 by Jorrit Tyberghein, John Harger, Daniel Duhprey
    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.h"
    00023
    00024 #include "csgeom/vector3.h"
    00025 #include "csgeom/vector4.h"
    00026 #include "csutil/array.h"
    00027 #include "csutil/cscolor.h"
    00028
    00036 struct iMaterialWrapper;
    00037
    00038 class csColor;
    00039 class csMatrix3;
    00040 class csReversibleTransform;
    00041
    00043 enum csParticleFalloffType
    00044 {
    00045   CS_PART_FALLOFF_CONSTANT,
    00046   CS_PART_FALLOFF_LINEAR,
    00047   CS_PART_FALLOFF_PARABOLIC
    00048 };
    00049
    00051 enum csParticleColorMethod
    00052 {
    00053   CS_PART_COLOR_CONSTANT,
    00054   CS_PART_COLOR_LINEAR,
    00055   CS_PART_COLOR_LOOPING,
    00056   CS_PART_COLOR_HEAT,
    00057   CS_PART_COLOR_CALLBACK
    00058 };
    00059
    00061 enum csParticleEmitType
    00062 {
    00063   CS_PART_EMIT_SPHERE,
    00064   CS_PART_EMIT_PLANE,
    00065   CS_PART_EMIT_BOX,
    00066   CS_PART_EMIT_CYLINDER
    00067 };
    00068
    00070 enum csParticleForceType
    00071 {
    00072   CS_PART_FORCE_RADIAL,
    00073   CS_PART_FORCE_LINEAR,
    00074   CS_PART_FORCE_CONE
    00075 };
    00076
    00078 struct csParticlesData
    00079 {
    00080   csVector3 position;
    00081   csVector4 color;
    00082   csVector3 velocity;
    00083   float mass;
    00084   float time_to_live;
    00085   float sort;
    00086 };
    00087
    00088 SCF_VERSION (iParticlesColorCallback, 0, 0, 1);
    00089
    00095 struct iParticlesColorCallback : public iBase
    00096 {
    00102   virtual csColor GetColor (float time) = 0;
    00103 };
    00104
    00105 SCF_VERSION (iParticlesStateBase, 1, 1, 0);
    00106
    00110 struct iParticlesStateBase : public iBase
    00111 {
    00113   virtual void SetParticlesPerSecond (int count) = 0;
    00114
    00116   virtual int GetParticlesPerSecond () = 0;
    00117
    00119   virtual void SetInitialParticleCount (int count) = 0;
    00120
    00122   virtual int GetInitialParticleCount () = 0;
    00123
    00125   virtual void SetPointEmitType () = 0;
    00126
    00128   virtual void SetSphereEmitType (float outer_radius, float inner_radius) = 0;
    00129
    00131   virtual void SetPlaneEmitType (float x_size, float y_size) = 0;
    00132
    00134   virtual void SetBoxEmitType (float x_size, float y_size, float z_size) = 0;
    00135
    00137   virtual void SetCylinderEmitType (float radius, float height) = 0;
    00138
    00140   virtual float GetSphereEmitInnerRadius () = 0;
    00141
    00143   virtual float GetSphereEmitOuterRadius () = 0;
    00144
    00146   virtual float GetEmitXSize () = 0;
    00147
    00149   virtual float GetEmitYSize () = 0;
    00150
    00152   virtual float GetEmitZSize () = 0;
    00153
    00155   virtual csParticleEmitType GetEmitType () = 0;
    00156
    00158   virtual void SetRadialForceType (float range, csParticleFalloffType) = 0;
    00159
    00161   virtual void SetLinearForceType (const csVector3 &direction,
    00162         const csVector3& direction_variation, float range,
    00163         csParticleFalloffType falloff) = 0;
    00164
    00166   virtual void SetConeForceType (const csVector3 &direction,
    00167         const csVector3& direction_variation, float range,
    00168         csParticleFalloffType falloff, float radius,
    00169         csParticleFalloffType radius_falloff) = 0;
    00170
    00172   virtual csParticleForceType GetForceType () = 0;
    00173
    00175   virtual float GetForceRange () = 0;
    00176
    00178   virtual void GetFalloffType (csParticleFalloffType &force,
    00179     csParticleFalloffType &cone) = 0;
    00180
    00182   virtual void GetForceDirection (csVector3 &dir) = 0;
    00183
    00185   virtual void GetForceDirectionVariation (csVector3 &dirvar) = 0;
    00186
    00188   virtual float GetForceConeRadius () = 0;
    00189
    00191   virtual void SetForce (float force) = 0;
    00192
    00194   virtual float GetForce () = 0;
    00195
    00197   virtual void SetDiffusion (float size) = 0;
    00198
    00200   virtual float GetDiffusion () = 0;
    00201
    00203   virtual void SetGravity (const csVector3 &gravity) = 0;
    00204
    00206   virtual void GetGravity (csVector3 &gravity) = 0;
    00207
    00209   virtual void SetEmitTime (float time) = 0;
    00210
    00212   virtual float GetEmitTime () = 0;
    00213
    00215   virtual void SetTimeToLive (float time) = 0;
    00216
    00218   virtual float GetTimeToLive () = 0;
    00219
    00221   virtual void SetTimeVariation (float variation) = 0;
    00222
    00224   virtual float GetTimeVariation () = 0;
    00225
    00227   virtual void SetConstantColorMethod (csColor4 color) = 0;
    00228
    00234   virtual void SetLinearColorMethod () = 0;
    00235
    00240   virtual void SetLoopingColorMethod (float seconds) = 0;
    00241
    00246   virtual void SetHeatColorMethod (int base_temp) = 0;
    00247
    00249   virtual void SetColorCallback (iParticlesColorCallback*) = 0;
    00250
    00252   virtual iParticlesColorCallback* GetColorCallback () = 0;
    00253
    00255   virtual void AddColor (csColor4 color) = 0;
    00256
    00258   virtual void ClearColors () = 0;
    00259
    00261   virtual csParticleColorMethod GetParticleColorMethod () = 0;
    00262
    00264   virtual void GetConstantColor (csColor4& color) = 0;
    00265
    00267   virtual const csArray<csColor4> &GetGradient () = 0;
    00268
    00270   virtual float GetColorLoopTime () = 0;
    00271
    00273   virtual float GetBaseHeat () = 0;
    00274
    00276   virtual void SetParticleRadius (float radius) = 0;
    00277
    00279   virtual float GetParticleRadius () = 0;
    00280
    00282   virtual void SetDampener (float damp) = 0;
    00283
    00285   virtual float GetDampener () = 0;
    00286
    00288   virtual void SetMass(float mass) = 0;
    00289
    00291   virtual void SetMassVariation (float variation) = 0;
    00292
    00294   virtual float GetMass () = 0;
    00295
    00297   virtual float GetMassVariation () = 0;
    00298
    00300   virtual void SetTransformMode (bool transform) = 0;
    00301
    00303   virtual bool GetTransformMode () = 0;
    00304
    00306   virtual void SetMixMode (uint mode) = 0;
    00308   virtual uint GetMixMode () const = 0;
    00309
    00316   virtual void EnableZSort (bool en) = 0;
    00320   virtual bool IsZSortEnabled () const = 0;
    00321 };
    00322
    00323
    00324 SCF_VERSION (iParticlesObjectState, 1, 0, 1);
    00325
    00329 struct iParticlesObjectState : public iParticlesStateBase
    00330 {
    00332   virtual void GetEmitPosition (csVector3 &position) = 0;
    00333
    00335   virtual const csMatrix3 &GetRotation () = 0;
    00336
    00338   virtual csReversibleTransform GetObjectToCamera () = 0;
    00339
    00344   virtual void ChangePhysicsPlugin (const char *plugin) = 0;
    00345
    00351   virtual void Start () = 0;
    00352
    00354   virtual void Stop () = 0;
    00355
    00357   virtual bool IsRunning () = 0;
    00358 };
    00359
    00360 SCF_VERSION (iParticlesFactoryState, 1, 0, 1);
    00361
    00365 struct iParticlesFactoryState : public iParticlesStateBase
    00366 {
    00368   virtual void SetMaterial (iMaterialWrapper *material) = 0;
    00369
    00371   virtual void SetAutoStart (bool autostart) = 0;
    00372
    00377   virtual void SetPhysicsPlugin (const char *plugin) = 0;
    00378 };
    00379
    00380
    00381 SCF_VERSION (iParticlesPhysics, 0, 1, 0);
    00382
    00386 struct iParticlesPhysics : public iBase
    00387 {
    00391   virtual const csArray<csParticlesData> *RegisterParticles (
    00392         iParticlesObjectState *particles) = 0;
    00393
    00397   virtual void RemoveParticles (iParticlesObjectState *particles) = 0;
    00398
    00400   virtual void Start (iParticlesObjectState *particles) = 0;
    00401
    00403   virtual void Stop (iParticlesObjectState *particles) = 0;
    00404 };
    00405
    00408 #endif // __CS_IMESH_PARTICLES_H__