当前位置: 首页>>代码示例>>C++>>正文


C++ TextureUnitState::setTextureFiltering方法代码示例

本文整理汇总了C++中ogre::TextureUnitState::setTextureFiltering方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureUnitState::setTextureFiltering方法的具体用法?C++ TextureUnitState::setTextureFiltering怎么用?C++ TextureUnitState::setTextureFiltering使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ogre::TextureUnitState的用法示例。


在下文中一共展示了TextureUnitState::setTextureFiltering方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateVertexBuffers

//------------------------------------------------------------------------------
Background2D::Background2D():
    m_AlphaMaxVertexCount( 0 ),
    m_AddMaxVertexCount( 0 ),

    m_ScrollEntity( NULL ),
    m_ScrollPositionStart( Ogre::Vector2::ZERO ),
    m_ScrollPositionEnd( Ogre::Vector2::ZERO ),
    m_ScrollType( Background2D::NONE ),
    m_ScrollSeconds( 0 ),
    m_ScrollCurrentSeconds( 0 ),
    m_Position( Ogre::Vector2::ZERO ),
    m_PositionReal( Ogre::Vector2::ZERO )

   ,m_range( Ogre::AxisAlignedBox::BOX_INFINITE )
    // for ffvii
   ,m_virtual_screen_size( 320, 240 )
{
    m_SceneManager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
    m_RenderSystem = Ogre::Root::getSingletonPtr()->getRenderSystem();

    CreateVertexBuffers();

    m_AlphaMaterial = Ogre::MaterialManager::getSingleton().create( "Background2DAlpha", "General" );
    Ogre::Pass* pass = m_AlphaMaterial->getTechnique( 0 )->getPass( 0 );
    pass->setVertexColourTracking( Ogre::TVC_AMBIENT );
    pass->setCullingMode( Ogre::CULL_NONE );
    pass->setDepthCheckEnabled( true );
    pass->setDepthWriteEnabled( true );
    pass->setLightingEnabled( false );
    pass->setSceneBlending( Ogre::SBT_TRANSPARENT_ALPHA );
    pass->setAlphaRejectFunction( Ogre::CMPF_GREATER );
    pass->setAlphaRejectValue( 0 );
    Ogre::TextureUnitState* tex = pass->createTextureUnitState();
    tex->setTextureName( "system/blank.png" );
    tex->setNumMipmaps( -1 );
    tex->setTextureFiltering( Ogre::TFO_NONE );

    m_AddMaterial = Ogre::MaterialManager::getSingleton().create( "Background2DAdd", "General" );
    pass = m_AddMaterial->getTechnique( 0 )->getPass( 0 );
    pass->setVertexColourTracking( Ogre::TVC_AMBIENT );
    pass->setCullingMode( Ogre::CULL_NONE );
    pass->setDepthCheckEnabled( true );
    pass->setDepthWriteEnabled( true );
    pass->setLightingEnabled( false );
    pass->setSceneBlending( Ogre::SBT_ADD );
    pass->setAlphaRejectFunction( Ogre::CMPF_GREATER );
    pass->setAlphaRejectValue( 0 );
    tex = pass->createTextureUnitState();
    tex->setTextureName( "system/blank.png" );
    tex->setNumMipmaps( -1 );
    tex->setTextureFiltering( Ogre::TFO_NONE );

    m_SceneManager->addRenderQueueListener( this );
}
开发者ID:DeejStar,项目名称:q-gears,代码行数:55,代码来源:Background2D.cpp

示例2: AddMaterial

	void TerrainProjectionMarker::AddMaterial(const string& matName)
	{
		// check if material is already added or there's no material
		if( _targetMaterials.find(matName) != _targetMaterials.end() ||
			matName.empty() )
		{
			return;
		}

		string matName2 = "StoreMat";

		// get the material ptr
		Ogre::MaterialPtr mat = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().getByName(matName);

		// create a new pass in the material to render the decal
		Ogre::Pass* pass = mat->getTechnique(0)->createPass();

		// set up the decal's texture unit
		Ogre::TextureUnitState *texState = pass->createTextureUnitState(GetTextureName());
		texState->setProjectiveTexturing(true, _projectionFrustum);
		texState->setTextureAddressingMode(Ogre::TextureUnitState::TAM_WRAP);
		texState->setTextureFiltering(Ogre::FO_POINT, Ogre::FO_LINEAR, Ogre::FO_NONE);
		texState->setAlphaOperation(Ogre::LBX_ADD);

		// set our pass to blend the decal over the model's regular texture
		pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
		pass->setDepthBias(2.5f, 2.5f);
		pass->setDepthCheckEnabled(false);

		// set the decal to be self illuminated instead of lit by scene lighting
		pass->setLightingEnabled(false);

		// save pass in map
		_targetMaterials[matName] = pass;
	}
开发者ID:KFlaga,项目名称:FlagRTS,代码行数:35,代码来源:TerrainProjectionMarker.cpp

示例3: onInitialize

