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


C++ Geode::setStateSet方法代码示例

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


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

示例1: applyTextures

void applyTextures(Group* root, vector<string>& fileVect, vector<Vec2Array*>& coordVect) {
		/*osg::Vec4Array* colors = new osg::Vec4Array;
		if (i == 29){
			colors->push_back(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
		}
		else{
			colors->push_back(osg::Vec4(i/(float)numPlanes, i/(float)numPlanes, i/(float)numPlanes, 1.0f) ); 
		}
		planeGeometry->setColorArray(colors);
		planeGeometry->setColorBinding(osg::Geometry::BIND_OVERALL);*/
	for (int i = 0; i < fileVect.size(); i ++ ){
		if (fileVect[i] == ""){
			continue;
		}
		Geode* currGeode = (Geode*)root->getChild(i);
		Geometry* currGeometry = (Geometry*)currGeode->getDrawable(0);
		Vec2Array* currVectArray = coordVect[i];
		osg::Vec2Array* texcoords = new osg::Vec2Array(currVectArray->size());
		for (int j = 0; j < currVectArray->size(); j ++ ){
			(*texcoords)[j].set(currVectArray->at(j)[0], currVectArray->at(j)[1]);
		}
		currGeometry->setTexCoordArray(0,texcoords);

		osg::Texture2D* currTexture = new osg::Texture2D;
		currTexture->setDataVariance(osg::Object::DYNAMIC);
		osg::Image* currFace = osgDB::readImageFile(fileVect[i]);
		currTexture->setImage(currFace);
		osg::StateSet* state = new osg::StateSet;
		state->setTextureAttributeAndModes(0, currTexture,osg::StateAttribute::ON);
		currGeode->setStateSet(state);
	}
}
开发者ID:petercheng00,项目名称:Indoor-Modeling,代码行数:32,代码来源:renderPlanes.cpp

示例2: if


//.........这里部分代码省略.........
         {
         geoState->setAttributeAndModes(combineEnvTextures.get(), StateAttribute::ON);
         }
         #endif*/

            if (vertex && (vertexCount > 0))
            {
                for (int elems = 0; elems < vertexCount; elems++)
                {
                    vert->push_back(Vec3(vertex[elems * 3 + 0], vertex[elems * 3 + 1], vertex[elems * 3 + 2]));
                }
                JtkEntityFactory::deleteMemory(vertex);
            }

            if (normal && (normCount > 0))
            {
                for (int elems = 0; elems < normCount; elems++)
                {
                    normalArray->push_back(Vec3(normal[elems * 3 + 0], normal[elems * 3 + 1], normal[elems * 3 + 2]));
                }
                if (normCount == vertexCount)
                {
                }
                else
                {
                    //geom->setNormalBinding(Geometry::BIND_PER_PRIMITIVE);
                    std::cerr << "JTOpen: normals per primitive not supported" << std::endl;
                }
                JtkEntityFactory::deleteMemory(normal);
            }
            else // generate normals
            {
            }

            if (color && (colorCount > 0))
            {

                for (int elems = 0; elems < colorCount; elems++)
                {
                    colorArray->push_back(Vec3(color[elems * 3 + 0], color[elems * 3 + 1], color[elems * 3 + 2]));
                }

                if (colorCount == vertexCount)
                {
                }
                else
                {
                    //geom->setColorBinding(Geometry::BIND_PER_PRIMITIVE);
                    std::cerr << "JTOpen: colors per primitive not supported" << std::endl;
                }
                JtkEntityFactory::deleteMemory(color);
            }

            if (texture && (textCount > 0))
            {

                for (int elems = 0; elems < textCount; elems++)
                {
                    tcArray->push_back(Vec2(texture[elems * 2 + 0], texture[elems * 2 + 1]));
                }
                JtkEntityFactory::deleteMemory(texture);
            }

            /*   if(!(mask & Viewer::MASK_CONVEX))
         {
         osgUtil::Tesselator *tess = new osgUtil::Tesselator;
         tess->retesselatePolygons(*geom);
         //delete[] tess;
         }*/

            // if enabled, generate tri strips, but not for animated objects
            // if(genStrips && strncmp(objName, "Animated", 8))
            {
                //      d_stripper->stripify(*geom);
            }
        }
        geom->setVertexArray(vert);
        geom->addPrimitiveSet(primitives);
        if (normalArray->size() > 0)
        {
            geom->setNormalArray(normalArray);
            geom->setNormalBinding(Geometry::BIND_PER_VERTEX);
        }
        if (colorArray->size() > 0)
        {
            geom->setColorArray(colorArray);
            geom->setColorBinding(Geometry::BIND_PER_VERTEX);
        }
        if (tcArray->size() > 0)
            geom->setTexCoordArray(0, tcArray);
        if (normalArray->size() == 0)
        {
            osgUtil::SmoothingVisitor::smooth(*(geom.get()), 40.0 / 180.0 * M_PI);
        }
        geode->addDrawable(geom.get());
        geode->setStateSet(geoState);
        return geode;
    }
    return NULL;
}
开发者ID:nixz,项目名称:covise,代码行数:101,代码来源:JTOpenPlugin.cpp

