Project

General

Profile

SO3Engine
SCOLObject.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#include "SO3Utils/SO3RayCast.h"
36
37// Animation includes
39
40// Renderer includes
42
43// Scene Graph includes
51
52
69int SO3ObjectRotate(mmachine m)
70{
71#ifdef SO3_DEBUG
72 MMechostr(MSKDEBUG, "SO3ObjectRotate\n");
73#endif
74
75 int rep = MMpull(m);
76 int axe = MTOP(MMpull(m));
77 int rot = MMpull(m);
78 int n = MMget(m, 0);
79
80 if ((n == NIL) || (rot == NIL) || (rep == NIL) || (axe == NIL))
81 {
82 MMset(m, 0, NIL);
83 return 0;
84 }
85
86 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
87 if (node == 0)
88 {
89 MMset(m, 0, NIL);
90 return 0;
91 }
92
93 int x = MMfetch(m, axe, 0);
94 int y = MMfetch(m, axe, 1);
95 int z = MMfetch(m, axe, 2);
96
97 if ((x == NIL) || (y == NIL) || (z == NIL))
98 {
99 MMset(m, 0, NIL);
100 return 0;
101 }
102
103 node->Rotate(Ogre::Vector3(MTOF(x), MTOF(y), MTOF(z)), MTOF(rot), static_cast<SNode::NodeTransformSpace> (MTOI(rep)));
104
105 MMset(m, 0, ITOM(1));
106 return 0;
107}
108
109
120{
121#ifdef SO3_DEBUG
122 MMechostr(MSKDEBUG, "SO3ObjectShowBoundingBox\n");
123#endif
124
125 int i = MMpull(m);
126 int n = MMget(m, 0);
127
128 if ((i == NIL) || (n == NIL))
129 {
130 MMset(m, 0, NIL);
131 return 0;
132 }
133
134 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
135 if (node == 0)
136 {
137 MMset(m, 0, NIL);
138 return 0;
139 }
140
141 if (node->GetNodeType() == SNode::BONE_TYPE_ID)
142 {
143 MMset(m, 0, NIL);
144 return 0;
145 }
146
147 if (MTOI(i) == 0)
148 node->SetShowBoundingBox(false);
149 else
150 node->SetShowBoundingBox(true);
151
152 MMset(m, 0, ITOM(1));
153
154 return 0;
155}
156
157
174{
175#ifdef SO3_DEBUG
176 MMechostr(MSKDEBUG, "SO3ObjectSetDirection\n");
177#endif
178
179 int rep = MMpull(m);
180 int vec = MTOP(MMpull(m));
181 int n = MMget(m, 0);
182
183 if ((n == NIL) || (vec == NIL) || (rep == NIL))
184 {
185 MMset(m, 0, NIL);
186 return 0;
187 }
188
189 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
190 if (node == 0)
191 {
192 MMset(m, 0, NIL);
193 return 0;
194 }
195
196 // TODO Why ?
197 if (node->GetNodeType() == SNode::BONE_TYPE_ID)
198 {
199 MMset(m, 0, NIL);
200 return 0;
201 }
202
203 int x = MMfetch(m, vec, 0);
204 int y = MMfetch(m, vec, 1);
205 int z = MMfetch(m, vec, 2);
206
207 if ((x == NIL) || (y == NIL) || (z == NIL))
208 {
209 MMset(m, 0, NIL);
210 return 0;
211 }
212
213 node->SetDirection(Ogre::Vector3(MTOF(x), MTOF(y), MTOF(z)), static_cast <SNode::NodeTransformSpace> (MTOI(rep)), Ogre::Vector3::NEGATIVE_UNIT_Z);
214
215 MMset(m, 0, ITOM(1));
216
217 return 0;
218}
219
220
230{
231#ifdef SO3_DEBUG
232 MMechostr(MSKDEBUG, "SO3ObjectGetDirection\n");
233#endif
234
235 int obj = MMget(m, 0);
236 if (obj == NIL)
237 {
238 MMset(m, 0, NIL);
239 return 0;
240 }
241
242 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
243 if (node == 0)
244 {
245 MMset(m, 0, NIL);
246 return 0;
247 }
248
249 Ogre::Vector3 dirvec(node->GetDirection());
250 int tuple = MMmalloc(m, 3, TYPETAB);
251 if (tuple == NIL)
252 {
253 MMset(m, 0, NIL);
254 return MERRMEM;
255 }
256
257 MMstore(m, tuple, 0, FTOM((dirvec.x)));
258 MMstore(m, tuple, 1, FTOM((dirvec.y)));
259 MMstore(m, tuple, 2, FTOM((dirvec.z)));
260 MMset(m, 0, PTOM(tuple));
261
262 return 0;
263}
264
265
275{
276#ifdef SO3_DEBUG
277 MMechostr(MSKDEBUG, "SO3ObjectGetDerivedDirection\n");
278#endif
279
280 int obj = MMget(m, 0);
281 if (obj == NIL)
282 {
283 MMset(m, 0, NIL);
284 return 0;
285 }
286
287 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
288 if (node == 0)
289 {
290 MMset(m, 0, NIL);
291 return 0;
292 }
293
294 Ogre::Vector3 dirvec(node->GetDirection(true));
295 int tuple = MMmalloc(m, 3, TYPETAB);
296 if (tuple == NIL)
297 {
298 MMset(m, 0, NIL);
299 return MERRMEM;
300 }
301
302 MMstore(m, tuple, 0, FTOM((dirvec.x)));
303 MMstore(m, tuple, 1, FTOM((dirvec.y)));
304 MMstore(m, tuple, 2, FTOM((dirvec.z)));
305 MMset(m, 0, PTOM(tuple));
306
307 return 0;
308}
309
310
320{
321#ifdef SO3_DEBUG
322 MMechostr(MSKDEBUG, "SO3ObjectGetDirectionAxis\n");
323#endif
324
325 int vec = MTOP(MMpull(m));
326 int obj = MMget(m, 0);
327 if ((obj == NIL) || (vec == NIL))
328 {
329 MMset(m, 0, NIL);
330 return 0;
331 }
332
333 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
334 if (node == 0)
335 {
336 MMset(m, 0, NIL);
337 return 0;
338 }
339
340 int x = MMfetch(m, vec, 0);
341 int y = MMfetch(m, vec, 1);
342 int z = MMfetch(m, vec, 2);
343
344 if ((x == NIL) || (y == NIL) || (z == NIL))
345 {
346 MMset(m, 0, NIL);
347 return 0;
348 }
349 Ogre::Vector3 axis(MTOF(x), MTOF(y), MTOF(z));
350
351 Ogre::Vector3 dirvec(node->GetDirection(false, axis));
352 int tuple = MMmalloc(m, 3, TYPETAB);
353 if (tuple == NIL)
354 {
355 MMset(m, 0, NIL);
356 return MERRMEM;
357 }
358
359 MMstore(m, tuple, 0, FTOM((dirvec.x)));
360 MMstore(m, tuple, 1, FTOM((dirvec.y)));
361 MMstore(m, tuple, 2, FTOM((dirvec.z)));
362 MMset(m, 0, PTOM(tuple));
363
364 return 0;
365}
366
367
377{
378#ifdef SO3_DEBUG
379 MMechostr(MSKDEBUG, "SO3ObjectGetDerivedDirectionAxis\n");
380#endif
381
382 int vec = MTOP(MMpull(m));
383 int obj = MMget(m, 0);
384 if ((obj == NIL) || (vec == NIL))
385 {
386 MMset(m, 0, NIL);
387 return 0;
388 }
389
390 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
391 if (node == 0)
392 {
393 MMset(m, 0, NIL);
394 return 0;
395 }
396
397 int x = MMfetch(m, vec, 0);
398 int y = MMfetch(m, vec, 1);
399 int z = MMfetch(m, vec, 2);
400
401 if ((x == NIL) || (y == NIL) || (z == NIL))
402 {
403 MMset(m, 0, NIL);
404 return 0;
405 }
406 Ogre::Vector3 axis(MTOF(x), MTOF(y), MTOF(z));
407
408 Ogre::Vector3 dirvec(node->GetDirection(true, axis));
409 int tuple = MMmalloc(m, 3, TYPETAB);
410 if (tuple == NIL)
411 {
412 MMset(m, 0, NIL);
413 return MERRMEM;
414 }
415
416 MMstore(m, tuple, 0, FTOM((dirvec.x)));
417 MMstore(m, tuple, 1, FTOM((dirvec.y)));
418 MMstore(m, tuple, 2, FTOM((dirvec.z)));
419 MMset(m, 0, PTOM(tuple));
420
421 return 0;
422}
423
424
440int SO3ObjectLookAt(mmachine m)
441{
442#ifdef SO3_DEBUG
443 MMechostr(MSKDEBUG, "SO3ObjectLookAt\n");
444#endif
445
446 int rep = MMpull(m);
447 int vec = MTOP(MMpull(m));
448 int n = MMget(m, 0);
449
450 if ((n == NIL) || (vec == NIL) || (rep == NIL))
451 {
452 MMset(m, 0, NIL);
453 return 0;
454 }
455
456 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
457 if (node == 0)
458 {
459 MMset(m, 0, NIL);
460 return 0;
461 }
462
463 if (node->GetNodeType() == SNode::BONE_TYPE_ID)
464 {
465 MMset(m, 0, NIL);
466 return 0;
467 }
468
469 int x = MMfetch(m, vec, 0);
470 int y = MMfetch(m, vec, 1);
471 int z = MMfetch(m, vec, 2);
472
473 if ((x == NIL) || (y == NIL) || (z == NIL))
474 {
475 MMset(m, 0, NIL);
476 return 0;
477 }
478
479 node->LookAt(Ogre::Vector3(MTOF(x), MTOF(y), MTOF(z)), static_cast <SNode::NodeTransformSpace> (MTOI(rep)), Ogre::Vector3::NEGATIVE_UNIT_Z);
480 MMset(m, 0, ITOM(1));
481
482 return 0;
483}
484
485
496int SO3ObjectSetVisible(mmachine m)
497{
498#ifdef SO3_DEBUG
499 MMechostr(MSKDEBUG, "SO3ObjectSetVisible\n");
500#endif
501
502 int c = MMpull(m);
503 int v = MMpull(m);
504 int n = MMget(m, 0);
505
506 if ((n == NIL) || (c == NIL) || (v == NIL))
507 {
508 MMset(m, 0, NIL);
509 return 0;
510 }
511
512 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
513 if (node == 0)
514 {
515 MMset(m, 0, NIL);
516 return 0;
517 }
518
519 //if (node->GetNodeType() == SNode::BONE_TYPE_ID)
520 //{
521 // MMset(m, 0, NIL);
522 // return 0;
523 //}
524
525 bool bvisible = false;
526 bool brecursive = false;
527
528 if (MTOI(v) == 1)
529 bvisible = true;
530
531 if (MTOI(c) == 1)
532 brecursive = true;
533
534 node->SetVisible(bvisible, brecursive);
535
536 MMset(m, 0, ITOM(1));
537
538 return 0;
539}
540
541
550int SO3ObjectGetVisible(mmachine m)
551{
552#ifdef SO3_DEBUG
553 MMechostr(MSKDEBUG, "SO3ObjectGetVisible\n");
554#endif
555
556 int n = MMget(m, 0);
557
558 if (n == NIL)
559 {
560 MMset(m, 0, NIL);
561 return 0;
562 }
563
564 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
565 if (node == 0)
566 {
567 MMset(m, 0, NIL);
568 return 0;
569 }
570
571 //if (node->GetNodeType() == SNode::BONE_TYPE_ID)
572 //{
573 // MMset(m, 0, NIL);
574 // return 0;
575 //}
576
577 bool result = node->GetVisible();
578
579 if (result)
580 MMset(m, 0, ITOM(1));
581 else
582 MMset(m, 0, ITOM(0));
583
584 return 0;
585}
586
587
596int SO3ObjectGetName(mmachine m)
597{
598#ifdef SO3_DEBUG
599 MMechostr(MSKDEBUG, "SO3ObjectGetName\n");
600#endif
601
602 int n = MMpull(m);
603 if (n == NIL)
604 {
605 MMpush(m, NIL);
606 return 0;
607 }
608
609 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
610 if (node == 0)
611 {
612 MMpush(m, NIL);
613 return 0;
614 }
615
616 return Mpushstrbloc(m, (char*)(node->GetName().c_str()));
617}
618
619
630{
631#ifdef SO3_DEBUG
632 MMechostr(MSKDEBUG, "SO3ObjectSetOrientation\n");
633#endif
634
635 int q = MTOP(MMpull(m));
636 int n = MMget(m, 0);
637
638 if ((n == NIL) || (q == NIL))
639 {
640 MMset(m, 0, NIL);
641 return 0;
642 }
643
644 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
645 if (node == 0)
646 {
647 MMset(m, 0, NIL);
648 return 0;
649 }
650
651 int x = MMfetch(m, q, 0);
652 int y = MMfetch(m, q, 1);
653 int z = MMfetch(m, q, 2);
654 int w = MMfetch(m, q, 3);
655
656 if ((x == NIL) || (y == NIL) || (z == NIL) || (w == NIL))
657 {
658 MMset(m, 0, NIL);
659 return 0;
660 }
661
662 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(w), MTOF(x), MTOF(y), MTOF(z));
663 quat.normalise();
664
665 node->SetOrientation(quat);
666
667 MMset(m, 0, ITOM(1));
668 return 0;
669}
670
671
682{
683#ifdef SO3_DEBUG
684 MMechostr(MSKDEBUG, "SO3ObjectAddOrientation\n");
685#endif
686
687 int q = MTOP(MMpull(m));
688 int n = MMget(m, 0);
689
690 if ((n == NIL) || (q == NIL))
691 {
692 MMset(m, 0, NIL);
693 return 0;
694 }
695
696 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
697 if (node == 0)
698 {
699 MMset(m, 0, NIL);
700 return 0;
701 }
702
703 int x = MMfetch(m, q, 0);
704 int y = MMfetch(m, q, 1);
705 int z = MMfetch(m, q, 2);
706 int w = MMfetch(m, q, 3);
707
708 if ((x == NIL) || (y == NIL) || (z == NIL) || (w == NIL))
709 {
710 MMset(m, 0, NIL);
711 return 0;
712 }
713
714 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(w), MTOF(x), MTOF(y), MTOF(z));
715
716 node->AddOrientation(quat);
717
718 MMset(m, 0, ITOM(1));
719 return 0;
720}
721
722
732{
733#ifdef SO3_DEBUG
734 MMechostr(MSKDEBUG, "SO3ObjectResetToInitialOrientation\n");
735#endif
736
737 int n = MMget(m, 0);
738
739 if (n == NIL)
740 {
741 MMset(m, 0, NIL);
742 return 0;
743 }
744
745 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
746 if (node == 0)
747 {
748 MMset(m, 0, NIL);
749 return 0;
750 }
751
752 node->ResetToInitialOrientation();
753
754 MMset(m, 0, ITOM(1));
755
756 return 0;
757}
758
759
769int SO3ObjectSetPosition(mmachine m)
770{
771#ifdef SO3_DEBUG
772 MMechostr(MSKDEBUG, "SO3ObjectSetPosition\n");
773#endif
774
775 int vec = MTOP(MMpull(m));
776 int n = MMget(m, 0);
777
778 if ((n == NIL) || (vec == NIL))
779 {
780 MMset(m, 0, NIL);
781 return 0;
782 }
783
784 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
785 if (node == 0)
786 {
787 MMset(m, 0, NIL);
788 return 0;
789 }
790
791 int x = MMfetch(m, vec, 0);
792 int y = MMfetch(m, vec, 1);
793 int z = MMfetch(m, vec, 2);
794
795 if ((x == NIL) || (y == NIL) || (z == NIL))
796 {
797 MMset(m, 0, NIL);
798 return 0;
799 }
800
801 node->SetPosition(Ogre::Vector3(MTOF(x), MTOF(y), MTOF(z)));
802 MMset(m, 0, ITOM(1));
803
804 return 0;
805}
806
807
823int SO3ObjectTranslate(mmachine m)
824{
825#ifdef SO3_DEBUG
826 MMechostr(MSKDEBUG, "SO3ObjectTranslate\n");
827#endif
828
829 int rep = MMpull(m);
830 int vec = MTOP(MMpull(m));
831 int n = MMget(m, 0);
832
833 if ((n == NIL) || (vec == NIL) || (rep == NIL))
834 {
835 MMset(m, 0, NIL);
836 return 0;
837 }
838
839 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
840 if (node == 0)
841 {
842 MMechostr(MSKDEBUG, "SO3ObjectTranslate Node is NULL\n");
843 MMset(m, 0, NIL);
844 return 0;
845 }
846
847 int x = MMfetch(m, vec, 0);
848 int y = MMfetch(m, vec, 1);
849 int z = MMfetch(m, vec, 2);
850
851 if ((x == NIL) || (y == NIL) || (z == NIL))
852 {
853 MMset(m, 0, NIL);
854 return 0;
855 }
856
857 // 0 translation don't need to do something
858 if ((MTOF(x) == 0.0) && (MTOF(y) == 0.0) && (MTOF(z) == 0.0))
859 {
860 MMset(m, 0, NIL);
861 return 0;
862 }
863
864 SNode::NodeTransformSpace ts = SNode::SO3_LOCAL_TS;
865 if (rep != NIL)
866 ts = static_cast <SNode::NodeTransformSpace>(MTOI(rep));
867
868 node->Translate(Ogre::Vector3(MTOF(x), MTOF(y), MTOF(z)), ts);
869
870 MMset(m, 0, ITOM(1));
871 return 0;
872}
873
874
884int SO3ObjectSetScale(mmachine m)
885{
886#ifdef SO3_DEBUG
887 MMechostr(MSKDEBUG, "SO3ObjectSetScale\n");
888#endif
889
890 int vec = MTOP(MMpull(m));
891 int n = MMget(m, 0);
892
893 if ((n == NIL) || (vec == NIL))
894 {
895 MMset(m, 0, NIL);
896 return 0;
897 }
898
899 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
900 if (node == 0)
901 {
902 MMset(m, 0, NIL);
903 return 0;
904 }
905
906 int x = MMfetch(m, vec, 0);
907 int y = MMfetch(m, vec, 1);
908 int z = MMfetch(m, vec, 2);
909
910 if ((x == NIL) || (y == NIL) || (z == NIL))
911 {
912 MMset(m, 0, NIL);
913 return 0;
914 }
915
916 node->SetScale(Ogre::Vector3(MTOF(x), MTOF(y), MTOF(z)));
917
918 MMset(m, 0, ITOM(1));
919 return 0;
920}
921
922
932{
933#ifdef SO3_DEBUG
934 MMechostr(MSKDEBUG, "SO3ObjectGetOrientation\n");
935#endif
936
937 int n = MMget(m, 0);
938
939 if (n == NIL)
940 {
941 MMset(m, 0, NIL);
942 return 0;
943 }
944
945 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
946 if (node == 0)
947 {
948 MMset(m, 0, NIL);
949 return 0;
950 }
951
952 Ogre::Quaternion q = node->GetOrientation();
953
954 int tuple = MMmalloc(m, 4, TYPETAB);
955 if (tuple == NIL)
956 {
957 MMset(m, 0, NIL);
958 return MERRMEM;
959 }
960
961 MMstore(m, tuple, 0, FTOM((q.x)));
962 MMstore(m, tuple, 1, FTOM((q.y)));
963 MMstore(m, tuple, 2, FTOM((q.z)));
964 MMstore(m, tuple, 3, FTOM((q.w)));
965 MMset(m, 0, PTOM(tuple));
966
967 return 0;
968}
969
970
980{
981#ifdef SO3_DEBUG
982 MMechostr(MSKDEBUG, "SO3ObjectGetInitialOrientation\n");
983#endif
984
985 int n = MMget(m, 0);
986
987 if (n == NIL)
988 {
989 MMset(m, 0, NIL);
990 return 0;
991 }
992
993 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
994 if (node == 0)
995 {
996 MMset(m, 0, NIL);
997 return 0;
998 }
999
1000 Ogre::Quaternion q = node->GetInitialOrientation();
1001
1002 int tuple = MMmalloc(m, 4, TYPETAB);
1003 if (tuple == NIL)
1004 {
1005 MMset(m, 0, NIL);
1006 return MERRMEM;
1007 }
1008
1009 MMstore(m, tuple, 0, FTOM((q.x)));
1010 MMstore(m, tuple, 1, FTOM((q.y)));
1011 MMstore(m, tuple, 2, FTOM((q.z)));
1012 MMstore(m, tuple, 3, FTOM((q.w)));
1013 MMset(m, 0, PTOM(tuple));
1014
1015 return 0;
1016}
1017
1018
1028{
1029#ifdef SO3_DEBUG
1030 MMechostr(MSKDEBUG, "SO3ObjectGetGlobalOrientation\n");
1031#endif
1032
1033 int n = MMget(m, 0);
1034
1035 if (n == NIL)
1036 {
1037 MMset(m, 0, NIL);
1038 return 0;
1039 }
1040
1041 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1042 if (node == 0)
1043 {
1044 MMset(m, 0, NIL);
1045 return 0;
1046 }
1047
1048 Ogre::Quaternion q = node->GetGlobalOrientation();
1049
1050 int tuple = MMmalloc(m, 4, TYPETAB);
1051 if (tuple == NIL)
1052 {
1053 MMset(m, 0, NIL);
1054 return MERRMEM;
1055 }
1056
1057 MMstore(m, tuple, 0, FTOM(q.x));
1058 MMstore(m, tuple, 1, FTOM(q.y));
1059 MMstore(m, tuple, 2, FTOM(q.z));
1060 MMstore(m, tuple, 3, FTOM(q.w));
1061 MMset(m, 0, PTOM(tuple));
1062
1063 return 0;
1064}
1065
1066
1077{
1078#ifdef SO3_DEBUG
1079 MMechostr(MSKDEBUG, "SO3ObjectSetGlobalPosition\n");
1080#endif
1081
1082 int vec = MMpull(m);
1083 int n = MMget(m, 0);
1084
1085 if ((n == NIL) || (vec == NIL))
1086 {
1087 MMset(m, 0, NIL);
1088 return 0;
1089 }
1090
1091 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1092 if (node == 0)
1093 {
1094 MMset(m, 0, NIL);
1095 return 0;
1096 }
1097
1098 int x = MMfetch(m, MTOP(vec), 0);
1099 int y = MMfetch(m, MTOP(vec), 1);
1100 int z = MMfetch(m, MTOP(vec), 2);
1101
1102 if ((x == NIL) || (y == NIL) || (z == NIL))
1103 {
1104 MMset(m, 0, NIL);
1105 return 0;
1106 }
1107
1108 Ogre::Vector3 position = Ogre::Vector3(MTOF(x), MTOF(y), MTOF(z));
1109 node->SetGlobalPosition(position);
1110
1111 MMset(m, 0, ITOM(1));
1112 return 0;
1113}
1114
1115
1126{
1127#ifdef SO3_DEBUG
1128 MMechostr(MSKDEBUG, "SO3ObjectSetGlobalOrientation\n");
1129#endif
1130
1131 int q = MMpull(m);
1132 int n = MMget(m, 0);
1133
1134 if ((n == NIL) || (q == NIL))
1135 {
1136 MMset(m, 0, NIL);
1137 return 0;
1138 }
1139
1140 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1141 if (node == 0)
1142 {
1143 MMset(m, 0, NIL);
1144 return 0;
1145 }
1146
1147 int x = MMfetch(m, MTOP(q), 0);
1148 int y = MMfetch(m, MTOP(q), 1);
1149 int z = MMfetch(m, MTOP(q), 2);
1150 int w = MMfetch(m, MTOP(q), 3);
1151
1152 if ((x == NIL) || (y == NIL) || (z == NIL) || (w == NIL))
1153 {
1154 MMset(m, 0, NIL);
1155 return 0;
1156 }
1157
1158 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(w), MTOF(x), MTOF(y), MTOF(z));
1159 quat.normalise();
1160
1161 node->SetGlobalOrientation(quat);
1162
1163 MMset(m, 0, ITOM(1));
1164 return 0;
1165}
1166
1167
1178{
1179#ifdef SO3_DEBUG
1180 MMechostr(MSKDEBUG, "SO3ObjectSetGlobalScale\n");
1181#endif
1182
1183 int vec = MTOP(MMpull(m));
1184 int n = MMget(m, 0);
1185
1186 if ((n == NIL) || (vec == NIL))
1187 {
1188 MMset(m, 0, NIL);
1189 return 0;
1190 }
1191
1192 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1193 if (node == 0)
1194 {
1195 MMset(m, 0, NIL);
1196 return 0;
1197 }
1198
1199 int x = MMfetch(m, vec, 0);
1200 int y = MMfetch(m, vec, 1);
1201 int z = MMfetch(m, vec, 2);
1202
1203 if ((x == NIL) || (y == NIL) || (z == NIL))
1204 {
1205 MMset(m, 0, NIL);
1206 return 0;
1207 }
1208
1209 Ogre::Vector3 scale = Ogre::Vector3(MTOF(x), MTOF(y), MTOF(z));
1210 node->SetGlobalScale(scale);
1211
1212 MMset(m, 0, ITOM(1));
1213 return 0;
1214}
1215
1216
1226{
1227#ifdef SO3_DEBUG
1228 MMechostr(MSKDEBUG, "SO3ObjectGetPosition\n");
1229#endif
1230
1231 int n = MMget(m, 0);
1232
1233 if (n == NIL)
1234 {
1235 MMset(m, 0, NIL);
1236 return 0;
1237 }
1238
1239 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1240 if (node == 0)
1241 {
1242 MMset(m, 0, NIL);
1243 return 0;
1244 }
1245
1246 Ogre::Vector3 pos = node->GetPosition();
1247
1248 int tuple = MMmalloc(m, 3, TYPETAB);
1249 if (tuple == NIL)
1250 {
1251 MMset(m, 0, NIL);
1252 return MERRMEM;
1253 }
1254
1255 MMstore(m, tuple, 0, FTOM((pos.x)));
1256 MMstore(m, tuple, 1, FTOM((pos.y)));
1257 MMstore(m, tuple, 2, FTOM((pos.z)));
1258 MMset(m, 0, PTOM(tuple));
1259
1260 return 0;
1261}
1262
1263
1273{
1274#ifdef SO3_DEBUG
1275 MMechostr(MSKDEBUG, "SO3ObjectGetInitialPosition\n");
1276#endif
1277
1278 int n = MMget(m, 0);
1279
1280 if (n == NIL)
1281 {
1282 MMset(m, 0, NIL);
1283 return 0;
1284 }
1285
1286 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1287 if (node == 0)
1288 {
1289 MMset(m, 0, NIL);
1290 return 0;
1291 }
1292
1293 Ogre::Vector3 pos = node->GetInitialPosition();
1294
1295 int tuple = MMmalloc(m, 3, TYPETAB);
1296 if (tuple == NIL)
1297 {
1298 MMset(m, 0, NIL);
1299 return MERRMEM;
1300 }
1301
1302 MMstore(m, tuple, 0, FTOM((pos.x)));
1303 MMstore(m, tuple, 1, FTOM((pos.y)));
1304 MMstore(m, tuple, 2, FTOM((pos.z)));
1305 MMset(m, 0, PTOM(tuple));
1306
1307 return 0;
1308}
1309
1310
1320{
1321#ifdef SO3_DEBUG
1322 MMechostr(MSKDEBUG, "SO3ObjectGetGlobalPosition\n");
1323#endif
1324
1325 int n = MMget(m, 0);
1326
1327 if (n == NIL)
1328 {
1329 MMset(m, 0, NIL);
1330 return 0;
1331 }
1332
1333 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1334 if (node == 0)
1335 {
1336 MMset(m, 0, NIL);
1337 return 0;
1338 }
1339
1340 Ogre::Vector3 vec = node->GetGlobalPosition();
1341
1342 int tuple = MMmalloc(m, 3, TYPETAB);
1343 if (tuple == NIL)
1344 {
1345 MMset(m, 0, NIL);
1346 return MERRMEM;
1347 }
1348
1349 MMstore(m, tuple, 0, FTOM((vec.x)));
1350 MMstore(m, tuple, 1, FTOM((vec.y)));
1351 MMstore(m, tuple, 2, FTOM((vec.z)));
1352 MMset(m, 0, PTOM(tuple));
1353
1354 return 0;
1355}
1356
1357
1366int SO3ObjectGetScale(mmachine m)
1367{
1368#ifdef SO3_DEBUG
1369 MMechostr(MSKDEBUG, "SO3ObjectGetScale\n");
1370#endif
1371
1372 int n = MMget(m, 0);
1373
1374 if (n == NIL)
1375 {
1376 MMset(m, 0, NIL);
1377 return 0;
1378 }
1379
1380 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1381 if (node == 0)
1382 {
1383 MMset(m, 0, NIL);
1384 return 0;
1385 }
1386
1387 Ogre::Vector3 pos = node->GetScale();
1388
1389 int tuple = MMmalloc(m, 3, TYPETAB);
1390 if (tuple == NIL)
1391 {
1392 MMset(m, 0, NIL);
1393 return MERRMEM;
1394 }
1395
1396 MMstore(m, tuple, 0, FTOM((pos.x)));
1397 MMstore(m, tuple, 1, FTOM((pos.y)));
1398 MMstore(m, tuple, 2, FTOM((pos.z)));
1399 MMset(m, 0, PTOM(tuple));
1400
1401 return 0;
1402}
1403
1404
1414{
1415#ifdef SO3_DEBUG
1416 MMechostr(MSKDEBUG, "SO3ObjectGetInitialScale\n");
1417#endif
1418
1419 int n = MMget(m, 0);
1420
1421 if (n == NIL)
1422 {
1423 MMset(m, 0, NIL);
1424 return 0;
1425 }
1426
1427 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1428 if (node == 0)
1429 {
1430 MMset(m, 0, NIL);
1431 return 0;
1432 }
1433
1434 Ogre::Vector3 pos = node->GetInitialScale();
1435
1436 int tuple = MMmalloc(m, 3, TYPETAB);
1437 if (tuple == NIL)
1438 {
1439 MMset(m, 0, NIL);
1440 return MERRMEM;
1441 }
1442
1443 MMstore(m, tuple, 0, FTOM((pos.x)));
1444 MMstore(m, tuple, 1, FTOM((pos.y)));
1445 MMstore(m, tuple, 2, FTOM((pos.z)));
1446 MMset(m, 0, PTOM(tuple));
1447
1448 return 0;
1449}
1450
1451
1460int SO3ObjectGetMatrix(mmachine m)
1461{
1462#ifdef SO3_DEBUG
1463 MMechostr(MSKDEBUG, "SO3ObjectGetMatrix\n");
1464#endif
1465
1466 int n = MMget(m, 0);
1467
1468 if (n == NIL)
1469 {
1470 MMset(m, 0, NIL);
1471 return 0;
1472 }
1473
1474 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1475 if (node == 0)
1476 {
1477 MMset(m, 0, NIL);
1478 return 0;
1479 }
1480
1481 Ogre::Matrix3 rot;
1482 node->GetOrientation().ToRotationMatrix(rot);
1483 Ogre::Matrix4 matTr = (Ogre::Matrix4)rot;
1484 matTr.setTrans(node->GetPosition());
1485 matTr.setScale(node->GetScale());
1486
1487 int tuple = MMmalloc(m, 16, TYPETAB);
1488 if (tuple == NIL)
1489 {
1490 MMset(m, 0, NIL);
1491 return MERRMEM;
1492 }
1493
1494 MMstore(m, tuple, 0, FTOM(matTr[0][0]));
1495 MMstore(m, tuple, 1, FTOM(matTr[0][1]));
1496 MMstore(m, tuple, 2, FTOM(matTr[0][2]));
1497 MMstore(m, tuple, 3, FTOM(matTr[0][3]));
1498 MMstore(m, tuple, 4, FTOM(matTr[1][0]));
1499 MMstore(m, tuple, 5, FTOM(matTr[1][1]));
1500 MMstore(m, tuple, 6, FTOM(matTr[1][2]));
1501 MMstore(m, tuple, 7, FTOM(matTr[1][3]));
1502 MMstore(m, tuple, 8, FTOM(matTr[2][0]));
1503 MMstore(m, tuple, 9, FTOM(matTr[2][1]));
1504 MMstore(m, tuple, 10, FTOM(matTr[2][2]));
1505 MMstore(m, tuple, 11, FTOM(matTr[2][3]));
1506 MMstore(m, tuple, 12, FTOM(matTr[3][0]));
1507 MMstore(m, tuple, 13, FTOM(matTr[3][1]));
1508 MMstore(m, tuple, 14, FTOM(matTr[3][2]));
1509 MMstore(m, tuple, 15, FTOM(matTr[3][3]));
1510 MMset(m, 0, PTOM(tuple));
1511
1512 return 0;
1513}
1514
1515
1525{
1526#ifdef SO3_DEBUG
1527 MMechostr(MSKDEBUG, "SO3ObjectGetWorldMatrix\n");
1528#endif
1529
1530 int n = MMget(m, 0);
1531
1532 if (n == NIL)
1533 {
1534 MMset(m, 0, NIL);
1535 return 0;
1536 }
1537
1538 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1539 if (node == 0)
1540 {
1541 MMset(m, 0, NIL);
1542 return 0;
1543 }
1544
1545 Ogre::Matrix4 matTr(node->GetTransformationMatrix());
1546
1547 int tuple = MMmalloc(m, 16, TYPETAB);
1548 if (tuple == NIL)
1549 {
1550 MMset(m, 0, NIL);
1551 return MERRMEM;
1552 }
1553
1554 MMstore(m, tuple, 0, FTOM(matTr[0][0]));
1555 MMstore(m, tuple, 1, FTOM(matTr[0][1]));
1556 MMstore(m, tuple, 2, FTOM(matTr[0][2]));
1557 MMstore(m, tuple, 3, FTOM(matTr[0][3]));
1558 MMstore(m, tuple, 4, FTOM(matTr[1][0]));
1559 MMstore(m, tuple, 5, FTOM(matTr[1][1]));
1560 MMstore(m, tuple, 6, FTOM(matTr[1][2]));
1561 MMstore(m, tuple, 7, FTOM(matTr[1][3]));
1562 MMstore(m, tuple, 8, FTOM(matTr[2][0]));
1563 MMstore(m, tuple, 9, FTOM(matTr[2][1]));
1564 MMstore(m, tuple, 10, FTOM(matTr[2][2]));
1565 MMstore(m, tuple, 11, FTOM(matTr[2][3]));
1566 MMstore(m, tuple, 12, FTOM(matTr[3][0]));
1567 MMstore(m, tuple, 13, FTOM(matTr[3][1]));
1568 MMstore(m, tuple, 14, FTOM(matTr[3][2]));
1569 MMstore(m, tuple, 15, FTOM(matTr[3][3]));
1570 MMset(m, 0, PTOM(tuple));
1571
1572 return 0;
1573}
1574
1575
1585{
1586#ifdef SO3_DEBUG
1587 MMechostr(MSKDEBUG, "SO3ObjectGetGlobalScale\n");
1588#endif
1589
1590 int n = MMget(m, 0);
1591
1592 if (n == NIL)
1593 {
1594 MMset(m, 0, NIL);
1595 return 0;
1596 }
1597
1598 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1599 if (node == 0)
1600 {
1601 MMset(m, 0, NIL);
1602 return 0;
1603 }
1604
1605 Ogre::Vector3 pos = node->GetGlobalScale();
1606
1607 int tuple = MMmalloc(m, 3, TYPETAB);
1608 if (tuple == NIL)
1609 {
1610 MMset(m, 0, NIL);
1611 return MERRMEM;
1612 }
1613
1614 MMstore(m, tuple, 0, FTOM((pos.x)));
1615 MMstore(m, tuple, 1, FTOM((pos.y)));
1616 MMstore(m, tuple, 2, FTOM((pos.z)));
1617 MMset(m, 0, PTOM(tuple));
1618
1619 return 0;
1620}
1621
1622
1638int SO3ObjectRotateRoll(mmachine m)
1639{
1640#ifdef SO3_DEBUG
1641 MMechostr(MSKDEBUG, "SO3ObjectRotateRoll\n");
1642#endif
1643
1644 int rep = MMpull(m);
1645 int ang = MMpull(m);
1646 int n = MMget(m, 0);
1647
1648 if ((n == NIL) || (rep == NIL) || (ang == NIL))
1649 {
1650 MMset(m, 0, NIL);
1651 return 0;
1652 }
1653
1654 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1655 if (node == 0)
1656 {
1657 MMset(m, 0, NIL);
1658 return 0;
1659 }
1660
1661 node->Roll(MTOF(ang), static_cast <SNode::NodeTransformSpace>(MTOI(rep)));
1662
1663 MMset(m, 0, ITOM(1));
1664 return 0;
1665}
1666
1667
1683int SO3ObjectRotateYaw(mmachine m)
1684{
1685#ifdef SO3_DEBUG
1686 MMechostr(MSKDEBUG, "SO3ObjectRotateYaw\n");
1687#endif
1688
1689 int rep = MMpull(m);
1690 int ang = MMpull(m);
1691 int n = MMget(m, 0);
1692
1693 if ((n == NIL) || (rep == NIL) || (ang == NIL))
1694 {
1695 MMset(m, 0, NIL);
1696 return 0;
1697 }
1698
1699 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1700 if (node == 0)
1701 {
1702 MMset(m, 0, NIL);
1703 return 0;
1704 }
1705
1706 node->Yaw(MTOF(ang), static_cast <SNode::NodeTransformSpace>(MTOI(rep)));
1707
1708 MMset(m, 0, ITOM(1));
1709
1710 return 0;
1711}
1712
1713
1730{
1731#ifdef SO3_DEBUG
1732 MMechostr(MSKDEBUG, "SO3ObjectRotatePitch\n");
1733#endif
1734
1735 int rep = MMpull(m);
1736 int ang = MMpull(m);
1737 int n = MMget(m, 0);
1738
1739 if ((n == NIL) || (rep == NIL) || (ang == NIL))
1740 {
1741 MMset(m, 0, NIL);
1742 return 0;
1743 }
1744
1745 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1746 if (node == 0)
1747 {
1748 MMset(m, 0, NIL);
1749 return 0;
1750 }
1751
1752 node->Pitch(MTOF(ang), static_cast <SNode::NodeTransformSpace>(MTOI(rep)));
1753
1754 MMset(m, 0, ITOM(1));
1755
1756 return 0;
1757}
1758
1759
1768int SO3ObjectNbOfChild(mmachine m)
1769{
1770#ifdef SO3_DEBUG
1771 MMechostr(MSKDEBUG, "SO3ObjectNbOfChild\n");
1772#endif
1773
1774 int n = MMget(m, 0);
1775
1776 if (n == NIL)
1777 {
1778 MMset(m, 0, NIL);
1779 return 0;
1780 }
1781
1782 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1783 if (node == 0)
1784 {
1785 MMset(m, 0, NIL);
1786 return 0;
1787 }
1788
1789 int nb = node->GetNumChildren();
1790
1791 MMset(m, 0, nb);
1792
1793 return 0;
1794}
1795
1796
1806{
1807#ifdef SO3_DEBUG
1808 MMechostr(MSKDEBUG, "SO3ObjectRemoveAllChildren\n");
1809#endif
1810
1811 int n = MMget(m, 0);
1812
1813 if (n == NIL)
1814 {
1815 MMset(m, 0, NIL);
1816 return 0;
1817 }
1818
1819 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1820 if (node == 0)
1821 {
1822 MMset(m, 0, NIL);
1823 return 0;
1824 }
1825
1826 node->DetachAllChildren();
1827
1828 MMset(m, 0, ITOM(1));
1829 return 0;
1830}
1831
1832
1842{
1843#ifdef SO3_DEBUG
1844 MMechostr(MSKDEBUG, "SO3ObjectGetChildren\n");
1845#endif
1846
1847 int n = MMget(m, 0);
1848
1849 if (n == NIL)
1850 {
1851 MMset(m, 0, NIL);
1852 return 0;
1853 }
1854
1855 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1856 if (node == 0)
1857 {
1858 MMset(m, 0, NIL);
1859 return 0;
1860 }
1861
1862 int tmp_res;
1863 int p = 0;
1864
1865 const SNodeMap childrenNodesListCopy = node->GetChildrenNodes();
1866 SNodeMap::const_iterator iChildrenList = childrenNodesListCopy.begin();
1867
1868 while (iChildrenList != childrenNodesListCopy.end())
1869 {
1870 int c = OBJfindTH(m, SO3OBJTYPE, SCOL_PTR(iChildrenList->second));
1871 if (c != NIL)
1872 c = MMfetch(m, c, OFFOBJMAG);
1873
1874 if (MMpush(m, c))
1875 return MERRMEM;
1876
1877 INVERT(m, 0, 1);
1878 p++;
1879 iChildrenList++;
1880 }
1881 MMpull(m);
1882
1883 if (MMpush(m, NIL))
1884 return MERRMEM;
1885
1886 for (int j = 0; j < p; j++)
1887 {
1888 if (MMpush(m, 2 * 2))
1889 return MERRMEM;
1890
1891 if (int k = MBdeftab(m))
1892 return k;
1893 }
1894 return 0;
1895}
1896
1897
1906int SO3ObjectDestroy(mmachine m)
1907{
1908#ifdef SO3_DEBUG
1909 MMechostr(MSKDEBUG, "SO3ObjectDestroy\n");
1910#endif
1911
1912 int n = MMget(m, 0);
1913
1914 if (n == NIL)
1915 {
1916 MMset(m, 0, NIL);
1917 return 0;
1918 }
1919
1920 OBJdelTM(m, SO3OBJTYPE, n);
1921
1922 MMset(m, 0, ITOM(1));
1923 return 0;
1924}
1925
1926
1936{
1937#ifdef SO3_DEBUG
1938 MMechostr(MSKDEBUG, "SO3ObjectSetInitialState\n");
1939#endif
1940
1941 int n = MMget(m, 0);
1942
1943 if (n == NIL)
1944 {
1945 MMechostr(MSKDEBUG, "SO3ObjectSetInitialState : Node is NIL\n");
1946 MMset(m, 0, NIL);
1947 return 0;
1948 }
1949
1950 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1951 if (node == 0)
1952 {
1953 MMechostr(MSKDEBUG, "SO3ObjectSetInitialState : Node is NULL \n");
1954 MMset(m, 0, NIL);
1955 return 0;
1956 }
1957
1958 node->StoreInitialPRS();
1959
1960 MMset(m, 0, ITOM(1));
1961
1962 return 0;
1963}
1964
1965
1975{
1976#ifdef SO3_DEBUG
1977 MMechostr(MSKDEBUG, "SO3ObjectResetToInitialState\n");
1978#endif
1979
1980 int n = MMget(m, 0);
1981
1982 if (n == NIL)
1983 {
1984 MMechostr(MSKDEBUG, "Node is NIL\n");
1985 MMset(m, 0, NIL);
1986 return 0;
1987 }
1988
1989 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1990 if (node == 0)
1991 {
1992 MMset(m, 0, NIL);
1993 return 0;
1994 }
1995
1996 node->ResetToInitialPRS();
1997
1998 MMset(m, 0, ITOM(1));
1999
2000 return 0;
2001}
2002
2003
2013{
2014#ifdef SO3_DEBUG
2015 MMechostr(MSKDEBUG, "SO3ObjectGetSceneRoot\n");
2016#endif
2017
2018 int s = MMget(m, 0);
2019
2020 if (s == NIL)
2021 {
2022 MMset(m, 0, NIL);
2023 return 0;
2024 }
2025
2026 SScene* scene = MMgetPointer<SScene*>(m, MTOP(s));
2027 if (scene == 0)
2028 {
2029 MMset(m, 0, NIL);
2030 return 0;
2031 }
2032
2033 SNode* curNode = scene->GetRootNode();
2034 int so3obj = OBJfindTH(m, SO3OBJTYPE, SCOL_PTR(curNode));
2035
2036 so3obj = MMfetch(m, so3obj, OFFOBJMAG);
2037 MMset(m, 0, so3obj);
2038
2039 return 0;
2040}
2041
2042
2051int SO3ObjectGetParent(mmachine m)
2052{
2053#ifdef SO3_DEBUG
2054 MMechostr(MSKDEBUG, "SO3ObjectGetParent\n");
2055#endif
2056
2057 int n = MMget(m, 0);
2058
2059 if (n == NIL)
2060 {
2061 MMset(m, 0, NIL);
2062 return 0;
2063 }
2064
2065 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
2066 if (node == 0)
2067 {
2068 MMset(m, 0, NIL);
2069 return 0;
2070 }
2071
2072 SNode* parent = node->GetParentSceneNode();
2073 if (parent == 0)
2074 {
2075 MMset(m, 0, NIL);
2076 return 0;
2077 }
2078
2079 int p = OBJfindTH(m, SO3OBJTYPE, SCOL_PTR(parent));
2080
2081 if (p != NIL)
2082 p = MMfetch(m, p, OFFOBJMAG);
2083
2084 MMset(m, 0, p);
2085
2086 return 0;
2087}
2088
2089
2098int SO3ObjectGetScene(mmachine m)
2099{
2100#ifdef SO3_DEBUG
2101 MMechostr(MSKDEBUG, "SO3ObjectGetScene\n");
2102#endif
2103
2104 int n = MMget(m, 0);
2105
2106 if (n == NIL)
2107 {
2108 MMset(m, 0, NIL);
2109 return 0;
2110 }
2111
2112 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
2113 if (node == 0)
2114 {
2115 MMset(m, 0, NIL);
2116 return 0;
2117 }
2118
2119 SScene* scene = node->GetParentScene();
2120 if (scene == 0)
2121 {
2122 MMset(m, 0, NIL);
2123 return 0;
2124 }
2125
2126 int p = OBJfindTH(m, SO3SCENETYPE, SCOL_PTR(scene));
2127
2128 if (p != NIL)
2129 p = MMfetch(m, p, OFFOBJMAG);
2130
2131 MMset(m, 0, p);
2132
2133 return 0;
2134}
2135
2136
2146int SO3ObjectLink(mmachine m)
2147{
2148#ifdef SO3_DEBUG
2149 MMechostr(MSKDEBUG, "SO3ObjectLink\n");
2150#endif
2151
2152 int p = MMpull(m);
2153 int n = MMget(m, 0);
2154
2155 if (n == NIL)
2156 {
2157 MMset(m, 0, NIL);
2158 return 0;
2159 }
2160
2161 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
2162 if (node == 0)
2163 {
2164 MMset(m, 0, NIL);
2165 return 0;
2166 }
2167
2168 SNode* parent = 0;
2169 if (p != NIL)
2170 {
2171 parent = MMgetPointer<SNode*>(m, MTOP(p));
2172 if (parent == 0)
2173 {
2174 MMset(m, 0, NIL);
2175 return 0;
2176 }
2177 }
2178
2179 if (node == parent)
2180 {
2181 MMechostr(MSKRUNTIME, "SO3ObjectLink can't link an object to himslef!\n");
2182 MMset(m, 0, NIL);
2183 return 0;
2184 }
2185
2186 // Exclude case of link bone to object
2187 if (node->GetNodeType() == SNode::BONE_TYPE_ID)
2188 {
2189 MMset(m, 0, NIL);
2190 return 0;
2191 }
2192
2193 if (p == NIL)
2194 node->AttachToParent(node->GetParentScene()->GetRootNode());
2195 else
2196 node->AttachToParent(parent);
2197
2198 MMset(m, 0, ITOM(1));
2199 return 0;
2200}
2201
2202
2213{
2214#ifdef SO3_DEBUG
2215 MMechostr(MSKDEBUG, "SO3ObjectGetPositionInObjectRef\n");
2216#endif
2217
2218 int p = MMpull(m);
2219 int n = MMget(m, 0);
2220
2221 if ((n == NIL) || (p == NIL))
2222 {
2223 MMset(m, 0, NIL);
2224 return 0;
2225 }
2226
2227 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
2228 SNode* parent = MMgetPointer<SNode*>(m, MTOP(p));
2229
2230 if ((node == 0) || (parent == 0))
2231 {
2232 MMset(m, 0, NIL);
2233 return 0;
2234 }
2235
2236 Ogre::Vector3 v = node->GetPositionFromNode(parent);
2237
2238 int tuple = MMmalloc(m, 3, TYPETAB);
2239 if (tuple == NIL)
2240 {
2241 MMset(m, 0, NIL);
2242 return MERRMEM;
2243 }
2244
2245 MMstore(m, tuple, 0, FTOM(v.x));
2246 MMstore(m, tuple, 1, FTOM(v.y));
2247 MMstore(m, tuple, 2, FTOM(v.z));
2248 MMset(m, 0, PTOM(tuple));
2249
2250 return 0;
2251}
2252
2253
2264{
2265#ifdef SO3_DEBUG
2266 MMechostr(MSKDEBUG, "SO3ObjectGetOrientationInObjectRef\n");
2267#endif
2268
2269 int p = MMpull(m);
2270 int n = MMget(m, 0);
2271
2272 if ((n == NIL) || (p == NIL))
2273 {
2274 MMset(m, 0, NIL);
2275 return 0;
2276 }
2277
2278 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
2279 SNode* parent = MMgetPointer<SNode*>(m, MTOP(p));
2280
2281 if ((node == 0) || (parent == 0))
2282 {
2283 MMset(m, 0, NIL);
2284 return 0;
2285 }
2286
2287 Ogre::Quaternion orient = node->GetOrientationFromNode(parent);
2288
2289 int tuple = MMmalloc(m, 4, TYPETAB);
2290 if (tuple == NIL)
2291 {
2292 MMset(m, 0, NIL);
2293 return MERRMEM;
2294 }
2295
2296 MMstore(m, tuple, 0, FTOM((orient.x)));
2297 MMstore(m, tuple, 1, FTOM((orient.y)));
2298 MMstore(m, tuple, 2, FTOM((orient.z)));
2299 MMstore(m, tuple, 3, FTOM((orient.w)));
2300 MMset(m, 0, PTOM(tuple));
2301
2302 return 0;
2303}
2304
2305
2316{
2317#ifdef SO3_DEBUG
2318 MMechostr(MSKDEBUG, "SO3ObjectGetScaleInObjectRef\n");
2319#endif
2320
2321 int p = MMpull(m);
2322 int n = MMget(m, 0);
2323
2324 if ((n == NIL) || (p == NIL))
2325 {
2326 MMset(m, 0, NIL);
2327 return 0;
2328 }
2329
2330 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
2331 SNode* parent = MMgetPointer<SNode*>(m, MTOP(p));
2332
2333 if ((node == 0) || (parent == 0))
2334 {
2335 MMset(m, 0, NIL);
2336 return 0;
2337 }
2338
2339 Ogre::Vector3 scaleResult = node->GetScaleFromNode(parent);
2340
2341 int tuple = MMmalloc(m, 3, TYPETAB);
2342 if (tuple == NIL)
2343 {
2344 MMset(m, 0, NIL);
2345 return MERRMEM;
2346 }
2347
2348 MMstore(m, tuple, 0, FTOM((scaleResult.x)));
2349 MMstore(m, tuple, 1, FTOM((scaleResult.y)));
2350 MMstore(m, tuple, 2, FTOM((scaleResult.z)));
2351 MMset(m, 0, PTOM(tuple));
2352
2353 return 0;
2354}
2355
2356
2365int SO3ObjectUnlink(mmachine m)
2366{
2367#ifdef SO3_DEBUG
2368 MMechostr(MSKDEBUG, "SO3ObjectUnlink\n");
2369#endif
2370
2371 int n = MMget(m, 0);
2372
2373 if (n == NIL)
2374 {
2375 MMset(m, 0, NIL);
2376 return 0;
2377 }
2378
2379 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
2380 if (node == 0)
2381 {
2382 MMset(m, 0, NIL);
2383 return 0;
2384 }
2385
2386 // Detach the node from his parent.
2387 node->DetachFromParent();
2388
2389 MMset(m, 0, ITOM(1));
2390
2391 return 0;
2392}
2393
2394
2407{
2408#ifdef SO3_DEBUG
2409 MMechostr(MSKDEBUG, "SO3ObjectSetAutoTracking\n");
2410#endif
2411
2412 int offset = MMpull(m);
2413 int direction = MMpull(m);
2414 int booleen = MTOI(MMpull(m));
2415 int p = MMpull(m);
2416 int n = MMget(m, 0);
2417
2418 if ((n == NIL) || (p == NIL))
2419 {
2420 MMset(m, 0, NIL);
2421 return 0;
2422 }
2423
2424 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
2425 SNode* parent = MMgetPointer<SNode*>(m, MTOP(p));
2426
2427 if ((node == 0) || (parent == 0))
2428 {
2429 MMset(m, 0, NIL);
2430 return 0;
2431 }
2432
2433 if (parent->GetNodeType() == SNode::BONE_TYPE_ID || node->GetNodeType() == SNode::BONE_TYPE_ID)
2434 {
2435 MMset(m, 0, NIL);
2436 return 0;
2437 }
2438
2439 if (direction == NIL && offset == NIL)
2440 {
2441 if (booleen == 0)
2442 node->SetAutoTracking(false, parent);
2443 else
2444 node->SetAutoTracking(true, parent);
2445 }
2446 else if (direction != NIL && offset == NIL)
2447 {
2448 Ogre::Vector3 dir(Ogre::Vector3::NEGATIVE_UNIT_Z);
2449
2450 if ((MMfetch(m, MTOP(direction), 0) != NIL))
2451 dir.x = MTOF(MMfetch(m, MTOP(direction), 0));
2452 if ((MMfetch(m, MTOP(direction), 1) != NIL))
2453 dir.y = MTOF(MMfetch(m, MTOP(direction), 1));
2454 if ((MMfetch(m, MTOP(direction), 2) != NIL))
2455 dir.z = MTOF(MMfetch(m, MTOP(direction), 2));
2456
2457 if (booleen == 0)
2458 node->SetAutoTracking(false, parent, dir);
2459 else
2460 node->SetAutoTracking(true, parent, dir);
2461 }
2462 else if (direction == NIL && offset != NIL)
2463 {
2464 Ogre::Vector3 dir(Ogre::Vector3::NEGATIVE_UNIT_Z); // Default Value
2465 Ogre::Vector3 off(Ogre::Vector3::ZERO);
2466
2467 if ((MMfetch(m, MTOP(offset), 0) != NIL))
2468 off.x = MTOF(MMfetch(m, MTOP(offset), 0));
2469 if ((MMfetch(m, MTOP(offset), 1) != NIL))
2470 off.y = MTOF(MMfetch(m, MTOP(offset), 1));
2471 if ((MMfetch(m, MTOP(offset), 2) != NIL))
2472 off.z = MTOF(MMfetch(m, MTOP(offset), 2));
2473
2474 if (booleen == 0)
2475 node->SetAutoTracking(false, parent, dir, off);
2476 else
2477 node->SetAutoTracking(true, parent, dir, off);
2478 }
2479 else
2480 {
2481 Ogre::Vector3 dir(Ogre::Vector3::NEGATIVE_UNIT_Z);
2482
2483 if ((MMfetch(m, MTOP(direction), 0) != NIL))
2484 dir.x = MTOF(MMfetch(m, MTOP(direction), 0));
2485 if ((MMfetch(m, MTOP(direction), 1) != NIL))
2486 dir.y = MTOF(MMfetch(m, MTOP(direction), 1));
2487 if ((MMfetch(m, MTOP(direction), 2) != NIL))
2488 dir.z = MTOF(MMfetch(m, MTOP(direction), 2));
2489
2490 Ogre::Vector3 off(Ogre::Vector3::ZERO);
2491
2492 if ((MMfetch(m, MTOP(offset), 0) != NIL))
2493 off.x = MTOF(MMfetch(m, MTOP(offset), 0));
2494 if ((MMfetch(m, MTOP(offset), 1) != NIL))
2495 off.y = MTOF(MMfetch(m, MTOP(offset), 1));
2496 if ((MMfetch(m, MTOP(offset), 2) != NIL))
2497 off.z = MTOF(MMfetch(m, MTOP(offset), 2));
2498
2499 if (booleen == 0)
2500 node->SetAutoTracking(false, parent, dir, off);
2501 else
2502 node->SetAutoTracking(true, parent, dir, off);
2503 }
2504
2505 MMset(m, 0, ITOM(1));
2506 return 0;
2507}
2508
2509
2520{
2521#ifdef SO3_DEBUG
2522 MMechostr(MSKDEBUG, "SO3ObjectSetRenderingDistance\n");
2523#endif
2524
2525 int value = MMpull(m);
2526 int n = MMget(m, 0);
2527
2528 if (n == NIL)
2529 {
2530 MMset(m, 0, NIL);
2531 return 0;
2532 }
2533
2534 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
2535 if (node == 0)
2536 {
2537 MMset(m, 0, NIL);
2538 return 0;
2539 }
2540
2541 float fvalue = (value == NIL) ? 0.0f : MTOF(value);
2542
2543 try
2544 {
2545 node->SetRenderingDistance(fvalue);
2546 }
2547 catch (Ogre::Exception &e)
2548 {
2549 MMechostr(MSKDEBUG, "An exception has occurred: %s\n", e.what());
2550
2551 MMset(m, 0, NIL);
2552 return 0;
2553 }
2554
2555 MMset(m, 0, ITOM(1));
2556 return 0;
2557}
2558
2559
2569{
2570#ifdef SO3_DEBUG
2571 MMechostr(MSKDEBUG, "SO3ObjectGetRenderingDistance\n");
2572#endif
2573
2574 int n = MMget(m, 0);
2575
2576 if (n == NIL)
2577 {
2578 MMset(m, 0, NIL);
2579 return 0;
2580 }
2581
2582 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
2583 if (node == 0)
2584 {
2585 MMset(m, 0, NIL);
2586 return 0;
2587 }
2588
2589 float value = 0;
2590 try
2591 {
2592 value = node->GetRenderingDistance();
2593 }
2594 catch (Ogre::Exception &e)
2595 {
2596 MMechostr(MSKDEBUG, "An exception has occurred: %s\n", e.what());
2597
2598 MMset(m, 0, NIL);
2599 return 0;
2600 }
2601
2602 MMset(m, 0, FTOM(value));
2603 return 0;
2604}
2605
2606
2617{
2618#ifdef SO3_DEBUG
2619 MMechostr(MSKDEBUG, "SO3ObjectSetCastShadows\n");
2620#endif
2621
2622 int booleen = MTOI(MMpull(m));
2623 int n = MMget(m, 0);
2624
2625 if (n == NIL)
2626 {
2627 MMset(m, 0, NIL);
2628 return 0;
2629 }
2630
2631 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
2632 if (node == 0)
2633 {
2634 MMset(m, 0, NIL);
2635 return 0;
2636 }
2637
2638 try
2639 {
2640 if (booleen == SO3_FALSE)
2641 node->SetCastShadows(false);
2642 else
2643 node->SetCastShadows(true);
2644 }
2645 catch (Ogre::Exception &e)
2646 {
2647 MMechostr(MSKDEBUG, "An exception has occurred: %s\n", e.what());
2648
2649 MMset(m, 0, NIL);
2650 return 0;
2651 }
2652
2653 MMset(m, 0, ITOM(1));
2654 return 0;
2655}
2656
2657
2671{
2672#ifdef SO3_DEBUG
2673 MMechostr(MSKDEBUG, "SO3ObjectGetBoundingBoxInfo\n");
2674#endif
2675
2676 int ichilds = MMpull(m);
2677 int n = MMget(m, 0);
2678 if (n == NIL)
2679 {
2680 MMset(m, 0, NIL);
2681 return 0;
2682 }
2683
2684 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
2685 if (node == 0)
2686 {
2687 MMset(m, 0, NIL);
2688 return 0;
2689 }
2690
2691 Ogre::Vector3 sizeBB(0.0f, 0.0f, 0.0f);
2692 Ogre::Vector3 position(0.0f, 0.0f, 0.0f);
2693 Ogre::Quaternion quat;
2694
2695 bool childs = false;
2696 if ((ichilds != NIL) && (MTOI(ichilds) == 1))
2697 childs = true;
2698
2699 try
2700 {
2701 sizeBB = node->GetBoundingBoxSize(childs);
2702 }
2703 catch (std::exception &e)
2704 {
2705 MMechostr(MSKDEBUG, "An exception has occurred: %s\n", e.what());
2706
2707 MMset(m, 0, NIL);
2708 return 0;
2709 }
2710
2711 try
2712 {
2713 position = node->GetBoundingBoxCenter(childs);
2714 }
2715 catch (std::exception &)
2716 {
2717 }
2718
2719 quat = node->GetOrientation();
2720
2721 // Size
2722 int size = MMmalloc(m, 3, TYPETAB);
2723 if (size == NIL)
2724 {
2725 MMset(m, 0, NIL);
2726 return MERRMEM;
2727 }
2728
2729 MMstore(m, size, 0, FTOM(sizeBB.x));
2730 MMstore(m, size, 1, FTOM(sizeBB.y));
2731 MMstore(m, size, 2, FTOM(sizeBB.z));
2732 MMpush(m, PTOM(size));
2733
2734 // pos
2735 int pos = MMmalloc(m, 3, TYPETAB);
2736 if (pos == NIL)
2737 {
2738 MMpull(m);
2739 MMset(m, 0, NIL);
2740 return MERRMEM;
2741 }
2742
2743 MMstore(m, pos, 0, FTOM(position.x));
2744 MMstore(m, pos, 1, FTOM(position.y));
2745 MMstore(m, pos, 2, FTOM(position.z));
2746 MMpush(m, PTOM(pos));
2747
2748 // orient
2749 int orient = MMmalloc(m, 4, TYPETAB);
2750 if (orient == NIL)
2751 {
2752 MMpull(m);
2753 MMpull(m);
2754 MMset(m, 0, NIL);
2755 return MERRMEM;
2756 }
2757
2758 MMstore(m, orient, 0, FTOM(quat.x));
2759 MMstore(m, orient, 1, FTOM(quat.y));
2760 MMstore(m, orient, 2, FTOM(quat.z));
2761 MMstore(m, orient, 3, FTOM(quat.w));
2762 MMpush(m, PTOM(orient));
2763
2764 // FINAL TUPPLE
2765 int result = MMmalloc(m, 3, TYPETAB);
2766 if (result == NIL)
2767 {
2768 MMpull(m);
2769 MMpull(m);
2770 MMpull(m);
2771 MMset(m, 0, NIL);
2772 return MERRMEM;
2773 }
2774
2775 MMstore(m, result, 2, MMpull(m));
2776 MMstore(m, result, 1, MMpull(m));
2777 MMstore(m, result, 0, MMpull(m));
2778 MMset(m, 0, PTOM(result));
2779
2780 return 0;
2781}
2782
2783
2797{
2798#ifdef SO3_DEBUG
2799 MMechostr(MSKDEBUG, "SO3ObjectGetWorldBoundingBoxInfo\n");
2800#endif
2801
2802 int ichilds = MMpull(m);
2803 int n = MMget(m, 0);
2804 if (n == NIL)
2805 {
2806 MMset(m, 0, NIL);
2807 return 0;
2808 }
2809
2810 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
2811 if (node == 0)
2812 {
2813 MMset(m, 0, NIL);
2814 return 0;
2815 }
2816
2817 Ogre::Vector3 sizeBB(0.0f, 0.0f, 0.0f);
2818 Ogre::Vector3 position(0.0f, 0.0f, 0.0f);
2819 Ogre::Quaternion quat;
2820
2821 bool childs = false;
2822 if ((ichilds != NIL) && (MTOI(ichilds) == 1))
2823 childs = true;
2824
2825 try
2826 {
2827 sizeBB = node->GetWorldBoundingBoxSize(childs);
2828 }
2829 catch (std::exception &e)
2830 {
2831 MMechostr(MSKDEBUG, "An exception has occurred: %s\n", e.what());
2832
2833 MMset(m, 0, NIL);
2834 return 0;
2835 }
2836
2837 try
2838 {
2839 position = node->GetWorldBoundingBoxCenter(childs);
2840 }
2841 catch (std::exception &)
2842 {
2843 }
2844
2845 quat = node->GetOrientation();
2846
2847 // Size
2848 int size = MMmalloc(m, 3, TYPETAB);
2849 if (size == NIL)
2850 {
2851 MMset(m, 0, NIL);
2852 return MERRMEM;
2853 }
2854
2855 MMstore(m, size, 0, FTOM(sizeBB.x));
2856 MMstore(m, size, 1, FTOM(sizeBB.y));
2857 MMstore(m, size, 2, FTOM(sizeBB.z));
2858 MMpush(m, PTOM(size));
2859
2860 // pos
2861 int pos = MMmalloc(m, 3, TYPETAB);
2862 if (pos == NIL)
2863 {
2864 MMpull(m);
2865 MMset(m, 0, NIL);
2866 return MERRMEM;
2867 }
2868
2869 MMstore(m, pos, 0, FTOM(position.x));
2870 MMstore(m, pos, 1, FTOM(position.y));
2871 MMstore(m, pos, 2, FTOM(position.z));
2872 MMpush(m, PTOM(pos));
2873
2874 // orient
2875 int orient = MMmalloc(m, 4, TYPETAB);
2876 if (orient == NIL)
2877 {
2878 MMpull(m);
2879 MMpull(m);
2880 MMset(m, 0, NIL);
2881 return MERRMEM;
2882 }
2883
2884 MMstore(m, orient, 0, FTOM(quat.x));
2885 MMstore(m, orient, 1, FTOM(quat.y));
2886 MMstore(m, orient, 2, FTOM(quat.z));
2887 MMstore(m, orient, 3, FTOM(quat.w));
2888 MMpush(m, PTOM(orient));
2889
2890 // FINAL TUPPLE
2891 int result = MMmalloc(m, 3, TYPETAB);
2892 if (result == NIL)
2893 {
2894 MMpull(m);
2895 MMpull(m);
2896 MMpull(m);
2897 MMset(m, 0, NIL);
2898 return MERRMEM;
2899 }
2900
2901 MMstore(m, result, 2, MMpull(m));
2902 MMstore(m, result, 1, MMpull(m));
2903 MMstore(m, result, 0, MMpull(m));
2904 MMset(m, 0, PTOM(result));
2905
2906 return 0;
2907}
2908
2918{
2919#ifdef SO3_DEBUG
2920 MMechostr(MSKDEBUG, "SO3ObjectGetCastShadows\n");
2921#endif
2922
2923 int n = MMget(m, 0);
2924
2925 if (n == NIL)
2926 {
2927 MMset(m, 0, NIL);
2928 return 0;
2929 }
2930
2931 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
2932 if (node == 0)
2933 {
2934 MMset(m, 0, NIL);
2935 return 0;
2936 }
2937
2938 int booleen = 0;
2939 try
2940 {
2941 if (node->GetCastShadows())
2942 booleen = 1;
2943 }
2944 catch (Ogre::Exception &e)
2945 {
2946 MMechostr(MSKDEBUG, "An exception has occurred: %s\n", e.what());
2947
2948 MMset(m, 0, NIL);
2949 return 0;
2950 }
2951
2952 MMset(m, 0, ITOM(booleen));
2953
2954 return 0;
2955}
2956
2957
2967{
2968#ifdef SO3_DEBUG
2969 MMechostr(MSKDEBUG, "SO3ObjectGetPolygonCount\n");
2970#endif
2971
2972 int n = MMget(m, 0);
2973
2974 if (n == NIL)
2975 {
2976 MMset(m, 0, NIL);
2977 return 0;
2978 }
2979
2980 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
2981 if (node == 0)
2982 {
2983 MMset(m, 0, NIL);
2984 return 0;
2985 }
2986
2987 if (node->GetNodeType() != SNode::ENTITY_TYPE_ID)
2988 {
2989 MMset(m, 0, NIL);
2990 return 0;
2991 }
2992
2993 SEntity* entity = static_cast<SEntity*>(node);
2994 MMset(m, 0, ITOM(entity->GetPolygonCount()));
2995
2996 return 0;
2997}
2998
2999
3009{
3010#ifdef SO3_DEBUG
3011 MMechostr(MSKDEBUG, "SO3ObjectGetVerticesCount\n");
3012#endif
3013
3014 int n = MMget(m, 0);
3015
3016 if (n == NIL)
3017 {
3018 MMset(m, 0, NIL);
3019 return 0;
3020 }
3021
3022 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
3023 if (node == 0)
3024 {
3025 MMset(m, 0, NIL);
3026 return 0;
3027 }
3028
3029 if (node->GetNodeType() != SNode::ENTITY_TYPE_ID)
3030 {
3031 MMset(m, 0, NIL);
3032 return 0;
3033 }
3034
3035 SEntity* entity = static_cast<SEntity*>(node);
3036 MMset(m, 0, ITOM(entity->GetVerticesCount()));
3037
3038 return 0;
3039}
3040
3041
3052{
3053#ifdef SO3_DEBUG
3054 MMechostr(MSKDEBUG, "SO3ObjectSetMouseForeGround\n");
3055#endif
3056
3057 int i = MTOI(MMpull(m));
3058 int n = MMget(m, 0);
3059
3060 if ((i == NIL) || (n == NIL))
3061 {
3062 MMset(m, 0, NIL);
3063 return 0;
3064 }
3065
3066 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
3067 if (node == 0)
3068 {
3069 MMset(m, 0, NIL);
3070 return 0;
3071 }
3072
3073 if (node->GetNodeType() != SNode::ENTITY_TYPE_ID)
3074 {
3075 MMset(m, 0, NIL);
3076 return 0;
3077 }
3078
3079 if (i == 0)
3080 node->SetSceneNodeIsMouseForeground(false);
3081 else
3082 node->SetSceneNodeIsMouseForeground(true);
3083
3084 MMset(m, 0, ITOM(i));
3085
3086 return 0;
3087}
3088
3089
3100{
3101#ifdef SO3_DEBUG
3102 MMechostr(MSKDEBUG, "SO3ObjectSetMouseClick\n");
3103#endif
3104
3105 int i = MTOI(MMpull(m));
3106 int n = MMget(m, 0);
3107
3108 if ((i == NIL) || (n == NIL))
3109 {
3110 MMset(m, 0, NIL);
3111 return 0;
3112 }
3113
3114 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
3115 if (node == 0)
3116 {
3117 MMset(m, 0, NIL);
3118 return 0;
3119 }
3120
3121 if (node->GetNodeType() != SNode::ENTITY_TYPE_ID)
3122 {
3123 MMset(m, 0, NIL);
3124 return 0;
3125 }
3126
3127 if (i == 0)
3128 node->SetSceneNodeIsMouseClick(false);
3129 else
3130 node->SetSceneNodeIsMouseClick(true);
3131
3132 MMset(m, 0, ITOM(i));
3133
3134 return 0;
3135}
3136
3137
3147{
3148#ifdef SO3_DEBUG
3149 MMechostr(MSKDEBUG, "SO3ObjectGetMouseForeGround\n");
3150#endif
3151
3152 int n = MMget(m, 0);
3153
3154 if (n == NIL)
3155 {
3156 MMset(m, 0, NIL);
3157 return 0;
3158 }
3159
3160 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
3161 if (node == 0)
3162 {
3163 MMset(m, 0, NIL);
3164 return 0;
3165 }
3166
3167 if (node->GetNodeType() != SNode::ENTITY_TYPE_ID)
3168 {
3169 MMset(m, 0, NIL);
3170 return 0;
3171 }
3172
3173 int result = 0;
3174
3175 if (node->GetSceneNodeIsMouseForeground())
3176 result = 1;
3177
3178 MMset(m, 0, ITOM(result));
3179
3180 return 0;
3181}
3182
3183
3193{
3194#ifdef SO3_DEBUG
3195 MMechostr(MSKDEBUG, "SO3ObjectGetMouseClick\n");
3196#endif
3197
3198 int n = MMget(m, 0);
3199
3200 if (n == NIL)
3201 {
3202 MMset(m, 0, NIL);
3203 return 0;
3204 }
3205
3206 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
3207 if (node == 0)
3208 {
3209 MMset(m, 0, NIL);
3210 return 0;
3211 }
3212
3213 if (node->GetNodeType() != SNode::ENTITY_TYPE_ID)
3214 {
3215 MMset(m, 0, NIL);
3216 return 0;
3217 }
3218
3219 int result = 0;
3220
3221 if (node->GetSceneNodeIsMouseClick())
3222 result = 1;
3223
3224 MMset(m, 0, ITOM(result));
3225
3226 return 0;
3227}
3228
3229
3239int SO3ObjectSetFlags(mmachine m)
3240{
3241#ifdef SO3_DEBUG
3242 MMechostr(MSKDEBUG, "SO3ObjectSetFlags\n");
3243#endif
3244
3245 int i = MMpull(m);
3246 int n = MMget(m, 0);
3247 if ((i == NIL) || (n == NIL))
3248 {
3249 MMset(m, 0, NIL);
3250 return 0;
3251 }
3252
3253 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
3254 if (node == 0)
3255 {
3256 MMset(m, 0, NIL);
3257 return 0;
3258 }
3259
3260 node->SetFlags(MTOI(i));
3261
3262 MMset(m, 0, i);
3263 return 0;
3264}
3265
3266
3275int SO3ObjectGetFlags(mmachine m)
3276{
3277#ifdef SO3_DEBUG
3278 MMechostr(MSKDEBUG, "SO3ObjectGetFlags\n");
3279#endif
3280
3281 int n = MMget(m, 0);
3282 if (n == NIL)
3283 {
3284 MMset(m, 0, NIL);
3285 return 0;
3286 }
3287
3288 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
3289 if (node == 0)
3290 {
3291 MMset(m, 0, NIL);
3292 return 0;
3293 }
3294
3295 MMset(m, 0, ITOM(node->GetFlags()));
3296 return 0;
3297}
3298
3299
3310{
3311#ifdef SO3_DEBUG
3312 MMechostr(MSKDEBUG, "SO3ObjectSetRenderOverlay\n");
3313#endif
3314
3315 int booleen = MTOI(MMpull(m));
3316 int n = MMget(m, 0);
3317
3318 if (n == NIL)
3319 {
3320 MMset(m, 0, NIL);
3321 return 0;
3322 }
3323
3324 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
3325 if (node == 0)
3326 {
3327 MMset(m, 0, NIL);
3328 return 0;
3329 }
3330
3331 if (node->GetNodeType() != SNode::ENTITY_TYPE_ID)
3332 {
3333 MMset(m, 0, NIL);
3334 return 0;
3335 }
3336
3337 SEntity* entity = static_cast<SEntity*>(node);
3338
3339 if (booleen == 0)
3340 entity->SetRenderQueue(Ogre::RENDER_QUEUE_MAIN);
3341 else
3342 entity->SetRenderQueue(Ogre::RENDER_QUEUE_OVERLAY);
3343
3344 MMset(m, 0, ITOM(1));
3345
3346 return 0;
3347}
3348
3359{
3360#ifdef SO3_DEBUG
3361 MMechostr(MSKDEBUG, "SO3ObjectSetRenderQueue\n");
3362#endif
3363
3364 int val = MMpull(m);
3365 int n = MMget(m, 0);
3366
3367 if (n == NIL)
3368 {
3369 MMset(m, 0, NIL);
3370 return 0;
3371 }
3372
3373 if (val == NIL)
3374 val = Ogre::RENDER_QUEUE_MAIN;
3375 else
3376 val = MTOI(val);
3377
3378 if (val >= Ogre::RENDER_QUEUE_MAX)
3379 val = Ogre::RENDER_QUEUE_MAX-1;
3380 else if (val < Ogre::RENDER_QUEUE_1)
3381 val = Ogre::RENDER_QUEUE_1;
3382
3383 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
3384 if (node == 0)
3385 {
3386 MMset(m, 0, NIL);
3387 return 0;
3388 }
3389
3390 if (node->GetNodeType() != SNode::ENTITY_TYPE_ID)
3391 {
3392 MMset(m, 0, NIL);
3393 return 0;
3394 }
3395
3396 SEntity* entity = static_cast<SEntity*>(node);
3397 entity->SetRenderQueue((Ogre::RenderQueueGroupID)val);
3398
3399 MMset(m, 0, ITOM(1));
3400
3401 return 0;
3402}
3403
3417int SO3ObjectGetInfo(mmachine m)
3418{
3419#ifdef SO3_DEBUG
3420 MMechostr(MSKDEBUG, "SO3ObjectGetInfo\n");
3421#endif
3422
3423 int x = MMpull(m);
3424 int y = MMpull(m);
3425 int v = MMget(m, 0);
3426
3427 if ((v == NIL) || (x == NIL) || (y == NIL))
3428 {
3429 MMset(m, 0, NIL);
3430 return 0;
3431 }
3432
3433 SViewPort* viewport = MMgetPointer<SViewPort*>(m, MTOP(v));
3434 if (viewport == 0)
3435 {
3436 MMset(m, 0, NIL);
3437 return 0;
3438 }
3439
3440 SRaycastResult rayCastResults = viewport->RayCast(MTOI(y), MTOI(x));
3441
3442 int ent = OBJfindTH(m, SO3OBJTYPE, SCOL_PTR(rayCastResults.entity));
3443 if (ent != NIL)
3444 ent = MMfetch(m, ent, OFFOBJMAG);
3445
3446 createOrRetrieveScolMaterialAndSendToVM(m, rayCastResults.scene, rayCastResults.material);
3447 int mat = MMpull(m);
3448
3449 int tuple = MMmalloc(m, 3, TYPETAB);
3450 if (tuple == NIL)
3451 {
3452 MMset(m, 0, NIL);
3453 return MERRMEM;
3454 }
3455
3456 MMstore(m, tuple, 0, ent == 0 ? NIL : ent);
3457 MMstore(m, tuple, 1, mat);
3458 MMstore(m, tuple, 2, ITOM(rayCastResults.indexSubEntity));
3459 MMset(m, 0, PTOM(tuple));
3460
3461 return 0;
3462}
3463
3487int SO3ObjectGetInfoEx(mmachine m)
3488{
3489#ifdef SO3_DEBUG
3490 MMechostr(MSKDEBUG, "SO3ObjectGetInfoEx\n");
3491#endif
3492
3493 int x = MMpull(m);
3494 int y = MMpull(m);
3495 int v = MMget(m, 0);
3496
3497 if ((v == NIL) || (x == NIL) || (y == NIL))
3498 {
3499 MMset(m, 0, NIL);
3500 return 0;
3501 }
3502
3503 SViewPort* viewport = MMgetPointer<SViewPort*>(m, MTOP(v));
3504 if (viewport == 0)
3505 {
3506 MMset(m, 0, NIL);
3507 return 0;
3508 }
3509
3510 SRaycastResult rayCastResults = viewport->RayCast(MTOI(y), MTOI(x));
3511
3512 int ent = OBJfindTH(m, SO3OBJTYPE, SCOL_PTR(rayCastResults.entity));
3513 if (ent == NIL)
3514 {
3515 // nothing found just return
3516 MMset(m, 0, NIL);
3517 return 0;
3518 }
3519
3520 //remove last parameter
3521 MMpull(m);
3522
3523 ent = MMfetch(m, ent, OFFOBJMAG);
3524 MMpush(m, ent);
3525
3526 //push mat
3527 createOrRetrieveScolMaterialAndSendToVM(m, rayCastResults.scene, rayCastResults.material);
3528
3529 MMpush(m, ITOM(rayCastResults.indexSubEntity));
3530 MMpush(m, FTOM(rayCastResults.closestDistance));
3531 MMpush(m, ITOM(rayCastResults.indexFace));
3532
3533 // FaceData
3534 // Coordinates of the vertices of the face
3535 // v1
3536 int vertex1 = MMmalloc(m, 3, TYPETAB);
3537 if (vertex1 == NIL)
3538 {
3539 return MERRMEM;
3540 }
3541
3542 MMstore(m, vertex1, 0, FTOM(rayCastResults.v1.x));
3543 MMstore(m, vertex1, 1, FTOM(rayCastResults.v1.y));
3544 MMstore(m, vertex1, 2, FTOM(rayCastResults.v1.z));
3545 MMpush(m, PTOM(vertex1));
3546
3547 // v2
3548 int vertex2 = MMmalloc(m, 3, TYPETAB);
3549 if (vertex2 == NIL)
3550 {
3551 return MERRMEM;
3552 }
3553
3554 MMstore(m, vertex2, 0, FTOM(rayCastResults.v2.x));
3555 MMstore(m, vertex2, 1, FTOM(rayCastResults.v2.y));
3556 MMstore(m, vertex2, 2, FTOM(rayCastResults.v2.z));
3557 MMpush(m, PTOM(vertex2));
3558
3559 // v3
3560 int vertex3 = MMmalloc(m, 3, TYPETAB);
3561 if (vertex3 == NIL)
3562 {
3563 return MERRMEM;
3564 }
3565
3566 MMstore(m, vertex3, 0, FTOM(rayCastResults.v3.x));
3567 MMstore(m, vertex3, 1, FTOM(rayCastResults.v3.y));
3568 MMstore(m, vertex3, 2, FTOM(rayCastResults.v3.z));
3569 MMpush(m, PTOM(vertex3));
3570
3571 // UV Coordinates of the vertices of the face
3572 //pReal1
3573 int uv1 = MMmalloc(m, 2, TYPETAB);
3574 if (uv1 == NIL)
3575 {
3576 return MERRMEM;
3577 }
3578
3579 MMstore(m, uv1, 0, FTOM(rayCastResults.pReal1[0]));
3580 MMstore(m, uv1, 1, FTOM(rayCastResults.pReal1[1]));
3581 MMpush(m, PTOM(uv1));
3582
3583 //pReal2
3584 int uv2 = MMmalloc(m, 2, TYPETAB);
3585 if (uv2 == NIL)
3586 {
3587 return MERRMEM;
3588 }
3589 MMstore(m, uv2, 0, FTOM(rayCastResults.pReal2[0]));
3590 MMstore(m, uv2, 1, FTOM(rayCastResults.pReal2[1]));
3591 MMpush(m, PTOM(uv2));
3592
3593 //pReal3
3594 int uv3 = MMmalloc(m, 2, TYPETAB);
3595 if (uv3 == NIL)
3596 {
3597 return MERRMEM;
3598 }
3599 MMstore(m, uv3, 0, FTOM(rayCastResults.pReal3[0]));
3600 MMstore(m, uv3, 1, FTOM(rayCastResults.pReal3[1]));
3601 MMpush(m, PTOM(uv3));
3602
3603 // Coordinate of the intersection point
3604 int inter = MMmalloc(m, 3, TYPETAB);
3605 if (inter == NIL)
3606 {
3607 return MERRMEM;
3608 }
3609
3610 MMstore(m, inter, 0, FTOM(rayCastResults.point.x));
3611 MMstore(m, inter, 1, FTOM(rayCastResults.point.y));
3612 MMstore(m, inter, 2, FTOM(rayCastResults.point.z));
3613 MMpush(m, PTOM(inter));
3614
3615 // UV coordinates of the intersection point
3616 int uvf = MMmalloc(m, 2, TYPETAB);
3617 if (uvf == NIL)
3618 {
3619 return MERRMEM;
3620 }
3621
3622 MMstore(m, uvf, 0, FTOM(rayCastResults.uvResult.x));
3623 MMstore(m, uvf, 1, FTOM(rayCastResults.uvResult.y));
3624 MMpush(m, PTOM(uvf));
3625
3626 MMpush(m, 26);
3627 MBdeftab(m);
3628
3629 return 0;
3630}
3631
3632
3642{
3643#ifdef SO3_DEBUG
3644 MMechostr(MSKDEBUG, "SO3ObjectGetScreenCoord\n");
3645#endif
3646
3647 int v = MMpull(m);
3648 int n = MMget(m, 0);
3649
3650 if ((n == NIL) || (v == NIL))
3651 {
3652 MMset(m, 0, NIL);
3653 return 0;
3654 }
3655
3656 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
3657 if (node == 0)
3658 {
3659 MMset(m, 0, NIL);
3660 return 0;
3661 }
3662
3663 SViewPort* viewport = MMgetPointer<SViewPort*>(m, MTOP(v));
3664 if (viewport == 0)
3665 {
3666 MMset(m, 0, NIL);
3667 return 0;
3668 }
3669
3670 SCamera* camera = viewport->GetCamera();
3671 if (camera == 0)
3672 {
3673 MMset(m, 0, NIL);
3674 return 0;
3675 }
3676
3677 Ogre::Vector2 result;
3678 Ogre::Vector3 point = node->GetGlobalPosition();
3679
3680 // Is the camera facing that point? If not, return false
3681 if (camera->IsFacingPoint(point))
3682 {
3683 MMset(m, 0, NIL);
3684 return 0;
3685 }
3686
3687 // Transform the 3D point into screen space
3688 point = camera->ToScreenSpace(point);
3689
3690 // Transform from coordinate space [-1, 1] to [0, 1] and update in-value
3691 result.x = (point.x / 2) + 0.5f;
3692 result.y = 1 - ((point.y / 2) + 0.5f);
3693
3694 int tuple = MMmalloc(m, 2, TYPETAB);
3695 if (tuple == NIL)
3696 {
3697 MMset(m, 0, NIL);
3698 return MERRMEM;
3699 }
3700
3701 MMstore(m, tuple, 0, FTOM((result.x)));
3702 MMstore(m, tuple, 1, FTOM((result.y)));
3703 MMset(m, 0, PTOM(tuple));
3704
3705 return 0;
3706}
3707
3708
3719{
3720#ifdef SO3_DEBUG
3721 MMechostr(MSKDEBUG, "SO3ObjectGetScreenPixelCoord\n");
3722#endif
3723
3724 int vp = MMpull(m);
3725 int n = MMget(m, 0);
3726
3727 if ((n == NIL) || (vp == NIL))
3728 {
3729 MMset(m, 0, NIL);
3730 return 0;
3731 }
3732
3733 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
3734 if (node == 0)
3735 {
3736 MMset(m, 0, NIL);
3737 return 0;
3738 }
3739
3740 SViewPort* viewport = MMgetPointer<SViewPort*>(m, MTOP(vp));
3741 if (viewport == 0)
3742 {
3743 MMechostr(MSKDEBUG, "vp is NULL \n");
3744 MMset(m, 0, NIL);
3745 return 0;
3746 }
3747
3748 SCamera* camera = viewport->GetCamera();
3749 if (camera == 0)
3750 {
3751 MMset(m, 0, NIL);
3752 return 0;
3753 }
3754
3755 Ogre::Vector2 result;
3756 Ogre::Vector3 point = node->GetGlobalPosition();
3757
3758 // Is the camera facing that point? If not, return false
3759 if (camera->IsFacingPoint(point))
3760 {
3761 MMset(m, 0, NIL);
3762 return 0;
3763 }
3764
3765 // Transform the 3D point into screen space
3766 point = camera->ToScreenSpace(point);
3767
3768 // Transform from coordinate space [-1, 1] to [0, 1] and update in-value
3769 result.x = (point.x / 2) + 0.5f;
3770 result.y = 1 - ((point.y / 2) + 0.5f);
3771
3772 result.x *= viewport->GetWidthPixels();
3773 result.y *= viewport->GetHeightPixels();
3774
3775 int tuple = MMmalloc(m, 2, TYPETAB);
3776 if (tuple == NIL)
3777 {
3778 MMset(m, 0, NIL);
3779 return MERRMEM;
3780 }
3781
3782 MMstore(m, tuple, 0, ITOM(((int)result.x)));
3783 MMstore(m, tuple, 1, ITOM(((int)result.y)));
3784 MMset(m, 0, PTOM(tuple));
3785
3786 return 0;
3787}
3788
3789
3802{
3803 //$BB rewrited using a direction vector and the getRotationTo methode
3804#ifdef SO3_DEBUG
3805 MMechostr(MSKDEBUG, "SO3ObjectGetNodeFacingOrientation\n");
3806#endif
3807
3808 int axis = MMpull(m);
3809 int dir = MMpull(m);
3810 int des = MMpull(m);
3811 int src = MMget(m, 0);
3812
3813 if ((des == NIL) || (src == NIL))
3814 {
3815 MMset(m, 0, NIL);
3816 return 0;
3817 }
3818
3819 SNode* srcnode = MMgetPointer<SNode*>(m, MTOP(src));
3820 if (srcnode == 0)
3821 {
3822 MMset(m, 0, NIL);
3823 return 0;
3824 }
3825
3826 SNode* destnode = MMgetPointer<SNode*>(m, MTOP(des));
3827 if (destnode == 0)
3828 {
3829 MMset(m, 0, NIL);
3830 return 0;
3831 }
3832
3833 Ogre::Vector3 uDir = Ogre::Vector3::NEGATIVE_UNIT_Z;
3834
3835 if (dir != NIL)
3836 {
3837 if (MMfetch(m, MTOP(dir), 0) != NIL)
3838 uDir.x = MTOF(MMfetch(m, MTOP(dir), 0));
3839 if (MMfetch(m, MTOP(dir), 1) != NIL)
3840 uDir.y = MTOF(MMfetch(m, MTOP(dir), 1));
3841 if (MMfetch(m, MTOP(dir), 2) != NIL)
3842 uDir.z = MTOF(MMfetch(m, MTOP(dir), 2));
3843 }
3844 uDir.normalise();
3845
3846 Ogre::Vector3 uAxis;
3847 uAxis.x = 1;
3848 uAxis.y = 1;
3849 uAxis.z = 1;
3850
3851 if (axis != NIL)
3852 {
3853 if (MMfetch(m, MTOP(axis), 0) != NIL)
3854 uAxis.x = (float)MTOI(MMfetch(m, MTOP(axis), 0));
3855 if (MMfetch(m, MTOP(axis), 1) != NIL)
3856 uAxis.y = (float)MTOI(MMfetch(m, MTOP(axis), 1));
3857 if (MMfetch(m, MTOP(axis), 2) != NIL)
3858 uAxis.z = (float)MTOI(MMfetch(m, MTOP(axis), 2));
3859 }
3860 uAxis.normalise();
3861
3862 // see http://www.ogre3d.org/wiki/index.php/Quaternion_and_Rotation_Primer
3863 Ogre::Vector3 direction = srcnode->GetGlobalPosition() - destnode->GetGlobalPosition();
3864 Ogre::Vector3 srcvec = destnode->GetGlobalOrientation() * uDir;
3865 srcvec.normalise();
3866 direction.normalise();
3867
3868 Ogre::Quaternion dirQuat = srcvec.getRotationTo(direction) * destnode->GetGlobalOrientation();
3869
3870 Ogre::Vector3 xaxis = srcnode->GetGlobalOrientation().xAxis();
3871 Ogre::Vector3 yaxis = srcnode->GetGlobalOrientation().yAxis();
3872 Ogre::Vector3 zaxis = srcnode->GetGlobalOrientation().zAxis();
3873
3874 Ogre::Vector3 dxaxis = dirQuat.xAxis();
3875 Ogre::Vector3 dyaxis = dirQuat.yAxis();
3876 Ogre::Vector3 dzaxis = dirQuat.zAxis();
3877
3878 Ogre::Vector3 fxaxis;
3879 Ogre::Vector3 fyaxis;
3880 Ogre::Vector3 fzaxis;
3881
3882 if (uAxis.x)
3883 fxaxis = dxaxis;
3884 else
3885 fxaxis = xaxis;
3886
3887 if (uAxis.y)
3888 fyaxis = dyaxis;
3889 else
3890 fyaxis = yaxis;
3891
3892 if (uAxis.z)
3893 fzaxis = dzaxis;
3894 else
3895 fzaxis = zaxis;
3896
3897 Ogre::Quaternion returnQuat = Ogre::Quaternion(fxaxis, fyaxis, fzaxis);
3898 int tuple = MMmalloc(m, 4, TYPETAB);
3899 if (tuple == NIL)
3900 {
3901 MMset(m, 0, NIL);
3902 return MERRMEM;
3903 }
3904
3905 MMstore(m, tuple, 0, FTOM((returnQuat.x)));
3906 MMstore(m, tuple, 1, FTOM((returnQuat.y)));
3907 MMstore(m, tuple, 2, FTOM((returnQuat.z)));
3908 MMstore(m, tuple, 3, FTOM((returnQuat.w)));
3909 MMset(m, 0, PTOM(tuple));
3910
3911 return 0;
3912}
3913
3914
3925{
3926#ifdef SO3_DEBUG
3927 MMechostr(MSKDEBUG, "SO3ObjectGetAnimation\n");
3928#endif
3929
3930 int name = MMpull(m);
3931 int n = MMget(m, 0);
3932 if ((name == NIL) || (n == NIL))
3933 {
3934 MMset(m, 0, NIL);
3935 return 0;
3936 }
3937
3938 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
3939 if (node == 0)
3940 {
3941 MMset(m, 0, NIL);
3942 return 0;
3943 }
3944
3945 std::string animationName(MMstartstr(m, MTOP(name)));
3946 SAnim* curAnim = node->GetAnimation(animationName);
3947 if (curAnim == 0)
3948 {
3949 if (node->GetNodeType() == SNode::ENTITY_TYPE_ID)
3950 {
3951 SEntity* entity = static_cast<SEntity*> (node);
3952 SSkeleton* skeleton = entity->GetSkeleton();
3953 if (skeleton != 0)
3954 {
3955 curAnim = skeleton->GetAnimation(animationName);
3956 }
3957 }
3958
3959 if (curAnim == 0)
3960 {
3961 MMechostr(MSKDEBUG, "Animation not found!\n");
3962 MMset(m, 0, NIL);
3963 return 0;
3964 }
3965 }
3966
3967 int a = OBJfindTH(m, SO3ANIM, SCOL_PTR(curAnim));
3968 if (a != NIL)
3969 a = MMfetch(m, a, OFFOBJMAG);
3970
3971 MMset(m, 0, a);
3972 return 0;
3973}
3974
3975
3987{
3988#ifdef SO3_DEBUG
3989 MMechostr(MSKDEBUG, "SO3ObjectCreateNodesAnimation\n");
3990#endif
3991
3992 int length = MMpull(m);
3993 int p = MMpull(m);
3994 int n = MMpull(m);
3995 if ((p == NIL) || (n == NIL) || (length == NIL))
3996 {
3997 MMpush(m, NIL);
3998 return 0;
3999 }
4000
4001 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
4002 if (node == 0)
4003 {
4004 MMpush(m, NIL);
4005 return 0;
4006 }
4007
4008 try
4009 {
4010 std::string animationName(MMstartstr(m, MTOP(p)));
4011 SAnim* animation = node->CreateNodeAnimation(animationName, MTOF(length));
4012 return createAnim(m, animation, node);
4013 }
4014 catch (Ogre::Exception &e)
4015 {
4016 MMechostr(MSKDEBUG, "An exception has occurred: %s\n", e.what());
4017 MMpush(m, NIL);
4018 return 0;
4019 }
4020}
4021
4022
4033{
4034#ifdef SO3_DEBUG
4035 MMechostr(MSKDEBUG, "SO3ObjectSetInheritOrientation\n");
4036#endif
4037
4038 int state = MMpull(m);
4039 int obj = MMget(m, 0);
4040 if (obj == NIL)
4041 {
4042 MMset(m, 0, NIL);
4043 return 0;
4044 }
4045
4046 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
4047 if (node == 0)
4048 {
4049 MMset(m, 0, NIL);
4050 return 0;
4051 }
4052
4053 bool bState = false;
4054 if (MTOI(state) == 1)
4055 bState = true;
4056
4057 node->SetInheritOrientation(bState);
4058
4059 MMset(m, 0, ITOM(1));
4060
4061 return 0;
4062}
4063
4064
4074{
4075#ifdef SO3_DEBUG
4076 MMechostr(MSKDEBUG, "SO3ObjectGetInheritOrientation\n");
4077#endif
4078
4079 int obj = MMget(m, 0);
4080 if (obj == NIL)
4081 {
4082 MMset(m, 0, NIL);
4083 return 0;
4084 }
4085
4086 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
4087 if (node == 0)
4088 {
4089 MMset(m, 0, NIL);
4090 return 0;
4091 }
4092
4093 MMset(m, 0, ITOM(node->GetInheritOrientation() ? 1 : 0));
4094
4095 return 0;
4096}
4097
4107{
4108#ifdef SO3_DEBUG
4109 MMechostr(MSKDEBUG, "SO3ObjectResetOrientation\n");
4110#endif
4111
4112 int obj = MMget(m, 0);
4113 if (obj == NIL)
4114 {
4115 MMset(m, 0, NIL);
4116 return 0;
4117 }
4118
4119 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
4120 if (node == 0)
4121 {
4122 MMset(m, 0, NIL);
4123 return 0;
4124 }
4125
4126 node->ResetOrientation();
4127
4128 MMset(m, 0, ITOM(1));
4129
4130 return 0;
4131}
4132
4133
4144{
4145#ifdef SO3_DEBUG
4146 MMechostr(MSKDEBUG, "SO3ObjectSetAsStaticGeometry\n");
4147#endif
4148
4149 int state = MMpull(m);
4150 int obj = MMget(m, 0);
4151 if (obj == NIL)
4152 {
4153 MMset(m, 0, NIL);
4154 return 0;
4155 }
4156
4157 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
4158 if (node == 0)
4159 {
4160 MMset(m, 0, NIL);
4161 return 0;
4162 }
4163
4164 bool bState = false;
4165 if (MTOI(state) == 1)
4166 bState = true;
4167
4168 try
4169 {
4170 node->SetAsStaticGeometry(bState);
4171 }
4172 catch (Ogre::Exception &)
4173 {
4174 MMset(m, 0, NIL);
4175 return 0;
4176 }
4177
4178 MMset(m, 0, ITOM(1));
4179
4180 return 0;
4181}
4182
4183
4193{
4194#ifdef SO3_DEBUG
4195 MMechostr(MSKDEBUG, "SO3ObjectGetAsStaticGeometry\n");
4196#endif
4197
4198 int obj = MMget(m, 0);
4199 if (obj == NIL)
4200 {
4201 MMset(m, 0, NIL);
4202 return 0;
4203 }
4204
4205 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
4206 if (node == 0)
4207 {
4208 MMset(m, 0, NIL);
4209 return 0;
4210 }
4211
4212 MMset(m, 0, ITOM(node->GetAsStaticGeometry() ? 1 : 0));
4213
4214 return 0;
4215}
4216
4239int SO3ObjectGetType(mmachine m)
4240{
4241#ifdef SO3_DEBUG
4242 MMechostr(MSKDEBUG, "SO3ObjectGetType\n");
4243#endif
4244
4245 int obj = MMget(m, 0);
4246 if (obj == NIL)
4247 {
4248 MMset(m, 0, NIL);
4249 return 0;
4250 }
4251
4252 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
4253 if (node == 0)
4254 {
4255 MMset(m, 0, NIL);
4256 return 0;
4257 }
4258
4259 MMset(m, 0, ITOM(node->GetNodeType()));
4260
4261 return 0;
4262}
4263
4264NativeDefinition natSO3Obj[] = {
4265 { "SO3_TYPE_NODE", TYPVAR, "I", SCOL_TYPTYPE(SNode::NODE_TYPE_ID) },
4266 { "SO3_TYPE_ENTITY", TYPVAR, "I", SCOL_TYPTYPE(SNode::ENTITY_TYPE_ID) },
4267 { "SO3_TYPE_CAMERA", TYPVAR, "I", SCOL_TYPTYPE(SNode::CAMERA_TYPE_ID) },
4268 { "SO3_TYPE_LIGHT", TYPVAR, "I", SCOL_TYPTYPE(SNode::LIGHT_TYPE_ID) },
4269 { "SO3_TYPE_SKELETON", TYPVAR, "I", SCOL_TYPTYPE(SNode::SKELETON_TYPE_ID) },
4270 { "SO3_TYPE_BONE", TYPVAR, "I", SCOL_TYPTYPE(SNode::BONE_TYPE_ID) },
4271 { "SO3_TYPE_PARTICLE", TYPVAR, "I", SCOL_TYPTYPE(SNode::PARTICLE_SYSTEM_TYPE_ID) },
4272 { "SO3_TYPE_CUBE_MAP", TYPVAR, "I", SCOL_TYPTYPE(SNode::DYNAMIC_CUBE_MAP_ID) },
4273 { "SO3_TYPE_REFLECTION_MAP", TYPVAR, "I", SCOL_TYPTYPE(SNode::DYNAMIC_REFLECTION_MAP_ID) },
4274 { "SO3_TYPE_RENDER_TO_TEXTURE", TYPVAR, "I", SCOL_TYPTYPE(SNode::RENDER_TO_TEXTURE_ID) },
4275 { "SO3_TYPE_LINE_ENTITY", TYPVAR, "I", SCOL_TYPTYPE(SNode::LINE_ENTITY_TYPE_ID) },
4276 { "SO3_TYPE_VIRTUAL_POINTER", TYPVAR, "I", SCOL_TYPTYPE(SNode::VIRTUAL_POINTER_TYPE_ID) },
4277
4278 { "SO3ObjectRotate", 4, "fun [SO3_OBJECT F [F F F] I] I", SO3ObjectRotate },
4279 { "SO3ObjectShowBoundingBox", 2, "fun [SO3_OBJECT I] I", SO3ObjectShowBoundingBox },
4280 { "SO3ObjectRotateYaw", 3, "fun [SO3_OBJECT F I] I", SO3ObjectRotateYaw },
4281 { "SO3ObjectSetDirection", 3, "fun [SO3_OBJECT [F F F] I] I", SO3ObjectSetDirection },
4282 { "SO3ObjectGetDirection", 1, "fun [SO3_OBJECT] [F F F]", SO3ObjectGetDirection },
4283 { "SO3ObjectGetDerivedDirection", 1, "fun [SO3_OBJECT] [F F F]", SO3ObjectGetDerivedDirection },
4284 { "SO3ObjectGetDirectionAxis", 2, "fun [SO3_OBJECT [F F F]] [F F F]", SO3ObjectGetDirectionAxis },
4285 { "SO3ObjectGetDerivedDirectionAxis", 2, "fun [SO3_OBJECT [F F F]] [F F F]", SO3ObjectGetDerivedDirectionAxis },
4286 { "SO3ObjectLookAt", 3, "fun [SO3_OBJECT [F F F] I] I", SO3ObjectLookAt },
4287 { "SO3ObjectSetVisible", 3, "fun [SO3_OBJECT I I] I", SO3ObjectSetVisible },
4288 { "SO3ObjectGetVisible", 1, "fun [SO3_OBJECT] I", SO3ObjectGetVisible },
4289 { "SO3ObjectGetName", 1, "fun [SO3_OBJECT] S", SO3ObjectGetName },
4290 { "SO3ObjectSetOrientation", 2, "fun [SO3_OBJECT [F F F F]] I", SO3ObjectSetOrientation },
4291 { "SO3ObjectAddOrientation", 2, "fun [SO3_OBJECT [F F F F]] I", SO3ObjectAddOrientation },
4292 { "SO3ObjectResetToInitialOrientation", 1, "fun [SO3_OBJECT] I", SO3ObjectResetToInitialOrientation },
4293 { "SO3ObjectSetPosition", 2, "fun [SO3_OBJECT [F F F]] I", SO3ObjectSetPosition },
4294 { "SO3ObjectTranslate", 3, "fun [SO3_OBJECT [F F F] I] I", SO3ObjectTranslate },
4295 { "SO3ObjectSetScale", 2, "fun [SO3_OBJECT [F F F]] I", SO3ObjectSetScale },
4296 { "SO3ObjectGetOrientation", 1, "fun [SO3_OBJECT] [F F F F]", SO3ObjectGetOrientation },
4297 { "SO3ObjectGetInitialOrientation", 1, "fun [SO3_OBJECT] [F F F F]", SO3ObjectGetInitialOrientation },
4298 { "SO3ObjectGetGlobalOrientation", 1, "fun [SO3_OBJECT] [F F F F]", SO3ObjectGetGlobalOrientation },
4299 { "SO3ObjectSetGlobalOrientation", 2, "fun [SO3_OBJECT [F F F F]] I", SO3ObjectSetGlobalOrientation },
4300 { "SO3ObjectGetPosition", 1, "fun [SO3_OBJECT] [F F F]", SO3ObjectGetPosition },
4301 { "SO3ObjectGetInitialPosition", 1, "fun [SO3_OBJECT] [F F F]", SO3ObjectGetInitialPosition },
4302 { "SO3ObjectGetGlobalPosition", 1, "fun [SO3_OBJECT] [F F F]", SO3ObjectGetGlobalPosition },
4303 { "SO3ObjectSetGlobalPosition", 2, "fun [SO3_OBJECT [F F F]] I", SO3ObjectSetGlobalPosition },
4304 { "SO3ObjectGetScale", 1, "fun [SO3_OBJECT] [F F F]", SO3ObjectGetScale },
4305 { "SO3ObjectGetInitialScale", 1, "fun [SO3_OBJECT] [F F F]", SO3ObjectGetInitialScale },
4306 { "SO3ObjectGetMatrix", 1, "fun [SO3_OBJECT] [F F F F F F F F F F F F F F F F]", SO3ObjectGetMatrix },
4307 { "SO3ObjectGetWorldMatrix", 1, "fun [SO3_OBJECT] [F F F F F F F F F F F F F F F F]", SO3ObjectGetWorldMatrix },
4308 { "SO3ObjectGetGlobalScale", 1, "fun [SO3_OBJECT] [F F F]", SO3ObjectGetGlobalScale },
4309 { "SO3ObjectSetGlobalScale", 2, "fun [SO3_OBJECT [F F F]] I", SO3ObjectSetGlobalScale },
4310 { "SO3ObjectRotateRoll", 3, "fun [SO3_OBJECT F I] I", SO3ObjectRotateRoll },
4311 { "SO3ObjectRotatePitch", 3, "fun [SO3_OBJECT F I] I", SO3ObjectRotatePitch },
4312 { "SO3ObjectNbOfChild", 1, "fun [SO3_OBJECT] I", SO3ObjectNbOfChild },
4313 { "SO3ObjectRemoveAllChildren", 1, "fun [SO3_OBJECT] I", SO3ObjectRemoveAllChildren },
4314 { "SO3ObjectGetChildren", 1, "fun [SO3_OBJECT] [SO3_OBJECT r1]", SO3ObjectGetChildren },
4315 { "SO3ObjectDestroy", 1, "fun [SO3_OBJECT] I", SO3ObjectDestroy },
4316 { "SO3ObjectSetInitialState", 1, "fun [SO3_OBJECT] I", SO3ObjectSetInitialState },
4317 { "SO3ObjectResetToInitialState", 1, "fun [SO3_OBJECT] I", SO3ObjectResetToInitialState },
4318 { "SO3ObjectGetSceneRoot", 1, "fun [SO3_SCENE] SO3_OBJECT", SO3ObjectGetSceneRoot },
4319 { "SO3ObjectGetParent", 1, "fun [SO3_OBJECT] SO3_OBJECT", SO3ObjectGetParent },
4320 { "SO3ObjectGetScene", 1, "fun [SO3_OBJECT] SO3_SCENE", SO3ObjectGetScene },
4321 { "SO3ObjectLink", 2, "fun [SO3_OBJECT SO3_OBJECT] I", SO3ObjectLink },
4322 { "SO3ObjectGetPositionInObjectRef", 2, "fun [SO3_OBJECT SO3_OBJECT] [F F F]", SO3ObjectGetPositionInObjectRef },
4323 { "SO3ObjectGetOrientationInObjectRef", 2, "fun [SO3_OBJECT SO3_OBJECT] [F F F F]", SO3ObjectGetOrientationInObjectRef },
4324 { "SO3ObjectGetScaleInObjectRef", 2, "fun [SO3_OBJECT SO3_OBJECT] [F F F]", SO3ObjectGetScaleInObjectRef },
4325 { "SO3ObjectUnlink", 1, "fun [SO3_OBJECT] I", SO3ObjectUnlink },
4326 { "SO3ObjectSetAutoTracking", 5, "fun [SO3_OBJECT SO3_OBJECT I [F F F] [F F F]] I", SO3ObjectSetAutoTracking },
4327 { "SO3ObjectSetCastShadows", 2, "fun [SO3_OBJECT I] I", SO3ObjectSetCastShadows },
4328 { "SO3ObjectGetBoundingBoxInfo", 2, "fun [SO3_OBJECT I] [[F F F] [F F F] [F F F F]]", SO3ObjectGetBoundingBoxInfo },
4329 { "SO3ObjectGetWorldBoundingBoxInfo", 2, "fun [SO3_OBJECT I] [[F F F] [F F F] [F F F F]]", SO3ObjectGetWorldBoundingBoxInfo },
4330 { "SO3ObjectGetCastShadows", 1, "fun [SO3_OBJECT] I", SO3ObjectGetCastShadows },
4331 { "SO3ObjectSetMouseForeGround", 2, "fun [SO3_OBJECT I] I", SO3ObjectSetMouseForeGround },
4332 { "SO3ObjectSetMouseClick", 2, "fun [SO3_OBJECT I] I", SO3ObjectSetMouseClick },
4333 { "SO3ObjectGetMouseForeGround", 1, "fun [SO3_OBJECT] I", SO3ObjectGetMouseForeGround },
4334 { "SO3ObjectGetMouseClick", 1, "fun [SO3_OBJECT] I", SO3ObjectGetMouseClick },
4335 { "SO3ObjectSetFlags", 2, "fun [SO3_OBJECT I] I", SO3ObjectSetFlags },
4336 { "SO3ObjectGetFlags", 1, "fun [SO3_OBJECT] I", SO3ObjectGetFlags },
4337 { "SO3ObjectSetRenderOverlay", 2, "fun [SO3_OBJECT I] I", SO3ObjectSetRenderOverlay },
4338 { "SO3ObjectSetRenderQueue", 2, "fun [SO3_OBJECT I] I", SO3ObjectSetRenderQueue },
4339 { "SO3ObjectGetPolygonCount", 1, "fun [SO3_OBJECT] I", SO3ObjectGetPolygonCount },
4340 { "SO3ObjectGetVerticesCount", 1, "fun [SO3_OBJECT] I", SO3ObjectGetVerticesCount },
4341 { "SO3ObjectGetInfo", 3, "fun [SO3_VIEWPORT I I] [SO3_OBJECT SO3_MATERIAL I]", SO3ObjectGetInfo },
4342 { "SO3ObjectGetInfoEx", 3, "fun [SO3_VIEWPORT I I] [SO3_OBJECT SO3_MATERIAL I F I [F F F] [F F F] [F F F] [F F] [F F] [F F] [F F F] [F F]]", SO3ObjectGetInfoEx },
4343 { "SO3ObjectGetScreenCoord", 2, "fun [SO3_OBJECT SO3_VIEWPORT] [F F]", SO3ObjectGetScreenCoord },
4344 { "SO3ObjectGetScreenPixelCoord", 2, "fun [SO3_OBJECT SO3_VIEWPORT] [I I]", SO3ObjectGetScreenPixelCoord },
4345 { "SO3ObjectGetNodeFacingOrientation", 4, "fun [SO3_OBJECT SO3_OBJECT [F F F] [I I I]] [F F F F]", SO3ObjectGetNodeFacingOrientation },
4346 { "SO3ObjectSetRenderingDistance", 2, "fun [SO3_OBJECT F] I", SO3ObjectSetRenderingDistance },
4347 { "SO3ObjectGetRenderingDistance", 1, "fun [SO3_OBJECT] F", SO3ObjectGetRenderingDistance },
4348 { "SO3ObjectGetAnimation", 2, "fun [SO3_OBJECT S] SO3_ANIM", SO3ObjectGetAnimation },
4349 { "SO3ObjectCreateNodesAnimation", 3, "fun [SO3_OBJECT S F] SO3_ANIM", SO3ObjectCreateNodesAnimation },
4350 { "SO3ObjectSetInheritOrientation", 2, "fun [SO3_OBJECT I] I", SO3ObjectSetInheritOrientation },
4351 { "SO3ObjectGetInheritOrientation", 1, "fun [SO3_OBJECT] I", SO3ObjectGetInheritOrientation },
4352 { "SO3ObjectResetOrientation", 1, "fun [SO3_OBJECT] I", SO3ObjectResetOrientation },
4353 { "SO3ObjectSetAsStaticGeometry", 2, "fun [SO3_OBJECT I] I", SO3ObjectSetAsStaticGeometry },
4354 { "SO3ObjectGetAsStaticGeometry", 1, "fun [SO3_OBJECT] I", SO3ObjectGetAsStaticGeometry },
4355 { "SO3ObjectGetType", 1, "fun [SO3_OBJECT] I", SO3ObjectGetType }
4356};
4357
4363int SCOLloadObject(mmachine m, cbmachine w)
4364{
4365 return PKhardpak2(m, "SO3Object.pkg", sizeof(natSO3Obj) / sizeof(natSO3Obj[0]), natSO3Obj);
4366}
4367
4368
4374{
4375 return 0;
4376}
int SCOLfreeObject()
free the SO3Engine Viewport function
NativeDefinition natSO3Obj[]
int SCOLloadObject(mmachine m, cbmachine w)
Load the SO3Engine Viewport function.
MMechostr(MSKDEBUG, " > Start loading Plugin SO3Engine dll\n")
SCOL_EXPORT int cbmachine w
Definition SO3SCOL.cpp:5150
int createAnim(mmachine m, SAnim *curAnim, SNode *curNode)
int SO3SCENETYPE
Definition SO3SCOL.cpp:88
int SO3OBJTYPE
Definition SO3SCOL.cpp:90
int SO3ANIM
Definition SO3SCOL.cpp:92
int createOrRetrieveScolMaterialAndSendToVM(mmachine m, SScene *scene, SMaterial *mat)
int SO3ObjectCreateNodesAnimation(mmachine m)
SO3ObjectCreateNodesAnimation : Create a Scene Node Animation.
int SO3ObjectSetRenderingDistance(mmachine m)
SO3ObjectSetRenderingDistance : defines a maximum distance for rendering the object.
int SO3ObjectSetGlobalOrientation(mmachine m)
SO3ObjectSetGlobalOrientation : Set Global Object Orientation.
int SO3ObjectGetParent(mmachine m)
SO3ObjectGetParent : Get the parent node of a node.
int SO3ObjectRotateRoll(mmachine m)
SO3ObjectRotateRoll : Roll a node.
int SO3ObjectGetInitialScale(mmachine m)
SO3ObjectGetScale : Get Object Initial Scale.
int SO3ObjectSetRenderQueue(mmachine m)
SO3ObjectSetRenderQueue : defines render queue position of a mesh.
int SO3ObjectSetInheritOrientation(mmachine m)
SO3ObjectSetInheritOrientation : Set the inherit orientation of a node.
int SO3ObjectLink(mmachine m)
SO3ObjectLink : Link two nodes.
int SO3ObjectGetVisible(mmachine m)
SO3ObjectGetVisible : Get the visible state of a node.
int SO3ObjectSetOrientation(mmachine m)
SO3ObjectSetOrientation : Set an orientation for a given node.
int SO3ObjectGetWorldBoundingBoxInfo(mmachine m)
SO3ObjectGetWorldBoundingBoxInfo : Return the world bounding box information of a node.
int SO3ObjectGetGlobalPosition(mmachine m)
SO3ObjectGetGlobalPosition : Get Object Global Position.
int SO3ObjectGetInfoEx(mmachine m)
SO3ObjectGetInfoEx : Get extended mouse informations (raycast) from a viewport.
int SO3ObjectSetDirection(mmachine m)
SO3ObjectSetDirection : defines direction of a node.
int SO3ObjectGetBoundingBoxInfo(mmachine m)
SO3ObjectGetBoundingBoxInfo : Return the bounding box information of a node.
int SO3ObjectSetInitialState(mmachine m)
SO3ObjectSetInitialState : defines initial state of a node.
int SO3ObjectGetInitialOrientation(mmachine m)
SO3ObjectGetInitialOrientation : Get Initial Object Orientation.
int SO3ObjectGetGlobalScale(mmachine m)
SO3ObjectGetScale : Get Object Global Scale.
int SO3ObjectSetGlobalScale(mmachine m)
SO3ObjectSetGlobalScale : Set Global Object scale.
int SO3ObjectSetMouseForeGround(mmachine m)
SO3ObjectSetMouseForeGround : defines mouse foreground priority of a node.
int SO3ObjectResetToInitialOrientation(mmachine m)
SO3ObjectResetToInitialOrientation : Reset node orientation.
int SO3ObjectGetAsStaticGeometry(mmachine m)
SO3ObjectGetAsStaticGeometry : Get the static gemoetry state of a node.
int SO3ObjectGetInfo(mmachine m)
SO3ObjectGetInfo : Get mouse informations (raycast) from a viewport.
int SO3ObjectResetOrientation(mmachine m)
SO3ObjectResetOrientation : Resets the node orientation (local axes as world axes,...
int SO3ObjectLookAt(mmachine m)
SO3ObjectLookAt : defines "look at" direction of a node.
int SO3ObjectRotateYaw(mmachine m)
SO3ObjectRotateYaw : Yaw a node.
int SO3ObjectGetScene(mmachine m)
SO3ObjectGetScene : Get the parent scene of a node.
int SO3ObjectTranslate(mmachine m)
SO3ObjectTranslate : Translate a given node.
int SO3ObjectUnlink(mmachine m)
SO3ObjectUnlink : Unlink a node from the scene.
int SO3ObjectGetVerticesCount(mmachine m)
SO3ObjectGetVerticesCount : Return the numer of Vertex for a node.
int SO3ObjectGetChildren(mmachine m)
SO3ObjectGetChildren : Return the list of child node.
int SO3ObjectAddOrientation(mmachine m)
SO3ObjectAddOrientation : Add orientation to a given node.
int SO3ObjectGetAnimation(mmachine m)
SO3ObjectGetAnimation : return an animation by its name.
int SO3ObjectRotatePitch(mmachine m)
SO3ObjectRotatePitch : Pitch a node.
int SO3ObjectGetMouseForeGround(mmachine m)
SO3ObjectGetMouseForeGround :Get the mouse foreground priority of a node.
int SO3ObjectGetMouseClick(mmachine m)
SO3ObjectGetMouseClick :Get the mouse click state of a node.
int SO3ObjectSetFlags(mmachine m)
SO3ObjectSetFlags : defines any flags value on a node.
int SO3ObjectGetInitialPosition(mmachine m)
SO3ObjectGetInitialPosition : Get Object Initial Position.
int SO3ObjectNbOfChild(mmachine m)
SO3ObjectNbOfChild : return the numer of child of a node.
int SO3ObjectGetOrientation(mmachine m)
SO3ObjectGetOrientation : Get Object Orientation.
int SO3ObjectGetScaleInObjectRef(mmachine m)
SO3ObjectGetScaleInObjectRef : Return the scale of node in the transform space of another node.
int SO3ObjectGetSceneRoot(mmachine m)
SO3ObjectGetSceneRoot : Get the scene root node.
int SO3ObjectGetPosition(mmachine m)
SO3ObjectGetPosition : Get Object Position.
int SO3ObjectSetCastShadows(mmachine m)
SO3ObjectSetCastShadows : defines cast shadow state for a node.
int SO3ObjectGetPositionInObjectRef(mmachine m)
SO3ObjectGetPositionInObjectRef : Return the position of node in the transform space of another node.
int SO3ObjectGetDerivedDirection(mmachine m)
SO3ObjectGetDerivedDirection : Get the node derived direction.
int SO3ObjectGetGlobalOrientation(mmachine m)
SO3ObjectGetGlobalOrientation : Get Global Object Orientation.
int SO3ObjectSetScale(mmachine m)
SO3ObjectSetScale : Scale a given node.
int SO3ObjectGetRenderingDistance(mmachine m)
SO3ObjectGetRenderingDistance : return the maximum distance for rendering the object.
int SO3ObjectGetFlags(mmachine m)
SO3ObjectGetFlags : Get a node flags value.
int SO3ObjectResetToInitialState(mmachine m)
SO3ObjectResetToInitialState : Reset a node to its initial state.
int SO3ObjectGetMatrix(mmachine m)
SO3ObjectGetMatrix : Return the matrix of a given node.
int SO3ObjectShowBoundingBox(mmachine m)
SO3ObjectShowBoundingBox : Allow the display of BoundingBox.
int SO3ObjectGetInheritOrientation(mmachine m)
SO3ObjectGetInheritOrientation : Get the inherit orientation of a node.
int SO3ObjectGetName(mmachine m)
SO3ObjectGetName : Return a node's name.
int SO3ObjectRemoveAllChildren(mmachine m)
SO3ObjectRemoveAllChildren : Remove all children.
int SO3ObjectGetOrientationInObjectRef(mmachine m)
SO3ObjectGetOrientationInObjectRef : Return the orientation of node in the transform space of another...
int SO3ObjectSetVisible(mmachine m)
SO3ObjectSetVisible : defines visible state of a node.
int SO3ObjectGetScreenPixelCoord(mmachine m)
SO3ObjectGetScreenPixelCoord : Get screen coordinates in pixels of a node.
int SO3ObjectDestroy(mmachine m)
SO3ObjectDestroy : Destroy a node and its hierarchy.
int SO3ObjectGetNodeFacingOrientation(mmachine m)
SO3ObjectGetNodeFacingOrientation : Get the necessary rotation for making the target node facing the ...
int SO3ObjectGetDirection(mmachine m)
SO3ObjectGetDirection : Get the node direction.
int SO3ObjectGetCastShadows(mmachine m)
SO3ObjectGetCastShadows : Get the cast shadows state of a node.
int SO3ObjectGetDerivedDirectionAxis(mmachine m)
SO3ObjectGetDerivedDirectionAxis : Get the node derived direction from axis.
int SO3ObjectRotate(mmachine m)
main include
int SO3ObjectSetRenderOverlay(mmachine m)
SO3ObjectSetRenderOverlay : defines render overlay priority of a mesh.
int SO3ObjectGetPolygonCount(mmachine m)
SO3ObjectGetPolygonCount : Return the numer of Polygone for a node.
int SO3ObjectGetDirectionAxis(mmachine m)
SO3ObjectGetDirectionAxis : Get the node direction from axis.
int SO3ObjectSetAsStaticGeometry(mmachine m)
SO3ObjectSetAsStaticGeometry : Set the object as a static geometry.
int SO3ObjectGetWorldMatrix(mmachine m)
SO3ObjectGetWorldMatrix : Return the world matrix of a given node.
int SO3ObjectGetType(mmachine m)
SO3ObjectGetType : Get the type of an object.
int SO3ObjectSetPosition(mmachine m)
SO3ObjectSetPosition : defines position for a given node.
int SO3ObjectGetScale(mmachine m)
SO3ObjectGetScale : Get Object Scale.
int SO3ObjectSetAutoTracking(mmachine m)
SO3ObjectSetAutoTracking : defines auto tracking for a node.
int SO3ObjectSetGlobalPosition(mmachine m)
SO3ObjectSetGlobalPosition : Set Global Object Postion.
int SO3ObjectGetScreenCoord(mmachine m)
SO3ObjectGetScreenCoord : Get screen coordinates of a node.
int SO3ObjectSetMouseClick(mmachine m)
SO3ObjectSetMouseClick : defines mouse click state of a node.