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


C++ Geode类代码示例

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


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

示例1: apply

  void BaseDotVisitor::apply(Geode& node) {
    int id;
    if ( getOrCreateId( &node, id ) ) {
      handle( node, id );
      handleNodeAndTraverse( node, id );

      unsigned int i;
      for ( i = 0; i < node.getNumDrawables(); i++ ) {
        osg::Drawable* drawable = node.getDrawable( i );
        int id2;
        if ( getOrCreateId( drawable, id2 ) ) {
          handle( *drawable, id2 );
          osg::StateSet* s = drawable->getStateSet();
          if ( s ) {
            int id3;
            if ( getOrCreateId( s, id3 ) ) {
              handle( *s, id3 );
            }
            handle( *drawable, *s, id2, id3 );
          }
        }
        handle( node, *drawable, id, id2 );
      }

    }

  }
开发者ID:Kurdakov,项目名称:emscripten_OSG,代码行数:27,代码来源:BaseDotVisitor.cpp

示例2: apply

void POVWriterNodeVisitor::apply( Geode& node )
{
   pushStateSet( node.getStateSet() );

   // iterate through drawables
   for(unsigned int i=0; i<node.getNumDrawables(); ++i)
   {
      // get drawable
      const Drawable *d = node.getDrawable(i);
      if (!d) continue;

      // push state set
      const StateSet *ss = d->getStateSet();
      if( ss )  pushStateSet( ss );

      // transformation matrix
      Matrix m = _transformationStack.top();

      // process lights
      processLights( _stateSetStack.top().get(), m );

      // process geometry
      const Geometry *g = d->asGeometry();
      if( g )
         processGeometry( g, _stateSetStack.top().get(), m );

      // pop state set
      if( ss )  popStateSet( ss );
   }

   popStateSet( node.getStateSet() );
}
开发者ID:AlexBobkov,项目名称:OpenSceneGraph,代码行数:32,代码来源:POVWriterNodeVisitor.cpp

示例3: createTextureQuad

Geode* createTextureQuad(Texture2D *texture)
{
    Vec3Array *vertices = new Vec3Array;
    vertices->push_back(Vec3(-1.0, -1.0, 0.0));
    vertices->push_back(Vec3(1.0, -1.0, 0.0));
    vertices->push_back(Vec3(1.0, 1.0, 0.0));
    vertices->push_back(Vec3(-1.0, 1.0, 0.0));

    Vec2Array *texcoord = new Vec2Array;
    texcoord->push_back(Vec2(0.0, 0.0));
    texcoord->push_back(Vec2(1.0, 0.0));
    texcoord->push_back(Vec2(1.0, 1.0));
    texcoord->push_back(Vec2(0.0, 1.0));

    Geometry *geom = new Geometry;
    geom->setVertexArray(vertices);
    geom->setTexCoordArray(0, texcoord);
    geom->addPrimitiveSet(new DrawArrays(GL_QUADS, 0, 4));

    Geode *geode = new Geode;
    geode->addDrawable(geom);
    geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture, StateAttribute::ON);

    return geode;
}
开发者ID:AndreyIstomin,项目名称:osg,代码行数:25,代码来源:osgfpdepth.cpp

示例4: 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

示例5: 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

示例6: 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

示例7: buildDrawable

void _dwobj::buildDrawable(Group *grp, const osgDB::ReaderWriter::Options *options)
{  // current DWobject complete; make a drawable, and add it to a osg::Group
    if (nfaces>0) {
        if (themat->isType(dwmaterial::PointLight) || themat->isType(dwmaterial::SpotLight)) {
            Vec4 pos;
            pos.set(0.0f,0.0f,0.0f,0.0f);
            for (int i=0; i<nverts; i++) {
                pos[0]+=verts[i].x();
                pos[1]+=verts[i].y();
                pos[2]+=verts[i].z();
            }
            pos/=nverts;
            pos[3]=1.0f;
            LightSource *ls=themat->makeLight(pos);
            grp->addChild(ls);
        } else {
            Geode *geode = new Geode;
            int nfnvf=0; // number of vertices for faces plus holes
            int i; // a general counter
            for (i=0; i<nfaces; i++) { // for each face
                faces[i].setnorm(verts); // set its normal and any hole normals
                nfnvf+=faces[i].getallverts(); // get total vertices in object, defines dimensions of NEW arrays
            }


            GLUtesselator* ts=gluNewTess();
            gluTessCallback(ts, GLU_TESS_BEGIN, (GLU_TESS_CALLBACK) myFaceBegin);
            gluTessCallback(ts, GLU_TESS_VERTEX, (GLU_TESS_CALLBACK) myVertex);
            gluTessCallback(ts, GLU_TESS_END, (GLU_TESS_CALLBACK) myFaceEnd);
            gluTessCallback(ts, GLU_TESS_ERROR, (GLU_TESS_CALLBACK) error);
            gluTessCallback(ts, GLU_TESS_COMBINE_DATA, (GLU_TESS_CALLBACK) combineCallback);
            //  for (int nvf=0; nvf<6; nvf++) { // for each length of face
            // for Geometry we dont need to collect prim types individually
            //     prd.setmode(nvf , nfnvf); // filter out only this type of tessellated face
            prd=new prims;
            prd->settmat(tmat.get());
            osg::Geometry *gset = new osg::Geometry;
            prd->setGeometry(gset);
            StateSet *dstate=themat->make(options);
            gset->setStateSet( dstate );
            grp->addChild( geode ); // add to the world outside
            geode->addDrawable(gset);

            // each face adds a primitive to the geometry, after it is tessellated
            for (i=0; i<nfaces; i++) { // for each face, collect up
                prd->tessellate(faces[i],verts, themat, ts, this);
            }
            for (i=0; i<nopens; i++) { // for each hole, join up front & back with Quads
                if (fc1 && fc2) {
                    faces[fc1[i]].link(openings[i*2], &faces[fc2[i]],openings[i*2+1],verts, themat);
                }
            } // for each opening
            prd->buildGeometry();
        gluDeleteTess(ts);
        delete prd;
        }
    } // nfaces>0
    verts.clear();
}
开发者ID:Kurdakov,项目名称:emscripten_OSG,代码行数:59,代码来源:ReaderWriterDW.cpp

