Esempio n. 1
0
void HDRListener::notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
	
	if(pass_id == 600 || pass_id == 800)
	{
		Ogre::Pass *pass = mat->getBestTechnique()->getPass(0);
		Ogre::GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
    
		if (params->_findNamedConstantDefinition("toneMapSettings"))
		{
			Ogre::Vector4 toneMapSettings(1-mApp->pSet->hdrParam1, mApp->pSet->hdrParam2, mApp->pSet->hdrParam3, 1.0);
			params->setNamedConstant("toneMapSettings", toneMapSettings);
		}
		if (params->_findNamedConstantDefinition("bloomSettings"))
		{
			Ogre::Vector4 bloomSettings(mApp->pSet->hdrbloomorig*2, mApp->pSet->hdrbloomint, 1.0, 1.0);
			params->setNamedConstant("bloomSettings", bloomSettings);
		}
		if (params->_findNamedConstantDefinition("vignettingSettings"))
		{
			Ogre::Vector4 vignettingSettings(mApp->pSet->vignettingRadius, mApp->pSet->vignettingDarkness, 1.0, 1.0);
			params->setNamedConstant("vignettingSettings", vignettingSettings);
		}
	
	}
	else if(pass_id == 989)
	{
		Ogre::Pass *pass = mat->getBestTechnique()->getPass(0);
		Ogre::GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
		if (params->_findNamedConstantDefinition("AdaptationScale"))
		{
			params->setNamedConstant("AdaptationScale", mApp->pSet->hdrAdaptationScale);
		}
	}
}
void EC_OgreMovableTextOverlay::SetMaterial(const std::string& new_base_material)
{
    ///\todo Make this work for other materials!
    // Clone own copy of the material for this overlay.
    Ogre::MaterialManager &mm = Ogre::MaterialManager::getSingleton();
    Ogre::MaterialPtr material = mm.getByName(new_base_material);
    if (material.get())
    {
        baseMaterialName_ = new_base_material;
        Ogre::MaterialPtr baseMaterial = mm.getByName(baseMaterialName_);
        materialName_ = renderer_.lock()->GetUniqueObjectName();
        material = baseMaterial->clone(materialName_);

        //todo Check that the the material alpha channel?
        const Ogre::LayerBlendModeEx &blend = baseMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->getAlphaBlendMode();
        if (blend.alphaArg1 > 0)
            materialHasAlpha_ = true;
        else
            materialHasAlpha_ = false;

        // Set the max alpha for the material.
        materialMaxAlpha_ = blend.alphaArg1;

        container_->setMaterialName(materialName_);
    }
    else
        OgreRenderingModule::LogError("Invalid material name!");
}
Esempio n. 3
0
void EC_Sky::CreateSky()
{
    if (!ViewEnabled())
        return;

    if (world_.expired())
        return;

    QString currentMaterial = materialRef.Get().ref;

    Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(currentMaterial.toStdString().c_str());
    //Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(framework->Asset()->LookupAssetRefToStorage(materialRef.Get().ref).toStdString().c_str());
    if (materialPtr.isNull())
    {
        LogError("Could not get SkyBox material : " + currentMaterial.toStdString());
        return;
    }

    materialPtr->setReceiveShadows(false);

    try
    {
        world_.lock()->GetSceneManager()->setSkyBox(true, currentMaterial.toStdString().c_str(), distance.Get(),
            drawFirst.Get(), orientation.Get());
    }
    catch(Ogre::Exception& e)
    {
        LogError("Could not set SkyBox: " + std::string(e.what()));
    }
}
Esempio n. 4
0
/* Loads the app */
void ImgShowerApp::load(void)
{
	Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();

	if(!mContainer){
		// Create a panel
		mContainer = static_cast<Ogre::OverlayContainer*>(
			overlayManager.createOverlayElement("Panel", "ImgShowerAppPanel"));
		mContainer->setMetricsMode(Ogre::GMM_RELATIVE);
		mContainer->setPosition(0, 0);
		mContainer->setDimensions(1, 1);
		mContainer->setMaterialName(mOverlayName); // Optional background material
		// Ensures that the material exists
#ifdef DEBUG
		Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName(
				mOverlayName,Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
		ASSERT(!mat.isNull());
#endif

	}

	if(!mOverlay){
		// Create an overlay, and add the panel
		mOverlay = overlayManager.create("ImgShowerAppOverlay");
		mOverlay->add2D(mContainer);
		mOverlay->show();
	}

	// extracted from http://www.ogre3d.org/tikiwiki/Creating+Overlays+via+Code

}
Esempio n. 5
0
StringVector EC_OgreSky::GetMaterialTextureNames()
{
    StringVector texture_names;
    Ogre::MaterialPtr skyMaterial;
    switch(type_)
    {
    case OgreRenderer::SKYTYPE_BOX:
        skyMaterial = Ogre::MaterialManager::getSingleton().getByName(skyBoxParameters.material);
        break;
    case OgreRenderer::SKYTYPE_DOME:
        skyMaterial = Ogre::MaterialManager::getSingleton().getByName(skyDomeParameters.material);
        break;
    case OgreRenderer::SKYTYPE_PLANE:
        skyMaterial = Ogre::MaterialManager::getSingleton().getByName(skyPlaneParameters.material);
        break;
    }

    if (!skyMaterial.isNull())
    {
        Ogre::TextureUnitState *texture_state = skyMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0);
        if (texture_state)
            for(uint i = 0; i < texture_state->getNumFrames(); i++)
                texture_names.push_back(texture_state->getFrameTextureName(i));
        //Ogre::String textures = texture_state->getTextureName();
        //texture_names = Ogre::StringConverter::parseStringVector(textures);
    }
    return texture_names;
}
//-------------------------------------------------------------------------------------
bool BaseApplication::setup(void)
{
    mRoot = new Ogre::Root(mPluginsCfg);

    setupResources();

    bool carryOn = configure();
    if (!carryOn) return false;

    chooseSceneManager();
    createCamera();
    createViewports();

    // Set default mipmap level (NB some APIs ignore this)
    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);


    
    // Create background material
    Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("Background", "General");
    material->getTechnique(0)->getPass(0)->createTextureUnitState("space.jpg");
    material->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
    material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
    material->getTechnique(0)->getPass(0)->setLightingEnabled(false);

    // Create background rectangle covering the whole screen
    rect = new Ogre::Rectangle2D(true);
    rect->setCorners(-1.0, 1.0, 1.0, -1.0);
    rect->setMaterial("Background");
     
    // Render the background before everything else
    rect->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND);
     
    // Use infinite AAB to always stay visible
    Ogre::AxisAlignedBox aabInf;
    aabInf.setInfinite();
    rect->setBoundingBox(aabInf);
     
    // Attach background to the scene
    Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Background");
    node->attachObject(rect);
     
    // Example of background scrolling
    material->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setScrollAnimation(-0.10, 0.0);
     
    // Don't forget to delete the Rectangle2D in the destructor of your application:

    // Create any resource listeners (for loading screens)
    createResourceListener();
    // Load resources
    loadResources();

    // Create the scene
    createScene();
    

    createFrameListener();

    return true;
};
Esempio n. 7
0
    void UpdateLegacyMaterials(const std::string& texture_name)
    {
        Ogre::TextureManager &tm = Ogre::TextureManager::getSingleton();
        Ogre::MaterialManager &mm = Ogre::MaterialManager::getSingleton();
        
        Ogre::TexturePtr tex = tm.getByName(texture_name);
        bool has_alpha = false;
        if (!tex.isNull())
            if (Ogre::PixelUtil::hasAlpha(tex->getFormat()))
                has_alpha = true;

        for (uint i = 0; i < MAX_MATERIAL_VARIATIONS; ++i)
        {
            std::string material_name = texture_name + MaterialSuffix[i];
            Ogre::MaterialPtr material = mm.getByName(material_name);
            
            if (!material.get())
                continue;
            
            Ogre::MaterialPtr base_material;
            if (!has_alpha)
                base_material = mm.getByName(BaseMaterials[i]);
            else
                base_material = mm.getByName(AlphaBaseMaterials[i]);
            if (!base_material.get())
            {
                OgreRenderingModule::LogError("Could not find " + MaterialSuffix[i] + " base material for " + texture_name);
                continue;
            }
            
            base_material->copyDetailsTo(material);
            SetTextureUnitOnMaterial(material, texture_name, 0);
        }
    }
