libmoldeo (Moldeo 1.0 Core)  1.0
libmoldeo is the group of objects and functions that executes the basic operations of Moldeo 1.0 Platform.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
moEffect.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2 
3  moEffect.cpp
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 *******************************************************************************/
30 
31 // Clase padre de todos los efectos //
32 
33 #include "moEffect.h"
34 #include <moArray.h>
35 #include <moDataManager.h>
36 #include <moFileManager.h>
37 
38 
39 moDefineDynamicArray(moEffectsArray)
40 
41 
42 
43 moEffect::moEffect() {
44  SetType( MO_OBJECT_EFFECT );
45  devicecode = NULL;
46  ncodes = 0;
47 
48  InletTime = InletT = InletTimems = NULL;
49  InletTimes = InletMilliseconds = NULL;
50  InletSeconds = InletMilliseconds = NULL;
51 }
52 
54 
55 }
56 
57 
58 const
60  return m_EffectState;
61 }
62 
63 bool moEffect::SetEffectState( const moEffectState& p_state ) {
64 
65  //TODO: check valid states!
66  m_MobState = (moMobState&) p_state;
67  m_EffectState = p_state;
68  return true;
69 
70 }
71 
72 const
74  return (moMobState&)m_EffectState;
75 }
76 
77 bool
78 moEffect::SetState( const moMobState& p_MobState ) {
79 
80  //TODO: check things before commit changes
81  m_MobState = p_MobState;
82  (moMobState&)(m_EffectState) = p_MobState;
83  return true;
84 }
85 
86 
87 // Esta funcion debe ser llamada al comienzo en cada implementacion
88 // de la funcion virtual Init(). Contiene el codigo obligatorio.
89 // 1) Levanta el config de disco
90 // 2) el parametro del Syncro
91 // 3) Inicializa el efecto en la primera preconfiguración.
94 
95  moText debug;
96 
97  devicecode = NULL;
99 
100  //glewInit();
101  InletTimems = new moInlet();
102  if (InletTimems) {
103  //Inlet->Init( "tempo", m_Inlets.Count(), param.GetPtr() );
104  //param.SetExternData( Inlet->GetData() );
105  ((moConnector*)InletTimems)->Init( moText("timems"), m_Inlets.Count(), MO_DATA_NUMBER_DOUBLE );
106  m_Inlets.Add(InletTimems);
107  }
108 
109  InletTimes = new moInlet();
110  if (InletTimes) {
111  //Inlet->Init( "tempo", m_Inlets.Count(), param.GetPtr() );
112  //param.SetExternData( Inlet->GetData() );
113  ((moConnector*)InletTimes)->Init( moText("times"), m_Inlets.Count(), MO_DATA_NUMBER_DOUBLE );
114  m_Inlets.Add(InletTimes);
115  }
116 
118  InletTime = new moInlet();
119  if (InletTime) {
120  //Inlet->Init( "tempo", m_Inlets.Count(), param.GetPtr() );
121  //param.SetExternData( Inlet->GetData() );
122  ((moConnector*)InletTime)->Init( moText("time"), m_Inlets.Count(), MO_DATA_NUMBER_DOUBLE );
123  m_Inlets.Add(InletTime);
124  }
125 
126  InletTempo = new moInlet();
127  if (InletTempo) {
128  //Inlet->Init( "tempo", m_Inlets.Count(), param.GetPtr() );
129  //param.SetExternData( Inlet->GetData() );
130  ((moConnector*)InletTempo)->Init( moText("tempo"), m_Inlets.Count(), MO_DATA_NUMBER_DOUBLE );
131  m_Inlets.Add(InletTempo);
132  }
133 
134  InletT = new moInlet();
135  if (InletT) {
136  //Inlet->Init( "tempo", m_Inlets.Count(), param.GetPtr() );
137  //param.SetExternData( Inlet->GetData() );
138  ((moConnector*)InletT)->Init( moText("t"), m_Inlets.Count(), MO_DATA_NUMBER_DOUBLE );
139  m_Inlets.Add(InletT);
140  }
141 
142 
143  InletMilliseconds = new moInlet();
144  if (InletMilliseconds) {
145  //Inlet->Init( "tempo", m_Inlets.Count(), param.GetPtr() );
146  //param.SetExternData( Inlet->GetData() );
147  ((moConnector*)InletMilliseconds)->Init( moText("milliseconds"), m_Inlets.Count(), MO_DATA_NUMBER_DOUBLE );
148  m_Inlets.Add(InletMilliseconds);
149  }
150 
151  InletSeconds = new moInlet();
152  if (InletSeconds) {
153  //Inlet->Init( "tempo", m_Inlets.Count(), param.GetPtr() );
154  //param.SetExternData( Inlet->GetData() );
155  ((moConnector*)InletSeconds)->Init( moText("seconds"), m_Inlets.Count(), MO_DATA_NUMBER_DOUBLE );
156  m_Inlets.Add(InletSeconds);
157  }
158 
159 
160  if (!m_pResourceManager) return false;
161 
164  if (moMoldeoObject::Init()) {
167  } else return false;
168 
169  isyncro = m_Config.GetParamIndex("syncro");
170  iphase = m_Config.GetParamIndex("phase");
171  if(isyncro==MO_PARAM_NOT_FOUND) MODebug2->Error(moText("syncro parameter missing."));
172  if(iphase==MO_PARAM_NOT_FOUND) MODebug2->Error(moText("phase parameter missing."));
173 
174 
175  //if(m_EffectState.fulldebug==MO_ACTIVATED) MODebug2->Push(moText("Initializing m_EffectState"));//debug
176  //if(m_EffectState.fulldebug==MO_ACTIVATED) MODebug2->Push(moText("Setting preconfigs..."));//debug
177 
178  //devicecode es llenado por la moConsole(por defecto)
179  //si en el nombrefecto.cfg encontramos el parametro ":acciones" entonces tomamos las acciones
180  //definidas arbitrariamente allí....
181  //se tratará de mantener valuees como: MOACCIONES_ALPHA... para poder hacer un FADE
182  //la idea es que sea completamente reconfigurable la interfaz del teclado
183 
184  MODebug2->Message("moEffect::PreInit > OK! for object: " + GetName()+ " config: " + GetConfigName() + " label: " + GetLabelName() );
185 
186  return true;
187 }
188 
190  if (moScript::IsInitialized()) {
191  if (ScriptHasFunction("Draw")) {
192  SelectScriptFunction("Draw");
194  }
195  }
196 }
197 
199  if (moScript::IsInitialized()) {
200  if (ScriptHasFunction("Interaction")) {
201  SelectScriptFunction("Interaction");
203  }
204  }
205 }
206 
207 
208 // Esta funcion debe ser llamada al comienzo en cada implementacion
209 // de la funcion virtual Draw(). Contiene el codigo obligatorio.
210 // 1) toma el nuevo Syncro del config
211 // 2) fija el value del tempo dependiendo si esta o no syncronizado con el master
212 void moEffect::PreDraw( moTempo *tempogral,moEffectState* parentstate) {
213 
214  BeginDraw( tempogral, parentstate );
215 
216 }
217 
218 void moEffect::BeginDraw( moTempo *tempogral,moEffectState* parentstate) {
219 
220  MOdouble syncrotmp;
221 
222  if(isyncro != MO_PARAM_NOT_FOUND) {
224  if (sync) {
225  moMathFunction* pFun = sync->Fun();
226  if (sync->Type()==MO_DATA_FUNCTION && pFun) {
227  //m_EffectState.tempo.syncro = pFun->Eval(m_EffectState.tempo.ang);
228  m_EffectState.tempo.syncro = pFun->Eval();
229  }
230  else m_EffectState.tempo.syncro = sync->Double();
231  }
232 
234  //m_EffectState.tempo.syncro = m_Config.Fun(isyncro).Eval( m_EffectState.tempo.ang );
235  }
236 
238  {
239  //m_EffectState.tempo.ticks = moGetTicks();
243  }
244  else
245  {
246  syncrotmp = m_EffectState.tempo.syncro;
247  m_EffectState.tempo = *tempogral;
248  m_EffectState.tempo.syncro = syncrotmp;
250  //if(m_EffectState.fulldebug==MO_ACTIVATED) MODebug2->Push("SYNCRO: " + FloatToStr(m_EffectState.tempo.syncro,3));
251  }
252 
253  if(iphase != MO_PARAM_NOT_FOUND) {
254  moData *phase = m_Config.GetParam(iphase).GetData();
255  if (phase) {
256  moMathFunction* pFun = phase->Fun();
257  if (phase->Type()==MO_DATA_FUNCTION && pFun) {
258  //m_EffectState.tempo.ang+= pFun->Eval(m_EffectState.tempo.ang);
259  m_EffectState.tempo.ang+= pFun->Eval();
260  }
261  else m_EffectState.tempo.ang+= phase->Double();
262  }
263  }
264 
265  if(parentstate!=NULL) {
266  //asginar parametros del state del padre al state del hijo
267  m_EffectState = *parentstate;
268  }
269 
270  if (InletTime) {
272  }
273  if (InletTimems) {
275  }
276  if (InletMilliseconds) {
278  }
279  if (InletTimes) {
280  if (InletTimes->GetData()) InletTimes->GetData()->SetDouble( (double)m_EffectState.tempo.Duration()/1000.0 );
281  }
282  if (InletSeconds) {
284  }
285  if (InletT) {
287  }
288  if (InletTempo) {
290  }
291 
292  ScriptExeRun();
293 
294 }
295 
297 
298  ScriptExeDraw();
299 
300  if (m_pResourceManager)
303 
304 
305  if (m_pResourceManager)
308 
309 }
310 
311 
312 // Esta funcion debe ser llamada al comienzo en cada implementacion
313 // de la funcion virtual Finish(). Contiene el codigo obligatorio.
315  //vaciamos las listas de codigos de acciones
316  if(devicecode!=NULL)
317  delete[] devicecode;
318  devicecode = NULL;
319  return true;
320 }
321 
322 void
324 
325  moText texto;
326  MOint nroparam;
327  MOuint i,j,k;
328  MOint coddisp,accioncod;
329  moText strcod;
330 
331  if(m_EffectState.fulldebug==MO_ACTIVATED) MODebug2->Message(moText("Cargando codigos de dispositivo especificos..."));
332 
333  nroparam = m_Config.GetParamIndex("codes");
334  if(nroparam==MO_PARAM_NOT_FOUND) return;//se va, no hay codigos
335  m_Config.SetCurrentParamIndex(nroparam);
337  ncodes = (MOint)m_Config.GetValuesCount(nroparam);
339 
340 #ifdef MO_DEBUG
341  texto = moText("\nCargando codigos efecto ");
342  texto += GetName();
343  texto += moText(" ncodes: ");
344  texto += IntToStr(ncodes);
345  //printf(texto);
346  MODebug2->Log( texto );
347 #endif
348  if(ncodes>0)
349  for( i = 0; i < (MOuint)ncodes; i++) {
350  m_Config.SetCurrentValueIndex(nroparam,i);
351  for( k = 1; k < m_Config.GetParam().GetValue().GetSubValueCount(); k++) {
352  accioncod = i;
353  coddisp = -1;
354  strcod = m_Config.GetParam().GetValue().GetSubValue(k).Text();
355  for( j=0 ; j < consolaesarray->IODevices().Count(); j++) {
356  moIODevice* pIODevice;
357  pIODevice = consolaesarray->IODevices().GetRef(j);
358  if (pIODevice) {
359  if (strcod.Trim().Length()>0) {
360  coddisp = pIODevice->GetCode(strcod);
361  } else {
362  MODebug2->Error("string code is empty: [" + moText(strcod) +"].");
363  }
364 
365  } else {
366 
367  MODebug2->Error("Device id:" + IntToStr(j) +" is null.");
368 
369  }
370  if(coddisp != -1) break; //lo encontramos "j" es el nro de disp y "coddisp" el id
371  }
372 
373  if((accioncod>=0) &&(accioncod<ncodes)) {
374  if(coddisp==-1) {
375  texto = moText("\n");
376  texto += GetConfigName();
377  texto += moText(".cfg: no se encontró en ningun dispositivo el codigo de dispositivo correspondiente a: ");
378  texto += strcod;
379  MODebug2->Error(texto);
380  } else {
381  devicecode[accioncod].Add(j,coddisp); //agregar un cod disp a la lista
382 #ifdef MO_DEBUG
383  texto = moText("\naccioncod: ");
384  texto += IntToStr(accioncod);
385  texto += moText(" strcod: ");
386  texto += strcod;
387  texto += moText(" dispositivo: ");
388  texto += IntToStr(j);
389  texto += moText(" codisp: ");
390  texto += IntToStr(coddisp);
391  MODebug2->Log(texto);
392 #endif
393  }
394  } else {
395  MODebug2->Error("error: codigo de la accion fuera de rango");
396  }
397 
398  }
399  }
400 
401  if(m_EffectState.fulldebug==MO_ACTIVATED) MODebug2->Push(moText("Codes loaded."));
402 }
403 
404 
406 
407  Update(consolaes->GetEvents());
408 
409 }
410 
411 void moEffect::SetColor( const moColorRGBA& color_rgba, double alpha, moEffectState& pstate ) {
412 
414  color_rgba.X() * pstate.tintr,
415  color_rgba.Y() * pstate.tintg,
416  color_rgba.Z() * pstate.tintb
417  );
418 
419  m_Effect3D.m_Material.m_fOpacity = color_rgba.W() * alpha * pstate.alpha;
420 
421 #ifndef OPENGLESV2
422  glColor4f( m_Effect3D.m_Material.m_Color.X(),
426 #endif
427 }
428 
429 void moEffect::SetColor( moValue& color, moValue& alpha, moEffectState& pstate ) {
430  moColorRGBA color_rgba = moColorRGBA(
431  color[MO_RED].Eval(),
432  color[MO_GREEN].Eval(),
433  color[MO_BLUE].Eval(),
434  color[MO_ALPHA].Eval()
435  );
436  double valpha = alpha[0].Eval();
437 
438  SetColor( color_rgba, valpha, pstate );
439 
440 }
441 
442 void moEffect::SetColor( moParam& color, moParam& alpha, moEffectState& pstate ) {
443 
444  //moValue& Color( color[MO_SELECTED] );
445  //SetColor( Color, alpha[MO_SELECTED], pstate );
446 
447  moColorRGBA color_rgba = moColorRGBA(
448  color[MO_SELECTED][MO_RED].Eval(),
449  color[MO_SELECTED][MO_GREEN].Eval(),
450  color[MO_SELECTED][MO_BLUE].Eval(),
451  color[MO_SELECTED][MO_ALPHA].Eval()
452  );
453  double valpha = alpha.GetData()->Eval();
454  SetColor( color_rgba, valpha, pstate );
455 }
456 
458 
459 
460  m_Effect3D.m_Material.m_PolygonMode = polygonmode;
461 #ifndef OPENGLESV2
462  switch( polygonmode ) {
463 
464  case MO_POLYGONMODE_FILL:
465  glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
466  break;
467 
468  case MO_POLYGONMODE_LINE:
469  glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
470  glBindTexture(GL_TEXTURE_2D, 0);
471  break;
472 
474 
475  break;
476  default:
477  break;
478  }
479 #endif // OPENGLESV2
480 }
481 
482 
484 
485  m_Effect3D.m_Material.m_Blending = blending;
486 
487  glEnable (GL_BLEND);
488  switch(blending) {
489  //ALPHA DEPENDENT
491  //TRANSPARENCY [Rs * As] + [Rd *(1 -As)] = As*(Rs-Rd) + Rd
492  glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
493  break;
495  //ADDITIVE WITH TRANSPARENCY: Rs*As + Rd*Ad
497  glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
498 
500  //ADDITIVE WITH SRC TRANSPARENCY: Rs*As + Rd
501  //glBlendFunc(GL_SRC_ALPHA,GL_ONE);
502  break;
503 
504  //NON ALPHA
505  case MO_BLENDING_MIXING:
506  //MIXING [Rs *( 1 - Rd )] + [ Rd * 1] = Rs + Rd - Rs*Rd
507  //additive without saturation
508  glBlendFunc( GL_ONE_MINUS_DST_COLOR, GL_ONE );
509  break;
511  //MULTIPLY: [Rs * Rd] + [Rd * 0] = Rs * Rd
512  glBlendFunc( GL_DST_COLOR, GL_ZERO );
513  break;
515  //EXCLUSION: [Rs *(1 - Rd)] + [Rd *(1 - Rs)] = Rs + Rd - 2*Rs*Rd
516  glBlendFunc( GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR);//
517  break;
519  //ADDITIVE Rs+Rd
520  glBlendFunc( GL_ONE, GL_ONE );
521  break;
522  case MO_BLENDING_OVERLAY:
523  //OVERLAY: 2*Rs*Rd
524  glBlendFunc( GL_DST_COLOR, GL_SRC_COLOR );
525  break;
527  //SUBSTRACTIVE [Rs *( 1 - Rd )] + [ Rd * 0] = Rs - Rs*Rd
528  //substractive
529  glBlendFunc( GL_ONE_MINUS_DST_COLOR, GL_ZERO );
530  break;
532  // [Rs * min(As,1-Ad) ] + [ Rd * Ad]
533  //
534  glBlendFunc( GL_SRC_ALPHA_SATURATE, GL_DST_ALPHA);
535  break;
536  //Multiply mode:(a*b)
537  //Average mode:(a+b)/2
538  //Screen mode: f(a,b) = 1 -(1-a) *(1-b)
539  //Difference mode: f(a,b) = |a - b|
540  //Negation mode: f(a,b) = 1 - |1 - a - b|
541  //Exclusion mode f(a,b) = a + b - 2ab or f(a,b) = average(difference(a,b),negation(a,b))
542  //Overlay mode f(a,b) = 2ab(for a < ) 1 - 2 *(1 - a) *(1 - b)(else)
543  //Color dodge mode: f(a,b) = a /(1 - b)
544  //Color burn mode: f(a,b) = 1 -(1 - a) / b
545  //Inverse color dodge mode: f(a,b) = b /(1 - a)
546  //Inverse color burn mode: f(a,b) = 1 -(1 - b) / a
547  default: //alpha transparent
548  glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
549  break;
550  }
551 
552 }
553 
556  Activate();
557 }
558 
561  Deactivate();
562 }
563 
566 }
567 
570 }
571 
574 }
575 
577  this->m_EffectState.enabled*= -1;
578 }
579 
580 
583 }
584 
585 
588 }
589 
591  return (this->m_EffectState.synchronized == MO_ACTIVATED);
592 }
593 
597 }
598 
599 
600 double
601 moEffect::TempoDelta( double p_delta ) {
602 
603  if (p_delta!=0.0) this->Unsynchronize();
604 
605  m_EffectState.tempo.delta+=p_delta;
606  if(m_EffectState.tempo.delta>2.0)
607  m_EffectState.tempo.delta = 2.0;
608  else
609  if( m_EffectState.tempo.delta < 0.005 )
610  m_EffectState.tempo.delta = 0.0;
611 
612  return m_EffectState.tempo.delta;
613 }
614 
615 double
616 moEffect::SetTempoDelta( double p_delta ) {
617 
618  this->Unsynchronize();
619 
620  m_EffectState.tempo.delta = p_delta;
621  if(m_EffectState.tempo.delta>2.0)
622  m_EffectState.tempo.delta = 2.0;
623  else
624  if( m_EffectState.tempo.delta < 0.005 )
625  m_EffectState.tempo.delta = 0.0;
626 
627  return m_EffectState.tempo.delta;
628 }
629 
630 double
632  return m_EffectState.tempo.delta;
633 }
634 
635 
636 double
637 moEffect::TempoFactor( double p_factor ) {
638  m_EffectState.tempo.factor+=p_factor;
639  if(m_EffectState.tempo.factor>50.0)
640  m_EffectState.tempo.factor = 50.0;
641  else
642  if(m_EffectState.tempo.factor<1.0)
643  m_EffectState.tempo.factor = 1.0;
644  return m_EffectState.tempo.factor;
645 }
646 
647 double
649  return m_EffectState.tempo.factor;
650 }
651 
652 
653 double moEffect::Alpha( double alpha ) {
654  m_EffectState.alpha+= alpha;
655  if(m_EffectState.alpha>=1.0)
656  m_EffectState.alpha=1.0;
657  else
658  if(m_EffectState.alpha<=0.0)
659  m_EffectState.alpha=0.0;
660  return m_EffectState.alpha;
661 }
662 
663 double moEffect::GetAlpha() const {
664  return m_EffectState.alpha;
665 }
666 
667 double
668 moEffect::Amplitude( double amplitude ) {
669  m_EffectState.amplitude = amplitude;
670  return m_EffectState.amplitude;
671 }
672 
673 double
675  return m_EffectState.amplitude;
676 }
677 
678 double
679 moEffect::Magnitude( double magnitude ) {
680  m_EffectState.magnitude = magnitude;
681  return m_EffectState.magnitude;
682 }
683 
684 double
686  return m_EffectState.magnitude;
687 }
688 
689 void
690 moEffect::TintCSV( double tintc, double tints, double tint ) {
691  m_EffectState.tint+= tint;
692  m_EffectState.tintc+= tintc;
693  m_EffectState.tints+= tints;
694 
695  //circular (0..1) > (0..1) > (0..1)
696  if (m_EffectState.tintc>1.0) {
697  m_EffectState.tintc = 0.0;
698  } else if (m_EffectState.tintc<0.0) {
699  m_EffectState.tintc = 1.0;
700  }
701 
702  //lineal [0 .. 1.0]
703  if (m_EffectState.tints>1.0) {
704  m_EffectState.tints = 1.0;
705  } else if (m_EffectState.tints<0.0) {
706  m_EffectState.tints = 0.0;
707  }
708 
709  //lineal 0..1.0
710  if (m_EffectState.tint>1.0) {
711  m_EffectState.tint = 1.0;
712  } else if (m_EffectState.tint<0.0) {
713  m_EffectState.tint = 0.0;
714  }
715 
716 
718 }
719 
720 
724 }
725 
729 }
730 
731 
732 
734  Unsynchronize();
735  return this->m_EffectState.tempo.Start();
736 }
737 
739  Unsynchronize();
740  return this->m_EffectState.tempo.Stop();
741 }
742 
744  Unsynchronize();
745  return this->m_EffectState.tempo.Pause();
746 }
747 
749  Unsynchronize();
750  return this->m_EffectState.tempo.Continue();
751 }
752 
754  return this->m_EffectState.tempo.State();
755 }
756 
757 /*
758 MO_PARAM_ALPHA, //value type: NUM or FUNCTION
759 MO_PARAM_COLOR, //value type: NUM[4] or FUNCTION[4] or
760 MO_PARAM_SYNC, //value type: NUM or FUNCTION
761 MO_PARAM_TEXT, //value type: TXT or LNK
762 MO_PARAM_TEXTURE, //value type: TXT or LNK
763 MO_PARAM_VIDEO, //value type: TXT or LNK
764 MO_PARAM_SOUND, //value type: TXT or LNK
765 MO_PARAM_FUNCTION, //value type: NUM or FUNCTION
766 MO_PARAM_SCRIPT, //value type: TXT or LNK
767 MO_PARAM_TRA, //value type: NUM[3] or FUNCTION[3]
768 MO_PARAM_ROT, //value type: NUM[3] or FUNCTION[3]
769 MO_PARAM_SCA //value type: NUM[3] or FUNCTION[3]
770 */
773 
774  p_configdefinition = moMoldeoObject::GetDefinition(p_configdefinition);
775  p_configdefinition->Add( moText("alpha"), MO_PARAM_ALPHA, -1, moValue("1.0","FUNCTION").Ref() );
776  p_configdefinition->Add( moText("color"), MO_PARAM_COLOR, -1, moValue("1.0","FUNCTION","1.0","FUNCTION","1.0","FUNCTION","1.0","FUNCTION").Ref() );
777  p_configdefinition->Add( moText("syncro"), MO_PARAM_SYNC, -1, moValue("1.0","FUNCTION").Ref() );
778  p_configdefinition->Add( moText("phase"), MO_PARAM_PHASE, -1, moValue("0.0","FUNCTION").Ref() );
779  p_configdefinition->Add( moText("guides"), MO_PARAM_NUMERIC, -1, moValue("0","NUM").Ref(), moText("No,Yes,Full") );
780  //p_configdefinition->Add( moText("blending"), MO_PARAM_, -1, );
781  //p_configdefinition->Add( moText("polygonmode"), MO_PARAM_, -1, );
782  //p_configdefinition->Add( moText("depthtest"), MO_PARAM_, -1, );
783  return p_configdefinition;
784 }
785 
787 {
790 
792  RegisterBaseFunction("Play");//0
793  RegisterFunction("Pause");//1
794  RegisterFunction("Stop");//2
795  RegisterFunction("State");//3
796  RegisterFunction("Enable");//4
797  RegisterFunction("Disable");//5
798 
799  RegisterFunction("SetTicks");//6
800  RegisterFunction("GetTicks");//7
801 
802  RegisterFunction("GetEffectState");//8
803  RegisterFunction("SetEffectState");//9
804 
806 
807 }
808 
809 int moEffect::ScriptCalling(moLuaVirtualMachine& vm, int iFunctionNumber)
810 {
811  m_iMethodBase = 37;
812  switch ( iFunctionNumber - m_iMethodBase )
813  {
814  case 0:
816  return luaPlay(vm);
817  case 1:
819  return luaPause(vm);
820  case 2:
822  return luaStop(vm);
823  case 3:
825  return luaState(vm);
826 
827  case 4:
829  return luaEnable(vm);
830  case 5:
832  return luaDisable(vm);
833 
834 
835 
836  case 6:
838  return luaSetTicks(vm);
839  case 7:
841  return luaGetTicks(vm);
842 
844  case 8:
846  return luaGetEffectState(vm);
847  case 9:
849  return luaSetEffectState(vm);
850 
851  default:
852  //MODebug2->Message( moText("Called moEffect::ScriptCalling, NextScriptCalling, from m_iMethodBase: ") + IntToStr(m_iMethodBase) );
854  //MODebug2->Message( moText("Called moEffect::ScriptCalling, NextScriptCalling, to m_iMethodBase: ") + IntToStr(m_iMethodBase) );
855  return moMoldeoObject::ScriptCalling( vm, iFunctionNumber );
856  }
857  return 0;
858 }
859 
860 
862 
863  lua_State *luastate = (lua_State *) vm;
864  if (luastate)
865  Play();
866 
867  return 0;
868 }
869 
871 
872  lua_State *luastate = (lua_State *) vm;
873  if (luastate)
874  Pause();
875 
876  return 0;
877 }
878 
880 
881  lua_State *luastate = (lua_State *) vm;
882  if (luastate)
883  Stop();
884 
885  return 0;
886 }
887 
889 
890  lua_State *luastate = (lua_State *) vm;
891 
892  moTimerState elstate = State();
893  int retstate = (int) elstate;
894  lua_pushnumber( luastate, (lua_Number) retstate);
895 
896  return 1;
897 }
898 
900 {
901  lua_State *luastate = (lua_State *) vm;
902 
903  MOint ticksint = (MOint) lua_tonumber (luastate, 1);
904 
905  m_EffectState.tempo.SetDuration( ticksint );
906 
907  return 0;
908 }
909 
911 {
912  lua_State *luastate = (lua_State *) vm;
913  //MODebug2->Message(moText("moEffect::luaGetTicks() > ")+IntToStr(moGetTicks()) );
914  lua_pushnumber(luastate, (lua_Number) moGetTicks() );
915 
916  return 1;
917 }
918 
920 {
921  lua_State *luastate = (lua_State *) vm;
922 
923  luastate = NULL;
924 
925  TurnOn();
926 
927  return luastate==NULL;
928 }
929 
931 {
932  lua_State *luastate = (lua_State *) vm;
933  if (luastate)
934  TurnOff();
935 
936  return 0;
937 }
938 
939 
940 
942 
943  lua_State *luastate = (lua_State *) vm;
944 
945 
946  m_EffectState.alpha = (MOfloat) lua_tonumber (luastate, 1);
947  m_EffectState.tint = (MOfloat) lua_tonumber (luastate, 2);
948  m_EffectState.tintr = (MOfloat) lua_tonumber (luastate, 3);
949  m_EffectState.tintg = (MOfloat) lua_tonumber (luastate, 4);
950  m_EffectState.tintb = (MOfloat) lua_tonumber (luastate, 5);
951  m_EffectState.tempo.ang = (MOfloat) lua_tonumber (luastate, 7);
952 
953  return 0;
954 
955 }
956 
958  lua_State *luastate = (lua_State *) vm;
959 
960  lua_pushnumber(luastate, (lua_Number) m_EffectState.alpha );
961  lua_pushnumber(luastate, (lua_Number) m_EffectState.tint );
962  lua_pushnumber(luastate, (lua_Number) m_EffectState.tintr );
963  lua_pushnumber(luastate, (lua_Number) m_EffectState.tintg );
964  lua_pushnumber(luastate, (lua_Number) m_EffectState.tintb );
965  lua_pushnumber(luastate, (lua_Number) m_EffectState.tempo.ang );
966 
967  return 0;
968 }
969 
970 
971 const moText&
973 
974  moText fieldSeparation = ",";
975  moEffectState EffectState = GetEffectState();
976  moText objectJSON = moMoldeoObject::ToJSON();
977  m_FullJSON = "{";
978  m_FullJSON+= "'effectstate': " + EffectState.ToJSON();
979  m_FullJSON+= fieldSeparation + "'object': " + objectJSON;
980  m_FullJSON+= "}";
981 
982  return m_FullJSON;
983 
984 }
985 
986 
double SetTempoDelta(double p_delta)
Definition: moEffect.cpp:616
virtual void Deactivate()
virtual int NextScriptCalling()
Definition: moScript.h:178
int luaState(moLuaVirtualMachine &vm)
Definition: moEffect.cpp:888
virtual void ScriptExeInteraction()
Definition: moEffect.cpp:198
Valor de un Parámetro.
Definition: moValue.h:501
int RegisterBaseFunction(const char *strFuncName)
Definition: moScript.cpp:340
bool IsInitialized()
Definition: moScript.h:74
const moText & GetLabelName() const
sólo líneas
Definition: moTypes.h:475
MOdouble Eval()
Definition: moValue.cpp:424
aditivo por color
Definition: moTypes.h:460
virtual void SetDuration(MOulong p_timecode)
Fija el valor del reloj del temporizador.
Definition: moTimer.cpp:249
void RegisterFunctions()
beware ! call only once or die!!!
Definition: moEffect.cpp:786
#define MO_BLUE
Definition: moTypes.h:443
void Error(moText p_text)
Anuncia y registra un error.
Definition: moAbstract.cpp:79
Tempo, beat, ritmo.
Definition: moTempo.h:44
virtual double TempoDelta(double p_delta)
Definition: moEffect.cpp:601
moMathFunction * Fun()
referencias a clases
Definition: moValue.cpp:417
virtual void Unsynchronize()
Definition: moEffect.cpp:586
virtual void Start()
Inicia el temporizador.
Definition: moTimer.cpp:196
MOint isyncro
Definition: moEffect.h:197
Conector Inlet, conector que recibe datos.
Definition: moConnectors.h:374
virtual void Continue()
Definition: moEffect.cpp:748
moValueBase & GetSubValue(MOint p_indexsubvalue=0)
Definition: moValue.h:539
virtual void TintCSV(double tintc, double tints, double tint)
Definition: moEffect.cpp:690
virtual MOboolean CreateConnectors()
virtual void Play()
Definition: moEffect.cpp:733
virtual void ScriptExeDraw()
Definition: moEffect.cpp:189
void SetDouble(MOdouble pdouble)
Definition: moValue.cpp:172
sustracción
Definition: moTypes.h:462
virtual void LoadCodes(moIODeviceManager *)
Definition: moEffect.cpp:323
int luaPlay(moLuaVirtualMachine &vm)
Definition: moEffect.cpp:861
virtual double TempoFactor(double p_factor)
Definition: moEffect.cpp:637
virtual double GetTempoFactor() const
Definition: moEffect.cpp:648
moRenderManager * GetRenderMan()
#define MOboolean
Definition: moTypes.h:385
#define MO_OFF
Definition: moTypes.h:366
virtual void Activate()
virtual int ScriptCalling(moLuaVirtualMachine &vm, int iFunctionNumber)
int GetParamIndex(moText p_paramname)
Devuelve el índice correspondiente al parámetro por nombre.
Definition: moConfig.cpp:1008
virtual MOdevcode GetCode(moText)=0
bool RunSelectedFunction(int nReturns=0)
Definition: moScript.cpp:529
Real Y() const
Definition: moMathVector4.h:77
virtual void Pause()
Definition: moEffect.cpp:743
virtual moTimerState State() const
Definition: moTimer.cpp:101
virtual void Disable()
Definition: moEffect.cpp:568
MOswitch enabled
Definition: moEffectState.h:85
int luaDisable(moLuaVirtualMachine &vm)
habilita deshabilita
Definition: moEffect.cpp:930
virtual void Synchronize()
Definition: moEffect.cpp:581
bool Activated() const
Real Z() const
Definition: moMathVector3.h:77
const moText & GetName() const
value type: NUM or FUNCTION
Definition: moParam.h:46
int luaPause(moLuaVirtualMachine &vm)
Definition: moEffect.cpp:870
static const double TWO_PI
Definition: moMath.h:827
moInlet * InletTime
Definition: moEffect.h:229
int luaStop(moLuaVirtualMachine &vm)
Definition: moEffect.cpp:879
moDataType Type() const
Definition: moValue.cpp:940
virtual moTimerState State()
Definition: moEffect.cpp:753
virtual ~moEffect()
Definition: moEffect.cpp:53
Objeto indefinido.
Definition: moTypes.h:527
MOulong moGetTicksAbsolute(bool force_real_absolute)
Devuelve en milisegundos el valor del reloj de Moldeo.
Definition: moTimer.cpp:15
moInlet * InletTempo
Definition: moEffect.h:235
virtual MOboolean PreInit()
Definition: moEffect.cpp:93
Real X() const
Definition: moMathVector3.h:73
MOdouble syncro
Syncronización o factor fraccionario, 1.0 predeterminado, sino KX donde K puede ser fraccional (un núme...
Definition: moTempo.h:79
MOboolean CheckErrors(moText p_location)
moInlets m_Inlets
Conectores de entrada, Arreglo de moInlet's.
virtual void BeginDraw(moTempo *, moEffectState *parentstate=NULL)
Definition: moEffect.cpp:218
moGLManager * GetGLMan()
definición de todos los parámetros a encontrar o a crear dentro del moConfig
Definition: moConfig.h:57
#define MOfloat
Definition: moTypes.h:403
MOdouble delta
variacion de frecuencia entre 0X y 2X, delta es real
Definition: moTempo.h:69
void Add(MOint, MOint, MOint=0)
value type: TXT or LNK
Definition: moParam.h:57
virtual const moMobState & GetState()
Definition: moEffect.cpp:73
virtual double Alpha(double alpha)
Definition: moEffect.cpp:653
moPolygonModes m_PolygonMode
Definition: moGUIManager.h:276
clase de para manejar textos
Definition: moText.h:75
virtual void TurnOff()
Definition: moEffect.cpp:559
MOuint GetValuesCount(int p_paramindex)
Devuelve la cantidad de valores que contiene el parámetro indexado.
Definition: moConfig.cpp:1019
aditivo según transparencia
Definition: moTypes.h:456
virtual void Stop()
Definition: moEffect.cpp:738
moResourceManager * m_pResourceManager
Puntero al administrador de recursos.
virtual const moEffectState & GetEffectState()
Definition: moEffect.cpp:59
void Stop()
Detiene el temporizador.
Definition: moTimer.h:219
moInlet * InletTimems
Definition: moEffect.h:230
virtual moConfigDefinition * GetDefinition(moConfigDefinition *p_configdefinition=NULL)
Definition: moEffect.cpp:772
virtual moConfigDefinition * GetDefinition(moConfigDefinition *p_configdefinition=NULL)
void Log(moText p_text)
Escribe un mensaje en el archivo de registro (log)
Definition: moAbstract.cpp:123
void SetCurrentValueIndex(int p_paramindex, int p_valueindex)
Posiciona el puntero de selección del valor del parámetro a la posición indicada.
Definition: moConfig.cpp:1470
moText0 & Trim()
Definition: moText.cpp:604
moMaterial m_Material
Definition: moGUIManager.h:317
moInlet * InletTimes
Definition: moEffect.h:232
moText0 moText
Definition: moText.h:291
moConfig m_Config
Configuración de parámetros del objeto.
moEffectState m_EffectState
Definition: moEffect.h:206
moColorRGB moColor
Definition: moGUIManager.h:49
MOboolean Init()
Inicializa el objeto.
moInlet * InletT
Definition: moEffect.h:234
Real Z() const
Definition: moMathVector4.h:79
virtual void EndDraw()
Definition: moEffect.cpp:296
int luaEnable(moLuaVirtualMachine &vm)
Definition: moEffect.cpp:919
moMobState m_MobState
Moldeo Object State.
MOdouble getTempo()
Definition: moTempo.cpp:153
#define MOint
Definition: moTypes.h:388
MOswitch synchronized
Definition: moEffectState.h:77
moTimerState
Estado del temporizador.
Definition: moTimer.h:75
virtual int ResetScriptCalling()
Definition: moScript.h:172
bool ScriptHasFunction(const char *strScriptName)
Definition: moScript.cpp:417
moColor m_Color
Definition: moGUIManager.h:273
#define MO_DEACTIVATED
Definition: moTypes.h:368
virtual const moText & ToJSON()
Definition: moEffect.cpp:972
virtual MOboolean PreFinish()
Definition: moEffect.cpp:314
void Pause()
Congela o pausa el temporizador.
Definition: moTimer.h:231
moVector4f moColorRGBA
Definition: moGUIManager.h:48
#define MO_PARAM_NOT_FOUND
Definition: moConfig.h:41
MOdouble factor
Multiplicador a partir de 2X hasta KX, donde K en principio es entero.
Definition: moTempo.h:76
virtual void SwitchEnabled()
Definition: moEffect.cpp:576
virtual void SwitchOn()
Definition: moEffect.cpp:572
virtual double Amplitude(double amplitude)
Definition: moEffect.cpp:668
virtual void Update(moEventList *p_EventList)
MOuint Length() const
Definition: moText.cpp:347
#define MO_GREEN
Definition: moTypes.h:442
virtual double GetMagnitude() const
Definition: moEffect.cpp:685
void BeatPulse(MOulong tik)
Definition: moTempo.cpp:209
void Continue()
Prosigue el temporizador.
Definition: moTimer.h:239
virtual double GetTempoDelta() const
Definition: moEffect.cpp:631
int luaGetTicks(moLuaVirtualMachine &vm)
Definition: moEffect.cpp:910
multipliación
Definition: moTypes.h:458
virtual bool SetEffectState(const moEffectState &p_state)
Definition: moEffect.cpp:63
MOdouble Double() const
Definition: moValue.cpp:859
moObject3D m_Effect3D
Definition: moEffect.h:207
virtual void RegisterFunctions()
beware ! call only once or die!!!
static moDebug * MODebug2
Clase de impresión de errores para depuración
Definition: moAbstract.h:225
value type: NUM or FUNCTION
Definition: moParam.h:42
virtual void BeatPulse()
Definition: moEffect.cpp:594
void SetBlending(moBlendingModes blending)
Definition: moEffect.cpp:483
moText Text()
Definition: moValue.cpp:539
virtual double Eval()
void Deactivate()
moDeviceCodeList * devicecode
Definition: moEffect.h:194
void Push(moText p_text)
Apila el mensaje dentro de la pila de mensajes.
Definition: moAbstract.h:115
Real Y() const
Definition: moMathVector3.h:75
MOswitch fulldebug
saturación
static double FMod(doublefX, doublefY)
Definition: moMath.h:200
#define MO_SELECTED
Definition: moConfig.h:44
moValue & GetValue(MOint i=-1)
Definition: moParam.cpp:1204
void SetColor(const moColorRGBA &color_rgba, double alpha, moEffectState &pstate)
Definition: moEffect.cpp:411
moInlet * InletMilliseconds
Definition: moEffect.h:231
Real W() const
Definition: moMathVector4.h:81
moParam & GetParam(MOint p_paramindex=-1)
Devuelve el parámetro por índice.
Definition: moConfig.cpp:984
value type: NUM or TEXT ( 0:FILL 1:LINE 2:POINT)
Definition: moParam.h:45
#define MOdouble
Definition: moTypes.h:404
#define MO_ON
Definition: moTypes.h:365
moBlendingModes m_Blending
Definition: moGUIManager.h:277
virtual double Magnitude(double magnitude)
Definition: moEffect.cpp:679
virtual long Duration()
Devuelve el valor del reloj del temporizador.
Definition: moTempo.cpp:146
const moText & GetConfigName() const
MOfloat amplitude
Definition: moEffectState.h:88
virtual void PreDraw(moTempo *, moEffectState *parentstate=NULL)
Definition: moEffect.cpp:212
Real X() const
Definition: moMathVector4.h:75
void Add(const moText &p_name, moParamType p_type, int p_index=-1, const moValue &p_defaultvalue=moValue("INVALID", MO_VALUE_UNDEFINED), const moText &p_OptionsStr=moText(""))
Agrega la definición de un parámetro con un valor predeterminado a tomar.
Definition: moConfig.cpp:139
transparencia
Definition: moTypes.h:455
virtual void Interaction(moIODeviceManager *)
Definition: moEffect.cpp:405
virtual double GetAlpha() const
Definition: moEffect.cpp:663
#define MOuint
Definition: moTypes.h:387
moVector3< MOfloat > moVector3f
LIBMOLDEO_API moText0 IntToStr(int a)
Definition: moText.cpp:1070
moDefineDynamicArray(moEffectsArray) moEffect
Definition: moEffect.cpp:39
virtual void Enable()
Definition: moEffect.cpp:564
int luaSetTicks(moLuaVirtualMachine &vm)
Definition: moEffect.cpp:899
clase base para objetos dibujables
Definition: moEffect.h:82
virtual moVector3f GetTintCSV() const
Definition: moEffect.cpp:722
bool SetCurrentParamIndex(int)
Selecciona el parámetro por el índice.
Definition: moConfig.cpp:1497
virtual const moText & ToJSON()
exclusión
Definition: moTypes.h:459
MOuint GetSubValueCount()
Definition: moValue.h:545
moIODevicesArray & IODevices()
moData * GetData()
Definition: moParam.cpp:1286
moEventList * GetEvents()
virtual double GetAmplitude() const
Definition: moEffect.cpp:674
virtual bool Synchronized()
Definition: moEffect.cpp:590
#define MO_ACTIVATED
Definition: moTypes.h:367
MOint iphase
Definition: moEffect.h:198
virtual int ScriptCalling(moLuaVirtualMachine &vm, int iFunctionNumber)
Definition: moEffect.cpp:809
bool SelectScriptFunction(const char *strFuncName)
Definition: moScript.cpp:370
Conector para vincular objetos con datos.
Definition: moConnectors.h:57
MOdouble ang
Definition: moTempo.h:81
virtual moVector3f GetTintRGB() const
Definition: moEffect.cpp:727
moData * GetData()
MOint ncodes
Definition: moEffect.h:195
void Message(moText p_text)
Anuncia un mensaje al usuario además de guardarlo en el log de texto.
Definition: moAbstract.cpp:114
void SetPolygonMode(moPolygonModes polygonmode)
Definition: moEffect.cpp:457
MOfloat magnitude
Definition: moEffectState.h:87
moMathFunction
bool FirstValue()
Selecciona el primer valor del parámetro actual.
Definition: moConfig.cpp:1532
moPolygonModes
Modos de dibujado de polígonos.
Definition: moTypes.h:472
virtual void ScriptExeRun()
int RegisterFunction(const char *strFuncName, moScript::Function &fun)
Definition: moScript.cpp:286
virtual void TurnOn()
Definition: moEffect.cpp:554
moBlendingModes
Modos de combinación
Definition: moTypes.h:453
int m_iMethodBase
Definition: moScript.h:206
#define MO_ALPHA
Definition: moTypes.h:444
int luaGetEffectState(moLuaVirtualMachine &vm)
Definition: moEffect.cpp:957
#define MO_RED
Definition: moTypes.h:441
moInlet * InletSeconds
Definition: moEffect.h:233
virtual const moText & ToJSON()
MOulong moGetTicks()
Devuelve en milisegundos el valor del reloj de Moldeo.
Definition: moTimer.cpp:138
virtual MOboolean Init()
virtual bool SetState(const moMobState &p_MobState)
Definition: moEffect.cpp:78
int luaSetEffectState(moLuaVirtualMachine &vm)
Definition: moEffect.cpp:941