Project

General

Profile

SO3Engine
SCOLLineEntity.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
41
53int SO3LineEntityCreate(mmachine m)
54{
55#ifdef SO3_DEBUG
56 MMechostr(MSKDEBUG, "SO3LineEntityCreate\n");
57#endif
58 int color = MMpull(m);
59 int points = MMpull(m);
60 int name = MMpull(m);
61 int s = MMget(m, 0);
62 if (s==NIL)
63 {
64 MMset(m, 0, NIL);
65 return 0;
66 }
67
68 SScene* scene = MMgetPointer<SScene*>(m, MTOP(s));
69 if (scene==NULL)
70 {
71 MMset(m, 0, NIL);
72 return 0;
73 }
74
75 // Create Node
76 SLineEntity* lineEntity = 0;
77 try
78 {
79 // Create the line entity
80 lineEntity = scene->CreateLineEntity(MMstartstr(m, MTOP(name)));
81 SO3::SLines* lines = lineEntity->GetSLines();
82
83 // Load points
84 if (points != NIL)
85 {
86 // Iterate through the recursive tuple
87 int pointTuple;
88 float x, y, z;
89 points = MTOP(points);
90 while(points != NIL)
91 {
92 // Get point coordinate
93 pointTuple = MTOP(MMfetch(m, points, 0));
94 x = MTOF(MMfetch(m, pointTuple, 0));
95 y = MTOF(MMfetch(m, pointTuple, 1));
96 z = MTOF(MMfetch(m, pointTuple, 2));
97 points = MTOP(MMfetch(m, points, 1));
98
99 // Add point
100 lines->AddPoint(x, y, z);
101 }
102
103 // Draw the line
104 lines->Draw();
105 }
106
107 // Set optionnal color
108 if (color != NIL)
110 }
111 catch(Ogre::Exception &e)
112 {
113 MMechostr(MSKDEBUG,"An exception has occurred : %s\n", e.what());
114 MMset(m, 0, NIL);
115 return 0;
116 }
117
118 // remove last param
119 MMpull(m);
120 return createObject(m, lineEntity, scene);
121}
122
123
136{
137#ifdef SO3_DEBUG
138 MMechostr(MSKDEBUG, "SO3LineEntityCreateDashed\n");
139#endif
140 int color = MMpull(m);
141 int points = MMpull(m);
142 int name = MMpull(m);
143 int s = MMget(m, 0);
144 if (s==NIL)
145 {
146 MMset(m, 0, NIL);
147 return 0;
148 }
149
150 SScene* scene = MMgetPointer<SScene*>(m, MTOP(s));
151 if (scene==NULL)
152 {
153 MMset(m, 0, NIL);
154 return 0;
155 }
156
157 // Create Node
158 SLineEntity* lineEntity = 0;
159 try
160 {
161 // Create the line entity
162 lineEntity = scene->CreateLineEntity(MMstartstr(m, MTOP(name)), true);
163 SO3::SLines* lines = lineEntity->GetSLines();
164
165 // Load points
166 if (points != NIL)
167 {
168 // Iterate through the recursive tuple
169 int pointTuple;
170 float x, y, z;
171 points = MTOP(points);
172 while(points != NIL)
173 {
174 // Get point coordinate
175 pointTuple = MTOP(MMfetch(m, points, 0));
176 x = MTOF(MMfetch(m, pointTuple, 0));
177 y = MTOF(MMfetch(m, pointTuple, 1));
178 z = MTOF(MMfetch(m, pointTuple, 2));
179 points = MTOP(MMfetch(m, points, 1));
180
181 // Add point
182 lines->AddPoint(x, y, z);
183 }
184
185 // Draw the line
186 lines->Draw();
187 }
188
189 // Set optionnal color
190 if (color != NIL)
192 }
193 catch(Ogre::Exception &e)
194 {
195 MMechostr(MSKDEBUG,"An exception has occurred : %s\n", e.what());
196 MMset(m, 0, NIL);
197 return 0;
198 }
199
200 // remove last param
201 MMpull(m);
202 return createObject(m, lineEntity, scene);
203}
204
205
219{
220#ifdef SO3_DEBUG
221 MMechostr(MSKDEBUG, "SO3LineEntityCreateEx\n");
222#endif
223
224 int idepth = MMpull(m);
225 int color = MMpull(m);
226 int points = MMpull(m);
227 int name = MMpull(m);
228 int s = MMget(m, 0);
229 if (s == NIL)
230 {
231 MMset(m, 0, NIL);
232 return 0;
233 }
234
235 SScene* scene = MMgetPointer<SScene*>(m, MTOP(s));
236 if (scene == NULL)
237 {
238 MMset(m, 0, NIL);
239 return 0;
240 }
241
242 bool disableDepth = false;
243 if (idepth != NIL && (MTOI(idepth) > 0))
244 disableDepth = true;
245
246 // Create Node
247 SLineEntity* lineEntity = 0;
248 try
249 {
250 // Create the line entity
251 lineEntity = scene->CreateLineEntity(MMstartstr(m, MTOP(name)), false, disableDepth);
252 SO3::SLines* lines = lineEntity->GetSLines();
253
254 // Load points
255 if (points != NIL)
256 {
257 // Iterate through the recursive tuple
258 int pointTuple;
259 float x, y, z;
260 points = MTOP(points);
261 while (points != NIL)
262 {
263 // Get point coordinate
264 pointTuple = MTOP(MMfetch(m, points, 0));
265 x = MTOF(MMfetch(m, pointTuple, 0));
266 y = MTOF(MMfetch(m, pointTuple, 1));
267 z = MTOF(MMfetch(m, pointTuple, 2));
268 points = MTOP(MMfetch(m, points, 1));
269
270 // Add point
271 lines->AddPoint(x, y, z);
272 }
273
274 // Draw the line
275 lines->Draw();
276 }
277
278 // Set optionnal color
279 if (color != NIL)
281 }
282 catch (Ogre::Exception &e)
283 {
284 MMechostr(MSKDEBUG, "An exception has occurred : %s\n", e.what());
285 MMset(m, 0, NIL);
286 return 0;
287 }
288
289 // remove last param
290 MMpull(m);
291 return createObject(m, lineEntity, scene);
292}
293
294
308{
309#ifdef SO3_DEBUG
310 MMechostr(MSKDEBUG, "SO3LineEntityCreateDashedEx\n");
311#endif
312
313 int idepth = MMpull(m);
314 int color = MMpull(m);
315 int points = MMpull(m);
316 int name = MMpull(m);
317 int s = MMget(m, 0);
318 if (s == NIL)
319 {
320 MMset(m, 0, NIL);
321 return 0;
322 }
323
324 SScene* scene = MMgetPointer<SScene*>(m, MTOP(s));
325 if (scene == NULL)
326 {
327 MMset(m, 0, NIL);
328 return 0;
329 }
330
331 bool disableDepth = false;
332 if (idepth != NIL && (MTOI(idepth) > 0))
333 disableDepth = true;
334
335 // Create Node
336 SLineEntity* lineEntity = 0;
337 try
338 {
339 // Create the line entity
340 lineEntity = scene->CreateLineEntity(MMstartstr(m, MTOP(name)), true, disableDepth);
341 SO3::SLines* lines = lineEntity->GetSLines();
342
343 // Load points
344 if (points != NIL)
345 {
346 // Iterate through the recursive tuple
347 int pointTuple;
348 float x, y, z;
349 points = MTOP(points);
350 while (points != NIL)
351 {
352 // Get point coordinate
353 pointTuple = MTOP(MMfetch(m, points, 0));
354 x = MTOF(MMfetch(m, pointTuple, 0));
355 y = MTOF(MMfetch(m, pointTuple, 1));
356 z = MTOF(MMfetch(m, pointTuple, 2));
357 points = MTOP(MMfetch(m, points, 1));
358
359 // Add point
360 lines->AddPoint(x, y, z);
361 }
362
363 // Draw the line
364 lines->Draw();
365 }
366
367 // Set optionnal color
368 if (color != NIL)
370 }
371 catch (Ogre::Exception &e)
372 {
373 MMechostr(MSKDEBUG, "An exception has occurred : %s\n", e.what());
374 MMset(m, 0, NIL);
375 return 0;
376 }
377
378 // remove last param
379 MMpull(m);
380 return createObject(m, lineEntity, scene);
381}
382
392{
393#ifdef SO3_DEBUG
394 MMechostr(MSKDEBUG, "SO3LineEntityGetDiffuse\n");
395#endif
396 int obj = MMget(m, 0);
397 if(obj==NIL)
398 {
399 MMset(m, 0, NIL);
400 return 0;
401 }
402
403 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
404 if(node==NULL)
405 {
406 MMset(m, 0, NIL);
407 return 0;
408 }
409
410 if(node->GetNodeType()!=SNode::LINE_ENTITY_TYPE_ID)
411 {
412 MMset(m, 0, NIL);
413 return 0;
414 }
415
416 try
417 {
418 MMset(m, 0, ITOM(SO3::ConversionTools::OgreToScolColorRGBA((static_cast<SLineEntity*>(node))->GetSLines()->GetColour())));
419 return 0;
420 }
421 catch(const SException&)
422 {
423 MMechostr(MSKDEBUG, "SO3LineEntityGetDiffuse error\n");
424 MMset(m, 0, NIL);
425 return 0;
426 }
427}
428
429
440{
441#ifdef SO3_DEBUG
442 MMechostr(MSKDEBUG, "SO3LineEntitySetDiffuse\n");
443#endif
444 int color = MMpull(m);
445 int obj = MMget(m, 0);
446 if(obj==NIL)
447 {
448 MMset(m, 0, NIL);
449 return 0;
450 }
451
452 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
453 if(node==NULL)
454 {
455 MMset(m, 0, NIL);
456 return 0;
457 }
458
459 if(node->GetNodeType()!=SNode::LINE_ENTITY_TYPE_ID)
460 {
461 MMset(m, 0, NIL);
462 return 0;
463 }
464
465 if (color == NIL)
466 color = 0;
467 else
468 color = MTOI(color);
469
470 (static_cast<SLineEntity*>(node))->GetSLines()->SetColour(SO3::ConversionTools::ScolToOgreColorRGBA(color));
471 MMset(m, 0, ITOM(1));
472 return 0;
473}
474
475
486{
487#ifdef SO3_DEBUG
488 MMechostr(MSKDEBUG, "SO3LineEntityGetPoint\n");
489#endif
490 int idx = MMpull(m);
491 int obj = MMget(m, 0);
492 if(obj==NIL)
493 {
494 MMset(m, 0, NIL);
495 return 0;
496 }
497
498 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
499 if(node==NULL)
500 {
501 MMset(m, 0, NIL);
502 return 0;
503 }
504
505 if(node->GetNodeType()!=SNode::LINE_ENTITY_TYPE_ID)
506 {
507 MMset(m, 0, NIL);
508 return 0;
509 }
510
511 try
512 {
513 SLines* lines = (static_cast<SLineEntity*>(node))->GetSLines();
514 if(idx != NIL)
515 idx = MTOI(idx);
516 else
517 idx = lines->GetNumberOfPoints() - 1;
518
519 if(idx >= 0)
520 {
521 int tuple = MMmalloc(m, 3, TYPETAB);
522 if(tuple==NIL)
523 {
524 MMset(m, 0, NIL);
525 return MERRMEM;
526 }
527
528 Ogre::Vector3 position = lines->GetPoint(idx);
529 MMstore(m, tuple, 0, FTOM((position.x)));
530 MMstore(m, tuple, 1, FTOM((position.y)));
531 MMstore(m, tuple, 2, FTOM((position.z)));
532 MMset(m, 0, PTOM(tuple));
533 return 0;
534 }
535 // else return nil at the end of the function
536 }
537 catch(const SException&)
538 {
539 MMechostr(MSKDEBUG, "SO3LineEntityGetPoint error\n");
540 MMset(m, 0, NIL);
541 }
542
543 return 0;
544}
545
546
558{
559#ifdef SO3_DEBUG
560 MMechostr(MSKDEBUG, "SO3LineEntitySetPoint\n");
561#endif
562 int pos = MMpull(m);
563 int idx = MMpull(m);
564 int obj = MMget(m, 0);
565 if((obj==NIL) || (pos==NIL))
566 {
567 MMset(m, 0, NIL);
568 return 0;
569 }
570
571 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
572 if(node==NULL)
573 {
574 MMset(m, 0, NIL);
575 return 0;
576 }
577
578 if(node->GetNodeType()!=SNode::LINE_ENTITY_TYPE_ID)
579 {
580 MMset(m, 0, NIL);
581 return 0;
582 }
583
584 try
585 {
586 SLines* lines = (static_cast<SLineEntity*>(node))->GetSLines();
587 if(idx != NIL)
588 idx = MTOI(idx);
589 else
590 idx = lines->GetNumberOfPoints() - 1;
591
592 if(idx >= 0)
593 {
594 pos = MTOP(pos);
595 lines->SetPoint(idx, Ogre::Vector3(MTOF(MMfetch(m, pos, 0)), MTOF(MMfetch(m, pos, 1)), MTOF(MMfetch(m, pos, 2))));
596
597 lines->Draw();
598 MMset(m, 0, ITOM(1));
599 return 0;
600 }
601 // else return nil at the end of the function
602 }
603 catch(const SException&)
604 {
605 MMechostr(MSKDEBUG, "SO3LineEntitySetPoint error\n");
606 MMset(m, 0, NIL);
607 }
608
609 return 0;
610}
611
612
624{
625#ifdef SO3_DEBUG
626 MMechostr(MSKDEBUG, "SO3LineEntityAddPoint\n");
627#endif
628 int pos = MMpull(m);
629 int idx = MMpull(m);
630 int obj = MMget(m, 0);
631 if((obj==NIL) || (pos==NIL))
632 {
633 MMset(m, 0, NIL);
634 return 0;
635 }
636
637 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
638 if(node==NULL)
639 {
640 MMset(m, 0, NIL);
641 return 0;
642 }
643
644 if(node->GetNodeType()!=SNode::LINE_ENTITY_TYPE_ID)
645 {
646 MMset(m, 0, NIL);
647 return 0;
648 }
649
650 try
651 {
652 SLines* lines = (static_cast<SLineEntity*>(node))->GetSLines();
653 if(idx != NIL)
654 idx = MTOI(idx);
655 else
656 idx = lines->GetNumberOfPoints() - 1;
657
658 pos = MTOP(pos);
659 if(idx < 0)
660 lines->AddPoint(Ogre::Vector3(MTOF(MMfetch(m, pos, 0)), MTOF(MMfetch(m, pos, 1)), MTOF(MMfetch(m, pos, 2))));
661 else
662 lines->AddPoint(idx, Ogre::Vector3(MTOF(MMfetch(m, pos, 0)), MTOF(MMfetch(m, pos, 1)), MTOF(MMfetch(m, pos, 2))));
663
664 lines->Draw();
665 MMset(m, 0, ITOM(1));
666 return 0;
667 }
668 catch(const SException&)
669 {
670 MMechostr(MSKDEBUG, "SO3LineEntityAddPoint error\n");
671 MMset(m, 0, NIL);
672 return 0;
673 }
674}
675
676
687{
688#ifdef SO3_DEBUG
689 MMechostr(MSKDEBUG, "SO3LineEntityRemovePoint\n");
690#endif
691 int idx = MMpull(m);
692 int obj = MMget(m, 0);
693 if(obj==NIL)
694 {
695 MMset(m, 0, NIL);
696 return 0;
697 }
698
699 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
700 if(node==NULL)
701 {
702 MMset(m, 0, NIL);
703 return 0;
704 }
705
706 if(node->GetNodeType()!=SNode::LINE_ENTITY_TYPE_ID)
707 {
708 MMset(m, 0, NIL);
709 return 0;
710 }
711
712 try
713 {
714 SLines* lines = (static_cast<SLineEntity*>(node))->GetSLines();
715 if(idx != NIL)
716 idx = MTOI(idx);
717 else
718 idx = lines->GetNumberOfPoints() - 1;
719
720 if(idx >= 0)
721 {
722 lines->RemovePoint(idx);
723
724 lines->Draw();
725 MMset(m, 0, ITOM(1));
726 return 0;
727 }
728 // else return nil at the end of the function
729 }
730 catch(const SException&)
731 {
732 MMechostr(MSKDEBUG, "SO3LineEntityRemovePoint error\n");
733 }
734 MMset(m, 0, NIL);
735 return 0;
736}
737
738
748{
749#ifdef SO3_DEBUG
750 MMechostr(MSKDEBUG, "SO3LineEntityGetNumberOfPoints\n");
751#endif
752 int obj = MMget(m, 0);
753 if(obj==NIL)
754 {
755 MMset(m, 0, NIL);
756 return 0;
757 }
758
759 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
760 if(node==NULL)
761 {
762 MMset(m, 0, NIL);
763 return 0;
764 }
765
766 if(node->GetNodeType()!=SNode::LINE_ENTITY_TYPE_ID)
767 {
768 MMset(m, 0, NIL);
769 return 0;
770 }
771
772 try
773 {
774 SLines* lines = (static_cast<SLineEntity*>(node))->GetSLines();
775 MMset(m, 0, ITOM(lines->GetNumberOfPoints()));
776 return 0;
777 }
778 catch(const SException&)
779 {
780 MMechostr(MSKDEBUG, "SO3LineEntityGetNumberOfPoints error\n");
781 MMset(m, 0, NIL);
782 return 0;
783 }
784}
785
786
796{
797#ifdef SO3_DEBUG
798 MMechostr(MSKDEBUG, "SO3LineEntityGetPoints\n");
799#endif
800 int obj = MMget(m, 0);
801 if(obj==NIL)
802 {
803 MMset(m, 0, NIL);
804 return 0;
805 }
806
807 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
808 if(node==NULL)
809 {
810 MMset(m, 0, NIL);
811 return 0;
812 }
813
814 if(node->GetNodeType()!=SNode::LINE_ENTITY_TYPE_ID)
815 {
816 MMset(m, 0, NIL);
817 return 0;
818 }
819
820 // remove last param
821 MMpull(m);
822 try
823 {
824 SLines* lines = (static_cast<SLineEntity*>(node))->GetSLines();
825 size_t counter = 0;
826 size_t numberOfPoints = lines->GetNumberOfPoints();
827 if(numberOfPoints > 0)
828 {
829 while(counter < numberOfPoints)
830 {
831 Ogre::Vector3 position = lines->GetPoint(counter);
832 MMpush(m, FTOM(position.x));
833 MMpush(m, FTOM(position.y));
834 MMpush(m, FTOM(position.z));
835
836 MMpush(m, ITOM(3));
837 MBdeftab(m);
838 counter++;
839 }
840 MMpush(m,NIL);
841 counter = 0;
842 while(counter < numberOfPoints)
843 {
844 MMpush(m, ITOM(2));
845 MBdeftab(m);
846 counter++;
847 }
848 return 0;
849 }
850 // else return nil at the end of the function
851 }
852 catch(const SException&)
853 {
854 MMechostr(MSKDEBUG, "SO3LineEntityGetPoints error\n");
855 MMpush(m, NIL);
856 }
857
858 return 0;
859}
860
861
872{
873#ifdef SO3_DEBUG
874 MMechostr(MSKDEBUG, "SO3LineEntitySetPoints\n");
875#endif
876 int points = MMpull(m);
877 int obj = MMget(m, 0);
878 if(obj==NIL)
879 {
880 MMset(m, 0, NIL);
881 return 0;
882 }
883
884 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
885 if(node==NULL)
886 {
887 MMset(m, 0, NIL);
888 return 0;
889 }
890
891 if(node->GetNodeType()!=SNode::LINE_ENTITY_TYPE_ID)
892 {
893 MMset(m, 0, NIL);
894 return 0;
895 }
896
897 try
898 {
899 // Delete line content
900 SLines* lines = (static_cast<SLineEntity*>(node))->GetSLines();
901 lines->Clear();
902
903 // Load points
904 if (points != NIL)
905 {
906 // Iterate through the recursive tuple
907 int pointTuple;
908 float x, y, z;
909 points = MTOP(points);
910 while(points != NIL)
911 {
912 // Get point coordinate
913 pointTuple = MTOP(MMfetch(m, points, 0));
914 x = MTOF(MMfetch(m, pointTuple, 0));
915 y = MTOF(MMfetch(m, pointTuple, 1));
916 z = MTOF(MMfetch(m, pointTuple, 2));
917 points = MTOP(MMfetch(m, points, 1));
918
919 // Add point
920 lines->AddPoint(x, y, z);
921 }
922
923 // Draw the line
924 lines->Draw();
925 MMset(m, 0, ITOM(1));
926 return 0;
927 }
928 }
929 catch(Ogre::Exception&)
930 {
931 MMechostr(MSKDEBUG, "SO3LineEntitySetPoints error\n");
932 }
933 MMset(m, 0, NIL);
934 return 0;
935}
936
937
947{
948#ifdef SO3_DEBUG
949 MMechostr(MSKDEBUG, "SO3LineEntityClearPoints\n");
950#endif
951 int obj = MMget(m, 0);
952 if(obj==NIL)
953 {
954 MMset(m, 0, NIL);
955 return 0;
956 }
957
958 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
959 if(node==NULL)
960 {
961 MMset(m, 0, NIL);
962 return 0;
963 }
964
965 if(node->GetNodeType()!=SNode::LINE_ENTITY_TYPE_ID)
966 {
967 MMset(m, 0, NIL);
968 return 0;
969 }
970
971 try
972 {
973 SLines* lines = (static_cast<SLineEntity*>(node))->GetSLines();
974 lines->Clear();
975 MMset(m, 0, ITOM(1));
976 return 0;
977 }
978 catch(const SException&)
979 {
980 MMechostr(MSKDEBUG, "SO3LineEntityClearPoints error\n");
981 MMset(m, 0, NIL);
982 return 0;
983 }
984}
985
986
997{
998#ifdef SO3_DEBUG
999 MMechostr(MSKDEBUG, "SO3LineEntitySetDashed\n");
1000#endif
1001 int dash = MMpull(m);
1002 int obj = MMget(m, 0);
1003 if(obj==NIL)
1004 {
1005 MMset(m, 0, NIL);
1006 return 0;
1007 }
1008
1009 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
1010 if(node==NULL)
1011 {
1012 MMset(m, 0, NIL);
1013 return 0;
1014 }
1015
1016 if(node->GetNodeType()!=SNode::LINE_ENTITY_TYPE_ID)
1017 {
1018 MMset(m, 0, NIL);
1019 return 0;
1020 }
1021
1022 bool dashed = false;
1023 if (dash != NIL)
1024 dashed = (MTOI(dashed) > 1) ? true : false;
1025
1026 try
1027 {
1028 SLines* lines = (static_cast<SLineEntity*>(node))->GetSLines();
1029 lines->SetDashed(dashed);
1030 MMset(m, 0, ITOM(1));
1031 return 0;
1032 }
1033 catch(const SException&)
1034 {
1035 MMechostr(MSKDEBUG, "SO3LineEntitySetDashed error\n");
1036 MMset(m, 0, NIL);
1037 return 0;
1038 }
1039}
1040
1041
1051{
1052#ifdef SO3_DEBUG
1053 MMechostr(MSKDEBUG, "SO3LineEntityGetDashed\n");
1054#endif
1055 int obj = MMget(m, 0);
1056 if(obj==NIL)
1057 {
1058 MMset(m, 0, NIL);
1059 return 0;
1060 }
1061
1062 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
1063 if(node==NULL)
1064 {
1065 MMset(m, 0, NIL);
1066 return 0;
1067 }
1068
1069 if(node->GetNodeType()!=SNode::LINE_ENTITY_TYPE_ID)
1070 {
1071 MMset(m, 0, NIL);
1072 return 0;
1073 }
1074
1075 try
1076 {
1077 SLines* lines = (static_cast<SLineEntity*>(node))->GetSLines();
1078 MMset(m, 0, ITOM(lines->GetDashed() ? 1 : 0));
1079 return 0;
1080 }
1081 catch(const SException&)
1082 {
1083 MMechostr(MSKDEBUG, "SO3LineEntityGetDashed error\n");
1084 MMset(m, 0, NIL);
1085 return 0;
1086 }
1087}
1088
1089
1090NativeDefinition natSO3Line[] = {
1091 { "SO3LineEntityCreate", 4, "fun [SO3_SCENE S [[F F F] r1] I] SO3_OBJECT", SO3LineEntityCreate },
1092 { "SO3LineEntityCreateDashed", 4, "fun [SO3_SCENE S [[F F F] r1] I] SO3_OBJECT", SO3LineEntityCreateDashed },
1093 { "SO3LineEntityCreateEx", 5, "fun [SO3_SCENE S [[F F F] r1] I I] SO3_OBJECT", SO3LineEntityCreateEx },
1094 { "SO3LineEntityCreateDashedEx", 5, "fun [SO3_SCENE S [[F F F] r1] I I] SO3_OBJECT", SO3LineEntityCreateDashedEx },
1095 { "SO3LineEntityGetDiffuse", 1, "fun [SO3_OBJECT] I", SO3LineEntityGetDiffuse },
1096 { "SO3LineEntitySetDiffuse", 2, "fun [SO3_OBJECT I] I", SO3LineEntitySetDiffuse },
1097 { "SO3LineEntityGetPoint", 2, "fun [SO3_OBJECT I] [F F F]", SO3LineEntityGetPoint },
1098 { "SO3LineEntitySetPoint", 3, "fun [SO3_OBJECT I [F F F]] I", SO3LineEntitySetPoint },
1099 { "SO3LineEntityAddPoint", 3, "fun [SO3_OBJECT I [F F F]] I", SO3LineEntityAddPoint },
1100 { "SO3LineEntityRemovePoint", 2, "fun [SO3_OBJECT I] I", SO3LineEntityRemovePoint },
1101 { "SO3LineEntityGetNumberOfPoints", 1, "fun [SO3_OBJECT] I", SO3LineEntityGetNumberOfPoints },
1102 { "SO3LineEntityGetPoints", 1, "fun [SO3_OBJECT] [[F F F] r1]", SO3LineEntityGetPoints },
1103 { "SO3LineEntitySetPoints", 2, "fun [SO3_OBJECT [[F F F] r1]] I", SO3LineEntitySetPoints },
1104 { "SO3LineEntityClearPoints", 1, "fun [SO3_OBJECT] I", SO3LineEntityClearPoints },
1105 { "SO3LineEntitySetDashed", 2, "fun [SO3_OBJECT I] I", SO3LineEntitySetDashed },
1106 { "SO3LineEntityGetDashed", 1, "fun [SO3_OBJECT] I", SO3LineEntityGetDashed }
1107};
1108
1109
1115int SCOLloadLineEntity(mmachine m,cbmachine w)
1116{
1117 return PKhardpak2(m, "SO3Line.pkg", sizeof(natSO3Line) / sizeof(natSO3Line[0]), natSO3Line);
1118}
1119
1125{
1126 return 0;
1127}
NativeDefinition natSO3Line[]
int SCOLfreeLineEntity()
free the SO3Engine LineEntity function
int SCOLloadLineEntity(mmachine m, cbmachine w)
Load the SO3Engine LineEntity function.
MMechostr(MSKDEBUG, " > Start loading Plugin SO3Engine dll\n")
SCOL_EXPORT int cbmachine w
Definition SO3SCOL.cpp:5150
int createObject(mmachine m, SNode *curNode, SScene *curScene)
static Ogre::ColourValue ScolToOgreColorRGBA(const int &scolColor)
static int OgreToScolColorRGBA(const Ogre::ColourValue &ogreColor)
void SetColour(const Ogre::ColourValue &newColour)
Definition SO3Lines.cpp:77
void Draw()
Definition SO3Lines.cpp:181
void AddPoint(const size_t &pointIndex, const Ogre::Vector3 &pt)
Definition SO3Lines.cpp:96
int SO3LineEntitySetPoints(mmachine m)
SO3LineEntitySetPoints : Set all the points of the line in a single call.
int SO3LineEntityGetPoints(mmachine m)
SO3LineEntityGetPoints : Retrieves the list of points positions.
int SO3LineEntityRemovePoint(mmachine m)
SO3LineEntityRemovePoint : Removes an existing point on the line, at the indicated position.
int SO3LineEntityCreateDashedEx(mmachine m)
SO3LineEntityCreateDashedEx : Create a new line entity.
int SO3LineEntitySetPoint(mmachine m)
SO3LineEntitySetPoint : Sets the position of an existing point of the line.
int SO3LineEntityGetNumberOfPoints(mmachine m)
SO3LineEntityGetNumberOfPoints : Retrieves the numbers of points composing the line.
int SO3LineEntityGetDashed(mmachine m)
SO3LineEntityGetDashed : Get the drawing mode of the line.
int SO3LineEntityClearPoints(mmachine m)
SO3LineEntityClearPoints : Clear all the points of the line.
int SO3LineEntityGetDiffuse(mmachine m)
SO3LineEntityGetDiffuse : Retrieves the color of the line (RGBA)
int SO3LineEntitySetDashed(mmachine m)
SO3LineEntitySetDashed : Change the drawing mode of the line.
int SO3LineEntityCreate(mmachine m)
main include
int SO3LineEntityAddPoint(mmachine m)
SO3LineEntityAddPoint : Add a new point on the line, after the indicated position.
int SO3LineEntitySetDiffuse(mmachine m)
SO3LineEntitySetDiffuse : Set the color of the line (RGBA)
int SO3LineEntityCreateDashed(mmachine m)
SO3LineEntityCreateDashed : Create a new line entity.
int SO3LineEntityCreateEx(mmachine m)
SO3LineEntityCreateEx : Create a new line entity.
int SO3LineEntityGetPoint(mmachine m)
SO3LineEntityGetPoint : Retrieves the position of an existing point of the line.