Esempio n. 8
0
//---------------------------------------------------------------------------
void GaussianListener::notifyMaterialSetup(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
    // Prepare the fragment params offsets
    switch(pass_id)
    {
    case 701: // blur horz
    {
        // horizontal bloom
        mat->load();
        Ogre::GpuProgramParametersSharedPtr fparams =
            mat->getBestTechnique()->getPass(0)->getFragmentProgramParameters();
        fparams->setNamedConstant("sampleOffsets", mBloomTexOffsetsHorz[0], 15);
        fparams->setNamedConstant("sampleWeights", mBloomTexWeights[0], 15);

        break;
    }
    case 700: // blur vert
    {
        // vertical bloom
        mat->load();
        Ogre::GpuProgramParametersSharedPtr fparams =
            mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters();
        fparams->setNamedConstant("sampleOffsets", mBloomTexOffsetsVert[0], 15);
        fparams->setNamedConstant("sampleWeights", mBloomTexWeights[0], 15);

        break;
    }
    }
}
Esempio n. 9
0
bool Simple::compileMaterial(Ogre::MaterialPtr material, std::set<std::string>& managedTextures) const
{
	material->removeAllTechniques();
	Ogre::Technique* technique = material->createTechnique();
	if (!mTerrainPageSurfaces.empty()) {
		//First add a base pass
		auto surfaceLayer = mTerrainPageSurfaces.begin()->second;
		Ogre::Pass* pass = technique->createPass();
		pass->setLightingEnabled(false);
		Ogre::TextureUnitState * textureUnitState = pass->createTextureUnitState();
		textureUnitState->setTextureScale(1.0f / surfaceLayer->getScale(), 1.0f / surfaceLayer->getScale());
		textureUnitState->setTextureName(surfaceLayer->getDiffuseTextureName());
		textureUnitState->setTextureCoordSet(0);

		for (auto& layer : mLayers) {
			addPassToTechnique(*mGeometry, technique, layer, managedTextures);
		}
	}
	if (mTerrainPageShadow) {
		addShadow(technique, mTerrainPageShadow, material, managedTextures);
	}

//	addLightingPass(technique, managedTextures);

	material->load();
	if (material->getNumSupportedTechniques() == 0) {
		S_LOG_WARNING("The material '" << material->getName() << "' has no supported techniques. The reason for this is: \n" << material->getUnsupportedTechniquesExplanation());
		return false;
	}
	return true;
}
void RenderComponentBillboardSet::setChangeWorldFactor(double factor)
{
	Ogre::Technique * technique;
	Ogre::GpuProgramParametersSharedPtr params;
	Ogre::Pass * pass;

	Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(mChangeWorldMaterial);

	if(material.get())
	{
		technique= material->getTechnique(0);
		if(technique)
		{
			if(technique->getNumPasses()>0)
			{
				pass=technique->getPass(0);
				if(pass->hasFragmentProgram())
				{
					params=pass->getFragmentProgramParameters();

					if(params.get())
					{
						params->setNamedConstant("mix_factor",Ogre::Real(factor));
					}
				}
			}
		}
	}
}
Esempio n. 11
0
    void DatuPointEditAction::_createIndicatorInstance(void)
    {
        Ogre::SceneManager* sceneManager = mSceneManipulator->getSceneManager();

        mSoundMovingEntity = sceneManager->createEntity("DatuPointMovingEntity", "axes.mesh");
        mSoundNode = mSceneManipulator->getIndicatorRootSceneNode()->createChildSceneNode();

        mSoundNode->setVisible(false);

        mSoundNode->createChildSceneNode()->attachObject(mSoundMovingEntity);

        mSoundMovingEntity->getParentSceneNode()->setScale(10,10,10);

        Real radius = 1;
        int rings = 16;
        int segments = 64;

        Ogre::MeshPtr sphereMesh = WX::createCommonSphere("DatuPointRadiusEntity", radius, rings, segments);
        Ogre::MaterialPtr material = WX::createPureColourMaterial(
            Ogre::ColourValue(1, 0, 0, 0.75)   );

        material->getTechnique(0)->getPass(0)->setPolygonMode(Ogre::PM_WIREFRAME);

        mDatuPointRadiusEntity = sceneManager->createEntity("DatuPointRadiusEntity", sphereMesh->getName());
        mSoundNode->createChildSceneNode()->attachObject(mDatuPointRadiusEntity);
        mDatuPointRadiusEntity->setMaterialName(material->getName());
        mDatuPointRadiusEntity->getParentSceneNode()->setVisible(false);

        mFirstInit = true;
    }
