Exemple #1
0
    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);
        }
    }
Exemple #2
0
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() );
}
Exemple #3
0
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;
}
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);
}
/***************************************************************
* 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;
}
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;
    }
Exemple #7
0
/**
 * 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++;
		}
	}
}
Exemple #8
0
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);
}
/***************************************************************
* 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);
}
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);
        }
    }
}
Exemple #11
0
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);
}
Exemple #12
0
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();
}
Exemple #13
0
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;
}
//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);
}
Exemple #15
0
/** 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());
}
// 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);
}
Exemple #17
0
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);
}
Exemple #18
0
void TFColorWidget::setSize(int size)
{
    LineWidth *width = new LineWidth();
    width->setWidth(size);
    StateSet *state = _geom->getOrCreateStateSet();
    state->setAttribute(width, osg::StateAttribute::ON);
    state->setMode(GL_LIGHTING, StateAttribute::OFF);
}
Exemple #19
0
ref_ptr<Geode> MyView::creationGeode(ref_ptr<Drawable> objet){
	StateSet* stateset;
	ref_ptr<Geode> unBouton = new Geode;
	stateset = unBouton->getOrCreateStateSet();
	stateset->setMode(GL_LIGHTING,StateAttribute::ON);
	unBouton->addDrawable(objet.get());
	return unBouton;
}
Exemple #20
0
int main()
{
    using namespace osg;
//    // read Neuron Obj file from desk
//    ref_ptr<Node> model = osgDB::readNodeFile( "Neuron.obj" );
//    model->setName("Neuron");
    ref_ptr<MatrixTransform> mt = new MatrixTransform;
//    mt->addChild( model.get() );
    myModel model1 ("Neuron.obj","Neuron");
    mt = model1.getMatrix();


    osgUtil::SmoothingVisitor sv;
    model->accept( sv );

    // BlendFunc
    ref_ptr<BlendFunc> blendFunc = new BlendFunc;
    blendFunc->setFunction( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
    StateSet* stateset = model->getOrCreateStateSet();
    stateset->setAttributeAndModes( blendFunc );

    // Material
    ref_ptr<StateSet> nodess =  model->getOrCreateStateSet();
    ref_ptr<Material> nodeMaterial = new Material;
    nodeMaterial->setDiffuse( Material::FRONT   , Vec4(0.5f,0.5f,0.5f,1.0f));
    nodeMaterial->setAmbient( Material::FRONT   , Vec4(2.0f,0.0f,0.0f,1.0f) );
    nodeMaterial->setTransparency(Material::FRONT , 0.25f);
    //nodeMaterial->setAlpha( Material::FRONT , 0.5f );
    nodess->setAttribute( nodeMaterial.get() );

    // create camera
    ref_ptr<Camera> camera = new Camera();
    camera->setClearMask( GL_DEPTH_BUFFER_BIT );
    camera->setRenderOrder( Camera::POST_RENDER );
    camera->setReferenceFrame( Camera::ABSOLUTE_RF );
    camera->setViewMatrixAsLookAt( Vec3d(-1.0f,0.0f,0.0f) , Vec3d(0.0,0.0,0.0) , Vec3d(0.0f,1.0f,0.0f) );

    // create root node
    ref_ptr<Group> root = new Group;
    // add child to it
    root->addChild( mt.get() );
    root->addChild( camera.get() );

    ref_ptr<PickHandler> picker = new PickHandler;
    root->addChild( picker->getOrCreateSelectionBox() );

    ref_ptr<ModelController> ctrler = new ModelController( mt.get() );

    // create viewer to display data
    osgViewer::Viewer viewer;
    viewer.addEventHandler( picker.get() );
    viewer.addEventHandler( ctrler.get() );
    viewer.setSceneData( root.get() );
    return viewer.run();
}
Exemple #21
0
 const std::set< State> getCalls(Nwa const & nwa)
 {
   details::TransitionStorage const & trans = nwa._private_get_transition_storage_();
   const Returns call = trans.getReturns();
   StateSet calls;
   for( ReturnIterator it = call.begin(); it != call.end(); it++ )
   {
     calls.insert( Trans::getCallSite(*it) );
   }
   return calls;
 }
Exemple #22
0
 const std::set< State> getReturns(Nwa const & nwa)
 {
   details::TransitionStorage const & trans = nwa._private_get_transition_storage_();
   const Returns ret = trans.getReturns();
   StateSet returns;
   for( ReturnIterator it = ret.begin(); it != ret.end(); it++ )
   {
     returns.insert( Trans::getReturnSite(*it) );
   }
   return returns;
 }
Exemple #23
0
 const std::set< State> getExits(Nwa const & nwa)
 {
   details::TransitionStorage const & trans = nwa._private_get_transition_storage_();
   const Returns & exit = trans.getReturns();
   StateSet exits;
   for( ReturnIterator it = exit.begin(); it != exit.end(); it++ )
   {
     exits.insert( Trans::getExit(*it) );
   }
   return exits;
 }
/***************************************************************
* 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;
}
Exemple #25
0
void Wire::coverStuff(void)
{
    //start of design functions
    geom = new osg::Geometry();
    geode = new Geode();
    geode->setNodeMask(geode->getNodeMask() & ~(Isect::Walk | Isect::Intersection | Isect::Collision | Isect::Touch | Isect::Pick));
    geom->setUseDisplayList(true);
    geom->setUseVertexBufferObjects(false);
    geode->addDrawable(geom.get());
    vert = new Vec3Array;
    primitives = new DrawArrayLengths(PrimitiveSet::POLYGON);
    indices = new UShortArray();
    normals = new Vec3Array;
    //cindices = new UShortArray()   //colors = new Vec4Array();
    StateSet *geoState = geom->getOrCreateStateSet();

    this->createGeom();

    geom->setVertexArray(vert.get());
    geom->setVertexIndices(indices.get());
    geom->setNormalIndices(indices.get());
    geom->setNormalArray(normals.get());
    //geom->setColorIndices(cindices.get());
    //geom->setColorArray(colors.get());
    geom->addPrimitiveSet(primitives.get());

    geoState = geode->getOrCreateStateSet();
    if (globalmtl.get() == NULL)
    {
        globalmtl = new Material;
        globalmtl->ref();
        globalmtl->setColorMode(Material::OFF);
        globalmtl->setAmbient(Material::FRONT_AND_BACK, Vec4(0.2f, 0.2f, 0.2f, 1.0));
        globalmtl->setDiffuse(Material::FRONT_AND_BACK, Vec4(0.9f, 0.9f, 0.9f, 1.0));
        globalmtl->setSpecular(Material::FRONT_AND_BACK, Vec4(0.9f, 0.9f, 0.9f, 1.0));
        globalmtl->setEmission(Material::FRONT_AND_BACK, Vec4(0.0f, 0.0f, 0.0f, 1.0));
        globalmtl->setShininess(Material::FRONT_AND_BACK, 10.0f);
    }

    geoState->setRenderingHint(StateSet::OPAQUE_BIN);
    geoState->setMode(GL_BLEND, StateAttribute::OFF);
    geoState->setAttributeAndModes(globalmtl.get(), StateAttribute::ON);
    //char name[1000];
    //sprintf(name,"Wire %d", this->getID());
    coVRShader *SolidClipping = coVRShaderList::instance()->get("SolidClipping");
    if (SolidClipping)
        SolidClipping->apply(geode, geom);
    geode->setName(this->getName());
    this->coverGroup->addChild(geode.get());
    //end of design functions
}
void POVWriterNodeVisitor::pushStateSet( const StateSet *ss )
{
   if( ss ) {

      // merge state set
      StateSet *mergedSS = new StateSet(
            *_stateSetStack.top().get(), CopyOp::SHALLOW_COPY );
      mergedSS->merge( *ss );

      // push state set
      _stateSetStack.push( mergedSS );

   }
}
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);
}
Exemple #28
0
    const  std::set< State> getCalls_Ret(Nwa const & nwa, Symbol symbol, State returnSite )
    {
      assert(returnSite < wali::WALI_BAD_KEY);
      assert(symbol < wali::WALI_BAD_KEY);

      details::TransitionStorage const & trans = nwa._private_get_transition_storage_();

      const Returns call = trans.getTransRet(returnSite);
      StateSet calls;
      for( ReturnIterator it = call.begin(); it != call.end(); it++ )
      {
        if( symbol == Trans::getReturnSym(*it) )
          calls.insert( Trans::getCallSite(*it) );
      }
      return calls;
    }
Exemple #29
0
// Set the GLModes on StateSet associated with the LightSource.
void LightSource::setStateSetModes(StateSet& stateset,StateAttribute::GLModeValue value) const
{
    if (_light.valid())
    {
        stateset.setAssociatedModes(_light.get(),value);
    }
}
Exemple #30
0
    const std::set< State> getReturns_Call(Nwa const & nwa, State callSite, Symbol symbol )
    {
      assert(callSite < wali::WALI_BAD_KEY);
      assert(symbol < wali::WALI_BAD_KEY);

      details::TransitionStorage const & trans = nwa._private_get_transition_storage_();

      const Returns ret = trans.getTransPred(callSite);
      StateSet returns;
      for( ReturnIterator it = ret.begin(); it != ret.end(); it++ )
      {
        if( symbol == Trans::getReturnSym(*it) )
          returns.insert( Trans::getReturnSite(*it) );
      }
      return returns;
    }