00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00036
00037 #include "SO3SCOL.h"
00038 #include "../SO3Utils/SO3RayCast.h"
00039
00040
00041 #include "../SO3Animation/SO3NodeAnimation.h"
00042
00043
00044 #include "../SO3Renderer/SO3Viewport.h"
00045
00046
00047 #include "../SO3SceneGraph/SO3Bone.h"
00048 #include "../SO3SceneGraph/SO3Camera.h"
00049 #include "../SO3SceneGraph/SO3Entity.h"
00050 #include "../SO3SceneGraph/SO3Light.h"
00051 #include "../SO3SceneGraph/SO3ParticleSystem.h"
00052 #include "../SO3SceneGraph/SO3Scene.h"
00053 #include "../SO3SceneGraph/SO3Skeleton.h"
00054
00055
00072 int SO3ObjectRotate(mmachine m)
00073 {
00074 #ifdef SO3_DEBUG
00075 MMechostr(MSKDEBUG,"SO3ObjectRotate\n");
00076 #endif
00077
00078 int rep = MMpull(m);
00079 int axe = MTOP(MMpull(m));
00080 int rot = MMpull(m);
00081 int n = MMget(m, 0);
00082
00083 if((n==NIL)||(rot==NIL)||(rep==NIL)||(axe==NIL))
00084 {
00085 MMset(m, 0, NIL);
00086 return 0;
00087 }
00088
00089 SNode* node = (SNode*)MMfetch(m, MTOP(n), 0);
00090 if(node==NULL)
00091 {
00092 MMset(m, 0, NIL);
00093 return 0;
00094 }
00095
00096 int x = MMfetch(m, axe, 0);
00097 int y = MMfetch(m, axe, 1);
00098 int z = MMfetch(m, axe, 2);
00099
00100 if((x==NIL) || (y==NIL) || (z==NIL))
00101 {
00102 MMset(m, 0, NIL);
00103 return 0;
00104 }
00105
00106 Ogre::Vector3 vecteur = Ogre::Vector3(MTOF(x), MTOF(y), MTOF(z));
00107
00108 node->Rotate(vecteur, MTOF(rot), static_cast<SNode::NodeTransformSpace> (MTOI(rep)));
00109
00110 MMset(m, 0, ITOM(1));
00111 return 0;
00112 }
00113
00114
00124 int SO3ObjectShowBoundingBox(mmachine m)
00125 {
00126 #ifdef SO3_DEBUG
00127 MMechostr(MSKDEBUG,"SO3ObjectShowBoundingBox\n");
00128 #endif
00129
00130 int i = MMpull(m);
00131 int n = MMget(m, 0);
00132
00133 if ((i==NIL)||(n==NIL))
00134 {
00135 MMset(m, 0, NIL);
00136 return 0;
00137 }
00138
00139 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
00140 if (node==NULL)
00141 {
00142 MMset(m, 0, NIL);
00143 return 0;
00144 }
00145
00146 if (node->GetNodeType() == SNode::BONE_TYPE_ID)
00147 {
00148 MMset(m, 0, NIL);
00149 return 0;
00150 }
00151
00152 if (MTOI(i)==0)
00153 node->SetShowBoundingBox(false);
00154 else
00155 node->SetShowBoundingBox(true);
00156
00157 MMset(m, 0, ITOM(1));
00158
00159 return 0;
00160 }
00161
00162
00178 int SO3ObjectSetDirection(mmachine m)
00179 {
00180 #ifdef SO3_DEBUG
00181 MMechostr(MSKDEBUG,"SO3ObjectSetDirection\n");
00182 #endif
00183
00184 int rep = MMpull(m) ;
00185 int vec = MTOP(MMpull(m));
00186 int n = MMget(m, 0);
00187
00188 if ((n==NIL)||(vec==NIL)||(rep==NIL))
00189 {
00190 MMset(m, 0, NIL);
00191 return 0;
00192 }
00193
00194 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
00195 if (node==NULL)
00196 {
00197 MMset(m, 0, NIL);
00198 return 0;
00199 }
00200
00201
00202 if (node->GetNodeType() == SNode::BONE_TYPE_ID)
00203 {
00204 MMset(m, 0, NIL);
00205 return 0;
00206 }
00207
00208 int x = MMfetch(m, vec, 0);
00209 int y = MMfetch(m, vec, 1);
00210 int z = MMfetch(m, vec, 2);
00211
00212 if((x==NIL) || (y==NIL) || (z==NIL))
00213 {
00214 MMset(m, 0, NIL);
00215 return 0;
00216 }
00217
00218 Ogre::Vector3 vecteur = Ogre::Vector3(MTOF(x), MTOF(y), MTOF(z));
00219
00220 node->SetDirection(vecteur, static_cast <SNode::NodeTransformSpace> (MTOI(rep)), Ogre::Vector3::NEGATIVE_UNIT_Z);
00221
00222 MMset(m, 0, ITOM(1));
00223
00224 return 0;
00225 }
00226
00227
00243 int SO3ObjectLookAt(mmachine m)
00244 {
00245 #ifdef SO3_DEBUG
00246 MMechostr(MSKDEBUG,"SO3ObjectLookAt\n");
00247 #endif
00248
00249 int rep = MMpull(m);
00250 int vec = MTOP(MMpull(m));
00251 int n = MMget(m, 0);
00252
00253 if ((n==NIL)||(vec==NIL)||(rep==NIL))
00254 {
00255 MMset(m, 0, NIL);
00256 return 0;
00257 }
00258
00259 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
00260 if (node==NULL)
00261 {
00262 MMset(m, 0, NIL);
00263 return 0;
00264 }
00265
00266 if (node->GetNodeType() == SNode::BONE_TYPE_ID)
00267 {
00268 MMset(m, 0, NIL);
00269 return 0;
00270 }
00271
00272 int x = MMfetch(m, vec, 0);
00273 int y = MMfetch(m, vec, 1);
00274 int z = MMfetch(m, vec, 2);
00275
00276 if((x==NIL) || (y==NIL) || (z==NIL))
00277 {
00278 MMset(m, 0, NIL);
00279 return 0;
00280 }
00281
00282 Ogre::Vector3 vecteur = Ogre::Vector3(MTOF(x), MTOF(y), MTOF(z));
00283
00284 node->LookAt(vecteur, static_cast <SNode::NodeTransformSpace> (MTOI(rep)), Ogre::Vector3::NEGATIVE_UNIT_Z);
00285
00286 MMset(m, 0, ITOM(1));
00287
00288 return 0;
00289 }
00290
00291
00302 int SO3ObjectSetVisible(mmachine m)
00303 {
00304 #ifdef SO3_DEBUG
00305 MMechostr(MSKDEBUG,"SO3ObjectSetVisible\n");
00306 #endif
00307
00308 int c = MMpull(m);
00309 int v = MMpull(m);
00310 int n = MMget(m, 0);
00311
00312 if ((n==NIL)||(c==NIL)||(v==NIL))
00313 {
00314 MMset(m, 0, NIL);
00315 return 0;
00316 }
00317
00318 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
00319 if (node==NULL)
00320 {
00321 MMset(m, 0, NIL);
00322 return 0;
00323 }
00324
00325 if (node->GetNodeType() == SNode::BONE_TYPE_ID)
00326 {
00327 MMset(m, 0, NIL);
00328 return 0;
00329 }
00330
00331 bool bvisible = false;
00332 bool brecursive = false;
00333
00334 if (MTOI(v)==1)
00335 bvisible = true;
00336
00337 if (MTOI(c)==1)
00338 brecursive = true;
00339
00340 node->SetVisible(bvisible, brecursive);
00341
00342 MMset(m, 0, ITOM(1));
00343
00344 return 0;
00345 }
00346
00347
00356 int SO3ObjectGetVisible(mmachine m)
00357 {
00358 #ifdef SO3_DEBUG
00359 MMechostr(MSKDEBUG,"SO3ObjectGetVisible\n");
00360 #endif
00361
00362 int n = MMget(m, 0);
00363
00364 if (n==NIL)
00365 {
00366 MMset(m, 0, NIL);
00367 return 0;
00368 }
00369
00370 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
00371 if(node==NULL)
00372 {
00373 MMset(m, 0, NIL);
00374 return 0;
00375 }
00376
00377 if(node->GetNodeType() == SNode::BONE_TYPE_ID)
00378 {
00379 MMset(m, 0, NIL);
00380 return 0;
00381 }
00382
00383 bool result = node->GetVisible();
00384
00385 if(result)
00386 MMset(m, 0, ITOM(1));
00387 else
00388 MMset(m, 0, ITOM(0));
00389
00390 return 0;
00391 }
00392
00393
00402 int SO3ObjectGetName(mmachine m)
00403 {
00404 #ifdef SO3_DEBUG
00405 MMechostr(MSKDEBUG,"SO3ObjectGetName\n");
00406 #endif
00407
00408 int n = MMpull(m);
00409 if(n==NIL)
00410 {
00411 MMpush(m, NIL);
00412 return 0;
00413 }
00414
00415 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
00416 if(node==NULL)
00417 {
00418 MMpush(m, NIL);
00419 return 0;
00420 }
00421
00422 return Mpushstrbloc(m, (char*)(node->GetName().c_str()));
00423 }
00424
00425
00435 int SO3ObjectSetOrientation(mmachine m)
00436 {
00437 #ifdef SO3_DEBUG
00438 MMechostr(MSKDEBUG,"SO3ObjectSetOrientation\n");
00439 #endif
00440
00441 int q = MTOP(MMpull(m));
00442 int n = MMget(m, 0);
00443
00444 if((n==NIL)||(q==NIL))
00445 {
00446 MMset(m, 0, NIL);
00447 return 0;
00448 }
00449
00450 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
00451 if(node==NULL)
00452 {
00453 MMset(m, 0, NIL);
00454 return 0;
00455 }
00456
00457 int x = MMfetch(m, q, 0);
00458 int y = MMfetch(m, q, 1);
00459 int z = MMfetch(m, q, 2);
00460 int w = MMfetch(m, q, 3);
00461
00462 if((x==NIL) || (y==NIL) || (z==NIL) || (w==NIL))
00463 {
00464 MMset(m, 0, NIL);
00465 return 0;
00466 }
00467
00468 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(w), MTOF(x), MTOF(y), MTOF(z));
00469 quat.normalise();
00470
00471 node->SetOrientation(quat);
00472
00473 MMset(m, 0, ITOM(1));
00474 return 0;
00475 }
00476
00477
00487 int SO3ObjectAddOrientation(mmachine m)
00488 {
00489 #ifdef SO3_DEBUG
00490 MMechostr(MSKDEBUG,"SO3ObjectAddOrientation\n");
00491 #endif
00492
00493 int q = MTOP(MMpull(m));
00494 int n = MMget(m, 0);
00495
00496 if((n==NIL)||(q==NIL))
00497 {
00498 MMset(m, 0, NIL);
00499 return 0;
00500 }
00501
00502 SNode* node = (SNode*) MMfetch(m,MTOP(n),0);
00503 if(node==NULL)
00504 {
00505 MMset(m, 0, NIL);
00506 return 0;
00507 }
00508
00509 int x = MMfetch(m, q, 0);
00510 int y = MMfetch(m, q, 1);
00511 int z = MMfetch(m, q, 2);
00512 int w = MMfetch(m, q, 3);
00513
00514 if((x==NIL) || (y==NIL) || (z==NIL) || (w==NIL))
00515 {
00516 MMset(m, 0, NIL);
00517 return 0;
00518 }
00519
00520 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(w), MTOF(x), MTOF(y), MTOF(z));
00521
00522 node->AddOrientation(quat);
00523
00524 MMset(m, 0, ITOM(1));
00525 return 0;
00526 }
00527
00528
00537 int SO3ObjectResetToInitialOrientation(mmachine m)
00538 {
00539 #ifdef SO3_DEBUG
00540 MMechostr(MSKDEBUG,"SO3ObjectResetToInitialOrientation\n");
00541 #endif
00542
00543 int n = MMget(m, 0);
00544
00545 if(n==NIL)
00546 {
00547 MMset(m, 0, NIL);
00548 return 0;
00549 }
00550
00551 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
00552 if(node==NULL)
00553 {
00554 MMset(m, 0, NIL);
00555 return 0;
00556 }
00557
00558 node->ResetToInitialOrientation();
00559
00560 MMset(m, 0, ITOM(1));
00561
00562 return 0;
00563 }
00564
00565
00575 int SO3ObjectSetPosition(mmachine m)
00576 {
00577 #ifdef SO3_DEBUG
00578 MMechostr(MSKDEBUG,"SO3ObjectSetPosition\n");
00579 #endif
00580
00581 int vec = MTOP(MMpull(m));
00582 int n = MMget(m, 0);
00583
00584 if((n==NIL)||(vec == NIL))
00585 {
00586 MMset(m, 0, NIL);
00587 return 0;
00588 }
00589
00590 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
00591 if(node==NULL)
00592 {
00593 MMset(m, 0, NIL);
00594 return 0;
00595 }
00596
00597 int x = MMfetch(m, vec, 0);
00598 int y = MMfetch(m, vec, 1);
00599 int z = MMfetch(m, vec, 2);
00600
00601 if((x==NIL) || (y==NIL) || (z==NIL))
00602 {
00603 MMset(m, 0, NIL);
00604 return 0;
00605 }
00606
00607 Ogre::Vector3 vecteur = Ogre::Vector3(MTOF(x), MTOF(y), MTOF(z));
00608
00609 node->SetPosition(vecteur);
00610
00611 MMset(m, 0, ITOM(1));
00612
00613 return 0;
00614 }
00615
00616
00632 int SO3ObjectTranslate(mmachine m)
00633 {
00634 #ifdef SO3_DEBUG
00635 MMechostr(MSKDEBUG,"SO3ObjectTranslate\n");
00636 #endif
00637
00638 int rep = MMpull(m);
00639 int vec = MTOP(MMpull(m));
00640 int n = MMget(m, 0);
00641
00642 if((n==NIL)||(vec==NIL)||(rep==NIL))
00643 {
00644 MMset(m, 0, NIL);
00645 return 0;
00646 }
00647
00648 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
00649 if(node==NULL)
00650 {
00651 MMechostr(MSKDEBUG,"Node is NULL\n") ;
00652 MMset(m, 0, NIL);
00653 return 0;
00654 }
00655
00656 int x = MMfetch(m, vec, 0);
00657 int y = MMfetch(m, vec, 1);
00658 int z = MMfetch(m, vec, 2);
00659
00660 if((x==NIL) || (y==NIL) || (z==NIL))
00661 {
00662 MMset(m, 0, NIL);
00663 return 0;
00664 }
00665
00666
00667 if((MTOF(x) == 0.0) && (MTOF(y) == 0.0) && (MTOF(z) == 0.0))
00668 {
00669 MMset(m, 0, NIL);
00670 return 0;
00671 }
00672
00673 Ogre::Vector3 vecteur = Ogre::Vector3(MTOF(x), MTOF(y), MTOF(z));
00674
00675 node->Translate(vecteur, static_cast <SNode::NodeTransformSpace> (MTOI(rep)));
00676
00677 MMset(m, 0, ITOM(1));
00678 return 0;
00679 }
00680
00681
00691 int SO3ObjectSetScale(mmachine m)
00692 {
00693 #ifdef SO3_DEBUG
00694 MMechostr(MSKDEBUG,"SO3ObjectSetScale\n");
00695 #endif
00696
00697 int vec = MTOP(MMpull(m));
00698 int n = MMget(m, 0);
00699
00700 if((n==NIL)||(vec==NIL))
00701 {
00702 MMset(m, 0, NIL);
00703 return 0;
00704 }
00705
00706 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
00707 if(node==NULL)
00708 {
00709 MMset(m, 0, NIL);
00710 return 0;
00711 }
00712
00713 int x = MMfetch(m, vec, 0);
00714 int y = MMfetch(m, vec, 1);
00715 int z = MMfetch(m, vec, 2);
00716
00717 if((x==NIL) || (y==NIL) || (z==NIL))
00718 {
00719 MMset(m, 0, NIL);
00720 return 0;
00721 }
00722
00723 Ogre::Vector3 vecteur = Ogre::Vector3(MTOF(x), MTOF(y), MTOF(z));
00724
00725 node->SetScale(vecteur);
00726
00727 MMset(m, 0, ITOM(1));
00728 return 0;
00729 }
00730
00731
00740 int SO3ObjectGetOrientation(mmachine m)
00741 {
00742 #ifdef SO3_DEBUG
00743 MMechostr(MSKDEBUG,"SO3ObjectGetOrientation\n");
00744 #endif
00745
00746 int n = MMget(m, 0);
00747
00748 if (n==NIL)
00749 {
00750 MMset(m, 0, NIL);
00751 return 0;
00752 }
00753
00754 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
00755 if(node==NULL)
00756 {
00757 MMset(m, 0, NIL);
00758 return 0;
00759 }
00760
00761 Ogre::Quaternion q = node->GetOrientation();
00762
00763 int tuple = MMmalloc(m, 4, TYPETAB);
00764 if(tuple==NIL)
00765 {
00766 MMset(m, 0, NIL);
00767 return MERRMEM;
00768 }
00769
00770 MMstore(m, tuple, 0, FTOM((q.x)));
00771 MMstore(m, tuple, 1, FTOM((q.y)));
00772 MMstore(m, tuple, 2, FTOM((q.z)));
00773 MMstore(m, tuple, 3, FTOM((q.w)));
00774 MMset(m, 0, PTOM(tuple));
00775
00776 return 0;
00777 }
00778
00779
00788 int SO3ObjectGetInitialOrientation(mmachine m)
00789 {
00790 #ifdef SO3_DEBUG
00791 MMechostr(MSKDEBUG,"SO3ObjectGetInitialOrientation\n");
00792 #endif
00793
00794 int n = MMget(m, 0);
00795
00796 if(n==NIL)
00797 {
00798 MMset(m, 0, NIL);
00799 return 0;
00800 }
00801
00802 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
00803 if(node==NULL)
00804 {
00805 MMset(m, 0, NIL);
00806 return 0;
00807 }
00808
00809 Ogre::Quaternion q = node->GetInitialOrientation();
00810
00811 int tuple = MMmalloc(m, 4, TYPETAB);
00812 if(tuple==NIL)
00813 {
00814 MMset(m, 0, NIL);
00815 return MERRMEM;
00816 }
00817
00818 MMstore(m, tuple, 0, FTOM((q.x)));
00819 MMstore(m, tuple, 1, FTOM((q.y)));
00820 MMstore(m, tuple, 2, FTOM((q.z)));
00821 MMstore(m, tuple, 3, FTOM((q.w)));
00822 MMset(m, 0, PTOM(tuple));
00823
00824 return 0;
00825 }
00826
00827
00836 int SO3ObjectGetGlobalOrientation(mmachine m)
00837 {
00838 #ifdef SO3_DEBUG
00839 MMechostr(MSKDEBUG,"SO3ObjectGetGlobalOrientation\n");
00840 #endif
00841
00842 int n = MMget(m, 0);
00843
00844 if(n==NIL)
00845 {
00846 MMset(m, 0, NIL);
00847 return 0;
00848 }
00849
00850 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
00851 if(node==NULL)
00852 {
00853 MMset(m, 0, NIL);
00854 return 0;
00855 }
00856
00857 Ogre::Quaternion q = node->GetGlobalOrientation();
00858
00859 int tuple = MMmalloc(m, 4, TYPETAB);
00860 if(tuple==NIL)
00861 {
00862 MMset(m, 0, NIL);
00863 return MERRMEM;
00864 }
00865
00866 MMstore(m, tuple, 0, FTOM(q.x));
00867 MMstore(m, tuple, 1, FTOM(q.y));
00868 MMstore(m, tuple, 2, FTOM(q.z));
00869 MMstore(m, tuple, 3, FTOM(q.w));
00870 MMset(m, 0, PTOM(tuple));
00871
00872 return 0;
00873 }
00874
00875
00885 int SO3ObjectSetGlobalPosition(mmachine m)
00886 {
00887 #ifdef SO3_DEBUG
00888 MMechostr(MSKDEBUG,"SO3ObjectSetGlobalPosition\n");
00889 #endif
00890
00891 int vec = MMpull(m);
00892 int n = MMget(m, 0);
00893
00894 if ((n==NIL)||(vec==NIL))
00895 {
00896 MMset(m, 0, NIL);
00897 return 0;
00898 }
00899
00900 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
00901 if (node==NULL)
00902 {
00903 MMset(m, 0, NIL);
00904 return 0;
00905 }
00906
00907 int x = MMfetch(m, MTOP(vec), 0);
00908 int y = MMfetch(m, MTOP(vec), 1);
00909 int z = MMfetch(m, MTOP(vec), 2);
00910
00911 if((x==NIL) || (y==NIL) || (z==NIL))
00912 {
00913 MMset(m, 0, NIL);
00914 return 0;
00915 }
00916
00917 Ogre::Vector3 position = Ogre::Vector3(MTOF(x), MTOF(y), MTOF(z));
00918 node->SetGlobalPosition(position);
00919
00920 MMset(m, 0, ITOM(1));
00921 return 0;
00922 }
00923
00924
00934 int SO3ObjectSetGlobalOrientation(mmachine m)
00935 {
00936 #ifdef SO3_DEBUG
00937 MMechostr(MSKDEBUG,"SO3ObjectSetGlobalOrientation\n");
00938 #endif
00939
00940 int q = MMpull(m);
00941 int n = MMget(m, 0);
00942
00943 if((n==NIL)||(q==NIL))
00944 {
00945 MMset(m, 0, NIL);
00946 return 0;
00947 }
00948
00949 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
00950 if(node==NULL)
00951 {
00952 MMset(m, 0, NIL);
00953 return 0;
00954 }
00955
00956 int x = MMfetch(m, MTOP(q), 0);
00957 int y = MMfetch(m, MTOP(q), 1);
00958 int z = MMfetch(m, MTOP(q), 2);
00959 int w = MMfetch(m, MTOP(q), 3);
00960
00961 if((x==NIL) || (y==NIL) || (z==NIL) || (w==NIL))
00962 {
00963 MMset(m, 0, NIL);
00964 return 0;
00965 }
00966
00967 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(w), MTOF(x), MTOF(y), MTOF(z));
00968 quat.normalise();
00969
00970 node->SetGlobalOrientation(quat);
00971
00972 MMset(m, 0, ITOM(1));
00973 return 0;
00974 }
00975
00976
00986 int SO3ObjectSetGlobalScale(mmachine m)
00987 {
00988 #ifdef SO3_DEBUG
00989 MMechostr(MSKDEBUG,"SO3ObjectSetGlobalScale\n");
00990 #endif
00991
00992 int vec = MTOP(MMpull(m));
00993 int n = MMget(m, 0);
00994
00995 if ((n==NIL)||(vec==NIL))
00996 {
00997 MMset(m, 0, NIL);
00998 return 0;
00999 }
01000
01001 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
01002 if (node==NULL)
01003 {
01004 MMset(m, 0, NIL);
01005 return 0;
01006 }
01007
01008 int x = MMfetch(m, vec, 0);
01009 int y = MMfetch(m, vec, 1);
01010 int z = MMfetch(m, vec, 2);
01011
01012 if((x==NIL) || (y==NIL) || (z==NIL))
01013 {
01014 MMset(m, 0, NIL);
01015 return 0;
01016 }
01017
01018 Ogre::Vector3 scale = Ogre::Vector3(MTOF(x), MTOF(y), MTOF(z));
01019 node->SetGlobalScale(scale);
01020
01021 MMset(m, 0, ITOM(1));
01022 return 0;
01023 }
01024
01025
01034 int SO3ObjectGetPosition(mmachine m)
01035 {
01036 #ifdef SO3_DEBUG
01037 MMechostr(MSKDEBUG,"SO3ObjectGetPosition\n");
01038 #endif
01039
01040 int n = MMget(m, 0);
01041
01042 if(n==NIL)
01043 {
01044 MMset(m, 0, NIL);
01045 return 0;
01046 }
01047
01048 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
01049 if(node==NULL)
01050 {
01051 MMset(m, 0, NIL);
01052 return 0;
01053 }
01054
01055 Ogre::Vector3 vecteur = node->GetPosition();
01056
01057 int tuple = MMmalloc(m, 3, TYPETAB);
01058 if(tuple==NIL)
01059 {
01060 MMset(m, 0, NIL);
01061 return MERRMEM;
01062 }
01063
01064 MMstore(m, tuple, 0, FTOM((vecteur.x)));
01065 MMstore(m, tuple, 1, FTOM((vecteur.y)));
01066 MMstore(m, tuple, 2, FTOM((vecteur.z)));
01067 MMset(m, 0, PTOM(tuple));
01068
01069 return 0;
01070 }
01071
01072
01081 int SO3ObjectGetInitialPosition(mmachine m)
01082 {
01083 #ifdef SO3_DEBUG
01084 MMechostr(MSKDEBUG,"SO3ObjectGetInitialPosition\n");
01085 #endif
01086
01087 int n = MMget(m, 0);
01088
01089 if(n==NIL)
01090 {
01091 MMset(m, 0, NIL);
01092 return 0;
01093 }
01094
01095 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
01096 if(node==NULL)
01097 {
01098 MMset(m, 0, NIL);
01099 return 0;
01100 }
01101
01102 Ogre::Vector3 vecteur = node->GetInitialPosition();
01103
01104 int tuple = MMmalloc(m, 3, TYPETAB);
01105 if(tuple==NIL)
01106 {
01107 MMset(m, 0, NIL);
01108 return MERRMEM;
01109 }
01110
01111 MMstore(m, tuple, 0, FTOM((vecteur.x)));
01112 MMstore(m, tuple, 1, FTOM((vecteur.y)));
01113 MMstore(m, tuple, 2, FTOM((vecteur.z)));
01114 MMset(m,0,PTOM(tuple));
01115
01116 return 0;
01117 }
01118
01119
01128 int SO3ObjectGetGlobalPosition(mmachine m)
01129 {
01130 #ifdef SO3_DEBUG
01131 MMechostr(MSKDEBUG,"SO3ObjectGetGlobalPosition\n");
01132 #endif
01133
01134 int n = MMget(m, 0);
01135
01136 if(n==NIL)
01137 {
01138 MMset(m, 0 ,NIL);
01139 return 0;
01140 }
01141
01142 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
01143 if(node==NULL)
01144 {
01145 MMset(m, 0, NIL);
01146 return 0;
01147 }
01148
01149 Ogre::Vector3 vec = node->GetGlobalPosition();
01150
01151 int tuple = MMmalloc(m, 3, TYPETAB);
01152 if(tuple==NIL)
01153 {
01154 MMset(m, 0, NIL);
01155 return MERRMEM;
01156 }
01157
01158 MMstore(m, tuple, 0, FTOM((vec.x)));
01159 MMstore(m, tuple, 1, FTOM((vec.y)));
01160 MMstore(m, tuple, 2, FTOM((vec.z)));
01161 MMset(m, 0, PTOM(tuple));
01162
01163 return 0;
01164 }
01165
01166
01175 int SO3ObjectGetScale(mmachine m)
01176 {
01177 #ifdef SO3_DEBUG
01178 MMechostr(MSKDEBUG,"SO3ObjectGetScale\n");
01179 #endif
01180
01181 int n = MMget(m, 0);
01182
01183 if(n==NIL)
01184 {
01185 MMset(m, 0, NIL);
01186 return 0;
01187 }
01188
01189 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
01190 if(node==NULL)
01191 {
01192 MMset(m, 0, NIL);
01193 return 0;
01194 }
01195
01196 Ogre::Vector3 vecteur = node->GetScale();
01197
01198 int tuple = MMmalloc(m, 3, TYPETAB);
01199 if(tuple==NIL)
01200 {
01201 MMset(m, 0, NIL);
01202 return MERRMEM;
01203 }
01204
01205 MMstore(m, tuple, 0, FTOM((vecteur.x)));
01206 MMstore(m, tuple, 1, FTOM((vecteur.y)));
01207 MMstore(m, tuple, 2, FTOM((vecteur.z)));
01208 MMset(m, 0, PTOM(tuple));
01209
01210 return 0;
01211 }
01212
01213
01222 int SO3ObjectGetInitialScale(mmachine m)
01223 {
01224 #ifdef SO3_DEBUG
01225 MMechostr(MSKDEBUG,"SO3ObjectGetInitialScale\n");
01226 #endif
01227
01228 int n = MMget(m, 0);
01229
01230 if(n==NIL)
01231 {
01232 MMset(m, 0, NIL);
01233 return 0;
01234 }
01235
01236 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
01237 if(node==NULL)
01238 {
01239 MMset(m, 0, NIL);
01240 return 0;
01241 }
01242
01243 Ogre::Vector3 vecteur = node->GetInitialScale();
01244
01245 int tuple = MMmalloc(m, 3, TYPETAB);
01246 if(tuple==NIL)
01247 {
01248 MMset(m, 0, NIL);
01249 return MERRMEM;
01250 }
01251
01252 MMstore(m, tuple, 0, FTOM((vecteur.x)));
01253 MMstore(m, tuple, 1, FTOM((vecteur.y)));
01254 MMstore(m, tuple, 2, FTOM((vecteur.z)));
01255 MMset(m, 0, PTOM(tuple));
01256
01257 return 0;
01258 }
01259
01260
01269 int SO3ObjectGetMatrix(mmachine m)
01270 {
01271 #ifdef SO3_DEBUG
01272 MMechostr(MSKDEBUG,"SO3ObjectGetMatrix\n");
01273 #endif
01274
01275 int n = MMget(m, 0);
01276
01277 if(n==NIL)
01278 {
01279 MMset(m, 0, NIL);
01280 return 0;
01281 }
01282
01283 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
01284 if(node==NULL)
01285 {
01286 MMset(m, 0, NIL);
01287 return 0;
01288 }
01289
01290 Ogre::Matrix3 rot;
01291 node->GetOrientation().ToRotationMatrix(rot);
01292 Ogre::Matrix4 matTr = (Ogre::Matrix4)rot;
01293 matTr.setTrans(node->GetPosition());
01294 matTr.setScale(node->GetScale());
01295
01296 int tuple = MMmalloc(m, 16, TYPETAB);
01297 if(tuple==NIL)
01298 {
01299 MMset(m,0,NIL);
01300 return MERRMEM;
01301 }
01302
01303 MMstore(m, tuple, 0, FTOM(matTr[0][0]));
01304 MMstore(m, tuple, 1, FTOM(matTr[0][1]));
01305 MMstore(m, tuple, 2, FTOM(matTr[0][2]));
01306 MMstore(m, tuple, 3, FTOM(matTr[0][3]));
01307 MMstore(m, tuple, 4, FTOM(matTr[1][0]));
01308 MMstore(m, tuple, 5, FTOM(matTr[1][1]));
01309 MMstore(m, tuple, 6, FTOM(matTr[1][2]));
01310 MMstore(m, tuple, 7, FTOM(matTr[1][3]));
01311 MMstore(m, tuple, 8, FTOM(matTr[2][0]));
01312 MMstore(m, tuple, 9, FTOM(matTr[2][1]));
01313 MMstore(m, tuple, 10, FTOM(matTr[2][2]));
01314 MMstore(m, tuple, 11, FTOM(matTr[2][3]));
01315 MMstore(m, tuple, 12, FTOM(matTr[3][0]));
01316 MMstore(m, tuple, 13, FTOM(matTr[3][1]));
01317 MMstore(m, tuple, 14, FTOM(matTr[3][2]));
01318 MMstore(m, tuple, 15, FTOM(matTr[3][3]));
01319 MMset(m, 0, PTOM(tuple));
01320
01321 return 0;
01322 }
01323
01324
01333 int SO3ObjectGetWorldMatrix(mmachine m)
01334 {
01335 #ifdef SO3_DEBUG
01336 MMechostr(MSKDEBUG,"SO3ObjectGetWorldMatrix\n");
01337 #endif
01338
01339 int n = MMget(m, 0);
01340
01341 if(n==NIL)
01342 {
01343 MMset(m, 0, NIL);
01344 return 0;
01345 }
01346
01347 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
01348 if(node==NULL)
01349 {
01350 MMset(m, 0, NIL);
01351 return 0;
01352 }
01353
01354 Ogre::Matrix4 matTr(node->GetTransformationMatrix());
01355
01356 int tuple = MMmalloc(m, 16, TYPETAB);
01357 if(tuple==NIL)
01358 {
01359 MMset(m, 0, NIL);
01360 return MERRMEM;
01361 }
01362
01363 MMstore(m, tuple, 0, FTOM(matTr[0][0]));
01364 MMstore(m, tuple, 1, FTOM(matTr[0][1]));
01365 MMstore(m, tuple, 2, FTOM(matTr[0][2]));
01366 MMstore(m, tuple, 3, FTOM(matTr[0][3]));
01367 MMstore(m, tuple, 4, FTOM(matTr[1][0]));
01368 MMstore(m, tuple, 5, FTOM(matTr[1][1]));
01369 MMstore(m, tuple, 6, FTOM(matTr[1][2]));
01370 MMstore(m, tuple, 7, FTOM(matTr[1][3]));
01371 MMstore(m, tuple, 8, FTOM(matTr[2][0]));
01372 MMstore(m, tuple, 9, FTOM(matTr[2][1]));
01373 MMstore(m, tuple, 10, FTOM(matTr[2][2]));
01374 MMstore(m, tuple, 11, FTOM(matTr[2][3]));
01375 MMstore(m, tuple, 12, FTOM(matTr[3][0]));
01376 MMstore(m, tuple, 13, FTOM(matTr[3][1]));
01377 MMstore(m, tuple, 14, FTOM(matTr[3][2]));
01378 MMstore(m, tuple, 15, FTOM(matTr[3][3]));
01379 MMset(m, 0, PTOM(tuple));
01380
01381 return 0;
01382 }
01383
01384
01393 int SO3ObjectGetGlobalScale(mmachine m)
01394 {
01395 #ifdef SO3_DEBUG
01396 MMechostr(MSKDEBUG,"SO3ObjectGetGlobalScale\n");
01397 #endif
01398
01399 int n = MMget(m, 0);
01400
01401 if(n==NIL)
01402 {
01403 MMset(m, 0, NIL);
01404 return 0;
01405 }
01406
01407 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
01408 if(node==NULL)
01409 {
01410 MMset(m, 0, NIL);
01411 return 0;
01412 }
01413
01414 Ogre::Vector3 vecteur = node->GetGlobalScale();
01415
01416 int tuple = MMmalloc(m, 3, TYPETAB);
01417 if(tuple==NIL)
01418 {
01419 MMset(m, 0, NIL);
01420 return MERRMEM;
01421 }
01422
01423 MMstore(m, tuple, 0, FTOM((vecteur.x)));
01424 MMstore(m, tuple, 1, FTOM((vecteur.y)));
01425 MMstore(m, tuple, 2, FTOM((vecteur.z)));
01426 MMset(m, 0, PTOM(tuple));
01427
01428 return 0;
01429 }
01430
01431
01447 int SO3ObjectRotateRoll(mmachine m)
01448 {
01449 #ifdef SO3_DEBUG
01450 MMechostr(MSKDEBUG,"SO3ObjectRotateRoll\n");
01451 #endif
01452
01453 int rep = MMpull(m) ;
01454 int ang = MMpull(m);
01455 int n = MMget(m, 0);
01456
01457 if((n==NIL)||(rep==NIL)||(ang == NIL))
01458 {
01459 MMset(m, 0, NIL);
01460 return 0;
01461 }
01462
01463 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
01464 if(node==NULL)
01465 {
01466 MMset(m, 0, NIL);
01467 return 0;
01468 }
01469
01470 node->Roll(MTOF(ang), static_cast <SNode::NodeTransformSpace>(MTOI(rep)));
01471
01472 MMset(m, 0, ITOM(1));
01473 return 0;
01474 }
01475
01476
01492 int SO3ObjectRotateYaw(mmachine m)
01493 {
01494 #ifdef SO3_DEBUG
01495 MMechostr(MSKDEBUG,"SO3ObjectRotateYaw\n");
01496 #endif
01497
01498 int rep = MMpull(m) ;
01499 int ang = MMpull(m);
01500 int n = MMget(m, 0);
01501
01502 if((n==NIL)||(rep==NIL)||(ang == NIL))
01503 {
01504 MMset(m, 0, NIL);
01505 return 0;
01506 }
01507
01508 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
01509 if(node==NULL)
01510 {
01511 MMset(m, 0, NIL);
01512 return 0;
01513 }
01514
01515 node->Yaw(MTOF(ang), static_cast <SNode::NodeTransformSpace>(MTOI(rep)));
01516
01517 MMset(m, 0, ITOM(1));
01518
01519 return 0;
01520 }
01521
01522
01538 int SO3ObjectRotatePitch(mmachine m)
01539 {
01540 #ifdef SO3_DEBUG
01541 MMechostr(MSKDEBUG,"SO3ObjectRotatePitch\n");
01542 #endif
01543
01544 int rep = MMpull(m) ;
01545 int ang = MMpull(m);
01546 int n = MMget(m, 0);
01547
01548 if((n==NIL)||(rep==NIL)||(ang == NIL))
01549 {
01550 MMset(m, 0, NIL);
01551 return 0;
01552 }
01553
01554 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
01555 if(node==NULL)
01556 {
01557 MMset(m, 0, NIL);
01558 return 0;
01559 }
01560
01561 node->Pitch(MTOF(ang), static_cast <SNode::NodeTransformSpace>(MTOI(rep)));
01562
01563 MMset(m, 0, ITOM(1));
01564
01565 return 0;
01566 }
01567
01568
01577 int SO3ObjectNbOfChild(mmachine m)
01578 {
01579 #ifdef SO3_DEBUG
01580 MMechostr(MSKDEBUG,"SO3ObjectNbOfChild\n");
01581 #endif
01582
01583 int n = MMget(m, 0);
01584
01585 if(n==NIL)
01586 {
01587 MMset(m, 0, NIL);
01588 return 0;
01589 }
01590
01591 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
01592 if(node==NULL)
01593 {
01594 MMset(m, 0, NIL);
01595 return 0;
01596 }
01597
01598 int nb = node->GetNumChildren();
01599
01600 MMset(m, 0, nb);
01601
01602 return 0;
01603 }
01604
01605
01614 int SO3ObjectRemoveAllChildren(mmachine m)
01615 {
01616 #ifdef SO3_DEBUG
01617 MMechostr(MSKDEBUG,"SO3ObjectRemoveAllChildren\n");
01618 #endif
01619
01620 int n = MMget(m, 0);
01621
01622 if(n==NIL)
01623 {
01624 MMset(m, 0, NIL);
01625 return 0;
01626 }
01627
01628 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
01629 if(node==NULL)
01630 {
01631 MMset(m, 0, NIL);
01632 return 0;
01633 }
01634
01635 node->DetachAllChildren();
01636
01637 MMset(m, 0, ITOM(1));
01638 return 0;
01639 }
01640
01641
01650 int SO3ObjectGetChildren(mmachine m)
01651 {
01652 #ifdef SO3_DEBUG
01653 MMechostr(MSKDEBUG,"SO3ObjectGetChildren\n");
01654 #endif
01655
01656 int n = MMget(m, 0);
01657
01658 if(n==NIL)
01659 {
01660 MMset(m, 0, NIL);
01661 return 0;
01662 }
01663
01664 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
01665 if(node==NULL)
01666 {
01667 MMset(m, 0, NIL);
01668 return 0;
01669 }
01670
01671 int tmp_res;
01672 int p = 0;
01673
01674 const SNodeMap childrenNodesListCopy = node->GetChildrenNodes();
01675 SNodeMap::const_iterator iChildrenList = childrenNodesListCopy.begin();
01676
01677 while (iChildrenList != childrenNodesListCopy.end())
01678 {
01679 int c = OBJfindTH(m, SO3OBJTYPE, (int)(iChildrenList->second));
01680 if(c!=NIL)
01681 c = MMfetch(m, c, OFFOBJMAG);
01682
01683 if(MMpush(m, c))
01684 return MERRMEM;
01685
01686 INVERT(m, 0, 1);
01687 p++;
01688 iChildrenList++;
01689 }
01690 MMpull(m);
01691
01692 if(MMpush(m, NIL))
01693 return MERRMEM;
01694
01695 for(int j=0; j<p; j++)
01696 {
01697 if(MMpush(m, 2*2))
01698 return MERRMEM;
01699
01700 if(int k=MBdeftab(m))
01701 return k;
01702 }
01703 return 0;
01704 }
01705
01706
01715 int SO3ObjectDestroy(mmachine m)
01716 {
01717 #ifdef SO3_DEBUG
01718 MMechostr(MSKDEBUG, "SO3ObjectDestroy\n");
01719 #endif
01720
01721 int n = MMget(m, 0);
01722
01723 if (n==NIL)
01724 {
01725 MMset(m, 0, NIL);
01726 return 0;
01727 }
01728
01729 OBJdelTM(m, SO3OBJTYPE, n);
01730
01731 MMset(m, 0, ITOM(1));
01732 return 0;
01733 }
01734
01735
01744 int SO3ObjectSetInitialState(mmachine m)
01745 {
01746 #ifdef SO3_DEBUG
01747 MMechostr(MSKDEBUG,"SO3ObjectSetInitialState\n");
01748 #endif
01749
01750 int n = MMget(m, 0);
01751
01752 if(n==NIL)
01753 {
01754 MMechostr(MSKDEBUG,"Node is NIL\n");
01755 MMset(m, 0, NIL);
01756 return 0;
01757 }
01758
01759 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
01760 if(node==NULL)
01761 {
01762 MMechostr(MSKDEBUG,"Node is NULL \n");
01763 MMset(m, 0, NIL);
01764 return 0;
01765 }
01766
01767 node->StoreInitialPRS();
01768
01769 MMset(m, 0, ITOM(1));
01770
01771 return 0;
01772 }
01773
01774
01783 int SO3ObjectResetToInitialState(mmachine m)
01784 {
01785 #ifdef SO3_DEBUG
01786 MMechostr(MSKDEBUG,"SO3ObjectResetToInitialState\n");
01787 #endif
01788
01789 int n = MMget(m, 0);
01790
01791 if(n==NIL)
01792 {
01793 MMechostr(MSKDEBUG,"Node is NIL\n");
01794 MMset(m, 0, NIL);
01795 return 0;
01796 }
01797
01798 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
01799 if(node==NULL)
01800 {
01801 MMset(m, 0, NIL);
01802 return 0;
01803 }
01804
01805 node->ResetToInitialPRS();
01806
01807 MMset(m, 0, ITOM(1));
01808
01809 return 0;
01810 }
01811
01812
01821 int SO3ObjectGetSceneRoot(mmachine m)
01822 {
01823 #ifdef SO3_DEBUG
01824 MMechostr(MSKDEBUG,"SO3ObjectGetSceneRoot\n");
01825 #endif
01826
01827 int s = MMget(m, 0);
01828
01829 if((s==NIL))
01830 {
01831 MMset(m, 0, NIL);
01832 return 0;
01833 }
01834
01835 SScene* scene = (SScene*) MMfetch(m, MTOP(s), 0);
01836 if(scene==NULL)
01837 {
01838 MMset(m, 0, NIL);
01839 return 0;
01840 }
01841
01842 SNode* curNode = scene->GetRootNode();
01843 int so3obj = OBJfindTH(m, SO3OBJTYPE, (int)(curNode));
01844
01845 so3obj = MMfetch(m, so3obj, OFFOBJMAG);
01846 MMset(m, 0, so3obj);
01847
01848 return 0;
01849 }
01850
01851
01860 int SO3ObjectGetParent(mmachine m)
01861 {
01862 #ifdef SO3_DEBUG
01863 MMechostr(MSKDEBUG, "SO3ObjectGetParent\n");
01864 #endif
01865
01866 int n = MMget(m, 0);
01867
01868 if(n==NIL)
01869 {
01870 MMset(m, 0, NIL);
01871 return 0;
01872 }
01873
01874 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
01875 if(node==NULL)
01876 {
01877 MMset(m, 0, NIL);
01878 return 0;
01879 }
01880
01881 SNode* parent = node->GetParentSceneNode();
01882 if (parent == 0)
01883 {
01884 MMset(m, 0, NIL);
01885 return 0;
01886 }
01887
01888 int p = OBJfindTH(m, SO3OBJTYPE, (int)(parent));
01889
01890 if(p!=NIL)
01891 p = MMfetch(m, p, OFFOBJMAG);
01892
01893 MMset(m, 0, p);
01894
01895 return 0;
01896 }
01897
01898
01908 int SO3ObjectLink(mmachine m)
01909 {
01910 #ifdef SO3_DEBUG
01911 MMechostr(MSKDEBUG, "SO3ObjectLink\n");
01912 #endif
01913
01914 int p = MMpull(m);
01915 int n = MMget(m,0);
01916
01917 if (n==NIL)
01918 {
01919 MMset(m, 0, NIL);
01920 return 0;
01921 }
01922
01923 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
01924 if (node == NULL)
01925 {
01926 MMset(m, 0, NIL);
01927 return 0;
01928 }
01929
01930 SNode* parent = 0;
01931 if (p!=NIL)
01932 {
01933 parent = (SNode*) MMfetch(m, MTOP(p), 0);
01934 if(parent == NULL)
01935 {
01936 MMset(m, 0, NIL);
01937 return 0;
01938 }
01939 }
01940
01941
01942 if (node->GetNodeType()==SNode::BONE_TYPE_ID)
01943 {
01944 MMset(m, 0, NIL);
01945 return 0;
01946 }
01947
01948 if (p==NIL)
01949 node->AttachToParent(node->GetParentScene()->GetRootNode());
01950 else
01951 node->AttachToParent(parent);
01952
01953 MMset(m, 0, ITOM(1));
01954 return 0;
01955 }
01956
01957
01967 int SO3ObjectGetPositionInObjectRef(mmachine m)
01968 {
01969 #ifdef SO3_DEBUG
01970 MMechostr(MSKDEBUG, "SO3ObjectGetPositionInObjectRef\n");
01971 #endif
01972
01973 int p = MMpull(m);
01974 int n = MMget(m, 0);
01975
01976 if ((n==NIL)||(p==NIL))
01977 {
01978 MMset(m, 0, NIL);
01979 return 0;
01980 }
01981
01982 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
01983 SNode* parent = (SNode*) MMfetch(m, MTOP(p), 0);
01984
01985 if ((node==NULL)||(parent==NULL))
01986 {
01987 MMset(m, 0, NIL);
01988 return 0;
01989 }
01990
01991 Ogre::Vector3 v = node->GetPositionFromNode(parent);
01992
01993 int tuple = MMmalloc(m, 3, TYPETAB);
01994 if (tuple==NIL)
01995 {
01996 MMset(m, 0, NIL);
01997 return MERRMEM;
01998 }
01999
02000 MMstore(m, tuple, 0, FTOM(v.x));
02001 MMstore(m, tuple, 1, FTOM(v.y));
02002 MMstore(m, tuple, 2, FTOM(v.z));
02003 MMset(m, 0, PTOM(tuple));
02004
02005 return 0;
02006 }
02007
02008
02018 int SO3ObjectGetOrientationInObjectRef(mmachine m)
02019 {
02020 #ifdef SO3_DEBUG
02021 MMechostr(MSKDEBUG,"SO3ObjectGetOrientationInObjectRef\n");
02022 #endif
02023
02024 int p = MMpull(m);
02025 int n = MMget(m, 0);
02026
02027 if((n==NIL)||(p==NIL))
02028 {
02029 MMset(m, 0, NIL);
02030 return 0;
02031 }
02032
02033 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
02034 SNode* parent = (SNode*) MMfetch(m, MTOP(p), 0);
02035
02036 if((node==NULL)||(parent==NULL))
02037 {
02038 MMset(m, 0, NIL);
02039 return 0;
02040 }
02041
02042 Ogre::Quaternion orient = node->GetOrientationFromNode(parent);
02043
02044 int tuple = MMmalloc(m, 4, TYPETAB);
02045 if(tuple==NIL)
02046 {
02047 MMset(m, 0, NIL);
02048 return MERRMEM;
02049 }
02050
02051 MMstore(m, tuple, 0, FTOM((orient.x)));
02052 MMstore(m, tuple, 1, FTOM((orient.y)));
02053 MMstore(m, tuple, 2, FTOM((orient.z)));
02054 MMstore(m, tuple, 3, FTOM((orient.w)));
02055 MMset(m, 0, PTOM(tuple));
02056
02057 return 0;
02058 }
02059
02060
02070 int SO3ObjectGetScaleInObjectRef(mmachine m)
02071 {
02072 #ifdef SO3_DEBUG
02073 MMechostr(MSKDEBUG,"SO3ObjectGetScaleInObjectRef\n");
02074 #endif
02075
02076 int p = MMpull(m);
02077 int n = MMget(m, 0);
02078
02079 if((n==NIL)||(p==NIL))
02080 {
02081 MMset(m, 0, NIL);
02082 return 0;
02083 }
02084
02085 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
02086 SNode* parent = (SNode*) MMfetch(m, MTOP(p), 0);
02087
02088 if((node==NULL)||(parent==NULL))
02089 {
02090 MMset(m, 0, NIL);
02091 return 0;
02092 }
02093
02094 Ogre::Vector3 scaleResult = node->GetScaleFromNode(parent);
02095
02096 int tuple = MMmalloc(m, 3, TYPETAB);
02097 if(tuple==NIL)
02098 {
02099 MMset(m,0,NIL);
02100 return MERRMEM;
02101 }
02102
02103 MMstore(m, tuple, 0, FTOM((scaleResult.x)));
02104 MMstore(m, tuple, 1, FTOM((scaleResult.y)));
02105 MMstore(m, tuple, 2, FTOM((scaleResult.z)));
02106 MMset(m, 0, PTOM(tuple));
02107
02108 return 0;
02109 }
02110
02111
02120 int SO3ObjectUnlink(mmachine m)
02121 {
02122 #ifdef SO3_DEBUG
02123 MMechostr(MSKDEBUG,"SO3ObjectUnlink\n");
02124 #endif
02125
02126 int n = MMget(m, 0);
02127
02128 if (n==NIL)
02129 {
02130 MMset(m, 0, NIL);
02131 return 0;
02132 }
02133
02134 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
02135 if(node == NULL)
02136 {
02137 MMset(m, 0, NIL);
02138 return 0;
02139 }
02140
02141
02142 node->DetachFromParent();
02143
02144 MMset(m, 0, ITOM(1));
02145
02146 return 0;
02147 }
02148
02149
02161 int SO3ObjectSetAutoTracking(mmachine m)
02162 {
02163 #ifdef SO3_DEBUG
02164 MMechostr(MSKDEBUG,"SO3ObjectSetAutoTracking\n");
02165 #endif
02166
02167 int offset = MMpull(m);
02168 int direction = MMpull(m);
02169 int booleen = MTOI(MMpull(m));
02170 int p = MMpull(m);
02171 int n = MMget(m, 0);
02172
02173 if((n==NIL)||(p==NIL))
02174 {
02175 MMset(m, 0, NIL);
02176 return 0;
02177 }
02178
02179 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
02180 SNode* parent = (SNode*) MMfetch(m, MTOP(p), 0);
02181
02182 if((node == NULL)||(parent == NULL))
02183 {
02184 MMset(m, 0, NIL);
02185 return 0;
02186 }
02187
02188 if(parent->GetNodeType() == SNode::BONE_TYPE_ID || node->GetNodeType() == SNode::BONE_TYPE_ID)
02189 {
02190 MMset(m, 0, NIL);
02191 return 0;
02192 }
02193
02194 if(direction == NIL && offset == NIL)
02195 {
02196 if(booleen == 0)
02197 node->SetAutoTracking(false, parent);
02198 else
02199 node->SetAutoTracking(true, parent);
02200 }
02201 else if(direction != NIL && offset == NIL)
02202 {
02203 Ogre::Vector3 dir(Ogre::Vector3::NEGATIVE_UNIT_Z);
02204
02205 if((MMfetch(m, MTOP(direction), 0)!=NIL))
02206 dir.x = MTOF(MMfetch(m, MTOP(direction), 0));
02207 if((MMfetch(m, MTOP(direction), 1)!=NIL))
02208 dir.y = MTOF(MMfetch(m, MTOP(direction), 1));
02209 if((MMfetch(m, MTOP(direction), 2)!=NIL))
02210 dir.z = MTOF(MMfetch(m, MTOP(direction), 2));
02211
02212 if(booleen == 0)
02213 node->SetAutoTracking(false, parent, dir);
02214 else
02215 node->SetAutoTracking(true, parent,dir);
02216 }
02217 else if(direction == NIL && offset != NIL)
02218 {
02219 Ogre::Vector3 dir(Ogre::Vector3::NEGATIVE_UNIT_Z);
02220 Ogre::Vector3 off(Ogre::Vector3::ZERO);
02221
02222 if((MMfetch(m, MTOP(offset), 0)!=NIL))
02223 off.x = MTOF(MMfetch(m, MTOP(offset), 0));
02224 if((MMfetch(m, MTOP(offset), 1)!=NIL))
02225 off.y = MTOF(MMfetch(m, MTOP(offset), 1));
02226 if((MMfetch(m, MTOP(offset), 2)!=NIL))
02227 off.z = MTOF(MMfetch(m, MTOP(offset), 2));
02228
02229 if(booleen == 0)
02230 node->SetAutoTracking(false, parent, dir, off);
02231 else
02232 node->SetAutoTracking(true, parent, dir, off);
02233 }
02234 else
02235 {
02236 Ogre::Vector3 dir(Ogre::Vector3::NEGATIVE_UNIT_Z);
02237
02238 if((MMfetch(m, MTOP(direction), 0)!=NIL))
02239 dir.x = MTOF(MMfetch(m, MTOP(direction), 0));
02240 if((MMfetch(m, MTOP(direction), 1)!=NIL))
02241 dir.y = MTOF(MMfetch(m, MTOP(direction), 1));
02242 if((MMfetch(m, MTOP(direction), 2)!=NIL))
02243 dir.z = MTOF(MMfetch(m, MTOP(direction), 2));
02244
02245 Ogre::Vector3 off(Ogre::Vector3::ZERO);
02246
02247 if((MMfetch(m, MTOP(offset), 0)!=NIL))
02248 off.x = MTOF(MMfetch(m, MTOP(offset), 0));
02249 if((MMfetch(m, MTOP(offset), 1)!=NIL))
02250 off.y = MTOF(MMfetch(m, MTOP(offset), 1));
02251 if((MMfetch(m, MTOP(offset), 2)!=NIL))
02252 off.z = MTOF(MMfetch(m, MTOP(offset), 2));
02253
02254 if(booleen == 0)
02255 node->SetAutoTracking(false, parent, dir, off);
02256 else
02257 node->SetAutoTracking(true, parent, dir, off);
02258 }
02259
02260 MMset(m, 0, ITOM(1));
02261 return 0;
02262 }
02263
02264
02274 int SO3ObjectSetRenderingDistance(mmachine m)
02275 {
02276 #ifdef SO3_DEBUG
02277 MMechostr(MSKDEBUG,"SO3ObjectSetRenderingDistance\n");
02278 #endif
02279
02280 int value = MMpull(m);
02281 int n = MMget(m, 0);
02282
02283 if (n==NIL)
02284 {
02285 MMset(m, 0, NIL);
02286 return 0;
02287 }
02288
02289 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
02290 if (node == NULL)
02291 {
02292 MMset(m, 0, NIL);
02293 return 0;
02294 }
02295
02296 float fvalue = (value == NIL) ? 0.0f : MTOF(value);
02297
02298 try
02299 {
02300 node->SetRenderingDistance(fvalue) ;
02301 }
02302 catch(Ogre::Exception &e)
02303 {
02304 if (e.getNumber() == Ogre::Exception::ERR_NOT_IMPLEMENTED)
02305 MMechostr(MSKDEBUG, "Object do not support Rendering distance: %s\n", e.what());
02306 else
02307 MMechostr(MSKDEBUG, "An exception has occurred: %s\n", e.what()) ;
02308
02309 MMset(m, 0, NIL);
02310 return 0;
02311 }
02312
02313 MMset(m, 0, ITOM(1));
02314 return 0;
02315 }
02316
02317
02326 int SO3ObjectGetRenderingDistance(mmachine m)
02327 {
02328 #ifdef SO3_DEBUG
02329 MMechostr(MSKDEBUG, "SO3ObjectGetRenderingDistance\n");
02330 #endif
02331
02332 int n = MMget(m,0);
02333
02334 if (n==NIL)
02335 {
02336 MMset(m, 0, NIL);
02337 return 0;
02338 }
02339
02340 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
02341 if (node == NULL)
02342 {
02343 MMset(m, 0, NIL);
02344 return 0;
02345 }
02346
02347 float value = 0;
02348 try
02349 {
02350 value = node->GetRenderingDistance();
02351 }
02352 catch(Ogre::Exception &e)
02353 {
02354 if (e.getNumber() == Ogre::Exception::ERR_NOT_IMPLEMENTED)
02355 MMechostr(MSKDEBUG, "Object do not support Rendering Distance: %s\n", e.what());
02356 else
02357 MMechostr(MSKDEBUG, "An exception has occurred: %s\n", e.what()) ;
02358
02359 MMset(m, 0, NIL);
02360 return 0;
02361 }
02362
02363 MMset(m, 0, FTOM(value));
02364 return 0;
02365 }
02366
02367
02377 int SO3ObjectSetCastShadows(mmachine m)
02378 {
02379 #ifdef SO3_DEBUG
02380 MMechostr(MSKDEBUG, "SO3ObjectSetCastShadows\n");
02381 #endif
02382
02383 int booleen = MTOI(MMpull(m));
02384 int n = MMget(m, 0);
02385
02386 if (n==NIL)
02387 {
02388 MMset(m, 0, NIL);
02389 return 0;
02390 }
02391
02392 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
02393 if (node == NULL)
02394 {
02395 MMset(m, 0, NIL);
02396 return 0;
02397 }
02398
02399 try
02400 {
02401 if (booleen == SO3_FALSE)
02402 node->SetCastShadows(false);
02403 else
02404 node->SetCastShadows(true) ;
02405 }
02406 catch(Ogre::Exception &e)
02407 {
02408 if (e.getNumber() == Ogre::Exception::ERR_NOT_IMPLEMENTED)
02409 MMechostr(MSKDEBUG, "Object do not support Shadow Casting: %s\n", e.what());
02410 else
02411 MMechostr(MSKDEBUG, "An exception has occurred: %s\n", e.what()) ;
02412
02413 MMset(m, 0, NIL);
02414 return 0;
02415 }
02416
02417 MMset(m, 0, ITOM(1));
02418 return 0;
02419 }
02420
02421
02434 int SO3ObjectGetBoundingBoxInfo(mmachine m)
02435 {
02436 #ifdef SO3_DEBUG
02437 MMechostr(MSKDEBUG,"SO3ObjectGetBoundingBoxInfo\n");
02438 #endif
02439
02440 int ichilds = MMpull(m);
02441 int n = MMget(m, 0);
02442 if (n==NIL)
02443 {
02444 MMset(m, 0, NIL);
02445 return 0;
02446 }
02447
02448 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
02449 if (node == NULL)
02450 {
02451 MMset(m, 0, NIL);
02452 return 0;
02453 }
02454
02455 Ogre::Vector3 sizeBB;
02456 Ogre::Vector3 position;
02457 Ogre::Quaternion quat;
02458
02459 bool childs = false;
02460 if ((ichilds != NIL) && (MTOI(ichilds) == 1))
02461 childs = true;
02462
02463
02464 try
02465 {
02466 position = node->GetBoundingBoxCenter();
02467 }
02468 catch(std::exception&)
02469 {
02470 }
02471
02472 try
02473 {
02474 sizeBB = node->GetBoundingBoxSize(childs);
02475 quat = node->GetOrientation();
02476 }
02477 catch(std::exception &e)
02478 {
02479 MMechostr(MSKDEBUG, "An exception has occurred: %s\n", e.what()) ;
02480
02481 MMset(m, 0, NIL);
02482 return 0;
02483 }
02484
02485
02486 int size = MMmalloc(m, 3, TYPETAB);
02487 if (size==NIL)
02488 {
02489 MMset(m, 0, NIL);
02490 return MERRMEM;
02491 }
02492
02493 MMstore(m, size, 0, FTOM(sizeBB.x));
02494 MMstore(m, size, 1, FTOM(sizeBB.y));
02495 MMstore(m, size, 2, FTOM(sizeBB.z));
02496 MMpush(m, PTOM(size));
02497
02498
02499 int pos = MMmalloc(m, 3, TYPETAB);
02500 if (pos==NIL)
02501 {
02502 MMset(m, 0, NIL);
02503 return MERRMEM;
02504 }
02505
02506 MMstore(m, pos, 0, FTOM(position.x));
02507 MMstore(m, pos, 1, FTOM(position.y));
02508 MMstore(m, pos, 2, FTOM(position.z));
02509 MMpush(m, PTOM(pos));
02510
02511
02512 int orient = MMmalloc(m, 4, TYPETAB);
02513 if (orient==NIL)
02514 {
02515 MMset(m, 0, NIL);
02516 return MERRMEM;
02517 }
02518
02519 MMstore(m, orient, 0, FTOM(quat.x));
02520 MMstore(m, orient, 1, FTOM(quat.y));
02521 MMstore(m, orient, 2, FTOM(quat.z));
02522 MMstore(m, orient, 3, FTOM(quat.w));
02523 MMpush(m, PTOM(orient));
02524
02525
02526 int result = MMmalloc(m, 3, TYPETAB);
02527 if (result==NIL)
02528 {
02529 MMset(m, 0, NIL);
02530 return MERRMEM;
02531 }
02532
02533 MMstore(m, result, 2, MMpull(m));
02534 MMstore(m, result, 1, MMpull(m));
02535 MMstore(m, result, 0, MMpull(m));
02536 MMset(m, 0, PTOM(result));
02537
02538 return 0;
02539 }
02540
02541
02550 int SO3ObjectGetCastShadows(mmachine m)
02551 {
02552 #ifdef SO3_DEBUG
02553 MMechostr(MSKDEBUG, "SO3ObjectGetCastShadows\n");
02554 #endif
02555
02556 int n = MMget(m, 0);
02557
02558 if (n==NIL)
02559 {
02560 MMset(m, 0, NIL);
02561 return 0;
02562 }
02563
02564 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
02565 if (node == NULL)
02566 {
02567 MMset(m, 0, NIL);
02568 return 0;
02569 }
02570
02571 int booleen = 0 ;
02572 try
02573 {
02574 if (node->GetCastShadows())
02575 booleen = 1 ;
02576 }
02577 catch(Ogre::Exception &e)
02578 {
02579 if (e.getNumber() == Ogre::Exception::ERR_NOT_IMPLEMENTED)
02580 MMechostr(MSKDEBUG, "Object do not support Shadow Casting: %s\n", e.what());
02581 else
02582 MMechostr(MSKDEBUG, "An exception has occurred: %s\n", e.what()) ;
02583
02584 MMset(m, 0, NIL);
02585 return 0;
02586 }
02587
02588 MMset(m, 0, ITOM(booleen));
02589
02590 return 0;
02591 }
02592
02593
02602 int SO3ObjectGetPolygonCount(mmachine m)
02603 {
02604 #ifdef SO3_DEBUG
02605 MMechostr(MSKDEBUG,"SO3ObjectGetPolygonCount\n");
02606 #endif
02607
02608 int n = MMget(m, 0);
02609
02610 if(n==NIL)
02611 {
02612 MMset(m, 0, NIL);
02613 return 0;
02614 }
02615
02616 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
02617 if(node==NULL)
02618 {
02619 MMset(m, 0, NIL);
02620 return 0;
02621 }
02622
02623 if(node->GetNodeType()!=SNode::ENTITY_TYPE_ID)
02624 {
02625 MMset(m, 0, NIL);
02626 return 0;
02627 }
02628
02629 SEntity* entity = static_cast<SEntity*>(node);
02630
02631 MMset(m,0,ITOM(entity->GetPolygonCount()));
02632
02633 return 0;
02634 }
02635
02636
02646 int SO3ObjectSetMouseForeGround(mmachine m)
02647 {
02648 #ifdef SO3_DEBUG
02649 MMechostr(MSKDEBUG,"SO3ObjectSetMouseForeGround\n");
02650 #endif
02651
02652 int i = MTOI(MMpull(m));
02653 int n = MMget(m, 0);
02654
02655 if((i==NIL)||(n==NIL))
02656 {
02657 MMset(m, 0, NIL);
02658 return 0;
02659 }
02660
02661 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
02662 if(node==NULL)
02663 {
02664 MMset(m, 0, NIL);
02665 return 0;
02666 }
02667
02668 if(node->GetNodeType()!=SNode::ENTITY_TYPE_ID)
02669 {
02670 MMset(m, 0, NIL);
02671 return 0;
02672 }
02673
02674 if(i==0)
02675 node->setSceneNodeIsMouseForeground(false);
02676 else
02677 node->setSceneNodeIsMouseForeground(true);
02678
02679 MMset(m, 0, ITOM(i));
02680
02681 return 0;
02682 }
02683
02684
02694 int SO3ObjectSetMouseClick(mmachine m)
02695 {
02696 #ifdef SO3_DEBUG
02697 MMechostr(MSKDEBUG,"SO3ObjectSetMouseClick\n");
02698 #endif
02699
02700 int i = MTOI(MMpull(m));
02701 int n = MMget(m, 0);
02702
02703 if((i==NIL)||(n==NIL))
02704 {
02705 MMset(m, 0, NIL);
02706 return 0;
02707 }
02708
02709 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
02710 if(node==NULL)
02711 {
02712 MMset(m, 0, NIL);
02713 return 0;
02714 }
02715
02716 if(node->GetNodeType()!=SNode::ENTITY_TYPE_ID)
02717 {
02718 MMset(m, 0, NIL);
02719 return 0;
02720 }
02721
02722 if(i==0)
02723 node->setSceneNodeIsMouseClick(false);
02724 else
02725 node->setSceneNodeIsMouseClick(true);
02726
02727 MMset(m, 0, ITOM(i));
02728
02729 return 0;
02730 }
02731
02732
02741 int SO3ObjectGetMouseForeGround(mmachine m)
02742 {
02743 #ifdef SO3_DEBUG
02744 MMechostr(MSKDEBUG,"SO3ObjectGetMouseForeGround\n");
02745 #endif
02746
02747 int n = MMget(m, 0);
02748
02749 if(n==NIL)
02750 {
02751 MMset(m, 0, NIL);
02752 return 0;
02753 }
02754
02755 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
02756 if(node==NULL)
02757 {
02758 MMset(m, 0, NIL);
02759 return 0;
02760 }
02761
02762 if(node->GetNodeType()!=SNode::ENTITY_TYPE_ID)
02763 {
02764 MMset(m, 0, NIL);
02765 return 0;
02766 }
02767
02768 int result = 0;
02769
02770 if(node->getSceneNodeIsMouseForeground())
02771 result = 1;
02772
02773 MMset(m, 0, ITOM(result));
02774
02775 return 0;
02776 }
02777
02778
02787 int SO3ObjectGetMouseClick(mmachine m)
02788 {
02789 #ifdef SO3_DEBUG
02790 MMechostr(MSKDEBUG,"SO3ObjectGetMouseClick\n");
02791 #endif
02792
02793 int n = MMget(m, 0);
02794
02795 if(n==NIL)
02796 {
02797 MMset(m, 0, NIL);
02798 return 0;
02799 }
02800
02801 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
02802 if(node==NULL)
02803 {
02804 MMset(m, 0, NIL);
02805 return 0;
02806 }
02807
02808 if(node->GetNodeType()!=SNode::ENTITY_TYPE_ID)
02809 {
02810 MMset(m, 0, NIL);
02811 return 0;
02812 }
02813
02814 int result = 0;
02815
02816 if(node->getSceneNodeIsMouseClick())
02817 result = 1;
02818
02819 MMset(m, 0, ITOM(result));
02820
02821 return 0;
02822 }
02823
02824
02834 int SO3ObjectSetRenderOverlay(mmachine m)
02835 {
02836 #ifdef SO3_DEBUG
02837 MMechostr(MSKDEBUG,"SO3ObjectSetRenderOverlay\n");
02838 #endif
02839
02840 int booleen = MTOI(MMpull(m));
02841 int n = MMget(m, 0);
02842
02843 if(n==NIL)
02844 {
02845 MMset(m, 0, NIL);
02846 return 0;
02847 }
02848
02849 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
02850 if(node==NULL)
02851 {
02852 MMset(m, 0, NIL);
02853 return 0;
02854 }
02855
02856 if(node->GetNodeType()!=SNode::ENTITY_TYPE_ID)
02857 {
02858 MMset(m, 0, NIL);
02859 return 0;
02860 }
02861
02862 SEntity* entity = static_cast<SEntity*>(node);
02863
02864 if(booleen == 0)
02865 entity->SetRenderQueue(Ogre::RENDER_QUEUE_MAIN);
02866 else
02867 entity->SetRenderQueue(Ogre::RENDER_QUEUE_OVERLAY);
02868
02869 MMset(m, 0, ITOM(1));
02870
02871 return 0;
02872 }
02873
02874
02888 int SO3ObjectGetInfo(mmachine m)
02889 {
02890 #ifdef SO3_DEBUG
02891 MMechostr(MSKDEBUG,"SO3ObjectGetInfo\n");
02892 #endif
02893
02894 int x = MMpull(m);
02895 int y = MMpull(m);
02896 int v = MMget(m, 0);
02897
02898 if((v==NIL)||(x==NIL)||(y==NIL))
02899 {
02900 MMset(m, 0, NIL);
02901 return 0;
02902 }
02903
02904 SViewPort* viewport = (SViewPort*) MMfetch(m, MTOP(v), 0);
02905 if(viewport==NULL)
02906 {
02907 MMset(m, 0, NIL);
02908 return 0;
02909 }
02910
02911 SRaycastResult rayCastResults = viewport->RayCast(MTOI(y), MTOI(x));
02912
02913 int ent = OBJfindTH(m, SO3OBJTYPE, (int)(rayCastResults.entity));
02914 if(ent!=NIL)
02915 ent = MMfetch(m, ent, OFFOBJMAG);
02916
02917 createOrRetrieveScolMaterialAndSendToVM(m, rayCastResults.scene, rayCastResults.material);
02918 int mat = MMpull(m);
02919
02920 int tuple = MMmalloc(m, 3, TYPETAB);
02921 if(tuple==NIL)
02922 {
02923 MMset(m, 0, NIL);
02924 return MERRMEM;
02925 }
02926
02927 MMstore(m, tuple, 0, ent);
02928 MMstore(m, tuple, 1, mat);
02929 MMstore(m, tuple, 2, ITOM(-1 ));
02930 MMset(m, 0, PTOM(tuple));
02931
02932 return 0;
02933 }
02934
02958 int SO3ObjectGetInfoEx(mmachine m)
02959 {
02960 #ifdef SO3_DEBUG
02961 MMechostr(MSKDEBUG,"SO3ObjectGetInfoEx\n");
02962 #endif
02963
02964 int x = MMpull(m);
02965 int y = MMpull(m);
02966 int v = MMget(m, 0);
02967
02968 if((v==NIL)||(x==NIL)||(y==NIL))
02969 {
02970 MMset(m,0,NIL);
02971 return 0;
02972 }
02973
02974 SViewPort* viewport = (SViewPort*) MMfetch(m, MTOP(v), 0);
02975 if(viewport==NULL)
02976 {
02977 MMset(m, 0, NIL);
02978 return 0;
02979 }
02980
02981 SRaycastResult rayCastResults = viewport->RayCast(MTOI(y), MTOI(x));
02982
02983 int ent = OBJfindTH(m, SO3OBJTYPE, (int)(rayCastResults.entity));
02984 if(ent!=NIL)
02985 ent = MMfetch(m, ent, OFFOBJMAG);
02986
02987 createOrRetrieveScolMaterialAndSendToVM(m, rayCastResults.scene, rayCastResults.material);
02988 int mat = MMpull(m);
02989
02990 MMpush(m, ent);
02991 MMpush(m, mat);
02992 MMpush(m, ITOM(-1 ));
02993 MMpush(m, FTOM(rayCastResults.closestDistance));
02994 MMpush(m, ITOM(rayCastResults.indexFace));
02995
02996
02997
02998
02999 int vertex1 = MMmalloc(m, 3, TYPETAB);
03000 if(vertex1==NIL)
03001 {
03002 MMset(m, 0, NIL);
03003 return MERRMEM;
03004 }
03005
03006 MMstore(m, vertex1, 0, FTOM(rayCastResults.v1.x));
03007 MMstore(m, vertex1, 1, FTOM(rayCastResults.v1.y));
03008 MMstore(m, vertex1, 2, FTOM(rayCastResults.v1.z));
03009 MMpush(m, PTOM(vertex1));
03010
03011
03012 int vertex2 = MMmalloc(m, 3, TYPETAB);
03013 if(vertex2==NIL)
03014 {
03015 MMset(m, 0, NIL);
03016 return MERRMEM;
03017 }
03018
03019 MMstore(m, vertex2, 0, FTOM(rayCastResults.v2.x));
03020 MMstore(m, vertex2, 1, FTOM(rayCastResults.v2.y));
03021 MMstore(m, vertex2, 2, FTOM(rayCastResults.v2.z));
03022 MMpush(m, PTOM(vertex2));
03023
03024
03025 int vertex3 = MMmalloc(m, 3, TYPETAB);
03026 if(vertex3==NIL)
03027 {
03028 MMset(m, 0, NIL);
03029 return MERRMEM;
03030 }
03031
03032 MMstore(m, vertex3, 0, FTOM(rayCastResults.v3.x));
03033 MMstore(m, vertex3, 1, FTOM(rayCastResults.v3.y));
03034 MMstore(m, vertex3, 2, FTOM(rayCastResults.v3.z));
03035 MMpush(m, PTOM(vertex3));
03036
03037
03038
03039 int uv1 = MMmalloc(m, 2, TYPETAB);
03040 if(uv1==NIL)
03041 {
03042 MMset(m, 0, NIL);
03043 return MERRMEM;
03044 }
03045
03046 MMstore(m, uv1, 0, FTOM(rayCastResults.pReal1[0]));
03047 MMstore(m, uv1, 1, FTOM(rayCastResults.pReal1[1]));
03048 MMpush(m, PTOM(uv1));
03049
03050
03051 int uv2 = MMmalloc(m, 2, TYPETAB);
03052 if(uv2==NIL)
03053 {
03054 MMset(m, 0, NIL);
03055 return MERRMEM;
03056 }
03057 MMstore(m, uv2, 0, FTOM(rayCastResults.pReal2[0]));
03058 MMstore(m, uv2, 1, FTOM(rayCastResults.pReal2[1]));
03059 MMpush(m, PTOM(uv2));
03060
03061
03062 int uv3 = MMmalloc(m, 2, TYPETAB);
03063 if(uv3==NIL)
03064 {
03065 MMset(m, 0, NIL);
03066 return MERRMEM;
03067 }
03068 MMstore(m, uv3, 0, FTOM(rayCastResults.pReal3[0]));
03069 MMstore(m, uv3, 1, FTOM(rayCastResults.pReal3[1]));
03070 MMpush(m, PTOM(uv3));
03071
03072
03073
03074 int inter = MMmalloc(m, 3, TYPETAB);
03075 if(inter==NIL)
03076 {
03077 MMset(m, 0, NIL);
03078 return MERRMEM;
03079 }
03080
03081 MMstore(m, inter, 0, FTOM(rayCastResults.point.x));
03082 MMstore(m, inter, 1, FTOM(rayCastResults.point.y));
03083 MMstore(m, inter, 2, FTOM(rayCastResults.point.z));
03084 MMpush(m, PTOM(inter));
03085
03086
03087 int uvf = MMmalloc(m, 2, TYPETAB);
03088 if(uvf==NIL)
03089 {
03090 MMset(m, 0, NIL);
03091 return MERRMEM;
03092 }
03093
03094 MMstore(m, uvf, 0, FTOM(rayCastResults.uvResult.x));
03095 MMstore(m, uvf, 1, FTOM(rayCastResults.uvResult.y));
03096 MMpush(m, PTOM(uvf));
03097
03098 return 0;
03099 }
03100
03101
03110 int SO3ObjectGetScreenCoord(mmachine m)
03111 {
03112 #ifdef SO3_DEBUG
03113 MMechostr(MSKDEBUG, "SO3ObjectGetScreenCoord\n");
03114 #endif
03115
03116 int v = MMpull(m);
03117 int n = MMget(m, 0);
03118
03119 if((n==NIL)||(v==NIL))
03120 {
03121 MMset(m, 0, NIL);
03122 return 0;
03123 }
03124
03125 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
03126 if(node==NULL)
03127 {
03128 MMset(m, 0, NIL);
03129 return 0;
03130 }
03131
03132 SViewPort* viewport = (SViewPort*) MMfetch(m, MTOP(v), 0);
03133 if(viewport==NULL)
03134 {
03135 MMset(m, 0, NIL);
03136 return 0;
03137 }
03138
03139 SCamera* camera = viewport->GetCamera();
03140 if(camera==NULL)
03141 {
03142 MMset(m, 0, NIL);
03143 return 0;
03144 }
03145
03146 Ogre::Vector2 result;
03147 Ogre::Vector3 point = node->GetGlobalPosition();
03148
03149
03150 if(camera->IsFacingPoint(point))
03151 {
03152 MMset(m, 0, NIL);
03153 return 0;
03154 }
03155
03156
03157 point = camera->ToScreenSpace(point);
03158
03159
03160 result.x = (point.x / 2) + 0.5f;
03161 result.y = 1 - ((point.y / 2) + 0.5f);
03162
03163 int tuple = MMmalloc(m, 2, TYPETAB);
03164 if(tuple==NIL)
03165 {
03166 MMset(m, 0, NIL);
03167 return MERRMEM;
03168 }
03169
03170 MMstore(m, tuple, 0, FTOM((result.x)));
03171 MMstore(m, tuple, 1, FTOM((result.y)));
03172 MMset(m, 0, PTOM(tuple));
03173
03174 return 0;
03175 }
03176
03177
03187 int SO3ObjectGetScreenPixelCoord(mmachine m)
03188 {
03189 #ifdef SO3_DEBUG
03190 MMechostr(MSKDEBUG, "SO3ObjectGetScreenPixelCoord\n");
03191 #endif
03192
03193 int vp = MMpull(m);
03194 int n = MMget(m, 0);
03195
03196 if((n==NIL)||(vp==NIL))
03197 {
03198 MMset(m, 0, NIL);
03199 return 0;
03200 }
03201
03202 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
03203 if(node==NULL)
03204 {
03205 MMset(m, 0, NIL);
03206 return 0;
03207 }
03208
03209 SViewPort* viewport = (SViewPort*) MMfetch(m, MTOP(vp), 0);
03210 if(viewport==NULL)
03211 {
03212 MMechostr(MSKDEBUG, "vp is NULL \n");
03213 MMset(m, 0, NIL);
03214 return 0;
03215 }
03216
03217 SCamera* camera = viewport->GetCamera();
03218 if(camera==NULL)
03219 {
03220 MMset(m, 0, NIL);
03221 return 0;
03222 }
03223
03224 Ogre::Vector2 result;
03225 Ogre::Vector3 point = node->GetGlobalPosition();
03226
03227
03228 if(camera->IsFacingPoint(point))
03229 {
03230 MMset(m, 0, NIL);
03231 return 0;
03232 }
03233
03234
03235 point = camera->ToScreenSpace(point);
03236
03237
03238 result.x = (point.x / 2) + 0.5f;
03239 result.y = 1 - ((point.y / 2) + 0.5f);
03240
03241 result.x *= viewport->GetWidthPixels();
03242 result.y *= viewport->GetHeightPixels();
03243
03244 int tuple = MMmalloc(m, 2, TYPETAB);
03245 if(tuple==NIL)
03246 {
03247 MMset(m, 0, NIL);
03248 return MERRMEM;
03249 }
03250
03251 MMstore(m, tuple, 0, ITOM(((int)result.x)));
03252 MMstore(m, tuple, 1, ITOM(((int)result.y)));
03253 MMset(m, 0, PTOM(tuple));
03254
03255 return 0;
03256 }
03257
03258
03270 int SO3ObjectGetNodeFacingOrientation(mmachine m)
03271 {
03272
03273 #ifdef SO3_DEBUG
03274 MMechostr(MSKDEBUG,"SO3ObjectGetNodeFacingOrientation\n");
03275 #endif
03276
03277 int axis = MMpull(m);
03278 int dir = MMpull(m);
03279 int des = MMpull(m);
03280 int src = MMget(m,0);
03281
03282 if((des==NIL)||(src==NIL))
03283 {
03284 MMset(m, 0, NIL);
03285 return 0;
03286 }
03287
03288 SNode* srcnode = (SNode*) MMfetch(m,MTOP(src),0);
03289 if(srcnode==NULL)
03290 {
03291 MMset(m, 0, NIL);
03292 return 0;
03293 }
03294
03295 SNode* destnode = (SNode*) MMfetch(m,MTOP(des),0);
03296 if(destnode==NULL)
03297 {
03298 MMset(m, 0, NIL);
03299 return 0;
03300 }
03301
03302 Ogre::Vector3 uDir = Ogre::Vector3::NEGATIVE_UNIT_Z;
03303
03304 if(dir != NIL)
03305 {
03306 if(MMfetch(m, MTOP(dir), 0)!=NIL)
03307 uDir.x = MTOF(MMfetch(m, MTOP(dir), 0)) ;
03308 if(MMfetch(m,MTOP(dir),1)!=NIL)
03309 uDir.y = MTOF(MMfetch(m, MTOP(dir), 1)) ;
03310 if(MMfetch(m,MTOP(dir),2)!=NIL)
03311 uDir.z = MTOF(MMfetch(m, MTOP(dir), 2)) ;
03312 }
03313 uDir.normalise();
03314
03315 Ogre::Vector3 uAxis;
03316 uAxis.x = 1;
03317 uAxis.y = 1;
03318 uAxis.z = 1;
03319
03320 if(axis != NIL)
03321 {
03322 if(MMfetch(m, MTOP(axis), 0)!=NIL)
03323 uAxis.x = MTOI(MMfetch(m, MTOP(axis), 0));
03324 if(MMfetch(m, MTOP(axis), 1)!=NIL)
03325 uAxis.y = MTOI(MMfetch(m, MTOP(axis), 1));
03326 if(MMfetch(m, MTOP(axis), 2)!=NIL)
03327 uAxis.z = MTOI(MMfetch(m, MTOP(axis), 2));
03328 }
03329 uAxis.normalise();
03330
03331
03332 Ogre::Vector3 direction = srcnode->GetGlobalPosition() - destnode->GetGlobalPosition();
03333 Ogre::Vector3 srcvec = destnode->GetGlobalOrientation() * uDir;
03334 srcvec.normalise();
03335 direction.normalise();
03336
03337 Ogre::Quaternion dirQuat = srcvec.getRotationTo(direction) * destnode->GetGlobalOrientation();
03338
03339 Ogre::Vector3 xaxis = srcnode->GetGlobalOrientation().xAxis();
03340 Ogre::Vector3 yaxis = srcnode->GetGlobalOrientation().yAxis();
03341 Ogre::Vector3 zaxis = srcnode->GetGlobalOrientation().zAxis();
03342
03343 Ogre::Vector3 dxaxis = dirQuat.xAxis();
03344 Ogre::Vector3 dyaxis = dirQuat.yAxis();
03345 Ogre::Vector3 dzaxis = dirQuat.zAxis();
03346
03347 Ogre::Vector3 fxaxis;
03348 Ogre::Vector3 fyaxis;
03349 Ogre::Vector3 fzaxis;
03350
03351 if(uAxis.x)
03352 fxaxis = dxaxis;
03353 else
03354 fxaxis = xaxis;
03355
03356 if(uAxis.y)
03357 fyaxis = dyaxis;
03358 else
03359 fyaxis = yaxis;
03360
03361 if(uAxis.z)
03362 fzaxis = dzaxis;
03363 else
03364 fzaxis = zaxis;
03365
03366 Ogre::Quaternion returnQuat = Ogre::Quaternion(fxaxis, fyaxis, fzaxis);
03367 int tuple = MMmalloc(m, 4, TYPETAB);
03368 if(tuple==NIL)
03369 {
03370 MMset(m, 0, NIL);
03371 return MERRMEM;
03372 }
03373
03374 MMstore(m, tuple, 0, FTOM((returnQuat.x)));
03375 MMstore(m, tuple, 1, FTOM((returnQuat.y)));
03376 MMstore(m, tuple, 2, FTOM((returnQuat.z)));
03377 MMstore(m, tuple, 3, FTOM((returnQuat.w)));
03378 MMset(m, 0, PTOM(tuple));
03379
03380 return 0;
03381 }
03382
03383
03393 int SO3ObjectGetAnimation(mmachine m)
03394 {
03395 #ifdef SO3_DEBUG
03396 MMechostr(MSKDEBUG, "SO3ObjectGetAnimation\n");
03397 #endif
03398
03399 int name = MMpull(m);
03400 int n = MMget(m, 0);
03401 if((name==NIL)||(n==NIL))
03402 {
03403 MMset(m,0,NIL);
03404 return 0;
03405 }
03406
03407 SNode* node = (SNode*) MMfetch(m,MTOP(n),0);
03408 if(node==NULL)
03409 {
03410 MMset(m,0,NIL);
03411 return 0;
03412 }
03413
03414 std::string animationName(MMstartstr(m,MTOP(name)));
03415 SAnim* curAnim = node->GetAnimation(animationName);
03416 if(curAnim==0)
03417 {
03418 if (node->GetNodeType() == SNode::ENTITY_TYPE_ID)
03419 {
03420 SEntity* entity = static_cast<SEntity*> (node);
03421 SSkeleton* skeleton = entity->GetSkeleton();
03422 if (skeleton != 0)
03423 {
03424 curAnim = skeleton->GetAnimation(animationName);
03425 }
03426 }
03427
03428 if(curAnim==0)
03429 {
03430 MMechostr(MSKDEBUG,"Animation not found!\n");
03431 MMset(m, 0, NIL);
03432 return 0;
03433 }
03434 }
03435
03436 int a = OBJfindTH(m, SO3ANIM, (int)(curAnim));
03437 if(a!=NIL)
03438 a = MMfetch(m, a, OFFOBJMAG);
03439
03440 MMset(m, 0, a);
03441 return 0;
03442 }
03443
03444
03455 int SO3ObjectCreateNodesAnimation(mmachine m)
03456 {
03457 #ifdef SO3_DEBUG
03458 MMechostr(MSKDEBUG, "SO3ObjectCreateNodesAnimation\n");
03459 #endif
03460
03461 int length = MMpull(m);
03462 int p = MMpull(m);
03463 int n = MMpull(m);
03464 if((p==NIL)||(n==NIL)||(length==NIL))
03465 {
03466 MMpush(m, NIL);
03467 return 0;
03468 }
03469
03470 SNode* node = (SNode*) MMfetch(m, MTOP(n), 0);
03471 if(node==NULL)
03472 {
03473 MMpush(m, NIL);
03474 return 0;
03475 }
03476
03477 try
03478 {
03479 std::string animationName(MMstartstr(m, MTOP(p)));
03480 SAnim* animation = node->CreateNodeAnimation(animationName, MTOF(length));
03481 return createAnim(m, animation, (SNode*)node);
03482 }
03483 catch(Ogre::Exception &e)
03484 {
03485 MMechostr(MSKDEBUG, "An exception has occurred: %s\n", e.what());
03486 MMpush(m, NIL);
03487 return 0;
03488 }
03489 }
03490
03491
03501 int SO3ObjectSetInheritOrientation(mmachine m)
03502 {
03503 #ifdef SO3_DEBUG
03504 MMechostr(MSKDEBUG, "SO3ObjectSetInheritOrientation\n");
03505 #endif
03506
03507 int state = MMpull(m);
03508 int obj = MMget(m, 0);
03509 if(obj==NIL)
03510 {
03511 MMset(m, 0, NIL);
03512 return 0;
03513 }
03514
03515 SNode* node = (SNode*) MMfetch(m, MTOP(obj), 0);
03516 if(node==NULL)
03517 {
03518 MMset(m, 0, NIL);
03519 return 0;
03520 }
03521
03522 bool bState = false;
03523 if (MTOI(state) == 1)
03524 bState = true;
03525
03526 node->SetInheritOrientation(bState);
03527
03528 MMset(m, 0, ITOM(1));
03529
03530 return 0;
03531 }
03532
03533
03542 int SO3ObjectGetInheritOrientation(mmachine m)
03543 {
03544 #ifdef SO3_DEBUG
03545 MMechostr(MSKDEBUG, "SO3ObjectGetInheritOrientation\n");
03546 #endif
03547
03548 int obj = MMget(m, 0);
03549 if(obj==NIL)
03550 {
03551 MMset(m, 0, NIL);
03552 return 0;
03553 }
03554
03555 SNode* node = (SNode*) MMfetch(m, MTOP(obj), 0);
03556 if(node==NULL)
03557 {
03558 MMset(m, 0, NIL);
03559 return 0;
03560 }
03561
03562 MMset(m, 0, ITOM(node->GetInheritOrientation() ? 1 : 0));
03563
03564 return 0;
03565 }
03566
03575 int SO3ObjectResetOrientation(mmachine m)
03576 {
03577 #ifdef SO3_DEBUG
03578 MMechostr(MSKDEBUG, "SO3ObjectResetOrientation\n");
03579 #endif
03580
03581 int obj = MMget(m, 0);
03582 if(obj==NIL)
03583 {
03584 MMset(m, 0, NIL);
03585 return 0;
03586 }
03587
03588 SNode* node = (SNode*) MMfetch(m, MTOP(obj), 0);
03589 if(node==NULL)
03590 {
03591 MMset(m, 0, NIL);
03592 return 0;
03593 }
03594
03595 node->ResetOrientation();
03596
03597 MMset(m, 0, ITOM(1));
03598
03599 return 0;
03600 }
03601
03602
03606 #define NBOBJECTPKG 65
03607
03608
03612 char* OBJECTname[NBOBJECTPKG]=
03613 {
03614 "SO3ObjectRotate",
03615 "SO3ObjectShowBoundingBox",
03616 "SO3ObjectRotateYaw",
03617 "SO3ObjectSetDirection",
03618 "SO3ObjectLookAt",
03619 "SO3ObjectSetVisible",
03620 "SO3ObjectGetVisible",
03621 "SO3ObjectGetName",
03622 "SO3ObjectSetOrientation",
03623 "SO3ObjectAddOrientation",
03624 "SO3ObjectResetToInitialOrientation",
03625 "SO3ObjectSetPosition",
03626 "SO3ObjectTranslate",
03627 "SO3ObjectSetScale",
03628 "SO3ObjectGetOrientation",
03629 "SO3ObjectGetInitialOrientation",
03630 "SO3ObjectGetGlobalOrientation",
03631 "SO3ObjectSetGlobalOrientation",
03632 "SO3ObjectGetPosition",
03633 "SO3ObjectGetInitialPosition",
03634 "SO3ObjectGetGlobalPosition",
03635 "SO3ObjectSetGlobalPosition",
03636 "SO3ObjectGetScale",
03637 "SO3ObjectGetInitialScale",
03638 "SO3ObjectGetMatrix",
03639 "SO3ObjectGetWorldMatrix",
03640 "SO3ObjectGetGlobalScale",
03641 "SO3ObjectSetGlobalScale",
03642 "SO3ObjectRotateRoll",
03643 "SO3ObjectRotatePitch",
03644 "SO3ObjectNbOfChild",
03645 "SO3ObjectRemoveAllChildren",
03646 "SO3ObjectGetChildren",
03647 "SO3ObjectDestroy",
03648 "SO3ObjectSetInitialState",
03649 "SO3ObjectResetToInitialState",
03650 "SO3ObjectGetSceneRoot",
03651 "SO3ObjectGetParent",
03652 "SO3ObjectLink",
03653 "SO3ObjectGetPositionInObjectRef",
03654 "SO3ObjectGetOrientationInObjectRef",
03655 "SO3ObjectGetScaleInObjectRef",
03656 "SO3ObjectUnlink",
03657 "SO3ObjectSetAutoTracking",
03658 "SO3ObjectSetCastShadows",
03659 "SO3ObjectGetBoundingBoxInfo",
03660 "SO3ObjectGetCastShadows",
03661 "SO3ObjectSetMouseForeGround",
03662 "SO3ObjectSetMouseClick",
03663 "SO3ObjectGetMouseForeGround",
03664 "SO3ObjectGetMouseClick",
03665 "SO3ObjectSetRenderOverlay",
03666 "SO3ObjectGetPolygonCount",
03667 "SO3ObjectGetInfo",
03668 "SO3ObjectGetInfoEx",
03669 "SO3ObjectGetScreenCoord",
03670 "SO3ObjectGetScreenPixelCoord",
03671 "SO3ObjectGetNodeFacingOrientation",
03672 "SO3ObjectSetRenderingDistance",
03673 "SO3ObjectGetRenderingDistance",
03674 "SO3ObjectGetAnimation",
03675 "SO3ObjectCreateNodesAnimation",
03676 "SO3ObjectSetInheritOrientation",
03677 "SO3ObjectGetInheritOrientation",
03678 "SO3ObjectResetOrientation"
03679 };
03680
03681
03685 int (*OBJECTFunc[NBOBJECTPKG])(mmachine m)=
03686 {
03687 SO3ObjectRotate,
03688 SO3ObjectShowBoundingBox,
03689 SO3ObjectRotateYaw,
03690 SO3ObjectSetDirection,
03691 SO3ObjectLookAt,
03692 SO3ObjectSetVisible,
03693 SO3ObjectGetVisible,
03694 SO3ObjectGetName,
03695 SO3ObjectSetOrientation,
03696 SO3ObjectAddOrientation,
03697 SO3ObjectResetToInitialOrientation,
03698 SO3ObjectSetPosition,
03699 SO3ObjectTranslate,
03700 SO3ObjectSetScale,
03701 SO3ObjectGetOrientation,
03702 SO3ObjectGetInitialOrientation,
03703 SO3ObjectGetGlobalOrientation,
03704 SO3ObjectSetGlobalOrientation,
03705 SO3ObjectGetPosition,
03706 SO3ObjectGetInitialPosition,
03707 SO3ObjectGetGlobalPosition,
03708 SO3ObjectSetGlobalPosition,
03709 SO3ObjectGetScale,
03710 SO3ObjectGetInitialScale,
03711 SO3ObjectGetMatrix,
03712 SO3ObjectGetWorldMatrix,
03713 SO3ObjectGetGlobalScale,
03714 SO3ObjectSetGlobalScale,
03715 SO3ObjectRotateRoll,
03716 SO3ObjectRotatePitch,
03717 SO3ObjectNbOfChild,
03718 SO3ObjectRemoveAllChildren,
03719 SO3ObjectGetChildren,
03720 SO3ObjectDestroy,
03721 SO3ObjectSetInitialState,
03722 SO3ObjectResetToInitialState,
03723 SO3ObjectGetSceneRoot,
03724 SO3ObjectGetParent,
03725 SO3ObjectLink,
03726 SO3ObjectGetPositionInObjectRef,
03727 SO3ObjectGetOrientationInObjectRef,
03728 SO3ObjectGetScaleInObjectRef,
03729 SO3ObjectUnlink,
03730 SO3ObjectSetAutoTracking,
03731 SO3ObjectSetCastShadows,
03732 SO3ObjectGetBoundingBoxInfo,
03733 SO3ObjectGetCastShadows,
03734 SO3ObjectSetMouseForeGround,
03735 SO3ObjectSetMouseClick,
03736 SO3ObjectGetMouseForeGround,
03737 SO3ObjectGetMouseClick,
03738 SO3ObjectSetRenderOverlay,
03739 SO3ObjectGetPolygonCount,
03740 SO3ObjectGetInfo,
03741 SO3ObjectGetInfoEx,
03742 SO3ObjectGetScreenCoord,
03743 SO3ObjectGetScreenPixelCoord,
03744 SO3ObjectGetNodeFacingOrientation,
03745 SO3ObjectSetRenderingDistance,
03746 SO3ObjectGetRenderingDistance,
03747 SO3ObjectGetAnimation,
03748 SO3ObjectCreateNodesAnimation,
03749 SO3ObjectSetInheritOrientation,
03750 SO3ObjectGetInheritOrientation,
03751 SO3ObjectResetOrientation
03752 };
03753
03754
03758 int OBJECTnarg[NBOBJECTPKG]=
03759 {
03760 4,
03761 2,
03762 3,
03763 3,
03764 3,
03765 3,
03766 1,
03767 1,
03768 2,
03769 2,
03770 1,
03771 2,
03772 3,
03773 2,
03774 1,
03775 1,
03776 1,
03777 2,
03778 1,
03779 1,
03780 1,
03781 2,
03782 1,
03783 1,
03784 1,
03785 1,
03786 1,
03787 2,
03788 3,
03789 3,
03790 1,
03791 1,
03792 1,
03793 1,
03794 1,
03795 1,
03796 1,
03797 1,
03798 2,
03799 2,
03800 2,
03801 2,
03802 1,
03803 5,
03804 2,
03805 2,
03806 1,
03807 2,
03808 2,
03809 1,
03810 1,
03811 2,
03812 1,
03813 3,
03814 3,
03815 2,
03816 2,
03817 4,
03818 2,
03819 1,
03820 2,
03821 3,
03822 2,
03823 1,
03824 1
03825 };
03826
03827
03831 char* OBJECTType[NBOBJECTPKG]=
03832 {
03833 "fun [SO3_OBJECT F [F F F] I] I",
03834 "fun [SO3_OBJECT I] I",
03835 "fun [SO3_OBJECT F I] I",
03836 "fun [SO3_OBJECT [F F F] I] I",
03837 "fun [SO3_OBJECT [F F F] I] I",
03838 "fun [SO3_OBJECT I I] I",
03839 "fun [SO3_OBJECT] I",
03840 "fun [SO3_OBJECT] S",
03841 "fun [SO3_OBJECT [F F F F]] I",
03842 "fun [SO3_OBJECT [F F F F]] I",
03843 "fun [SO3_OBJECT] I",
03844 "fun [SO3_OBJECT [F F F]] I",
03845 "fun [SO3_OBJECT [F F F] I] I",
03846 "fun [SO3_OBJECT [F F F]] I",
03847 "fun [SO3_OBJECT] [F F F F]",
03848 "fun [SO3_OBJECT] [F F F F]",
03849 "fun [SO3_OBJECT] [F F F F]",
03850 "fun [SO3_OBJECT [F F F F]] I",
03851 "fun [SO3_OBJECT] [F F F]",
03852 "fun [SO3_OBJECT] [F F F]",
03853 "fun [SO3_OBJECT] [F F F]",
03854 "fun [SO3_OBJECT [F F F]] I",
03855 "fun [SO3_OBJECT] [F F F]",
03856 "fun [SO3_OBJECT] [F F F]",
03857 "fun [SO3_OBJECT] [F F F F F F F F F F F F F F F F]",
03858 "fun [SO3_OBJECT] [F F F F F F F F F F F F F F F F]",
03859 "fun [SO3_OBJECT] [F F F]",
03860 "fun [SO3_OBJECT [F F F]] I",
03861 "fun [SO3_OBJECT F I] I",
03862 "fun [SO3_OBJECT F I] I",
03863 "fun [SO3_OBJECT] I",
03864 "fun [SO3_OBJECT] I",
03865 "fun [SO3_OBJECT] [SO3_OBJECT r1]",
03866 "fun [SO3_OBJECT] I",
03867 "fun [SO3_OBJECT] I",
03868 "fun [SO3_OBJECT] I",
03869 "fun [SO3_SCENE] SO3_OBJECT",
03870 "fun [SO3_OBJECT] SO3_OBJECT",
03871 "fun [SO3_OBJECT SO3_OBJECT] I",
03872 "fun [SO3_OBJECT SO3_OBJECT] [F F F]",
03873 "fun [SO3_OBJECT SO3_OBJECT] [F F F F]",
03874 "fun [SO3_OBJECT SO3_OBJECT] [F F F]",
03875 "fun [SO3_OBJECT] I",
03876 "fun [SO3_OBJECT SO3_OBJECT I [F F F] [F F F]] I",
03877 "fun [SO3_OBJECT I] I",
03878 "fun [SO3_OBJECT I] [[F F F] [F F F] [F F F F]]",
03879 "fun [SO3_OBJECT] I",
03880 "fun [SO3_OBJECT I] I",
03881 "fun [SO3_OBJECT I] I",
03882 "fun [SO3_OBJECT] I",
03883 "fun [SO3_OBJECT] I",
03884 "fun [SO3_OBJECT I] I",
03885 "fun [SO3_OBJECT] I",
03886 "fun [SO3_VIEWPORT I I] [SO3_OBJECT SO3_MATERIAL I]",
03887 "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]]",
03888 "fun [SO3_OBJECT SO3_VIEWPORT] [F F]",
03889 "fun [SO3_OBJECT SO3_VIEWPORT] [I I]",
03890 "fun [SO3_OBJECT SO3_OBJECT [F F F] [I I I]] [F F F F]",
03891 "fun [SO3_OBJECT F] I",
03892 "fun [SO3_OBJECT] F",
03893 "fun [SO3_OBJECT S] SO3_ANIM",
03894 "fun [SO3_OBJECT S F] SO3_ANIM",
03895 "fun [SO3_OBJECT I] I",
03896 "fun [SO3_OBJECT] I",
03897 "fun [SO3_OBJECT] I"
03898 };
03899
03900
03906 int SCOLloadObject(mmachine m,cbmachine w)
03907 {
03908 return PKhardpak(m, "Object", NBOBJECTPKG, OBJECTname, OBJECTFunc, OBJECTnarg, OBJECTType);
03909 }
03910
03911
03916 int SCOLfreeObject()
03917 {
03918 return 0;
03919 }