Пример #1
0
CallbackDrawable::CallbackDrawable(FlowPagedRenderer * renderer, osg::BoundingBox bounds)
{
    _bbox = bounds;
    _renderer = renderer;
    setUseDisplayList(false);
    setUseVertexBufferObjects(true);
}
Пример #2
0
FlexDrawable::FlexDrawable()
:   _solver(NULL)
{
    setUseDisplayList( false );
    setUseVertexBufferObjects( false );
    setCullCallback( FlexUpdater::instance() );
    
    osg::ref_ptr<osg::Program> program = new osg::Program;
    program->addShader( new osg::Shader(osg::Shader::VERTEX, flexVertCode) );
    program->addShader( new osg::Shader(osg::Shader::FRAGMENT, flexFragCode) );
    
    osg::StateSet* ss = getOrCreateStateSet();
    ss->setAttributeAndModes( program.get() );
}
Z3DLineWithFixedWidthColorRenderer::Z3DLineWithFixedWidthColorRenderer(QObject *parent)
  : Z3DLineRenderer(parent)
  , m_lineWidth("Line Width", 2.0f, 1.0f, 10.0f)
  , m_lineColor("Line Color", glm::vec4(1.f, 1.f, 0.f, 1.f))
{
  setNeedLighting(false);
  setUseDisplayList(true);
  m_lineColor.setStyle("COLOR");
  connect(&m_lineWidth, SIGNAL(valueChanged()), this, SLOT(invalidateOpenglRenderer()));
  connect(&m_lineWidth, SIGNAL(valueChanged()), this, SLOT(invalidateOpenglPickingRenderer()));
  connect(&m_lineColor, SIGNAL(valueChanged()), this, SLOT(invalidateOpenglRenderer()));
  connect(&m_lineColor, SIGNAL(valueChanged()), this, SLOT(setLineColors()));
  addParameter(m_lineWidth);
  addParameter(m_lineColor);
}
//------------------------------------------------------------------------------
void HudTextureElement::init()
{
    Texture * tex_object = s_texturemanager.getResource(texture_name_);
    if (!tex_object) return;
    
    osg::ref_ptr<osg::Texture2D> tex = tex_object->getOsgTexture();
    osg::ref_ptr<osg::Image> image = tex->getImage();

    aspect_ratio_ = (float)image->s() / image->t();

    tex->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
    tex->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);

    tex->setBorderColor(osg::Vec4(0,0,0,0));
    tex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_BORDER);
    tex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_BORDER);
    
    getOrCreateStateSet()->setTextureAttributeAndModes(0,tex.get(),osg::StateAttribute::ON);

    setUseDisplayList(false);
    setUseVertexBufferObjects(true);

    addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,4));

    Color color  = s_params.get<Color>   ("hud." + section_ + ".color");
    
    osg::Vec2Array* texcoord = new osg::Vec2Array(4);
    setTexCoordArray(0,texcoord);
        
    osg::Vec4Array * osg_color = new osg::Vec4Array(1);
    (*osg_color)[0].set(color.r_, color.g_, color.b_, color.a_);
    setColorArray(osg_color);
    setColorBinding(osg::Geometry::BIND_OVERALL);

    (*texcoord)[0].set(0,0);
    (*texcoord)[1].set(1,0);
    (*texcoord)[2].set(1,1);
    (*texcoord)[3].set(0,1);


    s_scene_manager.addObserver(ObserverCallbackFun0(this, &HudTextureElement::onResolutionChanged),
                                SOE_RESOLUTION_CHANGED,
                                &fp_group_);    
    onResolutionChanged();
}
Пример #5
0
Widget::Widget(const std::string& name, point_type w, point_type h):
_parent    (0),
_index     (0),
_layer     (LAYER_LOW),
_padLeft   (0.0f),
_padRight  (0.0f),
_padTop    (0.0f),
_padBottom (0.0f),
_valign    (VA_CENTER),
_halign    (HA_CENTER),
_coordMode (CM_ABSOLUTE),
_canFill   (false),
_canClone  (true),
_isManaged (false),
_isStyled  (false),
_minWidth  (0.0f),
_minHeight (0.0f) {
    _name = name.size() ? name : generateRandomName("Widget");

    if(!_norms.valid()) {
        _norms = new PointArray(1);

        (*_norms)[0].set(0.0f, 0.0f, 1.0f);
        (*_norms)[0].normalize();
    }

    TexCoordArray* texs = new TexCoordArray(4);

    // Fill our texture coordinates with null stuff for now, since we aren't using them
    // until an Image is set at some later point.
    std::fill(texs->begin(), texs->end(), osg::Vec2(0.0f, 0.0f));

    setUseDisplayList(false);
    setDataVariance(osg::Object::DYNAMIC);
    setVertexArray(new PointArray(4));
    setColorArray(new ColorArray(4));
    setNormalArray(_norms.get());
    setTexCoordArray(0, texs);
    setNormalBinding(osg::Geometry::BIND_OVERALL);
    setColorBinding(osg::Geometry::BIND_PER_VERTEX);
    addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS, 0, 4));

    setDimensions(0.0f, 0.0f, w, h);
    setColor(1.0f, 1.0f, 1.0f, 1.0f);
}
//==============================================================================
cBackground::cBackground()
{
    // create a panel without rounded corners (radius = 0). The default width 
    // and height values are updated in the render method() to span the full 
    // window.

    set(200,   // default width
        100,   // default height
          0,
          0,
          0,
          0);

    m_fixedAspectRatio = false;

    // use display lists
    setUseDisplayList(false);
}
Пример #7
0
NoiseVolumeRenderer::NoiseVolumeRenderer(const WaterVolume* const wv, double threshold)
	: WaterVolumeRenderer(wv, threshold)
{
	osg::StateSet *stateSet = getOrCreateStateSet();

	// activating blending in this drawable
	stateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
	stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
	stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
	stateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
	osg::BlendFunc *bf = new osg::BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	stateSet->setAttribute(bf);
/*
	const unsigned sx = 64;
	const unsigned sy = 64;
	const unsigned sz = 64;

	// 3D image to hold noise
	osg::Image *img = new osg::Image;
	img->allocateImage(sx, sy, sz, GL_RGB, GL_FLOAT);
	float *buf = reinterpret_cast<float*>(img->data());
	for(unsigned i = 0; i < sx; i++) {
		for(unsigned j = 0; j < sy; j++) {
			for(unsigned k = 0; k < sz; k++) {
				double n = ImprovedNoise::noise(i / static_cast<double>(sx),
												j / static_cast<double>(sy),
												k / static_cast<double>(sz)) + 0.5;
				buf[0] = n;
				buf[1] = n;
				buf[2] = n;

				buf += 3;
			}
		}
	}

	// setting up 3D smoke texture
	osg::Texture3D *tex = new osg::Texture3D;
	tex->setImage(img);
	stateSet->setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON);
*/
	setUseDisplayList(false);
}
Пример #8
0
ScreenTexture::ScreenTexture( unsigned order, Type type )
    : _texture(new osg::TextureRectangle())
    , _resolveFbo(new osg::FrameBufferObject())
    , _isNeededValidation(false)
{
    setUseDisplayList(false);

    _texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
    _texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
    _texture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::NEAREST);
    _texture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::NEAREST);
    _texture->setUseHardwareMipMapGeneration(false);

    if (type == DEPTH_TEXTURE)
    {
        _texture->setInternalFormat(GL_DEPTH_COMPONENT);
        _settings = new osg::Uniform(osg::Uniform::FLOAT_VEC2, "DepthTextureSettings");
    }
    else if (type == COLOR_TEXTURE)
        _texture->setInternalFormat(GL_RGBA);
    else
        avAssert(false);

    osg::ref_ptr<osg::StateSet> stateSet = getOrCreateStateSet();
    stateSet->setRenderBinDetails(order, "RenderBin");
    stateSet->setNestRenderBins(false);

    // create FBO for blit operations
    _blitBitMask = 0;
    if (type == DEPTH_TEXTURE)
        _blitBitMask = GL_DEPTH_BUFFER_BIT;
    else if (type == COLOR_TEXTURE)
        _blitBitMask = GL_COLOR_BUFFER_BIT;
    else
        avAssert(false);
}