本文整理汇总了C++中ogre::Entity::hasSkeleton方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::hasSkeleton方法的具体用法?C++ Entity::hasSkeleton怎么用?C++ Entity::hasSkeleton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Entity
的用法示例。
在下文中一共展示了Entity::hasSkeleton方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintGL
/**
* @brief render a frame
* @author Kito Berg-Taylor
*/
void THIS::paintGL()
{
if (!initialised)
initializeOgre();
for (Ogre::SceneManager::MovableObjectIterator mit = mSceneMgr->getMovableObjectIterator("Entity");mit.hasMoreElements(); mit.moveNext() )
{
Ogre::Entity *entity = static_cast<Ogre::Entity*>(mit.peekNextValue());
if (entity->hasSkeleton() )
{
for (Ogre::AnimationStateIterator animIt = entity->getAllAnimationStates()->getAnimationStateIterator(); animIt.hasMoreElements(); animIt.moveNext() )
{
Ogre::AnimationState *animState = animIt.peekNextValue();
if ( animState->getEnabled() )
{
animState->addTime(mWindow->getBestFPS()/10000);
}
}
}
}
//Ogre::WindowEventUtilities::messagePump();
mRoot->renderOneFrame();
}
示例2: makeManual
void gkSkeletonLoader::makeManual(gkEntity* ent)
{
Ogre::Entity* oent = ent->getEntity();
if (!oent || !oent->hasSkeleton())
return;
Ogre::SkeletonInstance* inst = oent->getSkeleton();
gkBone::BoneList::Iterator it = m_skeleton->getBoneList().iterator();
while (it.hasMoreElements())
{
gkBone* bone = it.getNext();
if (inst->hasBone(bone->getName()))
{
Ogre::Bone* obone = inst->getBone(bone->getName());
bone->_setOgreBone(obone);
obone->setManuallyControlled(true);
}
}
}
示例3: OnUpdateUI_AttachEffectAdd
void CMainFrame::OnUpdateUI_AttachEffectAdd( CCmdUI* pCmdUI )
{
Ogre::Entity* curSel = ManipulatorSystem.GetObject().GetSelection();
if (curSel && curSel->hasSkeleton())
pCmdUI->Enable(TRUE);
else
pCmdUI->Enable(FALSE);
}
示例4: OnFrameMove
void ManipulatorEffect::OnFrameMove( float dt )
{
Ogre::Entity* ent = ManipulatorSystem.GetObject().GetSelection();
if (ent && ent->hasSkeleton())
{
auto iter = m_effectTemplates.find(ent->getMesh()->getName());
if (iter != m_effectTemplates.end())
{
Kratos::EffectController* controller = iter->second;
controller->Update(dt);
}
}
}
示例5: visitor
Ogre::SceneNode *EMDOgre::createOgreSceneNodeModel(EMDModel *model, Ogre::SceneNode *parent, Ogre::SceneManager *scene_manager) {
Ogre::SceneNode *model_node = parent->createChildSceneNode();
vector<EMDMesh *> &meshes = model->getMeshes();
for (size_t i = 0; i < meshes.size(); i++) {
vector<EMDSubmesh *> &submeshes = meshes[i]->getSubmeshes();
if (!mesh_resources_created) {
createOgreEntityMeshes(meshes[i]);
}
for (size_t j = 0; j < submeshes.size(); j++) {
Ogre::Entity *entity = scene_manager->createEntity(meshes[i]->getName() + "_" + submeshes[j]->getMaterialName());
entity->setMaterialName(name + "_" + submeshes[j]->getMaterialName());
// Create Render Object Listeners depending on submesh definitions
vector<EMDSubmeshDefinition> definitions = submeshes[j]->getDefinitions();
EMBOgre *texture_pack = material_pack->getTexturePack();
EMBOgre *texture_dyt_pack = material_pack->getDYTTexturePack();
if (texture_pack && texture_dyt_pack) {
vector<Ogre::TexturePtr> textures = texture_pack->getOgreTextures();
vector<Ogre::TexturePtr> textures_dyt = texture_dyt_pack->getOgreTextures();
for (size_t k = 0; k < definitions.size(); k++) {
unsigned short texture_index = definitions[k].tex_index;
unsigned short dyt_texture_index = definitions[k].tex_index;
if (texture_index >= textures.size()) texture_index = textures.size()-1;
if (dyt_texture_index >= textures_dyt.size()) dyt_texture_index = textures_dyt.size() - 1;
EMDRenderObject *emd_render_object = new EMDRenderObject(textures[texture_index], textures_dyt[dyt_texture_index]);
EMDRenderObjectAssignVisitor visitor(emd_render_object);
entity->visitRenderables(&visitor);
created_render_objects.push_back(emd_render_object);
break; // FIXME: Figure out why there's multiple definitions
}
}
// Share Skeleton Instances with ESK's fake entity
if (skeleton) {
if (entity->hasSkeleton()) {
entity->shareSkeletonInstanceWith(skeleton->getEntity());
}
}
model_node->attachObject(entity);
}
}
return model_node;
}
示例6: updateOGRE
void MainWindow::updateOGRE()
{
QMutexLocker locker(&mutex);
static bool updateGUI=true;
Ogre::Root* mRoot = Ogre::Root::getSingletonPtr();
mRoot->_fireFrameStarted();
// loop through ogre widgets and update animation
QList<OgreWidget*> rendlist = this->findChildren<OgreWidget*>();
foreach (OgreWidget* w, rendlist)
{
// update animation for OgreWidget's sceneManager
if (w->mRenderWindow && w->updatesEnabled())
{
// update OgreWidget
w->update();
//emit w->paintEvent(new QPaintEvent(w->rect()));
for (Ogre::SceneManager::MovableObjectIterator mit = w->getSceneManager()->getMovableObjectIterator("Entity");
mit.hasMoreElements(); mit.moveNext() )
{
Ogre::Entity *entity = static_cast<Ogre::Entity*>(mit.peekNextValue());
if (updateGUI) {
updateGUI = false;
}
// check has skeleton to avoid crash for non animable entities
if (entity->hasSkeleton())
{
for (Ogre::AnimationStateIterator animIt = entity->getAllAnimationStates()->getAnimationStateIterator();
animIt.hasMoreElements(); animIt.moveNext() )
{
Ogre::AnimationState *animState = animIt.peekNextValue();
if ( animState->getEnabled() )
{
//std::cout << entity->getName() << " ZZZZZZZZZZZ " << animState->getAnimationName();
animState->addTime(w->getRenderWindow()->getBestFPS()/10000);
}
}
}
}
}
}
mRoot->_fireFrameRenderingQueued();
mRoot->_fireFrameEnded();
}
示例7: SceneManager
void
Player::stopAnimation(std::string anim)
{
Ogre::SceneManager::MovableObjectIterator iterator = SceneManager()->getMovableObjectIterator("Entity");
while(iterator.hasMoreElements())
{
Ogre::Entity* e = static_cast<Ogre::Entity*>(iterator.getNext());
if (e->hasSkeleton())
{
Ogre::AnimationState *animation = e->getAnimationState(anim);
animation->setEnabled(false);
animation->setTimePosition(0);
}
}
}
示例8: ClearSelection
void ManipulatorObject::ClearSelection()
{
if (m_pSelectEntity)
{
//隐藏所有gizmo
ShowEntityGizmo(m_pSelectEntity, false, eEditMode_Select);
ShowEntityGizmo(m_pSelectEntity, false, eEditMode_Move);
Ogre::Entity* ent = m_pSelectEntity;
m_pSelectEntity = nullptr;
//改变摄像机模式
if(ent->hasSkeleton())
ManipulatorSystem.GetCamera().SetType(eCameraType_RTS);
//回调事件
Excute([=,this](ManipulatorObjectEventCallback* callback){ callback->OnObjectClearSelection(ent); });
}
}
示例9: while
//!
//! 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());
//.........这里部分代码省略.........
示例10: Update
//.........这里部分代码省略.........
i->second.weight_ -= (1.0f / i->second.fade_period_) * frametime;
if (i->second.weight_ <= 0.0f)
{
i->second.weight_ = 0.0f;
i->second.phase_ = PHASE_STOP;
}
}
break;
}
// Set weight & step the animation forward
if (i->second.phase_ != PHASE_STOP)
{
Ogre::Real advance = i->second.speed_factor_ * frametime;
Ogre::Real new_weight = i->second.weight_ * i->second.weight_factor_;
if (new_weight != animstate->getWeight())
animstate->setWeight((Ogre::Real)i->second.weight_ * i->second.weight_factor_);
if (advance != 0.0f)
animstate->addTime((Ogre::Real)(i->second.speed_factor_ * frametime));
if (!animstate->getEnabled())
animstate->setEnabled(true);
}
else
{
// If stopped, disable & remove this animation from list
animstate->setEnabled(false);
erase_list.push_back(i->first);
}
}
for (uint i = 0; i < erase_list.size(); ++i)
{
animations_.erase(erase_list[i]);
}
// High-priority/low-priority blending code
if (entity->hasSkeleton())
{
Ogre::SkeletonInstance* skel = entity->getSkeleton();
if (!skel)
return;
if (highpriority_mask_.size() != skel->getNumBones())
highpriority_mask_.resize(skel->getNumBones());
if (lowpriority_mask_.size() != skel->getNumBones())
lowpriority_mask_.resize(skel->getNumBones());
for (uint i = 0; i < skel->getNumBones(); ++i)
{
highpriority_mask_[i] = 1.0;
lowpriority_mask_[i] = 1.0;
}
// Loop through all high priority animations & update the lowpriority-blendmask based on their active tracks
for (AnimationMap::iterator i = animations_.begin(); i != animations_.end(); ++i)
{
Ogre::AnimationState* animstate = GetAnimationState(entity, i->first);
if (!animstate)
continue;
// Create blend mask if animstate doesn't have it yet
if (!animstate->hasBlendMask())
animstate->createBlendMask(skel->getNumBones());
if ((i->second.high_priority_) && (i->second.weight_ > 0.0))
{
// High-priority animations get the full weight blend mask
animstate->_setBlendMaskData(&highpriority_mask_[0]);
if (!skel->hasAnimation(animstate->getAnimationName()))
continue;
Ogre::Animation* anim = skel->getAnimation(animstate->getAnimationName());
Ogre::Animation::NodeTrackIterator it = anim->getNodeTrackIterator();
while (it.hasMoreElements())
{
Ogre::NodeAnimationTrack* track = it.getNext();
unsigned id = track->getHandle();
// For each active track, reduce corresponding bone weight in lowpriority-blendmask
// by this animation's weight
if (id < lowpriority_mask_.size())
{
lowpriority_mask_[id] -= i->second.weight_;
if (lowpriority_mask_[id] < 0.0) lowpriority_mask_[id] = 0.0;
}
}
}
}
// Now set the calculated blendmask on low-priority animations
for (AnimationMap::iterator i = animations_.begin(); i != animations_.end(); ++i)
{
Ogre::AnimationState* animstate = GetAnimationState(entity, i->first);
if (!animstate)
continue;
if (i->second.high_priority_ == false)
animstate->_setBlendMaskData(&lowpriority_mask_[0]);
}
}
}
示例11: AniName
void
AnimationSelector::Reload(void)
{
resetState();
if (!Ogre::ResourceGroupManager::getSingletonPtr())
return;
if(NULL == GetDataManipulator())
return;
mAnimationList->Freeze();
wxTreeItemId root = mAnimationList->GetRootItem();
mAnimationList->Unselect();
mAnimationList->DeleteChildren(root);
if (mIsMeshAnim)
{
// Get animation list of current mesh
Fairy::ObjectPtr pCurMesh = GetDataManipulator()->m_pMeshObject;
if (!pCurMesh)
{
mAnimationList->Thaw();
return;
}
Fairy::StaticEntityObject* entity = static_cast<Fairy::StaticEntityObject*>((pCurMesh).get());
Ogre::Entity* pCurEntity = entity->getEntity();
if(pCurEntity && pCurEntity->hasSkeleton())
{
//更新动画列表
unsigned short numAnim = pCurEntity->getSkeleton()->getNumAnimations();
for(int i=0;i<numAnim;++i)
{
Ogre::String AniName = pCurEntity->getSkeleton()->getAnimation(i)->getName();
wxTreeItemId item = AddLeaf(root, AniName);
mAnimationList->SetItemData(item, new AnimationItemData(AniName));
}
}
mAnimationList->Thaw();
}
else
{
Fairy::LogicModel* pObjModel = GetDataManipulator()->m_pObjTemplate;
if (!pObjModel)
{
mAnimationList->Thaw();
return;
}
Fairy::LogicModelManager::AnimationSkeletonLinks* pAniLinks = GetDataManipulator()->_getCurAniLinks();
if (!pAniLinks)
{
mAnimationList->Thaw();
return;
}
for ( Fairy::LogicModelManager::AnimationSkeletonLinks::iterator iter = pAniLinks->begin(); iter!= pAniLinks->end(); ++iter)
{
Ogre::String AniName(iter->first);
wxTreeItemId item = AddLeaf(root, AniName);
mAnimationList->SetItemData(item, new AnimationItemData(AniName));
}
mAnimationList->Thaw();
}
}