From Paul Martz, speeling fixes for Tessellator/Tessellation.
This commit is contained in:
parent
2bf5f56311
commit
462803fd57
2
NEWS.txt
2
NEWS.txt
@ -360,7 +360,7 @@ Andes Engineering - http://www.andesengineering.com
|
|||||||
osgbluemarble an example of how to build PagedLOD database for
|
osgbluemarble an example of how to build PagedLOD database for
|
||||||
paging imagery
|
paging imagery
|
||||||
|
|
||||||
osgtesselate - an example of how to use osgUtil::Tesselate to
|
osgtessellate an example of how to use osgUtil::Tesselate to
|
||||||
tessellate polygonal boundaries
|
tessellate polygonal boundaries
|
||||||
|
|
||||||
osgsimulation an example of how to use various features in osgSim.
|
osgsimulation an example of how to use various features in osgSim.
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
|
||||||
/** Describe several hints that can be passed to a tesselator (like the one used
|
/** Describe several hints that can be passed to a Tessellator (like the one used
|
||||||
* by \c ShapeDrawable) as a mean to try to influence the way it works.
|
* by \c ShapeDrawable) as a mean to try to influence the way it works.
|
||||||
*/
|
*/
|
||||||
class TessellationHints : public Object
|
class TessellationHints : public Object
|
||||||
|
@ -38,11 +38,11 @@ class OSGSIM_EXPORT Optimizer
|
|||||||
|
|
||||||
enum OptimizationOptions
|
enum OptimizationOptions
|
||||||
{
|
{
|
||||||
TESSELATE_POLYGON = 0x001,
|
TESSELLATE_POLYGON = 0x001,
|
||||||
MERGE_GEODES = 0x002,
|
MERGE_GEODES = 0x002,
|
||||||
MAKE_LIT = 0x004,
|
MAKE_LIT = 0x004,
|
||||||
DEFAULT_OPTIMIZATIONS = TESSELATE_POLYGON | MERGE_GEODES,
|
DEFAULT_OPTIMIZATIONS = TESSELLATE_POLYGON | MERGE_GEODES,
|
||||||
ALL_OPTIMIZATIONS = TESSELATE_POLYGON | MERGE_GEODES
|
ALL_OPTIMIZATIONS = TESSELLATE_POLYGON | MERGE_GEODES
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -59,12 +59,12 @@ class OSGSIM_EXPORT Optimizer
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
class OSGSIM_EXPORT TesselateVisitor : public osg::NodeVisitor
|
class OSGSIM_EXPORT TessellateVisitor : public osg::NodeVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// default to traversing all children.
|
/// default to traversing all children.
|
||||||
TesselateVisitor() :
|
TessellateVisitor() :
|
||||||
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}
|
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}
|
||||||
|
|
||||||
virtual void apply(osg::Geode& geode);
|
virtual void apply(osg::Geode& geode);
|
||||||
|
@ -73,7 +73,7 @@ public:
|
|||||||
|
|
||||||
/** Add vertices and constraint loops from dco
|
/** Add vertices and constraint loops from dco
|
||||||
* Can be used to generate extra vertices where dco crosses 'this' using
|
* Can be used to generate extra vertices where dco crosses 'this' using
|
||||||
* osgUtil::tessellator to insert overlap vertices.
|
* osgUtil::Tessellator to insert overlap vertices.
|
||||||
*/
|
*/
|
||||||
void merge(DelaunayConstraint *dco);
|
void merge(DelaunayConstraint *dco);
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ public:
|
|||||||
virtual bool contains(const osg::Vec3 testpoint) const;
|
virtual bool contains(const osg::Vec3 testpoint) const;
|
||||||
virtual bool outside(const osg::Vec3 testpoint) const;
|
virtual bool outside(const osg::Vec3 testpoint) const;
|
||||||
|
|
||||||
/** Tesselate the constraint loops so that the crossing points are interpolated
|
/** Tessellate the constraint loops so that the crossing points are interpolated
|
||||||
* and added to the contraints for the triangulation. */
|
* and added to the contraints for the triangulation. */
|
||||||
void handleOverlaps(void);
|
void handleOverlaps(void);
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class OSGUTIL_EXPORT Hit
|
|||||||
* A Hit is always on a surface as rendered by the Open Scene Graph scene (usually
|
* A Hit is always on a surface as rendered by the Open Scene Graph scene (usually
|
||||||
* a triangle or other primitive, but a special hit handler could return a
|
* a triangle or other primitive, but a special hit handler could return a
|
||||||
* different value perhaps: a sphere shape might return a Hit on the true sphere
|
* different value perhaps: a sphere shape might return a Hit on the true sphere
|
||||||
* rather than the approximate tesselated sphere rendered.
|
* rather than the approximate tessellated sphere rendered.
|
||||||
*/
|
*/
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ class OSGUTIL_EXPORT Optimizer
|
|||||||
SPATIALIZE_GROUPS = 0x080,
|
SPATIALIZE_GROUPS = 0x080,
|
||||||
COPY_SHARED_NODES = 0x100,
|
COPY_SHARED_NODES = 0x100,
|
||||||
TRISTRIP_GEOMETRY = 0x200,
|
TRISTRIP_GEOMETRY = 0x200,
|
||||||
TESSELATE_GEOMETRY = 0x400,
|
TESSELLATE_GEOMETRY = 0x400,
|
||||||
OPTIMIZE_TEXTURE_SETTINGS = 0x800,
|
OPTIMIZE_TEXTURE_SETTINGS = 0x800,
|
||||||
MERGE_GEODES = 0x1000,
|
MERGE_GEODES = 0x1000,
|
||||||
FLATTEN_BILLBOARDS = 0x2000,
|
FLATTEN_BILLBOARDS = 0x2000,
|
||||||
@ -353,16 +353,16 @@ class OSGUTIL_EXPORT Optimizer
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Tesselate all geodes, to remove POLYGONS.*/
|
/** Tessellate all geodes, to remove POLYGONS.*/
|
||||||
class OSGUTIL_EXPORT TesselateVisitor : public BaseOptimizerVisitor
|
class OSGUTIL_EXPORT TessellateVisitor : public BaseOptimizerVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef std::set<osg::Group*> GroupList;
|
typedef std::set<osg::Group*> GroupList;
|
||||||
GroupList _groupList;
|
GroupList _groupList;
|
||||||
|
|
||||||
TesselateVisitor(Optimizer* optimizer=0):
|
TessellateVisitor(Optimizer* optimizer=0):
|
||||||
BaseOptimizerVisitor(optimizer, TESSELATE_GEOMETRY) {}
|
BaseOptimizerVisitor(optimizer, TESSELLATE_GEOMETRY) {}
|
||||||
|
|
||||||
virtual void apply(osg::Geode& geode);
|
virtual void apply(osg::Geode& geode);
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ class FLTReaderWriter : public ReaderWriter
|
|||||||
if (!document.getPreserveFace())
|
if (!document.getPreserveFace())
|
||||||
{
|
{
|
||||||
osgUtil::Optimizer optimizer;
|
osgUtil::Optimizer optimizer;
|
||||||
optimizer.optimize(document.getHeaderNode(), osgUtil::Optimizer::SHARE_DUPLICATE_STATE | osgUtil::Optimizer::MERGE_GEOMETRY | osgUtil::Optimizer::MERGE_GEODES | osgUtil::Optimizer::TESSELATE_GEOMETRY );
|
optimizer.optimize(document.getHeaderNode(), osgUtil::Optimizer::SHARE_DUPLICATE_STATE | osgUtil::Optimizer::MERGE_GEOMETRY | osgUtil::Optimizer::MERGE_GEODES | osgUtil::Optimizer::TESSELLATE_GEOMETRY );
|
||||||
}
|
}
|
||||||
|
|
||||||
return document.getHeaderNode();
|
return document.getHeaderNode();
|
||||||
|
@ -735,7 +735,7 @@ class SurfaceBin : public PrimitiveBin {
|
|||||||
std::vector<VertexIndex> index;
|
std::vector<VertexIndex> index;
|
||||||
};
|
};
|
||||||
std::vector<PolygonData> _polygons;
|
std::vector<PolygonData> _polygons;
|
||||||
std::vector<PolygonData> _toTesselatePolygons;
|
std::vector<PolygonData> _toTessellatePolygons;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SurfaceBin(unsigned flags, VertexSet *vertexSet) :
|
SurfaceBin(unsigned flags, VertexSet *vertexSet) :
|
||||||
@ -768,7 +768,7 @@ class SurfaceBin : public PrimitiveBin {
|
|||||||
|
|
||||||
// Compute the normal times the enclosed area.
|
// Compute the normal times the enclosed area.
|
||||||
// During that check if the surface is convex. If so, put in the surface as such.
|
// During that check if the surface is convex. If so, put in the surface as such.
|
||||||
bool needTesselation = false;
|
bool needTessellation = false;
|
||||||
osg::Vec3 prevEdgeNormal;
|
osg::Vec3 prevEdgeNormal;
|
||||||
osg::Vec3 weightedNormal(0, 0, 0);
|
osg::Vec3 weightedNormal(0, 0, 0);
|
||||||
osg::Vec3 v0 = _vertexSet->getVertex(_refs[0].index);
|
osg::Vec3 v0 = _vertexSet->getVertex(_refs[0].index);
|
||||||
@ -776,11 +776,11 @@ class SurfaceBin : public PrimitiveBin {
|
|||||||
osg::Vec3 side1 = _vertexSet->getVertex(_refs[i-1].index) - v0;
|
osg::Vec3 side1 = _vertexSet->getVertex(_refs[i-1].index) - v0;
|
||||||
osg::Vec3 side2 = _vertexSet->getVertex(_refs[i].index) - v0;
|
osg::Vec3 side2 = _vertexSet->getVertex(_refs[i].index) - v0;
|
||||||
osg::Vec3 newNormal = side1^side2;
|
osg::Vec3 newNormal = side1^side2;
|
||||||
if (!needTesselation)
|
if (!needTessellation)
|
||||||
{
|
{
|
||||||
if (3 < nRefs && newNormal*weightedNormal < 0)
|
if (3 < nRefs && newNormal*weightedNormal < 0)
|
||||||
{
|
{
|
||||||
needTesselation = true;
|
needTessellation = true;
|
||||||
}
|
}
|
||||||
if (i < 3)
|
if (i < 3)
|
||||||
{
|
{
|
||||||
@ -793,7 +793,7 @@ class SurfaceBin : public PrimitiveBin {
|
|||||||
osg::Vec3 edgeNormal = sideim1^sidei;
|
osg::Vec3 edgeNormal = sideim1^sidei;
|
||||||
if (edgeNormal*prevEdgeNormal < 0)
|
if (edgeNormal*prevEdgeNormal < 0)
|
||||||
{
|
{
|
||||||
needTesselation = true;
|
needTessellation = true;
|
||||||
}
|
}
|
||||||
prevEdgeNormal = edgeNormal;
|
prevEdgeNormal = edgeNormal;
|
||||||
}
|
}
|
||||||
@ -802,14 +802,14 @@ class SurfaceBin : public PrimitiveBin {
|
|||||||
weightedNormal += newNormal;
|
weightedNormal += newNormal;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needTesselation)
|
if (needTessellation)
|
||||||
{
|
{
|
||||||
unsigned polygonIndex = _toTesselatePolygons.size();
|
unsigned polygonIndex = _toTessellatePolygons.size();
|
||||||
_toTesselatePolygons.resize(polygonIndex + 1);
|
_toTessellatePolygons.resize(polygonIndex + 1);
|
||||||
for (unsigned i = 0; i < nRefs; ++i) {
|
for (unsigned i = 0; i < nRefs; ++i) {
|
||||||
RefData refData(weightedNormal, _refs[i].texCoord, isSmooth());
|
RefData refData(weightedNormal, _refs[i].texCoord, isSmooth());
|
||||||
VertexIndex vertexIndex = _vertexSet->addRefData(_refs[i].index, refData);
|
VertexIndex vertexIndex = _vertexSet->addRefData(_refs[i].index, refData);
|
||||||
_toTesselatePolygons[polygonIndex].index.push_back(vertexIndex);
|
_toTessellatePolygons[polygonIndex].index.push_back(vertexIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (nRefs == 3)
|
else if (nRefs == 3)
|
||||||
@ -888,23 +888,23 @@ class SurfaceBin : public PrimitiveBin {
|
|||||||
_geometry->setVertexArray(vertexArray);
|
_geometry->setVertexArray(vertexArray);
|
||||||
_geometry->setTexCoordArray(0, texcoordArray);
|
_geometry->setTexCoordArray(0, texcoordArray);
|
||||||
|
|
||||||
// At first handle the the polygons to tesselate, fix them and append the other polygons later
|
// At first handle the the polygons to tessellate, fix them and append the other polygons later
|
||||||
if (!_toTesselatePolygons.empty())
|
if (!_toTessellatePolygons.empty())
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < _toTesselatePolygons.size(); ++i)
|
for (unsigned i = 0; i < _toTessellatePolygons.size(); ++i)
|
||||||
{
|
{
|
||||||
unsigned start = vertexArray->size();
|
unsigned start = vertexArray->size();
|
||||||
for (unsigned j = 0; j < _toTesselatePolygons[i].index.size(); ++j)
|
for (unsigned j = 0; j < _toTessellatePolygons[i].index.size(); ++j)
|
||||||
{
|
{
|
||||||
pushVertex(_toTesselatePolygons[i].index[j], vertexArray, normalArray, texcoordArray);
|
pushVertex(_toTessellatePolygons[i].index[j], vertexArray, normalArray, texcoordArray);
|
||||||
}
|
}
|
||||||
unsigned count = _toTesselatePolygons[i].index.size();
|
unsigned count = _toTessellatePolygons[i].index.size();
|
||||||
osg::DrawArrays* drawArray = new osg::DrawArrays(osg::PrimitiveSet::POLYGON, start, count);
|
osg::DrawArrays* drawArray = new osg::DrawArrays(osg::PrimitiveSet::POLYGON, start, count);
|
||||||
_geometry->addPrimitiveSet(drawArray);
|
_geometry->addPrimitiveSet(drawArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
osgUtil::Tessellator tessellator;
|
osgUtil::Tessellator Tessellator;
|
||||||
tessellator.retessellatePolygons(*_geometry);
|
Tessellator.retessellatePolygons(*_geometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle triangles
|
// handle triangles
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool BSPLoad::Load(const std::string& filename, int curveTesselation)
|
bool BSPLoad::Load(const std::string& filename, int curveTessellation)
|
||||||
{
|
{
|
||||||
std::ifstream file(filename.c_str(),std::ios::binary);
|
std::ifstream file(filename.c_str(),std::ios::binary);
|
||||||
if(!file.is_open())
|
if(!file.is_open())
|
||||||
@ -45,7 +45,7 @@ bool BSPLoad::Load(const std::string& filename, int curveTesselation)
|
|||||||
|
|
||||||
|
|
||||||
//Load in faces
|
//Load in faces
|
||||||
LoadFaces(file, curveTesselation);
|
LoadFaces(file, curveTessellation);
|
||||||
|
|
||||||
//Load textures
|
//Load textures
|
||||||
LoadTextures(file);
|
LoadTextures(file);
|
||||||
@ -96,7 +96,7 @@ void BSPLoad::LoadVertices(std::ifstream& aFile)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void BSPLoad::LoadFaces(std::ifstream& aFile, int /*curveTesselation*/)
|
void BSPLoad::LoadFaces(std::ifstream& aFile, int /*curveTessellation*/)
|
||||||
{
|
{
|
||||||
//calculate number of load faces
|
//calculate number of load faces
|
||||||
int numTotalFaces=m_header.m_directoryEntries[bspFaces].m_length/sizeof(BSP_LOAD_FACE);
|
int numTotalFaces=m_header.m_directoryEntries[bspFaces].m_length/sizeof(BSP_LOAD_FACE);
|
||||||
|
@ -174,9 +174,9 @@ class BSPLoad
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool Load(const std::string& filename, int curveTesselation);
|
bool Load(const std::string& filename, int curveTessellation);
|
||||||
void LoadVertices(std::ifstream& aFile);
|
void LoadVertices(std::ifstream& aFile);
|
||||||
void LoadFaces(std::ifstream& aFile, int curveTesselation);
|
void LoadFaces(std::ifstream& aFile, int curveTessellation);
|
||||||
void LoadTextures(std::ifstream& aFile);
|
void LoadTextures(std::ifstream& aFile);
|
||||||
void LoadLightmaps(std::ifstream& aFile);
|
void LoadLightmaps(std::ifstream& aFile);
|
||||||
void LoadBSPData(std::ifstream& aFile);
|
void LoadBSPData(std::ifstream& aFile);
|
||||||
|
@ -153,13 +153,13 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Tesselate(int newTesselation,osg::Geometry* aGeometry);
|
bool Tessellate(int newTessellation,osg::Geometry* aGeometry);
|
||||||
|
|
||||||
BSP_VERTEX m_controlPoints[9]; // Se accede a ellos en la carga
|
BSP_VERTEX m_controlPoints[9]; // Se accede a ellos en la carga
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
int m_tesselation;
|
int m_tessellation;
|
||||||
std::vector<BSP_VERTEX> m_vertices;
|
std::vector<BSP_VERTEX> m_vertices;
|
||||||
std::vector<GLuint> m_indices;
|
std::vector<GLuint> m_indices;
|
||||||
|
|
||||||
@ -319,7 +319,7 @@ osg::Geode* ReaderWriterQ3BSP::convertFromBSP(BSPLoad& aLoadData,const osgDB::Re
|
|||||||
|
|
||||||
|
|
||||||
osg::Geometry* patch_geom = new osg::Geometry;
|
osg::Geometry* patch_geom = new osg::Geometry;
|
||||||
//tesselate the patch
|
//tessellate the patch
|
||||||
|
|
||||||
osg::StateSet* stateset = patch_geom->getOrCreateStateSet();
|
osg::StateSet* stateset = patch_geom->getOrCreateStateSet();
|
||||||
if(texture)
|
if(texture)
|
||||||
@ -334,7 +334,7 @@ osg::Geode* ReaderWriterQ3BSP::convertFromBSP(BSPLoad& aLoadData,const osgDB::Re
|
|||||||
|
|
||||||
//patch_group->addChild(map_geode);
|
//patch_group->addChild(map_geode);
|
||||||
|
|
||||||
current_patch.m_quadraticPatches[y*numPatchesWide+x].Tesselate(8/*aCurveTesselation*/,patch_geom);
|
current_patch.m_quadraticPatches[y*numPatchesWide+x].Tessellate(8/*aCurveTessellation*/,patch_geom);
|
||||||
map_geode->addDrawable(patch_geom);
|
map_geode->addDrawable(patch_geom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -555,27 +555,27 @@ bool ReaderWriterQ3BSP::loadLightMaps(const BSPLoad& aLoadData,std::vector<osg::
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Tesselate a biquadratic patch
|
//Tessellate a biquadratic patch
|
||||||
bool BSP_BIQUADRATIC_PATCH::Tesselate(int newTesselation,osg::Geometry* aGeometry)
|
bool BSP_BIQUADRATIC_PATCH::Tessellate(int newTessellation,osg::Geometry* aGeometry)
|
||||||
{
|
{
|
||||||
m_tesselation=newTesselation;
|
m_tessellation=newTessellation;
|
||||||
|
|
||||||
float px, py;
|
float px, py;
|
||||||
BSP_VERTEX temp[3];
|
BSP_VERTEX temp[3];
|
||||||
m_vertices.resize((m_tesselation+1)*(m_tesselation+1));
|
m_vertices.resize((m_tessellation+1)*(m_tessellation+1));
|
||||||
|
|
||||||
for(int v=0; v<=m_tesselation; ++v)
|
for(int v=0; v<=m_tessellation; ++v)
|
||||||
{
|
{
|
||||||
px=(float)v/m_tesselation;
|
px=(float)v/m_tessellation;
|
||||||
|
|
||||||
m_vertices[v]=m_controlPoints[0]*((1.0f-px)*(1.0f-px))+
|
m_vertices[v]=m_controlPoints[0]*((1.0f-px)*(1.0f-px))+
|
||||||
m_controlPoints[3]*((1.0f-px)*px*2)+
|
m_controlPoints[3]*((1.0f-px)*px*2)+
|
||||||
m_controlPoints[6]*(px*px);
|
m_controlPoints[6]*(px*px);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int u=1; u<=m_tesselation; ++u)
|
for(int u=1; u<=m_tessellation; ++u)
|
||||||
{
|
{
|
||||||
py=(float)u/m_tesselation;
|
py=(float)u/m_tessellation;
|
||||||
|
|
||||||
temp[0]=m_controlPoints[0]*((1.0f-py)*(1.0f-py))+
|
temp[0]=m_controlPoints[0]*((1.0f-py)*(1.0f-py))+
|
||||||
m_controlPoints[1]*((1.0f-py)*py*2)+
|
m_controlPoints[1]*((1.0f-py)*py*2)+
|
||||||
@ -589,47 +589,47 @@ bool BSP_BIQUADRATIC_PATCH::Tesselate(int newTesselation,osg::Geometry* aGeometr
|
|||||||
m_controlPoints[7]*((1.0f-py)*py*2)+
|
m_controlPoints[7]*((1.0f-py)*py*2)+
|
||||||
m_controlPoints[8]*(py*py);
|
m_controlPoints[8]*(py*py);
|
||||||
|
|
||||||
for(int v=0; v<=m_tesselation; ++v)
|
for(int v=0; v<=m_tessellation; ++v)
|
||||||
{
|
{
|
||||||
px=(float)v/m_tesselation;
|
px=(float)v/m_tessellation;
|
||||||
|
|
||||||
m_vertices[u*(m_tesselation+1)+v]=temp[0]*((1.0f-px)*(1.0f-px))+
|
m_vertices[u*(m_tessellation+1)+v]=temp[0]*((1.0f-px)*(1.0f-px))+
|
||||||
temp[1]*((1.0f-px)*px*2)+
|
temp[1]*((1.0f-px)*px*2)+
|
||||||
temp[2]*(px*px);
|
temp[2]*(px*px);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Create indices
|
//Create indices
|
||||||
m_indices.resize(m_tesselation*(m_tesselation+1)*2);
|
m_indices.resize(m_tessellation*(m_tessellation+1)*2);
|
||||||
|
|
||||||
int row;
|
int row;
|
||||||
for(row=0; row<m_tesselation; ++row)
|
for(row=0; row<m_tessellation; ++row)
|
||||||
{
|
{
|
||||||
for(int point=0; point<=m_tesselation; ++point)
|
for(int point=0; point<=m_tessellation; ++point)
|
||||||
{
|
{
|
||||||
//calculate indices
|
//calculate indices
|
||||||
//reverse them to reverse winding
|
//reverse them to reverse winding
|
||||||
m_indices[(row*(m_tesselation+1)+point)*2+1]= row*(m_tesselation+1)+point;
|
m_indices[(row*(m_tessellation+1)+point)*2+1]= row*(m_tessellation+1)+point;
|
||||||
m_indices[(row*(m_tesselation+1)+point)*2]= (row+1)*(m_tesselation+1)+point;
|
m_indices[(row*(m_tessellation+1)+point)*2]= (row+1)*(m_tessellation+1)+point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Fill in the arrays for multi_draw_arrays
|
//Fill in the arrays for multi_draw_arrays
|
||||||
m_trianglesPerRow.resize(m_tesselation);
|
m_trianglesPerRow.resize(m_tessellation);
|
||||||
m_rowIndexPointers.resize(m_tesselation);
|
m_rowIndexPointers.resize(m_tessellation);
|
||||||
|
|
||||||
for(row=0; row<m_tesselation; ++row)
|
for(row=0; row<m_tessellation; ++row)
|
||||||
{
|
{
|
||||||
m_trianglesPerRow[row]=2*(m_tesselation+1);
|
m_trianglesPerRow[row]=2*(m_tessellation+1);
|
||||||
m_rowIndexPointers[row]=&m_indices[row*2*(m_tesselation+1)];
|
m_rowIndexPointers[row]=&m_indices[row*2*(m_tessellation+1)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
osg::Vec3Array* patch_vertex_array = new osg::Vec3Array( (m_tesselation+1)*(m_tesselation+1) );
|
osg::Vec3Array* patch_vertex_array = new osg::Vec3Array( (m_tessellation+1)*(m_tessellation+1) );
|
||||||
osg::Vec2Array* patch_textcoord_array = new osg::Vec2Array( (m_tesselation+1)*(m_tesselation+1) );
|
osg::Vec2Array* patch_textcoord_array = new osg::Vec2Array( (m_tessellation+1)*(m_tessellation+1) );
|
||||||
osg::Vec2Array* patch_lmapcoord_array = new osg::Vec2Array( (m_tesselation+1)*(m_tesselation+1) );
|
osg::Vec2Array* patch_lmapcoord_array = new osg::Vec2Array( (m_tessellation+1)*(m_tessellation+1) );
|
||||||
for(int i=0;i<(m_tesselation+1)*(m_tesselation+1);i++)
|
for(int i=0;i<(m_tessellation+1)*(m_tessellation+1);i++)
|
||||||
{
|
{
|
||||||
(*patch_vertex_array)[i].set( m_vertices[ i ].m_position[0],
|
(*patch_vertex_array)[i].set( m_vertices[ i ].m_position[0],
|
||||||
m_vertices[ i ].m_position[1],
|
m_vertices[ i ].m_position[1],
|
||||||
@ -651,10 +651,10 @@ bool BSP_BIQUADRATIC_PATCH::Tesselate(int newTesselation,osg::Geometry* aGeometr
|
|||||||
aGeometry->setTexCoordArray(1,patch_lmapcoord_array);
|
aGeometry->setTexCoordArray(1,patch_lmapcoord_array);
|
||||||
|
|
||||||
|
|
||||||
for(row=0; row<m_tesselation; ++row)
|
for(row=0; row<m_tessellation; ++row)
|
||||||
{
|
{
|
||||||
osg::DrawElementsUInt* face_indices = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLE_STRIP,
|
osg::DrawElementsUInt* face_indices = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLE_STRIP,
|
||||||
m_tesselation*(m_tesselation+1)*2,
|
m_tessellation*(m_tessellation+1)*2,
|
||||||
&m_indices[0]
|
&m_indices[0]
|
||||||
);
|
);
|
||||||
aGeometry->addPrimitiveSet(face_indices);
|
aGeometry->addPrimitiveSet(face_indices);
|
||||||
|
@ -179,7 +179,7 @@ private:
|
|||||||
int _lightnum;
|
int _lightnum;
|
||||||
StateSet *dstate; // used to represent the dw material in OSG
|
StateSet *dstate; // used to represent the dw material in OSG
|
||||||
};
|
};
|
||||||
// structure to use as data for tesselation
|
// structure to use as data for tessellation
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
double pos[3]; // must be double for the tessellator to detect vertices
|
double pos[3]; // must be double for the tessellator to detect vertices
|
||||||
@ -327,7 +327,7 @@ public:
|
|||||||
poses.nrmv=nrm;
|
poses.nrmv=nrm;
|
||||||
poses.idx=idx[j];
|
poses.idx=idx[j];
|
||||||
}
|
}
|
||||||
void tesselate(const std::vector<Vec3> verts, const dwmaterial *themat,
|
void tessellate(const std::vector<Vec3> verts, const dwmaterial *themat,
|
||||||
GLUtesselator *ts, _dwobj *dwob, const Matrix *tmat) const;
|
GLUtesselator *ts, _dwobj *dwob, const Matrix *tmat) const;
|
||||||
void link(const int idop, const _face *f2, const int idop2,const std::vector<Vec3> verts, const dwmaterial *themat) const; // to join up opposed faces of a hole
|
void link(const int idop, const _face *f2, const int idop2,const std::vector<Vec3> verts, const dwmaterial *themat) const; // to join up opposed faces of a hole
|
||||||
inline const int getidx(int i) const { return idx[i];}
|
inline const int getidx(int i) const { return idx[i];}
|
||||||
@ -366,12 +366,12 @@ public:
|
|||||||
~prims() { /*delete [] primlengs; delete [] nrms;
|
~prims() { /*delete [] primlengs; delete [] nrms;
|
||||||
delete [] gsidx; delete [] nrmidx; delete [] txcoords;*/
|
delete [] gsidx; delete [] nrmidx; delete [] txcoords;*/
|
||||||
}
|
}
|
||||||
void addv(avertex *pos) { // tesselation callback
|
void addv(avertex *pos) { // tessellation callback
|
||||||
vertices->push_back(osg::Vec3(pos->pos[0],pos->pos[1],pos->pos[2]));
|
vertices->push_back(osg::Vec3(pos->pos[0],pos->pos[1],pos->pos[2]));
|
||||||
normals->push_back(pos->nrmv);
|
normals->push_back(pos->nrmv);
|
||||||
txcoords->push_back(osg::Vec3(pos->uv[0],pos->uv[1],0.0f));
|
txcoords->push_back(osg::Vec3(pos->uv[0],pos->uv[1],0.0f));
|
||||||
}
|
}
|
||||||
void End() { // tesselation is done
|
void End() { // tessellation is done
|
||||||
int nverts=vertices->size()-nbegin;
|
int nverts=vertices->size()-nbegin;
|
||||||
osg::DrawArrays *drw=NULL;
|
osg::DrawArrays *drw=NULL;
|
||||||
switch (primType) {
|
switch (primType) {
|
||||||
@ -405,7 +405,7 @@ public:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void begin(GLenum op) { // part of a tesselator callback - starts a new primitive of type op
|
void begin(GLenum op) { // part of a Tessellator callback - starts a new primitive of type op
|
||||||
primType=op;
|
primType=op;
|
||||||
nbegin=vertices->size();
|
nbegin=vertices->size();
|
||||||
}
|
}
|
||||||
@ -440,10 +440,10 @@ public:
|
|||||||
drw=new osg::DrawArrays(osg::PrimitiveSet::QUADS,n1,4);
|
drw=new osg::DrawArrays(osg::PrimitiveSet::QUADS,n1,4);
|
||||||
gset->addPrimitiveSet(drw);
|
gset->addPrimitiveSet(drw);
|
||||||
}
|
}
|
||||||
void tesselate(_face &fc, const std::vector<Vec3> verts, const dwmaterial *themat,GLUtesselator* ts, _dwobj *dwob)
|
void tessellate(_face &fc, const std::vector<Vec3> verts, const dwmaterial *themat,GLUtesselator* ts, _dwobj *dwob)
|
||||||
{ // generates a set of primitives all of one type (eg tris, qstrip trifan...)
|
{ // generates a set of primitives all of one type (eg tris, qstrip trifan...)
|
||||||
fc.setNBegin(vertices->size());
|
fc.setNBegin(vertices->size());
|
||||||
fc.tesselate(verts, themat, ts, dwob, tmat);
|
fc.tessellate(verts, themat, ts, dwob, tmat);
|
||||||
}
|
}
|
||||||
void buildGeometry() { // at end of all faces, add collection of vertices to geometry
|
void buildGeometry() { // at end of all faces, add collection of vertices to geometry
|
||||||
gset->setNormalBinding(osg::Geometry::BIND_PER_VERTEX); //BIND_PERPRIM); //
|
gset->setNormalBinding(osg::Geometry::BIND_PER_VERTEX); //BIND_PERPRIM); //
|
||||||
@ -468,9 +468,9 @@ private:
|
|||||||
const Matrix *tmat; // local texture matrix, or may be NULL for default mapping
|
const Matrix *tmat; // local texture matrix, or may be NULL for default mapping
|
||||||
};
|
};
|
||||||
|
|
||||||
static prims *prd=NULL; // OK not nice to have a static but the OpenGL tesselator etc wants to be able to refer
|
static prims *prd=NULL; // OK not nice to have a static but the OpenGL Tessellator etc wants to be able to refer
|
||||||
// to things that are not available via an argument
|
// to things that are not available via an argument
|
||||||
// tesselation subroutines - have 'C' prototypes, not a member of any class...
|
// tessellation subroutines - have 'C' prototypes, not a member of any class...
|
||||||
// But I want ot use the prims class to contain useful information such as texture matrix etc.
|
// But I want ot use the prims class to contain useful information such as texture matrix etc.
|
||||||
void CALLBACK myFaceBegin(GLenum op)
|
void CALLBACK myFaceBegin(GLenum op)
|
||||||
{// tess 'primitive begins' call back
|
{// tess 'primitive begins' call back
|
||||||
@ -493,7 +493,7 @@ void CALLBACK combineCallback( GLdouble coords[3], avertex *d[4],
|
|||||||
void CALLBACK error (GLenum errno)
|
void CALLBACK error (GLenum errno)
|
||||||
{ // tess error code
|
{ // tess error code
|
||||||
const unsigned char *errm=gluErrorString(errno);
|
const unsigned char *errm=gluErrorString(errno);
|
||||||
printf("tesselator error %d %s\n", static_cast<int>(errno),errm);//, errm
|
printf("Tessellator error %d %s\n", static_cast<int>(errno),errm);//, errm
|
||||||
}
|
}
|
||||||
//==========
|
//==========
|
||||||
void _face::linkholes(const std::vector<Vec3> verts, const dwmaterial *themat, const _face *f2) const
|
void _face::linkholes(const std::vector<Vec3> verts, const dwmaterial *themat, const _face *f2) const
|
||||||
@ -669,11 +669,11 @@ private:
|
|||||||
Matrix *mx; // current uvw transform for currently tessealting face
|
Matrix *mx; // current uvw transform for currently tessealting face
|
||||||
};
|
};
|
||||||
|
|
||||||
void _face::tesselate(const std::vector<Vec3> verts, const dwmaterial *themat,
|
void _face::tessellate(const std::vector<Vec3> verts, const dwmaterial *themat,
|
||||||
GLUtesselator *ts, _dwobj *dwob, const Matrix * /*tmat*/) const {
|
GLUtesselator *ts, _dwobj *dwob, const Matrix * /*tmat*/) const {
|
||||||
int nvall=getallverts();
|
int nvall=getallverts();
|
||||||
int nused=0;
|
int nused=0;
|
||||||
avertex *poses=new avertex[2*nvall]; // passed to tesselator to redraw
|
avertex *poses=new avertex[2*nvall]; // passed to Tessellator to redraw
|
||||||
Matrix mx; // texture matrix transform to plane
|
Matrix mx; // texture matrix transform to plane
|
||||||
settrans(mx, nrm, verts,themat);
|
settrans(mx, nrm, verts,themat);
|
||||||
dwob->setmx(&mx); // may be used by combine callback to define txcoord
|
dwob->setmx(&mx); // may be used by combine callback to define txcoord
|
||||||
@ -761,7 +761,7 @@ void _dwobj::buildDrawable(Group *grp, const osgDB::ReaderWriter::Options *optio
|
|||||||
gluTessCallback(ts, GLU_TESS_COMBINE_DATA, (GLU_TESS_CALLBACK) combineCallback);
|
gluTessCallback(ts, GLU_TESS_COMBINE_DATA, (GLU_TESS_CALLBACK) combineCallback);
|
||||||
// for (int nvf=0; nvf<6; nvf++) { // for each length of face
|
// for (int nvf=0; nvf<6; nvf++) { // for each length of face
|
||||||
// for Geometry we dont need to collect prim types individually
|
// for Geometry we dont need to collect prim types individually
|
||||||
// prd.setmode(nvf , nfnvf); // filter out only this type of tesselated face
|
// prd.setmode(nvf , nfnvf); // filter out only this type of tessellated face
|
||||||
prd=new prims;
|
prd=new prims;
|
||||||
prd->settmat(tmat);
|
prd->settmat(tmat);
|
||||||
osg::Geometry *gset = new osg::Geometry;
|
osg::Geometry *gset = new osg::Geometry;
|
||||||
@ -771,9 +771,9 @@ void _dwobj::buildDrawable(Group *grp, const osgDB::ReaderWriter::Options *optio
|
|||||||
grp->addChild( geode ); // add to the world outside
|
grp->addChild( geode ); // add to the world outside
|
||||||
geode->addDrawable(gset);
|
geode->addDrawable(gset);
|
||||||
|
|
||||||
// each face adds a primitive to the geometry, after it is tesselated
|
// each face adds a primitive to the geometry, after it is tessellated
|
||||||
for (i=0; i<nfaces; i++) { // for each face, collect up
|
for (i=0; i<nfaces; i++) { // for each face, collect up
|
||||||
prd->tesselate(faces[i],verts, themat, ts, this);
|
prd->tessellate(faces[i],verts, themat, ts, this);
|
||||||
}
|
}
|
||||||
for (i=0; i<nopens; i++) { // for each hole, join up front & back with Quads
|
for (i=0; i<nopens; i++) { // for each hole, join up front & back with Quads
|
||||||
if (fc1 && fc2) {
|
if (fc1 && fc2) {
|
||||||
@ -787,7 +787,7 @@ void _dwobj::buildDrawable(Group *grp, const osgDB::ReaderWriter::Options *optio
|
|||||||
} // nfaces>0
|
} // nfaces>0
|
||||||
verts.clear();
|
verts.clear();
|
||||||
}
|
}
|
||||||
////////// tesselation complete
|
////////// tessellation complete
|
||||||
|
|
||||||
class ReaderWriterDW : public osgDB::ReaderWriter
|
class ReaderWriterDW : public osgDB::ReaderWriter
|
||||||
{
|
{
|
||||||
|
@ -321,7 +321,7 @@ osg::Geode* GeoSetBuilder::createOsgGeoSets(osg::Geode* geode)
|
|||||||
optimizer.optimize(geode, osgUtil::Optimizer::SHARE_DUPLICATE_STATE |
|
optimizer.optimize(geode, osgUtil::Optimizer::SHARE_DUPLICATE_STATE |
|
||||||
osgUtil::Optimizer::MERGE_GEOMETRY |
|
osgUtil::Optimizer::MERGE_GEOMETRY |
|
||||||
osgUtil::Optimizer::CHECK_GEOMETRY |
|
osgUtil::Optimizer::CHECK_GEOMETRY |
|
||||||
osgUtil::Optimizer::TESSELATE_GEOMETRY);
|
osgUtil::Optimizer::TESSELLATE_GEOMETRY);
|
||||||
return geode;
|
return geode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ bool GraphicsContextImplementation::makeContextCurrentImplementation(osg::Graphi
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GraphicsContextImplementation::makeCurrentImplementation()
|
bool GraphicsContextImplementation::releaseContextImplementation()
|
||||||
{
|
{
|
||||||
osg::notify(osg::NOTICE)<<"GraphicsContextImplementation::makeCurrentImplementation(): not implemented - release not supported under Producer."<<std::endl;
|
osg::notify(osg::NOTICE)<<"GraphicsContextImplementation::makeCurrentImplementation(): not implemented - release not supported under Producer."<<std::endl;
|
||||||
return false;
|
return false;
|
||||||
|
@ -32,8 +32,8 @@ void Optimizer::optimize(osg::Node* node)
|
|||||||
if(str.find("~DEFAULT")!=std::string::npos) options ^= DEFAULT_OPTIMIZATIONS;
|
if(str.find("~DEFAULT")!=std::string::npos) options ^= DEFAULT_OPTIMIZATIONS;
|
||||||
else if(str.find("DEFAULT")!=std::string::npos) options |= DEFAULT_OPTIMIZATIONS;
|
else if(str.find("DEFAULT")!=std::string::npos) options |= DEFAULT_OPTIMIZATIONS;
|
||||||
|
|
||||||
if(str.find("~TESSELATE_POLYGON")!=std::string::npos) options ^= TESSELATE_POLYGON;
|
if(str.find("~TESSELLATE_POLYGON")!=std::string::npos) options ^= TESSELLATE_POLYGON;
|
||||||
else if(str.find("TESSELATE_POLYGON")!=std::string::npos) options |= TESSELATE_POLYGON;
|
else if(str.find("TESSELLATE_POLYGON")!=std::string::npos) options |= TESSELLATE_POLYGON;
|
||||||
|
|
||||||
if(str.find("~MAKE_LIT")!=std::string::npos) options ^= MAKE_LIT;
|
if(str.find("~MAKE_LIT")!=std::string::npos) options ^= MAKE_LIT;
|
||||||
else if(str.find("MAKE_LIT")!=std::string::npos) options |= MAKE_LIT;
|
else if(str.find("MAKE_LIT")!=std::string::npos) options |= MAKE_LIT;
|
||||||
@ -51,11 +51,11 @@ void Optimizer::optimize(osg::Node* node)
|
|||||||
|
|
||||||
void Optimizer::optimize(osg::Node* node, unsigned int options)
|
void Optimizer::optimize(osg::Node* node, unsigned int options)
|
||||||
{
|
{
|
||||||
if (options & TESSELATE_POLYGON)
|
if (options & TESSELLATE_POLYGON)
|
||||||
{
|
{
|
||||||
osg::notify(osg::INFO)<<"osgFlightUtil::Optimizer::optimize() doing TESSELATE_POLYGON"<<std::endl;
|
osg::notify(osg::INFO)<<"osgFlightUtil::Optimizer::optimize() doing TESSELLATE_POLYGON"<<std::endl;
|
||||||
|
|
||||||
TesselateVisitor visitor;
|
TessellateVisitor visitor;
|
||||||
node->accept(visitor);
|
node->accept(visitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ void Optimizer::optimize(osg::Node* node, unsigned int options)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Optimizer::TesselateVisitor::apply(osg::Geode& geode)
|
void Optimizer::TessellateVisitor::apply(osg::Geode& geode)
|
||||||
{
|
{
|
||||||
for (unsigned int i=0; i<geode.getNumDrawables(); ++i)
|
for (unsigned int i=0; i<geode.getNumDrawables(); ++i)
|
||||||
{
|
{
|
||||||
@ -86,15 +86,15 @@ void Optimizer::TesselateVisitor::apply(osg::Geode& geode)
|
|||||||
{
|
{
|
||||||
if (hasPolygons(*geometry))
|
if (hasPolygons(*geometry))
|
||||||
{
|
{
|
||||||
// Tesselate
|
// Tessellate
|
||||||
osgUtil::Tessellator tessellator;
|
osgUtil::Tessellator Tessellator;
|
||||||
tessellator.retessellatePolygons(*geometry);
|
Tessellator.retessellatePolygons(*geometry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Optimizer::TesselateVisitor::hasPolygons(osg::Geometry& geometry)
|
bool Optimizer::TessellateVisitor::hasPolygons(osg::Geometry& geometry)
|
||||||
{
|
{
|
||||||
for (unsigned int i=0; i<geometry.getNumPrimitiveSets(); ++i)
|
for (unsigned int i=0; i<geometry.getNumPrimitiveSets(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <map> //GWM July 2005 map is used in constraints.
|
#include <map> //GWM July 2005 map is used in constraints.
|
||||||
#include <osgUtil/Tessellator> // tesselator triangulates the constrained triangles
|
#include <osgUtil/Tessellator> // Tessellator triangulates the constrained triangles
|
||||||
|
|
||||||
namespace osgUtil
|
namespace osgUtil
|
||||||
{
|
{
|
||||||
@ -440,7 +440,7 @@ Triangle_list fillHole(osg::Vec3Array *points, std::vector<unsigned int> vind
|
|||||||
tscx->setTessellationNormal(osg::Vec3(0.0,0.0,1.0));
|
tscx->setTessellationNormal(osg::Vec3(0.0,0.0,1.0));
|
||||||
tscx->setTessellationType(osgUtil::Tessellator::TESS_TYPE_GEOMETRY);
|
tscx->setTessellationType(osgUtil::Tessellator::TESS_TYPE_GEOMETRY);
|
||||||
tscx->setBoundaryOnly(false);
|
tscx->setBoundaryOnly(false);
|
||||||
tscx->setWindingType( osgUtil::Tessellator::TESS_WINDING_ODD); // the commonest tesselation is default, ODD. GE2 allows intersections of constraints to be found.
|
tscx->setWindingType( osgUtil::Tessellator::TESS_WINDING_ODD); // the commonest tessellation is default, ODD. GE2 allows intersections of constraints to be found.
|
||||||
tscx->retessellatePolygons(*(gtess.get())); // this should insert extra vertices where constraints overlap
|
tscx->retessellatePolygons(*(gtess.get())); // this should insert extra vertices where constraints overlap
|
||||||
|
|
||||||
// extract triangles from gtess
|
// extract triangles from gtess
|
||||||
@ -862,7 +862,7 @@ bool DelaunayTriangulator::triangulate()
|
|||||||
// http://www.geom.uiuc.edu/~samuelp/del_project.html
|
// http://www.geom.uiuc.edu/~samuelp/del_project.html
|
||||||
// we could also implement the sourcecode in http://gts.sourceforge.net/reference/gts-delaunay-and-constrained-delaunay-triangulations.html
|
// we could also implement the sourcecode in http://gts.sourceforge.net/reference/gts-delaunay-and-constrained-delaunay-triangulations.html
|
||||||
// this uses the set of lines which are boundaries of the constraints, including points
|
// this uses the set of lines which are boundaries of the constraints, including points
|
||||||
// added to the contours by tesselation.
|
// added to the contours by tessellation.
|
||||||
for (linelist::iterator dcitr=constraint_lines.begin();dcitr!=constraint_lines.end();dcitr++)
|
for (linelist::iterator dcitr=constraint_lines.begin();dcitr!=constraint_lines.end();dcitr++)
|
||||||
{
|
{
|
||||||
//DelaunayConstraint *dc=(*dcitr).get();
|
//DelaunayConstraint *dc=(*dcitr).get();
|
||||||
@ -911,7 +911,7 @@ bool DelaunayTriangulator::triangulate()
|
|||||||
// The hole joins vertex ip1 to ip2, and one list of edges lies to the left
|
// The hole joins vertex ip1 to ip2, and one list of edges lies to the left
|
||||||
// of the line ip1-ip2m the other to the right.
|
// of the line ip1-ip2m the other to the right.
|
||||||
// a list of vertices forming 2 halves of the removed triangles.
|
// a list of vertices forming 2 halves of the removed triangles.
|
||||||
// which in turn are filled in with the tesselator.
|
// which in turn are filled in with the tessellator.
|
||||||
for (titr=triangles.begin(); titr!=triangles.end(); )
|
for (titr=triangles.begin(); titr!=triangles.end(); )
|
||||||
{
|
{
|
||||||
int icut=titr->lineBisects(points_.get(),ip1,p2);
|
int icut=titr->lineBisects(points_.get(),ip1,p2);
|
||||||
@ -1269,7 +1269,7 @@ osg::Vec3Array* DelaunayConstraint::getPoints(const osg::Vec3Array *points)
|
|||||||
|
|
||||||
void DelaunayConstraint::handleOverlaps(void)
|
void DelaunayConstraint::handleOverlaps(void)
|
||||||
{
|
{
|
||||||
// use tesselator to interpolate crossing vertices.
|
// use Tessellator to interpolate crossing vertices.
|
||||||
osg::ref_ptr<osgUtil::Tessellator> tscx=new osgUtil::Tessellator; // this assembles all the constraints
|
osg::ref_ptr<osgUtil::Tessellator> tscx=new osgUtil::Tessellator; // this assembles all the constraints
|
||||||
tscx->setTessellationType(osgUtil::Tessellator::TESS_TYPE_GEOMETRY);
|
tscx->setTessellationType(osgUtil::Tessellator::TESS_TYPE_GEOMETRY);
|
||||||
tscx->setBoundaryOnly(true);
|
tscx->setBoundaryOnly(true);
|
||||||
|
@ -47,7 +47,7 @@ void Optimizer::reset()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static osg::ApplicationUsageProxy Optimizer_e0(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_OPTIMIZER \"<type> [<type>]\"","OFF | DEFAULT | FLATTEN_STATIC_TRANSFORMS | REMOVE_REDUNDANT_NODES | COMBINE_ADJACENT_LODS | SHARE_DUPLICATE_STATE | MERGE_GEOMETRY | MERGE_GEODES | SPATIALIZE_GROUPS | COPY_SHARED_NODES | TRISTRIP_GEOMETRY | OPTIMIZE_TEXTURE_SETTINGS | REMOVE_LOADED_PROXY_NODES | TESSELATE_GEOMETRY | CHECK_GEOMETRY | FLATTEN_BILLBOARDS | TEXTURE_ATLAS_BUILDER");
|
static osg::ApplicationUsageProxy Optimizer_e0(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_OPTIMIZER \"<type> [<type>]\"","OFF | DEFAULT | FLATTEN_STATIC_TRANSFORMS | REMOVE_REDUNDANT_NODES | COMBINE_ADJACENT_LODS | SHARE_DUPLICATE_STATE | MERGE_GEOMETRY | MERGE_GEODES | SPATIALIZE_GROUPS | COPY_SHARED_NODES | TRISTRIP_GEOMETRY | OPTIMIZE_TEXTURE_SETTINGS | REMOVE_LOADED_PROXY_NODES | TESSELLATE_GEOMETRY | CHECK_GEOMETRY | FLATTEN_BILLBOARDS | TEXTURE_ATLAS_BUILDER");
|
||||||
|
|
||||||
void Optimizer::optimize(osg::Node* node)
|
void Optimizer::optimize(osg::Node* node)
|
||||||
{
|
{
|
||||||
@ -91,8 +91,8 @@ void Optimizer::optimize(osg::Node* node)
|
|||||||
if(str.find("~COPY_SHARED_NODES")!=std::string::npos) options ^= COPY_SHARED_NODES;
|
if(str.find("~COPY_SHARED_NODES")!=std::string::npos) options ^= COPY_SHARED_NODES;
|
||||||
else if(str.find("COPY_SHARED_NODES")!=std::string::npos) options |= COPY_SHARED_NODES;
|
else if(str.find("COPY_SHARED_NODES")!=std::string::npos) options |= COPY_SHARED_NODES;
|
||||||
|
|
||||||
if(str.find("~TESSELATE_GEOMETRY")!=std::string::npos) options ^= TESSELATE_GEOMETRY;
|
if(str.find("~TESSELLATE_GEOMETRY")!=std::string::npos) options ^= TESSELLATE_GEOMETRY;
|
||||||
else if(str.find("TESSELATE_GEOMETRY")!=std::string::npos) options |= TESSELATE_GEOMETRY;
|
else if(str.find("TESSELLATE_GEOMETRY")!=std::string::npos) options |= TESSELLATE_GEOMETRY;
|
||||||
|
|
||||||
if(str.find("~TRISTRIP_GEOMETRY")!=std::string::npos) options ^= TRISTRIP_GEOMETRY;
|
if(str.find("~TRISTRIP_GEOMETRY")!=std::string::npos) options ^= TRISTRIP_GEOMETRY;
|
||||||
else if(str.find("TRISTRIP_GEOMETRY")!=std::string::npos) options |= TRISTRIP_GEOMETRY;
|
else if(str.find("TRISTRIP_GEOMETRY")!=std::string::npos) options |= TRISTRIP_GEOMETRY;
|
||||||
@ -131,11 +131,11 @@ void Optimizer::optimize(osg::Node* node, unsigned int options)
|
|||||||
stats.print(osg::notify(osg::NOTICE));
|
stats.print(osg::notify(osg::NOTICE));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options & TESSELATE_GEOMETRY)
|
if (options & TESSELLATE_GEOMETRY)
|
||||||
{
|
{
|
||||||
osg::notify(osg::INFO)<<"Optimizer::optimize() doing TESSELATE_GEOMETRY"<<std::endl;
|
osg::notify(osg::INFO)<<"Optimizer::optimize() doing TESSELLATE_GEOMETRY"<<std::endl;
|
||||||
|
|
||||||
TesselateVisitor tsv;
|
TessellateVisitor tsv;
|
||||||
node->accept(tsv);
|
node->accept(tsv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,16 +312,16 @@ void Optimizer::optimize(osg::Node* node, unsigned int options)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// Tesselate geometry - eg break complex POLYGONS into triangles, strips, fans..
|
// Tessellate geometry - eg break complex POLYGONS into triangles, strips, fans..
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
void Optimizer::TesselateVisitor::apply(osg::Geode& geode)
|
void Optimizer::TessellateVisitor::apply(osg::Geode& geode)
|
||||||
{
|
{
|
||||||
for(unsigned int i=0;i<geode.getNumDrawables();++i)
|
for(unsigned int i=0;i<geode.getNumDrawables();++i)
|
||||||
{
|
{
|
||||||
osg::Geometry* geom = dynamic_cast<osg::Geometry*>(geode.getDrawable(i));
|
osg::Geometry* geom = dynamic_cast<osg::Geometry*>(geode.getDrawable(i));
|
||||||
if (geom) {
|
if (geom) {
|
||||||
osgUtil::Tessellator tessellator;
|
osgUtil::Tessellator Tessellator;
|
||||||
tessellator.retessellatePolygons(*geom);
|
Tessellator.retessellatePolygons(*geom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
traverse(geode);
|
traverse(geode);
|
||||||
|
@ -702,15 +702,11 @@ void Viewer::eventTraversal()
|
|||||||
{
|
{
|
||||||
case(osgGA::GUIEventAdapter::CLOSE_WINDOW):
|
case(osgGA::GUIEventAdapter::CLOSE_WINDOW):
|
||||||
{
|
{
|
||||||
stopThreading();
|
// stopThreading();
|
||||||
|
|
||||||
gw->close();
|
gw->close();
|
||||||
|
|
||||||
// setThreadingModel(ThreadPerCamera);
|
// startThreading();
|
||||||
|
|
||||||
setThreadingModel(SingleThreaded);
|
|
||||||
|
|
||||||
startThreading();
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
BEGIN_ENUM_REFLECTOR(osgFlightUtil::Optimizer::OptimizationOptions)
|
BEGIN_ENUM_REFLECTOR(osgFlightUtil::Optimizer::OptimizationOptions)
|
||||||
I_EnumLabel(osgFlightUtil::Optimizer::TESSELATE_POLYGON);
|
I_EnumLabel(osgFlightUtil::Optimizer::TESSELLATE_POLYGON);
|
||||||
I_EnumLabel(osgFlightUtil::Optimizer::MERGE_GEODES);
|
I_EnumLabel(osgFlightUtil::Optimizer::MERGE_GEODES);
|
||||||
I_EnumLabel(osgFlightUtil::Optimizer::MAKE_LIT);
|
I_EnumLabel(osgFlightUtil::Optimizer::MAKE_LIT);
|
||||||
I_EnumLabel(osgFlightUtil::Optimizer::DEFAULT_OPTIMIZATIONS);
|
I_EnumLabel(osgFlightUtil::Optimizer::DEFAULT_OPTIMIZATIONS);
|
||||||
@ -71,9 +71,9 @@ BEGIN_OBJECT_REFLECTOR(osgFlightUtil::Optimizer::MergeGeodesVisitor)
|
|||||||
"");
|
"");
|
||||||
END_REFLECTOR
|
END_REFLECTOR
|
||||||
|
|
||||||
BEGIN_OBJECT_REFLECTOR(osgFlightUtil::Optimizer::TesselateVisitor)
|
BEGIN_OBJECT_REFLECTOR(osgFlightUtil::Optimizer::TessellateVisitor)
|
||||||
I_BaseType(osg::NodeVisitor);
|
I_BaseType(osg::NodeVisitor);
|
||||||
I_Constructor0(____TesselateVisitor,
|
I_Constructor0(____TessellateVisitor,
|
||||||
"default to traversing all children. ",
|
"default to traversing all children. ",
|
||||||
"");
|
"");
|
||||||
I_Method1(void, apply, IN, osg::Geode &, geode,
|
I_Method1(void, apply, IN, osg::Geode &, geode,
|
||||||
|
@ -154,6 +154,14 @@ BEGIN_OBJECT_REFLECTOR(osgText::Font)
|
|||||||
__C5_FontImplementation_P1__getImplementation,
|
__C5_FontImplementation_P1__getImplementation,
|
||||||
"",
|
"",
|
||||||
"");
|
"");
|
||||||
|
I_Method1(void, setThreadSafeRefUnref, IN, bool, threadSafe,
|
||||||
|
__void__setThreadSafeRefUnref__bool,
|
||||||
|
"Set whether to use a mutex to ensure ref() and unref() are thread safe. ",
|
||||||
|
"");
|
||||||
|
I_Method1(void, resizeGLObjectBuffers, IN, unsigned int, maxSize,
|
||||||
|
__void__resizeGLObjectBuffers__unsigned_int,
|
||||||
|
"Resize any per context GLObject buffers to specified size. ",
|
||||||
|
"");
|
||||||
I_MethodWithDefaults1(void, releaseGLObjects, IN, osg::State *, state, 0,
|
I_MethodWithDefaults1(void, releaseGLObjects, IN, osg::State *, state, 0,
|
||||||
__void__releaseGLObjects__osg_State_P1,
|
__void__releaseGLObjects__osg_State_P1,
|
||||||
"If State is non-zero, this function releases OpenGL objects for the specified graphics context. ",
|
"If State is non-zero, this function releases OpenGL objects for the specified graphics context. ",
|
||||||
@ -191,6 +199,9 @@ BEGIN_OBJECT_REFLECTOR(osgText::Font)
|
|||||||
I_SimpleProperty(unsigned int, TextureWidthHint,
|
I_SimpleProperty(unsigned int, TextureWidthHint,
|
||||||
__unsigned_int__getTextureWidthHint,
|
__unsigned_int__getTextureWidthHint,
|
||||||
0);
|
0);
|
||||||
|
I_SimpleProperty(bool, ThreadSafeRefUnref,
|
||||||
|
0,
|
||||||
|
__void__setThreadSafeRefUnref__bool);
|
||||||
END_REFLECTOR
|
END_REFLECTOR
|
||||||
|
|
||||||
BEGIN_ABSTRACT_OBJECT_REFLECTOR(osgText::Font::FontImplementation)
|
BEGIN_ABSTRACT_OBJECT_REFLECTOR(osgText::Font::FontImplementation)
|
||||||
@ -396,9 +407,20 @@ BEGIN_OBJECT_REFLECTOR(osgText::Font::GlyphTexture)
|
|||||||
__void__apply__osg_State_R1,
|
__void__apply__osg_State_R1,
|
||||||
"Bind the texture object. ",
|
"Bind the texture object. ",
|
||||||
"If the texture object hasn't already been compiled, create the texture mipmap levels. ");
|
"If the texture object hasn't already been compiled, create the texture mipmap levels. ");
|
||||||
|
I_Method1(void, setThreadSafeRefUnref, IN, bool, threadSafe,
|
||||||
|
__void__setThreadSafeRefUnref__bool,
|
||||||
|
"Set whether to use a mutex to ensure ref() and unref() are thread safe. ",
|
||||||
|
"");
|
||||||
|
I_Method1(void, resizeGLObjectBuffers, IN, unsigned int, maxSize,
|
||||||
|
__void__resizeGLObjectBuffers__unsigned_int,
|
||||||
|
"Resize any per context GLObject buffers to specified size. ",
|
||||||
|
"");
|
||||||
I_SimpleProperty(unsigned int, GlyphImageMargin,
|
I_SimpleProperty(unsigned int, GlyphImageMargin,
|
||||||
__unsigned_int__getGlyphImageMargin,
|
__unsigned_int__getGlyphImageMargin,
|
||||||
__void__setGlyphImageMargin__unsigned_int);
|
__void__setGlyphImageMargin__unsigned_int);
|
||||||
|
I_SimpleProperty(bool, ThreadSafeRefUnref,
|
||||||
|
0,
|
||||||
|
__void__setThreadSafeRefUnref__bool);
|
||||||
END_REFLECTOR
|
END_REFLECTOR
|
||||||
|
|
||||||
BEGIN_ENUM_REFLECTOR(osgText::KerningType)
|
BEGIN_ENUM_REFLECTOR(osgText::KerningType)
|
||||||
|
@ -388,6 +388,14 @@ BEGIN_OBJECT_REFLECTOR(osgText::Text)
|
|||||||
__void__accept__osg_PrimitiveFunctor_R1,
|
__void__accept__osg_PrimitiveFunctor_R1,
|
||||||
"accept a PrimtiveFunctor and call its methods to tell it about the interal primtives that this Drawable has. ",
|
"accept a PrimtiveFunctor and call its methods to tell it about the interal primtives that this Drawable has. ",
|
||||||
"");
|
"");
|
||||||
|
I_Method1(void, setThreadSafeRefUnref, IN, bool, threadSafe,
|
||||||
|
__void__setThreadSafeRefUnref__bool,
|
||||||
|
"Set whether to use a mutex to ensure ref() and unref() are thread safe. ",
|
||||||
|
"");
|
||||||
|
I_Method1(void, resizeGLObjectBuffers, IN, unsigned int, maxSize,
|
||||||
|
__void__resizeGLObjectBuffers__unsigned_int,
|
||||||
|
"Resize any per context GLObject buffers to specified size. ",
|
||||||
|
"");
|
||||||
I_MethodWithDefaults1(void, releaseGLObjects, IN, osg::State *, state, 0,
|
I_MethodWithDefaults1(void, releaseGLObjects, IN, osg::State *, state, 0,
|
||||||
__void__releaseGLObjects__osg_State_P1,
|
__void__releaseGLObjects__osg_State_P1,
|
||||||
"If State is non-zero, this function releases OpenGL objects for the specified graphics context. ",
|
"If State is non-zero, this function releases OpenGL objects for the specified graphics context. ",
|
||||||
@ -497,6 +505,9 @@ BEGIN_OBJECT_REFLECTOR(osgText::Text)
|
|||||||
I_SimpleProperty(const osgText::Text::TextureGlyphQuadMap &, TextureGlyphQuadMap,
|
I_SimpleProperty(const osgText::Text::TextureGlyphQuadMap &, TextureGlyphQuadMap,
|
||||||
__C5_TextureGlyphQuadMap_R1__getTextureGlyphQuadMap,
|
__C5_TextureGlyphQuadMap_R1__getTextureGlyphQuadMap,
|
||||||
0);
|
0);
|
||||||
|
I_SimpleProperty(bool, ThreadSafeRefUnref,
|
||||||
|
0,
|
||||||
|
__void__setThreadSafeRefUnref__bool);
|
||||||
END_REFLECTOR
|
END_REFLECTOR
|
||||||
|
|
||||||
TYPE_NAME_ALIAS(std::vector< osgText::Font::Glyph * >, osgText::Text::GlyphQuads::Glyphs);
|
TYPE_NAME_ALIAS(std::vector< osgText::Font::Glyph * >, osgText::Text::GlyphQuads::Glyphs);
|
||||||
|
@ -51,7 +51,7 @@ BEGIN_OBJECT_REFLECTOR(osgUtil::DelaunayConstraint)
|
|||||||
"");
|
"");
|
||||||
I_Method1(void, merge, IN, osgUtil::DelaunayConstraint *, dco,
|
I_Method1(void, merge, IN, osgUtil::DelaunayConstraint *, dco,
|
||||||
__void__merge__DelaunayConstraint_P1,
|
__void__merge__DelaunayConstraint_P1,
|
||||||
"Add vertices and constraint loops from dco Can be used to generate extra vertices where dco crosses 'this' using osgUtil::tessellator to insert overlap vertices. ",
|
"Add vertices and constraint loops from dco Can be used to generate extra vertices where dco crosses 'this' using osgUtil::Tessellator to insert overlap vertices. ",
|
||||||
"");
|
"");
|
||||||
I_Method1(void, removeVerticesInside, IN, const osgUtil::DelaunayConstraint *, dco,
|
I_Method1(void, removeVerticesInside, IN, const osgUtil::DelaunayConstraint *, dco,
|
||||||
__void__removeVerticesInside__C5_DelaunayConstraint_P1,
|
__void__removeVerticesInside__C5_DelaunayConstraint_P1,
|
||||||
@ -71,7 +71,7 @@ BEGIN_OBJECT_REFLECTOR(osgUtil::DelaunayConstraint)
|
|||||||
"");
|
"");
|
||||||
I_Method0(void, handleOverlaps,
|
I_Method0(void, handleOverlaps,
|
||||||
__void__handleOverlaps,
|
__void__handleOverlaps,
|
||||||
"Tesselate the constraint loops so that the crossing points are interpolated and added to the contraints for the triangulation. ",
|
"Tessellate the constraint loops so that the crossing points are interpolated and added to the contraints for the triangulation. ",
|
||||||
"");
|
"");
|
||||||
I_SimpleProperty(osg::DrawElementsUInt *, Triangles,
|
I_SimpleProperty(osg::DrawElementsUInt *, Triangles,
|
||||||
__osg_DrawElementsUInt_P1__getTriangles,
|
__osg_DrawElementsUInt_P1__getTriangles,
|
||||||
|
@ -40,7 +40,7 @@ TYPE_NAME_ALIAS(std::vector< int >, osgUtil::Hit::VecIndexList);
|
|||||||
BEGIN_VALUE_REFLECTOR(osgUtil::Hit)
|
BEGIN_VALUE_REFLECTOR(osgUtil::Hit)
|
||||||
I_Constructor0(____Hit,
|
I_Constructor0(____Hit,
|
||||||
"Describes a point in space produced by an intersection of a line with a scene. ",
|
"Describes a point in space produced by an intersection of a line with a scene. ",
|
||||||
"A Hit is always on a surface as rendered by the Open Scene Graph scene (usually a triangle or other primitive, but a special hit handler could return a different value perhaps: a sphere shape might return a Hit on the true sphere rather than the approximate tesselated sphere rendered.");
|
"A Hit is always on a surface as rendered by the Open Scene Graph scene (usually a triangle or other primitive, but a special hit handler could return a different value perhaps: a sphere shape might return a Hit on the true sphere rather than the approximate tessellated sphere rendered.");
|
||||||
I_Constructor1(IN, const osgUtil::Hit &, hit,
|
I_Constructor1(IN, const osgUtil::Hit &, hit,
|
||||||
____Hit__C5_Hit_R1,
|
____Hit__C5_Hit_R1,
|
||||||
"",
|
"",
|
||||||
|
@ -73,7 +73,7 @@ BEGIN_ENUM_REFLECTOR(osgUtil::Optimizer::OptimizationOptions)
|
|||||||
I_EnumLabel(osgUtil::Optimizer::SPATIALIZE_GROUPS);
|
I_EnumLabel(osgUtil::Optimizer::SPATIALIZE_GROUPS);
|
||||||
I_EnumLabel(osgUtil::Optimizer::COPY_SHARED_NODES);
|
I_EnumLabel(osgUtil::Optimizer::COPY_SHARED_NODES);
|
||||||
I_EnumLabel(osgUtil::Optimizer::TRISTRIP_GEOMETRY);
|
I_EnumLabel(osgUtil::Optimizer::TRISTRIP_GEOMETRY);
|
||||||
I_EnumLabel(osgUtil::Optimizer::TESSELATE_GEOMETRY);
|
I_EnumLabel(osgUtil::Optimizer::TESSELLATE_GEOMETRY);
|
||||||
I_EnumLabel(osgUtil::Optimizer::OPTIMIZE_TEXTURE_SETTINGS);
|
I_EnumLabel(osgUtil::Optimizer::OPTIMIZE_TEXTURE_SETTINGS);
|
||||||
I_EnumLabel(osgUtil::Optimizer::MERGE_GEODES);
|
I_EnumLabel(osgUtil::Optimizer::MERGE_GEODES);
|
||||||
I_EnumLabel(osgUtil::Optimizer::FLATTEN_BILLBOARDS);
|
I_EnumLabel(osgUtil::Optimizer::FLATTEN_BILLBOARDS);
|
||||||
@ -500,19 +500,19 @@ BEGIN_OBJECT_REFLECTOR(osgUtil::Optimizer::StateVisitor)
|
|||||||
"");
|
"");
|
||||||
END_REFLECTOR
|
END_REFLECTOR
|
||||||
|
|
||||||
TYPE_NAME_ALIAS(std::set< osg::Group * >, osgUtil::Optimizer::TesselateVisitor::GroupList);
|
TYPE_NAME_ALIAS(std::set< osg::Group * >, osgUtil::Optimizer::TessellateVisitor::GroupList);
|
||||||
|
|
||||||
BEGIN_OBJECT_REFLECTOR(osgUtil::Optimizer::TesselateVisitor)
|
BEGIN_OBJECT_REFLECTOR(osgUtil::Optimizer::TessellateVisitor)
|
||||||
I_BaseType(osgUtil::BaseOptimizerVisitor);
|
I_BaseType(osgUtil::BaseOptimizerVisitor);
|
||||||
I_ConstructorWithDefaults1(IN, osgUtil::Optimizer *, optimizer, 0,
|
I_ConstructorWithDefaults1(IN, osgUtil::Optimizer *, optimizer, 0,
|
||||||
____TesselateVisitor__Optimizer_P1,
|
____TessellateVisitor__Optimizer_P1,
|
||||||
"",
|
"",
|
||||||
"");
|
"");
|
||||||
I_Method1(void, apply, IN, osg::Geode &, geode,
|
I_Method1(void, apply, IN, osg::Geode &, geode,
|
||||||
__void__apply__osg_Geode_R1,
|
__void__apply__osg_Geode_R1,
|
||||||
"",
|
"",
|
||||||
"");
|
"");
|
||||||
I_PublicMemberProperty(osgUtil::Optimizer::TesselateVisitor::GroupList, _groupList);
|
I_PublicMemberProperty(osgUtil::Optimizer::TessellateVisitor::GroupList, _groupList);
|
||||||
END_REFLECTOR
|
END_REFLECTOR
|
||||||
|
|
||||||
BEGIN_VALUE_REFLECTOR(osgUtil::Optimizer::TextureAtlasBuilder)
|
BEGIN_VALUE_REFLECTOR(osgUtil::Optimizer::TextureAtlasBuilder)
|
||||||
|
Loading…
Reference in New Issue
Block a user