void ImageDisplay::onInitialize()
{
  ImageDisplayBase::onInitialize();
  {
    static uint32_t count = 0;
    std::stringstream ss;
    ss << "ImageDisplay" << count++;
    img_scene_manager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, ss.str());
  }

  img_scene_node_ = img_scene_manager_->getRootSceneNode()->createChildSceneNode();

  {
    static int count = 0;
    std::stringstream ss;
    ss << "ImageDisplayObject" << count++;

    screen_rect_ = new Ogre::Rectangle2D(true);
    screen_rect_->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY - 1);
    screen_rect_->setCorners(-1.0f, 1.0f, 1.0f, -1.0f);

    ss << "Material";
    material_ = Ogre::MaterialManager::getSingleton().create( ss.str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
    material_->setSceneBlending( Ogre::SBT_REPLACE );
    material_->setDepthWriteEnabled(false);
    material_->setReceiveShadows(false);
    material_->setDepthCheckEnabled(false);

    material_->getTechnique(0)->setLightingEnabled(false);
    Ogre::TextureUnitState* tu = material_->getTechnique(0)->getPass(0)->createTextureUnitState();
    tu->setTextureName(texture_.getTexture()->getName());
    tu->setTextureFiltering( Ogre::TFO_NONE );

    material_->setCullingMode(Ogre::CULL_NONE);
    Ogre::AxisAlignedBox aabInf;
    aabInf.setInfinite();
    screen_rect_->setBoundingBox(aabInf);
    screen_rect_->setMaterial(material_->getName());
    img_scene_node_->attachObject(screen_rect_);
  }

  render_panel_ = new RenderPanel();
  render_panel_->getRenderWindow()->setAutoUpdated(false);
  render_panel_->getRenderWindow()->setActive( false );

  render_panel_->resize( 640, 480 );
  render_panel_->initialize(img_scene_manager_, context_);

  setAssociatedWidget( render_panel_ );

  render_panel_->setAutoRender(false);
  render_panel_->setOverlaysEnabled(false);
  render_panel_->getCamera()->setNearClipDistance( 0.01f );

  updateNormalizeOptions();
}
开发者ID:CURG,项目名称:rviz,代码行数:56,代码来源:image_display.cpp

示例4: createCubeMesh

//-------------------------------------------------------------------------------------
void BasicTutorial2::createScene(void)
{
    mSceneMgr->setAmbientLight(Ogre::ColourValue(0, 0, 0));
    //mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
 
	//Create cube
	    //Create a basic green color texture 
 
	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->setTextureName("grassTexture.png");
	//tex->setNumMipmaps(4);
	tex->setTextureAnisotropy(1);
	tex->setTextureFiltering(Ogre::FO_POINT, Ogre::FO_POINT, Ogre::FO_POINT);

	    //Create the one box and the supporting class objects
	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");
	
	//testBox->triangle
	pGeom->setRegionDimensions(Ogre::Vector3(300, 300, 300));
 
	World::Instance();
	 
	pGeom->build ();
 
        mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
	Ogre::Light* l = mSceneMgr->createLight("MainLight");
        l->setPosition(20,80,50);
	//Create Cube

 /*   Ogre::Entity* entNinja = mSceneMgr->createEntity("Ninja", "ninja.mesh");
    entNinja->setCastShadows(true);
    mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entNinja);*/
 
 
    Ogre::Light* directionalLight = mSceneMgr->createLight("directionalLight");
    directionalLight->setType(Ogre::Light::LT_DIRECTIONAL);
    directionalLight->setDiffuseColour(Ogre::ColourValue(.25, .25, 0));
    directionalLight->setSpecularColour(Ogre::ColourValue(.25, .25, 0));
 
    directionalLight->setDirection(Ogre::Vector3( 0, -1, 1 )); 
 
 
}
开发者ID:asvsfs,项目名称:TheJourney,代码行数:52,代码来源:BasicTutorial2.cpp

示例5: addShadow

void Simple::addShadow(Ogre::Technique* technique, const TerrainPageShadow* terrainPageShadow, Ogre::MaterialPtr material, std::set<std::string>& managedTextures) const
{
	Ogre::Pass* shadowPass = technique->createPass();

	shadowPass->setSceneBlending(Ogre::SBT_MODULATE);
	shadowPass->setLightingEnabled(false);
//	shadowPass->setFog(true, Ogre::FOG_NONE);

	Ogre::TextureUnitState * textureUnitStateSplat = shadowPass->createTextureUnitState();
	Ogre::TexturePtr texture = updateShadowTexture(material, terrainPageShadow, managedTextures);
	textureUnitStateSplat->setTextureName(texture->getName());

	textureUnitStateSplat->setTextureCoordSet(0);
	textureUnitStateSplat->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
	textureUnitStateSplat->setTextureFiltering(Ogre::TFO_ANISOTROPIC);
}
开发者ID:Chimangoo,项目名称:ember,代码行数:16,代码来源:Simple.cpp

示例6: registerPass

	void Decal::registerPass(Ogre::Pass* _Pass)
	{
		unregister();

		_Pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
		_Pass->setCullingMode(Ogre::CULL_NONE);
        _Pass->setDepthBias(1,1);
        _Pass->setLightingEnabled(false);
		_Pass->setDepthWriteEnabled(false);

		Ogre::TextureUnitState *DecalTexture = _Pass->createTextureUnitState(mTextureName);
        DecalTexture->setProjectiveTexturing(true, mProjector);
		DecalTexture->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
		DecalTexture->setTextureFiltering(Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_NONE);
		DecalTexture->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_TEXTURE, Ogre::LBS_MANUAL, 1.0, mTransparency);

		mRegisteredPass = _Pass;
	}
