本文整理汇总了C++中TextureUnitState::setTextureFiltering方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureUnitState::setTextureFiltering方法的具体用法?C++ TextureUnitState::setTextureFiltering怎么用?C++ TextureUnitState::setTextureFiltering使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextureUnitState
的用法示例。
在下文中一共展示了TextureUnitState::setTextureFiltering方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createJorgeMaterial
// ---------------------------------------------------------------------
void MaterialService::createJorgeMaterial(const Ogre::String& resourceGroup) {
std::string shaderName("@template0");
if (!MaterialManager::getSingleton().resourceExists(shaderName)) {
MaterialPtr shadMat = MaterialManager::getSingleton().create(shaderName, resourceGroup);
shadMat->setReceiveShadows(true);
Pass *shadPass = shadMat->getTechnique(0)->getPass(0);
shadPass->setAmbient(0.5, 0.5, 0.5);
shadPass->setDiffuse(1, 1, 1, 1);
shadPass->setSpecular(1, 1, 1, 1);
// Texture unit state for the main texture...
// jorge.png is compiled-in - see the RenderService::prepareHardcodedMedia
TextureUnitState* tus = shadPass->createTextureUnitState("jorge.png");
// Set replace on all first layer textures for now
tus->setTextureAddressingMode(TextureUnitState::TAM_WRAP);
tus->setTextureCoordSet(0);
tus->setTextureFiltering(TFO_BILINEAR);
tus->setTextureUScale(1.0f);
tus->setTextureVScale(1.0f);
// No dynamic lighting
shadMat->setLightingEnabled(false);
shadMat->load();
addWorldMaterialTemplate(0, shadMat); // fixed at slot 0
}
}
示例2: prepareMaterialInstance
//------------------------------------------------------
void MaterialService::prepareMaterialInstance(MaterialPtr& mat, unsigned int idx, int tag) {
if (tag < 0) // Should not be here if the polygon is sky textured
OPDE_EXCEPT("Non-instanced material instance requested", "MaterialService::prepareMaterialInstance");
mat->setReceiveShadows(true);
StringUtil::StrStreamType lightmapName;
lightmapName << "@lightmap" << tag;
Pass *shadPass = mat->getTechnique(0)->getPass(0);
if (shadPass->getNumTextureUnitStates() <= 1) {
// Lightmap texture is added here
TextureUnitState* tex = shadPass->createTextureUnitState(lightmapName.str());
// Blend
tex->setColourOperation(LBO_MODULATE);
// Use 2nd texture co-ordinate set
tex->setTextureCoordSet(1);
// Clamp
tex->setTextureAddressingMode(TextureUnitState::TAM_CLAMP);
// Switch filtering off to see lmap pixels: TFO_NONE
tex->setTextureFiltering(TFO_BILINEAR);
} else {
// There is a definition of the lightmapping pass already, we only update that definition
TextureUnitState* tex = shadPass->getTextureUnitState(1);
tex->setTextureName(lightmapName.str());
tex->setTextureCoordSet(1);
}
}
示例3: makeMaterialReceiveDecal
void FiveApp::makeMaterialReceiveDecal(const String & matName)
{
MaterialPtr mat = (MaterialPtr)MaterialManager::getSingleton().getByName(matName);
Pass *pass = mat->getTechnique(0)->createPass();
pass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
pass->setDepthBias(1);
pass->setLightingEnabled(true);
TextureUnitState *texState = pass->createTextureUnitState("decal.png");
texState->setProjectiveTexturing(true,mDecalFrustum);
texState->setTextureAddressingMode(TextureUnitState::TAM_CLAMP);
texState->setTextureFiltering(FO_LINEAR,FO_LINEAR,FO_NONE);
texState = pass->createTextureUnitState("decal_filter.png");
texState->setProjectiveTexturing(true,mFilterFrustum);
texState->setTextureAddressingMode(TextureUnitState::TAM_CLAMP);
texState->setTextureFiltering(TFO_NONE);
}
示例4:
void Canvas::Texture::createMaterial()
{
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create(mTexture->getName(), "General");
Pass* pass = material->getTechnique(0)->getPass(0);
pass->setDepthCheckEnabled(false);
pass->setDepthWriteEnabled(false);
pass->setLightingEnabled(false);
pass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
TextureUnitState* texUnit = pass->createTextureUnitState(mTexture->getName());
texUnit->setTextureFiltering(FO_NONE, FO_NONE, FO_NONE);
}
示例5: createWebcamMaterial
void GPUSurfApplication::createWebcamMaterial()
{
Ogre::DShowTextureSource *videoTextureSource = (DShowTextureSource *)Ogre::ExternalTextureSourceManager::getSingleton().getExternalTextureSource("dshow");
if(videoTextureSource == NULL)
{
OGRE_EXCEPT(Exception::ERR_FILE_NOT_FOUND, "Could not find Plugin_DShow.dll", "GPUSurfApplication::createWebcamMaterial()");
}
try
{
//create texture
videoTextureSource->initialise();
//videoTextureSource->setInputFileName(videoFileName);
videoTextureSource->setInputCaptureDevice(0);
videoTextureSource->setFPS(90);
videoTextureSource->setVideoSize(640, 480);
mVideo = videoTextureSource->_createVideo("WebcamVideoTexture");
mVideo->createTexture("WebcamVideoTexture");
mVideo->load();
mVideo->start();
mVideo->addListener(mGPUSurf);
//create material
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("WebcamVideoMaterial", "General");
Pass* pass = material->getTechnique(0)->getPass(0);
pass->setDepthCheckEnabled(false);
pass->setDepthWriteEnabled(false);
pass->setLightingEnabled(false);
pass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
TextureUnitState* texUnit = pass->createTextureUnitState("WebcamVideoTexture");
texUnit->setTextureFiltering(FO_POINT, FO_POINT, FO_POINT);
}
catch (const InternalErrorException &)
{
OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, "Could not init webcam", "GPUSurfApplication::createWebcamMaterial()");
}
}
示例6: addTerrainBlockerPass
// 为地形添加一个障碍区域的显示Pass
void TerrainEditorPlugin::addTerrainBlockerPass(ETTerrain *terrain)
{
MaterialPtr mat = terrain->getTerrainImpl()->getMaterial();
Technique *tech = mat->getTechnique(0);
// 看有没有这个Blocker的Pass,如果有就不用添加了
for(size_t i = 0 ; i < tech->getNumPasses() ; i ++)
{
if(tech->getPass(i)->getName() == "Blocker")
return;
}
Pass *blockerPass = mat->getTechnique(0)->createPass();
blockerPass->setName("Blocker");
// 使用透明渲染
blockerPass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
blockerPass->setVertexProgram("ET/Programs/VSLodMorph2");
//blockerPass->setPolygonMode(PM_WIREFRAME);
//blockerPass->setLightingEnabled(false);
blockerPass->setCullingMode(CULL_ANTICLOCKWISE);
//blockerPass->setDepthCheckEnabled(false);
// 创建个贴图
TextureUnitState *state = blockerPass->createTextureUnitState(terrain->getBlockerTexture()->getName());
state->setTextureFiltering(TFO_NONE);
}
示例7: initialise
//.........这里部分代码省略.........
{
float xcoord = coords[y][0]-0.5;
float ycoord = coords[y][1]-0.5;
float zcoord = -((float)x/(float)(mSlices-1) - 0.5f);
// 1.0f .. a/(a+1)
// coordinate
vertices[x*4*elemsize+y*elemsize+0] = xcoord*(mSize/2.0f);
vertices[x*4*elemsize+y*elemsize+1] = ycoord*(mSize/2.0f);
vertices[x*4*elemsize+y*elemsize+2] = zcoord*(mSize/2.0f);
// normal
vertices[x*4*elemsize+y*elemsize+3] = 0.0f;
vertices[x*4*elemsize+y*elemsize+4] = 0.0f;
vertices[x*4*elemsize+y*elemsize+5] = 1.0f;
// tex
vertices[x*4*elemsize+y*elemsize+6] = xcoord*sqrtf(3.0f);
vertices[x*4*elemsize+y*elemsize+7] = ycoord*sqrtf(3.0f);
vertices[x*4*elemsize+y*elemsize+8] = zcoord*sqrtf(3.0f);
}
}
unsigned short *faces = new unsigned short[mSlices*6];
for(x=0; x<mSlices; x++)
{
faces[x*6+0] = x*4+0;
faces[x*6+1] = x*4+1;
faces[x*6+2] = x*4+2;
faces[x*6+3] = x*4+1;
faces[x*6+4] = x*4+2;
faces[x*6+5] = x*4+3;
}
// Setup buffers
vdata->vertexStart = 0;
vdata->vertexCount = nvertices;
VertexDeclaration* decl = vdata->vertexDeclaration;
VertexBufferBinding* bind = vdata->vertexBufferBinding;
size_t offset = 0;
decl->addElement(0, offset, VET_FLOAT3, VES_POSITION);
offset += VertexElement::getTypeSize(VET_FLOAT3);
decl->addElement(0, offset, VET_FLOAT3, VES_NORMAL);
offset += VertexElement::getTypeSize(VET_FLOAT3);
decl->addElement(0, offset, VET_FLOAT3, VES_TEXTURE_COORDINATES);
offset += VertexElement::getTypeSize(VET_FLOAT3);
HardwareVertexBufferSharedPtr vbuf =
HardwareBufferManager::getSingleton().createVertexBuffer(
offset, nvertices, HardwareBuffer::HBU_STATIC_WRITE_ONLY);
bind->setBinding(0, vbuf);
vbuf->writeData(0, vbuf->getSizeInBytes(), vertices, true);
HardwareIndexBufferSharedPtr ibuf = HardwareBufferManager::getSingleton().
createIndexBuffer(
HardwareIndexBuffer::IT_16BIT,
mSlices*6,
HardwareBuffer::HBU_STATIC_WRITE_ONLY);
idata->indexBuffer = ibuf;
idata->indexCount = mSlices*6;
idata->indexStart = 0;
ibuf->writeData(0, ibuf->getSizeInBytes(), faces, true);
// Delete temporary buffers
delete [] vertices;
delete [] faces;
// Now make the render operation
mRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
mRenderOp.indexData = idata;
mRenderOp.vertexData = vdata;
mRenderOp.useIndexes = true;
// Create a brand new private material
MaterialPtr material =
MaterialManager::getSingleton().create(mTexture, "VolumeRenderable",
false, 0); // Manual, loader
// Remove pre-created technique from defaults
material->removeAllTechniques();
// Create a techinique and a pass and a texture unit
Technique * technique = material->createTechnique();
Pass * pass = technique->createPass();
TextureUnitState * textureUnit = pass->createTextureUnitState();
// Set pass parameters
pass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
pass->setDepthWriteEnabled(false);
pass->setCullingMode(CULL_NONE);
pass->setLightingEnabled(false);
// Set texture unit parameters
textureUnit->setTextureAddressingMode(TextureUnitState::TAM_CLAMP);
textureUnit->setTextureName(mTexture, TEX_TYPE_3D);
textureUnit->setTextureFiltering(TFO_TRILINEAR);
mUnit = textureUnit;
m_pMaterial = material;
}
示例8: createStandardMaterial
//-----------------------------------------------------------------------
void MaterialService::createStandardMaterial(unsigned int idx, std::string matName, std::string textureName,
std::string resourceGroup) {
Image tex;
bool loaded = false; // indicates we were successful finding the texture
StringVectorPtr texnames = ResourceGroupManager::getSingleton().findResourceNames(resourceGroup, textureName
+ ".*");
if (texnames->size() <= 0) {
// no results, try the localised version
// prev. path + /language/filename
String locresname = mConfigService->getLocalisedResourcePath(textureName);
LOG_INFO("Specified resource (%s) was not found, trying localized version: %s", textureName.c_str(), locresname.c_str());
texnames = ResourceGroupManager::getSingleton().findResourceNames(resourceGroup, locresname
+ ".*");
}
String txtfile;
// Let's try the extensions from the extensions vector
StringVector::iterator it = texnames->begin();
for (; it != texnames->end(); it++) { // Try loading every given
try {
tex.load((*it), resourceGroup);
TextureManager::getSingleton().loadImage(textureName, resourceGroup, tex, TEX_TYPE_2D, 5, 1.0f);
txtfile = (*it);
loaded = true;
break; // we got it!
} catch (Ogre::Exception) {
// Nothing. We are trying more extensions
}
}
if (!loaded)
LOG_ERROR("Image %s was not found, texture will be invalid!", textureName.c_str());
// Construct a material out of this texture. We'll just clone the material upstairs to enable lmap-txture combinations
MaterialPtr shadMat = MaterialManager::getSingleton().create(matName, resourceGroup);
shadMat->setReceiveShadows(true);
Pass *shadPass = shadMat->getTechnique(0)->getPass(0);
shadPass->setAmbient(0.5, 0.5, 0.5);
shadPass->setDiffuse(1, 1, 1, 1);
shadPass->setSpecular(1, 1, 1, 1);
TextureUnitState* tus = createAnimatedTextureState(shadPass, txtfile, resourceGroup, 5);
// Set replace on all first layer textures for now
// tus->setColourOperation(LBO_REPLACE);
tus->setTextureAddressingMode(TextureUnitState::TAM_WRAP);
tus->setTextureCoordSet(0);
tus->setTextureFiltering(TFO_BILINEAR);
tus->setTextureUScale(1.0f);
tus->setTextureVScale(1.0f);
// tus->setTextureFiltering(TFO_NONE);
// Set culling mode to none
// shadMat->setCullingMode(CULL_ANTICLOCKWISE);
// No dynamic lighting
shadMat->setLightingEnabled(false);
// DYNL:
shadMat->load();
// standard size
addWorldMaterialTemplate(idx, shadMat);
}