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


C++ StateSet::setMode方法代码示例

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


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

示例1: initLabels

void TextureWidget::initLabels()
{
  StateSet* stateSet;
  Vec3 pos(0.0, -_height / 2.0, EPSILON_Z);

  _label0 = new osgText::Text();
  _label0->setDataVariance(Object::DYNAMIC);
  _label0->setFont(osgText::readFontFile("fonts/arial.ttf"));
  _label0->setColor(COL_WHITE);
  _label0->setFontResolution(20, 20);
  _label0->setPosition(pos);
  _label0->setCharacterSize(DEFAULT_FONT_SIZE);
  _label0->setMaximumWidth(_width);
  _label0->setMaximumHeight(DEFAULT_LABEL_HEIGHT);
  _label0->setAlignment(osgText::Text::CENTER_CENTER);
  _label0->setUseDisplayList(false);

  stateSet = _label0->getOrCreateStateSet();
  stateSet->setMode(GL_LIGHTING, StateAttribute::OFF);

  _label1 = new osgText::Text();
  _label1->setDataVariance(Object::DYNAMIC);
  _label1->setFont(osgText::readFontFile("fonts/arial.ttf"));
  _label1->setColor(COL_WHITE);
  _label1->setFontResolution(20, 20);
  _label1->setPosition(pos);
  _label1->setCharacterSize(DEFAULT_FONT_SIZE);
  _label1->setMaximumWidth(_width);
  _label1->setMaximumHeight(DEFAULT_LABEL_HEIGHT);
  _label1->setAlignment(osgText::Text::CENTER_CENTER);
  _label1->setUseDisplayList(false);

  stateSet = _label1->getOrCreateStateSet();
  stateSet->setMode(GL_LIGHTING, StateAttribute::OFF);
}
开发者ID:dacevedofeliz,项目名称:calvr,代码行数:35,代码来源:TextureWidget.cpp

示例2: Geometry

// Constructor: CAVEGeodeSnapWireframe
CAVEGeodeSnapWireframe::CAVEGeodeSnapWireframe()
{
    // unit grid size 'mSnappingUnitDist' will inherit the default value 'gSnappingUnitDist' unless modified
    mSnappingUnitDist = gSnappingUnitDist;

    mInitPosition = Vec3(0, 0, 0);
    mScaleVect = Vec3(1, 1, 1);
    mDiagonalVect = Vec3(1, 1, 1);

    mBaseGeometry = new Geometry();
    mSnapwireGeometry = new Geometry();
    addDrawable(mBaseGeometry);
    addDrawable(mSnapwireGeometry);

    Material* material = new Material;
    material->setAmbient(Material::FRONT_AND_BACK, Vec4(0.0, 1.0, 0.0, 1.0));
    material->setDiffuse(Material::FRONT_AND_BACK, Vec4(1.0, 1.0, 0.0, 1.0));
    material->setSpecular(Material::FRONT_AND_BACK, osg::Vec4( 1.f, 1.f, 1.f, 1.0f));
    material->setAlpha(Material::FRONT_AND_BACK, 0.f);

    StateSet* stateset = new StateSet();
    stateset->setAttributeAndModes(material, StateAttribute::OVERRIDE | StateAttribute::ON);
    stateset->setMode(GL_BLEND, StateAttribute::OVERRIDE | osg::StateAttribute::ON );
    stateset->setMode(GL_LIGHTING, StateAttribute::OVERRIDE | StateAttribute::ON );
    stateset->setRenderingHint(StateSet::TRANSPARENT_BIN);
    setStateSet(stateset);
}
开发者ID:CalVR,项目名称:calvr_plugins,代码行数:28,代码来源:CAVEGeodeSnapWireframe.cpp

示例3: Widget

