int MyLink::GetBornNum() { Ogre::Skeleton *tmp = mEntity->getSkeleton(); if(tmp) { return tmp->getNumBones(); } return 0; }
Ogre::Bone* EC_Mesh::GetBone(const QString& boneName) const { std::string boneNameStd = boneName.toStdString(); if (!entity_) return 0; Ogre::Skeleton* skel = entity_->getSkeleton(); if (skel && skel->hasBone(boneNameStd)) return skel->getBone(boneNameStd); else return 0; }
void NPCCharacter::_behaviorMove(const Ogre::Vector3& target) { //Check for duplicate move calls and update lua function call with that info //std::cout << target << std::endl; if(_destination.squaredDistance(target) >= 5) { updateDestination(target,false); _destination = target; } if(destinationReached()) { _isBhvFinished = true; } else { _isBhvFinished = false; } //point the character in the direction it's traveling Ogre::Vector3 vel = getVelocity(); float speed = vel.length(); vel.y = 0; vel.normalise(); if(speed > .2f) { Ogre::Vector3 src = _node->getOrientation() * Ogre::Vector3::NEGATIVE_UNIT_Z; src.y = 0; //moving sufficiently fast, change to moving animation and point character Utility::rotateToTarget(_node,vel,true); //change animation if needed. if(_animHandler.getSource() != nullptr) { Ogre::AnimationState* target = _animHandler.getTarget(); //this relies on the properties of the '&&' construct used by C++(if the first is false, //then the if-statement is false. It DOESN'T check both fields. if((target == nullptr && _animHandler.getSource()->getAnimationName() != "Walk") || (target != nullptr && target->getAnimationName() != "Walk")) { _animHandler.blend("Walk",AnimationBlender::BlendWhileAnimating,.2f,true); } } } //also have to reset the head, since I'm manually controlling it. Ogre::Skeleton* skel = static_cast<Ogre::Entity*>(_movableObject)->getSkeleton(); Ogre::Bone* headBone = skel->getBone("Bip01_Head"); //not sure how to do this. }
void CBlendingAnimationsView::OnTimer(UINT_PTR nIDEvent) { CEngine *Engine = ((CBlendingAnimationsApp*)AfxGetApp())->m_Engine; Ogre::Root *Root = Engine->GetRoot(); Ogre::SceneNode *RobotNode = Root->getSceneManager("Walking")->getSceneNode("Robot"); Ogre::Entity *RobotEntity = Root->getSceneManager("Walking")->getEntity("Robot"); Ogre::Skeleton *Skeleton = RobotEntity->getSkeleton(); if (m_WeightDlg->m_IsAverage) { Skeleton->setBlendMode(Ogre::SkeletonAnimationBlendMode::ANIMBLEND_AVERAGE); } else { Skeleton->setBlendMode(Ogre::SkeletonAnimationBlendMode::ANIMBLEND_CUMULATIVE); } double WalkWeight; double SlumpWeight; switch(nIDEvent) { case 1: WalkWeight = m_WeightDlg->m_WalkWeight.GetPos() / 10.0; SlumpWeight = m_WeightDlg->m_SlumpWeight.GetPos() / 10.0; m_WalkAnimation->setWeight(WalkWeight); m_SlumpAnimation->setWeight(SlumpWeight); m_WalkAnimation->addTime(0.01); m_SlumpAnimation->addTime(0.01); break; case 2: m_WalkAnimation->addTime(0.01); break; case 3: m_SlumpAnimation->addTime(0.01); break; } Root->renderOneFrame(); CView::OnTimer(nIDEvent); }
AnimationSystem::AnimationSystem( Ogre::Entity* entity ) : ExampleAnimationSystem() , m_animations( NULL ) { assert( entity ); m_animations = entity->getAllAnimationStates(); bool entityIsAnimated = ( entity->getAllAnimationStates() != NULL ); assert( entityIsAnimated ); Ogre::Skeleton* skeleton = entity->getSkeleton(); skeleton->setBlendMode( Ogre::ANIMBLEND_CUMULATIVE ); }
//This is basically just a time-waster void NPCCharacter::_actionIdle() { //want the head to point straight ahead when it's idling Ogre::Bone* headBone; Ogre::Skeleton* skel = static_cast<Ogre::Entity*>(_movableObject)->getSkeleton(); headBone = skel->getBone("Bip01_Head"); if(headBone->isManuallyControlled()) { //rotate it to be aligned with the body. } _isActFinished = true; }
//void _getBoneMatrices(Matrix4* pMatrices); void skeleton__get_bone_matrices(SkeletonHandle handle, coiMatrix4* matrices[]) { Ogre::Skeleton* skeleton = static_cast<Ogre::Skeleton*>(handle); // Borrowed from OgreEntity.cpp unsigned short num = skeleton->getNumBones(); Ogre::Matrix4* BoneMatrices = static_cast<Ogre::Matrix4*>(OGRE_MALLOC_SIMD(sizeof(Ogre::Matrix4) * num, Ogre::MEMCATEGORY_ANIMATION)); skeleton->_getBoneMatrices(BoneMatrices); for (unsigned short current = 0; current != num; ++current) { Ogre::Matrix4 o_matrix = *BoneMatrices; ogre_matrix4_to_llcoi_matrix4(o_matrix, *matrices[current]); } }
void NIFSkeletonLoader::loadResource(Ogre::Resource *resource) { Ogre::Skeleton *skel = dynamic_cast<Ogre::Skeleton*>(resource); OgreAssert(skel, "Attempting to load a skeleton into a non-skeleton resource!"); Nif::NIFFile::ptr nif(Nif::NIFFile::create(skel->getName())); const Nif::Node *node = static_cast<const Nif::Node*>(nif->getRoot(0)); try { buildBones(skel, node); } catch(std::exception &e) { std::cerr<< "Exception while loading "<<skel->getName() <<std::endl; std::cerr<< e.what() <<std::endl; return; } }
//! //! Create new scene. //! \return True if the scene was successfully created, otherwise False. //! bool Model2SceneNode::createEntity(QString name, QString fileName) { // destroy the entity through its scene manager Ogre::SceneManager *sceneManager = OgreManager::getSceneManager(); // create a new OGRE entity for each vertex m_entity = sceneManager->createEntity(name.toStdString(), fileName.toStdString()); if (m_entity) { // set cumulative blend mode instead of Ogre::ANIMBLEND_AVERAGE which is default if (m_entity->hasSkeleton()) { Ogre::Skeleton *skeleton = m_entity->getSkeleton(); skeleton->setBlendMode(Ogre::ANIMBLEND_CUMULATIVE); } } // create a container for the entity m_entityContainer = new OgreContainer(m_entity); m_entity->setUserAny(Ogre::Any(m_entityContainer)); return true; }
void CAnimatedEntity::moveBone(const std::string &bone, float pitch) { Ogre::Bone * entityBone = _entity->getSkeleton()->getBone(bone); entityBone->reset(); Ogre::Skeleton * skel = _entity->getSkeleton(); //entityBone->setManuallyControlled(true); unsigned short boneHandle = entityBone->getHandle(); Ogre::AnimationStateIterator animStateIt = _entity->getAllAnimationStates()->getAnimationStateIterator(); while( animStateIt.hasMoreElements() ) { Ogre::AnimationState *pAnimState = animStateIt.getNext(); // ignore disabled animations skel->getAnimation(pAnimState->getAnimationName())->destroyNodeTrack(boneHandle); } entityBone->pitch(Ogre::Radian(pitch)); }
void NPCCharacter::_actionLook(const Ogre::Vector3& target) { Ogre::Bone* headBone; std::string n = _node->getName(); Ogre::Skeleton* skel = static_cast<Ogre::Entity*>(_movableObject)->getSkeleton(); headBone = skel->getBone("Bip01_Head"); headBone->setManuallyControlled(true); headBone->setInheritOrientation(true); int nAnim = skel->getNumAnimations(); //have to do this to allow the head to turn properly. for(int i = 0; i < nAnim; ++i) { skel->getAnimation(i)->destroyNodeTrack(headBone->getHandle()); } Ogre::Vector3 test = headBone->_getDerivedPosition() * CHARACTER_SCALE_FACTOR + _node->getPosition(); Ogre::Vector3 dir = target - test; Ogre::Quaternion nodeRot,boneRot; Ogre::Euler boneEuler; boneEuler.setDirection(dir,true,false); /*boneRot = _node->convertLocalToWorldOrientation(_node->getOrientation()) * headBone->_getDerivedOrientation(); Ogre::Vector3 boneTest = boneRot * Ogre::Vector3::UNIT_Z;*/ //Ogre::Vector3 boneTest = headBone->getOrientation() * Ogre::Vector3::UNIT_Z; //turns the direction vector into a 2D normalized vector on the X/Z axis. dir.y = 0; dir.normalise(); //All of this ray query stuff is to make sure that the AI can "see" the target before attempting to look at it. Ogre::SceneManager* scene = _node->getCreator(); Ogre::Ray ray(headBone->_getDerivedPosition() * CHARACTER_SCALE_FACTOR + _node->getPosition(),dir); Ogre::RaySceneQuery* query = scene->createRayQuery(ray); query->setSortByDistance(true); query->setQueryMask(CHARACTER_MASK | SCENERY_MASK); Ogre::RaySceneQueryResult results = query->execute(); bool withinView = false; if(results.size() == 0) { withinView = true; } else { if(results.begin()->movable->getParentNode()->getName() == getName()) { if(results.size() == 1) { withinView = true; } } if(!withinView && results.size() > 1 && std::next(results.begin())->distance > test.distance(target)) { withinView = true; } } scene->destroyQuery(query); if(withinView) { Ogre::Euler node; Ogre::Euler t = headOrientation.getRotationTo(dir); t.limitYaw(Ogre::Radian(3.0)); t.limitPitch(Ogre::Radian(0.0)); headOrientation = headOrientation + t; headOrientation.limitYaw(Ogre::Degree(100)); headOrientation.limitPitch(Ogre::Degree(60)); headBone->setOrientation(headOrientation); /*headBone->rotate(boneTest.getRotationTo(dir),Ogre::Node::TS_WORLD); Ogre::Quaternion boneRotation = _node->convertLocalToWorldOrientation(_node->getOrientation()) * headBone->_getDerivedOrientation() * (Ogre::Quaternion(Ogre::Degree(180),Ogre::Vector3::UNIT_Y)); Ogre::Quaternion nodeRotation = _node->_getDerivedOrientation(); Ogre::Quaternion diff = nodeRotation.Inverse() * boneRotation;*/ } _isActFinished = true; }
//void reset(bool resetManualBones = false); void skeleton_reset(SkeletonHandle handle, int reset_manual_bones) { Ogre::Skeleton* skeleton = static_cast<Ogre::Skeleton*>(handle); skeleton->reset(reset_manual_bones); }
//void removeAnimation(const String& name); void skeleton_remove_animation(SkeletonHandle handle, const char* name) { Ogre::Skeleton* skeleton = static_cast<Ogre::Skeleton*>(handle); skeleton->removeAnimation(Ogre::String(name)); }
//! //! Clones an Ogre::MovableObject. //! //! Is needed because OGRE does not provide clone functions for cameras and //! lights. //! //! \param movableObject The object to clone. //! \param name The name to use for the object. //! \param sceneManager The scene manager to use for creating the object. //! \return The cloned object. //! Ogre::MovableObject * OgreTools::cloneMovableObject ( Ogre::MovableObject *movableObject, const QString &name, Ogre::SceneManager *sceneManager /* = 0 */ ) { // make sure the given object is valid if (!movableObject) { Log::error("The given movable object is invalid.", "OgreTools::cloneMovableObject"); return 0; } // make sure a valid scene manager is available if (!sceneManager) sceneManager = movableObject->_getManager(); if (!sceneManager) { Log::error("No valid scene manager available.", "OgreTools::cloneMovableObject"); return 0; } Ogre::MovableObject *result = 0; Ogre::String typeName = movableObject->getMovableType(); if (typeName == "Entity") { // clone entity Ogre::Entity *entity = dynamic_cast<Ogre::Entity *>(movableObject); //movableObjectCopy = entity->clone(name.toStdString()); Ogre::Entity *entityCopy = sceneManager->createEntity(name.toStdString(), entity->getMesh()->getName()); Ogre::AnimationStateSet *animationStateSet = entity->getAllAnimationStates(); Ogre::AnimationStateSet *animationStateSetCopy = entityCopy->getAllAnimationStates(); // set the same blend mode on entity copy if (entity && entityCopy) { if (entity->hasSkeleton() && entityCopy->hasSkeleton()) { Ogre::Skeleton *skeleton = entity->getSkeleton(); Ogre::Skeleton *skeletonCopy = entityCopy->getSkeleton(); skeletonCopy->setBlendMode(skeleton->getBlendMode()); } } // copy all animation states if (animationStateSet && animationStateSetCopy) { Ogre::AnimationStateIterator animationStateIter = animationStateSet->getAnimationStateIterator(); Ogre::AnimationStateIterator animationStateCopyIter = animationStateSetCopy->getAnimationStateIterator(); while (animationStateIter.hasMoreElements()) { if (!animationStateCopyIter.hasMoreElements()) break; Ogre::AnimationState *animationState = animationStateIter.getNext(); Ogre::AnimationState *animationStateCopy = animationStateCopyIter.getNext(); animationStateCopy->setLoop(animationState->getLoop()); //bool enabled = animationState->getEnabled(); //animationStateCopy->setEnabled(animationState->getEnabled()); animationStateCopy->setEnabled(true); animationStateCopy->setTimePosition(animationState->getTimePosition()); } } // create a new container for the cloned entity OgreContainer *entityCopyContainer = new OgreContainer(entityCopy); entityCopy->setUserAny(Ogre::Any(entityCopyContainer)); if (!entity->getUserAny().isEmpty()) { OgreContainer *entityContainer = Ogre::any_cast<OgreContainer *>(entity->getUserAny()); if (entityContainer) { QObject::connect(entityContainer, SIGNAL(animationStateUpdated(const QString &, double)), entityCopyContainer, SLOT(updateAnimationState(const QString &, double))); QObject::connect(entityContainer, SIGNAL(boneTransformUpdated(const QString &, double, double, double, double, double, double)), entityCopyContainer, SLOT(updateBoneTransform(const QString &, double, double, double, double, double, double))); } } result = dynamic_cast<Ogre::MovableObject *>(entityCopy); } else if (typeName == "Light") { // clone light Ogre::Light *light = dynamic_cast<Ogre::Light *>(movableObject); Ogre::Light *lightCopy = sceneManager->createLight(name.toStdString()); lightCopy->setType(light->getType()); lightCopy->setDiffuseColour(light->getDiffuseColour()); lightCopy->setSpecularColour(light->getSpecularColour()); lightCopy->setAttenuation(light->getAttenuationRange(), light->getAttenuationConstant(), light->getAttenuationLinear(), light->getAttenuationQuadric()); lightCopy->setPosition(light->getPosition()); lightCopy->setDirection(light->getDirection()); if (lightCopy->getType() == Ogre::Light::LT_SPOTLIGHT) lightCopy->setSpotlightRange(light->getSpotlightInnerAngle(), light->getSpotlightOuterAngle(), light->getSpotlightFalloff()); lightCopy->setPowerScale(light->getPowerScale()); lightCopy->setCastShadows(light->getCastShadows()); // create a new container for the cloned light OgreContainer *lightCopyContainer = new OgreContainer(lightCopy); lightCopy->setUserAny(Ogre::Any(lightCopyContainer)); if (!light->getUserAny().isEmpty()) { OgreContainer *lightContainer = Ogre::any_cast<OgreContainer *>(light->getUserAny()); if (lightContainer) QObject::connect(lightContainer, SIGNAL(sceneNodeUpdated()), lightCopyContainer, SLOT(updateLight())); } result = dynamic_cast<Ogre::MovableObject *>(lightCopy); } else if (typeName == "Camera") { // clone camera Ogre::Camera *camera = dynamic_cast<Ogre::Camera *>(movableObject); Ogre::Camera *cameraCopy = sceneManager->createCamera(name.toStdString()); //cameraCopy->setCustomParameter(0, camera->getCustomParameter(0)); cameraCopy->setAspectRatio(camera->getAspectRatio()); cameraCopy->setAutoAspectRatio(camera->getAutoAspectRatio()); //cameraCopy->setAutoTracking(...); cameraCopy->setCastShadows(camera->getCastsShadows()); //cameraCopy->setCullingFrustum(camera->getCullingFrustum()); //cameraCopy->setCustomParameter(...); //cameraCopy->setCustomProjectionMatrix(..); //cameraCopy->setCustomViewMatrix(..); //cameraCopy->setDebugDisplayEnabled(...); //cameraCopy->setDefaultQueryFlags(...); //cameraCopy->setDefaultVisibilityFlags(...); cameraCopy->setDirection(camera->getDirection()); //cameraCopy->setFixedYawAxis(...); cameraCopy->setFocalLength(camera->getFocalLength()); cameraCopy->setFOVy(camera->getFOVy()); //Ogre::Real left; //Ogre::Real right; //Ogre::Real top; //Ogre::Real bottom; //camera->getFrustumExtents(left, right, top, bottom); //cameraCopy->setFrustumExtents(left, right, top, bottom); //cameraCopy->setFrustumOffset(camera->getFrustumOffset()); //cameraCopy->setListener(camera->getListener()); cameraCopy->setLodBias(camera->getLodBias()); //cameraCopy->setLodCamera(camera->getLodCamera()); cameraCopy->setNearClipDistance(camera->getNearClipDistance()); cameraCopy->setFarClipDistance(camera->getFarClipDistance()); cameraCopy->setOrientation(camera->getOrientation()); //cameraCopy->setOrthoWindow(...); //cameraCopy->setOrthoWindowHeight(...); //cameraCopy->setOrthoWindowWidth(...); cameraCopy->setPolygonMode(camera->getPolygonMode()); cameraCopy->setPolygonModeOverrideable(camera->getPolygonModeOverrideable()); cameraCopy->setPosition(camera->getPosition()); cameraCopy->setProjectionType(camera->getProjectionType()); cameraCopy->setQueryFlags(camera->getQueryFlags()); cameraCopy->setRenderingDistance(camera->getRenderingDistance()); cameraCopy->setRenderQueueGroup(camera->getRenderQueueGroup()); //cameraCopy->setRenderSystemData(camera->getRenderSystemData()); cameraCopy->setUseIdentityProjection(camera->getUseIdentityProjection()); cameraCopy->setUseIdentityView(camera->getUseIdentityView()); //cameraCopy->setUserAny(camera->getUserAny()); cameraCopy->setUseRenderingDistance(camera->getUseRenderingDistance()); //cameraCopy->setUserObject(camera->getUserObject()); cameraCopy->setVisibilityFlags(camera->getVisibilityFlags()); cameraCopy->setVisible(camera->getVisible()); //cameraCopy->setWindow(...); if (!movableObject->getUserAny().isEmpty()) { CameraInfo *sourceCameraInfo = Ogre::any_cast<CameraInfo *>(movableObject->getUserAny()); if (sourceCameraInfo) { CameraInfo *targetCameraInfo = new CameraInfo(); targetCameraInfo->width = sourceCameraInfo->width; targetCameraInfo->height = sourceCameraInfo->height; dynamic_cast<Ogre::MovableObject *>(cameraCopy)->setUserAny(Ogre::Any(targetCameraInfo)); } } //// Setup connections for instances //SceneNode *targetSceneNode = new SceneNode(cameraCopy); //((Ogre::MovableObject *)cameraCopy)->setUserAny(Ogre::Any(targetSceneNode)); //if (!((Ogre::MovableObject *)camera)->getUserAny().isEmpty()) { // SceneNode *sourceSceneNode = Ogre::any_cast<SceneNode *>(((Ogre::MovableObject *)camera)->getUserAny()); // if (sourceSceneNode) { // QObject::connect(sourceSceneNode, SIGNAL(sceneNodeUpdated()), targetSceneNode, SLOT(updateSceneNode())); // } //} result = dynamic_cast<Ogre::MovableObject *>(cameraCopy); } if (!result) Log::error(QString("Could not clone movable object \"%1\" of type \"%2\".").arg(movableObject->getName().c_str()).arg(typeName.c_str()), "OgreTools::cloneMovableObject"); return result; }
bool OgreSmartBody::frameRenderingQueued(const Ogre::FrameEvent& evt) { if(mWindow->isClosed()) return false; //Need to capture/update each device mKeyboard->capture(); mMouse->capture(); if(mKeyboard->isKeyDown(OIS::KC_ESCAPE)) return false; // smartbody if (!m_pScene) return true; SmartBody::SBSimulationManager* sim = m_pScene->getSimulationManager(); sim->setTime((Ogre::Root::getSingleton().getTimer()->getMilliseconds() / 1000.0f) - mStartTime); m_pScene->update(); int numCharacters = m_pScene->getNumCharacters(); if (numCharacters == 0) return true; const std::vector<std::string>& characterNames = m_pScene->getCharacterNames(); for (size_t n = 0; n < characterNames.size(); n++) { SmartBody::SBCharacter* character = m_pScene->getCharacter(characterNames[n]); if (!this->getSceneManager()->hasEntity(characterNames[n])) continue; Ogre::Entity* entity = this->getSceneManager()->getEntity(characterNames[n]); Ogre::Skeleton* meshSkel = entity->getSkeleton(); Ogre::Node* node = entity->getParentNode(); SrVec pos = character->getPosition(); SrQuat ori = character->getOrientation(); //std::cout << ori.w << ori.x << " " << ori.y << " " << ori.z << std::endl; node->setPosition(pos.x, pos.y, pos.z); node->setOrientation(ori.w, ori.x, ori.y, ori.z); // Update joints SmartBody::SBSkeleton* sbSkel = character->getSkeleton(); int numJoints = sbSkel->getNumJoints(); for (int j = 0; j < numJoints; j++) { SmartBody::SBJoint* joint = sbSkel->getJoint(j); try { SrQuat orientation = joint->quat()->value(); Ogre::Vector3 posDelta(joint->getPosition().x, joint->getPosition().y, joint->getPosition().z); Ogre::Quaternion quatDelta(orientation.w, orientation.x, orientation.y, orientation.z); Ogre::Bone* bone = meshSkel->getBone(joint->getName()); if (!bone) continue; bone->setPosition(bone->getInitialPosition() + posDelta); bone->setOrientation(quatDelta); } catch (Ogre::ItemIdentityException& ex) { // Should not happen as we filtered using m_mValidBones } } } return true; }
//void setBlendMode(SkeletonAnimationBlendMode state); void skeleton_set_blend_mode(SkeletonHandle handle, skeleton_animation_blend_mode state) { Ogre::Skeleton* skeleton = static_cast<Ogre::Skeleton*>(handle); Ogre::SkeletonAnimationBlendMode mode = llcoi_skeleton_blend_mode_to_ogre(state); skeleton->setBlendMode(mode); }
//void optimiseAllAnimations(bool preservingIdentityNodeTracks = false); void skeleton_optimise_all_animations(SkeletonHandle handle, int preserving_identity_node_tracks) { Ogre::Skeleton* skeleton = static_cast<Ogre::Skeleton*>(handle); skeleton->optimiseAllAnimations(preserving_identity_node_tracks); }
//Bone* createBone(const String& name, unsigned short handle); BoneHandle skeleton_create_bone_with_name_and_handle(SkeletonHandle handle, const char* name, unsigned short bone_handle) { Ogre::Skeleton* skeleton = static_cast<Ogre::Skeleton*>(handle); Ogre::Bone* bone = skeleton->createBone(Ogre::String(name), bone_handle); return static_cast<BoneHandle>(bone); }
//Bone* createBone(unsigned short handle); BoneHandle skeleton_create_bone_with_handle(SkeletonHandle handle, unsigned short bone_handle) { Ogre::Skeleton* skeleton = static_cast<Ogre::Skeleton*>(handle); Ogre::Bone* bone = skeleton->createBone(bone_handle); return static_cast<BoneHandle>(bone); }
//Bone* createBone(void); BoneHandle skeleton_create_bone(SkeletonHandle handle) { Ogre::Skeleton* skeleton = static_cast<Ogre::Skeleton*>(handle); Ogre::Bone* bone = skeleton->createBone(); return static_cast<BoneHandle>(bone); }
//void _notifyManualBoneStateChange(Bone* bone); void skeleton__notify_manual_bone_state_change(SkeletonHandle handle, BoneHandle bone) { Ogre::Skeleton* skeleton = static_cast<Ogre::Skeleton*>(handle); Ogre::Bone* b = static_cast<Ogre::Bone*>(bone); skeleton->_notifyManualBoneStateChange(b); }
//void removeAllLinkedSkeletonAnimationSources(void); void skeleton_remove_all_linked_skeleton_animation_sources(SkeletonHandle handle) { Ogre::Skeleton* skeleton = static_cast<Ogre::Skeleton*>(handle); skeleton->removeAllLinkedSkeletonAnimationSources(); }
//void addLinkedSkeletonAnimationSource(const String& skelName, Real scale = 1.0f); void skeleton_add_linked_skeleton_animation_source(SkeletonHandle handle, const char* skel_name, coiReal scale) { Ogre::Skeleton* skeleton = static_cast<Ogre::Skeleton*>(handle); skeleton->addLinkedSkeletonAnimationSource(Ogre::String(skel_name), scale); }
bool EC_Mesh::SetAttachmentMesh(uint index, const std::string& mesh_name, const std::string& attach_point, bool share_skeleton) { if (!ViewEnabled()) return false; OgreWorldPtr world = world_.lock(); if (!entity_) { LogError("EC_Mesh::SetAttachmentMesh: No mesh entity created yet, can not create attachments!"); return false; } Ogre::SceneManager* sceneMgr = world->OgreSceneManager(); size_t oldsize = attachment_entities_.size(); size_t newsize = index + 1; if (oldsize < newsize) { attachment_entities_.resize(newsize); attachment_nodes_.resize(newsize); for(uint i = oldsize; i < newsize; ++i) { attachment_entities_[i] = 0; attachment_nodes_[i] = 0; } } RemoveAttachmentMesh(index); Ogre::Mesh* mesh = PrepareMesh(mesh_name, false); if (!mesh) return false; if (share_skeleton) { // If sharing a skeleton, force the attachment mesh to use the same skeleton // This is theoretically quite a scary operation, for there is possibility for things to go wrong Ogre::SkeletonPtr entity_skel = entity_->getMesh()->getSkeleton(); if (entity_skel.isNull()) { LogError("EC_Mesh::SetAttachmentMesh: Cannot share skeleton for attachment, not found"); return false; } try { mesh->_notifySkeleton(entity_skel); } catch(const Ogre::Exception &/*e*/) { LogError("EC_Mesh::SetAttachmentMesh: Could not set shared skeleton for attachment"); return false; } } try { QString entityName = QString("EC_Mesh_attach") + QString::number(index); attachment_entities_[index] = sceneMgr->createEntity(world->GetUniqueObjectName(entityName.toStdString()), mesh->getName()); if (!attachment_entities_[index]) { LogError("EC_Mesh::SetAttachmentMesh: Could not set attachment mesh " + mesh_name); return false; } attachment_entities_[index]->setRenderingDistance(drawDistance.Get()); attachment_entities_[index]->setCastShadows(castShadows.Get()); attachment_entities_[index]->setUserAny(entity_->getUserAny()); // Set UserAny also on subentities for(uint i = 0; i < attachment_entities_[index]->getNumSubEntities(); ++i) attachment_entities_[index]->getSubEntity(i)->setUserAny(entity_->getUserAny()); Ogre::Bone* attach_bone = 0; if (!attach_point.empty()) { Ogre::Skeleton* skel = entity_->getSkeleton(); if (skel && skel->hasBone(attach_point)) attach_bone = skel->getBone(attach_point); } if (attach_bone) { Ogre::TagPoint* tag = entity_->attachObjectToBone(attach_point, attachment_entities_[index]); attachment_nodes_[index] = tag; } else { QString nodeName = QString("EC_Mesh_attachment_") + QString::number(index); Ogre::SceneNode* node = sceneMgr->createSceneNode(world->GetUniqueObjectName(nodeName.toStdString())); node->attachObject(attachment_entities_[index]); adjustment_node_->addChild(node); attachment_nodes_[index] = node; } if (share_skeleton && entity_->hasSkeleton() && attachment_entities_[index]->hasSkeleton()) { attachment_entities_[index]->shareSkeletonInstanceWith(entity_); } } catch(Ogre::Exception& e) { LogError("EC_Mesh::SetAttachmentMesh: Could not set attachment mesh " + mesh_name + ": " + std::string(e.what())); return false; } return true; }
//void setBindingPose(void); void skeleton_set_binding_pose(SkeletonHandle handle) { Ogre::Skeleton* skeleton = static_cast<Ogre::Skeleton*>(handle); skeleton->setBindingPose(); }
//typedef vector<LinkedSkeletonAnimationSource>::type LinkedSkeletonAnimSourceList; //typedef ConstVectorIterator<LinkedSkeletonAnimSourceList> LinkedSkeletonAnimSourceIterator; //TODO: LinkedSkeletonAnimSourceIterator getLinkedSkeletonAnimationSourceIterator(void) const; //void _notifyManualBonesDirty(void); void skeleton__notify_manual_bones_dirty(SkeletonHandle handle) { Ogre::Skeleton* skeleton = static_cast<Ogre::Skeleton*>(handle); skeleton->_notifyManualBonesDirty(); }
//void _updateTransforms(void); void skeleton__update_transforms(SkeletonHandle handle) { Ogre::Skeleton* skeleton = static_cast<Ogre::Skeleton*>(handle); skeleton->_updateTransforms(); }