本文整理汇总了C++中ogre::MeshPtr::isPrepared方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshPtr::isPrepared方法的具体用法?C++ MeshPtr::isPrepared怎么用?C++ MeshPtr::isPrepared使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::MeshPtr
的用法示例。
在下文中一共展示了MeshPtr::isPrepared方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: poll
bool ModelBackgroundLoader::poll(const TimeFrame& timeFrame)
{
#if OGRE_THREAD_SUPPORT
if (mState == LS_UNINITIALIZED) {
//Start to load the meshes
for (SubModelDefinitionsStore::const_iterator I_subModels = mModel.getDefinition()->getSubModelDefinitions().begin(); I_subModels != mModel.getDefinition()->getSubModelDefinitions().end(); ++I_subModels) {
Ogre::MeshPtr meshPtr = static_cast<Ogre::MeshPtr> (Ogre::MeshManager::getSingleton().getByName((*I_subModels)->getMeshName()));
if (meshPtr.isNull() || !meshPtr->isPrepared()) {
try {
Ogre::BackgroundProcessTicket ticket = Ogre::ResourceBackgroundQueue::getSingleton().prepare(Ogre::MeshManager::getSingleton().getResourceType(), (*I_subModels)->getMeshName(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, false, 0, 0, createListener());
if (ticket) {
addTicket(ticket);
}
} catch (const std::exception& ex) {
S_LOG_FAILURE("Could not load the mesh " << (*I_subModels)->getMeshName() << " when loading model " << mModel.getName() << "." << ex);
continue;
}
}
}
mState = LS_MESH_PREPARING;
return poll(timeFrame);
} else if (mState == LS_MESH_PREPARING) {
if (areAllTicketsProcessed()) {
mState = LS_MESH_PREPARED;
return poll(timeFrame);
}
} else if (mState == LS_MESH_PREPARED) {
for (SubModelDefinitionsStore::const_iterator I_subModels = mModel.getDefinition()->getSubModelDefinitions().begin(); I_subModels != mModel.getDefinition()->getSubModelDefinitions().end(); ++I_subModels) {
Ogre::MeshPtr meshPtr = static_cast<Ogre::MeshPtr> (Ogre::MeshManager::getSingleton().getByName((*I_subModels)->getMeshName()));
if (!meshPtr.isNull()) {
if (!meshPtr->isLoaded()) {
#if OGRE_THREAD_SUPPORT == 1
Ogre::BackgroundProcessTicket ticket = Ogre::ResourceBackgroundQueue::getSingleton().load(Ogre::MeshManager::getSingleton().getResourceType(), meshPtr->getName(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, false, 0, 0, createListener());
if (ticket) {
// meshPtr->setBackgroundLoaded(true);
addTicket(ticket);
}
#else
if (!timeFrame.isTimeLeft()) {
return false;
}
try {
meshPtr->load();
} catch (const std::exception& ex) {
S_LOG_FAILURE("Could not load the mesh " << meshPtr->getName() << " when loading model " << mModel.getName() << "." << ex);
continue;
}
#endif
}
}
}
mState = LS_MESH_LOADING;
return poll(timeFrame);
} else if (mState == LS_MESH_LOADING) {
if (areAllTicketsProcessed()) {
mState = LS_MESH_LOADED;
return poll(timeFrame);
}
} else if (mState == LS_MESH_LOADED) {
for (SubModelDefinitionsStore::const_iterator I_subModels = mModel.getDefinition()->getSubModelDefinitions().begin(); I_subModels != mModel.getDefinition()->getSubModelDefinitions().end(); ++I_subModels) {
Ogre::MeshPtr meshPtr = static_cast<Ogre::MeshPtr> (Ogre::MeshManager::getSingleton().getByName((*I_subModels)->getMeshName()));
if (!meshPtr.isNull()) {
if (meshPtr->isLoaded()) {
Ogre::Mesh::SubMeshIterator subMeshI = meshPtr->getSubMeshIterator();
while (subMeshI.hasMoreElements()) {
Ogre::SubMesh* submesh(subMeshI.getNext());
Ogre::MaterialPtr materialPtr = static_cast<Ogre::MaterialPtr> (Ogre::MaterialManager::getSingleton().getByName(submesh->getMaterialName()));
if (materialPtr.isNull() || !materialPtr->isPrepared()) {
// S_LOG_VERBOSE("Preparing material " << materialPtr->getName());
Ogre::BackgroundProcessTicket ticket = Ogre::ResourceBackgroundQueue::getSingleton().prepare(Ogre::MaterialManager::getSingleton().getResourceType(),submesh->getMaterialName(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, false, 0, 0, createListener());
if (ticket) {
addTicket(ticket);
}
}
}
}
}
for (PartDefinitionsStore::const_iterator I_parts = (*I_subModels)->getPartDefinitions().begin(); I_parts != (*I_subModels)->getPartDefinitions().end(); ++I_parts) {
if ((*I_parts)->getSubEntityDefinitions().size() > 0) {
for (SubEntityDefinitionsStore::const_iterator I_subEntities = (*I_parts)->getSubEntityDefinitions().begin(); I_subEntities != (*I_parts)->getSubEntityDefinitions().end(); ++I_subEntities) {
const std::string& materialName = (*I_subEntities)->getMaterialName();
if (materialName != "") {
Ogre::MaterialPtr materialPtr = static_cast<Ogre::MaterialPtr> (Ogre::MaterialManager::getSingleton().getByName(materialName));
if (materialPtr.isNull() || !materialPtr->isPrepared()) {
// S_LOG_VERBOSE("Preparing material " << materialName);
Ogre::BackgroundProcessTicket ticket = Ogre::ResourceBackgroundQueue::getSingleton().prepare(Ogre::MaterialManager::getSingleton().getResourceType(), materialName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, false, 0, 0, createListener());
if (ticket) {
addTicket(ticket);
}
}
}
}
}
}
}
mState = LS_MATERIAL_PREPARING;
return poll(timeFrame);
} else if (mState == LS_MATERIAL_PREPARING) {
//.........这里部分代码省略.........