TextureWidget::TextureWidget(Interaction* interaction, float width, float height) :  Widget(), Events()
{
  StateSet* stateSet;

  _interaction = interaction;

  _width = width;
  _height = height;

  createBackground();
  createTexturesGeometry();
  initLabels();
  initTextures();

  _texture[0] = new Geode();
  _texture[0]->addDrawable(_geom);
  _texture[0]->addDrawable(_label0);
  _texture[0]->addDrawable(_texGeom0);
  stateSet = _texGeom0->getOrCreateStateSet();
  stateSet->setMode(GL_LIGHTING, StateAttribute::OFF);
  stateSet->setRenderingHint(StateSet::TRANSPARENT_BIN);
  stateSet->setTextureAttributeAndModes(StateAttribute::TEXTURE, _tex0, StateAttribute::ON);

  _texture[1] = new Geode();
  _texture[1]->addDrawable(_geom);
  _texture[1]->addDrawable(_label1);
  _texture[1]->addDrawable(_texGeom1);
  stateSet = _texGeom1->getOrCreateStateSet();
  stateSet->setMode(GL_LIGHTING, StateAttribute::OFF);
  stateSet->setRenderingHint(StateSet::TRANSPARENT_BIN);
  stateSet->setTextureAttributeAndModes(StateAttribute::TEXTURE, _tex1, StateAttribute::ON);

  _swTexture = new Switch();
  _swTexture->addChild(_texture[0]);
  _swTexture->addChild(_texture[1]);
  _swTexture->setSingleChildOn(0);

  _node->addChild(_swTexture.get());

  _leftGeode = new Geode();
  _rightGeode = new Geode();

  MatrixTransform* transLeft = new MatrixTransform();
  MatrixTransform* transRight = new MatrixTransform();

  Matrix trans;

  trans.makeTranslate(Vec3(-_width/2.0, -_height/2.0 - DEFAULT_LABEL_HEIGHT/2.0, 3*EPSILON_Z));
  transLeft->setMatrix(trans);
  transLeft->addChild(_leftGeode);

  trans.makeTranslate(Vec3(+_width/2.0, -_height/2.0 - DEFAULT_LABEL_HEIGHT/2.0, 3*EPSILON_Z));
  transRight->setMatrix(trans);
  transRight->addChild(_rightGeode);

  _node->addChild(transLeft);
  _node->addChild(transRight);

  _interaction->addListener(this, this);
}
开发者ID:dacevedofeliz,项目名称:calvr,代码行数:60,代码来源:TextureWidget.cpp

示例4: initStateset

void Virvo::initStateset()
{
    StateSet *stateset = new StateSet();
    stateset->setMode(GL_LIGHTING, StateAttribute::OFF);
    stateset->setMode(GL_BLEND, StateAttribute::ON);
    stateset->setRenderBinDetails(100, "RenderBin"); // draw after everything else
    setStateSet(stateset);
}
开发者ID:nixz,项目名称:covise,代码行数:8,代码来源:Virvo.cpp

示例5: setHighlight

void DSGeometryCreator::setHighlight(bool isHighlighted, const osg::Vec3 &pointerOrg, const osg::Vec3 &pointerPos) 
{
    int idx = -1;
    mIsHighlighted = isHighlighted;

    for (int i = 0; i < mNumShapeSwitches; i++)
    {
        ((osg::PositionAttitudeTransform*)(mShapeSwitchEntryArray[i]->mSwitch->getChild(0)))->removeChild(mHighlightGeode);
        mDSIntersector->loadRootTargetNode(gDesignStateRootGroup, 
            ((osg::PositionAttitudeTransform*)(mShapeSwitchEntryArray[i]->mSwitch->getChild(0)))->getChild(0));

        if (mDSIntersector->test(pointerOrg, pointerPos))
        {
            idx = i;
        }
    }

    if (idx > -1)
    {
        osg::Sphere *sphere = new osg::Sphere();
        mSD = new osg::ShapeDrawable(sphere);
        mHighlightGeode = new osg::Geode();
        mHighlightGeode->addDrawable(mSD);
        sphere->setRadius(0.25);
        mSD->setColor(osg::Vec4(1, 1, 1, 0.5));

        StateSet *stateset = mSD->getOrCreateStateSet();
        stateset->setMode(GL_BLEND, StateAttribute::OVERRIDE | StateAttribute::ON);
        stateset->setMode(GL_CULL_FACE, StateAttribute::OVERRIDE | StateAttribute::ON);
        stateset->setRenderingHint(StateSet::TRANSPARENT_BIN);

        //fwdVec[i]->addChild(mHighlightGeode);
        //((osg::Geode*)mShapeSwitchEntryArray[idx]->mSwitch->getChild(0))->addDrawable(mSD);
        //std::cout << idx << std::endl;

        ((osg::PositionAttitudeTransform*)(mShapeSwitchEntryArray[idx]->mSwitch->getChild(0)))->addChild(mHighlightGeode);
    }

    /*    else
    {
        for (int i = 0; i < mNumShapeSwitches; i++)
        {
            if (mHighlightGeode)
                ((osg::PositionAttitudeTransform*)(mShapeSwitchEntryArray[i]->mSwitch->getChild(0)))->removeChild(mHighlightGeode);
                //((osg::Geode*)mShapeSwitchEntryArray[i]->mSwitch->getChild(0))->removeDrawable(mSD);
        }
    }*/

    mDSIntersector->loadRootTargetNode(gDesignStateRootGroup, mSphereExteriorGeode);
}
开发者ID:cehughes,项目名称:calvr_plugins,代码行数:50,代码来源:DSGeometryCreator.cpp

