52 MMechostr(MSKDEBUG,
"SO3BoneListFromMesh\n");
55 int obj = MMget(m, 0);
62 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
69 if(node->GetNodeType()!=SNode::ENTITY_TYPE_ID)
75 SEntity* curEntity =
static_cast<SEntity*
> (node);
76 SSkeleton* skeleton = curEntity->GetSkeleton();
85 SBoneMap boneListCopy = skeleton->GetBones();
86 SBoneMap::const_iterator iBones = boneListCopy.begin();
87 while (iBones != boneListCopy.end());
89 int b = OBJfindTH(m,
SO3OBJTYPE, SCOL_PTR (iBones->second));
91 b = MMfetch(m, b, OFFOBJMAG);
103 for(
int j=0; j<p; j++)
108 if(
int k=MBdeftab(m))
127 MMechostr(MSKDEBUG,
"SO3GetRootBoneFromMesh: DEPRECATED!\n");
130 int obj = MMget(m, 0);
137 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
144 if(node->GetNodeType()!=SNode::ENTITY_TYPE_ID)
150 SEntity* curEntity =
static_cast<SEntity*
> (node);
151 SSkeleton* skeleton = curEntity->GetSkeleton();
158 SBoneMap rootBonesList = skeleton->GetRootBones();
159 if(rootBonesList.empty())
165 int so3obj = OBJfindTH(m,
SO3OBJTYPE, SCOL_PTR(rootBonesList.begin()->second));
167 so3obj = MMfetch(m, so3obj, OFFOBJMAG);
185 MMechostr(MSKDEBUG,
"SO3GetRootBonesFromMesh\n");
188 int obj = MMget(m, 0);
195 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
202 if(node->GetNodeType()!=SNode::ENTITY_TYPE_ID)
208 SEntity* curEntity =
static_cast<SEntity*
> (node);
209 SSkeleton* skeleton = curEntity->GetSkeleton();
218 SBoneMap rootBoneListCopy = skeleton->GetRootBones();
219 SBoneMap::iterator iRootBones = rootBoneListCopy.begin();
220 while (iRootBones != rootBoneListCopy.end())
222 int b = OBJfindTH(m,
SO3OBJTYPE, SCOL_PTR(iRootBones->second));
224 b = MMfetch(m, b, OFFOBJMAG);
236 for(
int j=0; j<p; j++)
241 if(
int k=MBdeftab(m))
260 MMechostr(MSKDEBUG,
"SO3GetBoneLocalOrientation\n");
264 int obj = MMget(m, 0);
265 if((obj==NIL) || (q==NIL))
271 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
278 if(node->GetNodeType()!=SNode::BONE_TYPE_ID)
284 SBone* curBone =
static_cast<SBone*
> (node);
291 int x = MMfetch(m, MTOP(q), 0);
292 int y = MMfetch(m, MTOP(q), 1);
293 int z = MMfetch(m, MTOP(q), 2);
294 int w = MMfetch(m, MTOP(q), 3);
296 if((x==NIL) || (y==NIL) || (z==NIL) || (
w==NIL))
302 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
304 Ogre::Quaternion lquat = curBone->ConvertWorldToLocalOrientation(quat);
306 int tuple = MMmalloc(m, 4, TYPETAB);
312 MMstore(m, tuple, 0, FTOM((lquat.x)));
313 MMstore(m, tuple, 1, FTOM((lquat.y)));
314 MMstore(m, tuple, 2, FTOM((lquat.z)));
315 MMstore(m, tuple, 3, FTOM((lquat.w)));
316 MMset(m, 0, PTOM(tuple));