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


C++ osg::Vec4类代码示例

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


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

示例1: getFloat

osg::Vec4 ConfigManager::getVec4(std::string attributeX, std::string attributeY,
        std::string attributeZ, std::string attributeW, std::string path,
        osg::Vec4 def, bool * found)
{
    bool hasEntry = false;
    bool isFound;

    osg::Vec4 result;
    result.x() = getFloat(attributeX,path,def.x(),&isFound);
    if(isFound)
    {
        hasEntry = true;
    }
    result.y() = getFloat(attributeY,path,def.y(),&isFound);
    if(isFound)
    {
        hasEntry = true;
    }
    result.z() = getFloat(attributeZ,path,def.z(),&isFound);
    if(isFound)
    {
        hasEntry = true;
    }
    result.w() = getFloat(attributeW,path,def.w(),&isFound);
    if(isFound)
    {
        hasEntry = true;
    }

    if(found)
    {
        *found = hasEntry;
    }
    return result;
}
开发者ID:CalVR,项目名称:calvr,代码行数:35,代码来源:ConfigManager.cpp

示例2: rasterize

    // rasterizes a geometry to color
    void rasterize(const Geometry* geometry, const osg::Vec4& color, RenderFrame& frame, 
                   agg::rasterizer& ras, agg::rendering_buffer& buffer)
    {
        unsigned a = (unsigned)(127.0f+(color.a()*255.0f)/2.0f); // scale alpha up
        agg::rgba8 fgColor = agg::rgba8( (unsigned)(color.r()*255.0f), (unsigned)(color.g()*255.0f), (unsigned)(color.b()*255.0f), a );
        
        ConstGeometryIterator gi( geometry );
        while( gi.hasMore() )
        {
            const Geometry* g = gi.next();

            for( Geometry::const_iterator p = g->begin(); p != g->end(); p++ )
            {
                const osg::Vec3d& p0 = *p;
                double x0 = frame.xf*(p0.x()-frame.xmin);
                double y0 = frame.yf*(p0.y()-frame.ymin);

                if ( p == g->begin() )
                    ras.move_to_d( x0, y0 );
                else
                    ras.line_to_d( x0, y0 );
            }
        }
        agg::renderer<agg::span_abgr32, agg::rgba8> ren(buffer);
        ras.render(ren, fgColor);

        ras.reset();
    }
开发者ID:ldelgass,项目名称:osgearth,代码行数:29,代码来源:AGGLiteRasterizerTileSource.cpp

示例3: drawPlane

void ConicSectionPlugin::drawPlane(osg::Vec4 eq)
{
    //if (showClipplane_->getState())
    //{
    //helper plane
    Vec3 normal = Vec3(eq.x(), eq.y(), eq.z());
    normal.normalize();
    Vec3 point = normal * -eq.w();
    point = point + normal * 0.003;
    helperPlane_->update(normal, point);
    Vec3 intersect[6];
    osg::BoundingBox bboxCompl = cover->getBBox(Cone_.get());
    int numIntersect = helperPlane_->getBoxIntersectionPoints(bboxCompl, intersect);

    if (numIntersect > 0)
    {
        for (int i = 0; i < numIntersect; i++)
        {
            (*polyCoords_)[i] = intersect[i];
        }
        for (int i = numIntersect; i < 6; i++)
        {

            (*polyCoords_)[i] = (*polyCoords_)[numIntersect - 1];
        }
    }

    (*polyNormal_)[0].set(normal[0], normal[1], normal[2]);

    plane_->dirtyBound();
    //}
}
开发者ID:nixz,项目名称:covise,代码行数:32,代码来源:ConicSectionPlugin.cpp

示例4: apply

	virtual void apply(osg::Geode& geode)
	{
		for (unsigned i=0; i<geode.getNumDrawables(); ++i)
		{
			osg::Geometry *geo = dynamic_cast<osg::Geometry *>(geode.getDrawable(i));
			if (!geo) continue;

			osg::StateSet *stateset = geo->getStateSet();
			if (!stateset) continue;

			osg::StateAttribute *state = stateset->getAttribute(osg::StateAttribute::MATERIAL);
			if (!state) continue;

			osg::Material *mat = dynamic_cast<osg::Material *>(state);
			if (!mat) continue;

			const osg::Vec4 v4 = mat->getDiffuse(FAB);
			if (v4.r() == 1.0f && v4.g() == 0.0f && v4.b() == 1.0f)
			{
				//VTLOG("oldmat rc %d, ", mat->referenceCount());

				osg::Material *newmat = (osg::Material *)mat->clone(osg::CopyOp::DEEP_COPY_ALL);
				newmat->setDiffuse(FAB, osg::Vec4(c.r*2/3,c.g*2/3,c.b*2/3,1));
				newmat->setAmbient(FAB, osg::Vec4(c.r*1/3,c.g*1/3,c.b*1/3,1));

				//VTLOG("newmat rc %d\n", newmat->referenceCount());

				stateset->setAttribute(newmat);
				//VTLOG(" -> %d %d\n", mat->referenceCount(), newmat->referenceCount());
			}
		}
		osg::NodeVisitor::apply(geode);
	}