示例6: mnv

Normals::Normals( Node *node, float scale, Mode mode )
{
    setName(mode == VertexNormals ? "VertexNormals" : "SurfaceNormals");

    MakeNormalsVisitor mnv(scale,mode);
    node->accept( mnv );

    ref_ptr<Vec3Array> coords = mnv.getCoords();
    ref_ptr<Vec4Array> colors = new Vec4Array;
    if( mode == SurfaceNormals )
        colors->push_back( Vec4( 0, 1, 0, 1 ));
    else if( mode == VertexNormals )
        colors->push_back( Vec4( 1, 0, 0, 1 ));

    ref_ptr<Geometry> geom = new Geometry;
    geom->setVertexArray( coords.get() );
    geom->setColorArray( colors.get() );
    geom->setColorBinding( Geometry::BIND_OVERALL );

    geom->addPrimitiveSet( new DrawArrays( PrimitiveSet::LINES, 0, coords->size()));

    StateSet *sset = new StateSet;
    sset->setMode( GL_LIGHTING,   StateAttribute::OFF);
    geom->setStateSet( sset );
    addDrawable( geom.get() );
}
开发者ID:amhagan,项目名称:osg,代码行数:26,代码来源:Normals.cpp

示例7: 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;
}
开发者ID:cehughes,项目名称:calvr_plugins,代码行数:35,代码来源:CAVEGeode.cpp

示例8: setBGTexture

void Panel::setBGTexture(unsigned char* img, int width, int height)
{
  //_texWidth = width;
  //_texHeight = height;

  Texture2D* texture;

  // Initialize panel texture:
  texture = new Texture2D();
  _panelImage = new Image();
  _panelImage->setImage(width, height, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, img, Image::USE_NEW_DELETE);
  texture->setImage(_panelImage);

  Vec2Array* texCoords = new Vec2Array(4);
  (*texCoords)[0].set(0.0, 0.0);
  (*texCoords)[1].set(1.0, 0.0);
  (*texCoords)[2].set(1.0, 1.0);
  (*texCoords)[3].set(0.0, 1.0);
  _geom->setTexCoordArray(0, texCoords);

  // Texture:
  StateSet* stateset = _geom->getOrCreateStateSet();
  stateset->setMode(GL_LIGHTING, StateAttribute::OFF);
  stateset->setRenderingHint(StateSet::TRANSPARENT_BIN);
  stateset->setTextureAttributeAndModes(0, texture, StateAttribute::ON);

  _panelImage->dirty();
}
开发者ID:dacevedofeliz,项目名称:calvr,代码行数:28,代码来源:Panel.cpp

示例9: setObjectBlendState

void Panel::setObjectBlendState(Geode *geodeCurrent)
{
  // retrieve or create a StateSet
  StateSet *stateBlend = geodeCurrent->getOrCreateStateSet();

  // create a new blend function using GL_SRC_ALPHA and GL_ONE
  BlendFunc *bf = new BlendFunc(GL_SRC_ALPHA,GL_ONE);

  // turn depth testing off
  // stateBlend->setMode(GL_DEPTH_TEST,StateAttribute::OFF);

  // turn standard OpenGL lighting on
  // stateBlend->setMode(GL_LIGHTING,StateAttribute::ON);

  // turn blending on
  stateBlend->setMode(GL_BLEND,StateAttribute::ON);

  // add rendering hint
  stateBlend->setRenderingHint(StateSet::TRANSPARENT_BIN);

  // add the blend function to the StateSet
  stateBlend->setAttribute(bf);

  // set the StateSet of the Geode to the one that was just created
  geodeCurrent->setStateSet(stateBlend);
}
开发者ID:dacevedofeliz,项目名称:calvr,代码行数:26,代码来源:Panel.cpp

示例10: createGeometry