示例3: Sphere

/***************************************************************
* Function: ANIMCreateRefSkyDome()
*
***************************************************************/
MatrixTransform *ANIMCreateRefSkyDome(StateSet **stateset)
{
    /* sky dome geometry */
    Sphere *skyShape = new Sphere();
    ShapeDrawable* skyDrawable = new ShapeDrawable(skyShape);
    Geode* skyGeode = new Geode();
    MatrixTransform *skyDomeTrans = new MatrixTransform;
    
    //osg::Matrix m;
    //m.makeRotate(osg::Quat(M_PI/2, osg::Vec3(0, 1, 0)));
    //skyDomeTrans->setMatrix(m);

    skyShape->setRadius(ANIM_SKYDOME_RADIUS);
    skyGeode->addDrawable(skyDrawable);
    skyDomeTrans->addChild(skyGeode);

    // apply simple colored materials
    Material* material = new Material;
    material->setDiffuse(Material::FRONT_AND_BACK, Vec4(1.0f, 1.0f, 1.0f, 1.0f));
    material->setAlpha(Material::FRONT_AND_BACK, 1.0f);

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

//    skyGeode->setNodeMask(0xFFFFFF & ~(0x2 | 0x3));

    // load sky dome shader
    Uniform* sunrUniform = new Uniform("hazeRadisuMin", 0.975f);
    (*stateset)->addUniform(sunrUniform);

    Uniform* sunRUniform = new Uniform("hazeRadisuMax", 0.995f);
    (*stateset)->addUniform(sunRUniform);

    Uniform* sunDirUniform = new Uniform("sundir", Vec4(0.0, 0.0, 1.0, 1.0));
    (*stateset)->addUniform(sunDirUniform);

    Uniform* suncolorUniform = new Uniform("suncolor", Vec4(1.0, 1.0, 1.0, 1.0));
    (*stateset)->addUniform(suncolorUniform);

    Uniform* skycolorUniform = new Uniform("skycolor", Vec4(0.5, 0.5, 1.0, 1.0));
    (*stateset)->addUniform(skycolorUniform);

    Uniform* skyfadingcolorUniform = new Uniform("skyfadingcolor", Vec4(0.8, 0.8, 0.8, 1.0));
    (*stateset)->addUniform(skyfadingcolorUniform);

    Uniform* skymaskingcolorUniform = new Uniform("skymaskingcolor", Vec4(1.0, 1.0, 1.0, 1.0));
    (*stateset)->addUniform(skymaskingcolorUniform);

    Uniform *matShaderToWorldUniform = new Uniform("shaderToWorldMat", Matrixd());
    (*stateset)->addUniform(matShaderToWorldUniform);

    Image* imageSky = osgDB::readImageFile(ANIMDataDir() + "Textures/NightSky.JPG");
    Texture2D* textureSky = new Texture2D(imageSky);    
    (*stateset)->setTextureAttributeAndModes(0, textureSky, StateAttribute::ON);

    Image* imagePara = osgDB::readImageFile(ANIMDataDir() + "Textures/Paramounts/Paramount00.JPG");
    Texture2D* texturePara = new Texture2D(imagePara);

    (*stateset)->setTextureAttributeAndModes(1, texturePara, StateAttribute::ON);

    Uniform* skyNightSampler = new Uniform("texNightSky", 0);
    (*stateset)->addUniform(skyNightSampler);

    Uniform* paraImageTextureSampler = new Uniform("texParamount", 1);
    (*stateset)->addUniform(paraImageTextureSampler);

    Program* programSky = new Program;
    (*stateset)->setAttribute(programSky);
    programSky->addShader(Shader::readShaderFile(Shader::VERTEX, ANIMDataDir() + "Shaders/EnvSky.vert"));
    programSky->addShader(Shader::readShaderFile(Shader::FRAGMENT, ANIMDataDir() + "Shaders/EnvSky.frag"));

    return skyDomeTrans;
}
开发者ID:Peachychan,项目名称:calvr_plugins,代码行数:80,代码来源:ANIMRefSkyDome.cpp

