本文整理汇总了C++中StateSet::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ StateSet::getAttribute方法的具体用法?C++ StateSet::getAttribute怎么用?C++ StateSet::getAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StateSet
的用法示例。
在下文中一共展示了StateSet::getAttribute方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyColorTexture
/***************************************************************
* Function: applyColorTexture()
***************************************************************/
void CAVEGeode::applyColorTexture(const Vec3 &diffuse, const Vec3 &specular, const float &alpha, const string &texFilename)
{
StateSet *stateset = getOrCreateStateSet();
/* update material parameters */
Material *material = dynamic_cast <Material*> (stateset->getAttribute(StateAttribute::MATERIAL));
if (!material)
material = new Material;
material->setDiffuse(Material::FRONT_AND_BACK, Vec4(diffuse, 1.f));
material->setSpecular(Material::FRONT_AND_BACK, Vec4(specular, 1.f));
material->setAlpha(Material::FRONT_AND_BACK, alpha);
stateset->setAttributeAndModes(material, StateAttribute::ON);
/* update texture image */
Texture2D *texture = dynamic_cast <Texture2D*> (stateset->getAttribute(StateAttribute::TEXTURE));
if (!texture)
texture = new Texture2D;
Image* texImage = osgDB::readImageFile(texFilename);
texture->setImage(texImage);
texture->setWrap(Texture::WRAP_S,Texture::REPEAT);
texture->setWrap(Texture::WRAP_T,Texture::REPEAT);
texture->setDataVariance(Object::DYNAMIC);
stateset->setTextureAttributeAndModes(0, texture, StateAttribute::ON);
stateset->setMode(GL_BLEND, StateAttribute::OVERRIDE | osg::StateAttribute::ON );
stateset->setRenderingHint(StateSet::TRANSPARENT_BIN);
/* update of color & texture properties */
mDiffuse = diffuse;
mSpecular = specular;
mAlpha = alpha;
mTexFilename = texFilename;
}
示例2:
void Object3D::setObjectTextureState(Image *image, bool flipVertically)
{
// retrieve or create a StateSet
StateSet* stateTexture = _originalNode->getOrCreateStateSet();
if(stateTexture && image)
{
// create a new two-dimensional texture object
Texture2D *texCube = new Texture2D;
texCube->setDataVariance(Object::DYNAMIC);
// set the texture to the loaded image
texCube->setImage(image);
texCube->setResizeNonPowerOfTwoHint(false);
texCube->setWrap(Texture2D::WRAP_S, Texture2D::REPEAT);
texCube->setWrap(Texture2D::WRAP_T, Texture2D::REPEAT);
// set the texture to the state
stateTexture->setTextureAttributeAndModes(0, texCube, StateAttribute::ON|StateAttribute::OVERRIDE);
if(flipVertically)
{
// apply a vertical (Y component) flip on the texture coordinates
TexMat *texMat = dynamic_cast<TexMat*>(stateTexture->getAttribute(StateAttribute::TEXMAT,0));
if(!texMat)
texMat = new TexMat;
Matrix M = Matrix::scale(1, -1, 1);
texMat->setMatrix(M);
stateTexture->setTextureAttributeAndModes(0, texMat, StateAttribute::ON|StateAttribute::OVERRIDE);
}
}
}
示例3: applyAlpha
/***************************************************************
* Function: applyAlpha()
***************************************************************/
void CAVEGeode::applyAlpha(const float &alpha)
{
StateSet *stateset = getOrCreateStateSet();
/* update material parameters */
Material *material = dynamic_cast <Material*> (stateset->getAttribute(StateAttribute::MATERIAL));
if (!material) material = new Material;
material->setAlpha(Material::FRONT_AND_BACK, alpha);
stateset->setAttributeAndModes(material, StateAttribute::ON);
/* update alpha value */
mAlpha = alpha;
}
示例4: setVSParamountPreviewHighlight
/***************************************************************
* Function: setVSParamountPreviewHighlight()
***************************************************************/
void VirtualScenicHandler::setVSParamountPreviewHighlight(bool flag, Geode *paintGeode)
{
StateSet *stateset = paintGeode->getOrCreateStateSet();
Material *material = dynamic_cast<Material*> (stateset->getAttribute(StateAttribute::MATERIAL));
if (!material)
material = new Material;
if (flag)
{
material->setAlpha(Material::FRONT_AND_BACK, 0.5f);
material->setDiffuse(Material::FRONT_AND_BACK, Vec4(0.3, 1.0, 0.3, 1.0));
material->setSpecular(Material::FRONT_AND_BACK, Vec4(0.3, 1.0, 0.3, 1.0));
}
else
{
material->setAlpha(Material::FRONT_AND_BACK, 1.0f);
material->setDiffuse(Material::FRONT_AND_BACK, Vec4(1, 1, 1, 1));
material->setSpecular(Material::FRONT_AND_BACK, Vec4(1, 1, 1, 1));
}
stateset->setAttributeAndModes(material, StateAttribute::OVERRIDE | StateAttribute::ON);
}
示例5: switchFloorplan
/***************************************************************
* Function: switchFloorplan()
***************************************************************/
void VirtualScenicHandler::switchFloorplan(const int &idx, const VisibilityOption &option)
{
if (idx >= mFloorplanSwitch->getNumChildren())
{
return;
}
if (option == INVISIBLE)
{
if (mFloorplanIdx >= 0)
{
mFloorplanSwitch->setSingleChildOn(mFloorplanIdx);
}
else
{
mFloorplanSwitch->setAllChildrenOff();
}
}
else
{
Geode *floorplanGeode = dynamic_cast <Geode*> (mFloorplanSwitch->getChild(idx));
StateSet *stateset = floorplanGeode->getOrCreateStateSet();
Material *material = dynamic_cast<Material*> (stateset->getAttribute(StateAttribute::MATERIAL));
if (!material)
{
material = new Material;
}
if (option == TRANSPARENT)
{
material->setAlpha(Material::FRONT_AND_BACK, 0.5f);
}
else if (option == SOLID)
{
material->setAlpha(Material::FRONT_AND_BACK, 1.0f);
mFloorplanIdx = idx;
}
mFloorplanSwitch->setSingleChildOn(idx);
}
}
示例6: applyStateSet
void DisplayRequirementsVisitor::applyStateSet(StateSet& stateset)
{
if (!_ds) _ds = new osg::DisplaySettings;
unsigned int min = 0; // assume stencil not needed by this stateset.
if (stateset.getMode(GL_STENCIL_TEST) & StateAttribute::ON)
{
min = 1; // number stencil bits we need at least.
}
if (stateset.getAttribute(StateAttribute::STENCIL))
{
min = 1; // number stencil bits we need at least.
}
if (min>_ds->getMinimumNumStencilBits())
{
// only update if new minimum exceeds previous minimum.
_ds->setMinimumNumStencilBits(min);
}
}
示例7: apply
virtual void apply( StateSet &ss )
{
inherited::apply( ss );
// Textures
int c = ss.getNumTextureAttributeLists();
for( int i=0; i<c; i++ )
{
Texture *t = dynamic_cast< Texture* >( ss.getTextureAttribute( i, StateAttribute::TEXTURE ) );
if( t )
{
++_numInstancedTextures;
_textureSet.insert( t );
}
}
// shader programs
Program *p = dynamic_cast< Program* >( ss.getAttribute( StateAttribute::PROGRAM ) );
if( p )
{
++_numInstancedShaderPrograms;
_shaderProgramSet.insert( p );
}
}