Example #1
0
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();
}
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;
}
Example #3
0
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;
}
Example #4
0
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();
}
Example #5
0
Ogre::MeshPtr LinearControlet::getMesh(){
	Ogre::MeshPtr mesh;
	
	mesh = Ogre::MeshManager::getSingleton().getByName( "LinearControletArrow" );

	if( !mesh.isNull() ){
		//先删除在重新建立
		return mesh;
	}

	Geometry::tPath path;
	//构造一个箭头
	path.push_back( Ogre::Vector3(0,0,1) );
	path.push_back( Ogre::Vector3(0.4f,0,0.4f) );
	path.push_back( Ogre::Vector3(0.2f,0,0.4f) );
	path.push_back( Ogre::Vector3(0.2f,0,0) );
	path.push_back( Ogre::Vector3(0,0,0) );
	for( int i = 0;i < (int)path.size();++i ){
		path[i] *= mScale;
		path[i].z += mScale/2;
	}
	mesh = Geometry::getSingleton().createSpin("LinearControletArrow",path );

	return mesh;
}
Example #6
0
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;
}
Example #7
0
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();
}
Example #8
0
/* 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;
}
Example #9
0
Ogre::MeshPtr OrientationControlet::getMesh(){
	Ogre::MeshPtr mesh;
	
	mesh = Ogre::MeshManager::getSingleton().getByName( "OrientationControletSphere" );

	if( !mesh.isNull() ){
		//先删除在重新建立
		return mesh;
	}

	mesh = Geometry::getSingleton().createSphere("OrientationControletSphere",mScale );

	return mesh;
}
Example #10
0
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;
}
Example #11
0
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());
	}
}
Example #12
0
 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;
 }
// 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());
			}
		}
	}
}
Example #14
0
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) {
		if (areAllTicketsProcessed()) {
			mState = LS_MATERIAL_PREPARED;
			return poll(timeFrame);
		}
	} else if (mState == LS_MATERIAL_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()));
			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->isLoaded()) {

#if OGRE_THREAD_SUPPORT == 1
					Ogre::BackgroundProcessTicket ticket = Ogre::ResourceBackgroundQueue::getSingleton().load(Ogre::MaterialManager::getSingleton().getResourceType(), materialPtr->getName(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, false, 0, 0, createListener());
					if (ticket) {
						//						materialPtr->setBackgroundLoaded(true);
						addTicket(ticket);
					}
#else
					Ogre::Material::TechniqueIterator techIter = materialPtr->getSupportedTechniqueIterator();
					while (techIter.hasMoreElements()) {
						Ogre::Technique* tech = techIter.getNext();
						Ogre::Technique::PassIterator passIter = tech->getPassIterator();
						while (passIter.hasMoreElements()) {
							Ogre::Pass* pass = passIter.getNext();
							Ogre::Pass::TextureUnitStateIterator tusIter = pass->getTextureUnitStateIterator();
							while (tusIter.hasMoreElements()) {
								Ogre::TextureUnitState* tus = tusIter.getNext();
								unsigned int frames = tus->getNumFrames();
								for (unsigned int i = 0; i < frames; ++i) {
									if (!timeFrame.isTimeLeft()) {
										return false;
									}
									//This will automatically load the texture.
//									S_LOG_VERBOSE("Loading texture " << tus->getTextureName());
									Ogre::TexturePtr texturePtr = tus->_getTexturePtr(i);
								}
							}
						}
					}
					if (!timeFrame.isTimeLeft()) {
						return false;
					}
//					S_LOG_VERBOSE("Loading material " << materialPtr->getName());
					materialPtr->load();
#endif

				}
			}
			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->isLoaded()) {
#if OGRE_THREAD_SUPPORT == 1
								Ogre::BackgroundProcessTicket ticket = Ogre::ResourceBackgroundQueue::getSingleton().load(Ogre::MaterialManager::getSingleton().getResourceType(), materialPtr->getName(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, false, 0, 0, createListener());
								if (ticket) {
									addTicket(ticket);
								}
#else
								Ogre::Material::TechniqueIterator techIter = materialPtr->getSupportedTechniqueIterator();
								while (techIter.hasMoreElements()) {
									Ogre::Technique* tech = techIter.getNext();
									Ogre::Technique::PassIterator passIter = tech->getPassIterator();
									while (passIter.hasMoreElements()) {
										Ogre::Pass* pass = passIter.getNext();
										Ogre::Pass::TextureUnitStateIterator tusIter = pass->getTextureUnitStateIterator();
										while (tusIter.hasMoreElements()) {
											Ogre::TextureUnitState* tus = tusIter.getNext();
											unsigned int frames = tus->getNumFrames();
											for (unsigned int i = 0; i < frames; ++i) {
												if (!timeFrame.isTimeLeft()) {
													return false;
												}
												//This will automatically load the texture.
//												S_LOG_VERBOSE("Loading texture " << tus->getTextureName());
												Ogre::TexturePtr texturePtr = tus->_getTexturePtr(i);
											}
										}
									}
								}
								if (!timeFrame.isTimeLeft()) {
									return false;
								}
//								S_LOG_VERBOSE("Loading material " << materialPtr->getName());
								materialPtr->load();
#endif
							}
						}
					}
				}
			}
		}

		mState = LS_MATERIAL_LOADING;
		return poll(timeFrame);
	} else if (mState == LS_MATERIAL_LOADING) {
		if (areAllTicketsProcessed()) {
			mState = LS_DONE;
			return true;
		}

	} else {
		return true;
	}
	return false;
#else
	//If there's no threading support, just return here.
	return true;
#endif
}
// ===============================================================================
// 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);
	}
}
// ===============================================================================
// 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);
	}
}
Example #17
0
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));
}
Example #18
0
Ogre::MeshPtr SkeletonDebug::GetBoneMesh(const Ogre::Real boneSize)
{
    Ogre::MeshPtr boneMeshPtr =
        Ogre::MeshManager::getSingleton().getByName(boneMeshName);

    if(boneMeshPtr.isNull())
    {
        Ogre::ManualObject mo("tmp");
        mo.begin(GetBoneMaterial()->getName());

        Ogre::Vector3 basepos[6] =
        {
            Ogre::Vector3(0,0,0),
            Ogre::Vector3(boneSize, boneSize*2, boneSize),
            Ogre::Vector3(-boneSize, boneSize*2, boneSize),
            Ogre::Vector3(-boneSize, boneSize*2, -boneSize),
            Ogre::Vector3(boneSize, boneSize*2, -boneSize),
            Ogre::Vector3(0, 1.0f, 0),
        };

        // Two colours so that we can distinguish the sides of the bones
        // (we don't use any lighting on the material)
        Ogre::ColourValue col = Ogre::ColourValue(0.7f, 0.7f, 0.7f, 1.0f);
        Ogre::ColourValue col1 = Ogre::ColourValue(0.8f, 0.8f, 0.8f, 1.0f);

        mo.position(basepos[0]);
        mo.colour(col);
        mo.position(basepos[2]);
        mo.colour(col);
        mo.position(basepos[1]);
        mo.colour(col);

        mo.position(basepos[0]);
        mo.colour(col1);
        mo.position(basepos[3]);
        mo.colour(col1);
        mo.position(basepos[2]);
        mo.colour(col1);

        mo.position(basepos[0]);
        mo.colour(col);
        mo.position(basepos[4]);
        mo.colour(col);
        mo.position(basepos[3]);
        mo.colour(col);

        mo.position(basepos[0]);
        mo.colour(col1);
        mo.position(basepos[1]);
        mo.colour(col1);
        mo.position(basepos[4]);
        mo.colour(col1);

        mo.position(basepos[1]);
        mo.colour(col1);
        mo.position(basepos[2]);
        mo.colour(col1);
        mo.position(basepos[5]);
        mo.colour(col1);

        mo.position(basepos[2]);
        mo.colour(col);
        mo.position(basepos[3]);
        mo.colour(col);
        mo.position(basepos[5]);
        mo.colour(col);

        mo.position(basepos[3]);
        mo.colour(col1);
        mo.position(basepos[4]);
        mo.colour(col1);
        mo.position(basepos[5]);
        mo.colour(col1);

        mo.position(basepos[4]);
        mo.colour(col);
        mo.position(basepos[1]);
        mo.colour(col);
        mo.position(basepos[5]);
        mo.colour(col);

        // indices
        mo.triangle(0, 1, 2);
        mo.triangle(3, 4, 5);
        mo.triangle(6, 7, 8);
        mo.triangle(9, 10, 11);
        mo.triangle(12, 13, 14);
        mo.triangle(15, 16, 17);
        mo.triangle(18, 19, 20);
        mo.triangle(21, 22, 23);

        mo.end();

        boneMeshPtr = mo.convertToMesh(
            boneMeshName, Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
    }

    return boneMeshPtr;
}