示例4: DrawArrayLengths

Geode *ClipPlanePlugin::loadPlane()
{

    // *5---*6---*7
    // |    |    |
    // *3--------*4
    // |    |    |
    // *0---*1---*2

    float w = cover->getSceneSize() * 0.1; // width of plane

    Vec3Array *lineCoords = new Vec3Array(12);
    (*lineCoords)[0].set(-w, -0.01, -w);
    (*lineCoords)[1].set(w, -0.01, -w);
    (*lineCoords)[2].set(-w, -0.01, 0.0f);
    (*lineCoords)[3].set(w, -0.01, 0.0f);
    (*lineCoords)[4].set(-w, -0.01, w);
    (*lineCoords)[5].set(w, -0.01, w);
    (*lineCoords)[6].set(-w, -0.01, -w);
    (*lineCoords)[7].set(-w, -0.01, w);
    (*lineCoords)[8].set(0.0f, -0.01, -w);
    (*lineCoords)[9].set(0.0f, -0.01, w);
    (*lineCoords)[10].set(w, -0.01, -w);
    (*lineCoords)[11].set(w, -0.01, w);

    DrawArrayLengths *primitives = new DrawArrayLengths(PrimitiveSet::LINE_STRIP);
    for (int i = 0; i < 6; i++)
    {
        primitives->push_back(2);
    }

    Vec3Array *lineColors = new Vec3Array(12);
    for (int i = 0; i < 12; i++)
    {
        (*lineColors)[i].set(Vec3(1.0f, 1.0f, 1.0f));
    }

    Geometry *geoset = new Geometry();
    geoset->setVertexArray(lineCoords);
    geoset->addPrimitiveSet(primitives);
    geoset->setColorArray(lineColors);

    Material *mtl = new Material;
    mtl->setColorMode(Material::AMBIENT_AND_DIFFUSE);
    mtl->setAmbient(Material::FRONT_AND_BACK, Vec4(0.2f, 0.2f, 0.2f, 1.0f));
    mtl->setDiffuse(Material::FRONT_AND_BACK, Vec4(0.9f, 0.9f, 0.9f, 1.0f));
    mtl->setSpecular(Material::FRONT_AND_BACK, Vec4(0.9f, 0.9f, 0.9f, 1.0f));
    mtl->setEmission(Material::FRONT_AND_BACK, Vec4(0.0f, 0.0f, 0.0f, 1.0f));
    mtl->setShininess(Material::FRONT_AND_BACK, 16.0f);

    Geode *geode = new Geode;
    geode->setName("ClipPlane");
    geode->addDrawable(geoset);

    StateSet *geostate = geode->getOrCreateStateSet();
    geostate->setAttributeAndModes(mtl, StateAttribute::ON);
    geostate->setMode(GL_LIGHTING, StateAttribute::OFF);
    LineWidth *lineWidth = new LineWidth(3.0);
    geostate->setAttributeAndModes(lineWidth, StateAttribute::ON);
    geode->setStateSet(geostate);

    return geode;
}
开发者ID:dwickeroth,项目名称:covise,代码行数:63,代码来源:ClipPlane.cpp


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