开发者ID:Aperion,项目名称:rigsofrods-next-stable,代码行数:18,代码来源:DecalsManager.cpp

示例7: prepareResources

	//------------------------------------------------------
	void TextureAtlas::prepareResources() {
		mTexture = Ogre::TextureManager::getSingleton().createManual(mAtlasName,
			Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
			Ogre::TEX_TYPE_2D,
			mAtlasSize.width,
			mAtlasSize.height,
			1,
			Ogre::PF_BYTE_BGRA,
			Ogre::TU_STATIC_WRITE_ONLY);

		Ogre::TextureUnitState* tus = mMaterial->getTechnique(0)->getPass(0)->createTextureUnitState(mTexture->getName());

		tus->setTextureFiltering(Ogre::FO_NONE, Ogre::FO_NONE, Ogre::FO_NONE);

		Ogre::Pass *pass = mMaterial->getTechnique(0)->getPass(0);
		pass->setAlphaRejectSettings(Ogre::CMPF_GREATER, 128);
		pass->setLightingEnabled(false);
	}
开发者ID:Painpillow,项目名称:openDarkEngine,代码行数:19,代码来源:TextureAtlas.cpp

示例8: CreateRenderTargetOverlay

void RenderWindow::CreateRenderTargetOverlay(int width, int height)
{
    width = max(1, width);
    height = max(1, height);

    Ogre::TexturePtr renderTarget = Ogre::TextureManager::getSingleton().createManual(
        rttTextureName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
        Ogre::TEX_TYPE_2D, width, height, 0, Ogre::PF_A8R8G8B8, Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);

    Ogre::MaterialPtr rttMaterial = Ogre::MaterialManager::getSingleton().create(
        rttMaterialName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);

    Ogre::TextureUnitState *rttTuState = rttMaterial->getTechnique(0)->getPass(0)->createTextureUnitState();

    rttTuState->setTextureName(rttTextureName);
    rttTuState->setTextureFiltering(Ogre::TFO_NONE);
    rttTuState->setNumMipmaps(1);
    rttTuState->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);

    rttMaterial->setFog(true, Ogre::FOG_NONE); ///\todo Check, shouldn't here be false?
    rttMaterial->setReceiveShadows(false);
    rttMaterial->setTransparencyCastsShadows(false);

    rttMaterial->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBF_SOURCE_ALPHA, Ogre::SBF_ONE_MINUS_SOURCE_ALPHA);
    rttMaterial->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
    rttMaterial->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
    rttMaterial->getTechnique(0)->getPass(0)->setLightingEnabled(false);
    rttMaterial->getTechnique(0)->getPass(0)->setCullingMode(Ogre::CULL_NONE);

    overlayContainer = Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "MainWindow Overlay Panel");
    overlayContainer->setMaterialName(rttMaterialName);
    overlayContainer->setMetricsMode(Ogre::GMM_PIXELS);
    overlayContainer->setPosition(0, 0);
    overlayContainer->setDimensions((Ogre::Real)width, (Ogre::Real)height);
    overlayContainer->setPosition(0,0);

    overlay = Ogre::OverlayManager::getSingleton().create("MainWindow Overlay");
    overlay->add2D(static_cast<Ogre::OverlayContainer *>(overlayContainer));
    overlay->setZOrder(500);
    overlay->show();

//    ResizeOverlay(width, height);
}
开发者ID:katik,项目名称:naali,代码行数:43,代码来源:RenderWindow.cpp

示例9: addLightingPass

void Simple::addLightingPass(Ogre::Technique* technique, std::set<std::string>& managedTextures) const
{
	Ogre::Pass* lightingPass = technique->createPass();

	lightingPass->setSceneBlending(Ogre::SBT_MODULATE);
	lightingPass->setLightingEnabled(false);

	Ogre::TextureUnitState * textureUnitStateSplat = lightingPass->createTextureUnitState();

	//we need an unique name for our alpha texture
	std::stringstream lightingTextureNameSS;
	lightingTextureNameSS << technique->getParent()->getName() << "_lighting";
	const Ogre::String lightingTextureName(lightingTextureNameSS.str());

	Ogre::TexturePtr texture = static_cast<Ogre::TexturePtr>(Ogre::Root::getSingletonPtr()->getTextureManager()->getByName(lightingTextureName));
	if (texture.isNull()) {
		texture = Ogre::Root::getSingletonPtr()->getTextureManager()->createManual(lightingTextureName, "General", Ogre::TEX_TYPE_2D, mPage.getBlendMapSize(), mPage.getBlendMapSize(), 1, Ogre::PF_L8, Ogre::TU_DYNAMIC_WRITE_ONLY);
		managedTextures.insert(texture->getName());
	}

	Ogre::Image ogreImage;
	ogreImage.loadDynamicImage(const_cast<unsigned char*>(mLightingImage->getData()), mLightingImage->getResolution(), mLightingImage->getResolution(), 1, Ogre::PF_L8);

	texture->loadImage(ogreImage);

	//blit the whole image to the hardware buffer
	Ogre::PixelBox sourceBox(ogreImage.getPixelBox());
	//blit for each mipmap
	for (unsigned int i = 0; i <= texture->getNumMipmaps(); ++i) {
		Ogre::HardwarePixelBufferSharedPtr hardwareBuffer(texture->getBuffer(0, i));
		hardwareBuffer->blitFromMemory(sourceBox);
	}

	textureUnitStateSplat->setTextureName(texture->getName());

	textureUnitStateSplat->setTextureCoordSet(0);
	textureUnitStateSplat->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
	textureUnitStateSplat->setTextureFiltering(Ogre::TFO_ANISOTROPIC);

}
开发者ID:Chimangoo,项目名称:ember,代码行数:40,代码来源:Simple.cpp