Esempio n. 12
0
 void ReplaceTextureOnMaterial(Ogre::MaterialPtr material, const std::string& original_name, const std::string& texture_name)
 {
     if (material.isNull())
         return;
     
     Ogre::TextureManager &tm = Ogre::TextureManager::getSingleton();
     Ogre::TexturePtr tex = tm.getByName(texture_name);
     
     Ogre::Material::TechniqueIterator iter = material->getTechniqueIterator();
     while(iter.hasMoreElements())
     {
         Ogre::Technique *tech = iter.getNext();
         assert(tech);
         Ogre::Technique::PassIterator passIter = tech->getPassIterator();
         while(passIter.hasMoreElements())
         {
             Ogre::Pass *pass = passIter.getNext();
             
             Ogre::Pass::TextureUnitStateIterator texIter = pass->getTextureUnitStateIterator();
             
             while(texIter.hasMoreElements())
             {
                 Ogre::TextureUnitState *texUnit = texIter.getNext();
                 if (texUnit->getTextureName() == original_name)
                 {
                     if (tex.get())
                         texUnit->setTextureName(texture_name);
                     else
                         texUnit->setTextureName("TextureMissing.png");
                 }
             }
         }
     }
 }
Esempio n. 13
0
    void DynamicLines::init(Ogre::String const &resourceGroup,
                            Ogre::RenderOperation::OperationType opType /*= Ogre::RenderOperation::OT_LINE_STRIP*/,
                            bool use2d /*= false*/)
    {
        mPoints.clear();
        mColors.clear();
        //dynamic renderable
        initialize(opType, false);

        {
            Ogre::MaterialPtr const whiteNoLignthing = Ogre::MaterialManager::getSingleton().getByName("BaseWhiteNoLighting");
            Ogre::String const resName = "DynamicLines_" + Ogre::StringConverter::toString(mId) + "_BaseWhiteNoLighting_" + resourceGroup;
            mMaterial = Ogre::MaterialManager::getSingleton().getByName(resName);

            if(mMaterial.isNull())
            {
                mMaterial = whiteNoLignthing->clone(resName, true, resourceGroup);
                mMaterial->load();
            }

            mMaterial->setDepthCheckEnabled(!use2d);
        }
        setMaterial(mMaterial->getName());

        setUse2D(use2d);
        mDirty = false;
    }
