340 MMechostr(MSKDEBUG,
"SO3EntityGetMaterialByIndex\n");
344 int obj = MMget(m, 0);
345 if ((obj == NIL) || (idx == NIL) || ((MTOI(idx)) < 0))
351 SNode* node = MMgetPointer<SNode*>(m, MTOP(obj));
358 if (node->GetNodeType() != SNode::ENTITY_TYPE_ID)
364 unsigned int uidx = MTOI(idx);
366 SEntity* curEntity =
static_cast<SEntity*
> (node);
367 if (!curEntity->getOgreEntityPointer() || uidx >= curEntity->GetNumSubEntities())
373 SMaterial* tmpMat = curEntity->GetParentScene()->GetMaterial(curEntity->GetGroupName(), curEntity->getOgreEntityPointer()->getSubEntity(uidx)->getMaterial()->getName());
397 MMechostr(MSKDEBUG,
"SO3EntityMaterialList\n");
400 int ent = MMget(m, 0);
408 SNode* node = MMgetPointer<SNode*>(m, MTOP(ent));
415 if (node->GetNodeType() != SNode::ENTITY_TYPE_ID)
421 SEntity* entity =
static_cast<SEntity*
>(node);
422 if (!entity || !entity->getOgreEntityPointer())
430 int nbMat = entity->GetNumSubEntities();
433 for (
int i = 0; i < nbMat; i++)
435 SMaterial* material = node->GetParentScene()->GetMaterial(entity->GetGroupName(), entity->getOgreEntityPointer()->getSubEntity(i)->getMaterial()->getName());
436 if (material == NULL)
451 for (
int j = 0; j < n; j++)
453 if (MMpush(m, 2 * 2))
475 MMechostr(MSKDEBUG,
"SO3EntityAttachSkeleton\n");
481 if ((p == NIL) || (ent == NIL))
487 SNode* node = MMgetPointer<SNode*>(m, MTOP(ent));
494 if (node->GetNodeType() != SNode::ENTITY_TYPE_ID)
500 SEntity* entity =
static_cast<SEntity*
> (node);
501 if (!entity || !entity->getOgreEntityPointer())
507 SScene* scene = entity->GetParentScene();
508 string pathStd = MMstartstr(m, MTOP(p));
510 for (
unsigned int i = 0; i < pathStd.length(); i++)
512 if (pathStd.substr(i, 1) ==
"\\")
513 pathStd.replace(i, 1,
"/");
518 Ogre::SkeletonPtr sklptr = (Ogre::SkeletonPtr)scene->O3SkeletonManager->getByName(pathStd, entity->GetGroupName());
519 if (sklptr && !sklptr->getRootBones().empty())
522 if (entity->getOgreEntityPointer()->getMesh()->getSkeleton() != sklptr)
524 entity->getOgreEntityPointer()->getMesh()->setSkeletonName(pathStd);
525 entity->getOgreEntityPointer()->getMesh()->_notifySkeleton(sklptr);
529 Ogre::Entity* ogreEntity = entity->getOgreEntityPointer();
530 ogreEntity->_initialise(
true);
536 if (entity->getOgreEntityPointer()->getMesh()->getSkeletonName() != pathStd)
538 entity->getOgreEntityPointer()->getMesh()->setSkeletonName(pathStd);
541 Ogre::Entity* ogreEntity = entity->getOgreEntityPointer();
542 ogreEntity->_initialise(
true);
585 string tmpSkeletonName = entity->GetName() +
"." + pathStd;
586 SSkeleton* newSkeleton = scene->CreateSkeleton(tmpSkeletonName, entity);
589 SBoneMap bonesListCopy = newSkeleton->GetBones();
590 SBoneMap::iterator iBone = bonesListCopy.begin();
591 while (iBone != bonesListCopy.end())
593 SBone* newBone = iBone->second;
594 assert(newBone != 0);
596 createBone(m, (SNode*)newBone, scene, entity);
604 const SAnimMap animations = newSkeleton->GetAnimations();
605 SAnimMap::const_iterator iAnimation = animations.begin();
606 while (iAnimation != animations.end())
608 SAnim* newAnimation = iAnimation->second;
609 assert(newAnimation != 0);
612 const SAnimTrackList animationsTracksList = newAnimation->GetAnimationsTracks();
613 SAnimTrackList::const_iterator iAnimationTrack = animationsTracksList.begin();
614 while (iAnimationTrack != animationsTracksList.end())
616 SAnimTrack* newAnimationTrack = (*iAnimationTrack);
617 assert(newAnimationTrack != 0);
633 catch (Ogre::Exception &e)
635 MMechostr(MSKDEBUG,
"An exception has occurred: %s\n", e.what());
704 MMechostr(MSKDEBUG,
"SO3EntitySetMaterial\n");
707 int index = MMpull(m);
709 int ent = MMget(m, 0);
710 if ((ent == NIL) || (mat == NIL))
716 SMaterial* material = MMgetPointer<SMaterial*>(m, MTOP(mat));
717 if (material == NULL)
723 SNode* mNode = MMgetPointer<SNode*>(m, MTOP(ent));
724 if (mNode->GetNodeType() != SNode::ENTITY_TYPE_ID)
729 SEntity* entity =
static_cast <SEntity*
> (mNode);
736 if (entity->SetMaterial(material, MTOI(index)))
737 MMset(m, 0, ITOM(1));
755 MMechostr(MSKDEBUG,
"SO3EntityGetResourceGroup\n");
758 int ent = MMget(m, 0);
765 SNode* mNode = MMgetPointer<SNode*>(m, MTOP(ent));
766 if (mNode->GetNodeType() != SNode::ENTITY_TYPE_ID)
772 SEntity* entity =
static_cast <SEntity*
> (mNode);
773 if (!entity || !entity->getOgreEntityPointer())
780 std::string group = entity->GetGroupName();
781 group = group.substr(entity->GetParentScene()->GetName().length());
782 Mpushstrbloc(m, (
char*)group.c_str());