Ejemplo n.º 1
0
CSulGeomGrid::CSulGeomGrid() :
osg::Geode(), 
m_colorGrid( 1.0f, 1.0f, 1.0f, 1.0f ),
m_colorGridDiv( 0.5f, 0.5f, 0.5f, 1.0f )
{
	createDrawable();
}
Ejemplo n.º 2
0
void SimpleHeightmap::create(int w, int h, float res, const float height) {
	setup(w,h,res);
	float* vx = new float[w*h*6];
	for(int x=0; x<w; ++x) for(int y=0; y<h; ++y) {
		float* v = vx + (x + y*w) * 6;
		v[0] = x * res;
		v[1] = height;
		v[2] = y * res;
	}
	createDrawable(vx);
}
Ejemplo n.º 3
0
void SimpleHeightmap::create(int w, int h, float res, const ubyte* data, int stride, float scale, float offset) {
	setup(w,h,res);
	float* vx = new float[w*h*6];
	for(int x=0; x<w; ++x) for(int y=0; y<h; ++y) {
		float* v = vx + (x + y*w) * 6;
		v[0] = x * res;
		v[1] = data[x+y*w] * scale + offset;
		v[2] = y * res;
	}
	createDrawable(vx);
}
Ejemplo n.º 4
0
CSulGeomBox::CSulGeomBox( float extent ) :
CSulGeode()
{
	m_minX = -extent;
	m_maxX =  extent;
	m_minY = -extent;
	m_maxY =  extent;
	m_minZ = -extent;
	m_maxZ =  extent;

	createDrawable();
}
Ejemplo n.º 5
0
CSulGeomBox::CSulGeomBox( const osg::BoundingBox& bb ) :
CSulGeode()
{
	m_minX = bb.xMin();
	m_maxX = bb.xMax();
	m_minY = bb.yMin();
	m_maxY = bb.yMax();
	m_minZ = bb.zMin();
	m_maxZ = bb.zMax();

	createDrawable();
}
Ejemplo n.º 6
0
CSulGeomBox::CSulGeomBox( float minX, float maxX, float minY, float maxY, float minZ, float maxZ ) :
CSulGeode()
{
	m_minX = minX;
	m_maxX = maxX;
	m_minY = minY;
	m_maxY = maxY;
	m_minZ = minZ;
	m_maxZ = maxZ;

	createDrawable();
}
Ejemplo n.º 7
0
CSulGeomBox::CSulGeomBox( float extentX, float extentY, float extentZ ) :
CSulGeode()
{
	m_minX = -extentX;
	m_maxX =  extentX;
	m_minY = -extentY;
	m_maxY =  extentY;
	m_minZ = -extentZ;
	m_maxZ =  extentZ;

	createDrawable();
}
Ejemplo n.º 8
0
CSulGeomArrow3D::CSulGeomArrow3D( float len, const osg::Vec4& colorHead, const osg::Vec4& colorBody ) :
CSulGeode(),
m_colorHead( colorHead ),
m_colorBody( colorBody )
{
	m_headLen		= len/3.0f; 
	m_headRadius	= len/5.0f;

	m_bodyLen		= len-m_headLen;
	m_bodyRadius	= len/10.0f;

	createDrawable();
}
Ejemplo n.º 9
0
void CSulGeomTriangleList::setColor( float r, float g, float b, float a )
{
	if ( !m_rColors.valid() )
	{
		createDrawable();
	}

	sigma::uint32 count = m_vecTri.size()*3;
	for ( sigma::uint32 i=0; i<count; i++  )
	{
		(*m_rColors)[i].set( r, g, b, a );
	}

	m_rGeo->dirtyDisplayList();
}
Ejemplo n.º 10
0
glws::Drawable *
createDrawable(void) {
    return createDrawable(defaultProfile);
}
Ejemplo n.º 11
0
osg::Node*
createSceneGraph()
{
    // Create the root node Group.
    osg::ref_ptr<osg::Group> root = new osg::Group;
    {
        // Disable lighting in the root node's StateSet. Make
        //   it PROTECTED to prevent osgviewer from enabling it.
        osg::StateSet* state = root->getOrCreateStateSet();
        state->setMode( GL_LIGHTING,
            osg::StateAttribute::OFF |
            osg::StateAttribute::PROTECTED );
    }

    // Create the leaf node Geode and attach the Drawable.
    osg::ref_ptr<osg::Geode> geode = new osg::Geode;
    geode->addDrawable( createDrawable() );

    osg::Matrix m;
    {
        // Upper-left: Render the drawable with default state.
        osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform;
        m.makeTranslate( -2.f, 0.f, 2.f );
        mt->setMatrix( m );
        root->addChild( mt.get() );
        mt->addChild( geode.get() );
    }
    {
        // Upper-right Set shade model to FLAT.
        osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform;
        mt->setName( "Flat" );
        m.makeTranslate( 2.f, 0.f, 2.f );
        mt->setMatrix( m );
        root->addChild( mt.get() );
        mt->addChild( geode.get() );

        osg::StateSet* state = mt->getOrCreateStateSet();
        osg::ShadeModel* sm = new osg::ShadeModel();
        sm->setMode( osg::ShadeModel::FLAT );
        state->setAttribute( sm );
    }
    {
        // Lower-left: Enable back face culling.
        osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform;
        m.makeTranslate( -2.f, 0.f, -2.f );
        mt->setMatrix( m );
        root->addChild( mt.get() );
        mt->addChild( geode.get() );

        osg::StateSet* state = mt->getOrCreateStateSet();
        osg::CullFace* cf = new osg::CullFace(); // Default: BACK
        state->setAttributeAndModes( cf );
    }
    {
        // Lower-right: Set polygon mode to LINE in draw3's StateSet.
        osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform;
        m.makeTranslate( 2.f, 0.f, -2.f );
        mt->setMatrix( m );
        root->addChild( mt.get() );
        mt->addChild( geode.get() );

        osg::StateSet* state = mt->getOrCreateStateSet();
        osg::PolygonMode* pm = new osg::PolygonMode(
            osg::PolygonMode::FRONT_AND_BACK,
            osg::PolygonMode::LINE );
        state->setAttributeAndModes( pm );

        // Also set the line width to 3.
        osg::LineWidth* lw = new osg::LineWidth( 3.f );
        state->setAttribute( lw );
    }

    return( root.release() );
}
Ejemplo n.º 12
0
CSulGeomAxis::CSulGeomAxis( float len ) :
m_len( len )
{
	createDrawable();
}
Ejemplo n.º 13
0
glws::Drawable *
createDrawable(void) {
    return createDrawable(getDefaultProfile());
}