本文整理汇总了C++中ogre::SkeletonPtr类的典型用法代码示例。如果您正苦于以下问题:C++ SkeletonPtr类的具体用法?C++ SkeletonPtr怎么用?C++ SkeletonPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SkeletonPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadMeshWork
void ResourceLoader::loadMeshWork(const String& name, Mesh::MeshdataPtr mesh, const String& skeletonName, LoadedCallback cb) {
Ogre::MeshManager& mm = Ogre::MeshManager::getSingleton();
Ogre::MeshPtr mo = mm.getByName(name);
if (mo.isNull()) {
/// FIXME: set bounds, bounding radius here
Ogre::ManualResourceLoader *reload;
mo = mm.createManual(name,Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,(reload=
#ifdef _WIN32
#ifdef NDEBUG
OGRE_NEW
#else
new
#endif
#else
OGRE_NEW
#endif
ManualMeshLoader(mesh, name)));
reload->prepareResource(&*mo);
reload->loadResource(&*mo);
if (!skeletonName.empty()) {
Ogre::SkeletonManager& skel_mgr = Ogre::SkeletonManager::getSingleton();
Ogre::SkeletonPtr skel = skel_mgr.getByName(skeletonName);
if (!skel.isNull())
mo->_notifySkeleton(skel);
}
}
cb();
}
示例2: PrepareMesh
Ogre::Mesh* EC_Mesh::PrepareMesh(const std::string& mesh_name, bool clone)
{
if (!ViewEnabled())
return 0;
if (renderer_.expired())
return 0;
RendererPtr renderer = renderer_.lock();
Ogre::MeshManager& mesh_mgr = Ogre::MeshManager::getSingleton();
Ogre::MeshPtr mesh = mesh_mgr.getByName(SanitateAssetIdForOgre(mesh_name));
// For local meshes, mesh will not get automatically loaded until used in an entity. Load now if necessary
if (mesh.isNull())
{
try
{
mesh_mgr.load(mesh_name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
mesh = mesh_mgr.getByName(mesh_name);
}
catch (Ogre::Exception& e)
{
LogError("Could not load mesh " + mesh_name + ": " + std::string(e.what()));
return 0;
}
}
// If mesh is still null, must abort
if (mesh.isNull())
{
LogError("Mesh " + mesh_name + " does not exist");
return 0;
}
if (clone)
{
try
{
mesh = mesh->clone(renderer->GetUniqueObjectName("EC_Mesh_clone"));
mesh->setAutoBuildEdgeLists(false);
cloned_mesh_name_ = mesh->getName();
}
catch (Ogre::Exception& e)
{
LogError("Could not clone mesh " + mesh_name + ":" + std::string(e.what()));
return 0;
}
}
if (mesh->hasSkeleton())
{
Ogre::SkeletonPtr skeleton = Ogre::SkeletonManager::getSingleton().getByName(mesh->getSkeletonName());
if (skeleton.isNull() || skeleton->getNumBones() == 0)
{
LogDebug("Mesh " + mesh_name + " has a skeleton with 0 bones. Disabling the skeleton.");
mesh->setSkeletonName("");
}
}
return mesh.get();
}
示例3:
Ogre::Skeleton *ESKOgre::createOgreSkeleton(Ogre::SceneManager *mSceneMgr) {
Ogre::SkeletonPtr mSkel = Ogre::SkeletonManager::getSingleton().create(name, XENOVIEWER_RESOURCE_GROUP, true);
if (bones.size()) {
buildBone(0, mSkel.getPointer(), NULL);
}
resources_created = true;
createFakeEntity(mSceneMgr);
skeleton = mSkel.getPointer();
return mSkel.getPointer();
}
示例4: file_s
void
BcxFile::GetSkeleton( std::vector< s16 >& skeleton_length )
{
u32 offset_to_model_info = GetU32LE(0x04);
u8 number_of_bones = GetU8(offset_to_model_info + 0x02);
u16 offset_to_bones = GetU16LE(offset_to_model_info + 0x1C);
SkeletonFile file_s(this);
Ogre::SkeletonPtr skeleton;
skeleton.setNull();
file_s.GetData( skeleton_length, offset_to_bones, number_of_bones, skeleton);
}
示例5:
gkSkeletonLoader::gkSkeletonLoader(gkSkeletonResource* skel)
: m_skeleton(skel)
{
Ogre::SkeletonManager& mgr = Ogre::SkeletonManager::getSingleton();
const gkString& name = m_skeleton->getResourceName().getName();
Ogre::SkeletonPtr oskel = mgr.getByName(name);
if (oskel.isNull())
oskel = mgr.create(name, skel->getGroupName(), true, this); //GK_BUILTIN_GROUP
}
示例6: loadSkeletonWork
void ResourceLoader::loadSkeletonWork(const String& name, Mesh::MeshdataPtr mesh, const std::set<String>& animationList, LoadedCallback cb) {
Ogre::SkeletonManager& skel_mgr = Ogre::SkeletonManager::getSingleton();
Ogre::SkeletonPtr skel = skel_mgr.getByName(name);
if (skel.isNull()) {
Ogre::ManualResourceLoader *reload;
Ogre::SkeletonPtr skel = Ogre::SkeletonPtr(skel_mgr.create(name,Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true,
(reload=new ManualSkeletonLoader(mesh, animationList))));
reload->prepareResource(&*skel);
reload->loadResource(&*skel);
}
cb();
}
示例7: loadCorrelativeResource
Ogre::MeshPtr
loadMesh(const Ogre::String& meshName, const Ogre::String& groupName,
const Ogre::String& baseResourceName, const Ogre::String& baseGroupName)
{
// Load the mesh
Ogre::MeshPtr mesh = loadCorrelativeResource(
meshName, groupName,
baseResourceName, baseGroupName,
Ogre::MeshManager::getSingleton());
if (mesh.isNull())
{
OGRE_EXCEPT(Ogre::Exception::ERR_ITEM_NOT_FOUND,
"Unable to load mesh " + meshName,
"loadMesh");
}
// Try to resolve skeleton resource
if (mesh->hasSkeleton() && mesh->getSkeleton().isNull())
{
// resolve correlative with mesh
Ogre::SkeletonPtr skeleton = loadCorrelativeResource(
mesh->getSkeletonName(), groupName,
mesh->getName(), mesh->getGroup(),
Ogre::SkeletonManager::getSingleton());
if (skeleton.isNull())
{
// resolve correlative with base resource
skeleton = loadCorrelativeResource(
mesh->getSkeletonName(), groupName,
baseResourceName, baseGroupName,
Ogre::SkeletonManager::getSingleton());
}
if (skeleton.isNull())
{
OGRE_EXCEPT(Ogre::Exception::ERR_ITEM_NOT_FOUND,
"Unable to load skeleton " + mesh->getSkeletonName() +
" for mesh " + mesh->getName(),
"loadMesh");
}
// Set to the actual name
mesh->setSkeletonName(skeleton->getName());
}
return mesh;
}
示例8: material_base_name
//---------------------------------------------------------------------
void
PFile::addGroups( Ogre::Mesh *mesh, const String &bone_name
,const RSDFilePtr &rsd ) const
{
const Ogre::SkeletonPtr skeleton( mesh->getSkeleton() );
const String material_base_name( rsd->getMaterialBaseName() );
String rsd_base;
StringUtil::splitBase( rsd->getName(), rsd_base );
ManualObject mo( mesh );
for( size_t g(0); g < m_groups.size(); ++g )
{
const String sub_name( bone_name + "/" + rsd_base + "/" + Ogre::StringConverter::toString(g) );
addGroup( m_groups[g], mo, sub_name, material_base_name, skeleton->getBone( bone_name ) );
}
}
示例9: GetLocalSkeleton
Ogre::SkeletonPtr GetLocalSkeleton(const std::string& name)
{
Ogre::SkeletonManager& manager = Ogre::SkeletonManager::getSingleton();
Ogre::SkeletonPtr skel = manager.getByName(name);
if (skel.isNull())
{
try
{
manager.load(name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
skel = manager.getByName(name);
}
catch(...) {}
}
return skel;
}
示例10:
const std::string& EC_Mesh::GetSkeletonName() const
{
static std::string empty_name;
if (!entity_)
return empty_name;
else
{
Ogre::MeshPtr mesh = entity_->getMesh();
if (!mesh->hasSkeleton())
return empty_name;
Ogre::SkeletonPtr skel = mesh->getSkeleton();
if (skel.isNull())
return empty_name;
return skel->getName();
}
}
示例11: length
//-------------------------------------------------------------------------
void
AFile::addTo( Ogre::SkeletonPtr skeleton, const String& name ) const
{
if( skeleton->hasAnimation( name) ) return;
Ogre::Real length( ( m_frames.size() - 1 ) * FRAME_DURATION );
Ogre::Animation *anim( skeleton->createAnimation(name, length ));
uint16 track_handle( 0 );
Ogre::Bone* bone( skeleton->getBone( "root" ) );
Ogre::NodeAnimationTrack* track;
track = anim->createNodeTrack( track_handle++, bone );
Ogre::Real time;
size_t index( 0 );
for( FrameList::const_iterator frame( m_frames.begin())
;frame != m_frames.end(); ++frame )
{
time = (index++) * FRAME_DURATION;
Ogre::TransformKeyFrame* key_frame( track->createNodeKeyFrame( time ) );
key_frame->setTranslate( frame->root_translation );
setFrameRotation( key_frame, frame->root_rotation );
}
for( uint32 i(0); i < m_bone_count; ++i )
{
if (i + 1 >= skeleton->getNumBones())
{
// TODO: Figure out why this happens/fix it
LOG_ERROR("Bone " + std::to_string(i + 1) + " is out of bounds " + std::to_string(skeleton->getNumBones()) + " for: " + name + " in: " + skeleton->getName());
}
else
{
bone = skeleton->getBone(i + 1);
track = anim->createNodeTrack(track_handle++, bone);
time = 0;
for (FrameList::const_iterator frame(m_frames.begin())
; frame != m_frames.end(); ++frame)
{
const Ogre::Vector3& rot(frame->bone_rotations[i]);
Ogre::TransformKeyFrame* key_frame(track->createNodeKeyFrame(time));
setFrameRotation(key_frame, rot);
time += FRAME_DURATION;
}
}
}
}
示例12: OnSkeletonAssetLoaded
void EC_Mesh::OnSkeletonAssetLoaded(AssetPtr asset)
{
OgreSkeletonAsset *skeletonAsset = dynamic_cast<OgreSkeletonAsset*>(asset.get());
if (!skeletonAsset)
{
LogError("OnSkeletonAssetLoaded: Skeleton asset load finished for asset \"" +
asset->Name().toStdString() + "\", but downloaded asset was not of type OgreSkeletonAsset!");
return;
}
Ogre::SkeletonPtr skeleton = skeletonAsset->ogreSkeleton;
if (skeleton.isNull())
{
LogError("OnSkeletonAssetLoaded: Skeleton asset load finished for asset \"" +
asset->Name().toStdString() + "\", but Ogre::Skeleton pointer was null!");
return;
}
if(!entity_)
{
LogDebug("Could not set skeleton yet because entity is not yet created");
return;
}
try
{
// If old skeleton is same as a new one no need to replace it.
if (entity_->getSkeleton() && entity_->getSkeleton()->getName() == skeleton->getName())
return;
entity_->getMesh()->_notifySkeleton(skeleton);
// LogDebug("Set skeleton " + skeleton->getName() + " to mesh " + entity_->getName());
emit SkeletonChanged(QString::fromStdString(skeleton->getName()));
}
catch (...)
{
LogError("Exception while setting skeleton to mesh" + entity_->getName());
}
// Now we have to recreate the entity to get proper animations etc.
SetMesh(entity_->getMesh()->getName().c_str(), false);
}
示例13:
void CMonster3D::setupSkeleton(std::string skeletonFile)
{
Ogre::SkeletonPtr pSkeletonBody = Ogre::SkeletonManager::getSingleton().getByName(m_meshName + ".skeleton");
Ogre::Skeleton::BoneHandleMap boneHandleMap;
Ogre::SkeletonPtr pNewSkeleton = Ogre::SkeletonManager::getSingleton().load(skeletonFile, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::Animation *pSrcAnimation = pNewSkeleton->getAnimation(0);
std::string newAnimationName = pSrcAnimation->getName() + "::" + m_pMonsterNode->getName();
Ogre::Animation *pNewAnimation = pNewSkeleton->createAnimation(newAnimationName, pSrcAnimation->getLength());
Ogre::Animation *pCloneAnimation = pNewSkeleton->getAnimation(0)->clone(newAnimationName);
*pNewAnimation = *pCloneAnimation;
pNewSkeleton->removeAnimation(pSrcAnimation->getName());
pNewSkeleton->_buildMapBoneByHandle(pNewSkeleton.getPointer(), boneHandleMap);
pSkeletonBody->_mergeSkeletonAnimations(pNewSkeleton.getPointer(), boneHandleMap);
Ogre::SkeletonManager::getSingleton().remove(skeletonFile);
m_pBodyEntity->getSkeleton()->_refreshAnimationState(m_pBodyEntity->getAllAnimationStates());
}
示例14: move
std::vector<std::wstring> ManipulatorEffect::GetLocatorNames() const
{
Ogre::Entity* ent = ManipulatorSystem.GetObject().GetSelection();
assert(ent);
std::vector<std::wstring> ret;
//M3模型从max导出时locator命名为Ref_xxx形式
Ogre::SkeletonPtr skel = ent->getMesh()->getSkeleton();
Ogre::Skeleton::BoneIterator iter = skel->getBoneIterator();
while (iter.hasMoreElements())
{
Ogre::Bone* pBone = iter.peekNext();
if(pBone->getName().find("Ref_") != Ogre::String::npos)
ret.push_back(Utility::EngineToUnicode(pBone->getName()));
iter.getNext();
}
return std::move(ret);
}
示例15: file
void
AnimationFile::GetData( std::vector< s16 >& skeleton_length, const Unit& unit, const int offset_to_animations, const int number_of_animation, const int start_animation, Ogre::SkeletonPtr skeleton)
{
for (int i = 0; i < number_of_animation; ++i)
{
/*LOGGER->Log(LOGGER_INFO, "Animation Header %02x%02x %02x %02x %02x %02x %02x%02x %02x%02x %02x%02x %02x%02x%02x%02x",
GetU8(offset_to_animations + i * 0x10 + 0x00), GetU8(offset_to_animations + i * 0x10 + 0x01), GetU8(offset_to_animations + i * 0x10 + 0x02), GetU8(offset_to_animations + i * 0x10 + 0x03),
GetU8(offset_to_animations + i * 0x10 + 0x04), GetU8(offset_to_animations + i * 0x10 + 0x05), GetU8(offset_to_animations + i * 0x10 + 0x06), GetU8(offset_to_animations + i * 0x10 + 0x07),
GetU8(offset_to_animations + i * 0x10 + 0x08), GetU8(offset_to_animations + i * 0x10 + 0x09), GetU8(offset_to_animations + i * 0x10 + 0x0A), GetU8(offset_to_animations + i * 0x10 + 0x0B),
GetU8(offset_to_animations + i * 0x10 + 0x0C), GetU8(offset_to_animations + i * 0x10 + 0x0D), GetU8(offset_to_animations + i * 0x10 + 0x0E), GetU8(offset_to_animations + i * 0x10 + 0x0F));
*/
AnimationHeader header;
header.number_of_frames = GetU16LE(offset_to_animations + i * 0x10 + 0x00);
header.number_of_bones = GetU8(offset_to_animations + i * 0x10 + 0x02);
header.number_of_frames_translation = GetU8(offset_to_animations + i * 0x10 + 0x03);
header.number_of_static_translation = GetU8(offset_to_animations + i * 0x10 + 0x04);
header.number_of_frames_rotation = GetU8(offset_to_animations + i * 0x10 + 0x05);
header.offset_to_frames_translation_data = GetU16LE(offset_to_animations + i * 0x10 + 0x06);
header.offset_to_static_translation_data = GetU16LE(offset_to_animations + i * 0x10 + 0x08);
header.offset_to_frames_rotation_data = GetU16LE(offset_to_animations + i * 0x10 + 0x0A);
header.offset_to_animation_data = GetU32LE(offset_to_animations + i * 0x10 + 0x0C) - 0x80000000;
m_AnimationHeaders.push_back(header);
}
for (size_t i = 0; (i < static_cast<size_t>(number_of_animation)) && (start_animation + i < unit.animations.size()); ++i)
{
if (unit.animations[start_animation + i] == "" || unit.animations[start_animation + i] == " ")
{
continue;
}
/*
File file(mpBuffer, m_AnimationHeaders[i].offset_to_animation_data, 0x04 + m_AnimationHeaders[i].number_of_bones * 0x08 + m_AnimationHeaders[i].number_of_frames_translation * m_AnimationHeaders[i].number_of_frames * 0x02 + m_AnimationHeaders[i].number_of_static_translation * 0x02 + m_AnimationHeaders[i].number_of_frames_rotation * m_AnimationHeaders[i].number_of_frames);
file.WriteFile(RString((Ogre::String("dump/") + Ogre::String("animation_") + Ogre::StringConverter::toString(i) + Ogre::String("_data")).c_str()));
*/
Ogre::Animation* anim = skeleton->createAnimation(unit.animations[start_animation + i], (float)(m_AnimationHeaders[i].number_of_frames - 1) / 30.0f);
for (u32 j = 0; j < m_AnimationHeaders[i].number_of_frames; ++j)
{
Frame frame;
// root bone
Ogre::Bone* root = skeleton->getBone(0);
Ogre::NodeAnimationTrack* track;
if (j == 0)
{
track = anim->createNodeTrack(0, root);
track->removeAllKeyFrames();
}
else
{
track = anim->getNodeTrack(0);
}
Ogre::TransformKeyFrame* frame_root = track->createNodeKeyFrame((float)j / 30.0f);
Ogre::Quaternion rot;
Ogre::Matrix3 mat;
mat.FromEulerAnglesZXY(Ogre::Radian(Ogre::Degree(180)), Ogre::Radian(Ogre::Degree(0)), Ogre::Radian(Ogre::Degree(0)));
rot.FromRotationMatrix(mat);
frame_root->setRotation(rot);
for (u32 k = 0; k < m_AnimationHeaders[i].number_of_bones; ++k)
{
BonePosition position;
u8 flag = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x00);
u8 rx = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x01);
u8 ry = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x02);
u8 rz = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x03);
u8 tx = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x04);
u8 ty = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x05);
u8 tz = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x06);
// rotation
if (flag & 0x01)
{
position.rotation_x = 360.0f * GetU8(m_AnimationHeaders[i].offset_to_animation_data + m_AnimationHeaders[i].offset_to_frames_rotation_data + rx * m_AnimationHeaders[i].number_of_frames + j) / 255.0f;
}
else
{
position.rotation_x = 360.0f * rx / 255.0f;
}
if (flag & 0x02)
{
position.rotation_y = 360.0f * GetU8(m_AnimationHeaders[i].offset_to_animation_data + m_AnimationHeaders[i].offset_to_frames_rotation_data + ry * m_AnimationHeaders[i].number_of_frames + j) / 255.0f;
}
else
{
position.rotation_y = 360.0f * ry / 255.0f;
}
if (flag & 0x04)
{
position.rotation_z = 360.0f * GetU8(m_AnimationHeaders[i].offset_to_animation_data + m_AnimationHeaders[i].offset_to_frames_rotation_data + rz * m_AnimationHeaders[i].number_of_frames + j) / 255.0f;
}
//.........这里部分代码省略.........