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
moValue.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2 
3  moValue.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 #include "moValue.h"
32 
33 
34 #include "moTexture.h"
35 #include "moTextureFilter.h"
36 
37 #include "moArray.h"
38 #include "moText.h"
39 #include <tinyxml.h>
40 #include "moDebugManager.h"
41 
42 moDefineDynamicArray( moValueIndexes )
43 moDefineDynamicArray( moValueBases )
44 moDefineDynamicArray( moValues )
45 moDefineDynamicArray( moDatas )
46 moDefineDynamicArray( moDataMessages )
47 
48 //================================================================
49 // moData
50 //================================================================
51 
52 moData::moData() {
53  m_Number.m_Long = 0;
54  m_Number.m_Pointer = NULL;
55  m_DataSize = 0;
56  m_DataType = MO_DATA_UNDEFINED;
57  m_bFilteredAlpha = false;
58  m_bFilteredParams = false;
59  m_AlphaFilter = 1.0;
60  //m_pFilterParam = NULL;
61  m_pAlphaFilter = NULL;
62 }
63 
65  (*this) = moData();
66  m_Number.m_Char = data;
67  m_DataSize = 0;
69 }
70 
72  (*this) = moData();
73  m_Number.m_Int = data;
74  m_DataSize = 0;
76 }
77 
79  (*this) = moData();
80  m_Number.m_Long = data;
81  m_DataSize = 0;
83 }
84 
86  (*this) = moData();
87  m_Number.m_Double = data;
88  m_DataSize = 0;
90 }
91 
93  (*this) = moData();
94  m_Number.m_Float = data;
95  m_DataSize = 0;
97 }
98 
99 /*
100  MO_DATA_POINTER,//may be a pointer to struct or to class
101  MO_DATA_VECTOR,//array of values
102  MO_DATA_IMAGESAMPLE,//pointer to an imagesample pointer
103  MO_DATA_SOUNDSAMPLE,//pointer to a soundsample pointer
104  MO_DATA_VIDEOSAMPLE,//pointer to a videosample pointer
105 */
107  (*this) = moData();
108  m_Number.m_Pointer = data;
109  m_DataSize = size;
110  m_DataType = type;
111 }
112 
114  (*this) = moData();
115  m_Text = data;
116  m_DataSize = 0;
117  m_Number.m_Long = 0;
119 }
120 
122  (*this) = moData();
123  m_DataType = datatype;
124 }
125 
127 
128 }
129 
131 {
132  m_Number = data.m_Number;
133  m_Text = data.m_Text;
134  m_DataType = data.m_DataType;
135  m_DataSize = data.m_DataSize;
141  m_LastEval = data.m_LastEval;
142  return *this;
143 }
144 
145 void
146 moData::Copy( const moData& data ) {
147  (*this) = data;
148 }
149 
150 
151 bool
153  return (m_DataType!=MO_DATA_UNDEFINED);
154 }
155 
156 
157 void
159  m_Text = ptext;
161 }
162 
163 void
165  m_Number.m_Float = pfloat;
168  m_LastEval = (MOdouble)pfloat;
169 }
170 
171 void
173  m_Number.m_Double = pdouble;
176  m_LastEval = pdouble;
177 }
178 
179 void
181  m_Number.m_Int = pint;
184  m_LastEval = (MOdouble)pint;
185 }
186 
187 void
189  m_Number.m_Long = plong;
192  m_LastEval = (MOdouble)plong;//loose precision...
193 }
194 
195 void
197  m_Number.m_Char = pchar;
200 }
201 
202 void
204  m_Number = p_number;
206  m_Text = "";
207 }
208 
209 void
211  m_DataType = p_DataType;
212 }
213 
214 void
216  m_Number.m_Pointer = (MOpointer) data;
217  m_DataSize = size;
220 }
221 
222 void
223 moData::SetSize( MOulong p_DataSize ) {
224  m_DataSize = p_DataSize;
225 }
226 
227 void
228 moData::SetFun( const moText& p_functionExpression ) {
230  m_Text = p_functionExpression;
231  m_Number.m_Pointer = (MOpointer) NULL;
232 }
233 
234 void
237  m_Number.m_Pointer = (MOpointer) p_Function;
238  if (p_Function)
239  m_Text = p_Function->GetExpression();
240 }
241 
242 
243 void
246  m_Number.m_Pointer = (MOpointer) p_Texture;
247 }
248 
249 void
252  m_Number.m_Pointer = (MOpointer) p_TextureBuffer;
253 }
254 
255 void
258  m_Number.m_Pointer = (MOpointer) p_VideoBuffer;
259 }
260 
261 void
264  m_Number.m_Pointer = (MOpointer) p_TextureFilter;
265 
266 }
267 
268 void
271  m_Number.m_Pointer = (MOpointer) p_Font;
272 }
273 
274 void
277  m_Number.m_Pointer = (MOpointer) p_Model;
278 }
279 
280 void
282 
283  if (p_alpha!=NULL)
284  switch( p_alpha->m_DataType ) {
285  case MO_DATA_FUNCTION:
286  m_bFilteredAlpha = true;
287  m_AlphaFilter = p_alpha->Fun()->Eval(0);
288  m_pAlphaFilter = p_alpha;
289  m_pAlphaFilter = NULL;
290  break;
291  case MO_DATA_NUMBER:
292  case MO_DATA_NUMBER_CHAR:
295  case MO_DATA_NUMBER_INT:
296  case MO_DATA_NUMBER_LONG:
297  m_bFilteredAlpha = true;
298  m_AlphaFilter = p_alpha->Float();
299  m_pAlphaFilter = NULL;
300  break;
301  default:
302  m_bFilteredAlpha = true;
303  m_AlphaFilter = 1.0;
304  m_pAlphaFilter = NULL;
305  break;
306  }
307 }
308 
309 void
311  m_bFilteredParams = true;
312  m_pFilterParam = p_filterparam;
313 
314 }
315 
316 void
319  m_Number.m_Pointer = (MOpointer) p_vector2d;
320 }
321 
322 void
325  m_Number.m_Pointer = (MOpointer) p_vector3d;
326 }
327 
328 void
331  m_Number.m_Pointer = (MOpointer) p_vector4d;
332 }
333 
334 void
337  m_Number.m_Pointer = (MOpointer) p_vector2i;
338 }
339 
340 void
343  m_Number.m_Pointer = (MOpointer) p_vector3i;
344 }
345 
346 void
349  m_Number.m_Pointer = (MOpointer) p_vector4i;
350 }
351 
352 
353 void
356  m_Number.m_Pointer = (MOpointer) p_datamessage;
357 }
358 
359 
360 void
361 moData::SetMessages( moDataMessages *p_datamessages ) {
363  m_Number.m_Pointer = (MOpointer) p_datamessages;
364 }
365 
366 
367 void
370  m_Number.m_Pointer = (MOpointer) p_Sound;
371 }
372 
373 
374 moVector2d *
376  return (moVector2d*) m_Number.m_Pointer;
377 }
378 
379 moVector2i *
381  return (moVector2i*) m_Number.m_Pointer;
382 }
383 
384 moVector3d *
386  return (moVector3d*) m_Number.m_Pointer;
387 }
388 
389 moVector3i *
391  return (moVector3i*) m_Number.m_Pointer;
392 }
393 
394 moVector4d *
396  return (moVector4d*) m_Number.m_Pointer;
397 }
398 
399 moVector4i *
401  return (moVector4i*) m_Number.m_Pointer;
402 }
403 
404 
405 
408  return (moDataMessage*) m_Number.m_Pointer;
409 }
410 
411 moDataMessages*
413  return (moDataMessages*) m_Number.m_Pointer;
414 }
415 
420  } else return NULL;
421 }
422 
423 MOdouble
426  moMathFunction* pFun = Fun();
427  m_LastEval = 0.0;
428  if (pFun)
429  m_LastEval = pFun->Eval();
430  }
431 
432  return LastEval();
433 }
434 
435 MOdouble
436 moData::Eval( double x ) {
438  moMathFunction* pFun = Fun();
439  m_LastEval = 0.0;
440  if (pFun)
441  m_LastEval = pFun->Eval(x);
442  }
443 
444  return LastEval();
445 
446 }
447 
448 MOdouble
450  switch((int)m_DataType) {
452  return m_Number.m_Double;
453  break;
455  return (MOdouble)m_Number.m_Float;
456  break;
457  case MO_DATA_NUMBER_INT:
458  return (MOdouble)m_Number.m_Int;
459  break;
460  case MO_DATA_NUMBER_LONG:
461  return (MOdouble)m_Number.m_Long;
462  break;
463  case MO_DATA_FUNCTION:
464  return m_LastEval;
465  break;
466  default:
467  return m_LastEval;
468  break;
469  }
470 }
471 
472 
473 moFont*
475  moFont* pFont = static_cast<moFont*>(m_Number.m_Pointer);
476  return pFont;
477 }
478 
480  moTextureBuffer* pTexBuf = static_cast<moTextureBuffer*>(m_Number.m_Pointer);
481  return pTexBuf;
482 
483 }
484 
485 
488  moSceneNode* pModel = static_cast<moSceneNode*>(m_Number.m_Pointer);
489  return pModel;
490 }
491 
492 moSound*
494  moSound* pSound = static_cast<moSound*>(m_Number.m_Pointer);
495  return pSound;
496 }
497 
500 moTexture*
502  moTexture* pTexture = NULL;
505  if (pTF) {
506  moTextureIndex* PTI = pTF->GetSrcTex();
507  if (PTI) {
508  pTexture = PTI->GetTexture(0);
509  }
510  }
512  pTexture = static_cast<moTexture*>(m_Number.m_Pointer);
513  }
514  return pTexture;
515 }
516 
518 moTexture*
520 
521  moTexture* pTexture = NULL;
522 
525  if (pTF) {
526  moTextureIndex* PTI = pTF->GetDestTex();
527  if (PTI) {
528  pTexture = PTI->GetTexture(0);
529  }
530  }
532  pTexture = static_cast<moTexture*>(m_Number.m_Pointer);
533  }
534  return pTexture;
535 }
536 
537 
538 moText
540  return m_Text;
541 }
542 
543 moText
545  return moData::TypeToText( m_DataType );
546 }
547 
548 moText
550 
551  switch((int)p_data_type) {
552  case MO_DATA_NUMBER:
553  return moText("MO_DATA_NUMBER");
554  break;
555  case MO_DATA_NUMBER_CHAR:
556  return moText("MO_DATA_NUMBER_CHAR");
557  break;
558  case MO_DATA_NUMBER_INT:
559  return moText("MO_DATA_NUMBER_INT");
560  break;
561  case MO_DATA_NUMBER_LONG:
562  return moText("MO_DATA_NUMBER_LONG");
563  break;
565  return moText("MO_DATA_NUMBER_DOUBLE");
566  break;
568  return moText("MO_DATA_NUMBER_FLOAT");
569  break;
570  case MO_DATA_NUMBER_MIDI:
571  return moText("MO_DATA_NUMBER_MIDI");
572  break;
573  case MO_DATA_FUNCTION:
574  return moText("MO_DATA_FUNCTION");
575  break;
576  case MO_DATA_IMAGESAMPLE:
577  return moText("MO_DATA_IMAGESAMPLE");
578  break;
580  return moText("MO_DATA_IMAGESAMPLE_FILTERED");
581  break;
582  case MO_DATA_VIDEOSAMPLE:
583  return moText("MO_DATA_VIDEOSAMPLE");
584  break;
585  case MO_DATA_SOUNDSAMPLE:
586  return moText("MO_DATA_SOUNDSAMPLE");
587  break;
588  case MO_DATA_POINTER:
589  return moText("MO_DATA_POINTER");
590  break;
591  case MO_DATA_TEXT:
592  return moText("MO_DATA_TEXT");
593  break;
594  case MO_DATA_UNDEFINED:
595  return moText("MO_DATA_UNDEFINED");
596  break;
597  case MO_DATA_VECTOR2I:
598  return moText("MO_DATA_VECTOR2I");
599  break;
600  case MO_DATA_VECTOR3I:
601  return moText("MO_DATA_VECTOR3I");
602  break;
603  case MO_DATA_VECTOR4I:
604  return moText("MO_DATA_VECTOR4I");
605  break;
606  case MO_DATA_VECTOR2F:
607  return moText("MO_DATA_VECTOR2F");
608  break;
609  case MO_DATA_VECTOR3F:
610  return moText("MO_DATA_VECTOR3F");
611  break;
612  case MO_DATA_VECTOR4F:
613  return moText("MO_DATA_VECTOR4F");
614  break;
615  case MO_DATA_MESSAGE:
616  return moText("MO_DATA_MESSAGE");
617  break;
618  case MO_DATA_MESSAGES:
619  return moText("MO_DATA_MESSAGES");
620  break;
621  default:
622  break;
623 
624  }
625 
626  return moText("MO_DATA_UNDEFINED");
627 }
628 
631 
632  if ( texttype == moText("MO_DATA_NUMBER") ) {
633  return MO_DATA_NUMBER;
634  } else
635  if ( texttype == moText("MO_DATA_NUMBER_CHAR") ) {
636  return MO_DATA_NUMBER_CHAR;
637  } else
638  if ( texttype == moText("MO_DATA_NUMBER_INT") ) {
639  return MO_DATA_NUMBER_INT;
640  } else
641  if ( texttype == moText("MO_DATA_NUMBER_LONG") ) {
642  return MO_DATA_NUMBER_LONG;
643  } else
644  if ( texttype == moText("MO_DATA_NUMBER_DOUBLE") ) {
645  return MO_DATA_NUMBER_DOUBLE;
646  } else
647  if ( texttype == moText("MO_DATA_NUMBER_FLOAT") ) {
648  return MO_DATA_NUMBER_FLOAT;
649  } else
650  if ( texttype == moText("MO_DATA_NUMBER_MIDI") ) {
651  return MO_DATA_NUMBER_MIDI;
652  } else
653  if ( texttype == moText("MO_DATA_FUNCTION") ) {
654  return MO_DATA_FUNCTION;
655  } else
656  if ( texttype == moText("MO_DATA_IMAGESAMPLE") ) {
657  return MO_DATA_IMAGESAMPLE;
658  } else
659  if ( texttype == moText("MO_DATA_IMAGESAMPLE_FILTERED") ) {
661  } else
662  if ( texttype == moText("MO_DATA_VIDEOSAMPLE") ) {
663  return MO_DATA_VIDEOSAMPLE;
664  } else
665  if ( texttype == moText("MO_DATA_SOUNDSAMPLE") ) {
666  return MO_DATA_SOUNDSAMPLE;
667  } else
668  if ( texttype == moText("MO_DATA_POINTER") ) {
669  return MO_DATA_POINTER;
670  } else
671  if ( texttype == moText("MO_DATA_TEXT") ) {
672  return MO_DATA_TEXT;
673  } else
674  if ( texttype == moText("MO_DATA_UNDEFINED") ) {
675  return MO_DATA_UNDEFINED;
676  } else
677  if ( texttype == moText("MO_DATA_VECTOR2I") ) {
678  return MO_DATA_VECTOR2I;
679  } else
680  if ( texttype == moText("MO_DATA_VECTOR2F") ) {
681  return MO_DATA_VECTOR2F;
682  } else
683  if ( texttype == moText("MO_DATA_VECTOR3I") ) {
684  return MO_DATA_VECTOR3I;
685  } else
686  if ( texttype == moText("MO_DATA_VECTOR3F") ) {
687  return MO_DATA_VECTOR3F;
688  } else
689  if ( texttype == moText("MO_DATA_VECTOR4I") ) {
690  return MO_DATA_VECTOR4I;
691  } else
692  if ( texttype == moText("MO_DATA_VECTOR4F") ) {
693  return MO_DATA_VECTOR4F;
694  } else
695  if ( texttype == moText("MO_DATA_MESSAGE") ) {
696  return MO_DATA_MESSAGE;
697  } else
698  if ( texttype == moText("MO_DATA_MESSAGES") ) {
699  return MO_DATA_MESSAGES;
700  }
701 
702  return MO_DATA_UNDEFINED;
703 }
704 
705 
706 moText
707 moData::ToText() const {
708 
709  moText finalMsg = "";
710  moDataMessage *dM =NULL;
711  moDataMessages *dMs = NULL;
712 
713  switch((int)m_DataType) {
714  case MO_DATA_NUMBER:
715  return IntToStr( Int() );
716  break;
717  case MO_DATA_NUMBER_CHAR:
718  return IntToStr( Char() );
719  break;
720  case MO_DATA_NUMBER_INT:
721  return IntToStr( Int() );
722  break;
723  case MO_DATA_NUMBER_LONG:
724  return IntToStr( Long() );
725  break;
727  return FloatToStr( Double() );
728  break;
730  return FloatToStr( Float() );
731  break;
732  /*
733  case MO_DATA_FUNCTION:
734  return moText(Eval());
735  break;
736  case MO_DATA_TEXT:
737  return Text();
738  break;
739  */
740  case MO_DATA_MESSAGE:
742  if (dM) {
743  for(int c=0;c<(int)dM->Count();c++) {
744  finalMsg+= ";" + dM->Get(c).ToText();
745  }
746  }
747  return finalMsg;
748  break;
749  case MO_DATA_MESSAGES:
750  dMs = (moDataMessages*)m_Number.m_Pointer;
751  if (dMs) {
752  for(int c=0;c<(int)dMs->Count();c++) {
753  moDataMessage Mes = dMs->Get(c);
754  for(int cc=0;cc<(int)Mes.Count();cc++) {
755  finalMsg+= ";" + Mes.Get(c).ToText();
756  }
757  finalMsg+= "\n";
758 
759  }
760  }
761  return finalMsg;
762  break;
763  default:
764  break;
765  }
766 
767  return m_Text;
768  //return moText("");
769  /*return moText("moData::ToText() for "+TypeToText()+" not implemented");*/
770 }
771 
772 MOint
773 moData::Int() const {
774  double rndD;
775  float rndF;
776  switch((int)m_DataType) {
777  case MO_DATA_NUMBER_INT:
778  return m_Number.m_Int;
779  break;
780  case MO_DATA_NUMBER_CHAR:
781  return (MOint)m_Number.m_Char;
782  break;
783  case MO_DATA_NUMBER_LONG:
784  return (MOint)m_Number.m_Long;
785  break;
787  rndF = moRound(m_Number.m_Float);
788  return (MOint) rndF;
789  break;
791  rndD = moRound(m_Number.m_Double);
792  return (MOint) rndD;
793  break;
794  case MO_DATA_FUNCTION:
795  return (MOint)m_LastEval;
796  break;
797  default:
798  return m_Number.m_Int;
799  break;
800  }
801 }
802 
804 moData::Long() const {
805  double rndD;
806  float rndF;
807  switch((int)m_DataType) {
808  case MO_DATA_NUMBER_LONG:
809  return m_Number.m_Long;
810  break;
811  case MO_DATA_NUMBER_INT:
812  return (MOlonglong) m_Number.m_Int;
813  break;
814  case MO_DATA_NUMBER_CHAR:
815  return (MOlonglong)m_Number.m_Char;
816  break;
818  rndF = moRound( m_Number.m_Float );
819  return (MOlonglong) rndF;
820  break;
822  rndD = moRound( m_Number.m_Double );
823  return (MOlonglong) rndD;
824  break;
825  case MO_DATA_FUNCTION:
826  return (MOlonglong)m_LastEval;
827  break;
828  default:
829  return m_Number.m_Long;
830  break;
831  }
832 }
833 
834 MOfloat
835 moData::Float() const {
836  switch((int)m_DataType) {
838  return m_Number.m_Float;
839  break;
841  return (MOfloat) m_Number.m_Double;
842  break;
843  case MO_DATA_NUMBER_INT:
844  return (MOfloat)m_Number.m_Int;
845  break;
846  case MO_DATA_NUMBER_LONG:
847  return (MOfloat)m_Number.m_Long;
848  break;
849  case MO_DATA_FUNCTION:
850  return (MOfloat)m_LastEval;
851  break;
852  default:
853  return m_Number.m_Float;
854  break;
855  }
856 }
857 
858 MOdouble
859 moData::Double() const {
860  switch((int)m_DataType) {
862  return m_Number.m_Double;
863  break;
865  return (MOdouble)m_Number.m_Float;
866  break;
867  case MO_DATA_NUMBER_INT:
868  return (MOdouble)m_Number.m_Int;
869  break;
870  case MO_DATA_NUMBER_LONG:
871  return (MOdouble)m_Number.m_Long;
872  break;
873  case MO_DATA_FUNCTION:
874  return m_LastEval;
875  break;
876  default:
877  return m_Number.m_Double;
878  break;
879  }
880 }
881 
882 MOchar
883 moData::Char() const {
884  float rndF;
885  double rndD;
886  switch((int)m_DataType) {
887  case MO_DATA_NUMBER_CHAR:
888  return m_Number.m_Char;
889  break;
890  case MO_DATA_NUMBER_LONG:
891  return (MOchar)m_Number.m_Long;
892  break;
893  case MO_DATA_NUMBER_INT:
894  return (MOchar) m_Number.m_Int;
895  break;
897  rndF = moRound( m_Number.m_Float );
898  return (MOchar) rndF;
899  break;
901  rndD = moRound( m_Number.m_Double );
902  return (MOchar) rndD;
903  break;
904  case MO_DATA_FUNCTION:
905  return (MOchar)m_LastEval;
906  break;
907  default:
908  return m_Number.m_Char;
909  break;
910  }
911 }
912 
913 moNumber
915  return m_Number;
916 }
917 
918 MOpointer
922  if (pTF) {
923  moTextureIndex* PTI = pTF->GetDestTex();
924  if (PTI) {
925  return (MOpointer) PTI->GetTexture(0);
926  }
927  }
928  }
929 
930  return m_Number.m_Pointer;
931 }
932 
933 MOulong
934 moData::Size() const {
935  return m_DataSize;
936 }
937 
938 
940 moData::Type() const {
941  return m_DataType;
942 }
943 
944 moData*
946  return (this);
947 }
948 
949 GLint
951  moTextFilterParam p_filterparam;
952  return GetGLId( p_cycle, 1.0, p_filterparam);
953 }
954 
955 GLint
956 moData::GetGLId( MOfloat p_cycle, MOfloat p_fade, const moTextFilterParam &p_filterparam ) {
957 
958  moTexture* pTexture = NULL;
959 
962  if (pTF) {
963  if (m_bFilteredAlpha) {
964  p_fade = m_AlphaFilter;
965  if (m_pAlphaFilter) {
966  p_fade = m_pAlphaFilter->Fun()->Eval(p_cycle);
967  }
968  }
969  //if (m_pFilterParam)
970  // p_filterparam = m_pFilterParam;
971 
972  pTF->Apply( p_cycle, p_fade, p_filterparam);
973  moTextureIndex* PTI = pTF->GetDestTex();
974  if (PTI) {
975  pTexture = PTI->GetTexture(0);
976  }
977  }
978  } else pTexture = this->Texture();
979 
980  if (pTexture) {
981  if ((p_cycle >= 0.0) && ((pTexture->GetType() == MO_TYPE_TEXTURE_MULTIPLE) ||
982  (pTexture->GetType() == MO_TYPE_MOVIE) ||
983  (pTexture->GetType() == MO_TYPE_VIDEOBUFFER)))
984  {
985  moTextureAnimated* ptex_anim = (moTextureAnimated*)pTexture;
986  return ptex_anim ->GetGLId((MOfloat)p_cycle);
987  }
988  else return pTexture->GetGLId();
989 
990  } else return 0;
991 }
992 
993 GLint
995  moTextFilterParam p_filterparam;
996  return GetGLId( p_tempo, 1.0, p_filterparam);
997 }
998 
999 GLint
1000 moData::GetGLId( moTempo *p_tempo, MOfloat p_fade, const moTextFilterParam &p_filterparam ) {
1001 
1002  moTexture* pTexture = NULL;
1003 
1006  if (pTF) {
1007 
1008  if (m_bFilteredAlpha) {
1009  p_fade = m_AlphaFilter;
1010  if (m_pAlphaFilter) {
1011  p_fade = m_pAlphaFilter->Fun()->Eval(p_tempo->ang);
1012  }
1013  }
1014  //if (m_pFilterParam)
1015  // p_filterparam = m_pFilterParam;
1016 
1017  pTF->Apply( p_tempo, p_fade, p_filterparam);
1018  moTextureIndex* PTI = pTF->GetDestTex();
1019  if (PTI) {
1020  pTexture = PTI->GetTexture(0);
1021  }
1022  }
1023  } else pTexture = this->Texture();
1024 
1025  if (pTexture) {
1026  if ( (p_tempo != NULL) && ((pTexture->GetType() == MO_TYPE_TEXTURE_MULTIPLE) ||
1027  (pTexture->GetType() == MO_TYPE_MOVIE) ||
1028  (pTexture->GetType() == MO_TYPE_VIDEOBUFFER)))
1029  {
1030  moTextureAnimated* ptex_anim = (moTextureAnimated*)pTexture;
1031  return ptex_anim ->GetGLId((moTempo *) p_tempo);
1032  }
1033  else return pTexture->GetGLId();
1034 
1035  } else return 0;
1036 }
1037 
1038 
1039 GLint
1041  moTextFilterParam p_filterparam;
1042  return GetGLId( p_i, 1.0, p_filterparam);
1043 }
1044 
1045 GLint
1046 moData::GetGLId( MOuint p_i , MOfloat p_fade, const moTextFilterParam &p_filterparam ) {
1047 
1048  moTexture* pTexture = NULL;
1049 
1052  if (pTF) {
1053 
1054  if (m_bFilteredAlpha) {
1055  p_fade = m_AlphaFilter;
1056  if (m_pAlphaFilter) {
1057  p_fade = m_pAlphaFilter->Fun()->Eval(p_i);
1058  }
1059  }
1060  //if (m_pFilterParam)
1061  // p_filterparam = m_pFilterParam;
1062 
1063 
1064  pTF->Apply( p_i, p_fade, p_filterparam);
1065  moTextureIndex* PTI = pTF->GetDestTex();
1066  if (PTI) {
1067  pTexture = PTI->GetTexture(0);
1068  }
1069  }
1070  } else pTexture = this->Texture();
1071 
1072  if (pTexture) {
1073  if ( ((pTexture->GetType() == MO_TYPE_TEXTURE_MULTIPLE) ||
1074  (pTexture->GetType() == MO_TYPE_MOVIE) ||
1075  (pTexture->GetType() == MO_TYPE_VIDEOBUFFER)))
1076  {
1077  moTextureAnimated* ptex_anim = (moTextureAnimated*)pTexture;
1078  return ptex_anim ->GetGLId( (MOuint) p_i);
1079  }
1080  else return pTexture->GetGLId();
1081 
1082  } else return 0;
1083 }
1084 
1085 
1086 GLint
1088  moTextFilterParam p_filterparam;
1089  return GetGLId(1.0, p_filterparam);
1090 }
1091 
1092 GLint
1093 moData::GetGLId( MOfloat p_fade, const moTextFilterParam &p_filterparam ) {
1094 
1095  moTexture* pTexture = NULL;
1096 
1099  if (pTF) {
1100 
1101  if (m_bFilteredAlpha) {
1102  p_fade = m_AlphaFilter;
1103  if (m_pAlphaFilter) {
1104  p_fade = m_pAlphaFilter->Fun()->Eval(0);
1105  }
1106  }
1107  //if (m_pFilterParam)
1108  // p_filterparam = m_pFilterParam;
1109 
1110 
1111  pTF->Apply( (MOuint)0, p_fade, p_filterparam );
1112 
1113  moTextureIndex* PTI = pTF->GetDestTex();
1114  if (PTI) {
1115  pTexture = PTI->GetTexture(0);
1116  }
1117  }
1118  } else pTexture = this->Texture();
1119 
1120  if (pTexture)
1121  return pTexture->GetGLId();
1122  else return 0;
1123 }
1124 
1125 GLint
1127  return GetGLId( p_mob, NULL);
1128 }
1129 
1130 GLint
1132  moTextFilterParam p_filterparam;
1133  return GetGLId( p_mob, p_tempo, 1.0, p_filterparam);
1134 }
1135 
1136 
1137 GLint
1138 moData::GetGLId( moMoldeoObject* p_mob, MOfloat p_fade, const moTextFilterParam &p_filterparam ) {
1139 
1140  GetGLId( p_mob, NULL, p_fade, p_filterparam );
1141 }
1142 
1143 GLint
1144 moData::GetGLId( moMoldeoObject* p_mob, moTempo *p_tempo, MOfloat p_fade, const moTextFilterParam &p_filterparam ) {
1145  moTexture* pTexture = NULL;
1146 
1149  if (pTF) {
1150 
1151  if (m_bFilteredAlpha) {
1152  p_fade = m_AlphaFilter;
1153  if (m_pAlphaFilter) {
1154  moMathFunction* mFun = m_pAlphaFilter->Fun();
1155  mFun->Init( mFun->GetExpression(), p_mob );
1156  p_fade = m_pAlphaFilter->Fun()->Eval();
1157  }
1158  }
1159  //if (m_pFilterParam)
1160  // p_filterparam = m_pFilterParam;
1161 
1162  pTF->Apply( p_mob, p_tempo, p_fade, p_filterparam);
1163  moTextureIndex* PTI = pTF->GetDestTex();
1164  if (PTI) {
1165  pTexture = PTI->GetTexture(0);
1166  }
1167  }
1168  } else pTexture = this->Texture();
1169 
1170  if (pTexture) {
1171  if ( (p_tempo != NULL) && (
1172  (pTexture->GetType() == MO_TYPE_TEXTURE_MULTIPLE) ||
1173  (pTexture->GetType() == MO_TYPE_MOVIE) ||
1174  (pTexture->GetType() == MO_TYPE_VIDEOBUFFER)
1175  )
1176  )
1177  {
1178  moTextureAnimated* ptex_anim = (moTextureAnimated*)pTexture;
1179  return ptex_anim ->GetGLId((moTempo *) p_tempo);
1180  }
1181  else return pTexture->GetGLId();
1182 
1183  } else return 0;
1184 }
1185 
1186 //================================================================
1187 // moValueDefinition
1188 //================================================================
1189 
1190 
1192  m_Min = -1.0;
1193  m_Max = -1.0;
1194  m_CodeName = moText("");
1195  m_Attribute = moText("");
1196  m_Index = -1;
1197  m_Type = MO_VALUE_UNDEFINED;
1198 }
1199 
1201  *this = src;
1202 }
1203 
1205 }
1206 
1208 {
1209  m_Type = src.m_Type;
1210  m_Index = src.m_Index;
1211  m_CodeName = src.m_CodeName;
1212  m_Min = src.m_Min;
1213  m_Max = src.m_Max;
1214  m_Attribute = src.m_Attribute;
1215  return *this;
1216 }
1217 
1218 void
1220  m_Type = p_type;
1221 }
1222 
1223 void
1225  m_Index = p_index;
1226 }
1227 
1230  return m_Type;
1231 }
1232 
1233 moText
1235  switch((int)m_Type) {
1236  case MO_VALUE_FUNCTION:
1237  return moText("FUNCTION");
1238  break;
1239  case MO_VALUE_LNK:
1240  return moText("LNK");
1241  break;
1242  case MO_VALUE_NUM:
1243  return moText("NUM");
1244  break;
1245  case MO_VALUE_NUM_CHAR:
1246  return moText("CHAR");
1247  break;
1248  case MO_VALUE_NUM_DOUBLE:
1249  return moText("DOUBLE");
1250  break;
1251  case MO_VALUE_NUM_FLOAT:
1252  return moText("FLOAT");
1253  break;
1254  case MO_VALUE_NUM_INT:
1255  return moText("INT");
1256  break;
1257  case MO_VALUE_NUM_LONG:
1258  return moText("LONG");
1259  break;
1260  case MO_VALUE_TXT:
1261  return moText("TXT");
1262  break;
1263  case MO_VALUE_XML:
1264  return moText("XML");
1265  break;
1266  case MO_VALUE_MATRIX:
1267  return moText("MATRIX");
1268  break;
1269  }
1270  return moText("UNDEFINED");
1271 }
1272 
1274 moValueDefinition::ValueTypeFromStr( const moText& p_value_type_str ) {
1275  if (p_value_type_str=="FUNCTION") {
1276  return MO_VALUE_FUNCTION;
1277  } else if (p_value_type_str=="NUM") {
1278  return MO_VALUE_NUM;
1279  } else if (p_value_type_str=="CHAR") {
1280  return MO_VALUE_NUM_CHAR;
1281  } else if (p_value_type_str=="INT") {
1282  return MO_VALUE_NUM_INT;
1283  } else if (p_value_type_str=="LONG") {
1284  return MO_VALUE_NUM_LONG;
1285  } else if (p_value_type_str=="FLOAT") {
1286  return MO_VALUE_NUM_FLOAT;
1287  } else if (p_value_type_str=="DOUBLE") {
1288  return MO_VALUE_NUM_DOUBLE;
1289  } else if (p_value_type_str=="TXT") {
1290  return MO_VALUE_TXT;
1291  } else if (p_value_type_str=="XML") {
1292  return MO_VALUE_XML;
1293  } else if (p_value_type_str=="LNK") {
1294  return MO_VALUE_LNK;
1295  } else if (p_value_type_str=="MATRIX") {
1296  return MO_VALUE_MATRIX;
1297  }
1298 
1299  return MO_VALUE_UNDEFINED;
1300 }
1301 
1302 MOint
1304  return m_Index;
1305 }
1306 
1307 moText
1309  return m_CodeName;
1310 }
1311 
1312 void
1314  m_CodeName = p_codename;
1315 }
1316 
1317 void
1319  m_Min = min;
1320  m_Max = max;
1321 }
1322 
1323 void
1325 
1326  sscanf( min, "%f", &m_Min);
1327  sscanf( max, "%f", &m_Max);
1328 }
1329 
1330 void
1332  if (min && max) {
1333  (*min) = m_Min;
1334  (*max) = m_Max;
1335  }
1336 }
1337 
1338 moText
1340  return m_Attribute;
1341 }
1342 
1343 void
1345  m_Attribute = p_attribute;
1346 }
1347 
1348 bool
1350  return (m_Type!=MO_VALUE_UNDEFINED);
1351 }
1352 
1353 const moText&
1355  moText fieldSeparation = ",";
1356 
1357  m_FullJSON = "{";
1358  m_FullJSON+= "'t': '" + GetTypeStr() + "'";
1359  if (m_CodeName!="") m_FullJSON+= fieldSeparation+"'cod': '" + m_CodeName + "'";
1360  if (m_Min!=m_Max) {
1361  m_FullJSON+= fieldSeparation + "'min': " + FloatToStr(m_Min);
1362  m_FullJSON+= fieldSeparation + "'max': " + FloatToStr(m_Max);
1363  }
1364  m_FullJSON+= "}";
1365  return m_FullJSON;
1366 }
1367 
1368 const moText&
1370  moText fieldSeparation = " ";
1371 
1372  m_FullXML = "<moValueDefinition ";
1373  m_FullXML+= "codename='" + m_CodeName + "'";
1374  m_FullXML+= fieldSeparation + "type='" + GetTypeStr() + "'";
1375  m_FullXML+= fieldSeparation + "min='" + FloatToStr(m_Min)+ "'";
1376  m_FullXML+= fieldSeparation + "max='" + FloatToStr(m_Max)+ "'";
1377  m_FullXML+= fieldSeparation + ">";
1378  m_FullXML+= "</moValueDefinition>";
1379  return m_FullXML;
1380 }
1381 
1382 
1383 int
1384 moValueDefinition::Set( const moText& p_XmlText ) {
1385  TiXmlDocument m_XMLDoc;
1386  //TiXmlHandle xmlHandle( &m_XMLDoc );
1387  TiXmlEncoding xencoding = TIXML_ENCODING_LEGACY;
1388 
1389  m_XMLDoc.Parse((const char*) p_XmlText, 0, xencoding );
1391  //TiXmlElement* rootKey = m_XMLDoc.FirstChildElement( "D" );
1392  TiXmlElement* definitionNode = m_XMLDoc.FirstChildElement("moValueDefinition");
1393 
1394  //if (rootKey) {
1395 
1396  //TiXmlElement* sceneStateNode = rootKey->FirstChildElement("moSceneState");
1397  if (definitionNode) {
1398  m_CodeName = moText( definitionNode->Attribute("codename") );
1399  m_Type = ValueTypeFromStr( moText(definitionNode->Attribute("type")) );
1400  m_Min = atof(moText( definitionNode->Attribute("min") ));
1401  m_Max = atof(moText( definitionNode->Attribute("max") ));
1402  return 0;
1403  } else moDebugManager::Log( "No XML moValueDefinition in: " + p_XmlText );
1404 
1405  //} else moDebugManager::Error();
1406  return -1;
1407 }
1408 
1409 //================================================================
1410 // moValueBase
1411 //================================================================
1412 
1414 }
1415 
1417 {
1418  *this = src;
1419 }
1420 
1422 }
1423 
1425  m_ValueDefinition = src.m_ValueDefinition;
1426  (moData&)(*this)=(const moData&) src;
1427  return *this;
1428 }
1429 
1430 
1431 void
1433  m_ValueDefinition.SetRange(min,max);
1434 }
1435 
1436 void
1438  m_ValueDefinition.SetRange(min,max);
1439 }
1440 
1441 void
1443  m_ValueDefinition.GetRange(min,max);
1444 }
1445 
1446 moText
1448  return m_ValueDefinition.GetAttribute();
1449 }
1450 
1451 void
1453  m_ValueDefinition.SetAttribute(p_attribute);
1454 }
1455 
1456 void
1458  m_ValueDefinition.SetType(p_type);
1459 }
1460 
1461 bool moValueBase::FixType( moValueType p_ValueType ) {
1462 
1463  moText datavalue;
1464  bool result = true;
1465 
1466  if (p_ValueType==MO_VALUE_FUNCTION) {
1467  switch(m_ValueDefinition.GetType()) {
1468 
1469  case MO_VALUE_NUM:
1470  case MO_VALUE_NUM_CHAR:
1471  case MO_VALUE_NUM_DOUBLE:
1472  case MO_VALUE_NUM_FLOAT:
1473  case MO_VALUE_NUM_INT:
1474  case MO_VALUE_NUM_LONG:
1475  datavalue = moData::ToText();
1476  SetFun( datavalue );
1477  this->m_ValueDefinition.SetType( p_ValueType );
1478  result = true;
1479  break;
1480 
1481  case MO_VALUE_FUNCTION:
1482  result = true;
1483  break;
1484  default:
1485  result = false;
1486  break;
1487  }
1488  }
1489  return result;
1490 }
1491 
1492 void
1494  m_ValueDefinition.SetIndex(p_index);
1495 }
1496 
1499  return m_ValueDefinition.GetType();
1500 }
1501 
1502 moText
1504  return m_ValueDefinition.GetTypeStr();
1505 }
1506 
1507 MOint
1509  return m_ValueDefinition.GetIndex();
1510 }
1511 
1512 moText
1514  return m_ValueDefinition.GetCodeName();
1515 }
1516 
1517 void
1519  m_ValueDefinition.SetCodeName( p_codename );
1520 }
1521 
1522 const moText&
1524  moText fieldSeparation =",";
1525  m_FullJSON = "{";
1526  m_FullJSON+= "'d':" + m_ValueDefinition.ToJSON();
1527  m_FullJSON+= fieldSeparation + "'v':" + "'" + ToText() + "'";
1528  m_FullJSON+= "}";
1529  return m_FullJSON;
1530 }
1531 
1532 const moText&
1534  moText fieldSeparation = " ";
1535  m_FullXML = "<moValueBase ";
1536  m_FullXML+= fieldSeparation+"type='"+GetTypeStr()+"'";
1537  m_FullXML+= fieldSeparation+"value='"+ToText()+"'";
1541  /*m_FullXML+= m_ValueDefinition.ToXML();*/
1542  m_FullXML+= fieldSeparation+">";
1543  m_FullXML+= ToText();
1544  m_FullXML+= "</moValueBase>";
1545  return m_FullXML;
1546 }
1547 
1548 int
1549 moValueBase::Set( const moText& p_XmlText ) {
1550 
1551 TiXmlDocument m_XMLDoc;
1552  //TiXmlHandle xmlHandle( &m_XMLDoc );
1553  TiXmlEncoding xencoding = TIXML_ENCODING_LEGACY;
1554 
1555  m_XMLDoc.Parse((const char*) p_XmlText, 0, xencoding );
1557  //TiXmlElement* rootKey = m_XMLDoc.FirstChildElement( "D" );
1558  TiXmlElement* valueNode = m_XMLDoc.FirstChildElement("moValueBase");
1559 
1560  if (valueNode) {
1561  //moData data( moText( valueNode->Attribute("value") ) );
1562  //SetType( );
1563 
1564  moText value = moText( valueNode->Attribute("value") );
1565  switch(GetType()) {
1566  case MO_VALUE_FUNCTION:
1567  SetFun( value );
1568  break;
1569  case MO_VALUE_NUM:
1570  case MO_VALUE_NUM_INT:
1571  SetInt( atoi(value) );
1572  break;
1573  case MO_VALUE_NUM_CHAR:
1574  SetChar( atoi(value) );
1575  break;
1576  case MO_VALUE_NUM_LONG:
1577  SetLong( atoi(value) );
1578  break;
1579  case MO_VALUE_NUM_FLOAT:
1580  SetFloat( atof(value) );
1581  break;
1582  case MO_VALUE_NUM_DOUBLE:
1583  SetDouble( atof(value) );
1584  break;
1585  case MO_VALUE_TXT:
1586  SetText( value );
1587  break;
1588  case MO_VALUE_XML:
1589  SetText( value );
1590  break;
1591  case MO_VALUE_MATRIX:
1592  case MO_VALUE_LNK:
1593  SetText( value );
1594  break;
1595  default:
1596  SetText(value);
1597  break;
1598  };
1599 
1600  SetType( moValueDefinition::ValueTypeFromStr( moText( valueNode->Attribute("type") ) ) );
1601 
1602  return 0;
1603  } else moDebugManager::Log( "No XML moValueBase in: " + p_XmlText );
1604 
1605  return -1;
1606 
1607 }
1608 
1609 //================================================================
1610 // moValue
1611 //================================================================
1612 
1614 
1615 }
1616 
1618  *this = src;
1619 }
1620 /*
1621  MO_VALUE_NUM,//any type of number
1622  MO_VALUE_MATRIX,//any type of VECTOR
1623  MO_VALUE_TXT,//any type of text, single or multiline
1624  MO_VALUE_LNK,//link to a file, text is interpreted as relative, absolute link to a file
1625  MO_VALUE_FUNCTION,//function parameter value, with lots of attributes....
1626  MO_VALUE_XML//
1627 */
1628 
1629 moValue::moValue( const moText &strvalue, moValueType p_type ) {
1630  AddSubValue( strvalue, p_type );
1631 }
1632 
1634  moValueBase valuebase;
1635  valuebase.SetChar( p_char );
1636  AddSubValue( valuebase );
1637 }
1638 
1640  moValueBase valuebase;
1641  valuebase.SetInt( p_int );
1642  AddSubValue( valuebase );
1643 }
1644 
1646  moValueBase valuebase;
1647  valuebase.SetLong( p_long );
1648  AddSubValue( valuebase );
1649 }
1650 
1652  moValueBase valuebase;
1653  valuebase.SetFloat( p_float );
1654  AddSubValue( valuebase );
1655 }
1656 
1658  moValueBase valuebase;
1659  valuebase.SetDouble( p_double );
1660  AddSubValue( valuebase );
1661 }
1662 
1663 moValue::moValue( const moText &strvalue , const moText &type ) {
1664  AddSubValue( strvalue, type );
1665 }
1666 
1667 
1668 moValue::moValue( const moText &strvalue, const moText &type, const moText &strvalue2, const moText &type2 ) {
1669  AddSubValue( strvalue, type );
1670  AddSubValue( strvalue2, type2 );
1671 }
1672 
1673 moValue::moValue( const moText &strvalue, const moText &type, const moText &strvalue2, const moText &type2, const moText &strvalue3, const moText &type3 ) {
1674  AddSubValue( strvalue, type );
1675  AddSubValue( strvalue2, type2 );
1676  AddSubValue( strvalue3, type3 );
1677 }
1678 moValue::moValue( const moText &strvalue, const moText &type, const moText &strvalue2, const moText &type2, const moText &strvalue3, const moText &type3, const moText &strvalue4, const moText &type4 ) {
1679  AddSubValue( strvalue, type );
1680  AddSubValue( strvalue2, type2 );
1681  AddSubValue( strvalue3, type3 );
1682  AddSubValue( strvalue4, type4 );
1683 }
1684 
1685 
1686 void moValue::RemoveSubValue( MOint p_indexsubvalue ) {
1687  m_List.Remove( p_indexsubvalue );
1688 }
1689 
1690 
1691 void moValue::RemoveSubValues( bool leavefirstone ) {
1692  if (leavefirstone) {
1693  while( m_List.Count()>1 ) {
1694  m_List.Remove(1);
1695  }
1696  } else {
1697  m_List.Empty();
1698  }
1699 }
1700 
1701 void
1702 moValue::AddSubValue( const moValueBase &valuebase ) {
1703  m_List.Add( valuebase );
1704 }
1705 
1706 void
1707 moValue::AddSubValue(const moText &strvalue, moValueType p_valuetype ) {
1708 
1709  MOint tmpInt;
1710  MOchar tmpChar;
1711  MOlong tmpLong;
1712  MOdouble tmpDouble;
1713  MOfloat tmpFloat;
1714 
1715  moValueBase valuebase;
1716 
1717  valuebase.SetText( strvalue );
1718 
1719  switch(p_valuetype) {
1720 
1721  case MO_VALUE_NUM:
1722  case MO_VALUE_NUM_INT:
1723  sscanf( moText(strvalue), "%i", &tmpInt);
1724  valuebase.SetInt( tmpInt );
1725  break;
1726 
1727  case MO_VALUE_NUM_LONG:
1728  sscanf( moText(strvalue), "%li", &tmpLong);
1729  valuebase.SetLong( tmpLong );
1730  break;
1731 
1732  case MO_VALUE_NUM_CHAR:
1733  sscanf( moText(strvalue), "%c", &tmpChar);
1734  valuebase.SetChar( tmpChar );
1735  break;
1736 
1737  case MO_VALUE_NUM_FLOAT:
1738  sscanf( moText(strvalue), "%f", &tmpFloat);
1739  valuebase.SetFloat( tmpFloat );
1740  break;
1741 
1742  case MO_VALUE_NUM_DOUBLE:
1743  sscanf( moText(strvalue), "%lf", &tmpDouble);
1744  valuebase.SetDouble( tmpDouble );
1745  break;
1746 
1747  case MO_VALUE_FUNCTION:
1748  valuebase.SetFun( strvalue );
1749  valuebase.SetType( MO_VALUE_FUNCTION );
1750  break;
1751 
1752  default:
1753  break;
1754 
1755  }
1756 
1757  valuebase.SetType( p_valuetype );
1758 
1759  m_List.Add( valuebase );
1760 
1761 }
1762 
1763 
1764 void
1765 moValue::AddSubValue( const moText &strvalue, const moText &type ) {
1766 
1767  moValueBase valuebase;
1768 
1769  if ( (moText)type == moText("TXT") ) {
1770 
1771  valuebase.SetText( strvalue );
1772  valuebase.SetType( MO_VALUE_TXT );
1773 
1774  } else if ((moText)type == moText("LNK")) {
1775 
1776  valuebase.SetText( strvalue );
1777  valuebase.SetType( MO_VALUE_LNK );
1778 
1779  } else if ((moText)type== moText("XML") ) {
1780 
1781  valuebase.SetText( strvalue );
1782  valuebase.SetType( MO_VALUE_XML );
1783 
1784  } else if ( (moText)type== moText("NUM")) {
1785 
1786  MOint tmp2 = 0;
1787  sscanf( moText(strvalue), "%i", &tmp2);
1788  valuebase.SetInt( tmp2 );
1789  valuebase.SetType( MO_VALUE_NUM );
1790 
1791  } else if ( (moText)type== moText("INT")) {
1792 
1793  MOint tmp2 = 0;
1794  sscanf( moText(strvalue), "%i", &tmp2);
1795  valuebase.SetInt( tmp2 );
1796  valuebase.SetType( MO_VALUE_NUM_INT );
1797 
1798  } else if ( (moText)type== moText("CHAR")) {
1799 
1800  MOchar tmp2 = 0;
1801  sscanf( moText(strvalue), "%c", &tmp2);
1802  valuebase.SetChar( tmp2 );
1803  valuebase.SetType( MO_VALUE_NUM_CHAR );
1804 
1805  } else if ( (moText)type== moText("LONG")) {
1806 
1807  MOlong tmp2 = 0;
1808  sscanf( moText(strvalue), "%li", &tmp2);
1809  valuebase.SetLong( tmp2 );
1810  valuebase.SetType( MO_VALUE_NUM_LONG );
1811 
1812  } else if ( (moText)type== moText("FLOAT")) {
1813 
1814  MOfloat tmp2 = 0.0f;
1815  sscanf( moText(strvalue), "%f", &tmp2);
1816  valuebase.SetFloat( tmp2 );
1817  valuebase.SetType( MO_VALUE_NUM_FLOAT );
1818 
1819  } else if ( (moText)type== moText("DOUBLE")) {
1820 
1821  MOdouble tmp2 = 0.0;
1822  sscanf( moText(strvalue), "%lf", &tmp2);
1823  valuebase.SetDouble( tmp2 );
1824  valuebase.SetType( MO_VALUE_NUM_DOUBLE );
1825 
1826  } else if ((moText)type== moText("FUNCTION")) {
1827  //float tmp2;
1828  //sscanf( strvalue, "%f", &tmp2);
1829  //valuebase.SetFloat( tmp2 );
1830  valuebase.SetFun( strvalue );
1831  valuebase.SetType( MO_VALUE_FUNCTION );
1832 
1833  } else if ((moText)type== moText("MATRIX") ) {
1834 
1835  //SetText( strvalue );
1836  //float tmp2;
1837  //sscanf( strvalue, "%f", &tmp2);
1838  //valuebase.SetFloat( tmp2 );
1839  valuebase.SetText( strvalue );
1840  valuebase.SetType( MO_VALUE_MATRIX );
1841 
1842  }
1843 
1844  m_List.Add( valuebase );
1845 
1846 }
1847 
1849 
1850 }
1851 
1853  m_List = src.m_List;
1854  return *this;
1855 }
1856 
1857 const moText&
1859  moText fieldSeparation = "";
1860  m_FullJSON = "[";
1861  for( int vbase=0; vbase < (int)m_List.Count(); vbase++) {
1862  m_FullJSON+= fieldSeparation + m_List[vbase].ToJSON();
1863  fieldSeparation = ",";
1864  }
1865  m_FullJSON+= "]";
1866  return m_FullJSON;
1867 }
1868 
1869 const moText&
1871  moText fieldSeparation = "";
1872  m_FullXML = "<moValue>";
1873  for( int vbase=0; vbase < (int)m_List.Count(); vbase++) {
1874  m_FullXML+= fieldSeparation + m_List[vbase].ToXML();
1875  fieldSeparation = "";
1876  }
1877  m_FullXML+= "</moValue>";
1878  return m_FullXML;
1879 }
1880 
1881 
1882 int
1883 moValue::Set( const moText& p_XmlText ) {
1884 
1885  TiXmlDocument m_XMLDoc;
1886  //TiXmlHandle xmlHandle( &m_XMLDoc );
1887  TiXmlEncoding xencoding = TIXML_ENCODING_LEGACY;
1888 
1889  m_XMLDoc.Parse((const char*) p_XmlText, 0, xencoding );
1891  //TiXmlElement* rootKey = m_XMLDoc.FirstChildElement( "D" );
1892  TiXmlElement* valueNode = m_XMLDoc.FirstChildElement("moValue");
1893 
1894  //if (rootKey) {
1895 
1896  //TiXmlElement* sceneStateNode = rootKey->FirstChildElement("moSceneState");
1897  if (valueNode) {
1898 
1899  TiXmlElement* valuebaseNode = valueNode->FirstChildElement("moValueBase");
1900  int vbidx = 0;
1901  while(valuebaseNode) {
1902  moValueBase vb;
1903  moText vbXML;
1904  TiXmlPrinter printer;
1905  TiXmlNode* NODEDATAXML = valuebaseNode;
1906  if (NODEDATAXML) {
1907  NODEDATAXML->Accept( &printer );
1908  vbXML = moText( printer.CStr() );
1909  }
1910  vb.Set( vbXML );
1911 
1912  if (vbidx<(int)GetSubValueCount()) GetSubValue(vbidx) = vb;
1913  else AddSubValue( vb );
1914 
1915  valuebaseNode = valuebaseNode->NextSiblingElement("moValueBase");
1916  vbidx+= 1;
1917  }
1918  return 0;
1919  } else moDebugManager::Log( "No XML moValue in: " + p_XmlText );
1920 
1921  //} else moDebugManager::Error();
1922  return -1;
1923 }
void SetRange(MOfloat min, MOfloat max)
Definition: moValue.cpp:1318
void SetAttribute(moText p_attribute)
Definition: moValue.cpp:1452
Valor de un Parámetro.
Definition: moValue.h:501
moVector4i * Vector4i()
Definition: moValue.cpp:400
void SetMessages(moDataMessages *p_datamessages)
Definition: moValue.cpp:361
void SetText(moText ptext)
Definition: moValue.cpp:158
MOdouble Eval()
Definition: moValue.cpp:424
#define MOulong
Definition: moTypes.h:392
MOint GetIndex() const
Definition: moValue.cpp:1303
Tempo, beat, ritmo.
Definition: moTempo.h:44
MOdouble m_LastEval
Definition: moValue.h:282
moDataType
Definition: moValue.h:98
MOint m_Int
Definition: moValue.h:135
moMathFunction * Fun()
referencias a clases
Definition: moValue.cpp:417
MOdouble m_Double
Definition: moValue.h:137
clase base para una fuente 3d o 2d
Definition: moFontManager.h:63
void GetRange(MOfloat *min, MOfloat *max)
Definition: moValue.cpp:1331
moValueBase & GetSubValue(MOint p_indexsubvalue=0)
Definition: moValue.h:539
moText GetAttribute() const
Definition: moValue.cpp:1447
virtual ~moValueDefinition()
Definition: moValue.cpp:1204
void SetDouble(MOdouble pdouble)
Definition: moValue.cpp:172
void SetVector(moVector2d *p_vector2d)
Definition: moValue.cpp:317
MOdouble LastEval() const
Definition: moValue.cpp:449
moTextureBuffer * TextureBuffer()
Definition: moValue.cpp:479
moDatas moDataMessage
Definition: moValue.h:149
moText m_Text
Definition: moValue.h:272
LIBMOLDEO_API moText0 FloatToStr(double a)
Definition: moText.cpp:1134
moDataType TextToType(moText texttype)
Definition: moValue.cpp:630
moText ToText() const
Definition: moValue.cpp:707
void SetType(moValueType p2_type)
Definition: moValue.cpp:1219
#define MOchar
Definition: moTypes.h:397
static moValueType ValueTypeFromStr(const moText &p_value_type_str)
Definition: moValue.cpp:1274
const moText & ToJSON()
Definition: moValue.cpp:1523
virtual MOboolean Init(const moText &p_Expression, moMoldeoObject *p_pMOB=NULL)
textura múltiple
Definition: moTexture.h:55
const moText & ToXML()
Definition: moValue.cpp:1533
void SetCodeName(moText p_codename)
Fija el nombre del código para este valor.
Definition: moValue.cpp:1518
MOchar m_Char
Definition: moValue.h:134
moDataType Type() const
Definition: moValue.cpp:940
int Set(const moText &p_XmlText)
Definition: moValue.cpp:1549
void SetTexture(moTexture *p_Texture)
Definition: moValue.cpp:244
void AddSubValue(const moText &strvalue, moValueType p_valuetype)
Definition: moValue.cpp:1707
void SetFun(const moText &p_functionExpression)
Definition: moValue.cpp:228
void SetLong(MOlonglong plong)
Definition: moValue.cpp:188
void Apply(MOuint p_i, MOfloat p_fade, const moTextFilterParam &p_params)
void SetSize(MOulong p_DataSize)
Definition: moValue.cpp:223
moValue & operator=(const moValue &src)
Definition: moValue.cpp:1852
void SetAttribute(moText p_attribute)
Definition: moValue.cpp:1344
#define MOfloat
Definition: moTypes.h:403
int Set(const moText &p_XmlText)
Definition: moValue.cpp:1883
bool m_bFilteredParams
Definition: moValue.h:277
MOpointer Pointer()
Definition: moValue.cpp:919
moDataMessages * Messages()
Definition: moValue.cpp:412
clase de para manejar textos
Definition: moText.h:75
bool FixType(moValueType p_ValueType)
Definition: moValue.cpp:1461
int Set(const moText &p_XmlText)
Definition: moValue.cpp:1384
#define MOlong
Definition: moTypes.h:391
const moText & ToJSON()
Definition: moValue.cpp:1858
void SetNumber(moNumber p_number)
Definition: moValue.cpp:203
GLint GetGLId()
Definition: moValue.cpp:1087
moDataType m_DataType
Definition: moValue.h:270
moTexture * GetTexture(MOuint p_idx)
void SetSound(moSound *p_Sound)
Definition: moValue.cpp:368
void SetIndex(MOint p_index)
Definition: moValue.cpp:1224
#define moRound(x)
Definition: moValue.h:79
MOfloat Float() const
Definition: moValue.cpp:835
moValueBase & operator=(const moValueBase &src)
Definition: moValue.cpp:1424
static void Log(moText p_text)
Escribe un mensaje en el archivo de registro (log)
moText0 moText
Definition: moText.h:291
Buffer de imágenes para video.
MOulong m_DataSize
Definition: moValue.h:273
MOint GetIndex() const
Devuelve el índice de este valor.
Definition: moValue.cpp:1508
void SetMessage(moDataMessage *p_datamessage)
Definition: moValue.cpp:354
#define MOint
Definition: moTypes.h:388
void SetModel(moSceneNode *p_Model)
Definition: moValue.cpp:275
MOulong Size() const
Definition: moValue.cpp:934
void SetTextureFilter(moTextureFilter *p_TextureFilter)
Definition: moValue.cpp:262
void GetRange(MOfloat *min, MOfloat *max)
Definition: moValue.cpp:1442
moNumber Number()
Definition: moValue.cpp:914
void SetInt(MOint pint)
Definition: moValue.cpp:180
void SetType(moValueType p_type)
Fija el tipo de valor, esta función se implementa sólo como atajo a ciertos datos de la definición ...
Definition: moValue.cpp:1457
moDataMessage * Message()
Definition: moValue.cpp:407
MOfloat m_AlphaFilter
Definition: moValue.h:278
Clase Base para Objetos Moldeo ( moEffect, moIODevice, moResource, moConsole )
MOuint GetGLId() const
Definition: moTexture.h:224
clase base para el manejo de una textura
Definition: moTexture.h:78
moText TypeToText()
Definition: moValue.cpp:544
void RemoveSubValues(bool leavefirstone=true)
Definition: moValue.cpp:1691
moTextureIndex * GetDestTex()
película
Definition: moTexture.h:56
void SetVideoBuffer(moVideoBuffer *p_VideoBuffer)
Definition: moValue.cpp:256
moValueType GetType() const
Definition: moValue.cpp:1229
moVector3d * Vector3d()
Definition: moValue.cpp:385
Clase base de sonido.
void Copy(const moData &data)
Definition: moValue.cpp:146
moSceneNode * Model()
Definition: moValue.cpp:487
MOdouble Double() const
Definition: moValue.cpp:859
TEXTURA BASE.
Definition: moTexture.h:54
moText GetTypeStr() const
Devuelve el tipo en formato texto.
Definition: moValue.cpp:1503
moVector3i * Vector3i()
Definition: moValue.cpp:390
virtual ~moValue()
Definition: moValue.cpp:1848
moText Text()
Definition: moValue.cpp:539
moData & operator=(const moData &data)
Definition: moValue.cpp:130
void SetIndex(MOint p_index)
Fija el índice al que corresponde este valor dentro de la configuración
Definition: moValue.cpp:1493
virtual double Eval()
moVector2i * Vector2i()
Definition: moValue.cpp:380
MOlonglong Long() const
Definition: moValue.cpp:804
moText GetCodeName() const
Devuelve un nombre de código en texto fijado por el usuario para este valor.
Definition: moValue.cpp:1513
void SetPointer(MOpointer data, MOulong size)
Definition: moValue.cpp:215
moTextFilterParam m_pFilterParam
Definition: moValue.h:279
#define MOdouble
Definition: moTypes.h:404
void SetRange(MOfloat min, MOfloat max)
Definition: moValue.cpp:1432
moDefineDynamicArray(moValueIndexes) moDefineDynamicArray(moValueBases) moDefineDynamicArray(moValues) moDefineDynamicArray(moDatas) moDefineDynamicArray(moDataMessages) moData
Definition: moValue.cpp:42
moValueBase()
Contructor.
Definition: moValue.cpp:1413
moVector4d * Vector4d()
Definition: moValue.cpp:395
moText GetCodeName() const
Definition: moValue.cpp:1308
#define MOlonglong
Definition: moTypes.h:393
MOfloat m_Float
Definition: moValue.h:138
moTextureType GetType() const
Definition: moTexture.h:219
MOlonglong m_Long
Definition: moValue.h:136
virtual MOint GetGLId(moTempo *tempo)
Definition: moTexture.cpp:1648
void SetTextureBuffer(moTextureBuffer *p_TextureBuffer)
Definition: moValue.cpp:250
#define MOuint
Definition: moTypes.h:387
void SetFont(moFont *p_Font)
Definition: moValue.cpp:269
MOpointer m_Pointer
Definition: moValue.h:139
LIBMOLDEO_API moText0 IntToStr(int a)
Definition: moText.cpp:1070
moData * GetData()
Definition: moValue.cpp:945
void SetChar(MOchar pchar)
Definition: moValue.cpp:196
moData * m_pAlphaFilter
Definition: moValue.h:280
void SetCodeName(moText p_codename)
Definition: moValue.cpp:1313
MOint Int() const
Definition: moValue.cpp:773
moFont * Font()
Definition: moValue.cpp:474
MOuint GetSubValueCount()
Definition: moValue.h:545
virtual ~moData()
Definition: moValue.cpp:126
const moText & ToXML()
Definition: moValue.cpp:1369
moSound * Sound()
Definition: moValue.cpp:493
bool m_bFilteredAlpha
Definition: moValue.h:276
una textura asociada a una animación de cuadros
Definition: moTexture.h:549
virtual ~moValueBase()
Definition: moValue.cpp:1421
moTexture * TextureDestination()
if MO_DATA_IMAGESAMPLE source = destination
Definition: moValue.cpp:519
bool IsValid() const
Definition: moValue.cpp:152
moTextureIndex * GetSrcTex()
moText GetTypeStr() const
Definition: moValue.cpp:1234
MOdouble ang
Definition: moTempo.h:81
const moText & ToXML()
Definition: moValue.cpp:1870
void SetTextureFilterAlpha(moData *p_alpha)
Definition: moValue.cpp:281
void SetType(moDataType p_DataType)
Definition: moValue.cpp:210
moNumber m_Number
Definition: moValue.h:271
moText GetAttribute() const
Definition: moValue.cpp:1339
moValueType GetType() const
Devuelve el tipo de valor ,esta función se implementa sólo como atajo a ciertos datos de la definición ...
Definition: moValue.cpp:1498
void SetFloat(MOfloat pfloat)
Definition: moValue.cpp:164
moValueDefinition & operator=(const moValueDefinition &src)
Definition: moValue.cpp:1207
moMathFunction
#define MOpointer
Definition: moTypes.h:409
void SetTextureFilterParam(const moTextFilterParam &p_filterparam)
Definition: moValue.cpp:310
void RemoveSubValue(MOint p_indexsubvalue)
Definition: moValue.cpp:1686
moTexture * Texture()
Definition: moValue.cpp:501
virtual moText & GetExpression()
bool IsValid() const
Definition: moValue.cpp:1349
moValueType
Definition: moValue.h:300
moVector2d * Vector2d()
Definition: moValue.cpp:375
MOchar Char() const
Definition: moValue.cpp:883
const moText & ToJSON()
Definition: moValue.cpp:1354