source: Swollen/swollen/createSky.cpp @ 35

Last change on this file since 35 was 6, checked in by darran, 20 years ago

new import

File size: 993 bytes
Line 
1
2#include <osg/Geode>
3#include <osg/Geometry>
4#include <osg/ShapeDrawable>
5#include <osg/Texture2D>
6#include <osg/PolygonOffset>
7#include <osgDB/Registry>
8#include <osgDB/ReadFile>
9
10
11osg::Geode* createSky(float radius, char* filename)
12{
13    osg::Geode* geode = new osg::Geode;
14    osg::ShapeDrawable* geom = new osg::ShapeDrawable( new osg::Sphere(osg::Vec3(0,0,-radius/4.0),radius) );
15   
16    // set up the texture state.   
17    osg::Texture2D* texture = new osg::Texture2D;
18    texture->setDataVariance(osg::Object::DYNAMIC);  // protect from being optimized away as static state.
19    texture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
20    texture->setImage(osgDB::readImageFile(filename));
21   
22    osg::StateSet* stateset = new osg::StateSet;
23    stateset->setTextureAttributeAndModes( 0, texture, osg::StateAttribute::ON );
24    stateset->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
25    geom->setStateSet( stateset );
26 
27    geode->addDrawable(geom);
28    return geode;
29}
Note: See TracBrowser for help on using the repository browser.