root/OpenSceneGraph/trunk/include/osgUtil/TriStripVisitor @ 3526

Revision 3526, 3.2 kB (checked in by robert, 10 years ago)

From Geoff Michel, speeling and typo fixes in osgUtil

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
RevLine 
[1529]1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 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*/
[51]13
[10]14#ifndef OSGUTIL_TRISTRIPVISITOR
15#define OSGUTIL_TRISTRIPVISITOR 1
16
17#include <osg/NodeVisitor>
18#include <osg/Geode>
[794]19#include <osg/Geometry>
[10]20
[2525]21#include <osgUtil/Optimizer>
[10]22
[2491]23#include <set>
24
[10]25namespace osgUtil {
26
[797]27/** A tri stripping visitor for converting Geometry surface primitives into tri strips.
[3526]28  * The current implemention is based upon Tanguy Fautre's triangulation code.
[10]29  */
30class OSGUTIL_EXPORT TriStripVisitor : public osg::NodeVisitor
31{
32    public:
33
34        /// default to traversing all children.
[3216]35        TriStripVisitor(Optimizer* =0) :
[1879]36                osg::NodeVisitor( osg::NodeVisitor::TRAVERSE_ALL_CHILDREN ),
[2501]37                _cacheSize( 16 ),
[2932]38                _minStripSize( 2 ),
39                _generateFourPointPrimitivesQuads ( false)
[1879]40        {}
[10]41
[2431]42        /** Convert mesh primitives in Geometry into Tri Strips.
43          * Converts all primitive types except points
[10]44          * and lines, linestrips which it leaves unchanged.
45          */
[1879]46        void stripify(osg::Geometry& drawable);
[10]47
[3526]48        /** Stripify (make into strips of tria or quads) the accumulated list of Geometry drawables.*/
[2491]49        void stripify();
50
[3526]51        /// Accumulate the Geometry drawables to make into strips.
[10]52        virtual void apply(osg::Geode& geode);
53
[1879]54        inline void setCacheSize( unsigned int size )
55        {
56            _cacheSize = size;
57        }
58       
59        inline unsigned int getCacheSize()
60        {
61            return _cacheSize;
62        }
63
64        inline const unsigned int getCacheSize() const
65        {
66            return _cacheSize;
67        }
68       
69        inline void setMinStripSize( unsigned int size )
70        {
71            _minStripSize = size;
72        }
73       
74        inline unsigned int getMinStripSize()
75        {
76            return _minStripSize;
77        }
78
79        inline const unsigned int getMinStripSize() const
80        {
81            return _minStripSize;
82        }
83       
[3432]84        inline bool isOperationPermissibleForObject(const osg::Object* object) const
[2525]85        {
[3432]86            return _optimizer ? _optimizer->isOperationPermissibleForObject(object,osgUtil::Optimizer::TRISTRIP_GEOMETRY) : true;
[2525]87        }
[2932]88       
89        void setGenerateFourPointPrimitivesQuads(bool flag) { _generateFourPointPrimitivesQuads = flag; }
90        bool getGenerateFourPointPrimitivesQuads() const { return _generateFourPointPrimitivesQuads; }
91       
[2525]92
[1879]93    private:
94   
[2491]95        typedef std::set<osg::Geometry*> GeometryList;
96
[2525]97        Optimizer*   _optimizer;
[1879]98        unsigned int _cacheSize;
99        unsigned int _minStripSize;
[2491]100        GeometryList _geometryList;
[2932]101        bool         _generateFourPointPrimitivesQuads;
[10]102};
103
[349]104}
[10]105
106#endif
Note: See TracBrowser for help on using the browser.