ParticlesSimple Plugin  1.0
Efecto de partículas simple, con motor físico por aproximación de Euler.
 Todo Clases Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones 'defines' Páginas
moEffectParticlesSimple.h
Ir a la documentación de este archivo.
1 /*******************************************************************************
2 
3  moEffectParticlesSimple.h
4 
5  ****************************************************************************
6  * *
7  * This source is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This code is distributed in the hope that it will be useful, but *
13  * WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15  * General Public License for more details. *
16  * *
17  * A copy of the GNU General Public License is available on the World *
18  * Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
19  * obtain it by writing to the Free Software Foundation, *
20  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  * *
22  ****************************************************************************
23 
24  Copyright(C) 2006 Fabricio Costa
25 
26  Authors:
27  Fabricio Costa
28 
29  \brief Particles Effect Plugin, Simple Version
30  \todo 1) ColorIn 2) ColorOut 3) BreakIn 4) BreakOut
31  \todo 5) Script general
32  \todo 6) Script por particula ( se ejecuta por cada particula ) ( acceso a eventos [tecla presionada...] )
33  \todo *) movimiento y posicionamieno de particuclas....
34  \todo 7) parametro desfazaje de movimiento??? que sea una opcion...
35  \todo 8) Improve the orientation modes... they dont work correctly
36 
37 
38 *******************************************************************************/
39 
165 #ifndef __MO_EFFECT_PARTICLES_H__
166 #define __MO_EFFECT_PARTICLES_H__
167 
168 #include "moTypes.h"
169 #include "moTimer.h"
170 #include "moTempo.h"
171 #include "moPlugin.h"
172 #include "moTimeManager.h"
173 #include "moFilterManager.h"
174 
175 #define MO_PARTICLES_TRANSLATE_X 0
176 #define MO_PARTICLES_TRANSLATE_Y 1
177 #define MO_PARTICLES_SCALE_X 2
178 #define MO_PARTICLES_SCALE_Y 3
179 
180 
181 
183 
220 };
221 
223 
233 };
234 
251 };
252 
267 };
268 
279 };
280 
281 
292 };
293 
294 static moTextArray TextureModeOptions;
295 
306 };
307 
316 };
317 
328 };
329 
339 };
340 
341 
354 
359 
365 
368 
374 
379 
383 
388 
393 
398 
399 
404 
410 
417 
423 
440 };
441 
442 
443 class moParticlesSimple : public moAbstract {
444 
445  public:
446 
448 
449  Pos3d = moVector3f(0.0,0.0,0.0);
450  Destination = moVector3f(0.0,0.0,0.0);
451  Velocity = moVector3f(0.0,0.0,0.0);
452  Force = moVector3f(0.0,0.0,0.0);
453  U = moVector3f(0.0,0.0,0.0);
454  V = moVector3f(0.0,0.0,0.0);
455  W = moVector3f(0.0,0.0,0.0);
456  dpdt = moVector3f(0.0,0.0,0.0);
457  dvdt = moVector3f(0.0,0.0,0.0);
458  Rotation = moVector3f(0.0,0.0,0.0);
459 
460 
461  Pos = moVector2f(0.0,0.0);
462  TCoord = moVector2f(0.0,0.0);
463  TCoord2 = moVector2f(0.0,0.0);
464  Size = moVector2f(0.0,0.0);
465  TSize = moVector2f(0.0,0.0);
466  TSize2 = moVector2f(0.0,0.0);
467  Color = moVector3f(1.0,1.0,1.0);
468 
469  Mass = 1.0;
470  Alpha = 1.0;
471  Scale = 1.0;
472  ImageProportion = 1.0;
473 
474  Fixed = false;
475  Visible = false;
476  Captured = false;
477 
478  /* Graphics */
479  GLId = -1;
480  GLId2 = -1;
481  pTextureMemory = NULL;
482 
483  MOId = -1;
484 
485  ActualFrame = 0;
486  FrameCount = 0;
487  FramePS = 0;
488 
489  FrameForced = false;
490 
491  MaxAge = 0; //depends on Physics.MaxAge first....
492  Age.Stop();
493 
494  }
495  virtual ~moParticlesSimple() {}
496 
498  moVector3f Pos3d;
499 
501  moVector3f Destination;
502 
504  moVector3f Velocity;
505 
507  moVector3f Force;
508 
510 
512 
517  moVector2f Pos;//relativo a una grilla
518 
520  moVector2f TCoord;
521  moVector2f TCoord2;
522 
524 
529  moVector2f Size;
530 
532  moVector2f TSize;
533  moVector2f TSize2;
534 
536 
540  moVector3f U,V,W;
541 
543  moVector3f dpdt;
544  moVector3f dvdt;
545 
547  double Mass;
548 
550  bool Fixed;
551 
553  bool Visible;
554 
556 
559  bool Captured;
560 
561 
563  double Alpha;
564 
566  double Scale;
567 
569  moVector3f Rotation;
570 
572  MOint GLId;
573  MOint GLId2;
574  moTextureMemory *pTextureMemory;
575 
577  int MOId;
578  MOuint ActualFrame;
579  MOuint FrameCount;
580  MOuint FramePS;
581 
584 
585  moVector3f Color;
586 
588  moTimer Age;
589  long MaxAge;
590 };
591 
592 class moParticlesSimplePhysics : public moAbstract {
593 
594  public:
595 
597  m_GravityCenter = moVector3f(0.0,0.0,0.0);
598  m_GravityVector = moVector3f(0.0,0.0,0.0);
599  m_GravityDisc = moVector3f(0.0,0.0,0.0);
600 
601  m_Plane = moVector3f(0.0,0.0,0.0);
602 
603  m_MaxAge = 0;
604  m_EmitionPeriod = 0;
605  m_EmitionRate = 0;
606  m_DeathPeriod = 0;
607 
612 
613  m_FadeIn = 0.0;
614  m_FadeOut = 0.0;
615  m_SizeIn = 0.0;
616  m_SizeOut = 0.0;
617 
619  m_EmitterSize = moVector3f( 0.0, 0.0, 0.0 );
620  m_EmitterVector = moVector3f( 0.0, 0.0, 0.0 );
621 
624  m_AttractorVector = moVector3f( 0.0, 0.0, 0.0 );
625 
626  m_EyeVector = moVector3f( 0.0, 0.0, 0.0 );
627 
628  m_RandomVelocity = 0.0;
629  m_VelocityVector = moVector3f( 0.0, 0.0, 0.0 );
630 
631  m_RandomPosition = 0.0;
632  m_PositionVector = moVector3f( 0.0, 0.0, 0.0 );
633 
634  m_RandomMotion = 0.0;
635  m_MotionVector = moVector3f( 0.0, 0.0, 0.0 );
636 
637  gravitational = 0.0;
638  viscousdrag = 0.0;
639 
640  EmitionTimer.Stop();
641 
642  m_ParticleScript = moText("");
643 
644  m_pLastBordParticle = NULL;
645 
646 
647  }
649 
650 
651  moVector3f m_GravityCenter;//x,y,z,intensity
652  moVector3f m_GravityVector;//x,y,z,intensity
653  moVector3f m_GravityDisc;//normal x, normal y, normal z,intensity
654 
655  moVector3f m_Plane;
656 
657  long m_MaxAge;
661 
666 
667  double m_FadeIn;
668  double m_FadeOut;
669  double m_SizeIn;
670  double m_SizeOut;
671 
673  moVector3f m_EmitterVector;
674  moVector3f m_EmitterSize;
675 
678  moVector3f m_AttractorVector;
679 
680  moVector3f m_EyeVector;
681 
683  moVector3f m_VelocityVector;
684 
686  moVector3f m_PositionVector;
687 
689  moVector3f m_MotionVector;
690 
692  double viscousdrag;
693 
694  moTimer EmitionTimer;
695 
697 
699 
700 
701 
702 
703 };
704 
705 
707 
714 };
715 
716 
717 
718 moDeclareDynamicArray( moParticlesSimple*, moParticlesSimpleArray );
719 
720 typedef std::map< double, moParticlesSimple* > TMapDepthToParticleSimple;
721 
722 
724 
743 class moEffectParticlesSimple : public moEffect
744 {
745  public:
746 
749 
751  virtual ~moEffectParticlesSimple();
752 
754  MOboolean Init();
755 
757  void Draw(moTempo*, moEffectState* parentstate = NULL);
758 
760  MOboolean Finish();
761 
763  void ReInit();
764 
766  void Shot( moText source = moText(""), int shot_type = 0, int shot_file=0 );
767 
769  void Interaction( moIODeviceManager * );
770 
772  void Update( moEventList * p_eventlist);
773 
775  moConfigDefinition * GetDefinition( moConfigDefinition *p_configdefinition );
776 
778  int ScriptCalling(moLuaVirtualMachine& vm, int iFunctionNumber);
779 
780  void TrackParticle( int partid );
781 
782  void OrderParticles();
783 
784  private:
785 
787  void UpdateDt();
788 
790  void UpdateParameters();
791 
793  void ResetTimers();
795  void RevealingAll();
797  void RestoringAll();
798 
800  void InitParticlesSimple( int p_cols, int p_rows , bool p_forced = true );
801 
803  void CalculateForces( bool tmparray = false );
804 
806  void CalculateDerivatives( bool tmparray = false, double dt = 0.0 );
807 
809 
819  void UpdateParticles( double dt, int method );
820 
822 
834  void Regenerate();
835 
837  double Solver1D( double h, double y0, int method, double (*fcn)(double) );
838 
840  void SetParticlePosition( moParticlesSimple* pParticle );
841 
842 
843  void ParticlesSimpleInfluence( float posx, float posy, float velx, float vely, float veln );
844  void ParticlesSimpleAnimation( moTempo* tempogral, moEffectState* parentstate );
845 
847  void DrawParticlesSimple( moTempo* tempogral, moEffectState* parentstate );
848  void DrawTracker();
849 
851  void RegisterFunctions();
852 
853  int luaGetDelta(moLuaVirtualMachine& vm);
854  int luaGetParticleCount(moLuaVirtualMachine& vm);
855  int luaGetParticle(moLuaVirtualMachine& vm);
856  int luaGetParticlePosition(moLuaVirtualMachine& vm);
857  int luaGetParticleSize(moLuaVirtualMachine& vm);
858  int luaGetParticleScale(moLuaVirtualMachine& vm);
859  int luaGetParticleVelocity(moLuaVirtualMachine& vm);
860  int luaGetParticleRotation(moLuaVirtualMachine& vm);
861  int luaGetParticleGraphics(moLuaVirtualMachine& vm);
862 
863  int luaUpdateParticle( moLuaVirtualMachine& vm );
864  int luaUpdateParticlePosition( moLuaVirtualMachine& vm );
865  int luaUpdateParticleSize( moLuaVirtualMachine& vm );
866  int luaUpdateParticleScale( moLuaVirtualMachine& vm );
867  int luaUpdateParticleVelocity( moLuaVirtualMachine& vm );
868  int luaUpdateParticleRotation( moLuaVirtualMachine& vm );
869  int luaUpdateParticleGraphics( moLuaVirtualMachine& vm );
870 
871  int luaUpdateForce( moLuaVirtualMachine& vm );
872 
873  int luaShot(moLuaVirtualMachine& vm);
874  int luaReInit(moLuaVirtualMachine& vm);
875 
876  int luaDrawPoint(moLuaVirtualMachine& vm);
877  int luaGetParticleIntersection(moLuaVirtualMachine& vm);
878 
880 
881  moInlet* m_pParticleTime;
882  moInlet* m_pParticleIndex;
883 
884  moParticlesSimpleArray m_ParticlesSimpleArray;
885  moParticlesSimpleArray m_ParticlesSimpleArrayTmp;
886  moParticlesSimplePhysics m_Physics;
887 
888  bool m_bTrackerInit;
889 
890  moTrackerSystemData* m_pTrackerData;
891  MOint m_InletTrackerSystemIndex;
892 
893  #ifdef USE_TUIO
894  moTUIOSystemData* m_pTUIOData;
895  MOint m_InletTuioSystemIndex;
896  #endif
897 
898 
899 
900  moVector2f m_TrackerBarycenter;
901 
902 
903  void setUpLighting();
904 
905  int m_rows,m_cols;
906  float normalf;
907 
908  long time_tofull_revelation;
909  long time_tofull_restoration;
910  long time_of_revelation;
911  long time_of_restoration;
912  long drawing_features;
913  long texture_mode;
914 
915 
916 
917  bool ortho;
918 
920  moTimer MotionTimer;
921 
922  moTimer TimerFullRevelation;
923  moTimer TimerFullRestoration;
924  moTimer TimerOfRevelation;
925  moTimer TimerOfRestoration;
926 
927  moTimer FeatureActivity;
928  moTimer MotionActivity;
929  moTimer NoMotionActivity;
930 
931  enumRevelationStatus revelation_status;
932 
933  long m_Rate;
934 
935  long last_tick;
936 
937  //special for script
938  moTexture* pTextureDest;
939  moTexture* pSubSample;
940  MObyte* samplebuffer;
941 
942  int glidori;
943  int glid;
944  int frame;
945 
946  int original_width;
947  int original_height;
948  float original_proportion;
949 
950  float emiper;
951  long emiperi;
952 
953  float midi_red, midi_green, midi_blue;
954  float midi_maxage; //in millis
955  float midi_emitionperiod;//in millisec
956  float midi_emitionrate; // n per emitionperiod
957  float midi_randomvelocity; //inicial vel
958  float midi_randommotion; //motion dynamic
959 
960  float tx,ty,tz;
961  float sx,sy,sz;
962  float rx,ry,rz;
963 
964  TMapDepthToParticleSimple m_OrderedParticles;
965 
966  double dtrel;
967  double dt;
968  long gral_ticks;
969 
970 };
971 
972 class moEffectParticlesSimpleFactory : public moEffectFactory
973 {
974 public:
977  moEffect* Create();
978  void Destroy(moEffect* fx);
979 };
980 
981 extern "C"
982 {
983 MO_PLG_API moEffectFactory* CreateEffectFactory();
984 MO_PLG_API void DestroyEffectFactory();
985 }
986 
987 #endif
2: Volumétrico. Los lugares de nacimientos están diseminados dentro del volumen del emisor aleatoriam...
moVector3f U
particle orientation
moParticlesCreationMethod
Creation Method.
2: Many Different Textures Image for each Particle ( taken from texturefolder )
1: accelerate, reach and stop instantly
double Alpha
Transparency of the particle.
void Interaction(moIODeviceManager *)
Interacción.
moParticlesCreationMethod m_CreationMethod
5: each particle attract each one to a dot of the tracker
MO_PLG_API void DestroyEffectFactory()
moParticlesSimpleFolderShotType
Folder Shot Type.
1: Esfera (una esfera de "width" longitudes y "height" latitudes) 3D
double Mass
Mass in g of the particle.
virtual ~moEffectParticlesSimple()
Destructor.
MOboolean Init()
Inicialización.
3: complete view dependent ordering >
0: One Same Texture Image for each Particle (taken from texture)
2: 2: Tubo ( un tubo de "width" facetas y "height" segmentos) 3D
moVector3f Pos3d
Position absolute.
1: Superficial. Los lugares de nacimientos están diseminados sobre la superficie del emisor aleatoria...
3: Line shape emitter (3d) vector line (x,y,z)
moEffectParticlesSimple
moParticlesSimpleTextureMode
Texture Mode.
moTimer Age
Age of the particle.
6: each particle attract each one to a dot of the tracker
0: Alineado. Los lugares de nacimientos están alineados con el orden de los vertices del emisor...
4: each particle attract perpendicular to jet vector
0: Grilla (un rectángulo de "width" x "height") 2D
moParticlesSimpleAttractorMode
Attractor Mode.
moVector2f TSize
particle texture size
2: accelerate and bounce....(inverse direction)
moParticlesSimpleEmitterType m_EmitterType
1: each particle attract perp to a face of the grid
0: las partículas son atraídas entre ellas
moVector2f Size
particle size
4: accelerate then brake and slowdown slowly
moParticlesSimpleBehaviourMode
Behaviour Mode.
0: filename screenshot has a random id
moParticlesSimpleAttractorType m_AttractorType
MOboolean Finish()
Finalizacion.
3: accelerate and breaks (generate debris on place)
5: constant speed to attractortype
0: each particle attract diretly to the same point
moVector3f Velocity
Speed or Velocity vector.
moVector2f Pos
Particles Vectors.
moConfigDefinition * GetDefinition(moConfigDefinition *p_configdefinition)
Definicion de campos.
moTextureMemory * pTextureMemory
moDeclareDynamicArray(moParticlesSimple *, moParticlesSimpleArray)
8: Círculo ( una ronda de "width"X"height" partículas )
moParticlesSimple * m_pLastBordParticle
moParticlesRandomMethod
Random Method.
moParticlesSimpleEmitterType
Emitter Type.
moParticlesSimpleAttractorMode m_AttractorMode
1: Same Texture Image Divided In Different Fragments for each Particle (taken from texture...
float ImageProportion
Texture image proportion Width / Height ....
MOint GLId2
para asociar la textura al momento de la creación
1: las partículas son libres y mantienen una distancia mínima de separación
2: each particle attract perp to a face of the grid
void Shot(moText source=moText(""), int shot_type=0, int shot_file=0)
Foto de la cámara.
void Update(moEventList *p_eventlist)
Actualización del ciclo de eventos.
moVector3f Rotation
Angle of the particle.
3: las partículas se alinean y acomodan cristalmente
3: each particle attract perp to a face of the grid
2: las partículas son repelidas entre ellas
moVector3f Destination
Destination.
moParticlesRandomMethod m_RandomMethod
moParticlesSimpleParamIndex
void ReInit()
Reiniciar el analisis de la imagen.
moVector3f dpdt
Differentials of position (speed) and velocity (acceleration)
moParticlesOrientationMode m_OrientationMode
5: Trackeador ( reservado para información de sensado )
MOint GLId
Unique ID of OpenGL Texture.
6: Trackeador2 ( reservado para información de sensado )
0: 0: no reordering for drawing
2: zposition -> simple order relative to particle Z calculated position
4: Punto ( colapsados en un punto )
int ScriptCalling(moLuaVirtualMachine &vm, int iFunctionNumber)
Llamada de scripts.
3: Many textures/particle to construct a patched texture one ( taken from texturefolder, build the one defined on texture parameter, or from a folder, call to Shot(source) then ReInit to build... )
double Scale
Scale of the particle.
std::map< double, moParticlesSimple * > TMapDepthToParticleSimple
bool Visible
Exists but is invisible.
moVector2f TCoord
texture coordinate
moParticlesSimpleAttractorType
Attractor Type.
MO_PLG_API moEffectFactory * CreateEffectFactory()
moParticlesOrderingMode m_OrderingMode
moVector3f Force
Self force (propulsion) of the particle.
7: Espiral ( forma de espiral, "width" ángulos que forman "height" ciclos )
3: Central. Los lugares de nacimiento están colapsados en el centro del emisor.
void Draw(moTempo *, moEffectState *parentstate=NULL)
Dibujado.
moParticlesOrderingMode
moParticlesOrientationMode
Orientation Method.