本文整理汇总了C++中ogre::MeshPtr::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshPtr::isNull方法的具体用法?C++ MeshPtr::isNull怎么用?C++ MeshPtr::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::MeshPtr
的用法示例。
在下文中一共展示了MeshPtr::isNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: MeshShape
MeshShape* MeshShape::GetMeshShape (Ogre::Entity* pEntity) {
if (!pEntity) return 0;
Ogre::MeshPtr pMesh = pEntity->getMesh();
assert(!pMesh.isNull() && "entity has no mesh");
if (pMesh.isNull()) return 0;
// look in cache
MeshShape*& pShape = gMeshShapeCache[pMesh->getName()];
if (pShape) { pShape->Update(pEntity); return pShape; }
// register new shape
pShape = new MeshShape(pMesh);
pShape->Update(pEntity);
return pShape;
}
示例3: getMesh
Ogre::MeshPtr RaduisControlet::getMesh()
{
Ogre::MeshPtr mesh;
mesh = Ogre::MeshManager::getSingleton().getByName( "RaduisControletRing" );
if( !mesh.isNull() ){
//先删除在重新建立
return mesh;
}
Geometry::tPath path;
//构造构造一个圆环
for( int i = 0;i < Geometry::DEFAULT_DENSITY;++i ){
Ogre::Real d = (Ogre::Real)((i*2.0f*Ogre::Math::PI)/(Geometry::DEFAULT_DENSITY-1));
path.push_back(
Ogre::Vector3(
mScale*sinf(d)+mRaduis,
0,
mScale*cosf(d))
);
}
mesh = Geometry::getSingleton().createSpin("RaduisControletRing",path );
return mesh;
}
示例4: 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();
}
示例5: LoadModel
Ogre::MeshPtr CMapLoader::LoadModel(const char * path)
{
MapResource<Ogre::MeshPtr> res;
Ogre::MeshPtr pMesh;
// Check if this model was already loaded
pMesh = Ogre::MeshManager::getSingleton().getByName(path);
if(!pMesh.isNull())
return pMesh;
sectionitem_t * item = LoadItem(path, &res.map);
if(item == NULL)
return Ogre::MeshPtr(NULL);
pMesh = Ogre::MeshManager::getSingleton().createManual(path,
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::DataStreamPtr stream(new Ogre::MemoryDataStream(item->data, item->size, false, true));
Ogre::MeshSerializer serializer;
serializer.importMesh(stream, pMesh.getPointer());
// No need to keep this in memory
mapUnloadItem(item);
// Track this resource
res.data = pMesh;
meshes.push_back(res);
return pMesh;
}
示例6: reload
void gkMesh::reload()
{
Ogre::MeshManager& mgr = Ogre::MeshManager::getSingleton();
const gkString& name = getResourceName().getName();
Ogre::MeshPtr omesh = mgr.getByName(name);
if (!omesh.isNull())
omesh.getPointer()->reload();
}
示例7: getTrianglesFromMesh
/* Creates a list of triangles and allocating all the vertexs from a mesh
* Requires:
* @cont The Vertex container where it will been put the vertexs
* @mesh The mesh to extract the triangles
* @triangles The list to be filled with the triangles
* Returns:
* true on success
* false otherwise
*/
bool Util::getTrianglesFromMesh(PolyStructsContainer<sm::Vertex *> &cont,
PolyStructsContainer<Triangle *> &triangles,
Ogre::MeshPtr mesh)
{
ASSERT(!mesh.isNull());
if(!cont.isEmpty()){
debug("Warning: Not an empty container\n");
}
if(!triangles.isEmpty()){
debug("Warning, triangles is not empty\n");
ASSERT(false);
}
size_t vertex_count,index_count;
Ogre::Vector3* vertices = 0;
long unsigned* indices = 0;
getMeshInformation(mesh.get(),vertex_count,vertices,index_count,indices);
// TODO: hacer esta funcion mas rapida, estamos buscando para cada vector
// el vertice asociado. Es lento
// here we will map Ogre::Vector3[i] -> Vertex*
std::vector<sm::Vertex *> vertexMap;
vertexMap.resize(vertex_count);
// fills the map of vertexs
sm::Vertex *v = 0;
for(size_t i = 0; i < vertex_count; ++i){
v = findVertex(cont.getObjs(), vertices[i]);
if(!v){
// create a new vertex and put it in the container
v = new sm::Vertex(vertices[i].x, vertices[i].z);
cont.addObj(v);
}
// associate the vec to the vertex
vertexMap[i] = v;
}
// now we have to create the triangles
for(size_t i = 0; i < index_count; i += 3){
triangles.addObj(new Triangle(vertexMap[indices[i]],
vertexMap[indices[i+1]],
vertexMap[indices[i+2]]));
}
delete []vertices;
delete []indices;
return true;
}
示例8: 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;
}
示例9: updateBounds
void gkMesh::updateBounds()
{
m_boundsInit = false;
getBoundingBox();
// update ogre-bounds
Ogre::MeshManager& mgr = Ogre::MeshManager::getSingleton();
const gkString& name = getResourceName().getName();
Ogre::MeshPtr omesh = mgr.getByName(name);
if (!omesh.isNull()){
omesh.getPointer()->_setBounds(m_bounds, false);
omesh.getPointer()->_setBoundingSphereRadius(m_bounds.getSize().squaredLength());
}
}
示例10: GetLocalMesh
Ogre::MeshPtr GetLocalMesh(const std::string& name)
{
Ogre::MeshManager& manager = Ogre::MeshManager::getSingleton();
Ogre::MeshPtr mesh = manager.getByName(name);
if (mesh.isNull())
{
try
{
manager.load(name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
mesh = manager.getByName(name);
}
catch(...) {}
}
return mesh;
}
示例11: MakeUnLoadedLocked
// Call for an unload when list is already locked
void OLMeshTracker::MakeUnLoadedLocked(Ogre::String meshName, Ogre::String stringParam, Ogre::Entity* entityParam) {
// see if in the loading list. Remove if there.
GenericQm* loadEntry = m_meshesToLoad->Find(meshName);
if (loadEntry != NULL) {
loadEntry->Abort();
m_meshesToLoad->Remove(meshName);
}
// see if in the serialize list. Mark for unload if it's there
GenericQm* serialEntry = m_meshesToSerialize->Find(meshName);
if (serialEntry != NULL) {
serialEntry->stringParam = "unload";
}
else {
Ogre::MeshPtr meshP = Ogre::MeshManager::getSingleton().getByName(meshName);
if (!meshP.isNull()) {
if (meshP.useCount() == 1) {
meshP->unload();
}
else {
LG::Log("OLMeshTracker::MakeUnLoaded: Didn't unload mesh because count = %d", meshP.useCount());
}
}
}
}
示例12: 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) {
//.........这里部分代码省略.........
示例13: UpdateSceneNodesForMesh
// ===============================================================================
// We updated a mesh. Now we have to find all the scene nodes that use this mesh
// and tell them something changed.
void OLMeshTracker::UpdateSceneNodesForMesh(Ogre::String meshName) {
Ogre::MeshPtr meshP = (Ogre::MeshPtr)Ogre::MeshManager::getSingleton().getByName(meshName);
if (!meshP.isNull()) {
UpdateSceneNodesForMesh(meshP);
}
}
示例14: DoReload
// ===============================================================================
// Reload the mesh if we should
// This is usually called when a resource needs to be refreshed
void OLMeshTracker::DoReload(Ogre::String meshName) {
Ogre::MeshPtr meshP = (Ogre::MeshPtr)Ogre::MeshManager::getSingleton().getByName(meshName);
if (!meshP.isNull()) {
DoReload(meshP);
}
}
示例15: Data_Wrap_Struct
VALUE wrap< Ogre::MeshPtr >(const Ogre::MeshPtr &mesh )
{
if(mesh.isNull())
return Qnil;
return Data_Wrap_Struct(rb_cOgreMesh, NULL, free, new Ogre::MeshPtr(mesh));
}