本文整理汇总了C++中ogre::SkeletonPtr::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ SkeletonPtr::isNull方法的具体用法?C++ SkeletonPtr::isNull怎么用?C++ SkeletonPtr::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::SkeletonPtr
的用法示例。
在下文中一共展示了SkeletonPtr::isNull方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例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: 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();
}
示例4:
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
}
示例5: 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();
}
示例6:
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();
}
}
示例7: 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;
}
示例8: 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);
}
示例9: 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;
}
示例10: doExportMesh
//.........这里部分代码省略.........
// Vertex normals
// For the moment, ignore any discrepancies per vertex
msTriangleEx_GetNormal(pTriangleEx, k, &Normal[0]);
msTriangleEx_GetTexCoord(pTriangleEx, k, &uv[0]);
pTex[(vertIdx*2)]=uv[0];
pTex[(vertIdx*2)+1]=uv[1];
pNorm[(vertIdx*3)] = Normal[0];
pNorm[(vertIdx*3)+1] = Normal[1];
pNorm[(vertIdx*3)+2] = Normal[2];
}
} // Faces
nbuf->unlock();
ibuf->unlock();
tbuf->unlock();
// Now use Ogre's ability to reorganise the vertex buffers the best way
Ogre::VertexDeclaration* newDecl =
ogreSubMesh->vertexData->vertexDeclaration->getAutoOrganisedDeclaration(
foundBoneAssignment, false);
Ogre::BufferUsageList bufferUsages;
for (size_t u = 0; u <= newDecl->getMaxSource(); ++u)
bufferUsages.push_back(Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
ogreSubMesh->vertexData->reorganiseBuffers(newDecl, bufferUsages);
logMgr.logMessage("Geometry done.");
} // SubMesh
// Set bounds
ogreMesh->_setBoundingSphereRadius(Ogre::Math::Sqrt(maxSquaredRadius));
ogreMesh->_setBounds(Ogre::AxisAlignedBox(min, max), false);
// Keep hold of a Skeleton pointer for deletion later
// Mesh uses Skeleton pointer for skeleton name
Ogre::SkeletonPtr pSkel;
if (exportSkeleton && foundBoneAssignment)
{
// export skeleton, also update mesh to point to it
pSkel = doExportSkeleton(pModel, ogreMesh);
}
else if (!exportSkeleton && foundBoneAssignment)
{
// We've found bone assignments, but skeleton is not to be exported
// Prompt the user to find the skeleton
if (!locateSkeleton(ogreMesh))
return;
}
// Export
logMgr.logMessage("Creating MeshSerializer..");
Ogre::MeshSerializer serializer;
logMgr.logMessage("MeshSerializer created.");
// Generate LODs if required
if (generateLods)
{
// Build LOD depth list
Ogre::Mesh::LodDistanceList distList;
float depth = 0;
for (unsigned short depthidx = 0; depthidx < numLods; ++depthidx)
{
depth += lodDepthIncrement;
distList.push_back(depth);
}
ogreMesh->generateLodLevels(distList, lodReductionMethod, lodReductionAmount);
}
if (generateEdgeLists)
{
ogreMesh->buildEdgeList();
}
if (generateTangents)
{
unsigned short src, dest;
ogreMesh->suggestTangentVectorBuildParams(tangentSemantic, src, dest);
ogreMesh->buildTangentVectors(tangentSemantic, src, dest, tangentsSplitMirrored, tangentsSplitRotated, tangentsUseParity);
}
// Export
Ogre::String msg;
msg = "Exporting mesh data to file '" + Ogre::String(szFile) + "'";
logMgr.logMessage(msg);
serializer.exportMesh(ogreMesh.getPointer(), szFile);
logMgr.logMessage("Export successful");
Ogre::MeshManager::getSingleton().remove(ogreMesh->getHandle());
if (!pSkel.isNull())
Ogre::SkeletonManager::getSingleton().remove(pSkel->getHandle());
if (exportMaterials && msModel_GetMaterialCount(pModel) > 0)
{
doExportMaterials(pModel);
}
}