开发者ID:kamalsirsa,项目名称:vtp,代码行数:33,代码来源:Vehicles.cpp

示例5: writeFloat

void DataOutputStream::writeVec4(const osg::Vec4& v){
    writeFloat(v.x());
    writeFloat(v.y());
    writeFloat(v.z());
    writeFloat(v.w());

    if (_verboseOutput) std::cout<<"read/writeVec4() ["<<v<<"]"<<std::endl;
}
开发者ID:BackupTheBerlios,项目名称:eu07-svn,代码行数:8,代码来源:DataOutputStream.cpp

示例6: getValue

bool HeightFieldLayer::getValue(unsigned int i, unsigned int j, osg::Vec4& value) const
{
    value.x() = _heightField->getHeight(i,j);
    value.y() = _defaultValue.y();
    value.z() = _defaultValue.z();
    value.w() = _defaultValue.w();
    return true;
}
开发者ID:dev2dev,项目名称:OpenSceneGraph-port-to-IOS,代码行数:8,代码来源:Layer.cpp

示例7: color

QColor OSGTextNode::color() const
{
    const osg::Vec4 osgColor = h->text->getColor();
    return QColor::fromRgbF(
                osgColor.r(),
                osgColor.g(),
                osgColor.b(),
                osgColor.a());
}
开发者ID:mp3butcher,项目名称:osg4noob,代码行数:9,代码来源:OSGTextNode.cpp

示例8: getElement

bool Uniform::getElement( unsigned int index, osg::Vec4& v4 ) const
{
    if( index>=getNumElements() || !isCompatibleType(FLOAT_VEC4) ) return false;
    unsigned int j = index * getTypeNumComponents(getType());
    v4.x() = (*_floatArray)[j];
    v4.y() = (*_floatArray)[j+1];
    v4.z() = (*_floatArray)[j+2];
    v4.w() = (*_floatArray)[j+3];
    return true;
}
开发者ID:aalex,项目名称:osg,代码行数:10,代码来源:Uniform.cpp

示例9: SetBackDropColor

//
//set the drop shadow color
//
void TextRegion::SetBackDropColor(const osg::Vec4 &color)
{
	_backdropColor.r() = color.r();
	_backdropColor.g() = color.g();
	_backdropColor.b() = color.b();
	_backdropColor.a() = this->GetAlpha()*0.5f;
    
	_text->setBackdropColor(_backdropColor);
    
    _dirtyRenderState = true;
}
开发者ID:crycrane,项目名称:hogbox,代码行数:14,代码来源:TextRegion.cpp

示例10: assert

void OrbitalBodyImposter::updateTint(osg::Vec4 const &color, double flare_alpha) {
	osg::Vec4Array *colors = dynamic_cast<osg::Vec4Array*>(m_CoreImposter->getColorArray());
	assert(colors);
	(*colors)[0] = color;
	m_CoreImposter->dirtyDisplayList();
	if (m_FlareImposter.valid()) {
		osg::Vec4Array *colors = dynamic_cast<osg::Vec4Array*>(m_FlareImposter->getColorArray());
		assert(colors);
		(*colors)[0] = osg::Vec4(color.x(), color.y(), color.z(), flare_alpha);
		m_FlareImposter->dirtyDisplayList();
	}
}
开发者ID:nsmoooose,项目名称:csp,代码行数:12,代码来源:OrbitalBodyImposter.cpp

示例11: position

void StandardShadowMap::ViewData::aimShadowCastingCamera(
                                        const osg::BoundingSphere &bs,
                                        const osg::Light *light,
                                        const osg::Vec4 &lightPos,
                                        const osg::Vec3 &lightDir,
                                        const osg::Vec3 &lightUpVector
                                        /* by default = osg::Vec3( 0, 1 0 )*/ )
{
    osg::Matrixd & view = _camera->getViewMatrix();
    osg::Matrixd & projection = _camera->getProjectionMatrix();

    osg::Vec3 up = lightUpVector;
    if( up.length2() <= 0 )  up.set( 0,1,0 );

    osg::Vec3d position(lightPos.x(), lightPos.y(), lightPos.z());
    if (lightPos[3]==0.0)   // infinite directional light
    {
        // make an orthographic projection
        // set the position far away along the light direction
        position = bs.center() - lightDir * bs.radius() * 2;
    }

    float centerDistance = (position-bs.center()).length();
    float znear = centerDistance-bs.radius();
    float zfar  = centerDistance+bs.radius();
    float zNearRatio = 0.001f;
    if (znear<zfar*zNearRatio)
        znear = zfar*zNearRatio;

    if ( lightPos[3]!=0.0 ) {  // positional light
        if( light->getSpotCutoff() < 180.0f) // also needs znear zfar estimates
        {
            float spotAngle = light->getSpotCutoff();
            projection.makePerspective( spotAngle * 2, 1.0, znear, zfar);
            view.makeLookAt(position,position+lightDir,up);
        } else { // standard omnidirectional positional light
            float top   = (bs.radius()/centerDistance)*znear;
            float right = top;

            projection.makeFrustum(-right,right,-top,top,znear,zfar);
            view.makeLookAt(position,bs.center(),up );
        }
    }
    else    // directional light
    {
            float top   = bs.radius();
            float right = top;
            projection.makeOrtho(-right, right, -top, top, znear, zfar);
            view.makeLookAt(position,bs.center(),up);
    }
}
开发者ID:4ker,项目名称:osg,代码行数:51,代码来源:StandardShadowMap.cpp

