libmoldeo (Moldeo 1.0 Core)  1.0
libmoldeo es el conjunto de objetos y funciones, que permiten ejecutar las operaciones básicas de la plataforma Moldeo, y que compone su núcleo.
moLunaClasses.cpp
Ir a la documentación de este archivo.
1 /*******************************************************************************
2 
3  moLunaClasses.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  Andrés Colubri
29 
30  referencias codigo: http://dev.alt.textdrive.com/browser/lu/
31  benchmarks: http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=luajit&lang2=lua
32 
33 
34 *******************************************************************************/
35 
36 #include "moLunaClasses.h"
37 
38 #define lua_pindexes( L ) ( lua_gettop(L) - 1 )
39 #define lua_pindex( index ) (index + 1)
40 
50 
52  SCRIPT_FUNCTION( moLuaSoundManager, GetSoundCount ),
54  {0,0}
56 
58  {0,0,0}
60 
61 
63 {
64  m_pSoundMan = NULL;
65  MODebug2->Message("moLuaSoundManager > constructor L: " + IntToStr( (long)(L) ) );
66 }
67 
68 void moLuaSoundManager::Set( moSoundManager* p_pSoundManager) {
69  m_pSoundMan = p_pSoundManager;
70 }
71 
72 
74 {
75  //MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
76  //MOdouble res = moMathd::ACos(fValue);
77  //lua_pushnumber(L, (lua_Number)res);
78  int count = 0;
79  if (m_pSoundMan)
80  count = m_pSoundMan->GetSoundCount();
81  lua_pushnumber(L, (lua_Number)count);
82  return 1;
83 }
84 
86 {
87  int id = (int) lua_tonumber (L, lua_pindex(1) );
88  moSound* pSound = NULL;
89  if (m_pSoundMan)
90  pSound = m_pSoundMan->GetSound(id);
91  //if (pCirc)
92  return 1;
93 }
94 
104 
106  SCRIPT_FUNCTION( moLuaTextureManager, GetTextureCount),
107  SCRIPT_FUNCTION( moLuaTextureManager, GetTextureMOId),
108  SCRIPT_FUNCTION( moLuaTextureManager, GetTextureBuffer),
109  SCRIPT_FUNCTION( moLuaTextureManager, AddTexture),
110  SCRIPT_FUNCTION( moLuaTextureManager, DeleteTexture),
111  SCRIPT_FUNCTION( moLuaTextureManager, AddTextureBuffer),
112  SCRIPT_FUNCTION( moLuaTextureManager, DeleteTextureBuffer),
114  SCRIPT_FUNCTION( moLuaTextureManager, ValidTexture),
115  { 0, 0 }
117 
119 {0,0,0}
121 
122 
124 {
125  m_pTextureMan = NULL;
126  MODebug2->Message("moLuaTextureManager > constructor L: " + IntToStr( (long)L ) );
127 }
128 
129 void moLuaTextureManager::Set( moTextureManager* p_pTextureMan) {
130  m_pTextureMan = p_pTextureMan;
131 }
132 
133 
135 {
136  int count = 0;
137  if (m_pTextureMan) {
138  count = m_pTextureMan->GetTextureCount();
139  lua_pushnumber(L, (lua_Number)count);
140  return 1;
141  }
142 
143  moText tx_error("moLuaTextureManager::GetTextureCount > no m_pTextureMan pointer");
144  lua_pushstring( L, tx_error );
145  return 1;
146 }
147 
149 {
150  moText texturename = (char *) lua_tostring( L, lua_pindex(1) );
151  //int create_if_not_found = (int) lua_tonumber( L, lua_pindex(1) );
152 
153  if (texturename=="") {
154  moText tx_error("moLuaTextureManager::GetTextureMOId > first parameter cannot be empty");
155  lua_pushstring( L, tx_error );
156  return 1;
157  }
158 
159  int moid = -1;
160  if (m_pTextureMan) {
161  moid = m_pTextureMan->GetTextureMOId( texturename, false );
162  lua_pushnumber(L, (lua_Number)moid);
163  return 1;
164  }
165 
166  moText tx_error("moLuaTextureManager::GetTextureMOId > no m_pTextureMan pointer");
167  lua_pushstring( L, tx_error );
168  return 1;
169 }
170 
172 {
173  int moid = -1;
174  moText texturename = (char *) lua_tostring( L, lua_pindex(1) );
175  int create_if_not_found = (int) lua_tonumber( L, lua_pindex(1) );
176  moText buffer_format = (char *) lua_tostring( L, lua_pindex(1) );
177 
178  if (m_pTextureMan) {
179  moid = m_pTextureMan->GetTextureBuffer( texturename, create_if_not_found, buffer_format );
180  lua_pushnumber(L, (lua_Number)moid);
181  return 1;
182  }
183 
184  moText tx_error("moLuaTextureManager::GetTextureBuffer > no m_pTextureMan pointer");
185  lua_pushstring( L, tx_error );
186  return 1;
187 }
188 
190 {
191  MODebug2->Message("moLuaTextureManager::AddTexture > TODO implement L: " + IntToStr( (long)L ) );
192  /*
193  int moid = -1;
194  if (m_pTextureMan)
195  moid = m_pTextureMan->AddTexture( texturename );
196  */
197  return 0;
198 }
199 
201 {
202  MODebug2->Message("moLuaTextureManager::DeleteTexture > TODO implement L: " + IntToStr( (long)L ) );
203  /*
204  int moid = -1;
205  if (m_pTextureMan)
206  moid = m_pTextureMan->DeleteTexture( moid );
207  */
208  return 0;
209 }
210 
212 {
213  MODebug2->Message("moLuaTextureManager::AddTextureBuffer > TODO implement L: " + IntToStr( (long)L ) );
214  /*
215  int moid = -1;
216  if (m_pTextureMan)
217  moid = m_pTextureMan->AddTextureBuffer( texturename );
218  */
219  return 0;
220 }
221 
223 {
224  MODebug2->Message("moLuaTextureManager::DeleteTextureBuffer > TODO implement L: " + IntToStr( (long)L ) );
225  /*
226  int moid = -1;
227  if (m_pTextureMan)
228  moid = m_pTextureMan->DeleteTextureBuffer( texturename );
229  return 1;
230  */
231  return 0;
232 }
233 
234 
236 {
237  int moid = (int) lua_tonumber( L, lua_pindex(1) );
238  int glid = -1;
239  if (m_pTextureMan) {
240  glid = m_pTextureMan->GetGLId( moid );
241  lua_pushnumber(L, (lua_Number)glid);
242  return 1;
243  }
244 
245  moText tx_error("moLuaTextureManager::GetGLId > no m_pTextureMan pointer");
246  lua_pushstring( L, tx_error );
247  return 1;
248 }
249 
251 {
252  int moid = (int) lua_tonumber( L, lua_pindex(1) );
253 
254  int res = 0;
255  if (m_pTextureMan) {
256  res = (int) m_pTextureMan->ValidTexture( moid );
257  lua_pushnumber(L, (lua_Number)res);
258  return 1;
259  }
260 
261  moText tx_error("moLuaTextureManager::ValidTexture > no m_pTextureMan pointer");
262  lua_pushstring( L, tx_error );
263  return 1;
264 }
265 
266 
276 
278  SCRIPT_FUNCTION( moLuaCircularVideoBuffer, StartRecording),
279  SCRIPT_FUNCTION( moLuaCircularVideoBuffer, PauseRecording),
280  SCRIPT_FUNCTION( moLuaCircularVideoBuffer, ContinueRecording),
281  SCRIPT_FUNCTION( moLuaCircularVideoBuffer, StopRecording),
282  SCRIPT_FUNCTION( moLuaCircularVideoBuffer, GetRecordPosition),
283  SCRIPT_FUNCTION( moLuaCircularVideoBuffer, GetFrameCount),
285  { 0, 0 }
287 
288 
290  {0,0,0}
292 
293 
295 {
296  m_pCircularVideoBuffer = NULL;
297  MODebug2->Message("moLuaCircularVideoBuffer constructor > L: " + IntToStr( (long)L ) );
298 }
299 
300 void moLuaCircularVideoBuffer::Set( moCircularVideoBuffer* p_pCircularVideoBuffer) {
301  m_pCircularVideoBuffer = p_pCircularVideoBuffer;
302 }
303 
304 
306 {
307  int at_position = (int) lua_tonumber (L, lua_pindex(1) );
308  MODebug2->Push("at_position:"+IntToStr(at_position));
309  if (m_pCircularVideoBuffer)
310  m_pCircularVideoBuffer->StartRecording(at_position);
311  return 0;
312 }
313 
315 {
316  MODebug2->Message("moLuaCircularVideoBuffer::PauseRecording > L: " + IntToStr( (long)L ) );
317  if (m_pCircularVideoBuffer)
318  m_pCircularVideoBuffer->PauseRecording();
319  return 0;
320 }
321 
322 
324 {
325  MODebug2->Message("moLuaCircularVideoBuffer::ContinueRecording > L: " + IntToStr( (long)L ) );
326  if (m_pCircularVideoBuffer)
327  m_pCircularVideoBuffer->ContinueRecording();
328  return 0;
329 }
330 
332 {
333  MODebug2->Message("moLuaCircularVideoBuffer::StopRecording > L: " + IntToStr( (long)L ) );
334  if (m_pCircularVideoBuffer)
335  m_pCircularVideoBuffer->StopRecording();
336  return 0;
337 }
338 
340 {
341 
342  int recp = -1;
343  if (m_pCircularVideoBuffer)
344  recp = m_pCircularVideoBuffer->GetRecordPosition();
345  lua_pushnumber(L, (lua_Number)recp);
346  return 1;
347 }
348 
350 {
351  int fcount = 0;
352  if (m_pCircularVideoBuffer)
353  fcount = m_pCircularVideoBuffer->GetFrameCount();
354  lua_pushnumber(L, (lua_Number)fcount);
355  return 1;
356 }
357 
359 {
360  bool res = false;
361  if (m_pCircularVideoBuffer)
362  res = m_pCircularVideoBuffer->IsRecording();
363  lua_pushboolean(L, res);
364  return 1;
365 }
366 
367 
368 
378 
380  SCRIPT_FUNCTION( moLuaVideoBuffer, GetFrameCount),
381  { 0, 0 }
383 
384 
386 {0,0,0}
388 
389 
391 {
392  m_pVideoBuffer = NULL;
393  MODebug2->Message("moLuaVideoBuffer constructor > L: " + IntToStr( (long)L ) );
394 }
395 
396 void moLuaVideoBuffer::Set( moVideoBuffer* p_pVideoBuffer) {
397  m_pVideoBuffer = p_pVideoBuffer;
398 }
399 
400 
402 {
403  int fcount = -1;
404  if (m_pVideoBuffer) {
405  fcount = m_pVideoBuffer->GetFrameCount();
406  lua_pushnumber(L, (lua_Number)fcount);
407  return 1;
408  }
409 
410  return 0;
411 }
412 
413 
423 
426  SCRIPT_FUNCTION( moLuaVideoBufferPath, GetCompletePath),
427  SCRIPT_FUNCTION( moLuaVideoBufferPath, GetTotalFiles),
428  SCRIPT_FUNCTION( moLuaVideoBufferPath, GetImagesProcessed),
429  SCRIPT_FUNCTION( moLuaVideoBufferPath, LoadCompleted),
430  { 0, 0 }
432 
433 
435  {0,0,0}
437 
438 
440 {
441  m_pVideoBufferPath = NULL;
442  MODebug2->Message("moLuaVideoBufferPath constructor > L: " + IntToStr( (long)L ) );
443 }
444 
445 void moLuaVideoBufferPath::Set( moVideoBufferPath* p_pVideoBufferPath) {
446  m_pVideoBufferPath = p_pVideoBufferPath;
447 }
448 
449 
451 {
452  moText path = "";
453  if (m_pVideoBufferPath) {
454  path = m_pVideoBufferPath->GetPath();
455  lua_pushstring(L, path );
456  return 1;
457  }
458 
459  return 0;
460 }
461 
463 {
464  moText path = "";
465  if (m_pVideoBufferPath) {
466  path = m_pVideoBufferPath->GetCompletePath();
467  lua_pushstring(L, path );
468  return 1;
469  }
470 
471  return 0;
472 }
473 
475 {
476  int fcount = -1;
477  if (m_pVideoBufferPath) {
478  fcount = m_pVideoBufferPath->GetTotalFiles();
479  lua_pushnumber(L, (lua_Number)fcount);
480  return 1;
481  }
482 
483  return 0;
484 }
485 
487 {
488  int fcount = -1;
489  if (m_pVideoBufferPath) {
490  fcount = m_pVideoBufferPath->GetImagesProcessed();
491  lua_pushnumber(L, (lua_Number)fcount);
492  return 1;
493  }
494 
495  return 0;
496 }
497 
498 
500 {
501  int completed = -1;
502  if (m_pVideoBufferPath) {
503  completed = (int)m_pVideoBufferPath->LoadCompleted();
504  lua_pushnumber(L, (lua_Number)completed);
505  return 1;
506  }
507 
508  return 0;
509 }
510 
511 
521 
523  SCRIPT_FUNCTION( moLuaVideoManager, GetVideoBufferCount ),
524  SCRIPT_FUNCTION( moLuaVideoManager, GetVideoBuffer ),
525  SCRIPT_FUNCTION( moLuaVideoManager, GetCircularVideoBufferCount ),
526  SCRIPT_FUNCTION( moLuaVideoManager, GetCircularVideoBuffer ),
527  SCRIPT_FUNCTION( moLuaVideoManager, GetVideoBufferPathCount ),
528  SCRIPT_FUNCTION( moLuaVideoManager, GetVideoBufferPath ),
529  { 0, 0 }
531 
533 {0,0,0}
535 
537 {
538  m_pVideoMan = NULL;
539  MODebug2->Message("moLuaVideoManager constructor > L: " + IntToStr( (long)L ) );
540 }
541 
542 void moLuaVideoManager::Set( moVideoManager* p_pVideoManager) {
543  m_pVideoMan = p_pVideoManager;
544 }
545 
546 
547 SCRIPT_FUNCTION_IMPLEMENTATION(moLuaVideoManager, GetCircularVideoBufferCount )
548 {
549  //MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
550  //MOdouble res = moMathd::ACos(fValue);
551  //lua_pushnumber(L, (lua_Number)res);
552  int count = m_pVideoMan->GetCircularVideoBufferCount();
553  lua_pushnumber(L, (lua_Number)count);
554  return 1;
555 }
556 
557 SCRIPT_FUNCTION_IMPLEMENTATION(moLuaVideoManager, GetCircularVideoBuffer )
558 {
559  int id = (int) lua_tonumber (L, 1);
560 
561  moCircularVideoBuffer* pCirc = NULL;
562  moLuaCircularVideoBuffer* pLuaCirc = NULL;
563 
564  if (m_pVideoMan) {
565  pCirc = m_pVideoMan->GetCircularVideoBuffer(id);
566  if (pCirc) {
567  pLuaCirc = new moLuaCircularVideoBuffer(L);
568  pLuaCirc->Set( pCirc );
570  }
571  }
572  return 1;
573 }
574 
575 
577 {
578  //MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
579  //MOdouble res = moMathd::ACos(fValue);
580  //lua_pushnumber(L, (lua_Number)res);
581  int count = m_pVideoMan->GetVideoBufferCount();
582  lua_pushnumber(L, (lua_Number)count);
583  return 1;
584 }
585 
587 {
588  int id = (int) lua_tonumber (L, 1);
589 
590  moVideoBuffer* pVid = NULL;
591  moLuaVideoBuffer* pLuaVid = NULL;
592 
593  if (m_pVideoMan) {
594  pVid = m_pVideoMan->GetVideoBuffer(id);
595  if (pVid) {
596  pLuaVid = new moLuaVideoBuffer(L);
597  pLuaVid->Set( pVid );
599  }
600  }
601  return 1;
602 }
603 
604 
605 
606 SCRIPT_FUNCTION_IMPLEMENTATION(moLuaVideoManager, GetVideoBufferPathCount )
607 {
608  //MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
609  //MOdouble res = moMathd::ACos(fValue);
610  //lua_pushnumber(L, (lua_Number)res);
611  int count = m_pVideoMan->GetVideoBufferPathCount();
612  lua_pushnumber(L, (lua_Number)count);
613  return 1;
614 }
615 
617 {
618  int id = (int) lua_tonumber (L, 1);
619 
620  moVideoBufferPath* pVid = NULL;
621  moLuaVideoBufferPath* pLuaVid = NULL;
622 
623  if (m_pVideoMan) {
624  pVid = m_pVideoMan->GetVideoBufferPath(id);
625  if (pVid) {
626  pLuaVid = new moLuaVideoBufferPath(L);
627  pLuaVid->Set( pVid );
629  }
630  }
631  return 1;
632 }
633 
643 
645  SCRIPT_FUNCTION( moLuaResourceManager, GetResourceCount),
646  SCRIPT_FUNCTION( moLuaResourceManager, GetResource),
647  SCRIPT_FUNCTION( moLuaResourceManager, GetResourceIndex),
648  SCRIPT_FUNCTION( moLuaResourceManager, GetResourceByType),
649  SCRIPT_FUNCTION( moLuaResourceManager, GetResourceName),
650  SCRIPT_FUNCTION( moLuaResourceManager, GetResourceLabelName),
651  SCRIPT_FUNCTION( moLuaResourceManager, GetResourceType),
652 
653  SCRIPT_FUNCTION( moLuaResourceManager, GetTextureMan),
654  SCRIPT_FUNCTION( moLuaResourceManager, GetVideoMan),
655  SCRIPT_FUNCTION( moLuaResourceManager, GetSoundMan),
656  { 0, 0 }
658 
659 
661 {0,0,0}
663 
664 
666 {
667  m_pResourceManager = NULL;
668  MODebug2->Message("moLuaResourceManager constructor > L: " + IntToStr( (long)L ) );
669 }
670 
671 void moLuaResourceManager::Set( moResourceManager* p_pResourceManager) {
672  m_pResourceManager = p_pResourceManager;
673 }
674 
675 
677 {
678  //MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
679  //MOdouble res = moMathd::ACos(fValue);
680  //lua_pushnumber(L, (lua_Number)res);
681  int count = m_pResourceManager->Resources().Count();
682  lua_pushnumber(L, (lua_Number)count);
683  return 1;
684 }
685 
687 {
688  int id = (int) lua_tonumber (L, 1);
689  moResource* pResource = m_pResourceManager->GetResource(id);
690  if (pResource)
691  id = pResource->GetId();
692  else
693  id = -1;
694  lua_pushnumber(L, (lua_Number)id);
695  return 1;
696 }
697 
699 {
700  moText labelname = (moText) lua_tostring (L, 1);
701  int id = -1;
702 
703  if (m_pResourceManager) {
704  id = m_pResourceManager->GetResourceIndex(labelname);
705  }
706 
707  lua_pushnumber(L, (lua_Number)id);
708  return 1;
709 }
710 
711 
713 {
714  int id;
715 
716  id = -1;
717 
718  if (lua_isnumber(L,1)) {
721  } else if (lua_isstring(L,1)) {
722  moText typestr = (moText) lua_tostring (L, 1);
724  }
725 
726 /*
727  if (m_pResourceManager) {
728  moResourceType rtype;
729  moResource* pResource;
730  rtype = MO_RESOURCETYPE_DATA;
731 
732  if (pResource)
733  id = pResource->GetId();
734  }
735 
736  (m_pResourceManager && typei<MO_RESOURCETYPE_) ?
737  pResource = m_pResourceManager->GetResourceByType((moResourceType)typei) : pResource=NULL;
738 */
739 
740  lua_pushnumber(L, (lua_Number)id);
741  return 1;
742 }
743 
745 {
746  moText rname;
747  int id = (int) lua_tonumber (L, 1);
748 
749  moResource* pResource = m_pResourceManager->GetResource(id);
750 
751  if (pResource)
752  rname = pResource->GetName();
753  else
754  rname = "";
755 
756  lua_pushstring(L, rname);
757  return 1;
758 }
759 
761 {
762  moText rlname;
763  int id = (int) lua_tonumber (L, 1);
764 
765  moResource* pResource = m_pResourceManager->GetResource(id);
766 
767  if (pResource)
768  rlname = pResource->GetLabelName();
769  else
770  rlname = "";
771 
772  lua_pushstring(L, rlname);
773  return 1;
774 }
775 
777 {
778  int id = (int) lua_tonumber (L, 1);
779  moResourceType rtype;
780 
781  moResource* pResource = m_pResourceManager->GetResource(id);
782 
783  if (pResource)
784  rtype = pResource->GetResourceType();
785  else
787 
788  lua_pushnumber(L, (lua_Number)(int)rtype);
789  return 1;
790 }
791 
793 {
794  moLuaTextureManager* pLuaTextureMan = new moLuaTextureManager( L );
795  if (pLuaTextureMan && m_pResourceManager) {
796  pLuaTextureMan->Set( m_pResourceManager->GetTextureMan());
798  return 1;
799  }
800  return 0;
801 }
802 
804 {
805  moLuaVideoManager* pLuaVideoMan = new moLuaVideoManager( L );
806  if (pLuaVideoMan && m_pResourceManager) {
807  pLuaVideoMan->Set( m_pResourceManager->GetVideoMan());
809  }
810  return 1;
811 }
812 
814 {
815  moLuaSoundManager* pLuaSoundMan = new moLuaSoundManager( L );
816  if (pLuaSoundMan && m_pResourceManager) {
817  pLuaSoundMan->Set( m_pResourceManager->GetSoundMan());
819  }
820  return 1;
821 }
822 
823 
824 
825 
830 
831 // Bind member functions to LUA
833  SCRIPT_FUNCTION(moLuaMath, ACos),
834  SCRIPT_FUNCTION(moLuaMath, ASin),
835  SCRIPT_FUNCTION(moLuaMath, ATan),
836  SCRIPT_FUNCTION(moLuaMath, ATan2),
837  SCRIPT_FUNCTION(moLuaMath, Ceil),
840  SCRIPT_FUNCTION(moLuaMath, FAbs),
841  SCRIPT_FUNCTION(moLuaMath, Floor),
842  SCRIPT_FUNCTION(moLuaMath, FMod),
843  SCRIPT_FUNCTION(moLuaMath, InvSqrt),
845  SCRIPT_FUNCTION(moLuaMath, Log2),
846  SCRIPT_FUNCTION(moLuaMath, Log10),
850  SCRIPT_FUNCTION(moLuaMath, Sqrt),
852  SCRIPT_FUNCTION(moLuaMath, UnitRandom),
853  SCRIPT_FUNCTION(moLuaMath, SymmetricRandom),
854  SCRIPT_FUNCTION(moLuaMath, IntervalRandom),
855  { 0, 0 }
857 
858 
860 {0,0,0}
862 
863 
865 {
866  MODebug2->Message("moLuaMath > constructor L: " + IntToStr( (long)(L) ) );
867 }
868 
870 {
871  MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
872  MOdouble res = moMathd::ACos(fValue);
873  lua_pushnumber(L, (lua_Number)res);
874  return 1;
875 }
876 
878 {
879  MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
880  MOdouble res = moMathd::ASin(fValue);
881  lua_pushnumber(L, (lua_Number)res);
882  return 1;
883 }
884 
886 {
887  MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
888  MOdouble res = moMathd::ATan(fValue);
889  lua_pushnumber(L, (lua_Number)res);
890  return 1;
891 }
892 
894 {
895  MOdouble fY = (MOdouble) lua_tonumber (L, 1);
896  MOdouble fX = (MOdouble) lua_tonumber (L, 2);
897  MOdouble res = moMathd::ATan2(fY, fX);
898  lua_pushnumber(L, (lua_Number)res);
899  return 1;
900 }
901 
903 {
904  MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
905  MOdouble res = moMathd::Ceil(fValue);
906  lua_pushnumber(L, (lua_Number)res);
907  return 1;
908 }
909 
911 {
912  MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
913  MOdouble res = moMathd::Cos(fValue);
914  lua_pushnumber(L, (lua_Number)res);
915  return 1;
916 }
917 
919 {
920  MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
921  MOdouble res = moMathd::Exp(fValue);
922  lua_pushnumber(L, (lua_Number)res);
923  return 1;
924 }
925 
927 {
928  MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
929  MOdouble res = moMathd::FAbs(fValue);
930  lua_pushnumber(L, (lua_Number)res);
931  return 1;
932 }
933 
935 {
936  MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
937  MOdouble res = moMathd::Floor(fValue);
938  lua_pushnumber(L, (lua_Number)res);
939  return 1;
940 }
941 
943 {
944  MOdouble fX = (MOdouble) lua_tonumber (L, 1);
945  MOdouble fY = (MOdouble) lua_tonumber (L, 2);
946  MOdouble res = moMathd::FMod(fX, fY);
947  lua_pushnumber(L, (lua_Number)res);
948  return 1;
949 }
950 
952 {
953  MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
954  MOdouble res = moMathd::InvSqrt(fValue);
955  lua_pushnumber(L, (lua_Number)res);
956  return 1;
957 }
958 
960 {
961  MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
962  MOdouble res = moMathd::Log(fValue);
963  lua_pushnumber(L, (lua_Number)res);
964  return 1;
965 }
966 
968 {
969  MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
970  MOdouble res = moMathd::Log2(fValue);
971  lua_pushnumber(L, (lua_Number)res);
972  return 1;
973 }
974 
976 {
977  MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
978  MOdouble res = moMathd::Log10(fValue);
979  lua_pushnumber(L, (lua_Number)res);
980  return 1;
981 }
982 
984 {
985  MOdouble fBase = (MOdouble) lua_tonumber (L, 1);
986  MOdouble fExponent = (MOdouble) lua_tonumber (L, 2);
987  MOdouble res = moMathd::Pow(fBase, fExponent);
988  lua_pushnumber(L, (lua_Number)res);
989  return 1;
990 }
991 
993 {
994  MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
995  MOdouble res = moMathd::Sin(fValue);
996  lua_pushnumber(L, (lua_Number)res);
997  return 1;
998 }
999 
1001 {
1002  MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
1003  MOdouble res = moMathd::Sqr(fValue);
1004  lua_pushnumber(L, (lua_Number)res);
1005  return 1;
1006 }
1007 
1009 {
1010  MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
1011  MOdouble res = moMathd::Sqrt(fValue);
1012  lua_pushnumber(L, (lua_Number)res);
1013  return 1;
1014 }
1015 
1017 {
1018  MOdouble fValue = (MOdouble) lua_tonumber (L, 1);
1019  MOdouble res = moMathd::Tan(fValue);
1020  lua_pushnumber(L, (lua_Number)res);
1021  return 1;
1022 }
1023 
1025 {
1026  MOuint uiSeed = (MOuint) lua_tonumber (L, 1);
1027  MOdouble rand = moMathd::UnitRandom((unsigned int)uiSeed);
1028  lua_pushnumber(L, (lua_Number)rand);
1029  return 1;
1030 }
1031 
1032 SCRIPT_FUNCTION_IMPLEMENTATION(moLuaMath, SymmetricRandom)
1033 {
1034  MOuint uiSeed = (MOuint) lua_tonumber (L, 1);
1035  MOdouble rand = moMathd::SymmetricRandom((unsigned int)uiSeed);
1036  lua_pushnumber(L, (lua_Number)rand);
1037  return 1;
1038 }
1039 
1041 {
1042  MOdouble fMin = (MOdouble) lua_tonumber (L, 1);
1043  MOdouble fMax = (MOdouble) lua_tonumber (L, 2);
1044  MOuint uiSeed = (MOuint) lua_tonumber (L, 3);
1045  MOdouble rand = moMathd::IntervalRandom(fMin, fMax, (unsigned int)uiSeed);
1046  lua_pushnumber(L, (lua_Number)rand);
1047  return 1;
1048 }
1049 
1050 
1052 /*
1053 IMPLEMENT_SCRIPT_CLASS(moLuaParserFunction)
1054 
1055 // Bind member functions to LUA
1056 DEFINE_SCRIPT_CLASS_FUNCTIONS(moLuaParserFunction)
1057 SCRIPT_FUNCTION(moLuaParserFunction, SetExpression),
1058 SCRIPT_FUNCTION(moLuaParserFunction, SetParameters1),
1059 SCRIPT_FUNCTION(moLuaParserFunction, SetParameters2),
1060 SCRIPT_FUNCTION(moLuaParserFunction, SetParameters3),
1061 SCRIPT_FUNCTION(moLuaParserFunction, Eval1),
1062 SCRIPT_FUNCTION(moLuaParserFunction, Eval2),
1063 SCRIPT_FUNCTION(moLuaParserFunction, Eval3),
1064 SCRIPT_FUNCTION(moLuaParserFunction, GetParameterCount),
1065 SCRIPT_FUNCTION(moLuaParserFunction, GetVariableCount),
1066 { 0, 0 }
1067 END_SCRIPT_CLASS_FUNCTIONS
1068 
1069 
1070 DEFINE_SCRIPT_CLASS_PROPERTIES(moLuaParserFunction)
1071 {0,0,0}
1072 END_SCRIPT_CLASS_PROPERTIES
1073 
1074 
1075 SCRIPT_CONSTRUCTOR_IMPLEMENTATION(moLuaParserFunction) : moParserFunction()
1076 {
1077 }
1078 
1079 SCRIPT_FUNCTION_IMPLEMENTATION(moLuaParserFunction, SetExpression)
1080 {
1081  char *expr = (char *) lua_tostring (L, 1);
1082  int res = moParserFunction::Init(moText(expr));
1083  lua_pushboolean(L, res);
1084  return 1;
1085 }
1086 
1087 SCRIPT_FUNCTION_IMPLEMENTATION(moLuaParserFunction, SetParameters1)
1088 {
1089  MOdouble par1 = (MOdouble) lua_tonumber (L, 1);
1090  moParserFunction::SetParameters(par1);
1091  return 0;
1092 }
1093 
1094 SCRIPT_FUNCTION_IMPLEMENTATION(moLuaParserFunction, SetParameters2)
1095 {
1096  MOdouble par1 = (MOdouble) lua_tonumber (L, 1);
1097  MOdouble par2 = (MOdouble) lua_tonumber (L, 2);
1098  moParserFunction::SetParameters(par1, par2);
1099  return 0;
1100 }
1101 
1102 SCRIPT_FUNCTION_IMPLEMENTATION(moLuaParserFunction, SetParameters3)
1103 {
1104  MOdouble par1 = (MOdouble) lua_tonumber (L, 1);
1105  MOdouble par2 = (MOdouble) lua_tonumber (L, 2);
1106  MOdouble par3 = (MOdouble) lua_tonumber (L, 3);
1107  moParserFunction::SetParameters(par1, par2, par3);
1108  return 0;
1109 }
1110 
1111 SCRIPT_FUNCTION_IMPLEMENTATION(moLuaParserFunction, Eval1)
1112 {
1113  MOdouble var1 = (MOdouble) lua_tonumber (L, 1);
1114  MOdouble res = moParserFunction::Eval(var1);
1115  lua_pushnumber(L, (lua_Number)res);
1116  return 1;
1117 }
1118 
1119 SCRIPT_FUNCTION_IMPLEMENTATION(moLuaParserFunction, Eval2)
1120 {
1121  MOdouble var1 = (MOdouble) lua_tonumber (L, 1);
1122  MOdouble var2 = (MOdouble) lua_tonumber (L, 2);
1123  MOdouble res = moParserFunction::Eval(var1, var2);
1124  lua_pushnumber(L, (lua_Number)res);
1125  return 1;
1126 }
1127 
1128 SCRIPT_FUNCTION_IMPLEMENTATION(moLuaParserFunction, Eval3)
1129 {
1130  MOdouble var1 = (MOdouble) lua_tonumber (L, 1);
1131  MOdouble var2 = (MOdouble) lua_tonumber (L, 2);
1132  MOdouble var3 = (MOdouble) lua_tonumber (L, 3);
1133  MOdouble res = moParserFunction::Eval(var1, var2, var3);
1134  lua_pushnumber(L, (lua_Number)res);
1135  return 1;
1136 }
1137 
1138 SCRIPT_FUNCTION_IMPLEMENTATION(moLuaParserFunction, GetParameterCount)
1139 {
1140  MOint res = moParserFunction::GetParameterCount();
1141  lua_pushnumber(L, (lua_Number)res);
1142  return 1;
1143 }
1144 
1145 SCRIPT_FUNCTION_IMPLEMENTATION(moLuaParserFunction, GetVariableCount)
1146 {
1147  MOint res = moParserFunction::GetVariableCount();
1148  lua_pushnumber(L, (lua_Number)res);
1149  return 1;
1150 }
1151 */
1152 
1156 
1157 // Bind member functions to LUA
1159 
1160 SCRIPT_FUNCTION(moLuaP5, triangle),
1161 SCRIPT_FUNCTION(moLuaP5, line),
1162 SCRIPT_FUNCTION(moLuaP5, arc),
1163 SCRIPT_FUNCTION(moLuaP5, point),
1164 SCRIPT_FUNCTION(moLuaP5, quad),
1165 SCRIPT_FUNCTION(moLuaP5, ellipse),
1166 SCRIPT_FUNCTION(moLuaP5, rect),
1167 
1168 SCRIPT_FUNCTION(moLuaP5, strokeWeight),
1169 SCRIPT_FUNCTION(moLuaP5, background),
1170 SCRIPT_FUNCTION(moLuaP5, colorMode),
1171 
1172 SCRIPT_FUNCTION(moLuaP5, stroke),
1173 SCRIPT_FUNCTION(moLuaP5, noFill),
1174 SCRIPT_FUNCTION(moLuaP5, noStroke),
1175 SCRIPT_FUNCTION(moLuaP5, fill),
1176 
1177 SCRIPT_FUNCTION(moLuaP5, pushMatrix),
1178 SCRIPT_FUNCTION(moLuaP5, popMatrix),
1179 SCRIPT_FUNCTION(moLuaP5, resetMatrix),
1180 
1181 SCRIPT_FUNCTION(moLuaP5, scale),
1182 SCRIPT_FUNCTION(moLuaP5, translate),
1183 SCRIPT_FUNCTION(moLuaP5, rotate),
1184 
1185 SCRIPT_FUNCTION(moLuaP5, PRGB),
1186 SCRIPT_FUNCTION(moLuaP5, PHSB),
1187 
1188 SCRIPT_FUNCTION(moLuaP5, PHALF_PI),
1189 SCRIPT_FUNCTION(moLuaP5, PTWO_PI),
1190 SCRIPT_FUNCTION(moLuaP5, PPI),
1191 
1192 { 0, 0 }
1194 
1196 {0,0,0}
1198 
1200 {
1201  MODebug2->Message("moLuaP5 constructor > L: " + IntToStr( (long)L ) );
1202 }
1203 
1205 {
1206  int n = lua_pindexes(L);
1207 
1208  MOfloat x1,y1,x2,y2,x3,y3;
1209 
1210  if (n==6) {
1211  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1212  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1213  x2 = (MOfloat) lua_tonumber (L, lua_pindex(3));
1214  y2 = (MOfloat) lua_tonumber (L, lua_pindex(4));
1215  x3 = (MOfloat) lua_tonumber (L, lua_pindex(5));
1216  y3 = (MOfloat) lua_tonumber (L, lua_pindex(6));
1217  moP5::triangle( x1, y1, x2, y2, x3, y3 );
1218  }
1219 
1220  return 0;
1221 }
1222 
1224 {
1225  int n = lua_pindexes(L);
1226 
1227  MOfloat x1,x2, y1,y2, z1,z2;
1228 
1229  switch(n) {
1230  case 4:
1231  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1232  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1233  x2 = (MOfloat) lua_tonumber (L, lua_pindex(3));
1234  y2 = (MOfloat) lua_tonumber (L, lua_pindex(4));
1235  moP5::line(x1, y1, x2, y2);
1236  break;
1237  case 6:
1238  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1239  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1240  z1 = (MOfloat) lua_tonumber (L, lua_pindex(3));
1241 
1242  x2 = (MOfloat) lua_tonumber (L, lua_pindex(4));
1243  y2 = (MOfloat) lua_tonumber (L, lua_pindex(5));
1244  z2 = (MOfloat) lua_tonumber (L, lua_pindex(6));
1245  moP5::line(x1, y1, z1, x2, y2, z2);
1246  break;
1247  }
1248 
1249  return 0;
1250 }
1251 
1253 {
1254 
1255  int n = lua_pindexes(L);
1256 
1257  MOfloat x1,y1,width,height,start,stop,band;
1258  int slices;
1259 
1260  switch(n) {
1261 
1262  case 6:
1263  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1264  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1265  width = (MOfloat) lua_tonumber (L, lua_pindex(3));
1266  height = (MOfloat) lua_tonumber (L, lua_pindex(4));
1267  start = (MOfloat) lua_tonumber (L, lua_pindex(5));
1268  stop = (MOfloat) lua_tonumber (L, lua_pindex(6));
1269  moP5::arc(x1, y1, width, height,start,stop);
1270  break;
1271  case 7:
1272  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1273  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1274  width = (MOfloat) lua_tonumber (L, lua_pindex(3));
1275  height = (MOfloat) lua_tonumber (L, lua_pindex(4));
1276  start = (MOfloat) lua_tonumber (L, lua_pindex(5));
1277  stop = (MOfloat) lua_tonumber (L, lua_pindex(6));
1278  slices = (int) lua_tonumber (L, lua_pindex(7));
1279  moP5::arc(x1, y1, width, height,start,stop, slices );
1280  break;
1281  case 8:
1282  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1283  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1284  width = (MOfloat) lua_tonumber (L, lua_pindex(3));
1285  height = (MOfloat) lua_tonumber (L, lua_pindex(4));
1286  start = (MOfloat) lua_tonumber (L, lua_pindex(5));
1287  stop = (MOfloat) lua_tonumber (L, lua_pindex(6));
1288  slices = (int) lua_tonumber (L, lua_pindex(7));
1289  band = (MOfloat) lua_tonumber (L, lua_pindex(8));
1290  moP5::arc(x1, y1, width, height,start,stop, slices, band );
1291  break;
1292  }
1293 
1294  return 0;
1295 }
1296 
1298 {
1299  int n = lua_pindexes(L);
1300 
1301  MOfloat x1,y1,z1;
1302 
1303  if (n==2) {
1304  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1305  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1306  moP5::point(x1, y1);
1307  } else if (n==3) {
1308  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1309  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1310  z1 = (MOfloat) lua_tonumber (L, lua_pindex(3));
1311 
1312  moP5::point(x1, y1, z1);
1313  }
1314 
1315  return 0;
1316 }
1317 
1319 {
1320  int n = lua_pindexes(L);
1321 
1322  MOfloat x1,x2,x3,x4,y1,y2,y3,y4;
1323 
1324  if (n==8) {
1325  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1326  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1327  x2 = (MOfloat) lua_tonumber (L, lua_pindex(3));
1328  y2 = (MOfloat) lua_tonumber (L, lua_pindex(4));
1329  x3 = (MOfloat) lua_tonumber (L, lua_pindex(5));
1330  y3 = (MOfloat) lua_tonumber (L, lua_pindex(6));
1331  x4 = (MOfloat) lua_tonumber (L, lua_pindex(7));
1332  y4 = (MOfloat) lua_tonumber (L, lua_pindex(8));
1333  moP5::quad(x1, y1, x2, y2, x3, y3, x4, y4);
1334  }
1335 
1336  return 0;
1337 }
1338 
1340 {
1341  int n = lua_pindexes(L);
1342 
1343  MOfloat x1,y1,width,height;
1344  int slices;
1345 
1346  switch(n) {
1347 
1348  case 4:
1349  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1350  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1351  width = (MOfloat) lua_tonumber (L, lua_pindex(3));
1352  height = (MOfloat) lua_tonumber (L, lua_pindex(4));
1353  moP5::ellipse(x1, y1, width, height);
1354  break;
1355  case 5:
1356  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1357  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1358  width = (MOfloat) lua_tonumber (L, lua_pindex(3));
1359  height = (MOfloat) lua_tonumber (L, lua_pindex(4));
1360  slices = (int) lua_tonumber (L, lua_pindex(5));
1361  moP5::ellipse(x1, y1, width, height, slices );
1362  break;
1363 
1364  }
1365 
1366  return 0;
1367 }
1368 
1370 {
1371 
1372  int n = lua_pindexes(L);
1373 
1374  MOfloat x1,y1,width,height;
1375 
1376  switch(n) {
1377 
1378  case 4:
1379  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1380  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1381  width = (MOfloat) lua_tonumber (L, lua_pindex(3));
1382  height = (MOfloat) lua_tonumber (L, lua_pindex(4));
1383  moP5::rect(x1, y1, width, height);
1384  break;
1385  }
1386 
1387  return 0;
1388 }
1389 
1390 
1392 {
1393  //int n = lua_pindexes(L);
1394  MOfloat width = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1395 
1396  //MODebug2->Push( "strokeWeight > width:" + FloatToStr(width) );
1397 
1398  moP5::strokeWeight( width );
1399 
1400  return 0;
1401 }
1402 
1404 {
1405  int n = lua_pindexes(L);
1406  MOfloat r,g,b,grey;
1407  MOfloat alpha = 1.0;
1408 
1409  switch(n) {
1410  case 1:
1411  grey = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1412  alpha = (MOfloat) lua_tonumber (L, lua_pindex(2));
1413  moP5::background(grey);
1414  break;
1415  case 2:
1416  grey = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1417  moP5::background(grey, alpha);
1418  break;
1419  case 3:
1420  r = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1421  g = (MOfloat) lua_tonumber (L, lua_pindex(2) );
1422  b = (MOfloat) lua_tonumber (L, lua_pindex(3) );
1423  moP5::background( r, g, b );
1424  break;
1425  case 4:
1426  r = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1427  g = (MOfloat) lua_tonumber (L, lua_pindex(2) );
1428  b = (MOfloat) lua_tonumber (L, lua_pindex(3) );
1429  alpha = (MOfloat) lua_tonumber (L, lua_pindex(4));
1430  moP5::background( r, g, b, alpha );
1431  break;
1432  default:
1433  moP5::background( 1.0, 1.0, 1.0, 1.0 );
1434  break;
1435  }
1436  return 0;
1437 }
1438 
1440 {
1441  MOint mode = (MOint) lua_tonumber (L, 2);
1442  moP5::colorMode(mode);
1443 
1444  return 0;
1445 }
1446 
1448 {
1449  int n = lua_pindexes(L);
1450  MOfloat r,g,b,grey;
1451  MOfloat alpha = 1.0;
1452 
1453  switch(n) {
1454  case 1:
1455  grey = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1456  alpha = (MOfloat) lua_tonumber (L, lua_pindex(2));
1457  moP5::stroke(grey);
1458  break;
1459  case 2:
1460  grey = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1461  moP5::stroke(grey, alpha);
1462  break;
1463  case 3:
1464  r = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1465  g = (MOfloat) lua_tonumber (L, lua_pindex(2) );
1466  b = (MOfloat) lua_tonumber (L, lua_pindex(3) );
1467  moP5::stroke( r, g, b );
1468  break;
1469  case 4:
1470  r = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1471  g = (MOfloat) lua_tonumber (L, lua_pindex(2) );
1472  b = (MOfloat) lua_tonumber (L, lua_pindex(3) );
1473  alpha = (MOfloat) lua_tonumber (L, lua_pindex(4));
1474  moP5::stroke( r, g, b, alpha );
1475  break;
1476  default:
1477  moP5::stroke( 1.0, 1.0, 1.0, 1.0 );
1478  break;
1479  }
1480 
1481  return 0;
1482 }
1483 
1485 {
1486  MODebug2->Message("moLuaP5::noFill > L: " + IntToStr( (long)L ) );
1487 
1488  moP5::noFill();
1489 
1490  return 0;
1491 }
1492 
1494 {
1495 
1496  MODebug2->Message("moLuaP5::noStroke > L: " + IntToStr( (long)L ) );
1497 
1498  moP5::noStroke();
1499 
1500  return 0;
1501 }
1502 
1504 {
1505 
1506  int n = lua_pindexes(L);
1507  MOfloat r=1.0f,g=1.0f,b=1.0f,grey=1.0f;
1508  MOfloat alpha = 1.0f;
1509 
1510  switch(n) {
1511  case 1:
1512  grey = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1513  r = g = b = grey;
1514  break;
1515  case 2:
1516  grey = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1517  alpha = (MOfloat) lua_tonumber (L, lua_pindex(2));
1518  r = g = b = grey;
1519  break;
1520  case 3:
1521  r = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1522  g = (MOfloat) lua_tonumber (L, lua_pindex(2) );
1523  b = (MOfloat) lua_tonumber (L, lua_pindex(3) );
1524  break;
1525  case 4:
1526  r = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1527  g = (MOfloat) lua_tonumber (L, lua_pindex(2) );
1528  b = (MOfloat) lua_tonumber (L, lua_pindex(3) );
1529  alpha = (MOfloat) lua_tonumber (L, lua_pindex(4));
1530  break;
1531  }
1532 
1533  moP5::fill( r, g, b, alpha );
1534 
1535  return 0;
1536 }
1537 
1539 {
1540  MODebug2->Message("moLuaP5::pushMatrix > L: " + IntToStr( (long)L ) );
1541 
1542  return 0;
1543 }
1544 
1546 {
1547  MODebug2->Message("moLuaP5::popMatrix > L: " + IntToStr( (long)L ) );
1548  return 0;
1549 }
1550 
1552 {
1553  MODebug2->Message("moLuaP5::resetMatrix > L: " + IntToStr( (long)L ) );
1554  return 0;
1555 }
1556 
1558 {
1559  int n = lua_pindexes(L);
1560 
1561  MOfloat x1 = 1.0f,y1 = 1.0f, z1 = 1.0f;
1562 
1563  switch(n) {
1564  case 1:
1565  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1566  break;
1567  case 2:
1568  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1569  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1570  break;
1571  case 3:
1572  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1573  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1574  z1 = (MOfloat) lua_tonumber (L, lua_pindex(3));
1575  break;
1576  }
1577 
1578  moP5::scale(x1, y1, z1 );
1579 
1580  return 0;
1581 }
1582 
1584 {
1585  int n = lua_pindexes(L);
1586 
1587  MOfloat x1 = 0.0f,y1 = 0.0f, z1 = 0.0f;
1588 
1589  switch(n) {
1590  case 1:
1591  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1592  break;
1593  case 2:
1594  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1595  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1596  break;
1597  case 3:
1598  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1599  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1600  z1 = (MOfloat) lua_tonumber (L, lua_pindex(3));
1601  break;
1602  }
1603 
1604  moP5::translate(x1, y1, z1 );
1605 
1606  return 0;
1607 
1608 }
1609 
1611 {
1612  int n = lua_pindexes(L);
1613 
1614  MOfloat angle = 0.0f, x1=0.0f, y1=0.0f, z1=1.0f;
1615 
1616  switch(n) {
1617  case 1:
1618  angle = (MOfloat) lua_tonumber (L, lua_pindex(1));
1619  break;
1620  case 4:
1621  angle = (MOfloat) lua_tonumber (L, lua_pindex(1));
1622  x1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1623  y1 = (MOfloat) lua_tonumber (L, lua_pindex(3));
1624  z1 = (MOfloat) lua_tonumber (L, lua_pindex(4));
1625  break;
1626  }
1627 
1628  moP5::rotate( angle, x1, y1, z1 );
1629 
1630  return 0;
1631 
1632 }
1633 
1635 {
1636  lua_pushnumber(L, (lua_Number)MO_P5_RGB);
1637  return 1;
1638 }
1639 
1641 {
1642  lua_pushnumber(L, (lua_Number)MO_P5_HSB);
1643  return 1;
1644 }
1645 
1647 {
1648  lua_pushnumber(L, (lua_Number)MO_P5_HALF_PI);
1649  return 1;
1650 }
1651 
1653 {
1654  lua_pushnumber(L, (lua_Number)MO_P5_TWO_PI);
1655  return 1;
1656 }
1657 
1659 {
1660  lua_pushnumber(L, (lua_Number)MO_P5_PI);
1661  return 1;
1662 }
1663 
moSoundManager * m_pSoundMan
Definition: moLunaClasses.h:67
void fill(float gray)
Definition: moP5.cpp:449
void Set(moResourceManager *p_pResourceManager)
void Set(moTextureManager *p_pTextureMan)
static double Log2(double fValue)
Definition: moMath.h:230
void scale(float size)
Definition: moP5.cpp:508
void arc(float x, float y, float width, float height, float start, float stop, int slices=24, float band=0.0)
Definition: moP5.cpp:100
Recurso ( objeto para cargar y manipular objetos físicos de datos de imágenes, audio, video, 3d, 2d, fuentes, shaders y de cualquier otro tipo extendible por un plugin )
#define END_SCRIPT_CLASS_FUNCTIONS
Definition: moLuna.h:621
void translate(float x, float y, float z=0.0f)
Definition: moP5.cpp:526
static double ACos(double fValue)
Definition: moMath.h:81
moResourceType
Tipos de recursos que se pueden implementar.
static double ATan2(double fY, double fX)
Definition: moMath.h:140
void triangle(float x1, float y1, float x2, float y2, float x3, float y3)
Definition: moP5.cpp:56
#define lua_pindexes(L)
Administrador de sonidos.
static double Sin(double fValue)
Definition: moMath.h:260
static double Tan(double fValue)
Definition: moMath.h:288
static double Log(double fValue)
Definition: moMath.h:220
void Set(moVideoManager *p_pVideoMan)
void Set(moVideoBufferPath *p_pVideoBufferPath)
static double Sqr(double fValue)
Definition: moMath.h:270
void Set(moSoundManager *p_pSoundMan)
const moText & GetLabelName() const
static double SymmetricRandom(unsigned int uiSeed=0)
Definition: moMath.h:396
static T * createFromExisting(lua_State *L, T *existingobj)
Definition: moLuna.h:384
#define IMPLEMENT_SCRIPT_CLASS(ClassName)
Definition: moLuna.h:613
#define MOfloat
Definition: moTypes.h:403
static double Floor(double fValue)
Definition: moMath.h:190
void quad(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
Definition: moP5.cpp:188
clase de para manejar textos
Definition: moText.h:75
static double ATan(double fValue)
Definition: moMath.h:129
static double Log10(double fValue)
Definition: moMath.h:240
void background(float gray)
Definition: moP5.cpp:297
static double InvSqrt(double fValue)
Definition: moMath.h:210
moText0 moText
Definition: moText.h:291
Buffer de imágenes para video.
static double Sqrt(double fValue)
Definition: moMath.h:279
static double ASin(double fValue)
Definition: moMath.h:105
#define MOint
Definition: moTypes.h:388
void ellipse(float x, float y, float width, float height, int slices=24)
Definition: moP5.cpp:202
MOint GetId() const
void rotate(float angle, float x=0.0f, float y=0.0f, float z=1.0f)
Definition: moP5.cpp:535
void stroke(float gray)
Definition: moP5.cpp:401
Administrador de recursos.
moResourceType GetResourceType()
Clase base de sonido.
static moDebug * MODebug2
Clase de impresión de errores para depuración.
Definition: moAbstract.h:225
static double Cos(double fValue)
Definition: moMath.h:160
#define DEFINE_SCRIPT_CLASS_PROPERTIES(ClassName)
Definition: moLuna.h:624
void Set(moCircularVideoBuffer *p_pCircularVideoBuffer)
void Push(moText p_text)
Apila el mensaje dentro de la pila de mensajes.
Definition: moAbstract.h:115
static double FMod(double fX, double fY)
Definition: moMath.h:200
SCRIPT_FUNCTION(moLuaSoundManager, GetSoundCount)
void noStroke()
Definition: moP5.cpp:441
void strokeWeight(float width)
Definition: moP5.cpp:266
#define MOdouble
Definition: moTypes.h:404
void noFill()
Definition: moP5.cpp:431
void colorMode(int mode)
Definition: moP5.cpp:325
#define DEFINE_SCRIPT_CLASS_FUNCTIONS(ClassName)
Definition: moLuna.h:616
#define MOuint
Definition: moTypes.h:387
LIBMOLDEO_API moText0 IntToStr(int a)
Definition: moText.cpp:1070
static double Pow(double fBase, double fExponent)
Definition: moMath.h:250
void rect(float x, float y, float width, float height)
Definition: moP5.cpp:238
void point(float x, float y)
Definition: moP5.cpp:165
LunaFourCode.
Definition: moLuna.h:68
static double IntervalRandom(double fMin, double fMax, unsigned int uiSeed=0)
Definition: moMath.h:414
#define SCRIPT_CONSTRUCTOR_IMPLEMENTATION(ClassName)
Definition: moLuna.h:635
Definition: moP5.h:41
#define lua_pindex(index)
moSound * GetSound(moText p_name, bool create=true)
static double FAbs(double fValue)
Definition: moMath.h:180
Buffer Circular de imágenes para video.
void Message(moText p_text)
Anuncia un mensaje al usuario además de guardarlo en el log de texto.
Definition: moAbstract.cpp:114
#define SCRIPT_FUNCTION_IMPLEMENTATION(ClassName, FunctionName)
Definition: moLuna.h:638
static double UnitRandom(unsigned int uiSeed=0)
Definition: moMath.h:380
#define END_SCRIPT_CLASS_PROPERTIES
Definition: moLuna.h:629
void line(float x1, float y1, float x2, float y2)
Definition: moP5.cpp:70
static double Exp(double fValue)
Definition: moMath.h:170
static double Ceil(double fValue)
Definition: moMath.h:150
const moText & GetName() const
void Set(moVideoBuffer *p_pVideoBuffer)