00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _SO_PARTICLE_ANIMATION_
00027 #define _SO_PARTICLE_ANIMATION_
00028
00029 #include <Inventor/nodes/SoShape.h>
00030
00031 #include <Inventor/fields/SoSFEnum.h>
00032 #include <Inventor/fields/SoSFInt32.h>
00033 #include <Inventor/fields/SoSFColor.h>
00034 #include <Inventor/fields/SoSFFloat.h>
00035 #include <Inventor/fields/SoSFVec2f.h>
00036 #include <Inventor/fields/SoSFVec3f.h>
00037 #include <Inventor/fields/SoSFFilePathString.h>
00038 #include <Inventor/fields/SoSFImage.h>
00039 #include <Inventor/fields/SoSFTrigger.h>
00040 #include <Inventor/fields/SoSFBool.h>
00041
00042 #include <Inventor/nodes/SoTexture2.h>
00043
00044 class CParticle;
00045 class CPoint3D;
00046 class CVector3D;
00047 class CMatrix;
00048 class CParticleList;
00049 class SbPParticleList;
00050
00051
00052
00053 class SoGetPrimitiveCountAction ;
00054 class SoGLRenderAction ;
00055 class SoSensor ;
00056 class SoFieldSensor ;
00057 class SoOneShotSensor ;
00058
00059
00060
00061 class SoDEPRECATED SoParticleAnimation : public SoShape {
00168
00169 SO_NODE_HEADER(SoParticleAnimation);
00170
00171 public:
00175 enum ParticleShape {
00179 POINT_SHAPE,
00183 LINE_SHAPE,
00188 BILLBOARD_SHAPE
00189 };
00190
00194 enum EmitShapeType {
00198 POINT,
00202 CYLINDER,
00206 LINE,
00210 SQUARE,
00214 SPHERE,
00218 CIRCLE,
00222 DISK,
00226 GEOMETRY
00227 };
00228
00232 enum ParticleLife {
00236 ONE_EMISSION,
00240 CYCLIC_EMISSION
00241 };
00242
00246 enum TransparencyType {
00250 ADD,
00254 BLEND,
00258 INHERITED
00259 };
00260
00264 SoParticleAnimation();
00265
00269 SoSFInt32 numParticles;
00270
00276 SoSFFloat numParticlesVariation;
00277
00281 SoSFColor initialColor;
00282
00288 SoSFVec3f initialColorVariation;
00289
00295 SoSFFloat initialOpacity;
00296
00302 SoSFFloat initialOpacityVariation;
00303
00307 SoSFFloat initialSize;
00308
00314 SoSFFloat initialSizeVariation;
00315
00319 SoSFColor endColor;
00320
00326 SoSFVec3f endColorVariation;
00327
00333 SoSFFloat endOpacity;
00334
00340 SoSFFloat endOpacityVariation;
00341
00345 SoSFFloat endSize;
00346
00352 SoSFFloat endSizeVariation;
00353
00357 SoSFInt32 lifeSpan;
00358
00364 SoSFFloat lifeSpanVariation;
00365
00370 SoSFEnum particleShape;
00371
00394 SoSFEnum emitShapeType;
00395
00401 SoSFVec3f shapeScale;
00402
00411 SoSFVec2f dispersionAngles;
00412
00419 SoSFEnum particleLife;
00420
00424 SoSFFloat speed;
00425
00431 SoSFFloat speedVariation;
00432
00445 SoSFFilePathString particleFilename;
00446
00455 SoSFImage particleTexture;
00456
00466 SoSFFloat goalFramesPerSecond;
00467
00475 SoSFTrigger trigger;
00476
00480 SoSFEnum transparencyType;
00481
00485 SoSFBool on;
00486
00487
00488
00489 private:
00490 virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er);
00491 virtual void rayPick(SoRayPickAction *action);
00492 virtual void GLRender(SoGLRenderAction *action);
00493
00494 private:
00495 static void initClass();
00496 static void exitClass() ;
00497
00498 private:
00499 void init(void);
00500
00501 virtual ~SoParticleAnimation();
00502
00503 virtual void generatePrimitives(SoAction *action);
00504
00505 void loadTexture();
00506
00507 private:
00508
00509 void update(unsigned long currentTime);
00510 void initParticle(CParticle *p, unsigned long time);
00511 void getRandomPositionAndDirectionInShape(CPoint3D *position, CVector3D *direction);
00512 void rotationToDirection(float pitch, float yaw, CVector3D *dir);
00513
00514
00515 void renderPoints();
00516 void renderLines();
00517 void renderBillboards();
00518
00519 static void timerSensorCB(void *data, SoSensor *);
00520
00521
00522 SbPParticleList *m_deadParticles;
00523
00524 SbPParticleList *m_aliveParticles;
00525
00526 float m_emissionResidue;
00527
00528
00529 SbBool pickingBoundingBox;
00530
00531
00532 unsigned long m_currentTime;
00533 unsigned long m_lastTime;
00534
00535
00536 GLuint m_handle;
00537
00538
00539 SbMatrix curModelMatrix;
00540
00541
00542
00543 static void imageChangedCB(void *, SoSensor *);
00544 static void filenameChangedCB(void *, SoSensor *);
00545
00546
00547 static void triggerFunc(void *data, SoSensor *);
00548
00549
00550 SoFieldSensor *m_imageSensor;
00551 SoFieldSensor *m_filenameSensor;
00552
00553 SbBool m_textureLoaded;
00554
00555 SoFieldSensor *m_triggerSensor;
00556
00557
00558 SoTimerSensor *m_timerSensor;
00559 SoOneShotSensor* m_oneShotSensor ;
00560
00561
00562 int32_t m_prevCacheContext;
00563
00564 int m_alreadyTriggered;
00565 };
00566
00567
00568 #endif // _SO_PARTICLE_ANIMATION_
00569
00570