示例12:

void DebugShadowMap::ViewData::setDebugPolytope
    ( const char * name, const ConvexPolyhedron & polytope, 
      osg::Vec4 colorOutline, osg::Vec4 colorInside )
{
    if( !getDebugDraw() ) return;

    if( &polytope == NULL ) { // delete        
        PolytopeGeometry & pg = _polytopeGeometryMap[ std::string( name ) ];
        for( unsigned int i = 0; i < VECTOR_LENGTH( pg._geometry ) ; i++ )
        {
            if( pg._geometry[i].valid() ) {
                if( _geode[i].valid() &&
                    _geode[i]->containsDrawable( pg._geometry[i].get() ) )
                        _geode[i]->removeDrawable( pg._geometry[i].get() );

                pg._geometry[i] = NULL;
            }
        }
        _polytopeGeometryMap.erase( std::string( name ) );
    } else { // update
        PolytopeGeometry & pg = _polytopeGeometryMap[ std::string( name ) ];

        pg._polytope = polytope;
        if( colorOutline.a() > 0 )
            pg._colorOutline = colorOutline;
        if( colorInside.a() > 0 )
            pg._colorInside = colorInside;

        for( unsigned int i = 0; i < VECTOR_LENGTH( pg._geometry ) ; i++ )
        {
            if( !pg._geometry[i].valid() ) {
                pg._geometry[i] = new osg::Geometry;
                pg._geometry[i]->setDataVariance( osg::Object::DYNAMIC );
                pg._geometry[i]->setUseDisplayList( false );
                pg._geometry[i]->setSupportsDisplayList( false );
            }

            if( _geode[i].valid() && 
                  !_geode[i]->containsDrawable( pg._geometry[i].get() ) ) {
                        osg::Geode::DrawableList & dl = 
                           const_cast< osg::Geode::DrawableList &>
                              ( _geode[i]->getDrawableList() );
                        dl.insert( dl.begin(), pg._geometry[i].get() );
            }            
        }       
    }
}
开发者ID:aalex,项目名称:osg,代码行数:47,代码来源:DebugShadowMap.cpp

示例13: setPosition

void Light::setPosition(const osg::Vec4 &position)
{
    _lightSource->getLight()->setPosition(position);
    if(position.w() == 0.0f)
        _isDirectional = true;
    else
        _isDirectional = false;
    updateViewableObject();
    refresh();
}
开发者ID:ConfusedReality,项目名称:pkg_augmented-reality_polAR,代码行数:10,代码来源:Light.cpp

示例14: calcCoordReprojTrans

osg::Vec2 calcCoordReprojTrans(const osg::Vec3 &vert,const osg::Matrix &trans,const osg::Matrix &viewProj,const osg::Vec2 &size,const osg::Vec4 &ratio){
    osg::Vec4 v(vert.x(),vert.y(),vert.z(),1.0);
    v=v*trans;
    v=v*viewProj;
    v.x() /= v.w();
    v.y() /= v.w();
    v.z() /= v.w();
    v.w() /= v.w();
    //std::cout << "Pre shift " << v << std::endl;
    v.x() /= size.x();;
    v.y() /= size.y();


    v.x() -= (ratio.x()/size.x());
    v.y() -= (ratio.y()/size.y());
    //std::cout << "Post shift " << v << std::endl;


    //  std::cout << "PP shift " << v << std::endl;


    osg::Vec2 tc(v.x(),v.y());
    tc.x() *= ratio.z();
    tc.y() *=ratio.w();
    //tc.x()*=ratio.x();
    //tc.y()*=ratio.y();
    tc.x()/=(ratio.z());
    tc.y()/=(ratio.w());


    return tc;

}
开发者ID:SorinS,项目名称:structured,代码行数:33,代码来源:imageNode.cpp

示例15: SetTextColor

//
//Set the color of the text
//
void TextRegion::SetTextColor(const osg::Vec4& color)
{
	_textColor.r() = color.x();
	_textColor.g() = color.y();
	_textColor.b() = color.z();
    _textColor.a() = this->GetAlpha();
	_text->setColor(_textColor);

    this->SetColor(osg::Vec3(color.x(),color.y(),color.z()));
    
    _dirtyRenderState = true;
}
开发者ID:crycrane,项目名称:hogbox,代码行数:15,代码来源:TextRegion.cpp


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