本文整理汇总了C++中ogre::SkeletonInstance::setBlendMode方法的典型用法代码示例。如果您正苦于以下问题:C++ SkeletonInstance::setBlendMode方法的具体用法?C++ SkeletonInstance::setBlendMode怎么用?C++ SkeletonInstance::setBlendMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::SkeletonInstance
的用法示例。
在下文中一共展示了SkeletonInstance::setBlendMode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetMesh
bool EC_Mesh::SetMesh(QString meshResourceName, bool clone)
{
if (!ViewEnabled())
return false;
OgreWorldPtr world = world_.lock();
std::string mesh_name = meshResourceName.trimmed().toStdString();
RemoveMesh();
// If placeable is not set yet, set it manually by searching it from the parent entity
if (!placeable_)
{
Entity* entity = ParentEntity();
if (entity)
{
ComponentPtr placeable = entity->GetComponent(EC_Placeable::TypeNameStatic());
if (placeable)
placeable_ = placeable;
}
}
Ogre::SceneManager* sceneMgr = world->OgreSceneManager();
Ogre::Mesh* mesh = PrepareMesh(mesh_name, clone);
if (!mesh)
return false;
try
{
entity_ = sceneMgr->createEntity(world->GetUniqueObjectName("EC_Mesh_entity"), mesh->getName());
if (!entity_)
{
LogError("EC_Mesh::SetMesh: Could not set mesh " + mesh_name);
return false;
}
entity_->setRenderingDistance(drawDistance.Get());
entity_->setCastShadows(castShadows.Get());
entity_->setUserAny(Ogre::Any(static_cast<IComponent *>(this)));
// Set UserAny also on subentities
for(uint i = 0; i < entity_->getNumSubEntities(); ++i)
entity_->getSubEntity(i)->setUserAny(entity_->getUserAny());
if (entity_->hasSkeleton())
{
Ogre::SkeletonInstance* skel = entity_->getSkeleton();
// Enable cumulative mode on skeletal animations
if (skel)
skel->setBlendMode(Ogre::ANIMBLEND_CUMULATIVE);
}
// Make sure adjustment node is uptodate
Transform newTransform = nodeTransformation.Get();
adjustment_node_->setPosition(newTransform.pos);
adjustment_node_->setOrientation(newTransform.Orientation());
// Prevent Ogre exception from zero scale
adjustment_node_->setScale(Max(newTransform.scale, float3::FromScalar(0.0000001f)));
// Force a re-apply of all materials to this new mesh.
ApplyMaterial();
}
catch(Ogre::Exception& e)
{
LogError("EC_Mesh::SetMesh: Could not set mesh " + mesh_name + ": " + std::string(e.what()));
return false;
}
AttachEntity();
emit MeshChanged();
return true;
}
示例2: SetMeshWithSkeleton
bool EC_Mesh::SetMeshWithSkeleton(const std::string& mesh_name, const std::string& skeleton_name, bool clone)
{
if (!ViewEnabled())
return false;
OgreWorldPtr world = world_.lock();
Ogre::SkeletonPtr skel = Ogre::SkeletonManager::getSingleton().getByName(AssetAPI::SanitateAssetRef(skeleton_name));
if (skel.isNull())
{
LogError("EC_Mesh::SetMeshWithSkeleton: Could not set skeleton " + skeleton_name + " to mesh " + mesh_name + ": not found");
return false;
}
RemoveMesh();
Ogre::SceneManager* sceneMgr = world->OgreSceneManager();
Ogre::Mesh* mesh = PrepareMesh(mesh_name, clone);
if (!mesh)
return false;
try
{
mesh->_notifySkeleton(skel);
// LogDebug("Set skeleton " + skeleton_name + " to mesh " + mesh_name);
}
catch(Ogre::Exception& e)
{
LogError("EC_Mesh::SetMeshWithSkeleton: Could not set skeleton " + skeleton_name + " to mesh " + mesh_name + ": " + std::string(e.what()));
return false;
}
try
{
entity_ = sceneMgr->createEntity(world->GetUniqueObjectName("EC_Mesh_entwithskel"), mesh->getName());
if (!entity_)
{
LogError("EC_Mesh::SetMeshWithSkeleton: Could not set mesh " + mesh_name);
return false;
}
entity_->setRenderingDistance(drawDistance.Get());
entity_->setCastShadows(castShadows.Get());
entity_->setUserAny(Ogre::Any(static_cast<IComponent *>(this)));
// Set UserAny also on subentities
for(uint i = 0; i < entity_->getNumSubEntities(); ++i)
entity_->getSubEntity(i)->setUserAny(entity_->getUserAny());
if (entity_->hasSkeleton())
{
Ogre::SkeletonInstance* skel = entity_->getSkeleton();
// Enable cumulative mode on skeletal animations
if (skel)
skel->setBlendMode(Ogre::ANIMBLEND_CUMULATIVE);
}
}
catch(Ogre::Exception& e)
{
LogError("EC_Mesh::SetMeshWithSkeleton: Could not set mesh " + mesh_name + ": " + std::string(e.what()));
return false;
}
AttachEntity();
emit MeshChanged();
return true;
}
示例3: SetMesh
bool EC_Mesh::SetMesh(QString meshResourceName, bool clone)
{
if (!ViewEnabled())
return false;
if (renderer_.expired())
return false;
RendererPtr renderer = renderer_.lock();
std::string mesh_name = meshResourceName.trimmed().toStdString();
RemoveMesh();
// If placeable is not set yet, set it manually by searching it from the parent entity
if (!placeable_)
{
Scene::Entity* entity = GetParentEntity();
if (entity)
{
ComponentPtr placeable = entity->GetComponent(EC_Placeable::TypeNameStatic());
if (placeable)
placeable_ = placeable;
}
}
Ogre::SceneManager* scene_mgr = renderer->GetSceneManager();
Ogre::Mesh* mesh = PrepareMesh(mesh_name, clone);
if (!mesh)
return false;
try
{
entity_ = scene_mgr->createEntity(renderer->GetUniqueObjectName("EC_Mesh_entity"), mesh->getName());
if (!entity_)
{
LogError("Could not set mesh " + mesh_name);
return false;
}
entity_->setRenderingDistance(drawDistance.Get());
entity_->setCastShadows(castShadows.Get());
entity_->setUserAny(Ogre::Any(GetParentEntity()));
// Set UserAny also on subentities
for (uint i = 0; i < entity_->getNumSubEntities(); ++i)
entity_->getSubEntity(i)->setUserAny(entity_->getUserAny());
if (entity_->hasSkeleton())
{
Ogre::SkeletonInstance* skel = entity_->getSkeleton();
// Enable cumulative mode on skeletal animations
if (skel)
skel->setBlendMode(Ogre::ANIMBLEND_CUMULATIVE);
}
// Make sure adjustment node is uptodate
if (adjustment_node_)
{
Transform newTransform = nodeTransformation.Get();
adjustment_node_->setPosition(newTransform.position.x, newTransform.position.y, newTransform.position.z);
Quaternion adjust(DEGTORAD * newTransform.rotation.x,
DEGTORAD * newTransform.rotation.y,
DEGTORAD * newTransform.rotation.z);
adjustment_node_->setOrientation(Ogre::Quaternion(adjust.w, adjust.x, adjust.y, adjust.z));
// Prevent Ogre exception from zero scale
if (newTransform.scale.x < 0.0000001f)
newTransform.scale.x = 0.0000001f;
if (newTransform.scale.y < 0.0000001f)
newTransform.scale.y = 0.0000001f;
if (newTransform.scale.z < 0.0000001f)
newTransform.scale.z = 0.0000001f;
adjustment_node_->setScale(newTransform.scale.x, newTransform.scale.y, newTransform.scale.z);
}
// Force a re-apply of all materials to this new mesh.
ApplyMaterial();
}
catch (Ogre::Exception& e)
{
LogError("Could not set mesh " + mesh_name + ": " + std::string(e.what()));
return false;
}
AttachEntity();
emit MeshChanged();
return true;
}