示例10: preAddToRenderState

//-----------------------------------------------------------------------
bool RTShaderSRSSegmentedLights::preAddToRenderState(const RenderState* renderState, Pass* srcPass, Pass* dstPass)
{
    if (srcPass->getLightingEnabled() == false)
        return false;

    mUseSegmentedLightTexture = SegmentedDynamicLightManager::getSingleton().isActive();
    setTrackVertexColourType(srcPass->getVertexColourTracking());           

    if (srcPass->getShininess() > 0.0 &&
        srcPass->getSpecular() != ColourValue::Black)
    {
        setSpecularEnable(true);
    }
    else
    {
        setSpecularEnable(false);   
    }

    
    int lightCount[3];
    renderState->getLightCount(lightCount);
    setLightCount(lightCount);

    if (mUseSegmentedLightTexture)
    {
        const_cast<RenderState*>(renderState)->setLightCountAutoUpdate(false);

        Ogre::TextureUnitState* pLightTexture = dstPass->createTextureUnitState();
        pLightTexture->setTextureName(SegmentedDynamicLightManager::getSingleton().getSDLTextureName(), Ogre::TEX_TYPE_2D);
        pLightTexture->setTextureFiltering(Ogre::TFO_NONE);
        mLightSamplerIndex = dstPass->getNumTextureUnitStates() - 1;
    }


    return true;
}
开发者ID:LiberatorUSA,项目名称:GUCEF,代码行数:37,代码来源:RTShaderSRSSegmentedLights.cpp

示例11: expandAll


//.........这里部分代码省略.........
                                      colorProperty->getAlpha()/255.0f);
            }
            break;
            case PASS_EMISSIVE:
            {
                colorProperty = static_cast<QtColorProperty*>(property);
                pass = static_cast<Ogre::Pass*>(colorProperty->mUserData);
                if (pass)
                    pass->setEmissive(colorProperty->getRed()/255.0f,
                                      colorProperty->getGreen()/255.0f,
                                      colorProperty->getBlue()/255.0f);
            }
            break;
            case PASS_SELF_ILLUMINATION:
            {
                colorProperty = static_cast<QtColorProperty*>(property);
                pass = static_cast<Ogre::Pass*>(colorProperty->mUserData);
                if (pass)
                    pass->setSelfIllumination(colorProperty->getRed()/255.0f,
                                              colorProperty->getGreen()/255.0f,
                                              colorProperty->getBlue()/255.0f);
            }
            break;
            case PASS_SHININESS:
            {
                decimalProperty = static_cast<QtDecimalProperty*>(property);
                pass = static_cast<Ogre::Pass*>(decimalProperty->mUserData);
                if (pass)
                    pass->setShininess(decimalProperty->getValue());
            }
            break;

            // Texture unit properties
            case TUS_FILTERING:
            {
                selectProperty = static_cast<QtSelectProperty*>(property);
                textureUnit = static_cast<Ogre::TextureUnitState*>(selectProperty->mUserData);
                if (textureUnit)
                {
                    if (selectProperty->getCurrentIndex() == 0)
                    {
                        textureUnit->setTextureFiltering(Ogre::FT_MIN, Ogre::FO_NONE);
                        textureUnit->setTextureFiltering(Ogre::FT_MAG, Ogre::FO_NONE);
                    }
                    else if (selectProperty->getCurrentIndex() == 1)
                    {
                        textureUnit->setTextureFiltering(Ogre::FT_MIN, Ogre::FO_POINT);
                        textureUnit->setTextureFiltering(Ogre::FT_MAG, Ogre::FO_POINT);
                    }
                    else if (selectProperty->getCurrentIndex() == 2)
                    {
                        textureUnit->setTextureFiltering(Ogre::FT_MIN, Ogre::FO_LINEAR);
                        textureUnit->setTextureFiltering(Ogre::FT_MAG, Ogre::FO_LINEAR);
                    }
                    else if (selectProperty->getCurrentIndex() == 3)
                    {
                        textureUnit->setTextureFiltering(Ogre::FT_MIN, Ogre::FO_ANISOTROPIC);
                        textureUnit->setTextureFiltering(Ogre::FT_MAG, Ogre::FO_ANISOTROPIC);
                    }
                }
            }
            break;

            case TUS_USCALE:
            {
                decimalProperty = static_cast<QtDecimalProperty*>(property);
                textureUnit = static_cast<Ogre::TextureUnitState*>(decimalProperty->mUserData);
                if (textureUnit)
                    textureUnit->setTextureUScale(decimalProperty->getValue());
            }
            break;

            case TUS_VSCALE:
            {
                decimalProperty = static_cast<QtDecimalProperty*>(property);
                textureUnit = static_cast<Ogre::TextureUnitState*>(decimalProperty->mUserData);
                if (textureUnit)
                    textureUnit->setTextureVScale(decimalProperty->getValue());
            }
            break;

            case TUS_USCROLL:
            {
                decimalProperty = static_cast<QtDecimalProperty*>(property);
                textureUnit = static_cast<Ogre::TextureUnitState*>(decimalProperty->mUserData);
                if (textureUnit)
                    textureUnit->setTextureUScroll(decimalProperty->getValue());
            }
            break;

            case TUS_VSCROLL:
            {
                decimalProperty = static_cast<QtDecimalProperty*>(property);
                textureUnit = static_cast<Ogre::TextureUnitState*>(decimalProperty->mUserData);
                if (textureUnit)
                    textureUnit->setTextureVScroll(decimalProperty->getValue());
            }
            break;
        }
    }