Geometry* Panel::createGeometry()
{
  _geom = new Geometry();
  _panelVertices = new Vec3Array(4);

  setVertices();
  _geom->setVertexArray(_panelVertices);

  // Create normals:
  _normals = new Vec3Array(1);
  (*_normals)[0].set(0.0f, 0.0f, 1.0f);
  _geom->setNormalArray(_normals);
  _geom->setNormalBinding(Geometry::BIND_OVERALL);

  // Create colors:
  _BGcolor = new Vec4Array(1);
  setBGColor();
  _geom->setColorArray(_BGcolor);
  _geom->setColorBinding(Geometry::BIND_OVERALL);

  // Create quad:
  _geom->addPrimitiveSet(new DrawArrays(GL_QUADS,0,4));
  _geom->setUseDisplayList(false);

  StateSet* stateSet = _geom->getOrCreateStateSet();
  stateSet->setMode(GL_LIGHTING, StateAttribute::OFF);

  return _geom;
}
开发者ID:dacevedofeliz,项目名称:calvr,代码行数:29,代码来源:Panel.cpp

示例11:

/***************************************************************
* Function: createText()
***************************************************************/
Geode *CAVEGroupReferenceAxis::createText3D(osgText::Text3D **text)
{
    Geode *textGeode = new Geode;
    *text = new osgText::Text3D;
    textGeode->addDrawable(*text);

    (*text)->setFont(CAVEGeode::getDataDir() + "Fonts/TN.ttf");
    (*text)->setCharacterSize(gCharSize, 0.7);
    (*text)->setCharacterDepth(gCharDepth);
    (*text)->setPosition(Vec3(0, 0, 0));
    (*text)->setAlignment(osgText::Text3D::CENTER_BOTTOM);
    (*text)->setDrawMode(osgText::Text3D::TEXT);
    (*text)->setAxisAlignment(osgText::Text3D::XZ_PLANE);
    (*text)->setRenderMode(osgText::Text3D::PER_GLYPH);
    (*text)->setText("");

    Material *material = new Material;
    material->setDiffuse(Material::FRONT_AND_BACK, Vec4(0, 1, 0, 1));
    material->setAmbient(Material::FRONT_AND_BACK, Vec4(0, 1, 0, 1));
    material->setAlpha(Material::FRONT_AND_BACK, 1.0f);

    StateSet *stateset = textGeode->getOrCreateStateSet();
    stateset->setAttributeAndModes(material, StateAttribute::OVERRIDE | StateAttribute::ON);
    stateset->setMode(GL_BLEND, StateAttribute::OVERRIDE | StateAttribute::ON );
    stateset->setRenderingHint(StateSet::TRANSPARENT_BIN);

    return textGeode;
}
开发者ID:aprudhomme,项目名称:calvr_plugins,代码行数:31,代码来源:CAVEGroupReference.cpp

示例12: createGeometry

/** Create PickBox geometry.
*/
void PickBox::createGeometry(const Vec4 &c1, const Vec4 &c2, const Vec4 &c3)
{
    Geode *frame[NUM_BOX_COLORS];
    int i;

    // Create geometries:
    _geom[0] = createWireframe(c1);
    _geom[1] = createWireframe(c2);
    _geom[2] = createWireframe(c3);

    // Create geodes:
    for (i = 0; i < NUM_BOX_COLORS; ++i)
    {
        frame[i] = new Geode();
        frame[i]->addDrawable(_geom[i]);
        frame[i]->setNodeMask(~0);
        _switch->addChild(frame[i]);
    }
    updateWireframe(); // initialize wireframe color

    // Thick lines and lighting off:
    LineWidth *lineWidth = new LineWidth();
    lineWidth->setWidth(4.0f);
    StateSet *stateset = _switch->getOrCreateStateSet();
    stateset->setAttribute(lineWidth);
    stateset->setMode(GL_LIGHTING, StateAttribute::OFF);

    _scale->addChild(_switch.get());
}
开发者ID:nixz,项目名称:covise,代码行数:31,代码来源:PickBox.cpp

示例13: init

