SO3Engine
SCOLEnvironment.cpp
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
25
33#include "SCOLPack/SO3SCOL.h"
34
35// Renderer includes
36#include "SO3Renderer/SO3Root.h"
38
39// Scene Graph includes
44
45// Utils includes
47
58{
59#ifdef SO3_DEBUG
60 MMechostr(MSKDEBUG, "SO3EnvironmentRegisterViewport\n");
61#endif
62
63 int scolViewport = MMpull(m);
64 int scolScene = MMget(m, 0);
65 if((scolViewport==NIL)||(scolScene==NIL))
66 {
67 MMset(m, 0, NIL);
68 return 0;
69 }
70
71 if (SRoot::getSingletonPtr()->IsRendering())
72 {
73 MMechostr(MSKRUNTIME, "SO3EnvironmentRegisterViewport: Can not be called in a render callback\n");
74 MMset(m, 0, NIL);
75 return 0;
76 }
77
78 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
79 if(parentScene==0)
80 {
81 MMechostr(MSKDEBUG, "SO3EnvironmentRegisterViewport: Scene instance is NULL\n");
82 MMset(m, 0, NIL);
83 return 0;
84 }
85
86 SViewPort* targetViewport = MMgetPointer<SViewPort*>(m, MTOP(scolViewport));
87 if(targetViewport==0)
88 {
89 MMechostr(MSKDEBUG, "SO3EnvironmentRegisterViewport: Viewport instance is NULL\n");
90 MMset(m, 0, NIL);
91 return 0;
92 }
93
94 if (!parentScene->GetEnvironment())
95 {
96 MMset(m, 0, NIL);
97 return 0;
98 }
99
100 try
101 {
102 parentScene->GetEnvironment()->RegisterViewport(targetViewport);
103 MMset(m, 0, ITOM(1));
104 return 0;
105 }
106 catch(Ogre::Exception&)
107 {
108 MMset(m, 0, NIL);
109 return 0;
110 }
111}
112
123{
124#ifdef SO3_DEBUG
125 MMechostr(MSKDEBUG, "SO3EnvironmentUnregisterViewport\n");
126#endif
127
128 int scolViewport = MMpull(m);
129 int scolScene = MMget(m, 0);
130 if((scolViewport==NIL)||(scolScene==NIL))
131 {
132 MMset(m, 0, NIL);
133 return 0;
134 }
135
136 if (SRoot::getSingletonPtr()->IsRendering())
137 {
138 MMechostr(MSKRUNTIME, "SO3EnvironmentUnregisterViewport: Can not be called in a render callback\n");
139 MMset(m, 0, NIL);
140 return 0;
141 }
142
143 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
144 if(parentScene==0)
145 {
146 MMechostr(MSKDEBUG, "SO3EnvironmentUnregisterViewport: Scene instance is NULL\n");
147 MMset(m, 0, NIL);
148 return 0;
149 }
150
151 SViewPort* targetViewport = MMgetPointer<SViewPort*>(m, MTOP(scolViewport));
152 if(targetViewport==0)
153 {
154 MMechostr(MSKDEBUG, "SO3EnvironmentUnregisterViewport: Viewport instance is NULL\n");
155 MMset(m, 0, NIL);
156 return 0;
157 }
158
159 if (!parentScene->GetEnvironment())
160 {
161 MMset(m, 0, NIL);
162 return 0;
163 }
164
165 try
166 {
167 parentScene->GetEnvironment()->UnregisterViewport(targetViewport);
168 MMset(m, 0, ITOM(1));
169 return 0;
170 }
171 catch(Ogre::Exception&)
172 {
173 MMset(m, 0, NIL);
174 return 0;
175 }
176}
177
187{
188#ifdef SO3_DEBUG
189 MMechostr(MSKDEBUG, "SO3EnvironmentGetRegisteredViewports\n");
190#endif
191
192 int scolScene = MMget(m, 0);
193 if(scolScene==NIL)
194 {
195 MMset(m, 0, NIL);
196 return 0;
197 }
198
199 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
200 if(parentScene==0)
201 {
202 MMechostr(MSKDEBUG, "SO3EnvironmentGetRegisteredViewports: Scene instance is NULL\n");
203 MMset(m, 0, NIL);
204 return 0;
205 }
206
207 if (!parentScene->GetEnvironment())
208 {
209 MMset(m, 0, NIL);
210 return 0;
211 }
212
213 //remove last param
214 MMpull(m);
215
216 try
217 {
218 SEnvironment::ViewportList viewports = parentScene->GetEnvironment()->GetRegisteredViewports();
219 if(viewports.size() > 0)
220 {
221 // Push tuple values on stack
222 SEnvironment::ViewportList::iterator iViewport = viewports.begin();
223 while(iViewport != viewports.end())
224 {
225 int scolViewport = OBJfindTH(m, SO3VPTYPE, SCOL_PTR (*iViewport));
226 if(scolViewport!=NIL)
227 scolViewport = MMfetch(m, scolViewport, OFFOBJMAG);
228
229 MMpush(m, scolViewport);
230 iViewport++;
231 }
232
233 // Push tuple final value on stack
234 if(MMpush(m, NIL))
235 return MERRMEM;
236
237 // Build the recursive tuple
238 for(unsigned int j=0; j<viewports.size(); j++)
239 {
240 if(MMpush(m, 2*2))
241 return MERRMEM;
242
243 if(int k=MBdeftab(m))
244 return k;
245 }
246 return 0;
247 }
248 }
249 catch(const Ogre::Exception& e)
250 {
251 MMechostr(MSKDEBUG, "SO3EnvironmentGetRegisteredViewports: %s\n", e.getFullDescription().c_str());
252 }
253
254 MMpush(m, NIL);
255 return 0;
256}
257
267{
268#ifdef SO3_DEBUG
269 MMechostr(MSKDEBUG, "SO3EnvironmentGetEnable\n");
270#endif
271
272 int scolScene = MMget(m, 0);
273 if(scolScene==NIL)
274 {
275 MMset(m, 0, NIL);
276 return 0;
277 }
278
279 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
280 if(parentScene==0)
281 {
282 MMechostr(MSKDEBUG, "SO3EnvironmentGetEnable: Scene instance is NULL\n");
283 MMset(m, 0, NIL);
284 return 0;
285 }
286
287 if (!parentScene->GetEnvironment())
288 {
289 MMset(m, 0, NIL);
290 return 0;
291 }
292
293 bool isEnabled = parentScene->GetEnvironment()->GetEnable();
294 if(isEnabled)
295 MMset(m, 0, ITOM(1));
296 else
297 MMset(m, 0, ITOM(0));
298 return 0;
299}
300
301
312{
313#ifdef SO3_DEBUG
314 MMechostr(MSKDEBUG, "SO3EnvironmentSetEnable\n");
315#endif
316
317 int scolEnable = MMpull(m);
318 int scolScene = MMget(m, 0);
319 if((scolScene==NIL)||(scolEnable==NIL))
320 {
321 MMset(m, 0, NIL);
322 return 0;
323 }
324
325 if (SRoot::getSingletonPtr()->IsRendering())
326 {
327 MMechostr(MSKRUNTIME, "SO3EnvironmentSetEnable: Can not be called in a render callback\n");
328 MMset(m, 0, NIL);
329 return 0;
330 }
331
332 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
333 if(parentScene==0)
334 {
335 MMechostr(MSKDEBUG, "SO3EnvironmentSetEnable: Scene instance is NULL\n");
336 MMset(m, 0, NIL);
337 return 0;
338 }
339
340 if (!parentScene->GetEnvironment())
341 {
342 MMset(m, 0, NIL);
343 return 0;
344 }
345
346 bool enable = false;
347 if(MTOI(scolEnable) == 1)
348 enable = true;
349
350 parentScene->GetEnvironment()->SetEnable(enable);
351 MMset(m, 0, ITOM(1));
352 return 0;
353}
354
364{
365#ifdef SO3_DEBUG
366 MMechostr(MSKDEBUG, "SO3EnvironmentGetWindSpeed\n");
367#endif
368
369 int scolScene = MMget(m, 0);
370 if(scolScene==NIL)
371 {
372 MMset(m, 0, NIL);
373 return 0;
374 }
375
376 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
377 if(parentScene==0)
378 {
379 MMechostr(MSKDEBUG, "SO3EnvironmentGetWindSpeed: Scene instance is NULL\n");
380 MMset(m, 0, NIL);
381 return 0;
382 }
383
384 if (!parentScene->GetEnvironment())
385 {
386 MMset(m, 0, NIL);
387 return 0;
388 }
389
390 MMset(m, 0, FTOM(parentScene->GetEnvironment()->GetWindSpeed()));
391 return 0;
392}
393
404{
405#ifdef SO3_DEBUG
406 MMechostr(MSKDEBUG, "SO3EnvironmentSetWindSpeed\n");
407#endif
408
409 int scolWindSpeed = MMpull(m);
410 int scolScene = MMget(m, 0);
411 if((scolScene==NIL)||(scolWindSpeed==NIL))
412 {
413 MMset(m, 0, NIL);
414 return 0;
415 }
416
417 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
418 if(parentScene==0)
419 {
420 MMechostr(MSKDEBUG, "SO3EnvironmentSetWindSpeed: Scene instance is NULL\n");
421 MMset(m, 0, NIL);
422 return 0;
423 }
424
425 if (!parentScene->GetEnvironment())
426 {
427 MMset(m, 0, NIL);
428 return 0;
429 }
430
431 parentScene->GetEnvironment()->SetWindSpeed(MTOF(scolWindSpeed));
432 MMset(m, 0, ITOM(1));
433 return 0;
434}
435
447{
448#ifdef SO3_DEBUG
449 MMechostr(MSKDEBUG, "SO3EnvironmentGetWindDirection\n");
450#endif
451
452 int scolScene = MMget(m, 0);
453 if(scolScene==NIL)
454 {
455 MMset(m, 0, NIL);
456 return 0;
457 }
458
459 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
460 if(parentScene==0)
461 {
462 MMechostr(MSKDEBUG, "SO3EnvironmentGetWindDirection: Scene instance is NULL\n");
463 MMset(m, 0, NIL);
464 return 0;
465 }
466
467 if (!parentScene->GetEnvironment())
468 {
469 MMset(m, 0, NIL);
470 return 0;
471 }
472
473 // Create the wind direction tuple
474 int scolWindDirection = MMmalloc(m, 6, TYPETAB);
475 if(scolWindDirection==NIL)
476 return MERRMEM;
477
478 // Store the wind direction
479 Ogre::Vector2 currentWindDirection = parentScene->GetEnvironment()->GetWindDirection();
480 MMstore(m, scolWindDirection, 0, FTOM(currentWindDirection.x));
481 MMstore(m, scolWindDirection, 1, FTOM(currentWindDirection.y));
482 MMset(m, 0, PTOM(scolWindDirection));
483 return 0;
484}
485
497{
498#ifdef SO3_DEBUG
499 MMechostr(MSKDEBUG, "SO3EnvironmentSetWindDirection\n");
500#endif
501
502 int scolWindDirectionY = MMpull(m);
503 int scolWindDirectionX = MMpull(m);
504 int scolScene = MMget(m, 0);
505 if((scolScene==NIL)||(scolWindDirectionX==NIL)||(scolWindDirectionY==NIL))
506 {
507 MMset(m, 0, NIL);
508 return 0;
509 }
510
511 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
512 if(parentScene==0)
513 {
514 MMechostr(MSKDEBUG, "SO3EnvironmentSetWindDirection: Scene instance is NULL\n");
515 MMset(m, 0, NIL);
516 return 0;
517 }
518
519 if (!parentScene->GetEnvironment())
520 {
521 MMset(m, 0, NIL);
522 return 0;
523 }
524
525 parentScene->GetEnvironment()->SetWindDirection(Ogre::Vector2(MTOF(scolWindDirectionX), MTOF(scolWindDirectionY)));
526 MMset(m, 0, ITOM(1));
527 return 0;
528}
529
539{
540#ifdef SO3_DEBUG
541 MMechostr(MSKDEBUG, "SO3EnvironmentGetHumidity\n");
542#endif
543
544 int scolScene = MMget(m, 0);
545 if(scolScene==NIL)
546 {
547 MMset(m, 0, NIL);
548 return 0;
549 }
550
551 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
552 if(parentScene==0)
553 {
554 MMechostr(MSKDEBUG, "SO3EnvironmentGetHumidity: Scene instance is NULL\n");
555 MMset(m, 0, NIL);
556 return 0;
557 }
558
559 if (!parentScene->GetEnvironment())
560 {
561 MMset(m, 0, NIL);
562 return 0;
563 }
564
565 // Store the humidity factor
566 MMset(m, 0, FTOM(parentScene->GetEnvironment()->GetHumidity()));
567 return 0;
568}
569
580{
581#ifdef SO3_DEBUG
582 MMechostr(MSKDEBUG, "SO3EnvironmentSetHumidity\n");
583#endif
584
585 int scolHumidityFactor = MMpull(m);
586 int scolScene = MMget(m, 0);
587 if((scolScene==NIL)||(scolHumidityFactor==NIL))
588 {
589 MMset(m, 0, NIL);
590 return 0;
591 }
592
593 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
594 if(parentScene==0)
595 {
596 MMechostr(MSKDEBUG, "SO3EnvironmentSetHumidity: Scene instance is NULL\n");
597 MMset(m, 0, NIL);
598 return 0;
599 }
600
601 if (!parentScene->GetEnvironment())
602 {
603 MMset(m, 0, NIL);
604 return 0;
605 }
606
607 parentScene->GetEnvironment()->SetHumidity(MTOF(scolHumidityFactor));
608 MMset(m, 0, ITOM(1));
609 return 0;
610}
611
621{
622#ifdef SO3_DEBUG
623 MMechostr(MSKDEBUG, "SO3EnvironmentGetTimeSpeedFactor\n");
624#endif
625
626 int scolScene = MMget(m, 0);
627 if(scolScene==NIL)
628 {
629 MMset(m, 0, NIL);
630 return 0;
631 }
632
633 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
634 if(parentScene==0)
635 {
636 MMechostr(MSKDEBUG, "SO3EnvironmentGetTimeSpeedFactor: Scene instance is NULL\n");
637 MMset(m, 0, NIL);
638 return 0;
639 }
640
641 if (!parentScene->GetEnvironment())
642 {
643 MMset(m, 0, NIL);
644 return 0;
645 }
646
647 MMset(m, 0, FTOM(parentScene->GetEnvironment()->GetTimeSpeedFactor()));
648 return 0;
649}
650
661{
662#ifdef SO3_DEBUG
663 MMechostr(MSKDEBUG, "SO3EnvironmentSetTimeSpeedFactor\n");
664#endif
665
666 int scolTimeSpeedFactor = MMpull(m);
667 int scolScene = MMget(m, 0);
668 if(scolScene==NIL)
669 {
670 MMset(m, 0, NIL);
671 return 0;
672 }
673
674 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
675 if(parentScene==0)
676 {
677 MMechostr(MSKDEBUG, "SO3EnvironmentSetTimeSpeedFactor: Scene instance is NULL\n");
678 MMset(m, 0, NIL);
679 return 0;
680 }
681
682 if (!parentScene->GetEnvironment())
683 {
684 MMset(m, 0, NIL);
685 return 0;
686 }
687
688 // If NIL then value is zero
689 float timeSpeedFactor = 0;
690 if(scolTimeSpeedFactor != NIL)
691 timeSpeedFactor = MTOF(scolTimeSpeedFactor);
692
693 parentScene->GetEnvironment()->SetTimeSpeedFactor(timeSpeedFactor);
694 MMset(m, 0, ITOM(1));
695 return 0;
696}
697
698
708{
709#ifdef SO3_DEBUG
710 MMechostr(MSKDEBUG, "SO3EnvironmentGetPaused\n");
711#endif
712
713 int scolScene = MMget(m, 0);
714 if(scolScene==NIL)
715 {
716 MMset(m, 0, NIL);
717 return 0;
718 }
719
720 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
721 if(parentScene==0)
722 {
723 MMechostr(MSKDEBUG, "SO3EnvironmentGetPaused: Scene instance is NULL\n");
724 MMset(m, 0, NIL);
725 return 0;
726 }
727
728 if (!parentScene->GetEnvironment())
729 {
730 MMset(m, 0, NIL);
731 return 0;
732 }
733
734 bool isPaused = parentScene->GetEnvironment()->GetPaused();
735 if(isPaused)
736 MMset(m, 0, ITOM(1));
737 else
738 MMset(m, 0, ITOM(0));
739 return 0;
740}
741
742
753{
754#ifdef SO3_DEBUG
755 MMechostr(MSKDEBUG, "SO3EnvironmentSetPaused\n");
756#endif
757
758 int scolEnvironmentPause = MMpull(m);
759 int scolScene = MMget(m, 0);
760 if((scolScene==NIL)||(scolEnvironmentPause==NIL))
761 {
762 MMset(m, 0, NIL);
763 return 0;
764 }
765
766 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
767 if(parentScene==0)
768 {
769 MMechostr(MSKDEBUG, "SO3EnvironmentSetPaused: Scene instance is NULL\n");
770 MMset(m, 0, NIL);
771 return 0;
772 }
773
774 if (!parentScene->GetEnvironment())
775 {
776 MMset(m, 0, NIL);
777 return 0;
778 }
779
780 bool pause = false;
781 if(MTOI(scolEnvironmentPause) == 1)
782 pause = true;
783
784 parentScene->GetEnvironment()->SetPaused(pause);
785 MMset(m, 0, ITOM(1));
786 return 0;
787}
788
789
805{
806#ifdef SO3_DEBUG
807 MMechostr(MSKDEBUG, "SO3EnvironmentGetDateTime\n");
808#endif
809
810 int scolScene = MMget(m, 0);
811 if(scolScene==NIL)
812 {
813 MMset(m, 0, NIL);
814 return 0;
815 }
816
817 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
818 if(parentScene==0)
819 {
820 MMechostr(MSKDEBUG, "SO3EnvironmentGetDateTime: Scene instance is NULL\n");
821 MMset(m, 0, NIL);
822 return 0;
823 }
824
825 if (!parentScene->GetEnvironment())
826 {
827 MMset(m, 0, NIL);
828 return 0;
829 }
830
831 // Create the date/time return tuple
832 int scolDateTime = MMmalloc(m, 6, TYPETAB);
833 if(scolDateTime==NIL)
834 return MERRMEM;
835
836 // Store the date/time
837 SDateTime currentDateTime = parentScene->GetEnvironment()->GetDateTime();
838 MMstore(m, scolDateTime, 0, ITOM(currentDateTime.year));
839 MMstore(m, scolDateTime, 1, ITOM(currentDateTime.month));
840 MMstore(m, scolDateTime, 2, ITOM(currentDateTime.day));
841 MMstore(m, scolDateTime, 3, ITOM(currentDateTime.hour));
842 MMstore(m, scolDateTime, 4, ITOM(currentDateTime.minute));
843 MMstore(m, scolDateTime, 5, ITOM(currentDateTime.second));
844 MMset(m, 0, PTOM(scolDateTime));
845 return 0;
846}
847
863{
864#ifdef SO3_DEBUG
865 MMechostr(MSKDEBUG, "SO3EnvironmentSetDateTime\n");
866#endif
867
868 int scolSeconds = MMpull(m);
869 int scolMinutes = MMpull(m);
870 int scolHours = MMpull(m);
871 int scolDay = MMpull(m);
872 int scolMonth = MMpull(m);
873 int scolYear = MMpull(m);
874 int scolScene = MMget(m, 0);
875 if(scolScene==NIL)
876 {
877 MMset(m, 0, NIL);
878 return 0;
879 }
880
881 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
882 if(parentScene==0)
883 {
884 MMechostr(MSKDEBUG, "SO3EnvironmentSetDateTime: Scene instance is NULL\n");
885 MMset(m, 0, NIL);
886 return 0;
887 }
888
889 if (!parentScene->GetEnvironment())
890 {
891 MMset(m, 0, NIL);
892 return 0;
893 }
894
895 // Get the actual environment date/time
896 SDateTime currentDateTime = parentScene->GetEnvironment()->GetDateTime();
897
898 // Update year
899 if(scolYear != NIL)
900 currentDateTime.year = MTOI(scolYear);
901
902 // Update month
903 if(scolMonth != NIL)
904 currentDateTime.month = MTOI(scolMonth);
905
906 // Update day
907 if(scolDay != NIL)
908 currentDateTime.day = MTOI(scolDay);
909
910 // Update hours
911 if(scolHours != NIL)
912 currentDateTime.hour = MTOI(scolHours);
913
914 // Update minutes
915 if(scolMinutes != NIL)
916 currentDateTime.minute = MTOI(scolMinutes);
917
918 // Update seconds
919 if(scolSeconds != NIL)
920 currentDateTime.second = MTOI(scolSeconds);
921
922 // Update environment date/time
923 parentScene->GetEnvironment()->SetDateTime(currentDateTime);
924 MMset(m, 0, ITOM(1));
925 return 0;
926}
927
937{
938#ifdef SO3_DEBUG
939 MMechostr(MSKDEBUG, "SO3EnvironmentGetLongitude\n");
940#endif
941
942 int scolScene = MMget(m, 0);
943 if(scolScene==NIL)
944 {
945 MMset(m, 0, NIL);
946 return 0;
947 }
948
949 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
950 if(parentScene==0)
951 {
952 MMechostr(MSKDEBUG, "SO3EnvironmentGetLongitude: Scene instance is NULL\n");
953 MMset(m, 0, NIL);
954 return 0;
955 }
956
957 if (!parentScene->GetEnvironment())
958 {
959 MMset(m, 0, NIL);
960 return 0;
961 }
962
963 MMset(m, 0, FTOM(parentScene->GetEnvironment()->GetLongitude().valueDegrees()));
964 return 0;
965}
966
977{
978#ifdef SO3_DEBUG
979 MMechostr(MSKDEBUG, "SO3EnvironmentSetLongitude\n");
980#endif
981
982 int scolLongitude = MMpull(m);
983 int scolScene = MMget(m, 0);
984 if((scolScene==NIL)||(scolLongitude==NIL))
985 {
986 MMset(m, 0, NIL);
987 return 0;
988 }
989
990 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
991 if(parentScene==0)
992 {
993 MMechostr(MSKDEBUG, "SO3EnvironmentSetLongitude: Scene instance is NULL\n");
994 MMset(m, 0, NIL);
995 return 0;
996 }
997
998 if (!parentScene->GetEnvironment())
999 {
1000 MMset(m, 0, NIL);
1001 return 0;
1002 }
1003
1004 parentScene->GetEnvironment()->SetLongitude(Ogre::Degree(MTOF(scolLongitude)));
1005 MMset(m, 0, ITOM(1));
1006 return 0;
1007}
1008
1018{
1019#ifdef SO3_DEBUG
1020 MMechostr(MSKDEBUG, "SO3EnvironmentGetLatitude\n");
1021#endif
1022
1023 int scolScene = MMget(m, 0);
1024 if(scolScene==NIL)
1025 {
1026 MMset(m, 0, NIL);
1027 return 0;
1028 }
1029
1030 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
1031 if(parentScene==0)
1032 {
1033 MMechostr(MSKDEBUG, "SO3EnvironmentGetLatitude: Scene instance is NULL\n");
1034 MMset(m, 0, NIL);
1035 return 0;
1036 }
1037
1038 if (!parentScene->GetEnvironment())
1039 {
1040 MMset(m, 0, NIL);
1041 return 0;
1042 }
1043
1044 MMset(m, 0, FTOM(parentScene->GetEnvironment()->GetLatitude().valueDegrees()));
1045 return 0;
1046}
1047
1058{
1059#ifdef SO3_DEBUG
1060 MMechostr(MSKDEBUG, "SO3EnvironmentSetLatitude\n");
1061#endif
1062
1063 int scolLatitude = MMpull(m);
1064 int scolScene = MMget(m, 0);
1065 if((scolScene==NIL)||(scolLatitude==NIL))
1066 {
1067 MMset(m, 0, NIL);
1068 return 0;
1069 }
1070
1071 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
1072 if(parentScene==0)
1073 {
1074 MMechostr(MSKDEBUG, "SO3EnvironmentSetLatitude: Scene instance is NULL\n");
1075 MMset(m, 0, NIL);
1076 return 0;
1077 }
1078
1079 if (!parentScene->GetEnvironment())
1080 {
1081 MMset(m, 0, NIL);
1082 return 0;
1083 }
1084
1085 parentScene->GetEnvironment()->SetLatitude(Ogre::Degree(MTOF(scolLatitude)));
1086 MMset(m, 0, ITOM(1));
1087 return 0;
1088}
1089
1098int SO3WaterGetEnable(mmachine m)
1099{
1100#ifdef SO3_DEBUG
1101 MMechostr(MSKDEBUG, "SO3WaterGetEnable\n");
1102#endif
1103
1104 int scolScene = MMget(m, 0);
1105 if(scolScene==NIL)
1106 {
1107 MMset(m, 0, NIL);
1108 return 0;
1109 }
1110
1111 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
1112 if(parentScene==0)
1113 {
1114 MMechostr(MSKDEBUG, "SO3WaterGetEnable: Scene instance is NULL\n");
1115 MMset(m, 0, NIL);
1116 return 0;
1117 }
1118
1119 if (!parentScene->GetEnvironment())
1120 {
1121 MMset(m, 0, NIL);
1122 return 0;
1123 }
1124
1125 if(parentScene->GetEnvironment()->GetWaterEnable())
1126 MMset(m, 0, ITOM(1));
1127 else
1128 MMset(m, 0, ITOM(0));
1129 return 0;
1130}
1131
1141int SO3WaterSetEnable(mmachine m)
1142{
1143#ifdef SO3_DEBUG
1144 MMechostr(MSKDEBUG, "SO3WaterSetEnable\n");
1145#endif
1146
1147 int scolEnable = MMpull(m);
1148 int scolScene = MMget(m, 0);
1149 if(scolScene==NIL)
1150 {
1151 MMset(m, 0, NIL);
1152 return 0;
1153 }
1154
1155 if (SRoot::getSingletonPtr()->IsRendering())
1156 {
1157 MMechostr(MSKRUNTIME, "SO3WaterSetEnable: Can not be called in a render callback\n");
1158 MMset(m, 0, NIL);
1159 return 0;
1160 }
1161
1162 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
1163 if(parentScene==0)
1164 {
1165 MMechostr(MSKDEBUG, "SO3WaterSetEnable: Scene instance is NULL\n");
1166 MMset(m, 0, NIL);
1167 return 0;
1168 }
1169
1170 if (!parentScene->GetEnvironment())
1171 {
1172 MMset(m, 0, NIL);
1173 return 0;
1174 }
1175
1176 bool enable = false;
1177 if(MTOI(scolEnable) == 1)
1178 enable = true;
1179
1180 parentScene->GetEnvironment()->SetWaterEnable(enable);
1181 MMset(m, 0, ITOM(1));
1182 return 0;
1183}
1184
1205{
1206#ifdef SO3_DEBUG
1207 MMechostr(MSKDEBUG, "SO3WaterComponentGetEnabled\n");
1208#endif
1209
1210 int scolComponentType = MMpull(m);
1211 int scolScene = MMget(m, 0);
1212 if((scolScene==NIL)||(scolComponentType==NIL))
1213 {
1214 MMset(m, 0, NIL);
1215 return 0;
1216 }
1217
1218 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
1219 if(parentScene==0)
1220 {
1221 MMechostr(MSKDEBUG, "SO3WaterComponentGetEnabled: Scene instance is NULL\n");
1222 MMset(m, 0, NIL);
1223 return 0;
1224 }
1225
1226 if (!parentScene->GetEnvironment())
1227 {
1228 MMset(m, 0, NIL);
1229 return 0;
1230 }
1231
1232 SWater* water = parentScene->GetEnvironment()->GetWater();
1233 if(water)
1234 {
1235 try
1236 {
1237 bool isEnable = false;
1238 if(water->GetComponent(static_cast<SWater::WaterComponentType>(MTOI(scolComponentType)))->GetEnabled())
1239 isEnable = true;
1240
1241 if(isEnable)
1242 MMset(m, 0, ITOM(1));
1243 else
1244 MMset(m, 0, ITOM(0));
1245 return 0;
1246 }
1247 catch(const Ogre::Exception& e)
1248 {
1249 MMechostr(MSKDEBUG, "SO3WaterComponentGetEnabled: %s\n", e.getFullDescription().c_str());
1250 }
1251 }
1252 MMset(m, 0, NIL);
1253 return 0;
1254}
1255
1277{
1278#ifdef SO3_DEBUG
1279 MMechostr(MSKDEBUG, "SO3WaterComponentSetEnabled\n");
1280#endif
1281
1282 int scolEnableComponent = MMpull(m);
1283 int scolComponentType = MMpull(m);
1284 int scolScene = MMget(m, 0);
1285 if((scolScene==NIL) || (scolComponentType==NIL))
1286 {
1287 MMset(m, 0, NIL);
1288 return 0;
1289 }
1290
1291 if (SRoot::getSingletonPtr()->IsRendering())
1292 {
1293 MMechostr(MSKRUNTIME, "SO3WaterComponentSetEnabled: Can not be called in a render callback\n");
1294 MMset(m, 0, NIL);
1295 return 0;
1296 }
1297
1298 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
1299 if(parentScene==0)
1300 {
1301 MMechostr(MSKDEBUG, "SO3WaterComponentSetEnabled: Scene instance is NULL\n");
1302 MMset(m, 0, NIL);
1303 return 0;
1304 }
1305
1306 if (!parentScene->GetEnvironment())
1307 {
1308 MMset(m, 0, NIL);
1309 return 0;
1310 }
1311
1312 SWater* water = parentScene->GetEnvironment()->GetWater();
1313 if(water)
1314 {
1315 bool enableComponent = false;
1316 if(MTOI(scolEnableComponent) == 1)
1317 enableComponent = true;
1318
1319 try
1320 {
1321 water->GetComponent(static_cast<SWater::WaterComponentType>(MTOI(scolComponentType)))->SetEnabled(enableComponent);
1322 }
1323 catch(const Ogre::Exception& e)
1324 {
1325 MMechostr(MSKDEBUG, "SO3WaterComponentSetEnabled: %s\n", e.getFullDescription().c_str());
1326 MMset(m, 0, NIL);
1327 return 0;
1328 }
1329 }
1330
1331 MMset(m, 0, ITOM(1));
1332 return 0;
1333}
1334
1343int SO3SkyGetEnable(mmachine m)
1344{
1345#ifdef SO3_DEBUG
1346 MMechostr(MSKDEBUG, "SO3SkyGetEnable\n");
1347#endif
1348
1349 int scolScene = MMget(m, 0);
1350 if(scolScene==NIL)
1351 {
1352 MMset(m, 0, NIL);
1353 return 0;
1354 }
1355
1356 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
1357 if(parentScene==0)
1358 {
1359 MMechostr(MSKDEBUG, "SO3SkyGetEnable: Scene instance is NULL\n");
1360 MMset(m, 0, NIL);
1361 return 0;
1362 }
1363
1364 if (!parentScene->GetEnvironment())
1365 {
1366 MMset(m, 0, NIL);
1367 return 0;
1368 }
1369
1370 if(parentScene->GetEnvironment()->GetSkyEnable())
1371 MMset(m, 0, ITOM(1));
1372 else
1373 MMset(m, 0, ITOM(0));
1374 return 0;
1375}
1376
1386int SO3SkySetEnable(mmachine m)
1387{
1388#ifdef SO3_DEBUG
1389 MMechostr(MSKDEBUG, "SO3SkySetEnable\n");
1390#endif
1391
1392 int scolEnable = MMpull(m);
1393 int scolScene = MMget(m, 0);
1394 if(scolScene==NIL)
1395 {
1396 MMset(m, 0, NIL);
1397 return 0;
1398 }
1399
1400 if (SRoot::getSingletonPtr()->IsRendering())
1401 {
1402 MMechostr(MSKRUNTIME, "SO3SkySetEnable: Can not be called in a render callback\n");
1403 MMset(m, 0, NIL);
1404 return 0;
1405 }
1406
1407 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
1408 if(parentScene==0)
1409 {
1410 MMechostr(MSKDEBUG, "SO3SkySetEnable: Scene instance is NULL\n");
1411 MMset(m, 0, NIL);
1412 return 0;
1413 }
1414
1415 if (!parentScene->GetEnvironment())
1416 {
1417 MMset(m, 0, NIL);
1418 return 0;
1419 }
1420
1421 bool enable = false;
1422 if(MTOI(scolEnable) == 1)
1423 enable = true;
1424
1425 parentScene->GetEnvironment()->SetSkyEnable(enable);
1426 MMset(m, 0, ITOM(1));
1427 return 0;
1428}
1429
1444{
1445#ifdef SO3_DEBUG
1446 MMechostr(MSKDEBUG, "SO3SkyComponentGetEnabled\n");
1447#endif
1448
1449 int scolComponentType = MMpull(m);
1450 int scolScene = MMget(m, 0);
1451 if((scolScene==NIL)||(scolComponentType==NIL))
1452 {
1453 MMset(m, 0, NIL);
1454 return 0;
1455 }
1456
1457 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
1458 if(parentScene==0)
1459 {
1460 MMechostr(MSKDEBUG, "SO3SkyComponentGetEnabled: Scene instance is NULL\n");
1461 MMset(m, 0, NIL);
1462 return 0;
1463 }
1464
1465 if (!parentScene->GetEnvironment())
1466 {
1467 MMset(m, 0, NIL);
1468 return 0;
1469 }
1470
1471 SSky* sky = parentScene->GetEnvironment()->GetSky();
1472 if(sky)
1473 {
1474 try
1475 {
1476 bool isEnable = false;
1477 if (sky->GetComponent(static_cast<SSky::SkyComponentType>(MTOI(scolComponentType))) && sky->GetComponent(static_cast<SSky::SkyComponentType>(MTOI(scolComponentType)))->GetEnabled())
1478 isEnable = true;
1479
1480 if(isEnable)
1481 MMset(m, 0, ITOM(1));
1482 else
1483 MMset(m, 0, ITOM(0));
1484 return 0;
1485 }
1486 catch(const Ogre::Exception& e)
1487 {
1488 MMechostr(MSKDEBUG, "SO3SkyComponentGetEnabled: %s\n", e.getFullDescription().c_str());
1489 }
1490 }
1491
1492 MMset(m, 0, NIL);
1493 return 0;
1494}
1495
1509{
1510#ifdef SO3_DEBUG
1511 MMechostr(MSKDEBUG, "SO3SkyComponentSetEnabled\n");
1512#endif
1513
1514 int scolEnableComponent = MMpull(m);
1515 int scolComponentType = MMpull(m);
1516 int scolScene = MMget(m, 0);
1517 if((scolScene==NIL)||(scolEnableComponent==NIL)||(scolEnableComponent==NIL))
1518 {
1519 MMset(m, 0, NIL);
1520 return 0;
1521 }
1522
1523 if (SRoot::getSingletonPtr()->IsRendering())
1524 {
1525 MMechostr(MSKRUNTIME, "SO3SkyComponentSetEnabled: Can not be called in a render callback\n");
1526 MMset(m, 0, NIL);
1527 return 0;
1528 }
1529
1530 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
1531 if(parentScene==0)
1532 {
1533 MMechostr(MSKDEBUG, "SO3SkyComponentSetEnabled: Scene instance is NULL\n");
1534 MMset(m, 0, NIL);
1535 return 0;
1536 }
1537
1538 if (!parentScene->GetEnvironment())
1539 {
1540 MMset(m, 0, NIL);
1541 return 0;
1542 }
1543
1544 SSky* sky = parentScene->GetEnvironment()->GetSky();
1545 if(sky)
1546 {
1547 try
1548 {
1549 bool enableComponent = false;
1550 if(MTOI(scolEnableComponent) == 1)
1551 enableComponent = true;
1552
1553 if (sky->GetComponent(static_cast<SSky::SkyComponentType>(MTOI(scolComponentType))))
1554 sky->GetComponent(static_cast<SSky::SkyComponentType>(MTOI(scolComponentType)))->SetEnabled(enableComponent);
1555 }
1556 catch(const Ogre::Exception& e)
1557 {
1558 MMechostr(MSKDEBUG, "SO3SkyComponentSetEnabled: %s\n", e.getFullDescription().c_str());
1559 MMset(m, 0, NIL);
1560 return 0;
1561 }
1562 }
1563
1564 MMset(m, 0, ITOM(1));
1565 return 0;
1566}
1567
1576int SO3WaterGetPosition(mmachine m)
1577{
1578#ifdef SO3_DEBUG
1579 MMechostr(MSKDEBUG, "SO3WaterGetPosition\n");
1580#endif
1581
1582 int scolScene = MMget(m, 0);
1583 if(scolScene==NIL)
1584 {
1585 MMset(m, 0, NIL);
1586 return 0;
1587 }
1588
1589 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
1590 if(parentScene==0)
1591 {
1592 MMechostr(MSKDEBUG, "SO3WaterGetPosition: Scene instance is NULL\n");
1593 MMset(m, 0, NIL);
1594 return 0;
1595 }
1596
1597 if (!parentScene->GetEnvironment())
1598 {
1599 MMset(m, 0, NIL);
1600 return 0;
1601 }
1602
1603 SWater* water = parentScene->GetEnvironment()->GetWater();
1604 if(water)
1605 {
1606 // Create the return tuple
1607 int scolWaterPosition = MMmalloc(m, 3, TYPETAB);
1608 if(scolWaterPosition==NIL)
1609 return MERRMEM;
1610
1611 // Store all the values that were pushed on stack
1612 Ogre::Vector3 waterPosition = water->GetPosition();
1613 MMstore(m, scolWaterPosition, 0, FTOM(waterPosition.x));
1614 MMstore(m, scolWaterPosition, 1, FTOM(waterPosition.y));
1615 MMstore(m, scolWaterPosition, 2, FTOM(waterPosition.z));
1616 MMset(m, 0, PTOM(scolWaterPosition));
1617 return 0;
1618 }
1619
1620 MMset(m, 0, NIL);
1621 return 0;
1622}
1623
1624
1634int SO3WaterSetPosition(mmachine m)
1635{
1636#ifdef SO3_DEBUG
1637 MMechostr(MSKDEBUG, "SO3WaterSetPosition\n");
1638#endif
1639
1640 int scolWaterPosition = MMpull(m);
1641 int scolScene = MMget(m, 0);
1642 if((scolScene==NIL)||(scolWaterPosition==NIL))
1643 {
1644 MMset(m, 0, NIL);
1645 return 0;
1646 }
1647
1648 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
1649 if(parentScene==0)
1650 {
1651 MMechostr(MSKDEBUG, "SO3WaterSetPosition: Scene instance is NULL\n");
1652 MMset(m, 0, NIL);
1653 return 0;
1654 }
1655
1656 if (!parentScene->GetEnvironment())
1657 {
1658 MMset(m, 0, NIL);
1659 return 0;
1660 }
1661
1662 SWater* water = parentScene->GetEnvironment()->GetWater();
1663 if(water)
1664 {
1665 // Check x component
1666 Ogre::Vector3 waterPosition;
1667 int vectorComponent = MMfetch(m, MTOP(scolWaterPosition), 0);
1668 if(vectorComponent == NIL)
1669 waterPosition.x = 0.0f;
1670 else
1671 waterPosition.x = MTOF(vectorComponent);
1672
1673 // Check y component
1674 vectorComponent = MMfetch(m, MTOP(scolWaterPosition), 1);
1675 if(vectorComponent == NIL)
1676 waterPosition.y = 0.0f;
1677 else
1678 waterPosition.y = MTOF(vectorComponent);
1679
1680 // Check z component
1681 vectorComponent = MMfetch(m, MTOP(scolWaterPosition), 2);
1682 if(vectorComponent == NIL)
1683 waterPosition.z = 0.0f;
1684 else
1685 waterPosition.z = MTOF(vectorComponent);
1686
1687 // Set water position
1688 water->SetPosition(waterPosition);
1689 }
1690
1691 MMset(m, 0, ITOM(1));
1692 return 0;
1693}
1694
1703int SO3WaterGetColor(mmachine m)
1704{
1705#ifdef SO3_DEBUG
1706 MMechostr(MSKDEBUG, "SO3WaterGetColor\n");
1707#endif
1708
1709 int scolScene = MMget(m, 0);
1710 if(scolScene==NIL)
1711 {
1712 MMset(m, 0, NIL);
1713 return 0;
1714 }
1715
1716 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
1717 if(parentScene==0)
1718 {
1719 MMechostr(MSKDEBUG, "SO3WaterGetColor: Scene instance is NULL\n");
1720 MMset(m, 0, NIL);
1721 return 0;
1722 }
1723
1724 if (!parentScene->GetEnvironment())
1725 {
1726 MMset(m, 0, NIL);
1727 return 0;
1728 }
1729
1730 SWater* water = parentScene->GetEnvironment()->GetWater();
1731 if(water)
1732 {
1733 MMset(m, 0, ITOM(ConversionTools::OgreToScolColorRGBA(water->GetColor())));
1734 return 0;
1735 }
1736
1737 MMset(m, 0, NIL);
1738 return 0;
1739}
1740
1750int SO3WaterSetColor(mmachine m)
1751{
1752#ifdef SO3_DEBUG
1753 MMechostr(MSKDEBUG, "SO3WaterSetColor\n");
1754#endif
1755
1756 int scolWaterColor = MMpull(m);
1757 int scolScene = MMget(m, 0);
1758 if((scolScene==NIL)||(scolWaterColor==NIL))
1759 {
1760 MMset(m, 0, NIL);
1761 return 0;
1762 }
1763
1764 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
1765 if(parentScene==0)
1766 {
1767 MMechostr(MSKDEBUG, "SO3WaterSetColor: Scene instance is NULL\n");
1768 MMset(m, 0, NIL);
1769 return 0;
1770 }
1771
1772 if (!parentScene->GetEnvironment())
1773 {
1774 MMset(m, 0, NIL);
1775 return 0;
1776 }
1777
1778 SWater* water = parentScene->GetEnvironment()->GetWater();
1779 if(water)
1780 {
1781 water->SetColor(ConversionTools::ScolToOgreColorRGBA(MTOI(scolWaterColor)));
1782 MMset(m, 0, ITOM(1));
1783 return 0;
1784 }
1785
1786 MMset(m, 0, NIL);
1787 return 0;
1788}
1789
1799{
1800#ifdef SO3_DEBUG
1801 MMechostr(MSKDEBUG, "SO3WaterGetAnimationSpeed\n");
1802#endif
1803
1804 int scolScene = MMget(m, 0);
1805 if(scolScene==NIL)
1806 {
1807 MMset(m, 0, NIL);
1808 return 0;
1809 }
1810
1811 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
1812 if(parentScene==0)
1813 {
1814 MMechostr(MSKDEBUG, "SO3WaterGetAnimationSpeed: Scene instance is NULL\n");
1815 MMset(m, 0, NIL);
1816 return 0;
1817 }
1818
1819 if (!parentScene->GetEnvironment())
1820 {
1821 MMset(m, 0, NIL);
1822 return 0;
1823 }
1824
1825 SWater* water = parentScene->GetEnvironment()->GetWater();
1826 if(water)
1827 {
1828 MMset(m, 0, FTOM(water->GetAnimationSpeed()));
1829 return 0;
1830 }
1831
1832 MMset(m, 0, NIL);
1833 return 0;
1834}
1835
1836
1847{
1848#ifdef SO3_DEBUG
1849 MMechostr(MSKDEBUG, "SO3WaterSetAnimationSpeed\n");
1850#endif
1851
1852 int scolWaterAnimationSpeed = MMpull(m);
1853 int scolScene = MMget(m, 0);
1854 if((scolScene==NIL)||(scolWaterAnimationSpeed==NIL))
1855 {
1856 MMset(m, 0, NIL);
1857 return 0;
1858 }
1859
1860 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
1861 if(parentScene==0)
1862 {
1863 MMechostr(MSKDEBUG, "SO3WaterSetAnimationSpeed: Scene instance is NULL\n");
1864 MMset(m, 0, NIL);
1865 return 0;
1866 }
1867
1868 if (!parentScene->GetEnvironment())
1869 {
1870 MMset(m, 0, NIL);
1871 return 0;
1872 }
1873
1874 SWater* water = parentScene->GetEnvironment()->GetWater();
1875 if(water)
1876 {
1877 water->SetAnimationSpeed(MTOF(scolWaterAnimationSpeed));
1878 }
1879
1880 MMset(m, 0, ITOM(1));
1881 return 0;
1882}
1883
1884
1898{
1899#ifdef SO3_DEBUG
1900 MMechostr(MSKDEBUG, "SO3WaterGetSunParameters\n");
1901#endif
1902
1903 int scolScene = MMget(m, 0);
1904 if(scolScene==NIL)
1905 {
1906 MMset(m, 0, NIL);
1907 return 0;
1908 }
1909
1910 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
1911 if(parentScene==0)
1912 {
1913 MMechostr(MSKDEBUG, "SO3WaterGetSunParameters: Scene instance is NULL\n");
1914 MMset(m, 0, NIL);
1915 return 0;
1916 }
1917
1918 if (!parentScene->GetEnvironment())
1919 {
1920 MMset(m, 0, NIL);
1921 return 0;
1922 }
1923
1924 // Get sun parameters.
1925 SWater* water = parentScene->GetEnvironment()->GetWater();
1926 if(water)
1927 {
1928 // Get sun component.
1929 SWater::WaterComponentSun* sun = water->GetSun();
1930
1931 // Create a tuple for storing sun position
1932 int scolSunPosition = MMmalloc(m, 3, TYPETAB);
1933 if(scolSunPosition==NIL)
1934 return MERRMEM;
1935
1936 // Store sun position
1937 Ogre::Vector3 sunPosition = sun->GetPosition();
1938 MMstore(m, scolSunPosition, 0, FTOM(sunPosition.x));
1939 MMstore(m, scolSunPosition, 1, FTOM(sunPosition.y));
1940 MMstore(m, scolSunPosition, 2, FTOM(sunPosition.z));
1941 MMpush(m, PTOM(scolSunPosition));
1942
1943 // Store sun strength
1944 MMpush(m, FTOM(sun->GetStrength()));
1945
1946 // Store sun area
1947 MMpush(m, FTOM(sun->GetArea()));
1948
1949 // Create a tuple for storing sun color
1950 MMpush(m, ITOM(ConversionTools::OgreToScolColorRGBA(sun->GetColor())));
1951
1952 // Create the final tuple
1953 int result = MMmalloc(m, 4, TYPETAB);
1954 if(result==NIL)
1955 return MERRMEM;
1956
1957 // Store all the values that were pushed on stack
1958 MMstore(m, result, 3, MMpull(m));
1959 MMstore(m, result, 2, MMpull(m));
1960 MMstore(m, result, 1, MMpull(m));
1961 MMstore(m, result, 0, MMpull(m));
1962 MMset(m, 0, PTOM(result));
1963 return 0;
1964 }
1965
1966 MMset(m, 0, NIL);
1967 return 0;
1968}
1969
1983{
1984#ifdef SO3_DEBUG
1985 MMechostr(MSKDEBUG, "SO3WaterSetSunParameters\n");
1986#endif
1987
1988 int scolSunColor = MMpull(m);
1989 int scolSunArea = MMpull(m);
1990 int scolSunStrength = MMpull(m);
1991 int scolSunPosition = MMpull(m);
1992 int scolScene = MMget(m, 0);
1993 if(scolScene==NIL)
1994 {
1995 MMset(m, 0, NIL);
1996 return 0;
1997 }
1998
1999 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
2000 if(parentScene==0)
2001 {
2002 MMechostr(MSKDEBUG, "SO3WaterSetSunParameters: Scene instance is NULL\n");
2003 MMset(m, 0, NIL);
2004 return 0;
2005 }
2006
2007 if (!parentScene->GetEnvironment())
2008 {
2009 MMset(m, 0, NIL);
2010 return 0;
2011 }
2012
2013 // Set sun parameters.
2014 SWater* water = parentScene->GetEnvironment()->GetWater();
2015 if(water)
2016 {
2017 // Get sun component.
2018 SWater::WaterComponentSun* sun = water->GetSun();
2019
2020 // Set sun position
2021 if(scolSunPosition!=NIL)
2022 {
2023 Ogre::Vector3 sunPosition;
2024 sunPosition.x = MTOF(MMfetch(m, MTOP(scolSunPosition), 0));
2025 sunPosition.y = MTOF(MMfetch(m, MTOP(scolSunPosition), 1));
2026 sunPosition.z = MTOF(MMfetch(m, MTOP(scolSunPosition), 2));
2027 sun->SetPosition(sunPosition);
2028 }
2029
2030 // Set sun strength
2031 if(scolSunStrength!=NIL)
2032 sun->SetStrength(MTOF(scolSunStrength));
2033
2034 // Set sun area
2035 if(scolSunArea!=NIL)
2036 sun->SetArea(MTOF(scolSunArea));
2037
2038 // Set sun color
2039 if(scolSunColor!=NIL)
2040 sun->SetColor(ConversionTools::ScolToOgreColorRGBA(MTOI(scolSunColor)));
2041 }
2042
2043 MMset(m, 0, ITOM(1));
2044 return 0;
2045}
2046
2060{
2061#ifdef SO3_DEBUG
2062 MMechostr(MSKDEBUG, "SO3WaterGetFoamParameters\n");
2063#endif
2064
2065 int scolScene = MMget(m, 0);
2066 if(scolScene==NIL)
2067 {
2068 MMset(m, 0, NIL);
2069 return 0;
2070 }
2071
2072 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
2073 if(parentScene==0)
2074 {
2075 MMechostr(MSKDEBUG, "SO3WaterGetFoamParameters: Scene instance is NULL\n");
2076 MMset(m, 0, NIL);
2077 return 0;
2078 }
2079
2080 if (!parentScene->GetEnvironment())
2081 {
2082 MMset(m, 0, NIL);
2083 return 0;
2084 }
2085
2086 // Get foam parameters.
2087 SWater* water = parentScene->GetEnvironment()->GetWater();
2088 if(water)
2089 {
2090 // Get foam component.
2091 SWater::WaterComponentFoam* foam = water->GetFoam();
2092
2093 // Store foam maximum visibility distance.
2094 MMpush(m, FTOM(foam->GetMaxDistance()));
2095
2096 // Store foam scale
2097 MMpush(m, FTOM(foam->GetScale()));
2098
2099 // Store foam start
2100 MMpush(m, FTOM(foam->GetStart()));
2101
2102 // Store foam transparency power
2103 MMpush(m, FTOM(foam->GetTransparency()));
2104
2105 // Create the final tuple
2106 int result = MMmalloc(m, 4, TYPETAB);
2107 if(result==NIL)
2108 return MERRMEM;
2109
2110 // Store all the values that were pushed on stack
2111 MMstore(m, result, 3, MMpull(m));
2112 MMstore(m, result, 2, MMpull(m));
2113 MMstore(m, result, 1, MMpull(m));
2114 MMstore(m, result, 0, MMpull(m));
2115 MMset(m, 0, PTOM(result));
2116 return 0;
2117 }
2118
2119 MMset(m, 0, NIL);
2120 return 0;
2121}
2122
2136{
2137#ifdef SO3_DEBUG
2138 MMechostr(MSKDEBUG, "SO3WaterSetFoamParameters\n");
2139#endif
2140
2141 int scolFoamTransparancy = MMpull(m);
2142 int scolFoamStart = MMpull(m);
2143 int scolFoamScale = MMpull(m);
2144 int scolFoamMaxDistance = MMpull(m);
2145 int scolScene = MMget(m, 0);
2146 if(scolScene==NIL)
2147 {
2148 MMset(m, 0, NIL);
2149 return 0;
2150 }
2151
2152 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
2153 if(parentScene==0)
2154 {
2155 MMechostr(MSKDEBUG, "SO3WaterSetFoamParameters: Scene instance is NULL\n");
2156 MMset(m, 0, NIL);
2157 return 0;
2158 }
2159
2160 if (!parentScene->GetEnvironment())
2161 {
2162 MMset(m, 0, NIL);
2163 return 0;
2164 }
2165
2166 // Set foam parameters.
2167 SWater* water = parentScene->GetEnvironment()->GetWater();
2168 if(water)
2169 {
2170 // Get foam component.
2171 SWater::WaterComponentFoam* foam = water->GetFoam();
2172
2173 // Set foam max distance
2174 if(scolFoamMaxDistance!=NIL)
2175 foam->SetMaxDistance(MTOF(scolFoamMaxDistance));
2176
2177 // Set foam scale
2178 if(scolFoamScale!=NIL)
2179 foam->SetScale(MTOF(scolFoamScale));
2180
2181 // Set foam start
2182 if(scolFoamStart!=NIL)
2183 foam->SetStart(MTOF(scolFoamStart));
2184
2185 // Set foam scale
2186 if(scolFoamTransparancy!=NIL)
2187 foam->SetTransparency(MTOF(scolFoamTransparancy));
2188 }
2189
2190 MMset(m, 0, ITOM(1));
2191 return 0;
2192}
2193
2205{
2206#ifdef SO3_DEBUG
2207 MMechostr(MSKDEBUG, "SO3WaterGetDepthParameters\n");
2208#endif
2209
2210 int scolScene = MMget(m, 0);
2211 if(scolScene==NIL)
2212 {
2213 MMset(m, 0, NIL);
2214 return 0;
2215 }
2216
2217 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
2218 if(parentScene==0)
2219 {
2220 MMechostr(MSKDEBUG, "SO3WaterGetDepthParameters: Scene instance is NULL\n");
2221 MMset(m, 0, NIL);
2222 return 0;
2223 }
2224
2225 if (!parentScene->GetEnvironment())
2226 {
2227 MMset(m, 0, NIL);
2228 return 0;
2229 }
2230
2231 // Get depth parameters
2232 SWater* water = parentScene->GetEnvironment()->GetWater();
2233 if(water)
2234 {
2235 int tuple = MMmalloc(m, 2, TYPETAB);
2236 if(tuple==NIL)
2237 {
2238 MMset(m, 0, NIL);
2239 return MERRMEM;
2240 }
2241 MMstore(m, tuple, 0, FTOM(water->GetDepth()->GetDepthLimit()));
2242 MMstore(m, tuple, 1, FTOM(water->GetDepth()->GetDistanceLimit()));
2243 MMset(m, 0, PTOM(tuple));
2244 return 0;
2245 }
2246
2247 MMset(m, 0, NIL);
2248 return 0;
2249}
2250
2262{
2263#ifdef SO3_DEBUG
2264 MMechostr(MSKDEBUG, "SO3WaterSetDepthParameters\n");
2265#endif
2266
2267 int scolDistanceDepthLimit = MMpull(m);
2268 int scolDepthLimit = MMpull(m);
2269 int scolScene = MMget(m, 0);
2270 if(scolScene==NIL)
2271 {
2272 MMset(m, 0, NIL);
2273 return 0;
2274 }
2275
2276 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
2277 if(parentScene==0)
2278 {
2279 MMechostr(MSKDEBUG, "SO3WaterSetDepthParameters: Scene instance is NULL\n");
2280 MMset(m, 0, NIL);
2281 return 0;
2282 }
2283
2284 if (!parentScene->GetEnvironment())
2285 {
2286 MMset(m, 0, NIL);
2287 return 0;
2288 }
2289
2290 // Apply new depth limit.
2291 SWater* water = parentScene->GetEnvironment()->GetWater();
2292 if(water)
2293 {
2294 if(scolDepthLimit!=NIL)
2295 water->GetDepth()->SetDepthLimit(MTOF(scolDepthLimit));
2296
2297 if(scolDistanceDepthLimit!=NIL)
2298 water->GetDepth()->SetDistanceLimit(MTOF(scolDistanceDepthLimit));
2299 }
2300
2301 MMset(m, 0, ITOM(1));
2302 return 0;
2303}
2304
2314{
2315#ifdef SO3_DEBUG
2316 MMechostr(MSKDEBUG, "SO3WaterGetSmoothPower\n");
2317#endif
2318
2319 int scolScene = MMget(m, 0);
2320 if(scolScene==NIL)
2321 {
2322 MMset(m, 0, NIL);
2323 return 0;
2324 }
2325
2326 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
2327 if(parentScene==0)
2328 {
2329 MMechostr(MSKDEBUG, "SO3WaterGetSmoothPower: Scene instance is NULL\n");
2330 MMset(m, 0, NIL);
2331 return 0;
2332 }
2333
2334 if (!parentScene->GetEnvironment())
2335 {
2336 MMset(m, 0, NIL);
2337 return 0;
2338 }
2339
2340 // Get smooth power.
2341 SWater* water = parentScene->GetEnvironment()->GetWater();
2342 if(water)
2343 {
2344 MMset(m, 0, FTOM(water->GetSmooth()->GetPower()));
2345 return 0;
2346 }
2347
2348 MMset(m, 0, NIL);
2349 return 0;
2350}
2351
2362{
2363#ifdef SO3_DEBUG
2364 MMechostr(MSKDEBUG, "SO3WaterSetSmoothPower\n");
2365#endif
2366
2367 int scolSmoothPower = MMpull(m);
2368 int scolScene = MMget(m, 0);
2369
2370 // Check params
2371 if((scolSmoothPower==NIL)||(scolScene==NIL))
2372 {
2373 MMset(m, 0, NIL);
2374 return 0;
2375 }
2376
2377 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
2378 if(parentScene==0)
2379 {
2380 MMechostr(MSKDEBUG, "SO3WaterSetSmoothPower: Scene instance is NULL\n");
2381 MMset(m, 0, NIL);
2382 return 0;
2383 }
2384
2385 if (!parentScene->GetEnvironment())
2386 {
2387 MMset(m, 0, NIL);
2388 return 0;
2389 }
2390
2391 // Apply new smooth power.
2392 SWater* water = parentScene->GetEnvironment()->GetWater();
2393 if(water)
2394 water->GetSmooth()->SetPower(MTOF(scolSmoothPower));
2395
2396 MMset(m, 0, ITOM(1));
2397 return 0;
2398}
2399
2412{
2413#ifdef SO3_DEBUG
2414 MMechostr(MSKDEBUG, "SO3WaterGetCausticsParameters\n");
2415#endif
2416
2417 int scolScene = MMget(m, 0);
2418 if(scolScene==NIL)
2419 {
2420 MMset(m, 0, NIL);
2421 return 0;
2422 }
2423
2424 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
2425 if(parentScene==0)
2426 {
2427 MMechostr(MSKDEBUG, "SO3WaterGetCausticsParameters: Scene instance is NULL\n");
2428 MMset(m, 0, NIL);
2429 return 0;
2430 }
2431
2432 if (!parentScene->GetEnvironment())
2433 {
2434 MMset(m, 0, NIL);
2435 return 0;
2436 }
2437
2438 // Get caustics parameters.
2439 SWater* water = parentScene->GetEnvironment()->GetWater();
2440 if(water)
2441 {
2442 // Get caustics component.
2443 SWater::WaterComponentCaustics* caustics = water->GetCaustics();
2444
2445 // Store caustics scale
2446 MMpush(m, FTOM(caustics->GetScale()));
2447
2448 // Store caustics power
2449 MMpush(m, FTOM(caustics->GetPower()));
2450
2451 // Store caustics end
2452 MMpush(m, FTOM(caustics->GetEnd()));
2453
2454 // Create the final end
2455 int result = MMmalloc(m, 3, TYPETAB);
2456 if(result==NIL)
2457 return MERRMEM;
2458
2459 // Store all the values that were pushed on stack
2460 MMstore(m, result, 2, MMpull(m));
2461 MMstore(m, result, 1, MMpull(m));
2462 MMstore(m, result, 0, MMpull(m));
2463 MMset(m, 0, PTOM(result));
2464 return 0;
2465 }
2466
2467 MMset(m, 0, NIL);
2468 return 0;
2469}
2470
2483{
2484#ifdef SO3_DEBUG
2485 MMechostr(MSKDEBUG, "SO3WaterSetCausticsParameters\n");
2486#endif
2487
2488 int scolCausticsEnd = MMpull(m);
2489 int scolCausticsPower = MMpull(m);
2490 int scolCausticsScale = MMpull(m);
2491 int scolScene = MMget(m, 0);
2492 if(scolScene==NIL)
2493 {
2494 MMset(m, 0, NIL);
2495 return 0;
2496 }
2497
2498 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
2499 if(parentScene==0)
2500 {
2501 MMechostr(MSKDEBUG, "SO3WaterSetCausticsParameters: Scene instance is NULL\n");
2502 MMset(m, 0, NIL);
2503 return 0;
2504 }
2505
2506 if (!parentScene->GetEnvironment())
2507 {
2508 MMset(m, 0, NIL);
2509 return 0;
2510 }
2511
2512 // Set caustics parameters.
2513 SWater* water = parentScene->GetEnvironment()->GetWater();
2514 if(water)
2515 {
2516 // Get caustics component.
2517 SWater::WaterComponentCaustics* caustics = water->GetCaustics();
2518
2519 // Set caustics scale
2520 if(scolCausticsScale!=NIL)
2521 caustics->SetScale(MTOF(scolCausticsScale));
2522
2523 // Set caustics power
2524 if(scolCausticsPower!=NIL)
2525 caustics->SetPower(MTOF(scolCausticsPower));
2526
2527 // Set caustics end
2528 if(scolCausticsEnd!=NIL)
2529 caustics->SetEnd(MTOF(scolCausticsEnd));
2530 }
2531
2532 MMset(m, 0, ITOM(1));
2533 return 0;
2534}
2535
2551{
2552#ifdef SO3_DEBUG
2553 MMechostr(MSKDEBUG, "SO3WaterGetGodRaysParameters\n");
2554#endif
2555
2556 int scolScene = MMget(m, 0);
2557 if(scolScene==NIL)
2558 {
2559 MMset(m, 0, NIL);
2560 return 0;
2561 }
2562
2563 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
2564 if(parentScene==0)
2565 {
2566 MMechostr(MSKDEBUG, "SO3WaterGetGodRaysParameters: Scene instance is NULL\n");
2567 MMset(m, 0, NIL);
2568 return 0;
2569 }
2570
2571 if (!parentScene->GetEnvironment())
2572 {
2573 MMset(m, 0, NIL);
2574 return 0;
2575 }
2576
2577 // Get "god rays" parameters.
2578 SWater* water = parentScene->GetEnvironment()->GetWater();
2579 if(water)
2580 {
2581 // Get "god rays" component.
2582 SWater::WaterComponentGodRays* godRays = water->GetGodRays();
2583
2584 // Create a tuple for storing exposure
2585 int scolGodRaysExposure = MMmalloc(m, 3, TYPETAB);
2586 if(scolGodRaysExposure==NIL)
2587 return MERRMEM;
2588
2589 // Store exposure
2590 Ogre::Vector3 godRaysExposure = godRays->GetExposure();
2591 MMstore(m, scolGodRaysExposure, 0, FTOM(godRaysExposure.x));
2592 MMstore(m, scolGodRaysExposure, 1, FTOM(godRaysExposure.y));
2593 MMstore(m, scolGodRaysExposure, 2, FTOM(godRaysExposure.z));
2594 MMpush(m, PTOM(scolGodRaysExposure));
2595
2596 // Store intensity
2597 MMpush(m, FTOM(godRays->GetIntensity()));
2598
2599 // Store speed
2600 MMpush(m, FTOM(godRays->GetSpeed()));
2601
2602 // Store number of rays
2603 MMpush(m, ITOM(godRays->GetNumberOfRays()));
2604
2605 // Store ray size
2606 MMpush(m, FTOM(godRays->GetRaysSize()));
2607
2608 // Store object intersection
2609 if(godRays->GetRaysIntersectionEnable())
2610 MMpush(m, ITOM(1));
2611 else
2612 MMpush(m, ITOM(0));
2613
2614 // Create the final end
2615 int result = MMmalloc(m, 6, TYPETAB);
2616 if(result==NIL)
2617 return MERRMEM;
2618
2619 // Store all the values that were pushed on stack
2620 MMstore(m, result, 5, MMpull(m));
2621 MMstore(m, result, 4, MMpull(m));
2622 MMstore(m, result, 3, MMpull(m));
2623 MMstore(m, result, 2, MMpull(m));
2624 MMstore(m, result, 1, MMpull(m));
2625 MMstore(m, result, 0, MMpull(m));
2626 MMset(m, 0, PTOM(result));
2627 return 0;
2628 }
2629
2630 MMset(m, 0, NIL);
2631 return 0;
2632}
2633
2649{
2650#ifdef SO3_DEBUG
2651 MMechostr(MSKDEBUG, "SO3WaterSetGodRaysParameters\n");
2652#endif
2653
2654 int scolGodRaysObjectIntersect = MMpull(m);
2655 int scolGodRaysSize = MMpull(m);
2656 int scolGodRaysNumber = MMpull(m);
2657 int scolGodRaysSpeed = MMpull(m);
2658 int scolGodRaysIntensity = MMpull(m);
2659 int scolGodRaysExposure = MMpull(m);
2660 int scolScene = MMget(m, 0);
2661 if(scolScene==NIL)
2662 {
2663 MMset(m, 0, NIL);
2664 return 0;
2665 }
2666
2667 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
2668 if(parentScene==0)
2669 {
2670 MMechostr(MSKDEBUG, "SO3WaterSetGodRaysParameters: Scene instance is NULL\n");
2671 MMset(m, 0, NIL);
2672 return 0;
2673 }
2674
2675 if (!parentScene->GetEnvironment())
2676 {
2677 MMset(m, 0, NIL);
2678 return 0;
2679 }
2680
2681 // Set "god rays" parameters.
2682 SWater* water = parentScene->GetEnvironment()->GetWater();
2683 if(water)
2684 {
2685 // Get "god rays" component.
2686 SWater::WaterComponentGodRays* godRays = water->GetGodRays();
2687
2688 // Set god rays exposure
2689 if(scolGodRaysExposure!=NIL)
2690 {
2691 Ogre::Vector3 godRaysExposure;
2692 godRaysExposure.x = MTOF(MMfetch(m, MTOP(scolGodRaysExposure), 0));
2693 godRaysExposure.y = MTOF(MMfetch(m, MTOP(scolGodRaysExposure), 1));
2694 godRaysExposure.z = MTOF(MMfetch(m, MTOP(scolGodRaysExposure), 2));
2695 godRays->SetExposure(godRaysExposure);
2696 }
2697
2698 // Set god rays intensity
2699 if(scolGodRaysIntensity!=NIL)
2700 godRays->SetIntensity(MTOF(scolGodRaysIntensity));
2701
2702 // Set god rays speed
2703 if(scolGodRaysSpeed!=NIL)
2704 godRays->SetSpeed(MTOF(scolGodRaysSpeed));
2705
2706 // Set god rays numbers
2707 if(scolGodRaysNumber!=NIL)
2708 godRays->SetNumberOfRays(MTOI(scolGodRaysNumber));
2709
2710 // Set god rays size
2711 if(scolGodRaysSize!=NIL)
2712 godRays->SetRaysSize(MTOF(scolGodRaysSize));
2713
2714 // Set god rays object intersection
2715 if(scolGodRaysObjectIntersect!=NIL)
2716 if(MTOI(scolGodRaysObjectIntersect) == 1)
2717 godRays->SetRaysIntersectionEnable(true);
2718 else
2719 godRays->SetRaysIntersectionEnable(false);
2720 }
2721
2722 MMset(m, 0, ITOM(1));
2723 return 0;
2724}
2725
2742{
2743#ifdef SO3_DEBUG
2744 MMechostr(MSKDEBUG, "SO3WaterGetPerlinNoiseParameters\n");
2745#endif
2746
2747 int scolScene = MMget(m, 0);
2748 if(scolScene==NIL)
2749 {
2750 MMset(m, 0, NIL);
2751 return 0;
2752 }
2753
2754 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
2755 if(parentScene==0)
2756 {
2757 MMechostr(MSKDEBUG, "SO3WaterGetPerlinNoiseParameters: Scene instance is NULL\n");
2758 MMset(m, 0, NIL);
2759 return 0;
2760 }
2761
2762 if (!parentScene->GetEnvironment())
2763 {
2764 MMset(m, 0, NIL);
2765 return 0;
2766 }
2767
2768 // Get "god rays" parameters.
2769 SWater* water = parentScene->GetEnvironment()->GetWater();
2770 if(water)
2771 {
2772 // Get perlin parameters
2773 Hydrax::Noise::Perlin::Options perlinParameters = water->GetPerlinOptions();
2774
2775 // Store scale
2776 MMpush(m, FTOM(perlinParameters.Scale));
2777
2778 // Store octaves
2779 MMpush(m, ITOM(perlinParameters.Octaves));
2780
2781 // Store falloff
2782 MMpush(m, FTOM(perlinParameters.Falloff));
2783
2784 // Store animspeed
2785 MMpush(m, FTOM(perlinParameters.Animspeed));
2786
2787 // Store Timemulti
2788 MMpush(m, FTOM(perlinParameters.Timemulti));
2789
2790 // Create a tuple for storing GPU_LODParameters
2791 int scolGpuLodParameters = MMmalloc(m, 3, TYPETAB);
2792 if(scolGpuLodParameters==NIL)
2793 return MERRMEM;
2794
2795 // Store GPU_LODParameters
2796 MMstore(m, scolGpuLodParameters, 0, FTOM(perlinParameters.GPU_LODParameters.x));
2797 MMstore(m, scolGpuLodParameters, 1, FTOM(perlinParameters.GPU_LODParameters.y));
2798 MMstore(m, scolGpuLodParameters, 2, FTOM(perlinParameters.GPU_LODParameters.z));
2799 MMpush(m, PTOM(scolGpuLodParameters));
2800
2801 // Store GPU_Strength
2802 MMpush(m, FTOM(perlinParameters.GPU_Strength));
2803
2804 // Create the final end
2805 int result = MMmalloc(m, 7, TYPETAB);
2806 if(result==NIL)
2807 return MERRMEM;
2808
2809 // Store all the values that were pushed on stack
2810 MMstore(m, result, 6, MMpull(m));
2811 MMstore(m, result, 5, MMpull(m));
2812 MMstore(m, result, 4, MMpull(m));
2813 MMstore(m, result, 3, MMpull(m));
2814 MMstore(m, result, 2, MMpull(m));
2815 MMstore(m, result, 1, MMpull(m));
2816 MMstore(m, result, 0, MMpull(m));
2817 MMset(m, 0, PTOM(result));
2818 return 0;
2819 }
2820
2821 MMset(m, 0, NIL);
2822 return 0;
2823}
2824
2841{
2842#ifdef SO3_DEBUG
2843 MMechostr(MSKDEBUG, "SO3WaterSetPerlinNoiseParameters\n");
2844#endif
2845
2846 int scolPerlinGpuStrength = MMpull(m);
2847 int scolPerlinGpuLod = MMpull(m);
2848 int scolPerlinTimeMultiplier = MMpull(m);
2849 int scolPerlinAnimationSpeed = MMpull(m);
2850 int scolPerlinFallOff = MMpull(m);
2851 int scolPerlinOctaves = MMpull(m);
2852 int scolPerlinScale = MMpull(m);
2853 int scolScene = MMget(m, 0);
2854 if(scolScene==NIL)
2855 {
2856 MMset(m, 0, NIL);
2857 return 0;
2858 }
2859
2860 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
2861 if(parentScene==0)
2862 {
2863 MMechostr(MSKDEBUG, "SO3WaterSetPerlinNoiseParameters: Scene instance is NULL\n");
2864 MMset(m, 0, NIL);
2865 return 0;
2866 }
2867
2868 if (!parentScene->GetEnvironment())
2869 {
2870 MMset(m, 0, NIL);
2871 return 0;
2872 }
2873
2874 // Set perlin parameters.
2875 SWater* water = parentScene->GetEnvironment()->GetWater();
2876 if(water)
2877 {
2878 // Get perlin actual options.
2879 Hydrax::Noise::Perlin::Options perlinParameters = water->GetPerlinOptions();
2880
2881 // Set perlin scale
2882 if(scolPerlinScale!=NIL)
2883 perlinParameters.Scale = MTOF(scolPerlinScale);
2884
2885 // Set perlin octaves
2886 if(scolPerlinOctaves!=NIL)
2887 perlinParameters.Octaves = MTOI(scolPerlinOctaves);
2888
2889 // Set perlin fall off
2890 if(scolPerlinFallOff!=NIL)
2891 perlinParameters.Falloff = MTOF(scolPerlinFallOff);
2892
2893 // Set perlin animation speed
2894 if(scolPerlinAnimationSpeed!=NIL)
2895 perlinParameters.Animspeed = MTOF(scolPerlinAnimationSpeed);
2896
2897 // Set perlin time multiplier
2898 if(scolPerlinTimeMultiplier!=NIL)
2899 perlinParameters.Timemulti = MTOF(scolPerlinTimeMultiplier);
2900
2901 // Set perlin gpu lod
2902 if(scolPerlinGpuLod!=NIL)
2903 {
2904 perlinParameters.GPU_LODParameters.x = MTOF(MMfetch(m, MTOP(scolPerlinGpuLod), 0));
2905 perlinParameters.GPU_LODParameters.y = MTOF(MMfetch(m, MTOP(scolPerlinGpuLod), 1));
2906 perlinParameters.GPU_LODParameters.z = MTOF(MMfetch(m, MTOP(scolPerlinGpuLod), 2));
2907 }
2908
2909 // Set perlin gpu strength
2910 if(scolPerlinGpuStrength!=NIL)
2911 perlinParameters.GPU_Strength = MTOF(scolPerlinGpuStrength);
2912
2913 // Update noise params
2914 water->SetPerlinOptions(perlinParameters);
2915 }
2916
2917 MMset(m, 0, ITOM(1));
2918 return 0;
2919}
2920
2938{
2939#ifdef SO3_DEBUG
2940 MMechostr(MSKDEBUG, "SO3WaterGetFftNoiseParameters\n");
2941#endif
2942
2943 int scolScene = MMget(m, 0);
2944 if(scolScene==NIL)
2945 {
2946 MMset(m, 0, NIL);
2947 return 0;
2948 }
2949
2950 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
2951 if(parentScene==0)
2952 {
2953 MMechostr(MSKDEBUG, "SO3WaterGetFftNoiseParameters: Scene instance is NULL\n");
2954 MMset(m, 0, NIL);
2955 return 0;
2956 }
2957
2958 if (!parentScene->GetEnvironment())
2959 {
2960 MMset(m, 0, NIL);
2961 return 0;
2962 }
2963
2964 // Get "god rays" parameters.
2965 SWater* water = parentScene->GetEnvironment()->GetWater();
2966 if(water)
2967 {
2968 // Get fft parameters
2969 Hydrax::Noise::FFT::Options fftParameters = water->GetFFTOptions();
2970
2971 // Store scale
2972 MMpush(m, FTOM(fftParameters.Scale));
2973
2974 // Store animation speed
2975 MMpush(m, FTOM(fftParameters.AnimationSpeed));
2976
2977 // Store amplitude
2978 MMpush(m, FTOM(fftParameters.Amplitude));
2979
2980 // Store Kw param
2981 MMpush(m, FTOM(fftParameters.KwPower));
2982
2983 // Store resolution
2984 MMpush(m, ITOM(fftParameters.Resolution));
2985
2986 // Store physical resolution
2987 MMpush(m, FTOM(fftParameters.PhysicalResolution));
2988
2989 // Create a tuple for storing GPU_LODParameters
2990 int scolGpuLodParameters = MMmalloc(m, 3, TYPETAB);
2991 if(scolGpuLodParameters==NIL)
2992 return MERRMEM;
2993
2994 // Store GPU_LODParameters
2995 MMstore(m, scolGpuLodParameters, 0, FTOM(fftParameters.GPU_LODParameters.x));
2996 MMstore(m, scolGpuLodParameters, 1, FTOM(fftParameters.GPU_LODParameters.y));
2997 MMstore(m, scolGpuLodParameters, 2, FTOM(fftParameters.GPU_LODParameters.z));
2998 MMpush(m, PTOM(scolGpuLodParameters));
2999
3000 // Store GPU_Strength
3001 MMpush(m, FTOM(fftParameters.GPU_Strength));
3002
3003 // Create the final end
3004 int result = MMmalloc(m, 8, TYPETAB);
3005 if(result==NIL)
3006 return MERRMEM;
3007
3008 // Store all the values that were pushed on stack
3009 MMstore(m, result, 7, MMpull(m));
3010 MMstore(m, result, 6, MMpull(m));
3011 MMstore(m, result, 5, MMpull(m));
3012 MMstore(m, result, 4, MMpull(m));
3013 MMstore(m, result, 3, MMpull(m));
3014 MMstore(m, result, 2, MMpull(m));
3015 MMstore(m, result, 1, MMpull(m));
3016 MMstore(m, result, 0, MMpull(m));
3017 MMset(m, 0, PTOM(result));
3018 return 0;
3019 }
3020
3021 MMset(m, 0, NIL);
3022 return 0;
3023}
3024
3042{
3043#ifdef SO3_DEBUG
3044 MMechostr(MSKDEBUG, "SO3WaterSetFftNoiseParameters\n");
3045#endif
3046
3047 int scolFftGpuStrength = MMpull(m);
3048 int scolFftGpuLod = MMpull(m);
3049 int scolFftPhysicalResolution = MMpull(m);
3050 int scolFftResolution = MMpull(m);
3051 int scolFftKwPower = MMpull(m);
3052 int scolFftAmplitude = MMpull(m);
3053 int scolFftAnimationSpeed = MMpull(m);
3054 int scolFftScale = MMpull(m);
3055 int scolScene = MMget(m, 0);
3056 if(scolScene==NIL)
3057 {
3058 MMset(m, 0, NIL);
3059 return 0;
3060 }
3061
3062 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
3063 if(parentScene==0)
3064 {
3065 MMechostr(MSKDEBUG, "SO3WaterSetFftNoiseParameters: Scene instance is NULL\n");
3066 MMset(m, 0, NIL);
3067 return 0;
3068 }
3069
3070 if (!parentScene->GetEnvironment())
3071 {
3072 MMset(m, 0, NIL);
3073 return 0;
3074 }
3075
3076 // Set fft parameters.
3077 SWater* water = parentScene->GetEnvironment()->GetWater();
3078 if(water)
3079 {
3080 // Get fft actual options.
3081 Hydrax::Noise::FFT::Options fftParameters = water->GetFFTOptions();
3082
3083 // Set fft scale
3084 if(scolFftScale!=NIL)
3085 fftParameters.Scale = MTOF(scolFftScale);
3086
3087 // Set fft animation speed
3088 if(scolFftAnimationSpeed!=NIL)
3089 fftParameters.AnimationSpeed = MTOF(scolFftAnimationSpeed);
3090
3091 // Set fft amplitude
3092 if(scolFftAmplitude!=NIL)
3093 fftParameters.Amplitude = MTOF(scolFftAmplitude);
3094
3095 // Set fft kw power
3096 if(scolFftKwPower!=NIL)
3097 fftParameters.KwPower = MTOF(scolFftKwPower);
3098
3099 // Set fft resolution
3100 if(scolFftResolution!=NIL)
3101 fftParameters.Resolution = MTOI(scolFftResolution);
3102
3103 // Set fft physical resolution
3104 if(scolFftPhysicalResolution!=NIL)
3105 fftParameters.PhysicalResolution = MTOF(scolFftPhysicalResolution);
3106
3107 // Set fft gpu lod
3108 if(scolFftGpuLod!=NIL)
3109 {
3110 fftParameters.GPU_LODParameters.x = MTOF(MMfetch(m, MTOP(scolFftGpuLod), 0));
3111 fftParameters.GPU_LODParameters.y = MTOF(MMfetch(m, MTOP(scolFftGpuLod), 1));
3112 fftParameters.GPU_LODParameters.z = MTOF(MMfetch(m, MTOP(scolFftGpuLod), 2));
3113 }
3114
3115 // Set fft gpu strength
3116 if(scolFftGpuStrength!=NIL)
3117 fftParameters.GPU_Strength = MTOF(scolFftGpuStrength);
3118
3119 // Update noise params
3120 water->SetFFTOptions(fftParameters);
3121 }
3122
3123 MMset(m, 0, ITOM(1));
3124 return 0;
3125}
3126
3139{
3140#ifdef SO3_DEBUG
3141 MMechostr(MSKDEBUG, "SO3WaterGetWaveParameters\n");
3142#endif
3143
3144 int scolScene = MMget(m, 0);
3145 if(scolScene==NIL)
3146 {
3147 MMset(m, 0, NIL);
3148 return 0;
3149 }
3150
3151 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
3152 if(parentScene==0)
3153 {
3154 MMechostr(MSKDEBUG, "SO3WaterGetWaveParameters: Scene instance is NULL\n");
3155 MMset(m, 0, NIL);
3156 return 0;
3157 }
3158
3159 if (!parentScene->GetEnvironment())
3160 {
3161 MMset(m, 0, NIL);
3162 return 0;
3163 }
3164
3165 // Get water.
3166 SWater* water = parentScene->GetEnvironment()->GetWater();
3167 if(water)
3168 {
3169 int result = MMmalloc(m, 3, TYPETAB);
3170 if(result==NIL)
3171 return MERRMEM;
3172
3173 // Store all the values that were pushed on stack
3174 MMstore(m, result, 0, FTOM(water->GetInfinitePlaneStrength()));
3175 MMstore(m, result, 1, FTOM(water->GetInfinitePlaneElevation()));
3176 MMstore(m, result, 2, FTOM(water->GetInfinitePlaneChoppyStrength()));
3177 MMset(m, 0, PTOM(result));
3178
3179 return 0;
3180 }
3181
3182 MMset(m, 0, NIL);
3183 return 0;
3184}
3185
3198{
3199#ifdef SO3_DEBUG
3200 MMechostr(MSKDEBUG, "SO3WaterSetWaveParameters\n");
3201#endif
3202
3203 int scolChoppy = MMpull(m);
3204 int scolElevation = MMpull(m);
3205 int scolStrength = MMpull(m);
3206 int scolScene = MMget(m, 0);
3207 if(scolScene==NIL)
3208 {
3209 MMset(m, 0, NIL);
3210 return 0;
3211 }
3212
3213 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
3214 if(parentScene==0)
3215 {
3216 MMechostr(MSKDEBUG, "SO3WaterSetWaveParameters: Scene instance is NULL\n");
3217 MMset(m, 0, NIL);
3218 return 0;
3219 }
3220
3221 if (!parentScene->GetEnvironment())
3222 {
3223 MMset(m, 0, NIL);
3224 return 0;
3225 }
3226
3227 SWater* water = parentScene->GetEnvironment()->GetWater();
3228 if(water)
3229 {
3230 // Update wave params
3231 if (scolStrength != NIL)
3232 water->SetInfinitePlaneStrength(MTOF(scolStrength));
3233
3234 if (scolElevation != NIL)
3235 water->SetInfinitePlaneElevation(MTOF(scolElevation));
3236
3237 if (scolChoppy != NIL)
3238 water->SetInfinitePlaneChoppyStrength(MTOF(scolChoppy));
3239 }
3240
3241 MMset(m, 0, ITOM(1));
3242 return 0;
3243}
3244
3245
3255{
3256#ifdef SO3_DEBUG
3257 MMechostr(MSKDEBUG, "SO3WaterGetGeometryComplexity\n");
3258#endif
3259
3260 int scolScene = MMget(m, 0);
3261 if(scolScene==NIL)
3262 {
3263 MMset(m, 0, NIL);
3264 return 0;
3265 }
3266
3267 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
3268 if(parentScene==0)
3269 {
3270 MMechostr(MSKDEBUG, "SO3WaterGetGeometryComplexity: Scene instance is NULL\n");
3271 MMset(m, 0, NIL);
3272 return 0;
3273 }
3274
3275 if (!parentScene->GetEnvironment())
3276 {
3277 MMset(m, 0, NIL);
3278 return 0;
3279 }
3280
3281 // Get water.
3282 SWater* water = parentScene->GetEnvironment()->GetWater();
3283 if(water)
3284 {
3285 int result = MMmalloc(m, 3, TYPETAB);
3286 if(result==NIL)
3287 return MERRMEM;
3288
3289 // Store all the values that were pushed on stack
3290 MMset(m, 0, ITOM(static_cast<int>(water->GetInfinitePlaneComplexity())));
3291
3292 return 0;
3293 }
3294
3295 MMset(m, 0, NIL);
3296 return 0;
3297}
3298
3309{
3310#ifdef SO3_DEBUG
3311 MMechostr(MSKDEBUG, "SO3WaterSetGeometryComplexity\n");
3312#endif
3313
3314 int scolComplexity = MMpull(m);
3315 int scolScene = MMget(m, 0);
3316 if(scolScene==NIL)
3317 {
3318 MMset(m, 0, NIL);
3319 return 0;
3320 }
3321
3322 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
3323 if(parentScene==0)
3324 {
3325 MMechostr(MSKDEBUG, "SO3WaterSetGeometryComplexity: Scene instance is NULL\n");
3326 MMset(m, 0, NIL);
3327 return 0;
3328 }
3329
3330 if (!parentScene->GetEnvironment())
3331 {
3332 MMset(m, 0, NIL);
3333 return 0;
3334 }
3335
3336 SWater* water = parentScene->GetEnvironment()->GetWater();
3337 if(water)
3338 {
3339 // Update mesh params
3340 if (scolComplexity != NIL)
3341 {
3342 int complexity = 2;
3343 if (MTOI(scolComplexity) > 2)
3344 complexity = MTOI(scolComplexity);
3345
3346 water->SetInfinitePlaneComplexity(complexity);
3347 }
3348 }
3349
3350 MMset(m, 0, ITOM(1));
3351 return 0;
3352}
3353
3363{
3364#ifdef SO3_DEBUG
3365 MMechostr(MSKDEBUG, "SO3SkyGetAnimationSpeed\n");
3366#endif
3367
3368 int scolScene = MMget(m, 0);
3369 if(scolScene==NIL)
3370 {
3371 MMset(m, 0, NIL);
3372 return 0;
3373 }
3374
3375 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
3376 if(parentScene==0)
3377 {
3378 MMechostr(MSKDEBUG, "SO3SkyGetAnimationSpeed: Scene instance is NULL\n");
3379 MMset(m, 0, NIL);
3380 return 0;
3381 }
3382
3383 if (!parentScene->GetEnvironment())
3384 {
3385 MMset(m, 0, NIL);
3386 return 0;
3387 }
3388
3389 SSky* sky = parentScene->GetEnvironment()->GetSky();
3390 if(sky)
3391 {
3392 MMset(m, 0, FTOM(sky->GetAnimationSpeed()));
3393 return 0;
3394 }
3395
3396 MMset(m, 0, NIL);
3397 return 0;
3398}
3399
3400
3411{
3412#ifdef SO3_DEBUG
3413 MMechostr(MSKDEBUG, "SO3SkySetAnimationSpeed\n");
3414#endif
3415
3416 int scolSkyAnimationSpeed = MMpull(m);
3417 int scolScene = MMget(m, 0);
3418 if((scolScene==NIL)||(scolSkyAnimationSpeed==NIL))
3419 {
3420 MMset(m, 0, NIL);
3421 return 0;
3422 }
3423
3424 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
3425 if(parentScene==0)
3426 {
3427 MMechostr(MSKDEBUG, "SO3SkySetAnimationSpeed: Scene instance is NULL\n");
3428 MMset(m, 0, NIL);
3429 return 0;
3430 }
3431
3432 if (!parentScene->GetEnvironment())
3433 {
3434 MMset(m, 0, NIL);
3435 return 0;
3436 }
3437
3438 SSky* sky = parentScene->GetEnvironment()->GetSky();
3439 if(sky)
3440 {
3441 sky->SetAnimationSpeed(MTOF(scolSkyAnimationSpeed));
3442 MMset(m, 0, ITOM(1));
3443 return 0;
3444 }
3445
3446 MMset(m, 0, NIL);
3447 return 0;
3448}
3449
3458int SO3SkyGetHdrEnable(mmachine m)
3459{
3460#ifdef SO3_DEBUG
3461 MMechostr(MSKDEBUG, "SO3SkyGetHdrEnable\n");
3462#endif
3463
3464 int scolScene = MMget(m, 0);
3465 if(scolScene==NIL)
3466 {
3467 MMset(m, 0, NIL);
3468 return 0;
3469 }
3470
3471 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
3472 if(parentScene==0)
3473 {
3474 MMechostr(MSKDEBUG, "SO3SkyGetHdrEnable: Scene instance is NULL\n");
3475 MMset(m, 0, NIL);
3476 return 0;
3477 }
3478
3479 if (!parentScene->GetEnvironment())
3480 {
3481 MMset(m, 0, NIL);
3482 return 0;
3483 }
3484
3485 SSky* sky = parentScene->GetEnvironment()->GetSky();
3486 if(sky)
3487 {
3488 if(sky->GetHDREnable())
3489 MMset(m, 0, ITOM(1));
3490 else
3491 MMset(m, 0, ITOM(0));
3492 return 0;
3493 }
3494 MMset(m, 0, NIL);
3495 return 0;
3496}
3497
3507int SO3SkySetHdrEnable(mmachine m)
3508{
3509#ifdef SO3_DEBUG
3510 MMechostr(MSKDEBUG, "SO3SkySetHdrEnable\n");
3511#endif
3512
3513 int scolEnable = MMpull(m);
3514 int scolScene = MMget(m, 0);
3515 if(scolScene==NIL)
3516 {
3517 MMset(m, 0, NIL);
3518 return 0;
3519 }
3520
3521 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
3522 if(parentScene==0)
3523 {
3524 MMechostr(MSKDEBUG, "SO3SkySetHdrEnable: Scene instance is NULL\n");
3525 MMset(m, 0, NIL);
3526 return 0;
3527 }
3528
3529 if (!parentScene->GetEnvironment())
3530 {
3531 MMset(m, 0, NIL);
3532 return 0;
3533 }
3534
3535 SSky* sky = parentScene->GetEnvironment()->GetSky();
3536 if(sky)
3537 {
3538 bool enable = false;
3539 if(MTOI(scolEnable) == 1)
3540 enable = true;
3541
3542 sky->SetHDREnable(enable);
3543 MMset(m, 0, ITOM(1));
3544 return 0;
3545 }
3546 MMset(m, 0, NIL);
3547 return 0;
3548}
3549
3559{
3560#ifdef SO3_DEBUG
3561 MMechostr(MSKDEBUG, "SO3SkyGetCloudCeiling\n");
3562#endif
3563
3564 int scolScene = MMget(m, 0);
3565 if(scolScene==NIL)
3566 {
3567 MMset(m, 0, NIL);
3568 return 0;
3569 }
3570
3571 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
3572 if(parentScene==0)
3573 {
3574 MMechostr(MSKDEBUG, "SO3SkyGetCloudCeiling: Scene instance is NULL\n");
3575 MMset(m, 0, NIL);
3576 return 0;
3577 }
3578
3579 if (!parentScene->GetEnvironment())
3580 {
3581 MMset(m, 0, NIL);
3582 return 0;
3583 }
3584
3585 SSky* sky = parentScene->GetEnvironment()->GetSky();
3586 if(sky)
3587 {
3588 MMset(m, 0, FTOM(sky->GetCloudCeiling()));
3589 return 0;
3590 }
3591
3592 MMset(m, 0, NIL);
3593 return 0;
3594}
3595
3606{
3607#ifdef SO3_DEBUG
3608 MMechostr(MSKDEBUG, "SO3SkySetCloudCeiling\n");
3609#endif
3610
3611 int scolSkyCloudCeiling = MMpull(m);
3612 int scolScene = MMget(m, 0);
3613 if((scolScene==NIL)||(scolSkyCloudCeiling==NIL))
3614 {
3615 MMset(m, 0, NIL);
3616 return 0;
3617 }
3618
3619 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
3620 if(parentScene==0)
3621 {
3622 MMechostr(MSKDEBUG, "SO3SkySetCloudCeiling: Scene instance is NULL\n");
3623 MMset(m, 0, NIL);
3624 return 0;
3625 }
3626
3627 if (!parentScene->GetEnvironment())
3628 {
3629 MMset(m, 0, NIL);
3630 return 0;
3631 }
3632
3633 SSky* sky = parentScene->GetEnvironment()->GetSky();
3634 if(sky)
3635 {
3636 sky->SetCloudCeiling(MTOF(scolSkyCloudCeiling));
3637 }
3638
3639 MMset(m, 0, ITOM(1));
3640 return 0;
3641}
3642
3653{
3654#ifdef SO3_DEBUG
3655 MMechostr(MSKDEBUG, "SO3SkyAddLayeredCloud\n");
3656#endif
3657
3658 int scolScene = MMget(m, 0);
3659 if(scolScene==NIL)
3660 {
3661 MMset(m, 0, NIL);
3662 return 0;
3663 }
3664
3665 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
3666 if(parentScene==0)
3667 {
3668 MMechostr(MSKDEBUG, "SO3SkyAddLayeredCloud: Scene instance is NULL\n");
3669 MMset(m, 0, NIL);
3670 return 0;
3671 }
3672
3673 if (!parentScene->GetEnvironment())
3674 {
3675 MMset(m, 0, NIL);
3676 return 0;
3677 }
3678
3679 SSky* sky = parentScene->GetEnvironment()->GetSky();
3680 if(sky)
3681 {
3682 int layerIndex = sky->GetCloudLayered()->AddLayer();
3683 MMset(m, 0, ITOM(layerIndex));
3684 return 0;
3685 }
3686
3687 MMset(m, 0, NIL);
3688 return 0;
3689}
3690
3701{
3702#ifdef SO3_DEBUG
3703 MMechostr(MSKDEBUG, "SO3SkyRemoveLayeredCloud\n");
3704#endif
3705
3706 int scolLayerIndex = MMpull(m);
3707 int scolScene = MMget(m, 0);
3708 if((scolScene==NIL)||(scolLayerIndex==NIL))
3709 {
3710 MMset(m, 0, NIL);
3711 return 0;
3712 }
3713
3714 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
3715 if(parentScene==0)
3716 {
3717 MMechostr(MSKDEBUG, "SO3SkyAddLayeredCloud: Scene instance is NULL\n");
3718 MMset(m, 0, NIL);
3719 return 0;
3720 }
3721
3722 if (!parentScene->GetEnvironment())
3723 {
3724 MMset(m, 0, NIL);
3725 return 0;
3726 }
3727
3728 SSky* sky = parentScene->GetEnvironment()->GetSky();
3729 if(sky)
3730 {
3731 try
3732 {
3733 sky->GetCloudLayered()->RemoveLayer(MTOI(scolLayerIndex));
3734 MMset(m, 0, ITOM(1));
3735 return 0;
3736 }
3737 catch(const Ogre::Exception& e)
3738 {
3739 MMechostr(MSKDEBUG, "SO3SkyAddLayeredCloud: %s\n", e.getFullDescription().c_str());
3740 }
3741 }
3742
3743 MMset(m, 0, NIL);
3744 return 0;
3745}
3746
3756{
3757#ifdef SO3_DEBUG
3758 MMechostr(MSKDEBUG, "SO3SkyGetLayeredCloudIndexes\n");
3759#endif
3760
3761 int scolScene = MMget(m, 0);
3762 if(scolScene==NIL)
3763 {
3764 MMset(m, 0, NIL);
3765 return 0;
3766 }
3767
3768 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
3769 if(parentScene==0)
3770 {
3771 MMechostr(MSKDEBUG, "SO3SkyAddLayeredCloud: Scene instance is NULL\n");
3772 MMset(m, 0, NIL);
3773 return 0;
3774 }
3775
3776 if (!parentScene->GetEnvironment())
3777 {
3778 MMset(m, 0, NIL);
3779 return 0;
3780 }
3781
3782 //remove last param
3783 MMpull(m);
3784
3785 SSky* sky = parentScene->GetEnvironment()->GetSky();
3786 if(sky)
3787 {
3788 try
3789 {
3790 std::vector<int> layerIndexes = sky->GetCloudLayered()->GetLayerIndexes();
3791 if(layerIndexes.size() > 0)
3792 {
3793 // Push tuple values on stack
3794 std::vector<int>::iterator iLayerIndexes = layerIndexes.begin();
3795 while(iLayerIndexes != layerIndexes.end())
3796 {
3797 MMpush(m, ITOM(*iLayerIndexes));
3798 iLayerIndexes++;
3799 }
3800
3801 // Push tuple final value on stack
3802 if(MMpush(m, NIL))
3803 return MERRMEM;
3804
3805 // Build the recursive tuple
3806 for(unsigned int j=0; j<layerIndexes.size(); j++)
3807 {
3808 if(MMpush(m, 2*2))
3809 return MERRMEM;
3810
3811 if(int k=MBdeftab(m))
3812 return k;
3813 }
3814 return 0;
3815 }
3816 }
3817 catch(const Ogre::Exception& e)
3818 {
3819 MMechostr(MSKDEBUG, "SO3SkyAddLayeredCloud: %s\n", e.getFullDescription().c_str());
3820 }
3821 }
3822
3823 MMpush(m, NIL);
3824 return 0;
3825}
3826
3843{
3844#ifdef SO3_DEBUG
3845 MMechostr(MSKDEBUG, "SO3SkyGetLayeredCloudParameters\n");
3846#endif
3847
3848 int scolLayerIndex = MMpull(m);
3849 int scolScene = MMget(m, 0);
3850 if((scolScene==NIL)||(scolLayerIndex==NIL))
3851 {
3852 MMset(m, 0, NIL);
3853 return 0;
3854 }
3855
3856 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
3857 if(parentScene==0)
3858 {
3859 MMechostr(MSKDEBUG, "SO3SkyGetLayeredCloudParameters: Scene instance is NULL\n");
3860 MMset(m, 0, NIL);
3861 return 0;
3862 }
3863
3864 if (!parentScene->GetEnvironment())
3865 {
3866 MMset(m, 0, NIL);
3867 return 0;
3868 }
3869
3870 SSky* sky = parentScene->GetEnvironment()->GetSky();
3871 if(sky)
3872 {
3873 try
3874 {
3875 // Get layered cloud component.
3876 SSky::CloudLayered* layeredCloud = sky->GetCloudLayered();
3877 int cloudLayerIndex = MTOI(scolLayerIndex);
3878
3879 // Store height from cloud ceiling
3880 MMpush(m, FTOM(layeredCloud->GetHeightFromCloudCeiling(cloudLayerIndex)));
3881
3882 // Store scale
3883 MMpush(m, FTOM(layeredCloud->GetScale(cloudLayerIndex)));
3884
3885 // Store attenuation distance
3886 MMpush(m, FTOM(layeredCloud->GetAttenuationDistance(cloudLayerIndex)));
3887
3888 // Store attenuation detail
3889 MMpush(m, FTOM(layeredCloud->GetAttenuationDetail(cloudLayerIndex)));
3890
3891 // Store height volume
3892 MMpush(m, FTOM(layeredCloud->GetHeightVolume(cloudLayerIndex)));
3893
3894 // Store volumetric displacement
3895 MMpush(m, FTOM(layeredCloud->GetVolumetricDisplacement(cloudLayerIndex)));
3896
3897 // Create the final end
3898 int result = MMmalloc(m, 6, TYPETAB);
3899 if(result==NIL)
3900 return MERRMEM;
3901
3902 // Store all the values that were pushed on stack
3903 MMstore(m, result, 5, MMpull(m));
3904 MMstore(m, result, 4, MMpull(m));
3905 MMstore(m, result, 3, MMpull(m));
3906 MMstore(m, result, 2, MMpull(m));
3907 MMstore(m, result, 1, MMpull(m));
3908 MMstore(m, result, 0, MMpull(m));
3909 MMset(m, 0, PTOM(result));
3910 return 0;
3911 }
3912 catch(const Ogre::Exception& e)
3913 {
3914 MMechostr(MSKDEBUG, "SO3SkyGetLayeredCloudParameters: %s\n", e.getFullDescription().c_str());
3915 }
3916 }
3917
3918 MMset(m, 0, NIL);
3919 return 0;
3920}
3921
3938{
3939#ifdef SO3_DEBUG
3940 MMechostr(MSKDEBUG, "SO3SkySetLayeredCloudParameters\n");
3941#endif
3942
3943 int scolVolumetricDisplacement = MMpull(m);
3944 int scolHeightVolume = MMpull(m);
3945 int scolAttenuationDetail = MMpull(m);
3946 int scolAttenuationDistance = MMpull(m);
3947 int scolScale = MMpull(m);
3948 int scolheightFromCloudCeiling = MMpull(m);
3949 int scolLayerIndex = MMpull(m);
3950 int scolScene = MMget(m, 0);
3951 if((scolScene==NIL)||(scolLayerIndex==NIL))
3952 {
3953 MMset(m, 0, NIL);
3954 return 0;
3955 }
3956
3957 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
3958 if(parentScene==0)
3959 {
3960 MMechostr(MSKDEBUG, "SO3SkySetLayeredCloudParameters: Scene instance is NULL\n");
3961 MMset(m, 0, NIL);
3962 return 0;
3963 }
3964
3965 if (!parentScene->GetEnvironment())
3966 {
3967 MMset(m, 0, NIL);
3968 return 0;
3969 }
3970
3971 SSky* sky = parentScene->GetEnvironment()->GetSky();
3972 if(sky)
3973 {
3974 try
3975 {
3976 // Get layered cloud component.
3977 SSky::CloudLayered* layeredCloud = sky->GetCloudLayered();
3978 int cloudLayerIndex = MTOI(scolLayerIndex);
3979
3980 // height from cloud ceiling
3981 if(scolheightFromCloudCeiling != NIL)
3982 layeredCloud->SetHeightFromCloudCeiling(cloudLayerIndex, MTOF(scolheightFromCloudCeiling));
3983
3984 // scale
3985 if(scolScale != NIL)
3986 layeredCloud->SetScale(cloudLayerIndex, MTOF(scolScale));
3987
3988 // attenuation distance
3989 if(scolAttenuationDistance != NIL)
3990 layeredCloud->SetAttenuationDistance(cloudLayerIndex, MTOF(scolAttenuationDistance));
3991
3992 // attenuation detail
3993 if(scolAttenuationDetail != NIL)
3994 layeredCloud->SetAttenuationDetail(cloudLayerIndex, MTOF(scolAttenuationDetail));
3995
3996 // Update height volume
3997 if(scolHeightVolume != NIL)
3998 layeredCloud->SetHeightVolume(cloudLayerIndex, MTOF(scolHeightVolume));
3999
4000 // Update volumetric displacement
4001 if(scolVolumetricDisplacement != NIL)
4002 layeredCloud->SetHeightVolume(cloudLayerIndex, MTOF(scolVolumetricDisplacement));
4003
4004 MMset(m, 0, ITOM(1));
4005 return 0;
4006 }
4007 catch(const Ogre::Exception& e)
4008 {
4009 MMechostr(MSKDEBUG, "SO3SkySetLayeredCloudParameters: %s\n", e.getFullDescription().c_str());
4010 }
4011 }
4012
4013 MMset(m, 0, NIL);
4014 return 0;
4015}
4016
4026{
4027#ifdef SO3_DEBUG
4028 MMechostr(MSKDEBUG, "SO3SkyGetLightningEnable\n");
4029#endif
4030
4031 int scolScene = MMget(m, 0);
4032 if(scolScene==NIL)
4033 {
4034 MMset(m, 0, NIL);
4035 return 0;
4036 }
4037
4038 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
4039 if(parentScene==0)
4040 {
4041 MMechostr(MSKDEBUG, "SO3SkyGetLightningEnable: Scene instance is NULL\n");
4042 MMset(m, 0, NIL);
4043 return 0;
4044 }
4045
4046 if (!parentScene->GetEnvironment())
4047 {
4048 MMset(m, 0, NIL);
4049 return 0;
4050 }
4051
4052 SSky* sky = parentScene->GetEnvironment()->GetSky();
4053 if(sky)
4054 {
4055 if(sky->GetLightningEnable())
4056 MMset(m, 0, ITOM(1));
4057 else
4058 MMset(m, 0, ITOM(0));
4059 return 0;
4060 }
4061 MMset(m, 0, NIL);
4062 return 0;
4063}
4064
4075{
4076#ifdef SO3_DEBUG
4077 MMechostr(MSKDEBUG, "SO3SkySetLightningEnable\n");
4078#endif
4079
4080 int scolEnable = MMpull(m);
4081 int scolScene = MMget(m, 0);
4082 if(scolScene==NIL)
4083 {
4084 MMset(m, 0, NIL);
4085 return 0;
4086 }
4087
4088 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
4089 if(parentScene==0)
4090 {
4091 MMechostr(MSKDEBUG, "SO3SkySetLightningEnable: Scene instance is NULL\n");
4092 MMset(m, 0, NIL);
4093 return 0;
4094 }
4095
4096 if (!parentScene->GetEnvironment())
4097 {
4098 MMset(m, 0, NIL);
4099 return 0;
4100 }
4101
4102 SSky* sky = parentScene->GetEnvironment()->GetSky();
4103 if(sky)
4104 {
4105 bool enable = false;
4106 if(MTOI(scolEnable) == 1)
4107 enable = true;
4108
4109 sky->SetLightningEnable(enable);
4110 MMset(m, 0, ITOM(1));
4111 return 0;
4112 }
4113 MMset(m, 0, NIL);
4114 return 0;
4115}
4116
4128int SO3SkyAddLightning(mmachine m)
4129{
4130#ifdef SO3_DEBUG
4131 MMechostr(MSKDEBUG, "SO3SkyAddLightning\n");
4132#endif
4133
4134 int sLength = MMpull(m);
4135 int sDir = MMpull(m);
4136 int sPos = MMpull(m);
4137 int scolScene = MMget(m, 0);
4138 if ((scolScene == NIL) || (sPos == NIL) || (sDir == NIL) || (sLength == NIL))
4139 {
4140 MMset(m, 0, NIL);
4141 return 0;
4142 }
4143
4144 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
4145 if(parentScene==0)
4146 {
4147 MMechostr(MSKDEBUG, "SO3SkyAddLightning: Scene instance is NULL\n");
4148 MMset(m, 0, NIL);
4149 return 0;
4150 }
4151
4152 if (!parentScene->GetEnvironment())
4153 {
4154 MMset(m, 0, NIL);
4155 return 0;
4156 }
4157
4158 SSky* sky = parentScene->GetEnvironment()->GetSky();
4159 if(sky)
4160 {
4161 Ogre::Vector3 pos;
4162 pos.x = MTOF(MMfetch(m, MTOP(sPos), 0));
4163 pos.y = MTOF(MMfetch(m, MTOP(sPos), 1));
4164 pos.z = MTOF(MMfetch(m, MTOP(sPos), 2));
4165
4166 Ogre::Vector3 dir;
4167 dir.x = MTOF(MMfetch(m, MTOP(sDir), 0));
4168 dir.y = MTOF(MMfetch(m, MTOP(sDir), 1));
4169 dir.z = MTOF(MMfetch(m, MTOP(sDir), 2));
4170
4171 Ogre::Real length = MTOF(sLength);
4172
4173 sky->AddLightning(pos, dir, length);
4174 MMset(m, 0, ITOM(1));
4175 return 0;
4176 }
4177 MMset(m, 0, NIL);
4178 return 0;
4179}
4180
4193{
4194#ifdef SO3_DEBUG
4195 MMechostr(MSKDEBUG, "SO3SkyGetVolumetricCloudParameters\n");
4196#endif
4197
4198 // TODO
4199 return 0;
4200}
4201
4203{
4204#ifdef SO3_DEBUG
4205 MMechostr(MSKDEBUG, "SO3SkySetVolumetricCloudParameters\n");
4206#endif
4207
4208 // TODO
4209 return 0;
4210}
4211
4220int SO3SunGetLightColor(mmachine m)
4221{
4222#ifdef SO3_DEBUG
4223 MMechostr(MSKDEBUG, "SO3SunGetLightColor\n");
4224#endif
4225
4226 int scolScene = MMget(m, 0);
4227 if(scolScene==NIL)
4228 {
4229 MMset(m, 0, NIL);
4230 return 0;
4231 }
4232
4233 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
4234 if(parentScene==0)
4235 {
4236 MMechostr(MSKDEBUG, "SO3SunGetLightColor: Scene instance is NULL\n");
4237 MMset(m, 0, NIL);
4238 return 0;
4239 }
4240
4241 if (!parentScene->GetEnvironment())
4242 {
4243 MMset(m, 0, NIL);
4244 return 0;
4245 }
4246
4247 SSun* sun = parentScene->GetEnvironment()->GetSun();
4248 if(sun)
4249 {
4250 // Store the sun color
4251 MMset(m, 0, ITOM(ConversionTools::OgreToScolColorRGBA(sun->GetLightColour())));
4252 return 0;
4253 }
4254
4255 MMset(m, 0, NIL);
4256 return 0;
4257}
4258
4259
4269int SO3SunSetLightColor(mmachine m)
4270{
4271#ifdef SO3_DEBUG
4272 MMechostr(MSKDEBUG, "SO3SunSetLightColor\n");
4273#endif
4274
4275 int scolSunColor = MMpull(m);
4276 int scolScene = MMget(m, 0);
4277 if((scolScene==NIL)||(scolSunColor==NIL))
4278 {
4279 MMset(m, 0, NIL);
4280 return 0;
4281 }
4282
4283 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
4284 if(parentScene==0)
4285 {
4286 MMechostr(MSKDEBUG, "SO3SunSetLightColor: Scene instance is NULL\n");
4287 MMset(m, 0, NIL);
4288 return 0;
4289 }
4290
4291 if (!parentScene->GetEnvironment())
4292 {
4293 MMset(m, 0, NIL);
4294 return 0;
4295 }
4296
4297 SSun* sun = parentScene->GetEnvironment()->GetSun();
4298 if(sun)
4299 {
4300 sun->SetLightColour(ConversionTools::ScolToOgreColorRGBA(MTOI(scolSunColor)));
4301 MMset(m, 0, ITOM(1));
4302 return 0;
4303 }
4304
4305 MMset(m, 0, NIL);
4306 return 0;
4307}
4308
4318{
4319#ifdef SO3_DEBUG
4320 MMechostr(MSKDEBUG, "SO3MoonGetLightColor\n");
4321#endif
4322
4323 int scolScene = MMget(m, 0);
4324 if(scolScene==NIL)
4325 {
4326 MMset(m, 0, NIL);
4327 return 0;
4328 }
4329
4330 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
4331 if(parentScene==0)
4332 {
4333 MMechostr(MSKDEBUG, "SO3MoonGetLightColor: Scene instance is NULL\n");
4334 MMset(m, 0, NIL);
4335 return 0;
4336 }
4337
4338 if (!parentScene->GetEnvironment())
4339 {
4340 MMset(m, 0, NIL);
4341 return 0;
4342 }
4343
4344 SMoon* moon = parentScene->GetEnvironment()->GetMoon();
4345 if(moon)
4346 {
4347 // Store the moon color
4348 MMset(m, 0, ITOM(ConversionTools::OgreToScolColorRGBA(moon->GetLightColour())));
4349 return 0;
4350 }
4351
4352 MMset(m, 0, NIL);
4353 return 0;
4354}
4355
4366{
4367#ifdef SO3_DEBUG
4368 MMechostr(MSKDEBUG, "SO3MoonSetLightColor\n");
4369#endif
4370
4371 int scolMoonColor = MMpull(m);
4372 int scolScene = MMget(m, 0);
4373 if((scolScene==NIL)||(scolMoonColor==NIL))
4374 {
4375 MMset(m, 0, NIL);
4376 return 0;
4377 }
4378
4379 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
4380 if(parentScene==0)
4381 {
4382 MMechostr(MSKDEBUG, "SO3MoonSetLightColor: Scene instance is NULL\n");
4383 MMset(m, 0, NIL);
4384 return 0;
4385 }
4386
4387 if (!parentScene->GetEnvironment())
4388 {
4389 MMset(m, 0, NIL);
4390 return 0;
4391 }
4392
4393 SMoon* moon = parentScene->GetEnvironment()->GetMoon();
4394 if(moon)
4395 {
4396 moon->SetLightColour(ConversionTools::ScolToOgreColorRGBA(MTOI(scolMoonColor)));
4397 MMset(m, 0, ITOM(1));
4398 return 0;
4399 }
4400
4401 MMset(m, 0, NIL);
4402 return 0;
4403}
4404
4414{
4415#ifdef SO3_DEBUG
4416 MMechostr(MSKDEBUG, "SO3MoonGetTexturePath\n");
4417#endif
4418
4419 int scolScene = MMpull(m);
4420 if (scolScene==NIL)
4421 {
4422 MMpush(m, NIL);
4423 return 0;
4424 }
4425
4426 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
4427 if(parentScene==0)
4428 {
4429 MMechostr(MSKDEBUG, "SO3MoonGetTexturePath: Scene instance is NULL\n");
4430 MMpush(m, NIL);
4431 return 0;
4432 }
4433
4434 if (!parentScene->GetEnvironment())
4435 {
4436 MMset(m, 0, NIL);
4437 return 0;
4438 }
4439
4440 SMoon* moon = parentScene->GetEnvironment()->GetMoon();
4441 if(moon)
4442 {
4443 return Mpushstrbloc(m, (char*)moon->GetTextureName().c_str());
4444 }
4445
4446 MMpush(m, NIL);
4447 return 0;
4448}
4449
4460{
4461#ifdef SO3_DEBUG
4462 MMechostr(MSKDEBUG, "SO3MoonSetTexturePath\n");
4463#endif
4464
4465 int scolTexturePath = MMpull(m);
4466 int scolScene = MMget(m, 0);
4467 if (scolScene==NIL)
4468 {
4469 MMset(m, 0, NIL);
4470 return 0;
4471 }
4472
4473 if(scolTexturePath==NIL)
4474 {
4475 MMechostr(MSKDEBUG, "SO3MoonSetTexturePath: texture path not provided!\n");
4476 MMset(m, 0, NIL);
4477 }
4478
4479 SScene* parentScene = MMgetPointer<SScene*>(m, MTOP(scolScene));
4480 if(parentScene==0)
4481 {
4482 MMechostr(MSKDEBUG, "SO3MoonSetTexturePath: Scene instance is NULL\n");
4483 MMset(m, 0, NIL);
4484 return 0;
4485 }
4486
4487 if (!parentScene->GetEnvironment())
4488 {
4489 MMset(m, 0, NIL);
4490 return 0;
4491 }
4492
4493 std::string texturePath(MMstartstr(m, MTOP(scolTexturePath)));
4494 SMoon* moon = parentScene->GetEnvironment()->GetMoon();
4495 if(moon)
4496 {
4497 moon->SetTextureName(texturePath);
4498 MMset(m, 0, ITOM(1));
4499 }
4500
4501 MMset(m, 0, NIL);
4502 return 0;
4503}
4504
4505
4506NativeDefinition natSO3Env[] = {
4507 { "SO3EnvironmentRegisterViewport", 2, "fun [SO3_SCENE SO3_VIEWPORT] I", SO3EnvironmentRegisterViewport },
4508 { "SO3EnvironmentUnregisterViewport", 2, "fun [SO3_SCENE SO3_VIEWPORT] I", SO3EnvironmentUnregisterViewport },
4509 { "SO3EnvironmentGetRegisteredViewports", 1, "fun [SO3_SCENE] [SO3_VIEWPORT r1]", SO3EnvironmentGetRegisteredViewports },
4510 { "SO3EnvironmentGetEnable", 1, "fun [SO3_SCENE] I", SO3EnvironmentGetEnable },
4511 { "SO3EnvironmentSetEnable", 2, "fun [SO3_SCENE I] I", SO3EnvironmentSetEnable },
4512 { "SO3EnvironmentGetWindSpeed", 1, "fun [SO3_SCENE] F", SO3EnvironmentGetWindSpeed },
4513 { "SO3EnvironmentSetWindSpeed", 2, "fun [SO3_SCENE F] I", SO3EnvironmentSetWindSpeed },
4514 { "SO3EnvironmentGetWindDirection", 1, "fun [SO3_SCENE] [F F]", SO3EnvironmentGetWindDirection },
4515 { "SO3EnvironmentSetWindDirection", 3, "fun [SO3_SCENE F F] I", SO3EnvironmentSetWindDirection },
4516 { "SO3EnvironmentGetHumidity", 1, "fun [SO3_SCENE] F", SO3EnvironmentGetHumidity },
4517 { "SO3EnvironmentSetHumidity", 2, "fun [SO3_SCENE F] I", SO3EnvironmentSetHumidity },
4518 { "SO3EnvironmentGetTimeSpeedFactor", 1, "fun [SO3_SCENE] F", SO3EnvironmentGetTimeSpeedFactor },
4519 { "SO3EnvironmentSetTimeSpeedFactor", 2, "fun [SO3_SCENE F] I", SO3EnvironmentSetTimeSpeedFactor },
4520 { "SO3EnvironmentGetPaused", 1, "fun [SO3_SCENE] I", SO3EnvironmentGetPaused },
4521 { "SO3EnvironmentSetPaused", 2, "fun [SO3_SCENE I] I", SO3EnvironmentSetPaused },
4522 { "SO3EnvironmentGetDateTime", 1, "fun [SO3_SCENE] [I I I I I I]", SO3EnvironmentGetDateTime },
4523 { "SO3EnvironmentSetDateTime", 7, "fun [SO3_SCENE I I I I I I] I", SO3EnvironmentSetDateTime },
4524 { "SO3EnvironmentGetLongitude", 1, "fun [SO3_SCENE] F", SO3EnvironmentGetLongitude },
4525 { "SO3EnvironmentSetLongitude", 2, "fun [SO3_SCENE F] I", SO3EnvironmentSetLongitude },
4526 { "SO3EnvironmentGetLatitude", 1, "fun [SO3_SCENE] F", SO3EnvironmentGetLatitude },
4527 { "SO3EnvironmentSetLatitude", 2, "fun [SO3_SCENE F] I", SO3EnvironmentSetLatitude },
4528 { "SO3WaterGetEnable", 1, "fun [SO3_SCENE] I", SO3WaterGetEnable },
4529 { "SO3WaterSetEnable", 2, "fun [SO3_SCENE I] I", SO3WaterSetEnable },
4530 { "SO3SkyGetEnable", 1, "fun [SO3_SCENE] I", SO3SkyGetEnable },
4531 { "SO3SkySetEnable", 2, "fun [SO3_SCENE I] I", SO3SkySetEnable },
4532 { "SO3SunGetLightColor", 1, "fun [SO3_SCENE] I", SO3SunGetLightColor },
4533 { "SO3SunSetLightColor", 2, "fun [SO3_SCENE I] I", SO3SunSetLightColor },
4534 { "SO3MoonGetLightColor", 1, "fun [SO3_SCENE] I", SO3MoonGetLightColor },
4535 { "SO3MoonSetLightColor", 2, "fun [SO3_SCENE I] I", SO3MoonSetLightColor },
4536 { "SO3MoonGetTexturePath", 1, "fun [SO3_SCENE] S", SO3MoonGetTexturePath },
4537 { "SO3MoonSetTexturePath", 2, "fun [SO3_SCENE S] I", SO3MoonSetTexturePath },
4538 { "SO3WaterComponentGetEnabled", 2, "fun [SO3_SCENE I] I", SO3WaterComponentGetEnabled },
4539 { "SO3WaterComponentSetEnabled", 3, "fun [SO3_SCENE I I] I", SO3WaterComponentSetEnabled },
4540 { "SO3_WATER_COMPONENT_SUN", TYPVAR, "I", SCOL_TYPTYPE(SWater::SO3_WATER_COMPONENT_SUN) },
4541 { "SO3_WATER_COMPONENT_FOAM", TYPVAR, "I", SCOL_TYPTYPE(SWater::SO3_WATER_COMPONENT_FOAM) },
4542 { "SO3_WATER_COMPONENT_DEPTH", TYPVAR, "I", SCOL_TYPTYPE(SWater::SO3_WATER_COMPONENT_DEPTH) },
4543 { "SO3_WATER_COMPONENT_SMOOTH", TYPVAR, "I", SCOL_TYPTYPE(SWater::SO3_WATER_COMPONENT_SMOOTH) },
4544 { "SO3_WATER_COMPONENT_CAUSTICS", TYPVAR, "I", SCOL_TYPTYPE(SWater::SO3_WATER_COMPONENT_CAUSTICS) },
4545 { "SO3_WATER_COMPONENT_UNDERWATER", TYPVAR, "I", SCOL_TYPTYPE(SWater::SO3_WATER_COMPONENT_UNDERWATER) },
4546 { "SO3_WATER_COMPONENT_UNDERWATER_REFLECTIONS", TYPVAR, "I", SCOL_TYPTYPE(SWater::SO3_WATER_COMPONENT_UNDERWATER_REFLECTIONS) },
4547 { "SO3_WATER_COMPONENT_GODRAYS", TYPVAR, "I", SCOL_TYPTYPE(SWater::SO3_WATER_COMPONENT_GODRAYS) },
4548 { "SO3SkyComponentGetEnabled", 2, "fun [SO3_SCENE I] I", SO3SkyComponentGetEnabled },
4549 { "SO3SkyComponentSetEnabled", 3, "fun [SO3_SCENE I I] I", SO3SkyComponentSetEnabled },
4550 { "SO3_SKY_COMPONENT_LAYERER_CLOUD", TYPVAR, "I", SCOL_TYPTYPE(SSky::SO3_SKY_COMPONENT_LAYERER_CLOUD) },
4551 { "SO3_SKY_COMPONENT_VOLUMETRIC_CLOUD", TYPVAR, "I", SCOL_TYPTYPE(SSky::SO3_SKY_COMPONENT_VOLUMETRIC_CLOUD) },
4552 { "SO3WaterGetPosition", 1, "fun [SO3_SCENE] [F F F]", SO3WaterGetPosition },
4553 { "SO3WaterSetPosition", 2, "fun [SO3_SCENE [F F F]] I", SO3WaterSetPosition },
4554 { "SO3WaterGetColor", 1, "fun [SO3_SCENE] I", SO3WaterGetColor },
4555 { "SO3WaterSetColor", 2, "fun [SO3_SCENE I] I", SO3WaterSetColor },
4556 { "SO3WaterGetAnimationSpeed", 1, "fun [SO3_SCENE] F", SO3WaterGetAnimationSpeed },
4557 { "SO3WaterSetAnimationSpeed", 2, "fun [SO3_SCENE F] I", SO3WaterSetAnimationSpeed },
4558 { "SO3WaterGetSunParameters", 1, "fun [SO3_SCENE] [[F F F] F F I]", SO3WaterGetSunParameters },
4559 { "SO3WaterSetSunParameters", 5, "fun [SO3_SCENE [F F F] F F I] I", SO3WaterSetSunParameters },
4560 { "SO3WaterGetFoamParameters", 1, "fun [SO3_SCENE] [F F F F]", SO3WaterGetFoamParameters },
4561 { "SO3WaterSetFoamParameters", 5, "fun [SO3_SCENE F F F F] I", SO3WaterSetFoamParameters },
4562 { "SO3WaterGetDepthParameters", 1, "fun [SO3_SCENE] [F F]", SO3WaterGetDepthParameters },
4563 { "SO3WaterSetDepthParameters", 3, "fun [SO3_SCENE F F] I", SO3WaterSetDepthParameters },
4564 { "SO3WaterGetSmoothPower", 1, "fun [SO3_SCENE] F", SO3WaterGetSmoothPower },
4565 { "SO3WaterSetSmoothPower", 2, "fun [SO3_SCENE F] I", SO3WaterSetSmoothPower },
4566 { "SO3WaterGetCausticsParameters", 1, "fun [SO3_SCENE] [F F F]", SO3WaterGetCausticsParameters },
4567 { "SO3WaterSetCausticsParameters", 4, "fun [SO3_SCENE F F F] I", SO3WaterSetCausticsParameters },
4568 { "SO3WaterGetGodRaysParameters", 1, "fun [SO3_SCENE] [[F F F] F F I F I]", SO3WaterGetGodRaysParameters },
4569 { "SO3WaterSetGodRaysParameters", 7, "fun [SO3_SCENE [F F F] F F I F I] I", SO3WaterSetGodRaysParameters },
4570 { "SO3WaterGetPerlinNoiseParameters", 1, "fun [SO3_SCENE] [F I F F F [F F F] F]", SO3WaterGetPerlinNoiseParameters },
4571 { "SO3WaterSetPerlinNoiseParameters", 8, "fun [SO3_SCENE F I F F F [F F F] F] I", SO3WaterSetPerlinNoiseParameters },
4572 { "SO3WaterGetFftNoiseParameters", 1, "fun [SO3_SCENE] [F F F F I F [F F F] F]", SO3WaterGetFftNoiseParameters },
4573 { "SO3WaterSetFftNoiseParameters", 9, "fun [SO3_SCENE F F F F I F [F F F] F] I", SO3WaterSetFftNoiseParameters },
4574 { "SO3WaterSetWaveParameters", 4, "fun [SO3_SCENE F F F] I", SO3WaterSetWaveParameters },
4575 { "SO3WaterGetWaveParameters", 1, "fun [SO3_SCENE] [F F F]", SO3WaterGetWaveParameters },
4576 { "SO3WaterSetGeometryComplexity", 2, "fun [SO3_SCENE I] I", SO3WaterSetGeometryComplexity },
4577 { "SO3WaterGetGeometryComplexity", 1, "fun [SO3_SCENE] I", SO3WaterGetGeometryComplexity },
4578 { "SO3SkyGetAnimationSpeed", 1, "fun [SO3_SCENE] F", SO3SkyGetAnimationSpeed },
4579 { "SO3SkySetAnimationSpeed", 2, "fun [SO3_SCENE F] I", SO3SkySetAnimationSpeed },
4580 { "SO3SkyGetHdrEnable", 1, "fun [SO3_SCENE] I", SO3SkyGetHdrEnable },
4581 { "SO3SkySetHdrEnable", 2, "fun [SO3_SCENE I] I", SO3SkySetHdrEnable },
4582 { "SO3SkyGetCloudCeiling", 1, "fun [SO3_SCENE] F", SO3SkyGetCloudCeiling },
4583 { "SO3SkySetCloudCeiling", 2, "fun [SO3_SCENE F] I", SO3SkySetCloudCeiling },
4584 { "SO3SkyAddLayeredCloud", 1, "fun [SO3_SCENE] I", SO3SkyAddLayeredCloud },
4585 { "SO3SkyRemoveLayeredCloud", 2, "fun [SO3_SCENE I] I", SO3SkyRemoveLayeredCloud },
4586 { "SO3SkyGetLayeredCloudIndexes", 1, "fun [SO3_SCENE] [I r1]", SO3SkyGetLayeredCloudIndexes },
4587 { "SO3SkyGetLayeredCloudParameters", 2, "fun [SO3_SCENE I] [F F F F F F]", SO3SkyGetLayeredCloudParameters },
4588 { "SO3SkySetLayeredCloudParameters", 8, "fun [SO3_SCENE I F F F F F F] I", SO3SkySetLayeredCloudParameters },
4589 { "SO3SkyGetVolumetricCloudParameters", 1, "fun [SO3_SCENE] [F F]", SO3SkyGetVolumetricCloudParameters },
4590 { "SO3SkySetVolumetricCloudParameters", 3, "fun [SO3_SCENE F F] I", SO3SkySetVolumetricCloudParameters },
4591 { "SO3SkyGetLightningEnable", 1, "fun [SO3_SCENE] I", SO3SkyGetLightningEnable },
4592 { "SO3SkySetLightningEnable", 2, "fun [SO3_SCENE I] I", SO3SkySetLightningEnable },
4593 { "SO3SkyAddLightning", 4, "fun [SO3_SCENE [F F F] [F F F] F] I", SO3SkyAddLightning }
4594};
4595
4596
4602int SCOLloadEnvironment(mmachine m, cbmachine w)
4603{
4604 return PKhardpak2(m, "SO3Env.pkg", sizeof(natSO3Env) / sizeof(natSO3Env[0]), natSO3Env);
4605}
4606
4612{
4613 return 0;
4614}
int SCOLloadEnvironment(mmachine m, cbmachine w)
Load the SO3Engine Environment functions.
int SCOLfreeEnvironment()
free the SO3Engine environment functions
NativeDefinition natSO3Env[]
int SO3SkySetVolumetricCloudParameters(mmachine m)
int SO3SkyGetLightningEnable(mmachine m)
SO3SkyGetHdrEnable : Get the sky Lightning state.
MMechostr(MSKDEBUG, " > Start loading Plugin SO3Engine dll\n")
SCOL_EXPORT int cbmachine w
Definition SO3SCOL.cpp:5150
int SO3VPTYPE
Definition SO3SCOL.cpp:94
int SO3SkyGetEnable(mmachine m)
SO3SkyGetEnable :
int SO3WaterSetGodRaysParameters(mmachine m)
SO3WaterSetGodRaysParameters :
int SO3WaterSetAnimationSpeed(mmachine m)
SO3WaterSetAnimationSpeed :
int SO3SkySetAnimationSpeed(mmachine m)
SO3SkySetAnimationSpeed :
int SO3MoonSetLightColor(mmachine m)
SO3MoonSetLightColor :
int SO3WaterSetCausticsParameters(mmachine m)
SO3WaterSetCausticsParameters :
int SO3EnvironmentGetWindSpeed(mmachine m)
SO3EnvironmentGetWindSpeed :
int SO3SkyComponentGetEnabled(mmachine m)
SO3SkyComponentGetEnabled :
int SO3SkyGetHdrEnable(mmachine m)
SO3SkyGetHdrEnable :
int SO3EnvironmentSetTimeSpeedFactor(mmachine m)
SO3EnvironmentSetTimeSpeedFactor :
int SO3WaterGetPerlinNoiseParameters(mmachine m)
SO3WaterGetPerlinNoiseParameters :
int SO3EnvironmentGetLongitude(mmachine m)
SO3EnvironmentGetLongitude :
int SO3EnvironmentGetHumidity(mmachine m)
SO3EnvironmentGetHumidity :
int SO3SkySetEnable(mmachine m)
SO3SkySetEnable :
int SO3WaterSetFoamParameters(mmachine m)
SO3WaterSetFoamParameters :
int SO3SunSetLightColor(mmachine m)
SO3SunSetLightColor :
int SO3SkyGetLayeredCloudParameters(mmachine m)
SO3SkyGetLayeredCloudParameters :
int SO3WaterGetPosition(mmachine m)
SO3WaterGetPosition :
int SO3WaterGetDepthParameters(mmachine m)
SO3WaterGetDepthParameters :
int SO3WaterGetGeometryComplexity(mmachine m)
SO3WaterGetGeometryComplexity : Set the water mesh complexity.
int SO3EnvironmentGetTimeSpeedFactor(mmachine m)
SO3EnvironmentGetTimeSpeedFactor :
int SO3SkySetLayeredCloudParameters(mmachine m)
SO3SkySetLayeredCloudParameters :
int SO3WaterGetColor(mmachine m)
SO3WaterGetColor :
int SO3WaterGetEnable(mmachine m)
SO3WaterGetEnable :
int SO3EnvironmentUnregisterViewport(mmachine m)
SO3EnvironmentUnregisterViewport :
int SO3SunGetLightColor(mmachine m)
SO3SunGetLightColor :
int SO3WaterGetSunParameters(mmachine m)
SO3WaterGetSunParameters :
int SO3WaterSetPerlinNoiseParameters(mmachine m)
SO3WaterSetPerlinNoiseParameters :
int SO3WaterSetGeometryComplexity(mmachine m)
SO3WaterSetGeometryComplexity : Set the water mesh complexity.
int SO3WaterComponentSetEnabled(mmachine m)
SO3WaterComponentSetEnabled :
int SO3SkyAddLightning(mmachine m)
SO3SkyAddLightning : Set the sky Lightning state, the sky component must be set on SO3_SKY_COMPONENT_...
int SO3EnvironmentGetEnable(mmachine m)
SO3EnvironmentGetEnable :
int SO3SkyGetAnimationSpeed(mmachine m)
SO3SkyGetAnimationSpeed :
int SO3SkySetCloudCeiling(mmachine m)
SO3SkySetCloudCeiling :
int SO3WaterSetFftNoiseParameters(mmachine m)
SO3WaterSetFftNoiseParameters :
int SO3EnvironmentGetLatitude(mmachine m)
SO3EnvironmentGetLatitude :
int SO3WaterSetDepthParameters(mmachine m)
SO3WaterSetDepthParameters :
int SO3EnvironmentRegisterViewport(mmachine m)
main include
int SO3EnvironmentSetPaused(mmachine m)
SO3EnvironmentSetPaused :
int SO3WaterSetEnable(mmachine m)
SO3WaterSetEnable :
int SO3WaterSetColor(mmachine m)
SO3WaterSetColor :
int SO3EnvironmentSetLatitude(mmachine m)
SO3EnvironmentSetLatitude :
int SO3EnvironmentSetWindSpeed(mmachine m)
SO3EnvironmentSetWindSpeed :
int SO3SkyGetCloudCeiling(mmachine m)
SO3SkyGetCloudCeiling :
int SO3EnvironmentSetDateTime(mmachine m)
SO3EnvironmentSetDateTime :
int SO3WaterGetWaveParameters(mmachine m)
SO3WaterGetWaveParameters : Get the water mesh parameters.
int SO3EnvironmentGetPaused(mmachine m)
SO3EnvironmentGetPaused :
int SO3WaterGetFoamParameters(mmachine m)
SO3WaterGetFoamParameters :
int SO3MoonGetTexturePath(mmachine m)
SO3MoonGetLightColor :
int SO3MoonGetLightColor(mmachine m)
SO3MoonGetLightColor :
int SO3EnvironmentSetWindDirection(mmachine m)
SO3EnvironmentSetWindDirection :
int SO3WaterSetSmoothPower(mmachine m)
SO3WaterSetSmoothPower :
int SO3EnvironmentGetWindDirection(mmachine m)
SO3EnvironmentGetWindDirection :
int SO3SkyGetLayeredCloudIndexes(mmachine m)
SO3SkyGetLayeredCloudIndexes :
int SO3EnvironmentSetEnable(mmachine m)
SO3EnvironmentSetEnable :
int SO3WaterGetFftNoiseParameters(mmachine m)
SO3WaterGetFftNoiseParameters :
int SO3SkySetHdrEnable(mmachine m)
SO3SkySetHdrEnable :
int SO3SkyRemoveLayeredCloud(mmachine m)
SO3SkyAddLayeredCloud :
int SO3WaterGetSmoothPower(mmachine m)
SO3WaterGetSmoothPower :
int SO3SkySetLightningEnable(mmachine m)
SO3SkySetLightningEnable : Set the sky Lightning state, the sky component must be set on SO3_SKY_COMP...
int SO3WaterGetCausticsParameters(mmachine m)
SO3WaterGetCausticsParameters :
int SO3EnvironmentGetRegisteredViewports(mmachine m)
SO3EnvironmentGetRegisteredViewports :
int SO3EnvironmentSetLongitude(mmachine m)
SO3EnvironmentSetLongitude :
int SO3WaterSetPosition(mmachine m)
SO3WaterSetPosition :
int SO3WaterGetAnimationSpeed(mmachine m)
SO3WaterGetAnimationSpeed :
int SO3WaterGetGodRaysParameters(mmachine m)
SO3WaterGetGodRaysParameters :
int SO3MoonSetTexturePath(mmachine m)
SO3MoonSetTexturePath :
int SO3WaterComponentGetEnabled(mmachine m)
SO3WaterComponentGetEnabled :
int SO3WaterSetWaveParameters(mmachine m)
SO3WaterSetWaveParameters : Set the water mesh parameters.
int SO3SkyAddLayeredCloud(mmachine m)
SO3SkyAddLayeredCloud :
int SO3EnvironmentSetHumidity(mmachine m)
SO3EnvironmentSetHumidity :
int SO3SkyGetVolumetricCloudParameters(mmachine m)
SO3SkyGetVolumetricCloudParameters :
int SO3EnvironmentGetDateTime(mmachine m)
SO3EnvironmentGetDateTime :
int SO3WaterSetSunParameters(mmachine m)
SO3WaterSetSunParameters :
int SO3SkyComponentSetEnabled(mmachine m)
SO3SkyComponentSetEnabled :