SO3Engine
SCOLLight.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
34#include "SCOLPack/SO3SCOL.h"
35
36// Scene Graph includes
39
49int SO3LightCreate(mmachine m)
50{
51#ifdef SO3_DEBUG
52 MMechostr(MSKDEBUG, "SO3LightCreate\n");
53#endif
54
55 int name = MMpull(m);
56 int s = MMget(m, 0);
57 if (s==NIL)
58 {
59 MMset(m, 0, NIL);
60 return 0;
61 }
62
63 SScene* scene = MMgetPointer<SScene*>(m, MTOP(s));
64 if (scene==NULL)
65 {
66 MMset(m, 0, NIL);
67 return 0;
68 }
69
70 // Create Node
71 std::string tmpLightName(MMstartstr(m,MTOP(name)));
72 SLight* light = 0;
73
74 try
75 {
76 light = scene->CreateLight(tmpLightName);
77 }
78 catch(Ogre::Exception &e)
79 {
80 MMechostr(MSKDEBUG,"An exception has occurred : %s\n",e.what());
81 MMset(m, 0, NIL);
82 return 0;
83 }
84
85 // remove last param
86 MMpull(m);
87 return createObject(m, light, scene);
88}
89
90
105int SO3LightSetType(mmachine m)
106{
107#ifdef SO3_DEBUG
108 MMechostr(MSKDEBUG, "SO3LightSetType\n");
109#endif
110
111 int type = MMpull(m);
112 int l = MMget(m, 0);
113 if ((type==NIL)||(l==NIL))
114 {
115 MMechostr(MSKDEBUG, "l==NIL\n");
116 MMset(m, 0, NIL);
117 return 0;
118 }
119
120 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
121 if(node == 0)
122 {
123 MMset(m, 0, NIL);
124 return 0;
125 }
126
127 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
128 {
129 MMset(m, 0, NIL);
130 return 0;
131 }
132
133 SLight* light = static_cast<SLight*>(node);
134
135 light->SetType(static_cast <SLight::LightType> (MTOI(type)));
136
137 MMset(m, 0, ITOM(1));
138
139 return 0;
140}
141
142
157int SO3LightGetType(mmachine m)
158{
159#ifdef SO3_DEBUG
160 MMechostr(MSKDEBUG, "SO3LightGetType\n");
161#endif
162
163 int l = MMget(m, 0);
164 if(l==NIL)
165 {
166 MMechostr(MSKDEBUG, "l==NIL\n");
167 MMset(m, 0, NIL);
168 return 0;
169 }
170
171 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
172 if(node == 0)
173 {
174 MMset(m, 0, NIL);
175 return 0;
176 }
177
178 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
179 {
180 MMset(m, 0, NIL);
181 return 0;
182 }
183
184 SLight* light = static_cast<SLight*>(node);
185
186 int type = static_cast <int> (light->GetType());
187 MMset(m, 0, ITOM(type));
188 return 0;
189}
190
191
202{
203#ifdef SO3_DEBUG
204 MMechostr(MSKDEBUG, "SO3LightSetDiffuseColor\n");
205#endif
206
207 int diffuse = MMpull(m);
208 int l = MMget(m, 0);
209 if ((l==NIL)||(diffuse==NIL))
210 {
211 MMset(m, 0, NIL);
212 return 0;
213 }
214
215 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
216 if(node == 0)
217 {
218 MMset(m, 0, NIL);
219 return 0;
220 }
221
222 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
223 {
224 MMset(m, 0, NIL);
225 return 0;
226 }
227
228 SLight* light = static_cast<SLight*>(node);
229
230 light->SetDiffuseColour(MTOI(diffuse));
231 MMset(m, 0, ITOM(1));
232
233 return 0;
234}
235
245{
246#ifdef SO3_DEBUG
247 MMechostr(MSKDEBUG, "SO3LightGetDiffuseColor\n");
248#endif
249
250 int l = MMget(m, 0);
251 if (l==NIL)
252 {
253 MMset(m, 0, NIL);
254 return 0;
255 }
256
257 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
258 if(node == 0)
259 {
260 MMset(m, 0, NIL);
261 return 0;
262 }
263
264 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
265 {
266 MMset(m, 0, NIL);
267 return 0;
268 }
269
270 SLight* light = static_cast<SLight*>(node);
271 int val = light->GetDiffuseColour();
272 MMset(m, 0, ITOM(val));
273 return 0;
274}
275
276
287{
288#ifdef SO3_DEBUG
289 MMechostr(MSKDEBUG, "SO3LightSetPowerScale\n");
290#endif
291
292 int pow = MMpull(m);
293 int l = MMget(m, 0);
294 if ((l==NIL)||(pow==NIL))
295 {
296 MMset(m, 0, NIL);
297 return 0;
298 }
299
300 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
301 if(node == 0)
302 {
303 MMset(m, 0, NIL);
304 return 0;
305 }
306
307 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
308 {
309 MMset(m, 0, NIL);
310 return 0;
311 }
312
313 SLight* light = static_cast<SLight*>(node);
314
315 light->SetPowerScale(MTOF(pow));
316 MMset(m, 0, ITOM(1));
317
318 return 0;
319}
320
321
332{
333#ifdef SO3_DEBUG
334 MMechostr(MSKDEBUG, "SO3LightSetShadowFarDistance\n");
335#endif
336
337 int d = MMpull(m);
338 int l = MMget(m, 0);
339 if ((l==NIL)||(d==NIL))
340 {
341 MMset(m, 0, NIL);
342 return 0;
343 }
344
345 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
346 if(node == 0)
347 {
348 MMset(m, 0, NIL);
349 return 0;
350 }
351
352 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
353 {
354 MMset(m, 0, NIL);
355 return 0;
356 }
357
358 SLight* light = static_cast<SLight*>(node);
359
360 light->SetShadowFarDistance(MTOF(d));
361 MMset(m, 0, ITOM(1));
362
363 return 0;
364}
365
366
376{
377#ifdef SO3_DEBUG
378 MMechostr(MSKDEBUG, "SO3LightGetPowerScale\n");
379#endif
380
381 int l = MMget(m, 0);
382 if (l==NIL)
383 {
384 MMset(m, 0, NIL);
385 return 0;
386 }
387
388 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
389 if(node == 0)
390 {
391 MMset(m, 0, NIL);
392 return 0;
393 }
394
395 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
396 {
397 MMset(m, 0, NIL);
398 return 0;
399 }
400
401 SLight* light = static_cast<SLight*>(node);
402
403 float pow = light->GetPowerScale();
404 MMset(m, 0, FTOM(pow));
405
406 return 0;
407}
408
409
419{
420#ifdef SO3_DEBUG
421 MMechostr(MSKDEBUG, "SO3LightGetShadowFarDistance\n");
422#endif
423
424 int l = MMget(m, 0);
425 if (l==NIL)
426 {
427 MMset(m, 0, NIL);
428 return 0;
429 }
430
431 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
432 if(node == 0)
433 {
434 MMset(m, 0, NIL);
435 return 0;
436 }
437
438 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
439 {
440 MMset(m, 0, NIL);
441 return 0;
442 }
443
444 SLight* light = static_cast<SLight*>(node);
445
446 float d = light->GetShadowFarDistance();
447 MMset(m, 0, FTOM(d));
448
449 return 0;
450}
451
452
462int SO3LightSetVisible(mmachine m)
463{
464#ifdef SO3_DEBUG
465 MMechostr(MSKDEBUG, "SO3LightSetVisible\n");
466#endif
467
468 int v = MTOI(MMpull(m));
469 int l = MMget(m, 0);
470 if (l==NIL)
471 {
472 MMset(m, 0, 0);
473 return 0;
474 }
475
476 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
477 if(node == 0)
478 {
479 MMset(m, 0, NIL);
480 return 0;
481 }
482
483 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
484 {
485 MMset(m, 0, NIL);
486 return 0;
487 }
488
489 SLight* light = static_cast<SLight*>(node);
490
491 if (v==0)
492 light->SetVisible(false);
493 else
494 light->SetVisible(true);
495
496 MMset(m, 0, ITOM(1));
497 return 0;
498}
499
500
509int SO3LightGetVisible(mmachine m)
510{
511#ifdef SO3_DEBUG
512 MMechostr(MSKDEBUG, "SO3LightGetVisible\n");
513#endif
514
515 int l = MMget(m, 0);
516 if (l==NIL)
517 {
518 MMset(m, 0, NIL);
519 return 0;
520 }
521
522 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
523 if(node == 0)
524 {
525 MMset(m, 0, NIL);
526 return 0;
527 }
528
529 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
530 {
531 MMset(m, 0, NIL);
532 return 0;
533 }
534
535 SLight* light = static_cast<SLight*>(node);
536
537 int val = 0;
538
539 if (light->GetVisible())
540 val = 1;
541
542 MMset(m, 0, ITOM(val));
543
544 return 0;
545}
546
547
558{
559#ifdef SO3_DEBUG
560 MMechostr(MSKDEBUG, "SO3LightSetVolumetric\n");
561#endif
562
563 int v = MTOI(MMpull(m));
564 int l = MMget(m, 0);
565 if (l==NIL)
566 {
567 MMset(m, 0, 0);
568 return 0;
569 }
570
571 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
572 if(node == 0)
573 {
574 MMset(m, 0, NIL);
575 return 0;
576 }
577
578 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
579 {
580 MMset(m, 0, NIL);
581 return 0;
582 }
583
584 SLight* light = static_cast<SLight*>(node);
585
586 if (v==0)
587 light->SetVolumetric(false);
588 else
589 light->SetVolumetric(true);
590
591 MMset(m, 0, ITOM(1));
592 return 0;
593}
594
595
605{
606#ifdef SO3_DEBUG
607 MMechostr(MSKDEBUG, "SO3LightGetVolumetric\n");
608#endif
609
610 int l = MMget(m, 0);
611 if (l==NIL)
612 {
613 MMset(m, 0, NIL);
614 return 0;
615 }
616
617 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
618 if(node == 0)
619 {
620 MMset(m, 0, NIL);
621 return 0;
622 }
623
624 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
625 {
626 MMset(m, 0, NIL);
627 return 0;
628 }
629
630 SLight* light = static_cast<SLight*>(node);
631
632 int val = 0;
633
634 if (light->GetVolumetric())
635 val = 1;
636
637 MMset(m, 0, ITOM(val));
638
639 return 0;
640}
641
642
653{
654#ifdef SO3_DEBUG
655 MMechostr(MSKDEBUG, "SO3LightSetAttenuation\n");
656#endif
657
658 int param = MMpull(m);
659 int l = MMget(m, 0);
660 if ((l==NIL)||(param==NIL))
661 {
662 MMset(m, 0, NIL);
663 return 0;
664 }
665
666 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
667 if(node == 0)
668 {
669 MMset(m, 0, NIL);
670 return 0;
671 }
672
673 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
674 {
675 MMset(m, 0, NIL);
676 return 0;
677 }
678
679 SLight* light = static_cast<SLight*>(node);
680
681 light->SetAttenuation(MTOF(MMfetch(m, MTOI(param), 0)),
682 MTOF(MMfetch(m, MTOI(param), 1)),
683 MTOF(MMfetch(m, MTOI(param), 2)),
684 MTOF(MMfetch(m, MTOI(param), 3)));
685
686 MMset(m, 0, ITOM(1));
687 return 0;
688}
689
690
701{
702#ifdef SO3_DEBUG
703 MMechostr(MSKDEBUG, "SO3LightSetAttenuationAuto\n");
704#endif
705
706 int irange = MMpull(m);
707 int l = MMget(m, 0);
708 if ((irange == NIL) || (l == NIL))
709 {
710 MMset(m, 0, NIL);
711 return 0;
712 }
713
714 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
715 if(node == 0)
716 {
717 MMset(m, 0, NIL);
718 return 0;
719 }
720
721 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
722 {
723 MMset(m, 0, NIL);
724 return 0;
725 }
726
727 SLight* light = static_cast<SLight*>(node);
728 light->SetAttenuation(MTOF(irange));
729 MMset(m, 0, ITOM(1));
730 return 0;
731}
732
733
734
744{
745#ifdef SO3_DEBUG
746 MMechostr(MSKDEBUG, "SO3LightGetAttenuation\n");
747#endif
748
749 int l = MMget(m, 0);
750 if (l==NIL)
751 {
752 MMset(m, 0, NIL);
753 return 0;
754 }
755
756 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
757 if(node == 0)
758 {
759 MMset(m, 0, NIL);
760 return 0;
761 }
762
763 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
764 {
765 MMset(m, 0, NIL);
766 return 0;
767 }
768
769 SLight* light = static_cast<SLight*>(node);
770
771 Ogre::Vector4 attenuation = light->GetAttenuation();
772
773 int tuple = MMmalloc(m, 4, TYPETAB);
774 if (tuple==NIL)
775 {
776 MMset(m, 0, NIL);
777 return MERRMEM;
778 }
779
780 MMstore(m, tuple, 0, FTOM(attenuation.x));
781 MMstore(m, tuple, 1, FTOM(attenuation.y));
782 MMstore(m, tuple, 2, FTOM(attenuation.z));
783 MMstore(m, tuple, 3, FTOM(attenuation.w));
784 MMset(m, 0, PTOM(tuple));
785
786 return 0;
787}
788
789
800{
801#ifdef SO3_DEBUG
802 MMechostr(MSKDEBUG, "SO3LightSetSpecularColor\n");
803#endif
804
805 int specular = MMpull(m);
806 int l = MMget(m, 0);
807 if ((l==NIL)||(specular==NIL))
808 {
809 MMset(m, 0, NIL);
810 return 0;
811 }
812
813 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
814 if(node == 0)
815 {
816 MMset(m, 0, NIL);
817 return 0;
818 }
819
820 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
821 {
822 MMset(m, 0, NIL);
823 return 0;
824 }
825
826 SLight* light = static_cast<SLight*>(node);
827
828 light->SetSpecularColour(MTOI(specular));
829
830 MMset(m, 0, ITOM(1));
831
832 return 0;
833}
834
835
845{
846#ifdef SO3_DEBUG
847 MMechostr(MSKDEBUG, "SO3LightGetSpecularColor\n");
848#endif
849
850 int l = MMget(m, 0);
851 if (l==NIL)
852 {
853 MMset(m, 0, NIL);
854 return 0;
855 }
856
857 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
858 if(node == 0)
859 {
860 MMset(m, 0, NIL);
861 return 0;
862 }
863
864 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
865 {
866 MMset(m, 0, NIL);
867 return 0;
868 }
869
870 SLight* light = static_cast<SLight*>(node);
871
872 int val = light->GetSpecularColour();
873 MMset(m, 0, ITOM(val));
874
875 return 0;
876}
877
878
889{
890#ifdef SO3_DEBUG
891 MMechostr(MSKDEBUG, "SO3LightSetSpotFallOff\n");
892#endif
893
894 int fal = MMpull(m);
895 int l = MMget(m, 0);
896 if ((l==NIL)||(fal==NIL))
897 {
898 MMset(m, 0, NIL);
899 return 0;
900 }
901
902 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
903 if(node == 0)
904 {
905 MMset(m, 0, NIL);
906 return 0;
907 }
908
909 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
910 {
911 MMset(m, 0, NIL);
912 return 0;
913 }
914
915 SLight* light = static_cast<SLight*>(node);
916
917 light->SetSpotlightFalloff(MTOF(fal));
918 MMset(m, 0, ITOM(1));
919
920 return 0;
921}
922
923
933{
934#ifdef SO3_DEBUG
935 MMechostr(MSKDEBUG, "SO3LightGetSpotFallOff\n");
936#endif
937
938 int l = MMget(m, 0);
939 if (l==NIL)
940 {
941 MMset(m, 0, NIL);
942 return 0;
943 }
944
945 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
946 if(node == 0)
947 {
948 MMset(m, 0, NIL);
949 return 0;
950 }
951
952 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
953 {
954 MMset(m, 0, NIL);
955 return 0;
956 }
957
958 SLight* light = static_cast<SLight*>(node);
959
960 float f = light->GetSpotlightFalloff();
961 MMset(m, 0, FTOM(f));
962
963 return 0;
964}
965
966
977{
978#ifdef SO3_DEBUG
979 MMechostr(MSKDEBUG, "SO3LightSetSpotInnerAngle\n");
980#endif
981
982 int ang = MMpull(m);
983 int l = MMget(m, 0);
984 if ((l==NIL)||(ang==NIL))
985 {
986 MMset(m, 0, NIL);
987 return 0;
988 }
989
990 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
991 if(node == 0)
992 {
993 MMset(m, 0, NIL);
994 return 0;
995 }
996
997 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
998 {
999 MMset(m, 0, NIL);
1000 return 0;
1001 }
1002
1003 SLight* light = static_cast<SLight*>(node);
1004
1005 light->SetSpotlightInnerAngle(MTOF(ang));
1006
1007 MMset(m, 0, ITOM(1));
1008
1009 return 0;
1010}
1011
1012
1023{
1024#ifdef SO3_DEBUG
1025 MMechostr(MSKDEBUG, "SO3LightSetSpotOuterAngle\n");
1026#endif
1027
1028 int ang = MMpull(m);
1029 int l = MMget(m, 0);
1030 if ((l==NIL)||(ang==NIL))
1031 {
1032 MMset(m, 0, NIL);
1033 return 0;
1034 }
1035
1036 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
1037 if(node == 0)
1038 {
1039 MMset(m, 0, NIL);
1040 return 0;
1041 }
1042
1043 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
1044 {
1045 MMset(m, 0, NIL);
1046 return 0;
1047 }
1048
1049 SLight* light = static_cast<SLight*>(node);
1050
1051 light->SetSpotlightOuterAngle(MTOF(ang));
1052
1053 MMset(m, 0, ITOM(1));
1054
1055 return 0;
1056}
1057
1058
1069{
1070#ifdef SO3_DEBUG
1071 MMechostr(MSKDEBUG, "SO3LightSetSpotRange\n");
1072#endif
1073
1074 int param = MMpull(m);
1075 int l = MMget(m, 0);
1076 if ((l==NIL)||(param==NIL))
1077 {
1078 MMset(m, 0, NIL);
1079 return 0;
1080 }
1081
1082 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
1083 if(node == 0)
1084 {
1085 MMset(m, 0, NIL);
1086 return 0;
1087 }
1088
1089 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
1090 {
1091 MMset(m, 0, NIL);
1092 return 0;
1093 }
1094
1095 SLight* light = static_cast<SLight*>(node);
1096
1097 if((MMfetch(m,MTOP(param),0)==NIL) || (MMfetch(m,MTOP(param),1)==NIL) || (MMfetch(m,MTOP(param),2)==NIL))
1098 {
1099 MMset(m, 0, NIL);
1100 return 0;
1101 }
1102
1103 light->SetSpotlightInnerAngle(MTOF(MMfetch(m, MTOP(param), 0)));
1104 light->SetSpotlightOuterAngle(MTOF(MMfetch(m, MTOP(param), 1)));
1105 light->SetSpotlightFalloff(MTOF(MMfetch(m, MTOP(param), 2)));
1106
1107 MMset(m, 0, ITOM(1));
1108
1109 return 0;
1110}
1111
1112
1122{
1123#ifdef SO3_DEBUG
1124 MMechostr(MSKDEBUG, "SO3LightGetSpotInnerAngle\n");
1125#endif
1126
1127 int l = MMget(m, 0);
1128 if (l==NIL)
1129 {
1130 MMset(m, 0, NIL);
1131 return 0;
1132 }
1133
1134 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
1135 if(node == 0)
1136 {
1137 MMset(m, 0, NIL);
1138 return 0;
1139 }
1140
1141 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
1142 {
1143 MMset(m, 0, NIL);
1144 return 0;
1145 }
1146
1147 SLight* light = static_cast<SLight*>(node);
1148
1149 float inner = light->GetSpotlightInnerAngle();
1150 MMset(m, 0, FTOM(inner));
1151
1152 return 0;
1153}
1154
1155
1165{
1166#ifdef SO3_DEBUG
1167 MMechostr(MSKDEBUG, "SO3LightGetSpotOuterAngle\n");
1168#endif
1169
1170 int l = MMget(m, 0);
1171 if (l==NIL)
1172 {
1173 MMset(m, 0, NIL);
1174 return 0;
1175 }
1176
1177 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
1178 if(node == 0)
1179 {
1180 MMset(m, 0, NIL);
1181 return 0;
1182 }
1183
1184 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
1185 {
1186 MMset(m, 0, NIL);
1187 return 0;
1188 }
1189
1190 SLight* light = static_cast<SLight*>(node);
1191
1192 float f = light->GetSpotlightOuterAngle();
1193 MMset(m, 0, FTOM(f));
1194
1195 return 0;
1196}
1197
1198
1209{
1210#ifdef SO3_DEBUG
1211 MMechostr(MSKDEBUG, "SO3LightSetSourceSize\n");
1212#endif
1213
1214 int param = MMpull(m);
1215 int l = MMget(m, 0);
1216 if ((l == NIL) || (param == NIL))
1217 {
1218 MMset(m, 0, NIL);
1219 return 0;
1220 }
1221
1222 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
1223 if (node == 0)
1224 {
1225 MMset(m, 0, NIL);
1226 return 0;
1227 }
1228
1229 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
1230 {
1231 MMset(m, 0, NIL);
1232 return 0;
1233 }
1234
1235 SLight* light = static_cast<SLight*>(node);
1236 if ((MMfetch(m, MTOP(param), 0) == NIL) || (MMfetch(m, MTOP(param), 1) == NIL))
1237 {
1238 MMset(m, 0, NIL);
1239 return 0;
1240 }
1241
1242 light->SetSourceSize(MTOF(MMfetch(m, MTOP(param), 0)), MTOF(MMfetch(m, MTOP(param), 1)));
1243 MMset(m, 0, ITOM(1));
1244
1245 return 0;
1246}
1247
1248
1258{
1259#ifdef SO3_DEBUG
1260 MMechostr(MSKDEBUG, "SO3LightGetSourceSize\n");
1261#endif
1262
1263 int l = MMget(m, 0);
1264 if (l == NIL)
1265 {
1266 MMset(m, 0, NIL);
1267 return 0;
1268 }
1269
1270 SNode* node = MMgetPointer<SNode*>(m, MTOP(l));
1271 if (node == 0)
1272 {
1273 MMset(m, 0, NIL);
1274 return 0;
1275 }
1276
1277 if (node->GetNodeType() != SNode::LIGHT_TYPE_ID)
1278 {
1279 MMset(m, 0, NIL);
1280 return 0;
1281 }
1282
1283 SLight* light = static_cast<SLight*>(node);
1284 Ogre::Vector2f src = light->GetSourceSize();
1285
1286 int tuple = MMmalloc(m, 2, TYPETAB);
1287 if (tuple == NIL)
1288 {
1289 MMset(m, 0, NIL);
1290 return MERRMEM;
1291 }
1292
1293 MMstore(m, tuple, 0, FTOM(src.x));
1294 MMstore(m, tuple, 1, FTOM(src.y));
1295 MMset(m, 0, PTOM(tuple));
1296
1297 return 0;
1298}
1299
1300
1301NativeDefinition natSO3Light[] = {
1302 { "SO3LightCreate", 2, "fun [SO3_SCENE S] SO3_OBJECT", SO3LightCreate },
1303 { "SO3LightSetType", 2, "fun [SO3_OBJECT I] I", SO3LightSetType },
1304 { "SO3LightGetType", 1, "fun [SO3_OBJECT] I", SO3LightGetType },
1305 { "SO3LightSetDiffuseColor", 2, "fun [SO3_OBJECT I] I", SO3LightSetDiffuseColor },
1306 { "SO3LightGetDiffuseColor", 1, "fun [SO3_OBJECT] I", SO3LightGetDiffuseColor },
1307 { "SO3LightSetPowerScale", 2, "fun [SO3_OBJECT F] I", SO3LightSetPowerScale },
1308 { "SO3LightSetShadowFarDistance", 2, "fun [SO3_OBJECT F] I", SO3LightSetShadowFarDistance },
1309 { "SO3LightGetPowerScale", 1, "fun [SO3_OBJECT] F", SO3LightGetPowerScale },
1310 { "SO3LightGetShadowFarDistance", 1, "fun [SO3_OBJECT] F", SO3LightGetShadowFarDistance },
1311 { "SO3LightSetVisible", 2, "fun [SO3_OBJECT I] I", SO3LightSetVisible },
1312 { "SO3LightGetVisible", 1, "fun [SO3_OBJECT] I", SO3LightGetVisible },
1313 { "SO3LightSetAttenuation", 2, "fun [SO3_OBJECT [F F F F]] I", SO3LightSetAttenuation },
1314 { "SO3LightSetAttenuationAuto", 2, "fun [SO3_OBJECT F] I", SO3LightSetAttenuationAuto },
1315 { "SO3LightGetAttenuation", 1, "fun [SO3_OBJECT] [F F F F]", SO3LightGetAttenuation },
1316 { "SO3LightSetSpecularColor", 2, "fun [SO3_OBJECT I] I", SO3LightSetSpecularColor },
1317 { "SO3LightGetSpecularColor", 1, "fun [SO3_OBJECT] I", SO3LightGetSpecularColor },
1318 { "SO3LightSetSpotFallOff", 2, "fun [SO3_OBJECT F] I", SO3LightSetSpotFallOff },
1319 { "SO3LightGetSpotFallOff", 1, "fun [SO3_OBJECT] F", SO3LightGetSpotFallOff },
1320 { "SO3LightSetSpotInnerAngle", 2, "fun [SO3_OBJECT F] I", SO3LightSetSpotInnerAngle },
1321 { "SO3LightSetSpotOuterAngle", 2, "fun [SO3_OBJECT F] I", SO3LightSetSpotOuterAngle },
1322 { "SO3LightGetSpotInnerAngle", 1, "fun [SO3_OBJECT] F", SO3LightGetSpotInnerAngle },
1323 { "SO3LightGetSpotOuterAngle", 1, "fun [SO3_OBJECT] F", SO3LightGetSpotOuterAngle },
1324 { "SO3LightSetSpotRange", 2, "fun [SO3_OBJECT [F F F]] I", SO3LightSetSpotRange },
1325 { "SO3LightSetSourceSize", 2, "fun [SO3_OBJECT [F F]] I", SO3LightSetSourceSize },
1326 { "SO3LightGetSourceSize", 1, "fun [SO3_OBJECT] [F F]", SO3LightGetSourceSize },
1327 { "SO3LightSetVolumetric", 2, "fun [SO3_OBJECT I] I", SO3LightSetVolumetric },
1328 { "SO3LightGetVolumetric", 1, "fun [SO3_OBJECT] I", SO3LightGetVolumetric }
1329};
1330
1331
1337int SCOLloadLight(mmachine m,cbmachine w)
1338{
1339 return PKhardpak2(m, "SO3Light.pkg", sizeof(natSO3Light) / sizeof(natSO3Light[0]), natSO3Light);
1340}
1341
1342
1348{
1349 return 0;
1350}
int SCOLloadLight(mmachine m, cbmachine w)
Load the SO3Engine Lights function.
int SCOLfreeLight()
free the SO3Engine Lights function
NativeDefinition natSO3Light[]
MMechostr(MSKDEBUG, " > Start loading Plugin SO3Engine dll\n")
SCOL_EXPORT int cbmachine w
Definition SO3SCOL.cpp:5150
SCOL_EXPORT void SCOL_PTR_TYPE param
Definition SO3SCOL.cpp:5089
int createObject(mmachine m, SNode *curNode, SScene *curScene)
int SO3LightSetAttenuationAuto(mmachine m)
SO3LightSetAttenuationAuto : defines attenuation coefficients for a light automatically,...
int SO3LightSetSpotRange(mmachine m)
SO3LightSetSpotRange : defines spot range of a spot light.
int SO3LightGetSourceSize(mmachine m)
SO3LightGetSourceSize : get the source size of a rect light.
int SO3LightSetType(mmachine m)
SO3LightSetType : Defines the type of light.
int SO3LightGetVolumetric(mmachine m)
SO3LightGetVolumetric : Get the volumetric state of a light.
int SO3LightGetAttenuation(mmachine m)
SO3LightGetAttenuation : Get the attenuation coefficients for a light.
int SO3LightGetVisible(mmachine m)
SO3LightGetVisible : Get the visibility state of a light.
int SO3LightSetPowerScale(mmachine m)
SO3LightSetPowerScale : defines power scale of a light.
int SO3LightSetSpotOuterAngle(mmachine m)
SO3LightSetSpotOuterAngle : defines spot outer angle of a spot light.
int SO3LightSetVolumetric(mmachine m)
SO3LightSetVolumetric : defines if a light is displayed as a volumetric light.
int SO3LightGetType(mmachine m)
SO3LightGetType : Returns the type of light.
int SO3LightGetShadowFarDistance(mmachine m)
SO3LightGetShadowFarDistance : Get the shadow far distance of a light.
int SO3LightGetSpotOuterAngle(mmachine m)
SO3LightGetSpotOuterAngle : Get the spot outer angle of a spot light.
int SO3LightGetSpecularColor(mmachine m)
SO3LightGetSpecularColor : Get the specular color of a light.
int SO3LightSetAttenuation(mmachine m)
SO3LightSetAttenuation : defines attenuation coefficients for a light.
int SO3LightSetDiffuseColor(mmachine m)
SO3LightSetDiffuseColor : defines diffuse color of a light.
int SO3LightSetVisible(mmachine m)
SO3LightSetVisible : defines visibility state of a light.
int SO3LightSetSpotInnerAngle(mmachine m)
SO3LightSetSpotInnerAngle : defines spot inner angle of a spot light.
int SO3LightGetPowerScale(mmachine m)
SO3LightGetPowerScale : Get the power scale of a light.
int SO3LightCreate(mmachine m)
main include
Definition SCOLLight.cpp:49
int SO3LightGetDiffuseColor(mmachine m)
SO3LightGetDiffuseColor : Get the diffuse color of a light.
int SO3LightSetSpecularColor(mmachine m)
SO3LightSetSpecularColor : defines specular color of a light.
int SO3LightSetSpotFallOff(mmachine m)
SO3LightSetSpotFallOff : defines spot fall off of a spot light.
int SO3LightGetSpotFallOff(mmachine m)
SO3LightGetSpotFallOff : Get the spot fall off of a spot light.
int SO3LightSetSourceSize(mmachine m)
SO3LightSetSourceSize : defines the source size of a rect light.
int SO3LightGetSpotInnerAngle(mmachine m)
SO3LightGetSpotInnerAngle : Get the spot inner angle of a spot light.
int SO3LightSetShadowFarDistance(mmachine m)
SO3LightSetShadowFarDistance : defines shadows far distance of a light.