|
楼主 |
发表于 2010-1-18 16:08:16
|
显示全部楼层
osg文件中的代码如下:
textureUnit 0 {
GL_TEXTURE_2D ON
Texture2D {
UniqueID Texture2D_0
file "images\\XJ-shui-tongyiTGA.dds"
wrap_s REPEAT
wrap_t REPEAT
wrap_r CLAMP_TO_EDGE
min_filter LINEAR_MIPMAP_NEAREST
mag_filter LINEAR
maxAnisotropy 1
borderColor 0 0 0 0
borderWidth 0
useHardwareMipMapGeneration TRUE
unRefImageDataAfterApply TRUE
internalFormatMode USE_S3TC_DXT3_COMPRESSION
resizeNonPowerOfTwo TRUE
}
TexEnvCombine {
UniqueID TexEnvCombine_1
combine_RGB REPLACE
combine_Alpha INTERPOLATE
source0_RGB PREVIOUS
source1_RGB PREVIOUS
source2_RGB CONSTANT
source0_Alpha TEXTURE
source1_Alpha PREVIOUS
source2_Alpha CONSTANT
operand0_RGB SRC_COLOR
operand1_RGB SRC_COLOR
operand2_RGB SRC_ALPHA
operand0_Alpha SRC_ALPHA
operand1_Alpha SRC_ALPHA
operand2_Alpha SRC_ALPHA
scale_RGB 1
scale_Alpha 1
constantColor 1 1 1 1
}
}
textureUnit 1 {
GL_TEXTURE_2D ON
Use Texture2D_0
}
}
我的目的是将 textureUnit 0中的TexEnvCombine 设置到 textureUnit 1 ,并将textureUnit 0中的删掉,我的实现如下:
osg::StateSet::TextureAttributeList& texAttriblist = state->getTextureAttributeList();
if (texAttriblist.size() == 2)
{
osg::TexEnvCombine *texenv = dynamic_cast<osg::TexEnvCombine*>(state->getTextureAttribute(0,osg::StateAttribute::TEXENV));
if (texenv)
{
state->removeAttribute(texenv);
state->setTextureAttributeAndModes(1,texenv, osg::StateAttribute::ON);
}
}
完成后 textureUnit 1中的成功设置,但是 textureUnit 0中的没有删掉,请问我的实现有什么错误?谢谢! |
|