Esempio n. 14
0
void PlayState::CreateInitialWorld() {
  // Creacion de la entidad y del SceneNode ------------------------
  Plane plane1(Vector3(0,1,0), 0);    // Normal y distancia

  Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create( "GroundJ", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);

  Ogre::TextureUnitState* tuisTexture = mat->getTechnique(0)->getPass(0)->createTextureUnitState("ground2.jpg");

  MeshManager::getSingleton().createPlane("p1",
  ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane1,
  200, 200, 1, 1, true, 1, 35, 35, Vector3::UNIT_Z);
  SceneNode* node = _sceneMgr->createSceneNode("groundJ");
  Entity* groundEnt = _sceneMgr->createEntity("planeEnt", "p1");
  groundEnt->setMaterialName("GroundJ");
  node->attachObject(groundEnt);
  _sceneMgr->getRootSceneNode()->addChild(node);

  // Creamos forma de colision para el plano ----------------------- 
  OgreBulletCollisions::CollisionShape *Shape;
  Shape = new OgreBulletCollisions::StaticPlaneCollisionShape
    (Ogre::Vector3(0,1,0), 0);   // Vector normal y distancia
  OgreBulletDynamics::RigidBody *rigidBodyPlane = new 
    OgreBulletDynamics::RigidBody("rigidBodyPlane", _world);
  
  // Creamos la forma estatica (forma, Restitucion, Friccion) ------
  rigidBodyPlane->setStaticShape(Shape, 0.1, 0.8); 
  std::cout << "Hola" << std::endl;
  
  ColocarWolfAndRedilAndPig();
  CrearBosqueAndColina();
  CreationWolf();
  std::cout << "BOSQUE AND COLINA COLOCADAS" <<std::endl;
}
Esempio n. 15
0
void CubeWorld::createWorldChunks (void)
{
	//std::vector<int> VertexArray;
	Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create("BoxColor", "General", true );
	Ogre::Technique* tech = mat->getTechnique(0);
	Ogre::Pass* pass = tech->getPass(0);
	Ogre::TextureUnitState* tex = pass->createTextureUnitState();
	tex->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, Ogre::ColourValue(0, 0.5, 0));

	Ogre::ManualObject* MeshChunk = new Ogre::ManualObject("MeshMatChunk");
	MeshChunk->begin("TerrainImage");

	for (int z = 0; z < WORLD_SIZE; z += CHUNK_SIZE)
	{
		for (int y = 0; y < WORLD_SIZE; y += CHUNK_SIZE)
		{
			for (int x = 0; x < WORLD_SIZE; x += CHUNK_SIZE)
			{
				createChunk(MeshChunk, x,y,z); /* WFaces or not */
				//createChunkWater(x, y, z);
			}
		}
	}

}
Esempio n. 16
0
void EC_WidgetCanvas::SetSelfIllumination(bool illuminating)
{
    if (material_name_.empty())
        return;

    Ogre::ColourValue emissiveColor;
    if (illuminating)
        emissiveColor = Ogre::ColourValue(1.0f, 1.0f, 1.0f, 1.0f);
    else
        emissiveColor = Ogre::ColourValue(0.0f, 0.0f, 0.0f, 0.0f);

    Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(material_name_);
    if (!material.isNull())
    {
        Ogre::Material::TechniqueIterator iter = material->getTechniqueIterator();
        while(iter.hasMoreElements())
        {
            Ogre::Technique *tech = iter.getNext();
            if (!tech)
                continue;
            Ogre::Technique::PassIterator passIter = tech->getPassIterator();
            while(passIter.hasMoreElements())
            {
                Ogre::Pass *pass = passIter.getNext();
                if (pass)
                    pass->setSelfIllumination(emissiveColor);
            }
        }
    }
}
Esempio n. 17
0
const Ogre::MaterialPtr& MaterialGenerator::GetMaterial(Perm permutation)
{
    // Check if material/shader permutation already was generated
    MaterialMap::iterator i = mMaterials.find(permutation);
    if (i != mMaterials.end())
    {
        return i->second;
    }
    else
    {
        // Create it
        Ogre::MaterialPtr templ = GetTemplateMaterial(permutation & mMatMask);
        Ogre::GpuProgramPtr vs = GetVertexShader(permutation & mVsMask);
        Ogre::GpuProgramPtr fs = GetFragmentShader(permutation & mFsMask);

        // Create material name
        string name = mMaterialBaseName + Ogre::StringConverter::toString(permutation);

        // Create material from template, and set shaders
        Ogre::MaterialPtr mat = templ->clone(name);
        Ogre::Technique* tech = mat->getTechnique(0);
        Ogre::Pass* pass = tech->getPass(0);
        pass->setFragmentProgram(fs->getName());
        pass->setVertexProgram(vs->getName());

        // And store it
        mMaterials[permutation] = mat;
        return mMaterials[permutation];
    }
}
Esempio n. 18
0
//create ColorDepth texture
void KinectDevice::createOgreColoredDepthTexture(const std::string coloredDepthTextureName,const std::string materialName)
{
	if(!coloredDepthTextureName.empty())
	{
		mColoredDepthTexture = TextureManager::getSingleton().createManual(
		coloredDepthTextureName, 
		ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, 
		TEX_TYPE_2D, 
		KINECT_DEPTH_WIDTH, 
		KINECT_DEPTH_HEIGHT, 
		0,
		PF_R8G8B8, 
		TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
		//mColoredDepthBuffer   = new unsigned char[Ogre::Kinect::depthWidth * Ogre::Kinect::depthHeight * 3];
		//mColoredDepthPixelBox = Ogre::PixelBox(Ogre::Kinect::depthWidth, Ogre::Kinect::depthHeight, 1, Ogre::PF_R8G8B8, mColoredDepthBuffer);
	}
	if(!materialName.empty())
	{
		//Create Material
		Ogre::MaterialPtr material = MaterialManager::getSingleton().create(materialName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
		material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
		material->getTechnique(0)->getPass(0)->createTextureUnitState(coloredDepthTextureName);
		//material->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureRotate(Ogre::Degree(180)); 
	}
}
void OGRE3DRenderSystem::setVisualisationMode(NxOgre::Enums::VisualDebugger type)
{

 if (Ogre::MaterialManager::getSingletonPtr()->resourceExists("OGRE3DRenderSystem.VisualDebugger") == false)
 {
  Ogre::MaterialPtr material = Ogre::MaterialManager::getSingletonPtr()->create("OGRE3DRenderSystem.VisualDebugger", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
  material->getTechnique(0)->getPass(0)->setDepthBias(1);
  material->getTechnique(0)->getPass(0)->setAmbient(1,1,1);
  material->getTechnique(0)->getPass(0)->setSelfIllumination(1,1,1);
  material->getTechnique(0)->setLightingEnabled(false);
 }

 if (mVisualDebuggerRenderable == 0)
 {
  mVisualDebuggerRenderable = createRenderable(NxOgre::Enums::RenderableType_VisualDebugger, "OGRE3DRenderSystem.VisualDebugger");
  ::NxOgre::World::getWorld()->getVisualDebugger()->setRenderable(mVisualDebuggerRenderable);
  mVisualDebuggerRenderable->setCastShadows(false);
  mVisualDebuggerNode = mSceneManager->getRootSceneNode()->createChildSceneNode();
  mVisualDebuggerNode->attachObject(mVisualDebuggerRenderable);
 }
 
 ::NxOgre::World::getWorld()->getVisualDebugger()->setVisualisationMode(type);
 
 if (type == NxOgre::Enums::VisualDebugger_ShowNone)
  mVisualDebuggerNode->setVisible(false);
 else
  mVisualDebuggerNode->setVisible(true);
 
 mVisualDebuggerShown = (type != NxOgre::Enums::VisualDebugger_ShowNone);
 
}
Esempio n. 20
0
void BoxChunk::addToGraph(Ogre::SceneManager* sceneMgr)
{
  // set up Ogre properties
  entity = sceneMgr->createEntity(name, "cube.mesh");

  // Create BoxChunk materials
  Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create(name+"Mat",
    Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
  entity->setMaterial(mat);
  entity->setMaterial(mat);
  entity->setCastShadows(false);

  node = sceneMgr->getRootSceneNode()->createChildSceneNode(name);
  node->attachObject(entity);

  Ogre::Real cur_height = entity->getBoundingBox().getSize().y;
  node->scale(height/cur_height, height/cur_height, height/cur_height);
  node->rotate(Ogre::Quaternion(((float)(rand() % 10))/10.f, ((float)(rand() % 10))/10.f,
                                ((float)(rand() % 10))/10.f, ((float)(rand() % 10))/10.f));

  Ogre::ColourValue c(1, 0, 0, 1);
  mat->setAmbient(c);
  mat->setDiffuse(c);
  mat->setSpecular(c);
}
Esempio n. 21
0
//create Depth texture
void KinectDevice::createOgreDepthTexture(const std::string depthTextureName,const std::string materialName)
{
	if(!depthTextureName.empty())
	{
		mDepthTexture = TextureManager::getSingleton().createManual(
			depthTextureName, 
			ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, 
			TEX_TYPE_2D, 
			KINECT_DEPTH_WIDTH, 
			KINECT_DEPTH_HEIGHT, 
			0,
			PF_L8, 
			TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
	}
	if(!materialName.empty())
	{
		//Create Material
		Ogre::MaterialPtr material = MaterialManager::getSingleton().create(materialName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
		material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
		material->getTechnique(0)->getPass(0)->setAlphaRejectSettings(CMPF_GREATER, 127);
		material->getTechnique(0)->getPass(0)->createTextureUnitState(depthTextureName);
		//material->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureRotate(Ogre::Degree(180)); 
		//material->getTechnique(0)->getPass(0)->setVertexProgram("Ogre/Compositor/StdQuad_vp");
		//material->getTechnique(0)->getPass(0)->setFragmentProgram("KinectDepth");
	}
}
Esempio n. 22
0
void CubeWorld::displaySimpleWorld (void)
{
	Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create("BoxColor", "General", true );
	Ogre::Technique* tech = mat->getTechnique(0);
	Ogre::Pass* pass = tech->getPass(0);
	Ogre::TextureUnitState* tex = pass->createTextureUnitState();
	tex->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, Ogre::ColourValue(0, 0.5, 0));

	Ogre::ManualObject* testBox  = createCubeMesh("TestBox1", "BoxColor");
        Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
	Ogre::MeshPtr Mesh = testBox->convertToMesh("TestBox2");
	Ogre::StaticGeometry* pGeom = new Ogre::StaticGeometry (mSceneMgr, "Boxes");

	Ogre::Entity* pEnt = mSceneMgr->createEntity("TestBox2");

	pGeom->setRegionDimensions(Ogre::Vector3(300, 300, 300));

	for (int z = 0; z < WORLD_SIZE; ++z)
	{
		for (int y = 0; y < WORLD_SIZE; ++y)
		{
			for (int x = 0; x < WORLD_SIZE; ++x)
			{
				if (GetBlock(x,y,z)) pGeom->addEntity(pEnt, Ogre::Vector3(x,y,z));
			}
		}
	}

	pGeom->build ();
}
Esempio n. 23
0
Fade::Fade() :
mTime(1.0f),
mType(FADE_IN),
mTexture(0),
mAccumTime(0)
{
	if(!mOverlay){
		// create the shared overlay
		mOverlay = Ogre::OverlayManager::getSingleton().create("sFadeOv");
		mOverlay->show();
	}

	// create the element
	mElement = Ogre::OverlayManager::getSingleton().createOverlayElement(
			"Panel", "FdE" + Ogre::StringConverter::toString(mICounter));

	// Set the material
	mElement->setMaterialName("FaderMaterial");
	Ogre::MaterialPtr mat = mElement->getMaterial();
	ASSERT(!mat.isNull());
	mTexture = mat->getTechnique(0)->getPass(0)->getTextureUnitState(0);
	mTexture->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL,
						Ogre::LBS_TEXTURE, 0);
	ASSERT(mTexture);

	mElement->show();

	++mICounter;
}
Esempio n. 24
0
bool Simple::compileMaterial(Ogre::MaterialPtr material)
{
	material->removeAllTechniques();
	Ogre::Technique* technique = material->createTechnique();
	for (SurfaceLayerStore::const_iterator I = mTerrainPageSurfaces.begin(); I != mTerrainPageSurfaces.end(); ++I) {
		const TerrainPageSurfaceLayer* surfaceLayer = I->second;
		if (I == mTerrainPageSurfaces.begin()) {
			Ogre::Pass* pass = technique->createPass();
			pass->setLightingEnabled(false);
			//add the first layer of the terrain, no alpha or anything
			Ogre::TextureUnitState * textureUnitState = pass->createTextureUnitState();
			textureUnitState->setTextureScale(1.0f / surfaceLayer->getScale(), 1.0f / surfaceLayer->getScale());
			textureUnitState->setTextureName(surfaceLayer->getDiffuseTextureName());
			textureUnitState->setTextureCoordSet(0);
		} else {
			if (surfaceLayer->intersects(*mGeometry)) {
				addPassToTechnique(*mGeometry, technique, surfaceLayer);
			}
		}
	}
	if (mTerrainPageShadow) {
		addShadow(technique, mTerrainPageShadow, material);
	}
	material->load();
	if (material->getNumSupportedTechniques() == 0) {
		S_LOG_WARNING("The material '" << material->getName() << "' has no supported techniques. The reason for this is: \n" << material->getUnsupportedTechniquesExplanation());
		return false;
	}
	return true;
}
Esempio n. 25
0
void CubeWorld::createSolidTexture (const TCHAR* pName)
{
	Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create("BoxColor", "General", true );
	Ogre::Technique* tech = mat->getTechnique(0);
	Ogre::Pass* pass = tech->getPass(0);
	Ogre::TextureUnitState* tex = pass->createTextureUnitState();
	tex->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, Ogre::ColourValue(0, 0.5, 0));
}
Esempio n. 26
0
 Foundation::ResourcePtr CreateResourceFromMaterial(Ogre::MaterialPtr material)
 {
     assert(!material.isNull());
     OgreMaterialResource* res = new OgreMaterialResource(material->getName());
     res->SetMaterial(material);
     Foundation::ResourcePtr res_ptr(res);
     return res_ptr;
 }
Esempio n. 27
0
	GlowMaterialListener()
	{
		mBlackMat = Ogre::MaterialManager::getSingleton().create("mGlowBlack", "Internal");
		mBlackMat->getTechnique(0)->getPass(0)->setDiffuse(0.0,0.0,0.0,0.0);
		mBlackMat->getTechnique(0)->getPass(0)->setSpecular(0.0,0.0,0.0,0.0);
		mBlackMat->getTechnique(0)->getPass(0)->setAmbient(0.0,0.0,0.0);
		mBlackMat->getTechnique(0)->getPass(0)->setSelfIllumination(0.0,0.0,0.0);
	}
Esempio n. 28
0
void                            Worms::setColor(Ogre::ColourValue &color)
{
  Ogre::MaterialPtr new_mat;
  Ogre::MaterialPtr mat = _ent->getSubEntity(2)->getMaterial();
  new_mat = mat->clone(_name);
  //new_mat->getTechnique(0)->getPass("Skin")->setSpecular(color);
  new_mat->getTechnique(0)->getPass("Skin")->setDiffuse(color);
  this->_ent->getSubEntity(2)->setMaterialName(_name);
}
Esempio n. 29
0
	// 设置碰撞小球原来的材质.
	void IntersectPoint::SetMaterial()
	{
		 Ogre::MaterialPtr material = createColourMaterial(
            Ogre::ColourValue(1, 0, 0, 0.75),
            Ogre::ColourValue(0, 1, 0),
            1);

		 mIntersectEntity->setMaterialName(material->getName());
	}
Esempio n. 30
-15
void CubeUpdater::apply_color(Ogre::Entity* entity, float r, float g, float b)
{
    Ogre::MaterialPtr manObj = entity->getSubEntity(0)->getMaterial();
    float newR(r/255.0f), newG(g/255.0f), newB(b/255.0f);
    ColourValue oldColor(manObj->getTechnique(0)->getPass(0)->getDiffuse());

    if (oldColor.r == newR && oldColor.g == newG && oldColor.b == newB)
    {
        return;
    }

    if (!is_first_update)
    {
        cout << "New color " << newR << ", " << newG << ", " << newB << " | ";
        cout << "Old color " << oldColor.r << ", " << oldColor.g << ", " << oldColor.b << " | ";
        cout << "Diff = " << newR-oldColor.r<< endl;

        newR = scale_value(oldColor.r, newR, _config->get<double>("application.grid.adaptive_factor"), 0.01);
        newG = scale_value(oldColor.g, newG, _config->get<double>("application.grid.adaptive_factor"), 0.01);
        newB = scale_value(oldColor.b, newB, _config->get<double>("application.grid.adaptive_factor"), 0.01);

        cout << "Actual New color " << newR << ", " << newG << ", " << newB << endl;

    }

//
    manObj->getTechnique(0)->getPass(0)->setDiffuse(Ogre::ColourValue(newR, newG, newB));
    manObj->getTechnique(0)->getPass(0)->setAmbient(Ogre::ColourValue(newR/2.0f, newG/2.0f, newB/2.0f));
    //manObj->getTechnique(0)->getPass(0)->setSelfIllumination(Ogre::ColourValue(r, g, b));
}