void Marker::init(GeometryType gt, Interaction *interaction, float size, Vec4 &color)
{
    Geode *geode;

    _gt = gt;
    if (_gt == CONE)
        geode = createCone(color);
    else if (_gt == BOX)
        geode = createBox(color);
    else
        geode = createSphere(color);

    setSize(size);
    setColor(color);

    // Make sure lighting is correct when marker is scaled:
    StateSet *stateSet = geode->getOrCreateStateSet();
    stateSet->setMode(GL_RESCALE_NORMAL, StateAttribute::ON);
    //stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF); // Philip added this else the color is not visible in opencover

    _interaction = interaction;
    _node->addChild(geode);

    if (_interaction)
        _interaction->addListener(this, this);
    _interactionA = new vrui::coTrackerButtonInteraction(vrui::coInteraction::ButtonA, "MarkerMove", vrui::coInteraction::Medium);
    _interactionB = NULL;
    assert(_interactionA);
}
开发者ID:nixz,项目名称:covise,代码行数:29,代码来源:Marker.cpp

示例14: createFrame

Geometry* DigitLabel::createFrame()
{
  float width2, height2;

  Geometry* geom = new Geometry();

  width2 = DEFAULT_LABEL_WIDTH / 2.0 * _scale;
  height2 = DEFAULT_LABEL_HEIGHT / 2.0 * _scale;

  Vec3Array* vertices = new Vec3Array(5);
  (*vertices)[0].set(-width2, -height2, EPSILON_Z);
  (*vertices)[1].set(width2, -height2, EPSILON_Z);
  (*vertices)[2].set(width2, height2, EPSILON_Z);
  (*vertices)[3].set(-width2, height2, EPSILON_Z);
  (*vertices)[4].set(-width2, -height2, EPSILON_Z);
  geom->setVertexArray(vertices);

  Vec3Array* normal = new Vec3Array(1);
  (*normal)[0].set(0.0, 0.0, 1.0);
  geom->setNormalArray(normal);
  geom->setNormalBinding(Geometry::BIND_OVERALL);

  _frameColor = new Vec4Array(1);
  (*_frameColor)[0].set(0.0, 0.0, 0.0, 1.0);
  geom->setColorArray(_frameColor);
  geom->setColorBinding(Geometry::BIND_OVERALL);

  geom->addPrimitiveSet(new DrawArrays(PrimitiveSet::LINE_STRIP, 0, 5));
  geom->setUseDisplayList(false);

  StateSet* stateSet = geom->getOrCreateStateSet();
  stateSet->setMode(GL_LIGHTING, StateAttribute::OFF);

  return geom;
}
开发者ID:dacevedofeliz,项目名称:calvr,代码行数:35,代码来源:DigitLabel.cpp

示例15: mNumVertices

//Constructor
CAVEGeodeShape::CAVEGeodeShape(const Type &typ, const Vec3 &initVect, const Vec3 &sVect):
		mCenterVect(Vec3(0, 0, 0)), mNumVertices(0), mNumNormals(0), mNumTexcoords(0),
		mDOCollectorIndex(-1)
{
    mVertexArray = new Vec3Array;
    mNormalArray = new Vec3Array;
    mUDirArray = new Vec3Array;
    mVDirArray = new Vec3Array;
    mTexcoordArray = new Vec2Array;
    mVertexMaskingVector.clear();

    switch (typ)
    {
	case BOX: initGeometryBox(initVect, sVect); break;
	case CYLINDER: initGeometryCylinder(initVect, sVect); break;
	default: break;
    }

    /* texture coordinates is associated with size of the geometry */
    Image* img = osgDB::readImageFile(CAVEGeode::getDataDir() + "Textures/White.JPG");
    Texture2D* texture = new Texture2D(img);
    texture->setWrap(Texture::WRAP_S, Texture::MIRROR);
    texture->setWrap(Texture::WRAP_T, Texture::MIRROR);

    Material *material = new Material;
    material->setSpecular(Material::FRONT_AND_BACK, Vec4(1, 1, 1, 1));
    material->setDiffuse(Material::FRONT_AND_BACK, Vec4(1, 1, 1, 1));
    material->setAlpha(Material::FRONT_AND_BACK, 1.0f);

    StateSet *stateset = getOrCreateStateSet();
    stateset->setTextureAttributeAndModes(0, texture, StateAttribute::ON);
    stateset->setAttributeAndModes(material, StateAttribute::OVERRIDE | StateAttribute::ON);
    stateset->setMode(GL_BLEND, StateAttribute::OVERRIDE | StateAttribute::ON );
    stateset->setRenderingHint(StateSet::TRANSPARENT_BIN);
}
开发者ID:aprudhomme,项目名称:calvr_plugins,代码行数:36,代码来源:CAVEGeodeShape.cpp


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