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


C++ StateSet类代码示例

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


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

示例1: processStateSet

    void Camera::processStateSet(const osg::StateSet *stateset, StateSet &s)
    {
        if (!stateset)
            return;
        for(int i = 15 ; i >= 0 ; --i)
        {
            const osg::StateSet::RefAttributePair *attr = stateset->getTextureAttributePair(i, StateAttribute::TEXTURE);
            if (!attr)
                continue;
            const Texture2D *ptex2D = dynamic_cast<const Texture2D*>(attr->first.get());
            const unsigned int mode = attr->second;
            if (ptex2D)
                s.setTexture(i, GL_TEXTURE_2D, pContext->getTextureID(ptex2D), mode);
            else
            {
                const TextureCubeMap *ptexCM = dynamic_cast<const TextureCubeMap*>(attr->first.get());
                if (ptexCM)
                    s.setTexture(i, GL_TEXTURE_CUBE_MAP, pContext->getTextureID(ptexCM), mode);
            }
        }
        s.setUniforms(stateset->getUniformList());
        const osg::StateSet::RefAttributePair *attr = stateset->getAttributePair(StateAttribute::PROGRAM, 0);
        if (attr && attr->first)
        {
            s.setProgram(pContext->getProgramID(dynamic_cast<const osg::Program*>(attr->first.get())), attr->second);
        }

        attr = stateset->getAttributePair(StateAttribute::MATERIAL);
        if (attr && attr->first)
        {
            s.setMaterial(dynamic_cast<const osg::Material*>(attr->first.get()), attr->second);
        }
    }
开发者ID:agpetit,项目名称:RoDyMan_Vision,代码行数:33,代码来源:camera.cpp

示例2: setName

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

示例3: Geometry

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

示例4: pos

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

示例5: Vec4

/***************************************************************
* 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

示例6: main

int main(int argc, char* argv[])
{
    StateSet entries;
    StateCreatorFunction initFunc(InitState::createState);
    entries.insert(StateEntry(INIT, "init", initFunc));

    StateCreatorFunction stopFunc(StopState::createState);
    entries.insert(StateEntry(STOP, "stop", stopFunc));

    StateEntry entryArray[] =
        {
            StateEntry(INIT, "init", initFunc),
            StateEntry(STOP, "stop", stopFunc)
        };

    StateSet entires2(entryArray, entryArray + (sizeof(entryArray) / sizeof(entryArray[0])));

    StateSet::iterator it = entries.find(INIT);
    boost::shared_ptr<State> s1 = it->creatorFunction_();

    StateSet::nth_index<1>::type::iterator it2 = entries.get<1>().find("stop");
    boost::shared_ptr<State> s2 = it2->creatorFunction_();

    std::cout << "State name: " << s1->name() << std::endl;
    std::cout << "State name: " << s2->name() << std::endl;

    BOOST_FOREACH(const StateEntry& entry, entires2)
    {
        std::cout << entry.umStateName_ << std::endl;
    }
开发者ID:ryanpartridge,项目名称:scratchpad,代码行数:30,代码来源:multi_index.cpp

示例7: dfs

/**
 * recursive solver (useless)
 */
void dfs(Statistics &stat, vector<State> &stateVector, StateSet &rec, const vector<string> &ground, State state, int &flg, State &result)
{
	// got a result, return
	if (flg)
		return;
	for (int i = 0; i < 4 && !flg; ++i) {
		State now = state;
		now.person.x += direction[i][0]; 
		now.person.y += direction[i][1];
		int s = validState(direction[i][0], direction[i][1], now, ground);
		now.move = step[i];
		now.previousStateNum = now.currentStateNum;
		stat.anodes++;
		if (s == -1) {
			result = now;
			flg = 1;
			return;
		} else if (s && !rec.count(now)) {
			now.currentStateNum = stateVector.size();
			stateVector.push_back(now);
			rec.insert(now);
			dfs(stat, stateVector, rec, ground, now, flg, result);
		} else if (s) {
			stat.bnodes++;
		}
	}
}
开发者ID:ChongZhang1989,项目名称:SokobanSolver,代码行数:30,代码来源:dfs.cpp

示例8: createCone

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

示例9: updateVSParameters

/***************************************************************
* Function: updateVSParameters()
***************************************************************/
void DSVirtualEarth::updateVSParameters(const Vec3 &viewDir, const Vec3 &viewPos)
{
    if (!mVirtualScenicHandler) return;

    /*  compute sun direction in world space: apply transforms resulted by viewer's orientation change, 
	guarantee that from the viewer's position, the virtual earth is always half illuminated. */
    Matrixd baserotMat;
    baserotMat.makeRotate(Vec3(0, 1, 0), gDesignStateFrontVect);
    Vec3 sunDirWorld = (CAVEAnimationModeler::ANIMVirtualEarthLightDir()) * baserotMat;
    StateSet *stateset = mEarthGeode->getStateSet();
    if (stateset)
    {
	Uniform *lightposUniform = stateset->getOrCreateUniform("LightPos", Uniform::FLOAT_VEC4);
	lightposUniform->set(Vec4(sunDirWorld, 0.0));
    }

    /* compute matrix combination that transforms a vector from shader space into world space */
    Matrixd latiMat;
    latiMat.makeRotate(mLati / 180.f * M_PI, Vec3(0, 1, 0));
    Matrixd equatorMat;   
    equatorMat.makeRotate((mTimeOffset / 12.f + mLongi / 180.f) * M_PI, Vec3(0, 0, 1));  
    Matrixd tiltaxisMat = mTiltAxisTrans->getMatrix();
    Matrixd eclipticMat = mEclipticTrans->getMatrix();
    Matrixd transMat = mUnitspaceMat * latiMat * equatorMat * tiltaxisMat * eclipticMat * baserotMat;

    /* updata environment rendering by passing parameters to VirtualScenicHandler */
    mVirtualScenicHandler->updateVSParameters(transMat, sunDirWorld, viewDir, viewPos);
}
开发者ID:aprudhomme,项目名称:calvr_plugins,代码行数:31,代码来源:DSVirtualEarth.cpp

示例10:

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);
        }
    }
}
开发者ID:ConfusedReality,项目名称:pkg_augmented-reality_polAR,代码行数:30,代码来源:Object3D.cpp

示例11: BlendFunc

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

示例12: Texture2D

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

示例13: Geometry

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

示例14: mCenterVect

//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

示例15: createWireframe

/** 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


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