openscenegraph
TriStripVisitor
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSGUTIL_TRISTRIPVISITOR
15#define OSGUTIL_TRISTRIPVISITOR 1
16
17#include <osg/NodeVisitor>
18#include <osg/Geode>
19#include <osg/Geometry>
20
21#include <osgUtil/Optimizer>
22
23#include <set>
24
25namespace osgUtil {
26
31{
32 public:
33
35 TriStripVisitor(Optimizer* optimizer=0) :
36 BaseOptimizerVisitor( optimizer, Optimizer::TRISTRIP_GEOMETRY),
37 _cacheSize( 16 ),
38 _minStripSize( 2 ),
39 _generateFourPointPrimitivesQuads ( false ),
40 _mergeTriangleStrips( false ),
41 _indexMesh( true )
42 {}
43
48 void stripify(osg::Geometry& drawable);
49
51
53 void stripify();
54
56 virtual void apply(osg::Geometry& geom);
57
58 inline void setCacheSize( unsigned int size )
59 {
60 _cacheSize = size;
61 }
62
63 inline unsigned int getCacheSize() const
64 {
65 return _cacheSize;
66 }
67
68 inline void setMinStripSize( unsigned int size )
69 {
70 _minStripSize = size;
71 }
72
73 inline unsigned int getMinStripSize() const
74 {
75 return _minStripSize;
76 }
77
78 inline void setIndexMesh( bool allow )
79 {
80 _indexMesh = allow;
81 }
82
83 inline bool getIndexMesh() const
84 {
85 return _indexMesh;
86 }
87
88 void setGenerateFourPointPrimitivesQuads(bool flag) { _generateFourPointPrimitivesQuads = flag; }
89 bool getGenerateFourPointPrimitivesQuads() const { return _generateFourPointPrimitivesQuads; }
90
91 void setMergeTriangleStrips(bool flag) { _mergeTriangleStrips = flag; }
92 bool getMergeTriangleStrips() const { return _mergeTriangleStrips; }
93
94 private:
95
96 typedef std::set<osg::Geometry*> GeometryList;
97
98 unsigned int _cacheSize;
99 unsigned int _minStripSize;
100 GeometryList _geometryList;
101 bool _generateFourPointPrimitivesQuads;
102 bool _mergeTriangleStrips;
103 bool _indexMesh;
104};
105
106}
107
108#endif
Definition Optimizer:34
Definition Optimizer:61
Definition TriStripVisitor:31
unsigned int getCacheSize() const
Definition TriStripVisitor:63
void stripify(osg::Geometry &drawable)
virtual void apply(osg::Geometry &geom)
Accumulate the Geometry drawables to make into strips.
void setGenerateFourPointPrimitivesQuads(bool flag)
Definition TriStripVisitor:88
void setMinStripSize(unsigned int size)
Definition TriStripVisitor:68
unsigned int getMinStripSize() const
Definition TriStripVisitor:73
void setCacheSize(unsigned int size)
Definition TriStripVisitor:58
bool getIndexMesh() const
Definition TriStripVisitor:83
bool getGenerateFourPointPrimitivesQuads() const
Definition TriStripVisitor:89
void setIndexMesh(bool allow)
Definition TriStripVisitor:78
bool getMergeTriangleStrips() const
Definition TriStripVisitor:92
TriStripVisitor(Optimizer *optimizer=0)
default to traversing all children.
Definition TriStripVisitor:35
void setMergeTriangleStrips(bool flag)
Definition TriStripVisitor:91
void mergeTriangleStrips(osg::Geometry::PrimitiveSetList &primitives)
Definition Geometry:31
std::vector< ref_ptr< PrimitiveSet > > PrimitiveSetList
Definition Geometry:102
Shader generator framework.
Definition NodeVisitor:25
#define OSGUTIL_EXPORT
Definition osgUtil/Export:40