开发者ID:galek,项目名称:Magus,代码行数:101,代码来源:ogre_asset_material.cpp

示例12: textureName

CRosRttTexture::CRosRttTexture(unsigned width, unsigned height, Ogre::Camera * camera, bool isDepth /*= false*/ )
: m_materialName("MyRttMaterial")
, width_(width)
, height_(height)
, frame_("/map")
, m_bIsDepth( isDepth )
{
  assert( height > 0 && width > 0 );

  {
    // Set encoding
    current_image_.encoding = ROS_IMAGE_FORMAT;

    // Set image size
    current_image_.width = width;
    current_image_.height = height;

    // Set image row length in bytes (row length * 3 bytes for a color)
    current_image_.step = width * BPP;

#if OGRE_ENDIAN == ENDIAN_BIG
    current_image_.is_bigendian = true;
#else
        current_image_.is_bigendian = false;
#endif

    // Resize data
    current_image_.data.resize( width_ * height_ * BPP);

  }

  Ogre::TextureManager & lTextureManager( Ogre::TextureManager::getSingleton() );
  Ogre::String textureName("RVIZ_CamCast_Texture");
  bool lGammaCorrection( false );
  unsigned int lAntiAliasing( 0 );
  unsigned int lNumMipmaps( 0 );

  if( isDepth )
  {
	  texture_ = lTextureManager.createManual(textureName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
		  Ogre::TEX_TYPE_2D, width, height, lNumMipmaps,
		  OGRE_DEPTH_TEXTURE_FORMAT, Ogre::TU_RENDERTARGET, 0, lGammaCorrection, lAntiAliasing);
  }
  else
  {
	  texture_ = lTextureManager.createManual(textureName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
	  		  Ogre::TEX_TYPE_2D, width, height, lNumMipmaps,
	  		  OGRE_TEXTURE_FORMAT, Ogre::TU_RENDERTARGET, 0, lGammaCorrection, lAntiAliasing);
  }

  // Create render target
  Ogre::RenderTexture* lRenderTarget = NULL;

  Ogre::HardwarePixelBufferSharedPtr lRttBuffer = texture_->getBuffer();
  lRenderTarget = lRttBuffer->getRenderTarget();
  lRenderTarget->setAutoUpdated(true);

  // Create and attach viewport

  Ogre::Viewport* lRttViewport1 = lRenderTarget->addViewport(camera, 50, 0.00f, 0.00f, 1.0f, 1.0f);
  lRttViewport1->setAutoUpdated(true);
  Ogre::ColourValue lBgColor1(0.0,0.0,0.0,1.0);
  lRttViewport1->setBackgroundColour(lBgColor1);

  // create a material using this texture.

  //Get a reference on the material manager, which is a singleton.
  Ogre::MaterialManager& lMaterialManager = Ogre::MaterialManager::getSingleton();
  Ogre::MaterialPtr lMaterial = lMaterialManager.create(m_materialName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
  Ogre::Technique * lTechnique = lMaterial->getTechnique(0);
  Ogre::Pass* lPass = lTechnique->getPass(0);

  if( isDepth )
  {
	  lPass->setLightingEnabled(false);
  }

  Ogre::TextureUnitState* lTextureUnit = lPass->createTextureUnitState();
  lTextureUnit->setTextureName(textureName);

  lTextureUnit->setNumMipmaps(0);
  lTextureUnit->setTextureFiltering(Ogre::TFO_BILINEAR);

  update();
}
开发者ID:Praveen-Ramanujam,项目名称:srs_public,代码行数:85,代码来源:ros_rtt_texture.cpp

示例13: createScene

void RenderState::createScene()
{
        ////////////////////// Volume texture
        // breadVolume.createTexture("media/fields/imagen3-1.field", "volumeTex");
        // breadVolume.createTexture("media/fields/mengel3d.field", "volumeTex");
        // breadVolume.createTexture("media/fields/3Dbread.256.field", "volumeTex");
        breadDensityVolume.createTexture("media/fields/warped.field", "densityTex");
        breadDensityTex = breadDensityVolume.getTexturePtr();
        if (breadDensityTex.isNull()) {
                printf("Error generating density texture");
                exit();
        }

        breadCrustVolume.createTexture("media/fields/warpedC.field", "crustTex");
        breadCrustTex = breadCrustVolume.getTexturePtr();
        if (breadCrustTex.isNull()) {
                printf("Error generating crust texture");
                exit();
        }

        breadOcclusionVolume.createTexture("media/fields/warpedO.field", "occlusionTex");
        breadOcclusionTex = breadOcclusionVolume.getTexturePtr();
        if (breadOcclusionTex.isNull()) {
                printf("Error generating occlusion texture");
                exit();
        }

        ///////////////////// Volume bounding cubes
        breadVolumeBoundingCubes.create(breadDensityVolume, 32, 1, 255, _sceneMgr);

        //////////// Background color
        Ogre::Viewport* vp = OgreFramework::getSingletonPtr()->_viewport;
        vp->setBackgroundColour (ColourValue(0.1,0.1,0.1));

        //////////// Light
        _sceneMgr->setAmbientLight(ColourValue(0.1,0.1,0.1));

        light = _sceneMgr->createLight("Light");
        // light->setType(Light::LT_POINT);
        light->setType(Light::LT_SPOTLIGHT);
        light->setPosition(100,100,100);
        light->setDirection(100,-100,100);
        light->setDiffuseColour(1,1,1);
        light->setSpecularColour(1.0,1.0,1.0);
        light->setSpotlightRange(Radian(M_PI/2), Radian(M_PI/3));
        // light->setAttenuation(20, 0.5, 1, 1);
        
        //////////// Shadows
        // _sceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);
        // _sceneMgr->setShadowTextureSettings( 256, 2);
        // _sceneMgr->setShadowTextureConfig( 0, 512, 512, PF_FLOAT16_R, 50 );

        ////////////////////// BREAD
        breadEntity = _sceneMgr->createEntity("BreadEntity", "Cube01.mesh");
        breadNode = _sceneMgr->getRootSceneNode()->createChildSceneNode("BreadNode");
        breadNode->attachObject(breadEntity);
        breadNode->setOrientation(Quaternion::IDENTITY);
        breadNode->setPosition(Vector3(0, 0, 0));
        breadNode->setScale(Vector3(20,20,20));
        // breadEntity->setRenderQueueGroup(RENDER_QUEUE_8);
        breadEntity->setCastShadows(true);

        breadEntity->getSubEntity(0)->setMaterialName("Bread","General");
        breadMat = breadEntity->getSubEntity(0)->getMaterial();

        Ogre::Pass* breadPass = breadMat->getTechnique(0)->getPass(0);

        Ogre::TextureUnitState* posTU = breadPass->createTextureUnitState("rayPos");
        Ogre::TextureUnitState* dirTU = breadPass->createTextureUnitState("rayDir");

        posTU->setTextureName("rayPos");
        dirTU->setTextureName("rayDir");

        posTU->setTextureFiltering(TFO_NONE);
        dirTU->setTextureFiltering(TFO_NONE);

        posTU->setTextureAddressingMode(TextureUnitState::TAM_CLAMP);
        dirTU->setTextureAddressingMode(TextureUnitState::TAM_CLAMP);
        
        /////////////////////// TABLE
        tableEntity = _sceneMgr->createEntity("PlaneEntity", "Plane.mesh");
        tableEntity->getSubEntity(0)->setMaterialName("Table","General");
        tableEntity->setCastShadows(false);
        tableNode = _sceneMgr->getRootSceneNode()->createChildSceneNode("PlaneNode");
        tableNode->attachObject(tableEntity);
        tableNode->setOrientation(Quaternion::IDENTITY);
        tableNode->setPosition(Vector3(0, 0, 0));
        tableNode->setScale(Vector3(10,10,10));

        /////////////////////// KNIFE
        knifeEntity = _sceneMgr->createEntity("KnifeEntity", "knife.mesh");
        knifeEntity->getSubEntity(0)->setMaterialName("Knife","General");
        knifeEntity->setCastShadows(false);
        knifeNode = _sceneMgr->getRootSceneNode()->createChildSceneNode("KnifeNode");
        knifeNode->attachObject(knifeEntity);
        Quaternion ori(Radian(-0.5), Vector3(0,1,0));
        knifeNode->setOrientation(ori);
        knifeNode->setPosition(Vector3(30, 1, -30));
        knifeNode->setScale(Vector3(50,50,50));

//.........这里部分代码省略.........
开发者ID:rbaravalle,项目名称:breaddemo,代码行数:101,代码来源:RenderState.cpp

示例14: onInitialize

void CameraDisplay::onInitialize()
{
  caminfo_tf_filter_ = new tf::MessageFilter<sensor_msgs::CameraInfo>(*vis_manager_->getTFClient(), "", 2, update_nh_);

  bg_scene_node_ = scene_manager_->getRootSceneNode()->createChildSceneNode();
  fg_scene_node_ = scene_manager_->getRootSceneNode()->createChildSceneNode();

  {
    static int count = 0;
    UniformStringStream ss;
    ss << "CameraDisplayObject" << count++;

    //background rectangle
    bg_screen_rect_ = new Ogre::Rectangle2D(true);
    bg_screen_rect_->setCorners(-1.0f, 1.0f, 1.0f, -1.0f);

    ss << "Material";
    bg_material_ = Ogre::MaterialManager::getSingleton().create( ss.str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
    bg_material_->setDepthWriteEnabled(false);

    bg_material_->setReceiveShadows(false);
    bg_material_->setDepthCheckEnabled(false);

    bg_material_->getTechnique(0)->setLightingEnabled(false);
    Ogre::TextureUnitState* tu = bg_material_->getTechnique(0)->getPass(0)->createTextureUnitState();
    tu->setTextureName(texture_.getTexture()->getName());
    tu->setTextureFiltering( Ogre::TFO_NONE );
    tu->setAlphaOperation( Ogre::LBX_SOURCE1, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, 0.0 );

    bg_material_->setCullingMode(Ogre::CULL_NONE);
    bg_material_->setSceneBlending( Ogre::SBT_REPLACE );

    Ogre::AxisAlignedBox aabInf;
    aabInf.setInfinite();

    bg_screen_rect_->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND);
    bg_screen_rect_->setBoundingBox(aabInf);
    bg_screen_rect_->setMaterial(bg_material_->getName());

    bg_scene_node_->attachObject(bg_screen_rect_);
    bg_scene_node_->setVisible(false);

    //overlay rectangle
    fg_screen_rect_ = new Ogre::Rectangle2D(true);
    fg_screen_rect_->setCorners(-1.0f, 1.0f, 1.0f, -1.0f);

    fg_material_ = bg_material_->clone( ss.str()+"fg" );
    fg_screen_rect_->setBoundingBox(aabInf);
    fg_screen_rect_->setMaterial(fg_material_->getName());

    fg_material_->setSceneBlending( Ogre::SBT_TRANSPARENT_ALPHA );
    fg_screen_rect_->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY - 1);

    fg_scene_node_->attachObject(fg_screen_rect_);
    fg_scene_node_->setVisible(false);
  }

  setAlpha( 0.5f );

  render_panel_ = new RenderPanel();
  render_panel_->getRenderWindow()->addListener( this );
  render_panel_->getRenderWindow()->setAutoUpdated(false);
  render_panel_->getRenderWindow()->setActive( false );
  render_panel_->resize( 640, 480 );
  render_panel_->initialize(vis_manager_->getSceneManager(), vis_manager_);

  WindowManagerInterface* wm = vis_manager_->getWindowManager();
  if( wm )
  {
    panel_container_ = wm->addPane(name_, render_panel_);
  }
  render_panel_->setAutoRender(false);
  render_panel_->setOverlaysEnabled(false);
  render_panel_->getCamera()->setNearClipDistance( 0.01f );

  caminfo_tf_filter_->connectInput(caminfo_sub_);
  caminfo_tf_filter_->registerCallback(boost::bind(&CameraDisplay::caminfoCallback, this, _1));
  vis_manager_->getFrameManager()->registerFilterForTransformStatusCheck(caminfo_tf_filter_, this);

  if( panel_container_ )
  {
    // TODO: wouldn't it be better to connect this straight to the wrapper?
    connect( panel_container_, SIGNAL( visibilityChanged( bool ) ), this, SLOT( setWrapperEnabled( bool )));
  }
}
开发者ID:efernandez,项目名称:lcsr_nettools,代码行数:85,代码来源:camera_display.cpp

示例15: addPassToTechnique


//.........这里部分代码省略.........
//     textureUnitState->setTextureAddressingMode(Ogre::TextureUnitState::TAM_WRAP);
// /*	textureUnitState->setTextureCoordSet(0);*/
// 	textureUnitState->setTextureScale(0.025, 0.025);
// 	textureUnitState->setColourOperationEx(Ogre::LBX_BLEND_CURRENT_ALPHA, Ogre::LBS_TEXTURE, Ogre::LBS_CURRENT);
//
// /*	Ogre::TextureUnitState * alphaTextureState= pass->createTextureUnitState();
//     alphaTextureState->setTextureName(mTextureName);
// //     alphaTextureState->setTextureName(splatTextureName);
//     alphaTextureState->setTextureCoordSet(0);
// 	alphaTextureState->setTextureFiltering(Ogre::TFO_ANISOTROPIC);
//     alphaTextureState->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
//  	alphaTextureState->setColourOperationEx(Ogre::LBX_BLEND_DIFFUSE_ALPHA, Ogre::LBS_CURRENT, Ogre::LBS_TEXTURE);
//
//
//
// // 	detailTextureState->setAlphaOperation(Ogre::LBX_SOURCE1, Ogre::LBS_TEXTURE, Ogre::LBS_TEXTURE);
// // 	detailTextureState->setColourOperationEx(Ogre::LBX_SOURCE1, Ogre::LBS_CURRENT, Ogre::LBS_CURRENT);
//
// 	Ogre::TextureUnitState * detailTextureState  = pass->createTextureUnitState();
//     detailTextureState ->setTextureName(splatTextureName);
// //     detailTextureState ->setTextureName(mTextureName);
//     detailTextureState ->setTextureAddressingMode(Ogre::TextureUnitState::TAM_WRAP);
// 	detailTextureState ->setTextureCoordSet(0);
// 	detailTextureState ->setTextureScale(0.01, 0.01);
// 	//detailTextureState ->setColourOperationEx(Ogre::LBX_BLEND_CURRENT_ALPHA, Ogre::LBS_TEXTURE, Ogre::LBS_CURRENT);*/
//
// }
//
Ogre::Pass* Simple::addPassToTechnique(const TerrainPageGeometry& geometry, Ogre::Technique* technique, const Layer& layer, std::set<std::string>& managedTextures) const
{
	//check if we instead can reuse the existing pass
	// 	if (technique->getNumPasses() != 0) {
	// 		Ogre::Pass* pass = technique->getPass(technique->getNumPasses() - 1);
	// 		if (4 - pass->getNumTextureUnitStates() >= 2) {
	// 			//there's more than two texture units available, use those instead of creating a new pass
	// 			S_LOG_VERBOSE("Reusing existing pass. ("<< pass->getNumTextureUnitStates() << " of "<< mNumberOfTextureUnitsOnCard << " texture unit used)");
	// 			addTextureUnitsToPass(pass, splatTextureName);
	// 			return pass;
	// 		}
	//
	// 	}

	const OgreImage& ogreImage = *layer.blendMap;
	Ogre::Image image;

	image.loadDynamicImage(const_cast<unsigned char*>(ogreImage.getData()), ogreImage.getResolution(), ogreImage.getResolution(), 1, Ogre::PF_A8);

	std::stringstream splatTextureNameSS;
	splatTextureNameSS << "terrain_" << mPage.getWFPosition().x() << "_" << mPage.getWFPosition().y() << "_" << technique->getNumPasses();
	const Ogre::String splatTextureName(splatTextureNameSS.str());
	Ogre::TexturePtr blendMapTexture;
	if (Ogre::Root::getSingletonPtr()->getTextureManager()->resourceExists(splatTextureName)) {
		blendMapTexture = static_cast<Ogre::TexturePtr>(Ogre::Root::getSingletonPtr()->getTextureManager()->getByName(splatTextureName));
		blendMapTexture->loadImage(image);

		Ogre::HardwarePixelBufferSharedPtr hardwareBuffer(blendMapTexture->getBuffer());
		//blit the whole image to the hardware buffer
		Ogre::PixelBox sourceBox(image.getPixelBox());
		hardwareBuffer->blitFromMemory(sourceBox);
	} else {
		blendMapTexture = Ogre::Root::getSingletonPtr()->getTextureManager()->loadImage(splatTextureName, "General", image, Ogre::TEX_TYPE_2D, 0);
		managedTextures.insert(blendMapTexture->getName());
	}

	//we need to create the image, update it and then destroy it again (to keep the memory usage down)
	//	if (layer->getBlendMapTextureName() == "") {
	//		//no texture yet; let's create one
	//		layer->createBlendMapImage();
	//		layer->updateBlendMapImage(geometry);
	//		layer->createTexture();
	//	} else {
	//		//a texture exists, so we just need to update the image
	//		layer->updateBlendMapImage(geometry); //calling this will also update the texture since the method will blit the image onto it
	//	}

	Ogre::Pass* pass = technique->createPass();

	pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
	pass->setAmbient(1, 1, 1);
	pass->setDiffuse(1, 1, 1, 1);
	pass->setLightingEnabled(false);

	Ogre::TextureUnitState * textureUnitState = pass->createTextureUnitState();
	textureUnitState->setTextureName(layer.surfaceLayer.getDiffuseTextureName());
	textureUnitState->setTextureAddressingMode(Ogre::TextureUnitState::TAM_WRAP);
	textureUnitState->setTextureCoordSet(0);
	textureUnitState->setTextureScale(1.0f / layer.surfaceLayer.getScale(), 1.0f / layer.surfaceLayer.getScale());

	Ogre::TextureUnitState * textureUnitStateSplat = pass->createTextureUnitState();
	textureUnitStateSplat->setTextureName(blendMapTexture->getName());

	textureUnitStateSplat->setTextureCoordSet(0);
	textureUnitStateSplat->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
	textureUnitStateSplat->setTextureFiltering(Ogre::TFO_ANISOTROPIC);
	//	textureUnitStateSplat->setAlphaOperation(Ogre::LBX_SOURCE1, Ogre::LBS_TEXTURE, Ogre::LBS_TEXTURE);
	textureUnitStateSplat->setAlphaOperation(Ogre::LBX_BLEND_DIFFUSE_COLOUR, Ogre::LBS_TEXTURE, Ogre::LBS_CURRENT);
	textureUnitStateSplat->setColourOperationEx(Ogre::LBX_SOURCE1, Ogre::LBS_CURRENT, Ogre::LBS_CURRENT);
	return pass;

}
开发者ID:Chimangoo,项目名称:ember,代码行数:101,代码来源:Simple.cpp


注:本文中的ogre::TextureUnitState::setTextureFiltering方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。