示例8: apply

void StateSetVisitor::apply( Geode& geode )
{
   StateSet *ss = geode.getStateSet();
   if( ss )
      apply( *ss );

   for( unsigned int i=0; i<geode.getNumDrawables(); ++i )
      apply( *geode.getDrawable( i ) );

   traverse( geode );
}
开发者ID:forry,项目名称:Lexoanim,代码行数:11,代码来源:StateSetVisitor.cpp

示例9: apply

void IntersectVisitor::apply(Geode& geode)
{
    if (!enterNode(geode)) return;

    for(unsigned int i = 0; i < geode.getNumDrawables(); i++ )
    {
        intersect(*geode.getDrawable(i));
    }

    leaveNode();
}
开发者ID:151706061,项目名称:OpenSceneGraph,代码行数:11,代码来源:IntersectVisitor.cpp

示例10:

unsigned int Object3D::getNumDrawables() const
{
    GeodeFindVisitor visitor;
    _originalNode->accept(visitor);
    Geode *geode = visitor.getFirst();
    if(geode)
    {
        return geode->getNumDrawables();
    }
    return 0;
}
开发者ID:ConfusedReality,项目名称:pkg_augmented-reality_polAR,代码行数:11,代码来源:Object3D.cpp

示例11: apply

void DisplayRequirementsVisitor::apply(Geode& geode)
{
    osg::StateSet* geode_stateset = geode.getStateSet();
    if (geode_stateset) applyStateSet(*geode_stateset);
    
    for(unsigned int i = 0; i < geode.getNumDrawables(); i++ )
    {
        osg::StateSet* stateset = geode.getDrawable(i)->getStateSet();
        if (stateset) applyStateSet(*stateset);
    }
}
开发者ID:BlitzMaxModules,项目名称:osg.mod,代码行数:11,代码来源:DisplayRequirementsVisitor.cpp

示例12: Vec3Array

Geode* ChessUtils::createRectangleWithTexture(Vec3 centerPosition, Image* image, int width, int height, Vec4 color) {
	int halfWidth = width / 2;
	int halfHeight = height / 2;

	Vec3Array* vertices = new Vec3Array();	
	vertices->push_back(Vec3(centerPosition.x() - halfWidth, centerPosition.y() - halfHeight, centerPosition.z()));
	vertices->push_back(Vec3(centerPosition.x() + halfWidth, centerPosition.y() - halfHeight, centerPosition.z()));
	vertices->push_back(Vec3(centerPosition.x() + halfWidth, centerPosition.y() + halfHeight, centerPosition.z()));
	vertices->push_back(Vec3(centerPosition.x() - halfWidth, centerPosition.y() + halfHeight, centerPosition.z()));

	Vec3Array* normals = new Vec3Array();
	normals->push_back(Vec3(0.0f, 0.0f, 1.0f));

	Vec2Array* texcoords = new Vec2Array();
	texcoords->push_back(Vec2(0.0f, 0.0f));
	texcoords->push_back(Vec2(1.0f, 0.0f));
	texcoords->push_back(Vec2(1.0f, 1.0f));
	texcoords->push_back(Vec2(0.0f, 1.0f));

	Vec4Array* colors = new Vec4Array();
	colors->push_back(color);

	Geometry* quad = new Geometry();
	quad->setVertexArray(vertices);
	quad->setNormalArray(normals);
	quad->setNormalBinding(osg::Geometry::BIND_OVERALL);	
	quad->setColorArray(colors);
	quad->setColorBinding(osg::Geometry::BIND_OVERALL);
	quad->setTexCoordArray(0, texcoords);
	quad->addPrimitiveSet(new osg::DrawArrays(GL_QUADS, 0, 4));

	Texture2D* texture = new Texture2D();
	if (image != NULL) {
		texture->setImage(image);
	}			

	Geode* geode = new Geode();
	geode->addDrawable(quad);

	osg::BlendFunc* blendFunc = new osg::BlendFunc();
	blendFunc->setFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	osg::TexEnv* blendTexEnv = new osg::TexEnv();
	blendTexEnv->setMode(osg::TexEnv::BLEND);

	osg::StateSet* geodeStateset = geode->getOrCreateStateSet();
	geodeStateset->setAttributeAndModes(blendFunc);
	geodeStateset->setTextureAttribute(0, blendTexEnv);
	geodeStateset->setTextureAttributeAndModes(0, texture);
	geodeStateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
	
	return geode;
}
开发者ID:carlosmccosta,项目名称:AR-Chess,代码行数:53,代码来源:ChessUtils.cpp

