33#include <boost/format.hpp>
67 MMechostr(MSKDEBUG,
"getAnimationCallbackEndEvent\n");
73 if (!(k = OBJbeginreflex(m,
SO3ANIM, SCOL_PTR
id, SO3_ANIM_END)))
75 res = OBJcallreflex(m, 0);
92 MMechostr(MSKDEBUG,
"SO3AnimTrackGetObject\n");
98 MMechostr(MSKDEBUG,
"AnimTrack IS NIL \n");
103 SAnimTrack* animTrack = MMgetPointer<SAnimTrack*>(m, MTOP(at));
104 if (animTrack == NULL)
106 MMechostr(MSKDEBUG,
"AnimTrack IS NULL \n");
111 if (animTrack->GetType() != SAnimTrack::SO3_NODE_TRACK)
119 SNode* curNode = animTrack->GetParentAnimation()->GetParentNode();
127 int n = OBJfindTH(m,
SO3OBJTYPE, SCOL_PTR (curNode));
129 n = MMfetch(m, n, OFFOBJMAG);
133 catch (Ogre::Exception &e)
135 MMechostr(MSKDEBUG,
"An exception has occurred: %s\n", e.what());
158 MMechostr(MSKDEBUG,
"SO3AnimTrackCreateKey\n");
161 int sc = MTOP(MMpull(m));
162 int q = MTOP(MMpull(m));
163 int t = MTOP(MMpull(m));
164 int keyFrame = MMpull(m);
165 int at = MMget(m, 0);
166 if ((at == NIL) || (keyFrame == NIL) || (t == NIL) || (q == NIL))
172 SAnimTrack* curAnimTrack = MMgetPointer<SAnimTrack*>(m, MTOP(at));
173 if (curAnimTrack == NULL)
179 if (curAnimTrack->GetType() != SAnimTrack::SO3_NODE_TRACK)
186 pos.x = (MMfetch(m, t, 0) == NIL) ? 0.0f : MTOF(MMfetch(m, t, 0));
187 pos.y = (MMfetch(m, t, 1) == NIL) ? 0.0f : MTOF(MMfetch(m, t, 1));
188 pos.z = (MMfetch(m, t, 2) == NIL) ? 0.0f : MTOF(MMfetch(m, t, 2));
191 scale.x = (MMfetch(m, sc, 0) == NIL) ? 1.0f : MTOF(MMfetch(m, sc, 0));
192 scale.y = (MMfetch(m, sc, 1) == NIL) ? 1.0f : MTOF(MMfetch(m, sc, 1));
193 scale.z = (MMfetch(m, sc, 2) == NIL) ? 1.0f : MTOF(MMfetch(m, sc, 2));
195 Ogre::Quaternion quat;
196 quat.x = (MMfetch(m, q, 0) == NIL) ? 0.0f : MTOF(MMfetch(m, q, 0));
197 quat.y = (MMfetch(m, q, 1) == NIL) ? 0.0f : MTOF(MMfetch(m, q, 1));
198 quat.z = (MMfetch(m, q, 2) == NIL) ? 0.0f : MTOF(MMfetch(m, q, 2));
199 quat.w = (MMfetch(m, q, 3) == NIL) ? 1.0f : MTOF(MMfetch(m, q, 3));
202 curAnimTrack->CreateKey(MTOF(keyFrame), pos, quat, scale);
204 MMset(m, 0, ITOM(1));
224 MMechostr(MSKDEBUG,
"SO3AnimTrackSetKeyTransform\n");
227 int sc = MTOP(MMpull(m));
228 int q = MTOP(MMpull(m));
229 int t = MTOP(MMpull(m));
230 int keyFrame = MMpull(m);
231 int at = MMget(m, 0);
232 if ((at == NIL) || (keyFrame == NIL) || (t == NIL) || (q == NIL))
238 SAnimTrack* curAnimTrack = MMgetPointer<SAnimTrack*>(m, MTOP(at));
239 if (curAnimTrack == NULL)
245 if (curAnimTrack->GetType() != SAnimTrack::SO3_NODE_TRACK)
252 pos.x = (MMfetch(m, t, 0) == NIL) ? 0.0f : MTOF(MMfetch(m, t, 0));
253 pos.y = (MMfetch(m, t, 1) == NIL) ? 0.0f : MTOF(MMfetch(m, t, 1));
254 pos.z = (MMfetch(m, t, 2) == NIL) ? 0.0f : MTOF(MMfetch(m, t, 2));
257 scale.x = (MMfetch(m, sc, 0) == NIL) ? 1.0f : MTOF(MMfetch(m, sc, 0));
258 scale.y = (MMfetch(m, sc, 1) == NIL) ? 1.0f : MTOF(MMfetch(m, sc, 1));
259 scale.z = (MMfetch(m, sc, 2) == NIL) ? 1.0f : MTOF(MMfetch(m, sc, 2));
261 Ogre::Quaternion quat;
262 quat.x = (MMfetch(m, q, 0) == NIL) ? 0.0f : MTOF(MMfetch(m, q, 0));
263 quat.y = (MMfetch(m, q, 1) == NIL) ? 0.0f : MTOF(MMfetch(m, q, 1));
264 quat.z = (MMfetch(m, q, 2) == NIL) ? 0.0f : MTOF(MMfetch(m, q, 2));
265 quat.w = (MMfetch(m, q, 3) == NIL) ? 1.0f : MTOF(MMfetch(m, q, 3));
268 curAnimTrack->SetKeyTransform(MTOI(keyFrame), pos, quat, scale);
270 MMset(m, 0, ITOM(1));
290 MMechostr(MSKDEBUG,
"SO3AnimTrackGetKeyTransform\n");
293 int keyFrame = MMpull(m);
294 int at = MMget(m, 0);
295 if ((at == NIL) || (keyFrame == NIL))
301 SAnimTrack* curAnimTrack = MMgetPointer<SAnimTrack*>(m, MTOP(at));
302 if (curAnimTrack == NULL)
308 if (curAnimTrack->GetType() != SAnimTrack::SO3_NODE_TRACK)
315 Ogre::Quaternion quat;
318 curAnimTrack->GetKeyTransform(MTOI(keyFrame), pos, quat, scale);
321 int trans = MMmalloc(m, 3, TYPETAB);
327 MMstore(m, trans, 0, FTOM(pos.x));
328 MMstore(m, trans, 1, FTOM(pos.y));
329 MMstore(m, trans, 2, FTOM(pos.z));
330 MMpush(m, PTOM(trans));
333 int torient = MMmalloc(m, 4, TYPETAB);
339 MMstore(m, torient, 0, FTOM(quat.x));
340 MMstore(m, torient, 1, FTOM(quat.y));
341 MMstore(m, torient, 2, FTOM(quat.z));
342 MMstore(m, torient, 3, FTOM(quat.w));
343 MMpush(m, PTOM(torient));
346 int tscale = MMmalloc(m, 3, TYPETAB);
352 MMstore(m, tscale, 0, FTOM(scale.x));
353 MMstore(m, tscale, 1, FTOM(scale.y));
354 MMstore(m, tscale, 2, FTOM(scale.z));
355 MMpush(m, PTOM(tscale));
358 int result = MMmalloc(m, 3, TYPETAB);
364 MMstore(m, result, 2, MMpull(m));
365 MMstore(m, result, 1, MMpull(m));
366 MMstore(m, result, 0, MMpull(m));
367 MMset(m, 0, PTOM(result));
383 MMechostr(MSKDEBUG,
"SO3AnimTrackGetNumKeys\n");
386 int at = MMget(m, 0);
393 SAnimTrack* curAnimTrack = MMgetPointer<SAnimTrack*>(m, MTOP(at));
394 if (curAnimTrack == NULL)
400 int nb = curAnimTrack->GetNumKeyFrames();
401 MMset(m, 0, ITOM(nb));
418 MMechostr(MSKDEBUG,
"SO3AnimTrackGetKeyAtTime\n");
421 int keyFrame = MMpull(m);
422 int at = MMget(m, 0);
423 if ((at == NIL) || (keyFrame == NIL))
429 SAnimTrack* curAnimTrack = MMgetPointer<SAnimTrack*>(m, MTOP(at));
430 if (curAnimTrack == NULL)
436 float ptime = curAnimTrack->GetKeyPositionTime(MTOI(keyFrame));
438 MMset(m, 0, FTOM(ptime));
455 MMechostr(MSKDEBUG,
"SO3AnimTrackRemoveKey\n");
458 int keyFrame = MMpull(m);
459 int at = MMget(m, 0);
460 if ((at == NIL) || (keyFrame == NIL))
466 SAnimTrack* curAnimTrack = MMgetPointer<SAnimTrack*>(m, MTOP(at));
467 if (curAnimTrack == NULL)
473 if ((curAnimTrack->GetType() != SAnimTrack::SO3_NODE_TRACK) && (curAnimTrack->GetType() != SAnimTrack::SO3_SEQUENCE_TRACK))
479 curAnimTrack->RemoveKey(MTOI(keyFrame));
481 MMset(m, 0, ITOM(1));
497 MMechostr(MSKDEBUG,
"SO3AnimTrackOptimise\n");
500 int at = MMget(m, 0);
507 SAnimTrack* curAnimTrack = MMgetPointer<SAnimTrack*>(m, MTOP(at));
508 if (curAnimTrack == NULL)
514 curAnimTrack->SetOptimise();
515 MMset(m, 0, ITOM(1));
531 MMechostr(MSKDEBUG,
"SO3AnimTrackRemoveAllKeys\n");
534 int at = MMget(m, 0);
541 SAnimTrack* curAnimTrack = MMgetPointer<SAnimTrack*>(m, MTOP(at));
542 if (curAnimTrack == NULL)
548 if ((curAnimTrack->GetType() != SAnimTrack::SO3_NODE_TRACK) && (curAnimTrack->GetType() != SAnimTrack::SO3_SEQUENCE_TRACK))
554 curAnimTrack->RemoveAllKeyFrames();
555 MMset(m, 0, ITOM(1));
571 MMechostr(MSKDEBUG,
"SO3AnimationGetName\n");
574 int anim = MMpull(m);
581 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
582 if (animation == NULL)
589 return Mpushstrbloc(m, (
char*)animation->GetName().c_str());
605 MMechostr(MSKDEBUG,
"SO3AnimationSetLength\n");
609 int anim = MMget(m, 0);
610 if ((anim == NIL) || (l == NIL))
616 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
617 if (animation == NULL)
623 animation->SetLength((Ogre::Real)MTOF(l));
624 MMset(m, 0, ITOM(1));
641 MMechostr(MSKDEBUG,
"SO3AnimationSetTimePosition\n");
645 int anim = MMget(m, 0);
646 if ((anim == NIL) || (t == NIL))
652 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
653 if (animation == NULL)
659 animation->SetTimePosition((Ogre::Real)MTOF(t));
660 MMset(m, 0, ITOM(1));
677 MMechostr(MSKDEBUG,
"SO3AnimationSetWeight\n");
681 int anim = MMget(m, 0);
682 if ((anim == NIL) || (
w == NIL))
688 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
689 if (animation == NULL)
695 animation->SetInitialWeight((Ogre::Real)MTOF(
w));
696 MMset(m, 0, ITOM(1));
717 MMechostr(MSKDEBUG,
"SO3AnimationSetInterpMode\n");
720 int flag = MTOI(MMpull(m));
721 int anim = MMget(m, 0);
728 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
729 if (animation == NULL)
735 animation->SetInterpolationMode(
static_cast<SAnim::AnimInterpolationMode
> (flag));
736 MMset(m, 0, ITOM(1));
757 MMechostr(MSKDEBUG,
"SO3AnimationSetRotInterpMode\n");
760 int flag = MTOI(MMpull(m));
761 int anim = MMget(m, 0);
768 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
769 if (animation == NULL)
775 animation->SetRotationInterpolationMode(
static_cast<SAnim::AnimRotationInterpolationMode
> (flag));
776 MMset(m, 0, ITOM(1));
796 MMechostr(MSKDEBUG,
"SO3AnimationGetInterpMode\n");
799 int anim = MMget(m, 0);
806 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
807 if (animation == NULL)
814 flag = (int)(animation->GetInterpolationMode());
815 MMset(m, 0, ITOM(flag));
838 MMechostr(MSKDEBUG,
"SO3AnimationGetType\n");
841 int anim = MMget(m, 0);
848 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
849 if (animation == NULL)
856 flag = (int)(animation->GetType());
857 MMset(m, 0, ITOM(flag));
873 MMechostr(MSKDEBUG,
"SO3AnimTrackDestroy\n");
876 int at = MMget(m, 0);
883 SAnimTrack* animTrack = MMgetPointer<SAnimTrack*>(m, MTOP(at));
884 if (animTrack == NULL)
890 if ((animTrack->GetType() != SAnimTrack::SO3_NODE_TRACK) && (animTrack->GetType() != SAnimTrack::SO3_SEQUENCE_TRACK))
897 MMset(m, 0, ITOM(1));
918 MMechostr(MSKDEBUG,
"SO3AnimationGetRotInterpMode\n");
921 int anim = MMget(m, 0);
928 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
929 if (animation == NULL)
936 flag = (int)(animation->GetRotationInterpolationMode());
937 MMset(m, 0, ITOM(flag));
954 MMechostr(MSKDEBUG,
"SO3AnimationSetEnable\n");
957 int bEnable = MTOI(MMpull(m));
958 int anim = MMget(m, 0);
965 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
966 if (animation == NULL)
972 animation->SetEnable(!bEnable ?
false :
true);
974 MMset(m, 0, ITOM(1));
991 MMechostr(MSKDEBUG,
"SO3AnimationSetPause\n");
994 int bPause = MTOI(MMpull(m));
995 int anim = MMget(m, 0);
1002 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
1003 if (animation == NULL)
1009 animation->SetPaused(!bPause ?
false :
true);
1011 MMset(m, 0, ITOM(1));
1028 MMechostr(MSKDEBUG,
"SO3AnimationSetLoop\n");
1030 int bLoop = MTOI(MMpull(m));
1031 int anim = MMget(m, 0);
1033 if ((anim == NIL) || (bLoop == NIL))
1039 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
1040 if (animation == NULL)
1046 animation->SetInitialLoop(!bLoop ?
false :
true);
1048 MMset(m, 0, ITOM(1));
1064 MMechostr(MSKDEBUG,
"SO3AnimationOptimise\n");
1067 int booleen = MTOI(MMpull(m));
1068 int anim = MMget(m, 0);
1075 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
1076 if (animation == NULL)
1083 animation->SetOptimise(
false);
1085 animation->SetOptimise(
true);
1087 MMset(m, 0, ITOM(1));
1103 MMechostr(MSKDEBUG,
"SO3AnimationGetEnable\n");
1106 int anim = MMget(m, 0);
1113 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
1114 if (animation == NULL)
1121 if (animation->GetEnable())
1124 MMset(m, 0, ITOM(booleen));
1140 MMechostr(MSKDEBUG,
"SO3AnimationGetPause\n");
1143 int anim = MMget(m, 0);
1150 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
1151 if (animation == NULL)
1158 if (animation->GetPaused())
1161 MMset(m, 0, ITOM(booleen));
1177 MMechostr(MSKDEBUG,
"SO3AnimationGetLoop\n");
1180 int anim = MMget(m, 0);
1187 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
1188 if (animation == NULL)
1195 if (animation->GetInitialLoop())
1198 MMset(m, 0, ITOM(state));
1214 MMechostr(MSKDEBUG,
"SO3AnimationGetLength\n");
1217 int anim = MMget(m, 0);
1224 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
1225 if (animation == NULL)
1232 l = animation->GetLength();
1233 MMset(m, 0, FTOM(l));
1249 MMechostr(MSKDEBUG,
"SO3AnimationGetTimePosition\n");
1252 int anim = MMget(m, 0);
1259 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
1260 if (animation == NULL)
1266 MMset(m, 0, FTOM(animation->GetTimePosition()));
1282 MMechostr(MSKDEBUG,
"SO3AnimationGetWeight\n");
1285 int anim = MMget(m, 0);
1292 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
1293 if (animation == NULL)
1299 MMset(m, 0, FTOM(animation->GetInitialWeight()));
1316 MMechostr(MSKDEBUG,
"SO3AnimationSetSpeed\n");
1319 int fspeed = MMpull(m);
1320 int anim = MMget(m, 0);
1321 if ((anim == NIL) || (fspeed == NIL))
1327 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
1328 if (animation == NULL)
1334 animation->SetSpeed(MTOF(fspeed));
1335 MMset(m, 0, ITOM(1));
1351 MMechostr(MSKDEBUG,
"SO3AnimationGetSpeed\n");
1354 int anim = MMget(m, 0);
1361 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
1362 if (animation == NULL)
1368 MMset(m, 0, FTOM(animation->GetSpeed()));
1384 MMechostr(MSKDEBUG,
"SO3AnimationHasEnded\n");
1387 int anim = MMget(m, 0);
1394 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
1395 if (animation == NULL)
1402 if (animation->HasEnded())
1405 MMset(m, 0, ITOM(booleen));
1421 MMechostr(MSKDEBUG,
"SO3AnimationNumOfAnimationTrack\n");
1424 int anim = MMget(m, 0);
1431 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
1432 if (animation == NULL)
1439 val = animation->GetNumAnimationsTracks();
1440 MMset(m, 0, ITOM(val));
1456 MMechostr(MSKDEBUG,
"SO3ObjectSkeletonNumOfAnimation\n");
1459 int skl = MMget(m, 0);
1466 SNode* node = MMgetPointer<SNode*>(m, MTOP(skl));
1473 if (node->GetNodeType() == SNode::ENTITY_TYPE_ID)
1475 SEntity* entity =
static_cast<SEntity*
> (node);
1482 if (entity->GetSkeleton() != 0)
1484 int val = (int)entity->GetSkeleton()->GetNumAnimations();
1485 MMset(m, 0, ITOM(val));
1508 MMechostr(MSKDEBUG,
"SO3ObjectGetAnimations\n");
1511 int n = MMget(m, 0);
1518 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1526 size_t numAnimations = node->GetNumAnimations();
1529 if (node->GetNodeType() == SNode::ENTITY_TYPE_ID)
1531 SEntity* entity =
static_cast<SEntity*
> (node);
1532 SSkeleton* entitySkeleton = entity->GetSkeleton();
1533 if (entitySkeleton != 0)
1534 numAnimations += entitySkeleton->GetNumAnimations();
1537 if (numAnimations > 0)
1539 const SAnimMap animationListCopy = node->GetAnimations();
1540 SAnimMap::const_iterator iAnimations = animationListCopy.begin();
1541 while (iAnimations != animationListCopy.end())
1543 int a = OBJfindTH(m,
SO3ANIM, SCOL_PTR (iAnimations->second));
1546 a = MMfetch(m, a, OFFOBJMAG);
1555 if (node->GetNodeType() == SNode::ENTITY_TYPE_ID)
1557 SEntity* entity =
static_cast<SEntity*
> (node);
1560 SSkeleton* entitySkeleton = entity->GetSkeleton();
1561 if (entitySkeleton != 0)
1563 if (entitySkeleton->GetNumAnimations() > 0)
1565 const SAnimMap animationListCopy = entitySkeleton->GetAnimations();
1566 SAnimMap::const_iterator iAnimations = animationListCopy.begin();
1567 while (iAnimations != animationListCopy.end())
1569 int a = OBJfindTH(m,
SO3ANIM, SCOL_PTR (iAnimations->second));
1572 a = MMfetch(m, a, OFFOBJMAG);
1584 if (numAnimations == 0)
1594 for (
int j = 0; j<numAnimations; j++)
1596 if (MMpush(m, 2 * 2))
1599 if (
int k = MBdeftab(m))
1621 MMechostr(MSKDEBUG,
"SO3AnimationListAnimTrack\n");
1624 int a = MMget(m, 0);
1631 SAnim* anim = MMgetPointer<SAnim*>(m, MTOP(a));
1638 if ((anim->GetType() == SAnim::SO3_SCENENODE_ANIM) || (anim->GetType() == SAnim::SO3_SEQUENCE_ANIM))
1641 const SAnimTrackList animationTrackListCopy = anim->GetAnimationsTracks();
1642 SAnimTrackList::const_iterator iAnimTrackList = animationTrackListCopy.begin();
1643 while (iAnimTrackList != animationTrackListCopy.end())
1645 int a = OBJfindTH(m,
SO3ANIMTRACK, SCOL_PTR (*iAnimTrackList));
1647 a = MMfetch(m, a, OFFOBJMAG);
1659 int numAnimations = anim->GetNumAnimationsTracks();
1660 for (
int j = 0; j<numAnimations; j++)
1662 if (MMpush(m, 2 * 2))
1665 if (
int k = MBdeftab(m))
1687 MMechostr(MSKDEBUG,
"SO3ObjectGetDisplaySkeleton\n");
1690 int n = MMget(m, 0);
1697 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1704 if (node->GetNodeType() == SNode::ENTITY_TYPE_ID)
1706 SEntity* entity =
static_cast<SEntity*
> (node);
1707 if (entity->GetSkeleton() != 0)
1711 if (entity->getOgreEntityPointer() && entity->getOgreEntityPointer()->getDisplaySkeleton())
1714 MMset(m, 0, ITOM(booleen));
1740 MMechostr(MSKDEBUG,
"SO3ObjectHasSkeleton\n");
1743 int n = MMget(m, 0);
1750 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1757 if (node->GetNodeType() == SNode::ENTITY_TYPE_ID)
1759 SEntity* entity =
static_cast<SEntity*
> (node);
1761 if (entity->GetSkeleton() != 0)
1764 MMset(m, 0, ITOM(booleen));
1784 MMechostr(MSKDEBUG,
"SO3ObjectIsHardwareSkinningEnabled\n");
1787 int n = MMget(m, 0);
1794 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1801 if (node->GetNodeType() == SNode::ENTITY_TYPE_ID)
1803 SEntity* entity =
static_cast<SEntity*
> (node);
1804 if (entity->GetSkeleton() != 0)
1808 if (entity->getOgreEntityPointer() && entity->getOgreEntityPointer()->isHardwareAnimationEnabled())
1811 MMset(m, 0, ITOM(booleen));
1837 MMechostr(MSKDEBUG,
"SO3ObjectSkeletonSetBindPose\n");
1840 int n = MMget(m, 0);
1847 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1854 if (node->GetNodeType() == SNode::ENTITY_TYPE_ID)
1856 SEntity* entity =
static_cast<SEntity*
> (node);
1857 if (entity->GetSkeleton() != 0)
1859 entity->GetSkeleton()->SetBindingPose();
1860 MMset(m, 0, ITOM(1));
1890 MMechostr(MSKDEBUG,
"SO3ObjectSkeletonGetBlendMode\n");
1893 int n = MMget(m, 0);
1900 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1907 if (node->GetNodeType() == SNode::ENTITY_TYPE_ID)
1909 SEntity* entity =
static_cast<SEntity*
> (node);
1910 if (entity->GetSkeleton() != 0)
1912 SSkeleton::SkeletonAnimationMode flag = entity->GetSkeleton()->GetBlendMode();
1913 MMset(m, 0, ITOM(flag));
1943 MMechostr(MSKDEBUG,
"SO3ObjectSkeletonSetBlendMode\n");
1946 int flag = MTOI(MMpull(m));
1947 int n = MMget(m, 0);
1948 if ((n == NIL) || (flag == NIL))
1954 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
1961 if (node->GetNodeType() == SNode::ENTITY_TYPE_ID)
1963 SEntity* entity =
static_cast<SEntity*
> (node);
1964 if (entity->GetSkeleton() != 0)
1966 entity->GetSkeleton()->SetBlendMode(
static_cast<SSkeleton::SkeletonAnimationMode
> (flag));
1967 MMset(m, 0, ITOM(1));
1994 MMechostr(MSKDEBUG,
"SO3ObjectSetDisplaySkeleton\n");
1997 int booleen = MTOI(MMpull(m));
1998 int n = MMget(m, 0);
2005 SNode* node = MMgetPointer<SNode*>(m, MTOP(n));
2012 if (node->GetNodeType() == SNode::ENTITY_TYPE_ID)
2014 SEntity* entity =
static_cast<SEntity*
> (node);
2015 if (entity->GetSkeleton() != 0)
2024 catch (Ogre::Exception &e)
2026 MMechostr(MSKDEBUG,
"An exception has occurred: %s\n", e.what());
2055 MMechostr(MSKDEBUG,
"SO3AnimationAddTime\n");
2058 int time = MMpull(m);
2059 int anim = MMget(m, 0);
2060 if ((anim == NIL) || (time == NIL))
2066 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
2067 if (animation == NULL)
2075 animation->AddTime(MTOF(time));
2077 catch (Ogre::Exception &e)
2079 MMechostr(MSKDEBUG,
"An exception has occurred: %s\n", e.what());
2083 MMset(m, 0, ITOM(1));
2099 MMechostr(MSKDEBUG,
"SO3AnimationDestroy\n");
2102 int a = MMget(m, 0);
2109 SAnim* anim = MMgetPointer<SAnim*>(m, MTOP(a));
2117 MMset(m, 0, ITOM(1));
2134 MMechostr(MSKDEBUG,
"SO3AnimationGetAnimTrack\n");
2137 int idx = MMpull(m);
2138 int anim = MMget(m, 0);
2139 if ((idx == NIL) || (anim == NIL))
2145 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
2146 if (animation == NULL)
2154 SAnimTrack* mTrack = animation->GetAnimationTrack(MTOI(idx));
2163 t = MMfetch(m, t, OFFOBJMAG);
2168 catch (Ogre::Exception& e)
2170 MMechostr(MSKDEBUG,
"An exception has occurred: %s\n", e.what());
2174 MMset(m, 0, ITOM(1));
2192 MMechostr(MSKDEBUG,
"SO3AnimationCreateAnimTrack\n");
2198 int anim = MMpull(m);
2205 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
2206 if (animation == NULL)
2214 SAnimTrack* animationTrack = animation->CreateAnimationTrack(boost::str(boost::format(
"%1%") % animation->GetNumAnimationsTracks()));
2217 catch (Ogre::Exception& e)
2219 MMechostr(MSKDEBUG,
"An exception has occurred: %s\n", e.what());
2238 MMechostr(MSKDEBUG,
"SO3AnimationSetSkipFrame\n");
2241 int iState = MMpull(m);
2242 int anim = MMget(m, 0);
2249 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
2250 if (animation == NULL)
2256 bool bState =
false;
2257 if ((iState != NIL) && (MTOI(iState) == 1))
2260 animation->SetSkipFrame(bState);
2262 MMset(m, 0, ITOM(0));
2278 MMechostr(MSKDEBUG,
"SO3AnimationGetSkipFrame\n");
2281 int anim = MMget(m, 0);
2288 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
2289 if (animation == NULL)
2295 bool bState = animation->SkipFrame();
2297 MMset(m, 0, bState ? ITOM(1) : ITOM(0));
2317 MMechostr(MSKDEBUG,
"SO3AnimTrackCreateSequenceKey\n");
2320 int idecal = MMpull(m);
2321 int ipos = MMpull(m);
2322 int ilength = MMpull(m);
2323 int anim = MMpull(m);
2324 int track = MMget(m, 0);
2325 if ((anim == NIL) || (track == NIL))
2335 float fdecal = 0.0f;
2337 fdecal = MTOF(idecal);
2339 float flength = 0.0f;
2341 flength = MTOF(ilength);
2343 SAnim* animation = MMgetPointer<SAnim*>(m, MTOP(anim));
2344 if (animation == NULL)
2350 SAnimTrack* curAnimTrack = MMgetPointer<SAnimTrack*>(m, MTOP(track));
2351 if (curAnimTrack == NULL)
2357 if (curAnimTrack->GetType() != SAnimTrack::SO3_SEQUENCE_TRACK)
2365 static_cast<SSequenceAnimationTrack*
>(curAnimTrack)->AddKey(animation, flength, fpos, fdecal);
2367 catch (Ogre::Exception)
2369 MMechostr(MSKRUNTIME,
"SO3AnimationSequenceAddAnim : Bad animation track type");
2370 MMset(m, 0, ITOM(0));
2374 MMset(m, 0, ITOM(1));
2398 MMechostr(MSKDEBUG,
"SO3AnimTrackGetSequenceKey\n");
2401 int index = MMpull(m);
2402 int track = MMget(m, 0);
2403 if ((track == NIL) || (index == NIL))
2409 SAnimTrack* curAnimTrack = MMgetPointer<SAnimTrack*>(m, MTOP(track));
2410 if (curAnimTrack == NULL)
2416 if (curAnimTrack->GetType() != SAnimTrack::SO3_SEQUENCE_TRACK)
2422 index = MTOI(index);
2425 float keyTime = 0.0f;
2426 float keyLength = 0.0f;
2427 float keyTrans = 0.0f;
2428 float keyDecal = 0.0f;
2432 SSequenceAnimationTrack* track =
static_cast<SSequenceAnimationTrack*
>(curAnimTrack);
2438 SSequenceAnimationKey* key = track->GetKeyFromIndex(index);
2445 keyAnim = key->GetAnim();
2446 keyTime = key->GetPosition();
2447 keyLength = key->GetLength();
2448 keyTrans = key->GetTransitionTime();
2449 keyDecal = key->GetDecalTime();
2451 int t = OBJfindTH(m,
SO3ANIM, SCOL_PTR (keyAnim));
2453 t = MMfetch(m, t, OFFOBJMAG);
2456 int result = MMmalloc(m, 4, TYPETAB);
2462 MMstore(m, result, 0, t);
2463 MMstore(m, result, 1, FTOM(keyTime));
2464 MMstore(m, result, 2, FTOM(keyLength));
2465 MMstore(m, result, 3, FTOM(keyTrans));
2466 MMstore(m, result, 4, FTOM(keyDecal));
2467 MMset(m, 0, PTOM(result));
2469 catch (Ogre::Exception)
2471 MMechostr(MSKRUNTIME,
"SO3AnimationSequenceAddAnim : Bad animation track type");
2495 MMechostr(MSKDEBUG,
"SO3AnimTrackSetSequenceKey\n");
2498 int idecal = MMpull(m);
2499 int ipos = MMpull(m);
2500 int ilength = MMpull(m);
2501 int index = MMpull(m);
2502 int track = MMget(m, 0);
2503 if ((index == NIL) || (track == NIL))
2509 index = MTOI(index);
2515 float fdecal = 0.0f;
2517 fdecal = MTOF(idecal);
2519 float flength = 0.0f;
2521 flength = MTOF(ilength);
2523 SAnimTrack* curAnimTrack = MMgetPointer<SAnimTrack*>(m, MTOP(track));
2524 if (curAnimTrack == NULL)
2530 if (curAnimTrack->GetType() != SAnimTrack::SO3_SEQUENCE_TRACK)
2538 SSequenceAnimationTrack* track =
static_cast<SSequenceAnimationTrack*
>(curAnimTrack);
2544 track->SetKey(index, flength, fpos, fdecal);
2546 catch (Ogre::Exception)
2548 MMechostr(MSKRUNTIME,
"SO3AnimationSequenceAddAnim : Bad animation track type");
2549 MMset(m, 0, ITOM(0));
2553 MMset(m, 0, ITOM(1));
2571 MMechostr(MSKDEBUG,
"SO3AnimTrackMoveSequenceKey\n");
2574 int nindex = MMpull(m);
2575 int index = MMpull(m);
2576 int track = MMget(m, 0);
2577 if ((index == NIL) || (nindex == NIL) || (track == NIL))
2583 index = MTOI(index);
2584 nindex = MTOI(nindex);
2586 SAnimTrack* curAnimTrack = MMgetPointer<SAnimTrack*>(m, MTOP(track));
2587 if (curAnimTrack == NULL)
2593 if (curAnimTrack->GetType() != SAnimTrack::SO3_SEQUENCE_TRACK)
2601 SSequenceAnimationTrack* track =
static_cast<SSequenceAnimationTrack*
>(curAnimTrack);
2607 track->MoveKeyFromIndex(index, nindex);
2609 catch (Ogre::Exception)
2611 MMechostr(MSKRUNTIME,
"SO3AnimationSequenceAddAnim : Bad animation track type");
2612 MMset(m, 0, ITOM(0));
2616 MMset(m, 0, ITOM(1));
2632 int k = OBJaddreflex(m,
SO3ANIM, SO3_ANIM_END);
2639 {
"SO3AnimTrackCreateKey", 5,
"fun [SO3_ANIMTRACK F [F F F] [F F F F] [F F F]] I",
SO3AnimTrackCreateKey },
2687 {
"SO3CbAnimationEnded", 3,
"fun [SO3_ANIM fun [SO3_ANIM u0] u1 u0] SO3_ANIM",
SO3CbAnimationEnded },
int SCOLloadAnim(mmachine m, cbmachine w)
int ANIMATION_END_EVENT
main include
int getAnimationCallbackEndEvent(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
C function that prepares the VM for the execution of the end animation callback.
NativeDefinition natSO3Anim[]
MMechostr(MSKDEBUG, " > Start loading Plugin SO3Engine dll\n")
SCOL_EXPORT int cbmachine w
SCOL_EXPORT void SCOL_PTR_TYPE param
int createAnimTrack(mmachine m, SAnimTrack *curAnimTrack, SAnim *curAnim)
int SO3AnimationSetInterpMode(mmachine m)
SO3AnimationSetInterpMode : defines interpolation mode for animation mix.
int SO3ObjectSkeletonGetBlendMode(mmachine m)
SO3ObjectSkeletonGetBlendMode : Get the blending mode for a skeleton.
int SO3AnimationOptimise(mmachine m)
SO3AnimationOptimise : Optimize a given animation.
int SO3AnimationGetTimePosition(mmachine m)
SO3AnimationGetTimePosition : Return the time position of an animation.
int SO3AnimationSetPause(mmachine m)
SO3AnimationSetPause : Play/Pause on a given animation.
int SO3AnimationSetSkipFrame(mmachine m)
SO3AnimationSetSkipFrame : Set the animation skip frame, this manage if the animation update is based...
int SO3AnimTrackCreateSequenceKey(mmachine m)
SO3AnimTrackCreateSequenceKey : Add an animation to an animation sequence.
int SO3ObjectSkeletonSetBlendMode(mmachine m)
SO3ObjectSkeletonGetBlendMode : defines blending mode for a skeleton.
int SO3AnimationGetSkipFrame(mmachine m)
SO3AnimationGetSkipFrame : Get the animation skip frame state.
int SO3AnimTrackSetKeyTransform(mmachine m)
SO3AnimTrackSetKeyTransform : Set a transform key for a given keyframe.
int SO3AnimationCreateAnimTrack(mmachine m)
SO3AnimationCreateAnimTrack : Create a SO3_ANIMTRACK in Scene on a given SO3_ANIM.
int SO3AnimTrackGetKeyTime(mmachine m)
SO3AnimTrackGetKeyTime : Return the time for this key frame.
int SO3ObjectGetAnimations(mmachine m)
SO3ObjectGetAnimations : Return the list of a node animation.
int SO3AnimTrackDestroy(mmachine m)
SO3AnimTrackDestroy : Destroy an animation Track.
int SO3ObjectGetDisplaySkeleton(mmachine m)
SO3ObjectGetDisplaySkeleton : Return the display state for a skeleton.
int SO3ObjectIsHardwareSkinningEnabled(mmachine m)
SO3ObjectIsHardwareSkinningEnabled : Return the hardware skinning enable state for an object.
int SO3AnimTrackSetSequenceKey(mmachine m)
SO3AnimTrackSetSequenceKey : Add an animation to an animation sequence.
int SO3AnimationGetName(mmachine m)
SO3AnimationGetName : Return the name of an animation.
int SO3AnimationSetEnable(mmachine m)
SO3AnimationSetEnable : Enable/Disable a current animation.
int SO3AnimTrackGetKeyTransform(mmachine m)
SO3AnimTrackGetKeyTransform : Return a key transform.
int SO3ObjectSetDisplaySkeleton(mmachine m)
SO3ObjectSetDisplaySkeleton : defines display skeleton mode for an object.
int SO3AnimTrackRemoveAllKeys(mmachine m)
SO3AnimTrackRemoveAllKeys : Remove all keys from an animation track.
int SO3AnimationGetLength(mmachine m)
SO3AnimationGetLength : Return the length of an animation.
int SO3ObjectHasSkeleton(mmachine m)
SO3ObjectHasSkeleton : Return true if an object has a skeleton otherwiser false.
int SO3AnimationGetEnable(mmachine m)
SO3AnimationGetEnable : Get the enable state for an animation.
int SO3AnimTrackOptimise(mmachine m)
SO3AnimTrackOptimise : Optimise the animation track.
int SO3AnimationListAnimTrack(mmachine m)
SO3AnimationListAnimTrack : Return the list of animation tracks for an animation.
int SO3AnimationGetInterpMode(mmachine m)
SO3AnimationGetInterpMode : Return the current interpolation mode for this animation.
int SO3AnimationSetTimePosition(mmachine m)
SO3AnimationSetTimePosition :defines time position for an animation.
int SO3AnimationAddTime(mmachine m)
SO3AnimationAddTime : Add time to an animation.
int SO3AnimationSetSpeed(mmachine m)
SO3AnimationGetTimePosition : defines speed of an animation.
int SO3AnimationGetRotInterpMode(mmachine m)
SO3AnimationGetRotInterpMode : Return the current rotation interpolation mode for this animation.
int SO3AnimationSetWeight(mmachine m)
SO3AnimationSetWeight : defines weight of a given animation.
int SO3AnimationNumOfAnimationTrack(mmachine m)
SO3AnimationNumOfAnimationTrack : Return the number of animation track for an animation.
int SO3ObjectSkeletonSetBindPose(mmachine m)
SO3ObjectSkeletonSetBindPose : defines bind pose on a skeleton.
int SO3AnimationGetWeight(mmachine m)
SO3AnimationGetTimePosition : Return the weight of an animation.
int SO3AnimationGetLoop(mmachine m)
SO3AnimationGetLoop : Get the loop state for an animation.
int SO3AnimationGetPause(mmachine m)
SO3AnimationGetEnable : Get the pause state for an animation.
int SO3AnimationHasEnded(mmachine m)
SO3AnimationHasEnded : Return the ended state for an animation.
int SO3CbAnimationEnded(mmachine m)
SO3CbAnimationEnded - TODO not implemented - Define the callback scol had to be called when an animat...
int SO3AnimationGetSpeed(mmachine m)
SO3AnimationGetSpeed : Return the speed of an animation.
int SO3AnimationSetLength(mmachine m)
SO3AnimationSetLength : defines length of an animation.
int SO3AnimationSetRotInterpMode(mmachine m)
SO3AnimationSetRotInterpMode : defines rotation interpolation mode for animation mix.
int SO3AnimTrackRemoveKey(mmachine m)
SO3AnimTrackGetObject : Remove a key frame frm an animation track.
int SO3AnimationGetAnimTrack(mmachine m)
SO3AnimationGetAnimTrack : Return an animation track from an animation.
int SO3AnimTrackGetObject(mmachine m)
SO3AnimTrackGetObject : Return the object associated with the current animation track.
int SO3AnimTrackCreateKey(mmachine m)
SO3AnimTrackCreateKey : Create an animation track key.
int SO3ObjectSkeletonNumOfAnimations(mmachine m)
SO3ObjectSkeletonNumOfAnimations : Return the number of animations for a skeleton.
int SO3AnimTrackGetSequenceKey(mmachine m)
SO3AnimTrackGetSequenceKey : Add an animation to an animation sequence.
int SO3AnimationSetLoop(mmachine m)
SO3AnimationSetLoop : defines loop state for this animation.
int SO3AnimTrackGetNumKeys(mmachine m)
SO3AnimTrackGetNumKeys : Return number of keys for this animation track.
int SO3AnimationDestroy(mmachine m)
SO3AnimationDestroy : Destroy an animation.
int SO3AnimTrackMoveSequenceKey(mmachine m)
SO3AnimTrackMoveSequenceKey : Add an animation to an animation sequence.
int SO3AnimationGetType(mmachine m)
SO3AnimationGetType : Return the current type for this animation.