Ported various demos and support classes over to use the new osg::Geometry class
thus removing dependancy on osg::Geoset from most of the OSG, only loaders left to port now.
This commit is contained in:
@@ -28,7 +28,7 @@ enum ArrayType
|
||||
Vec4ArrayType = 11
|
||||
};
|
||||
|
||||
class AttributeArray : public Object
|
||||
class SG_EXPORT AttributeArray : public Object
|
||||
{
|
||||
|
||||
public:
|
||||
@@ -117,7 +117,7 @@ enum PrimitiveType
|
||||
UIntDrawElementsPrimitiveType = 4,
|
||||
};
|
||||
|
||||
class Primitive : public Object
|
||||
class SG_EXPORT Primitive : public Object
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace osgUtil {
|
||||
|
||||
/** Visitor for traversing scene graph and setting each osg::GeoSet's _useDisplayList flag,
|
||||
/** Visitor for traversing scene graph and setting each osg::Drawable's _useDisplayList flag,
|
||||
* with option to immediately compile osg::Drawable OpenGL Display lists and
|
||||
* osg::StateAttribute's.
|
||||
*/
|
||||
@@ -32,13 +32,13 @@ class OSGUTIL_EXPORT DisplayListVisitor : public osg::NodeVisitor
|
||||
|
||||
typedef unsigned int Mode;
|
||||
|
||||
/** Construct a CompileGeoSetsVisior to traverse all child,
|
||||
/** Construct a DisplayListVisior to traverse all child,
|
||||
* with set specified display list mode. Default mode is to
|
||||
* gset->setUseDisplayList(true).
|
||||
*/
|
||||
DisplayListVisitor(Mode mode=COMPILE_DISPLAY_LISTS|COMPILE_STATE_ATTRIBUTES);
|
||||
|
||||
/** Set the operational mode of how the visitor should set up osg::GeoSet's.*/
|
||||
/** Set the operational mode of how the visitor should set up osg::Drawable's.*/
|
||||
void setMode(Mode mode) { _mode = mode; }
|
||||
|
||||
/** Get the operational mode.*/
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/Geode>
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Geometry>
|
||||
|
||||
#include <osgUtil/Export>
|
||||
|
||||
@@ -27,7 +27,7 @@ class OSGUTIL_EXPORT SmoothingVisitor : public osg::NodeVisitor
|
||||
}
|
||||
|
||||
/// smooth geoset by creating per vertex normals.
|
||||
static void smooth(osg::GeoSet& geoset);
|
||||
static void smooth(osg::Geometry& geoset);
|
||||
|
||||
/// apply smoothing method to all geode geosets.
|
||||
virtual void apply(osg::Geode& geode);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace osgUtil {
|
||||
|
||||
/** A tri stripping visitor for converting GeoSet primitives into tri strips.
|
||||
/** A tri stripping visitor for converting Geometry surface primitives into tri strips.
|
||||
* The current implemention is based up NVidia's NvTriStrip.
|
||||
*/
|
||||
class OSGUTIL_EXPORT TriStripVisitor : public osg::NodeVisitor
|
||||
@@ -26,13 +26,13 @@ class OSGUTIL_EXPORT TriStripVisitor : public osg::NodeVisitor
|
||||
setTraversalMode(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN);
|
||||
}
|
||||
|
||||
/** convert mesh primitives in geoset into Tri Strips using
|
||||
/** convert mesh primitives in Geometry into Tri Strips using
|
||||
* NvTriStrip. Converts all primitive types except points
|
||||
* and lines, linestrips which it leaves unchanged.
|
||||
*/
|
||||
static void stripify(osg::Geometry& drawable);
|
||||
|
||||
/// apply stripify method to all geode geosets.
|
||||
/// apply stripify method to all geode geometry.
|
||||
virtual void apply(osg::Geode& geode);
|
||||
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <osg/Geode>
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Texture>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/Depth>
|
||||
@@ -15,54 +15,39 @@ Node *makeBase( void )
|
||||
{
|
||||
int i, c;
|
||||
float theta;
|
||||
float ir, ori;
|
||||
ir = 0.0;
|
||||
ori = 20.0;
|
||||
float ir = 20.0f;
|
||||
|
||||
Vec3 *coords = new Vec3[38];
|
||||
Vec2 *tcoords = new Vec2[38];
|
||||
Vec4 *colors = new Vec4[1];
|
||||
Vec3Array *coords = new Vec3Array(19);
|
||||
Vec2Array *tcoords = new Vec2Array(19);
|
||||
Vec4Array *colors = new Vec4Array(1);
|
||||
int *lengths = new int[1];
|
||||
|
||||
colors[0][0] = colors[0][1] = colors[0][2] = colors[0][3] = 1;
|
||||
(*colors)[0].set(1.0f,1.0f,1.0f,1.0f);
|
||||
|
||||
c = 0;
|
||||
(*coords)[c].set(0.0f,0.0f,0.0f);
|
||||
(*tcoords)[c].set(0.0f,0.0f);
|
||||
|
||||
for( i = 0; i <= 18; i++ )
|
||||
{
|
||||
theta = osg::DegreesToRadians((float)i * 20.0);
|
||||
|
||||
coords[c][0] = ir * cosf( theta );
|
||||
coords[c][1] = ir * sinf( theta );
|
||||
coords[c][2] = 0.0;
|
||||
tcoords[c][0] = coords[c][0]/36.;
|
||||
tcoords[c][1] = coords[c][1]/36.;
|
||||
|
||||
c++;
|
||||
|
||||
coords[c][0] = ori * cosf( theta );
|
||||
coords[c][1] = ori * sinf( theta );
|
||||
coords[c][2] = 0.0f;
|
||||
|
||||
tcoords[c][0] = coords[c][0]/36.;
|
||||
tcoords[c][1] = coords[c][1]/36.;
|
||||
(*coords)[c].set(ir * cosf( theta ), ir * sinf( theta ), 0.0f);
|
||||
(*tcoords)[c].set((*coords)[c][0]/36.0f,(*coords)[c][1]/36.0f);
|
||||
|
||||
c++;
|
||||
}
|
||||
*lengths = 38;
|
||||
|
||||
GeoSet *gset = new GeoSet;
|
||||
Geometry *geom = new Geometry;
|
||||
|
||||
gset->setCoords( coords );
|
||||
geom->setVertexArray( coords );
|
||||
|
||||
gset->setTextureCoords( tcoords );
|
||||
gset->setTextureBinding( GeoSet::BIND_PERVERTEX );
|
||||
geom->setTexCoordArray( 0, tcoords );
|
||||
|
||||
gset->setColors( colors );
|
||||
gset->setColorBinding( GeoSet::BIND_OVERALL );
|
||||
geom->setColorArray( colors );
|
||||
geom->setColorBinding( Geometry::BIND_OVERALL );
|
||||
|
||||
gset->setPrimType( GeoSet::TRIANGLE_STRIP );
|
||||
gset->setNumPrims( 1 );
|
||||
gset->setPrimLengths( lengths );
|
||||
geom->addPrimitive( new DrawArrays(Primitive::TRIANGLE_FAN,0,19) );
|
||||
|
||||
Texture *tex = new Texture;
|
||||
|
||||
@@ -75,16 +60,6 @@ Node *makeBase( void )
|
||||
dstate->setAttributeAndModes( tex, StateAttribute::ON );
|
||||
|
||||
dstate->setAttribute( new TexEnv );
|
||||
/*
|
||||
pfFog *fog = new pfFog;
|
||||
|
||||
fog->setFogType( PFFOG_PIX_EXP2 );
|
||||
fog->setColor( 0.1, 0.2, 0.2 );
|
||||
fog->setRange( 16.0, 22.0 );
|
||||
|
||||
gstate->setMode( PFSTATE_ENFOG, PF_ON );
|
||||
gstate->setAttr( PFSTATE_FOG, fog );
|
||||
*/
|
||||
|
||||
// clear the depth to the far plane.
|
||||
osg::Depth* depth = new osg::Depth;
|
||||
@@ -95,10 +70,10 @@ Node *makeBase( void )
|
||||
dstate->setRenderBinDetails(-1,"RenderBin");
|
||||
|
||||
|
||||
gset->setStateSet( dstate );
|
||||
geom->setStateSet( dstate );
|
||||
|
||||
Geode *geode = new Geode;
|
||||
geode->addDrawable( gset );
|
||||
geode->addDrawable( geom );
|
||||
|
||||
return geode;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <osg/Geode>
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Texture>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/Depth>
|
||||
@@ -35,12 +35,13 @@ Node *makeSky( void )
|
||||
float radius = 20.0f;
|
||||
int nlev = sizeof( lev )/sizeof(float);
|
||||
|
||||
Vec3 *coords = new Vec3[19*nlev];
|
||||
Vec4 *colors = new Vec4[19*nlev];
|
||||
Vec2 *tcoords = new Vec2[19*nlev];
|
||||
osg::ushort *idx = new osg::ushort[38* nlev];
|
||||
int *lengths = new int[nlev];
|
||||
Geometry *geom = new Geometry;
|
||||
|
||||
Vec3Array& coords = *(new Vec3Array(19*nlev));
|
||||
Vec4Array& colors = *(new Vec4Array(19*nlev));
|
||||
Vec2Array& tcoords = *(new Vec2Array(19*nlev));
|
||||
|
||||
|
||||
int ci, ii;
|
||||
ii = ci = 0;
|
||||
|
||||
@@ -68,25 +69,35 @@ Node *makeSky( void )
|
||||
tcoords[ci][0] = (float)i/(float)(nlev-1);
|
||||
|
||||
ci++;
|
||||
|
||||
idx[ii++] = ((i+1)*19+j);
|
||||
idx[ii++] = ((i+0)*19+j);
|
||||
}
|
||||
lengths[i] = 38;
|
||||
|
||||
|
||||
}
|
||||
|
||||
GeoSet *gset = new GeoSet;
|
||||
for( i = 0; i < nlev-1; i++ )
|
||||
{
|
||||
for( j = 0; j <= 18; j++ )
|
||||
{
|
||||
|
||||
gset->setCoords( coords, idx );
|
||||
gset->setTextureCoords( tcoords, idx );
|
||||
gset->setTextureBinding( GeoSet::BIND_PERVERTEX );
|
||||
UShortDrawElements* drawElements = new UShortDrawElements(Primitive::TRIANGLE_STRIP);
|
||||
drawElements->reserve(38);
|
||||
|
||||
gset->setColors( colors, idx );
|
||||
gset->setColorBinding( GeoSet::BIND_PERVERTEX );
|
||||
for( j = 0; j <= 18; j++ )
|
||||
{
|
||||
drawElements->push_back((i+1)*19+j);
|
||||
drawElements->push_back((i+0)*19+j);
|
||||
}
|
||||
|
||||
geom->addPrimitive(drawElements);
|
||||
}
|
||||
}
|
||||
|
||||
geom->setVertexArray( &coords );
|
||||
geom->setTexCoordArray( 0, &tcoords );
|
||||
|
||||
geom->setColorArray( &colors );
|
||||
geom->setColorBinding( Geometry::BIND_PER_VERTEX );
|
||||
|
||||
gset->setPrimType( GeoSet::TRIANGLE_STRIP );
|
||||
gset->setNumPrims( nlev - 1 );
|
||||
gset->setPrimLengths( lengths );
|
||||
|
||||
Texture *tex = new Texture;
|
||||
tex->setImage(osgDB::readImageFile("Images/white.rgb"));
|
||||
@@ -107,10 +118,10 @@ Node *makeSky( void )
|
||||
|
||||
dstate->setRenderBinDetails(-2,"RenderBin");
|
||||
|
||||
gset->setStateSet( dstate );
|
||||
geom->setStateSet( dstate );
|
||||
|
||||
Geode *geode = new Geode;
|
||||
geode->addDrawable( gset );
|
||||
geode->addDrawable( geom );
|
||||
|
||||
geode->setName( "Sky" );
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <osg/GL>
|
||||
#include <osg/Group>
|
||||
#include <osg/Geode>
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Texture>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/StateSet>
|
||||
@@ -44,7 +44,7 @@ static void conv( const Vec3& a, const Matrix& mat, Vec3& b )
|
||||
Node *makeTank( void )
|
||||
{
|
||||
|
||||
Geode *geode1 = new Geode;
|
||||
Geode *geode = new Geode;
|
||||
|
||||
getDatabaseCenterRadius( dbcenter, &dbradius );
|
||||
|
||||
@@ -58,12 +58,16 @@ Node *makeTank( void )
|
||||
1
|
||||
);
|
||||
|
||||
Vec3 *vc = new Vec3[42];
|
||||
Vec2 *tc = new Vec2[42];
|
||||
int *lens = new int[1];
|
||||
int i, c;
|
||||
// 42 required for sodes, 22 for the top.
|
||||
Vec3Array& vc = *(new Vec3Array(42+22));
|
||||
Vec2Array& tc = *(new Vec2Array(42+22));
|
||||
|
||||
c = 0;
|
||||
Geometry *gset = new Geometry;
|
||||
gset->setVertexArray( &vc );
|
||||
gset->setTexCoordArray( 0, &tc );
|
||||
|
||||
// create the sides of the tank.
|
||||
unsigned int i, c = 0;
|
||||
for( i = 0; i <= 360; i += 18 )
|
||||
{
|
||||
float x, y, z;
|
||||
@@ -97,41 +101,13 @@ Node *makeTank( void )
|
||||
tc[c][1] = t;
|
||||
c++;
|
||||
}
|
||||
*lens = 42;
|
||||
|
||||
for( i = 0; i < c; i++ )
|
||||
conv( vc[i], *mat, vc[i] );
|
||||
gset->addPrimitive( new DrawArrays(Primitive::TRIANGLE_STRIP,0,c) );
|
||||
|
||||
GeoSet *gset = new GeoSet;
|
||||
gset->setCoords( vc );
|
||||
// create the top of the tank.
|
||||
|
||||
gset->setTextureCoords( tc );
|
||||
gset->setTextureBinding( GeoSet::BIND_PERVERTEX );
|
||||
int prev_c = c;
|
||||
|
||||
gset->setPrimType( GeoSet::TRIANGLE_STRIP );
|
||||
gset->setNumPrims( 1 );
|
||||
gset->setPrimLengths( lens );
|
||||
|
||||
Texture *tex = new Texture;
|
||||
|
||||
tex->setWrap( Texture::WRAP_S, Texture::REPEAT );
|
||||
tex->setWrap( Texture::WRAP_T, Texture::REPEAT );
|
||||
tex->setImage(osgDB::readImageFile("Images/tank.rgb"));
|
||||
|
||||
StateSet *dstate = new StateSet;
|
||||
dstate->setAttributeAndModes( tex, StateAttribute::ON );
|
||||
dstate->setAttribute( new TexEnv );
|
||||
|
||||
gset->setStateSet( dstate );
|
||||
geode1->addDrawable( gset );
|
||||
|
||||
lens = new int[1];
|
||||
*lens = 22;
|
||||
|
||||
vc = new Vec3[22];
|
||||
tc = new Vec2[22];
|
||||
|
||||
c = 0;
|
||||
vc[c][0] = 0.0f;
|
||||
vc[c][1] = 0.0f;
|
||||
vc[c][2] = 1.0f;
|
||||
@@ -167,26 +143,24 @@ Node *makeTank( void )
|
||||
|
||||
for( i = 0; i < c; i++ )
|
||||
conv( vc[i], *mat, vc[i] );
|
||||
|
||||
gset->addPrimitive(new DrawArrays(Primitive::TRIANGLE_FAN,prev_c,c-prev_c));
|
||||
|
||||
gset = new GeoSet;
|
||||
gset->setCoords( vc );
|
||||
gset->setTextureCoords( tc );
|
||||
gset->setPrimType(GeoSet::TRIANGLE_FAN);
|
||||
gset->setNumPrims( 1 );
|
||||
gset->setPrimLengths( lens );
|
||||
|
||||
|
||||
|
||||
Texture *tex = new Texture;
|
||||
|
||||
tex->setWrap( Texture::WRAP_S, Texture::REPEAT );
|
||||
tex->setWrap( Texture::WRAP_T, Texture::REPEAT );
|
||||
tex->setImage(osgDB::readImageFile("Images/tank.rgb"));
|
||||
|
||||
StateSet *dstate = new StateSet;
|
||||
dstate->setAttributeAndModes( tex, StateAttribute::ON );
|
||||
dstate->setAttribute( new TexEnv );
|
||||
|
||||
gset->setStateSet( dstate );
|
||||
geode->addDrawable( gset );
|
||||
|
||||
Geode *geode2 = new Geode;
|
||||
geode2->addDrawable( gset );
|
||||
|
||||
|
||||
Group *grp = new Group;
|
||||
grp->addChild( geode1 );
|
||||
grp->addChild( geode2 );
|
||||
|
||||
geode1->setName( "Geode 1" );
|
||||
geode2->setName( "Geode 2" );
|
||||
|
||||
return grp;
|
||||
return geode;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// #include <math.h>
|
||||
|
||||
#include <osg/Geode>
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Texture>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/StateSet>
|
||||
@@ -73,15 +73,11 @@ Node *makeTerrain( void )
|
||||
m = (sizeof( vertex ) /(sizeof( float[3])))/39;
|
||||
n = 39;
|
||||
|
||||
Vec3 *v = new Vec3[m*n];
|
||||
Vec2 *t = new Vec2[m*n];
|
||||
Vec4 *col = new Vec4[1];
|
||||
osg::ushort *cidx = new osg::ushort[1];
|
||||
osg::ushort *idx = new osg::ushort[m*n*2];
|
||||
int *lens = new int[m];
|
||||
|
||||
col[0][0] = col[0][1] = col[0][2] = col[0][3] = 1;
|
||||
*cidx = 0;
|
||||
Vec3Array& v = *(new Vec3Array(m*n));
|
||||
Vec2Array& t = *(new Vec2Array(m*n));
|
||||
Vec4Array& col = *(new Vec4Array(1));
|
||||
|
||||
col[0][0] = col[0][1] = col[0][2] = col[0][3] = 1.0f;
|
||||
|
||||
for( i = 0; i < m * n; i++ )
|
||||
{
|
||||
@@ -93,29 +89,27 @@ Node *makeTerrain( void )
|
||||
t[i][1] = texcoord[i][1];
|
||||
}
|
||||
|
||||
Geometry *geom = new Geometry;
|
||||
|
||||
geom->setVertexArray( &v );
|
||||
geom->setTexCoordArray( 0, &t );
|
||||
|
||||
geom->setColorArray( &col );
|
||||
geom->setColorBinding( Geometry::BIND_OVERALL );
|
||||
|
||||
c = 0;
|
||||
for( i = 0; i < m-2; i++ )
|
||||
{
|
||||
UShortDrawElements* elements = new UShortDrawElements(Primitive::TRIANGLE_STRIP);
|
||||
elements->reserve(39*2);
|
||||
for( j = 0; j < n; j++ )
|
||||
{
|
||||
idx[c++] = (i+0)*n+j;
|
||||
idx[c++] = (i+1)*n+j;
|
||||
elements->push_back((i+0)*n+j);
|
||||
elements->push_back((i+1)*n+j);
|
||||
}
|
||||
lens[i] = 39*2;
|
||||
geom->addPrimitive(elements);
|
||||
}
|
||||
|
||||
GeoSet *gset = new GeoSet;
|
||||
|
||||
gset->setCoords( v, idx );
|
||||
gset->setTextureCoords( t, idx );
|
||||
gset->setTextureBinding( GeoSet::BIND_PERVERTEX );
|
||||
|
||||
gset->setColors( col, cidx );
|
||||
gset->setColorBinding( GeoSet::BIND_OVERALL );
|
||||
|
||||
gset->setPrimType( GeoSet::TRIANGLE_STRIP );
|
||||
gset->setNumPrims( m-2 );
|
||||
gset->setPrimLengths( lens );
|
||||
|
||||
Texture *tex = new Texture;
|
||||
|
||||
@@ -126,12 +120,10 @@ Node *makeTerrain( void )
|
||||
dstate->setAttributeAndModes( tex, StateAttribute::ON );
|
||||
dstate->setAttribute( new TexEnv );
|
||||
|
||||
gset->setStateSet( dstate );
|
||||
geom->setStateSet( dstate );
|
||||
|
||||
Geode *geode = new Geode;
|
||||
geode->addDrawable( gset );
|
||||
|
||||
gset->check();
|
||||
geode->addDrawable( geom );
|
||||
|
||||
return geode;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <osg/Billboard>
|
||||
#include <osg/Group>
|
||||
#include <osg/Geode>
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Texture>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/Transparency>
|
||||
@@ -144,7 +144,7 @@ trees[] =
|
||||
{ -1, 0, 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
static GeoSet *makeTree( _tree *tree, StateSet *dstate )
|
||||
static Geometry *makeTree( _tree *tree, StateSet *dstate )
|
||||
{
|
||||
float vv[][3] =
|
||||
{
|
||||
@@ -154,9 +154,9 @@ static GeoSet *makeTree( _tree *tree, StateSet *dstate )
|
||||
{ -tree->w/2.0, 0.0, 2 * tree->h },
|
||||
};
|
||||
|
||||
Vec3 *v = new Vec3[4];
|
||||
Vec2 *t = new Vec2[4];
|
||||
Vec4 *l = new Vec4[1];
|
||||
Vec3Array& v = *(new Vec3Array(4));
|
||||
Vec2Array& t = *(new Vec2Array(4));
|
||||
Vec4Array& l = *(new Vec4Array(1));
|
||||
|
||||
int i;
|
||||
|
||||
@@ -174,22 +174,20 @@ static GeoSet *makeTree( _tree *tree, StateSet *dstate )
|
||||
t[2][0] = 1.0; t[2][1] = 1.0;
|
||||
t[3][0] = 0.0; t[3][1] = 1.0;
|
||||
|
||||
GeoSet *gset = new GeoSet;
|
||||
Geometry *geom = new Geometry;
|
||||
|
||||
gset->setCoords( v );
|
||||
geom->setVertexArray( &v );
|
||||
|
||||
gset->setTextureCoords( t );
|
||||
gset->setTextureBinding( GeoSet::BIND_PERVERTEX );
|
||||
geom->setTexCoordArray( 0, &t );
|
||||
|
||||
gset->setColors( l );
|
||||
gset->setColorBinding( GeoSet::BIND_OVERALL );
|
||||
geom->setColorArray( &l );
|
||||
geom->setColorBinding( Geometry::BIND_OVERALL );
|
||||
|
||||
gset->setPrimType( GeoSet::QUADS );
|
||||
gset->setNumPrims( 1 );
|
||||
geom->addPrimitive( new DrawArrays(Primitive::QUADS,0,4) );
|
||||
|
||||
gset->setStateSet( dstate );
|
||||
geom->setStateSet( dstate );
|
||||
|
||||
return gset;
|
||||
return geom;
|
||||
}
|
||||
|
||||
|
||||
@@ -263,8 +261,8 @@ Node *makeTrees( void )
|
||||
t->x -= 0.3f;
|
||||
float h = Hat(t->x, t->y, t->z );
|
||||
Vec3 pos( t->x, t->y, t->z-h );
|
||||
GeoSet *gset = makeTree( t, dstate );
|
||||
bb->addDrawable( gset, pos );
|
||||
Geometry *geom = makeTree( t, dstate );
|
||||
bb->addDrawable( geom, pos );
|
||||
t++;
|
||||
}
|
||||
group->addChild( bb );
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <osg/Node>
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Notify>
|
||||
#include <osg/Transform>
|
||||
#include <osg/Texture>
|
||||
@@ -60,33 +60,31 @@ ImageList getImagesFromFiles(std::vector<std::string>& commandLine)
|
||||
/** create 2,2 square with center at 0,0,0 and aligned along the XZ plan */
|
||||
osg::Drawable* createSquare(float textureCoordMax=1.0f)
|
||||
{
|
||||
// set up the geoset.
|
||||
osg::GeoSet* gset = osgNew osg::GeoSet;
|
||||
// set up the Geometry.
|
||||
osg::Geometry* geom = new osg::Geometry;
|
||||
|
||||
osg::Vec3* coords = osgNew osg::Vec3 [4];
|
||||
coords[0].set(-1.0f,0.0f,1.0f);
|
||||
coords[1].set(-1.0f,0.0f,-1.0f);
|
||||
coords[2].set(1.0f,0.0f,-1.0f);
|
||||
coords[3].set(1.0f,0.0f,1.0f);
|
||||
gset->setCoords(coords);
|
||||
osg::Vec3Array* coords = new osg::Vec3Array(4);
|
||||
(*coords)[0].set(-1.0f,0.0f,1.0f);
|
||||
(*coords)[1].set(-1.0f,0.0f,-1.0f);
|
||||
(*coords)[2].set(1.0f,0.0f,-1.0f);
|
||||
(*coords)[3].set(1.0f,0.0f,1.0f);
|
||||
geom->setVertexArray(coords);
|
||||
|
||||
osg::Vec3* norms = osgNew osg::Vec3 [1];
|
||||
norms[0].set(0.0f,-1.0f,0.0f);
|
||||
gset->setNormals(norms);
|
||||
gset->setNormalBinding(osg::GeoSet::BIND_OVERALL);
|
||||
osg::Vec3Array* norms = new osg::Vec3Array(1);
|
||||
(*norms)[0].set(0.0f,-1.0f,0.0f);
|
||||
geom->setNormalArray(norms);
|
||||
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
osg::Vec2* tcoords = osgNew osg::Vec2 [4];
|
||||
tcoords[0].set(0.0f,textureCoordMax);
|
||||
tcoords[1].set(0.0f,0.0f);
|
||||
tcoords[2].set(textureCoordMax,0.0f);
|
||||
tcoords[3].set(textureCoordMax,textureCoordMax);
|
||||
gset->setTextureCoords(tcoords);
|
||||
gset->setTextureBinding(osg::GeoSet::BIND_PERVERTEX);
|
||||
osg::Vec2Array* tcoords = new osg::Vec2Array(4);
|
||||
(*tcoords)[0].set(0.0f,textureCoordMax);
|
||||
(*tcoords)[1].set(0.0f,0.0f);
|
||||
(*tcoords)[2].set(textureCoordMax,0.0f);
|
||||
(*tcoords)[3].set(textureCoordMax,textureCoordMax);
|
||||
geom->setTexCoordArray(0,tcoords);
|
||||
|
||||
gset->setNumPrims(1);
|
||||
gset->setPrimType(osg::GeoSet::QUADS);
|
||||
geom->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::QUADS,0,4));
|
||||
|
||||
return gset;
|
||||
return geom;
|
||||
}
|
||||
|
||||
osg::Node* createTexturedItem(const osg::Vec3& offset,osg::Texture* texture,osg::Node* geometry)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <osgUtil/Optimizer>
|
||||
|
||||
#include <osg/OccluderNode>
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Geometry>
|
||||
|
||||
void write_usage(std::ostream& out,const std::string& name)
|
||||
{
|
||||
@@ -94,31 +94,27 @@ osg::Node* createOccluder(const osg::Vec3& v1,const osg::Vec3& v2,const osg::Vec
|
||||
|
||||
|
||||
// create a drawable for occluder.
|
||||
osg::GeoSet* geoset = osgNew osg::GeoSet;
|
||||
osg::Geometry* geom = osgNew osg::Geometry;
|
||||
|
||||
osg::Vec3* coords = osgNew osg::Vec3[occluder.getVertexList().size()];
|
||||
std::copy(occluder.getVertexList().begin(),occluder.getVertexList().end(),coords);
|
||||
geoset->setCoords(coords);
|
||||
osg::Vec3Array* coords = osgNew osg::Vec3Array(occluder.getVertexList().begin(),occluder.getVertexList().end());
|
||||
geom->setVertexArray(coords);
|
||||
|
||||
osg::Vec4* color = osgNew osg::Vec4[1];
|
||||
color[0].set(1.0f,1.0f,1.0f,0.5f);
|
||||
geoset->setColors(color);
|
||||
geoset->setColorBinding(osg::GeoSet::BIND_OVERALL);
|
||||
osg::Vec4Array* colors = osgNew osg::Vec4Array(1);
|
||||
(*colors)[0].set(1.0f,1.0f,1.0f,0.5f);
|
||||
geom->setColorArray(colors);
|
||||
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
geoset->setPrimType(osg::GeoSet::QUADS);
|
||||
geoset->setNumPrims(1);
|
||||
// geoset->setPrimType(osg::GeoSet::POINTS);
|
||||
// geoset->setNumPrims(4);
|
||||
geom->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::QUADS,0,4));
|
||||
|
||||
osg::Geode* geode = osgNew osg::Geode;
|
||||
geode->addDrawable(geoset);
|
||||
geode->addDrawable(geom);
|
||||
|
||||
osg::StateSet* stateset = osgNew osg::StateSet;
|
||||
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
|
||||
stateset->setMode(GL_BLEND,osg::StateAttribute::ON);
|
||||
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
|
||||
|
||||
geoset->setStateSet(stateset);
|
||||
geom->setStateSet(stateset);
|
||||
|
||||
// add the occluder geode as a child of the occluder,
|
||||
// as the occluder can't self occlude its subgraph the
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <osg/Node>
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Notify>
|
||||
#include <osg/Transform>
|
||||
#include <osg/Texture>
|
||||
@@ -65,38 +65,36 @@ osg::Drawable* createMirrorSurface(float xMin,float xMax,float yMin,float yMax,f
|
||||
|
||||
// set up the drawstate.
|
||||
|
||||
// set up the geoset.
|
||||
osg::GeoSet* gset = new osg::GeoSet;
|
||||
// set up the Geometry.
|
||||
osg::Geometry* geom = new osg::Geometry;
|
||||
|
||||
osg::Vec3* coords = new osg::Vec3[4];
|
||||
coords[0].set(xMin,yMax,z);
|
||||
coords[1].set(xMin,yMin,z);
|
||||
coords[2].set(xMax,yMin,z);
|
||||
coords[3].set(xMax,yMax,z);
|
||||
gset->setCoords(coords);
|
||||
osg::Vec3Array* coords = new osg::Vec3Array(4);
|
||||
(*coords)[0].set(xMin,yMax,z);
|
||||
(*coords)[1].set(xMin,yMin,z);
|
||||
(*coords)[2].set(xMax,yMin,z);
|
||||
(*coords)[3].set(xMax,yMax,z);
|
||||
geom->setVertexArray(coords);
|
||||
|
||||
osg::Vec3* norms = new osg::Vec3[1];
|
||||
norms[0].set(0.0f,0.0f,1.0f);
|
||||
gset->setNormals(norms);
|
||||
gset->setNormalBinding(osg::GeoSet::BIND_OVERALL);
|
||||
osg::Vec3Array* norms = new osg::Vec3Array(1);
|
||||
(*norms)[0].set(0.0f,0.0f,1.0f);
|
||||
geom->setNormalArray(norms);
|
||||
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
osg::Vec2* tcoords = new osg::Vec2[4];
|
||||
tcoords[0].set(0.0f,1.0f);
|
||||
tcoords[1].set(0.0f,0.0f);
|
||||
tcoords[2].set(1.0f,0.0f);
|
||||
tcoords[3].set(1.0f,1.0f);
|
||||
gset->setTextureCoords(tcoords);
|
||||
gset->setTextureBinding(osg::GeoSet::BIND_PERVERTEX);
|
||||
osg::Vec2Array* tcoords = new osg::Vec2Array(4);
|
||||
(*tcoords)[0].set(0.0f,1.0f);
|
||||
(*tcoords)[1].set(0.0f,0.0f);
|
||||
(*tcoords)[2].set(1.0f,0.0f);
|
||||
(*tcoords)[3].set(1.0f,1.0f);
|
||||
geom->setTexCoordArray(0,tcoords);
|
||||
|
||||
osg::Vec4* colours = new osg::Vec4[1];
|
||||
colours->set(1.0f,1.0f,1.0,1.0f);
|
||||
gset->setColors(colours);
|
||||
gset->setColorBinding(osg::GeoSet::BIND_OVERALL);
|
||||
osg::Vec4Array* colours = new osg::Vec4Array(1);
|
||||
(*colours)[0].set(1.0f,1.0f,1.0,1.0f);
|
||||
geom->setColorArray(colours);
|
||||
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
gset->setNumPrims(1);
|
||||
gset->setPrimType(osg::GeoSet::QUADS);
|
||||
geom->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::QUADS,0,4));
|
||||
|
||||
return gset;
|
||||
return geom;
|
||||
}
|
||||
|
||||
void write_usage(std::ostream& out,const std::string& name)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <osg/Node>
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Notify>
|
||||
#include <osg/Transform>
|
||||
#include <osg/Texture>
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
#include <osg/Node>
|
||||
#include <osg/StateSet>
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Material>
|
||||
#include <osg/Transparency>
|
||||
#include <osg/Transform>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <osg/Node>
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Notify>
|
||||
#include <osg/Transform>
|
||||
#include <osg/Texture>
|
||||
@@ -101,33 +101,31 @@ ImageList getImagesFromFiles(std::vector<std::string>& commandLine)
|
||||
/** create 2,2 square with center at 0,0,0 and aligned along the XZ plan */
|
||||
osg::Drawable* createSquare(float textureCoordMax=1.0f)
|
||||
{
|
||||
// set up the geoset.
|
||||
osg::GeoSet* gset = new osg::GeoSet;
|
||||
// set up the Geometry.
|
||||
osg::Geometry* geom = new osg::Geometry;
|
||||
|
||||
osg::Vec3* coords = new osg::Vec3 [4];
|
||||
coords[0].set(-1.0f,0.0f,1.0f);
|
||||
coords[1].set(-1.0f,0.0f,-1.0f);
|
||||
coords[2].set(1.0f,0.0f,-1.0f);
|
||||
coords[3].set(1.0f,0.0f,1.0f);
|
||||
gset->setCoords(coords);
|
||||
osg::Vec3Array* coords = new osg::Vec3Array(4);
|
||||
(*coords)[0].set(-1.0f,0.0f,1.0f);
|
||||
(*coords)[1].set(-1.0f,0.0f,-1.0f);
|
||||
(*coords)[2].set(1.0f,0.0f,-1.0f);
|
||||
(*coords)[3].set(1.0f,0.0f,1.0f);
|
||||
geom->setVertexArray(coords);
|
||||
|
||||
osg::Vec3* norms = new osg::Vec3 [1];
|
||||
norms[0].set(0.0f,-1.0f,0.0f);
|
||||
gset->setNormals(norms);
|
||||
gset->setNormalBinding(osg::GeoSet::BIND_OVERALL);
|
||||
osg::Vec3Array* norms = new osg::Vec3Array(1);
|
||||
(*norms)[0].set(0.0f,-1.0f,0.0f);
|
||||
geom->setNormalArray(norms);
|
||||
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
osg::Vec2* tcoords = new osg::Vec2 [4];
|
||||
tcoords[0].set(0.0f,textureCoordMax);
|
||||
tcoords[1].set(0.0f,0.0f);
|
||||
tcoords[2].set(textureCoordMax,0.0f);
|
||||
tcoords[3].set(textureCoordMax,textureCoordMax);
|
||||
gset->setTextureCoords(tcoords);
|
||||
gset->setTextureBinding(osg::GeoSet::BIND_PERVERTEX);
|
||||
osg::Vec2Array* tcoords = new osg::Vec2Array(4);
|
||||
(*tcoords)[0].set(0.0f,textureCoordMax);
|
||||
(*tcoords)[1].set(0.0f,0.0f);
|
||||
(*tcoords)[2].set(textureCoordMax,0.0f);
|
||||
(*tcoords)[3].set(textureCoordMax,textureCoordMax);
|
||||
geom->setTexCoordArray(0,tcoords);
|
||||
|
||||
gset->setNumPrims(1);
|
||||
gset->setPrimType(osg::GeoSet::QUADS);
|
||||
geom->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::QUADS,0,4));
|
||||
|
||||
return gset;
|
||||
return geom;
|
||||
}
|
||||
|
||||
osg::Node* createTexturedItem(const osg::Vec3& offset,osg::Texture* texture,osg::Node* geometry)
|
||||
|
||||
@@ -855,7 +855,7 @@ void Viewer::keyboard(unsigned char key, int x, int y)
|
||||
_useDisplayLists = !_useDisplayLists;
|
||||
if (_useDisplayLists)
|
||||
{
|
||||
// traverse the scene graph setting up all osg::GeoSet's so they will use
|
||||
// traverse the scene graph setting up all osg::Drawable's so they will use
|
||||
// OpenGL display lists.
|
||||
osgUtil::DisplayListVisitor dlv(osgUtil::DisplayListVisitor::SWITCH_ON_DISPLAY_LISTS);
|
||||
sceneView->getSceneData()->accept(dlv);
|
||||
@@ -863,7 +863,7 @@ void Viewer::keyboard(unsigned char key, int x, int y)
|
||||
}
|
||||
else
|
||||
{
|
||||
// traverse the scene graph setting up all osg::GeoSet's so they will use
|
||||
// traverse the scene graph setting up all osg::Drawable's so they will use
|
||||
// OpenGL display lists.
|
||||
osgUtil::DisplayListVisitor dlv(osgUtil::DisplayListVisitor::SWITCH_OFF_DISPLAY_LISTS);
|
||||
sceneView->getSceneData()->accept(dlv);
|
||||
|
||||
@@ -164,7 +164,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterLWO::readNode(const std::string& fil
|
||||
gset->setCoords(coord, cindex);
|
||||
gset->setStateSet(state);
|
||||
|
||||
smoother.smooth(*gset);
|
||||
// smoother.smooth(*gset);
|
||||
|
||||
geode->addDrawable(gset);
|
||||
|
||||
|
||||
@@ -9,11 +9,8 @@
|
||||
#include <osg/Notify>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/AlphaFunc>
|
||||
|
||||
#include <osg/LineSegment>
|
||||
|
||||
#include <osg/GeoSet>
|
||||
|
||||
#include <osgUtil/CullVisitor>
|
||||
#include <osgUtil/RenderToTextureStage>
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
#include <list>
|
||||
#include <set>
|
||||
|
||||
#include <osg/GeoSet>
|
||||
|
||||
#include <osgUtil/DisplayRequirementsVisitor>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
@@ -809,8 +809,8 @@ bool Optimizer::RemoveLowestStaticTransformsVisitor::removeTransforms()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(TransformMap::iterator titr=_transformMap.begin();
|
||||
TransformMap::iterator titr;
|
||||
for(titr=_transformMap.begin();
|
||||
titr!=_transformMap.end();
|
||||
++titr)
|
||||
{
|
||||
@@ -858,7 +858,7 @@ bool Optimizer::RemoveLowestStaticTransformsVisitor::removeTransforms()
|
||||
bool transformsRemoved = false;
|
||||
|
||||
// clean up the transforms.
|
||||
for(TransformMap::iterator titr=_transformMap.begin();
|
||||
for(titr=_transformMap.begin();
|
||||
titr!=_transformMap.end();
|
||||
++titr)
|
||||
{
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning( disable : 4786 )
|
||||
#endif
|
||||
#include <osgUtil/SmoothingVisitor>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <list>
|
||||
#include <set>
|
||||
|
||||
#include <osg/GeoSet>
|
||||
|
||||
#include <osgUtil/SmoothingVisitor>
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgUtil;
|
||||
@@ -25,14 +20,21 @@ struct LessPtr
|
||||
struct SmoothTriangleFunctor
|
||||
{
|
||||
|
||||
osg::Vec3 *_coordBase;
|
||||
osg::Vec3 *_normalBase;
|
||||
osg::Vec3* _coordBase;
|
||||
osg::Vec3* _normalBase;
|
||||
|
||||
typedef std::multiset<const osg::Vec3*,LessPtr> CoordinateSet;
|
||||
CoordinateSet _coordSet;
|
||||
|
||||
SmoothTriangleFunctor(osg::Vec3 *cb,int noVertices, osg::Vec3 *nb) : _coordBase(cb),_normalBase(nb)
|
||||
SmoothTriangleFunctor():
|
||||
_coordBase(0),
|
||||
_normalBase(0) {}
|
||||
|
||||
void set(osg::Vec3 *cb,int noVertices, osg::Vec3 *nb)
|
||||
{
|
||||
_coordBase=cb;
|
||||
_normalBase=nb;
|
||||
|
||||
osg::Vec3* vptr = cb;
|
||||
for(int i=0;i<noVertices;++i)
|
||||
{
|
||||
@@ -67,100 +69,62 @@ struct SmoothTriangleFunctor
|
||||
}
|
||||
};
|
||||
|
||||
void SmoothingVisitor::smooth(osg::GeoSet& gset)
|
||||
void SmoothingVisitor::smooth(osg::Geometry& geom)
|
||||
{
|
||||
GeoSet::PrimitiveType primTypeIn = gset.getPrimType();
|
||||
GeoSet::PrimitiveType primTypeOut = gset.getPrimType();
|
||||
|
||||
// determine whether to do smoothing or not, and if
|
||||
// the primitive type needs to be modified enable smoothed normals.
|
||||
bool doSmoothing;
|
||||
switch(primTypeIn)
|
||||
Geometry::PrimitiveList& primitives = geom.getPrimitiveList();
|
||||
Geometry::PrimitiveList::iterator itr;
|
||||
unsigned int numSurfacePrimitives=0;
|
||||
for(itr=primitives.begin();
|
||||
itr!=primitives.end();
|
||||
++itr)
|
||||
{
|
||||
case(GeoSet::TRIANGLES):
|
||||
case(GeoSet::TRIANGLE_STRIP):
|
||||
case(GeoSet::TRIANGLE_FAN):
|
||||
doSmoothing = true;
|
||||
break;
|
||||
/*
|
||||
case(GeoSet::FLAT_TRIANGLE_STRIP):
|
||||
primTypeOut = GeoSet::TRIANGLE_STRIP;
|
||||
doSmoothing = true;
|
||||
break;
|
||||
case(GeoSet::FLAT_TRIANGLE_FAN):
|
||||
primTypeOut = GeoSet::TRIANGLE_FAN;
|
||||
doSmoothing = true;
|
||||
break;
|
||||
*/
|
||||
case(GeoSet::QUADS):
|
||||
case(GeoSet::QUAD_STRIP):
|
||||
case(GeoSet::POLYGON):
|
||||
doSmoothing = true;
|
||||
break;
|
||||
default: // points and lines etc.
|
||||
doSmoothing = false;
|
||||
break;
|
||||
switch((*itr)->getMode())
|
||||
{
|
||||
case(Primitive::TRIANGLES):
|
||||
case(Primitive::TRIANGLE_STRIP):
|
||||
case(Primitive::TRIANGLE_FAN):
|
||||
case(Primitive::QUADS):
|
||||
case(Primitive::QUAD_STRIP):
|
||||
case(Primitive::POLYGON):
|
||||
++numSurfacePrimitives;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!numSurfacePrimitives) return;
|
||||
|
||||
osg::Vec3Array *coords = geom.getVertexArray();
|
||||
if (!coords || !coords->size()) return;
|
||||
|
||||
osg::Vec3Array *normals = osgNew osg::Vec3Array(coords->size());
|
||||
|
||||
osg::Vec3Array::iterator nitr;
|
||||
for(nitr = normals->begin();
|
||||
nitr!=normals->end();
|
||||
++nitr)
|
||||
{
|
||||
nitr->set(0.0f,0.0f,0.0f);
|
||||
}
|
||||
|
||||
if (doSmoothing)
|
||||
TriangleFunctor<SmoothTriangleFunctor> stf;
|
||||
stf.set(&(coords->front()),coords->size(),&(normals->front()));
|
||||
|
||||
geom.applyPrimitiveOperation(stf);
|
||||
|
||||
for(nitr= normals->begin();
|
||||
nitr!=normals->end();
|
||||
++nitr)
|
||||
{
|
||||
gset.computeNumVerts();
|
||||
int ncoords = gset.getNumCoords();
|
||||
osg::Vec3 *coords = gset.getCoords();
|
||||
osg::GeoSet::IndexPointer cindex = gset.getCoordIndices();
|
||||
osg::Vec3 *norms = osgNew osg::Vec3[ncoords];
|
||||
|
||||
int j;
|
||||
for(j = 0; j < ncoords; j++ )
|
||||
{
|
||||
norms[j].set(0.0f,0.0f,0.0f);
|
||||
}
|
||||
|
||||
SmoothTriangleFunctor tf(coords,ncoords,norms);
|
||||
for_each_triangle( gset, tf );
|
||||
|
||||
for(j = 0; j < ncoords; j++ )
|
||||
{
|
||||
float len = norms[j].length();
|
||||
if (len) norms[j]/=len;
|
||||
}
|
||||
|
||||
gset.setNormalBinding(osg::GeoSet::BIND_PERVERTEX);
|
||||
|
||||
if (cindex.valid())
|
||||
{
|
||||
if (cindex._is_ushort)
|
||||
gset.setNormals( norms, cindex._ptr._ushort );
|
||||
else
|
||||
gset.setNormals( norms, cindex._ptr._uint );
|
||||
}
|
||||
else
|
||||
{
|
||||
gset.setNormals( norms );
|
||||
}
|
||||
|
||||
if (primTypeIn!=primTypeOut)
|
||||
{
|
||||
|
||||
if (primTypeIn==GeoSet::FLAT_TRIANGLE_STRIP)
|
||||
{
|
||||
gset.setColorBinding( osg::GeoSet::BIND_OFF );
|
||||
gset.setColors(NULL);
|
||||
}
|
||||
else
|
||||
if (primTypeIn==GeoSet::FLAT_TRIANGLE_STRIP)
|
||||
{
|
||||
gset.setColorBinding( osg::GeoSet::BIND_OFF );
|
||||
gset.setColors(NULL);
|
||||
}
|
||||
|
||||
gset.setPrimType( primTypeOut );
|
||||
|
||||
}
|
||||
|
||||
gset.dirtyDisplayList();
|
||||
|
||||
nitr->normalize();
|
||||
}
|
||||
|
||||
geom.setNormalArray( normals );
|
||||
geom.setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
|
||||
|
||||
geom.dirtyDisplayList();
|
||||
}
|
||||
|
||||
|
||||
@@ -168,7 +132,7 @@ void SmoothingVisitor::apply(osg::Geode& geode)
|
||||
{
|
||||
for(int i = 0; i < geode.getNumDrawables(); i++ )
|
||||
{
|
||||
osg::GeoSet* gset = dynamic_cast<osg::GeoSet*>(geode.getDrawable(i));
|
||||
if (gset) smooth(*gset);
|
||||
osg::Geometry* geom = dynamic_cast<osg::Geometry*>(geode.getDrawable(i));
|
||||
if (geom) smooth(*geom);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user