45 if(m_EffectParticlesSimpleFactory==NULL)
47 return(moEffectFactory*) m_EffectParticlesSimpleFactory;
51 delete m_EffectParticlesSimpleFactory;
52 m_EffectParticlesSimpleFactory = NULL;
68 SetName(
"particlessimple");
82 p_configdefinition = moEffect::GetDefinition( p_configdefinition );
86 p_configdefinition->Add( moText(
"font"), MO_PARAM_FONT,
PARTICLES_FONT, moValue(
"Default",
"TXT",
"0",
"NUM",
"32.0",
"NUM") );
87 p_configdefinition->Add( moText(
"text"), MO_PARAM_TEXT,
PARTICLES_TEXT, moValue(
"Insert text in text parameter",
"TXT") );
88 p_configdefinition->Add( moText(
"ortho"), MO_PARAM_NUMERIC,
PARTICLES_ORTHO, moValue(
"0",
"NUM").Ref() );
91 p_configdefinition->Add( moText(
"texture"), MO_PARAM_TEXTURE,
PARTICLES_TEXTURE, moValue(
"default",
"TXT") );
92 p_configdefinition->Add( moText(
"folders"), MO_PARAM_TEXTUREFOLDER,
PARTICLES_FOLDERS, moValue(
"",
"TXT") );
94 p_configdefinition->Add( moText(
"texture_mode"), MO_PARAM_NUMERIC,
PARTICLES_TEXTUREMODE, moValue(
"0",
"NUM"), moText(
"UNIT,PATCH,MANY,MANY2PATCH"));
96 p_configdefinition->Add( moText(
"blending"), MO_PARAM_BLENDING,
PARTICLES_BLENDING, moValue(
"0",
"NUM") );
97 p_configdefinition->Add( moText(
"width"), MO_PARAM_NUMERIC,
PARTICLES_WIDTH, moValue(
"9",
"NUM") );
98 p_configdefinition->Add( moText(
"height"), MO_PARAM_NUMERIC,
PARTICLES_HEIGHT, moValue(
"9",
"NUM") );
100 p_configdefinition->Add( moText(
"sizex"), MO_PARAM_FUNCTION,
PARTICLES_SIZEX, moValue(
"10.0",
"FUNCTION").Ref() );
101 p_configdefinition->Add( moText(
"sizey"), MO_PARAM_FUNCTION,
PARTICLES_SIZEY, moValue(
"10.0",
"FUNCTION").Ref() );
102 p_configdefinition->Add( moText(
"sizez"), MO_PARAM_FUNCTION,
PARTICLES_SIZEY, moValue(
"10.0",
"FUNCTION").Ref() );
104 p_configdefinition->Add( moText(
"gravity"), MO_PARAM_FUNCTION,
PARTICLES_GRAVITY, moValue(
"0.0",
"FUNCTION").Ref() );
105 p_configdefinition->Add( moText(
"viscosity"), MO_PARAM_FUNCTION,
PARTICLES_VISCOSITY, moValue(
"0.8",
"FUNCTION").Ref() );
107 p_configdefinition->Add( moText(
"maxage"), MO_PARAM_FUNCTION,
PARTICLES_MAXAGE, moValue(
"3000",
"FUNCTION").Ref() );
108 p_configdefinition->Add( moText(
"emitionperiod"), MO_PARAM_FUNCTION,
PARTICLES_EMITIONPERIOD, moValue(
"10",
"FUNCTION").Ref() );
110 p_configdefinition->Add( moText(
"emitionrate"), MO_PARAM_FUNCTION,
PARTICLES_EMITIONRATE, moValue(
"1",
"FUNCTION").Ref() );
111 p_configdefinition->Add( moText(
"deathperiod"), MO_PARAM_NUMERIC,
PARTICLES_DEATHPERIOD, moValue(
"1",
"NUM").Ref() );
112 p_configdefinition->Add( moText(
"particlescript"), MO_PARAM_SCRIPT,
PARTICLES_SCRIPT2 );
114 p_configdefinition->Add( moText(
"randommethod"), MO_PARAM_NUMERIC,
PARTICLES_RANDOMMETHOD, moValue(
"0",
"NUM").Ref(), moText(
"NOISY,COLINEAR,PERPENDICULAR") );
115 p_configdefinition->Add( moText(
"creationmethod"), MO_PARAM_NUMERIC,
PARTICLES_CREATIONMETHOD, moValue(
"0",
"NUM").Ref(), moText(
"LINEAR,PLANAR,VOLUMETRIC,CENTER") );
116 p_configdefinition->Add( moText(
"orientationmode"), MO_PARAM_NUMERIC,
PARTICLES_ORIENTATIONMODE, moValue(
"0",
"NUM").Ref(), moText(
"FIXED,CAMERA,MOTION,ACCELERATION") );
118 p_configdefinition->Add( moText(
"fadein"), MO_PARAM_FUNCTION,
PARTICLES_FADEIN, moValue(
"0",
"FUNCTION").Ref() );
119 p_configdefinition->Add( moText(
"fadeout"), MO_PARAM_FUNCTION,
PARTICLES_FADEOUT, moValue(
"0",
"FUNCTION").Ref() );
120 p_configdefinition->Add( moText(
"sizein"), MO_PARAM_FUNCTION,
PARTICLES_SIZEIN, moValue(
"0",
"FUNCTION").Ref() );
121 p_configdefinition->Add( moText(
"sizeout"), MO_PARAM_FUNCTION,
PARTICLES_SIZEOUT, moValue(
"0",
"FUNCTION").Ref() );
125 p_configdefinition->Add( moText(
"attractortype"), MO_PARAM_NUMERIC,
PARTICLES_ATTRACTORTYPE, moValue(
"0",
"NUM").Ref(), moText(
"POINT,GRID,SPHERE,TUBE,JET,TRACKER,VERTEX") );
126 p_configdefinition->Add( moText(
"attractormode"), MO_PARAM_NUMERIC,
PARTICLES_ATTRACTORMODE, moValue(
"0",
"NUM").Ref(), moText(
"ACCELERATION,STICK,BOUNCE,BREAKS,BRAKE,LINEAR") );
127 p_configdefinition->Add( moText(
"attractorvectorx"), MO_PARAM_FUNCTION,
PARTICLES_ATTRACTORVECTOR_X, moValue(
"0",
"FUNCTION").Ref() );
128 p_configdefinition->Add( moText(
"attractorvectory"), MO_PARAM_FUNCTION,
PARTICLES_ATTRACTORVECTOR_Y, moValue(
"0",
"FUNCTION").Ref() );
129 p_configdefinition->Add( moText(
"attractorvectorz"), MO_PARAM_FUNCTION,
PARTICLES_ATTRACTORVECTOR_Z, moValue(
"0",
"FUNCTION").Ref() );
131 p_configdefinition->Add( moText(
"emittertype"), MO_PARAM_NUMERIC,
PARTICLES_EMITTERTYPE, moValue(
"0",
"NUM").Ref(), moText(
"GRID,SPHERE,TUBE,JET,POINT,TRACKER,TRACKER2,SPIRAL,CIRCLE") );
132 p_configdefinition->Add( moText(
"emittervectorx"), MO_PARAM_FUNCTION,
PARTICLES_EMITTERVECTOR_X, moValue(
"0",
"FUNCTION").Ref() );
133 p_configdefinition->Add( moText(
"emittervectory"), MO_PARAM_FUNCTION,
PARTICLES_EMITTERVECTOR_Y, moValue(
"0",
"FUNCTION").Ref() );
134 p_configdefinition->Add( moText(
"emittervectorz"), MO_PARAM_FUNCTION,
PARTICLES_EMITTERVECTOR_Z, moValue(
"0",
"FUNCTION").Ref() );
137 p_configdefinition->Add( moText(
"randomposition"), MO_PARAM_FUNCTION,
PARTICLES_RANDOMPOSITION, moValue(
"0",
"FUNCTION").Ref() );
138 p_configdefinition->Add( moText(
"randompositionx"), MO_PARAM_FUNCTION,
PARTICLES_RANDOMPOSITION_X, moValue(
"0",
"FUNCTION").Ref() );
139 p_configdefinition->Add( moText(
"randompositiony"), MO_PARAM_FUNCTION,
PARTICLES_RANDOMPOSITION_Y, moValue(
"0",
"FUNCTION").Ref() );
140 p_configdefinition->Add( moText(
"randompositionz"), MO_PARAM_FUNCTION,
PARTICLES_RANDOMPOSITION_Y, moValue(
"0",
"FUNCTION").Ref() );
142 p_configdefinition->Add( moText(
"randomvelocity"), MO_PARAM_FUNCTION,
PARTICLES_RANDOMVELOCITY, moValue(
"1.0",
"FUNCTION").Ref() );
143 p_configdefinition->Add( moText(
"randomvelocityx"), MO_PARAM_FUNCTION,
PARTICLES_RANDOMVELOCITY_X, moValue(
"1.0",
"FUNCTION").Ref() );
144 p_configdefinition->Add( moText(
"randomvelocityy"), MO_PARAM_FUNCTION,
PARTICLES_RANDOMVELOCITY_Y, moValue(
"1.0",
"FUNCTION").Ref() );
145 p_configdefinition->Add( moText(
"randomvelocityz"), MO_PARAM_FUNCTION,
PARTICLES_RANDOMVELOCITY_Z, moValue(
"1.0",
"FUNCTION").Ref() );
147 p_configdefinition->Add( moText(
"randommotion"), MO_PARAM_FUNCTION,
PARTICLES_RANDOMMOTION, moValue(
"0.0",
"FUNCTION").Ref() );
148 p_configdefinition->Add( moText(
"randommotionx"), MO_PARAM_FUNCTION,
PARTICLES_RANDOMMOTION_X, moValue(
"0.0",
"FUNCTION").Ref() );
149 p_configdefinition->Add( moText(
"randommotiony"), MO_PARAM_FUNCTION,
PARTICLES_RANDOMMOTION_Y, moValue(
"0.0",
"FUNCTION").Ref() );
150 p_configdefinition->Add( moText(
"randommotionz"), MO_PARAM_FUNCTION,
PARTICLES_RANDOMMOTION_Z, moValue(
"0.0",
"FUNCTION").Ref() );
152 p_configdefinition->Add( moText(
"rotatex_particle"), MO_PARAM_ROTATEX,
PARTICLES_ROTATEX_PARTICLE, moValue(
"0.0",
"FUNCTION").Ref() );
153 p_configdefinition->Add( moText(
"rotatey_particle"), MO_PARAM_ROTATEY,
PARTICLES_ROTATEY_PARTICLE, moValue(
"0.0",
"FUNCTION").Ref() );
154 p_configdefinition->Add( moText(
"rotatez_particle"), MO_PARAM_ROTATEZ,
PARTICLES_ROTATEZ_PARTICLE, moValue(
"0.0",
"FUNCTION").Ref() );
156 p_configdefinition->Add( moText(
"scalex_particle"), MO_PARAM_SCALEX,
PARTICLES_SCALEX_PARTICLE, moValue(
"1.0",
"FUNCTION").Ref() );
157 p_configdefinition->Add( moText(
"scaley_particle"), MO_PARAM_SCALEY,
PARTICLES_SCALEY_PARTICLE, moValue(
"1.0",
"FUNCTION").Ref() );
158 p_configdefinition->Add( moText(
"scalez_particle"), MO_PARAM_SCALEZ,
PARTICLES_SCALEZ_PARTICLE, moValue(
"1.0",
"FUNCTION").Ref() );
160 p_configdefinition->Add( moText(
"time_to_revelation"), MO_PARAM_NUMERIC,
PARTICLES_TIMETOREVELATION, moValue(
"2000",
"NUM") );
161 p_configdefinition->Add( moText(
"time_of_revelation"), MO_PARAM_NUMERIC,
PARTICLES_TIMEOFREVELATION, moValue(
"3000",
"NUM") );
164 p_configdefinition->Add( moText(
"drawing_features"), MO_PARAM_NUMERIC,
PARTICLES_DRAWINGFEATURES, moValue(
"0",
"NUM"), moText(
"NO,YES") );
166 p_configdefinition->Add( moText(
"translatex"), MO_PARAM_TRANSLATEX,
PARTICLES_TRANSLATEX, moValue(
"0.0",
"FUNCTION").Ref() );
167 p_configdefinition->Add( moText(
"translatey"), MO_PARAM_TRANSLATEY,
PARTICLES_TRANSLATEY, moValue(
"0.0",
"FUNCTION").Ref() );
168 p_configdefinition->Add( moText(
"translatez"), MO_PARAM_TRANSLATEZ,
PARTICLES_TRANSLATEZ, moValue(
"0.0",
"FUNCTION").Ref() );
169 p_configdefinition->Add( moText(
"rotatex"), MO_PARAM_ROTATEX,
PARTICLES_ROTATEX, moValue(
"0.0",
"FUNCTION").Ref() );
170 p_configdefinition->Add( moText(
"rotatey"), MO_PARAM_ROTATEY,
PARTICLES_ROTATEY, moValue(
"0.0",
"FUNCTION").Ref() );
171 p_configdefinition->Add( moText(
"rotatez"), MO_PARAM_ROTATEZ,
PARTICLES_ROTATEZ, moValue(
"0.0",
"FUNCTION").Ref() );
172 p_configdefinition->Add( moText(
"scalex"), MO_PARAM_SCALEX,
PARTICLES_SCALEX, moValue(
"1.0",
"FUNCTION").Ref() );
173 p_configdefinition->Add( moText(
"scaley"), MO_PARAM_SCALEY,
PARTICLES_SCALEY, moValue(
"1.0",
"FUNCTION").Ref() );
174 p_configdefinition->Add( moText(
"scalez"), MO_PARAM_SCALEZ,
PARTICLES_SCALEZ, moValue(
"1.0",
"FUNCTION").Ref() );
175 p_configdefinition->Add( moText(
"eyex"), MO_PARAM_FUNCTION,
PARTICLES_EYEX, moValue(
"0.0",
"FUNCTION").Ref() );
176 p_configdefinition->Add( moText(
"eyey"), MO_PARAM_FUNCTION,
PARTICLES_EYEY, moValue(
"0.0",
"FUNCTION").Ref() );
177 p_configdefinition->Add( moText(
"eyez"), MO_PARAM_FUNCTION,
PARTICLES_EYEZ, moValue(
"10.0",
"FUNCTION").Ref() );
178 p_configdefinition->Add( moText(
"viewx"), MO_PARAM_FUNCTION,
PARTICLES_VIEWX, moValue(
"0.0",
"FUNCTION").Ref() );
179 p_configdefinition->Add( moText(
"viewy"), MO_PARAM_FUNCTION,
PARTICLES_VIEWY, moValue(
"0.0",
"FUNCTION").Ref() );
180 p_configdefinition->Add( moText(
"viewz"), MO_PARAM_FUNCTION,
PARTICLES_VIEWZ, moValue(
"0.0",
"FUNCTION").Ref() );
181 p_configdefinition->Add( moText(
"orderingmode"), MO_PARAM_NUMERIC,
PARTICLES_ORDERING_MODE, moValue(
"0",
"NUM"), moText(
"NONE,ZDEPTHTEST,ZPOSITION,COMPLETE") );
182 return p_configdefinition;
190 m_pParticleTime =
new moInlet();
192 if (m_pParticleTime) {
193 ((moConnector*)m_pParticleTime)->Init( moText(
"particletime"), m_Inlets.Count(), MO_DATA_NUMBER_DOUBLE );
194 m_Inlets.Add(m_pParticleTime);
197 m_pParticleIndex =
new moInlet();
199 if (m_pParticleIndex) {
200 ((moConnector*)m_pParticleIndex)->Init( moText(
"particleindex"), m_Inlets.Count(), MO_DATA_NUMBER_LONG );
201 m_Inlets.Add(m_pParticleIndex);
205 if (!PreInit())
return false;
207 if (glActiveTextureARB) {
322 m_bTrackerInit =
false;
323 m_pTrackerData = NULL;
341 original_proportion = 1.0;
343 midi_red = midi_green = midi_blue = 1.0;
345 midi_emitionperiod = 1.0;
346 midi_emitionrate = 1.0;
347 midi_randomvelocity = 1.0;
348 midi_randommotion = 1.0;
350 m_InletTuioSystemIndex = GetInletIndex(
"TUIOSYSTEM");
352 m_InletTrackerSystemIndex = GetInletIndex(
"TRACKERKLT");
359 void moEffectParticlesSimple::ResetTimers() {
361 TimerFullRevelation.Stop();
362 TimerFullRestoration.Stop();
363 TimerOfRevelation.Stop();
364 TimerOfRestoration.Stop();
366 FeatureActivity.Stop();
367 MotionActivity.Stop();
368 NoMotionActivity.Stop();
371 for (
int i=0; i < m_ParticlesSimpleArray.Count(); i++ ) {
374 pPar->
Age.SetRelativeTimer( (moTimerAbsolute*)&m_EffectState.tempo );
383 MODebug2->Push(moText(
"moEffectParticlesSimple::Shot: Shot activated!!!!")+ (moText)source);
385 moTextureBuffer* pTexBuf = NULL;
389 if (pSubSample && samplebuffer) {
390 delete [] samplebuffer;
405 if ( source != moText(
"")) {
408 moTextureBuffer* pTexBufAltas = NULL;
411 int idid = m_pResourceManager->GetTextureMan()->GetTextureBuffer(moText( source ),
true);
413 pTexBufAltas = m_pResourceManager->GetTextureMan()->GetTextureBuffer(idid);
414 pTexBufAltas->UpdateImages(1);
417 pTexBufAltas->UpdateImages(1);
418 int np = pTexBufAltas->GetImagesProcessed();
422 ichosen = (int)( moMathf::UnitRandom() * np );
432 glidori = pTexBufAltas->GetFrame(ichosen);
435 pTextureDest = (moTexture*) pTexBufAltas->GetTexture(ichosen);
437 }
else MODebug2->Error( moText(
"no images processed yet"));
445 if (glid>0) pTextureDest = m_Config[moR(
PARTICLES_TEXTURE)][MO_SELECTED][0].Texture();
455 char strbuffer[0x100];
456 struct tm * timeinfo;
459 int randcode = rand();
462 timeinfo = localtime ( &rawtime );
463 strftime (strbuffer,80,
"%Y-%m-%d-%H-%M-",timeinfo);
466 moText datetime = strbuffer;
467 datetime+= IntToStr(randcode);
473 original_width = pTextureDest->GetWidth();
474 original_height = pTextureDest->GetHeight();
475 if (original_height>0) {
476 original_proportion = (float)original_width / (
float) original_height;
477 }
else original_proportion = 1.0f;
479 alta = (this->GetLabelName()) + moText(
"ALTA");
480 baja = (this->GetLabelName()) + moText(
"BAJA");
481 extension = moText(
".png");
486 destalta = m_pResourceManager->GetDataMan()->GetDataPath() + (moText)alta;
487 destbaja = m_pResourceManager->GetDataMan()->GetDataPath() + (moText)baja;
488 copyalta = m_pResourceManager->GetDataMan()->GetDataPath() + moText(
"cams/") + (moText)datetime + (moText)alta;
490 pTextureDest->CreateThumbnail(
"PNG", pTextureDest->GetWidth(), pTextureDest->GetHeight(), destalta );
491 pTextureDest->CreateThumbnail(
"PNG", m_cols, m_rows, destbaja );
493 if (source==moText(
"")) m_pResourceManager->GetFileMan()->CopyFile( destalta+(moText)extension , copyalta+(moText)extension );
495 int idori = m_pResourceManager->GetTextureMan()->GetTextureMOId( alta+(moText)extension,
false );
497 m_pResourceManager->GetTextureMan()->GetTexture(idori)->BuildFromFile( destalta+(moText)extension);
498 }
else idori = m_pResourceManager->GetTextureMan()->AddTexture( alta+(moText)extension );
500 int idti = m_pResourceManager->GetTextureMan()->GetTextureMOId( baja+(moText)extension,
false );
502 m_pResourceManager->GetTextureMan()->GetTexture(idti)->BuildFromFile( destbaja+(moText)extension );
503 }
else idti = m_pResourceManager->GetTextureMan()->AddTexture( baja+(moText)extension );
505 if (idori>-1) glidori = m_pResourceManager->GetTextureMan()->GetTexture(idori)->GetGLId();
509 pSubSample = m_pResourceManager->GetTextureMan()->GetTexture(idti);
511 glid = pSubSample->GetGLId();
512 samplebuffer =
new MObyte [ pSubSample->GetWidth() * pSubSample->GetHeight() * 3];
514 pSubSample->GetBuffer( samplebuffer, GL_RGB, GL_UNSIGNED_BYTE );
526 MODebug2->Push(moText(
"moEffectParticlesSimple::ReInit Face construction activated!!!!"));
537 m_pResourceManager->GetTimeMan()->ClearByObjectId( this->GetId() );
543 for( i=0; i<m_cols ; i++) {
544 for( j=0; j<m_rows ; j++) {
549 pPar->
Pos = moVector2f( (
float) i, (
float) j);
551 pPar->
Color = moVector3f(1.0,1.0,1.0);
557 moTextureBuffer* pTexBuf = m_Config[moR(
PARTICLES_FOLDERS)][MO_SELECTED][0].TextureBuffer();
559 pPar->
GLId = glidori;
563 pPar->
TCoord2 = moVector2f( 0.0, 0.0 );
564 pPar->
TSize2 = moVector2f( 1.0f, 1.0f );
566 pPar->
TCoord = moVector2f( (
float) (i ) / (
float) m_cols, (
float) (j) / (
float) m_rows );
567 pPar->
TSize = moVector2f( 1.0f / (
float) m_cols, 1.0f / (
float) m_rows );
573 if (pSubSample && samplebuffer) {
575 if (pSubSample->GetWidth()!=m_cols) MODebug2->Error(moText(
"pSubSample width doesnt match m_cols"));
576 if (pSubSample->GetHeight()!=m_rows) MODebug2->Error(moText(
"pSubSample height doesnt match m_rows"));
578 int r = samplebuffer[ (i + j*pSubSample->GetWidth() ) *3 ];
579 int g = samplebuffer[ (i+1 + j*pSubSample->GetWidth() ) *3 ];
580 int b = samplebuffer[ (i+2 + j*pSubSample->GetWidth() ) *3 ];
586 lum = ((lum & 1) << 7) | ((lum & 2) << 5) | ((lum & 4) << 3) | ((lum & 8) << 1) | ((lum & 16) >> 1) | ((lum & 32) >> 3) | ((lum & 64) >> 5) | ((lum & 128) >> 7);
593 lumf = ( 100.0 * (float)lum ) / (float)255.0;
594 lumindex = (int) lumf;
595 if (lumindex>99) lumindex = 99;
599 MODebug2->Message(moText(
"ReInit error:## lum is negative!!! ##")+IntToStr(lum)
600 +moText(
"subs: w:") + IntToStr(pSubSample->GetWidth())
601 +moText(
"subs: h:") + IntToStr(pSubSample->GetHeight())
606 }
else MODebug2->Push(moText(
"ReInit error: no texture nor samplebuffer"));
609 if (pTexBuf && pTextureDest && samplebuffer) {
611 int nim = pTexBuf->GetImagesProcessed();
617 moTextureFrames& pTextFrames(pTexBuf->GetBufferLevels( lumindex, 0 ) );
619 int nc = pTextFrames.Count();
622 irandom = (int)( moMathf::UnitRandom() * (double)nc );
625 moTextureMemory* pTexMem = pTextFrames.GetRef( irandom );
628 pPar->
GLId = glidori;
629 pTexMem->GetReference();
630 pPar->
GLId2 = pTexMem->GetGLId();
632 if (pTexMem->GetHeight()>0) pPar->
ImageProportion = (
float) pTexMem->GetWidth() / (float) pTexMem->GetHeight();
635 MODebug2->Message(moText(
"Sample not founded: lumindex:")+IntToStr(lumindex)+moText(
" irandom:")+IntToStr(irandom));
637 pPar->
GLId = glidori;
639 pPar->
Color.X() = ((float)lum )/ 255.0f;
640 pPar->
Color.Y() = ((float)lum )/ 255.0f;
641 pPar->
Color.Z() = ((float)lum )/ 255.0f;
652 MODebug2->Error( moText(
"particles error creating texture") );
662 pPar->
Force = moVector3f( 0.0f, 0.0f, 0.0f );
664 SetParticlePosition( pPar );
676 pPar->
Age.SetObjectId( this->GetId() );
677 pPar->
Age.SetTimerId( i + j*m_cols );
678 m_pResourceManager->GetTimeMan()->AddTimer( &pPar->
Age );
680 m_ParticlesSimpleArray.Set( i + j*m_cols, pPar );
688 m_ParticlesSimpleArrayTmp.Set( i + j*m_cols, pParTmp );
701 }
else MODebug2->Error(moText(
"ParticleSimple::ReInit::no particle pointer"));
709 void moEffectParticlesSimple::UpdateDt() {
736 dtrel = (double) ( m_EffectState.tempo.ticks - last_tick ) / (double)16.666666;
740 dt = m_Config.Eval( moR(
PARTICLES_SYNC)) * dtrel * (double)(m_EffectState.tempo.delta) / (double)100.0;
742 last_tick = m_EffectState.tempo.ticks;
746 void moEffectParticlesSimple::UpdateParameters() {
759 if ( moIsTimerStopped() || !m_EffectState.tempo.Started() ) {
768 moText fullscript = m_pResourceManager->GetDataMan()->GetDataPath()+ moSlash + (moText)m_Physics.
m_ParticleScript;
770 if ( CompileFile(fullscript) ) {
772 MODebug2->Message(moText(
"ParticlesSimple script loaded ") + (moText)fullscript );
774 SelectScriptFunction(
"Init" );
776 RunSelectedFunction();
778 }
else MODebug2->Error(moText(
"ParticlesSimple couldnt compile lua script ") + (moText)fullscript );
781 if (moScript::IsInitialized()) {
782 if (ScriptHasFunction(
"RunSystem")) {
783 SelectScriptFunction(
"RunSystem");
785 AddFunctionParam( (
int) ( m_rows*m_cols ) );
786 AddFunctionParam( (
float) dt );
787 RunSelectedFunction(1);
876 m_Physics.
m_EmitterVector = moVector3f( m_TrackerBarycenter.X()*normalf, m_TrackerBarycenter.Y()*normalf, 0.0f );
884 if (original_proportion!=1.0f) {
885 if (original_proportion>1.0f) {
895 void moEffectParticlesSimple::SetParticlePosition(
moParticlesSimple* pParticle ) {
899 float randomvelx = 0;
900 float randomvely = 0;
901 float randomvelz = 0;
902 float randomposx = 0;
903 float randomposy = 0;
904 float randomposz = 0;
912 double len=0,index=0,index_normal=0;
922 moVector4d fullcolor;
924 pParticle->
Color = moVector3f(
929 pParticle->
Mass = 10.0f;
930 pParticle->
Fixed =
false;
932 pParticle->
U = moVector3f( 1.0, 0.0, 0.0 );
933 pParticle->
V = moVector3f( 0.0, 1.0, 0.0 );
934 pParticle->
W = moVector3f( 0.0, 0.0, 1.0 );
936 pParticle->
dpdt = moVector3f( 0.0f, 0.0f, 0.0f );
937 pParticle->
dvdt = moVector3f( 0.0f, 0.0f, 0.0f );
940 else pParticle->
Alpha = fullcolor.W();
943 else pParticle->
Scale = 1.0;
954 pParticle->
Velocity = moVector3f( randomvelx,
964 pParticle->
Velocity = moVector3f( randomvelx,
976 alpha = 2 * moMathf::PI * pParticle->
Pos.X() / (double)m_cols;
977 phi = moMathf::PI * pParticle->
Pos.Y() / (double)m_rows;
980 pParticle->
Pos3d = moVector3f( (radius*moMathf::Cos(alpha)*moMathf::Sin(phi) + randomposx ) * m_Physics.
m_EmitterVector.X(),
981 (radius*moMathf::Sin(alpha)*moMathf::Sin(phi) + randomposy ) * m_Physics.
m_EmitterVector.Y(),
982 (radius*moMathf::Cos(phi) + randomposz ) * m_Physics.
m_EmitterVector.Z() );
984 pParticle->
Velocity = moVector3f( randomvelx,
990 alpha = 2 * (moMathf::PI) * moMathf::UnitRandom();
991 phi = moMathf::PI * moMathf::UnitRandom();
993 pParticle->
Pos3d = moVector3f(
994 (radius*moMathf::Cos(alpha)*moMathf::Sin(phi) + randomposx)* m_Physics.
m_EmitterVector.X(),
995 (radius*moMathf::Sin(alpha)*moMathf::Sin(phi) + randomposy)* m_Physics.
m_EmitterVector.Y(),
998 pParticle->
Velocity = moVector3f( randomvelx,
1004 alpha = 2 * moMathf::PI * moMathf::UnitRandom();
1005 phi = moMathf::PI * moMathf::UnitRandom();
1008 pParticle->
Pos3d = moVector3f( (radius*moMathf::Cos(alpha)*moMathf::Sin(phi) + randomposx ) * m_Physics.
m_EmitterVector.X(),
1009 (radius*moMathf::Sin(alpha)*moMathf::Sin(phi) + randomposy ) * m_Physics.
m_EmitterVector.Y(),
1010 (radius*moMathf::Cos(phi) + randomposz ) * m_Physics.
m_EmitterVector.Z() );
1012 pParticle->
Velocity = moVector3f( randomvelx,
1023 alpha = 2 * moMathf::PI * pParticle->
Pos.X() / (double)m_cols;
1026 z = m_Physics.
m_EmitterSize.Z() * ( 0.5f - ( pParticle->
Pos.Y() / (double)m_rows ) );
1028 pParticle->
Pos3d = moVector3f( ( radius1*moMathf::Cos(alpha) + randomposx ) * m_Physics.
m_EmitterVector.X(),
1029 ( radius1*moMathf::Sin(alpha) + randomposy ) * m_Physics.
m_EmitterVector.Y(),
1032 pParticle->
Velocity = moVector3f( randomvelx,
1038 alpha = 2 * moMathf::PI * moMathf::UnitRandom();
1041 z = m_Physics.
m_EmitterSize.Z() * ( 0.5f - moMathf::UnitRandom());
1043 pParticle->
Pos3d = moVector3f( ( radius1*moMathf::Cos(alpha) + randomposx ) * m_Physics.
m_EmitterVector.X(),
1044 ( radius1*moMathf::Sin(alpha) + randomposy ) * m_Physics.
m_EmitterVector.Y(),
1047 pParticle->
Velocity = moVector3f( randomvelx,
1053 alpha = 2 * moMathf::PI * moMathf::UnitRandom();
1056 radius = radius1 + moMathf::UnitRandom()*(radius2-radius1)*moMathf::UnitRandom();
1057 z = m_Physics.
m_EmitterSize.Z() * ( 0.5f - moMathf::UnitRandom());
1059 pParticle->
Pos3d = moVector3f( ( radius*moMathf::Cos(alpha) + randomposx ) * m_Physics.
m_EmitterVector.X(),
1060 ( radius*moMathf::Sin(alpha) + randomposy ) * m_Physics.
m_EmitterVector.Y(),
1063 pParticle->
Velocity = moVector3f( randomvelx,
1077 index = pParticle->
Pos.X()+pParticle->
Pos.Y()*(double)m_cols;
1080 if (m_cols*m_rows) {
1081 index_normal = index / (double)(m_cols*m_rows);
1089 pParticle->
Velocity = moVector3f( randomvelx,
1101 pParticle->
Velocity = moVector3f( randomvelx,
1115 pParticle->
Velocity = moVector3f( randomvelx,
1126 alpha = 2 * moMathf::PI * pParticle->
Pos.X() / (double)m_cols;
1129 z = m_Physics.
m_EmitterSize.Z() * ( 0.5f - ( pParticle->
Pos.Y() / (double)m_rows ) - (pParticle->
Pos.X() / (double)(m_cols*m_rows)) );
1131 pParticle->
Pos3d = moVector3f( ( radius1*moMathf::Cos(alpha) + randomposx ) * m_Physics.
m_EmitterVector.X(),
1132 ( radius1*moMathf::Sin(alpha) + randomposy ) * m_Physics.
m_EmitterVector.Y(),
1135 pParticle->
Velocity = moVector3f( randomvelx,
1145 alpha = 2 * moMathf::PI * ( pParticle->
Pos.X() + pParticle->
Pos.Y()*m_rows ) / ((
double)m_cols*(
double)m_rows );
1146 radius1 = m_Physics.m_EmitterSize.X() / 2.0;
1147 radius2 = m_Physics.m_EmitterSize.Y() / 2.0;
1151 pParticle->Pos3d = moVector3f( ( radius1*moMathf::Cos(alpha) + randomposx ) * m_Physics.m_EmitterVector.X(),
1152 ( radius1*moMathf::Sin(alpha) + randomposy ) * m_Physics.m_EmitterVector.Y(),
1153 ( z + randomposz ) );
1155 pParticle->Velocity = moVector3f( randomvelx,
1161 alpha = 2 * moMathf::PI * ( pParticle->Pos.X()*m_rows + pParticle->Pos.Y()) / ((
double)m_cols*(
double)m_rows );
1162 radius1 = m_Physics.m_EmitterSize.X() / 2.0;
1163 radius2 = m_Physics.m_EmitterSize.Y() / 2.0;
1166 randomposx = randomposx + (radius1-radius2)*moMathf::Cos(alpha);
1167 randomposy = randomposy + (radius1-radius2)*moMathf::Sin(alpha);
1168 pParticle->Pos3d = moVector3f( ( radius1*moMathf::Cos(alpha) + randomposx ) * m_Physics.m_EmitterVector.X(),
1169 ( radius1*moMathf::Sin(alpha) + randomposy ) * m_Physics.m_EmitterVector.Y(),
1170 ( z + randomposz ) );
1172 pParticle->Velocity = moVector3f( randomvelx,
1180 switch(m_Physics.m_CreationMethod) {
1182 if (m_pTrackerData) {
1183 pParticle->
Pos3d = moVector3f( (m_pTrackerData->GetBarycenter().X() - 0.5)*normalf, (-m_pTrackerData->GetBarycenter().Y()+0.5)*normalf, 0.0 );
1184 pParticle->
Pos3d+= moVector3f( randomposx, randomposy, randomposz );
1185 pParticle->
Velocity = moVector3f( randomvelx, randomvely, randomvelz );
1195 if (m_pTrackerData) {
1196 bool bfounded =
false;
1197 int np = (int) ( moMathf::UnitRandom() * m_pTrackerData->GetFeaturesCount() );
1199 moTrackerFeature *pTF = NULL;
1201 pTF = m_pTrackerData->GetFeature( np );
1203 pParticle->
Pos3d = moVector3f( (pTF->x - 0.5)*normalf, (-pTF->y+0.5)*normalf, 0.0 );
1217 pTF = m_pTrackerData->GetFeature( np );
1219 pParticle->
Pos3d = moVector3f( (pTF->x - 0.5)*normalf, (-pTF->y+0.5)*normalf, 0.0 );
1222 np = (int) ( moMathf::UnitRandom() * m_pTrackerData->GetFeaturesCount() );
1224 }
while (!pTF->valid && np < m_pTrackerData->GetFeaturesCount() && cn<5 );
1225 if (!bfounded) pParticle->
Pos3d = moVector3f( (m_pTrackerData->GetBarycenter().X() - 0.5)*normalf, (-m_pTrackerData->GetBarycenter().Y()+0.5)*normalf, 0.0 );
1230 pParticle->
Pos3d = moVector3f( 0, 0, 0 );
1233 pParticle->
Pos3d+= moVector3f( randomposx, randomposy, randomposz );
1235 pParticle->
Velocity = moVector3f( randomvelx,
1247 void moEffectParticlesSimple::InitParticlesSimple(
int p_cols,
int p_rows,
bool p_forced ) {
1251 bool m_bNewImage =
false;
1258 if (m_pResourceManager){
1259 if (m_pResourceManager->GetTimeMan()) {
1260 m_pResourceManager->GetTimeMan()->ClearByObjectId( this->GetId() );
1266 if (m_ParticlesSimpleArray.Count()>0) {
1274 m_ParticlesSimpleArray.Empty();
1277 if (m_ParticlesSimpleArrayTmp.Count()>0) {
1285 m_ParticlesSimpleArrayTmp.Empty();
1289 m_ParticlesSimpleArray.Init( p_cols*p_rows, NULL );
1290 m_ParticlesSimpleArrayTmp.Init( p_cols*p_rows, NULL );
1293 for( j=0; j<p_rows ; j++) {
1294 for( i=0; i<p_cols ; i++) {
1298 pPar->
Pos = moVector2f( (
float) i, (
float) j);
1301 moVector4d fullcolor;
1303 pPar->
Color = moVector3f(
1311 pPar->
TCoord = moVector2f( 0.0, 0.0 );
1312 pPar->
TSize = moVector2f( 1.0f, 1.0f );
1316 pPar->
TCoord = moVector2f( (
float) (i) / (
float) p_cols, (
float) (j) / (
float) p_rows );
1317 pPar->
TSize = moVector2f( 1.0f / (
float) p_cols, 1.0f / (
float) p_rows );
1321 pPar->
TCoord = moVector2f( 0.0, 0.0 );
1322 pPar->
TSize = moVector2f( 1.0f, 1.0f );
1327 moTextureBuffer* pTexBuf = m_Config[moR(
PARTICLES_FOLDERS)][MO_SELECTED][0].TextureBuffer();
1329 pPar->
GLId = glidori;
1332 pPar->
TCoord2 = moVector2f( 0.0, 0.0 );
1333 pPar->
TSize2 = moVector2f( 1.0f, 1.0f );
1335 pPar->
TCoord = moVector2f( (
float) (i ) / (
float) p_cols, (
float) (j) / (
float) p_rows );
1336 pPar->
TSize = moVector2f( 1.0f / (
float) p_cols, 1.0f / (
float) p_rows );
1345 if (pSubSample && samplebuffer) {
1347 lum = (samplebuffer[ (i + j*pSubSample->GetWidth() ) *3 ]
1348 + samplebuffer[ (i+1 + j*pSubSample->GetWidth() ) *3 ]
1349 + samplebuffer[ (i+2 + j*pSubSample->GetWidth() ) *3 ]) / 3;
1351 if (lum<0) lum = -lum;
1354 lumindex = (int)( 100.0 * (
float)lum / (float)256) - 1;
1355 if (lumindex>99) lumindex = 99;
1358 MODebug2->Message(moText(
"pSubSample: ")+IntToStr((
long)pSubSample) +
1359 moText(
"samplebuffer: ")+IntToStr((
long)samplebuffer));
1365 int nim = pTexBuf->GetImagesProcessed();
1374 moTextureFrames& pTextFrames(pTexBuf->GetBufferLevels( lumindex, 0 ) );
1376 int nc = pTextFrames.Count();
1379 irandom = (int)( moMathf::UnitRandom() * (double)nc );
1381 moTextureMemory* pTexMem = pTextFrames.GetRef( irandom );
1384 pPar->
GLId = glidori;
1385 pTexMem->GetReference();
1386 pPar->
GLId2 = pTexMem->GetGLId();
1388 if (pTexMem->GetHeight()>0) pPar->
ImageProportion = (
float) pTexMem->GetWidth() / (float) pTexMem->GetHeight();
1390 pPar->
GLId = glidori;
1392 pPar->
Color.X() = ((float)lum )/ 255.0f;
1393 pPar->
Color.Y() = ((float)lum )/ 255.0f;
1394 pPar->
Color.Z() = ((float)lum )/ 255.0f;
1403 }
else MODebug2->Error( moText(
"particles error creating texture") );
1408 pPar->
Force = moVector3f( 0.0f, 0.0f, 0.0f );
1410 SetParticlePosition( pPar );
1428 pPar->
Age.SetObjectId( this->GetId() );
1429 pPar->
Age.SetTimerId( i + j*p_cols );
1430 pPar->
Age.SetRelativeTimer( (moTimerAbsolute*)&m_EffectState.tempo );
1431 m_pResourceManager->GetTimeMan()->AddTimer( &pPar->
Age );
1433 m_ParticlesSimpleArray.Set( i + j*p_cols, pPar );
1441 m_ParticlesSimpleArrayTmp.Set( i + j*p_cols, pParTmp );
1452 void moEffectParticlesSimple::Regenerate() {
1455 float randommotionx,randommotiony,randommotionz;
1457 long emitiontimer_duration = m_Physics.
EmitionTimer.Duration();
1461 if (emitiontimer_duration<0)
1465 for( j=0; j<m_rows ; j++) {
1466 for( i=0; i<m_cols ; i++) {
1475 if (pPar->
Age.Duration() > moGetTicks() ) {
1510 if (m_Rate>0) m_Rate--;
1531 bool letsborn =
true;
1532 int id_last_particle = 0;
1533 int this_id_particle = 0;
1539 else id_last_particle = -1;
1541 this_id_particle = i+j*m_cols;
1543 if ( id_last_particle==(m_rows*m_cols-1)
1544 && this_id_particle == 0 ) {
1547 }
else if ( this_id_particle == (id_last_particle+1) ) {
1571 SetParticlePosition( pPar );
1596 moTextureBuffer* pTexBuf = m_Config[ moR(
PARTICLES_FOLDERS) ][MO_SELECTED][0].TextureBuffer();
1599 int nim = pTexBuf->GetImagesProcessed();
1606 float frandom = moMathf::UnitRandom() * nim;
1611 int irandom = (int)frandom;
1614 if (irandom>=nim) irandom = nim - 1;
1616 pPar->
GLId = pTexBuf->GetFrame( irandom );
1618 moTextureMemory* pTexMem = pTexBuf->GetTexture( irandom );
1621 if (pTexMem->GetHeight()>0) pPar->
ImageProportion = (
float) pTexMem->GetWidth() / (float) pTexMem->GetHeight();
1630 pPar->
TCoord = moVector2f( 0.0, 0.0 );
1631 pPar->
TSize = moVector2f( 1.0f, 1.0f );
1633 }
else MODebug2->Error( moText(
"PARTICLES_TEXTUREMODE_MANY particles error creating texture") );
1656 }
else pPar->
Alpha = 1.0 ;
1657 }
else if ( m_Physics.
m_MaxAge==0) {
1668 if ( (m_Physics.
m_MaxAge/2.0) < pPar->
Age.Duration() ) {
1687 }
else pPar->
Scale = 1.0 ;
1695 && ( (m_Physics.
m_MaxAge/2.0) < pPar->
Age.Duration() ) && (pPar->
Age.Duration() < m_Physics.
m_MaxAge) ) {
1728 void moEffectParticlesSimple::ParticlesSimpleInfluence(
float posx,
float posy,
float velx,
float vely,
float veln ) {
1787 void moEffectParticlesSimple::RevealingAll() {
1790 moVector2f BSize = moVector2f( normalf / (
float) m_cols, normalf / (
float) m_rows );
1792 if (!TimerOfRevelation.Started() ) {
1793 TimerOfRevelation.Start();
1796 if (TimerOfRevelation.Started() ) {
1798 if (TimerOfRevelation.Duration() < time_of_revelation ) {
1799 scale = (float)( time_of_revelation - TimerOfRevelation.Duration() ) / (
float)time_of_revelation;
1802 TimerOfRevelation.Stop();
1805 for(
int i=0; i<m_cols ; i++) {
1806 for(
int j=0; j<m_rows ; j++) {
1807 if (m_ParticlesSimpleArray[i+j*m_cols]->Size.X() > 0.1 )
1808 m_ParticlesSimpleArray[i+j*m_cols]->Size = BSize * scale;
1815 if (!TimerOfRevelation.Started() ) {
1821 void moEffectParticlesSimple::RestoringAll() {
1824 float left = - normalf / 2.0;
1825 float top = normalf / 2.0;
1826 moVector2f BSize = moVector2f( normalf / (
float) m_cols, normalf / (
float) m_rows );
1828 if (!TimerOfRestoration.Started() ) {
1829 TimerOfRestoration.Start();
1832 if (TimerOfRestoration.Started() ) {
1834 if (TimerOfRestoration.Duration() < time_of_restoration ) {
1835 scale = 1.0f - (float)( time_of_restoration - TimerOfRestoration.Duration() ) / (
float)time_of_restoration;
1838 TimerOfRestoration.Stop();
1841 for(
int i=0; i<m_cols ; i++) {
1842 for(
int j=0; j<m_rows ; j++) {
1843 m_ParticlesSimpleArray[i+j*m_cols]->Size = BSize * scale;
1844 m_ParticlesSimpleArray[i+j*m_cols]->Pos3d = moVector3f( left + (
float)(i)*BSize.X() + BSize.X()/2.0,
1845 top - (float)(j)*BSize.Y() - BSize.Y()/2.0,
1853 if (!TimerOfRestoration.Started() ) {
1859 void moEffectParticlesSimple::CalculateForces(
bool tmparray)
1863 moVector3f zero(0.0,0.0,0.0);
1866 double len,dx,dy,dz;
1872 for ( i=0; i < m_ParticlesSimpleArray.Count(); i++ ) {
1886 if (m_pTrackerData) {
1887 pPar->
Force = ( moVector3f( 0.5f - m_pTrackerData->GetBarycenter().X(), 0.5f - m_pTrackerData->GetBarycenter().Y(), 0.0 ) - pPar->
Pos3d )*(m_Physics.
gravitational * pPar->
Mass);
1961 void moEffectParticlesSimple::UpdateParticles(
double dt,
int method )
1970 CalculateDerivatives(
false,dt);
1971 for ( i=0; i<m_ParticlesSimpleArray.Count(); i++ ) {
1974 if (pPar && dt!=0.0) {
1983 CalculateDerivatives(
false,dt);
1984 for (i=0;i<m_ParticlesSimpleArray.Count();i++) {
1987 if (pPar && ptmpPar && dt!=0.0) {
1995 CalculateForces(
true);
1996 CalculateDerivatives(
true,dt);
1997 for ( i=0; i < m_ParticlesSimpleArray.Count(); i++ ) {
2000 if (pPar && ptmpPar && dt!=0.0) {
2014 void moEffectParticlesSimple::CalculateDerivatives(
bool tmparray,
double dt)
2018 for ( i=0; i<m_ParticlesSimpleArrayTmp.Count(); i++) {
2019 if (dt>0) m_ParticlesSimpleArrayTmp[i]->dpdt = m_ParticlesSimpleArrayTmp[i]->Velocity;
2020 if (dt>0) m_ParticlesSimpleArrayTmp[i]->dvdt = m_ParticlesSimpleArrayTmp[i]->Force * 1.0f / m_ParticlesSimpleArrayTmp[i]->Mass;
2024 for ( i=0; i<m_ParticlesSimpleArray.Count(); i++) {
2025 if (dt>0) m_ParticlesSimpleArray[i]->dpdt = m_ParticlesSimpleArray[i]->Velocity;
2027 if (dt>0) m_ParticlesSimpleArray[i]->dvdt = m_ParticlesSimpleArray[i]->Force * 1.0f / m_ParticlesSimpleArray[i]->Mass;
2042 double moEffectParticlesSimple::Solver1D(
double h,
double y0,
int method,
double (*fcn)(
double))
2045 double k1,k2,k3,k4,k5,k6;
2049 k1 = h * (*fcn)(y0);
2053 k1 = h * (*fcn)(y0);
2054 k2 = h * (*fcn)(y0 + k1);
2055 ynew = y0 + (k1 + k2) / 2;
2058 k1 = h * (*fcn)(y0);
2059 k2 = h * (*fcn)(y0 + 2 * k1 / 3);
2060 ynew = y0 + k1 / 4 + 3 * k2 / 4;
2063 k1 = h * (*fcn)(y0);
2064 k2 = h * (*fcn)(y0 + k1 / 2);
2068 k1 = h * (*fcn)(y0);
2069 k2 = h * (*fcn)(y0 + k1/2);
2070 k3 = h * (*fcn)(y0 + k2/2);
2071 k4 = h * (*fcn)(y0 + k3);
2072 ynew = y0 + k1 / 6 + k2 / 3 + k3 / 3 + k4 / 6;
2075 k1 = h * (*fcn)(y0);
2076 k2 = h * (*fcn)(y0 + k1 / 2);
2077 k3 = h * (*fcn)(y0 + (k1 + k2) / 4);
2078 k4 = h * (*fcn)(y0 - k2 + 2 * k3);
2079 k5 = h * (*fcn)(y0 + (7 * k1 + 10 * k2 + k4) / 27);
2080 k6 = h * (*fcn)(y0 + (28*k1 - 125*k2 + 546*k3 + 54*k4 - 378*k5) / 625);
2081 ynew = y0 + k1 / 6 + 4 * k3 / 6 + k4 / 6;
2089 void moEffectParticlesSimple::ParticlesSimpleAnimation( moTempo* tempogral, moEffectState* parentstate ) {
2093 int Ileft, Iright, Jtop, Jbottom;
2095 switch(revelation_status) {
2133 for( i = 0; i<m_cols ; i++) {
2134 for( j = 0; j<m_rows ; j++) {
2152 pPar = m_ParticlesSimpleArray.GetRef( partid );
2157 MODebug2->Push( moText(
"Pos X:") + FloatToStr(pPar->
Pos.X()) + moText(
" Pos Y:") + FloatToStr(pPar->
Pos.Y()) + moText(
" glid:") + IntToStr(pPar->
GLId) + moText(
" glid2:") + IntToStr(pPar->
GLId2));
2158 MODebug2->Push( moText(
"X:") + FloatToStr(pPar->
Pos3d.X()) + moText(
" Y:") + FloatToStr(pPar->
Pos3d.Y()) + moText(
" Z:") + FloatToStr(pPar->
Pos3d.Z()) );
2159 MODebug2->Push( moText(
"VX:") + FloatToStr(pPar->
Velocity.X()) + moText(
" VY:") + FloatToStr(pPar->
Velocity.Y()) + moText(
" VZ:") + FloatToStr(pPar->
Velocity.Z()) );
2160 MODebug2->Push( moText(
"FX:") + FloatToStr(pPar->
Force.X()) + moText(
" FY:") + FloatToStr(pPar->
Force.Y()) + moText(
" FZ:") + FloatToStr(pPar->
Force.Z()) );
2161 MODebug2->Push( moText(
"Size X:") + FloatToStr(pPar->
Size.X()) + moText(
" Size Y:") + FloatToStr(pPar->
Size.Y()) );
2162 MODebug2->Push( moText(
"TCoord X:") + FloatToStr(pPar->
TCoord.X()) + moText(
" TCoord Y:") + FloatToStr(pPar->
TCoord.Y()) );
2163 MODebug2->Push( moText(
"TCoord2 X:") + FloatToStr(pPar->
TCoord2.X()) + moText(
" TCoord2 Y:") + FloatToStr(pPar->
TCoord2.Y()) );
2164 MODebug2->Push( moText(
"Visible:") + IntToStr((
int)pPar->
Visible) );
2165 MODebug2->Push( moText(
"Age:") + IntToStr((
int)pPar->
Age.Duration()) );
2177 void moEffectParticlesSimple::DrawParticlesSimple( moTempo* tempogral, moEffectState* parentstate ) {
2187 if (cols2!=m_cols || rows2!=m_rows) {
2188 InitParticlesSimple(cols2,rows2);
2205 gral_ticks = tempogral->ticks;
2217 if (glid>=0) glBindTexture( GL_TEXTURE_2D, glid );
2218 else glBindTexture( GL_TEXTURE_2D, 0);
2229 float sizexd2,sizeyd2;
2230 float tsizex,tsizey;
2232 moFont* pFont = m_Config[moR(
PARTICLES_FONT) ][MO_SELECTED][0].Font();
2235 UpdateParticles( dt, 0 );
2236 ParticlesSimpleAnimation( tempogral, parentstate );
2240 for( j = 0; j<m_rows ; j++) {
2241 for( i = 0; i<m_cols ; i++) {
2244 idxt = 0.5 + (float)( i + j * m_cols ) / (float)( m_cols * m_rows * 2 );
2254 glActiveTextureARB( GL_TEXTURE0_ARB );
2255 glEnable(GL_TEXTURE_2D);
2257 glBindTexture( GL_TEXTURE_2D, pPar->
GLId );
2259 if (pPar->
GLId2>0) {
2260 glActiveTextureARB( GL_TEXTURE1_ARB );
2261 glEnable(GL_TEXTURE_2D);
2263 glBindTexture( GL_TEXTURE_2D, pPar->
GLId2 );
2267 if (moScript::IsInitialized()) {
2268 if (ScriptHasFunction(
"RunParticle")) {
2269 SelectScriptFunction(
"RunParticle");
2270 AddFunctionParam( (
int) ( i + j*m_cols ) );
2271 AddFunctionParam( (
float)dt );
2272 if (!RunSelectedFunction(1)) {
2273 MODebug2->Error( moText(
"RunParticle function not executed") );
2279 sizeyd2 = pPar->
Size.Y()/2.0;
2280 tsizex = pPar->
TSize.X();
2281 tsizey = pPar->
TSize.Y();
2282 double part_timer = 0.001f * (double)(pPar->
Age.Duration());
2284 if (m_pParticleTime) {
2285 if (m_pParticleTime->GetData()) {
2286 m_pParticleTime->GetData()->SetDouble(part_timer);
2287 m_pParticleTime->Update(
true);
2291 if (m_pParticleIndex) {
2292 if (m_pParticleIndex->GetData()) {
2293 m_pParticleIndex->GetData()->SetLong( i + j*m_cols );
2294 m_pParticleIndex->Update(
true);
2312 glColor4f( m_Config[moR(
PARTICLES_COLOR)][MO_SELECTED][MO_RED].Eval() * pPar->
Color.X() * m_EffectState.tintr,
2313 m_Config[moR(
PARTICLES_COLOR)][MO_SELECTED][MO_GREEN].Eval() * pPar->
Color.Y() * m_EffectState.tintg,
2314 m_Config[moR(
PARTICLES_COLOR)][MO_SELECTED][MO_BLUE].Eval() * pPar->
Color.Z() * m_EffectState.tintb,
2317 * m_EffectState.alpha * pPar->
Alpha );
2327 U = moVector3f( 0.0f, 0.0f, 1.0f );
2328 V = moVector3f( 1.0f, 0.0f, 0.0f );
2329 W = moVector3f( 0.0f, 1.0f, 0.0f );
2339 U = moVector3f( 0.0f, 0.0f, 1.0f );
2340 V = moVector3f( 1.0f, 0.0f, 0.0f );
2341 W = moVector3f( 0.0f, 1.0f, 0.0f );
2345 V = moVector3f( -CO.Y(), CO.X(), 0.0f );
2348 CPU = moVector3f( U.X(), U.Y(), 0.0f );
2349 W = moVector3f( 0.0f, 0.0f, CPU.Length() );
2358 if (U.Length() < 0.5) {
2359 U = moVector3f( 0.0, 0.0, 1.0 );
2362 V = moVector3f( -U.Y(), U.X(), 0.0f );
2364 CPU = moVector3f( U.X(), U.Y(), 0.0f );
2365 W = moVector3f( 0.0f, 0.0f, CPU.Length() );
2372 A = V * -sizexd2 + W * sizeyd2;
2373 B = V *sizexd2 + W * sizeyd2;
2374 C = V *sizexd2 + W * -sizeyd2;
2375 D = V * -sizexd2 + W * -sizeyd2;
2383 MOfloat cycleage = m_EffectState.tempo.ang;
2386 cycleage = part_timer;
2388 int glid = pPar->
GLId;
2390 if ( pPar->
MOId==-1 ) {
2397 if ( pPar->
MOId>-1 ) {
2399 moTexture* pTex = m_pResourceManager->GetTextureMan()->GetTexture(pPar->
MOId);
2404 pTex->GetType()==MO_TYPE_VIDEOBUFFER
2405 || pTex->GetType()==MO_TYPE_CIRCULARVIDEOBUFFER
2406 || pTex->GetType()==MO_TYPE_MOVIE
2407 || pTex->GetType()==MO_TYPE_TEXTURE_MULTIPLE
2409 moTextureAnimated *pTA = (moTextureAnimated*)pTex;
2414 glid = pTA->GetGLId((MOfloat)cycleage);
2417 pPar->
FramePS = pTA->GetFramesPerSecond();
2422 glid = pTex->GetGLId();
2429 glBindTexture( GL_TEXTURE_2D , glid );
2436 if (pPar->
GLId2>0) {
2438 glMultiTexCoord2fARB( GL_TEXTURE0_ARB, pPar->
TCoord.X(), pPar->
TCoord.Y() );
2439 glMultiTexCoord2fARB( GL_TEXTURE1_ARB, pPar->
TCoord2.X(), pPar->
TCoord2.Y());
2440 }
else glTexCoord2f( pPar->
TCoord.X(), pPar->
TCoord.Y() );
2441 glVertex3f( A.X(), A.Y(), 0.0);
2445 if (pPar->
GLId2>0) {
2446 glMultiTexCoord2fARB( GL_TEXTURE0_ARB, pPar->
TCoord.X()+tsizex, pPar->
TCoord.Y() );
2448 }
else glTexCoord2f( pPar->
TCoord.X()+tsizex, pPar->
TCoord.Y() );
2449 glVertex3f( B.X(), B.Y(), 0.0);
2452 if (pPar->
GLId2>0) {
2453 glMultiTexCoord2fARB( GL_TEXTURE0_ARB, pPar->
TCoord.X()+tsizex, pPar->
TCoord.Y()+tsizey );
2455 }
else glTexCoord2f( pPar->
TCoord.X()+tsizex, pPar->
TCoord.Y()+tsizey );
2456 glVertex3f( C.X(), C.Y(), 0.0);
2459 if (pPar->
GLId2>0) {
2460 glMultiTexCoord2fARB( GL_TEXTURE0_ARB, pPar->
TCoord.X(), pPar->
TCoord.Y()+pPar->
TSize.Y());
2462 }
else glTexCoord2f( pPar->
TCoord.X(), pPar->
TCoord.Y()+tsizey );
2463 glVertex3f( D.X(), D.Y(), 0.0);
2467 if ( drawing_features>2 ) {
2468 CENTRO = moVector3f( 0.0 , 0.0, 0.0 );
2470 glDisable( GL_TEXTURE_2D );
2474 glColor4f( 0.0, 1.0, 1.0, 1.0);
2475 glVertex3f( CENTRO.X(), CENTRO.Y(), 0.0001);
2477 glColor4f( 0.0, 1.0, 1.0, 1.0);
2478 glVertex3f( CENTRO.X() + U.X(), CENTRO.Y() + U.Y(), 0.0001);
2484 glColor4f( 1.0, 0.0, 1.0, 1.0);
2485 glVertex3f( CENTRO.X(), CENTRO.Y(), 0.0001);
2487 glColor4f( 1.0, 0.0, 1.0, 1.0);
2488 glVertex3f( CENTRO.X() + V.X(), CENTRO.Y() + V.Y(), 0.0001);
2494 glColor4f( 0.0, 0.0, 1.0, 1.0);
2495 glVertex3f( CENTRO.X(), CENTRO.Y(), 0.0001);
2497 glColor4f( 0.0, 0.0, 1.0, 1.0);
2498 glVertex3f( CENTRO.X() + W.X(), CENTRO.Y() + W.Y(), 0.0001);
2501 glEnable( GL_TEXTURE_2D );
2510 if (pFont && drawing_features>2) {
2511 for( i = 0; i<m_cols ; i++) {
2512 for( j = 0; j<m_rows ; j++) {
2515 if ((i + j*m_cols) % 10 == 0 ) {
2516 Texto = moText( IntToStr(i + j*m_cols));
2518 Texto+= moText(
"F:")+moText( (moText)FloatToStr( pPar->
Force.X() ).Left(5) + moText(
",")
2519 + (moText)FloatToStr( pPar->
Force.Y() ).Left(5)
2520 + moText(
",") + (moText)FloatToStr( pPar->
Force.Z() ).Left(5) );
2522 Texto+= moText(
"V:")+ moText( (moText)FloatToStr( pPar->
Velocity.X() ).Left(5) + moText(
",")
2523 + (moText)FloatToStr( pPar->
Velocity.Y() ).Left(5)
2524 + moText(
",") + (moText)FloatToStr( pPar->
Velocity.Z() ).Left(5) );
2526 pFont->Draw( pPar->
Pos3d.X(),
2531 Texto = moText( moText(
"(") + (moText)FloatToStr(pPar->
TCoord.X()).Left(4) + moText(
",") + (moText)FloatToStr(pPar->
TCoord.Y()).Left(4) + moText(
")") );
2533 pFont->Draw( pPar->
Pos3d.X()-sizexd2,
2534 pPar->
Pos3d.Y()+sizeyd2-2,
2537 Texto = moText( moText(
"(") + (moText)FloatToStr(pPar->
TCoord.X()+tsizex).Left(4) + moText(
",") + (moText)FloatToStr(pPar->
TCoord.Y()).Left(4) + moText(
")"));
2539 pFont->Draw( pPar->
Pos3d.X()+sizexd2-12,
2540 pPar->
Pos3d.Y()+sizeyd2-5,
2543 Texto = moText( moText(
"(") + (moText)FloatToStr(pPar->
TCoord.X()+tsizex).Left(4) + moText(
",") + (moText)FloatToStr(pPar->
TCoord.Y()+tsizey).Left(4) + moText(
")"));
2545 pFont->Draw( pPar->
Pos3d.X()+sizexd2-12,
2546 pPar->
Pos3d.Y()-sizeyd2+2,
2549 Texto = moText( moText(
"(") + (moText)FloatToStr(pPar->
TCoord.X()).Left(4) + moText(
",") + (moText)FloatToStr(pPar->
TCoord.Y()+tsizey).Left(4) + moText(
")"));
2551 pFont->Draw( pPar->
Pos3d.X()-sizexd2,
2552 pPar->
Pos3d.Y()-sizeyd2+5,
2560 if (pFont && drawing_features>2) {
2562 Texto = moText( moText(
"T2 Rest.:") + IntToStr(TimerFullRestoration.Duration()));
2563 pFont->Draw( -10.0f,
2567 Texto = moText( moText(
"T2 Revel.:") + IntToStr(TimerFullRevelation.Duration()));
2568 pFont->Draw( -10.0f,
2572 Texto = moText( moText(
"T Revel.:") + IntToStr(TimerOfRevelation.Duration()) + moText(
" rev: ") + IntToStr(time_of_revelation));
2573 pFont->Draw( -10.0f,
2577 Texto = moText( moText(
"T Rest.:") + IntToStr(TimerOfRestoration.Duration()) + moText(
" res: ") + IntToStr(time_of_restoration) );
2578 pFont->Draw( -10.0f,
2582 Texto = moText(
"Status: ");
2584 switch(revelation_status) {
2586 Texto+= moText(
"Full Restored");
2589 Texto+= moText(
"Revealing");
2592 Texto+= moText(
"Revealing");
2595 Texto+= moText(
"Full Revealed");
2598 Texto+= moText(
"Restoring");
2601 Texto+= moText(
"Restoring All");
2604 pFont->Draw( -10.0f,
2611 using namespace TUIO;
2613 void moEffectParticlesSimple::DrawTracker() {
2615 int w = m_pResourceManager->GetRenderMan()->ScreenWidth();
2616 int h = m_pResourceManager->GetRenderMan()->ScreenHeight();
2618 m_pTrackerData = NULL;
2620 bool has_motion =
false;
2621 bool has_features =
false;
2623 if (m_InletTrackerSystemIndex>-1) {
2624 moInlet* pInlet = m_Inlets.GetRef(m_InletTrackerSystemIndex);
2626 if (pInlet->Updated()) {
2627 m_pTrackerData = (moTrackerSystemData *)pInlet->GetData()->Pointer();
2637 if (m_InletTuioSystemIndex>-1) {
2638 moInlet* pInlet = m_Inlets.GetRef(m_InletTuioSystemIndex);
2640 if (pInlet->Updated()) {
2641 m_pTUIOData = (moTUIOSystemData *)pInlet->GetData()->Pointer();
2645 TuioObject* pObject;
2647 if (drawing_features > 0 ) {
2649 std::list<TuioObject*> objects = m_pTUIOData->getTuioObjects();
2651 for (std::list<TuioObject*>::iterator iter=objects.begin(); iter != objects.end(); iter++) {
2655 moVector2f position( pObject->getX(), pObject->getY() * h / w);
2657 glBindTexture(GL_TEXTURE_2D,0);
2658 glColor4f(0.0, 1.0, 1.0, 1.0);
2660 float angle = pObject->getAngle();
2675 glVertex2f((position.X() - 0.02)*normalf, (position.Y() - 0.02)*normalf);
2676 glVertex2f((position.X() - 0.02)*normalf, (position.Y() + 0.02)*normalf);
2677 glVertex2f((position.X() + 0.02)*normalf, (position.Y() + 0.02)*normalf);
2678 glVertex2f((position.X() + 0.02)*normalf, (position.Y() - 0.02)*normalf);
2683 glColor4f( 0.0,1.0,1.0,1.0);
2686 glVertex2f( position.X(), position.Y());
2687 glVertex2f( position.X() + 0.04*cos(angle), position.Y() + 0.04*sin(angle) );
2692 glColor4f( 0.4,0.6,0.2,1.0);
2695 glVertex2f( position.X(), position.Y());
2696 glVertex2f( position.X() + pObject->getXSpeed(), position.Y() + pObject->getYSpeed() );
2727 TuioCursor* pCursor;
2729 std::list<TuioCursor*> cursors = m_pTUIOData->getTuioCursors();
2731 for (std::list<TuioCursor*>::iterator iter=cursors.begin(); iter != cursors.end(); iter++) {
2735 moVector2f position( pCursor->getX(), pCursor->getY() * h / w);
2737 glBindTexture(GL_TEXTURE_2D,0);
2738 glColor4f(0.0, 0.0, 1.0, 1.0);
2743 glBegin(GL_LINE_LOOP);
2744 for(
float t = 0; t <= moMathf::TWO_PI; t += moMathf::TWO_PI / 12 )
2745 glVertex2f( r* cos(t) + position.X(), r* sin(t) + position.Y());
2769 if (m_pTrackerData ) {
2771 glDisable(GL_TEXTURE_2D);
2773 m_bTrackerInit =
true;
2781 if (m_pTrackerData->GetFeaturesCount()>0) {
2782 int tw = m_pTrackerData->GetVideoFormat().m_Width;
2783 int th = m_pTrackerData->GetVideoFormat().m_Height;
2786 m_TrackerBarycenter = moVector2f( ( ( m_pTrackerData->GetBarycenter().X() ) - 0.5),
2787 ( -( m_pTrackerData->GetBarycenter().Y() ) + 0.5) * h / w );
2791 if (drawing_features > 2 ) {
2793 glBindTexture(GL_TEXTURE_2D,0);
2794 glColor4f(0.3, 1.0, 1.0, 1.0);
2797 glVertex2f((m_TrackerBarycenter.X() - 0.02)*normalf, (m_TrackerBarycenter.Y() - 0.02)*normalf);
2798 glVertex2f((m_TrackerBarycenter.X() - 0.02)*normalf, (m_TrackerBarycenter.Y() + 0.02)*normalf);
2799 glVertex2f((m_TrackerBarycenter.X() + 0.02)*normalf, (m_TrackerBarycenter.Y() + 0.02)*normalf);
2800 glVertex2f((m_TrackerBarycenter.X() + 0.02)*normalf, (m_TrackerBarycenter.Y() - 0.02)*normalf);
2806 for (
int f = 0; f < m_pTrackerData->GetFeaturesCount(); f++)
2809 moTrackerFeature* pF = m_pTrackerData->GetFeature(f);
2811 if (pF && pF->valid) {
2813 float x = (pF->x ) - 0.5;
2814 float y = ( -(pF->y ) + 0.5 ) * h / w;
2815 float tr_x = (pF->tr_x ) - 0.5 ;
2816 float tr_y = ( -(pF->tr_y ) + 0.5 ) * h / w;
2817 float v_x = (pF->v_x );
2818 float v_y = -(pF->v_y);
2819 float vel = sqrtf( v_x*v_x+v_y*v_y );
2824 glBindTexture(GL_TEXTURE_2D,0);
2825 glColor4f(1.0, 0.0, 0.0, 1.0);
2827 if (v >= 0) glColor4f(0.0, 1.0, 0.0, 1.0);
2828 else if (v == -1) glColor4f(1.0, 0.0, 1.0, 1.0);
2829 else if (v == -2) glColor4f(1.0, 0.0, 1.0, 1.0);
2830 else if (v == -3) glColor4f(1.0, 0.0, 1.0, 1.0);
2831 else if (v == -4) glColor4f(1.0, 0.0, 1.0, 1.0);
2832 else if (v == -5) glColor4f(1.0, 0.0, 1.0, 1.0);
2838 has_features =
true;
2840 if (drawing_features > 0 ) {
2842 glPointSize((GLfloat)4);
2843 glLineWidth((GLfloat)4.0);
2845 if ( pF->is_object) {
2846 glColor4f(1.0, 0.0, 0.0, 1.0);
2854 for(
int pp=0; pp<m_pTrackerData->nPares; pp++) {
2855 k1 = m_pTrackerData->m_Pares[pp][0];
2856 k2 = m_pTrackerData->m_Pares[pp][1];
2857 if (o<3)
if (k1==f) myuplas[o++] = k2;
2858 if (o<3)
if (k2==f) myuplas[o++] = k1;
2862 moVector2f obj_v( x, y );
2863 glColor4f(1.0, 0.1, 0.1, 1.0);
2865 glLineWidth((GLfloat)2.0);
2866 for(
int pp=0; pp<3; pp++ ) {
2867 int e = myuplas[pp];
2868 moTrackerFeature* NF = m_pTrackerData->GetFeature(e);
2870 moVector2f av2( NF->x - 0.5, (-NF->y + 0.5 ) * h / w );
2873 glVertex2f(obj_v.X(),obj_v.Y());
2874 glVertex2f(av2.X(),av2.Y());
2882 glVertex2f((x - 0.008)*normalf, (y - 0.008)*normalf);
2883 glVertex2f((x - 0.008)*normalf, (y + 0.008)*normalf);
2884 glVertex2f((x + 0.008)*normalf, (y + 0.008)*normalf);
2885 glVertex2f((x + 0.008)*normalf, (y - 0.008)*normalf);
2890 if (drawing_features > 1 ) {
2892 glVertex2f((tr_x - 0.008)*normalf, (tr_y - 0.008)*normalf);
2893 glVertex2f((tr_x - 0.008)*normalf, (tr_y + 0.008)*normalf);
2894 glVertex2f((tr_x + 0.008)*normalf, (tr_y + 0.008)*normalf);
2895 glVertex2f((tr_x + 0.008)*normalf, (tr_y - 0.008)*normalf);
2899 glColor4f(1.0, 1.0, 1.0, 1.0);
2901 glVertex2f( x*normalf, y*normalf);
2902 glVertex2f( tr_x*normalf, tr_y*normalf);
2906 if ( vel > 0.01 && vel < 0.1) {
2910 if (drawing_features > 1 ) {
2912 glColor4f(0.0, 0.0, 1.0, 1.0);
2914 glLineWidth((GLfloat)2.0);
2917 glVertex2f( x*normalf, y*normalf);
2918 glVertex2f( (x+v_x)*normalf, (y+v_y)*normalf);
2937 if (!MotionActivity.Started()) {
2938 MotionActivity.Start();
2942 MotionActivity.Stop();
2947 if (!FeatureActivity.Started()) {
2948 FeatureActivity.Start();
2952 FeatureActivity.Stop();
2958 glEnable(GL_TEXTURE_2D);
2968 int w = m_pResourceManager->GetRenderMan()->ScreenWidth();
2969 int h = m_pResourceManager->GetRenderMan()->ScreenHeight();
2971 moFont* pFont = m_Config[ moR(
PARTICLES_FONT) ][MO_SELECTED][0].Font();
2983 PreDraw( tempogral, parentstate);
2992 glDisable(GL_DEPTH_TEST);
2994 glMatrixMode(GL_PROJECTION);
2996 glOrtho(-0.5,0.5,-0.5*h/w,0.5*h/w,-1,1);
3000 glDisable(GL_DEPTH_TEST);
3005 glMatrixMode(GL_PROJECTION);
3007 m_pResourceManager->GetGLMan()->SetPerspectiveView( w, h );
3010 glMatrixMode(GL_PROJECTION);
3013 if ( m_EffectState.stereoside == MO_STEREO_NONE ) {
3015 gluLookAt( m_Physics.m_EyeVector.X(),
3016 m_Physics.m_EyeVector.Y(),
3017 m_Physics.m_EyeVector.Z(),
3024 if ( m_EffectState.stereoside == MO_STEREO_LEFT ) {
3025 gluLookAt( m_Physics.m_EyeVector.X()-0.1,
3026 m_Physics.m_EyeVector.Y(),
3027 m_Physics.m_EyeVector.Z(),
3032 }
else if ( m_EffectState.stereoside == MO_STEREO_RIGHT ) {
3033 gluLookAt( m_Physics.m_EyeVector.X()+0.1,
3034 m_Physics.m_EyeVector.Y(),
3035 m_Physics.m_EyeVector.Z(),
3049 glMatrixMode(GL_MODELVIEW);
3066 glShadeModel(GL_SMOOTH);
3085 glRotatef( rz, 0.0, 0.0, 1.0 );
3108 DrawParticlesSimple( tempogral, parentstate );
3115 if (pFont && drawing_features>2) {
3116 moText infod = moText(
"gravitational:")+FloatToStr(m_Physics.gravitational)+moText(
" viscosity:")+FloatToStr(m_Physics.viscousdrag);
3117 pFont->Draw( 0.0, 0.0, infod );
3123 glMatrixMode(GL_MODELVIEW);
3125 glMatrixMode(GL_PROJECTION);
3130 void moEffectParticlesSimple::setUpLighting()
3133 float light1_ambient[4] = { 1.0, 1.0, 1.0, 1.0 };
3134 float light1_diffuse[4] = { 1.0, 0.9, 0.9, 1.0 };
3135 float light1_specular[4] = { 1.0, 0.7, 0.7, 1.0 };
3136 float light1_position[4] = { -1.0, 1.0, 1.0, 0.0 };
3137 glLightfv(GL_LIGHT1, GL_AMBIENT, light1_ambient);
3138 glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_diffuse);
3139 glLightfv(GL_LIGHT1, GL_SPECULAR, light1_specular);
3140 glLightfv(GL_LIGHT1, GL_POSITION, light1_position);
3141 glEnable(GL_LIGHT1);
3143 float light2_ambient[4] = { 0.2, 0.2, 0.2, 1.0 };
3144 float light2_diffuse[4] = { 0.9, 0.9, 0.9, 1.0 };
3145 float light2_specular[4] = { 0.7, 0.7, 0.7, 1.0 };
3146 float light2_position[4] = { 1.0, -1.0, -1.0, 0.0 };
3147 glLightfv(GL_LIGHT2, GL_AMBIENT, light2_ambient);
3148 glLightfv(GL_LIGHT2, GL_DIFFUSE, light2_diffuse);
3149 glLightfv(GL_LIGHT2, GL_SPECULAR, light2_specular);
3150 glLightfv(GL_LIGHT2, GL_POSITION, light2_position);
3153 float front_emission[4] = { 1, 1, 1, 0.0 };
3154 float front_ambient[4] = { 0.2, 0.2, 0.2, 0.0 };
3155 float front_diffuse[4] = { 0.95, 0.95, 0.8, 0.0 };
3156 float front_specular[4] = { 0.6, 0.6, 0.6, 0.0 };
3157 glMaterialfv(GL_FRONT, GL_EMISSION, front_emission);
3158 glMaterialfv(GL_FRONT, GL_AMBIENT, front_ambient);
3159 glMaterialfv(GL_FRONT, GL_DIFFUSE, front_diffuse);
3160 glMaterialfv(GL_FRONT, GL_SPECULAR, front_specular);
3161 glMaterialf(GL_FRONT, GL_SHININESS, 16.0);
3162 glColor4fv(front_diffuse);
3164 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
3165 glColorMaterial(GL_FRONT, GL_DIFFUSE);
3166 glEnable(GL_COLOR_MATERIAL);
3168 glEnable(GL_LIGHTING);
3186 MOint did,cid,state,valor;
3188 moEffect::Interaction( IODeviceManager );
3190 if (devicecode!=NULL)
3191 for(
int i=0; i<ncodes; i++) {
3193 temp = devicecode[i].First;
3197 cid = temp->devicecode;
3198 state = IODeviceManager->IODevices().GetRef(did)->GetStatus(cid);
3199 valor = IODeviceManager->IODevices().GetRef(did)->GetValue(cid);
3204 MODebug2->Push(IntToStr(valor));
3208 MODebug2->Push(IntToStr(valor));
3212 MODebug2->Push(IntToStr(valor));
3216 MODebug2->Push(IntToStr(valor));
3224 moEvent* actual = IODeviceManager->GetEvents()->First;
3228 while(actual!=NULL) {
3230 if(actual->deviceid == MO_IODEVICE_MIDI) {
3235 int CC = actual->reservedvalue1;
3236 int VAL = actual->reservedvalue2;
3241 this->
Shot(
"FOTOS", 1 );
3243 MODebug2->Message(moText(
"## Midi Shot Triggered ##"));
3249 midi_red = (float)VAL / (
float) 127.0;
3250 MODebug2->Message(moText(
"Red:")+FloatToStr(midi_red));
3253 midi_green = (float)VAL / (
float) 127.0;
3254 MODebug2->Message(moText(
"Green:")+FloatToStr(midi_green));
3257 midi_blue = (float)VAL / (
float) 127.0;
3258 MODebug2->Message(moText(
"Blue:")+FloatToStr(midi_blue));
3262 midi_maxage = (float)VAL / (
float) 127.0;
3263 MODebug2->Message(moText(
"Maxage:")+FloatToStr(midi_maxage));
3266 midi_emitionperiod = (float)VAL / (
float) 127.0;
3267 MODebug2->Message(moText(
"Emition Period:")+FloatToStr(midi_emitionperiod));
3270 midi_emitionrate = (float)VAL / (
float) 127.0;
3273 midi_randomvelocity = (float)VAL / (
float) 127.0;
3277 midi_randommotion = (float)VAL / (
float) 127.0;
3281 if (VAL==0 || VAL==127) {
3282 m_Config.PreConfPrev();
3286 if (VAL==0 || VAL==127) {
3287 m_Config.PreConfNext();
3293 MODebug2->Push(
"device in psimple!!!");
3294 MODebug2->Push(IntToStr(VAL));
3300 actual = actual->next;
3301 }
else actual = actual->next;
3308 moMoldeoObject::Update( p_eventlist );
3339 void moEffectParticlesSimple::RegisterFunctions()
3341 moMoldeoObject::RegisterFunctions();
3343 RegisterBaseFunction(
"GetDelta");
3344 RegisterFunction(
"GetParticleCount");
3345 RegisterFunction(
"GetParticle");
3346 RegisterFunction(
"GetParticlePosition");
3347 RegisterFunction(
"GetParticleSize");
3348 RegisterFunction(
"GetParticleScale");
3349 RegisterFunction(
"GetParticleVelocity");
3350 RegisterFunction(
"GetParticleRotation");
3351 RegisterFunction(
"GetParticleGraphics");
3353 RegisterFunction(
"UpdateParticle");
3354 RegisterFunction(
"UpdateParticlePosition");
3355 RegisterFunction(
"UpdateParticleSize");
3356 RegisterFunction(
"UpdateParticleScale");
3357 RegisterFunction(
"UpdateParticleVelocity");
3358 RegisterFunction(
"UpdateParticleRotation");
3359 RegisterFunction(
"UpdateParticleGraphics");
3361 RegisterFunction(
"UpdateForce");
3363 RegisterFunction(
"Shot");
3364 RegisterFunction(
"ReInit");
3366 RegisterFunction(
"DrawPoint");
3367 RegisterFunction(
"GetParticleIntersection");
3369 ResetScriptCalling();
3374 switch (iFunctionNumber - m_iMethodBase)
3377 ResetScriptCalling();
3378 return luaGetDelta(vm);
3380 ResetScriptCalling();
3381 return luaGetParticleCount(vm);
3383 ResetScriptCalling();
3384 return luaGetParticle(vm);
3386 ResetScriptCalling();
3387 return luaGetParticlePosition(vm);
3389 ResetScriptCalling();
3390 return luaGetParticleSize(vm);
3392 ResetScriptCalling();
3393 return luaGetParticleScale(vm);
3395 ResetScriptCalling();
3396 return luaGetParticleVelocity(vm);
3398 ResetScriptCalling();
3399 return luaGetParticleRotation(vm);
3401 ResetScriptCalling();
3402 return luaGetParticleGraphics(vm);
3406 ResetScriptCalling();
3407 return luaUpdateParticle(vm);
3409 ResetScriptCalling();
3410 return luaUpdateParticlePosition(vm);
3412 ResetScriptCalling();
3413 return luaUpdateParticleSize(vm);
3415 ResetScriptCalling();
3416 return luaUpdateParticleScale(vm);
3418 ResetScriptCalling();
3419 return luaUpdateParticleVelocity(vm);
3421 ResetScriptCalling();
3422 return luaUpdateParticleRotation(vm);
3424 ResetScriptCalling();
3425 return luaUpdateParticleGraphics(vm);
3428 ResetScriptCalling();
3429 return luaUpdateForce(vm);
3433 ResetScriptCalling();
3437 ResetScriptCalling();
3438 return luaReInit(vm);
3441 ResetScriptCalling();
3442 return luaDrawPoint(vm);
3445 ResetScriptCalling();
3446 return luaGetParticleIntersection(vm);
3449 NextScriptCalling();
3450 return moMoldeoObject::ScriptCalling( vm, iFunctionNumber );
3456 int moEffectParticlesSimple::luaDrawPoint(moLuaVirtualMachine& vm)
3458 lua_State *state = (lua_State *) vm;
3460 MOfloat x = (MOfloat) lua_tonumber (state, 1);
3461 MOfloat y = (MOfloat) lua_tonumber (state, 2);
3463 glDisable(GL_TEXTURE_2D);
3465 glColor4f( 1.0, 1.0, 1.0, 1.0);
3475 int moEffectParticlesSimple::luaGetDelta(moLuaVirtualMachine& vm)
3477 lua_State *state = (lua_State *) vm;
3479 lua_pushnumber(state, (lua_Number) dt );
3484 int moEffectParticlesSimple::luaGetParticleCount(moLuaVirtualMachine& vm)
3486 lua_State *state = (lua_State *) vm;
3488 lua_pushnumber(state, (lua_Number) m_ParticlesSimpleArray.Count() );
3495 int moEffectParticlesSimple::luaGetParticle(moLuaVirtualMachine& vm)
3497 lua_State *state = (lua_State *) vm;
3499 MOint i = (MOint) lua_tonumber (state, 1);
3503 Par = m_ParticlesSimpleArray[i];
3507 lua_pushnumber(state, (lua_Number) Par->
Age.Duration() );
3508 lua_pushnumber(state, (lua_Number) Par->
Visible );
3509 lua_pushnumber(state, (lua_Number) Par->
Mass );
3510 lua_pushnumber(state, (lua_Number) Par->
MaxAge );
3518 int moEffectParticlesSimple::luaGetParticleRotation(moLuaVirtualMachine& vm)
3520 lua_State *state = (lua_State *) vm;
3522 MOint i = (MOint) lua_tonumber (state, 1);
3526 moVector3f Rotation;
3528 Par = m_ParticlesSimpleArray[i];
3533 lua_pushnumber(state, (lua_Number) Rotation.X() );
3534 lua_pushnumber(state, (lua_Number) Rotation.Y() );
3535 lua_pushnumber(state, (lua_Number) Rotation.Z() );
3538 lua_pushnumber(state, (lua_Number) 0 );
3539 lua_pushnumber(state, (lua_Number) 0 );
3540 lua_pushnumber(state, (lua_Number) 0 );
3555 int moEffectParticlesSimple::luaGetParticleGraphics(moLuaVirtualMachine& vm)
3557 lua_State *state = (lua_State *) vm;
3559 MOint i = (MOint) lua_tonumber (state, 1);
3563 moVector3f Rotation;
3565 Par = m_ParticlesSimpleArray[i];
3568 int frameactual = 0;
3573 if (Par->
MOId==-1) {
3583 lua_pushnumber(state, (lua_Number) moid );
3584 lua_pushnumber(state, (lua_Number) frameactual );
3585 lua_pushnumber(state, (lua_Number) framecount );
3586 lua_pushnumber(state, (lua_Number) frameps );
3591 lua_pushnumber(state, (lua_Number) 0 );
3592 lua_pushnumber(state, (lua_Number) 0 );
3593 lua_pushnumber(state, (lua_Number) 0 );
3594 lua_pushnumber(state, (lua_Number) 0 );
3603 int moEffectParticlesSimple::luaGetParticlePosition(moLuaVirtualMachine& vm)
3605 lua_State *state = (lua_State *) vm;
3607 MOint i = (MOint) lua_tonumber (state, 1);
3611 moVector3f Position;
3613 Par = m_ParticlesSimpleArray[i];
3617 Position = Par->
Pos3d;
3618 lua_pushnumber(state, (lua_Number) Position.X() );
3619 lua_pushnumber(state, (lua_Number) Position.Y() );
3620 lua_pushnumber(state, (lua_Number) Position.Z() );
3623 lua_pushnumber(state, (lua_Number) 0 );
3624 lua_pushnumber(state, (lua_Number) 0 );
3625 lua_pushnumber(state, (lua_Number) 0 );
3631 int moEffectParticlesSimple::luaGetParticleSize(moLuaVirtualMachine& vm)
3633 lua_State *state = (lua_State *) vm;
3635 MOint i = (MOint) lua_tonumber (state, 1);
3641 Par = m_ParticlesSimpleArray[i];
3645 double part_timer = 0.001f * (double)(Par->
Age.Duration());
3647 if (m_pParticleTime) {
3648 m_pParticleTime->GetData()->SetDouble(part_timer);
3649 m_pParticleTime->Update(
true);
3655 lua_pushnumber(state, (lua_Number) Size.X()*sx );
3656 lua_pushnumber(state, (lua_Number) Size.Y()*sy );
3659 lua_pushnumber(state, (lua_Number) 0 );
3660 lua_pushnumber(state, (lua_Number) 0 );
3666 int moEffectParticlesSimple::luaGetParticleScale(moLuaVirtualMachine& vm)
3668 lua_State *state = (lua_State *) vm;
3670 MOint i = (MOint) lua_tonumber (state, 1);
3676 Par = m_ParticlesSimpleArray[i];
3680 lua_pushnumber(state, (lua_Number) Scale );
3682 lua_pushnumber(state, (lua_Number) 0 );
3688 int moEffectParticlesSimple::luaGetParticleVelocity(moLuaVirtualMachine& vm)
3690 lua_State *state = (lua_State *) vm;
3692 MOint i = (MOint) lua_tonumber (state, 1);
3696 moVector3f Velocity = Par->
Velocity;
3700 lua_pushnumber(state, (lua_Number) Velocity.X() );
3701 lua_pushnumber(state, (lua_Number) Velocity.Y() );
3702 lua_pushnumber(state, (lua_Number) Velocity.Z() );
3710 int moEffectParticlesSimple::luaGetParticleIntersection(moLuaVirtualMachine& vm)
3712 lua_State *state = (lua_State *) vm;
3714 MOfloat x = (MOfloat) lua_tonumber (state, 1);
3715 MOfloat y = (MOfloat) lua_tonumber (state, 2);
3719 moVector3f Position;
3737 for(
int i=0; i<m_ParticlesSimpleArray.Count(); i++ ) {
3739 Par = m_ParticlesSimpleArray[i];
3742 Position = Par->
Pos3d;
3746 xc = Par->
Pos3d.X()*sx*cos(rz/180) + tx;
3747 yc = Par->
Pos3d.Y()*sy*sin(rz/180) + ty;
3748 x1 = ( Par->
Pos3d.X() - Par->
Size.X()/2 ) * sx + tx;
3749 x2 = ( Par->
Pos3d.X() + Par->
Size.X()/2 ) * sx + tx;
3750 y1 = ( Par->
Pos3d.Y() - Par->
Size.Y()/2 ) * sy + ty;
3751 y2 = ( Par->
Pos3d.Y() + Par->
Size.Y()/2 ) * sy + ty;
3757 sizeu = Par->
Size.X()/2 * sx;
3758 sizev = Par->
Size.Y()/2 * sx;
3760 moVector2f feat( x, y );
3761 moVector2f u( ux, uy );
3762 moVector2f v( vx, vy );
3764 featuv = moVector2f ( fabs( feat.Dot(u)), fabs( feat.Dot(v) ) );
3765 if ( featuv.X() < sizeu && featuv.Y() < sizev ) {
3771 lua_pushnumber(state, (lua_Number) index );
3777 int moEffectParticlesSimple::luaUpdateParticle( moLuaVirtualMachine& vm ) {
3778 lua_State *state = (lua_State *) vm;
3780 MOint i = (MOint) lua_tonumber (state, 1);
3782 MOint age = (MOint) lua_tonumber (state, 2);
3783 MOint visible = (MOint) lua_tonumber (state, 3);
3784 MOint mass = (MOint) lua_tonumber (state, 4);
3785 MOint maxage = (MOint) lua_tonumber (state, 5);
3790 Par->
Age.SetDuration( age);
3800 int moEffectParticlesSimple::luaUpdateParticlePosition( moLuaVirtualMachine& vm ) {
3801 lua_State *state = (lua_State *) vm;
3803 MOint i = (MOint) lua_tonumber (state, 1);
3805 MOfloat x = (MOfloat) lua_tonumber (state, 2);
3806 MOfloat y = (MOfloat) lua_tonumber (state, 3);
3807 MOfloat z = (MOfloat) lua_tonumber (state, 4);
3812 Par->
Pos3d = moVector3f( x, y, z );
3819 int moEffectParticlesSimple::luaUpdateParticleSize( moLuaVirtualMachine& vm ) {
3820 lua_State *state = (lua_State *) vm;
3822 MOint i = (MOint) lua_tonumber (state, 1);
3824 MOfloat x = (MOfloat) lua_tonumber (state, 2);
3825 MOfloat y = (MOfloat) lua_tonumber (state, 3);
3831 Par->
Size = moVector2f( x, y );
3838 int moEffectParticlesSimple::luaUpdateParticleScale( moLuaVirtualMachine& vm ) {
3839 lua_State *state = (lua_State *) vm;
3841 MOint i = (MOint) lua_tonumber (state, 1);
3843 MOfloat scale = (MOfloat) lua_tonumber (state, 2);
3855 int moEffectParticlesSimple::luaUpdateParticleVelocity( moLuaVirtualMachine& vm ) {
3856 lua_State *state = (lua_State *) vm;
3858 MOint i = (MOint) lua_tonumber (state, 1);
3860 MOfloat x = (MOfloat) lua_tonumber (state, 2);
3861 MOfloat y = (MOfloat) lua_tonumber (state, 3);
3862 MOfloat z = (MOfloat) lua_tonumber (state, 4);
3867 Par->
Velocity = moVector3f( x, y, z );
3874 int moEffectParticlesSimple::luaUpdateParticleRotation( moLuaVirtualMachine& vm ) {
3875 lua_State *state = (lua_State *) vm;
3877 MOint i = (MOint) lua_tonumber (state, 1);
3879 MOfloat rx = (MOfloat) lua_tonumber (state, 2);
3880 MOfloat ry = (MOfloat) lua_tonumber (state, 3);
3881 MOfloat rz = (MOfloat) lua_tonumber (state, 4);
3886 Par->
Rotation = moVector3f( rx, ry, rz );
3893 int moEffectParticlesSimple::luaUpdateParticleGraphics( moLuaVirtualMachine& vm ) {
3894 lua_State *state = (lua_State *) vm;
3896 MOint i = (MOint) lua_tonumber (state, 1);
3898 MOuint moid = (MOuint) lua_tonumber (state, 2);
3899 MOuint actualframe = (MOuint) lua_tonumber (state, 3);
3900 MOuint frameps = (MOuint) lua_tonumber (state, 4);
3901 MOuint frameforced = (MOuint) lua_tonumber (state, 5);
3917 int moEffectParticlesSimple::luaUpdateForce( moLuaVirtualMachine& vm ) {
3926 int moEffectParticlesSimple::luaShot( moLuaVirtualMachine& vm) {
3928 lua_State *state = (lua_State *) vm;
3930 if (lua_isboolean(state,1)) {
3931 bool vb = lua_toboolean(state,1);
3932 vb ? MODebug2->Push(moText(
"true")) : MODebug2->Push(moText(
"false"));
3934 char *text = (
char *) lua_tostring (state, 1);
3935 int shot_type = lua_tonumber (state, 2);
3936 int shot_file = lua_tonumber (state, 3);
3938 moText source_to_shot = moText(text);
3939 this->
Shot( source_to_shot, shot_type, shot_file );
3945 int moEffectParticlesSimple::luaReInit(moLuaVirtualMachine& vm ) {
3947 lua_State *state = (lua_State *) vm;
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
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.
void TrackParticle(int partid)
moVector3f m_EmitterVector
void Destroy(moEffect *fx)
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)
MO_PLG_API void DestroyEffectFactory()
moTimer Age
Age of the particle.
0: Alineado. Los lugares de nacimientos están alineados con el orden de los vertices del emisor...
0: Grilla (un rectángulo de "width" x "height") 2D
moParticlesSimpleAttractorMode
Attractor Mode.
moVector2f TSize
particle texture size
moParticlesSimpleEmitterType m_EmitterType
moVector3f m_PositionVector
1: each particle attract perp to a face of the grid
0: accelerate with no stop
moVector2f Size
particle size
moParticlesSimpleAttractorType m_AttractorType
MO_PLG_API moEffectFactory * CreateEffectFactory()
MOboolean Finish()
Finalizacion.
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
8: CÃrculo ( una ronda de "width"X"height" partÃculas )
moParticlesSimple * m_pLastBordParticle
moVector3f m_VelocityVector
moParticlesRandomMethod
Random Method.
moParticlesSimpleEmitterType
Emitter Type.
moParticlesSimpleAttractorMode m_AttractorMode
1: Same Texture Image Divided In Different Fragments for each Particle (taken from texture...
moDefineDynamicArray(moParticlesSimpleArray) moEffectParticlesSimpleFactory *m_EffectParticlesSimpleFactory
float ImageProportion
Texture image proportion Width / Height ....
MOint GLId2
para asociar la textura al momento de la creación
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.
moVector3f Destination
Destination.
moParticlesRandomMethod m_RandomMethod
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 )
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.
bool Visible
Exists but is invisible.
moVector2f TCoord
texture coordinate
moParticlesSimpleAttractorType
Attractor Type.
moVector3f Force
Self force (propulsion) of the particle.
moVector3f m_MotionVector
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.
moVector3f m_AttractorVector
void Draw(moTempo *, moEffectState *parentstate=NULL)
Dibujado.
moEffectParticlesSimple()
Constructor.
moParticlesOrientationMode
Orientation Method.