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
moLunaClasses.cpp
Go to the documentation of this file.
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 ),
53  SCRIPT_FUNCTION( moLuaSoundManager, GetSound ),
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),
113  SCRIPT_FUNCTION( moLuaTextureManager, GetGLId),
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),
284  SCRIPT_FUNCTION( moLuaCircularVideoBuffer, IsRecording),
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),
838  SCRIPT_FUNCTION(moLuaMath, Cos),
839  SCRIPT_FUNCTION(moLuaMath, Exp),
840  SCRIPT_FUNCTION(moLuaMath, FAbs),
841  SCRIPT_FUNCTION(moLuaMath, Floor),
842  SCRIPT_FUNCTION(moLuaMath, FMod),
843  SCRIPT_FUNCTION(moLuaMath, InvSqrt),
844  SCRIPT_FUNCTION(moLuaMath, Log),
845  SCRIPT_FUNCTION(moLuaMath, Log2),
846  SCRIPT_FUNCTION(moLuaMath, Log10),
847  SCRIPT_FUNCTION(moLuaMath, Pow),
848  SCRIPT_FUNCTION(moLuaMath, Sin),
849  SCRIPT_FUNCTION(moLuaMath, Sqr),
850  SCRIPT_FUNCTION(moLuaMath, Sqrt),
851  SCRIPT_FUNCTION(moLuaMath, Tan),
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;
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  }
1308 
1309  return 0;
1310 }
1311 
1313 {
1314  int n = lua_pindexes(L);
1315 
1316  MOfloat x1,x2,x3,x4,y1,y2,y3,y4;
1317 
1318  if (n==8) {
1319  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1320  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1321  x2 = (MOfloat) lua_tonumber (L, lua_pindex(3));
1322  y2 = (MOfloat) lua_tonumber (L, lua_pindex(4));
1323  x3 = (MOfloat) lua_tonumber (L, lua_pindex(5));
1324  y3 = (MOfloat) lua_tonumber (L, lua_pindex(6));
1325  x4 = (MOfloat) lua_tonumber (L, lua_pindex(7));
1326  y4 = (MOfloat) lua_tonumber (L, lua_pindex(8));
1327  moP5::quad(x1, y1, x2, y2, x3, y3, x4, y4);
1328  }
1329 
1330  return 0;
1331 }
1332 
1334 {
1335  int n = lua_pindexes(L);
1336 
1337  MOfloat x1,y1,width,height;
1338  int slices;
1339 
1340  switch(n) {
1341 
1342  case 4:
1343  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1344  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1345  width = (MOfloat) lua_tonumber (L, lua_pindex(3));
1346  height = (MOfloat) lua_tonumber (L, lua_pindex(4));
1347  moP5::ellipse(x1, y1, width, height);
1348  break;
1349  case 5:
1350  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1351  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1352  width = (MOfloat) lua_tonumber (L, lua_pindex(3));
1353  height = (MOfloat) lua_tonumber (L, lua_pindex(4));
1354  slices = (int) lua_tonumber (L, lua_pindex(5));
1355  moP5::ellipse(x1, y1, width, height, slices );
1356  break;
1357 
1358  }
1359 
1360  return 0;
1361 }
1362 
1364 {
1365 
1366  int n = lua_pindexes(L);
1367 
1368  MOfloat x1,y1,width,height;
1369 
1370  switch(n) {
1371 
1372  case 4:
1373  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1374  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1375  width = (MOfloat) lua_tonumber (L, lua_pindex(3));
1376  height = (MOfloat) lua_tonumber (L, lua_pindex(4));
1377  moP5::rect(x1, y1, width, height);
1378  break;
1379  }
1380 
1381  return 0;
1382 }
1383 
1384 
1386 {
1387  //int n = lua_pindexes(L);
1388  MOfloat width = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1389 
1390  //MODebug2->Push( "strokeWeight > width:" + FloatToStr(width) );
1391 
1392  moP5::strokeWeight( width );
1393 
1394  return 0;
1395 }
1396 
1398 {
1399  int n = lua_pindexes(L);
1400  MOfloat r,g,b,grey;
1401  MOfloat alpha = 1.0;
1402 
1403  switch(n) {
1404  case 1:
1405  grey = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1406  alpha = (MOfloat) lua_tonumber (L, lua_pindex(2));
1407  moP5::background(grey);
1408  break;
1409  case 2:
1410  grey = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1411  moP5::background(grey, alpha);
1412  break;
1413  case 3:
1414  r = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1415  g = (MOfloat) lua_tonumber (L, lua_pindex(2) );
1416  b = (MOfloat) lua_tonumber (L, lua_pindex(3) );
1417  moP5::background( r, g, b );
1418  break;
1419  case 4:
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  alpha = (MOfloat) lua_tonumber (L, lua_pindex(4));
1424  moP5::background( r, g, b, alpha );
1425  break;
1426  default:
1427  moP5::background( 1.0, 1.0, 1.0, 1.0 );
1428  break;
1429  }
1430  return 0;
1431 }
1432 
1434 {
1435  MOint mode = (MOint) lua_tonumber (L, 2);
1436  moP5::colorMode(mode);
1437 
1438  return 0;
1439 }
1440 
1442 {
1443  int n = lua_pindexes(L);
1444  MOfloat r,g,b,grey;
1445  MOfloat alpha = 1.0;
1446 
1447  switch(n) {
1448  case 1:
1449  grey = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1450  alpha = (MOfloat) lua_tonumber (L, lua_pindex(2));
1451  moP5::stroke(grey);
1452  break;
1453  case 2:
1454  grey = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1455  moP5::stroke(grey, alpha);
1456  break;
1457  case 3:
1458  r = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1459  g = (MOfloat) lua_tonumber (L, lua_pindex(2) );
1460  b = (MOfloat) lua_tonumber (L, lua_pindex(3) );
1461  moP5::stroke( r, g, b );
1462  break;
1463  case 4:
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  alpha = (MOfloat) lua_tonumber (L, lua_pindex(4));
1468  moP5::stroke( r, g, b, alpha );
1469  break;
1470  default:
1471  moP5::stroke( 1.0, 1.0, 1.0, 1.0 );
1472  break;
1473  }
1474 
1475  return 0;
1476 }
1477 
1479 {
1480  MODebug2->Message("moLuaP5::noFill > L: " + IntToStr( (long)L ) );
1481 
1482  moP5::noFill();
1483 
1484  return 0;
1485 }
1486 
1488 {
1489 
1490  MODebug2->Message("moLuaP5::noStroke > L: " + IntToStr( (long)L ) );
1491 
1492  moP5::noStroke();
1493 
1494  return 0;
1495 }
1496 
1498 {
1499 
1500  int n = lua_pindexes(L);
1501  MOfloat r=1.0f,g=1.0f,b=1.0f,grey=1.0f;
1502  MOfloat alpha = 1.0f;
1503 
1504  switch(n) {
1505  case 1:
1506  grey = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1507  r = g = b = grey;
1508  break;
1509  case 2:
1510  grey = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1511  alpha = (MOfloat) lua_tonumber (L, lua_pindex(2));
1512  r = g = b = grey;
1513  break;
1514  case 3:
1515  r = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1516  g = (MOfloat) lua_tonumber (L, lua_pindex(2) );
1517  b = (MOfloat) lua_tonumber (L, lua_pindex(3) );
1518  break;
1519  case 4:
1520  r = (MOfloat) lua_tonumber (L, lua_pindex(1) );
1521  g = (MOfloat) lua_tonumber (L, lua_pindex(2) );
1522  b = (MOfloat) lua_tonumber (L, lua_pindex(3) );
1523  alpha = (MOfloat) lua_tonumber (L, lua_pindex(4));
1524  break;
1525  }
1526 
1527  moP5::fill( r, g, b, alpha );
1528 
1529  return 0;
1530 }
1531 
1533 {
1534  MODebug2->Message("moLuaP5::pushMatrix > L: " + IntToStr( (long)L ) );
1535 
1536  return 0;
1537 }
1538 
1540 {
1541  MODebug2->Message("moLuaP5::popMatrix > L: " + IntToStr( (long)L ) );
1542  return 0;
1543 }
1544 
1546 {
1547  MODebug2->Message("moLuaP5::resetMatrix > L: " + IntToStr( (long)L ) );
1548  return 0;
1549 }
1550 
1552 {
1553  int n = lua_pindexes(L);
1554 
1555  MOfloat x1 = 1.0f,y1 = 1.0f, z1 = 1.0f;
1556 
1557  switch(n) {
1558  case 1:
1559  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1560  break;
1561  case 2:
1562  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1563  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1564  break;
1565  case 3:
1566  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1567  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1568  z1 = (MOfloat) lua_tonumber (L, lua_pindex(3));
1569  break;
1570  }
1571 
1572  moP5::scale(x1, y1, z1 );
1573 
1574  return 0;
1575 }
1576 
1578 {
1579  int n = lua_pindexes(L);
1580 
1581  MOfloat x1 = 0.0f,y1 = 0.0f, z1 = 0.0f;
1582 
1583  switch(n) {
1584  case 1:
1585  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1586  break;
1587  case 2:
1588  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1589  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1590  break;
1591  case 3:
1592  x1 = (MOfloat) lua_tonumber (L, lua_pindex(1));
1593  y1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1594  z1 = (MOfloat) lua_tonumber (L, lua_pindex(3));
1595  break;
1596  }
1597 
1598  moP5::translate(x1, y1, z1 );
1599 
1600  return 0;
1601 
1602 }
1603 
1605 {
1606  int n = lua_pindexes(L);
1607 
1608  MOfloat angle = 0.0f, x1=0.0f, y1=0.0f, z1=1.0f;
1609 
1610  switch(n) {
1611  case 1:
1612  angle = (MOfloat) lua_tonumber (L, lua_pindex(1));
1613  break;
1614  case 4:
1615  angle = (MOfloat) lua_tonumber (L, lua_pindex(1));
1616  x1 = (MOfloat) lua_tonumber (L, lua_pindex(2));
1617  y1 = (MOfloat) lua_tonumber (L, lua_pindex(3));
1618  z1 = (MOfloat) lua_tonumber (L, lua_pindex(4));
1619  break;
1620  }
1621 
1622  moP5::rotate( angle, x1, y1, z1 );
1623 
1624  return 0;
1625 
1626 }
1627 
1629 {
1630  lua_pushnumber(L, (lua_Number)MO_P5_RGB);
1631  return 1;
1632 }
1633 
1635 {
1636  lua_pushnumber(L, (lua_Number)MO_P5_HSB);
1637  return 1;
1638 }
1639 
1641 {
1642  lua_pushnumber(L, (lua_Number)MO_P5_HALF_PI);
1643  return 1;
1644 }
1645 
1647 {
1648  lua_pushnumber(L, (lua_Number)MO_P5_TWO_PI);
1649  return 1;
1650 }
1651 
1653 {
1654  lua_pushnumber(L, (lua_Number)MO_P5_PI);
1655  return 1;
1656 }
1657 
void fill(float gray)
Definition: moP5.cpp:449
const moText & GetLabelName() const
MOint GetId() const
static double Log2(doublefValue)
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(doublefValue)
Definition: moMath.h:81
moResourceType
Tipos de recursos que se pueden implementar.
static double ATan2(doublefY, doublefX)
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(doublefValue)
Definition: moMath.h:260
static double Tan(doublefValue)
Definition: moMath.h:288
const moText & GetName() const
static double Log(doublefValue)
Definition: moMath.h:220
static double Sqr(doublefValue)
Definition: moMath.h:270
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(doublefValue)
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(doublefValue)
Definition: moMath.h:129
static double Log10(doublefValue)
Definition: moMath.h:240
void background(float gray)
Definition: moP5.cpp:297
static double InvSqrt(doublefValue)
Definition: moMath.h:210
moText0 moText
Definition: moText.h:291
Buffer de imágenes para video.
static double Sqrt(doublefValue)
Definition: moMath.h:279
static double ASin(doublefValue)
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
void rotate(float angle, float x=0.0f, float y=0.0f, float z=1.0f)
Definition: moP5.cpp:535
END_SCRIPT_CLASS_FUNCTIONS DEFINE_SCRIPT_CLASS_PROPERTIES(moLuaSoundManager)
void stroke(float gray)
Definition: moP5.cpp:401
Administrador de recursos.
moResourceType GetResourceType()
Clase base de sonido.
END_SCRIPT_CLASS_PROPERTIES SCRIPT_CONSTRUCTOR_IMPLEMENTATION(moLuaSoundManager)
static double Cos(doublefValue)
Definition: moMath.h:160
static double FMod(doublefX, doublefY)
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
SCRIPT_FUNCTION_IMPLEMENTATION(moLuaSoundManager, GetSoundCount)
#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(doublefBase, doublefExponent)
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(doublefMin, doublefMax, unsigned int uiSeed=0)
Definition: moMath.h:414
Definition: moP5.h:41
#define lua_pindex(index)
static double FAbs(doublefValue)
Definition: moMath.h:180
Circular Video Buffer for live loop video recording.
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(doublefValue)
Definition: moMath.h:170
static double Ceil(doublefValue)
Definition: moMath.h:150