示例13: displayScene

AppState::AppState(osgViewer::Viewer* viewer_)
    : displayScene(true), invertRange(true), currentConfig(0),
      viewer(viewer_), zNear(0.03125)
{
    sw = new Switch;
    string fontName("fonts/arial.ttf");
    // Text description of current config
    configText = new osgText::Text;
    configText->setDataVariance(Object::DYNAMIC);
    configText->setFont(fontName);
    configText->setPosition(Vec3(50.0f, 50.0f, 0.0f));
    configText->setColor(Vec4(1.0, 1.0, 1.0, 1.0));
    Geode* textGeode = new Geode;
    textGeode->addDrawable(configText.get());
    // Text for the near plane distance
    zNearText = new osgText::Text;
    zNearText->setDataVariance(Object::DYNAMIC);
    zNearText->setFont(fontName);
    zNearText->setPosition(Vec3(1230.0f, 50.0f, 0.0f));
    zNearText->setColor(Vec4(1.0, 1.0, 1.0, 1.0));
    zNearText->setAlignment(osgText::Text::RIGHT_BASE_LINE);
    textGeode->addDrawable(zNearText.get());
    // Projection that lets the text be placed in pixels.
    textProjection = new Projection;
    textProjection->setMatrix(Matrix::ortho2D(0,1280,0,1024));
    textProjection->addChild(textGeode);
    // "texture not available" text displayed when the user trys to
    // display the depth texture while multisampling.
    osgText::Text* noCanDo = new osgText::Text;
    noCanDo->setFont(fontName);
    noCanDo->setPosition(Vec3(512.0f, 384.0f, 0.0f));
    noCanDo->setColor(Vec4(1.0, 0.0, 0.0, 1.0));
    noCanDo->setText("not available");
    textNotAvailable = new Geode;
    textNotAvailable->addDrawable(noCanDo);
    textProjection->addChild(textNotAvailable.get());
    // Is the depth test inverted?
    osgText::Text* inverted = new osgText::Text;
    inverted->setFont(fontName);
    inverted->setPosition(Vec3(512.0f, 50.0f, 0.0f));
    inverted->setColor(Vec4(1.0, 1.0, 1.0, 1.0));
    inverted->setText("inverted depth test");
    textInverted = new Geode;
    textInverted->addDrawable(inverted);
    textInverted->setNodeMask(~0u);
    textProjection->addChild(textInverted.get());
    textProjection->getOrCreateStateSet()->setRenderBinDetails(11, "RenderBin");
}
开发者ID:AndreyIstomin,项目名称:osg,代码行数:48,代码来源:osgfpdepth.cpp

示例14: Geode

Geode *Marker::createBox(Vec4 &color)
{
    Geode *geode = new Geode();

    TessellationHints *hints = new TessellationHints();
    hints->setDetailRatio(0.3f);

    Vec3 boxCenter(0.0f, 0.0f, 0.0f);
    _boxShape = new Box(boxCenter, 1.0f);
    _shapeDrawable = new ShapeDrawable(_boxShape);
    _shapeDrawable->setTessellationHints(hints);
    _shapeDrawable->setColor(color);
    geode->addDrawable(_shapeDrawable);
    _shapeDrawable->setUseDisplayList(false); // allow changes to color and shape
    return geode;
}
开发者ID:nixz,项目名称:covise,代码行数:16,代码来源:Marker.cpp

示例15: apply

void ShadowVolumeGeometryGenerator::apply( Geode& geode )
{
   StateSet *ss = geode.getStateSet();
   if(ss)
      setCurrentFacingAndOrdering(ss);

   if( geode.getStateSet() )
      pushState( geode.getStateSet() );

   for( unsigned int i=0; i<geode.getNumDrawables(); ++i )
   {
      Drawable* drawable = geode.getDrawable( i );

      if( drawable->getStateSet() )
            pushState( drawable->getStateSet() );

      apply( geode.getDrawable( i ) );

      if( drawable->getStateSet() )
         popState(drawable->getStateSet());
   }

   if(ss)
      setCurrentFacingAndOrdering(ss);
   if( geode.getStateSet() )
      popState(geode);
}
开发者ID:forry,项目名称:Lexoanim,代码行数:27,代码来源:ShadowVolumeGeometryGenerator.cpp


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