Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/MatrixManipulator
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/MatrixManipulator (revision 3147)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/MatrixManipulator (revision 3147)
@@ -0,0 +1,184 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGGA_MatrixManipulator
+#define OSGGA_MatrixManipulator 1
+
+#include <osg/Node>
+#include <osg/Matrixd>
+#include <osg/CoordinateSystemNode>
+
+#include <osgUtil/SceneView>
+
+#include <osgGA/Export>
+#include <osgGA/GUIEventHandler>
+#include <osgGA/GUIEventAdapter>
+#include <osgGA/GUIActionAdapter>
+
+namespace osgGA{
+
+#define NEW_HOME_POSITION
+
+/**
+
+MatrixManipulator is an abstract base class defining the interface, and a certain
+amount of default functionality, for classes which wish to control OSG cameras
+in response to GUI events.
+
+*/
+class OSGGA_EXPORT MatrixManipulator : public GUIEventHandler
+{
+public:
+
+
+        virtual const char* className() const { return "MatrixManipulator"; }
+        
+        /** callback class to use to allow matrix manipulators to querry the application for the local coordinate frame.*/
+        class CoordinateFrameCallback : public osg::Referenced
+        {
+        public:
+            virtual osg::CoordinateFrame getCoordinateFrame(const osg::Vec3d& position) const = 0;
+        protected:
+            virtual ~CoordinateFrameCallback() {}
+        };
+        
+        
+
+        /** set the minimum distance (as ratio) the eye point can be zoomed in towards the
+            center before the center is pushed forward.*/        
+        virtual void setMinimumDistance(float minimumDistance) { _minimumDistance=minimumDistance; }
+
+        /** get the minimum distance (as ratio) the eye point can be zoomed in */
+        float getMinimumDistance() const { return _minimumDistance; }
+
+
+        /** set the coordinate frame which callback tells the manipulator which way is up, east and north.*/
+        virtual void setCoordinateFrameCallback(CoordinateFrameCallback* cb) { _coordinateFrameCallback = cb; }
+
+        /** get the coordinate frame callback which tells the manipulator which way is up, east and north.*/
+        CoordinateFrameCallback* getCoordinateFrameCallback() { return _coordinateFrameCallback.get(); }
+
+        /** get the coordinate frame callback which tells the manipulator which way is up, east and north.*/
+        const CoordinateFrameCallback* getCoordinateFrameCallback() const { return _coordinateFrameCallback.get(); }
+        
+        /** get the coordinate frame.*/
+        osg::CoordinateFrame getCoordinateFrame(const osg::Vec3d& position) const
+        {
+            if (_coordinateFrameCallback.valid()) return  _coordinateFrameCallback->getCoordinateFrame(position);
+            return osg::CoordinateFrame();
+        }
+        
+        osg::Vec3d getSideVector(const osg::CoordinateFrame& cf) const { return osg::Vec3d(cf(0,0),cf(0,1),cf(0,2)); }
+        osg::Vec3d getFrontVector(const osg::CoordinateFrame& cf) const { return osg::Vec3d(cf(1,0),cf(1,1),cf(1,2)); }
+        osg::Vec3d getUpVector(const osg::CoordinateFrame& cf) const { return osg::Vec3d(cf(2,0),cf(2,1),cf(2,2)); }
+
+        /** set the position of the matrix manipulator using a 4x4 Matrix.*/
+        virtual void setByMatrix(const osg::Matrixd& matrix) = 0;
+
+        /** set the position of the matrix manipulator using a 4x4 Matrix.*/
+        virtual void setByInverseMatrix(const osg::Matrixd& matrix) = 0;
+
+        /** get the position of the manipulator as 4x4 Matrix.*/
+        virtual osg::Matrixd getMatrix() const = 0;
+
+        /** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/
+        virtual osg::Matrixd getInverseMatrix() const = 0;
+
+        /** Get the FusionDistanceMode. Used by SceneView for setting up setereo convergence.*/
+        virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const { return osgUtil::SceneView::PROPORTIONAL_TO_SCREEN_DISTANCE; }
+
+        /** Get the FusionDistanceValue. Used by SceneView for setting up setereo convergence.*/
+        virtual float getFusionDistanceValue() const { return 1.0f; }
+
+
+        /**
+        Attach a node to the manipulator, automatically detaching any previously attached node.
+        setNode(NULL) detaches previous nodes.
+        May be ignored by manipulators which do not require a reference model.
+        */
+        virtual void setNode(osg::Node*) {}
+
+        /** Return const node if attached.*/
+        virtual const osg::Node* getNode() const { return NULL; }
+
+        /** Return node if attached.*/
+        virtual osg::Node* getNode() { return NULL; }
+
+        virtual void setHomePosition(const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up)
+        {
+            _homeEye = eye;
+            _homeCenter = center;
+            _homeUp = up;
+        }
+        
+        virtual void getHomePosition(osg::Vec3d& eye, osg::Vec3d& center, osg::Vec3d& up)
+        {
+            _homeEye = eye;
+            _homeCenter = center;
+            _homeUp = up;
+        }
+        
+        virtual void setAutoComputeHomePosition(bool flag) { _autoComputeHomePosition = flag; }
+        
+        bool getAutoComputeHomePosition() const { return _autoComputeHomePosition; }
+
+        virtual void computeHomePosition()
+        {
+            if(getNode())
+            {
+                const osg::BoundingSphere& boundingSphere=getNode()->getBound();
+
+                setHomePosition(boundingSphere._center+osg::Vec3( 0.0,-3.5f * boundingSphere._radius,0.0f),
+                                boundingSphere._center,
+                                osg::Vec3(0.0f,0.0f,1.0f));
+            }
+        }
+
+
+        /**
+        Move the camera to the default position. 
+        May be ignored by manipulators if home functionality is not appropriate.
+        */
+        virtual void home(const GUIEventAdapter& ,GUIActionAdapter&) {}
+
+        /**
+        Start/restart the manipulator.
+        FIXME: what does this actually mean? Provide examples.
+        */
+        virtual void init(const GUIEventAdapter& ,GUIActionAdapter&) {}
+
+        /** Handle events, return true if handled, false otherwise. */
+        virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
+
+        /** Handle visitations */
+        virtual void accept(GUIEventHandlerVisitor& v)    { v.visit(*this); }
+
+protected:
+
+        MatrixManipulator();
+        virtual ~MatrixManipulator();
+
+        double                  _minimumDistance;
+        
+        bool                    _autoComputeHomePosition;
+        
+        osg::Vec3d              _homeEye;
+        osg::Vec3d              _homeCenter;
+        osg::Vec3d              _homeUp;
+
+        osg::ref_ptr<CoordinateFrameCallback> _coordinateFrameCallback;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/TerrainManipulator
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/TerrainManipulator (revision 3130)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/TerrainManipulator (revision 3130)
@@ -0,0 +1,131 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGGA_TERRAINMANIPULATOR
+#define OSGGA_TERRAINMANIPULATOR 1
+
+#include <osgGA/MatrixManipulator>
+#include <osg/Quat>
+
+namespace osgGA{
+
+class OSGGA_EXPORT TerrainManipulator : public MatrixManipulator
+{
+    public:
+
+        TerrainManipulator();
+
+        virtual const char* className() const { return "Terrain"; }
+
+
+        enum RotationMode 
+        {
+            ELEVATION_AZIM_ROLL,
+            ELEVATION_AZIM,
+        };
+        
+        void setRotationMode(RotationMode mode);
+        RotationMode getRotationMode() const { return _rotationMode; }
+
+
+        /** set the position of the matrix manipulator using a 4x4 Matrix.*/
+        virtual void setByMatrix(const osg::Matrixd& matrix);
+
+        /** set the position of the matrix manipulator using a 4x4 Matrix.*/
+        virtual void setByInverseMatrix(const osg::Matrixd& matrix) { setByMatrix(osg::Matrixd::inverse(matrix)); }
+
+        /** get the position of the manipulator as 4x4 Matrix.*/
+        virtual osg::Matrixd getMatrix() const;
+
+        /** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/
+        virtual osg::Matrixd getInverseMatrix() const;
+
+        /** Get the FusionDistanceMode. Used by SceneView for setting up setereo convergence.*/
+        virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const { return osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE; }
+
+        /** Get the FusionDistanceValue. Used by SceneView for setting up setereo convergence.*/
+        virtual float getFusionDistanceValue() const { return _distance; }
+
+        /** Attach a node to the manipulator. 
+            Automatically detaches previously attached node.
+            setNode(NULL) detaches previously nodes.
+            Is ignored by manipulators which do not require a reference model.*/
+        virtual void setNode(osg::Node*);
+
+        /** Return node if attached.*/
+        virtual const osg::Node* getNode() const;
+
+        /** Return node if attached.*/
+        virtual osg::Node* getNode();
+
+        /** Move the camera to the default position. 
+            May be ignored by manipulators if home functionality is not appropriate.*/
+        virtual void home(const GUIEventAdapter& ea,GUIActionAdapter& us);
+        
+        /** Start/restart the manipulator.*/
+        virtual void init(const GUIEventAdapter& ea,GUIActionAdapter& us);
+
+        /** handle events, return true if handled, false otherwise.*/
+        virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
+
+        /** Get the keyboard and mouse usage of this manipulator.*/
+        virtual void getUsage(osg::ApplicationUsage& usage) const;
+
+    protected:
+
+        virtual ~TerrainManipulator();
+
+        /** Reset the internal GUIEvent stack.*/
+        void flushMouseEventStack();
+        /** Add the current mouse GUIEvent to internal stack.*/
+        void addMouseEvent(const GUIEventAdapter& ea);
+
+        void computePosition(const osg::Vec3d& eye,const osg::Vec3d& lv,const osg::Vec3d& up);
+
+        /** For the give mouse movement calculate the movement of the camera.
+            Return true is camera has moved and a redraw is required.*/
+        bool calcMovement();
+        
+        void trackball(osg::Vec3& axis,double& angle, double p1x, double p1y, double p2x, double p2y);
+        double tb_project_to_sphere(double r, double x, double y);
+
+
+        /** Check the speed at which the mouse is moving.
+            If speed is below a threshold then return false, otherwise return true.*/
+        bool isMouseMoving();
+
+
+        void clampOrientation();
+
+
+        // Internal event stack comprising last three mouse events.
+        osg::ref_ptr<const GUIEventAdapter> _ga_t1;
+        osg::ref_ptr<const GUIEventAdapter> _ga_t0;
+
+        osg::ref_ptr<osg::Node> _node;
+
+        RotationMode            _rotationMode;
+
+        bool                    _thrown;
+        
+        osg::Vec3d              _center;
+        osg::Quat               _rotation;
+        float                   _distance;
+        osg::Vec3d              _previousUp;
+
+};
+
+}
+
+#endif
+
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/Export
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/Export (revision 1704)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/Export (revision 1704)
@@ -0,0 +1,153 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+// The following symbol has a underscore suffix for compatibility.
+#ifndef OSGGA_EXPORT_
+#define OSGGA_EXPORT_ 1
+
+#if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__))
+    #pragma warning( disable : 4244 )
+    #pragma warning( disable : 4251 )
+    #pragma warning( disable : 4267 )
+    #pragma warning( disable : 4275 )
+    #pragma warning( disable : 4290 )
+    #pragma warning( disable : 4786 )
+    #pragma warning( disable : 4305 )
+#endif
+
+#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__)
+        #  ifdef OSGGA_LIBRARY
+        #    define OSGGA_EXPORT   __declspec(dllexport)
+        #  else
+        #    define OSGGA_EXPORT   __declspec(dllimport)
+        #endif /* OSGUTIL_LIBRARY */
+#else
+        #define OSGGA_EXPORT 
+#endif 
+
+#endif
+
+
+/**
+
+\namespace osgGA
+
+The 'GA' in osgGA stands for 'GUI Abstraction'; the osgGA namespace provides facilities to
+help developers write the glue to allow the osg to work with varying window systems.
+
+As a cross-platform, window system-agnostic class library, the OpenSceneGraph
+has no direct ties to any given windowing environment. Viewers, however, must at
+some level interact with a window system - where Window system may refer to a windowing
+API, e.g. GLUT, Qt, FLTK, MFC, ...
+
+There is much commonality in the implementation of Viewers for varying windowing
+environments. E.g. most Viewers will update a Camera position in response to a mouse
+event, and may request that a timer be started as a result of a model being 'spun'.
+
+The purpose of the osgGA namespace is to centralise the common areas of this
+functionality. The viewer writer needs then only write a GUIEventAdapter, a
+GUIActionAdapter, and assemble a collection of GUIEventHandlers
+as appropriate for the viewer.
+
+Events from the windowing environment are adpated, and then fed into the GUIEventHandlers.
+The GUIEventHandlers analyse and take action, and make requests of the windowing
+environemnt via the GUIActionAdapter. The viewer writer should then honour these
+requests, translating them into calls to the windowing API.
+
+*/
+
+
+// /**
+// 
+// \namespace osgGA::CmdLineArgs
+// 
+// A collection of utilities for processing command line arguments.
+// 
+// An osgGA::CmdLineArgs::Processor class is provided, which implements a chain
+// of responsibilty for handline command line arguments. Each item in the chain
+// is a subclass of the abstract osgGA::CmdLineArgs::ArgHandler. A number
+// of ArgHandlers are provided, though the user if free to implement their
+// own subclasses for specific needs (e.g. to validate an argument which
+// takes an integer which must be in a specific range).
+// 
+// Let's look at an example...
+// 
+// <h2>Example</h2>
+// 
+// \code
+// 
+// #include <osgGA/CmdLineArgs>
+// 
+// int main(int argc, char* argv[])
+// {
+//         using namespace osg;
+//         using namespace osgGA::CmdLineArgs;
+// 
+//         // Create some handlers
+//         ref_ptr<BoolHandler> helpSwitch(new BoolHandler("[-h]","\t\tPrint this help and exit","-h"));
+//         ref_ptr<BoolHandler> verboseSwitch(new BoolHandler("[-v]","\t\tActivate verbose output","-v"));
+//         ref_ptr<SwitchStringHandler> configFile(
+//                                                                         new SwitchStringHandler("[-config <configfile>",
+//                                                                         "\t\tSpecify a config file to load"), "-config");
+// 
+//         Processor clp;
+//         clp.push_back(helpSwitch.get());
+//         clp.push_back(verboseSwitch.get());
+//         clp.push_back(configFile.get());
+// 
+//         try{
+//                 clp.process(argc,argv);
+//         }
+//         catch(ArgHandlerX& e){
+//                 cerr<<e.what()<<endl;
+//                 clp.printUsage(cerr);
+//                 exit(1);
+//         }
+//         catch(...){
+//                 cerr<<"Unknown exception caught while processing command line arguments."<<endl;
+//                 clp.printUsage(cerr);
+//                 exit(1);
+//         }
+// 
+//         if(helpSwitch->wasSpecified()){
+//                 clp.printHelp(cerr);
+//                 exit(0);
+//         }
+// 
+//         if(verboseSwitch->wasSpecified()){
+//                 // Activate verbosity...
+//         }
+// 
+//         if(configFile->wasSpecified()){
+//                 loadConfigFile(configFile->getString());
+//         }
+// 
+// }
+// 
+// \endcode
+// 
+// The processor takes each argument on the command line in turn, and passes it
+// to the ArgHandler chain. Each ArgHandler is given the opportunity to handle
+// an argument and - if it requires - any subsequent arguments until the
+// end of the argument list (it can do this by incrementing the ArgIterator
+// passed to it. If an ArgHandler handles an argument (e.g. it's looking for
+// and recognises the argument '-h'), it returns true and further processing of
+// the argument stops. If an argument is not handled it is passed to the next
+// handler in the chain, and so on, until it is either handled, or it drops off
+// the end of the chain.
+// 
+// A number of pre-written ArgHandlers are supplied. User's may use these
+// directly, may write their own, or may extend a pre-written ArgHandler to
+// customise it for their specific needs.
+// 
+// */
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/GUIActionAdapter
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/GUIActionAdapter (revision 3044)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/GUIActionAdapter (revision 3044)
@@ -0,0 +1,85 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGGA_GUIACTIONADAPTER
+#define OSGGA_GUIACTIONADAPTER 1 
+
+#include <osgGA/Export>
+
+namespace osgGA{
+
+/**
+Abstract base class defining the interface by which GUIEventHandlers may request
+actions of the GUI system in use. These requests for actions should then be honoured
+by the GUI toolkit of the user's application.
+
+To provide more detail, when a GUIEventHandler (e.g. a TrackballManipulator)
+handles an incoming event, such as a mouse event, it may wish to make
+a request of the GUI. E.g. if a model is 'thrown', the trackball manipulator
+may wish to start a timer, and be repeatedly called, to continuously refresh the
+camera's position and orientation. However, it has no way of doing this, as it
+knows nothing of the window system in which it's operating. Instead, the
+GUIEventHandler issues it's request via a GUIActionAdapter, and the viewer
+in use should honour the request, using the GUI system in play.
+
+There is more than one way of using the GUIActionAdapter. E.g. it may be inherited
+into a Viewer class, as is done with osgGLUT::Viewer. Alternatively, a simple 
+subclass of GUIActionAdapter (e.g. osgQt::QtActionAdapter) may be passed to
+the GUIEventHandler::handle() function; once the function has returned, the viewer
+will then unpack the results and work out what to do to respond to the
+requests.
+
+Also there are several ways to run your app and handle the updating of
+the window.  osgGLUT::Viewer always has a idle callback registered which does a
+redraw all the time.  osgGLUT::Viewer can safely ignore both requestRedraw() and
+requestContinousUpdate() as these are happening all the time anyway.
+
+Other apps will probably want to respond to the requestRedraw() and
+requestContinousUpdate(bool) and again there is more than one way to handle it.
+You can override requestRedraw() and implement to call your own window
+redraw straight away. Or you can implement so that a flag is set and
+then you then respond the flag being set in your own leisure.
+
+*/
+class GUIActionAdapter
+{
+public:
+        
+        /**
+        requestRedraw() requests a single redraw.
+        */
+        virtual void requestRedraw() = 0;
+
+        /**
+        requestContinousUpdate(bool) is for en/disabling a throw or idle 
+        callback to be requested by a GUIEventHandler (typically a MatrixManipulator,
+        though other GUIEventHandler's may also provide functionality). 
+        GUI toolkits can respond  to this immediately by registering an idle/timed
+        callback, or can delay setting the callback and update at their own leisure.
+        */
+        virtual void requestContinuousUpdate(bool needed=true) = 0;
+
+        /**
+        requestWarpPointer(int,int) is requesting a repositioning of the mouse pointer
+        to a specified x,y location on the window.  This is used by some camera manipulators
+        to initialise the mouse pointer when mouse position relative to a controls
+        neutral mouse position is required, i.e when mimicking a aircrafts joystick.
+        */
+        virtual void requestWarpPointer(float x,float y) = 0;
+
+};
+
+}
+
+#endif
+
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/GUIEventHandler
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/GUIEventHandler (revision 2730)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/GUIEventHandler (revision 2730)
@@ -0,0 +1,146 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGGA_GUIEVENTHANDLER
+#define OSGGA_GUIEVENTHANDLER 1
+
+#include <vector>
+
+#include <osg/Referenced>
+#include <osg/Object>
+#include <osg/ApplicationUsage>
+
+#include <osgGA/Export>
+#include <osgGA/GUIEventAdapter>
+#include <osgGA/GUIActionAdapter>
+#include <osgGA/GUIEventHandlerVisitor>
+
+namespace osgGA{
+
+class CompositeGUIEventHandler;
+
+
+
+/**
+
+GUIEventHandler provides a basic interface for any class which wants to handle
+a GUI Events.
+
+The GUIEvent is supplied by a GUIEventAdapter. Feedback resulting from the
+handle method is supplied by a GUIActionAdapter, which allows the GUIEventHandler
+to ask the GUI to take some action in response to an incoming event.
+
+For example, consider a Trackball Viewer class which takes mouse events and
+manipulates a scene camera in response. The Trackball Viewer is a GUIEventHandler,
+and receives the events via the handle method. If the user 'throws' the model,
+the Trackball Viewer class can detect this via the incoming events, and
+request that the GUI set up a timer callback to continually redraw the view.
+This request is made via the GUIActionAdapter class.
+
+*/
+
+class OSGGA_EXPORT GUIEventHandler : public virtual osg::Object
+{
+public:
+
+        GUIEventHandler() {}
+        GUIEventHandler(const GUIEventHandler&,const osg::CopyOp&) {}
+
+        META_Object(osgGA,GUIEventHandler)
+
+
+        /** Returns 0 if this GUIEventHandler is not a CompositeGUIEventHandler. */
+        virtual const CompositeGUIEventHandler* getComposite() const { return 0; }
+
+        /** Returns 0 if this GUIEventHandler is not a CompositeGUIEventHandler. */
+        virtual CompositeGUIEventHandler* getComposite() { return 0; }
+
+        /** Handle events, return true if handled, false otherwise. */
+        virtual bool handle(const GUIEventAdapter&,GUIActionAdapter&) { return false; }
+
+        /** Accept visits from GUIEventHandler visitors */
+        virtual void accept(GUIEventHandlerVisitor&) {}
+        
+        /** Get the keyboard and mouse usage of this manipulator.*/
+        virtual void getUsage(osg::ApplicationUsage&) const {}
+};
+
+
+/**
+CompositeGUIEventHandler allows GUIEventHandlers to be composed into hierarchies.
+*/
+
+class OSGGA_EXPORT CompositeGUIEventHandler : public GUIEventHandler
+{
+public:
+
+        typedef std::vector< osg::ref_ptr<GUIEventHandler> > ChildList;
+
+        virtual const char* className() const { return "CompositeGUIEventHandler"; }
+
+        virtual const CompositeGUIEventHandler* getComposite() const { return this; }
+
+        virtual CompositeGUIEventHandler* getComposite() { return this; }
+
+        virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& aa);
+
+        virtual void accept(GUIEventHandlerVisitor& v)    { v.visit(*this); }
+
+        /** Get the keyboard and mouse usage of this manipulator.*/
+        virtual void getUsage(osg::ApplicationUsage& usage) const;
+
+
+        // Composite-specific methods below
+
+        virtual bool addChild(GUIEventHandler *geh);
+
+        virtual bool removeChild(GUIEventHandler *geh);
+
+        unsigned int getNumChildren() const { return _children.size(); }
+
+        GUIEventHandler *getChild( unsigned int i) { return _children[i].get(); }
+
+        const GUIEventHandler *getChild( unsigned int i ) const { return _children[i].get(); }
+
+        bool containsNode( const GUIEventHandler* node ) const
+        {
+                for (ChildList::const_iterator itr=_children.begin();
+                        itr!=_children.end();
+                        ++itr)
+                {
+                        if (itr->get()==node) return true;
+                }
+                return false;
+        }
+
+        ChildList::iterator findChild( const GUIEventHandler* node )
+        {
+                for (ChildList::iterator itr=_children.begin();
+                        itr!=_children.end();
+                        ++itr)
+                {
+                        if (itr->get()==node) return itr;
+                }
+                return _children.end();
+        }
+
+private:
+
+        ChildList   _children;
+
+};
+
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/SetSceneViewVisitor
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/SetSceneViewVisitor (revision 1949)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/SetSceneViewVisitor (revision 1949)
@@ -0,0 +1,54 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGGA_SETSCENEVIEWGEHVISITOR
+#define OSGGA_SETSCENEVIEWGEHVISITOR 1
+
+#include <osgGA/GUIEventHandlerVisitor>
+#include <osgUtil/SceneView>
+
+namespace osgGA{
+
+// Some forward declarations
+class GUIEventHandler;
+class MatrixManipulator;
+
+/**
+SetSceneViewGUIEventHandlerVisitor which visits various types of
+GUIEventHandler and sets them up appropriately, given a new scene
+view.
+*/
+class OSGGA_EXPORT SetSceneViewVisitor: public GUIEventHandlerVisitor
+{
+    public:
+
+        SetSceneViewVisitor(GUIEventAdapter* in,
+                               GUIActionAdapter* out,
+                               osgUtil::SceneView* sv):
+                               GUIEventHandlerVisitor(in,out),
+                               _sceneView(sv) {}
+ 
+        virtual ~SetSceneViewVisitor()         {}
+
+        virtual void visit(MatrixManipulator& cm);
+        virtual void visit(StateSetManipulator& cm);
+
+    private:
+
+        osg::ref_ptr<osgUtil::SceneView> _sceneView;
+
+};
+
+};
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/DriveManipulator
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/DriveManipulator (revision 3147)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/DriveManipulator (revision 3147)
@@ -0,0 +1,107 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGGA_DRIVEMANIPULATOR
+#define OSGGA_DRIVEMANIPULATOR 1 
+
+#include <osgGA/MatrixManipulator>
+#include <osg/Quat>
+
+namespace osgGA{
+
+/**
+DriveManipulator is a camera manipulator which provides drive-like
+functionality. By default, the left mouse button accelerates, the right
+mouse button decelerates, and the middle mouse button (or left and
+right simultaneously) stops dead.
+*/
+
+class OSGGA_EXPORT DriveManipulator : public MatrixManipulator
+{
+    public:
+
+        DriveManipulator();
+
+        virtual const char* className() const { return "Drive"; }
+
+        /** set the position of the matrix manipulator using a 4x4 Matrix.*/
+        virtual void setByMatrix(const osg::Matrixd& matrix);
+
+        /** set the position of the matrix manipulator using a 4x4 Matrix.*/
+        virtual void setByInverseMatrix(const osg::Matrixd& matrix) { setByMatrix(osg::Matrixd::inverse(matrix)); }
+
+        /** get the position of the manipulator as 4x4 Matrix.*/
+        virtual osg::Matrixd getMatrix() const;
+
+        /** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/
+        virtual osg::Matrixd getInverseMatrix() const;
+
+        virtual void setNode(osg::Node*);
+
+        virtual const osg::Node* getNode() const;
+
+        virtual osg::Node* getNode();
+
+        virtual void computeHomePosition();
+
+        virtual void home(const GUIEventAdapter& ea,GUIActionAdapter& us);
+
+        virtual void init(const GUIEventAdapter& ea,GUIActionAdapter& us);
+
+        virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
+
+        /** Get the keyboard and mouse usage of this manipulator.*/
+        virtual void getUsage(osg::ApplicationUsage& usage) const;
+
+    protected:
+
+        virtual ~DriveManipulator();
+
+        /** Reset the internal GUIEvent stack.*/
+        void flushMouseEventStack();
+
+        /** Add the current mouse GUIEvent to internal stack.*/
+        void addMouseEvent(const GUIEventAdapter& ea);
+
+        void computePosition(const osg::Vec3d& eye,const osg::Vec3d& lv,const osg::Vec3d& up);
+
+        /** For the give mouse movement calculate the movement of the camera.
+        Return true is camera has moved and a redraw is required.*/
+        bool calcMovement();
+
+        // Internal event stack comprising last three mouse events.
+        osg::ref_ptr<const GUIEventAdapter> _ga_t1;
+        osg::ref_ptr<const GUIEventAdapter> _ga_t0;
+
+        osg::ref_ptr<osg::Node>       _node;
+
+        double _modelScale;
+        double _velocity;
+        double _height;
+        double _buffer;
+
+        enum SpeedControlMode {
+                USE_MOUSE_Y_FOR_SPEED,
+                USE_MOUSE_BUTTONS_FOR_SPEED
+        };
+
+        SpeedControlMode _speedMode;
+
+        osg::Vec3d   _eye;
+        osg::Quat    _rotation;
+        double       _distance;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/Version
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/Version (revision 1529)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/Version (revision 1529)
@@ -0,0 +1,48 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGGA_VERSION
+#define OSGGA_VERSION 1
+
+#include <osgGA/Export>
+
+
+extern "C" {
+
+/**
+ * getVersion_osgGA() returns the library version number.
+ * Numbering convention : osg_src-0.8-31 will return 0.8.31 from getVersion_osgGA.
+ *
+ * This C function can be also used to check for the existence of the OpenSceneGraph
+ * library using autoconf and its m4 macro AC_CHECK_LIB.
+ *
+ * Here is the code to add to your configure.in:
+ \verbatim
+ #
+ # Check for the OpenSceneGraph (OSG) utility library
+ #
+ AC_CHECK_LIB(osg, osgGAGetVersion, ,
+    [AC_MSG_ERROR(OpenSceneGraph utility library not found. See http://www.openscenegraph.org)],)
+ \endverbatim
+*/
+extern OSGGA_EXPORT const char* osgGAGetVersion();
+
+/**
+ * getLibraryName_osgGA() returns the library name in human friendly form.
+*/
+extern OSGGA_EXPORT const char* osgGAGetLibraryName();
+
+}
+
+#endif
+
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/GUIEventAdapter
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/GUIEventAdapter (revision 3212)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/GUIEventAdapter (revision 3212)
@@ -0,0 +1,303 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGGA_GUIEVENTADAPTER
+#define OSGGA_GUIEVENTADAPTER 1 
+
+#include <osg/Referenced>
+#include <osgGA/Export>
+
+namespace osgGA{
+
+/**
+Pure virtual base class for adapting platform specific events into
+generic keyboard and mouse events. 
+
+Used as GUI toolkit-independent input into GUIEventAdapters. Viewer
+writers should subclass this base class to implement the functionality
+to translate one of their GUI events, e.g. a Qt Event or an MFC Event,
+as appropriate.
+*/
+class OSGGA_EXPORT GUIEventAdapter : public osg::Referenced
+{
+public:
+
+        enum MouseButtonMask { 
+            LEFT_MOUSE_BUTTON=1,
+            MIDDLE_MOUSE_BUTTON=2,
+            RIGHT_MOUSE_BUTTON=4
+        };
+
+        enum EventType {
+            NONE=0,
+            PUSH,
+            RELEASE,
+            DOUBLECLICK,
+            DRAG,
+            MOVE,
+            KEYDOWN,
+            KEYUP,
+            FRAME,
+            RESIZE,
+            SCROLLUP,
+            SCROLLDOWN,
+            SCROLLLEFT,
+            SCROLLRIGHT
+        };
+
+        enum KeySymbol
+        {
+            KEY_Space           = 0x20,
+            
+            KEY_BackSpace       = 0xFF08,        /* back space, back char */
+            KEY_Tab             = 0xFF09,
+            KEY_Linefeed        = 0xFF0A,        /* Linefeed, LF */
+            KEY_Clear           = 0xFF0B,
+            KEY_Return          = 0xFF0D,        /* Return, enter */
+            KEY_Pause           = 0xFF13,        /* Pause, hold */
+            KEY_Scroll_Lock     = 0xFF14,
+            KEY_Sys_Req         = 0xFF15,
+            KEY_Escape          = 0xFF1B,
+            KEY_Delete          = 0xFFFF,        /* Delete, rubout */
+
+
+            /* Cursor control & motion */
+
+            KEY_Home            = 0xFF50,
+            KEY_Left            = 0xFF51,        /* Move left, left arrow */
+            KEY_Up              = 0xFF52,        /* Move up, up arrow */
+            KEY_Right           = 0xFF53,        /* Move right, right arrow */
+            KEY_Down            = 0xFF54,        /* Move down, down arrow */
+            KEY_Prior           = 0xFF55,        /* Prior, previous */
+            KEY_Page_Up         = 0xFF55,
+            KEY_Next            = 0xFF56,        /* Next */
+            KEY_Page_Down       = 0xFF56,
+            KEY_End             = 0xFF57,        /* EOL */
+            KEY_Begin           = 0xFF58,        /* BOL */
+
+
+            /* Misc Functions */
+
+            KEY_Select          = 0xFF60,        /* Select, mark */
+            KEY_Print           = 0xFF61,
+            KEY_Execute         = 0xFF62,        /* Execute, run, do */
+            KEY_Insert          = 0xFF63,        /* Insert, insert here */
+            KEY_Undo            = 0xFF65,        /* Undo, oops */
+            KEY_Redo            = 0xFF66,        /* redo, again */
+            KEY_Menu            = 0xFF67,
+            KEY_Find            = 0xFF68,        /* Find, search */
+            KEY_Cancel          = 0xFF69,        /* Cancel, stop, abort, exit */
+            KEY_Help            = 0xFF6A,        /* Help */
+            KEY_Break           = 0xFF6B,
+            KEY_Mode_switch     = 0xFF7E,        /* Character set switch */
+            KEY_Script_switch   = 0xFF7E,        /* Alias for mode_switch */
+            KEY_Num_Lock        = 0xFF7F,
+
+            /* Keypad Functions, keypad numbers cleverly chosen to map to ascii */
+
+            KEY_KP_Space        = 0xFF80,        /* space */
+            KEY_KP_Tab          = 0xFF89,
+            KEY_KP_Enter        = 0xFF8D,        /* enter */
+            KEY_KP_F1           = 0xFF91,        /* PF1, KP_A, ... */
+            KEY_KP_F2           = 0xFF92,
+            KEY_KP_F3           = 0xFF93,
+            KEY_KP_F4           = 0xFF94,
+            KEY_KP_Home         = 0xFF95,
+            KEY_KP_Left         = 0xFF96,
+            KEY_KP_Up           = 0xFF97,
+            KEY_KP_Right        = 0xFF98,
+            KEY_KP_Down         = 0xFF99,
+            KEY_KP_Prior        = 0xFF9A,
+            KEY_KP_Page_Up      = 0xFF9A,
+            KEY_KP_Next         = 0xFF9B,
+            KEY_KP_Page_Down    = 0xFF9B,
+            KEY_KP_End          = 0xFF9C,
+            KEY_KP_Begin        = 0xFF9D,
+            KEY_KP_Insert       = 0xFF9E,
+            KEY_KP_Delete       = 0xFF9F,
+            KEY_KP_Equal        = 0xFFBD,        /* equals */
+            KEY_KP_Multiply     = 0xFFAA,
+            KEY_KP_Add          = 0xFFAB,
+            KEY_KP_Separator    = 0xFFAC,       /* separator, often comma */
+            KEY_KP_Subtract     = 0xFFAD,
+            KEY_KP_Decimal      = 0xFFAE,
+            KEY_KP_Divide       = 0xFFAF,
+
+            KEY_KP_0            = 0xFFB0,
+            KEY_KP_1            = 0xFFB1,
+            KEY_KP_2            = 0xFFB2,
+            KEY_KP_3            = 0xFFB3,
+            KEY_KP_4            = 0xFFB4,
+            KEY_KP_5            = 0xFFB5,
+            KEY_KP_6            = 0xFFB6,
+            KEY_KP_7            = 0xFFB7,
+            KEY_KP_8            = 0xFFB8,
+            KEY_KP_9            = 0xFFB9,
+            
+            /*
+             * Auxilliary Functions; note the duplicate definitions for left and right
+             * function keys;  Sun keyboards and a few other manufactures have such
+             * function key groups on the left and/or right sides of the keyboard.
+             * We've not found a keyboard with more than 35 function keys total.
+             */
+
+            KEY_F1              = 0xFFBE,
+            KEY_F2              = 0xFFBF,
+            KEY_F3              = 0xFFC0,
+            KEY_F4              = 0xFFC1,
+            KEY_F5              = 0xFFC2,
+            KEY_F6              = 0xFFC3,
+            KEY_F7              = 0xFFC4,
+            KEY_F8              = 0xFFC5,
+            KEY_F9              = 0xFFC6,
+            KEY_F10             = 0xFFC7,
+            KEY_F11             = 0xFFC8,
+            KEY_F12             = 0xFFC9,
+            KEY_F13             = 0xFFCA,
+            KEY_F14             = 0xFFCB,
+            KEY_F15             = 0xFFCC,
+            KEY_F16             = 0xFFCD,
+            KEY_F17             = 0xFFCE,
+            KEY_F18             = 0xFFCF,
+            KEY_F19             = 0xFFD0,
+            KEY_F20             = 0xFFD1,
+            KEY_F21             = 0xFFD2,
+            KEY_F22             = 0xFFD3,
+            KEY_F23             = 0xFFD4,
+            KEY_F24             = 0xFFD5,
+            KEY_F25             = 0xFFD6,
+            KEY_F26             = 0xFFD7,
+            KEY_F27             = 0xFFD8,
+            KEY_F28             = 0xFFD9,
+            KEY_F29             = 0xFFDA,
+            KEY_F30             = 0xFFDB,
+            KEY_F31             = 0xFFDC,
+            KEY_F32             = 0xFFDD,
+            KEY_F33             = 0xFFDE,
+            KEY_F34             = 0xFFDF,
+            KEY_F35             = 0xFFE0,
+
+            /* Modifiers */
+
+            KEY_Shift_L         = 0xFFE1,        /* Left shift */
+            KEY_Shift_R         = 0xFFE2,        /* Right shift */
+            KEY_Control_L       = 0xFFE3,        /* Left control */
+            KEY_Control_R       = 0xFFE4,        /* Right control */
+            KEY_Caps_Lock       = 0xFFE5,        /* Caps lock */
+            KEY_Shift_Lock      = 0xFFE6,        /* Shift lock */
+
+            KEY_Meta_L          = 0xFFE7,        /* Left meta */
+            KEY_Meta_R          = 0xFFE8,        /* Right meta */
+            KEY_Alt_L           = 0xFFE9,        /* Left alt */
+            KEY_Alt_R           = 0xFFEA,        /* Right alt */
+            KEY_Super_L         = 0xFFEB,        /* Left super */
+            KEY_Super_R         = 0xFFEC,        /* Right super */
+            KEY_Hyper_L         = 0xFFED,        /* Left hyper */
+            KEY_Hyper_R         = 0xFFEE,        /* Right hyper */
+        };
+
+
+        enum ModKeyMask
+        {
+            MODKEY_LEFT_SHIFT  = 0x0001,
+            MODKEY_RIGHT_SHIFT = 0x0002,
+            MODKEY_LEFT_CTRL   = 0x0040,
+            MODKEY_RIGHT_CTRL  = 0x0080,
+            MODKEY_LEFT_ALT    = 0x0100,
+            MODKEY_RIGHT_ALT   = 0x0200,
+            MODKEY_LEFT_META   = 0x0400,
+            MODKEY_RIGHT_META  = 0x0800,
+            MODKEY_NUM_LOCK    = 0x1000,
+            MODKEY_CAPS_LOCK   = 0x2000,
+            MODKEY_CTRL        = (MODKEY_LEFT_CTRL|MODKEY_RIGHT_CTRL),
+            MODKEY_SHIFT       = (MODKEY_LEFT_SHIFT|MODKEY_RIGHT_SHIFT),
+            MODKEY_ALT         = (MODKEY_LEFT_ALT|MODKEY_RIGHT_ALT),
+            MODKEY_META        = (MODKEY_LEFT_META|MODKEY_RIGHT_META)
+        };
+
+        /** Get the EventType of the GUI event.*/
+        virtual EventType getEventType() const = 0;
+
+        /** key pressed, return -1 if inappr   opriate for this event. */
+        virtual int getKey() const = 0;
+
+        /** button pressed/released, return -1 if inappropriate for this event.*/
+        virtual int getButton() const = 0;
+
+
+        enum MouseYOrientation
+        {
+            Y_INCREASING_UPWARDS,
+            Y_INCREASING_DOWNWARDS
+        };
+
+        void setMouseYOrientation(MouseYOrientation myo) { _mouseYOrientation = myo; }
+        MouseYOrientation getMouseYOrientation() const { return _mouseYOrientation; }
+
+        /** manimum x mouse position. */
+        virtual float getXmin() const = 0;
+
+        /** maximum x mouse position. */
+        virtual float getXmax() const = 0;
+
+        /** minimum y mouse position. */
+        virtual float getYmin() const = 0;
+
+        /** maximum y mouse position. */   
+        virtual float getYmax() const = 0;
+
+        /** current mouse x position.*/
+        virtual float getX() const = 0;
+
+        /** current mouse y position.*/
+        virtual float getY() const = 0;
+        
+        /** current mouse button state */
+        virtual unsigned int getButtonMask() const = 0;
+
+        /** current modkey state */
+        virtual unsigned int getModKeyMask() const = 0;
+
+        /** time in seconds of event. */
+        virtual double time() const = 0;
+        
+        /** return the getX() value normalised to the range of -1 to 1.
+          * -1 would be the left hand side of the window.
+          * 0.0 would be the middle of the window. 
+          * +1 would be the right hand side of the window.*/
+        inline float getXnormalized() const { return 2.0f*(getX()-getXmin())/(getXmax()-getXmin())-1.0f; }
+
+        /** return the getY() value normalised to the range of -1 to 1.
+          * -1 would be the bottom of the window.
+          * 0.0 would be the middle of the window. 
+          * +1 would be the top of the window.*/
+        inline float getYnormalized() const
+        {
+            if (_mouseYOrientation==Y_INCREASING_UPWARDS) return 2.0f*(getY()-getYmin())/(getYmax()-getYmin())-1.0f;
+            else return -(2.0f*(getY()-getYmin())/(getYmax()-getYmin())-1.0f);
+        }
+
+protected:
+
+        GUIEventAdapter(MouseYOrientation myo=Y_INCREASING_DOWNWARDS):_mouseYOrientation(myo) {}
+
+        /** Force users to create on heap, so that multiple referencing is safe.*/
+        virtual ~GUIEventAdapter(); // {}
+
+        MouseYOrientation _mouseYOrientation;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/FlightManipulator
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/FlightManipulator (revision 3044)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/FlightManipulator (revision 3044)
@@ -0,0 +1,110 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGGA_FLIGHTMANIPULATOR
+#define OSGGA_FLIGHTMANIPULATOR 1
+
+#include <osgGA/MatrixManipulator>
+#include <osg/Quat>
+
+namespace osgGA{
+
+/**
+FlightManipulator is a MatrixManipulator which provides flight simulator-like
+updating of the camera position & orientation. By default, the left mouse
+button accelerates, the right mouse button decelerates, and the middle mouse
+button (or left and right simultaneously) stops dead.
+*/
+
+class OSGGA_EXPORT FlightManipulator : public MatrixManipulator
+{
+    public:
+
+        FlightManipulator();
+
+        virtual const char* className() const { return "Flight"; }
+
+        /** set the position of the matrix manipulator using a 4x4 Matrix.*/
+        virtual void setByMatrix(const osg::Matrixd& matrix);
+
+        /** set the position of the matrix manipulator using a 4x4 Matrix.*/
+        virtual void setByInverseMatrix(const osg::Matrixd& matrix) { setByMatrix(osg::Matrixd::inverse(matrix)); }
+
+        /** get the position of the manipulator as 4x4 Matrix.*/
+        virtual osg::Matrixd getMatrix() const;
+
+        /** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/
+        virtual osg::Matrixd getInverseMatrix() const;
+
+
+        virtual void setNode(osg::Node*);
+
+        virtual const osg::Node* getNode() const;
+
+        virtual osg::Node* getNode();
+
+        virtual void home(const GUIEventAdapter& ea,GUIActionAdapter& us);
+
+        virtual void init(const GUIEventAdapter& ea,GUIActionAdapter& us);
+
+        virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
+
+        /** Get the keyboard and mouse usage of this manipulator.*/
+        virtual void getUsage(osg::ApplicationUsage& usage) const;
+
+        enum YawControlMode {
+                YAW_AUTOMATICALLY_WHEN_BANKED,
+                NO_AUTOMATIC_YAW
+        };
+
+        /**        Configure the Yaw control for the flight model.        */
+        void setYawControlMode(YawControlMode ycm) { _yawMode = ycm; }
+
+    protected:
+
+        virtual ~FlightManipulator();
+
+        /** Reset the internal GUIEvent stack.*/
+        void flushMouseEventStack();
+        /** Add the current mouse GUIEvent to internal stack.*/
+        void addMouseEvent(const GUIEventAdapter& ea);
+
+        void computePosition(const osg::Vec3& eye,const osg::Vec3& lv,const osg::Vec3& up);
+
+        /** For the give mouse movement calculate the movement of the camera.
+            Return true is camera has moved and a redraw is required.*/
+        bool calcMovement();
+
+
+        // Internal event stack comprising last three mouse events.
+        osg::ref_ptr<const GUIEventAdapter> _ga_t1;
+        osg::ref_ptr<const GUIEventAdapter> _ga_t0;
+
+        osg::ref_ptr<osg::Node>       _node;
+
+        double _modelScale;
+        double _acceleration;
+        double _velocity;
+
+        YawControlMode _yawMode;
+        
+        osg::Vec3d  _eye;
+        osg::Quat   _rotation;
+        double      _distance;
+
+};
+
+}
+
+#endif
+
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/GUIEventHandlerVisitor
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/GUIEventHandlerVisitor (revision 1949)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/GUIEventHandlerVisitor (revision 1949)
@@ -0,0 +1,70 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+#ifndef OSGGA_GUIEVENTHANDLERVISITOR
+#define OSGGA_GUIEVENTHANDLERVISITOR 1
+
+#include <osgGA/Export>
+#include <osgGA/GUIEventAdapter>
+#include <osg/ref_ptr>
+
+namespace osgGA{
+
+// Some forward declarations
+class GUIActionAdapter;
+class GUIEventHandler;
+class CompositeGUIEventHandler;
+class MatrixManipulator;
+class StateSetManipulator;
+
+/**
+Base class for visiting GUIEventHandlers.
+
+A Default Visitor, (Might want to make it an Extrinsic Visitor at some point).
+By default, it does nothing to the things it visits. Sub classes of this Visitor
+need only override visit operations for the types of object they're interested in.
+
+*/
+
+
+class OSGGA_EXPORT GUIEventHandlerVisitor
+{
+    public:
+
+        virtual void visit(GUIEventHandler&) {}
+        virtual void visit(CompositeGUIEventHandler&);
+        virtual void visit(MatrixManipulator&) {};
+        virtual void visit(StateSetManipulator&) {};
+
+        // Accessors
+
+        /** Get the GUI EventAdapter associated with this GUIEventHandlerVisitor */
+        const GUIEventAdapter *getGUIEventAdapter() {  return _gea.get(); }
+
+        /** Get the GUI Action Adapter associated with this GEH Visitor */
+        GUIActionAdapter *getGUIActionAdapter() { return _gaa; }
+
+    protected:
+
+        GUIEventHandlerVisitor(GUIEventAdapter* in, GUIActionAdapter* out):_gea(in),_gaa(out) {}
+        virtual ~GUIEventHandlerVisitor() {}
+
+    private:
+  
+        osg::ref_ptr<GUIEventAdapter> _gea;
+        GUIActionAdapter*             _gaa; // Just a pointer. NOT owned by this object.
+
+};
+
+};
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/TrackerManipulator
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/TrackerManipulator (revision 3205)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/TrackerManipulator (revision 3205)
@@ -0,0 +1,138 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGGA_TrackerMANIPULATOR
+#define OSGGA_TrackerMANIPULATOR 1
+
+#include <osgGA/MatrixManipulator>
+#include <osg/Quat>
+
+namespace osgGA{
+
+class OSGGA_EXPORT TrackerManipulator : public MatrixManipulator
+{
+    public:
+
+        TrackerManipulator();
+
+        virtual const char* className() const { return "Tracker"; }
+
+        void setTrackNode(osg::Node* node) { _trackNode = node; }
+        osg::Node* getTrackNode() { return _trackNode.get(); }
+        const osg::Node* getTrackNode() const { return _trackNode.get(); }
+
+
+        enum RotationMode 
+        {
+            ELEVATION_AZIM_ROLL,
+            ELEVATION_AZIM,
+        };
+        
+        void setRotationMode(RotationMode mode);
+        RotationMode getRotationMode() const { return _rotationMode; }
+
+
+        /** set the position of the matrix manipulator using a 4x4 Matrix.*/
+        virtual void setByMatrix(const osg::Matrixd& matrix);
+
+        /** set the position of the matrix manipulator using a 4x4 Matrix.*/
+        virtual void setByInverseMatrix(const osg::Matrixd& matrix) { setByMatrix(osg::Matrixd::inverse(matrix)); }
+
+        /** get the position of the manipulator as 4x4 Matrix.*/
+        virtual osg::Matrixd getMatrix() const;
+
+        /** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/
+        virtual osg::Matrixd getInverseMatrix() const;
+
+        /** Get the FusionDistanceMode. Used by SceneView for setting up setereo convergence.*/
+        virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const { return osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE; }
+
+        /** Get the FusionDistanceValue. Used by SceneView for setting up setereo convergence.*/
+        virtual float getFusionDistanceValue() const { return _distance; }
+
+        /** Attach a node to the manipulator. 
+            Automatically detaches previously attached node.
+            setNode(NULL) detaches previously nodes.
+            Is ignored by manipulators which do not require a reference model.*/
+        virtual void setNode(osg::Node*);
+
+        /** Return node if attached.*/
+        virtual const osg::Node* getNode() const;
+
+        /** Return node if attached.*/
+        virtual osg::Node* getNode();
+
+        /** Move the camera to the default position. 
+            May be ignored by manipulators if home functionality is not appropriate.*/
+        virtual void home(const GUIEventAdapter& ea,GUIActionAdapter& us);
+        
+        /** Start/restart the manipulator.*/
+        virtual void init(const GUIEventAdapter& ea,GUIActionAdapter& us);
+
+        /** handle events, return true if handled, false otherwise.*/
+        virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
+
+        /** Get the keyboard and mouse usage of this manipulator.*/
+        virtual void getUsage(osg::ApplicationUsage& usage) const;
+
+    protected:
+
+        virtual ~TrackerManipulator();
+
+        /** Reset the internal GUIEvent stack.*/
+        void flushMouseEventStack();
+        /** Add the current mouse GUIEvent to internal stack.*/
+        void addMouseEvent(const GUIEventAdapter& ea);
+
+        osg::Vec3d computeCenter() const;
+
+        void computePosition(const osg::Vec3d& eye,const osg::Vec3d& lv,const osg::Vec3d& up);
+
+        /** For the give mouse movement calculate the movement of the camera.
+            Return true is camera has moved and a redraw is required.*/
+        bool calcMovement();
+        
+        void trackball(osg::Vec3& axis,double& angle, double p1x, double p1y, double p2x, double p2y);
+        double tb_project_to_sphere(double r, double x, double y);
+
+
+        /** Check the speed at which the mouse is moving.
+            If speed is below a threshold then return false, otherwise return true.*/
+        bool isMouseMoving();
+
+
+        void clampOrientation();
+
+
+        // Internal event stack comprising last three mouse events.
+        osg::ref_ptr<const GUIEventAdapter> _ga_t1;
+        osg::ref_ptr<const GUIEventAdapter> _ga_t0;
+
+        osg::ref_ptr<osg::Node> _node;
+        osg::ref_ptr<osg::Node> _trackNode;
+
+        RotationMode            _rotationMode;
+
+        bool                    _thrown;
+        
+        osg::Vec3d              _center;
+        osg::Quat               _rotation;
+        float                   _distance;
+        osg::Vec3d              _previousUp;
+
+};
+
+}
+
+#endif
+
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/AnimationPathManipulator
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/AnimationPathManipulator (revision 2395)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/AnimationPathManipulator (revision 2395)
@@ -0,0 +1,102 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGGA_ANIMATION_PATH_MANIPULATOR
+#define OSGGA_ANIMATION_PATH_MANIPULATOR 1
+
+#include <osg/AnimationPath>
+#include <osg/Notify>
+#include <osgGA/MatrixManipulator>
+
+namespace osgGA{
+
+//
+// The AnimationPathManipulator is a Matrix Manipulator that reads an
+// animation path from a file and plays it back.  The file is expected
+// to be ascii and a succession of lines with 8 floating point values
+// per line.  The succession of values are:
+// time  px py pz ax ay az aw
+// where:
+//    time = elapsed time in seconds from the begining of the animation
+//    px py pz = World position in catesian coordinates
+//    ax ay az aw = Orientation (attitude) defined as a quaternion
+
+class OSGGA_EXPORT AnimationPathManipulator : public MatrixManipulator
+{
+    public:
+    
+	AnimationPathManipulator( osg::AnimationPath* animationPath=0 );
+
+	AnimationPathManipulator( const std::string& filename );
+        
+        virtual const char* className() const { return "AnimationPath"; }
+
+        void setPrintOutTimingInfo(bool printOutTiminInfo) { _printOutTiminInfo=printOutTiminInfo; }
+        bool getPrintOutTimingInfo() const { return _printOutTiminInfo; }
+        
+        /** set the position of the matrix manipulator using a 4x4 Matrix.*/
+        virtual void setByMatrix(const osg::Matrixd& matrix) { _matrix = matrix; }
+
+        /** set the position of the matrix manipulator using a 4x4 Matrix.*/
+        virtual void setByInverseMatrix(const osg::Matrixd& matrix) { _matrix.invert(matrix); }
+
+        /** get the position of the manipulator as 4x4 Matrix.*/
+        virtual osg::Matrixd getMatrix() const { return _matrix; }
+
+        /** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/
+        virtual osg::Matrixd getInverseMatrix() const { return osg::Matrixd::inverse(_matrix); } 
+
+
+        void setAnimationPath( osg::AnimationPath* animationPath ) { _animationPath=animationPath; }
+        
+        osg::AnimationPath* getAnimationPath() { return _animationPath.get(); }
+        
+        const osg::AnimationPath* getAnimationPath() const { return _animationPath.get(); }
+
+	bool valid() const { return _animationPath.valid(); }
+
+        void init(const GUIEventAdapter& ea,GUIActionAdapter& us);
+
+        void home(const GUIEventAdapter& ea,GUIActionAdapter& us);
+
+        virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
+
+        /** Get the keyboard and mouse usage of this manipulator.*/
+        virtual void getUsage(osg::ApplicationUsage& usage) const;
+            
+    protected:
+
+	bool _valid;
+        
+        bool _printOutTiminInfo;
+
+	void handleFrame( double time );
+
+	osg::ref_ptr<osg::AnimationPath> _animationPath;
+        
+        double  _timeOffset;
+        double  _timeScale;
+        double  _pauseTime;
+        bool    _isPaused;
+        
+        double  _realStartOfTimedPeriod;
+        double  _animStartOfTimedPeriod;
+        int     _numOfFramesSinceStartOfTimedPeriod;
+        
+        osg::Matrixd _matrix;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/StateSetManipulator
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/StateSetManipulator (revision 2730)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/StateSetManipulator (revision 2730)
@@ -0,0 +1,69 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGGA_GEOSTATE_MANIPULATOR
+#define OSGGA_GEOSTATE_MANIPULATOR 1
+
+#include <osgGA/Export>
+#include <osgGA/GUIEventAdapter>
+#include <osgGA/GUIActionAdapter>
+#include <osgGA/GUIEventHandler>
+
+#include <osg/StateSet>
+
+namespace osgGA{
+
+/**
+Experimental class, not been looked at for a while, but which will
+be returned to at some point :-\
+*/
+class OSGGA_EXPORT StateSetManipulator : public GUIEventHandler
+{
+public:
+
+        StateSetManipulator();
+        virtual ~StateSetManipulator();
+
+        virtual const char* className() const { return "StateSetManipulator"; }
+
+        /** attach a geostate to the manipulator to be used for specifying view.*/
+        virtual void setStateSet(osg::StateSet*);
+
+        /** get the attached a geostate.*/
+        virtual osg::StateSet * getStateSet();
+
+        /** get the attached a geostate.*/
+        virtual const osg::StateSet * getStateSet() const;
+
+        /** Handle events, return true if handled, false otherwise.*/
+        virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);        
+
+        /** Handle visitations */
+        virtual void accept(GUIEventHandlerVisitor&);
+
+        /** Get the keyboard and mouse usage of this manipulator.*/
+        virtual void getUsage(osg::ApplicationUsage& usage) const;
+
+protected:
+
+        // Reference pointer to a geostate
+        osg::ref_ptr<osg::StateSet> _drawState;
+
+        bool _backface;
+        bool _lighting;
+        bool _texture;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/KeySwitchMatrixManipulator
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/KeySwitchMatrixManipulator (revision 3147)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/KeySwitchMatrixManipulator (revision 3147)
@@ -0,0 +1,136 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_KEYSWITCMATRIXMANIPULATOR
+#define OSGUTIL_KEYSWITCMATRIXMANIPULATOR 1
+
+#include <osgGA/Export>
+#include <osgGA/MatrixManipulator>
+#include <osgGA/GUIEventHandler>
+#include <osgGA/GUIEventHandlerVisitor>
+
+namespace osgGA{
+
+class GUIEventAdapter;
+class GUIActionAdapter;
+
+/**
+KeySwitchMatrixManipulator is a decorator which allows the type of camera manipulator
+being used to be switched by pressing a key. E.g. '1' for a TrackballManipultor,
+'2' for a DriveManipulator, '3' for a FlightManipulator. The manipulators available,
+and the associated switch keys, can be configured.
+*/
+class OSGGA_EXPORT KeySwitchMatrixManipulator : public MatrixManipulator
+{
+public:
+
+        typedef std::pair<std::string, osg::ref_ptr<MatrixManipulator> > NamedManipulator;
+        typedef std::map<int, NamedManipulator> KeyManipMap;
+
+        virtual const char* className() const { return "KeySwitchMatrixManipulator"; }
+
+        /**
+        Add a camera manipulator with an associated name, and a key to
+        trigger the switch,
+        */
+        void addMatrixManipulator(int key, std::string name, MatrixManipulator *cm);
+
+	/**
+	Add a camera manipulator with an autogenerated keybinding which is '1' + previous number of camera's registerd.
+	*/
+        void addNumberedMatrixManipulator(MatrixManipulator *cm);
+
+        unsigned int getNumMatrixManipulators() const { return _manips.size(); }
+
+        void selectMatrixManipulator(unsigned int num);
+
+        /** Get the complete list of manipulators attached to this keyswitch manipulator.*/
+        KeyManipMap& getKeyManipMap() { return _manips; }
+
+        /** Get the const complete list of manipulators attached to this keyswitch manipulator.*/
+        const KeyManipMap& getKeyManipMap() const { return _manips; }
+ 
+
+        /** Get the current active manipulators.*/
+        MatrixManipulator* getCurrentMatrixManipulator() { return _current.get(); }
+
+        /** Get the const current active manipulators.*/
+        const MatrixManipulator* getCurrentMatrixManipulator() const { return _current.get(); }
+
+
+        /** Get manipulator assigned to a specified key.*/
+        MatrixManipulator* getMatrixManipulator(unsigned int key);
+
+        /** Get const manipulator assigned to a specified key.*/
+        const MatrixManipulator* getMatrixManipulator(unsigned int key) const;
+
+
+        // Overrides from MatrixManipulator...
+
+        /** set the minimum distance (as ratio) the eye point can be zoomed in towards the
+            center before the center is pushed forward.*/        
+        virtual void setMinimumDistance(float minimumDistance);
+
+        /** set the coordinate frame which callback tells the manipulator which way is up, east and north.*/
+        virtual void setCoordinateFrameCallback(CoordinateFrameCallback* cb);
+
+        /** Set the position of the matrix manipulator using a 4x4 Matrix.*/
+        virtual void setByMatrix(const osg::Matrixd& matrix) { _current->setByMatrix(matrix); }
+
+        /** set the position of the matrix manipulator using a 4x4 Matrix.*/
+        virtual void setByInverseMatrix(const osg::Matrixd& matrix) { _current->setByInverseMatrix(matrix); }
+
+        /** get the position of the manipulator as 4x4 Matrix.*/
+        virtual osg::Matrixd getMatrix() const { return _current->getMatrix(); }
+
+        /** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/
+        virtual osg::Matrixd getInverseMatrix() const { return _current->getInverseMatrix(); }
+
+        /** Get the FusionDistanceMode. Used by SceneView for setting up setereo convergence.*/
+        virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const { return _current->getFusionDistanceMode(); }
+
+        /** Get the FusionDistanceValue. Used by SceneView for setting up setereo convergence.*/
+        virtual float getFusionDistanceValue() const { return _current->getFusionDistanceValue(); }
+
+
+        virtual void setNode(osg::Node* n);
+
+        virtual const osg::Node* getNode() const        { return _current->getNode(); }
+
+        virtual osg::Node* getNode()                    { return _current->getNode(); }
+
+        virtual void setHomePosition(const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up);
+
+        virtual void setAutoComputeHomePosition(bool flag);
+
+        virtual void computeHomePosition();
+
+        virtual void home(const GUIEventAdapter& ee,GUIActionAdapter& aa) { _current->home(ee,aa); }
+
+        virtual void init(const GUIEventAdapter& ee,GUIActionAdapter& aa) { _current->init(ee,aa); }
+
+        virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
+
+        /** Get the keyboard and mouse usage of this manipulator.*/
+        virtual void getUsage(osg::ApplicationUsage& usage) const;
+
+private:
+
+        KeyManipMap _manips;
+
+        osg::ref_ptr<MatrixManipulator> _current;
+};
+
+};
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/TrackballManipulator
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/TrackballManipulator (revision 3008)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgGA/TrackballManipulator (revision 3008)
@@ -0,0 +1,123 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGGA_TRACKBALLMANIPULATOR
+#define OSGGA_TRACKBALLMANIPULATOR 1
+
+#include <osgGA/MatrixManipulator>
+#include <osg/Quat>
+
+namespace osgGA{
+
+class OSGGA_EXPORT TrackballManipulator : public MatrixManipulator
+{
+    public:
+
+        TrackballManipulator();
+
+        virtual const char* className() const { return "Trackball"; }
+
+        /** set the minimum distance (as ratio) the eye point can be zoomed in towards the
+            center before the center is pushed forward.*/        
+        void setMinimumZoomScale(float minimumZoomScale) { _minimumZoomScale=minimumZoomScale; }
+
+        /** get the minimum distance (as ratio) the eye point can be zoomed in */
+        float getMinimumZoomScale() const { return _minimumZoomScale; }
+
+        /** set the position of the matrix manipulator using a 4x4 Matrix.*/
+        virtual void setByMatrix(const osg::Matrixd& matrix);
+
+        /** set the position of the matrix manipulator using a 4x4 Matrix.*/
+        virtual void setByInverseMatrix(const osg::Matrixd& matrix) { setByMatrix(osg::Matrixd::inverse(matrix)); }
+
+        /** get the position of the manipulator as 4x4 Matrix.*/
+        virtual osg::Matrixd getMatrix() const;
+
+        /** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/
+        virtual osg::Matrixd getInverseMatrix() const;
+
+        /** Get the FusionDistanceMode. Used by SceneView for setting up setereo convergence.*/
+        virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const { return osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE; }
+
+        /** Get the FusionDistanceValue. Used by SceneView for setting up setereo convergence.*/
+        virtual float getFusionDistanceValue() const { return _distance; }
+
+        /** Attach a node to the manipulator. 
+            Automatically detaches previously attached node.
+            setNode(NULL) detaches previously nodes.
+            Is ignored by manipulators which do not require a reference model.*/
+        virtual void setNode(osg::Node*);
+
+        /** Return node if attached.*/
+        virtual const osg::Node* getNode() const;
+
+        /** Return node if attached.*/
+        virtual osg::Node* getNode();
+
+        /** Move the camera to the default position. 
+            May be ignored by manipulators if home functionality is not appropriate.*/
+        virtual void home(const GUIEventAdapter& ea,GUIActionAdapter& us);
+        
+        /** Start/restart the manipulator.*/
+        virtual void init(const GUIEventAdapter& ea,GUIActionAdapter& us);
+
+        /** handle events, return true if handled, false otherwise.*/
+        virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
+
+        /** Get the keyboard and mouse usage of this manipulator.*/
+        virtual void getUsage(osg::ApplicationUsage& usage) const;
+
+    protected:
+
+        virtual ~TrackballManipulator();
+
+        /** Reset the internal GUIEvent stack.*/
+        void flushMouseEventStack();
+        /** Add the current mouse GUIEvent to internal stack.*/
+        void addMouseEvent(const GUIEventAdapter& ea);
+
+        void computePosition(const osg::Vec3& eye,const osg::Vec3& lv,const osg::Vec3& up);
+
+        /** For the give mouse movement calculate the movement of the camera.
+            Return true is camera has moved and a redraw is required.*/
+        bool calcMovement();
+        
+        void trackball(osg::Vec3& axis,float& angle, float p1x, float p1y, float p2x, float p2y);
+        float tb_project_to_sphere(float r, float x, float y);
+
+
+        /** Check the speed at which the mouse is moving.
+            If speed is below a threshold then return false, otherwise return true.*/
+        bool isMouseMoving();
+
+        // Internal event stack comprising last three mouse events.
+        osg::ref_ptr<const GUIEventAdapter> _ga_t1;
+        osg::ref_ptr<const GUIEventAdapter> _ga_t0;
+
+        osg::ref_ptr<osg::Node>       _node;
+
+        double _modelScale;
+        double _minimumZoomScale;
+
+        bool _thrown;
+        
+        osg::Vec3d   _center;
+        osg::Quat    _rotation;
+        double       _distance;
+
+};
+
+}
+
+#endif
+
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/Sector
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/Sector (revision 2975)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/Sector (revision 2975)
@@ -0,0 +1,319 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGSIM_SECTOR
+#define OSGSIM_SECTOR 1
+
+#include <osgSim/Export>
+
+#include <osg/Quat>
+#include <osg/Vec3>
+#include <osg/Vec4>
+#include <osg/Matrix>
+#include <osg/Math>
+#include <osg/Object>
+
+namespace osgSim {
+
+class Sector : public osg::Object
+{
+    public:
+    
+        Sector() {}
+        
+        Sector(const Sector& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY):
+            osg::Object(copy,copyop) {}
+
+        virtual const char *libraryName() const { return "osgSim"; }
+        virtual const char *className() const { return "Sector"; }
+        virtual bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast<const Sector *>(obj) != 0; }
+    
+        virtual float operator() (const osg::Vec3& /*eyeLocal*/) const = 0;
+
+    protected:
+
+        virtual ~Sector() {}
+};
+
+class OSGSIM_EXPORT AzimRange
+{
+    public:
+
+       AzimRange():
+            _cosAzim(1.0f),
+            _sinAzim(0.0f),
+            _cosAngle(-1.0f),
+            _cosFadeAngle(-1.0f) {}
+            
+        void setAzimuthRange(float minAzimuth,float maxAzimuth,float fadeAngle=0.0f);
+        void getAzimuthRange(float& minAzimuth, float& maxAzimuth, float& fadeAngle) const;
+
+
+        inline float azimSector(const osg::Vec3& eyeLocal) const
+        {
+            float dotproduct = eyeLocal.x()*_sinAzim+eyeLocal.y()*_cosAzim;
+            float length = sqrt(osg::square(eyeLocal.x())+osg::square(eyeLocal.y()));
+            if (dotproduct<_cosFadeAngle*length) return 0.0f; // out of sector.
+            if (dotproduct>=_cosAngle*length) return 1.0f; // fully in sector.
+            return (dotproduct-_cosFadeAngle*length)/((_cosAngle-_cosFadeAngle)*length);
+        }
+
+    protected:
+
+        float _cosAzim;
+        float _sinAzim;
+        float _cosAngle;
+        float _cosFadeAngle;
+};
+
+
+class OSGSIM_EXPORT ElevationRange
+{
+    public:
+    
+    
+        ElevationRange():
+            _cosMinElevation(-1.0f),
+            _cosMinFadeElevation(-1.0f),
+            _cosMaxElevation(1.0),
+            _cosMaxFadeElevation(1.0) {}
+            
+        void setElevationRange(float minElevation,float maxElevation,float fadeAngle=0.0f);
+        
+        float getMinElevation() const;
+
+        float getMaxElevation() const;
+
+        float getFadeAngle() const;
+
+        inline float elevationSector(const osg::Vec3& eyeLocal) const
+        {
+            float dotproduct = eyeLocal.z(); // against z axis - eyeLocal*(0,0,1).
+            float length = eyeLocal.length();
+            if (dotproduct>_cosMaxFadeElevation*length) return 0.0f; // out of sector
+            if (dotproduct<_cosMinFadeElevation*length) return 0.0f; // out of sector
+            if (dotproduct>_cosMaxElevation*length)
+            {
+                // in uppoer fade band.
+                return (dotproduct-_cosMaxFadeElevation*length)/((_cosMaxElevation-_cosMaxFadeElevation)*length);
+            }
+            if (dotproduct<_cosMinElevation*length)
+            {
+                // in lower fade band.
+                return (dotproduct-_cosMinFadeElevation*length)/((_cosMinElevation-_cosMinFadeElevation)*length);
+            }
+            return 1.0f; // fully in sector
+        }
+        
+    protected:
+
+        float _cosMinElevation;
+        float _cosMinFadeElevation;
+        float _cosMaxElevation;
+        float _cosMaxFadeElevation;
+};
+
+class OSGSIM_EXPORT AzimSector : public Sector, public AzimRange
+{
+    public:
+    
+        AzimSector():
+            Sector(),
+            AzimRange() {}
+    
+        AzimSector(const AzimSector& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY):
+            Sector(copy,copyop),
+            AzimRange(copy) {}
+
+        AzimSector(float minAzimuth,float maxAzimuth,float fadeAngle=0.0f);
+
+        META_Object(osgSim,AzimSector)
+
+        virtual float operator() (const osg::Vec3& eyeLocal) const;
+
+    protected:
+
+        virtual ~AzimSector() {}
+
+};
+
+class OSGSIM_EXPORT ElevationSector : public Sector, public ElevationRange
+{
+    public:
+    
+    
+        ElevationSector():
+            Sector(),
+            ElevationRange() {}
+            
+        ElevationSector(const ElevationSector& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY):
+            Sector(copy,copyop),
+            ElevationRange(copy) {}
+            
+        ElevationSector(float minElevation,float maxElevation,float fadeAngle=0.0f);
+    
+        META_Object(osgSim,ElevationSector)
+
+        virtual float operator() (const osg::Vec3& eyeLocal) const;
+        
+    protected:
+
+        virtual ~ElevationSector() {}
+
+        float _cosMinElevation;
+        float _cosMinFadeElevation;
+        float _cosMaxElevation;
+        float _cosMaxFadeElevation;
+};
+
+
+class OSGSIM_EXPORT AzimElevationSector : public Sector, public AzimRange, public ElevationRange
+{
+    public:
+    
+        AzimElevationSector():
+            Sector(),
+            AzimRange(),
+            ElevationRange() {}
+    
+        AzimElevationSector(const AzimElevationSector& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY):
+            Sector(copy,copyop),
+            AzimRange(copy),
+            ElevationRange(copy) {}
+
+        AzimElevationSector(float minAzimuth,float maxAzimuth,float minElevation,float maxElevation,float fadeAngle=0.0f);
+
+        META_Object(osgSim,AzimElevationSector)
+
+        virtual float operator() (const osg::Vec3& eyeLocal) const;
+
+    protected:
+
+        virtual ~AzimElevationSector() {}
+};
+
+
+class OSGSIM_EXPORT ConeSector : public Sector
+{
+    public:
+    
+        ConeSector():
+            Sector(),
+            _axis(0.0f,0.0f,1.0f),
+            _cosAngle(-1.0f),
+            _cosAngleFade(-1.0f) {}
+
+        ConeSector(const ConeSector& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY):
+            Sector(copy,copyop),
+            _axis(copy._axis),
+            _cosAngle(copy._cosAngle),
+            _cosAngleFade(copy._cosAngleFade) {}
+
+        ConeSector(const osg::Vec3& axis,float angle,float fadeangle=0.0f);
+
+        META_Object(osgSim,ConeSector)
+
+        void setAxis(const osg::Vec3& axis);
+        
+        const osg::Vec3& getAxis() const;
+
+        void setAngle(float angle,float fadeangle=0.0f);
+        
+        float getAngle() const;
+    
+        float getFadeAngle() const;
+
+        virtual float operator() (const osg::Vec3& eyeLocal) const;
+
+    protected:
+
+        virtual ~ConeSector() {}
+    
+        osg::Vec3   _axis;
+        float       _cosAngle;
+        float       _cosAngleFade;
+};
+
+
+/* The DirectionalSector class was created to better handle OpenFlight directional
+  lightpoints.  The Elevation and Azimuth Sectors above impose invalid limits on
+  the elevation range which cause lightpoints whose direction vectors are not
+  on the XY plane to be displayed incorrectly.  Corbin Holtz 4/04 */
+
+class OSGSIM_EXPORT DirectionalSector : public Sector
+{
+    public:
+    
+        DirectionalSector():
+            Sector(),
+            _direction(0.0f, 0.0f, 1.0f),
+            _rollAngle(0.0f),
+            _cosHorizAngle(-1.0f),
+            _cosVertAngle(-1.0f),
+            _cosHorizFadeAngle(-1.0f),
+            _cosVertFadeAngle(-1.0f) {computeMatrix();}
+
+        DirectionalSector(const DirectionalSector& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY):
+            Sector(copy,copyop),
+            _direction(copy._direction),
+            _rollAngle(copy._rollAngle),
+            _local_to_LP(copy._local_to_LP),
+            _cosHorizAngle(copy._cosHorizAngle),
+            _cosVertAngle(copy._cosVertAngle),
+            _cosHorizFadeAngle(copy._cosHorizFadeAngle),
+            _cosVertFadeAngle(copy._cosVertFadeAngle) {}
+
+        DirectionalSector(const osg::Vec3& direction,float horizLobeAngle, float vertLobeAngle, float lobeRollAngle, float fadeAngle=0.0f);
+
+        META_Object(osgSim,DirectionalSector)
+
+        void setDirection(const osg::Vec3& direction);
+        
+        const osg::Vec3& getDirection() const;
+
+        void setHorizLobeAngle(float angle);
+        
+        float getHorizLobeAngle() const;
+    
+        void setLobeRollAngle(float angle);
+        
+        float getLobeRollAngle() const;
+    
+        void setVertLobeAngle(float angle);
+        
+        float getVertLobeAngle() const;
+    
+        void setFadeAngle(float angle);
+            
+        float getFadeAngle() const;
+
+        virtual float operator() (const osg::Vec3& eyeLocal) const;
+
+        void computeMatrix() ;
+
+    protected:
+
+        virtual ~DirectionalSector() {}
+    
+        osg::Vec3   _direction ;
+        float       _rollAngle ;
+        osg::Matrix _local_to_LP ;
+        float       _cosHorizAngle;
+        float       _cosVertAngle;
+        float       _cosHorizFadeAngle;
+        float       _cosVertFadeAngle;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/Export
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/Export (revision 1704)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/Export (revision 1704)
@@ -0,0 +1,46 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGSIM_EXPORT_
+#define OSGSIM_EXPORT_ 1
+
+#if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__))
+    #pragma warning( disable : 4244 )
+    #pragma warning( disable : 4251 )
+    #pragma warning( disable : 4275 )
+    #pragma warning( disable : 4786 )
+    #pragma warning( disable : 4290 )
+    #pragma warning( disable : 4305 )
+#endif
+
+#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__)  || defined( __MWERKS__)
+    #  ifdef OSGSIM_LIBRARY
+    #    define OSGSIM_EXPORT   __declspec(dllexport)
+    #  else
+    #    define OSGSIM_EXPORT   __declspec(dllimport)
+    #  endif /* SG_LIBRARY */
+#else
+    #  define OSGSIM_EXPORT
+#endif  
+
+/* Define NULL pointer value */
+
+#ifndef NULL
+#ifdef  __cplusplus
+#define NULL    0
+#else
+#define NULL    ((void *)0)
+#endif
+#endif
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/GeographicLocation
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/GeographicLocation (revision 2763)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/GeographicLocation (revision 2763)
@@ -0,0 +1,87 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2004 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGSIM_GEOGRAPHICLOCATION
+#define OSGSIM_GEOGRAPHICLOCATION 1
+
+#include <osg/Math>
+#include <osg/Referenced>
+
+#include <ostream>
+
+namespace osgSim {
+
+/** Stores a double precision geographic location, latitude and longitude.
+    Derived from Referenced so it can be used as an osg::Object userData.
+*/
+
+class GeographicLocation : public osg::Referenced
+{
+    public:
+
+        GeographicLocation() { _v[0]=0.; _v[1]=0.; }
+        GeographicLocation( double lat, double lon ) { _v[0]=lat; _v[1]=lon; }
+
+        inline bool operator == ( const GeographicLocation& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1]; }
+        inline bool operator != ( const GeographicLocation& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1]; }
+        inline bool operator < ( const GeographicLocation& v) const
+        {
+            if (_v[0]<v._v[0]) return true;
+            else if (_v[0]>v._v[0]) return false;
+            else if (_v[1]<v._v[1]) return true;
+            else return false;
+        }
+
+        inline double* ptr() { return _v; }
+        inline const double* ptr() const { return _v; }
+
+        inline void set( double lat, double lon ) { _v[0]=lat; _v[1]=lon; }
+
+        inline double& latitude() { return _v[0]; }
+        inline double& longitude() { return _v[1]; }
+
+        inline double latitude() const { return _v[0]; }
+        inline double longitude() const { return _v[1]; }
+
+        inline bool valid() const { return !isNaN(); }
+        inline bool isNaN() const { return osg::isNaN(_v[0]) || osg::isNaN(_v[1]); }
+
+        /// binary vector add
+        inline const GeographicLocation operator+( const GeographicLocation& rhs) const
+        {
+            return GeographicLocation(_v[0]+rhs._v[0], _v[1]+rhs._v[1]);
+        }
+
+        /// binary vector subtract
+        inline const GeographicLocation operator-( const GeographicLocation& rhs) const
+        {
+            return GeographicLocation(_v[0]-rhs._v[0], _v[1]-rhs._v[1]);
+        }
+
+        friend inline std::ostream& operator << (std::ostream& output, const GeographicLocation& loc)
+        {
+            output << loc._v[0] << " " << loc._v[1];
+            return output;  // to enable cascading
+        }
+
+    private:
+        // Note the convention is to store lat in _v[0] and lon in _v[1].
+        // This is contrary to typical X-Y convention. Who decided lat should come
+        //   before lon anyway? I'd like a word with him...
+        double _v[2];
+
+};  // end of class GeographicLocation
+
+}   // end of namespace osgSim
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/LightPoint
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/LightPoint (revision 2215)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/LightPoint (revision 2215)
@@ -0,0 +1,72 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGSIM_LIGHTPOINT
+#define OSGSIM_LIGHTPOINT 1
+
+#include <osgSim/Export>
+#include <osgSim/Sector>
+#include <osgSim/BlinkSequence>
+
+#include <osg/Quat>
+#include <osg/Vec3>
+#include <osg/Vec4>
+
+namespace osgSim {
+
+
+class OSGSIM_EXPORT LightPoint
+{
+    public:
+
+        enum BlendingMode
+        {
+            ADDITIVE,
+            BLENDED
+        };
+        
+        LightPoint();
+        
+        LightPoint(const osg::Vec3& position,
+                   const osg::Vec4& color);
+       
+        LightPoint(bool                on,
+                   const osg::Vec3& position,
+                   const osg::Vec4& color,
+                   float            intensity=1.0f,
+                   float            radius=1.0f,
+                   Sector*          sector=0,
+                   BlinkSequence*   blinkSequence=0,
+                   BlendingMode     blendingMode=BLENDED);
+            
+
+        LightPoint(const LightPoint& lp);
+        
+        LightPoint& operator = (const LightPoint& lp);
+
+
+        bool                        _on;
+        osg::Vec3                   _position;
+        osg::Vec4                   _color;
+        float                       _intensity;
+        float                       _radius;
+
+        osg::ref_ptr<Sector>        _sector;
+        osg::ref_ptr<BlinkSequence> _blinkSequence;
+
+        BlendingMode                _blendingMode;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/DOFTransform
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/DOFTransform (revision 2764)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/DOFTransform (revision 2764)
@@ -0,0 +1,159 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGSIM_DOFTRANSFORM
+#define OSGSIM_DOFTRANSFORM 1
+
+//base class:
+#include <osg/Transform>
+
+#include <osgSim/Export>
+
+namespace osgSim {
+
+/** DOFTransform - encapsulates Multigen DOF behavior*/
+class OSGSIM_EXPORT DOFTransform : public osg::Transform
+{
+    public:
+        /** constructor*/
+        DOFTransform();
+
+        /**copy constructor*/
+        DOFTransform(const DOFTransform& dof, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
+
+        META_Node(osgSim, DOFTransform);
+
+        virtual void traverse(osg::NodeVisitor& nv);
+
+        void setMinHPR(const osg::Vec3& hpr) { _minHPR = hpr;}
+        const osg::Vec3& getMinHPR() const { return _minHPR;}
+
+        void setMaxHPR(const osg::Vec3& hpr) {_maxHPR = hpr;}
+        const osg::Vec3& getMaxHPR() const { return _maxHPR;}
+
+        void setIncrementHPR(const osg::Vec3& hpr) {_incrementHPR = hpr;}
+        const osg::Vec3& getIncrementHPR() const { return _incrementHPR;}
+
+        void setCurrentHPR(const osg::Vec3& hpr) {_currentHPR = hpr;}
+        const osg::Vec3& getCurrentHPR() const {return _currentHPR;}
+
+        void updateCurrentHPR(const osg::Vec3& hpr);
+        
+
+        void setMinTranslate(const osg::Vec3& translate) {_minTranslate = translate;}
+        const osg::Vec3& getMinTranslate() const { return _minTranslate;}
+        
+        void setMaxTranslate(const osg::Vec3& translate) {_maxTranslate = translate;}
+        const osg::Vec3& getMaxTranslate() const { return _maxTranslate;}
+        
+        void setIncrementTranslate(const osg::Vec3& translate) { _incrementTranslate = translate;}
+        const osg::Vec3& getIncrementTranslate() const { return _incrementTranslate;}
+
+        void setCurrentTranslate(const osg::Vec3& translate){ _currentTranslate = translate;}
+        inline const osg::Vec3& getCurrentTranslate() const { return _currentTranslate;}
+
+        void updateCurrentTranslate(const osg::Vec3& translate);
+
+
+        void setMinScale(const osg::Vec3& scale) { _minScale = scale;}
+        const osg::Vec3& getMinScale() const { return _minScale;}
+
+        void setMaxScale(const osg::Vec3& scale) { _maxScale = scale;}
+        const osg::Vec3& getMaxScale() const { return _maxScale;}
+
+        void setIncrementScale(const osg::Vec3& scale) { _incrementScale = scale;}
+        const osg::Vec3& getIncrementScale() const { return _incrementScale;}
+
+        void setCurrentScale(const osg::Vec3& scale) { _currentScale = scale;}
+        inline const osg::Vec3& getCurrentScale() const { return _currentScale;}
+
+        void updateCurrentScale(const osg::Vec3& scale);
+
+
+        void setPutMatrix(const osg::Matrix& put) { _Put = put;}
+        inline const osg::Matrix& getPutMatrix() const {return _Put;}
+
+        void setInversePutMatrix(const osg::Matrix& inversePut) { _inversePut = inversePut;}
+        inline const osg::Matrix& getInversePutMatrix() const {return _inversePut;}
+
+        void setLimitationFlags(unsigned long flags) { _limitationFlags = flags;}
+        inline unsigned long getLimitationFlags() const {return _limitationFlags;}
+
+
+        inline void setAnimationOn(bool do_animate) {_animationOn = do_animate;}
+        inline bool getAnimationOn() const {return _animationOn;}
+
+        void animate(float deltaTime);
+
+        virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const;
+
+        virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const;
+
+    protected:
+
+        virtual ~DOFTransform() {}
+
+        int       _previousTraversalNumber;
+        double    _previousTime;
+
+        osg::Vec3 _minHPR;
+        osg::Vec3 _maxHPR;
+        osg::Vec3 _currentHPR;
+        osg::Vec3 _incrementHPR;
+
+        osg::Vec3 _minTranslate;
+        osg::Vec3 _maxTranslate;
+        osg::Vec3 _currentTranslate;
+        osg::Vec3 _incrementTranslate;
+
+        osg::Vec3 _minScale;
+        osg::Vec3 _maxScale;
+        osg::Vec3 _currentScale;
+        osg::Vec3 _incrementScale;
+
+        osg::Matrix _Put;
+        osg::Matrix _inversePut;
+
+        unsigned long _limitationFlags;
+        /* bits from left to right
+        0 = x translation limited (2^31)
+        1 = y translation limited (2^30)
+        2 = z translation limited (2^29)
+        3 = pitch limited (2^28)
+        4 = roll limited (2^27)
+        5 = yaw limited (2^26)
+        6 = x scale limited (2^25)
+        7 = y scale limited (2^24)
+        8 = z scale limited (2^23)
+
+        else reserved
+        */
+
+        bool _animationOn;
+        /** flags indicating whether value is incerasing or decreasing in animation
+        bits form right to left, 1 means increasing while 0 is decreasing
+        0 = x translation
+        1 = y translation
+        2 = z translation
+        3 = pitch
+        4 = roll
+        5 = yaw
+        6 = x scale
+        7 = y scale
+        8 = z scale
+        */
+        unsigned short _increasingFlags;
+};
+
+}
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/VisibilityGroup
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/VisibilityGroup (revision 2479)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/VisibilityGroup (revision 2479)
@@ -0,0 +1,58 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGSIM_VISIBILITYGROUP
+#define OSGSIM_VISIBILITYGROUP 1
+
+#include <osg/Node>
+#include <osg/Group>
+#include <osg/NodeVisitor>
+
+#include <osgSim/Export>
+
+namespace osgSim {
+
+class OSGSIM_EXPORT VisibilityGroup : public osg::Group
+{
+    public :
+    
+        VisibilityGroup();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        VisibilityGroup(const VisibilityGroup&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
+
+        META_Node(osgSim, VisibilityGroup)
+
+        virtual void traverse(osg::NodeVisitor& nv);
+        
+        void setVisibilityVolume(osg::Node* node) { _visibilityVolume = node; }
+        osg::Node* getVisibilityVolume() { return _visibilityVolume.get(); }
+        const osg::Node* getVisibilityVolume() const { return _visibilityVolume.get(); }
+        
+        void setVolumeIntersectionMask(osg::Node::NodeMask mask) { _volumeIntersectionMask = mask; }
+        osg::Node::NodeMask getVolumeIntersectionMask() const { return _volumeIntersectionMask; }
+        
+        void setSegmentLength(float length) { _segmentLength = length; }
+        float getSegmentLength() const { return _segmentLength; }
+        
+    protected :
+    
+        virtual ~VisibilityGroup() {}
+
+        osg::ref_ptr<osg::Node> _visibilityVolume;
+        osg::Node::NodeMask _volumeIntersectionMask;
+        float _segmentLength;
+};
+
+}
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/Version
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/Version (revision 1529)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/Version (revision 1529)
@@ -0,0 +1,46 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGSIM_VERSION
+#define OSGSIM_VERSION 1
+
+#include <osgSim/Export>
+
+extern "C" {
+
+/**
+ * osgSimGetVersion() returns the library version number.
+ * Numbering convention : OpenSceneGraph-Sim-0.1 will return 0.1 from osgSimgetVersion.
+ *
+ * This C function can be also used to check for the existence of the OpenSceneGraph
+ * library using autoconf and its m4 macro AC_CHECK_LIB.
+ *
+ * Here is the code to add to your configure.in:
+ \verbatim
+ #
+ # Check for the OpenSceneGraph-Sim library
+ #
+ AC_CHECK_LIB(osg, osgSimGetVersion, ,
+    [AC_MSG_ERROR(OpenSceneGraph library not found. See http://www.openscenegraph.org)],)
+ \endverbatim
+*/
+extern OSGSIM_EXPORT const char* osgSimGetVersion();
+
+/**
+ * osgSimGetLibraryName() returns the library name in human friendly form.
+*/
+extern OSGSIM_EXPORT const char* osgSimGetLibraryName();
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/LightPointSystem
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/LightPointSystem (revision 2875)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/LightPointSystem (revision 2875)
@@ -0,0 +1,63 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2004 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGSIM_LIGHTPOINTSYSTEM
+#define OSGSIM_LIGHTPOINTSYSTEM 1
+
+#include <osg/Object>
+
+
+namespace osgSim {
+
+
+/*
+ * LightPointSYSTEM encapsulates animation and intensity state in a single object
+ *   that can be shared by several osgSim::LightPointNodes, thereby allowing an
+ *   application to efficiently control the animation/intensity state of
+ *   several LightPointNodes.
+ */
+class LightPointSystem : public osg::Object
+{
+    public :
+        LightPointSystem() : _intensity( 1.f ), _animationState( ANIMATION_ON )
+            { }
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        LightPointSystem( const LightPointSystem& lps, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY ) :
+            osg::Object( lps, copyop ), _intensity( lps._intensity ), _animationState( lps._animationState )
+            { }
+
+        META_Object( osgSim, LightPointSystem )
+        
+        typedef enum {
+            ANIMATION_ON,
+            ANIMATION_OFF,
+            ANIMATION_RANDOM
+        } AnimationState;
+
+        void setIntensity( float intensity ) { _intensity = intensity; }
+        float getIntensity() const { return _intensity; }
+
+        void setAnimationState( LightPointSystem::AnimationState state ) { _animationState = state; }
+        LightPointSystem::AnimationState getAnimationState() const { return _animationState; }
+
+    protected:
+        ~LightPointSystem() {}
+
+        float _intensity;
+        AnimationState _animationState;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/LightPointNode
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/LightPointNode (revision 2875)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/LightPointNode (revision 2875)
@@ -0,0 +1,107 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGSIM_LIGHTPOINTNODE
+#define OSGSIM_LIGHTPOINTNODE 1
+
+#include <osgSim/Export>
+#include <osgSim/LightPoint>
+#include <osgSim/LightPointSystem>
+
+#include <osg/Node>
+#include <osg/NodeVisitor>
+#include <osg/BoundingBox>
+#include <osg/Quat>
+#include <osg/Vec4>
+
+#include <vector>
+#include <set>
+
+namespace osgSim {
+
+
+class OSGSIM_EXPORT LightPointNode : public osg::Node
+{
+    public :
+
+        typedef std::vector< LightPoint > LightPointList;
+
+        LightPointNode();
+        
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        LightPointNode(const LightPointNode&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
+
+        META_Node(osgSim,LightPointNode);
+
+        virtual void traverse(osg::NodeVisitor& nv);
+
+
+        unsigned int getNumLightPoints() const { return _lightPointList.size(); }
+
+
+        unsigned int addLightPoint(const LightPoint& lp);
+    
+        void removeLightPoint(unsigned int pos);
+
+
+        LightPoint& getLightPoint(unsigned int pos) { return _lightPointList[pos]; }
+
+        const LightPoint& getLightPoint(unsigned int pos) const { return _lightPointList[pos]; }
+        
+
+        void setLightPointList(const LightPointList& lpl) { _lightPointList=lpl; }
+
+        LightPointList& getLightPointList() { return _lightPointList; }
+
+        const LightPointList& getLightPointList() const { return _lightPointList; }
+
+
+        void setMinPixelSize(float minPixelSize) { _minPixelSize = minPixelSize; }
+        
+        float getMinPixelSize() const { return _minPixelSize; }
+
+        void setMaxPixelSize(float maxPixelSize) { _maxPixelSize = maxPixelSize; }
+        
+        float getMaxPixelSize() const { return _maxPixelSize; }
+
+        void setMaxVisibleDistance2(float maxVisibleDistance2) { _maxVisibleDistance2 = maxVisibleDistance2; }
+        
+        float getMaxVisibleDistance2() const { return _maxVisibleDistance2; }
+        
+        void setLightPointSystem( osgSim::LightPointSystem* lps) { _lightSystem = lps; }
+
+        osgSim::LightPointSystem* getLightPointSystem() { return _lightSystem.get(); }
+
+    protected:
+
+        ~LightPointNode() {}
+
+        // used to cache the bouding box of the lightpoints as a tighter
+        // view frustum check. 
+        mutable osg::BoundingBox _bbox;
+
+        virtual bool computeBound() const;
+
+        LightPointList  _lightPointList;
+
+        float _minPixelSize;
+        float _maxPixelSize;
+        float _maxVisibleDistance2;
+
+        osg::ref_ptr<osgSim::LightPointSystem> _lightSystem;        
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/BlinkSequence
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/BlinkSequence (revision 2727)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/BlinkSequence (revision 2727)
@@ -0,0 +1,171 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGSIM_BLINKSQUENCE
+#define OSGSIM_BLINKSQUENCE 1
+
+#include <osgSim/Export>
+
+#include <osg/Quat>
+#include <osg/Vec3>
+#include <osg/Vec4>
+#include <osg/Object>
+#include <osg/ref_ptr>
+
+#include <vector>
+
+namespace osgSim {
+
+/** sequence group which can be used to synchronize related blink sequences.*/
+class OSGSIM_EXPORT SequenceGroup : public osg::Object
+{
+    public:
+
+       SequenceGroup();
+       SequenceGroup(const SequenceGroup& bs, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
+       SequenceGroup(double baseTime);
+
+       META_Object(osgSim,SequenceGroup);
+
+       double      _baseTime;
+};
+
+class OSGSIM_EXPORT BlinkSequence : public osg::Object
+{
+    public:
+
+        BlinkSequence();
+
+        BlinkSequence(const BlinkSequence& bs, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
+
+        META_Object(osgSim,BlinkSequence);
+
+        /** add a pulse of specified color and duration to the BlinkSequence.*/
+        inline void addPulse(double length,const osg::Vec4& color);
+
+        /** return the number of pulses. */
+        inline int getNumPulses() const { return _pulseData.size(); }
+
+        /** return the pulse data at position i. */
+        inline void getPulse(unsigned int i, double& length,osg::Vec4& color) const;
+
+        /** get the total pulse period of the blink sequence, which is equal to the sum of all the pulse periods.*/
+        inline double getPulsePeriod() const { return _pulsePeriod; }
+
+        /** set the sequence group which can be used to synchronize related blink sequences.*/
+        inline void setSequenceGroup(SequenceGroup* sg) { _sequenceGroup = sg; }
+
+        /** get the non const sequence group.*/
+        inline SequenceGroup* getSequenceGroup() { return _sequenceGroup.get(); }
+
+        /** get the const sequence group.*/
+        inline const SequenceGroup* getSequenceGroup() const { return _sequenceGroup.get(); }
+
+        /** set the phase shift of the blink sequence, this would be used to shift a sequence within a sequence group.*/
+        inline void setPhaseShift(double ps) { _phaseShift = ps; }
+
+        /** get the pahse shift.*/        
+        inline double getPhaseShift() const { return _phaseShift; }
+
+        /** compute the local time clamped to this BlinkSequences period, and accounting for the phase shift and sequence group.*/
+        inline double localTime(double time) const;
+
+        /** compute the color for the time interval sepecifed. Averages the colors if the length is greater than the current pulse.*/
+        inline osg::Vec4 color(double time,double length) const;
+        
+
+    protected:
+
+
+        typedef std::pair<double,osg::Vec4> IntervalColor;
+        typedef std::vector<IntervalColor>  PulseData;
+        
+        double                      _pulsePeriod;
+        double                      _phaseShift;
+        PulseData                   _pulseData;
+        osg::ref_ptr<SequenceGroup> _sequenceGroup;
+};
+
+
+inline double BlinkSequence::localTime(double time) const
+{
+    if (_sequenceGroup.valid()) time -= _sequenceGroup->_baseTime;
+    time -= _phaseShift;
+    return time - floor(time/_pulsePeriod)*_pulsePeriod;
+}
+
+inline void BlinkSequence::addPulse(double length,const osg::Vec4& color)
+{
+    _pulseData.push_back(IntervalColor(length,color));
+    _pulsePeriod += length;
+}
+
+inline void BlinkSequence::getPulse(unsigned int i, double& length, osg::Vec4& color) const
+{
+    const IntervalColor& ic = _pulseData[i];
+    length = ic.first;
+    color = ic.second;
+}
+
+inline osg::Vec4 BlinkSequence::color(double time,double length) const
+{
+    if (_pulseData.empty()) return osg::Vec4(1.0f,1.0f,1.0f,1.0f);
+    double lt = localTime(time);
+    PulseData::const_iterator itr = _pulseData.begin();
+
+    // find the first sample at this time point.
+    while (lt>itr->first)
+    {
+        lt -= itr->first;
+        ++itr;
+        if (itr==_pulseData.end()) itr = _pulseData.begin();
+    }
+
+    // if time interval fits inside the current pulse 
+    // then simply return this pulses color value.
+    if (lt+length<=itr->first)
+    {
+        return itr->second;
+    }
+
+    // time length exceeds the current pulse therefore
+    // we have to average out the pules to get the correct
+    // results...
+
+    // accumulate final part of the first active pulses.
+    osg::Vec4 color(itr->second*(itr->first-lt));
+    double len = length-(itr->first-lt);
+    ++itr;
+    if (itr==_pulseData.end()) itr = _pulseData.begin();
+
+    // accumulate all the whole pluses pulses.
+    while (len>itr->first)
+    {
+        len -= itr->first;
+        color += itr->second*itr->first;
+        ++itr;
+        if (itr==_pulseData.end()) itr = _pulseData.begin();
+    }
+
+    // add remaining part of the final pulse.
+    color += itr->second*len;
+
+    // normalise the time waited color.   
+    color /= length;
+
+    return color;
+}
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/SphereSegment
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/SphereSegment (revision 2851)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/SphereSegment (revision 2851)
@@ -0,0 +1,292 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
+ *
+ * This library is open source and may be redistributed and/or modified under
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGSIM_SPHERESEGMENT
+#define OSGSIM_SPHERESEGMENT 1
+
+#include <osgSim/Export>
+
+#include <osg/Vec3>
+#include <osg/Vec4>
+#include <osg/Geode>
+#include <osg/BlendFunc>
+
+namespace osgSim{
+
+/**
+A SphereSegment is a Geode to represent an portion of a sphere (potentially
+the whole sphere). The sphere is aligned such that the line through the
+sphere's poles is parallel to the z axis. The sphere segment
+may be rendered various components switched on or off:
+
+    - The specified area of the sphere surface.
+
+    - An edge line around the boundary of the specified area
+      of the sphere surface.
+
+    - Four <i>spokes</i>, where a spoke is the line from
+      the sphere's centre to a corner of the rendered area.
+
+    - Four planar areas, where the planar areas are formed
+      between the spokes.
+
+Caveats:
+
+    - It's worth noting that the line through the sphere's poles is
+      parallel to the z axis. This has implications when specifying the
+      area to be rendered, and specifying areas where the centre of
+      the rendered area <i>is</i> the Z axis may lead to unexpected
+      geometry.
+
+    - It's possible to render the whole sphere by specifying elevation
+      and azimuth ranges round the full 360 degrees. When doing
+      so you may consider switching the planes, spokes, and edge lines
+      off, to avoid rendering artefacts, e.g. the upper and lower
+      planes will be coincident.
+
+*/
+class OSGSIM_EXPORT SphereSegment: public osg::Geode
+{
+public:
+
+    /**
+    DrawMask represents a bit field, the values of which may be OR'ed together
+    to specify which parts of the sphere segment should be drawn. E.g.
+    \code
+    sphereSegment->setDrawMask(SphereSegment::DrawMask(SphereSegment::SURFACE|SphereSegment::SPOKES));
+    \endcode
+    */
+    enum DrawMask{
+        SURFACE =   0x00000001, ///< Draw the specified area on the sphere's surface
+        SPOKES =    0x00000002, ///< Draw the spokes from the sphere's centre to the surface's corners
+        EDGELINE =  0x00000008, ///< Draw the line round the edge of the area on the sphere's surface
+        SIDES =    0x00000010, ///< Draw the planes from the sphere's centre to the edge of the sphere's surface
+        ALL =       0xffffffff  ///< Draw every part of the sphere segment
+    };
+
+
+    /** Default constructor. */
+    SphereSegment():osg::Geode(),
+                    _centre(0.0f,0.0f,0.0f), _radius(1.0f),
+                    _azMin(0.0f), _azMax(osg::PI/2.0f),
+                    _elevMin(0.0f), _elevMax(osg::PI/2.0f),
+                    _density(10),
+                    _drawMask(DrawMask(ALL))
+    {
+        init();
+    }
+
+    /**
+    Construct by angle ranges. Note that the azimuth 'zero' is the Y axis; specifying
+    an azimuth range from azMin -osg::PI/2.0f to azMax osg::PI/2.0f will cover the
+    'top half' of the circle in the XY plane. The elev angles are 'out' of the 'zero'
+    XY plane with +ve angles above the plane, and -ve angles below.
+    @param centre       sphere centre
+    @param radius       radius of sphere
+    @param azMin        azimuth minimum
+    @param azMin        azimuth maximum
+    @param elevMin      elevation minimum
+    @param elevMax      elevation maximum
+    @param density      number of units to divide the azimuth and elevation ranges into
+    */
+    SphereSegment(const osg::Vec3& centre, float radius, float azMin, float azMax,
+                    float elevMin, float elevMax, int density):
+        osg::Geode(),
+        _centre(centre), _radius(radius),
+        _azMin(azMin), _azMax(azMax),
+        _elevMin(elevMin), _elevMax(elevMax),
+        _density(density),
+        _drawMask(DrawMask(ALL))
+    {
+        init();
+    }
+
+    /**
+    Construct by vector.
+    @param centre       sphere centre
+    @param radius       radius of sphere
+    @param vec          vector pointing from sphere centre to centre point
+                        of rendered area on sphere surface
+    @param azRange      azimuth range in radians (with centre along vec)
+    @param elevRange    elevation range in radians (with centre along vec)
+    @param density      number of units to divide the azimuth and elevation ranges into
+    */
+    SphereSegment(const osg::Vec3& centre, float radius, const osg::Vec3& vec, float azRange,
+                    float elevRange, int density);
+
+    /** Copy constructor */
+    SphereSegment(const SphereSegment& rhs, const osg::CopyOp& co):
+        osg::Geode(rhs,co),
+        _centre(rhs._centre), _radius(rhs._radius),
+        _azMin(rhs._azMin), _azMax(rhs._azMax),
+        _elevMin(rhs._elevMin), _elevMax(rhs._elevMax),
+        _density(rhs._density),
+        _drawMask(rhs._drawMask)
+    {
+        init();
+    }
+
+    /** Set the centre point of the SphereSegment */
+    void setCentre(const osg::Vec3& c);
+
+    /** Get the centre point of the SphereSegment */
+    const osg::Vec3& getCentre() const;
+
+    /** Set the radius of the SphereSegment */
+    void setRadius(float r);
+
+    /** Get the radius of the SphereSegment */
+    float getRadius() const;
+
+    /** Set the area of the sphere segment
+
+    @param vec          vector pointing from sphere centre to centre point
+                        of rendered area on sphere surface
+    @param azRange      azimuth range in radians (with centre along vec)
+    @param elevRange    elevation range in radians (with centre along vec)
+    */
+    void setArea(const osg::Vec3& v, float azRange, float elevRange);
+
+    /** Get the area of the sphere segment
+
+    @param vec          vector pointing from sphere centre to centre point
+                        of rendered area on sphere surface (normalized)
+    @param azRange      azimuth range in radians (with centre along vec)
+    @param elevRange    elevation range in radians (with centre along vec)
+    */
+    void getArea(osg::Vec3& v, float& azRange, float& elevRange) const;
+
+    /** Set the area of the sphere segment
+    @param azMin        azimuth minimum
+    @param azMin        azimuth maximum
+    @param elevMin      elevation minimum
+    @param elevMax      elevation maximum
+    */
+    void setArea(float azMin, float azMax, float elevMin, float elevMax);
+
+    /** Get the area of the sphere segment
+    @param azMin        azimuth minimum
+    @param azMin        azimuth maximum
+    @param elevMin      elevation minimum
+    @param elevMax      elevation maximum
+    */
+    void getArea(float &azMin, float &azMax, float &elevMin, float &elevMax) const;
+
+    /** Set the density of the sphere segment */
+    void setDensity(int d);
+
+    /** Get the density of the sphere segment */
+    int getDensity() const;
+
+    /**
+    Specify the DrawMask.
+    @param dm   Bitmask specifying which parts of the sphere segment should be drawn.
+    @see DrawMask
+    */
+    void setDrawMask(DrawMask dm);
+
+    /** Get the DrawMask */
+    DrawMask getDrawMask() const { return _drawMask; }
+
+    /** Set the color of the surface. */
+    void setSurfaceColor(const osg::Vec4& c);
+
+    /** Get the color of the surface. */
+    osg::Vec4 getSurfaceColor() const { return _surfaceColor; }
+
+    /** Set the color of the spokes. */
+    void setSpokeColor(const osg::Vec4& c);
+
+    /** Get the color of the spokes. */
+    osg::Vec4 getSpokeColor() const { return _spokeColor; }
+
+    /** Set the color of the edge line. */
+    void setEdgeLineColor(const osg::Vec4& c);
+
+    /** Get the color of the edge line. */
+    osg::Vec4 getEdgeLineColor() const { return _edgeLineColor; }
+
+    /** Set the color of the planes. */
+    void setSideColor(const osg::Vec4& c);
+
+    /** Get the color of the planes. */
+    osg::Vec4 getSideColor() const { return _planeColor; }
+
+    /** Set color of all components. */
+    void setAllColors(const osg::Vec4& c);
+
+    META_Node(osgSim, SphereSegment)
+
+private:
+
+    void init();    // Shared constructor code, generates the drawables
+
+    void dirtyAllDrawableDisplayLists();    // Force re-calling of gl functions
+    void dirtyAllDrawableBounds();          // Force recalculation of bound geometry
+
+    // SphereSegment is actually made up of a number of Drawable classes,
+    // all of which are nested private classes, as declared below. These
+    // classes are defined in the .cpp for minimum visibility and physical
+    // coupling. (Reduces time spent compiling! :-)
+    //
+    // Each of the nested classes holds a pointer to the SphereSegment
+    // 'parent', which stores the geometry details, and performs any
+    // work required. The nested classes are lightweight objects which
+    // just pass the work on.
+    //
+    // Why are things done with these sub-Drawables? Alpha-blended
+    // Drawables need to be drawn last, depth sorted, and the various
+    // components of a SphereSegment also need to be depth sorted
+    // against one another (they may all be drawn with alpha blending).
+    // Making these Drawables allows us to get the OSG to depth sort
+    // for us.
+
+    class Surface;
+    friend class Surface;
+    bool Surface_computeBound(osg::BoundingBox&) const;
+    void Surface_drawImplementation(osg::State&) const;
+
+    class EdgeLine;
+    friend class EdgeLine;
+    bool EdgeLine_computeBound(osg::BoundingBox&) const;
+    void EdgeLine_drawImplementation(osg::State&) const;
+
+    enum BoundaryAngle{MIN,MAX};        // Why here and not in Side class? Because we can't forward
+    enum SideOrientation{AZIM,ELEV};   // declare enums, Side is in the .cpp, and this is tidier...
+    class Side;
+    friend class Side;
+    bool Side_computeBound(osg::BoundingBox&, SideOrientation, BoundaryAngle) const;
+    void Side_drawImplementation(osg::State&, SideOrientation, BoundaryAngle) const;
+
+    class Spoke;
+    friend class Spoke;
+    bool Spoke_computeBound(osg::BoundingBox&, BoundaryAngle, BoundaryAngle) const;
+    void Spoke_drawImplementation(osg::State&, BoundaryAngle, BoundaryAngle) const;
+
+    // Sphere segment geometry details
+    osg::Vec3 _centre;
+    float _radius;
+    float _azMin, _azMax, _elevMin, _elevMax;
+    int _density;
+
+    // Draw details
+    DrawMask _drawMask;
+    osg::Vec4 _surfaceColor;
+    osg::Vec4 _spokeColor;
+    osg::Vec4 _edgeLineColor;
+    osg::Vec4 _planeColor;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/ScalarBar
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/ScalarBar (revision 3212)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/ScalarBar (revision 3212)
@@ -0,0 +1,247 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
+ *
+ * This library is open source and may be redistributed and/or modified under
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGSIM_SCALARBAR
+#define OSGSIM_SCALARBAR 1
+
+#include <osgSim/Export>
+#include <osgSim/ColorRange>    // The default ScalarsToColors is a ColorRange
+#include <osg/Geode>
+#include <string>
+
+namespace osgSim
+{
+/**
+A ScalarBar is an osg::Geode to render a colored bar representing a range
+of scalars. The scalar/color ranges are specified by an instance of
+ScalarsToColors. There are a number of configurable properties on the
+ScalarBar, such as the orientation, the number of labels to be displayed
+across the range, the number of distinct colors to use when rendering the
+bar, text details etc.
+
+In summary, the main configurables on the ScalarBar are:
+
+ -# The range of scalars represented by the bar, and the colors
+    corresponding to this range - these are specified by the
+    ScalarsToColors object.
+ -# The number of colors used when rendering the bar geometry -
+    this may be thought of as the bar 'density'.
+ -# The number of text labels to be used when displaying the bar.
+
+The other configurables should be self-explanatory.
+*/
+class OSGSIM_EXPORT ScalarBar: public osg::Geode
+{
+
+public:
+
+    /** ScalarBar orientation specification. */
+    enum Orientation{
+        HORIZONTAL, ///< a horizontally ascending scalar bar (x-axis)
+        VERTICAL    ///< a vertically ascending scalar bar (y-axis)
+    };
+
+    /**
+    Users may provide their own ScalarPrinter by deriving from this base class and
+    overriding the printScalar() method. Users may map the scalar float passed in
+    to any string they wish.
+    */
+    struct OSGSIM_EXPORT ScalarPrinter: public osg::Referenced
+    {
+        virtual std::string printScalar(float scalar);
+    };
+
+    /**
+    TextProperties allows users to specify a number of properties for the
+    text used to display the labels & title on the ScalarBar. Specifiying a character
+    size of 0 will cause the ScalarBar to estimate an appropriate size. Note that
+    the attributes are public, and may be set directly.
+    */
+    struct TextProperties
+    {
+        std::string         _fontFile;
+        std::pair<int,int>  _fontResolution;
+        float               _characterSize;
+        osg::Vec4           _color;
+
+        TextProperties():
+            _fontFile("fonts/arial.ttf"),
+            _fontResolution(40,40),
+            _characterSize(0.0f),
+            _color(1.0f,1.0f,1.0f,1.0f)
+        {
+        }
+    };
+
+    /** Default constructor. */
+    ScalarBar(): osg::Geode(),
+        _numColors(256),
+        _numLabels(11),
+        _stc(new ColorRange(0.0f,1.0f)),
+        _title("Scalar Bar"),
+        _position(0.0f,0.0f,0.0f),
+        _width(1.0f),
+        _aspectRatio(0.03),
+        _orientation(HORIZONTAL),
+        _sp(new ScalarPrinter)
+    {
+        createDrawables();
+    }
+
+    /**
+    Construct a ScalarBar with the supplied parameters.
+    @param numColors    Specify the number of colors in the scalar bar. Color
+                        interpolation occurs where necessary.
+    @param stc          The ScalarsToColors defining the range of scalars
+                        and the colors they map to.
+    @param title        The title to be used when displaying the ScalarBar.
+                        Specify "" for no title.
+    @param orientation  The orientation of the ScalarBar. @see Orientation.
+    @param apectRatio   The aspect ration (y/x) for the displayed bar. Bear in mind you
+                        may want to change this if you change the orientation.
+    @param sp           A ScalarPrinter object for the ScalarBar. For every displayed
+                        ScalarBar label, the scalar value will be passed to the
+                        ScalarPrinter object to turn it into a string. Users may
+                        override the default ScalarPrinter object to map scalars to
+                        whatever strings they wish. @see ScalarPrinter
+    */
+    ScalarBar(int numColors, int numLabels, ScalarsToColors* stc,
+                const std::string& title,
+                Orientation orientation = HORIZONTAL,
+                float aspectRatio=0.25,
+                ScalarPrinter* sp=new ScalarPrinter):
+        osg::Geode(),
+        _numColors(numColors),
+        _numLabels(numLabels),
+        _stc(stc),
+        _title(title),
+        _position(0.0f,0.0f,0.0f),
+        _width(1.0f),
+        _aspectRatio(aspectRatio),
+        _orientation(orientation),
+        _sp(sp)
+    {
+        createDrawables();
+    }
+
+    /** Copy constructor */
+    ScalarBar(const ScalarBar& rhs, const osg::CopyOp& co): osg::Geode(rhs,co),
+        _numColors(rhs._numColors),
+        _numLabels(rhs._numLabels),
+        _stc(rhs._stc),                     // Consider clone for deep copy?
+        _title(rhs._title),
+        _position(rhs._position),
+        _width(rhs._width),
+        _aspectRatio(rhs._aspectRatio),
+        _orientation(rhs._orientation),
+        _sp(rhs._sp),                        // Consider clone for deep copy?
+        _textProperties(rhs._textProperties)
+    {
+    }
+
+
+    META_Node(osgSim, ScalarBar);
+
+    /** Set the number of distinct colours on the ScalarBar. */
+    void setNumColors(int numColors);
+
+    /** Get the number of distinct colours on the ScalarBar. */
+    int getNumColors() const;
+
+    /** Set the number of labels to display along the ScalarBar. There
+    will be one label at each end point, and evenly distributed labels
+    in between. */
+    void setNumLabels(int numLabels);
+
+    /** Get the number of labels displayed along the ScalarBar. */
+    int getNumLabels() const;
+
+    /** Set the ScalarsToColors mapping object for the ScalarBar. */
+    void setScalarsToColors(ScalarsToColors* stc);
+
+    /** Get the ScalarsToColors mapping object from the ScalarBar. */
+    const ScalarsToColors* getScalarsToColors() const;
+
+    /** Set the title for the ScalarBar, set ""  for no title. */
+    void setTitle(const std::string& title);
+
+    /** Get the title for the ScalarBar. */
+    std::string getTitle() const;
+
+
+    /** Set the position of scalar bar's lower left corner.*/
+    void setPosition(const osg::Vec3& pos);
+    
+    /** Get the position of scalar bar.*/
+    const osg::Vec3& getPosition() const { return _position; }
+
+    /** Set the width of the scalar bar.*/
+    void setWidth(float width);
+
+    /** Get the width of the scalar bar.*/
+    float getWidth() { return _width; }
+
+    /** Set the aspect ration (y/x) for the displayed bar. Bear in mind you
+    may want to change this if you change the orientation. */
+    void setAspectRatio(float aspectRatio);
+
+    /** Get the aspect ration (y/x) for the displayed bar. */
+    float getAspectRatio() const;
+
+
+    /** Set the orientation of the ScalarBar. @see Orientation */
+    void setOrientation(ScalarBar::Orientation orientation);
+
+    /** Get the orientation of the ScalarBar.  @see Orientation */
+    ScalarBar::Orientation getOrientation() const;
+
+
+    /** Set a ScalarPrinter object for the ScalarBar. For every displayed
+    ScalarBar label, the scalar value will be passed to the ScalarPrinter
+    object to turn it into a string. Users may override the default ScalarPrinter
+    object to map scalars to whatever strings they wish. @see ScalarPrinter */
+    void setScalarPrinter(ScalarPrinter* sp);
+
+    /** Get the ScalarPrinter object  */
+    const ScalarPrinter* getScalarPrinter() const;
+
+    /** Set the TextProperties for the labels & title. @see TextProperties */
+    void setTextProperties(const TextProperties& tp);
+
+    /** Get the TextProperties for the labels & title. @see TextProperties */
+    const TextProperties& getTextProperties() const;
+
+    /** force update the drawables used to render the scalar bar.*/
+    void update() { createDrawables(); }
+
+protected:
+    virtual ~ScalarBar();
+
+    int _numColors;
+    int _numLabels;
+    osg::ref_ptr<ScalarsToColors> _stc;
+    std::string _title;
+    osg::Vec3 _position;
+    float _width;
+    float _aspectRatio;
+    Orientation _orientation;
+    osg::ref_ptr<ScalarPrinter> _sp;
+    TextProperties  _textProperties;
+
+    void createDrawables();
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/ColorRange
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/ColorRange (revision 3028)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/ColorRange (revision 3028)
@@ -0,0 +1,63 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
+ *
+ * This library is open source and may be redistributed and/or modified under
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGSIM_COLORRANGE
+#define OSGSIM_COLORRANGE 1
+
+#include <osgSim/Export>
+
+#include <osgSim/ScalarsToColors>
+#include <vector>
+
+namespace osgSim
+{
+/**
+ColorRange is a ScalarsToColors object to define a color spectrum
+for a scalar range. An optional vector of colors may be passed in at
+construction time. The range of colors will be mapped to the scalar range,
+and interpolation between the colors will be performed as necessary.
+By default, the color range will run Red-Yellow-Green-Cyan-Blue.
+*/
+class OSGSIM_EXPORT ColorRange: public ScalarsToColors
+{
+public:
+
+    /** Constructor for a ColorRange with a default list of colors set to Red-Yellow-Green-Blue-Cyan
+    @param min      minimum scalar value
+    @param max      maximum scalar value
+    */
+    ColorRange(float min, float max);
+
+    /** Constructor for a ColorRange
+    @param min      minimum scalar value
+    @param max      maximum scalar value
+    @param colors   optional range of colors, 
+    */
+    ColorRange(float min, float max, const std::vector<osg::Vec4>& colors);
+
+    /** Set the range of colors. */
+    void setColors(const std::vector<osg::Vec4>& colors);
+
+    /** Get the color for a given scalar value. */
+    osg::Vec4 getColor(float scalar) const;
+
+private:
+
+    // Default assignment and copy construction are OK.
+
+    std::vector<osg::Vec4> _colors;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/MultiSwitch
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/MultiSwitch (revision 2497)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/MultiSwitch (revision 2497)
@@ -0,0 +1,92 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_MULTISWITCH
+#define OSG_MULTISWITCH 1
+
+#include <osg/Group>
+#include <osgSim/Export>
+
+namespace osgSim {
+
+/** MultiSwitch is a Group node which allows switching between sets of selected children.
+    MultiSwtich is based on the OpenFlight switch behaviour.
+*/
+class OSGSIM_EXPORT MultiSwitch : public osg::Group
+{
+    public :
+        
+
+        MultiSwitch();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        MultiSwitch(const MultiSwitch&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
+
+        META_Node(osgSim, MultiSwitch);
+
+        virtual void traverse(osg::NodeVisitor& nv);
+        
+        void setNewChildDefaultValue(bool value) { _newChildDefaultValue = value; }
+        
+        bool getNewChildDefaultValue() const { return _newChildDefaultValue; }
+
+        virtual bool addChild( osg::Node *child );
+
+        virtual bool insertChild( unsigned int index, osg::Node *child );
+
+        virtual bool removeChild( osg::Node *child );
+
+        void setValue(unsigned int switchSet, unsigned int pos,bool value);
+
+        bool getValue(unsigned int switchSet, unsigned int pos) const;
+
+        void setChildValue(const osg::Node* child,unsigned int switchSet, bool value);
+        
+        bool getChildValue(const osg::Node* child,unsigned int switchSet) const;
+
+        /** Set all the children off (false), and set the new default child value to off (false).*/
+        bool setAllChildrenOff(unsigned int switchSet);
+        
+        /** Set all the children on (true), and set the new default child value to on (true).*/
+        bool setAllChildrenOn(unsigned int switchSet);
+        
+        /** Set a single child to be on, MultiSwitch off all other children.*/
+        bool setSingleChildOn(unsigned int switchSet, unsigned int pos);
+        
+        /** Set which of the available switch set lists to use.*/
+        void setActiveSwitchSet(unsigned int switchSet) { _activeSwitchSet = switchSet; }
+        
+        /** Get which of the available switch set lists to use.*/
+        unsigned int getActiveSwitchSet() const { return _activeSwitchSet; }
+
+        typedef std::vector<bool>       ValueList;
+        typedef std::vector<ValueList>  SwitchSetList;
+        
+        const SwitchSetList& getSwitchSetList() const { return _values; }
+        const ValueList& getValueList(unsigned int switchSet) const { return _values[switchSet]; }
+
+    protected :
+    
+        virtual ~MultiSwitch() {}
+        
+        void expandToEncompassSwitchSet(unsigned int switchSet);
+
+        // this is effectively a list of bit mask.
+        bool            _newChildDefaultValue;
+        unsigned int    _activeSwitchSet;
+        SwitchSetList   _values;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/ScalarsToColors
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/ScalarsToColors (revision 2215)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgSim/ScalarsToColors (revision 2215)
@@ -0,0 +1,53 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
+ *
+ * This library is open source and may be redistributed and/or modified under
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGSIM_SCALARSTCOLORS
+#define OSGSIM_SCALARSTCOLORS 1
+
+#include <osgSim/Export>
+
+#include <osg/Vec4>
+#include <osg/Referenced>
+
+namespace osgSim
+{
+/**
+ScalarsToColors defines the interface to map a scalar value to a color,
+and provides a default implementation of the mapping functionaltity,
+with colors ranging from black to white across the min - max scalar
+range.
+*/
+class OSGSIM_EXPORT ScalarsToColors: public osg::Referenced
+{
+public:
+
+    ScalarsToColors(float scalarMin, float scalarMax);
+    virtual ~ScalarsToColors() {}
+
+    /** Get the color for a given scalar value. */
+    virtual osg::Vec4 getColor(float scalar) const;
+
+    /** Get the minimum scalar value. */
+    float getMin() const;
+
+    /** Get the maximum scalar value. */
+    float getMax() const;
+
+private:
+
+    float _min, _max;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/BumpMapping
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/BumpMapping (revision 2480)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/BumpMapping (revision 2480)
@@ -0,0 +1,198 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+//osgFX - Copyright (C) 2003 Marco Jez
+
+#ifndef OSGFX_BUMPMAPPING_
+#define OSGFX_BUMPMAPPING_
+
+#include <osgFX/Export>
+#include <osgFX/Effect>
+
+#include <osg/ref_ptr>
+#include <osg/Texture2D>
+
+namespace osgFX
+{
+
+    /**
+     This effect makes surfaces appear bumpy. Children nodes must use two textures, 
+     one for diffuse color and one for the normal map (which can be created 
+     from a height map with tools like nVIDIA's normal map generator). Furthermore, 
+     tangent-space basis vectors must be created and assigned to each Geometry; this 
+     can be done quickly by calling BumpMapping::prepareChildren(). Note that both 
+     diffuse and normal map textures must have corresponding UV maps defined in 
+     Geometry objects.
+     This effect defines a preferred technique which uses ARB vertex & fragment 
+     programs, and a fallback technique which doesn't use fragment programs. The 
+     latter is more limited though since it can't handle ambient and specular 
+     components.
+     */
+    class OSGFX_EXPORT BumpMapping: public Effect {
+    public:
+        BumpMapping();
+        BumpMapping(const BumpMapping &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY);
+
+        META_Effect(osgFX, BumpMapping, 
+        
+            "Bump Mapping", 
+            
+            "This effect makes surfaces appear bumpy. Children nodes must use two textures, "
+            "one for diffuse color and one for the normal map (which can be created "
+            "from a height map with tools like nVIDIA's normal map generator). Furthermore, "
+            "tangent-space basis vectors must be created and assigned to each Geometry; this "
+            "can be done quickly by calling BumpMapping::prepareChildren(). Note that both "
+            "diffuse and normal map textures must have corresponding UV maps defined in "
+            "Geometry objects.\n"
+            "This effect defines a preferred technique which uses ARB vertex & fragment "
+            "programs, and a fallback technique which doesn't use fragment programs. The "
+            "latter is more limited though since it can't handle ambient and specular "
+            "components.",
+            
+            "Marco Jez");
+            
+        
+        /** get the OpenGL light number */
+        inline int getLightNumber() const;
+        
+        /** set the OpenGL light number that will be used in lighting computations */
+        inline void setLightNumber(int n);
+        
+        /** get the texture unit that contains diffuse color texture. Default is 1 */
+        inline int getDiffuseTextureUnit() const;
+        
+        /** set the texture unit that contains diffuse color texture. Default is 1 */
+        inline void setDiffuseTextureUnit(int n);
+
+        /** get the texture unit that contains normal map texture. Default is 0 */
+        inline int getNormalMapTextureUnit() const;
+        
+        /** set the texture unit that contains normal map texture. Default is 0 */
+        inline void setNormalMapTextureUnit(int n);
+        
+        /** get the diffuse color texture that overrides children's texture */
+        inline osg::Texture2D *getOverrideDiffuseTexture();
+        
+        /** get the const diffuse color texture that overrides children's texture */
+        inline const osg::Texture2D *getOverrideDiffuseTexture() const;
+        
+        /** set the diffuse color texture that overrides children's texture */
+        inline void setOverrideDiffuseTexture(osg::Texture2D *texture);
+        
+        /** get the normal map texture that overrides children's texture */
+        inline osg::Texture2D *getOverrideNormalMapTexture();
+        
+        /** get the const normal map texture that overrides children's texture */
+        inline const osg::Texture2D *getOverrideNormalMapTexture() const;
+
+        /** set the normal map texture that overrides children's texture */
+        inline void setOverrideNormalMapTexture(osg::Texture2D *texture);
+        
+        /**
+         prepare a Geometry for bump lighting. Tangent-space basis vectors are
+         generated and attached to the geometry as vertex attribute arrays.
+         */
+        void prepareGeometry(osg::Geometry *geo);
+        
+        /** prepare a Node for bump lighting, calling prepareGeometry() for each Geometry */
+        void prepareNode(osg::Node *node);
+        
+        /** prepare children for bump lighting. Actually calls prepareNode() for each child */
+        void prepareChildren();
+        
+        /** set up a demo environment with predefined diffuse and normal maps, as well as texture coordinates */
+        void setUpDemo();
+
+    protected:
+        virtual ~BumpMapping() {}
+        BumpMapping &operator=(const BumpMapping &) { return *this; }
+
+        bool define_techniques();
+
+    private:
+        int lightnum_;
+        int diffuseunit_;
+        int normalunit_;
+        osg::ref_ptr<osg::Texture2D> diffuse_tex_;
+        osg::ref_ptr<osg::Texture2D> normal_tex_;
+    };
+
+    // INLINE METHODS    
+   
+    inline int BumpMapping::getLightNumber() const
+    {
+        return lightnum_;
+    }
+    
+    inline void BumpMapping::setLightNumber(int n)
+    {
+        lightnum_ = n;
+        dirtyTechniques();
+    }
+    
+    inline int BumpMapping::getDiffuseTextureUnit() const
+    {
+        return diffuseunit_;
+    }
+    
+    inline void BumpMapping::setDiffuseTextureUnit(int n)
+    {
+        diffuseunit_ = n;
+        dirtyTechniques();
+    }
+    
+    inline int BumpMapping::getNormalMapTextureUnit() const
+    {
+        return normalunit_;
+    }
+    
+    inline void BumpMapping::setNormalMapTextureUnit(int n)
+    {
+        normalunit_ = n;
+        dirtyTechniques();
+    }
+    
+    inline osg::Texture2D *BumpMapping::getOverrideDiffuseTexture()
+    {
+        return diffuse_tex_.get();
+    }
+
+    inline const osg::Texture2D *BumpMapping::getOverrideDiffuseTexture() const
+    {
+        return diffuse_tex_.get();
+    }
+    
+    inline void BumpMapping::setOverrideDiffuseTexture(osg::Texture2D *texture)
+    {
+        diffuse_tex_ = texture;
+        dirtyTechniques();
+    }
+
+    inline osg::Texture2D *BumpMapping::getOverrideNormalMapTexture()
+    {
+        return normal_tex_.get();
+    }
+
+    inline const osg::Texture2D *BumpMapping::getOverrideNormalMapTexture() const
+    {
+        return normal_tex_.get();
+    }
+    
+    inline void BumpMapping::setOverrideNormalMapTexture(osg::Texture2D *texture)
+    {
+        normal_tex_ = texture;
+        dirtyTechniques();
+    }
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/AnisotropicLighting
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/AnisotropicLighting (revision 2185)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/AnisotropicLighting (revision 2185)
@@ -0,0 +1,122 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+//osgFX - Copyright (C) 2003 Marco Jez
+
+#ifndef OSGFX_ANISOTROPICLIGHTING_
+#define OSGFX_ANISOTROPICLIGHTING_
+
+#include <osgFX/Export>
+#include <osgFX/Effect>
+
+#include <osg/ref_ptr>
+#include <osg/Texture2D>
+
+namespace osgFX
+{
+
+    /**
+     This single-pass effect implements a sort of anisotropic 
+     lighting that replaces the standard OpenGL lighting model.
+     The final color of vertices is not computed directly, it is 
+     the result of a texture lookup on a user-supplied lighting 
+     image map. A vertex program is used to compute the s and t 
+     texture coordinates as follows: s = (N dot H) ; t = (N dot L) 
+     where N is the vertex normal, L is the light-to-vertex vector, 
+     H is the half-way vector. This is a good example of how you 
+     can use the State::getInitialViewMatrix() method to retrieve 
+     the view matrix and perform view-dependant effects without 
+     fakes of any kind.
+     This effect requires the ARB_vertex_program extension.
+     */
+    class OSGFX_EXPORT AnisotropicLighting: public Effect {
+    public:
+        AnisotropicLighting();
+        AnisotropicLighting(const AnisotropicLighting &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY);
+
+        META_Effect(osgFX, AnisotropicLighting, 
+        
+            "Anisotropic Lighting", 
+            
+            "This single-pass effect implements a sort of anisotropic "
+            "lighting that replaces the standard OpenGL lighting model.\n"
+            "The final color of vertices is not computed directly, it is "
+            "the result of a texture lookup on a user-supplied lighting "
+            "image map. A vertex program is used to compute the s and t "
+            "texture coordinates as follows: s = (N dot H) ; t = (N dot L) "
+            "where N is the vertex normal, L is the light-to-vertex vector, "
+            "H is the half-way vector. This is a good example of how you "
+            "can use the State::getInitialViewMatrix() method to retrieve "
+            "the view matrix and perform view-dependant effects without "
+            "fakes of any kind.\n"
+            "This effect requires the ARB_vertex_program extension.", 
+            
+            "Marco Jez");
+            
+        
+        /** get the lighting map */
+        inline osg::Image *getLightingMap();
+        
+        /** get the const lighting map */
+        inline const osg::Image *getLightingMap() const;
+        
+        /** set the lighting map */
+        inline void setLightingMap(osg::Image *image);
+
+        /** get the OpenGL light number */
+        inline int getLightNumber() const;
+        
+        /** set the OpenGL light number that will be used in lighting computations */
+        inline void setLightNumber(int n);
+
+    protected:
+        virtual ~AnisotropicLighting() {}
+        AnisotropicLighting &operator=(const AnisotropicLighting &) { return *this; }
+
+        bool define_techniques();
+
+    private:
+        int lightnum_;
+        osg::ref_ptr<osg::Texture2D> texture_;
+    };
+
+    // INLINE METHODS
+    
+    inline osg::Image *AnisotropicLighting::getLightingMap()
+    {
+        return texture_->getImage();
+    }
+    
+    inline const osg::Image *AnisotropicLighting::getLightingMap() const
+    {
+        return texture_->getImage();
+    }
+    
+    inline void AnisotropicLighting::setLightingMap(osg::Image *image)
+    {
+        texture_->setImage(image);
+    }
+    
+    inline int AnisotropicLighting::getLightNumber() const
+    {
+        return lightnum_;
+    }
+    
+    inline void AnisotropicLighting::setLightNumber(int n)
+    {
+        lightnum_ = n;
+        dirtyTechniques();
+    }
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Export
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Export (revision 2185)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Export (revision 2185)
@@ -0,0 +1,28 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+//osgFX - Copyright (C) 2003 Marco Jez
+
+#ifndef OSGFX_EXPORT_
+#define OSGFX_EXPORT_
+
+#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__)  || defined( __MWERKS__)
+    #  ifdef OSGFX_LIBRARY
+    #    define OSGFX_EXPORT   __declspec(dllexport)
+    #  else
+    #    define OSGFX_EXPORT   __declspec(dllimport)
+    #  endif /* OSGFX_LIBRARY */
+#else
+    #  define OSGFX_EXPORT
+#endif
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Cartoon
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Cartoon (revision 2354)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Cartoon (revision 2354)
@@ -0,0 +1,122 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+//osgFX - Copyright (C) 2003 Marco Jez
+
+#ifndef OSGFX_CARTOON_
+#define OSGFX_CARTOON_
+
+#include <osgFX/Export>
+#include <osgFX/Effect>
+
+#include <osg/Material>
+#include <osg/LineWidth>
+
+namespace osgFX
+{
+
+     /**
+     This effect implements a technique called 'Cel-Shading' to produce a 
+     cartoon-style (non photorealistic) rendering. Two passes are required: 
+     the first one draws solid surfaces, the second one draws the outlines. 
+     A vertex program is used to setup texture coordinates for a sharp lighting 
+     texture on unit 0 which is generated on-the-fly.
+     This effect requires the ARB_vertex_program extension.
+     */
+    class OSGFX_EXPORT Cartoon: public Effect {
+    public:
+        Cartoon();
+        Cartoon(const Cartoon &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY);
+
+        // effect class informations
+        META_Effect(
+            osgFX, 
+            Cartoon, 
+            
+            "Cartoon", 
+            
+            "This effect implements a technique called 'Cel-Shading' to produce a "
+            "cartoon-style (non photorealistic) rendering. Two passes are required: "
+            "the first one draws solid surfaces, the second one draws the outlines. "
+            "A vertex program is used to setup texture coordinates for a sharp lighting "
+            "texture on unit 0 which is generated on-the-fly.\n"
+            "This effect requires the ARB_vertex_program extension "
+            "or OpenGL Shading Language.",
+            
+            "Marco Jez; OGLSL port by Mike Weiblen");
+
+        /** get the outline color */
+        inline const osg::Vec4 &getOutlineColor() const;
+        
+        /** set the outline color */
+        inline void setOutlineColor(const osg::Vec4 &color);
+        
+        /** get the outline line width */
+        inline float getOutlineLineWidth() const;
+        
+        /** set the outline line width */
+        inline void setOutlineLineWidth(float w);
+        
+        /** get the OpenGL light number */
+        inline int getLightNumber() const;
+        
+        /** set the OpenGL light number that will be used in lighting computations */
+        inline void setLightNumber(int n);
+
+    protected:
+        virtual ~Cartoon() {}
+        Cartoon &operator=(const Cartoon &) { return *this; }
+
+        bool define_techniques();
+
+    private:
+        osg::ref_ptr<osg::Material> wf_mat_;
+        osg::ref_ptr<osg::LineWidth> wf_lw_;
+        int lightnum_;
+    };
+
+    // INLINE METHODS
+
+    inline const osg::Vec4 &Cartoon::getOutlineColor() const
+    {
+        return wf_mat_->getEmission(osg::Material::FRONT_AND_BACK);
+    }
+
+    inline void Cartoon::setOutlineColor(const osg::Vec4 &color)
+    {
+        wf_mat_->setEmission(osg::Material::FRONT_AND_BACK, color);
+    }
+    
+    inline float Cartoon::getOutlineLineWidth() const
+    {
+        return wf_lw_->getWidth();
+    }
+    
+    inline void Cartoon::setOutlineLineWidth(float w)
+    {
+        wf_lw_->setWidth(w);
+    }
+    
+    inline int Cartoon::getLightNumber() const
+    {
+        return lightnum_;
+    }
+    
+    inline void Cartoon::setLightNumber(int n)
+    {
+        lightnum_ = n;
+        dirtyTechniques();
+    }
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Technique
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Technique (revision 2480)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Technique (revision 2480)
@@ -0,0 +1,158 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+//osgFX - Copyright (C) 2003 Marco Jez
+
+#ifndef OSGFX_TECHNIQUE_
+#define OSGFX_TECHNIQUE_
+
+#include <osgFX/Export>
+
+#include <osg/Referenced>
+#include <osg/State>
+#include <osg/Group>
+#include <osg/NodeVisitor>
+
+#include <vector>
+#include <string>
+
+/**
+ An helper macro that defines the methods techniqueName() and 
+ techniqueDescription() making them return the strings passed as parameters.
+ */
+#define META_Technique(name, description) \
+    inline virtual const char *techniqueName() { return name; } \
+    inline virtual const char *techniqueDescription() { return description; }
+
+
+namespace osgFX
+{
+
+    class Effect;
+
+    /**
+     This is the base class for effect techniques. A technique represents one
+     of the possible ways to implement a special effect. This base class is
+     abstract, you will have to subclass your own techniques for your custom
+     effects.
+     Derived classes will have to implement the define_passes() method to
+     configure the rendering pass(es) that make up the technique. Usually
+     you will create one StateSet object for each rendering pass and then
+     you'll call addPass(stateset).
+     The validate() method should return true if the technique is valid within
+     the current rendering context, false otherwise. The default implementation
+     of validate() calls getRequiredExtensions() and tests whether all required
+     extensions are supported or not, returning false if at least one extension
+     is not supported.
+     */
+    class OSGFX_EXPORT Technique: public osg::Referenced {
+    public:
+        Technique();
+
+        /** get the name of this technique */
+        virtual const char *techniqueName()        { return "Default"; }
+
+        /** get a brief description of this technique */
+        virtual const char *techniqueDescription() { return "This is the default technique"; }
+
+        /**
+         collect the GL extension strings which are required for this technique
+         to work properly. This method is called from the default implementation
+         of validate().
+         */
+        virtual void getRequiredExtensions(std::vector<std::string> & /*extensions*/) const {};
+
+        /**
+         tests whether this technique is valid for the current rendering context.
+         The default behavior is to call getRequiredExtensions() and check for
+         extension availability.
+         */
+        virtual bool validate(osg::State &) const;
+
+        /** get the number of rendering passes defined in this technique */
+        inline int getNumPasses() const;
+
+        /** get the StateSet object associated to the i-th pass */
+        inline osg::StateSet *getPassStateSet(int i);
+
+        /** get the const StateSet object associated to the i-th pass */
+        inline const osg::StateSet *getPassStateSet(int i) const;
+
+        /** 
+         traverse children with multipass if necessary. By default this method
+         simply calls the protected method traverse_implementation(); you can
+         override it to change the default behavior.
+         Don't call this method directly as it is called by osgFX::Effect
+         */
+        inline virtual void traverse(osg::NodeVisitor &nv, Effect *fx);
+        
+    protected:
+        Technique(const Technique &): osg::Referenced() {}    // copying is nonsense ;)
+        virtual ~Technique() {}
+        Technique &operator=(const Technique &)  { return *this; }
+
+        /** force rebuilding of pass nodes on next traversal */
+        inline void dirtyPasses();
+
+        /** create a new pass node, add it to the technique and associate a StateSet */
+        void addPass(osg::StateSet *ss = 0);
+        
+        /** optional: return a node that overrides the child node on a specified pass */
+        inline virtual osg::Node *getOverrideChild(int)  { return 0; }
+
+        /**
+         define the rendering passes that make up this technique. You must
+         implement this method in derived classes to add the required passes.
+         */
+        virtual void define_passes() = 0;
+        
+        /**
+         traverse children with multipass if necessary. Don't call this method
+         directly unless you are in a customized version of traverse().
+         */
+        void traverse_implementation(osg::NodeVisitor &nv, Effect *fx);
+
+    private:
+        typedef std::vector<osg::ref_ptr<osg::StateSet> > Pass_list;
+        Pass_list passes_;
+    };
+
+    // INLINE METHODS
+
+    inline int Technique::getNumPasses() const
+    {
+        return static_cast<int>(passes_.size());
+    }
+
+    inline osg::StateSet *Technique::getPassStateSet(int i)
+    {
+        return passes_[i].get();
+    }
+
+    inline const osg::StateSet *Technique::getPassStateSet(int i) const
+    {
+        return passes_[i].get();
+    }
+      
+    inline void Technique::dirtyPasses()
+    {
+        passes_.clear();
+    }
+    
+    inline void Technique::traverse(osg::NodeVisitor &nv, Effect *fx)
+    {
+        traverse_implementation(nv, fx);
+    }
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Validator
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Validator (revision 3240)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Validator (revision 3240)
@@ -0,0 +1,78 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+//osgFX - Copyright (C) 2003 Marco Jez
+
+#ifndef OSGFX_VALIDATOR_
+#define OSGFX_VALIDATOR_
+
+#include <osgFX/Effect>
+
+#include <osg/ref_ptr>
+#include <osg/StateAttribute>
+
+#include <vector>
+
+namespace osgFX
+{
+
+    /**
+     This class is used internally by osgFX::Effect to choose between different
+     techniques dynamically. The apply() method will call each technique's
+     validate() method and store the results in a buffered array. The Effect
+     class will then choose the first technique that could be validated in all
+     active rendering contexts.
+     */
+    class OSGFX_EXPORT Validator: public osg::StateAttribute {
+    public:
+        enum {
+            VALIDATOR = 0x56616C69
+        };
+        
+        Validator();
+        Validator(Effect *effect);
+        Validator(const Validator &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY);
+
+        META_StateAttribute(osgFX, Validator, VALIDATOR);
+
+        void apply(osg::State &state) const;
+        void compileGLObjects(osg::State &state) const;
+
+        inline int compare(const osg::StateAttribute &sa) const;
+        
+        inline void disable() { effect_ = 0; }
+
+    protected:
+        virtual ~Validator() {}
+        Validator &operator=(const Validator &) { return *this; }
+
+    private:
+        mutable Effect *effect_;
+    };
+
+    // INLINE METHODS
+
+    inline int Validator::compare(const osg::StateAttribute &sa) const
+    {
+        // check the types are equal and then create the rhs variable
+        //used by the COMPARE_StateAttribute_Paramter macro's below.
+        COMPARE_StateAttribute_Types(Validator,sa)
+        
+        // compare parameters
+        COMPARE_StateAttribute_Parameter(effect_)
+
+        return 0;
+    }
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Scribe
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Scribe (revision 2185)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Scribe (revision 2185)
@@ -0,0 +1,101 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+//osgFX - Copyright (C) 2003 Marco Jez
+
+#ifndef OSGFX_SCRIBE_
+#define OSGFX_SCRIBE_
+
+#include <osgFX/Export>
+#include <osgFX/Effect>
+
+#include <osg/Material>
+#include <osg/LineWidth>
+
+namespace osgFX
+{
+
+    /**
+     This is a two-passes effect; the first pass renders the subgraph as usual 
+     while the second pass switches to wireframe mode, sets up lighting and 
+     material to obtain a fixed (user-defined) color and then renders the subgraph.
+     This effect uses the PolygonOffset attribute to avoid Z-fighting, so it 
+     requires at least OpenGL version 1.1.
+    */
+    class OSGFX_EXPORT Scribe: public Effect {
+    public:
+        Scribe();
+        Scribe(const Scribe &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY);
+
+        // effect class informations
+        META_Effect(
+            osgFX, 
+            Scribe, 
+            
+            "Scribe", 
+            
+            "This is a two-passes effect; the first pass renders the subgraph as usual "
+            "while the second pass switches to wireframe mode, sets up lighting and "
+            "material to obtain a fixed (user-defined) color and then renders the subgraph.\n"
+            "This effect uses the PolygonOffset attribute to avoid Z-fighting, so it "
+            "requires at least OpenGL version 1.1.",
+            
+            "Marco Jez");
+
+        /** get the wireframe color */
+        inline const osg::Vec4 &getWireframeColor() const;
+        
+        /** set the wireframe color */
+        inline void setWireframeColor(const osg::Vec4 &color);
+        
+        /** get the wireframe line width */
+        inline float getWireframeLineWidth() const;
+        
+        /** set the wireframe line width */
+        inline void setWireframeLineWidth(float w);
+
+    protected:
+        virtual ~Scribe() {}
+        Scribe &operator=(const Scribe &) { return *this; }
+
+        bool define_techniques();
+
+    private:
+        osg::ref_ptr<osg::Material> wf_mat_;
+        osg::ref_ptr<osg::LineWidth> wf_lw_;
+    };
+
+    // INLINE METHODS
+
+    inline const osg::Vec4 &Scribe::getWireframeColor() const
+    {
+        return wf_mat_->getEmission(osg::Material::FRONT_AND_BACK);
+    }
+
+    inline void Scribe::setWireframeColor(const osg::Vec4 &color)
+    {
+        wf_mat_->setEmission(osg::Material::FRONT_AND_BACK, color);
+    }
+    
+    inline float Scribe::getWireframeLineWidth() const
+    {
+        return wf_lw_->getWidth();
+    }
+    
+    inline void Scribe::setWireframeLineWidth(float w)
+    {
+        wf_lw_->setWidth(w);
+    }
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Registry
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Registry (revision 3266)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Registry (revision 3266)
@@ -0,0 +1,73 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+//osgFX - Copyright (C) 2003 Marco Jez
+
+#ifndef OSGFX_REGISTRY_
+#define OSGFX_REGISTRY_
+
+#include <osgFX/Export>
+#include <osgFX/Effect>
+
+#include <osg/ref_ptr>
+
+#include <map>
+#include <string>
+
+namespace osgFX
+{
+
+    class OSGFX_EXPORT Registry : public osg::Referenced{
+    public:
+
+        struct Proxy {
+            Proxy(const Effect *effect)
+            {
+                Registry::instance()->registerEffect(effect);
+            }
+        };
+
+        typedef std::map<std::string, osg::ref_ptr<const Effect> > Effect_map;
+
+        static Registry *instance();
+
+        inline void registerEffect(const Effect *effect);
+
+        inline const Effect_map &getEffectMap() const;
+
+    protected:
+
+        // Registry is a singleton; constructor and destructor must be protected
+        Registry();
+        ~Registry() {}
+
+    private:
+        Effect_map effects_;
+    };
+
+    // INLINE METHODS
+
+    
+
+    inline const Registry::Effect_map &Registry::getEffectMap() const
+    {
+        return effects_;
+    }
+
+    inline void Registry::registerEffect(const Effect *effect)
+    {
+        effects_[effect->effectName()] = effect;
+    }
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/SpecularHighlights
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/SpecularHighlights (revision 2185)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/SpecularHighlights (revision 2185)
@@ -0,0 +1,138 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+//osgFX - Copyright (C) 2003 Marco Jez
+
+#ifndef OSGFX_SPECULARHIGHLIGHTS_
+#define OSGFX_SPECULARHIGHLIGHTS_
+
+#include <osgFX/Export>
+#include <osgFX/Effect>
+
+namespace osgFX
+{
+
+    /**
+      This effect applies additive specular highlights at fragment level (instead 
+     of OpenGL's vertex-level lighting) by using a cube map and reflective texgen. 
+     A texture matrix is computed to rotate the cube map automatically; this makes 
+     the specular effect consistent with respect to view direction and light position. 
+     The user can choose which light should be used to compute the texture matrix.
+     This effect requires the GL_ARB_texture_env_add extension and one of the cube map 
+     extensions (GL_EXT_texture_cube_map, GL_ARB_texture_cube_map or OpenGL v1.3).
+     */
+    class OSGFX_EXPORT SpecularHighlights: public Effect {
+    public:
+        SpecularHighlights();
+        SpecularHighlights(const SpecularHighlights &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY);
+
+        META_Effect(osgFX, SpecularHighlights, 
+        
+            "Specular Highlights", 
+            
+            "This effect applies additive specular highlights at fragment level (instead "
+            "of OpenGL's vertex-level lighting) by using a cube map and reflective texgen. "
+            "A texture matrix is computed to rotate the cube map automatically; this makes "
+            "the specular effect consistent with respect to view direction and light position. "
+            "The user can choose which light should be used to compute the texture matrix.\n"
+            "This effect requires the GL_ARB_texture_env_add extension and one of the cube map "
+            "extensions (GL_EXT_texture_cube_map, GL_ARB_texture_cube_map or OpenGL v1.3).", 
+            
+            "Marco Jez");
+            
+        
+        /** get the OpenGL light number */
+        inline int getLightNumber() const;
+        
+        /** set the OpenGL light number that will be used in lighting computations */
+        inline void setLightNumber(int n);
+        
+        /** get the texture unit number */
+        inline int getTextureUnit() const;
+        
+        /** set the texture unit that will be used to apply the cube map */
+        inline void setTextureUnit(int n);
+        
+        /** get the specular color */
+        inline const osg::Vec4 &getSpecularColor() const;
+        
+        /** set the specular color */
+        inline void setSpecularColor(const osg::Vec4 &color);
+        
+        /** get the specular exponent */
+        inline float getSpecularExponent() const;
+        
+        /** set the specular exponent */
+        inline void setSpecularExponent(float e);
+
+    protected:
+        virtual ~SpecularHighlights() {}
+        SpecularHighlights &operator=(const SpecularHighlights &) { return *this; }
+
+        bool define_techniques();
+
+    private:
+        int lightnum_;
+        int unit_;
+        osg::Vec4 color_;
+        float sexp_;
+    };
+
+    // INLINE METHODS
+    
+    inline int SpecularHighlights::getLightNumber() const
+    {
+        return lightnum_;
+    }
+    
+    inline void SpecularHighlights::setLightNumber(int n)
+    {
+        lightnum_ = n;
+        dirtyTechniques();
+    }
+    
+    inline int SpecularHighlights::getTextureUnit() const
+    {
+        return unit_;
+    }
+    
+    inline void SpecularHighlights::setTextureUnit(int n)
+    {
+        unit_ = n;
+        dirtyTechniques();
+    }
+
+    inline const osg::Vec4 &SpecularHighlights::getSpecularColor() const
+    {
+        return color_;
+    }
+    
+    inline void SpecularHighlights::setSpecularColor(const osg::Vec4 &color)
+    {
+        color_ = color;
+        dirtyTechniques();
+    }
+
+    inline float SpecularHighlights::getSpecularExponent() const
+    {
+        return sexp_;
+    }
+    
+    inline void SpecularHighlights::setSpecularExponent(float e)
+    {
+        sexp_ = e;
+        dirtyTechniques();
+    }
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Effect
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Effect (revision 2480)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgFX/Effect (revision 2480)
@@ -0,0 +1,217 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+//osgFX - Copyright (C) 2003 Marco Jez
+
+#ifndef OSGFX_EFFECT_
+#define OSGFX_EFFECT_
+
+#include <osgFX/Export>
+#include <osgFX/Technique>
+
+#include <osg/buffered_value>
+#include <osg/ref_ptr>
+#include <osg/Node>
+#include <osg/Group>
+#include <osg/Geode>
+#include <osg/OccluderNode>
+
+#include <vector>
+
+/**
+ An helper macro that defines the methods like effectName() and effectDescription()
+ making them return the strings passed as parameters, after the usual library name
+ and class name.
+ */
+#define META_Effect(library, classname, effectname, effectdescription, effectauthor) \
+    META_Node(library, classname) \
+    virtual const char *effectName() const        { return effectname; } \
+    virtual const char *effectDescription() const { return effectdescription; } \
+    virtual const char *effectAuthor() const      { return effectauthor; }
+
+
+namespace osgFX
+{
+
+    /**
+     The base class for special effects. An effect is basically a collection of
+     state attributes and an interface for configuring them in a predefined
+     fashion. The Effect class does more however, as it handles multipass
+     rendering transparently and it allows more than one "technique" to be
+     defined. Each technique tries to implement the effect in a different way,
+     often using different OpenGL extensions. The active technique can be
+     selected either manually, with selectTechnique(), or automatically, in which
+     case the first technique that is supported by all active rendering contexts 
+     is chosen.
+     If you are an Effect user, then simply use it as a node group. Create an 
+     instance of your desired effect, add it to your scene graph and call its 
+     addChild() method to add a child node as you would do with a Group.
+     If you are an Effect developer, you will have to implement the method
+     define_techniques() to define the different techniques that can be used
+     for obtaining the desired effect. In define_techniques() you will usually
+     create one or more instances of custom classes derived from Technique and
+     you will add them to the effect with addTechnique(). The order is important:
+     techniques added first will have higher priority and will be used first as
+     soon as all rendering contexts support it.
+     */
+    class OSGFX_EXPORT Effect: public osg::Group {
+    public:
+        Effect();
+        Effect(const Effect &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY);
+
+        virtual inline bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast<const Effect *>(obj) != NULL; }
+        virtual inline const char *libraryName() const { return "osgFX"; }
+        virtual inline const char *className() const { return "Effect"; }
+
+        /** get the name of this effect */
+        virtual const char *effectName() const        = 0;
+        
+        /** get a brief description of this effect */
+        virtual const char *effectDescription() const = 0;
+
+        /** get the effect author's name */
+        virtual const char *effectAuthor() const      = 0;
+
+        /** get whether the effect is enabled or not */
+        inline bool getEnabled() const;
+
+        /** set whether the effect is enabled or not */
+        inline void setEnabled(bool v);
+        
+        /**
+         optional: set effect parameters to produce a visually significant
+         result to be used in demo applications like osgfxbrowser. Default
+         is to do nothing.
+        */
+        inline virtual void setUpDemo()   {}
+
+        /** get the number of techniques defined for this effect */
+        inline int getNumTechniques() const;
+        
+        /** get the i-th technique */
+        inline Technique *getTechnique(int i);
+
+        /** get the i-th const technique */
+        inline const Technique *getTechnique(int i) const;
+
+        /** get the index of the currently selected technique */
+        inline int getSelectedTechnique() const;
+
+        enum TechniqueSelection {
+            AUTO_DETECT = -1
+        };
+
+        /** select a technique or enable automatic detection */
+        inline void selectTechnique(int i = AUTO_DETECT);
+
+        /** custom traversal */
+        virtual void traverse(osg::NodeVisitor &nv);        
+
+        /** default traversal */
+        inline void inherited_traverse(osg::NodeVisitor &nv);
+
+    protected:
+        virtual ~Effect();
+        Effect &operator=(const Effect &) { return *this; }
+       
+        /** force rebuilding of techniques on next traversal */
+        inline void dirtyTechniques();
+
+        /** add a technique to the effect */
+        inline void addTechnique(Technique *tech);
+
+        /**
+         abstract method to be implemented in derived classes; its purpose
+         if to create the techniques that can be used for obtaining the
+         desired effect. You will usually call addTechnique() inside
+         this method.
+         */
+        virtual bool define_techniques() = 0;
+        
+    private:
+        friend class Validator;
+
+        bool enabled_;
+
+        typedef std::vector<osg::ref_ptr<Technique> > Technique_list;
+        Technique_list techs_;
+
+        mutable osg::buffered_value<int> sel_tech_;
+
+        // use int instead of bool to avoid errors
+        mutable osg::buffered_value<int> tech_selected_;
+        
+        int global_sel_tech_;
+
+        bool techs_defined_;
+
+        osg::ref_ptr<osg::Geode> dummy_for_validation_;
+        
+        void build_dummy_node();
+    };
+
+    // INLINE METHODS
+
+    inline bool Effect::getEnabled() const
+    {
+        return enabled_;
+    }
+
+    inline void Effect::setEnabled(bool v)
+    {
+        enabled_ = v;
+    }
+    
+    inline int Effect::getNumTechniques() const
+    {
+        return static_cast<int>(techs_.size());
+    }
+
+    inline Technique *Effect::getTechnique(int i)
+    {
+        return techs_[i].get();
+    }
+
+    inline const Technique *Effect::getTechnique(int i) const
+    {
+        return techs_[i].get();
+    }
+
+    inline int Effect::getSelectedTechnique() const
+    {
+        return global_sel_tech_;
+    }
+
+    inline void Effect::selectTechnique(int i)
+    {
+        global_sel_tech_ = i;
+    }
+
+    inline void Effect::addTechnique(Technique *tech)
+    {
+        techs_.push_back(tech);
+    }
+    
+    inline void Effect::dirtyTechniques()
+    {
+        techs_defined_ = false;
+    }
+    
+    inline void Effect::inherited_traverse(osg::NodeVisitor &nv)
+    {
+        typedef osg::Group inherited;
+        inherited::traverse(nv);
+    }
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/CullVisitor
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/CullVisitor (revision 3230)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/CullVisitor (revision 3230)
@@ -0,0 +1,392 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_CULLVISITOR
+#define OSGUTIL_CULLVISITOR 1
+
+#include <map>
+#include <vector>
+
+#include <osg/NodeVisitor>
+#include <osg/BoundingSphere>
+#include <osg/BoundingBox>
+#include <osg/Matrix>
+#include <osg/Drawable>
+#include <osg/StateSet>
+#include <osg/State>
+#include <osg/Impostor>
+#include <osg/ClearNode>
+#include <osg/Notify>
+
+#include <osg/CullStack>
+
+#include <osgUtil/RenderGraph>
+#include <osgUtil/RenderStage>
+
+#include <osg/Vec3>
+
+namespace osgUtil {
+
+/**
+ * Basic NodeVisitor implementation for rendering a scene.
+ * This visitor traverses the scene graph, collecting transparent and
+ * opaque osg::Drawables into a depth sorted transparent bin and a state
+ * sorted opaque bin.  The opaque bin is rendered first, and then the
+ * transparent bin in rendered in order from the furthest osg::Drawable
+ * from the eye to the one nearest the eye. 
+ */
+class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStack
+{
+    public:
+    
+        typedef osg::Matrix::value_type value_type;
+    
+
+        CullVisitor();
+        virtual ~CullVisitor();
+
+        virtual CullVisitor* cloneType() const { return new CullVisitor(); }
+
+        virtual void reset();
+
+        virtual osg::Vec3 getEyePoint() const { return getEyeLocal(); }
+        virtual float getDistanceToEyePoint(const osg::Vec3& pos, bool withLODScale) const;
+        virtual float getDistanceFromEyePoint(const osg::Vec3& pos, bool withLODScale) const;
+
+        virtual void apply(osg::Node&);
+        virtual void apply(osg::Geode& node);
+        virtual void apply(osg::Billboard& node);
+        virtual void apply(osg::LightSource& node);
+        virtual void apply(osg::ClipNode& node);
+        virtual void apply(osg::TexGenNode& node);
+
+        virtual void apply(osg::Group& node);
+        virtual void apply(osg::Transform& node);
+        virtual void apply(osg::Projection& node);
+        virtual void apply(osg::Switch& node);
+        virtual void apply(osg::LOD& node);
+        virtual void apply(osg::ClearNode& node);
+        virtual void apply(osg::OccluderNode& node);
+        virtual void apply(osg::Impostor& node);
+
+        void setClearNode(const osg::ClearNode* earthSky) { _clearNode = earthSky; }
+        const osg::ClearNode* getClearNode() const { return _clearNode.get(); }
+
+        /** Push state set on the current state group.
+          * If the state exists in a child state group of the current
+          * state group then move the current state group to that child.
+          * Otherwise, create a new state group for the state set, add
+          * it to the current state group then move the current state
+          * group pointer to the new state group.
+          */
+        inline void pushStateSet(const osg::StateSet* ss)
+        {
+            _currentRenderGraph = _currentRenderGraph->find_or_insert(ss);
+            if (ss->useRenderBinDetails())
+            {
+                _currentRenderBin = _currentRenderBin->find_or_insert(ss->getBinNumber(),ss->getBinName());
+            }
+        }
+        
+        /** Pop the top state set and hence associated state group.
+          * Move the current state group to the parent of the popped
+          * state group.
+          */
+        inline void popStateSet()
+        {
+            if (_currentRenderGraph->_stateset->useRenderBinDetails())
+            {
+                _currentRenderBin = _currentRenderBin->getParent();
+            }
+            _currentRenderGraph = _currentRenderGraph->_parent;
+        }
+        
+        inline void setRenderGraph(RenderGraph* rg)
+        {
+            _rootRenderGraph = rg;
+            _currentRenderGraph = rg;
+        }
+
+        inline RenderGraph* getRootRenderGraph()
+        {
+            return _rootRenderGraph.get();
+        }
+
+        inline RenderGraph* getCurrentRenderGraph()
+        {
+            return _currentRenderGraph;
+        }
+
+        inline void setRenderStage(RenderStage* rg)
+        {
+            _rootRenderStage = rg;
+            _currentRenderBin = rg;
+        }
+
+        inline RenderStage* getRenderStage()
+        {
+            return _rootRenderStage.get();
+        }
+
+        inline RenderBin* getCurrentRenderBin()
+        {
+            return _currentRenderBin;
+        }
+
+        inline void setCurrentRenderBin(RenderBin* rb)
+        {
+            _currentRenderBin = rb;
+        }
+
+        inline value_type getCalculatedNearPlane() const { return _computed_znear; }
+        
+        inline value_type getCalculatedFarPlane() const { return _computed_zfar; }
+
+        value_type computeNearestPointInFrustum(const osg::Matrix& matrix, const osg::Polytope::PlaneList& planes,const osg::Drawable& drawable);
+
+	bool updateCalculatedNearFar(const osg::Matrix& matrix,const osg::BoundingBox& bb);
+
+	bool updateCalculatedNearFar(const osg::Matrix& matrix,const osg::Drawable& drawable, bool isBillboard=false);
+        
+    	void updateCalculatedNearFar(const osg::Vec3& pos);
+		
+        /** Add a drawable to current render graph.*/
+        inline void addDrawable(osg::Drawable* drawable,osg::RefMatrix* matrix);
+
+        /** Add a drawable and depth to current render graph.*/
+        inline void addDrawableAndDepth(osg::Drawable* drawable,osg::RefMatrix* matrix,float depth);
+
+        /** Add an attribute which is positioned related to the modelview matrix.*/
+        inline void addPositionedAttribute(osg::RefMatrix* matrix,const osg::StateAttribute* attr);
+
+        /** Add an attribute which is positioned related to the modelview matrix.*/
+        inline void addPositionedTextureAttribute(unsigned int textureUnit, osg::RefMatrix* matrix,const osg::StateAttribute* attr);
+
+        /** reimplement CullStack's popProjectionMatrix() adding clamping of the projection matrix to the computed near and far.*/
+        virtual void popProjectionMatrix();
+        
+
+        /** CullVisitor's default clamping of the projection float matrix to computed near and far values.
+          * Note, do not call this method directly, use clampProjectionMatrix(..) instead, unless you want to bypass the callback.*/
+        virtual bool clampProjectionMatrixImplementation(osg::Matrixf& projection, double& znear, double& zfar) const;
+
+        /** CullVisitor's default clamping of the projection double matrix to computed near and far values.
+          * Note, do not call this method directly, use clampProjectionMatrix(..) instead, unless you want to bypass the callback.*/
+        virtual bool clampProjectionMatrixImplementation(osg::Matrixd& projection, double& znear, double& zfar) const;
+
+        /** clamp the projection float matrix to computed near and far values, use callback if it exists, otherwise use default CullVisitro implemntation.*/
+        inline bool clampProjectionMatrix(osg::Matrixf& projection, value_type& znear, value_type& zfar) const
+        {
+            double zn = znear;
+            double zf = zfar;
+            bool result = false;
+            if (_clampProjectionMatrixCallback.valid()) result = _clampProjectionMatrixCallback->clampProjectionMatrixImplementation(projection, zn, zf);
+            else result = clampProjectionMatrixImplementation(projection, zn, zf);
+
+            if (result)
+            {
+                znear = zn;
+                zfar = zn;
+                return true;
+            }
+            else 
+                return false;
+        }
+
+        /** clamp the projection double matrix to computed near and far values, use callback if it exists, otherwise use default CullVisitro implemntation.*/
+        inline bool clampProjectionMatrix(osg::Matrixd& projection, value_type& znear, value_type& zfar) const
+        {
+            double zn = znear;
+            double zf = zfar;
+            bool result = false;
+
+            if (_clampProjectionMatrixCallback.valid()) result = _clampProjectionMatrixCallback->clampProjectionMatrixImplementation(projection, zn, zf);
+            else result = clampProjectionMatrixImplementation(projection, zn, zf);
+
+            if (result)
+            {
+                znear = zn;
+                zfar = zn;
+                return true;
+            }
+            else 
+                return false;
+        }
+        
+
+        void setState(osg::State* state) { _state = state; }
+        osg::State* getState() { return _state.get(); }
+        const osg::State* getState() const { return _state.get(); }
+
+    protected:
+
+//         /** prevent unwanted copy construction.*/
+//         CullVisitor(const CullVisitor&): osg::NodeVisitor(), osg::CullStack() {}
+
+        /** prevent unwanted copy operator.*/
+        CullVisitor& operator = (const CullVisitor&) { return *this; }
+        
+        inline void handle_cull_callbacks_and_traverse(osg::Node& node)
+        {
+            osg::NodeCallback* callback = node.getCullCallback();
+            if (callback) (*callback)(&node,this);
+            else traverse(node);
+        }
+
+        inline void handle_cull_callbacks_and_accept(osg::Node& node,osg::Node* acceptNode)
+        {
+            osg::NodeCallback* callback = node.getCullCallback();
+            if (callback) (*callback)(&node,this);
+            else acceptNode->accept(*this);
+        }
+
+
+        /** create an impostor sprite by setting up a pre-rendering stage
+          * to generate the impostor texture. */
+        osg::ImpostorSprite* createImpostorSprite(osg::Impostor& node);
+
+        osg::ref_ptr<const osg::ClearNode>                          _clearNode;
+
+        osg::ref_ptr<RenderGraph>                                   _rootRenderGraph;
+        RenderGraph*                                                _currentRenderGraph;
+
+        osg::ref_ptr<RenderStage>                                   _rootRenderStage;        
+        RenderBin*                                                  _currentRenderBin;
+
+
+        value_type               _computed_znear;
+        value_type               _computed_zfar;
+        
+        
+	typedef std::vector< osg::ref_ptr<RenderLeaf> > RenderLeafList;
+	RenderLeafList _reuseRenderLeafList;
+	unsigned int _currentReuseRenderLeafIndex;
+	
+	inline RenderLeaf* createOrReuseRenderLeaf(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* matrix, float depth=0.0f);
+        
+        osg::ref_ptr<osg::ImpostorSpriteManager>    _impostorSpriteManager;
+
+        osg::ref_ptr<osg::State>                    _state;
+
+
+        struct MatrixPlanesDrawables
+        {
+            MatrixPlanesDrawables(const osg::Matrix& matrix, const osg::Drawable* drawable, const osg::Polytope& frustum):
+                _matrix(matrix),
+                _drawable(drawable)
+            {
+                // create a new list of planes from the active walls of the frustum.
+                osg::Polytope::ClippingMask result_mask = frustum.getResultMask();
+                osg::Polytope::ClippingMask selector_mask = 0x1;
+                for(osg::Polytope::PlaneList::const_iterator itr=frustum.getPlaneList().begin();
+                    itr!=frustum.getPlaneList().end();
+                    ++itr)
+                {
+                    if (result_mask&selector_mask) _planes.push_back(*itr);
+                    selector_mask <<= 1; 
+                }
+            }
+            
+            MatrixPlanesDrawables(const MatrixPlanesDrawables& mpd):
+                _matrix(mpd._matrix),
+                _drawable(mpd._drawable),
+                _planes(mpd._planes) {}
+                
+            MatrixPlanesDrawables& operator = (const MatrixPlanesDrawables& mpd)
+            {
+                _matrix = mpd._matrix;
+                _drawable = mpd._drawable;
+                _planes = mpd._planes;
+                return *this;
+            }
+            
+            osg::Matrix                 _matrix;
+            const osg::Drawable*        _drawable;
+            osg::Polytope::PlaneList    _planes;
+        };
+        
+        typedef std::multimap<value_type, MatrixPlanesDrawables>   DistanceMatrixDrawableMap;
+        DistanceMatrixDrawableMap                                  _nearPlaneCandidateMap;
+	
+};
+
+inline void CullVisitor::addDrawable(osg::Drawable* drawable,osg::RefMatrix* matrix)
+{
+    if (_currentRenderGraph->leaves_empty())
+    {
+        // this is first leaf to be added to RenderGraph
+        // and therefore should not already know to current render bin,
+        // so need to add it.
+        _currentRenderBin->addRenderGraph(_currentRenderGraph);
+    }
+    //_currentRenderGraph->addLeaf(new RenderLeaf(drawable,matrix));
+    _currentRenderGraph->addLeaf(createOrReuseRenderLeaf(drawable,_projectionStack.back().get(),matrix));
+}
+
+/** Add a drawable and depth to current render graph.*/
+inline void CullVisitor::addDrawableAndDepth(osg::Drawable* drawable,osg::RefMatrix* matrix,float depth)
+{
+    if (_currentRenderGraph->leaves_empty())
+    {
+        // this is first leaf to be added to RenderGraph
+        // and therefore should not already know to current render bin,
+        // so need to add it.
+        _currentRenderBin->addRenderGraph(_currentRenderGraph);
+    }
+    //_currentRenderGraph->addLeaf(new RenderLeaf(drawable,matrix,depth));
+    _currentRenderGraph->addLeaf(createOrReuseRenderLeaf(drawable,_projectionStack.back().get(),matrix,depth));
+}
+
+/** Add an attribute which is positioned related to the modelview matrix.*/
+inline void CullVisitor::addPositionedAttribute(osg::RefMatrix* matrix,const osg::StateAttribute* attr)
+{
+    _currentRenderBin->getStage()->addPositionedAttribute(matrix,attr);
+}
+
+/** Add an attribute which is positioned related to the modelview matrix.*/
+inline void CullVisitor::addPositionedTextureAttribute(unsigned int textureUnit, osg::RefMatrix* matrix,const osg::StateAttribute* attr)
+{
+    _currentRenderBin->getStage()->addPositionedTextureAttribute(textureUnit,matrix,attr);
+}
+
+inline RenderLeaf* CullVisitor::createOrReuseRenderLeaf(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* matrix, float depth)
+{
+    // skip of any already reused renderleaf.
+    while (_currentReuseRenderLeafIndex<_reuseRenderLeafList.size() && 
+           _reuseRenderLeafList[_currentReuseRenderLeafIndex]->referenceCount()>1)
+    {
+        osg::notify(osg::NOTICE)<<"Warning:createOrReuseRenderLeaf() skipping multiply refrenced entry."<< std::endl;
+        ++_currentReuseRenderLeafIndex;
+    }
+
+    // if still within list, element must be singularly referenced
+    // there return it to be reused.
+    if (_currentReuseRenderLeafIndex<_reuseRenderLeafList.size())
+    {
+        RenderLeaf* renderleaf = _reuseRenderLeafList[_currentReuseRenderLeafIndex++].get();
+        renderleaf->set(drawable,projection,matrix,depth);
+        return renderleaf;
+    }
+
+    // otherwise need to create new renderleaf.
+    RenderLeaf* renderleaf = new RenderLeaf(drawable,projection,matrix,depth);
+    _reuseRenderLeafList.push_back(renderleaf);
+    ++_currentReuseRenderLeafIndex;
+    return renderleaf;
+}
+
+
+}
+
+#endif
+
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/IntersectVisitor
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/IntersectVisitor (revision 1629)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/IntersectVisitor (revision 1629)
@@ -0,0 +1,157 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_INTERSECTVISITOR
+#define OSGUTIL_INTERSECTVISITOR 1
+
+#include <osg/NodeVisitor>
+#include <osg/LineSegment>
+#include <osg/Geode>
+#include <osg/Matrix>
+
+#include <osgUtil/Export>
+
+#include <map>
+#include <set>
+#include <vector>
+
+namespace osgUtil {
+
+
+class OSGUTIL_EXPORT Hit
+{
+    public:
+
+        Hit();
+        Hit(const Hit& hit);
+        ~Hit();
+        
+        Hit& operator = (const Hit& hit);
+        
+        typedef std::vector<int> VecIndexList;
+
+        bool operator < (const Hit& hit) const
+        {
+            if (_originalLineSegment<hit._originalLineSegment) return true;
+            if (_originalLineSegment>hit._originalLineSegment) return false;
+            return _ratio<hit._ratio;
+        }
+        
+        
+        const osg::Vec3& getLocalIntersectPoint() const { return _intersectPoint; }
+        const osg::Vec3& getLocalIntersectNormal() const { return _intersectNormal; }
+        
+        const osg::Vec3 getWorldIntersectPoint() const { if (_matrix.valid()) return _intersectPoint*(*_matrix); else return _intersectPoint; }
+        const osg::Vec3 getWorldIntersectNormal() const ;
+
+        float                           _ratio;
+        osg::ref_ptr<osg::LineSegment>  _originalLineSegment;
+        osg::ref_ptr<osg::LineSegment>  _localLineSegment;
+        osg::NodePath                   _nodePath;
+        osg::ref_ptr<osg::Geode>        _geode;
+        osg::ref_ptr<osg::Drawable>     _drawable;
+        osg::ref_ptr<osg::RefMatrix>    _matrix;
+        osg::ref_ptr<osg::RefMatrix>    _inverse;
+        
+        VecIndexList                    _vecIndexList;
+        int                             _primitiveIndex;
+        osg::Vec3                       _intersectPoint;
+        osg::Vec3                       _intersectNormal;
+
+
+};
+
+
+/** Basic visitor for ray based collisions of a scene.*/
+class OSGUTIL_EXPORT IntersectVisitor : public osg::NodeVisitor
+{
+    public:
+
+        IntersectVisitor();
+        virtual ~IntersectVisitor();
+
+        void reset();
+        
+        /** Add a line segment to use for intersection testing during scene traversal.*/
+        void addLineSegment(osg::LineSegment* seg);
+
+        //typedef std::multiset<Hit> HitList;
+        typedef std::vector<Hit> HitList;
+        typedef std::map<osg::LineSegment*,HitList > LineSegmentHitListMap;
+        HitList& getHitList(osg::LineSegment* seg) { return _segHitList[seg]; }
+        int getNumHits(osg::LineSegment* seg) { return _segHitList[seg].size(); }
+
+        bool hits();
+
+        virtual void apply(osg::Node&);
+        virtual void apply(osg::Geode& node);
+        virtual void apply(osg::Billboard& node);
+
+        virtual void apply(osg::Group& node);
+        virtual void apply(osg::Transform& node);
+        virtual void apply(osg::Switch& node);
+        virtual void apply(osg::LOD& node);
+
+    protected:
+
+        class IntersectState : public osg::Referenced
+        {
+            public:
+
+                IntersectState();
+
+                osg::ref_ptr<osg::RefMatrix> _matrix;
+                osg::ref_ptr<osg::RefMatrix> _inverse;
+
+                typedef std::pair<osg::ref_ptr<osg::LineSegment>,osg::ref_ptr<osg::LineSegment> >   LineSegmentPair;
+                typedef std::vector< LineSegmentPair >                                              LineSegmentList;
+                LineSegmentList _segList;
+
+                typedef unsigned int LineSegmentMask;
+                typedef std::vector<LineSegmentMask> LineSegmentMaskStack;
+                LineSegmentMaskStack _segmentMaskStack;
+
+                bool isCulled(const osg::BoundingSphere& bs,LineSegmentMask& segMaskOut);
+                bool isCulled(const osg::BoundingBox& bb,LineSegmentMask& segMaskOut);
+
+                void addLineSegmentPair(osg::LineSegment* first,osg::LineSegment* second)
+                {
+                    _segList.push_back(LineSegmentPair(first,second));
+                }
+
+            protected:
+
+                ~IntersectState();
+
+        };
+
+        bool intersect(osg::Drawable& gset);
+
+        void pushMatrix(const osg::Matrix& matrix);
+        void popMatrix();
+
+        bool enterNode(osg::Node& node);
+        void leaveNode();
+
+        typedef std::vector<osg::ref_ptr<IntersectState> > IntersectStateStack;
+        
+        IntersectStateStack         _intersectStateStack;
+
+        osg::NodePath               _nodePath;
+        LineSegmentHitListMap       _segHitList;
+};
+
+}
+
+#endif
+
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/Export
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/Export (revision 1704)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/Export (revision 1704)
@@ -0,0 +1,39 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+// The following symbol has a underscore suffix for compatibility.
+#ifndef OSGUTIL_EXPORT_
+#define OSGUTIL_EXPORT_ 1
+
+#if defined(_MSC_VER)
+    #pragma warning( disable : 4244 )
+    #pragma warning( disable : 4251 )
+    #pragma warning( disable : 4267 )
+    #pragma warning( disable : 4275 )
+    #pragma warning( disable : 4290 )
+    #pragma warning( disable : 4786 )
+    #pragma warning( disable : 4305 )
+#endif
+
+#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__)
+	#  ifdef OSGUTIL_LIBRARY
+	#    define OSGUTIL_EXPORT   __declspec(dllexport)
+	#  else
+	#    define OSGUTIL_EXPORT   __declspec(dllimport)
+	#endif /* OSGUTIL_LIBRARY */
+#else
+	#define OSGUTIL_EXPORT 
+#endif 
+
+#endif
+
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/Optimizer
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/Optimizer (revision 3203)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/Optimizer (revision 3203)
@@ -0,0 +1,459 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_OPTIMIZER
+#define OSGUTIL_OPTIMIZER
+
+#include <osg/NodeVisitor>
+#include <osg/Matrix>
+#include <osg/Geometry>
+#include <osg/Transform>
+
+#include <osgUtil/Export>
+
+#include <set>
+
+namespace osgUtil {
+
+/** Insert impostor nodes into scene graph.
+  * For example of usage see src/Demos/osgimpostor.
+  */
+  
+class OSGUTIL_EXPORT Optimizer
+{
+
+    public:
+
+        Optimizer() {}
+        virtual ~Optimizer() {}
+
+        enum OptimizationOptions
+        {
+            FLATTEN_STATIC_TRANSFORMS = 0x001,
+            REMOVE_REDUNDANT_NODES =    0x002,
+            COMBINE_ADJACENT_LODS =     0x004,
+            SHARE_DUPLICATE_STATE =     0x008,
+            MERGE_GEOMETRY =            0x010,
+            CHECK_GEOMETRY =            0x020,
+            SPATIALIZE_GROUPS =         0x040,
+            COPY_SHARED_NODES =         0x080,
+            TRISTRIP_GEOMETRY =         0x100,
+            TESSELATE_GEOMETRY =        0x200,
+            OPTIMIZE_TEXTURE_SETTINGS = 0x400,
+            DEFAULT_OPTIMIZATIONS = FLATTEN_STATIC_TRANSFORMS |
+                                REMOVE_REDUNDANT_NODES |
+                                COMBINE_ADJACENT_LODS |
+                                SHARE_DUPLICATE_STATE |
+                                MERGE_GEOMETRY |
+                                CHECK_GEOMETRY |
+                                OPTIMIZE_TEXTURE_SETTINGS,
+            ALL_OPTIMIZATIONS = FLATTEN_STATIC_TRANSFORMS |
+                                REMOVE_REDUNDANT_NODES |
+                                COMBINE_ADJACENT_LODS |
+                                SHARE_DUPLICATE_STATE |
+                                MERGE_GEOMETRY |
+                                CHECK_GEOMETRY |
+                                SPATIALIZE_GROUPS |
+                                COPY_SHARED_NODES |
+                                TRISTRIP_GEOMETRY |
+                                OPTIMIZE_TEXTURE_SETTINGS
+        };
+
+        /** reset internal data to initial state - the getPrimissableOptionsMap is cleared.*/
+        void reset();
+        
+        /** traverse the node and its subgraph with a series of optimization
+          * visitors, specificied by the OptizationOptions.*/
+        void optimize(osg::Node* node);
+
+        /** traverse the node and its subgraph with a series of optimization
+          * visitors, specificied by the OptizationOptions.*/
+        virtual void optimize(osg::Node* node, unsigned int options);
+
+
+        inline void setPermissableOptimizationsForObject(const osg::Object* object, unsigned int options)
+        {
+            _permissableOptimizationsMap[object] = options;
+        }
+        
+        inline unsigned int getPermissableOptimizationsForObject(const osg::Object* object) const
+        {
+            PermissableOptimizationsMap::const_iterator itr = _permissableOptimizationsMap.find(object);
+            if (itr!=_permissableOptimizationsMap.end()) return itr->second;
+            else return 0xffffffff;
+        }
+        
+        inline bool isOperationPermissableForObject(const osg::Object* object,unsigned int option) const
+        {
+            return (option & getPermissableOptimizationsForObject(object))!=0; 
+        }
+        
+        typedef std::map<const osg::Object*,unsigned int> PermissableOptimizationsMap;
+
+        PermissableOptimizationsMap& getPrimissableOptionsMap() { return _permissableOptimizationsMap; }
+        const PermissableOptimizationsMap& getPrimissableOptionsMap() const { return _permissableOptimizationsMap; }
+        
+        
+    protected:
+    
+        PermissableOptimizationsMap _permissableOptimizationsMap;
+
+
+    public:
+
+
+        /** Flatten Static Trasform nodes by applying their transform to the
+          * geometry on the leaves of the scene graph, then removing the 
+          * now redundant transforms.*/        
+        class OSGUTIL_EXPORT FlattenStaticTransformsVisitor : public osg::NodeVisitor
+        {
+            public:
+
+
+
+                FlattenStaticTransformsVisitor(Optimizer* optimizer=0):
+                    osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
+                    _optimizer(optimizer) {}
+
+                virtual void apply(osg::Node& geode);
+                virtual void apply(osg::Geode& geode);
+                virtual void apply(osg::Billboard& geode);
+                virtual void apply(osg::Transform& transform);
+
+                bool removeTransforms(osg::Node* nodeWeCannotRemove);
+
+                inline bool isOperationPermissableForObject(const osg::Object* object) const
+                {
+                    return _optimizer ? _optimizer->isOperationPermissableForObject(object,FLATTEN_STATIC_TRANSFORMS) :  true; 
+                }
+
+            
+            protected:
+
+                typedef std::vector<osg::Transform*>                TransformStack;
+                typedef std::set<osg::Drawable*>                    DrawableSet;
+                typedef std::set<osg::Billboard*>                   BillboardSet;
+                typedef std::set<osg::Node* >                       NodeSet;
+                typedef std::set<osg::Transform*>                   TransformSet;
+                
+                Optimizer*      _optimizer;
+                TransformStack  _transformStack;
+                NodeSet         _excludedNodeSet;
+                DrawableSet     _drawableSet;
+                BillboardSet    _billboardSet;
+                TransformSet    _transformSet;
+        };
+
+
+        /** Combine Static Trasform nodes that sit above on another.*/        
+        class OSGUTIL_EXPORT CombineStaticTransformsVisitor : public osg::NodeVisitor
+        {
+            public:
+
+                CombineStaticTransformsVisitor(Optimizer* optimizer=0):
+                    osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
+                    _optimizer(optimizer) {}
+
+                virtual void apply(osg::MatrixTransform& transform);
+
+                bool removeTransforms(osg::Node* nodeWeCannotRemove);
+
+                inline bool isOperationPermissableForObject(const osg::Object* object) const
+                {
+                    return _optimizer ? _optimizer->isOperationPermissableForObject(object,FLATTEN_STATIC_TRANSFORMS) :  true; 
+                }
+
+            protected:
+
+                typedef std::set<osg::MatrixTransform*> TransformSet;
+                Optimizer*      _optimizer;
+                TransformSet  _transformSet;
+        };
+
+        /** Remove rendundant nodes, such as groups with one single child.*/
+        class OSGUTIL_EXPORT RemoveEmptyNodesVisitor : public osg::NodeVisitor
+        {
+            public:
+
+
+                typedef std::set<osg::Node*> NodeList;
+                NodeList                     _redundantNodeList;
+
+                RemoveEmptyNodesVisitor(Optimizer* optimizer=0):
+                    osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
+                    _optimizer(optimizer) {}
+
+                virtual void apply(osg::Geode& geode);
+                virtual void apply(osg::Group& group);
+                
+                void removeEmptyNodes();
+
+                inline bool isOperationPermissableForObject(const osg::Object* object) const
+                {
+                    return _optimizer ? _optimizer->isOperationPermissableForObject(object,REMOVE_REDUNDANT_NODES) :  true; 
+                }
+
+                Optimizer*      _optimizer;
+        };
+
+        /** Remove rendundant nodes, such as groups with one single child.*/
+        class OSGUTIL_EXPORT RemoveRedundantNodesVisitor : public osg::NodeVisitor
+        {
+            public:
+
+                typedef std::set<osg::Node*> NodeList;
+                NodeList                     _redundantNodeList;
+
+                RemoveRedundantNodesVisitor(Optimizer* optimizer=0):
+                    osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
+                    _optimizer(optimizer) {}
+                
+                virtual void apply(osg::Group& group);
+                virtual void apply(osg::Transform& transform);
+                
+                void removeRedundantNodes();
+
+                inline bool isOperationPermissableForObject(const osg::Object* object) const
+                {
+                    return _optimizer ? _optimizer->isOperationPermissableForObject(object,REMOVE_REDUNDANT_NODES) :  true; 
+                }
+
+                Optimizer*      _optimizer;
+        };
+
+        /** Tesselate all geodes, to remove POLYGONS
+          * complementary ranges.*/
+        class OSGUTIL_EXPORT TesselateVisitor : public osg::NodeVisitor
+        {
+            public:
+
+                typedef std::set<osg::Group*>  GroupList;
+                GroupList                      _groupList;
+
+                TesselateVisitor():osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}
+
+                virtual void apply(osg::Geode& geode);
+
+        };
+
+        /** Optimize the LOD groups, by combining adjacent LOD's which have
+          * complementary ranges.*/
+        class OSGUTIL_EXPORT CombineLODsVisitor : public osg::NodeVisitor
+        {
+            public:
+
+                typedef std::set<osg::Group*>  GroupList;
+                GroupList                      _groupList;
+
+                CombineLODsVisitor(Optimizer* optimizer=0):
+                    osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
+                    _optimizer(optimizer) {}
+
+                virtual void apply(osg::LOD& lod);
+
+                void combineLODs();
+
+                inline bool isOperationPermissableForObject(const osg::Object* object) const
+                {
+                    return _optimizer ? _optimizer->isOperationPermissableForObject(object,COMBINE_ADJACENT_LODS) :  true; 
+                }
+
+                Optimizer*      _optimizer;
+        };
+ 
+        /** Optimize State in the scene graph by removing duplicate state,
+          * replacing it with shared instances, both for StateAttributes,
+          * and whole StateSets.*/
+        class OSGUTIL_EXPORT StateVisitor : public osg::NodeVisitor
+        {
+            public:
+
+                /// default to traversing all children.
+                StateVisitor(Optimizer* optimizer=0):
+                    osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
+                    _optimizer(optimizer) {}
+
+                /** empty visitor, make it ready for next traversal.*/        
+                virtual void reset();
+
+                virtual void apply(osg::Node& node);
+
+                virtual void apply(osg::Geode& geode);
+
+                void optimize();
+
+                inline bool isOperationPermissableForObject(const osg::Object* object) const
+                {
+                    return _optimizer ? _optimizer->isOperationPermissableForObject(object,SHARE_DUPLICATE_STATE) :  true; 
+                }
+
+            protected:
+
+                void addStateSet(osg::StateSet* stateset,osg::Object* obj);
+
+                typedef std::set<osg::Object*>              ObjectSet;
+                typedef std::map<osg::StateSet*,ObjectSet>  StateSetMap;
+
+                Optimizer*      _optimizer;
+                StateSetMap _statesets;
+
+        };
+        
+        class OSGUTIL_EXPORT CheckGeometryVisitor : public osg::NodeVisitor
+        {
+            public:
+
+                /// default to traversing all children.
+                CheckGeometryVisitor(Optimizer* optimizer=0):
+                    osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
+                    _optimizer(optimizer) {}
+
+                virtual void apply(osg::Geode& geode) { checkGeode(geode); }
+
+                void checkGeode(osg::Geode& geode);
+                
+                inline bool isOperationPermissableForObject(const osg::Object* object) const
+                {
+                    return _optimizer ? _optimizer->isOperationPermissableForObject(object,CHECK_GEOMETRY) :  true; 
+                }
+
+                Optimizer*      _optimizer;
+
+        };
+        
+        class OSGUTIL_EXPORT MergeGeometryVisitor : public osg::NodeVisitor
+        {
+            public:
+
+                /// default to traversing all children.
+                MergeGeometryVisitor(Optimizer* optimizer=0) :
+                    osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
+                    _optimizer(optimizer) {}
+
+                virtual void apply(osg::Geode& geode) { mergeGeode(geode); }
+                virtual void apply(osg::Billboard&) { /* don't do anything*/ }
+
+                bool mergeGeode(osg::Geode& geode);
+
+                static bool geometryContainsSharedArrays(osg::Geometry& geom);
+
+                static bool mergeGeometry(osg::Geometry& lhs,osg::Geometry& rhs);
+
+                static bool mergePrimitive(osg::DrawArrays& lhs,osg::DrawArrays& rhs);
+                static bool mergePrimitive(osg::DrawArrayLengths& lhs,osg::DrawArrayLengths& rhs);
+                static bool mergePrimitive(osg::DrawElementsUByte& lhs,osg::DrawElementsUByte& rhs);
+                static bool mergePrimitive(osg::DrawElementsUShort& lhs,osg::DrawElementsUShort& rhs);
+                static bool mergePrimitive(osg::DrawElementsUInt& lhs,osg::DrawElementsUInt& rhs);
+
+                inline bool isOperationPermissableForObject(const osg::Object* object) const
+                {
+                    return _optimizer ? _optimizer->isOperationPermissableForObject(object,MERGE_GEOMETRY) :  true; 
+                }
+
+                Optimizer*      _optimizer;
+        };
+
+        /** Spatialize scene into a balanced quad/oct tree.*/
+        class OSGUTIL_EXPORT SpatializeGroupsVisitor : public osg::NodeVisitor
+        {
+            public:
+
+                SpatializeGroupsVisitor(Optimizer* optimizer=0):
+                    osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
+                    _optimizer(optimizer) {}
+                
+                virtual void apply(osg::Group& group);
+                
+                bool divide(unsigned int maxNumTreesPerCell=8);
+                
+                bool divide(osg::Group* group, unsigned int maxNumTreesPerCell);
+                
+                typedef std::set<osg::Group*> GroupsToDivideList;
+                GroupsToDivideList _groupsToDivideList;
+
+                inline bool isOperationPermissableForObject(const osg::Object* object) const
+                {
+                    return _optimizer ? _optimizer->isOperationPermissableForObject(object,SPATIALIZE_GROUPS) :  true; 
+                }
+
+                Optimizer*      _optimizer;
+
+        };
+
+        /** Copy any shared subgraphs, enabling flattening of static transforms.*/
+        class OSGUTIL_EXPORT CopySharedSubgraphsVisitor : public osg::NodeVisitor
+        {
+            public:
+
+                CopySharedSubgraphsVisitor(Optimizer* optimizer=0):
+                    osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
+                    _optimizer(optimizer) {}
+                
+                virtual void apply(osg::Node& node);
+
+                void copySharedNodes();
+                
+                typedef std::set<osg::Node*> SharedNodeList;
+                SharedNodeList _sharedNodeList;
+                
+                inline bool isOperationPermissableForObject(const osg::Object* object) const
+                {
+                    return _optimizer ? _optimizer->isOperationPermissableForObject(object,COPY_SHARED_NODES) :  true; 
+                }
+
+                Optimizer*      _optimizer;
+
+        };
+
+
+        /** For all textures apply settings.*/
+        class OSGUTIL_EXPORT TextureVisitor : public osg::NodeVisitor
+        {
+            public:
+
+                TextureVisitor(bool changeAutoUnRef, bool valueAutoUnRef,
+                               bool changeClientImageStorage, bool valueClientImageStorage,
+                               bool changeAnisotropy, float valueAnisotropy,
+                               Optimizer* optimizer=0):
+                        osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
+                        _optimizer(optimizer),
+                        _changeAutoUnRef(changeAutoUnRef), _valueAutoUnRef(valueAutoUnRef),
+                        _changeClientImageStorage(changeClientImageStorage), _valueClientImageStorage(valueClientImageStorage),
+                        _changeAnisotropy(changeAnisotropy), _valueAnisotropy(valueAnisotropy) {}
+                
+                virtual void apply(osg::Geode& node);
+                virtual void apply(osg::Node& node);
+
+                void apply(osg::StateSet& stateset);
+                void apply(osg::Texture& texture);
+                
+                inline bool isOperationPermissableForObject(const osg::Object* object) const
+                {
+                    return _optimizer ? _optimizer->isOperationPermissableForObject(object,OPTIMIZE_TEXTURE_SETTINGS) :  true; 
+                }
+
+                Optimizer*      _optimizer;
+                bool            _changeAutoUnRef, _valueAutoUnRef;
+                bool            _changeClientImageStorage, _valueClientImageStorage;
+                bool            _changeAnisotropy;
+                float           _valueAnisotropy;
+                                           
+                
+
+        };
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/TangentSpaceGenerator
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/TangentSpaceGenerator (revision 3032)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/TangentSpaceGenerator (revision 3032)
@@ -0,0 +1,71 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_TANGENTSPACEGENERATOR_
+#define OSGUTIL_TANGENTSPACEGENERATOR_
+
+#include <osgUtil/Export>
+
+#include <osg/ref_ptr>
+#include <osg/Referenced>
+#include <osg/Array>
+#include <osg/Geometry>
+
+namespace osgUtil
+{
+
+	/**
+	 This class generates three arrays containing tangent-space basis vectors. It takes
+	 a texture-mapped Geometry object as input, traverses its primitive sets and computes
+	 Tangent, Normal and Binormal vectors for each vertex, storing them into arrays.
+	 The resulting arrays can be used as vertex program varying (per-vertex) parameters,
+	 enabling advanced effects like bump-mapping.
+	 To use this class, simply call the generate() method specifying the Geometry object
+	 you want to process and the texture unit that contains UV mapping for the normal map;
+	 then you can retrieve the TBN arrays by calling getTangentArray(), getNormalArray()
+	 and getBinormalArray() methods.
+	 */
+	class OSGUTIL_EXPORT TangentSpaceGenerator: public osg::Referenced {
+	public:
+		TangentSpaceGenerator();
+		TangentSpaceGenerator(const TangentSpaceGenerator &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY);
+
+		void generate(osg::Geometry *geo, int normal_map_tex_unit = 0);
+
+		inline osg::Vec4Array *getTangentArray()               { return T_.get(); }
+		inline const osg::Vec4Array *getTangentArray() const   { return T_.get(); }
+		inline void setTangentArray(osg::Vec4Array *array)     { T_ = array; }
+
+		inline osg::Vec4Array *getNormalArray()                { return N_.get(); }
+		inline const osg::Vec4Array *getNormalArray() const    { return N_.get(); }
+		inline void setNormalArray(osg::Vec4Array *array)      { N_ = array; }
+
+		inline osg::Vec4Array *getBinormalArray()              { return B_.get(); }
+		inline const osg::Vec4Array *getBinormalArray() const  { return B_.get(); }
+		inline void setBinormalArray(osg::Vec4Array *array)    { B_ = array; }
+
+	protected:
+		virtual ~TangentSpaceGenerator() {}
+		TangentSpaceGenerator &operator=(const TangentSpaceGenerator &) { return *this; }
+
+		void compute_basis_vectors(osg::PrimitiveSet *pset, const osg::Array *vx, const osg::Array *nx, const osg::Array *tx, int iA, int iB, int iC);
+
+	private:
+		osg::ref_ptr<osg::Vec4Array> T_;
+		osg::ref_ptr<osg::Vec4Array> B_;
+		osg::ref_ptr<osg::Vec4Array> N_;
+	};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/CubeMapGenerator
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/CubeMapGenerator (revision 3035)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/CubeMapGenerator (revision 3035)
@@ -0,0 +1,121 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+#ifndef OSGUTIL_CUBEMAPGENERATOR_
+#define OSGUTIL_CUBEMAPGENERATOR_
+
+#include <osgUtil/Export>
+
+#include <osg/Vec3>
+#include <osg/Vec4>
+#include <osg/CopyOp>
+#include <osg/Referenced>
+#include <osg/TextureCubeMap>
+#include <osg/Image>
+#include <osg/Notify>
+
+#include <vector>
+
+namespace osgUtil
+{
+
+    /** This is the base class for cube map generators. 
+        It exposes the necessary interface to access the six generated images;
+        descendants    should only override the compute_color() method.
+    */
+    class OSGUTIL_EXPORT CubeMapGenerator: public osg::Referenced {
+    public:
+        explicit CubeMapGenerator(int texture_size = 64);
+        CubeMapGenerator(const CubeMapGenerator &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY);
+
+        inline osg::Image *getImage(osg::TextureCubeMap::Face face);
+        inline const osg::Image *getImage(osg::TextureCubeMap::Face face) const;
+
+        /** generate the six cube images. 
+            If use_osg_system is true, then the OSG's coordinate system is used instead 
+            of the default OpenGL one.
+        */
+        void generateMap(bool use_osg_system = true);
+
+    protected:
+        virtual ~CubeMapGenerator() {}
+        CubeMapGenerator &operator=(const CubeMapGenerator &) { return *this; }
+
+        inline void set_pixel(int index, int c, int r, const osg::Vec4 &color);
+        inline static osg::Vec4 vector_to_color(const osg::Vec3 &vec);        
+
+        /** override this method to define how colors are computed. 
+            The parameter R is the reflection vector, pointing from the center of the cube.
+            The return value should be the RGBA color associated with that reflection ray.
+        */
+        virtual osg::Vec4 compute_color(const osg::Vec3 &R) const = 0;
+
+    private:
+        int texture_size_;
+
+        typedef std::vector<osg::ref_ptr<osg::Image> > Image_list;
+        Image_list images_;        
+    };
+
+    // INLINE METHODS
+
+    inline osg::Image *CubeMapGenerator::getImage(osg::TextureCubeMap::Face face)
+    {
+        switch (face) {
+            case osg::TextureCubeMap::POSITIVE_X: return images_[0].get();
+            case osg::TextureCubeMap::NEGATIVE_X: return images_[1].get();
+            case osg::TextureCubeMap::POSITIVE_Y: return images_[2].get();
+            case osg::TextureCubeMap::NEGATIVE_Y: return images_[3].get();
+            case osg::TextureCubeMap::POSITIVE_Z: return images_[4].get();
+            case osg::TextureCubeMap::NEGATIVE_Z: return images_[5].get();            
+            default: return 0;
+        }
+    }
+
+    inline const osg::Image *CubeMapGenerator::getImage(osg::TextureCubeMap::Face face) const
+    {
+        switch (face) {
+            case osg::TextureCubeMap::POSITIVE_X: return images_[0].get();
+            case osg::TextureCubeMap::NEGATIVE_X: return images_[1].get();
+            case osg::TextureCubeMap::POSITIVE_Y: return images_[2].get();
+            case osg::TextureCubeMap::NEGATIVE_Y: return images_[3].get();
+            case osg::TextureCubeMap::POSITIVE_Z: return images_[4].get();
+            case osg::TextureCubeMap::NEGATIVE_Z: return images_[5].get();            
+            default: return 0;
+        }
+    }
+
+    inline void CubeMapGenerator::set_pixel(int index, int c, int r, const osg::Vec4 &color)
+    {
+        osg::Image *i = images_[index].get();
+        if (i) {
+            *(i->data(c, r)+0) = static_cast<unsigned char>(osg::clampBetween(color.x(),0.0f,1.0f) * 255);
+            *(i->data(c, r)+1) = static_cast<unsigned char>(osg::clampBetween(color.y(),0.0f,1.0f) * 255);
+            *(i->data(c, r)+2) = static_cast<unsigned char>(osg::clampBetween(color.z(),0.0f,1.0f) * 255);
+            *(i->data(c, r)+3) = static_cast<unsigned char>(osg::clampBetween(color.w(),0.0f,1.0f) * 255);            
+        } else {
+            osg::notify(osg::WARN) << "Warning: CubeMapGenerator::set_pixel(): invalid image index\n";
+        }
+    }
+
+    inline osg::Vec4 CubeMapGenerator::vector_to_color(const osg::Vec3 &vec)
+    {
+        return osg::Vec4(
+            vec.x() / vec.length() / 2 + 0.5f,
+            vec.y() / vec.length() / 2 + 0.5f,
+            vec.z() / vec.length() / 2 + 0.5f,
+            1);
+    }
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/Version
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/Version (revision 1529)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/Version (revision 1529)
@@ -0,0 +1,48 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_VERSION
+#define OSGUTIL_VERSION 1
+
+#include <osgUtil/Export>
+
+
+extern "C" {
+
+/**
+ * getVersion_osgUtil() returns the library version number.
+ * Numbering convention : osg_src-0.8-31 will return 0.8.31 from getVersion_osgUtil.
+ *
+ * This C function can be also used to check for the existence of the OpenSceneGraph
+ * library using autoconf and its m4 macro AC_CHECK_LIB.
+ *
+ * Here is the code to add to your configure.in:
+ \verbatim
+ #
+ # Check for the OpenSceneGraph (OSG) utility library
+ #
+ AC_CHECK_LIB(osg, osgUtilGetVersion, ,
+    [AC_MSG_ERROR(OpenSceneGraph utility library not found. See http://www.openscenegraph.org)],)
+ \endverbatim
+*/
+extern OSGUTIL_EXPORT const char* osgUtilGetVersion();
+
+/**
+ * getLibraryName_osgUtil() returns the library name in human friendly form.
+*/
+extern OSGUTIL_EXPORT const char* osgUtilGetLibraryName();
+
+}
+
+#endif
+
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/Tesselator
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/Tesselator (revision 3209)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/Tesselator (revision 3209)
@@ -0,0 +1,231 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_Tesselator
+#define OSGUTIL_Tesselator
+
+#include <osg/Geometry>
+
+#include <osgUtil/Export>
+
+#include <osg/GLU>
+
+#include <vector>
+
+/* Win32 calling conventions. (or a least thats what the GLUT example tess.c uses.)*/
+#ifndef CALLBACK
+#define CALLBACK
+#endif
+
+
+namespace osgUtil {
+
+/** Originally a simple class for tessellating a single polygon boundary.
+  * Using old style glu tessellation functions for portability.
+  * Upgraded Jan 2004 to use the modern glu tessellation functions.*/
+
+class OSGUTIL_EXPORT Tesselator : public osg::Referenced
+{
+    public:
+   
+        Tesselator();
+        ~Tesselator();
+
+        /** The winding rule, see red book ch 11. */
+        enum WindingType{
+            TESS_WINDING_ODD          = GLU_TESS_WINDING_ODD,
+            TESS_WINDING_NONZERO      = GLU_TESS_WINDING_NONZERO     ,
+            TESS_WINDING_POSITIVE     = GLU_TESS_WINDING_POSITIVE    ,
+            TESS_WINDING_NEGATIVE     = GLU_TESS_WINDING_NEGATIVE    ,
+            TESS_WINDING_ABS_GEQ_TWO  =    GLU_TESS_WINDING_ABS_GEQ_TWO
+        } ;
+
+        /** we interpret all contours in the geometry as a single set to be tesselated or
+         * each separate drawable's contours needs to be tesselated. */
+        enum TesselationType {
+            TESS_TYPE_GEOMETRY, // tesselate everything in the geometry object
+            TESS_TYPE_DRAWABLE, // tesselate each polygon, triangles & quads drawables in geometry separately
+            TESS_TYPE_POLYGONS // tesselate ONLY polygon drawables in geometry separately
+        };
+
+        /** Set and get tesselation request boundary only on/off */
+        void setBoundaryOnly (const bool tt) { _boundaryOnly=tt;}
+        inline const bool getBoundaryOnly ( ) { return _boundaryOnly;}
+
+        /** Set and get tesselation windong rule */
+        void setWindingType (const WindingType wt) { _wtype=wt;}
+        inline const WindingType getWindingType ( ) { return _wtype;}
+
+        /** Set and get tesselation type */
+        void setTesselationType (const TesselationType tt) { _ttype=tt;}
+        inline const TesselationType getTesselationType ( ) { return _ttype;}
+
+        /** Change the contours lists of the geometry into tesselated primitives (the
+          * list of primitives in the original geometry is stored in the tesselator for
+          * possible re-use. 
+          * The name remains retesselatePolygons although it now handles trifans, strips, quads etc.
+          * as well as Polygons so as to not break old codes relying on this function name. */
+        void retesselatePolygons(osg::Geometry &cxgeom);
+
+        osg::Geometry::PrimitiveSetList  getContours() { return _Contours;}
+
+        typedef std::vector<osg::Vec3*> VertexPointList;
+        
+        struct Prim : public osg::Referenced
+        {
+            Prim(GLenum mode):_mode(mode) {}
+        
+            typedef std::vector<osg::Vec3*> VecList;
+
+            GLenum  _mode;
+            VecList _vertices;
+        };
+        
+        void beginTesselation();
+        
+        void beginContour();
+        void addVertex(osg::Vec3* vertex);
+        void endContour();
+        
+        void endTesselation();
+
+        typedef std::vector< osg::ref_ptr<Prim> > PrimList;
+        
+        PrimList& getPrimList() { return _primList; }        
+        
+        void reset();
+        
+    protected:
+
+        /** remove unused parts of the array, eg for wehn retesselating
+         * tesselation can introduce extra vertices for concave or crossing boundaries,
+         * these will leak memory if not removed when retesselating. */
+        void reduceArray(osg::Array * cold, const unsigned int nnu);
+
+        void collectTesselation(osg::Geometry &cxgeom);
+        
+        typedef std::map<osg::Vec3*,unsigned int> VertexPtrToIndexMap;
+        void addContour(osg::PrimitiveSet* primitive, osg::Vec3Array* vertices);
+        void handleNewVertices(osg::Geometry& geom,VertexPtrToIndexMap &vertexPtrToIndexMap);
+
+        void begin(GLenum mode);
+        void vertex(osg::Vec3* vertex);
+        void combine(osg::Vec3* vertex,void* vertex_data[4],GLfloat weight[4]);
+        void end();
+        void error(GLenum errorCode);
+
+    
+        static void CALLBACK beginCallback(GLenum which, void* userData);
+        static void CALLBACK vertexCallback(GLvoid *data, void* userData);
+        static void CALLBACK combineCallback(GLdouble coords[3], void* vertex_data[4],
+                              GLfloat weight[4], void** outData,
+                              void* useData);
+        static void CALLBACK endCallback(void* userData);
+        static void CALLBACK errorCallback(GLenum errorCode, void* userData);
+        
+        
+        struct Vec3d
+        {
+            double _v[3];
+        };
+
+
+        struct NewVertex
+        {
+        
+            NewVertex():
+                _vpos(0),
+                _f1(0),
+                _v1(0),
+                _f2(0),
+                _v2(0),
+                _f3(0),
+                _v3(0),
+                _f4(0),
+                _v4(0) {}
+            
+            NewVertex(const NewVertex& nv):
+                _vpos(nv._vpos),
+                _f1(nv._f1),
+                _v1(nv._v1),
+                _f2(nv._f2),
+                _v2(nv._v2),
+                _f3(nv._f3),
+                _v3(nv._v3),
+                _f4(nv._f4),
+                _v4(nv._v4) {}
+
+            NewVertex(osg::Vec3* vx,
+                      float f1,osg::Vec3* v1,
+                      float f2,osg::Vec3* v2,
+                      float f3,osg::Vec3* v3,
+                      float f4,osg::Vec3* v4):
+                _vpos(vx),
+                _f1(f1),
+                _v1(v1),
+                _f2(f2),
+                _v2(v2),
+                _f3(f3),
+                _v3(v3),
+                _f4(f4),
+                _v4(v4) {}
+
+            osg::Vec3  *_vpos; // added gwm Jan 2004 the vertex coords s.t. NewVertex can be used in a std::vector
+        
+            float       _f1;
+            osg::Vec3*  _v1;
+
+            float       _f2;
+            osg::Vec3*  _v2;
+
+            float       _f3;
+            osg::Vec3*  _v3;
+
+            float       _f4;
+            osg::Vec3*  _v4;
+            
+        };
+        
+        //change NewVertexList from std::map<osg::Vec3*,NewVertex> NewVertexList;
+        // because this has undefined order of insertion for new vertices. 
+        // which occasionally corrupted the texture mapping.
+        typedef std::vector<NewVertex> NewVertexList;
+        typedef std::vector<Vec3d*> Vec3dList;
+
+        GLUtesselator*  _tobj;
+        PrimList        _primList;
+        Vec3dList       _coordData;
+        NewVertexList   _newVertexList;
+        GLenum          _errorCode;
+
+        /** winding rule, which parts will become solid */
+        WindingType _wtype; 
+
+        /** tesselation rule, which parts will become solid */
+        TesselationType _ttype;
+
+        bool _boundaryOnly; // see gluTessProperty - if true: make the boundary edges only.
+
+        /** number of vertices that are part of the 'original' set of contours */
+        unsigned int _numberVerts;
+
+        /** List of primitives that define the contours */
+        osg::Geometry::PrimitiveSetList                _Contours;
+
+        /** count number of primitives in a geometry to get right no. of norms/colurs etc for per_primitive attributes. */
+        unsigned int _index;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/SmoothingVisitor
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/SmoothingVisitor (revision 3230)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/SmoothingVisitor (revision 3230)
@@ -0,0 +1,46 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_SMOOTHINGVISITOR
+#define OSGUTIL_SMOOTHINGVISITOR 1
+
+#include <osg/NodeVisitor>
+#include <osg/Geode>
+#include <osg/Geometry>
+
+#include <osgUtil/Export>
+
+namespace osgUtil {
+
+/** A smoothing visitor for calculating smoothed normals for
+  * osg::GeoSet's which contains surface primitives.
+  */
+class OSGUTIL_EXPORT SmoothingVisitor : public osg::NodeVisitor
+{
+    public:
+
+        /// default to traversing all children.
+        SmoothingVisitor();
+        virtual ~SmoothingVisitor();
+        
+        /// smooth geoset by creating per vertex normals.
+        static void smooth(osg::Geometry& geoset);
+
+        /// apply smoothing method to all geode geosets.
+        virtual void apply(osg::Geode& geode);
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/RenderToTextureStage
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/RenderToTextureStage (revision 1529)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/RenderToTextureStage (revision 1529)
@@ -0,0 +1,66 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_RENDERTOTEXTURESTAGE
+#define OSGUTIL_RENDERTOTEXTURESTAGE 1
+
+#include <osg/Texture2D>
+
+#include <osgUtil/RenderStage>
+
+namespace osgUtil {
+
+/**
+ * RenderStage which copies the final image to an attached texture or image.
+ * Generally used as a pre-rendering stage.
+ */
+class OSGUTIL_EXPORT RenderToTextureStage : public RenderStage
+{
+    public:
+    
+
+        RenderToTextureStage();
+        
+
+        virtual osg::Object* cloneType() const { return new RenderToTextureStage(); }
+        virtual osg::Object* clone(const osg::CopyOp&) const { return new RenderToTextureStage(); } // note only implements a clone of type.
+        virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RenderToTextureStage*>(obj)!=0L; }
+        virtual const char* libraryName() const { return "osgUtil"; }
+        virtual const char* className() const { return "RenderToTextureStage"; }
+
+        virtual void reset();
+        
+        void setTexture(osg::Texture2D* texture) { _texture = texture; }
+        osg::Texture2D* getTexture() { return _texture.get(); }
+        
+        void setImage(osg::Image* image) { _image = image; }
+        osg::Image* getImage() { return _image.get(); }
+
+        virtual void draw(osg::State& state,RenderLeaf*& previous);
+
+    public:
+        
+        
+    protected:
+    
+        virtual ~RenderToTextureStage();
+        
+        osg::ref_ptr<osg::Texture2D> _texture;
+        osg::ref_ptr<osg::Image> _image;
+
+};
+
+}
+
+#endif
+
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/TransformCallback
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/TransformCallback (revision 2408)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/TransformCallback (revision 2408)
@@ -0,0 +1,50 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+//C++ header 
+
+#ifndef OSGUTIL_TRANSFORMCALLBACK
+#define OSGUTIL_TRANSFORMCALLBACK 1
+
+#include <osg/Node>
+#include <osgUtil/Export>
+
+namespace osgUtil
+{
+
+class OSGUTIL_EXPORT TransformCallback : public osg::NodeCallback
+{
+
+    public:
+
+        TransformCallback(const osg::Vec3& pivot,const osg::Vec3& axis,float angularVelocity);
+
+        void setPause(bool pause) { _pause = pause; }
+
+        /** implements the callback*/
+        virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
+
+    protected:
+    
+        float               _angular_velocity;
+        osg::Vec3           _pivot;
+        osg::Vec3           _axis;
+
+        int                 _previousTraversalNumber;
+        double              _previousTime;
+        bool                _pause;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/SceneView
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/SceneView (revision 3214)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/SceneView (revision 3214)
@@ -0,0 +1,485 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_SCENEVIEW
+#define OSGUTIL_SCENEVIEW 1
+
+#include <osg/Node>
+#include <osg/StateSet>
+#include <osg/Light>
+#include <osg/FrameStamp>
+#include <osg/DisplaySettings>
+#include <osg/CollectOccludersVisitor>
+#include <osg/CullSettings>
+
+#include <osgUtil/CullVisitor>
+
+namespace osgUtil {
+
+/**
+ * SceneView is literally a view of a scene, encapsulating the
+ * camera (modelview+projection matrices), global state, lights and the scene itself.  Provides
+ * methods for setting up the view and rendering it.
+*/
+class OSGUTIL_EXPORT SceneView : public osg::Referenced, public osg::CullSettings
+{
+    public:
+
+        /** Construct a default scene view.*/
+        SceneView(osg::DisplaySettings* ds=NULL);
+
+        enum Options
+        {
+            NO_SCENEVIEW_LIGHT = 0x0,
+            HEADLIGHT = 0x1,
+            SKY_LIGHT = 0x2,
+            COMPILE_GLOBJECTS_AT_INIT = 0x4,
+            STANDARD_SETTINGS = HEADLIGHT |
+                                COMPILE_GLOBJECTS_AT_INIT                                
+        };
+
+        /** Set scene view to use default global state, light, camera
+         *  and render visitor.
+        */
+        void setDefaults(unsigned int options = STANDARD_SETTINGS);
+
+        /** Set the data which to view. The data will typically be
+         *  an osg::Scene but can be any osg::Node type.
+         */
+        void setSceneData(osg::Node* node) { _sceneData = node; }
+        /** Get the scene data which to view. The data will typically be
+         *  an osg::Scene but can be any osg::Node type.
+         */
+        osg::Node* getSceneData() { return _sceneData.get(); }
+
+        /** Get the const scene data which to view. The data will typically be
+         *  an osg::Scene but can be any osg::Node type.
+         */
+        const osg::Node* getSceneData() const { return _sceneData.get(); }
+
+        /** Set the viewport of the scene view to use specfied osg::Viewport. */
+        void setViewport(osg::Viewport* viewport)
+        {
+            if (viewport) _viewport = viewport;
+            else
+            {
+                // ensure that _viewport is always valid.
+                _viewport = new osg::Viewport;
+            }
+        }
+
+        /** Set the viewport of the scene view to specified dimensions. */
+        void setViewport(int x,int y,int width,int height)
+        {
+            _viewport->setViewport(x,y,width,height);
+        }
+        
+
+        /** Get the const viewport. */
+        const osg::Viewport* getViewport() const { return _viewport.get(); }
+
+        /** Get the viewport. */
+        osg::Viewport* getViewport() { return _viewport.get(); }
+
+        /** Get the viewport of the scene view. */
+        void getViewport(int& x,int& y,int& width,int& height) const
+        {
+            _viewport->getViewport(x,y,width,height);
+        }
+
+        /** Set the DisplaySettings. */
+        inline void setDisplaySettings(osg::DisplaySettings* vs) { _displaySettings = vs; }
+        
+        /** Get the const DisplaySettings */
+        inline const osg::DisplaySettings* getDisplaySettings() const { return _displaySettings.get(); }
+
+        /** Get the DisplaySettings */
+        inline osg::DisplaySettings* getDisplaySettings() { return _displaySettings.get(); }
+
+
+#ifdef USE_DEPRECATED_API
+        /** Set the background color used in glClearColor().
+            Defaults to an off blue color.*/
+        void setBackgroundColor(const osg::Vec4& color) { _clearColor=color; }
+        /** Get the background color.*/
+        const osg::Vec4& getBackgroundColor() const { return _clearColor; }
+#endif
+
+        /** Set the color used in glClearColor().
+            Defaults to an off blue color.*/
+        void setClearColor(const osg::Vec4& color) { _clearColor=color; }
+        /** Get the color usinged in glClearColor.*/
+        const osg::Vec4& getClearColor() const { return _clearColor; }
+
+
+
+        void setGlobalStateSet(osg::StateSet* state) { _globalStateSet = state; }
+        osg::StateSet* getGlobalStateSet() { return _globalStateSet.get(); }
+        const osg::StateSet* getGlobalStateSet() const { return _globalStateSet.get(); }
+
+        void setLocalStateSet(osg::StateSet* state) { _localStateSet = state; }
+        osg::StateSet* getLocalStateSet() { return _localStateSet.get(); }
+        const osg::StateSet* getLocalStateSet() const { return _localStateSet.get(); }
+
+        typedef Options LightingMode;
+
+        void setLightingMode(LightingMode mode) { _lightingMode=mode; }
+        LightingMode getLightingMode() const { return _lightingMode; }
+
+        void setLight(osg::Light* light) { _light = light; }
+        osg::Light* getLight() { return _light.get(); }
+        const osg::Light* getLight() const { return _light.get(); }
+        
+        void setState(osg::State* state) { _state = state; }
+        osg::State* getState() { return _state.get(); }
+        const osg::State* getState() const { return _state.get(); }
+
+
+
+        /** Set the projection matrix. Can be thought of as setting the lens of a camera. */
+        inline void setProjectionMatrix(const osg::Matrixf& matrix) { _projectionMatrix.set(matrix); }
+
+        /** Set the projection matrix. Can be thought of as setting the lens of a camera. */
+        inline void setProjectionMatrix(const osg::Matrixd& matrix) { _projectionMatrix.set(matrix); }
+
+        /** Set to a orthographic projection. See OpenGL glOrtho for documentation further details.*/
+        void setProjectionMatrixAsOrtho(double left, double right,
+                                        double bottom, double top,
+                                        double zNear, double zFar);
+
+        /** Set to a 2D orthographic projection. See OpenGL glOrtho2D documentation for further details.*/
+        void setProjectionMatrixAsOrtho2D(double left, double right,
+                                          double bottom, double top);
+
+        /** Set to a perspective projection. See OpenGL glFrustum documentation for further details.*/
+        void setProjectionMatrixAsFrustum(double left, double right,
+                                          double bottom, double top,
+                                          double zNear, double zFar);
+
+        /** Create a symmetrical perspective projection, See OpenGL gluPerspective documentation for further details.
+          * Aspect ratio is defined as width/height.*/
+        void setProjectionMatrixAsPerspective(double fovy,double aspectRatio,
+                                              double zNear, double zFar);
+
+        /** Get the projection matrix.*/
+        osg::Matrixd& getProjectionMatrix() { return _projectionMatrix; }
+
+        /** Get the const projection matrix.*/
+        const osg::Matrixd& getProjectionMatrix() const { return _projectionMatrix; }
+
+        /** Get the othorgraphic settings of the orthographic projection matrix. 
+          * Returns false if matrix is not an orthographic matrix, where parameter values are undefined.*/
+        bool getProjectionMatrixAsOrtho(double& left, double& right,
+                                        double& bottom, double& top,
+                                        double& zNear, double& zFar);
+
+        /** Get the frustum setting of a perspective projection matrix.
+          * Returns false if matrix is not a perspective matrix, where parameter values are undefined.*/
+        bool getProjectionMatrixAsFrustum(double& left, double& right,
+                                          double& bottom, double& top,
+                                          double& zNear, double& zFar);
+
+        /** Get the frustum setting of a symetric perspective projection matrix.
+          * Returns false if matrix is not a perspective matrix, where parameter values are undefined. 
+          * Note, if matrix is not a symetric perspective matrix then the shear will be lost.
+          * Asymetric metrices occur when stereo, power walls, caves and reality center display are used.
+          * In these configuration one should use the AsFrustum method instead.*/
+        bool getProjectionMatrixAsPerspective(double& fovy,double& aspectRatio,
+                                              double& zNear, double& zFar);
+
+
+        /** Set the view matrix. Can be thought of as setting the position of the world relative to the camera in camera coordinates. */
+        inline void setViewMatrix(const osg::Matrixf& matrix) { _viewMatrix.set(matrix); }
+        
+        /** Set the view matrix. Can be thought of as setting the position of the world relative to the camera in camera coordinates. */
+        inline void setViewMatrix(const osg::Matrixd& matrix) { _viewMatrix.set(matrix); }
+
+        /** Set to the position and orientation of view matrix, using the same convention as gluLookAt. */
+        void setViewMatrixAsLookAt(const osg::Vec3& eye,const osg::Vec3& center,const osg::Vec3& up);
+
+        /** Get the view matrix. */
+        osg::Matrixd& getViewMatrix() { return _viewMatrix; }
+
+        /** Get the const view matrix. */
+        const osg::Matrixd& getViewMatrix() const { return _viewMatrix; }
+
+        /** Get to the position and orientation of a modelview matrix, using the same convention as gluLookAt. */
+        void getViewMatrixAsLookAt(osg::Vec3& eye,osg::Vec3& center,osg::Vec3& up,float lookDistance=1.0f);
+
+
+
+        
+        void setInitVisitor(osg::NodeVisitor* av) { _initVisitor = av; }
+        osg::NodeVisitor* getInitVisitor() { return _initVisitor.get(); }
+        const osg::NodeVisitor* getInitVisitor() const { return _initVisitor.get(); }
+
+
+        void setUpdateVisitor(osg::NodeVisitor* av) { _updateVisitor = av; }
+        osg::NodeVisitor* getUpdateVisitor() { return _updateVisitor.get(); }
+        const osg::NodeVisitor* getUpdateVisitor() const { return _updateVisitor.get(); }
+
+
+        void setCullVisitor(osgUtil::CullVisitor* cv) { _cullVisitor = cv; }
+        osgUtil::CullVisitor* getCullVisitor() { return _cullVisitor.get(); }
+        const osgUtil::CullVisitor* getCullVisitor() const { return _cullVisitor.get(); }
+
+        void setCullVisitorLeft(osgUtil::CullVisitor* cv) { _cullVisitorLeft = cv; }
+        osgUtil::CullVisitor* getCullVisitorLeft() { return _cullVisitorLeft.get(); }
+        const osgUtil::CullVisitor* getCullVisitorLeft() const { return _cullVisitorLeft.get(); }
+
+        void setCullVisitorRight(osgUtil::CullVisitor* cv) { _cullVisitorRight = cv; }
+        osgUtil::CullVisitor* getCullVisitorRight() { return _cullVisitorRight.get(); }
+        const osgUtil::CullVisitor* getCullVisitorRight() const { return _cullVisitorRight.get(); }
+        
+        void setCollectOccludersVisitor(osg::CollectOccludersVisitor* cov) { _collectOccludersVisistor = cov; }
+        osg::CollectOccludersVisitor* getCollectOccludersVisitor() { return _collectOccludersVisistor.get(); }
+        const osg::CollectOccludersVisitor* getCollectOccludersVisitor() const { return _collectOccludersVisistor.get(); }
+
+
+        void setRenderGraph(osgUtil::RenderGraph* rg) { _rendergraph = rg; }
+        osgUtil::RenderGraph* getRenderGraph() { return _rendergraph.get(); }
+        const osgUtil::RenderGraph* getRenderGraph() const { return _rendergraph.get(); }
+
+        void setRenderGraphLeft(osgUtil::RenderGraph* rg) { _rendergraphLeft = rg; }
+        osgUtil::RenderGraph* getRenderGraphLeft() { return _rendergraphLeft.get(); }
+        const osgUtil::RenderGraph* getRenderGraphLeft() const { return _rendergraphLeft.get(); }
+
+        void setRenderGraphRight(osgUtil::RenderGraph* rg) { _rendergraphRight = rg; }
+        osgUtil::RenderGraph* getRenderGraphRight() { return _rendergraphRight.get(); }
+        const osgUtil::RenderGraph* getRenderGraphRight() const { return _rendergraphRight.get(); }
+
+
+        void setRenderStage(osgUtil::RenderStage* rs) { _renderStage = rs; }
+        osgUtil::RenderStage* getRenderStage() { return _renderStage.get(); }
+        const osgUtil::RenderStage* getRenderStage() const { return _renderStage.get(); }
+
+        void setRenderStageLeft(osgUtil::RenderStage* rs) { _renderStageLeft = rs; }
+        osgUtil::RenderStage* getRenderStageLeft() { return _renderStageLeft.get(); }
+        const osgUtil::RenderStage* getRenderStageLeft() const { return _renderStageLeft.get(); }
+
+        void setRenderStageRight(osgUtil::RenderStage* rs) { _renderStageRight = rs; }
+        osgUtil::RenderStage* getRenderStageRight() { return _renderStageRight.get(); }
+        const osgUtil::RenderStage* getRenderStageRight() const { return _renderStageRight.get(); }
+
+
+        /** Set the draw buffer value used at the start of each frame draw.  Note, overridden in quad buffer stereo mode */
+        void setDrawBufferValue( GLenum drawBufferValue )
+        {
+            _drawBufferValue = drawBufferValue;
+        }
+
+        /** Get the draw buffer value used at the start of each frame draw. */
+        GLenum getDrawBufferValue() const
+        {
+            return _drawBufferValue;
+        }
+
+
+        /** FusionDistanceMode is used only when working in stereo.*/
+        enum FusionDistanceMode
+        {
+            /** Use fusion distance from the value set on the SceneView.*/
+            USE_FUSION_DISTANCE_VALUE,
+            /** Compute the fusion distance by multiplying the screen distance by the  fusion distance value.*/
+            PROPORTIONAL_TO_SCREEN_DISTANCE
+        };
+
+        /** Set the FusionDistanceMode and Value. Note, is used only when working in stereo.*/
+        void setFusionDistance(FusionDistanceMode mode,float value=1.0f)
+        {
+            _fusionDistanceMode = mode;
+            _fusionDistanceValue = value;
+        }
+
+        /** Get the FusionDistanceMode.*/
+        FusionDistanceMode getFusionDistanceMode() const { return _fusionDistanceMode; }
+
+        /** Get the FusionDistanceValue. Note, only used for USE_FUSION_DISTANCE_VALUE & PROPORTIONAL_TO_SCREEN_DISTANCE modes.*/
+        float getFusionDistanceValue() const { return _fusionDistanceValue; }
+
+
+        /** set whether the draw method should call renderer->prioritizeTexture.*/
+        void setPrioritizeTextures(bool pt) { _prioritizeTextures = pt; }
+        
+        /** get whether the draw method should call renderer->prioritizeTexture.*/
+        bool getPrioritizeTextures() const { return _prioritizeTextures; }
+
+        /** callback for overidding the default method for compute the offset projection and view matrices.*/
+        struct ComputeStereoMatricesCallback : public osg::Referenced
+        {
+            virtual osg::Matrixd computeLeftEyeProjection(const osg::Matrixd& projection) const = 0;
+            virtual osg::Matrixd computeLeftEyeView(const osg::Matrixd& view) const = 0;
+
+            virtual osg::Matrixd computeRightEyeProjection(const osg::Matrixd& projection) const = 0;
+            virtual osg::Matrixd computeRightEyeView(const osg::Matrixd& view) const = 0;
+        };
+        
+        void setComputeStereoMatricesCallback(ComputeStereoMatricesCallback* callback) { _computeStereoMatricesCallback=callback; }
+        ComputeStereoMatricesCallback* getComputeStereoMatricesCallback() { return _computeStereoMatricesCallback.get(); }
+        const ComputeStereoMatricesCallback* getComputeStereoMatricesCallback() const { return _computeStereoMatricesCallback.get(); }
+
+        /** Calculate, via glUnProject, the object coordinates of a window point.
+            Note, current implementation requires that SceneView::draw() has been previously called
+            for projectWindowIntoObject to produce valid values.  Consistent with OpenGL
+            windows coordinates are calculated relative to the bottom left of the window.
+            Returns true on successful projection.
+        */
+        bool projectWindowIntoObject(const osg::Vec3& window,osg::Vec3& object) const;
+
+        /** Calculate, via glUnProject, the object coordinates of a window x,y
+            when projected onto the near and far planes.
+            Note, current implementation requires that SceneView::draw() has been previously called
+            for projectWindowIntoObject to produce valid values.  Consistent with OpenGL
+            windows coordinates are calculated relative to the bottom left of the window.
+            Returns true on successful projection.
+        */
+        bool projectWindowXYIntoObject(int x,int y,osg::Vec3& near_point,osg::Vec3& far_point) const;
+
+        /** Calculate, via glProject, the object coordinates of a window.
+            Note, current implementation requires that SceneView::draw() has been previously called
+            for projectWindowIntoObject to produce valid values.  Consistent with OpenGL
+            windows coordinates are calculated relative to the bottom left of the window,
+            whereas as window API's normally have the top left as the origin,
+            so you may need to pass in (mouseX,window_height-mouseY,...).
+            Returns true on successful projection.
+        */
+        bool projectObjectIntoWindow(const osg::Vec3& object,osg::Vec3& window) const;
+
+
+        /** Set the frame stamp for the current frame.*/
+        inline void setFrameStamp(osg::FrameStamp* fs) { _frameStamp = fs; }
+
+        /** Set the frame stamp for the current frame.*/
+        inline const osg::FrameStamp* getFrameStamp() const { return _frameStamp.get(); }
+
+
+
+
+        inline osg::Matrixd computeLeftEyeProjection(const osg::Matrixd& projection)  const
+        {
+            if (_computeStereoMatricesCallback.valid()) return _computeStereoMatricesCallback->computeLeftEyeProjection(projection);
+            else return computeLeftEyeProjectionImplementation(projection);
+        }
+
+        inline osg::Matrixd computeLeftEyeView(const osg::Matrixd& view) const
+        {
+            if (_computeStereoMatricesCallback.valid()) return _computeStereoMatricesCallback->computeLeftEyeView(view);
+            else return computeLeftEyeViewImplementation(view);
+        }
+        
+        inline osg::Matrixd computeRightEyeProjection(const osg::Matrixd& projection)  const
+        {
+            if (_computeStereoMatricesCallback.valid()) return _computeStereoMatricesCallback->computeRightEyeProjection(projection);
+            else return computeRightEyeProjectionImplementation(projection);
+        }
+
+        inline osg::Matrixd computeRightEyeView(const osg::Matrixd& view) const
+        {
+            if (_computeStereoMatricesCallback.valid()) return _computeStereoMatricesCallback->computeRightEyeView(view);
+            else return computeRightEyeViewImplementation(view);
+        }
+
+        virtual osg::Matrixd computeLeftEyeProjectionImplementation(const osg::Matrixd& projection) const;
+        virtual osg::Matrixd computeLeftEyeViewImplementation(const osg::Matrixd& view) const;
+
+        virtual osg::Matrixd computeRightEyeProjectionImplementation(const osg::Matrixd& projection) const;
+        virtual osg::Matrixd computeRightEyeViewImplementation(const osg::Matrixd& view) const;
+
+
+        /** Do init traversal of attached scene graph using Init NodeVisitor.
+          * The init traversal is called once for each SceneView, and should
+          * be used to compile display list, texture objects intialize data
+          * not otherwise intializaed during scene graph loading. Note, is
+          * called automatically by update&cull if it hasn't already been called
+          * elsewhere. Also init() should only ever be called within a valid
+          * graphics context.*/
+        virtual void init();
+
+        /** Do app traversal of attached scene graph using App NodeVisitor.*/
+        virtual void update();
+
+        /** Do cull traversal of attached scene graph using Cull NodeVisitor.*/
+        virtual void cull();
+
+        /** Do draw traversal of draw bins generated by cull traversal.*/
+        virtual void draw();
+        
+        /** Flush all the OpenGL objects, such as texture objects, display lists etc.*/
+        virtual void flushDeletedGLObjects(double& availableTime);
+        
+    protected:
+
+        virtual ~SceneView();
+
+        /** Do cull traversal of attached scene graph using Cull NodeVisitor.*/
+        virtual void cullStage(const osg::Matrixd& projection,const osg::Matrixd& modelview,osgUtil::CullVisitor* cullVisitor, osgUtil::RenderGraph* rendergraph, osgUtil::RenderStage* renderStage);
+
+        const osg::Matrix computeMVPW() const;
+
+        void clearArea(int x,int y,int width,int height,const osg::Vec4& color);
+
+        osg::ref_ptr<osg::StateSet>                 _localStateSet;
+        osg::ref_ptr<osg::State>                    _state;
+        
+        osg::Matrixd                                _projectionMatrix;
+        osg::Matrixd                                _viewMatrix;
+        
+        bool                                        _initCalled;
+        osg::ref_ptr<osg::NodeVisitor>              _initVisitor;
+        osg::ref_ptr<osg::NodeVisitor>              _updateVisitor;
+        osg::ref_ptr<osgUtil::CullVisitor>          _cullVisitor;
+        osg::ref_ptr<osgUtil::RenderGraph>          _rendergraph;
+        osg::ref_ptr<osgUtil::RenderStage>          _renderStage;
+
+        osg::ref_ptr<ComputeStereoMatricesCallback> _computeStereoMatricesCallback;
+
+        osg::ref_ptr<osgUtil::CullVisitor>          _cullVisitorLeft;
+        osg::ref_ptr<osgUtil::RenderGraph>          _rendergraphLeft;
+        osg::ref_ptr<osgUtil::RenderStage>          _renderStageLeft;
+
+        osg::ref_ptr<osgUtil::CullVisitor>          _cullVisitorRight;
+        osg::ref_ptr<osgUtil::RenderGraph>          _rendergraphRight;
+        osg::ref_ptr<osgUtil::RenderStage>          _renderStageRight;
+
+        osg::ref_ptr<osg::CollectOccludersVisitor>  _collectOccludersVisistor;
+        
+        osg::ref_ptr<osg::FrameStamp>               _frameStamp;
+        
+
+        osg::ref_ptr<osg::Node>                     _sceneData;
+        osg::ref_ptr<osg::StateSet>                 _globalStateSet;
+        osg::ref_ptr<osg::Light>                    _light;
+        osg::ref_ptr<osg::DisplaySettings>          _displaySettings;
+        
+        osg::Vec4                                   _clearColor;
+
+
+        FusionDistanceMode                          _fusionDistanceMode;
+        float                                       _fusionDistanceValue;
+
+        osg::ref_ptr<osg::Viewport>                 _viewport;
+
+        LightingMode                                _lightingMode;
+        
+        bool                                        _prioritizeTextures;
+        
+        GLenum                                      _drawBufferValue;
+        
+        bool                                        _requiresFlush;
+        
+};
+
+}
+
+#endif
+
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/RenderStageLighting
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/RenderStageLighting (revision 3125)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/RenderStageLighting (revision 3125)
@@ -0,0 +1,73 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_RENDERSTAGELIGHTING
+#define OSGUTIL_RENDERSTAGELIGHTING 1
+
+#include <osg/Object>
+#include <osg/Light>
+#include <osg/State>
+
+#include <osgUtil/RenderLeaf>
+#include <osgUtil/RenderGraph>
+
+namespace osgUtil {
+
+/**
+ * RenderBin base class.
+ */
+class OSGUTIL_EXPORT RenderStageLighting : public osg::Object
+{
+    public:
+    
+
+        RenderStageLighting();
+        virtual osg::Object* cloneType() const { return new RenderStageLighting(); }
+        virtual osg::Object* clone(const osg::CopyOp&) const { return new RenderStageLighting(); } // note only implements a clone of type.
+        virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RenderStageLighting*>(obj)!=0L; }
+        virtual const char* libraryName() const { return "osgUtil"; }
+        virtual const char* className() const { return "RenderStageLighting"; }
+
+        virtual void reset();
+        
+        typedef std::pair< osg::ref_ptr<const osg::StateAttribute> , osg::ref_ptr<osg::RefMatrix> >    AttrMatrixPair;
+        typedef std::vector< AttrMatrixPair >                                            AttrMatrixList;
+        typedef std::map< unsigned int, AttrMatrixList >                                 TexUnitAttrMatrixListMap;
+
+        virtual void addPositionedAttribute(osg::RefMatrix* matrix,const osg::StateAttribute* attr)
+        {
+            _attrList.push_back(AttrMatrixPair(attr,matrix));
+        }
+
+        virtual void addPositionedTextureAttribute(unsigned int textureUnit, osg::RefMatrix* matrix,const osg::StateAttribute* attr)
+        {
+            _texAttrListMap[textureUnit].push_back(AttrMatrixPair(attr,matrix));
+        }
+
+        virtual void draw(osg::State& state,RenderLeaf*& previous);
+        
+    public:
+        
+        AttrMatrixList              _attrList;
+        TexUnitAttrMatrixListMap    _texAttrListMap;
+        
+    protected:
+    
+        virtual ~RenderStageLighting();
+
+};
+
+}
+
+#endif
+
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/DisplayRequirementsVisitor
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/DisplayRequirementsVisitor (revision 1529)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/DisplayRequirementsVisitor (revision 1529)
@@ -0,0 +1,62 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_DISPLAYREQUIREMENTSVISITOR
+#define OSGUTIL_DISPLAYREQUIREMENTSVISITOR 1
+
+#include <osg/NodeVisitor>
+#include <osg/Geode>
+#include <osg/DisplaySettings>
+
+#include <osgUtil/Export>
+
+namespace osgUtil {
+
+/** A visitor for traversing a scene graph establishing the OpenGL visuals are required
+  * to support rendering of that scene graph.  The results can then be used by
+  * applications to set up there windows with the correct visuals.  Have a look at
+  * src/osgGLUT/Viewer.cpp's Viewer::open() method for an example how to use it.
+  */
+class OSGUTIL_EXPORT DisplayRequirementsVisitor : public osg::NodeVisitor
+{
+    public:
+
+        /** Default to traversing all children, and reqiresDoubleBuffer,
+          * requiresRGB and requiresDepthBuffer to true and with
+          * alpha and stencil off.*/
+        DisplayRequirementsVisitor();
+        
+
+        /** Set the DisplaySettings. */
+        inline void setDisplaySettings(osg::DisplaySettings* ds) { _ds = ds; }
+        
+        /** Get the DisplaySettings */
+        inline const osg::DisplaySettings* getDisplaySettings() const { return _ds.get(); }
+        
+        virtual void applyStateSet(osg::StateSet& stateset);
+
+        virtual void apply(osg::Node& node);
+
+        virtual void apply(osg::Geode& geode);
+
+        virtual void apply(osg::Impostor& impostor);
+        
+    protected:
+    
+        osg::ref_ptr<osg::DisplaySettings> _ds;
+    
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/Statistics
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/Statistics (revision 2300)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/Statistics (revision 2300)
@@ -0,0 +1,191 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_STATISTICS
+#define OSGUTIL_STATISTICS 1
+
+#include <osg/Referenced>
+#include <osg/Drawable>
+
+#include <map>
+
+namespace osgUtil {
+
+/**
+ * Statistics base class. Used to extract primitive information from 
+ * the renderBin(s).  Add a case of getStats(osgUtil::Statistics *stat)
+ * for any new drawable (or drawable derived class) that you generate 
+ * (eg see Geometry.cpp).  There are 20 types of drawable counted - actually only
+ * 14 cases can occur in reality.  these represent sets of GL_POINTS, GL_LINES
+ * GL_LINESTRIPS, LOOPS, TRIANGLES, TRI-fans, tristrips, quads, quadstrips etc
+ * The number of triangles rendered is inferred:
+ * each triangle = 1 triangle (number of vertices/3)
+ * each quad = 2 triangles (nverts/2)
+ * each trifan or tristrip = (length-2) triangles and so on.
+ */
+
+class Statistics : public osg::Drawable::PrimitiveFunctor
+{
+    public:
+
+        typedef std::pair<unsigned int,unsigned int>    PrimitivePair;
+        typedef std::map<GLenum,PrimitivePair>          PrimtiveValueMap;
+        typedef std::map<GLenum, unsigned int>          PrimtiveCountMap;
+
+
+        Statistics()
+        {
+            reset();
+        };
+
+        enum statsType
+        {
+            STAT_NONE, // default
+            STAT_FRAMERATE, 
+            STAT_GRAPHS,
+            STAT_PRIMS, 
+            STAT_PRIMSPERVIEW, 
+            STAT_PRIMSPERBIN,
+            STAT_DC,
+            STAT_RESTART // hint to restart the stats
+        };
+        
+        void reset()
+        {
+            numDrawables=0, nummat=0; depth=0; stattype=STAT_NONE;
+            nlights=0; nbins=0; nimpostor=0;
+            
+            _vertexCount=0;
+            _primitiveCount.clear();            
+            
+            _currentPrimtiveFunctorMode=0;
+        }
+
+        void setType(statsType t) {stattype=t;}
+        
+        virtual void setVertexArray(unsigned int count,const osg::Vec3*) { _vertexCount += count; }
+        virtual void setVertexArray(unsigned int count,const osg::Vec2*) { _vertexCount += count; }
+        virtual void setVertexArray(unsigned int count,const osg::Vec4*) { _vertexCount += count; }
+
+        virtual void drawArrays(GLenum mode,GLint,GLsizei count) 
+        { 
+            PrimitivePair& prim = _primitiveCount[mode]; 
+            ++prim.first; 
+            prim.second+=count; 
+            _primitives_count[mode] += _calculate_primitives_number_by_mode(mode, count);
+        } 
+        virtual void drawElements(GLenum mode,GLsizei count,const GLubyte*) 
+        { 
+            PrimitivePair& prim = _primitiveCount[mode]; 
+            ++prim.first; 
+            prim.second+=count; 
+            _primitives_count[mode] += _calculate_primitives_number_by_mode(mode, count);
+        } 
+        virtual void drawElements(GLenum mode,GLsizei count,const GLushort*)
+        { 
+            PrimitivePair& prim = _primitiveCount[mode]; 
+            ++prim.first; 
+            prim.second+=count; 
+            _primitives_count[mode] += _calculate_primitives_number_by_mode(mode, count);
+        } 
+        virtual void drawElements(GLenum mode,GLsizei count,const GLuint*)
+        { 
+            PrimitivePair& prim = _primitiveCount[mode]; 
+            ++prim.first; 
+            prim.second+=count; 
+            _primitives_count[mode] += _calculate_primitives_number_by_mode(mode, count);
+        } 
+
+        virtual void begin(GLenum mode) 
+        { 
+            _currentPrimtiveFunctorMode=mode; 
+            PrimitivePair& prim = _primitiveCount[mode]; 
+            ++prim.first; 
+            _number_of_vertexes = 0;
+        }
+
+        inline void vertex() 
+        { 
+            PrimitivePair& prim = _primitiveCount[_currentPrimtiveFunctorMode]; 
+            ++prim.second; 
+           _number_of_vertexes++;
+        }
+        virtual void vertex(float,float,float) { vertex(); }
+        virtual void vertex(const osg::Vec3&)  { vertex(); }
+        virtual void vertex(const osg::Vec2&)  { vertex(); }
+        virtual void vertex(const osg::Vec4&)  { vertex(); }
+        virtual void vertex(float,float)   { vertex(); }
+        virtual void vertex(float,float,float,float)  { vertex(); }
+
+        virtual void end() 
+        {
+          _primitives_count[_currentPrimtiveFunctorMode] += 
+            _calculate_primitives_number_by_mode(_currentPrimtiveFunctorMode, _number_of_vertexes);
+        }
+        
+        void addDrawable() { numDrawables++;}
+        void addMatrix() { nummat++;}
+        void addLight(int np) { nlights+=np;}
+        void addImpostor(int np) { nimpostor+= np; }
+        inline int getBins() { return nbins;}
+        void setDepth(int d) { depth=d; }
+        void addBins(int np) { nbins+= np; }
+
+        void setBinNo(int n) { _binNo=n;}       
+                
+    public:
+                
+        PrimtiveCountMap::iterator GetPrimitivesBegin() { return _primitives_count.begin(); }
+        PrimtiveCountMap::iterator GetPrimitivesEnd() { return _primitives_count.end(); }
+
+        int numDrawables, nummat, nbins;
+        int nlights;
+        int depth; // depth into bins - eg 1.1,1.2,1.3 etc
+        int _binNo;
+        statsType stattype;
+        int nimpostor; // number of impostors rendered
+        
+        unsigned int        _vertexCount;
+        PrimtiveValueMap    _primitiveCount;
+        GLenum              _currentPrimtiveFunctorMode;
+
+    private:
+        PrimtiveCountMap                     _primitives_count;
+
+        unsigned int                         _total_primitives_count;
+        unsigned int                         _number_of_vertexes;
+
+        inline unsigned int _calculate_primitives_number_by_mode(GLenum, GLsizei);
+};
+
+inline unsigned int Statistics::_calculate_primitives_number_by_mode(GLenum mode, GLsizei count)
+{
+  switch (mode)
+    {
+    case GL_POINTS: 
+    case GL_LINE_LOOP:
+    case GL_POLYGON:  return count; 
+    case GL_LINES: return count / 2; 
+    case GL_LINE_STRIP: return count - 1; 
+    case GL_TRIANGLES: return count / 3; 
+    case GL_TRIANGLE_STRIP:
+    case GL_TRIANGLE_FAN: return count - 2; 
+    case GL_QUADS: return count / 4; 
+    case GL_QUAD_STRIP: return count - 3; 
+    default: return 0;
+    }
+}
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/GLObjectsVisitor
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/GLObjectsVisitor (revision 3178)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/GLObjectsVisitor (revision 3178)
@@ -0,0 +1,94 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_GLOBJECTSVISITOR
+#define OSGUTIL_GLOBJECTSVISITOR 1
+
+#include <osg/NodeVisitor>
+#include <osg/Geode>
+#include <osg/State>
+
+#include <osgUtil/Export>
+
+namespace osgUtil {
+
+/** 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.
+  */
+class OSGUTIL_EXPORT GLObjectsVisitor : public osg::NodeVisitor
+{
+    public:
+
+        /** Operation modes of the.*/
+        enum ModeValues
+        {
+            SWITCH_ON_DISPLAY_LISTS = 0x1,
+            SWITCH_OFF_DISPLAY_LISTS = 0x2,
+            COMPILE_DISPLAY_LISTS = 0x4,
+            COMPILE_STATE_ATTRIBUTES = 0x8,
+            RELEASE_DISPLAY_LISTS = 0x10,
+            RELEASE_STATE_ATTRIBUTES = 0x20
+        };
+        
+        typedef unsigned int Mode;
+
+        /** Construct a GLObjectsVisior to traverse all child, operating on
+          * node according to specified mode, such as to compile or release 
+          * display list/texture objects etc. Default mode is to compile 
+          * GL objects.
+          */
+        GLObjectsVisitor(Mode mode=COMPILE_DISPLAY_LISTS|COMPILE_STATE_ATTRIBUTES);
+        
+        /** Set the operational mode of what operations to do on the scene graph.*/
+        void setMode(Mode mode) { _mode = mode; }
+
+        /** Get the operational mode.*/
+        Mode getMode() const { return _mode; }
+        
+
+        /** Set the State to use during traversal. */
+        void setState(osg::State* state)
+        {
+            _state = state;
+        }
+        
+        osg::State* getState()
+        {
+            return _state.get();
+        }
+        
+
+        /** Simply traverse using standard NodeVisitor traverse method.*/
+        virtual void apply(osg::Node& node);
+        
+        /** For each Geode visited set the display list usage according to the 
+          * _displayListMode.
+          */
+        virtual void apply(osg::Geode& node);
+
+        void apply(osg::Drawable& drawable);
+        void apply(osg::StateSet& stateset);
+
+    protected:
+
+        Mode _mode;
+        
+        osg::ref_ptr<osg::State> _state;
+
+};
+
+}
+
+#endif
+
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/DelaunayTriangulator
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/DelaunayTriangulator (revision 1893)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/DelaunayTriangulator (revision 1893)
@@ -0,0 +1,121 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_DELAUNAYTRIANGULATOR_
+#define OSGUTIL_DELAUNAYTRIANGULATOR_
+
+#include <osg/ref_ptr>
+#include <osg/Array>
+#include <osg/Referenced>
+#include <osg/CopyOp>
+#include <osg/PrimitiveSet>
+
+#include <osgUtil/Export>
+
+namespace osgUtil 
+{
+
+/** Utility class that triangulates an irregolar network of sample points.
+    Just create a DelaunayTriangulator, assign it the sample point array and call
+    its triangulate() method to start the triangulation. Then you can obtain the
+    generated primitive by calling the getTriangles() method.
+*/
+class OSGUTIL_EXPORT DelaunayTriangulator: public osg::Referenced {
+public:
+
+    DelaunayTriangulator();
+    explicit DelaunayTriangulator(osg::Vec3Array *points, osg::Vec3Array *normals = 0);
+    DelaunayTriangulator(const DelaunayTriangulator &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY);
+
+    /// Get the const input point array.
+    inline const osg::Vec3Array *getInputPointArray() const;
+
+    /// Get the input point array.
+    inline osg::Vec3Array *getInputPointArray();
+
+    /// Set the input point array.
+    inline void setInputPointArray(osg::Vec3Array *points);
+
+    /// Get the const output normal array (optional).
+    inline const osg::Vec3Array *getOutputNormalArray() const;
+
+    /// Get the output normal array (optional).
+    inline osg::Vec3Array *getOutputNormalArray();
+
+    /// Set the output normal array (optional).
+    inline void setOutputNormalArray(osg::Vec3Array *normals);
+
+    /// Start triangulation.
+    bool triangulate();
+
+    /// Get the generated primitive (call triangulate() first).
+    inline const osg::DrawElementsUInt *getTriangles() const;
+
+    /// Get the generated primitive (call triangulate() first).
+    inline osg::DrawElementsUInt *getTriangles();
+
+protected:
+    virtual ~DelaunayTriangulator();
+    DelaunayTriangulator &operator=(const DelaunayTriangulator &) { return *this; }
+
+private:
+    osg::ref_ptr<osg::Vec3Array> points_;
+    osg::ref_ptr<osg::Vec3Array> normals_;
+    osg::ref_ptr<osg::DrawElementsUInt> prim_tris_;
+};
+
+// INLINE METHODS
+
+inline const osg::Vec3Array *DelaunayTriangulator::getInputPointArray() const
+{
+    return points_.get();
+}
+
+inline osg::Vec3Array *DelaunayTriangulator::getInputPointArray()
+{
+    return points_.get();
+}
+
+inline void DelaunayTriangulator::setInputPointArray(osg::Vec3Array *points)
+{
+    points_ = points;
+}
+
+inline const osg::Vec3Array *DelaunayTriangulator::getOutputNormalArray() const
+{
+    return normals_.get();
+}
+
+inline osg::Vec3Array *DelaunayTriangulator::getOutputNormalArray()
+{
+    return normals_.get();
+}
+
+inline void DelaunayTriangulator::setOutputNormalArray(osg::Vec3Array *normals)
+{
+    normals_ = normals;
+}
+
+inline const osg::DrawElementsUInt *DelaunayTriangulator::getTriangles() const
+{
+    return prim_tris_.get();
+}
+
+inline osg::DrawElementsUInt *DelaunayTriangulator::getTriangles()
+{
+    return prim_tris_.get();
+}
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/ReflectionMapGenerator
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/ReflectionMapGenerator (revision 1529)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/ReflectionMapGenerator (revision 1529)
@@ -0,0 +1,55 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+#ifndef OSGUTIL_REFLECTIONMAPGENERATOR_
+#define OSGUTIL_REFLECTIONMAPGENERATOR_
+
+#include <osgUtil/CubeMapGenerator>
+
+namespace osgUtil
+{
+
+	/** This is the most simple cube map generator. It performs a direct association 
+	    between reflection vector and RGBA color (C = R).
+	*/
+	class ReflectionMapGenerator: public CubeMapGenerator {
+	public:
+		inline ReflectionMapGenerator(int texture_size = 64);
+		inline ReflectionMapGenerator(const ReflectionMapGenerator &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY);
+
+	protected:
+		virtual ~ReflectionMapGenerator() {}
+		ReflectionMapGenerator &operator=(const ReflectionMapGenerator &) { return *this; }
+
+		inline virtual osg::Vec4 compute_color(const osg::Vec3 &R) const;
+	};
+
+	// INLINE METHODS
+
+	inline ReflectionMapGenerator::ReflectionMapGenerator(int texture_size)
+		: CubeMapGenerator(texture_size)
+	{
+	}
+
+	inline ReflectionMapGenerator::ReflectionMapGenerator(const ReflectionMapGenerator &copy, const osg::CopyOp &copyop)
+		: CubeMapGenerator(copy, copyop)
+	{
+	}
+
+	inline osg::Vec4 ReflectionMapGenerator::compute_color(const osg::Vec3 &R) const
+	{
+		return vector_to_color(R / R.length());
+	}
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/HalfWayMapGenerator
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/HalfWayMapGenerator (revision 1529)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/HalfWayMapGenerator (revision 1529)
@@ -0,0 +1,53 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+#ifndef OSGUTIL_HALFWAYMAPGENERATOR_
+#define OSGUTIL_HALFWAYMAPGENERATOR_
+
+#include <osgUtil/Export>
+
+#include <osgUtil/CubeMapGenerator>
+
+namespace osgUtil
+{
+
+	/** This cube map generator produces an Half-way vector map, useful for 
+	    hardware-based specular lighting effects.
+	    It computes: C = normalize(R - L), where C is the resulting color, 
+	    R is the reflection vector and L is the light direction.
+	*/
+	class OSGUTIL_EXPORT HalfWayMapGenerator: public CubeMapGenerator {
+	public:
+		HalfWayMapGenerator(const osg::Vec3 &light_direction, int texture_size = 64);
+		HalfWayMapGenerator(const HalfWayMapGenerator &copy, const osg::CopyOp &copyop);
+
+	protected:
+		virtual ~HalfWayMapGenerator() {}
+		HalfWayMapGenerator &operator=(const HalfWayMapGenerator &) { return *this; }
+
+		inline virtual osg::Vec4 compute_color(const osg::Vec3 &R) const;
+
+	private:
+		osg::Vec3 ldir_;
+	};
+
+	// INLINE METHODS
+
+	inline osg::Vec4 HalfWayMapGenerator::compute_color(const osg::Vec3 &R) const
+	{
+		const osg::Vec3 V = (R / R.length()) - ldir_;
+		return vector_to_color(V / V.length());
+	}
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/TransformAttributeFunctor
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/TransformAttributeFunctor (revision 1984)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/TransformAttributeFunctor (revision 1984)
@@ -0,0 +1,45 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_TRANSFORMATTRIBUTEFUNCTOR
+#define OSGUTIL_TRANSFORMATTRIBUTEFUNCTOR 1
+
+#include <osg/Drawable>
+#include <osg/Notify>
+
+#include <osgUtil/Export>
+
+namespace osgUtil {
+
+/** Functor for transforming a drawable's vertex and normal attributes by specified matrix.
+  * typically used for flattening transform down onto drawable leaves. */
+class OSGUTIL_EXPORT TransformAttributeFunctor : public osg::Drawable::AttributeFunctor
+{
+    public:
+    
+        /** construct a functor to transform a drawable's vertex and normal attributes by specified matrix.*/
+        TransformAttributeFunctor(const osg::Matrix& m);
+            
+        virtual ~TransformAttributeFunctor();
+
+        /** do the work of transforming vertex and normal attributes. */
+        virtual void apply(osg::Drawable::AttributeType type,unsigned int count,osg::Vec3* begin);
+
+        osg::Matrix _m;
+        osg::Matrix _im;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/TriStripVisitor
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/TriStripVisitor (revision 3216)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/TriStripVisitor (revision 3216)
@@ -0,0 +1,106 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_TRISTRIPVISITOR
+#define OSGUTIL_TRISTRIPVISITOR 1
+
+#include <osg/NodeVisitor>
+#include <osg/Geode>
+#include <osg/Geometry>
+
+#include <osgUtil/Optimizer>
+
+#include <set>
+
+namespace osgUtil {
+
+/** A tri stripping visitor for converting Geometry surface primitives into tri strips.
+  * The current implemention is based up Tanguy Fautre's triangulation code.
+  */
+class OSGUTIL_EXPORT TriStripVisitor : public osg::NodeVisitor
+{
+    public:
+
+        /// default to traversing all children.
+        TriStripVisitor(Optimizer* =0) : 
+                osg::NodeVisitor( osg::NodeVisitor::TRAVERSE_ALL_CHILDREN ), 
+                _cacheSize( 16 ),
+                _minStripSize( 2 ),
+                _generateFourPointPrimitivesQuads ( false)
+        {}
+
+        /** Convert mesh primitives in Geometry into Tri Strips.
+          * Converts all primitive types except points
+          * and lines, linestrips which it leaves unchanged.
+          */
+        void stripify(osg::Geometry& drawable);
+
+        /** Stripfy the accumulated list of Geometry drawables.*/
+        void stripify();
+
+        /// accumulate the Geometry drawables to stripify
+        virtual void apply(osg::Geode& geode);
+
+        inline void setCacheSize( unsigned int size )
+        {
+            _cacheSize = size;
+        }
+        
+        inline unsigned int getCacheSize()
+        {
+            return _cacheSize;
+        }
+
+        inline const unsigned int getCacheSize() const
+        {
+            return _cacheSize;
+        }
+        
+        inline void setMinStripSize( unsigned int size )
+        {
+            _minStripSize = size;
+        }
+        
+        inline unsigned int getMinStripSize()
+        {
+            return _minStripSize;
+        }
+
+        inline const unsigned int getMinStripSize() const
+        {
+            return _minStripSize;
+        }
+        
+        inline bool isOperationPermissableForObject(const osg::Object* object) const
+        {
+            return _optimizer ? _optimizer->isOperationPermissableForObject(object,osgUtil::Optimizer::TRISTRIP_GEOMETRY) : true; 
+        }
+        
+        void setGenerateFourPointPrimitivesQuads(bool flag) { _generateFourPointPrimitivesQuads = flag; }
+        bool getGenerateFourPointPrimitivesQuads() const { return _generateFourPointPrimitivesQuads; }
+        
+
+    private:
+    
+        typedef std::set<osg::Geometry*> GeometryList;
+
+        Optimizer*   _optimizer;
+        unsigned int _cacheSize;
+        unsigned int _minStripSize;
+        GeometryList _geometryList;
+        bool         _generateFourPointPrimitivesQuads;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/RenderGraph
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/RenderGraph (revision 1572)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/RenderGraph (revision 1572)
@@ -0,0 +1,283 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_RENDERGRAPH
+#define OSGUTIL_RENDERGRAPH 1
+
+#include <osg/Matrix>
+#include <osg/Drawable>
+#include <osg/StateSet>
+#include <osg/State>
+#include <osg/Light>
+
+#include <osgUtil/RenderLeaf>
+
+#include <set>
+#include <vector>
+#include <algorithm>
+
+namespace osgUtil {
+
+struct LeafDepthSortFunctor
+{
+    bool operator() (const osg::ref_ptr<RenderLeaf>& lhs,const osg::ref_ptr<RenderLeaf>& rhs)
+    {
+        return (lhs->_depth>rhs->_depth);
+    }
+};
+
+class OSGUTIL_EXPORT RenderGraph : public osg::Referenced
+{
+    public:
+    
+
+        typedef std::map< const osg::StateSet*, osg::ref_ptr<RenderGraph> >   ChildList;
+        typedef std::vector< osg::ref_ptr<RenderLeaf> >                 LeafList;
+
+        RenderGraph*                        _parent;
+        const osg::StateSet*                _stateset;
+
+        int                                 _depth;
+        ChildList                           _children;
+        LeafList                            _leaves;
+        
+        mutable float                       _averageDistance;
+        mutable float                       _minimumDistance;
+        
+        osg::ref_ptr<osg::Referenced>       _userData;
+
+
+        RenderGraph():
+            _parent(NULL), 
+            _stateset(NULL), 
+            _depth(0),
+            _averageDistance(0),
+            _minimumDistance(0),
+            _userData(NULL)
+        {
+        }
+
+        RenderGraph(RenderGraph* parent,const osg::StateSet* stateset):
+            _parent(parent), 
+            _stateset(stateset),
+            _depth(0),
+            _averageDistance(0),
+            _minimumDistance(0),
+            _userData(NULL)
+        {
+            if (_parent) _depth = _parent->_depth + 1;
+        }
+            
+        ~RenderGraph() {}
+        
+        RenderGraph* cloneType() const { return new RenderGraph; }
+        
+        void setUserData(osg::Referenced* obj) { _userData = obj; }
+        osg::Referenced* getUserData() { return _userData.get(); }
+        const osg::Referenced* getUserData() const { return _userData.get(); }
+        
+
+        /** return true if all of drawables, lights and children are empty.*/
+        inline bool empty() const
+        {
+            return _leaves.empty() && _children.empty();
+        }
+        
+        inline bool leaves_empty() const
+        {
+            return _leaves.empty();
+        }
+
+
+        inline float getAverageDistance() const
+        {
+            if (_averageDistance==FLT_MAX && !_leaves.empty())
+            {
+                _averageDistance = 0.0f;
+                for(LeafList::const_iterator itr=_leaves.begin();
+                    itr!=_leaves.end();
+                    ++itr)
+                {
+                   _averageDistance += (*itr)->_depth;
+                }
+                _averageDistance /= (float)_leaves.size();
+                
+            }
+            return _averageDistance;
+        }
+        
+        inline float getMinimumDistance() const
+        {
+            if (_minimumDistance==FLT_MAX && !_leaves.empty())
+            {
+                LeafList::const_iterator itr=_leaves.begin();
+                _minimumDistance = (*itr)->_depth;
+                ++itr;
+                for(;
+                    itr!=_leaves.end();
+                    ++itr)
+                {
+                   if ((*itr)->_depth<_minimumDistance) _minimumDistance=(*itr)->_depth;
+                }
+                
+            }
+            return _minimumDistance;
+        }
+
+        inline void sortFrontToBack()
+        {
+            std::sort(_leaves.begin(),_leaves.end(),LeafDepthSortFunctor());
+        }
+
+        /** reset the internal contents of a RenderGraph, including deleting all children.*/
+        void reset();
+
+        /** recursively clean the RenderGraph of all its drawables, lights and depths.
+          * Leaves children intact, and ready to be populated again.*/
+        void clean();
+
+        /** recursively prune the RenderGraph of empty children.*/
+        void prune();
+        
+        
+        inline RenderGraph* find_or_insert(const osg::StateSet* stateset)
+        {
+            // search for the appropriate state group, return it if found.
+            ChildList::iterator itr = _children.find(stateset);
+            if (itr!=_children.end()) return itr->second.get();
+            
+            // create a state group and insert it into the children list
+            // then return the state group.
+            RenderGraph* sg = new RenderGraph(this,stateset);
+            _children[stateset] = sg;
+            return sg;
+        }
+
+        /** add a render leaf.*/
+        inline void addLeaf(RenderLeaf* leaf)
+        {
+            if (leaf)
+            {
+                _averageDistance = FLT_MAX; // signify dirty.
+                _minimumDistance = FLT_MAX; // signify dirty.
+                _leaves.push_back(leaf);
+                leaf->_parent = this;
+            }
+        }
+
+        static inline void moveRenderGraph(osg::State& state,RenderGraph* sg_curr,RenderGraph* sg_new)
+        {
+            if (sg_new==sg_curr || sg_new==NULL) return;
+
+            if (sg_curr==NULL)
+            {
+
+                // use return path to trace back steps to sg_new.
+                std::vector<RenderGraph*> return_path;
+
+                // need to pop back root render graph.
+                do 
+                {
+                    return_path.push_back(sg_new);
+                    sg_new = sg_new->_parent;
+                } while (sg_new);
+
+                for(std::vector<RenderGraph*>::reverse_iterator itr=return_path.rbegin();
+                    itr!=return_path.rend();
+                    ++itr)
+                {
+                    RenderGraph* rg = (*itr);
+                    if (rg->_stateset) state.pushStateSet(rg->_stateset);
+                }
+                return;
+            }
+        
+
+            // first handle the typical case which is two state groups
+            // are neighbours.
+            if (sg_curr->_parent==sg_new->_parent)
+            {
+                
+                // state has changed so need to pop old state.
+                if (sg_curr->_stateset) state.popStateSet();
+                // and push new state.
+                if (sg_new->_stateset) state.pushStateSet(sg_new->_stateset);
+                return;
+            }
+        
+
+            // need to pop back up to the same depth as the new state group.
+            while (sg_curr->_depth>sg_new->_depth)
+            {
+                if (sg_curr->_stateset) state.popStateSet();
+                sg_curr = sg_curr->_parent;
+            }
+            
+            // use return path to trace back steps to sg_new.
+            std::vector<RenderGraph*> return_path;
+
+            // need to pop back up to the same depth as the curr state group.
+            while (sg_new->_depth>sg_curr->_depth)
+            {
+                return_path.push_back(sg_new);
+                sg_new = sg_new->_parent;
+            }
+            
+            // now pop back up both parent paths until they agree.
+
+            // DRT - 10/22/02
+            // should be this to conform with above case where two RenderGraph
+            // nodes have the same parent
+            while (sg_curr != sg_new)
+            {
+                if (sg_curr->_stateset) state.popStateSet();
+                sg_curr = sg_curr->_parent;
+
+                return_path.push_back(sg_new);
+                sg_new = sg_new->_parent;
+            }
+            
+            for(std::vector<RenderGraph*>::reverse_iterator itr=return_path.rbegin();
+                itr!=return_path.rend();
+                ++itr)
+            {
+                RenderGraph* rg = (*itr);
+                if (rg->_stateset) state.pushStateSet(rg->_stateset);
+            }
+
+        }
+
+        inline static void moveToRootRenderGraph(osg::State& state,RenderGraph* sg_curr)
+        {
+            // need to pop back all statesets and matrices.
+            while (sg_curr)
+            {
+                if (sg_curr->_stateset) state.popStateSet();
+                sg_curr = sg_curr->_parent;
+            }
+            
+        }
+        
+    private:
+
+        /// disallow copy construction.
+        RenderGraph(const RenderGraph&):osg::Referenced() {}
+        /// disallow copy operator.
+        RenderGraph& operator = (const RenderGraph&) { return *this; }
+
+};
+
+}
+
+#endif
+
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/UpdateVisitor
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/UpdateVisitor (revision 2313)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/UpdateVisitor (revision 2313)
@@ -0,0 +1,102 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_UPDATEVISITOR
+#define OSGUTIL_UPDATEVISITOR 1
+
+#include <osg/NodeVisitor>
+#include <osg/Node>
+#include <osg/Geode>
+#include <osg/Billboard>
+#include <osg/LOD>
+#include <osg/Switch>
+#include <osg/LightSource>
+#include <osg/Transform>
+#include <osg/Projection>
+#include <osg/Impostor>
+#include <osg/OccluderNode>
+
+#include <osgUtil/Export>
+
+namespace osgUtil {
+
+/**
+ * Basic UpdateVisitor implementation for animating a scene.
+ * This visitor traverses the scene graph, call each nodes appCallback if
+ * it exists. 
+ */
+class OSGUTIL_EXPORT UpdateVisitor : public osg::NodeVisitor
+{
+    public:
+
+        UpdateVisitor();
+        virtual ~UpdateVisitor();
+
+        virtual void reset();
+
+        virtual void apply(osg::Node& node)         { handle_callbacks_and_traverse(node); }
+        
+        virtual void apply(osg::Geode& node)        { handle_geode_callbacks(node); }
+        virtual void apply(osg::Billboard& node)    { handle_geode_callbacks(node); }
+        
+        virtual void apply(osg::LightSource& node)  { handle_callbacks_and_traverse(node); }
+        
+        virtual void apply(osg::Group& node)        { handle_callbacks_and_traverse(node); }
+        virtual void apply(osg::Transform& node)    { handle_callbacks_and_traverse(node); }
+        virtual void apply(osg::Projection& node)   { handle_callbacks_and_traverse(node); }
+        virtual void apply(osg::Switch& node)       { handle_callbacks_and_traverse(node); }
+        virtual void apply(osg::LOD& node)          { handle_callbacks_and_traverse(node); }
+        virtual void apply(osg::Impostor& node)     { handle_callbacks_and_traverse(node); }
+        virtual void apply(osg::OccluderNode& node) { handle_callbacks_and_traverse(node); }
+
+
+    protected:
+
+//         /** prevent unwanted copy construction.*/
+//         UpdateVisitor(const UpdateVisitor&):osg::NodeVisitor() {}
+
+        /** prevent unwanted copy operator.*/
+        UpdateVisitor& operator = (const UpdateVisitor&) { return *this; }
+        
+        inline void handle_callbacks_and_traverse(osg::Node& node)
+        {
+            osg::NodeCallback* callback = node.getUpdateCallback();
+            if (callback) (*callback)(&node,this);
+            else if (node.getNumChildrenRequiringUpdateTraversal()>0) traverse(node);
+        }
+
+        inline void handle_geode_callbacks(osg::Geode& node)
+        {
+            osg::NodeCallback* callback = node.getUpdateCallback();
+            if (callback) (*callback)(&node,this);
+            /*else if (node.getNumChildrenRequiringUpdateTraversal()>0)*/ traverseGeode(node);
+        }
+        
+        inline void traverseGeode(osg::Geode& geode)
+        {
+            traverse((osg::Node&)geode);
+            
+            // call the app callbacks on the drawables.
+            for(unsigned int i=0;i<geode.getNumDrawables();++i)
+            {
+                osg::Drawable::UpdateCallback* callback = geode.getDrawable(i)->getUpdateCallback();
+                if (callback) callback->update(this,geode.getDrawable(i));
+            }
+        }
+	
+};
+
+}
+
+#endif
+
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/RenderStage
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/RenderStage (revision 3214)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/RenderStage (revision 3214)
@@ -0,0 +1,166 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_RENDERSTAGE
+#define OSGUTIL_RENDERSTAGE 1
+
+#include <osg/ColorMask>
+#include <osg/Viewport>
+
+#include <osgUtil/RenderBin>
+#include <osgUtil/RenderStageLighting>
+
+namespace osgUtil {
+
+/**
+ * RenderState base class. Used for encapsulate a complete stage in
+ * rendering - setting up of viewport, the projection and model
+ * matrices and rendering the RenderBin's enclosed with this RenderStage.
+ * RenderStage also has a dependency list of other RenderStages, each
+ * of which must be called before the rendering of this stage.  These
+ * 'pre' rendering stages are used for advanced rendering techniques
+ * like multistage pixel shading or impostors.
+ */
+class OSGUTIL_EXPORT RenderStage : public RenderBin
+{
+    public:
+    
+
+        RenderStage(SortMode mode=SORT_BY_STATE);
+        
+        RenderStage(const RenderStage& rhs,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
+        
+        virtual osg::Object* cloneType() const { return new RenderStage(); }
+        virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new RenderStage(*this,copyop); } // note only implements a clone of type.
+        virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RenderStage*>(obj)!=0L; }
+        virtual const char* className() const { return "RenderStage"; }
+
+        virtual void reset();
+        
+        
+        /** Set the viewport.*/
+        void setViewport(osg::Viewport* viewport) { _viewport = viewport; }
+
+        /** Get the const viewport. */
+        const osg::Viewport* getViewport() const { return _viewport.get(); }
+
+        /** Get the viewport. */
+        osg::Viewport* getViewport() { return _viewport.get(); }
+
+
+
+        /** Set the clear mask used in glClear(..).
+          * Defaults to GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT. */
+        void setClearMask(GLbitfield mask) { _clearMask = mask; }
+
+        /** Get the clear mask.*/
+        GLbitfield getClearMask() const { return _clearMask; }
+
+
+        void setColorMask(osg::ColorMask* cm) { _colorMask = cm; }
+        osg::ColorMask* getColorMask() { return _colorMask.get(); }
+        const osg::ColorMask* getColorMask() const { return _colorMask.get(); }
+
+
+        /** Set the clear color used in glClearColor(..). 
+          * glClearColor is only called if mask & GL_COLOR_BUFFER_BIT is true*/
+        void setClearColor(const osg::Vec4& color) { _clearColor=color; }
+        
+        /** Get the clear color.*/
+        const osg::Vec4& getClearColor() const { return _clearColor; }
+        
+
+        /** Set the clear accum used in glClearAccum(..). 
+          * glClearAcumm is only called if mask & GL_ACCUM_BUFFER_BIT is true*/
+        void setClearAccum(const osg::Vec4& color) { _clearAccum=color; }
+        
+        /** Get the clear accum.*/
+        const osg::Vec4& getClearAccum() const { return _clearAccum; }
+        
+
+        
+        /** Set the clear depth used in glClearDepth(..). Defaults to 1.0
+          * glClearDepth is only called if mask & GL_DEPTH_BUFFER_BIT is true*/
+        void setClearDepth(double depth) { _clearDepth=depth; }
+        
+        /** Get the clear depth.*/
+        double getClearDepth() const { return _clearDepth; }
+
+        
+        /** Set the clear stencil value used in glClearStencil(). Defaults to 0 
+          * glClearStencil is only called if mask & GL_STENCIL_BUFFER_BIT is true*/
+        void setClearStencil(int stencil) { _clearStencil=stencil; }
+        
+        /** Get the clear color.*/
+        int getClearStencil() const { return _clearStencil; }
+
+        void setRenderStageLighting(RenderStageLighting* rsl) { _renderStageLighting = rsl; }
+
+        RenderStageLighting* getRenderStageLighting() const
+        {
+            if (!_renderStageLighting.valid()) _renderStageLighting = new RenderStageLighting;
+            return _renderStageLighting.get();
+        }
+
+        virtual void addPositionedAttribute(osg::RefMatrix* matrix,const osg::StateAttribute* attr)
+        {
+            getRenderStageLighting()->addPositionedAttribute(matrix,attr);
+        }
+        
+        virtual void addPositionedTextureAttribute(unsigned int textureUnit, osg::RefMatrix* matrix,const osg::StateAttribute* attr)
+        {
+            getRenderStageLighting()->addPositionedTextureAttribute(textureUnit, matrix,attr);
+        }
+
+        virtual void drawPreRenderStages(osg::State& state,RenderLeaf*& previous);
+
+        virtual void draw(osg::State& state,RenderLeaf*& previous);
+	
+        virtual void drawImplementation(osg::State& state,RenderLeaf*& previous);
+
+        void addToDependencyList(RenderStage* rs);
+
+        /** extract stats for current draw list. */
+        bool getStats(Statistics* primStats); 
+        
+#ifndef USE_DEPRECATED_API
+    protected:
+#endif
+        
+        virtual ~RenderStage();
+
+        typedef std::vector< osg::ref_ptr<RenderStage> > DependencyList;
+
+        bool                                _stageDrawnThisFrame;
+        DependencyList                      _dependencyList;
+
+        // viewport x,y,width,height.
+        osg::ref_ptr<osg::Viewport>         _viewport;
+        
+        GLbitfield                          _clearMask;
+        osg::ref_ptr<osg::ColorMask>        _colorMask;
+        osg::Vec4                           _clearColor;
+        osg::Vec4                           _clearAccum;
+        double                              _clearDepth;
+        int                                 _clearStencil;
+
+        mutable osg::ref_ptr<RenderStageLighting>   _renderStageLighting;
+        
+    
+
+};
+
+}
+
+#endif
+
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/Simplifier
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/Simplifier (revision 2910)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/Simplifier (revision 2910)
@@ -0,0 +1,104 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_SIMPLIYFIER
+#define OSGUTIL_SIMPLIYFIER 1
+
+#include <osg/NodeVisitor>
+#include <osg/Geode>
+#include <osg/Geometry>
+
+#include <osgUtil/Export>
+
+namespace osgUtil {
+
+/** A simplifier for reducing the number of traingles in osg::Geometry.
+  */
+class OSGUTIL_EXPORT Simplifier : public osg::NodeVisitor
+{
+    public:
+
+        Simplifier(float sampleRatio=1.0f, float maximumError=0.0f);
+
+
+        void setSampleRatio(float sampleRatio) { _sampleRatio = sampleRatio; }
+        float getSampleRatio() const { return _sampleRatio; }
+
+        void setMaximumError(float error) { _maximumError = error; }
+        float getMaximumError() const { return _maximumError; }
+            
+
+        class ContinueSimplificationCallback : public osg::Referenced
+        {
+            public:
+                /** return true if mesh should be continued to be simplified, return false to stop simplification.*/
+                virtual bool continueSimplification(const Simplifier& simplifier, float nextError, unsigned int numOriginalPrimitives, unsigned int numRemainingPrimitives) const
+                {
+                    return simplifier.continueSimplificationImplementation(nextError, numOriginalPrimitives, numRemainingPrimitives);
+                }
+            
+            protected:
+                virtual ~ContinueSimplificationCallback() {}
+        };
+        
+        void setContinueSimplificationCallback(ContinueSimplificationCallback* cb) { _continueSimplificationCallback = cb; }
+        ContinueSimplificationCallback* getContinueSimplificationCallback() { return _continueSimplificationCallback.get(); }
+        const ContinueSimplificationCallback* getContinueSimplificationCallback() const { return _continueSimplificationCallback.get(); }
+        
+        
+        bool continueSimplification(float nextError, unsigned int numOriginalPrimitives, unsigned int numRemainingPrimitives) const
+        {
+            if (_continueSimplificationCallback.valid()) return _continueSimplificationCallback->continueSimplification(*this, nextError, numOriginalPrimitives, numRemainingPrimitives);
+            else return continueSimplificationImplementation(nextError, numOriginalPrimitives, numRemainingPrimitives);
+        }
+
+        virtual bool continueSimplificationImplementation(float nextError, unsigned int numOriginalPrimitives, unsigned int numRemainingPrimitives) const
+        {
+            if (nextError<=getMaximumError()) return true;
+            return (float)numRemainingPrimitives > (float)numOriginalPrimitives * getSampleRatio();
+        }
+
+
+        virtual void apply(osg::Geode& geode)
+        {
+            for(unsigned int i=0;i<geode.getNumDrawables();++i)
+            {
+                osg::Geometry* geometry = geode.getDrawable(i)->asGeometry();
+                if (geometry)
+                {
+                    simplify(*geometry);
+                }
+            }
+        }
+
+        /** simply the geometry.*/
+        void simplify(osg::Geometry& geometry);
+        
+        typedef std::vector<unsigned int> IndexList; /// a list of point indices
+
+        /** simply the geometry, whilst protecting key points from being modified.*/
+        void simplify(osg::Geometry& geometry, const IndexList& protectedPoints);
+
+    protected:
+    
+        float _sampleRatio;
+        float _maximumError;
+        
+        osg::ref_ptr<ContinueSimplificationCallback> _continueSimplificationCallback;
+    
+};
+
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/InsertImpostorsVisitor
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/InsertImpostorsVisitor (revision 1529)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/InsertImpostorsVisitor (revision 1529)
@@ -0,0 +1,70 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_INSERTIMPOSTORSVISITOR
+#define OSGUTIL_INSERTIMPOSTORSVISITOR
+
+#include <osg/NodeVisitor>
+#include <osg/Impostor>
+
+#include <osgUtil/Export>
+
+namespace osgUtil {
+
+/** Insert impostor nodes into scene graph.
+  * For example of usage see src/Demos/osgimpostor.
+  */
+class OSGUTIL_EXPORT InsertImpostorsVisitor : public osg::NodeVisitor
+{
+    public:
+
+        /// default to traversing all children.
+        InsertImpostorsVisitor();
+        
+        void setImpostorThresholdRatio(float ratio) { _impostorThresholdRatio = ratio; }
+        float getImpostorThresholdRatio() const { return _impostorThresholdRatio; }
+
+        void setMaximumNumberOfNestedImpostors(unsigned int num) { _maximumNumNestedImpostors = num; }
+        unsigned int getMaximumNumberOfNestedImpostors() const { return _maximumNumNestedImpostors; }
+
+        /** empty visitor, make it ready for next traversal.*/        
+        void reset();
+
+        virtual void apply(osg::Node& node);
+
+        virtual void apply(osg::Group& node);
+
+        virtual void apply(osg::LOD& node);
+
+        virtual void apply(osg::Impostor& node);
+        
+        /* insert the required impostors into the scene graph.*/
+        void insertImpostors();
+        
+    protected:
+    
+        typedef std::vector< osg::Group* >  GroupList;
+        typedef std::vector< osg::LOD* >    LODList;
+        
+        GroupList       _groupList;
+        LODList         _lodList;        
+
+        float           _impostorThresholdRatio;
+        unsigned int    _maximumNumNestedImpostors;
+        unsigned int    _numNestedImpostors;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/RenderLeaf
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/RenderLeaf (revision 1529)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/RenderLeaf (revision 1529)
@@ -0,0 +1,95 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_RENDERLEAF
+#define OSGUTIL_RENDERLEAF 1
+
+#include <osg/ref_ptr>
+#include <osg/Matrix>
+#include <osg/Drawable>
+#include <osg/State>
+
+#include <osgUtil/Export>
+
+namespace osgUtil {
+
+// forward declare RenderGraph
+class RenderGraph;
+
+/** container class for all data required for rendering of drawables.
+  */
+class OSGUTIL_EXPORT RenderLeaf : public osg::Referenced
+{
+    public:
+    
+
+        inline RenderLeaf(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* modelview, float depth=0.0f):
+            _parent(0),
+            _drawable(drawable),
+            _projection(projection),
+            _modelview(modelview),
+            _depth(depth) {}
+
+        
+	inline void set(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* modelview, float depth=0.0f)
+	{
+	    _parent = 0;
+	    _drawable = drawable;
+            _projection = projection,
+            _modelview = modelview,
+	    _depth = depth;
+	}
+	
+	inline void reset()
+	{
+	    _parent = 0;
+	    _drawable = 0;
+	    _projection = 0;
+	    _modelview = 0;
+	    _depth = 0.0f;
+	}
+
+	
+        virtual void render(osg::State& state,RenderLeaf* previous);
+        
+        /// allow RenderGraph to change the RenderLeaf's _parent.
+        friend class osgUtil::RenderGraph;
+
+    public:
+    
+        RenderGraph*                    _parent;
+        osg::Drawable*                  _drawable;
+        osg::ref_ptr<osg::RefMatrix>    _projection;
+        osg::ref_ptr<osg::RefMatrix>    _modelview;
+        float                           _depth;
+
+    private:
+
+        /// disallow creation of blank RenderLeaf as this isn't useful.
+        RenderLeaf():
+            _parent(0),
+            _drawable(0),
+            _projection(0),
+            _modelview(0),
+            _depth(0.0f) {}
+
+        /// disallow copy construction.
+        RenderLeaf(const RenderLeaf&):osg::Referenced() {}
+        /// disallow copy operator.
+        RenderLeaf& operator = (const RenderLeaf&) { return *this; }
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/RenderBin
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/RenderBin (revision 3299)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/RenderBin (revision 3299)
@@ -0,0 +1,178 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSGUTIL_RENDERBIN
+#define OSGUTIL_RENDERBIN 1
+
+#include <osgUtil/RenderGraph>
+
+#include <map>
+#include <vector>
+#include <string>
+
+namespace osgUtil {
+
+class RenderStage;
+class Statistics;
+/**
+ * RenderBin base class.
+ */
+class OSGUTIL_EXPORT RenderBin : public osg::Object
+{
+    public:
+    
+        typedef std::vector<RenderLeaf*>                    RenderLeafList; 
+        typedef std::vector<RenderGraph*>                   RenderGraphList;
+        typedef std::map< int, osg::ref_ptr<RenderBin> >    RenderBinList; 
+
+        // static methods.
+        static RenderBin* createRenderBin(const std::string& binName);
+        static RenderBin* getRenderBinPrototype(const std::string& binName);
+        static void addRenderBinPrototype(const std::string& binName,RenderBin* proto);
+        static void removeRenderBinPrototype(RenderBin* proto);
+
+        enum SortMode
+        {
+            SORT_BY_STATE,
+            SORT_FRONT_TO_BACK,
+            SORT_BACK_TO_FRONT
+        };
+
+
+        RenderBin(SortMode mode=SORT_BY_STATE);
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        RenderBin(const RenderBin& rhs,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
+
+        virtual osg::Object* cloneType() const { return new RenderBin(); }
+        virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new RenderBin(*this,copyop); } // note only implements a clone of type.
+        virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RenderBin*>(obj)!=0L; }
+        virtual const char* libraryName() const { return "osgUtil"; }
+        virtual const char* className() const { return "RenderBin"; }
+
+        virtual void reset();
+        
+        RenderBin* getParent() { return _parent; }
+        const RenderBin* getParent() const { return _parent; }
+
+        RenderStage* getStage() { return _stage; }
+        const RenderStage* getStage() const { return _stage; }
+
+	int getBinNum() const { return _binNum; }
+
+        RenderGraphList& getRenderGraphList() { return _renderGraphList; }
+        const RenderGraphList& getRenderGraphList() const { return _renderGraphList; }
+
+        RenderBinList& getRenderBinList() { return _bins; }
+        const RenderBinList& getRenderBinList() const { return _bins; }
+
+        RenderLeafList& getRenderLeafList() { return _renderLeafList; }
+        const RenderLeafList& getRenderLeafList() const { return _renderLeafList; }
+
+
+        RenderBin* find_or_insert(int binNum,const std::string& binName);
+
+        void addRenderGraph(RenderGraph* rg)
+        {
+            _renderGraphList.push_back(rg);
+        }
+
+        void sort();
+
+        virtual void sortImplementation();
+	
+        void setSortMode(SortMode mode);
+        SortMode getSortMode() const { return _sortMode; }
+
+        virtual void sortByState();
+        virtual void sortFrontToBack();
+        virtual void sortBackToFront();
+        
+        struct SortCallback : public osg::Referenced    
+        {
+            virtual void sortImplementation(RenderBin*) = 0;
+        };
+
+        void setSortCallback(SortCallback* sortCallback) { _sortCallback = sortCallback; }
+        SortCallback* getSortCallback() { return _sortCallback.get(); }
+        const SortCallback* getSortCallback() const { return _sortCallback.get(); }
+
+
+
+        virtual void draw(osg::State& state,RenderLeaf*& previous);
+
+        virtual void drawImplementation(osg::State& state,RenderLeaf*& previous);
+
+        struct DrawCallback : public osg::Referenced    
+        {
+            virtual void drawImplementation(RenderBin* bin,osg::State& state,RenderLeaf*& previous) = 0;
+        };
+
+        void setDrawCallback(DrawCallback* drawCallback) { _drawCallback = drawCallback; }
+        DrawCallback* getDrawCallback() { return _drawCallback.get(); }
+        const DrawCallback* getDrawCallback() const { return _drawCallback.get(); }
+
+        /** extract stats for current draw list. */
+        bool getStats(Statistics* primStats);
+        void getPrims(Statistics* primStats);
+        bool getPrims(Statistics* primStats, int nbin);
+
+#ifndef USE_DEPRECATED_API
+    protected:
+#endif
+
+        virtual ~RenderBin();
+
+        void copyLeavesFromRenderGraphListToRenderLeafList();
+   
+        int                             _binNum;
+        RenderBin*                      _parent;
+        RenderStage*                    _stage;
+        RenderBinList                   _bins;
+        RenderGraphList                 _renderGraphList;
+        RenderLeafList                  _renderLeafList;
+           
+
+        SortMode                        _sortMode;
+        osg::ref_ptr<SortCallback>      _sortCallback;
+
+        osg::ref_ptr<DrawCallback>      _drawCallback;
+
+
+};
+
+/** Proxy class for automatic registration of renderbins with the RenderBin prototypelist.*/
+class RegisterRenderBinProxy
+{
+    public:
+        RegisterRenderBinProxy(const std::string& binName,RenderBin* proto)
+        {
+            _rb = proto;
+            RenderBin::addRenderBinPrototype(binName,_rb.get());
+        }
+
+        ~RegisterRenderBinProxy()
+        {
+            RenderBin::removeRenderBinPrototype(_rb.get());
+        }
+        
+    protected:
+        osg::ref_ptr<RenderBin> _rb;
+};
+
+
+}
+
+#endif
+
+    
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/HighlightMapGenerator
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/HighlightMapGenerator (revision 3035)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osgUtil/HighlightMapGenerator (revision 3035)
@@ -0,0 +1,63 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+#ifndef OSGUTIL_HIGHLIGHTMAPGENERATOR_
+#define OSGUTIL_HIGHLIGHTMAPGENERATOR_
+
+#include <osgUtil/Export>
+
+#include <osgUtil/CubeMapGenerator>
+
+namespace osgUtil
+{
+
+    /** This cube map generator produces a specular highlight map. 
+        The vector-color association is: C = (R dot (-L)) ^ n, where C is the 
+        resulting color, R is the reflection vector, L is the light direction 
+        and n is the specular exponent.
+    */
+    class OSGUTIL_EXPORT HighlightMapGenerator: public CubeMapGenerator {
+    public:
+        HighlightMapGenerator(
+            const osg::Vec3 &light_direction, 
+            const osg::Vec4 &light_color, 
+            float specular_exponent, 
+            int texture_size = 64);
+
+        HighlightMapGenerator(const HighlightMapGenerator &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY);
+
+    protected:
+        virtual ~HighlightMapGenerator() {}
+        HighlightMapGenerator &operator=(const HighlightMapGenerator &) { return *this; }
+
+        inline virtual osg::Vec4 compute_color(const osg::Vec3 &R) const;
+
+    private:
+        osg::Vec3 ldir_;
+        osg::Vec4 lcol_;
+        float sexp_;
+    };
+
+    // INLINE METHODS
+
+    inline osg::Vec4 HighlightMapGenerator::compute_color(const osg::Vec3 &R) const
+    {
+        float v = -ldir_ * (R / R.length());
+        if (v < 0) v = 0;
+        osg::Vec4 color(lcol_ * powf(v, sexp_));
+        color.w() = 1;
+        return color;
+    }
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Viewport
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Viewport (revision 1756)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Viewport (revision 1756)
@@ -0,0 +1,116 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_VIEWPORT
+#define OSG_VIEWPORT 1
+
+#include <osg/StateAttribute>
+#include <osg/Matrix>
+
+namespace osg {
+
+/** Encapsulte OpenGL glViewport.
+*/     
+class SG_EXPORT Viewport : public StateAttribute
+{
+    public :
+    
+    
+        Viewport();
+        
+        Viewport(int x,int y,int width,int height):
+            _x(x),
+            _y(y),
+            _width(width),
+            _height(height) {}
+            
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        Viewport(const Viewport& vp,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            StateAttribute(vp,copyop),
+            _x(vp._x),
+            _y(vp._y),
+            _width(vp._width),
+            _height(vp._height) {}
+
+        META_StateAttribute(osg, Viewport,VIEWPORT);
+        
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const StateAttribute& sa) const
+        {
+            // check the types are equal and then create the rhs variable
+            // used by the COMPARE_StateAttribute_Paramter macro's below.
+            COMPARE_StateAttribute_Types(Viewport,sa)
+
+            // compare each paramter in turn against the rhs.
+            COMPARE_StateAttribute_Parameter(_x)
+            COMPARE_StateAttribute_Parameter(_y)
+            COMPARE_StateAttribute_Parameter(_width)
+            COMPARE_StateAttribute_Parameter(_height)
+            
+            return 0; // passed all the above comparison macro's, must be equal.
+        }
+
+        inline void setViewport(int x,int y,int width,int height)
+        {
+            _x = x;
+            _y = y;
+            _width = width;
+            _height = height;
+        }
+        
+        void getViewport(int& x,int& y,int& width,int& height) const
+        {
+            x = _x;
+            y = _y;
+            width = _width;
+            height = _height;
+        }
+
+        inline int x() const { return _x; }
+        inline int y() const { return _y; }
+        inline int width() const { return _width; }
+        inline int height() const { return _height; }
+
+        inline bool valid() const { return _width!=0 && _height!=0; }
+
+        /** Return the aspcetRatio of the viewport, which is equal to width/height.
+          * If height is zero, the potental division by zero is avoid by simply returning 1.0f.*/
+        inline float aspectRatio() const { if (_height!=0) return (float)_width/(float)_height; else return 1.0f; }
+        
+        /** Compute the Window Matrix which takes projected coords into Window coordinates.
+          * To converted local coodinates into window coordinates use v_window = v_local * MVPW matrix, 
+          * where the MVPW matrix is ModelViewMatrix * ProjectionMatrix * WindowMatrix, the later supplied by 
+          * viewport::computeWindowMatrix(), the ModelView and Projection Matrix can either be sourced from the
+          * current osg::State object, via osgUtil::SceneView or CullVisitor.*/
+        inline const osg::Matrix computeWindowMatrix() const
+        {
+            return osg::Matrix::translate(1.0f,1.0f,1.0f)*osg::Matrix::scale(0.5f*width(),0.5f*height(),0.5f);
+        }
+
+        virtual void apply(State& state) const;
+
+    protected:
+    
+        virtual ~Viewport();
+
+        int _x;
+        int _y;
+        int _width;
+        int _height;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/PointSprite
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/PointSprite (revision 2773)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/PointSprite (revision 2773)
@@ -0,0 +1,59 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
+ *
+ * This library is open source and may be redistributed and/or modified under
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * OpenSceneGraph Public License for more details.
+ */
+
+#ifndef OSG_POINT_SPRITE
+#define OSG_POINT_SPRITE 1
+
+#include <osg/GL>
+#include <osg/StateAttribute>
+
+#ifndef GL_ARB_point_sprite
+#define GL_POINT_SPRITE_ARB               0x8861
+#define GL_COORD_REPLACE_ARB              0x8862
+#endif
+
+namespace osg {
+
+/** PointSprite base class which encapsulates enabling of point sprites .*/
+class SG_EXPORT PointSprite : public osg::StateAttribute {
+public:
+
+	PointSprite() {}
+
+	/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+	PointSprite(const PointSprite& texenv,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):        
+	    StateAttribute(texenv,copyop) {}
+
+
+	META_StateAttribute(osg, PointSprite, GL_POINT_SPRITE_ARB);
+
+	/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+	virtual int compare(const StateAttribute& sa) const;
+
+        virtual bool getModeUsage(ModeUsage& usage) const
+        {
+            usage.usesMode(GL_POINT_SPRITE_ARB);
+            return true;
+        }
+
+	virtual bool isTextureAttribute() const { return true; }
+
+	virtual void apply(osg::State& state) const;
+
+protected:
+	virtual ~PointSprite( void ) {}
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/BlendColor
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/BlendColor (revision 2773)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/BlendColor (revision 2773)
@@ -0,0 +1,121 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_BLENDCOLOR
+#define OSG_BLENDCOLOR 1
+
+#include <osg/GL>
+#include <osg/StateAttribute>
+#include <osg/ref_ptr>
+#include <osg/Vec4>
+
+
+
+namespace osg {
+
+/** BlendColor - encapsulates the OpenGL blend/transparency state.*/
+class SG_EXPORT BlendColor : public StateAttribute
+{
+    public :
+
+        BlendColor();
+        
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        BlendColor(const BlendColor& trans,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            StateAttribute(trans,copyop),
+            _constantColor(trans._constantColor) {}
+
+        META_StateAttribute(osg, BlendColor,BLENDCOLOR);
+        
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const StateAttribute& sa) const
+        {
+            // check the types are equal and then create the rhs variable
+            // used by the COMPARE_StateAttribute_Paramter macro's below.
+            COMPARE_StateAttribute_Types(BlendColor,sa)
+
+            // compare each paramter in turn against the rhs.
+            COMPARE_StateAttribute_Parameter(_constantColor)
+
+            return 0; // passed all the above comparison macro's, must be equal.
+        }
+
+        virtual bool getModeUsage(ModeUsage& usage) const
+        {
+            usage.usesMode(GL_BLEND);
+            return true;
+        }
+
+        void setConstantColor(const osg::Vec4& color) { _constantColor = color; }
+        inline osg::Vec4 getConstantColor() const { return _constantColor; }
+
+        virtual void apply(State& state) const;
+
+
+
+
+        /** Extensions class which encapsulates the querring of extensions and
+          * associated function pointers, and provide convinience wrappers to 
+          * check for the extensions or use the associated functions.*/        
+        class SG_EXPORT Extensions : public osg::Referenced
+        {
+            public:
+                Extensions();
+
+                Extensions(const Extensions& rhs);
+                
+                void lowestCommonDenominator(const Extensions& rhs);
+                
+                void setupGLExtenions();
+
+                void setBlendColorSupported(bool flag) { _isBlendColorSupported=flag; }
+                bool isBlendColorSupported() const { return _isBlendColorSupported; }
+                
+                void setBlendColorProc(void* ptr) { _glBlendColor = ptr; }
+                void glBlendColor(GLclampf red , GLclampf green , GLclampf blue , GLclampf alpha) const;
+
+            protected:
+
+                ~Extensions() {}
+                
+                bool    _isBlendColorSupported;
+
+                void*   _glBlendColor;
+
+        };
+        
+        /** Function to call to get the extension of a specified context.
+          * If the Exentsion object for that context has not yet been created then 
+          * and the 'createIfNotInitalized' flag been set to false then returns NULL.
+          * If 'createIfNotInitalized' is true then the Extensions object is 
+          * automatically created.  However, in this case the extension object 
+          * only be created with the graphics context associated with ContextID..*/
+        static Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized);
+
+        /** setExtensions allows users to override the extensions across graphics contexts.
+          * typically used when you have different extensions supported across graphics pipes
+          * but need to ensure that they all use the same low common denominator extensions.*/
+        static void setExtensions(unsigned int contextID,Extensions* extensions);
+
+
+
+    protected :
+
+        virtual ~BlendColor();
+
+        osg::Vec4 _constantColor;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Geode
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Geode (revision 2909)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Geode (revision 2909)
@@ -0,0 +1,127 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_GEODE
+#define OSG_GEODE 1
+
+#include <osg/Node>
+#include <osg/NodeVisitor>
+#include <osg/Drawable>
+
+namespace osg {
+
+/** Leaf Node for grouping Drawables.*/
+class SG_EXPORT Geode : public Node
+{
+    public:
+
+        typedef std::vector< ref_ptr<Drawable> > DrawableList;
+
+        Geode();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        Geode(const Geode&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+        META_Node(osg, Geode);
+
+        /** Add Drawable to Geode.
+         *  If gset is not NULL and is not contained in Geode then increment its  
+         *  reference count, add it to the drawables list and dirty the bounding 
+         *  sphere to force it to recompute on next getBound() and return true for success.
+         *  Otherwise return false.
+         */
+        virtual bool addDrawable( Drawable *drawable );
+
+        /** Remove Drawable from Geode.
+          * Equivalent to setDrawabke(getDrawableIndex(orignChild),node), 
+          * see docs for setNode for futher details on implementation.*/
+        virtual bool removeDrawable( Drawable *drawable );
+
+        /** Remove drawable(s) from the specified position in Geode's drawable list.*/
+        virtual bool removeDrawable(unsigned int i,unsigned int numDrawablesToRemove=1);
+
+        /** Replace specified Drawable with another Drawable.
+          * Equivalent to setDrawable(getDrawableIndex(orignChild),node), 
+          * see docs for setDrawable for futher details on implementation.*/
+        virtual bool replaceDrawable( Drawable *origDraw, Drawable *newDraw );
+
+        /** set drawable at position i.
+         * return true if set correctly, false on failure (if node==NULL || i is out of range).
+         *  Decrement the reference count origGSet and increments the
+         *  reference count of newGset, and dirty the bounding sphere
+         *  to force it to recompute on next getBound() and returns true.
+         *  If origDrawable is not found then return false and do not 
+         *  add newGset.  If newGset is NULL then return false and do
+         *  not remove origGset.
+         */
+        virtual bool setDrawable( unsigned int i, Drawable* drawable );
+
+        /** return the number of drawable's.*/
+        inline unsigned int getNumDrawables() const { return _drawables.size(); }
+
+        /** return drawable at position i.*/
+        inline Drawable* getDrawable( unsigned int i ) { return _drawables[i].get(); }
+
+        /** return drawable at position i.*/
+        inline const Drawable* getDrawable( unsigned int i ) const { return _drawables[i].get(); }
+
+        /** return true if drawable is contained within Geode.*/
+        inline bool containsDrawable(const Drawable* gset) const
+        {
+            
+            for (DrawableList::const_iterator itr=_drawables.begin();
+                 itr!=_drawables.end();
+                 ++itr)
+            {
+                if (itr->get()==gset) return true;
+            }
+            return false;
+        }
+
+        /** Get the index number of drawable, return a value between
+          * 0 and _drawables.size()-1 if found, if not found then
+          * return _drawables.size().*/
+        inline unsigned int getDrawableIndex( const Drawable* node ) const
+        {
+            for (unsigned int drawableNum=0;drawableNum<_drawables.size();++drawableNum)
+            {
+                if (_drawables[drawableNum]==node) return drawableNum;
+            }
+            return _drawables.size(); // node not found.
+        }
+
+        /** compile OpenGL Display List for each drawable.*/
+        void compileDrawables(State& state);
+        
+        /** return the Geode's bounding box, which the union of all the
+          * bounding boxes of the geode's drawables.*/
+        inline const BoundingBox& getBoundingBox() const
+        {
+            if(!_bsphere_computed) computeBound();
+            return _bbox;
+        }
+        
+    protected:
+
+        virtual ~Geode();
+
+        virtual bool computeBound() const;
+
+        mutable osg::BoundingBox        _bbox;
+        DrawableList                    _drawables;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/CullStack
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/CullStack (revision 2928)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/CullStack (revision 2928)
@@ -0,0 +1,282 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_CULLSTACK
+#define OSG_CULLSTACK 1
+
+#include <osg/CullingSet>
+#include <osg/CullSettings>
+#include <osg/Viewport>
+#include <osg/fast_back_stack>
+
+namespace osg {
+
+/** A CullStack class which accumulates the current project, modelview matrices
+and the CullingSet. */
+class SG_EXPORT CullStack : public osg::CullSettings
+{
+
+    public:
+    
+    
+        CullStack();
+        
+        ~CullStack();
+    
+        typedef std::vector<ShadowVolumeOccluder>   OccluderList;
+
+        void reset();
+        
+        void setOccluderList(const ShadowVolumeOccluderList& svol) { _occluderList = svol; }
+        ShadowVolumeOccluderList& getOccluderList() { return _occluderList; }
+        const ShadowVolumeOccluderList& getOccluderList() const { return _occluderList; }
+
+        void pushViewport(osg::Viewport* viewport);
+        void popViewport();
+
+        void pushProjectionMatrix(osg::RefMatrix* matrix);
+        void popProjectionMatrix();
+
+        void pushModelViewMatrix(osg::RefMatrix* matrix);
+        void popModelViewMatrix();
+
+        inline float getFrustumVolume() { if (_frustumVolume<0.0f) computeFrustumVolume(); return _frustumVolume; }
+
+
+        /** Compute the pixel of an object at position v, with specified radius.*/
+        float pixelSize(const Vec3& v,float radius) const
+        {
+            return getCurrentCullingSet().pixelSize(v,radius);
+        }
+        
+        /** Compute the pixel of an bounding sphere.*/
+        float pixelSize(const BoundingSphere& bs) const
+        {
+            return pixelSize(bs.center(),bs.radius());
+        }
+
+        inline void disableAndPushOccludersCurrentMask(NodePath& nodePath)
+        {
+            getCurrentCullingSet().disableAndPushOccludersCurrentMask(nodePath);
+        }
+
+        inline void popOccludersCurrentMask(NodePath& nodePath)
+        {
+            getCurrentCullingSet().popOccludersCurrentMask(nodePath);
+        }
+
+        inline bool isCulled(const std::vector<Vec3>& vertices)
+        {
+            return getCurrentCullingSet().isCulled(vertices);
+        }
+
+        inline bool isCulled(const BoundingBox& bb)
+        {
+            return bb.valid() && getCurrentCullingSet().isCulled(bb);
+        }
+        
+        inline bool isCulled(const BoundingSphere& bs)
+        {
+            return getCurrentCullingSet().isCulled(bs);
+        }
+        
+        inline bool isCulled(const osg::Node& node)
+        {
+            return node.isCullingActive() && getCurrentCullingSet().isCulled(node.getBound());
+        }
+
+        inline void pushCurrentMask()
+        {
+            getCurrentCullingSet().pushCurrentMask();
+        }
+        
+        inline void popCurrentMask()
+        {
+            getCurrentCullingSet().popCurrentMask();
+        }
+        
+        
+        typedef std::vector< CullingSet > CullingStack;
+
+        inline CullingStack& getClipSpaceCullingStack() { return _clipspaceCullingStack; }
+        
+        inline CullingStack& getProjectionCullingStack() { return _projectionCullingStack; }
+        
+        inline CullingStack& getModelViewCullingStack() { return _modelviewCullingStack; }
+        
+//        inline CullingSet& getCurrentCullingSet() { return _modelviewCullingStack.back(); }
+//        inline const CullingSet& getCurrentCullingSet() const { return _modelviewCullingStack.back(); }
+
+        inline CullingSet& getCurrentCullingSet() { return *_back_modelviewCullingStack; }
+        inline const CullingSet& getCurrentCullingSet() const { return *_back_modelviewCullingStack; }
+        
+        inline osg::Viewport* getViewport();
+        inline osg::RefMatrix& getModelViewMatrix();
+        inline osg::RefMatrix& getProjectionMatrix();
+        inline osg::Matrix getWindowMatrix();
+        inline const osg::RefMatrix& getMVPW();
+
+        inline const osg::Vec3& getEyeLocal() const { return _eyePointStack.back(); }
+
+        inline const osg::Vec3 getUpLocal() const
+        {
+            const osg::Matrix& matrix = *_modelviewStack.back();
+            return osg::Vec3(matrix(0,1),matrix(1,1),matrix(2,1));
+        }
+
+        inline const osg::Vec3 getLookVectorLocal() const
+        {
+            const osg::Matrix& matrix = *_modelviewStack.back();
+            return osg::Vec3(-matrix(0,2),-matrix(1,2),-matrix(2,2));
+        }
+        
+    protected:
+    
+        void pushCullingSet();
+        void popCullingSet();
+
+        // base set of shadow volume occluder to use in culling.
+        ShadowVolumeOccluderList                                    _occluderList;
+
+        typedef fast_back_stack< ref_ptr<RefMatrix> >                  MatrixStack;
+
+        MatrixStack                                                 _projectionStack;
+
+        MatrixStack                                                 _modelviewStack;
+        MatrixStack                                                 _MVPW_Stack;
+
+        typedef fast_back_stack<ref_ptr<Viewport> >                 ViewportStack;
+        ViewportStack                                               _viewportStack;
+        
+        typedef fast_back_stack<Vec3>                               EyePointStack;
+        EyePointStack                                               _eyePointStack;
+
+        CullingStack                                                _clipspaceCullingStack;
+        CullingStack                                                _projectionCullingStack;
+
+        CullingStack                                                _modelviewCullingStack;
+        unsigned int                                                _index_modelviewCullingStack;
+        CullingSet*                                                 _back_modelviewCullingStack;
+
+        void computeFrustumVolume();
+        float                                                       _frustumVolume;
+
+        unsigned int                                                _bbCornerNear;
+        unsigned int                                                _bbCornerFar;
+
+        ref_ptr<osg::RefMatrix>                                     _identity;
+        
+        typedef std::vector< osg::ref_ptr<osg::RefMatrix> > MatrixList;
+	MatrixList _reuseMatrixList;
+	unsigned int _currentReuseMatrixIndex;
+	
+	inline osg::RefMatrix* createOrReuseMatrix(const osg::Matrix& value);
+
+        
+};
+
+inline osg::Viewport* CullStack::getViewport()
+{
+    if (!_viewportStack.empty())
+    {
+        return _viewportStack.back().get();
+    }
+    else
+    {
+        return 0L;
+    }
+}
+
+inline osg::RefMatrix& CullStack::getModelViewMatrix()
+{
+    if (!_modelviewStack.empty())
+    {
+        return *_modelviewStack.back();
+    }
+    else
+    {
+        return *_identity;
+    }
+}
+
+inline osg::RefMatrix& CullStack::getProjectionMatrix()
+{
+    if (!_projectionStack.empty())
+    {
+        return *_projectionStack.back();
+    }
+    else
+    {
+        return *_identity;
+    }
+}
+
+inline osg::Matrix CullStack::getWindowMatrix()
+{
+    if (!_viewportStack.empty())
+    {
+        osg::Viewport* viewport = _viewportStack.back().get();
+        return viewport->computeWindowMatrix();
+    }
+    else
+    {
+        return *_identity;
+    }
+}
+
+inline const osg::RefMatrix& CullStack::getMVPW()
+{
+    if (!_MVPW_Stack.empty())
+    {
+        if (!_MVPW_Stack.back())
+        {
+            _MVPW_Stack.back() = createOrReuseMatrix(getModelViewMatrix());
+            (*_MVPW_Stack.back()) *= getProjectionMatrix();
+            (*_MVPW_Stack.back()) *= getWindowMatrix();
+        }
+        return *_MVPW_Stack.back();
+    }
+    else
+    {
+        return *_identity;
+    }
+}
+
+inline RefMatrix* CullStack::createOrReuseMatrix(const osg::Matrix& value)
+{
+    // skip of any already reused matrix.
+    while (_currentReuseMatrixIndex<_reuseMatrixList.size() && 
+           _reuseMatrixList[_currentReuseMatrixIndex]->referenceCount()>1)
+    {
+        ++_currentReuseMatrixIndex;
+    }
+
+    // if still within list, element must be singularly referenced
+    // there return it to be reused.
+    if (_currentReuseMatrixIndex<_reuseMatrixList.size())
+    {
+        RefMatrix* matrix = _reuseMatrixList[_currentReuseMatrixIndex++].get();
+        matrix->set(value);
+        return matrix;
+    }
+
+    // otherwise need to create new matrix.
+    osg::RefMatrix* matrix = new RefMatrix(value);
+    _reuseMatrixList.push_back(matrix);
+    ++_currentReuseMatrixIndex;
+    return matrix;
+}
+
+}	// end of namespace
+
+#endif 
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Node
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Node (revision 3064)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Node (revision 3064)
@@ -0,0 +1,284 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+
+#ifndef OSG_NODE
+#define OSG_NODE 1
+
+#include <osg/Object>
+#include <osg/StateSet>
+#include <osg/BoundingSphere>
+#include <osg/NodeCallback>
+
+#include <string>
+#include <vector>
+
+namespace osg {
+
+class NodeVisitor;
+class Group;
+class Transform;
+
+/** META_Node macro define the standard clone, isSameKindAs, className
+  * and accept methods.  Use when subclassing from Node to make it
+  * more convinient to define the required pure virtual methods.*/
+#define META_Node(library,name) \
+        virtual osg::Object* cloneType() const { return new name (); } \
+        virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new name (*this,copyop); } \
+        virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const name *>(obj)!=NULL; } \
+        virtual const char* className() const { return #name; } \
+        virtual const char* libraryName() const { return #library; } \
+        virtual void accept(osg::NodeVisitor& nv) { if (nv.validNodeMask(*this)) { nv.pushOntoNodePath(this); nv.apply(*this); nv.popFromNodePath(); } } \
+        
+
+/** Base class for all internal nodes in the scene graph.
+    Provides interface for most common node operations (Composite Pattern).
+*/
+class SG_EXPORT Node : public Object
+{
+    public:
+
+        /** Construct a node.
+            Initialize the parent list to empty, node name to "" and 
+            bounding sphere dirty flag to true.*/
+        Node();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        Node(const Node&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+        /** clone the an object of the same type as the node.*/
+        virtual Object* cloneType() const { return new Node(); }
+
+        /** return a clone of a node, with Object* return type.*/
+        virtual Object* clone(const CopyOp& copyop) const { return new Node(*this,copyop); }
+
+        /** return true if this and obj are of the same kind of object.*/
+        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Node*>(obj)!=NULL; }
+
+        /** return the name of the node's library.*/
+        virtual const char* libraryName() const { return "osg"; }
+
+        /** return the name of the node's class type.*/
+        virtual const char* className() const { return "Node"; }
+
+        /** convert 'this' into a Group pointer if Node is a Group, otherwise return 0.
+          * Equivalent to dynamic_cast<Group*>(this).*/
+        virtual Group* asGroup() { return 0; }
+        /** convert 'const this' into a const Group pointer if Node is a Group, otherwise return 0.
+          * Equivalent to dynamic_cast<const Group*>(this).*/
+        virtual const Group* asGroup() const { return 0; }
+
+        /** convert 'this' into a Transform pointer if Node is a Transform, otherwise return 0.
+          * Equivalent to dynamic_cast<Transform*>(this).*/
+        virtual Transform* asTransform() { return 0; }
+        /** convert 'const this' into a const Transform pointer if Node is a Transform, otherwise return 0.
+          * Equivalent to dynamic_cast<const Transform*>(this).*/
+        virtual const Transform* asTransform() const { return 0; }
+
+        /** Visitor Pattern : calls the apply method of a NodeVisitor with this node's type.*/
+        virtual void accept(NodeVisitor& nv);
+        /** Traverse upwards : calls parents' accept method with NodeVisitor.*/
+        virtual void ascend(NodeVisitor& nv);
+        /** Traverse downwards : calls children's accept method with NodeVisitor.*/
+        virtual void traverse(NodeVisitor& /*nv*/) {}
+
+
+        /** Set the name of node using C++ style string.*/
+        inline void setName( const std::string& name ) { _name = name; }
+        /** Set the name of node using a C style string.*/
+        inline void setName( const char* name ) { _name = name; }
+        /** Get the name of node.*/
+        inline const std::string& getName() const { return _name; }
+        
+
+        /** A vector of osg::Group pointers which is used to store the parent(s) of node.*/
+        typedef std::vector<Group*> ParentList;
+
+        /** Get the parent list of node. */
+        inline const ParentList& getParents() const { return _parents; }
+
+        /** Get the a copy of parent list of node. A copy is returned to 
+          * prevent modification of the parent list.*/
+        inline ParentList getParents() { return _parents; }
+
+        inline Group* getParent(unsigned int i)  { return _parents[i]; }
+        /**
+         * Get a single const parent of node.
+         * @param i index of the parent to get.
+         * @return the parent i.
+         */
+        inline const Group* getParent(unsigned int i) const  { return _parents[i]; }
+
+        /**
+         * Get the number of parents of node.
+         * @return the number of parents of this node.
+         */
+        inline unsigned int getNumParents() const { return _parents.size(); }
+
+
+        /** Set update node callback, called during update traversal. */
+        void setUpdateCallback(NodeCallback* nc);
+
+        /** Get update node callback, called during update traversal. */
+        inline NodeCallback* getUpdateCallback() { return _updateCallback.get(); }
+
+        /** Get const update node callback, called during update traversal. */
+        inline const NodeCallback* getUpdateCallback() const { return _updateCallback.get(); }
+
+        /** Get the number of Children of this node which require App traversal,
+          * since they have an AppCallback attached to them or their children.*/
+        inline unsigned int getNumChildrenRequiringUpdateTraversal() const { return _numChildrenRequiringUpdateTraversal; }
+
+
+        /** Set cull node callback, called during cull traversal. */
+        void setCullCallback(NodeCallback* nc) { _cullCallback = nc; }
+
+        /** Get cull node callback, called during cull traversal. */
+        inline NodeCallback* getCullCallback() { return _cullCallback.get(); }
+
+        /** Get const cull node callback, called during cull traversal. */
+        inline const NodeCallback* getCullCallback() const { return _cullCallback.get(); }
+
+        /** Set the view frustum/small feature culling of this node to be active or inactive.
+          * The default value to true for _cullingActive. Used a guide
+          * to the cull traversal.*/
+        void setCullingActive(bool active);
+
+        /** Get the view frustum/small feature _cullingActive flag for this node. Used a guide
+          * to the cull traversal.*/
+        inline bool getCullingActive() const { return _cullingActive; }
+
+        /** Get the number of Children of this node which have culling disabled.*/
+        inline unsigned int getNumChildrenWithCullingDisabled() const { return _numChildrenWithCullingDisabled; }
+
+        /** Return true if this node can be culled by view frustum, occlusion or small feature culling during the cull traversal.
+          * note, return true only if no children have culling disabled, and the local _cullingActive flag is true.*/
+        inline bool isCullingActive() const { return _numChildrenWithCullingDisabled==0 && _cullingActive && getBound().valid(); }
+
+        /** Get the number of Children of this node which are or have OccluderNode's.*/
+        inline unsigned int getNumChildrenWithOccluderNodes() const { return _numChildrenWithOccluderNodes; }
+
+        
+        /** return true if this node is an OccluderNode or the subgraph below this node are OccluderNodes.*/
+        bool containsOccluderNodes() const;
+
+
+        typedef unsigned int NodeMask;
+        /** Set the node mask.*/
+        inline void setNodeMask(NodeMask nm) { _nodeMask = nm; }
+        /** Get the node Mask.*/
+        inline NodeMask getNodeMask() const { return _nodeMask; }
+
+
+
+        /** A vector of std::string's which are used to describe the object.*/
+        typedef std::vector<std::string> DescriptionList;
+
+        /** Get the description list of the const node.*/        
+        inline const DescriptionList& getDescriptions() const { return _descriptions; }
+        /** Get the description list of the const node.*/        
+        inline DescriptionList& getDescriptions() { return _descriptions; }
+        /** Get a single const description of the const node.*/
+        inline const std::string& getDescription(unsigned int i) const { return _descriptions[i]; }
+        /** Get a single description of the node.*/
+        inline std::string& getDescription(unsigned int i) { return _descriptions[i]; }
+        /** Get the number of descriptions of the node.*/
+        inline unsigned int getNumDescriptions() const { return _descriptions.size(); }
+        /** Add a description string to the node.*/
+        void addDescription(const std::string& desc) { _descriptions.push_back(desc); }
+
+
+        /** set the node's StateSet.*/
+        inline void setStateSet(osg::StateSet* dstate) { _stateset = dstate; }
+
+        /** return the node's StateSet, if one does not already exist create it
+          * set the node and return the newly created StateSet. This ensures
+          * that a valid StateSet is always returned and can be used directly.*/
+        osg::StateSet* getOrCreateStateSet();
+
+        /** return the node's StateSet. returns NULL if a stateset is not attached.*/
+        inline osg::StateSet* getStateSet() { return _stateset.get(); }
+
+        /** return the node's const StateSet. returns NULL if a stateset is not attached.*/
+        inline const osg::StateSet* getStateSet() const { return _stateset.get(); }
+
+        /** get the bounding sphere of node.
+           Using lazy evaluation computes the bounding sphere if it is 'dirty'.*/
+        inline const BoundingSphere& getBound() const
+        {
+            if(!_bsphere_computed) computeBound();
+            return _bsphere;
+        }
+
+
+        /** Mark this node's bounding sphere dirty.
+            Forcing it to be computed on the next call to getBound().*/
+        void dirtyBound();
+
+
+    protected:
+
+        /** Node destructor. Note, is protected so that Nodes cannot
+            be deleted other than by being dereferenced and the reference
+            count being zero (see osg::Referenced), preventing the deletion
+            of nodes which are still in use. This also means that
+            Node's cannot be created on stack i.e Node node will not compile,
+            forcing all nodes to be created on the heap i.e Node* node
+            = new Node().*/
+        virtual ~Node();
+
+
+        /** Compute the bounding sphere around Node's geometry or children.
+            This method is automatically called by getBound() when the bounding
+            sphere has been marked dirty via dirtyBound().*/
+        virtual bool computeBound() const;
+
+        mutable BoundingSphere _bsphere;
+        mutable bool _bsphere_computed;
+
+        std::string _name;
+
+        void addParent(osg::Group* node);
+        void removeParent(osg::Group* node);
+
+        ParentList _parents;
+        friend class osg::Group;
+        friend class osg::Drawable;
+
+        ref_ptr<NodeCallback> _updateCallback;
+        unsigned int _numChildrenRequiringUpdateTraversal;
+        void setNumChildrenRequiringUpdateTraversal(unsigned int num);
+
+        ref_ptr<NodeCallback> _cullCallback;
+
+        bool _cullingActive;
+        unsigned int _numChildrenWithCullingDisabled;        
+        void setNumChildrenWithCullingDisabled(unsigned int num);
+
+        unsigned int _numChildrenWithOccluderNodes;        
+        void setNumChildrenWithOccluderNodes(unsigned int num);
+
+        NodeMask _nodeMask;
+        
+        DescriptionList _descriptions;
+
+        ref_ptr<StateSet> _stateset;
+
+};
+
+/** A vector of Nodes pointers which is used to describe the path from a root node to a descendant.*/
+typedef std::vector<Node*> NodePath;
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Texture2D
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Texture2D (revision 3190)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Texture2D (revision 3190)
@@ -0,0 +1,163 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_TEXTURE2D
+#define OSG_TEXTURE2D 1
+
+#include <osg/Texture>
+
+namespace osg {
+
+/** Texture state class which encapsulates OpenGl texture functionality.*/
+class SG_EXPORT Texture2D : public Texture
+{
+
+    public :
+        
+        Texture2D();
+
+        Texture2D(Image* image);
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        Texture2D(const Texture2D& text,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+        
+        META_StateAttribute(osg, Texture2D,TEXTURE);
+
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const StateAttribute& rhs) const;
+
+        virtual bool getModeUsage(ModeUsage& usage) const
+        {
+            usage.usesTextureMode(GL_TEXTURE_2D);
+            return true;
+        }
+
+        /** Set the texture image. */
+        void setImage(Image* image);
+
+        /** Get the texture image. */
+        Image* getImage() { return _image.get(); }
+
+        /** Get the const texture image. */
+        inline const Image* getImage() const { return _image.get(); }
+
+        inline unsigned int& getModifiedTag(unsigned int contextID) const
+        {
+            // get the modified tag for the current contextID.
+            return _modifiedTag[contextID];
+        }
+
+
+        /** Set the texture image, ignoring face. as there is only one image*/
+        virtual void setImage(unsigned int, Image* image) { setImage(image); }
+
+        /** Get the texture image, ignoring face value as there is only one image. */
+        virtual Image* getImage(unsigned int) { return _image.get(); }
+
+        /** Get the const texture image , ignoring face value as there is only one image. */
+        virtual const Image* getImage(unsigned int) const { return _image.get(); }
+
+        /** Get the number of images that can be assigned to the Texture. */
+        virtual unsigned int getNumImages() const { return 1; }
+
+
+        /** Set the texture width and height. If width or height are zero then
+          * the repsective size value is calculated from the source image sizes. */
+        inline void setTextureSize(int width, int height) const
+        {
+            _textureWidth = width;
+            _textureHeight = height;
+        }
+
+        int getTextureWidth() const { return _textureWidth; }
+        int getTextureHeight() const { return _textureHeight; }
+
+        // deprecated.
+        inline void getTextureSize(int& width, int& height) const
+        {
+            width = _textureWidth;
+            height = _textureHeight;
+        }
+
+
+        class SG_EXPORT SubloadCallback : public Referenced
+        {
+            public:
+                virtual void load(const Texture2D& texture,State& state) const = 0;
+                virtual void subload(const Texture2D& texture,State& state) const = 0;
+        };
+        
+        void setSubloadCallback(SubloadCallback* cb) { _subloadCallback = cb;; }
+        
+        SubloadCallback* getSubloadCallback() { return _subloadCallback.get(); }
+
+        const SubloadCallback* getSubloadCallback() const { return _subloadCallback.get(); }
+
+
+        /** Set the number of mip map levels the the texture has been created with,
+            should only be called within an osg::Texuture::apply() and custom OpenGL texture load.*/
+        void setNumMipmapLevels(unsigned int num) const { _numMipmapLevels=num; }
+
+        /** Get the number of mip map levels the the texture has been created with.*/
+        unsigned int getNumMipmapLevels() const { return _numMipmapLevels; }
+        
+
+        /** Copy pixels into a 2D texture image.As per glCopyTexImage2D.
+          * Creates an OpenGL texture object from the current OpenGL background
+          * framebuffer contents at pos \a x, \a y with width \a width and
+          * height \a height. \a width and \a height must be a power of two.
+          */
+        void copyTexImage2D(State& state, int x, int y, int width, int height );
+
+        /** Copy a two-dimensional texture subimage. As per glCopyTexSubImage2D.
+          * Updates portion of an existing OpenGL texture object from the current OpenGL background
+          * framebuffer contents at pos \a x, \a y with width \a width and
+          * height \a height. \a width and \a height must be a power of two,
+          * and writing into the texture with offset \a xoffset and \a yoffset.
+          */
+        void copyTexSubImage2D(State& state, int xoffset, int yoffset, int x, int y, int width, int height );
+
+
+        /** On first apply (unless already compiled), create the minmapped 
+          * texture and bind it, subsequent apply will simple bind to texture.*/
+        virtual void apply(State& state) const;
+
+    protected :
+
+        virtual ~Texture2D();
+
+        virtual void computeInternalFormat() const;
+
+
+        // not ideal that _image is mutable, but its required since
+        // Image::ensureDimensionsArePowerOfTwo() can only be called
+        // in a valid OpenGL context, a therefore within an Texture::apply
+        // which is const...
+        ref_ptr<Image> _image;
+
+        // subloaded images can have different texture and image sizes.
+        mutable GLsizei _textureWidth, _textureHeight;
+        
+        // number of mip map levels the the texture has been created with,        
+        mutable GLsizei _numMipmapLevels;
+
+        ref_ptr<SubloadCallback> _subloadCallback;
+
+        typedef buffered_value<unsigned int> ImageModifiedTag;
+        mutable ImageModifiedTag _modifiedTag;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/DisplaySettings
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/DisplaySettings (revision 2948)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/DisplaySettings (revision 2948)
@@ -0,0 +1,198 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_DisplaySettings
+#define OSG_DisplaySettings 1
+
+#include <osg/Referenced>
+
+#include <string>
+#include <vector>
+
+namespace osg {
+
+// forward declare
+class ArgumentParser;
+class ApplicationUsage;
+
+/** DisplaySettings class for encapsulating what visuals are required and
+  * have been set up, and the status of stereo viewing.*/
+class SG_EXPORT DisplaySettings : public osg::Referenced
+{
+
+    public:
+
+        /** Maintain a DisplaySettings singleton for objects to querry at runtime.*/
+        static DisplaySettings* instance();
+
+
+        DisplaySettings()
+        {
+            setDefaults();
+            readEnvironmentalVariables();
+        }
+        
+        DisplaySettings(ArgumentParser& arguments)
+        {
+            setDefaults();
+            readEnvironmentalVariables();
+            readCommandLine(arguments);
+        }
+
+        DisplaySettings(const DisplaySettings& vs);
+        
+
+        DisplaySettings& operator = (const DisplaySettings& vs);
+ 
+        void setDisplaySettings(const DisplaySettings& vs);
+        
+        void merge(const DisplaySettings& vs);
+
+        void setDefaults();
+        
+        /** read the environmental variables.*/
+        void readEnvironmentalVariables();
+
+        /** read the commandline arguments.*/
+        void readCommandLine(ArgumentParser& arguments);
+        
+        
+        enum DisplayType
+        {
+            MONITOR,
+            POWERWALL,
+            REALITY_CENTER,
+            HEAD_MOUNTED_DISPLAY
+        };
+
+        void setDisplayType(DisplayType type) { _displayType = type; }
+        
+        DisplayType getDisplayType() const { return _displayType; }
+
+
+        void setStereo(bool on) { _stereo = on; }
+        bool getStereo() const { return _stereo; }
+
+        enum StereoMode
+        {
+            QUAD_BUFFER,
+            ANAGLYPHIC,
+            HORIZONTAL_SPLIT,
+            VERTICAL_SPLIT,
+            LEFT_EYE,
+            RIGHT_EYE
+        };
+        
+        void setStereoMode(StereoMode mode) { _stereoMode = mode; }
+        StereoMode getStereoMode() const { return _stereoMode; }
+
+        void setEyeSeparation(float eyeSeparation) { _eyeSeparation = eyeSeparation; }
+        float getEyeSeparation() const { return _eyeSeparation; }
+
+        enum SplitStereoHorizontalEyeMapping
+        {
+            LEFT_EYE_LEFT_VIEWPORT,
+            LEFT_EYE_RIGHT_VIEWPORT
+        };
+        
+        void setSplitStereoHorizontalEyeMapping(SplitStereoHorizontalEyeMapping m) { _splitStereoHorizontalEyeMapping = m; }
+        SplitStereoHorizontalEyeMapping getSplitStereoHorizontalEyeMapping() const { return _splitStereoHorizontalEyeMapping; }
+
+        void setSplitStereoHorizontalSeparation(int s) { _splitStereoHorizontalSeparation = s; }
+        int getSplitStereoHorizontalSeparation() const { return _splitStereoHorizontalSeparation; }
+
+        enum SplitStereoVerticalEyeMapping
+        {
+            LEFT_EYE_TOP_VIEWPORT,
+            LEFT_EYE_BOTTOM_VIEWPORT
+        };
+
+        void setSplitStereoVerticalEyeMapping(SplitStereoVerticalEyeMapping m) { _splitStereoVerticalEyeMapping = m; }
+        SplitStereoVerticalEyeMapping getSplitStereoVerticalEyeMapping() const { return _splitStereoVerticalEyeMapping; }
+
+        void setSplitStereoVerticalSeparation(int s) { _splitStereoVerticalSeparation = s; }
+        int getSplitStereoVerticalSeparation() const { return _splitStereoVerticalSeparation; }
+
+        void setSplitStereoAutoAjustAspectRatio(bool flag) { _splitStereoAutoAdjustAspectRatio=flag; }
+        bool getSplitStereoAutoAjustAspectRatio() const { return _splitStereoAutoAdjustAspectRatio; }
+
+
+        void setScreenWidth(float width) { _screenWidth = width; }
+        float getScreenWidth() const { return _screenWidth; }
+
+        void setScreenHeight(float height) { _screenHeight = height; }
+        float getScreenHeight() const { return _screenHeight; }
+
+        void setScreenDistance(float distance) { _screenDistance = distance; }
+        float getScreenDistance() const { return _screenDistance; }
+
+
+
+        void setDoubleBuffer(bool flag) { _doubleBuffer = flag; }
+        bool getDoubleBuffer() const { return _doubleBuffer; }
+
+
+        void setRGB(bool flag) { _RGB = flag; }
+        bool getRGB() const { return _RGB; }
+
+
+        void setDepthBuffer(bool flag) { _depthBuffer = flag; }
+        bool getDepthBuffer() const { return _depthBuffer; }
+
+
+        void setMinimumNumAlphaBits(unsigned int bits) { _minimumNumberAlphaBits = bits; }
+        unsigned int getMinimumNumAlphaBits() const { return _minimumNumberAlphaBits; }
+        bool getAlphaBuffer() const { return _minimumNumberAlphaBits!=0; }
+
+
+        void setMinimumNumStencilBits(unsigned int bits) { _minimumNumberStencilBits = bits; }
+        unsigned int getMinimumNumStencilBits() const { return _minimumNumberStencilBits; }
+        bool getStencilBuffer() const { return _minimumNumberStencilBits!=0; }
+
+
+        void setMaxNumberOfGraphicsContexts(unsigned int num) { _maxNumOfGraphicsContexts = num; }
+        unsigned int getMaxNumberOfGraphicsContexts() const { return _maxNumOfGraphicsContexts; }
+
+
+    protected:
+    
+        virtual ~DisplaySettings();
+
+
+        DisplayType                     _displayType;
+        bool                            _stereo;
+        StereoMode                      _stereoMode;
+        float                           _eyeSeparation;
+        float                           _screenWidth;
+        float                           _screenHeight;
+        float                           _screenDistance;
+
+        SplitStereoHorizontalEyeMapping _splitStereoHorizontalEyeMapping;
+        int                             _splitStereoHorizontalSeparation;
+        SplitStereoVerticalEyeMapping   _splitStereoVerticalEyeMapping;
+        int                             _splitStereoVerticalSeparation;
+        bool                            _splitStereoAutoAdjustAspectRatio;
+    
+        bool                            _doubleBuffer;
+        bool                            _RGB;
+        bool                            _depthBuffer;
+        unsigned int                    _minimumNumberAlphaBits;
+        unsigned int                    _minimumNumberStencilBits;
+
+        unsigned int                    _maxNumOfGraphicsContexts;
+
+};
+
+}
+
+# endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/BoundsChecking
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/BoundsChecking (revision 1529)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/BoundsChecking (revision 1529)
@@ -0,0 +1,208 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_BOUNDSCHECKING
+#define OSG_BOUNDSCHECKING 1
+
+#include <osg/Notify>
+
+namespace osg {
+
+
+/** if value is greater than or equal to minValue do nothing - legal value,
+  * otherwise clamp value to specified maximum value and return warning 
+  * with valueName specifying which variable was clamped.*/
+template <class T>
+inline void clampGEQUAL(T& value,const T minValue,const char* valueName)
+{
+    if (value<minValue)
+    {
+        notify(WARN) << "Warning: "<<valueName<<" of "<<value<<" is below permitted minimum, clampping to "<<minValue<<"."<< std::endl;
+        value = minValue;
+    }
+}
+
+/** if value is less than or equal to maxValue do nothing - legal value,
+  * otherwise clamp value to specified maximum value and return warning 
+  * with valueName specifying which variable was clamped.*/
+template <class T>
+inline void clampLEQUAL(T& value,const T maxValue,const char* valueName)
+{
+    if (value>maxValue)
+    {
+        notify(WARN) << "Warning: "<<valueName<<" of "<<value<<" is above permitted maximum, clampping to "<<maxValue<<"."<< std::endl;
+        value = maxValue;
+    }
+}
+
+/** if value is between or equal to minValue and maxValue do nothing - legal value,
+  * otherwise clamp value to specified to range and return warning 
+  * with valueName specifying which variable was clamped. Equivilant to
+  * calling clampGEQUAL(value,minValue,valueName); clampLEQUAL(value,maxValue,valueName); */
+template <class T>
+inline void clampBetweenRange(T& value,const T minValue,const T maxValue,const char* valueName)
+{
+    if (value<minValue)
+    {
+        notify(WARN) << "Warning: "<<valueName<<" of "<<value<<" is below permitted minimum, clampping to "<<minValue<<"."<< std::endl;
+        value = minValue;
+    }
+    else
+    if (value>maxValue)
+    {
+        notify(WARN) << "Warning: "<<valueName<<" of "<<value<<" is above permitted maximum, clampping to "<<maxValue<<"."<< std::endl;
+        value = maxValue;
+    }
+    
+}
+
+/** if array element value[i] is greater than or equal to minValue do nothing - legal value,
+  * otherwise clamp value to specified maximum value and return warning 
+  * with valueName specifying which variable was clamped.*/
+template <class A, class T>
+inline void clampArrayElementGEQUAL(A& value,unsigned int i,const T minValue,const char* valueName)
+{
+    if (value[i]<minValue)
+    {
+        notify(WARN) << "Warning: "<<valueName<<"["<<i<<"] of "<<value[i]<<" is below permitted minimum, clampping to "<<minValue<<"."<< std::endl;
+        value[i] = minValue;
+    }
+}
+
+/** if array element value[i] is less than or equal to maxValue do nothing - legal value,
+  * otherwise clamp value to specified maximum value and return warning 
+  * with valueName specifying which variable was clamped.*/
+template <class A, class T>
+inline void clampArrayElementLEQUAL(A& value,unsigned int i,const T maxValue,const char* valueName)
+{
+    if (value[i]>maxValue)
+    {
+        notify(WARN) << "Warning: "<<valueName<<"["<<i<<"] of "<<value[i]<<" is above permitted maximum, clampping to "<<maxValue<<"."<< std::endl;
+        value = maxValue;
+    }
+}
+
+/** if array element value[i] is between or equal to minValue and maxValue do nothing - legal value,
+  * otherwise clamp value to specified to range and return warning 
+  * with valueName specifying which variable was clamped. Equivilant to
+  * calling clampGEQUAL(value,minValue,valueName); clampLEQUAL(value,maxValue,valueName); */
+template <class A, class T>
+inline void clampArrayElementBetweenRange(A& value,unsigned int i,const T minValue,const T maxValue,const char* valueName)
+{
+    if (value[i]<minValue)
+    {
+        notify(WARN) << "Warning: "<<valueName<<"["<<i<<"] of "<<value[i]<<" is below permitted minimum, clampping to "<<minValue<<"."<< std::endl;
+        value[i] = minValue;
+    }
+    else
+    if (value[i]>maxValue)
+    {
+        notify(WARN) << "Warning: "<<valueName<<"["<<i<<"] of "<<value[i]<<" is above permitted maximum, clampping to "<<maxValue<<"."<< std::endl;
+        value[i] = maxValue;
+    }
+    
+}
+
+/** if array elements are greater than or equal to minValue do nothing - legal value,
+  * otherwise clamp value to specified maximum value and return warning 
+  * with valueName specifying which variable was clamped.*/
+template <class A, class T>
+inline void clampArrayElementsGEQUAL(A& value,unsigned int first,unsigned int last,const T minValue,const char* valueName)
+{
+    for(unsigned int i=first;i<=last;++i)
+        clampArrayElementGEQUAL(value,i,minValue,valueName);
+}
+
+/** if array elements are less than or equal to maxValue do nothing - legal value,
+  * otherwise clamp value to specified maximum value and return warning 
+  * with valueName specifying which variable was clamped.*/
+template <class A, class T>
+inline void clampArrayElementsLEQUAL(A& value,unsigned int first,unsigned int last,const T maxValue,const char* valueName)
+{
+    for(unsigned int i=first;i<=last;++i)
+        clampArrayElementLEQUAL(value,i,maxValue,valueName);
+}
+
+/** if array elements are between or equal to minValue and maxValue do nothing - legal value,
+  * otherwise clamp value to specified to range and return warning 
+  * with valueName specifying which variable was clamped. Equivalent to
+  * calling clampGEQUAL(value,minValue,valueName); clampLEQUAL(value,maxValue,valueName); */
+template <class A, class T>
+inline void clampArrayElementsBetweenRange(A& value,unsigned int first,unsigned int last,const T minValue,const T maxValue,const char* valueName)
+{
+    for(unsigned int i=first;i<=last;++i)
+        clampArrayElementBetweenRange(value,i,minValue,maxValue,valueName);    
+}
+
+
+/** if array4 elements are greater than or equal to minValue do nothing - legal value,
+  * otherwise clamp value to specified maximum value and return warning 
+  * with valueName specifying which variable was clamped.*/
+template <class A, class T>
+inline void clampArray3GEQUAL(A& value,const T minValue,const char* valueName)
+{
+    clampArrayElementsGEQUAL(value,0u,2u,minValue,valueName);
+}
+
+/** if array4 elements are is less than or equal to maxValue do nothing - legal value,
+  * otherwise clamp value to specified maximum value and return warning 
+  * with valueName specifying which variable was clamped.*/
+template <class A, class T>
+inline void clampArray3LEQUAL(A& value,const T maxValue,const char* valueName)
+{
+    clampArrayElementsLEQUAL(value,0u,2u,maxValue,valueName);
+}
+
+/** if array4 elements are between or equal to minValue and maxValue do nothing - legal value,
+  * otherwise clamp value to specified to range and return warning 
+  * with valueName specifying which variable was clamped. Equivilant to
+  * calling clampGEQUAL(value,minValue,valueName); clampLEQUAL(value,maxValue,valueName); */
+template <class A, class T>
+inline void clampArray3BetweenRange(A& value,const T minValue,const T maxValue,const char* valueName)
+{
+    clampArrayElementsBetweenRange(value,0u,2u,minValue,maxValue,valueName);
+}
+
+
+
+/** if array4 elements are greater than or equal to minValue do nothing - legal value,
+  * otherwise clamp value to specified maximum value and return warning 
+  * with valueName specifying which variable was clamped.*/
+template <class A, class T>
+inline void clampArray4GEQUAL(A& value,const T minValue,const char* valueName)
+{
+    clampArrayElementsGEQUAL(value,0u,3u,minValue,valueName);
+}
+
+/** if array4 elements are is less than or equal to maxValue do nothing - legal value,
+  * otherwise clamp value to specified maximum value and return warning 
+  * with valueName specifying which variable was clamped.*/
+template <class A, class T>
+inline void clampArray4LEQUAL(A& value,unsigned int first,unsigned int last,const T maxValue,const char* valueName)
+{
+    clampArrayElementsLEQUAL(value,0u,3u,maxValue,valueName);
+}
+
+/** if array4 elements are between or equal to minValue and maxValue do nothing - legal value,
+  * otherwise clamp value to specified to range and return warning 
+  * with valueName specifying which variable was clamped. Equivilant to
+  * calling clampGEQUAL(value,minValue,valueName); clampLEQUAL(value,maxValue,valueName); */
+template <class A, class T>
+inline void clampArray4BetweenRange(A& value,const T minValue,const T maxValue,const char* valueName)
+{
+    clampArrayElementsBetweenRange(value,0u,3u,minValue,maxValue,valueName);
+}
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ColorMask
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ColorMask (revision 2135)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ColorMask (revision 2135)
@@ -0,0 +1,96 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_COLORMASK
+#define OSG_COLORMASK 1
+
+#include <osg/Export>
+#include <osg/StateAttribute>
+
+namespace osg {
+
+/** Encapsulate OpenGL glColorMaskFunc/Op/Mask functions.
+*/     
+class SG_EXPORT ColorMask : public StateAttribute
+{
+    public :
+    
+    
+        ColorMask();
+
+        ColorMask(bool red,bool green,bool blue,bool alpha):
+            _red(red),
+            _green(green),
+            _blue(blue),
+            _alpha(alpha) {}
+            
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        ColorMask(const ColorMask& cm,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            StateAttribute(cm,copyop),
+            _red(cm._red),
+            _green(cm._green),
+            _blue(cm._blue),
+            _alpha(cm._alpha) {}
+        
+        META_StateAttribute(osg, ColorMask, COLORMASK);
+        
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const StateAttribute& sa) const
+        {
+            // check the types are equal and then create the rhs variable
+            // used by the COMPARE_StateAttribute_Paramter macro's below.
+            COMPARE_StateAttribute_Types(ColorMask,sa)
+
+            // compare each paramter in turn against the rhs.
+            COMPARE_StateAttribute_Parameter(_red)
+            COMPARE_StateAttribute_Parameter(_green)
+            COMPARE_StateAttribute_Parameter(_blue)
+            COMPARE_StateAttribute_Parameter(_alpha)
+
+            return 0; // passed all the above comparison macro's, must be equal.
+        }
+
+        inline void setMask(bool red,bool green,bool blue,bool alpha)
+        {
+            _red = red;
+            _green = green;
+            _blue = blue;
+            _alpha = alpha;
+            
+        }
+        
+        inline bool getRedMask() const { return _red; }
+
+        inline bool getGreenMask() const { return _green; }
+
+        inline bool getBlueMask() const { return _blue; }
+        
+        inline bool getAlphaMask() const { return _alpha; }
+
+        virtual void apply(State& state) const;
+
+    protected:
+    
+        virtual ~ColorMask();
+
+        bool                _red;
+        bool                _green;
+        bool                _blue;
+        bool                _alpha;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Billboard
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Billboard (revision 3070)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Billboard (revision 3070)
@@ -0,0 +1,135 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_BILLBOARD
+#define OSG_BILLBOARD 1
+
+#include <osg/Matrix>
+#include <osg/Geode>
+
+namespace osg {
+
+/** Billboard - a Geode which orientates its child osg::Drawable's to face
+    the eye point.  Typical uses are for trees, or particle explosions.
+*/
+class SG_EXPORT Billboard : public Geode
+{
+    public:
+
+        enum Mode {
+            POINT_ROT_EYE,
+            POINT_ROT_WORLD,
+            AXIAL_ROT
+        };
+
+        Billboard();
+        
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        Billboard(const Billboard&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+        META_Node(osg, Billboard);
+
+        /** Set the billboard rotation mode. */
+        void setMode(Mode mode);
+        /** Get the billboard rotation mode. */
+        inline Mode getMode() const { return _mode; }
+
+        /** Set the axis about which all the billboard's drawable rotate. Only utlized when mode==AXIAL_ROT*/
+        void setAxis(const Vec3& axis);
+        /** Get the axis about which all the billboard's drawable rotate. */
+        inline const Vec3& getAxis() const { return _axis; }
+
+        /** Set the normal which defines the billboard's drawable front face, when unrotated. */
+        void setNormal(const Vec3& normal);
+        /** Get the normal of billboard's drawable front face. */
+        inline const Vec3& getNormal() const { return _normal; }
+
+
+#ifdef USE_DEPRECATED_API
+        /** Set the position of specified drawable. */
+        inline void setPos(unsigned int i,const Vec3& pos)      { _positionList[i] = pos; }
+        /** Get the position of specified drawable. */
+        inline const Vec3& getPos(unsigned int i) const         { return _positionList[i]; }
+#endif
+        
+        /** Set the position of specified drawable. */
+        inline void setPosition(unsigned int i,const Vec3& pos)      { _positionList[i] = pos; }
+        /** Get the position of specified drawable. */
+        inline const Vec3& getPosition(unsigned int i) const         { return _positionList[i]; }
+
+        /** PositionList represents a list of pivot points for each drawable.*/
+        typedef std::vector<Vec3> PositionList;
+        
+        /** Get the PositionList from the billboard.*/
+        inline PositionList& getPositionList()             { return _positionList; }
+        
+        /** Get a const PositionList from the billboard.*/
+        inline const PositionList& getPositionList() const { return _positionList; }
+
+        /** Add Drawable to Billboard with default position(0,0,0);
+         *  If gset not NULL and is not contained in Billboard then increment its 
+         *  reference count, and dirty the bounding box to cause it to recompute on 
+         *  next getBound() and return true for success.  Otherwise return false.
+         */
+        virtual bool addDrawable( Drawable *gset );
+
+        /** Add Drawable to Geode at position pos.
+         *  If gset not NULL and is not contained in Billboard then increment its 
+         *  reference count, and dirty the bounding box to cause it to recompute on 
+         *  next getBound() and return true for success.  Otherwise return false.
+         */
+        virtual bool addDrawable(Drawable *gset,const Vec3& pos);
+
+        /** Remove Drawable and associated position from Billboard.
+         *  If gset is contained in Billboard then remove it from the geoset
+         *  list and decrement its reference count, and dirty the 
+         *  bounding box to cause it to recompute on next getBound() and
+         *  return true for success.  If gset is not found then return false
+         *  and do not the reference count of gset is left unchanged.
+         */
+        virtual bool removeDrawable( Drawable *gset );
+                
+
+        bool computeMatrix(Matrix& modelview, const Vec3& eye_local, const Vec3& pos_local) const;
+
+    protected:
+
+        virtual ~Billboard();
+
+        virtual bool computeBound() const;
+
+        enum AxisAligned
+        {
+            AXIAL_ROT_X_AXIS=AXIAL_ROT+1,
+            AXIAL_ROT_Y_AXIS,
+            AXIAL_ROT_Z_AXIS,
+            CACHE_DIRTY
+        };
+
+
+        Mode                                _mode;
+        Vec3                                _axis;
+        Vec3                                _normal;
+        PositionList                        _positionList;
+        
+        // used internally as cache of which what _axis is aligned to help
+        // decide which method of rotation to use.
+        int                                 _cachedMode;
+        Vec3                                _side;
+        void updateCache();
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ShadowVolumeOccluder
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ShadowVolumeOccluder (revision 1529)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ShadowVolumeOccluder (revision 1529)
@@ -0,0 +1,172 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_SHADOWVOLUMEOCCLUDER
+#define OSG_SHADOWVOLUMEOCCLUDER 1
+
+#include <osg/Polytope>
+#include <osg/ConvexPlanarOccluder>
+#include <osg/Node>
+
+namespace osg {
+
+class CullStack;
+
+/** ShadowVolumeOccluder is a helper class for implementating shadow occlusion culling. */
+class SG_EXPORT ShadowVolumeOccluder
+{
+
+    public:
+    
+    
+        typedef std::vector<Polytope> HoleList;
+
+        ShadowVolumeOccluder(const ShadowVolumeOccluder& svo):
+            _volume(svo._volume),
+            _nodePath(svo._nodePath),
+            _projectionMatrix(svo._projectionMatrix),
+            _occluderVolume(svo._occluderVolume),
+            _holeList(svo._holeList) {}
+
+        ShadowVolumeOccluder():
+            _volume(0.0f) {}
+
+
+        bool operator < (const ShadowVolumeOccluder& svo) const { return getVolume()>svo.getVolume(); } // not greater volume first. 
+
+        /** compute the shadow volume occluder. */
+        bool computeOccluder(const NodePath& nodePath,const ConvexPlanarOccluder& occluder,CullStack& cullStack,bool createDrawables=false);
+        
+
+        inline void disableResultMasks();
+        
+        inline void pushCurrentMask();
+        inline void popCurrentMask();
+        
+        
+        /** return true if the matrix passed in matches the projection matrix that this ShaowVolumeOccluder is
+          * associated with.*/
+        bool matchProjectionMatrix(const osg::Matrix& matrix) const
+        {
+            if (_projectionMatrix.valid()) return matrix==*_projectionMatrix;
+            else return false;
+        }
+        
+
+        /** Set the NodePath which describes the which node in the scene graph
+          * that this occluder was attached to.*/
+        inline void setNodePath(NodePath& nodePath) { _nodePath = nodePath; }
+        inline NodePath& getNodePath() { return _nodePath; }
+        inline const NodePath& getNodePath() const { return _nodePath; }
+
+
+        /** get the volume of the occluder minus its holes, in eye coords, the volume is normalized by dividing by 
+          * the volume of the view frustum in eye coords.*/
+        float getVolume() const { return _volume; }
+        
+        /** return the occluder polytope.*/
+        Polytope& getOccluder() { return _occluderVolume; }
+        
+        /** return the const occluder polytope.*/
+        const Polytope& getOccluder() const { return _occluderVolume; }
+        
+        /** return the list of holes.*/
+        HoleList& getHoleList() { return _holeList; }
+        
+        /** return the const list of holes.*/
+        const HoleList& getHoleList() const { return _holeList; }
+        
+
+        /** return true if the specified vertex list is contaned entirely
+          * within this shadow occluder volume.*/
+        bool contains(const std::vector<Vec3>& vertices);
+
+        /** return true if the specified bounding sphere is contaned entirely
+          * within this shadow occluder volume.*/
+        bool contains(const BoundingSphere& bound);
+        
+        /** return true if the specified bounding box is contained entirely
+          * within this shadow occluder volume.*/
+        bool contains(const BoundingBox& bound);
+
+        inline void transformProvidingInverse(const osg::Matrix& matrix)
+        {
+            _occluderVolume.transformProvidingInverse(matrix);
+            for(HoleList::iterator itr=_holeList.begin();
+                itr!=_holeList.end();
+                ++itr)
+            {
+                itr->transformProvidingInverse(matrix);
+            }
+        }
+        
+
+    protected:
+
+        float                       _volume;
+        NodePath                    _nodePath;
+        ref_ptr<const RefMatrix>    _projectionMatrix;
+        Polytope                    _occluderVolume;
+        HoleList                    _holeList;
+};
+
+
+/** A list of ShadowVolumeOccluder, used by CollectOccluderVisitor and CullVistor's.*/
+typedef std::vector<ShadowVolumeOccluder> ShadowVolumeOccluderList;
+
+
+inline void ShadowVolumeOccluder::disableResultMasks()
+{
+    //std::cout<<"ShadowVolumeOccluder::disableResultMasks() - _occluderVolume.getMaskStack().size()="<<_occluderVolume.getMaskStack().size()<<"  "<<_occluderVolume.getCurrentMask()<<std::endl;
+    _occluderVolume.setResultMask(0);
+    for(HoleList::iterator itr=_holeList.begin();
+        itr!=_holeList.end();
+        ++itr)
+    {
+        itr->setResultMask(0);
+    }
+}
+
+inline void ShadowVolumeOccluder::pushCurrentMask()
+{
+    //std::cout<<"ShadowVolumeOccluder::pushCurrentMasks() - _occluderVolume.getMaskStack().size()="<<_occluderVolume.getMaskStack().size()<<"  "<<_occluderVolume.getCurrentMask()<<std::endl;
+    _occluderVolume.pushCurrentMask();
+    if (!_holeList.empty())
+    {
+        for(HoleList::iterator itr=_holeList.begin();
+            itr!=_holeList.end();
+            ++itr)
+        {
+            itr->pushCurrentMask();
+        }
+    }
+}
+
+inline void ShadowVolumeOccluder::popCurrentMask()
+{
+    _occluderVolume.popCurrentMask();
+    if (!_holeList.empty())
+    {
+        for(HoleList::iterator itr=_holeList.begin();
+            itr!=_holeList.end();
+            ++itr)
+        {
+            itr->popCurrentMask();
+        }
+    }
+    //std::cout<<"ShadowVolumeOccluder::popCurrentMasks() - _occluderVolume.getMaskStack().size()="<<_occluderVolume.getMaskStack().size()<<"  "<<_occluderVolume.getCurrentMask()<<std::endl;
+}
+
+}	// end of namespace
+
+#endif 
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ImageStream
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ImageStream (revision 3179)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ImageStream (revision 3179)
@@ -0,0 +1,75 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_IMAGESTREAM
+#define OSG_IMAGESTREAM 1
+
+#include <osg/Image>
+
+namespace osg {
+
+/**
+ * Image Stream class.
+ */
+class SG_EXPORT ImageStream : public Image
+{
+    public:
+        ImageStream();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        ImageStream(const ImageStream& image,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+        virtual Object* cloneType() const { return new ImageStream(); }
+        virtual Object* clone(const CopyOp& copyop) const { return new ImageStream(*this,copyop); }
+        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const ImageStream*>(obj)!=0; }
+        virtual const char* libraryName() const { return "osg"; }
+        virtual const char* className() const { return "ImageStream"; }
+
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const Image& rhs) const;
+
+	enum StreamStatus
+        {
+            PLAYING,
+            PAUSED,
+            REWINDING
+        };
+        
+        virtual void play() { _status=PLAYING; }
+
+        virtual void pause() { _status=PAUSED; }
+
+        virtual void rewind() { _status=REWINDING; }
+        
+        virtual void quit(bool /*wiatForThreadToExit*/ = true) {}
+
+        StreamStatus getStatus() { return _status; }
+        
+        virtual void setReferenceTime(double) {}
+        virtual double getReferenceTime() const { return 0.0; }
+                
+        virtual void setTimeMultiplier(double) {}
+        virtual double getTimeMultiplier() { return 0.0; }
+        
+        virtual void update() {}
+
+    protected:
+
+        virtual ~ImageStream() {}
+
+        StreamStatus    _status;
+};
+
+} // namespace
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Texture
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Texture (revision 3222)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Texture (revision 3222)
@@ -0,0 +1,686 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_TEXTURE
+#define OSG_TEXTURE 1
+
+#include <osg/GL>
+#include <osg/Image>
+#include <osg/StateAttribute>
+#include <osg/ref_ptr>
+#include <osg/Vec4>
+#include <osg/buffered_value>
+
+#include <list>
+#include <map>
+
+#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
+    #include <OpenThreads/ScopedLock>
+    #include <OpenThreads/Mutex>
+#endif
+
+// if not defined by gl.h use the definition found in:
+// http://oss.sgi.com/projects/ogl-sample/registry/EXT/texture_filter_anisotropic.txt
+#ifndef GL_TEXTURE_MAX_ANISOTROPY_EXT
+#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
+#endif
+
+#ifndef GL_ARB_texture_compression
+#define GL_COMPRESSED_ALPHA_ARB                 0x84E9
+#define GL_COMPRESSED_LUMINANCE_ARB             0x84EA
+#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB       0x84EB
+#define GL_COMPRESSED_INTENSITY_ARB             0x84EC
+#define GL_COMPRESSED_RGB_ARB                   0x84ED
+#define GL_COMPRESSED_RGBA_ARB                  0x84EE
+#define GL_TEXTURE_COMPRESSION_HINT_ARB         0x84EF
+#define GL_TEXTURE_COMPRESSED_ARB               0x86A1
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB   0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS_ARB       0x86A3
+#endif
+
+#ifndef GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB
+#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB    0x86A0
+#endif
+
+#ifndef GL_EXT_texture_compression_s3tc
+#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT         0x83F0
+#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT        0x83F1
+#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT        0x83F2
+#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT        0x83F3
+#endif
+
+#ifndef GL_NV_texture_shader
+#define GL_HILO_NV                              0x86F4
+#define GL_DSDT_NV                              0x86F5
+#define GL_DSDT_MAG_NV                          0x86F6
+#define GL_DSDT_MAG_VIB_NV                      0x86F7
+#define GL_HILO16_NV                            0x86F8
+#define GL_SIGNED_HILO_NV                       0x86F9
+#define GL_SIGNED_HILO16_NV                     0x86FA
+#define GL_SIGNED_RGBA_NV                       0x86FB
+#define GL_SIGNED_RGBA8_NV                      0x86FC
+#define GL_SIGNED_RGB_NV                        0x86FE
+#define GL_SIGNED_RGB8_NV                       0x86FF
+#define GL_SIGNED_LUMINANCE_NV                  0x8701
+#define GL_SIGNED_LUMINANCE8_NV                 0x8702
+#define GL_SIGNED_LUMINANCE_ALPHA_NV            0x8703
+#define GL_SIGNED_LUMINANCE8_ALPHA8_NV          0x8704
+#define GL_SIGNED_ALPHA_NV                      0x8705
+#define GL_SIGNED_ALPHA8_NV                     0x8706
+#define GL_SIGNED_INTENSITY_NV                  0x8707
+#define GL_SIGNED_INTENSITY8_NV                 0x8708
+#define GL_DSDT8_NV                             0x8709
+#define GL_DSDT8_MAG8_NV                        0x870A
+#define GL_DSDT8_MAG8_INTENSITY8_NV             0x870B
+#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV         0x870C
+#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV       0x870D
+#endif
+
+#ifndef GL_MIRRORED_REPEAT_IBM
+#define GL_MIRRORED_REPEAT_IBM            0x8370
+#endif
+
+#ifndef GL_CLAMP_TO_EDGE
+#define GL_CLAMP_TO_EDGE                  0x812F
+#endif
+
+#ifndef GL_CLAMP_TO_BORDER_ARB
+#define GL_CLAMP_TO_BORDER_ARB            0x812D
+#endif
+
+#ifndef GL_GENERATE_MIPMAP_SGIS
+#define GL_GENERATE_MIPMAP_SGIS           0x8191
+#define GL_GENERATE_MIPMAP_HINT_SGIS      0x8192
+#endif
+
+#ifndef GL_TEXTURE_3D
+#define GL_TEXTURE_3D                     0x806F
+#endif
+
+#ifndef GL_TEXTURE_COMPARE_MODE_ARB
+#define GL_DEPTH_TEXTURE_MODE_ARB         0x884B
+#define GL_TEXTURE_COMPARE_MODE_ARB       0x884C
+#define GL_TEXTURE_COMPARE_FUNC_ARB       0x884D
+#define GL_COMPARE_R_TO_TEXTURE_ARB       0x884E
+#endif
+
+#ifndef TEXTURE_COMPARE_FAIL_VALUE_ARB
+#define TEXTURE_COMPARE_FAIL_VALUE_ARB    0x80BF
+#endif
+
+#if !defined( GL_MAX_TEXTURE_UNITS )
+#define GL_MAX_TEXTURE_UNITS              0x84E2
+#endif
+
+#ifndef  GL_TEXTURE_DEPTH
+#define GL_TEXTURE_DEPTH                  0x8071
+#endif
+
+namespace osg {
+
+/** Texture base class which encapsulates OpenGl texture functionality which common betweent the various types of OpenGL textures.*/
+class SG_EXPORT Texture : public osg::StateAttribute
+{
+
+    public :
+    
+        Texture();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        Texture(const Texture& text,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+        virtual osg::Object* cloneType() const = 0;
+        virtual osg::Object* clone(const CopyOp& copyop) const = 0;
+        virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Texture *>(obj)!=NULL; }
+        virtual const char* libraryName() const { return "osg"; }
+        virtual const char* className() const { return "Texture"; }
+        virtual Type getType() const { return TEXTURE; }
+
+        virtual bool isTextureAttribute() const { return true; }
+
+        enum WrapParameter {
+            WRAP_S,
+            WRAP_T,
+            WRAP_R
+        };
+
+        enum WrapMode {
+            CLAMP  = GL_CLAMP,
+            CLAMP_TO_EDGE = GL_CLAMP_TO_EDGE,
+            CLAMP_TO_BORDER = GL_CLAMP_TO_BORDER_ARB,
+            REPEAT = GL_REPEAT,
+            MIRROR = GL_MIRRORED_REPEAT_IBM
+        };
+
+        /** Set the texture wrap mode.*/
+        void setWrap(WrapParameter which, WrapMode wrap);
+        /** Get the texture wrap mode.*/
+        WrapMode getWrap(WrapParameter which) const;
+
+
+        /** Set the border color for this texture. Makes difference only if
+          * wrap mode is CLAMP_TO_BORDER */
+        void setBorderColor(const Vec4& color) { _borderColor = color; dirtyTextureParameters(); }
+        
+        /** Get the border color for this texture.*/
+        const Vec4& getBorderColor() const { return _borderColor; }
+        
+        /** Set the border width.*/
+        void setBorderWidth(GLint width) { _borderWidth = width; dirtyTextureParameters(); }
+        
+        GLint getBorderWidth() const { return _borderWidth; }
+
+        enum FilterParameter {
+            MIN_FILTER,
+            MAG_FILTER
+        };
+
+        enum FilterMode {
+            LINEAR                    = GL_LINEAR,
+            LINEAR_MIPMAP_LINEAR      = GL_LINEAR_MIPMAP_LINEAR,
+            LINEAR_MIPMAP_NEAREST     = GL_LINEAR_MIPMAP_NEAREST,
+            NEAREST                   = GL_NEAREST,
+            NEAREST_MIPMAP_LINEAR     = GL_NEAREST_MIPMAP_LINEAR,
+            NEAREST_MIPMAP_NEAREST    = GL_NEAREST_MIPMAP_NEAREST
+        };
+
+
+        /** Set the texture filter mode.*/
+        void setFilter(FilterParameter which, FilterMode filter);
+
+        /** Get the texture filter mode.*/
+        FilterMode getFilter(FilterParameter which) const;
+
+        /** Set the maximum anisotropy value, default value is 1.0 for
+          * no anisotropic filtering.  If hardware does not support anisotropic
+          * filtering then normal filtering is used, equivilant to a max anisotropy value of 1.0.
+          * valid range is 1.0f upwards.  The maximum value depends on the graphics
+          * system being used.*/
+        void setMaxAnisotropy(float anis);
+        
+        /** Get the maximum anisotropy value.*/
+        inline float getMaxAnisotropy() const { return _maxAnisotropy; }
+
+        /** Set the hint of whether to use hardware mip map generation where available.*/
+        inline void setUseHardwareMipMapGeneration(bool useHardwareMipMapGeneration) { _useHardwareMipMapGeneration = useHardwareMipMapGeneration; }
+
+        /** Get the hint of whether to use hardware mip map generation where available.*/
+        inline bool getUseHardwareMipMapGeneration() const { return _useHardwareMipMapGeneration; }
+
+        /** Set the automatic unreference of image data after the texture has been set up in apply, on (true) or off (false).
+          * If the image data is only referened by this Texture then the image data will be autoamtically deleted.*/
+        inline void setUnRefImageDataAfterApply(bool flag) { _unrefImageDataAfterApply = flag; }
+        
+        /** Get the automatic unreference of image data after the texture has been set up in apply.*/
+        inline bool getUnRefImageDataAfterApply() const { return _unrefImageDataAfterApply; }
+
+        /** Set whether to use client storage of the texture where supported by OpenGL drivers.
+          * Note, if UseClientStorageHint is set, and the OpenGL drivers support it, the osg::Image(s) associated with
+          * this texture cannot be deleted, so the UnRefImageDataAfterApply flag is then ignored.*/
+        inline void setClientStorageHint(bool flag) { _clientStorageHint = flag; }
+        
+        /** Get whether to use client storage of the texture where supported by OpenGL drivers.*/
+        inline bool getClientStorageHint() const { return _clientStorageHint; }
+
+        enum InternalFormatMode {
+            USE_IMAGE_DATA_FORMAT,
+            USE_USER_DEFINED_FORMAT,
+            USE_ARB_COMPRESSION,
+            USE_S3TC_DXT1_COMPRESSION,
+            USE_S3TC_DXT3_COMPRESSION,
+            USE_S3TC_DXT5_COMPRESSION
+        };
+
+        /** Set the internal format mode.
+          * Note, If the mode is set USE_IMAGE_DATA_FORMAT, USE_ARB_COMPRESSION,
+          * USE_S3TC_COMPRESSION the internalFormat is automatically selected,
+          * and will overwrite the previous _internalFormat.
+          */
+        inline void setInternalFormatMode(InternalFormatMode mode) { _internalFormatMode = mode; }
+
+        /** Get the internal format mode.*/
+        inline InternalFormatMode getInternalFormatMode() const { return _internalFormatMode; }
+
+        /** Set the internal format to use when creating OpenGL textures.
+          * Also sets the internalFormatMode to USE_USER_DEFINED_FORMAT.
+          */
+        inline void setInternalFormat(GLint internalFormat)
+        {
+            _internalFormatMode = USE_USER_DEFINED_FORMAT;
+            _internalFormat = internalFormat;
+        }
+
+        /** Get the internal format to use when creating OpenGL textures.*/
+        inline GLint getInternalFormat() const { if (_internalFormat==0) computeInternalFormat(); return _internalFormat; }
+        
+        bool isCompressedInternalFormat() const;
+
+
+        class TextureObject;
+
+        /** Get the handle to the texture object for the current context.*/
+        inline TextureObject* getTextureObject(unsigned int contextID) const
+        {
+            return _textureObjectBuffer[contextID].get();
+        }
+
+        /** Force a recompile on next apply() of associated OpenGL texture objects.*/
+        void dirtyTextureObject();
+
+        /** return true if the texture objects for all the required graphics contexts are loaded.*/
+        bool areAllTextureObjectsLoaded() const;
+
+
+        /** get the dirty flag for the current contextID.*/
+        inline unsigned int& getTextureParameterDirty(unsigned int contextID) const
+        {
+            return _texParametersDirtyList[contextID];
+        }
+
+
+        /** Force a resetting on next apply() of associated OpenGL texture parameters.*/
+        void dirtyTextureParameters();
+
+
+        // set mode of GL_TEXTURE_COMPARE_MODE_ARB to GL_COMPARE_R_TO_TEXTURE_ARB
+        // See http://oss.sgi.com/projects/ogl-sample/registry/ARB/shadow.txt
+        void setShadowComparison(bool flag) { _use_shadow_comparison = flag; }
+
+        enum ShadowCompareFunc {
+            LEQUAL = GL_LEQUAL,
+            GEQUAL = GL_GEQUAL
+        };
+
+        // set shadow texture comparison function
+        void setShadowCompareFunc(ShadowCompareFunc func) { _shadow_compare_func = func; }
+        ShadowCompareFunc getShadowCompareFunc() { return _shadow_compare_func; }
+
+        enum ShadowTextureMode {
+            LUMINANCE = GL_LUMINANCE,
+            INTENSITY = GL_INTENSITY,
+            ALPHA = GL_ALPHA
+        };
+
+        // set shadow texture mode after comparison
+        void setShadowTextureMode(ShadowTextureMode mode) { _shadow_texture_mode = mode; }
+        ShadowTextureMode getShadowTextureMode() { return _shadow_texture_mode; }
+
+        // set value of TEXTURE_COMPARE_FAIL_VALUE_ARB texture parameter
+        // http://oss.sgi.com/projects/ogl-sample/registry/ARB/shadow_ambient.txt
+        void setShadowAmbient(float shadow_ambient) { _shadow_ambient = shadow_ambient; }
+        float getShadowAmbient() { return _shadow_ambient; }
+        
+
+        /** Set the texture image for specified face. */
+        virtual void setImage(unsigned int face, Image* image) = 0;
+
+        /** Get the texture image for specified face. */
+        virtual Image* getImage(unsigned int face) = 0;
+
+        /** Get the const texture image for specified face. */
+        virtual const Image* getImage(unsigned int face) const = 0;
+
+        /** Get the number of images that can be assigned to the Texture. */
+        virtual unsigned int getNumImages() const = 0;
+
+
+        /** Texture is pure virtual base class, apply must be overriden. */
+        virtual void apply(State& state) const = 0;
+
+        /** Calls apply(state) to compile the texture. */
+        virtual void compileGLObjects(State& state) const;
+
+        /** release an OpenGL objects in specified graphics context if State
+            object is passed, otherwise release OpenGL objexts for all graphics context if
+            State object pointer NULL.*/
+        virtual void releaseGLObjects(State* state=0) const;
+
+        /** Extensions class which encapsulates the querring of extensions and
+          * associated function pointers, and provide convinience wrappers to 
+          * check for the extensions or use the associated functions.*/        
+        class SG_EXPORT Extensions : public osg::Referenced
+        {
+            public:
+                Extensions();
+
+                Extensions(const Extensions& rhs);
+                
+                void lowestCommonDenominator(const Extensions& rhs);
+                
+                void setupGLExtensions();
+
+                void setMultiTexturingSupported(bool flag) { _isMultiTexturingSupported=flag; }
+                bool isMultiTexturingSupported() const { return _isMultiTexturingSupported; }
+
+                void setTextureFilterAnisotropicSupported(bool flag) { _isTextureFilterAnisotropicSupported=flag; }
+                bool isTextureFilterAnisotropicSupported() const { return _isTextureFilterAnisotropicSupported; }
+                
+                void setTextureCompressionARBSupported(bool flag) { _isTextureCompressionARBSupported=flag; }
+                bool isTextureCompressionARBSupported() const { return _isTextureCompressionARBSupported; }
+
+                void setTextureCompressionS3TCSupported(bool flag) { _isTextureCompressionS3TCSupported=flag; }
+                bool isTextureCompressionS3TCSupported() const { return _isTextureCompressionS3TCSupported; }
+
+                void setTextureMirroredRepeatSupported(bool flag) { _isTextureMirroredRepeatSupported=flag; }
+                bool isTextureMirroredRepeatSupported() const { return _isTextureMirroredRepeatSupported; }
+
+                void setTextureEdgeClampSupported(bool flag) { _isTextureEdgeClampSupported=flag; }
+                bool isTextureEdgeClampSupported() const { return _isTextureEdgeClampSupported; }
+
+                void setTextureBorderClampSupported(bool flag) { _isTextureBorderClampSupported=flag; }
+                bool isTextureBorderClampSupported() const { return _isTextureBorderClampSupported; }
+
+                void setGenerateMipMapSupported(bool flag) { _isGenerateMipMapSupported=flag; }
+                bool isGenerateMipMapSupported() const { return _isGenerateMipMapSupported; }
+
+                void setShadowSupported(bool flag) { _isShadowSupported = flag; }
+                bool isShadowSupported() const { return _isShadowSupported; }
+
+                void setShadowAmbientSupported(bool flag) { _isShadowAmbientSupported = flag; }
+                bool isShadowAmbientSupported() const { return _isShadowAmbientSupported; }
+
+                void setMaxTextureSize(GLint maxsize) { _maxTextureSize=maxsize; }
+                GLint maxTextureSize() const { return _maxTextureSize; }
+
+                void setNumTextureUnits(GLint nunits ) { _numTextureUnits=nunits; }
+                GLint numTextureUnits() const { return _numTextureUnits; }
+
+                bool isCompressedTexImage2DSupported() const { return _glCompressedTexImage2D!=0; }
+
+                void setCompressedTexImage2DProc(void* ptr) { _glCompressedTexImage2D = ptr; }
+                void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) const;
+
+                void setCompressedTexSubImage2DProc(void* ptr) { _glCompressedTexSubImage2D = ptr; }
+                void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei type, const GLvoid *data) const;
+
+                void setGetCompressedTexImageProc(void* ptr) { _glGetCompressedTexImage = ptr; }
+                void glGetCompressedTexImage(GLenum target, GLint level, GLvoid *data) const;
+
+                bool isClientStorageSupported() const { return _isClientStorageSupported; }
+              
+
+            protected:
+
+                ~Extensions() {}
+                
+                bool    _isMultiTexturingSupported;
+                bool    _isTextureFilterAnisotropicSupported;
+                bool    _isTextureCompressionARBSupported;
+                bool    _isTextureCompressionS3TCSupported;
+                bool    _isTextureMirroredRepeatSupported;
+                bool    _isTextureEdgeClampSupported;
+                bool    _isTextureBorderClampSupported;
+                bool    _isGenerateMipMapSupported;
+                bool    _isShadowSupported;
+                bool    _isShadowAmbientSupported;
+                bool    _isClientStorageSupported;
+                
+                GLint   _maxTextureSize;
+                GLint   _numTextureUnits;
+
+                void*   _glCompressedTexImage2D;
+                void*   _glCompressedTexSubImage2D;
+                void*   _glGetCompressedTexImage;
+
+        };
+        
+        /** Function to call to get the extension of a specified context.
+          * If the Exentsion object for that context has not yet been created then 
+          * and the 'createIfNotInitalized' flag been set to false then returns NULL.
+          * If 'createIfNotInitalized' is true then the Extensions object is 
+          * automatically created.  However, in this case the extension object 
+          * only be created with the graphics context associated with ContextID..*/
+        static Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized);
+
+        /** setExtensions allows users to override the extensions across graphics contexts.
+          * typically used when you have different extensions supported across graphics pipes
+          * but need to ensure that they all use the same low common denominator extensions.*/
+        static void setExtensions(unsigned int contextID,Extensions* extensions);
+
+
+        /** Helper method which does the creation of the texture itself, but does not set or use texture binding. 
+          * Note, do not call this method directly unless you are implementing your own Subload callback*/
+        void applyTexImage2D_load(State& state, GLenum target, const Image* image, GLsizei width, GLsizei height,GLsizei numMipmapLevels) const;
+        
+        /** Helper method which subloads images to the texture itself, but does not set or use texture binding. 
+          * Note, do not call this method directly unless you are implementing your own Subload callback*/
+        void applyTexImage2D_subload(State& state, GLenum target, const Image* image, GLsizei width, GLsizei height, GLint inInternalFormat, GLsizei numMipmapLevels) const;
+
+    protected :
+
+        virtual ~Texture();
+
+        virtual void computeInternalFormat() const = 0;
+        
+        void computeInternalFormatWithImage(const osg::Image& image) const;
+
+        void computeRequiredTextureDimensions(State& state, const osg::Image& image,GLsizei& width, GLsizei& height,GLsizei& numMipmapLevels) const;
+
+        bool isCompressedInternalFormat(GLint internalFormat) const;
+
+        /** Helper method which does setting of texture paramters. */
+        void applyTexParameters(GLenum target, State& state) const;
+        
+
+
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        int compareTexture(const Texture& rhs) const;
+
+        typedef buffered_value<unsigned int> TexParameterDirtyList;
+        mutable TexParameterDirtyList _texParametersDirtyList;
+
+        WrapMode _wrap_s;
+        WrapMode _wrap_t;
+        WrapMode _wrap_r;
+
+        FilterMode      _min_filter;
+        FilterMode      _mag_filter;
+        float           _maxAnisotropy;
+        bool            _useHardwareMipMapGeneration;
+        bool            _unrefImageDataAfterApply;
+        bool            _clientStorageHint;
+
+        Vec4            _borderColor;
+        GLint           _borderWidth;
+
+        InternalFormatMode  _internalFormatMode;
+        mutable GLint       _internalFormat;
+      
+        bool                _use_shadow_comparison;
+        ShadowCompareFunc   _shadow_compare_func;
+        ShadowTextureMode   _shadow_texture_mode;
+        float               _shadow_ambient;
+
+
+    public:
+    
+        class TextureObject : public osg::Referenced
+        {
+        public:
+        
+            inline TextureObject(GLuint    id,GLenum target):
+                _id(id),
+                _target(target),
+                _numMipmapLevels(0),
+                _internalFormat(0),
+                _width(0),
+                _height(0),
+                _depth(0),
+                _border(0),
+                _allocated(false),
+                _timeStamp(0) {}
+                
+            inline TextureObject(GLuint    id,
+                          GLenum    target,
+                          GLint     numMipmapLevels,
+                          GLenum    internalFormat,
+                          GLsizei   width,
+                          GLsizei   height,
+                          GLsizei   depth,
+                          GLint     border):
+                _id(id),
+                _target(target),
+                _numMipmapLevels(numMipmapLevels),
+                _internalFormat(internalFormat),
+                _width(width),
+                _height(height),
+                _depth(depth),
+                _border(border),
+                _allocated(false),
+                _timeStamp(0) {}
+                          
+            inline bool match(GLenum    target,
+                       GLint     numMipmapLevels,
+                       GLenum    internalFormat,
+                       GLsizei   width,
+                       GLsizei   height,
+                       GLsizei   depth,
+                       GLint     border)
+            {
+                return isReusable() &&
+                       (_target == target) &&
+                       (_numMipmapLevels == numMipmapLevels) &&
+                       (_internalFormat == internalFormat) &&
+                       (_width == width) &&
+                       (_height == height) &&
+                       (_depth == depth) &&
+                       (_border == border);
+            }
+            
+            
+            inline void bind()
+            {
+                glBindTexture( _target, _id);
+            }
+
+
+            inline void setAllocated(bool allocated=true) { _allocated = allocated; }
+            
+            inline void setAllocated(GLint     numMipmapLevels,
+                              GLenum    internalFormat,
+                              GLsizei   width,
+                              GLsizei   height,
+                              GLsizei   depth,
+                              GLint     border)
+            {
+                _allocated=true;
+                _numMipmapLevels = numMipmapLevels;
+                _internalFormat = internalFormat;
+                _width = width;
+                _height = height;
+                _depth = depth;
+                _border = border;
+            }
+        
+            inline bool isAllocated() const { return _allocated; }
+
+            inline bool isReusable() const { return _allocated && _width!=0; }
+
+            GLuint      _id;
+            GLenum      _target;
+            GLint       _numMipmapLevels;
+            GLenum      _internalFormat;
+            GLsizei     _width;
+            GLsizei     _height;
+            GLsizei     _depth;
+            GLint       _border;
+
+            bool        _allocated;
+            double      _timeStamp;
+        };
+        
+        typedef std::list< ref_ptr<TextureObject> > TextureObjectList;
+        typedef std::map<unsigned int, TextureObjectList > TextureObjectListMap; 
+
+        /** take the active texture objects from the Texture and place them in the specified TextureObjectListMap.*/
+        void takeTextureObjects(TextureObjectListMap& toblm);
+        
+        typedef buffered_object< ref_ptr<TextureObject> >  TextureObjectBuffer;
+        mutable TextureObjectBuffer _textureObjectBuffer;
+
+
+        class SG_EXPORT TextureObjectManager : public osg::Referenced
+        {
+        public:
+        
+            TextureObjectManager():
+                _expiryDelay(0.0) {}
+
+            virtual TextureObject* generateTextureObject(unsigned int contextID,GLenum target);
+
+            virtual TextureObject* generateTextureObject(unsigned int contextID,
+                                                         GLenum    target,
+                                                         GLint     numMipmapLevels,
+                                                         GLenum    internalFormat,
+                                                         GLsizei   width,
+                                                         GLsizei   height,
+                                                         GLsizei   depth,
+                                                         GLint     border);
+
+            virtual TextureObject* reuseTextureObject(unsigned int contextID,
+                                                      GLenum    target,
+                                                      GLint     numMipmapLevels,
+                                                      GLenum    internalFormat,
+                                                      GLsizei   width,
+                                                      GLsizei   height,
+                                                      GLsizei   depth,
+                                                      GLint     border);
+            
+            inline TextureObject* reuseOrGenerateTextureObject(unsigned int contextID,
+                                                      GLenum    target,
+                                                      GLint     numMipmapLevels,
+                                                      GLenum    internalFormat,
+                                                      GLsizei   width,
+                                                      GLsizei   height,
+                                                      GLsizei   depth,
+                                                      GLint     border)
+            {
+                TextureObject* to = reuseTextureObject(contextID,target,numMipmapLevels,internalFormat,width,height,depth,border);
+                if (to) return to;
+                else return generateTextureObject(contextID,target,numMipmapLevels,internalFormat,width,height,depth,border);
+            }                                                      
+
+            virtual void addTextureObjects(TextureObjectListMap& toblm);
+            
+            virtual void addTextureObjectsFrom(Texture& texture);
+            
+            virtual void flushTextureObjects(unsigned int contextID,double currentTime, double& availableTime);
+            
+
+            void setExpiryDelay(double expiryDelay) { _expiryDelay = expiryDelay; }
+
+            double getExpiryDelay() const { return _expiryDelay; }
+            
+            // how long to keep unsed texture objects around for before deleting.
+            double                  _expiryDelay;
+            
+            TextureObjectListMap    _textureObjectListMap;
+            
+#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
+            // mutex to keep access serialized.
+            OpenThreads::Mutex      _mutex;
+#endif            
+        };
+        
+        
+        static void setTextureObjectManager(TextureObjectManager* tom);
+        static TextureObjectManager* getTextureObjectManager();
+        static void flushTextureObjects(unsigned int contextID,double currentTime, double& availableTime);
+        
+        
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/MatrixTransform
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/MatrixTransform (revision 1558)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/MatrixTransform (revision 1558)
@@ -0,0 +1,85 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_MATRIXTRANSFORM
+#define OSG_MATRIXTRANSFORM 1
+
+#include <osg/Transform>
+#include <osg/AnimationPath>
+
+namespace osg {
+
+/** MatrixTransform - is a subclass of Transform which has an osg::Matrix
+  * which represent a 4x4 transformation of its children from local cordinates
+  * into the Transform's parent coordinates.
+*/
+class SG_EXPORT MatrixTransform : public Transform
+{
+    public :
+
+
+        MatrixTransform();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        MatrixTransform(const MatrixTransform&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+        MatrixTransform(const Matrix& matix);
+
+        META_Node(osg, MatrixTransform);
+
+        virtual MatrixTransform* asMatrixTransform() { return this; }
+        virtual const MatrixTransform* asMatrixTransform() const { return this; }
+
+
+        /** Set the transform's matrix.*/
+        void setMatrix(const Matrix& mat) { _matrix = mat; _inverseDirty=true; dirtyBound(); }
+        
+        /** Get the matrix. */
+        inline const Matrix& getMatrix() const { return _matrix; }
+
+        /** pre multiply the transforms matrix.*/
+        void preMult(const Matrix& mat) { _matrix.preMult(mat); _inverseDirty=true; dirtyBound(); }
+        
+        /** post multiply the transforms matrix.*/
+        void postMult(const Matrix& mat)  { _matrix.postMult(mat); _inverseDirty=true; dirtyBound(); }
+    
+        /** Get the inverse matrix. */
+        inline const Matrix& getInverseMatrix() const
+        {
+            if (_inverseDirty)
+            {
+                _inverse.invert(_matrix);
+                _inverseDirty = false;
+            }
+            return _inverse;
+        }
+
+        virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const;
+
+        virtual bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor*) const;
+
+
+    protected :
+    
+        virtual ~MatrixTransform();
+        
+        Matrix                              _matrix;
+        mutable Matrix                      _inverse;
+        mutable bool                        _inverseDirty;
+
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Switch
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Switch (revision 3072)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Switch (revision 3072)
@@ -0,0 +1,113 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_SWITCH
+#define OSG_SWITCH 1
+
+#include <osg/Group>
+
+namespace osg {
+
+/** Switch is a Group node which allows switching between children.
+    Typical uses would be for objects which might need to be rendered
+    differently at different times, for instance a switch could be used 
+    to represent the different states of a traffic light.
+*/
+class SG_EXPORT Switch : public Group
+{
+    public :
+        
+
+        Switch();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        Switch(const Switch&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+        META_Node(osg, Switch);
+
+        virtual void traverse(NodeVisitor& nv);
+        
+        void setNewChildDefaultValue(bool value) { _newChildDefaultValue = value; }
+        
+        bool getNewChildDefaultValue() const { return _newChildDefaultValue; }
+
+        virtual bool addChild( Node *child );
+
+        virtual bool addChild( Node *child, bool value );
+
+        virtual bool insertChild( unsigned int index, Node *child );
+
+        virtual bool insertChild( unsigned int index, Node *child, bool value );
+
+        virtual bool removeChild( Node *child );
+
+        void setValue(unsigned int pos,bool value);
+
+        bool getValue(unsigned int pos) const;
+
+        void setChildValue(const Node* child,bool value);
+        
+        bool getChildValue(const Node* child) const;
+
+        /** Set all the children off (false), and set the new default child value to off (false).*/
+        bool setAllChildrenOff();
+        
+        /** Set all the children on (true), and set the new default child value to on (true).*/
+        bool setAllChildrenOn();
+        
+        /** Set a single child to be on, switch off all other children.*/
+        bool setSingleChildOn(unsigned int pos);
+        
+#ifdef USE_DEPRECATED_API
+	/**
+	 * Special values for the Switch. Use these if you want to
+	 * turn on/off all child nodes.
+	 */
+        enum Values {
+                /** All children turned on. */
+		ALL_CHILDREN_ON=-1,
+                /** All children off. */
+		ALL_CHILDREN_OFF=-2,
+                /** Multiple children turned on.*/
+                MULTIPLE_CHILDREN_ON=-3
+        };
+
+	/**
+	 * Selects the active child Node or enables a special
+	 * SwitchType mode. 
+         * @param value the number of the active child
+	 * (first child == number 0) or SwitchType. Invalid values
+	 * will be ignored.
+	 */
+        void setValue(int value);
+
+        int getValue() const;
+        
+#endif        
+
+        typedef std::vector<bool>   ValueList;
+        
+        const ValueList& getValueList() const { return _values; }
+
+    protected :
+    
+        virtual ~Switch() {}
+
+        // this is effectively a bit mask.
+        bool        _newChildDefaultValue;
+        ValueList   _values;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Referenced
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Referenced (revision 3222)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Referenced (revision 3222)
@@ -0,0 +1,143 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_REFERENCED
+#define OSG_REFERENCED 1
+
+
+#include <osg/Export>
+
+// #define THREAD_SAFE_REF_UNREF 1
+
+#ifdef THREAD_SAFE_REF_UNREF
+    #include <OpenThreads/ScopedLock>
+    #include <OpenThreads/Mutex>
+#endif
+
+namespace osg {
+
+
+// forward declar, declared after Refenced below.
+class DeleteHandler;
+
+
+/** Base class from providing referencing counted objects.*/
+class SG_EXPORT Referenced
+{
+
+    public:
+        Referenced() 
+        {
+           
+           _refCount=0;
+        }
+        Referenced(const Referenced&) {
+            _refCount=0;
+        }
+
+        inline Referenced& operator = (const Referenced&) { return *this; }
+
+        friend class DeleteHandler;
+
+        /** Set a DeleteHandler to which deletion of all referenced counted objects
+          * will be delegated to.*/
+        static void setDeleteHandler(DeleteHandler* handler);
+
+        /** Get a DeleteHandler.*/
+        static DeleteHandler* getDeleteHandler();
+
+
+        /** increment the reference count by one, indicating that 
+            this object has another pointer which is referencing it.*/
+        inline void ref() const
+        { 
+#ifdef THREAD_SAFE_REF_UNREF
+            OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_refMutex); 
+#endif
+            ++_refCount;
+        }
+        
+        /** decrement the reference count by one, indicating that 
+            a pointer to this object is referencing it.  If the
+            reference count goes to zero, it is assumed that this object
+            is no longer referenced and is automatically deleted.*/
+        inline void unref() const;
+        
+        /** decrement the reference count by one, indicating that 
+            a pointer to this object is referencing it.  However, do
+            not delete it, even if ref count goes to 0.  Warning, unref_nodelete() 
+            should only be called if the user knows exactly who will
+            be resonsible for, one should prefer unref() over unref_nodelete() 
+            as the later can lead to memory leaks.*/
+        inline void unref_nodelete() const { --_refCount; }
+        
+        /** return the number pointers currently referencing this object. */
+        inline int referenceCount() const { return _refCount; }
+
+       
+    protected:
+        virtual ~Referenced();
+        
+#ifdef THREAD_SAFE_REF_UNREF
+        mutable OpenThreads::Mutex  _refMutex;
+#endif
+        mutable int                 _refCount;
+        
+};
+
+
+/** Class for override the default delete behavior so that users can implment their own object
+  * deletion schemes.  This might be done to help implement protection of multiple threads from deleting
+  * objects unintentionally.
+  * Note, the DeleteHandler cannot itself be reference counted, otherwise it
+  * would be responsible for deleting itself!
+  * An static auto_ptr<> is used internally in Referenced.cpp to manage the 
+  * DeleteHandler's memory.*/
+class DeleteHandler
+{
+    public:
+
+        virtual ~DeleteHandler() {}
+
+        /** flush any cache of objects that need to be deleted by doing an actual delete.*/
+        virtual void flush() {}
+        
+        inline void doDelete(const Referenced* object) { delete object; }
+         
+        /** Request the deletion of an object. 
+          * Depending on users implementation of DeleteHandler, the delete of the object may occur 
+          * straight away or be delayed until doDelete is called.
+          * The default implementation does a delete straight away.*/
+        virtual void requestDelete(const Referenced* object) { doDelete(object); }
+};
+
+inline void Referenced::unref() const
+{
+    bool needDelete = false;
+    {
+#ifdef THREAD_SAFE_REF_UNREF
+        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_refMutex); 
+#endif
+        --_refCount;
+        needDelete = _refCount<=0;
+    }
+    if (needDelete)
+    {
+        if (getDeleteHandler()) getDeleteHandler()->requestDelete(this);
+        else delete this;
+    }
+}
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/fast_back_stack
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/fast_back_stack (revision 1529)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/fast_back_stack (revision 1529)
@@ -0,0 +1,97 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_FAST_BACK_STACK
+#define OSG_FAST_BACK_STACK 1
+
+#include <vector>
+
+namespace osg {
+
+/** Simple stack implementation that keeps the back() cached locally for fast access
+  * rather than at the back of the vector which is the traditional stack implementation.
+  * A conventional std::vector<> stores the rest of the stack. The fast_back_stack
+  * although contains a stl container it only implments the back push_back(),pop_back()
+  * and back() methods so is not as general purpose as stl stack implementation.
+  * The focus of the fast_back_stack is purly to maximize the speed at which the
+  * back can be accessed.*/
+  
+template<class T>
+class fast_back_stack
+{
+    public:
+    
+        inline fast_back_stack():_value(),_stack(),_size(0) {}
+
+        inline fast_back_stack(const fast_back_stack& fbs):_value(fbs._value),_stack(fbs._stack),_size(fbs._size) {}
+
+        inline fast_back_stack(const T& value):_value(value),_stack(),_size(1) {}
+
+        fast_back_stack& operator = (const fast_back_stack& fbs)
+        {
+            _value = fbs._value;
+            _stack = fbs._stack;
+            _size = fbs._size;
+            return *this;
+        }
+
+        inline void clear() { _stack.clear(); _size = 0; }
+
+        inline bool empty() const { return _size==0; }
+
+        inline unsigned int size() const { return _size; }
+
+        inline T& back() { return _value; }
+
+        inline const T& back() const { return _value; }
+
+        inline void push_back()
+        {
+            if (_size>0)
+            {
+                _stack.push_back(_value);
+            }
+            ++_size;
+        }
+        
+        inline void push_back(const T& value)
+        {
+            if (_size>0)
+            {
+                _stack.push_back(_value);
+            }
+            _value = value;
+            ++_size;
+        }
+        
+        inline void pop_back()
+        {
+            if (_size>0)
+            {
+                if (!_stack.empty())
+                {
+                    _value = _stack.back();
+                    _stack.pop_back();
+                }
+                --_size;
+            } // else error condition.
+        }
+        
+        T              _value;
+        std::vector<T> _stack;
+        unsigned int   _size;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ImpostorSprite
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ImpostorSprite (revision 1847)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ImpostorSprite (revision 1847)
@@ -0,0 +1,226 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_ImpostorSprite
+#define OSG_ImpostorSprite 1
+
+#include <osg/Vec2>
+#include <osg/BoundingSphere>
+#include <osg/Drawable>
+#include <osg/ImpostorSprite>
+#include <osg/AlphaFunc>
+#include <osg/TexEnv>
+
+namespace osg {
+
+class Texture2D;
+class Impostor;
+class ImpostorSpriteManager;
+
+/** An ImposterSprite is a textured quad which is rendered in place a 
+  * 3D geometry.  The ImposterSprite is generated by rendering the original
+  * 3D geometry to a texture as an image cache. The ImpostorSprite is
+  * automatically generated by the osgUtil::CullVisitor so it not
+  * necessary to deal with it directly.
+  */
+class SG_EXPORT ImpostorSprite : public Drawable
+{
+    public:
+
+        ImpostorSprite();
+
+        /** Clone an object of the same type as an ImpostorSprite.*/
+        virtual Object* cloneType() const { return new ImpostorSprite(); }
+
+        /** Clone on ImpostorSprite just returns a clone of type, 
+          * since it is not appropriate to share data of an ImpostorSprite.*/
+        virtual Object* clone(const CopyOp&) const { return new ImpostorSprite(); }
+        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const ImpostorSprite*>(obj)!=NULL; }
+        virtual const char* libraryName() const { return "osg"; }
+        virtual const char* className() const { return "ImpostorSprite"; }
+
+        /** Set the parent, which must be an Impostor. 
+          * Unlike conventional Drawables, ImpostorSprite's can only ever have
+          * one parent.
+          */
+        void setParent(Impostor* parent) { _parent = parent; }
+
+        /** Get the parent, which is an Impostor. */
+        Impostor* getParent() { return _parent; }
+
+        /** Get the const parent, which is an Impostor. */
+        const Impostor* getParent() const { return _parent; }
+
+        /** Set the eye point for when the ImpsotorSprite was snapped.*/
+        inline void setStoredLocalEyePoint(const Vec3& v) { _storedLocalEyePoint=v; }
+
+        /** Get the eye point for when the ImpsotorSprite was snapped.*/
+        inline const Vec3& getStoredLocalEyePoint() const { return _storedLocalEyePoint; }
+        
+        /** Set the frame number for when the ImpostorSprite was last used in rendering.*/
+        inline void setLastFrameUsed(int frameNumber) { _lastFrameUsed = frameNumber; }
+        
+        /** Get the frame number for when the ImpostorSprite was last used in rendering.*/
+        inline int getLastFrameUsed() const { return _lastFrameUsed; }
+        
+
+        /** Get the coordinates of the corners of the quad.
+          * Stored in the order, [0] - top_left, [1] - bottom_left, [2] - bottom_right, [3] - top_left.
+          */
+        inline Vec3* getCoords() { return _coords; }
+        
+        /** Get the const coordinates of the corners of the quad.
+          */
+        inline const Vec3* getCoords() const { return _coords; }
+
+
+
+        /** Get the texture coordinates of the corners of the quad.
+          * Stored in the order, [0] - top_left, [1] - bottom_left, [2] - bottom_right, [3] - top_left.
+          */
+        inline Vec2* getTexCoords() { return _texcoords; }
+        
+        /** Get the const texture coordinates of the corners of the quad.*/
+        inline const Vec2* getTexCoords() const { return _texcoords; }
+
+        /** Get the control coordinates of the corners of the quad.
+          * The control coordinates are the corners of the quad projected
+          * out onto the front face of bounding box which enclosed the impostor
+          * geometry when it was pre-rendered into the impostor sprite's texture.
+          * At the point of creation/or update of the impostor sprite the control
+          * coords will lie on top of the corners of the quad in screen space - with a pixel error
+          * or zero.  Once the camera moves relative to the impostor sprite the
+          * control coords will no longer lie on top of the corners of the quad in
+          * screen space - a pixel error will have accumulated. This pixel error
+          * can then be used to determine whether the impostor needs to be updated.
+          * Stored in the order, [0] - top_left, [1] - bottom_left, [2] - bottom_right, [3] - top_left.
+          */
+        inline Vec3* getControlCoords() { return _controlcoords; }
+        
+        /** Get the const control coordinates of the corners of the quad.*/
+        inline const Vec3* getControlCoords() const { return _controlcoords; }
+
+
+        /** calculate the pixel error value for passing in the ModelViewProjectionWindow transform,
+          * which transform local coords into screen space.*/
+        float calcPixelError(const Matrix& MVPW) const;
+
+        void setTexture(Texture2D* tex,int s,int t);
+
+        Texture2D* getTexture() { return _texture; }
+        const Texture2D* getTexture() const { return _texture; }
+        int s() const { return _s; }
+        int t() const { return _t; }
+
+        /** draw ImpostorSprite directly. */
+        virtual void drawImplementation(State& state) const;
+
+        /** return true, osg::ImpostorSprite does support accept(AttributeFunctor&).*/
+        virtual bool supports(AttributeFunctor&) const { return true; }
+
+        /** accept an AttributeFunctor and call its methods to tell it about the interal attributes that this Drawable has.*/
+        virtual void accept(AttributeFunctor& af);
+
+        /** return true, osg::ImpostorSprite does support accept(ConstAttributeFunctor&).*/
+        virtual bool supports(ConstAttributeFunctor&) const { return true; }
+
+        /** accept an ConstAttributeFunctor and call its methods to tell it about the interal attributes that this Drawable has.*/
+        virtual void accept(ConstAttributeFunctor& af) const;
+
+        /** return true, osg::ImpostorSprite does support accept(PrimitiveFunctor&) .*/
+        virtual bool supports(PrimitiveFunctor&) const { return true; }
+
+        /** accept a PrimtiveFunctor and call its methods to tell it about the interal primtives that this Drawable has.*/
+        virtual void accept(PrimitiveFunctor& pf) const;
+
+        // for debugging purposes.
+        Vec4 _color;
+
+    protected:
+
+        ImpostorSprite(const ImpostorSprite&):Drawable() {}
+        ImpostorSprite& operator = (const ImpostorSprite&) { return *this;}
+
+        virtual ~ImpostorSprite();
+
+        virtual bool computeBound() const;
+
+        Impostor* _parent;
+
+        friend class osg::ImpostorSpriteManager;
+
+        // support for a double linked list managed by the
+        // ImposotorSpriteManager.
+        ImpostorSpriteManager*  _ism;
+        ImpostorSprite*         _previous;
+        ImpostorSprite*         _next;
+        
+        int _lastFrameUsed;
+
+        Vec3 _storedLocalEyePoint;
+        
+        Vec3 _coords[4];
+        Vec2 _texcoords[4];
+        Vec3 _controlcoords[4];
+        
+        Texture2D* _texture;
+        int _s;
+        int _t;
+        
+        
+};
+
+/** Helper class for managing the reuse of ImpostorSprite resources.*/
+class SG_EXPORT ImpostorSpriteManager : public Referenced
+{
+    public:
+    
+        ImpostorSpriteManager();
+        
+        bool empty() const { return _first==0; }
+
+        ImpostorSprite* first() { return _first; }
+        
+        ImpostorSprite* last() { return _last; }
+        
+        void push_back(ImpostorSprite* is);
+        
+        void remove(ImpostorSprite* is);
+        
+        ImpostorSprite* createOrReuseImpostorSprite(int s,int t,int frameNumber);
+
+        StateSet* createOrReuseStateSet();
+
+        void reset();
+    
+    protected:
+
+
+        ~ImpostorSpriteManager();
+
+        ref_ptr<TexEnv>     _texenv;
+        ref_ptr<AlphaFunc>  _alphafunc;
+
+        ImpostorSprite*     _first;
+        ImpostorSprite*     _last;
+        
+        typedef std::vector< ref_ptr<StateSet> > StateSetList;
+        StateSetList        _stateSetList;
+        unsigned int        _reuseStateSetIndex;
+
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec2d
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec2d (revision 3230)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec2d (revision 3230)
@@ -0,0 +1,177 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_VEC2D
+#define OSG_VEC2D 1
+
+#include <osg/Vec2f>
+
+namespace osg {
+
+/** General purpose double pair, uses include representation of
+    texture coordinates.
+    No support yet added for double * Vec2d - is it necessary?
+    Need to define a non-member non-friend operator*  etc.
+    BTW:	     Vec2d * double is okay
+*/
+
+class Vec2d
+{
+    public:
+
+        typedef double value_type;
+        value_type _v[2];
+
+        Vec2d() {_v[0]=0.0; _v[1]=0.0;}
+
+        Vec2d(value_type x,value_type y) { _v[0]=x; _v[1]=y; }
+
+        inline Vec2d(const Vec2f& vec) { _v[0]=vec._v[0]; _v[1]=vec._v[1]; }
+        
+        inline operator Vec2f() const { return Vec2f(static_cast<float>(_v[0]),static_cast<float>(_v[1]));}
+
+
+        inline bool operator == (const Vec2d& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1]; }
+
+        inline bool operator != (const Vec2d& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1]; }
+
+	inline bool operator <  (const Vec2d& v) const
+        {
+            if (_v[0]<v._v[0]) return true;
+            else if (_v[0]>v._v[0]) return false;
+            else return (_v[1]<v._v[1]);
+        }
+
+        inline value_type* ptr() { return _v; }
+        inline const value_type* ptr() const { return _v; }
+
+        inline void set( value_type x, value_type y ) { _v[0]=x; _v[1]=y; }
+
+        inline value_type& operator [] (int i) { return _v[i]; }
+        inline value_type operator [] (int i) const { return _v[i]; }
+
+        inline value_type& x() { return _v[0]; }
+        inline value_type& y() { return _v[1]; }
+
+        inline value_type x() const { return _v[0]; }
+        inline value_type y() const { return _v[1]; }
+
+        inline bool valid() const { return !isNaN(); }
+        inline bool isNaN() const { return osg::isNaN(_v[0]) || osg::isNaN(_v[1]); }
+
+        /// dot product
+        inline value_type operator * (const Vec2d& rhs) const
+        {
+            return _v[0]*rhs._v[0]+_v[1]*rhs._v[1];
+        }
+
+        /// multiply by scalar
+        inline const Vec2d operator * (value_type rhs) const
+        {
+            return Vec2d(_v[0]*rhs, _v[1]*rhs);
+        }
+
+        /// unary multiply by scalar
+        inline Vec2d& operator *= (value_type rhs)
+        {
+            _v[0]*=rhs;
+	    _v[1]*=rhs;
+	    return *this;
+        }
+
+        /// divide by scalar
+        inline const Vec2d operator / (value_type rhs) const
+        {
+            return Vec2d(_v[0]/rhs, _v[1]/rhs);
+        }
+
+        /// unary divide by scalar
+        inline Vec2d& operator /= (value_type rhs)
+        {
+            _v[0]/=rhs;
+	    _v[1]/=rhs;
+	    return *this;
+        }
+
+        /// binary vector add
+        inline const Vec2d operator + (const Vec2d& rhs) const
+        {
+            return Vec2d(_v[0]+rhs._v[0], _v[1]+rhs._v[1]);
+        }
+
+        /** unary vector add.  Slightly more efficient because no temporary
+            intermediate object.*/
+        inline Vec2d& operator += (const Vec2d& rhs)
+        {
+            _v[0] += rhs._v[0];
+            _v[1] += rhs._v[1];
+	    return *this;
+        }
+
+        /// binary vector subtract
+        inline const Vec2d operator - (const Vec2d& rhs) const
+        {
+            return Vec2d(_v[0]-rhs._v[0], _v[1]-rhs._v[1]);
+        }
+
+        /// unary vector subtract
+        inline Vec2d& operator -= (const Vec2d& rhs)
+        {
+            _v[0]-=rhs._v[0];
+            _v[1]-=rhs._v[1];
+	    return *this;
+	}
+
+        /// negation operator.  Returns the negative of the Vec2d
+        inline const Vec2d operator - () const
+        {
+	    return Vec2d (-_v[0], -_v[1]);
+	}
+
+        /// Length of the vector = sqrt( vec . vec )
+	inline value_type length() const
+	{
+	    return sqrt( _v[0]*_v[0] + _v[1]*_v[1] );
+	}
+
+        /// Length squared of the vector = vec . vec
+        inline value_type length2( void ) const
+        {
+            return _v[0]*_v[0] + _v[1]*_v[1];
+        }
+
+        /** normalize the vector so that it has length unity
+            returns the previous length of the vector*/
+	inline value_type normalize()
+	{
+	    value_type norm = Vec2d::length();
+            if (norm>0.0)
+            {
+                value_type inv = 1.0/norm;
+	        _v[0] *= inv;
+	        _v[1] *= inv;
+            }
+	    return( norm );
+	}
+
+	friend inline std::ostream& operator << (std::ostream& output, const Vec2d& vec)
+        {
+	    output << vec._v[0] << " "
+                   << vec._v[1];
+	    return output; 	// to enable cascading
+	}
+
+};	// end of class Vec2d
+
+}	// end of namespace osg
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/AutoTransform
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/AutoTransform (revision 3295)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/AutoTransform (revision 3295)
@@ -0,0 +1,137 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_AUTOTRANSFORM
+#define OSG_AUTOTRANSFORM 1
+
+#include <osg/Group>
+#include <osg/Transform>
+#include <osg/Quat>
+
+namespace osg {
+
+/** AutoTransform - is Transform the automatically scales or rotates 
+  * to keep its children relative to screen space coordinates.
+*/
+class SG_EXPORT AutoTransform : public Transform
+{
+    public :
+        AutoTransform();
+
+        AutoTransform(const AutoTransform& pat,const CopyOp& copyop=CopyOp::SHALLOW_COPY);            
+
+        virtual osg::Object* cloneType() const { return new AutoTransform (); }
+        virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new AutoTransform (*this,copyop); }
+        virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const AutoTransform *>(obj)!=NULL; }
+        virtual const char* className() const { return "AutoTransform"; }
+        virtual const char* libraryName() const { return "osg"; }
+
+        virtual void accept(NodeVisitor& nv);
+
+        virtual AutoTransform* asAutoTransform() { return this; }
+        virtual const AutoTransform* asAutoTransform() const { return this; }
+
+        inline void setPosition(const Vec3& pos) { _position = pos; _matrixDirty=true; dirtyBound(); }
+        inline const Vec3& getPosition() const { return _position; }
+
+
+        inline void setRotation(const Quat& quat) { _rotation = quat; _matrixDirty=true; dirtyBound(); }
+        inline const Quat& getRotation() const { return _rotation; }
+        
+        inline void setScale(float scale) { _scale.set(scale,scale,scale); _matrixDirty=true; dirtyBound(); }
+        inline void setScale(const Vec3& scale) { _scale = scale; dirtyBound(); }
+        inline const Vec3& getScale() const { return _scale; }
+        
+        inline void setPivotPoint(const Vec3& pivot) { _pivotPoint = pivot; _matrixDirty=true; dirtyBound(); }
+        inline const Vec3& getPivotPoint() const { return _pivotPoint; }
+        
+
+        void setAutoUpdateEyeMovementTolerance(float tolerance) { _autoUpdateEyeMovementTolerance = tolerance; }
+        float getAutoUpdateEyeMovementTolerance() const { return _autoUpdateEyeMovementTolerance; }
+
+
+
+
+        enum AutoRotateMode
+        {
+            NO_ROTATION,
+            ROTATE_TO_SCREEN,
+            ROTATE_TO_CAMERA
+        };
+        
+        void setAutoRotateMode(AutoRotateMode mode) { _autoRotateMode = mode; }
+
+        AutoRotateMode getAutoRotateMode() const { return _autoRotateMode; }
+
+#ifdef USE_DEPRECATED_API
+        void setAutoRotateToScreen(bool autoRotateToScreen)
+        {
+            setAutoRotateMode(autoRotateToScreen?ROTATE_TO_SCREEN:NO_ROTATION);
+	}
+
+        bool getAutoRotateToCamera() const { return _autoRotateMode==ROTATE_TO_SCREEN; }
+
+        void setAutoRotateToCamera(bool autoRotateToCamera)
+	{
+            setAutoRotateMode(autoRotateToScreen?ROTATE_TO_CAMERA:NO_ROTATION);
+	}
+        
+        bool getAutoRotateToCamera() const { return _autoRotateMode==ROTATE_TO_SCREEN; }
+#endif
+
+
+
+        void setAutoScaleToScreen(bool autoScaleToScreen) { _autoScaleToScreen = autoScaleToScreen; _matrixDirty=true; }
+
+        bool getAutoScaleToScreen() const { return _autoScaleToScreen; }
+
+
+        virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor* nv) const;
+
+        virtual bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor* nv) const;
+
+
+
+    protected :
+            
+        virtual ~AutoTransform() {}
+        
+
+        Vec3                _position;
+        Vec3                _pivotPoint;
+        float               _autoUpdateEyeMovementTolerance;
+
+        AutoRotateMode      _autoRotateMode;
+
+        bool                _autoScaleToScreen;
+        
+        mutable Quat        _rotation;
+        mutable Vec3        _scale;
+        mutable bool        _firstTimeToInitEyePoint;
+        mutable osg::Vec3   _previousEyePoint;
+        mutable osg::Vec3   _previousLocalUp;
+        mutable int         _previousWidth;
+        mutable int         _previousHeight;        
+        mutable osg::Matrix _previousProjection;
+        mutable osg::Vec3 _previousPosition;
+
+
+        void computeMatrix() const;
+
+        mutable bool        _matrixDirty;
+        mutable osg::Matrix _cachedMatrix;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/NodeVisitor
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/NodeVisitor (revision 3205)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/NodeVisitor (revision 3205)
@@ -0,0 +1,297 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_NODEVISITOR
+#define OSG_NODEVISITOR 1
+
+#include <osg/Node>
+#include <osg/Matrix>
+#include <osg/FrameStamp>
+
+namespace osg {
+
+class Geode;
+class Billboard;
+class LightSource;
+class ClipNode;
+class TexGenNode;
+class Group;
+class Transform;
+class MatrixTransform;
+class PositionAttitudeTransform;
+class Projection;
+class LOD;
+class PagedLOD;
+class Switch;
+class Impostor;
+class ClearNode;
+class OccluderNode;
+class Sequence;
+class CoordinateSystemNode;
+
+/** Visitor for type safe operations on osg::Node's.
+    Based on GOF's Visitor pattern. The NodeVisitor 
+    is useful for developing type safe operations to nodes
+    in the scene graph (as per Visitor pattern), and adds to this
+    support for optional scene graph traversal to allow
+    operations to be applied to whole scenes at once. The Visitor
+    pattern uses a technique of double dispatch as a mechanism to
+    called the appropriate apply(..) method of the NodeVisitor.  To
+    use this feature one must use the Node::accept(NodeVisitor) which
+    is extended in each Node subclass, rather than the NodeVisitor
+    apply directly.  So use root->accept(myVisitor); instead of
+    myVisitor.apply(*root).  The later method will bypass the double
+    dispatch and the appropriate NodeVisitor::apply(..) method will
+    not be called. */ 
+class SG_EXPORT NodeVisitor : public virtual Referenced
+{
+    public:
+
+        enum TraversalMode
+        {
+            TRAVERSE_NONE,
+            TRAVERSE_PARENTS,
+            TRAVERSE_ALL_CHILDREN,
+            TRAVERSE_ACTIVE_CHILDREN
+        };
+        
+        enum VisitorType
+        {
+            NODE_VISITOR = 0,
+            UPDATE_VISITOR,
+            COLLECT_OCCLUDER_VISITOR,
+            CULL_VISITOR
+        };
+
+        NodeVisitor(TraversalMode tm=TRAVERSE_NONE);
+        
+        NodeVisitor(VisitorType type,TraversalMode tm=TRAVERSE_NONE);
+        
+        virtual ~NodeVisitor();
+
+        /** Method to call to reset visitor. Useful for your visitor accumulates
+            state during a traversal, and you plan to reuse the visitor. 
+            To flush that state for the next traversal than call reset() prior
+            to each traversal.*/
+        virtual void reset() {}
+
+
+        /** Set the VisitorType, used to distingush different visitors during
+          * traversal of the scene, typically used in the Node::traverse() method
+          * to select which behaviour to use for different types of traversal/visitors.*/
+        inline void setVisitorType(VisitorType type) { _visitorType = type; }
+        
+        /** Get the VisitorType.*/
+        inline VisitorType getVisitorType() const { return _visitorType; }
+
+        /** Set the traversal number. Typically used to denote the frame count.*/
+        inline void setTraversalNumber(int fn) { _traversalNumber = fn; }
+        
+        /** Get the traversal number. Typically used to denote the frame count.*/
+        inline int getTraversalNumber() const { return _traversalNumber; }
+
+        /** Set the FrameStamp that this traversal is assoicated with.*/
+        inline void setFrameStamp(FrameStamp* fs) { _frameStamp = fs; }
+        
+        /** Get the FrameStamp that this traversal is assoicated with.*/
+        inline const FrameStamp* getFrameStamp() const { return _frameStamp.get(); }
+
+
+        /** Set the TraversalMask of this NodeVisitor.
+          * The TraversalMask is used by the NodeVisitor::validNodeMask() method
+          * to determine whether to operate on a node and its subgraph.
+          * validNodeMask() is called automaticaly in the Node::accept() method before
+          * any call to NodeVisitor::apply(), apply() is only ever called if validNodeMask
+          * returns true. Note, if NodeVisitor::_traversalMask is 0 then all operations
+          * will be swithced off for all nodes.  Whereas setting both _traversalMask and
+          * _nodeMaskOverride to 0xffffffff will allow a visitor to work on all nodes
+          * regardless of their own Node::_nodeMask state.*/
+        inline void setTraversalMask(Node::NodeMask mask) { _traversalMask = mask; }
+
+        /** Get the TraversalMask.*/
+        inline Node::NodeMask getTraversalMask() const { return _traversalMask; }
+
+        /** Set the NodeMaskOverride mask.
+          * Used in validNodeMask() to determine whether to operate on a node or its 
+          * subgraph, by OR'ing NodeVisitor::_nodeMaskOverride with the Node's own Node::_nodeMask.
+          * Typically used to force on nodes which may have
+          * been switched off by their own Node::_nodeMask.*/
+        inline void setNodeMaskOverride(Node::NodeMask mask) { _nodeMaskOverride = mask; }
+
+        /** Get the NodeMaskOverride mask.*/
+        inline Node::NodeMask getNodeMaskOverride() const { return _nodeMaskOverride; }
+        
+        /** Method to called by Node and its subclass' Node::accept() method, if the result is true
+          * to be used to cull operations of nodes and their subgraphs.
+          * Return true if the result of a bit wise and of the NodeVisitor::_traversalMask
+          * with the bit or between NodeVistor::_nodeMaskOverride and the Node::_nodeMask.
+          * default values for _traversalMask is 0xffffffff, _nodeMaskOverride is 0x0,
+          * and osg::Node::_nodeMask is 0xffffffff. */
+        inline bool validNodeMask(const osg::Node& node) const
+        {
+            return (getTraversalMask() & (getNodeMaskOverride() | node.getNodeMask()))!=0;
+        }
+
+        /** Set the traversal mode for Node::traverse() to use when 
+            deciding which children of a node to traverse. If a
+            NodeVisitor has been attached via setTraverseVisitor()
+            and the new mode is not TRAVERSE_VISITOR then the attached
+            visitor is detached. Default mode is TRAVERSE_NONE.*/
+        inline void setTraversalMode(TraversalMode mode) { _traversalMode = mode; }
+        
+        /** Get the traversal mode.*/
+        inline TraversalMode getTraversalMode() const { return _traversalMode; }
+
+        /**
+         * Set user data, data must be subclased from Referenced to allow
+         * automatic memory handling.  If you own data isn't directly 
+         * subclassed from Referenced then create and adapter object
+         * which points to your own objects and handles the memory addressing.
+         */
+        inline void setUserData(Referenced* obj) { _userData = obj; }
+        
+        /** Get user data.*/
+        inline Referenced* getUserData() { return _userData.get(); }
+        
+        /** Get const user data.*/
+        inline const Referenced* getUserData() const { return _userData.get(); }
+
+
+        /** Method for handling traversal of a nodes.
+            If you intend to use the visitor for actively traversing 
+            the scene graph then make sure the accept() methods call
+            this method unless they handle traversal directly.*/
+        inline void traverse(Node& node)
+        {
+            if (_traversalMode==TRAVERSE_PARENTS) node.ascend(*this);
+            else if (_traversalMode!=TRAVERSE_NONE) node.traverse(*this);
+        }
+        
+        /** Method called by osg::Node::accept() method before
+          * a call the NodeVisitor::apply(..).  The back of the list will,
+          * therefore, be the current node being visited inside the apply(..),
+          * and the rest of the list will be the parental sequence of nodes 
+          * from the top most node applied down the graph to the current node.
+          * Note, the user does not typically call pushNodeOnPath() as it
+          * will be called automatically by the Node::accept() method.*/
+        inline void pushOntoNodePath(Node* node) { if (_traversalMode!=TRAVERSE_PARENTS) _nodePath.push_back(node); else _nodePath.insert(_nodePath.begin(),node); }
+        
+        /** Method callby osg::Node::accept() method after
+          * a call the NodeVisitor::apply(..).
+          * Note, the user does not typically call pushNodeOnPath() as it
+          * will be called automatically by the Node::accept() method.*/
+        inline void popFromNodePath()            { if (_traversalMode!=TRAVERSE_PARENTS) _nodePath.pop_back(); else _nodePath.erase(_nodePath.begin()); }
+        
+        /** Get the non const NodePath from the top most node applied down
+          * to the current Node being visited.*/
+        NodePath& getNodePath() { return _nodePath; }
+
+        /** Get the const NodePath from the top most node applied down
+          * to the current Node being visited.*/
+        const NodePath& getNodePath() const { return _nodePath; }
+        
+        /** Get the eye point in local coordinates.
+          * Note, not all NodeVisitor implement this method, it is mainly cull visitors which will implement.*/
+        virtual osg::Vec3 getEyePoint() const { return Vec3(0.0f,0.0f,0.0f); }
+
+        /** Get the distance from a point to the eye point, distance value in local coordinate system.
+          * Note, not all NodeVisitor implement this method, it is mainly cull visitors which will implement.
+          * If the getDistianceFromEyePoint(pos) is not implmented than a default value of 0.0 is returned.*/
+        virtual float getDistanceToEyePoint(const Vec3& /*pos*/, bool /*useLODScale*/) const { return 0.0f; }
+
+        /** Get the distance of a point from the eye point, distance value in the eye coordinate system.
+          * Note, not all NodeVisitor implement this method, it is mainly cull visitors which will implement.
+          * If the getDistianceFromEyePoint(pos) is not implmented than a default value of 0.0 is returned.*/
+        virtual float getDistanceFromEyePoint(const Vec3& /*pos*/, bool /*useLODScale*/) const { return 0.0f; }
+
+        virtual void apply(Node& node)                      { traverse(node);}
+        
+        virtual void apply(Geode& node)                     { apply((Node&)node); }
+        virtual void apply(Billboard& node)                 { apply((Geode&)node); }
+        
+        virtual void apply(Group& node)                     { apply((Node&)node); }
+
+        virtual void apply(Projection& node)                { apply((Group&)node); }
+
+        virtual void apply(CoordinateSystemNode& node)      { apply((Group&)node); }
+
+        virtual void apply(ClipNode& node)                  { apply((Group&)node); }
+        virtual void apply(TexGenNode& node)                { apply((Group&)node); }
+        virtual void apply(LightSource& node)               { apply((Group&)node); }
+
+        virtual void apply(Transform& node)                 { apply((Group&)node); }
+        virtual void apply(MatrixTransform& node)           { apply((Transform&)node); }
+        virtual void apply(PositionAttitudeTransform& node) { apply((Transform&)node); }
+
+        virtual void apply(Switch& node)                    { apply((Group&)node); }
+        virtual void apply(Sequence& node)                  { apply((Group&)node); }
+        virtual void apply(LOD& node)                       { apply((Group&)node); }
+        virtual void apply(PagedLOD& node)                  { apply((LOD&)node); }
+        virtual void apply(Impostor& node)                  { apply((LOD&)node); }
+        virtual void apply(ClearNode& node)                 { apply((Group&)node); }
+        virtual void apply(OccluderNode& node)              { apply((Group&)node); }
+
+
+        /** callback for managing database paging, such as generated by PagedLOD nodes.*/
+        class DatabaseRequestHandler : public osg::Referenced
+        {
+        public:            
+            virtual void requestNodeFile(const std::string& fileName,osg::Group* group, float priority, const FrameStamp* framestamp) = 0;
+            
+        protected:
+            virtual ~DatabaseRequestHandler() {}
+        };
+        
+        /** Set the handler for database requests.*/
+        void setDatabaseRequestHandler(DatabaseRequestHandler* handler) { _databaseRequestHandler = handler; }
+        
+        /** Get the handler for database requests.*/
+        DatabaseRequestHandler* getDatabaseRequestHandler() { return _databaseRequestHandler.get(); }
+
+        /** Get the const handler for database requests.*/
+        const DatabaseRequestHandler* getDatabaseRequestHandler() const { return _databaseRequestHandler.get(); }
+
+
+
+    protected:
+
+        VisitorType                     _visitorType;
+        int                             _traversalNumber;
+        
+        ref_ptr<FrameStamp>             _frameStamp;
+        
+        TraversalMode                   _traversalMode;
+        Node::NodeMask                  _traversalMask;
+        Node::NodeMask                  _nodeMaskOverride;
+        
+        NodePath                        _nodePath;
+
+        ref_ptr<Referenced>             _userData;
+
+        ref_ptr<DatabaseRequestHandler> _databaseRequestHandler;
+
+};
+
+
+/** Convenience functor for assisting visiting of arrays of osg::Node's.*/ 
+struct NodeAcceptOp
+{
+    NodeVisitor& _nv;
+    NodeAcceptOp(NodeVisitor& nv):_nv(nv) {}
+    void operator () (Node* node) { node->accept(_nv); }
+    void operator () (ref_ptr<Node> node) { node->accept(_nv); }
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec2f
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec2f (revision 3230)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec2f (revision 3230)
@@ -0,0 +1,174 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_VEC2F
+#define OSG_VEC2F 1
+
+#include <ostream>
+
+#include <osg/Math>
+
+namespace osg {
+
+/** General purpose float pair, uses include representation of
+    texture coordinates.
+    No support yet added for float * Vec2f - is it necessary?
+    Need to define a non-member non-friend operator*  etc.
+    BTW:	     Vec2f * float is okay
+*/
+
+class Vec2f
+{
+    public:
+
+        typedef float value_type;
+        value_type _v[2];
+
+        Vec2f() {_v[0]=0.0; _v[1]=0.0;}
+        Vec2f(value_type x,value_type y) { _v[0]=x; _v[1]=y; }
+
+
+        inline bool operator == (const Vec2f& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1]; }
+
+        inline bool operator != (const Vec2f& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1]; }
+
+	inline bool operator <  (const Vec2f& v) const
+        {
+            if (_v[0]<v._v[0]) return true;
+            else if (_v[0]>v._v[0]) return false;
+            else return (_v[1]<v._v[1]);
+        }
+
+        inline value_type * ptr() { return _v; }
+        inline const value_type * ptr() const { return _v; }
+
+        inline void set( value_type x, value_type y ) { _v[0]=x; _v[1]=y; }
+
+        inline value_type & operator [] (int i) { return _v[i]; }
+        inline value_type operator [] (int i) const { return _v[i]; }
+
+        inline value_type & x() { return _v[0]; }
+        inline value_type & y() { return _v[1]; }
+
+        inline value_type x() const { return _v[0]; }
+        inline value_type y() const { return _v[1]; }
+
+        inline bool valid() const { return !isNaN(); }
+        inline bool isNaN() const { return osg::isNaN(_v[0]) || osg::isNaN(_v[1]); }
+
+        /// dot product
+        inline value_type operator * (const Vec2f& rhs) const
+        {
+            return _v[0]*rhs._v[0]+_v[1]*rhs._v[1];
+        }
+
+        /// multiply by scalar
+        inline const Vec2f operator * (value_type rhs) const
+        {
+            return Vec2f(_v[0]*rhs, _v[1]*rhs);
+        }
+
+        /// unary multiply by scalar
+        inline Vec2f& operator *= (value_type rhs)
+        {
+            _v[0]*=rhs;
+	    _v[1]*=rhs;
+	    return *this;
+        }
+
+        /// divide by scalar
+        inline const Vec2f operator / (value_type rhs) const
+        {
+            return Vec2f(_v[0]/rhs, _v[1]/rhs);
+        }
+
+        /// unary divide by scalar
+        inline Vec2f& operator /= (value_type rhs)
+        {
+            _v[0]/=rhs;
+	    _v[1]/=rhs;
+	    return *this;
+        }
+
+        /// binary vector add
+        inline const Vec2f operator + (const Vec2f& rhs) const
+        {
+            return Vec2f(_v[0]+rhs._v[0], _v[1]+rhs._v[1]);
+        }
+
+        /** unary vector add.  Slightly more efficient because no temporary
+            intermediate object.*/
+        inline Vec2f& operator += (const Vec2f& rhs)
+        {
+            _v[0] += rhs._v[0];
+            _v[1] += rhs._v[1];
+	    return *this;
+        }
+
+        /// binary vector subtract
+        inline const Vec2f operator - (const Vec2f& rhs) const
+        {
+            return Vec2f(_v[0]-rhs._v[0], _v[1]-rhs._v[1]);
+        }
+
+        /// unary vector subtract
+        inline Vec2f& operator -= (const Vec2f& rhs)
+        {
+            _v[0]-=rhs._v[0];
+            _v[1]-=rhs._v[1];
+	    return *this;
+	}
+
+        /// negation operator.  Returns the negative of the Vec2f
+        inline const Vec2f operator - () const
+        {
+	    return Vec2f (-_v[0], -_v[1]);
+	}
+
+        /// Length of the vector = sqrt( vec . vec )
+	inline value_type length() const
+	{
+	    return sqrtf( _v[0]*_v[0] + _v[1]*_v[1] );
+	}
+
+        /// Length squared of the vector = vec . vec
+        inline value_type length2( void ) const
+        {
+            return _v[0]*_v[0] + _v[1]*_v[1];
+        }
+
+        /** normalize the vector so that it has length unity
+            returns the previous length of the vector*/
+	inline value_type normalize()
+	{
+	    value_type norm = Vec2f::length();
+            if (norm>0.0)
+            {
+                value_type inv = 1.0f/norm;
+	        _v[0] *= inv;
+	        _v[1] *= inv;
+            }
+	    return( norm );
+	}
+
+	friend inline std::ostream& operator << (std::ostream& output, const Vec2f& vec)
+        {
+	    output << vec._v[0] << " "
+                   << vec._v[1];
+	    return output; 	// to enable cascading
+	}
+
+};	// end of class Vec2f
+
+}	// end of namespace osg
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Object
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Object (revision 1529)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Object (revision 1529)
@@ -0,0 +1,128 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_OBJECT
+#define OSG_OBJECT 1
+
+#include <osg/Referenced>
+#include <osg/CopyOp>
+#include <osg/ref_ptr>
+
+namespace osg {
+
+/** META_Object macro define the standard clone, isSameKindAs and className methods.
+  * Use when subclassing from Object to make it more convinient to define 
+  * the standard pure virtual clone, isSameKindAs and className methods 
+  * which are required for all Object subclasses.*/
+#define META_Object(library,name) \
+        virtual osg::Object* cloneType() const { return new name (); } \
+        virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new name (*this,copyop); } \
+        virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const name *>(obj)!=NULL; } \
+        virtual const char* libraryName() const { return #library; }\
+        virtual const char* className() const { return #name; }
+
+
+/** Base class/standard interface for objects which require IO support, 
+    cloning and reference counting.
+    Based on GOF Composite, Prototype and Template Method patterns.
+*/
+class SG_EXPORT Object : public Referenced
+{
+    public:
+
+
+        /** Construct an object. Note Object is a pure virtual base class
+            and therefore cannot be constructed on its own, only derived
+            classes which override the clone and className methods are
+            concrete classes and can be constructed.*/
+        inline Object():Referenced(),_dataVariance(DYNAMIC) {}
+
+        /** Copy constructor, optional CopyOp object can be used to control
+          * shallow vs deep copying of dynamic data.*/
+        Object(const Object&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+        /** Clone the type of an object, with Object* return type.
+            Must be defined by derived classes.*/
+        virtual Object* cloneType() const = 0;
+
+        /** Clone the an object, with Object* return type.
+            Must be defined by derived classes.*/
+        virtual Object* clone(const CopyOp&) const = 0;
+
+        virtual bool isSameKindAs(const Object*) const { return true; }
+
+        /** return the name of the object's library. Must be defined
+            by derived classes. The OpenSceneGraph convention the is
+            that the namspace of a library is the same as the library name.*/
+        virtual const char* libraryName() const = 0;
+
+        /** return the name of the object's class type. Must be defined
+            by derived classes.*/
+        virtual const char* className() const = 0;
+        
+
+        enum DataVariance
+        {
+            DYNAMIC,
+            STATIC
+        };
+        
+        /** Set the data variance of this object.
+           * Can be set to either STATIC for values that do not change over the lifetime of the object,
+           * or DYNAMIC for values that vary over the lifetime of the object. The DataVariance value
+           * can be used be routines such as optimzation codes that wish to share static data.*/
+        inline void setDataVariance(DataVariance dv) { _dataVariance = dv; }
+
+        /** Get the data variance of this object.*/
+        inline DataVariance getDataVariance() const { return _dataVariance; }
+
+
+        /**
+         * Set user data, data must be subclased from Referenced to allow
+         * automatic memory handling.  If you own data isn't directly 
+         * subclassed from Referenced then create and adapter object
+         * which points to your own objects and handles the memory addressing.
+         */
+        inline void setUserData(Referenced* obj) { _userData = obj; }
+        
+        /** Get user data.*/
+        inline Referenced* getUserData() { return _userData.get(); }
+        
+        /** Get const user data.*/
+        inline const Referenced* getUserData() const { return _userData.get(); }
+
+
+    protected:
+
+        /** Object destructor. Note, is protected so that Objects cannot
+            be deleted other than by being dereferenced and the reference
+            count being zero (see osg::Referenced), preventing the deletion
+            of nodes which are still in use. This also means that
+            Node's cannot be created on stack i.e Node node will not compile,
+            forcing all nodes to be created on the heap i.e Node* node
+            = new Node().*/
+        virtual ~Object() {}
+        
+        DataVariance _dataVariance;
+
+        ref_ptr<Referenced> _userData;
+
+    private:
+
+        /** disallow any copy operator.*/
+        Object& operator = (const Object&) { return *this; }
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TriangleFunctor
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TriangleFunctor (revision 3208)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TriangleFunctor (revision 3208)
@@ -0,0 +1,366 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_TRIANGLEFUNCTOR
+#define OSG_TRIANGLEFUNCTOR 1
+
+#include <osg/Drawable>
+#include <osg/Notify>
+
+namespace osg {
+
+template<class T>
+class TriangleFunctor : public Drawable::PrimitiveFunctor, public T
+{
+public:
+
+    TriangleFunctor()
+    {
+        _vertexArraySize=0;
+        _vertexArrayPtr=0;
+        _modeCache=0;
+        _treatVertexDataAsTemporary=false;
+    }
+    
+    virtual ~TriangleFunctor() {}
+    
+    void setTreatVertexDataAsTemporary(bool treatVertexDataAsTemporary) { _treatVertexDataAsTemporary=treatVertexDataAsTemporary; }
+    bool getTreatVertexDataAsTemporary() const { return _treatVertexDataAsTemporary; }
+
+    virtual void setVertexArray(unsigned int,const Vec2*) 
+    {
+        notify(WARN)<<"Triangle Functor does not support Vec2* vertex arrays"<<std::endl;
+    }
+
+    virtual void setVertexArray(unsigned int count,const Vec3* vertices)
+    {
+        _vertexArraySize = count;
+        _vertexArrayPtr = vertices;
+    }
+
+    virtual void setVertexArray(unsigned int,const Vec4* ) 
+    {
+        notify(WARN)<<"Triangle Functor does not support Vec4* vertex arrays"<<std::endl;
+    }
+
+
+    virtual void drawArrays(GLenum mode,GLint first,GLsizei count)
+    {
+        if (_vertexArrayPtr==0 && count==0) return;
+    
+        switch(mode)
+        {
+            case(GL_TRIANGLES):
+            {
+                const Vec3* vlast = &_vertexArrayPtr[first+count];
+                for(const Vec3* vptr=&_vertexArrayPtr[first];vptr<vlast;vptr+=3)
+                    this->operator()(*(vptr),*(vptr+1),*(vptr+2),_treatVertexDataAsTemporary);
+                break;
+            }
+            case(GL_TRIANGLE_STRIP):
+            {
+                const Vec3* vptr = &_vertexArrayPtr[first];
+                for(GLsizei i=2;i<count;++i,++vptr)
+                {
+		    if ((i%2)) this->operator()(*(vptr),*(vptr+2),*(vptr+1),_treatVertexDataAsTemporary);
+		    else       this->operator()(*(vptr),*(vptr+1),*(vptr+2),_treatVertexDataAsTemporary);
+                }
+                break;
+            }
+            case(GL_QUADS):
+            {
+                const Vec3* vptr = &_vertexArrayPtr[first];
+                for(GLsizei i=3;i<count;i+=4,vptr+=4)
+                {
+                    this->operator()(*(vptr),*(vptr+1),*(vptr+2),_treatVertexDataAsTemporary);
+                    this->operator()(*(vptr),*(vptr+2),*(vptr+3),_treatVertexDataAsTemporary);
+                }
+                break;
+            }
+            case(GL_QUAD_STRIP):
+            {
+                const Vec3* vptr = &_vertexArrayPtr[first];
+                for(GLsizei i=3;i<count;i+=2,vptr+=2)
+                {
+                    this->operator()(*(vptr),*(vptr+1),*(vptr+2),_treatVertexDataAsTemporary);
+                    this->operator()(*(vptr+1),*(vptr+3),*(vptr+2),_treatVertexDataAsTemporary);
+                }
+                break;
+            }
+            case(GL_POLYGON): // treat polygons as GL_TRIANGLE_FAN
+            case(GL_TRIANGLE_FAN):
+            {
+                const Vec3* vfirst = &_vertexArrayPtr[first];
+                const Vec3* vptr = vfirst+1;
+                for(GLsizei i=2;i<count;++i,++vptr)
+                {
+                    this->operator()(*(vfirst),*(vptr),*(vptr+1),_treatVertexDataAsTemporary);
+                }
+                break;
+            }
+            case(GL_POINTS):
+            case(GL_LINES):
+            case(GL_LINE_STRIP):
+            case(GL_LINE_LOOP):
+            default:
+                // can't be converted into to triangles.
+                break;
+        }
+    }
+    
+    virtual void drawElements(GLenum mode,GLsizei count,const GLubyte* indices)
+    {
+        if (indices==0 || count==0) return;
+    
+        typedef const GLubyte* IndexPointer;
+    
+        switch(mode)
+        {
+            case(GL_TRIANGLES):
+            {
+                IndexPointer ilast = &indices[count];
+                for(IndexPointer  iptr=indices;iptr<ilast;iptr+=3)
+                    this->operator()(_vertexArrayPtr[*iptr],_vertexArrayPtr[*(iptr+1)],_vertexArrayPtr[*(iptr+2)],_treatVertexDataAsTemporary);
+                break;
+            }
+            case(GL_TRIANGLE_STRIP):
+            {
+                IndexPointer iptr = indices;
+                for(GLsizei i=2;i<count;++i,++iptr)
+                {
+		    if ((i%2)) this->operator()(_vertexArrayPtr[*(iptr)],_vertexArrayPtr[*(iptr+2)],_vertexArrayPtr[*(iptr+1)],_treatVertexDataAsTemporary);
+		    else       this->operator()(_vertexArrayPtr[*(iptr)],_vertexArrayPtr[*(iptr+1)],_vertexArrayPtr[*(iptr+2)],_treatVertexDataAsTemporary);
+                }
+                break;
+            }
+            case(GL_QUADS):
+            {
+                IndexPointer iptr = indices;
+                for(GLsizei i=3;i<count;i+=4,iptr+=4)
+                {
+                    this->operator()(_vertexArrayPtr[*(iptr)],_vertexArrayPtr[*(iptr+1)],_vertexArrayPtr[*(iptr+2)],_treatVertexDataAsTemporary);
+                    this->operator()(_vertexArrayPtr[*(iptr)],_vertexArrayPtr[*(iptr+2)],_vertexArrayPtr[*(iptr+3)],_treatVertexDataAsTemporary);
+                }
+                break;
+            }
+            case(GL_QUAD_STRIP):
+            {
+                IndexPointer iptr = indices;
+                for(GLsizei i=3;i<count;i+=2,iptr+=2)
+                {
+                    this->operator()(_vertexArrayPtr[*(iptr)],_vertexArrayPtr[*(iptr+1)],_vertexArrayPtr[*(iptr+2)],_treatVertexDataAsTemporary);
+                    this->operator()(_vertexArrayPtr[*(iptr+1)],_vertexArrayPtr[*(iptr+3)],_vertexArrayPtr[*(iptr+2)],_treatVertexDataAsTemporary);
+                }
+                break;
+            }
+            case(GL_POLYGON): // treat polygons as GL_TRIANGLE_FAN
+            case(GL_TRIANGLE_FAN):
+            {
+                IndexPointer iptr = indices;
+                const Vec3& vfirst = _vertexArrayPtr[*iptr];
+                ++iptr;
+                for(GLsizei i=2;i<count;++i,++iptr)
+                {
+                    this->operator()(vfirst,_vertexArrayPtr[*(iptr)],_vertexArrayPtr[*(iptr+1)],_treatVertexDataAsTemporary);
+                }
+                break;
+            }
+            case(GL_POINTS):
+            case(GL_LINES):
+            case(GL_LINE_STRIP):
+            case(GL_LINE_LOOP):
+            default:
+                // can't be converted into to triangles.
+                break;
+        }
+    }    
+
+    virtual void drawElements(GLenum mode,GLsizei count,const GLushort* indices)
+    {
+        if (indices==0 || count==0) return;
+    
+        typedef const GLushort* IndexPointer;
+    
+        switch(mode)
+        {
+            case(GL_TRIANGLES):
+            {
+                IndexPointer ilast = &indices[count];
+                for(IndexPointer  iptr=indices;iptr<ilast;iptr+=3)
+                {
+                    this->operator()(_vertexArrayPtr[*iptr],_vertexArrayPtr[*(iptr+1)],_vertexArrayPtr[*(iptr+2)],_treatVertexDataAsTemporary);
+                }    
+                break;
+            }
+            case(GL_TRIANGLE_STRIP):
+            {
+                IndexPointer iptr = indices;
+                for(GLsizei i=2;i<count;++i,++iptr)
+                {
+		    if ((i%2)) this->operator()(_vertexArrayPtr[*(iptr)],_vertexArrayPtr[*(iptr+2)],_vertexArrayPtr[*(iptr+1)],_treatVertexDataAsTemporary);
+		    else       this->operator()(_vertexArrayPtr[*(iptr)],_vertexArrayPtr[*(iptr+1)],_vertexArrayPtr[*(iptr+2)],_treatVertexDataAsTemporary);
+                }
+                break;
+            }
+            case(GL_QUADS):
+            {
+                IndexPointer iptr = indices;
+                for(GLsizei i=3;i<count;i+=4,iptr+=4)
+                {
+                    this->operator()(_vertexArrayPtr[*(iptr)],_vertexArrayPtr[*(iptr+1)],_vertexArrayPtr[*(iptr+2)],_treatVertexDataAsTemporary);
+                    this->operator()(_vertexArrayPtr[*(iptr)],_vertexArrayPtr[*(iptr+2)],_vertexArrayPtr[*(iptr+3)],_treatVertexDataAsTemporary);
+                }
+                break;
+            }
+            case(GL_QUAD_STRIP):
+            {
+                IndexPointer iptr = indices;
+                for(GLsizei i=3;i<count;i+=2,iptr+=2)
+                {
+                    this->operator()(_vertexArrayPtr[*(iptr)],_vertexArrayPtr[*(iptr+1)],_vertexArrayPtr[*(iptr+2)],_treatVertexDataAsTemporary);
+                    this->operator()(_vertexArrayPtr[*(iptr+1)],_vertexArrayPtr[*(iptr+3)],_vertexArrayPtr[*(iptr+2)],_treatVertexDataAsTemporary);
+                }
+                break;
+            }
+            case(GL_POLYGON): // treat polygons as GL_TRIANGLE_FAN
+            case(GL_TRIANGLE_FAN):
+            {
+                IndexPointer iptr = indices;
+                const Vec3& vfirst = _vertexArrayPtr[*iptr];
+                ++iptr;
+                for(GLsizei i=2;i<count;++i,++iptr)
+                {
+                    this->operator()(vfirst,_vertexArrayPtr[*(iptr)],_vertexArrayPtr[*(iptr+1)],_treatVertexDataAsTemporary);
+                }
+                break;
+            }
+            case(GL_POINTS):
+            case(GL_LINES):
+            case(GL_LINE_STRIP):
+            case(GL_LINE_LOOP):
+            default:
+                // can't be converted into to triangles.
+                break;
+        }
+    }    
+
+    virtual void drawElements(GLenum mode,GLsizei count,const GLuint* indices)
+    {
+        if (indices==0 || count==0) return;
+    
+        typedef const GLuint* IndexPointer;
+    
+        switch(mode)
+        {
+            case(GL_TRIANGLES):
+            {
+                IndexPointer ilast = &indices[count];
+                for(IndexPointer  iptr=indices;iptr<ilast;iptr+=3)
+                    this->operator()(_vertexArrayPtr[*iptr],_vertexArrayPtr[*(iptr+1)],_vertexArrayPtr[*(iptr+2)],_treatVertexDataAsTemporary);
+                break;
+            }
+            case(GL_TRIANGLE_STRIP):
+            {
+                IndexPointer iptr = indices;
+                for(GLsizei i=2;i<count;++i,++iptr)
+                {
+		    if ((i%2)) this->operator()(_vertexArrayPtr[*(iptr)],_vertexArrayPtr[*(iptr+2)],_vertexArrayPtr[*(iptr+1)],_treatVertexDataAsTemporary);
+		    else       this->operator()(_vertexArrayPtr[*(iptr)],_vertexArrayPtr[*(iptr+1)],_vertexArrayPtr[*(iptr+2)],_treatVertexDataAsTemporary);
+                }
+                break;
+            }
+            case(GL_QUADS):
+            {
+                IndexPointer iptr = indices;
+                for(GLsizei i=3;i<count;i+=4,iptr+=4)
+                {
+                    this->operator()(_vertexArrayPtr[*(iptr)],_vertexArrayPtr[*(iptr+1)],_vertexArrayPtr[*(iptr+2)],_treatVertexDataAsTemporary);
+                    this->operator()(_vertexArrayPtr[*(iptr)],_vertexArrayPtr[*(iptr+2)],_vertexArrayPtr[*(iptr+3)],_treatVertexDataAsTemporary);
+                }
+                break;
+            }
+            case(GL_QUAD_STRIP):
+            {
+                IndexPointer iptr = indices;
+                for(GLsizei i=3;i<count;i+=2,iptr+=2)
+                {
+                    this->operator()(_vertexArrayPtr[*(iptr)],_vertexArrayPtr[*(iptr+1)],_vertexArrayPtr[*(iptr+2)],_treatVertexDataAsTemporary);
+                    this->operator()(_vertexArrayPtr[*(iptr+1)],_vertexArrayPtr[*(iptr+3)],_vertexArrayPtr[*(iptr+2)],_treatVertexDataAsTemporary);
+                }
+                break;
+            }
+            case(GL_POLYGON): // treat polygons as GL_TRIANGLE_FAN
+            case(GL_TRIANGLE_FAN):
+            {
+                IndexPointer iptr = indices;
+                const Vec3& vfirst = _vertexArrayPtr[*iptr];
+                ++iptr;
+                for(GLsizei i=2;i<count;++i,++iptr)
+                {
+                    this->operator()(vfirst,_vertexArrayPtr[*(iptr)],_vertexArrayPtr[*(iptr+1)],_treatVertexDataAsTemporary);
+                }
+                break;
+            }
+            case(GL_POINTS):
+            case(GL_LINES):
+            case(GL_LINE_STRIP):
+            case(GL_LINE_LOOP):
+            default:
+                // can't be converted into to triangles.
+                break;
+        }
+    }    
+
+
+
+    /** begin(..),vertex(..) & end() are convinience methods for adapting 
+     *  non vertex array primitives to vertex array based primitives.
+     * this is done to simplify the implementation of primtive functor
+     * subclasses - users only need override drawArray and drawElements.*/
+    virtual void begin(GLenum mode)
+    {
+        _modeCache = mode;
+        _vertexCache.clear();
+    }
+
+    virtual void vertex(const Vec2& vert) { _vertexCache.push_back(osg::Vec3(vert[0],vert[1],0.0f)); }
+    virtual void vertex(const Vec3& vert) { _vertexCache.push_back(vert); }
+    virtual void vertex(const Vec4& vert) { _vertexCache.push_back(osg::Vec3(vert[0],vert[1],vert[2])/vert[3]); }
+    virtual void vertex(float x,float y) { _vertexCache.push_back(osg::Vec3(x,y,0.0f)); }
+    virtual void vertex(float x,float y,float z) { _vertexCache.push_back(osg::Vec3(x,y,z)); }
+    virtual void vertex(float x,float y,float z,float w) { _vertexCache.push_back(osg::Vec3(x,y,z)/w); }
+    virtual void end()
+    {
+        if (!_vertexCache.empty())
+        {
+            setVertexArray(_vertexCache.size(),&_vertexCache.front());
+            _treatVertexDataAsTemporary = true;
+            drawArrays(_modeCache,0,_vertexCache.size());
+        }
+    }
+
+protected:
+
+
+    unsigned int        _vertexArraySize;
+    const Vec3*         _vertexArrayPtr;
+
+    GLenum              _modeCache;
+    std::vector<Vec3>   _vertexCache;
+    bool                _treatVertexDataAsTemporary;
+};
+
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Light
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Light (revision 2773)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Light (revision 2773)
@@ -0,0 +1,174 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_LIGHT
+#define OSG_LIGHT 1
+
+#include <osg/StateAttribute>
+#include <osg/Vec3>
+#include <osg/Vec4>
+
+namespace osg {
+
+/** Light state class which encapsulates OpenGL glLight() functionality.*/
+class SG_EXPORT Light : public StateAttribute
+{
+    public :
+
+        Light();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        Light(const Light& light,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            StateAttribute(light,copyop),
+            _lightnum(light._lightnum),
+            _ambient(light._ambient),
+            _diffuse(light._diffuse),
+            _specular(light._specular),
+            _position(light._position),
+            _direction(light._direction),
+            _constant_attenuation(light._constant_attenuation),
+            _linear_attenuation(light._linear_attenuation),
+            _quadratic_attenuation(light._quadratic_attenuation),
+            _spot_exponent(light._spot_exponent),
+            _spot_cutoff(light._spot_cutoff) {}
+        
+        META_StateAttribute(osg, Light, (Type)(LIGHT_0+_lightnum));
+
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const StateAttribute& sa) const
+        {
+            // check the types are equal and then create the rhs variable
+            // used by the COMPARE_StateAttribute_Paramter macro's below.
+            COMPARE_StateAttribute_Types(Light,sa)
+
+            // compare each paramter in turn against the rhs.
+            COMPARE_StateAttribute_Parameter(_lightnum)
+            COMPARE_StateAttribute_Parameter(_ambient)
+            COMPARE_StateAttribute_Parameter(_diffuse)
+            COMPARE_StateAttribute_Parameter(_specular)
+            COMPARE_StateAttribute_Parameter(_position)
+            COMPARE_StateAttribute_Parameter(_direction)
+            COMPARE_StateAttribute_Parameter(_constant_attenuation)
+            COMPARE_StateAttribute_Parameter(_linear_attenuation)
+            COMPARE_StateAttribute_Parameter(_quadratic_attenuation)
+            COMPARE_StateAttribute_Parameter(_spot_exponent)
+            COMPARE_StateAttribute_Parameter(_spot_cutoff)
+
+            return 0; // passed all the above comparison macro's, must be equal.
+        }
+
+        virtual bool getModeUsage(ModeUsage& usage) const
+        {
+            usage.usesMode(GL_LIGHT0+_lightnum);
+            return true;
+        }
+
+        /** Set which OpenGL light to operate on.*/
+        void setLightNum(int num) { _lightnum = num; }
+        
+        /** Get which OpenGL light this osg::Light operates on.*/
+        int getLightNum() const { return _lightnum; }
+
+	/** Set the ambient component of the light. */
+        inline void setAmbient( const Vec4& ambient ) { _ambient = ambient; }
+
+	/** Get the ambient component of the light. */
+        inline const Vec4& getAmbient() const { return _ambient; }
+
+	/** Set the diffuse component of the light. */
+        inline void setDiffuse( const Vec4& diffuse ) { _diffuse = diffuse; }
+
+	/** Get the diffuse component of the light. */
+        inline const Vec4& getDiffuse() const { return _diffuse; }
+
+	/** Set the specular component of the light. */
+        inline void setSpecular( const Vec4& specular ) { _specular = specular; }
+
+	/** Get the specular component of the light. */
+        inline const Vec4& getSpecular() const { return _specular; }
+
+	/** Set the position of the light. */	
+        inline void setPosition( const Vec4& position ) { _position = position; }
+
+	/** Get the position of the light. */	
+        inline const Vec4& getPosition() const { return _position; }
+
+	/** Set the direction of the light. */	
+        inline void setDirection( const Vec3& direction ) { _direction = direction; }
+
+	/** Get the direction of the light. */	
+        inline const Vec3& getDirection() const { return _direction; }
+
+	/** Set the constant attenuation of the light. */
+        inline void setConstantAttenuation( float constant_attenuation )     { _constant_attenuation = constant_attenuation; }
+
+	/** Get the constant attenuation of the light. */
+        inline float getConstantAttenuation() const { return _constant_attenuation; }
+
+	/** Set the linear attenuation of the light. */
+        inline void setLinearAttenuation ( float linear_attenuation )        { _linear_attenuation = linear_attenuation; }
+
+	/** Get the linear attenuation of the light. */
+        inline float getLinearAttenuation () const { return _linear_attenuation; }
+
+	/** Set the quadratic attenuation of the light. */
+        inline void setQuadraticAttenuation ( float quadratic_attenuation )  { _quadratic_attenuation = quadratic_attenuation; }
+
+	/** Get the quadratic attenuation of the light. */
+        inline float getQuadraticAttenuation()  const { return _quadratic_attenuation; }
+
+	/** Set the spot exponent of the light. */
+        inline void setSpotExponent( float spot_exponent )                   { _spot_exponent = spot_exponent; }
+
+	/** Get the spot exponent of the light. */
+        inline float getSpotExponent() const { return _spot_exponent; }
+
+	/** Set the spot cutoff of the light. */
+        inline void setSpotCutoff( float spot_cutoff )                       { _spot_cutoff = spot_cutoff; }
+
+	/** Get the spot cutoff of the light. */
+        inline float getSpotCutoff() const                                   { return _spot_cutoff; }
+
+	/**
+	 * Capture the lighting settings of the current OpenGL state
+	 * and store them in this object.
+	 */
+        void captureLightState();
+
+	/** Apply the light's state to the OpenGL state machine. */
+        virtual void apply(State& state) const;
+
+    protected :
+    
+        virtual ~Light();
+
+	/** Initialize the light's settings with some decent defaults. */
+        void init();
+
+        int _lightnum;                           // OpenGL light number
+
+        Vec4 _ambient;                           // r, g, b, w
+        Vec4 _diffuse;                           // r, g, b, w
+        Vec4 _specular;                          // r, g, b, w
+        Vec4 _position;                          // x, y, z, w
+        Vec3 _direction;                         // x, y, z
+        float _constant_attenuation;             // constant
+        float _linear_attenuation;               // linear
+        float _quadratic_attenuation;            // quadratic
+        float _spot_exponent;                    // exponent
+        float _spot_cutoff;                      // spread
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/FrontFace
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/FrontFace (revision 1529)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/FrontFace (revision 1529)
@@ -0,0 +1,70 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_FRONTFACE
+#define OSG_FRONTFACE 1
+
+#include <osg/StateAttribute>
+#include <osg/GL>
+
+namespace osg {
+
+/** Class to specifies the orientation of front-facing polygons.
+*/     
+class SG_EXPORT FrontFace : public StateAttribute
+{
+    public :
+    
+        FrontFace();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        FrontFace(const FrontFace& ff,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            StateAttribute(ff,copyop),
+            _mode(ff._mode) {}
+
+        META_StateAttribute(osg, FrontFace, FRONTFACE);
+        
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const StateAttribute& sa) const
+        {
+            // check the types are equal and then create the rhs variable
+            // used by the COMPARE_StateAttribute_Paramter macro's below.
+            COMPARE_StateAttribute_Types(FrontFace,sa)
+
+            // compare each paramter in turn against the rhs.
+            COMPARE_StateAttribute_Parameter(_mode)
+
+            return 0; // passed all the above comparison macro's, must be equal.
+        }
+
+        enum Mode {
+            CLOCKWISE = GL_CW,
+            COUNTER_CLOCKWISE = GL_CCW
+        };
+    
+        inline void setMode(Mode mode) { _mode = mode; }
+        inline const Mode getMode() const    { return _mode; }
+    
+        virtual void apply(State& state) const;
+        
+    protected:
+    
+        virtual ~FrontFace();
+        
+        Mode _mode;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/LineSegment
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/LineSegment (revision 2830)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/LineSegment (revision 2830)
@@ -0,0 +1,76 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_LINESEGMENT
+#define OSG_LINESEGMENT 1
+
+#include <osg/Matrix>
+#include <osg/BoundingBox>
+#include <osg/BoundingSphere>
+
+namespace osg {
+
+/** LineSegment class for representing a line segment.*/
+class SG_EXPORT LineSegment : public Referenced
+{
+    public:
+
+        LineSegment() {};
+        LineSegment(const LineSegment& seg) : Referenced(),_s(seg._s),_e(seg._e) {}
+        LineSegment(const Vec3& s,const Vec3& e) : _s(s),_e(e) {}
+
+        LineSegment& operator = (const LineSegment& seg) { _s = seg._s;  _e = seg._e; return *this; }
+
+        inline void set(const Vec3& s,const Vec3& e) { _s=s; _e=e; }
+        
+        inline Vec3& start() { return _s; }
+        inline const Vec3& start() const { return _s; }
+
+        inline Vec3& end() { return _e; }
+        inline const Vec3& end() const { return _e; }
+
+        inline bool valid() const { return _s.valid() && _e.valid() && _s!=_e; }
+
+        /** return true if segment intersects BoundingBox.*/
+        bool intersect(const BoundingBox& bb) const;
+
+        /** return true if segment intersects BoundingBox and return the intersection ratio's.*/
+        bool intersect(const BoundingBox& bb,float& r1,float& r2) const;
+
+        /** return true if segment intersects BoundingSphere.*/
+        bool intersect(const BoundingSphere& bs) const;
+
+        /** return true if segment intersects BoundingSphere and return the intersection ratio's.*/
+        bool intersect(const BoundingSphere& bs,float& r1,float& r2) const;
+        
+        /** return true if segment intersects triangle and set ratio long segment. */
+        bool intersect(const Vec3& v1,const Vec3& v2,const Vec3& v3,float& r);
+
+        /** post multiply a segment by matrix.*/
+        inline void mult(const LineSegment& seg,const Matrix& m) { _s = seg._s*m; _e = seg._e*m; }
+        /** pre multiply a segment by matrix.*/
+        inline void mult(const Matrix& m,const LineSegment& seg) { _s = m*seg._s; _e = m*seg._e; }
+
+    protected:
+
+        virtual ~LineSegment();
+        
+        static bool intersectAndClip(Vec3& s,Vec3& e,const BoundingBox& bb);
+
+        Vec3 _s;
+        Vec3 _e;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ClusterCullingCallback
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ClusterCullingCallback (revision 3136)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ClusterCullingCallback (revision 3136)
@@ -0,0 +1,66 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_CLUSTERCULLINGCALLBACK
+#define OSG_CLUSTERCULLINGCALLBACK 1
+
+#include <osg/Drawable>
+
+namespace osg {
+
+/** Drawable CullCallback for adding cluster culling to cull back facing
+  * drawables.*/
+class SG_EXPORT ClusterCullingCallback : public Drawable::CullCallback
+{
+    public:
+
+        ClusterCullingCallback();
+        ClusterCullingCallback(const ClusterCullingCallback& ccc,const CopyOp& copyop);
+        ClusterCullingCallback(const osg::Vec3& controlPoint, const osg::Vec3& normal, float deviation);
+        ClusterCullingCallback(const osg::Drawable* drawable);
+
+        META_Object(osg,ClusterCullingCallback)
+
+        /** compute the control point, normal and deviation from the contents of the drawable.*/
+        void computeFrom(const osg::Drawable* drawable);
+
+        void set(const osg::Vec3& controlPoint, const osg::Vec3& normal, float deviation, float radius);
+
+        void setControlPoint(const osg::Vec3& controlPoint) { _controlPoint = controlPoint; }
+        const osg::Vec3& getControlPoint() const { return _controlPoint; }
+
+        void setNormal(const osg::Vec3& normal) { _normal = normal; }
+        const osg::Vec3& getNormal() const { return _normal; }
+
+        void setRadius(float radius) { _radius = radius; }
+        float getRadius() const { return _radius; }
+
+        void setDeviation(float deviation) { _deviation = deviation; }
+        float getDeviation() const { return _deviation; }
+
+        virtual bool cull(osg::NodeVisitor*, osg::Drawable*, osg::State*) const;
+
+    protected:
+
+        virtual ~ClusterCullingCallback() {}
+
+        osg::Vec3    _controlPoint;
+        osg::Vec3    _normal;
+        float        _radius;
+        float        _deviation;
+};
+
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/BoundingSphere
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/BoundingSphere (revision 1529)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/BoundingSphere (revision 1529)
@@ -0,0 +1,128 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_BOUNDINGSPHERE
+#define OSG_BOUNDINGSPHERE 1
+
+#include <osg/Export>
+#include <osg/Vec3>
+
+namespace osg {
+
+class BoundingBox;
+
+/** General purpose bounding sphere class for enclosing nodes/objects/vertices.
+    Used to bound internal osg::Node's in the scene,
+    to assist in view frustum culling etc.  Similar in function to BoundingBox
+    but is quicker for evaluating culling, but generally encloses a greater volume
+    than a BoundingBox so will not cull so aggressively.
+*/
+class SG_EXPORT BoundingSphere
+{
+    public:
+        
+        Vec3 _center;
+        float _radius;
+
+        /** construct to invalid values to represent an unset bounding sphere.*/ 
+        BoundingSphere() : _center(0.0f,0.0f,0.0f),_radius(-1.0f) {}
+    
+        /** construct to specified bounding sphere.*/ 
+        BoundingSphere(const Vec3& center,float radius) : _center(center),_radius(radius) {}
+
+        /** initialize to invalid values to represent an unset bounding sphere.*/ 
+        inline void init()
+        {
+            _center.set(0.0f,0.0f,0.0f);
+            _radius = -1.0f;
+        }
+
+        /** return true if the bounding sphere contains valid values,
+            false if the bounding sphere is effectively unset.*/
+        inline bool valid() const { return _radius>=0.0f; }
+
+        /** set bounding sphere.*/ 
+        inline void set(const Vec3& center,float radius)
+        {
+            _center = center;
+            _radius = radius;
+        }
+
+        /** return the center of the bounding sphere.*/
+        inline Vec3& center() { return _center; }
+        /** return the const center of the bounding sphere.*/
+        inline const Vec3& center() const { return _center; }
+
+        /** return the radius of the bounding sphere.*/
+        inline float& radius() { return _radius; }
+
+        /** return the const radius of the bounding sphere.*/
+        inline float radius() const { return _radius; }
+        
+        /** return the radius squared. 
+            Note, for performance reasons, assumes the calling method has ensured 
+            that the sphere is valid before calling radius2(), i.e. has _radius>=0.0,
+            as it does not check th validity of sphere and will erroneously return a positive value.*/
+        inline float radius2() const { return _radius*_radius; }
+        
+        /** If the vertex is out-with the sphere expand to encompass vertex.
+            Calculates the combination of movement of center and radius which
+            minimizes the radius increase. If this sphere is empty then
+            move the center to v and set radius to 0.*/
+        void expandBy(const Vec3& v);
+
+        /** If the vertex is outwith the sphere expand radius to ecompass vertex.
+            Unlike update, does not move the center, just increasing the radius.
+            If this sphere is empty then move the centrer to v and set radius to 0 */
+        void expandRadiusBy(const Vec3& v);
+
+        /** If incomming sphere is outwith the sphere expand to ecompass incomming sphere.
+            calculates the combination of movement of center and radius which
+            minimizes the radius increase. If this sphere is empty then
+            move the centrer to v and set radius to 0.*/
+        void expandBy(const BoundingSphere& sh);
+
+        /** If incomming sphere is outwith the sphere expand radius to ecompass incomming sphere.
+            Unlike update, does not move the center, just increasing the radius.
+            If this sphere is empty then move the centrer to v and set radius to 0. */
+        void expandRadiusBy(const BoundingSphere& sh);
+
+        /** If incomming box is outwith the sphere expand to ecompass incomming box.
+            calculates the combination of movement of center and radius which
+            minimizes the radius increase. If this boz is empty then
+            move the centrer to v and set radius to 0.*/
+        void expandBy(const BoundingBox& bb);
+
+        /** If incomming box is outwith the sphere expand radius to ecompass incomming box.
+            Unlike update, does not move the center, just increasing the radius.
+            If this sphere is empty then move the centrer to v and set radius to 0. */
+        void expandRadiusBy(const BoundingBox& bb);
+
+        /** return true is vertex v is within the sphere.*/
+        inline bool contains(const Vec3& v) const
+        {
+            return valid() && ((v-_center).length2()<=radius2());
+        }
+
+        /** return true if bounding sphere's intersect each other.*/
+        inline bool intersects( const BoundingSphere& bs ) const
+        {
+            return valid() && bs.valid() &&
+                   ((_center - bs._center).length2() <= (_radius + bs._radius)*(_radius + bs._radius));
+        }
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/BoundingBox
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/BoundingBox (revision 2478)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/BoundingBox (revision 2478)
@@ -0,0 +1,193 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_BOUNDINGBOX
+#define OSG_BOUNDINGBOX 1
+
+#include <osg/Export>
+#include <osg/Vec3>
+#include <float.h>
+
+namespace osg {
+
+class BoundingSphere;
+
+/** General purpose axis-aligned bounding box class for enclosing objects/vertices.
+    Used to bounding the leaf objects in the scene,
+    i.e. osg::Drawable's to assist in view frustum culling etc.
+*/
+class SG_EXPORT BoundingBox
+{
+    public:
+    
+	/** The corner with the smallest values for each coordinate of the
+	    bounding box.*/
+	Vec3 _min;
+	/** The corner with the largest values for each coordinate of the
+	    bounding box.*/
+	Vec3 _max;
+
+        /** construct to invalid values to represent an unset bounding box.*/ 
+        inline BoundingBox() : _min(FLT_MAX,FLT_MAX,FLT_MAX),
+                        _max(-FLT_MAX,-FLT_MAX,-FLT_MAX) {}
+    
+        /** construct to with specified min and max values.*/ 
+        inline BoundingBox(float xmin,float ymin,float zmin,
+                    float xmax,float ymax,float zmax) :
+                    _min(xmin,ymin,zmin),
+                    _max(xmax,ymax,zmax) {}
+
+        /** construct to with specified min and max values.*/ 
+        inline BoundingBox(const Vec3& min,const Vec3& max) : 
+                    _min(min),
+                    _max(max) {}
+
+        /** initialize to invalid values to represent an unset bounding box.*/ 
+        inline void init()
+        {
+            _min.set(FLT_MAX,FLT_MAX,FLT_MAX);
+            _max.set(-FLT_MAX,-FLT_MAX,-FLT_MAX);
+        }
+                      
+        inline bool valid() const
+        {
+            return _max.x()>=_min.x() &&  _max.y()>=_min.y() &&  _max.z()>=_min.z();
+        }
+
+        inline void set (float xmin,float ymin,float zmin,
+                         float xmax,float ymax,float zmax)
+        {
+            _min.set(xmin,ymin,zmin);
+            _max.set(xmax,ymax,zmax);
+        }
+
+        /** construct to with specified min and max values.*/ 
+        inline void set(const Vec3& min,const Vec3& max)
+        {
+            _min = min;
+            _max = max;
+        }
+
+
+        inline float& xMin() { return _min.x(); }
+        inline float xMin() const { return _min.x(); }
+ 
+        inline float& yMin() { return _min.y(); }
+        inline float yMin() const { return _min.y(); }
+ 
+        inline float& zMin() { return _min.z(); }
+        inline float zMin() const { return _min.z(); }
+
+        inline float& xMax() { return _max.x(); }
+        inline float xMax() const { return _max.x(); }
+ 
+        inline float& yMax() { return _max.y(); }
+        inline float yMax() const { return _max.y(); }
+ 
+        inline float& zMax() { return _max.z(); }
+        inline float zMax() const { return _max.z(); }
+
+        /** Calculate and return the center of the bounding box.*/
+        inline const Vec3 center() const
+        {
+            return (_min+_max)*0.5f;
+        }
+
+        /** Calculate and return the radius of the bounding box.*/
+        inline float radius() const
+        {
+            return sqrtf(radius2());
+        }
+
+        /** Calculate and return the radius squared of the bounding box.
+            Note, radius2() is faster to calculate than radius().*/            
+        inline float radius2() const
+        {
+            return 0.25f*((_max-_min).length2());
+        }
+
+        /** return the corner of the bounding box.
+            Position (pos) is specified by a number between 0 and 7,
+            the first bit toggles between x min and x max, second
+            bit toggles between y min and y max, third bit toggles
+            between z min and z max.*/
+        inline const Vec3 corner(unsigned int pos) const
+        {
+            return Vec3(pos&1?_max.x():_min.x(),pos&2?_max.y():_min.y(),pos&4?_max.z():_min.z());
+        }
+
+        /** If the vertex is out-with the box expand to encompass vertex.
+            If this box is empty then move set this box's min max to vertex. */
+        inline void expandBy(const Vec3& v)
+        {
+            if(v.x()<_min.x()) _min.x() = v.x();
+            if(v.x()>_max.x()) _max.x() = v.x();
+
+            if(v.y()<_min.y()) _min.y() = v.y();
+            if(v.y()>_max.y()) _max.y() = v.y();
+
+            if(v.z()<_min.z()) _min.z() = v.z();
+            if(v.z()>_max.z()) _max.z() = v.z();
+        }
+
+        /** If the vertex is out-with the box expand to encompass vertex.
+            If this box is empty then move set this box's min max to vertex. */
+        inline void expandBy(float x,float y,float z)
+        {
+            if(x<_min.x()) _min.x() = x;
+            if(x>_max.x()) _max.x() = x;
+
+            if(y<_min.y()) _min.y() = y;
+            if(y>_max.y()) _max.y() = y;
+
+            if(z<_min.z()) _min.z() = z;
+            if(z>_max.z()) _max.z() = z;
+        }
+
+        /** If incoming box is out-with the box expand to encompass incoming box.
+            If this box is empty then move set this box to incoming box. */
+        void expandBy(const BoundingBox& bb);
+
+        /** If incoming sphere is out-with the box expand to encompass incoming sphere.
+            If this box is empty then move set this box to encompass the sphere. */
+        void expandBy(const BoundingSphere& sh);
+        
+
+        /** Compute the intesection of this bounding box with the specified bounding box.*/
+        BoundingBox intersect(const BoundingBox& bb) const
+        {    return osg::BoundingBox(osg::maximum(xMin(),bb.xMin()),osg::maximum(yMin(),bb.yMin()),osg::maximum(zMin(),bb.zMin()),
+                                     osg::minimum(xMax(),bb.xMax()),osg::minimum(yMax(),bb.yMax()),osg::minimum(zMax(),bb.zMax()));
+
+        }
+
+        /** return true if this bounding box with the specified bounding box.*/
+        bool intersects(const BoundingBox& bb) const
+        {    return osg::maximum(xMin(),bb.xMin()) <= osg::minimum(xMax(),bb.xMax()) &&
+                    osg::maximum(yMin(),bb.yMin()) <= osg::minimum(yMax(),bb.yMax()) &&
+                    osg::maximum(zMin(),bb.zMin()) <= osg::minimum(zMax(),bb.zMax());
+
+        }
+
+        /** return true is vertex v is within the box.*/
+        inline bool contains(const Vec3& v) const
+        {
+            return valid() && 
+                   (v.x()>=_min.x() && v.x()<=_max.x()) &&
+                   (v.y()>=_min.y() && v.y()<=_max.y()) &&
+                   (v.z()>=_min.z() && v.z()<=_max.z());
+        }
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/buffered_value
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/buffered_value (revision 1936)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/buffered_value (revision 1936)
@@ -0,0 +1,120 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_BUFFERED_VALUE
+#define OSG_BUFFERED_VALUE 1
+
+#include <osg/DisplaySettings>
+#include <vector>
+
+namespace osg {
+
+/** Simple buffered value array which is used for values that need to multibuffered on
+  * one per graphics context basis.*/
+  
+template<class T>
+class buffered_value
+{
+    public:
+    
+        inline buffered_value():
+            _array(DisplaySettings::instance()->getMaxNumberOfGraphicsContexts(),0)
+            {}
+
+        buffered_value& operator = (const buffered_value& rhs)
+        {
+            _array = rhs._array;
+            return *this;
+        }
+        
+        inline void setAllElementsTo(const T& t) { std::fill(_array.begin(),_array.end(),t); }
+
+        inline void clear() { _array.clear(); }
+
+        inline bool empty() const { return _array.empty(); }
+
+        inline unsigned int size() const { return _array.size(); }
+
+        inline T& operator[] (unsigned int pos)
+        {
+            // automatically resize array.
+            if (_array.size()<=pos)
+                _array.resize(pos+1,0);
+
+            return _array[pos];
+        }
+
+        inline T operator[] (unsigned int pos) const
+        {
+            // automatically resize array.
+            if (_array.size()<=pos)
+                _array.resize(pos+1,0);
+
+            return _array[pos];
+        }
+
+    protected:
+    
+        mutable std::vector<T> _array;
+};
+
+template<class T>
+class buffered_object
+{
+    public:
+    
+        inline buffered_object():
+            _array(DisplaySettings::instance()->getMaxNumberOfGraphicsContexts())
+            {}
+
+        buffered_object& operator = (const buffered_object& rhs)
+        {
+            _array = rhs._array;
+            return *this;
+        }
+
+        inline void setAllElementsTo(const T& t) { std::fill(_array.begin(),_array.end(),t); }
+
+        inline void clear() { _array.clear(); }
+
+        inline bool empty() const { return _array.empty(); }
+
+        inline unsigned int size() const { return _array.size(); }
+
+        inline T& operator[] (unsigned int pos)
+        {
+            // automatically resize array.
+            if (_array.size()<=pos)
+                _array.resize(pos+1);
+
+            return _array[pos];
+        }
+
+        inline const T& operator[] (unsigned int pos) const
+        {
+            // automatically resize array.
+            if (_array.size()<=pos)
+                _array.resize(pos+1);
+
+            return _array[pos];
+        }
+        
+
+    protected:
+    
+        mutable std::vector<T> _array;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Drawable
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Drawable (revision 3159)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Drawable (revision 3159)
@@ -0,0 +1,787 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_DRAWABLE
+#define OSG_DRAWABLE 1
+
+#include <osg/BoundingBox>
+#include <osg/State>
+#include <osg/NodeVisitor>
+#include <osg/Shape>
+#include <osg/buffered_value>
+
+namespace osg {
+
+class Vec2f;
+class Vec3f;
+class Vec4f;
+class UByte4;
+class Geometry;
+
+#ifndef GL_ARB_vertex_buffer_object
+
+    // for compatibility with gl.h headers that don't support VBO,
+    #if defined(_WIN64)
+        typedef __int64 GLintptrARB;
+        typedef __int64 GLsizeiptrARB;
+    #elif defined(__ia64__) || defined(__x86_64__)
+        typedef long int GLintptrARB;
+        typedef long int GLsizeiptrARB;
+    #else
+        typedef int GLintptrARB;
+        typedef int GLsizeiptrARB;
+    #endif
+    
+    #define GL_ARRAY_BUFFER_ARB               0x8892
+    #define GL_ELEMENT_ARRAY_BUFFER_ARB       0x8893
+    #define GL_ARRAY_BUFFER_BINDING_ARB       0x8894
+    #define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895
+    #define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896
+    #define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897
+    #define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898
+    #define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899
+    #define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A
+    #define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B
+    #define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C
+    #define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D
+    #define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E
+    #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F
+    #define GL_STREAM_DRAW_ARB                0x88E0
+    #define GL_STREAM_READ_ARB                0x88E1
+    #define GL_STREAM_COPY_ARB                0x88E2
+    #define GL_STATIC_DRAW_ARB                0x88E4
+    #define GL_STATIC_READ_ARB                0x88E5
+    #define GL_STATIC_COPY_ARB                0x88E6
+    #define GL_DYNAMIC_DRAW_ARB               0x88E8
+    #define GL_DYNAMIC_READ_ARB               0x88E9
+    #define GL_DYNAMIC_COPY_ARB               0x88EA
+    #define GL_READ_ONLY_ARB                  0x88B8
+    #define GL_WRITE_ONLY_ARB                 0x88B9
+    #define GL_READ_WRITE_ARB                 0x88BA
+    #define GL_BUFFER_SIZE_ARB                0x8764
+    #define GL_BUFFER_USAGE_ARB               0x8765
+    #define GL_BUFFER_ACCESS_ARB              0x88BB
+    #define GL_BUFFER_MAPPED_ARB              0x88BC
+    #define GL_BUFFER_MAP_POINTER_ARB         0x88BD
+
+#endif
+
+#ifndef GL_NV_occlusion_query
+
+    #define GL_OCCLUSION_TEST_HP                0x8165
+    #define GL_OCCLUSION_TEST_RESULT_HP         0x8166
+    #define GL_PIXEL_COUNTER_BITS_NV            0x8864
+    #define GL_CURRENT_OCCLUSION_QUERY_ID_NV    0x8865
+    #define GL_PIXEL_COUNT_NV                   0x8866
+    #define GL_PIXEL_COUNT_AVAILABLE_NV         0x8867
+
+#endif
+
+#ifndef GL_ARB_occlusion_query
+
+    #define GL_SAMPLES_PASSED_ARB               0x8914
+    #define GL_QUERY_COUNTER_BITS_ARB           0x8864
+    #define GL_CURRENT_QUERY_ARB                0x8865
+    #define GL_QUERY_RESULT_ARB                 0x8866
+    #define GL_QUERY_RESULT_AVAILABLE_ARB       0x8867
+
+#endif
+
+// this is define to alter the way display lists are compiled inside the
+// the draw method, it has been found that the NVidia drivers fail completely
+// to optimize COMPILE_AND_EXECUTE in fact make it go slower than for no display 
+// lists, but optimize a separate COMPILE very well?!  Define it as default
+// the use of a sperate COMPILE, then glCallList rather than use COMPILE_AND_EXECUTE.
+
+#define USE_SEPARATE_COMPILE_AND_EXECUTE
+
+/** Pure virtual base class for drawable Geometry.  Contains no drawing primitives
+    directly, these are provided by subclasses such as osg::Geometry. State attributes 
+    for a Drawable are maintained in StateSet which the Drawable maintains
+    a referenced counted pointer to.  Both Drawable's and StateSet's can 
+    be shared for optimal memory usage and graphics performance.
+*/
+class SG_EXPORT Drawable : public Object
+{
+    public:
+
+        Drawable();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        Drawable(const Drawable& drawable,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Drawable*>(obj)!=NULL; }
+        virtual const char* libraryName() const { return "osg"; }
+        virtual const char* className() const { return "Drawable"; }
+
+        /** convert 'this' into a Geometry pointer if Drawable is a Geometry, otherwise return 0.
+          * Equivalent to dynamic_cast<Geometry*>(this).*/
+        virtual Geometry* asGeometry() { return 0; }
+        /** convert 'const this' into a const Geometry pointer if Drawable is a Geometry, otherwise return 0.
+          * Equivalent to dynamic_cast<const Geometry*>(this).*/
+        virtual const Geometry* asGeometry() const { return 0; }
+
+
+        /** A vector of osg::Node pointers which is used to store the parent(s) of drawable.*/
+        typedef std::vector<Node*> ParentList;
+
+        /** Get the parent list of drawable. */
+        inline const ParentList& getParents() const { return _parents; }
+
+        /** Get the a copy of parent list of node. A copy is returned to 
+          * prevent modification of the parent list.*/
+        inline ParentList getParents() { return _parents; }
+
+        /** Get a single parent of Drawable.
+          * @param i index of the parent to get.
+          * @return the parent i.
+          */
+        inline Node* getParent(unsigned int i)  { return _parents[i]; }
+        /** Get a single const parent of Drawable.
+          * @param i index of the parent to get.
+          * @return the parent i.
+          */
+        inline const Node* getParent(unsigned int i) const  { return _parents[i]; }
+
+        /**
+         * Get the number of parents of node.
+         * @return the number of parents of this node.
+         */
+        inline unsigned int getNumParents() const { return _parents.size(); }
+
+
+
+        /** Set the StateSet attached to the Drawable.
+            Previously attached StateSet are automatically unreferenced on 
+            assignment of a new drawstate.*/
+        inline void setStateSet(StateSet *state) { _stateset = state; }
+        
+        /** Get the attached StateSet.*/
+        inline StateSet* getStateSet() { return _stateset.get();}
+
+        /** Get the attached const StateSet.*/
+        inline const StateSet* getStateSet() const { return _stateset.get();}
+
+        /** Get the attached const StateSet, 
+          * if one is not already attach create one, 
+          * attach it to the drawable and return a pointer to it.*/
+        StateSet* getOrCreateStateSet();
+
+
+        /** Dirty the bounding box, forcing a computeBound() on the next call
+          * to getBound(). Should be called in the internal geometry of the Drawable
+          * is modified.*/        
+        void dirtyBound();
+
+        /** get bounding box of geoset. 
+          * Note, now made virtual to make it possible to implement user-drawn
+          * objects albeit so what crudely, to be improved later.
+          */
+        inline const BoundingBox& getBound() const
+        {
+            if( !_bbox_computed)
+                computeBound();
+            return _bbox;
+        }
+
+
+        /** Set the Shape of the drawable. The shape can be used to
+      * speed up collision detection or as a guide for produral
+      * geometry generation - see osg::ProduralGeometry.*/
+        inline void setShape(Shape* shape) { _shape = shape; }
+
+        /** Get the Shape of the Drawable.*/
+        inline Shape* getShape() { return _shape.get(); }
+    
+        /** Get the const Shape of the const Drawable.*/
+        inline const Shape* getShape() const { return _shape.get(); }
+
+
+
+        /** Set the drawable to it can or cannot be used in conjunction with OpenGL
+          * display lists.  With set to true, calls to Drawable::setUseDisplayList,
+          * whereas when set to false, no display lists can be created and calls
+          * to setUseDisplayList are ignored, and a warning is produced.  The later
+          * is typically used to guard against the switching on of display lists
+          * on objects with dynamic internal data such as continuous Level of Detail
+          * algorithms.*/
+        void setSupportsDisplayList(bool flag);
+      
+        /** Get whether display lists are supported for this drawable instance.*/  
+        inline bool getSupportsDisplayList() const { return _supportsDisplayList; }
+
+
+        /** When set to true, force the draw method to use OpenGL Display List for rendering.
+            If false rendering directly.  If the display list has not been already
+            compile the next call to draw will automatically create the display list.*/
+        void setUseDisplayList(bool flag);
+
+        /** Return whether OpenGL display lists are being used for rendering.*/
+        inline bool getUseDisplayList() const { return _useDisplayList; }
+
+        /** When set to true, ignore the setUseDisplayList() settings, and hints to the drawImplemention 
+            method to use OpenGL vertex buffer objects for rendering..*/
+        void setUseVertexBufferObjects(bool flag);
+
+        /** Return whether OpenGL vertex buffer objects should be used when supported by OpenGL driver.*/
+        inline bool getUseVertexBufferObjects() const { return _useVertexBufferObjects; }
+
+
+        /** Force a recompile on next draw() of any OpenGL display list associated with this geoset.*/
+        void dirtyDisplayList();
+
+
+
+        /** draw OpenGL primitives. 
+          * If the drawable has _useDisplayList set to true then use an OpenGL display
+          * list, automatically compiling one if required.
+          * Otherwise call drawImplementation().
+          * Note, draw method should *not* be overridden in subclasses as it 
+          * manages the optional display list.
+          */
+        inline void draw(State& state) const;
+        
+        /** Immediately compile this drawable into an OpenGL Display List.
+            Note I, operation is ignored if _useDisplayList to false.
+            Note II, compile is not intended to be overridden in subclasses.*/
+        virtual void compileGLObjects(State& state) const;
+
+        /** release any OpenGL display lists associated with graphics context specified
+            in osg::State object is supplied, or release all display lists for all graphics contexts if state pointer is NULL*/
+        virtual void releaseGLObjects(State* state=0) const;
+
+        struct UpdateCallback : public virtual osg::Object
+        {
+            UpdateCallback() {}
+
+            UpdateCallback(const UpdateCallback&,const CopyOp&) {}
+
+            META_Object(osg,UpdateCallback)
+
+            /** do customized update code.*/
+            virtual void update(osg::NodeVisitor*, osg::Drawable*) {}
+        };
+        
+        /** Set the UpdateCallback which allows users to attach customize the undating of an object during the update traversal.*/
+        void setUpdateCallback(UpdateCallback* ac);
+        
+        /** Get the non const UpdateCallback.*/
+        UpdateCallback* getUpdateCallback() { return _updateCallback.get(); }
+
+        /** Get the const UpdateCallback.*/
+        const UpdateCallback* getUpdateCallback() const { return _updateCallback.get(); }
+        
+
+        struct CullCallback : public virtual osg::Object
+        {
+            CullCallback() {}
+
+            CullCallback(const CullCallback&,const CopyOp&) {}
+
+            META_Object(osg,CullCallback)
+
+            /** do customized cull code, return true if drawable should be culled.*/
+            virtual bool cull(osg::NodeVisitor*, osg::Drawable*, osg::State*) const { return false; }
+        };
+
+        /** Set the CullCallback which allows users to attach customize the culling of Drawable during the cull traversal.*/
+        void setCullCallback(CullCallback* cc) { _cullCallback=cc; }
+        
+        /** Get the non const CullCallback.*/
+        CullCallback* getCullCallback() { return _cullCallback.get(); }
+        
+        /** Get the const CullCallback.*/
+        const CullCallback* getCullCallback() const { return _cullCallback.get(); }
+        
+        
+
+
+        /** Callback attached to an Drawable which allows the users to customize the drawing of an exist Drawable object.
+          * The draw callback is implement as a replacement to the Drawable's own drawImplementation() method, if the
+          * the user intends to decorate the exist draw code then simple call the drawable->drawImplementation() from
+          * with the callbacks drawImplementation() method.  This allows the users to do both pre and post callbacks
+          * without fuss and can even diable the inner draw in required.*/
+        struct DrawCallback : public virtual osg::Object
+        {
+            DrawCallback() {}
+
+            DrawCallback(const DrawCallback&,const CopyOp&) {}
+
+            META_Object(osg,DrawCallback)
+
+            /** do customized draw code.*/
+            virtual void drawImplementation(osg::State&,const osg::Drawable*) const {}
+        };
+
+        /** Set the DrawCallback which allows users to attach customize the drawing of existing Drawable object.*/
+        void setDrawCallback(DrawCallback* dc) { _drawCallback=dc; dirtyDisplayList(); }
+        
+        /** Get the non const DrawCallback.*/
+        DrawCallback* getDrawCallback() { return _drawCallback.get(); }
+        
+        /** Get the const DrawCallback.*/
+        const DrawCallback* getDrawCallback() const { return _drawCallback.get(); }
+
+
+
+        /** draw directly ignoring an OpenGL display list which could be attached.
+          * This is the internal draw method which does the drawing itself,
+          * and is the method to override when deriving from Drawable.
+          */
+        virtual void drawImplementation(State& state) const = 0;
+
+
+
+        /** use deleteDisplayList instead of glDeleteList to allow
+          * OpenGL display list to cached until they can be deleted
+          * by the OpenGL context in which they were created, specified
+          * by contextID.*/
+        static void deleteDisplayList(unsigned int contextID,GLuint globj);
+        
+        /** flush all the cached display list which need to be deleted
+          * in the OpenGL context related to contextID.*/
+        static void flushDeletedDisplayLists(unsigned int contextID,double currentTime, double& availableTime);
+
+        /** use deleteVertexBufferObject instead of glDeleteList to allow
+          * OpenGL buffer objects to cached until they can be deleted
+          * by the OpenGL context in which they were created, specified
+          * by contextID.*/
+        static void deleteVertexBufferObject(unsigned int contextID,GLuint globj);
+        
+        /** flush all the cached vertex buffer objects which need to be deleted
+          * in the OpenGL context related to contextID.*/
+        static void flushDeletedVertexBufferObjects(unsigned int contextID,double currentTime, double& availableTime);
+
+        typedef unsigned int AttributeType;
+        
+        enum AttributeTypes
+        {
+            VERTICES            = 0,
+            WEIGHTS             = 1,
+            NORMALS             = 2,
+            COLORS              = 3,
+            SECONDARY_COLORS    = 4,
+            FOG_COORDS          = 5,
+            ATTIBUTE_6          = 6,
+            ATTIBUTE_7          = 7,
+            TEXTURE_COORDS      = 8,
+            TEXTURE_COORDS_0    = TEXTURE_COORDS,
+            TEXTURE_COORDS_1    = TEXTURE_COORDS_0+1,
+            TEXTURE_COORDS_2    = TEXTURE_COORDS_0+2,
+            TEXTURE_COORDS_3    = TEXTURE_COORDS_0+3,
+            TEXTURE_COORDS_4    = TEXTURE_COORDS_0+4,
+            TEXTURE_COORDS_5    = TEXTURE_COORDS_0+5,
+            TEXTURE_COORDS_6    = TEXTURE_COORDS_0+6,
+            TEXTURE_COORDS_7    = TEXTURE_COORDS_0+7 
+            // only eight texture coord examples provided here, but underlying code can handle any no of texure units,
+            // simply co them as (TEXTURE_COORDS_0+unit).
+        };
+        
+        class AttributeFunctor
+        {
+        public:
+        
+            virtual ~AttributeFunctor() {}
+            
+            virtual void apply(AttributeType,unsigned int,GLbyte*) {}
+            virtual void apply(AttributeType,unsigned int,GLshort*) {}
+            virtual void apply(AttributeType,unsigned int,GLint*) {}
+
+            virtual void apply(AttributeType,unsigned int,GLubyte*) {}
+            virtual void apply(AttributeType,unsigned int,GLushort*) {}
+            virtual void apply(AttributeType,unsigned int,GLuint*) {}
+
+            virtual void apply(AttributeType,unsigned int,float*) {}
+            virtual void apply(AttributeType,unsigned int,Vec2*) {}
+            virtual void apply(AttributeType,unsigned int,Vec3*) {}
+            virtual void apply(AttributeType,unsigned int,Vec4*) {}
+            virtual void apply(AttributeType,unsigned int,UByte4*) {}
+        };
+        
+        
+        /** return true if the Drawable subclass supports accept(AttributeFunctor&).*/
+        virtual bool supports(AttributeFunctor&) const { return false; }
+
+        /** accept an AttributeFunctor and call its methods to tell it about the interal attributes that this Drawable has.
+          * return true if functor handled by drawable, return false on failure of drawable to generate functor calls.*/
+        virtual void accept(AttributeFunctor&) {}
+        
+
+        class ConstAttributeFunctor
+        {
+        public:
+        
+            virtual ~ConstAttributeFunctor() {}
+            
+            virtual void apply(AttributeType,const unsigned int,const GLbyte*) {}
+            virtual void apply(AttributeType,const unsigned int,const GLshort*) {}
+            virtual void apply(AttributeType,const unsigned int,const GLint*) {}
+
+            virtual void apply(AttributeType,const unsigned int,const GLubyte*) {}
+            virtual void apply(AttributeType,const unsigned int,const GLushort*) {}
+            virtual void apply(AttributeType,const unsigned int,const GLuint*) {}
+
+            virtual void apply(AttributeType,const unsigned int,const float*) {}
+            virtual void apply(AttributeType,const unsigned int,const Vec2*) {}
+            virtual void apply(AttributeType,const unsigned int,const Vec3*) {}
+            virtual void apply(AttributeType,const unsigned int,const Vec4*) {}
+            virtual void apply(AttributeType,const unsigned int,const UByte4*) {}
+        };
+
+        /** return true if the Drawable subclass supports accept(ConstAttributeFunctor&).*/
+        virtual bool supports(ConstAttributeFunctor&) const { return false; }
+
+        /** accept an AttributeFunctor and call its methods to tell it about the interal attributes that this Drawable has.
+          * return true if functor handled by drawable, return false on failure of drawable to generate functor calls.*/
+        virtual void accept(ConstAttributeFunctor&) const {}
+
+
+        class PrimitiveFunctor
+        {
+        public:
+            
+            virtual ~PrimitiveFunctor() {}
+
+            virtual void setVertexArray(unsigned int count,const Vec2* vertices) = 0;
+            virtual void setVertexArray(unsigned int count,const Vec3* vertices) = 0;
+            virtual void setVertexArray(unsigned int count,const Vec4* vertices) = 0;
+            
+            virtual void drawArrays(GLenum mode,GLint first,GLsizei count) = 0;
+            virtual void drawElements(GLenum mode,GLsizei count,const GLubyte* indices) = 0;
+            virtual void drawElements(GLenum mode,GLsizei count,const GLushort* indices) = 0;
+            virtual void drawElements(GLenum mode,GLsizei count,const GLuint* indices) = 0;
+            
+            virtual void begin(GLenum mode) = 0;
+            virtual void vertex(const Vec2& vert) = 0;
+            virtual void vertex(const Vec3& vert) = 0;
+            virtual void vertex(const Vec4& vert) = 0;
+            virtual void vertex(float x,float y) = 0;
+            virtual void vertex(float x,float y,float z) = 0;
+            virtual void vertex(float x,float y,float z,float w) = 0;
+            virtual void end() = 0;
+            
+        };
+        
+        class PrimitiveIndexFunctor
+        {
+        public:
+            
+            virtual ~PrimitiveIndexFunctor() {}
+
+            virtual void setVertexArray(unsigned int count,const Vec2* vertices) = 0;
+            virtual void setVertexArray(unsigned int count,const Vec3* vertices) = 0;
+            virtual void setVertexArray(unsigned int count,const Vec4* vertices) = 0;
+            
+            virtual void drawArrays(GLenum mode,GLint first,GLsizei count) = 0;
+            virtual void drawElements(GLenum mode,GLsizei count,const GLubyte* indices) = 0;
+            virtual void drawElements(GLenum mode,GLsizei count,const GLushort* indices) = 0;
+            virtual void drawElements(GLenum mode,GLsizei count,const GLuint* indices) = 0;
+            
+            virtual void begin(GLenum mode) = 0;
+            virtual void vertex(unsigned int pos) = 0;
+            virtual void end() = 0;
+            
+        };
+
+        /** return true if the Drawable subclass supports accept(PrimitiveFunctor&).*/
+        virtual bool supports(PrimitiveFunctor&) const { return false; }
+
+        /** accept a PrimtiveFunctor and call its methods to tell it about the interal primtives that this Drawable has.
+          * return true if functor handled by drawable, return false on failure of drawable to generate functor calls.
+          * Note, PrimtiveFunctor only provide const access of the primtives, as primitives may be procedurally generated
+          * so one cannot modify it.*/
+        virtual void accept(PrimitiveFunctor&) const {}
+
+        /** return true if the Drawable subclass supports accept(PrimitiveIndexFunctor&).*/
+        virtual bool supports(PrimitiveIndexFunctor&) const { return false; }
+
+        /** accept a PrimtiveIndexFunctor and call its methods to tell it about the interal primtives that this Drawable has.
+          * return true if functor handled by drawable, return false on failure of drawable to generate functor calls.
+          * Note, PrimtiveIndexFunctor only provide const access of the primtives, as primitives may be procedurally generated
+          * so one cannot modify it.*/
+        virtual void accept(PrimitiveIndexFunctor&) const {}
+
+
+        /** Extensions class which encapsulates the querring of extensions and
+        * associated function pointers, and provide convinience wrappers to 
+        * check for the extensions or use the associated functions.*/        
+        class SG_EXPORT Extensions : public osg::Referenced
+        {
+        public:
+            Extensions();
+
+            Extensions(const Extensions& rhs);
+
+            void lowestCommonDenominator(const Extensions& rhs);
+
+            void setupGLExtenions();
+
+            void setVertexProgramSupported(bool flag) { _isVertexProgramSupported=flag; }
+            bool isVertexProgramSupported() const { return _isVertexProgramSupported; }
+
+            void setSecondaryColorSupported(bool flag) { _isSecondaryColorSupported=flag; }
+            bool isSecondaryColorSupported() const { return _isSecondaryColorSupported; }
+
+            void setFogCoordSupported(bool flag) { _isFogCoordSupported=flag; }
+            bool isFogCoordSupported() const { return _isFogCoordSupported; }
+
+            void setMultiTexSupported(bool flag) { _isMultiTexSupported=flag; }
+            bool isMultiTexSupported() const { return _isMultiTexSupported; }
+
+            void setOcclusionQuerySupported(bool flag) { _isOcclusionQuerySupported=flag; }
+            bool isOcclusionQuerySupported() const { return _isOcclusionQuerySupported; }
+
+            void setARBOcclusionQuerySupported(bool flag) { _isARBOcclusionQuerySupported=flag; }
+            bool isARBOcclusionQuerySupported() const { return _isARBOcclusionQuerySupported; }
+
+            void glSecondaryColor3ubv(const GLubyte* coord) const;
+            void glSecondaryColor3fv(const GLfloat* coord) const;
+
+            void glFogCoordfv(const GLfloat* coord) const;
+
+            void glMultiTexCoord1f(GLenum target,GLfloat coord) const;
+            void glMultiTexCoord2fv(GLenum target,const GLfloat* coord) const;
+            void glMultiTexCoord3fv(GLenum target,const GLfloat* coord) const;
+            void glMultiTexCoord4fv(GLenum target,const GLfloat* coord) const;
+
+            void glVertexAttrib1s(unsigned int index, GLshort s) const;
+            void glVertexAttrib1f(unsigned int index, GLfloat f) const;
+            void glVertexAttrib2fv(unsigned int index, const GLfloat * v) const;
+            void glVertexAttrib3fv(unsigned int index, const GLfloat * v) const;
+            void glVertexAttrib4fv(unsigned int index, const GLfloat * v) const;
+            void glVertexAttrib4ubv(unsigned int index, const GLubyte * v) const;
+            void glVertexAttrib4Nubv(unsigned int index, const GLubyte * v) const;
+
+            void glGenBuffers (GLsizei n, GLuint *buffers) const;
+            void glBindBuffer (GLenum target, GLuint buffer) const;
+            void glBufferData (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage) const;
+            void glBufferSubData (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data) const;
+            void glDeleteBuffers (GLsizei n, const GLuint *buffers) const;
+
+            void glGenOcclusionQueries( GLsizei n, GLuint *ids ) const;
+            void glDeleteOcclusionQueries( GLsizei n, const GLuint *ids ) const;
+            GLboolean glIsOcclusionQuery( GLuint id ) const;
+            void glBeginOcclusionQuery( GLuint id ) const;
+            void glEndOcclusionQuery() const;
+            void glGetOcclusionQueryiv( GLuint id, GLenum pname, GLint *params ) const;
+            void glGetOcclusionQueryuiv( GLuint id, GLenum pname, GLuint *params ) const;
+
+            void glGetQueryiv(GLenum target, GLenum pname, GLint *params) const;
+            void glGenQueries(GLsizei n, GLuint *ids) const;
+            void glBeginQuery(GLenum target, GLuint id) const;
+            void glEndQuery(GLenum target) const;
+            GLboolean glIsQuery(GLuint id) const;
+            void glGetQueryObjectiv(GLuint id, GLenum pname, GLint *params) const;
+            void glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) const;
+
+        protected:
+
+            typedef void (APIENTRY * FogCoordProc) (const GLfloat* coord);
+
+            typedef void (APIENTRY * VertexAttrib1sProc) (unsigned int index, GLshort s);
+            typedef void (APIENTRY * VertexAttrib1fProc) (unsigned int index, GLfloat f);
+            typedef void (APIENTRY * VertexAttribfvProc) (unsigned int index, const GLfloat * v);
+            typedef void (APIENTRY * VertexAttribubvProc) (unsigned int index, const GLubyte * v);
+
+            typedef void (APIENTRY * SecondaryColor3ubvProc) (const GLubyte* coord);
+            typedef void (APIENTRY * SecondaryColor3fvProc) (const GLfloat* coord);
+
+            typedef void (APIENTRY * MultiTexCoord1fProc) (GLenum target,GLfloat coord);
+            typedef void (APIENTRY * MultiTexCoordfvProc) (GLenum target,const GLfloat* coord);
+
+            typedef void (APIENTRY * GenBuffersProc) (GLsizei n, GLuint *buffers);
+            typedef void (APIENTRY * BindBufferProc) (GLenum target, GLuint buffer);
+            typedef void (APIENTRY * BufferDataProc) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage);
+            typedef void (APIENTRY * BufferSubDataProc) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data);
+            typedef void (APIENTRY * DeleteBuffersProc) (GLsizei n, const GLuint *buffers);
+
+            typedef void (APIENTRY * GenOcclusionQueriesProc) ( GLsizei n, GLuint *ids );
+            typedef void (APIENTRY * DeleteOcclusionQueriesProc) ( GLsizei n, const GLuint *ids );
+            typedef GLboolean (APIENTRY * IsOcclusionQueryProc) ( GLuint id );
+            typedef void (APIENTRY * BeginOcclusionQueryProc) ( GLuint id );
+            typedef void (APIENTRY * EndOcclusionQueryProc) ();
+            typedef void (APIENTRY * GetOcclusionQueryivProc) ( GLuint id, GLenum pname, GLint *params );
+            typedef void (APIENTRY * GetOcclusionQueryuivProc) ( GLuint id, GLenum pname, GLuint *params );
+
+            typedef void (APIENTRY *GenQueriesProc) (GLsizei n, GLuint *ids);
+            typedef void (APIENTRY *DeleteQueriesProc) (GLsizei n, const GLuint *ids);
+            typedef GLboolean (APIENTRY *IsQueryProc) (GLuint id);
+            typedef void (APIENTRY *BeginQueryProc) (GLenum target, GLuint id);
+            typedef void (APIENTRY *EndQueryProc) (GLenum target);
+            typedef void (APIENTRY *GetQueryivProc) (GLenum target, GLenum pname, GLint *params);
+            typedef void (APIENTRY *GetQueryObjectivProc) (GLuint id, GLenum pname, GLint *params);
+            typedef void (APIENTRY *GetQueryObjectuivProc) (GLuint id, GLenum pname, GLuint *params);
+
+            ~Extensions() {}
+
+            bool _isVertexProgramSupported;
+            bool _isSecondaryColorSupported;
+            bool _isFogCoordSupported;
+            bool _isMultiTexSupported;
+            bool _isOcclusionQuerySupported;
+            bool _isARBOcclusionQuerySupported;
+
+            FogCoordProc _glFogCoordfv;
+
+            SecondaryColor3ubvProc _glSecondaryColor3ubv;
+            SecondaryColor3fvProc _glSecondaryColor3fv;
+
+            VertexAttrib1sProc _glVertexAttrib1s;
+            VertexAttrib1fProc _glVertexAttrib1f;
+            VertexAttribfvProc _glVertexAttrib2fv;
+            VertexAttribfvProc _glVertexAttrib3fv;
+            VertexAttribfvProc _glVertexAttrib4fv;
+            VertexAttribubvProc _glVertexAttrib4ubv;
+            VertexAttribubvProc _glVertexAttrib4Nubv;
+
+            MultiTexCoord1fProc _glMultiTexCoord1f;
+            MultiTexCoordfvProc _glMultiTexCoord2fv;
+            MultiTexCoordfvProc _glMultiTexCoord3fv;
+            MultiTexCoordfvProc _glMultiTexCoord4fv;
+
+            GenBuffersProc      _glGenBuffers;
+            BindBufferProc      _glBindBuffer;
+            BufferDataProc      _glBufferData;
+            BufferSubDataProc   _glBufferSubData;
+            DeleteBuffersProc   _glDeleteBuffers;
+
+            GenOcclusionQueriesProc _glGenOcclusionQueries;
+            DeleteOcclusionQueriesProc _glDeleteOcclusionQueries;
+            IsOcclusionQueryProc _glIsOcclusionQuery;
+            BeginOcclusionQueryProc _glBeginOcclusionQuery;
+            EndOcclusionQueryProc _glEndOcclusionQuery;
+            GetOcclusionQueryivProc _glGetOcclusionQueryiv;
+            GetOcclusionQueryuivProc _glGetOcclusionQueryuiv;
+
+            GenQueriesProc _gl_gen_queries_arb;
+            DeleteQueriesProc _gl_delete_queries_arb;
+            IsQueryProc _gl_is_query_arb;
+            BeginQueryProc _gl_begin_query_arb;
+            EndQueryProc _gl_end_query_arb;
+            GetQueryivProc _gl_get_queryiv_arb;
+            GetQueryObjectivProc _gl_get_query_objectiv_arb;
+            GetQueryObjectuivProc  _gl_get_query_objectuiv_arb;
+
+        };
+
+        /** Function to call to get the extension of a specified context.
+        * If the Exentsion object for that context has not yet been created then 
+        * and the 'createIfNotInitalized' flag been set to false then returns NULL.
+        * If 'createIfNotInitalized' is true then the Extensions object is 
+        * automatically created.  However, in this case the extension object 
+        * only be created with the graphics context associated with ContextID..*/
+        static Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized);
+
+        /** setExtensions allows users to override the extensions across graphics contexts.
+        * typically used when you have different extensions supported across graphics pipes
+        * but need to ensure that they all use the same low common denominator extensions.*/
+        static void setExtensions(unsigned int contextID,Extensions* extensions);
+
+
+    protected:
+
+        Drawable& operator = (const Drawable&) { return *this;}
+
+        virtual ~Drawable();
+
+        /** compute the bounding box of the drawable. Method must be 
+            implemented by subclasses.*/
+        virtual bool computeBound() const;
+        
+        /** set the bounding box .*/
+        void setBound(const BoundingBox& bb) const;
+ 
+        void addParent(osg::Node* node);
+        void removeParent(osg::Node* node);
+
+        ParentList _parents;
+        friend class Node;
+        friend class Geode;
+
+        ref_ptr<StateSet>       _stateset;
+
+        mutable BoundingBox     _bbox;
+        mutable bool            _bbox_computed;
+        
+        ref_ptr<Shape>           _shape;
+
+        bool                    _supportsDisplayList;
+        bool                    _useDisplayList;
+        bool                    _supportsVertexBufferObjects;
+        bool                    _useVertexBufferObjects;
+
+        typedef osg::buffered_value<GLuint> GLObjectList;
+        mutable GLObjectList    _globjList;
+        mutable GLObjectList    _vboList;
+
+        ref_ptr<UpdateCallback> _updateCallback;
+        ref_ptr<CullCallback>   _cullCallback;
+        ref_ptr<DrawCallback>   _drawCallback;
+        
+
+};
+
+inline void Drawable::draw(State& state) const
+{
+    if (_useDisplayList && !(_supportsVertexBufferObjects && _useVertexBufferObjects && state.isVertexBufferObjectSupported()))
+    {
+        // get the contextID (user defined ID of 0 upwards) for the 
+        // current OpenGL context.
+        unsigned int contextID = state.getContextID();
+
+        // get the globj for the current contextID.
+        GLuint& globj = _globjList[contextID];
+
+        // call the globj if already set otherwise compile and execute.
+        if( globj != 0 )
+        {
+            glCallList( globj );
+        }
+        else if (_useDisplayList)
+        {
+#ifdef USE_SEPARATE_COMPILE_AND_EXECUTE
+            globj = glGenLists( 1 );
+            glNewList( globj, GL_COMPILE );
+            if (_drawCallback.valid())
+                _drawCallback->drawImplementation(state,this);
+            else 
+                drawImplementation(state);
+            glEndList();
+            
+            glCallList( globj);
+#else
+            globj = glGenLists( 1 );
+            glNewList( globj, GL_COMPILE_AND_EXECUTE );
+            if (_drawCallback.valid())
+                _drawCallback->drawImplementation(state,this);
+            else 
+                drawImplementation(state);                
+            glEndList();
+#endif
+        }
+        
+        return;
+
+    }
+
+    // draw object as nature intended..
+    if (_drawCallback.valid())
+        _drawCallback->drawImplementation(state,this);
+    else 
+        drawImplementation(state);
+};
+
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Export
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Export (revision 3222)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Export (revision 3222)
@@ -0,0 +1,59 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_EXPORT
+#define OSG_EXPORT 1
+
+// define used to include in API which is being fazed out
+// if you can compile your apps with this turned off you are
+// well placed for compatablity with future versions.
+// #define USE_DEPRECATED_API
+
+#if defined(_MSC_VER)
+    #pragma warning( disable : 4244 )
+    #pragma warning( disable : 4251 )
+    #pragma warning( disable : 4267 )
+    #pragma warning( disable : 4275 )
+    #pragma warning( disable : 4290 )
+    #pragma warning( disable : 4786 )
+    #pragma warning( disable : 4305 )
+#endif
+
+#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__)  || defined( __MWERKS__)
+	#  ifdef SG_LIBRARY
+	#    define SG_EXPORT   __declspec(dllexport)
+	#  else
+	#    define SG_EXPORT   __declspec(dllimport)
+	#  endif /* SG_LIBRARY */
+#else
+	#  define SG_EXPORT
+#endif  
+
+// set up define for whether member templates are supported by VisualStudio compilers.
+#ifdef _MSC_VER
+# if (_MSC_VER >= 1300)
+#  define __STL_MEMBER_TEMPLATES
+# endif
+#endif
+
+/* Define NULL pointer value */
+
+#ifndef NULL
+    #ifdef  __cplusplus
+        #define NULL    0
+    #else
+        #define NULL    ((void *)0)
+    #endif
+#endif
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Texture3D
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Texture3D (revision 3190)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Texture3D (revision 3190)
@@ -0,0 +1,215 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_TEXTURE3D
+#define OSG_TEXTURE3D 1
+
+#include <osg/Texture>
+
+namespace osg {
+
+/** Texture state class which encapsulates OpenGl 3D texture functionality.*/
+class SG_EXPORT Texture3D : public Texture
+{
+
+    public :
+        
+        Texture3D();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        Texture3D(const Texture3D& text,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+        
+        META_StateAttribute(osg, Texture3D,TEXTURE);
+
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const StateAttribute& rhs) const;
+
+        virtual bool getModeUsage(ModeUsage& usage) const
+        {
+            usage.usesTextureMode(GL_TEXTURE_3D);
+            return true;
+        }
+
+        /** Set the texture image. */
+        void setImage(Image* image);
+
+        /** Get the texture image. */
+        Image* getImage() { return _image.get(); }
+
+        /** Get the const texture image. */
+        inline const Image* getImage() const { return _image.get(); }
+
+        inline unsigned int& getModifiedTag(unsigned int contextID) const
+        {
+            // get the modified tag for the current contextID.
+            return _modifiedTag[contextID];
+        }
+
+        /** Set the texture image, ignoring face. as there is only one image*/
+        virtual void setImage(unsigned int, Image* image) { setImage(image); }
+
+        /** Get the texture image, ignoring face value as there is only one image. */
+        virtual Image* getImage(unsigned int) { return _image.get(); }
+
+        /** Get the const texture image , ignoring face value as there is only one image. */
+        virtual const Image* getImage(unsigned int) const { return _image.get(); }
+
+        /** Get the number of images that can be assigned to the Texture. */
+        virtual unsigned int getNumImages() const { return 1; }
+
+
+        /** Set the texture width and height. If width or height are zero then
+          * the repsective size value is calculated from the source image sizes. */
+        inline void setTextureSize(int width, int height, int depth) const
+        {
+            _textureWidth = width;
+            _textureHeight = height;
+            _textureDepth = depth;
+        }
+
+        /** Get the texture subload width. */
+        inline void getTextureSize(int& width, int& height, int& depth) const
+        {
+            width = _textureWidth;
+            height = _textureHeight;
+            depth = _textureDepth;
+        }
+
+
+        class SG_EXPORT SubloadCallback : public Referenced
+        {
+            public:
+                virtual void load(const Texture3D& texture,State& state) const = 0;
+                virtual void subload(const Texture3D& texture,State& state) const = 0;
+        };
+        
+        void setSubloadCallback(SubloadCallback* cb) { _subloadCallback = cb;; }
+        
+        SubloadCallback* getSubloadCallback() { return _subloadCallback.get(); }
+
+        const SubloadCallback* getSubloadCallback() const { return _subloadCallback.get(); }
+
+
+        /** Set the number of mip map levels the the texture has been created with,
+            should only be called within an osg::Texuture::apply() and custom OpenGL texture load.*/
+        void setNumMipmapLevels(unsigned int num) const { _numMipmapLevels=num; }
+
+        /** Get the number of mip map levels the the texture has been created with.*/
+        unsigned int getNumMipmapLevels() const { return _numMipmapLevels; }
+        
+
+        /** Copy a two-dimensional texture subimage. As per glCopyTexSubImage2D.
+          * Updates portion of an existing OpenGL texture object from the current OpenGL background
+          * framebuffer contents at pos \a x, \a y with width \a width and
+          * height \a height. */
+        void copyTexSubImage3D(State& state, int xoffset, int yoffset, int zoffset, int x, int y, int width, int height);
+
+
+        /** On first apply (unless already compiled), create the minmapped 
+          * texture and bind it, subsequent apply will simple bind to texture.*/
+        virtual void apply(State& state) const;
+        
+
+        /** Extensions class which encapsulates the querring of extensions and
+          * associated function pointers, and provide convinience wrappers to 
+          * check for the extensions or use the associated functions.*/        
+        class SG_EXPORT Extensions : public osg::Referenced
+        {
+            public:
+                Extensions();
+
+                Extensions(const Extensions& rhs);
+                
+                void lowestCommonDenominator(const Extensions& rhs);
+                
+                void setupGLExtenions();
+
+                void setTexture3DSupported(bool flag) { _isTexture3DSupported=flag; }
+                bool isTexture3DSupported() const { return _isTexture3DSupported; }
+                
+                void setTexture3DFast(bool flag) { _isTexture3DFast=flag; }
+                bool isTexture3DFast() const { return _isTexture3DFast; }
+
+                void setMaxTexture3DSize(GLint maxsize) { _maxTexture3DSize=maxsize; }
+                GLint maxTexture3DSize() const { return _maxTexture3DSize; }
+
+                void setTexImage3DProc(void* ptr) { _glTexImage3D = ptr; }
+                void glTexImage3D( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels) const;
+
+                void setTexSubImage3DProc(void* ptr) { _glTexSubImage3D = ptr; }
+                void glTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels) const;
+                
+                void setCopyTexSubImage3DProc(void* ptr) { _glCopyTexSubImage3D = ptr; }
+                void glCopyTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ) const;
+                
+                void setBuild3DMipmapsProc(void* ptr) { _gluBuild3DMipmaps = ptr; }
+                void gluBuild3DMipmaps( GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *data) const;
+
+            protected:
+
+                ~Extensions() {}
+                
+                bool    _isTexture3DSupported;
+                bool    _isTexture3DFast;
+                GLint   _maxTexture3DSize;
+
+                void*   _glTexImage3D;
+                void*   _glTexSubImage3D;
+                void*   _glCopyTexSubImage3D;
+                void*   _gluBuild3DMipmaps;
+
+        };
+        
+        /** Function to call to get the extension of a specified context.
+          * If the Exentsion object for that context has not yet been created then 
+          * and the 'createIfNotInitalized' flag been set to false then returns NULL.
+          * If 'createIfNotInitalized' is true then the Extensions object is 
+          * automatically created.  However, in this case the extension object 
+          * only be created with the graphics context associated with ContextID..*/
+        static Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized);
+
+        /** setExtensions allows users to override the extensions across graphics contexts.
+          * typically used when you have different extensions supported across graphics pipes
+          * but need to ensure that they all use the same low common denominator extensions.*/
+        static void setExtensions(unsigned int contextID,Extensions* extensions);
+
+    protected :
+
+        virtual ~Texture3D();
+
+        virtual void computeInternalFormat() const;
+
+        void applyTexImage3D(GLenum target, Image* image, State& state, GLsizei& inwidth, GLsizei& inheight, GLsizei& indepth, GLsizei& numMipmapLevels) const;
+
+        // not ideal that _image is mutable, but its required since
+        // Image::ensureDimensionsArePowerOfTwo() can only be called
+        // in a valid OpenGL context, a therefore within an Texture::apply
+        // which is const...
+        mutable ref_ptr<Image> _image;
+
+        // subloaded images can have different texture and image sizes.
+        mutable GLsizei _textureWidth, _textureHeight, _textureDepth;
+        
+        // number of mip map levels the the texture has been created with,        
+        mutable GLsizei _numMipmapLevels;
+
+        ref_ptr<SubloadCallback> _subloadCallback;
+
+        typedef buffered_value<unsigned int> ImageModifiedTag;
+        mutable ImageModifiedTag _modifiedTag;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/GLU
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/GLU (revision 2788)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/GLU (revision 2788)
@@ -0,0 +1,23 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_GLU
+#define OSG_GLU 1
+
+#ifdef __APPLE__
+	#include <OpenGL/glu.h>
+#else
+	#include <GL/glu.h>
+#endif
+
+#endif  // __osgGLU_h
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ApplicationUsage
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ApplicationUsage (revision 2772)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ApplicationUsage (revision 2772)
@@ -0,0 +1,103 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_APPLICATIONUSAGE
+#define OSG_APPLICATIONUSAGE 1
+
+#include <osg/Export>
+
+#include <map>
+#include <string>
+#include <ostream>
+
+namespace osg {
+
+class SG_EXPORT ApplicationUsage
+{
+    public:
+        
+        static ApplicationUsage* instance();
+
+        ApplicationUsage() {}
+
+        ApplicationUsage(const std::string& commandLineUsage);
+
+        typedef std::map<std::string,std::string> UsageMap;
+        
+
+        void setApplicationName(const std::string& name) { _applicationName = name; }
+        const std::string& getApplicationName() const { return _applicationName; }
+
+        void setDescription(const std::string& desc) { _description = desc; }
+        const std::string& getDescription() const { return _description; }
+
+        enum Type
+        {
+            COMMAND_LINE_OPTION = 0x1,
+            ENVIRONMENTAL_VARIABLE = 0x2,
+            KEYBOARD_MOUSE_BINDING = 0x4
+        };
+        
+        void addUsageExplanation(Type type,const std::string& option,const std::string& explanation);
+        
+        void setCommandLineUsage(const std::string& explanation) { _commandLineUsage=explanation; }
+
+        const std::string& getCommandLineUsage() const { return _commandLineUsage; }
+
+
+        void addCommandLineOption(const std::string& option,const std::string& explanation);
+        
+        const UsageMap& getCommandLineOptions() const { return _commandLineOptions; }
+
+
+        void addEnvironmentalVariable(const std::string& option,const std::string& explanation);
+        
+        const UsageMap& getEnvironmentalVariables() const { return _environmentalVariables; }
+
+
+        void addKeyboardMouseBinding(const std::string& option,const std::string& explanation);
+
+        const UsageMap& getKeyboardMouseBindings() const { return _keyboardMouse; }
+
+
+        void getFormatedString(std::string& str, const UsageMap& um,unsigned int widthOfOutput=80);
+
+        void write(std::ostream& output,const UsageMap& um,unsigned int widthOfOutput=80);
+        
+        void write(std::ostream& output,unsigned int type=COMMAND_LINE_OPTION|ENVIRONMENTAL_VARIABLE|KEYBOARD_MOUSE_BINDING, unsigned int widthOfOutput=80);
+
+    protected:
+    
+        std::string _applicationName;
+        std::string _description;
+        std::string _commandLineUsage;
+        UsageMap    _commandLineOptions;
+        UsageMap    _environmentalVariables;
+        UsageMap    _keyboardMouse;
+        
+};
+
+class ApplicationUsageProxy
+{   
+    public:
+
+        /** register an explanation of commandline/evironmentalvaraible/keyboard mouse usage.*/
+        ApplicationUsageProxy(ApplicationUsage::Type type,const std::string& option,const std::string& explanation)
+        {
+            ApplicationUsage::instance()->addUsageExplanation(type,option,explanation);
+        }
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/LightSource
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/LightSource (revision 3106)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/LightSource (revision 3106)
@@ -0,0 +1,86 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_LIGHTSOURCE
+#define OSG_LIGHTSOURCE 1
+
+#include <osg/NodeVisitor>
+#include <osg/Light>
+#include <osg/Group>
+
+namespace osg {
+
+/** Leaf Node for defining a light in the scene.*/
+class SG_EXPORT LightSource : public Group
+{
+    public:
+    
+        LightSource();
+
+        LightSource(const LightSource& ls, const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            Group(ls,copyop),
+            _value(ls._value),
+            _light(dynamic_cast<osg::Light*>(copyop(ls._light.get()))) {}
+
+        META_Node(osg, LightSource);
+
+        enum ReferenceFrame
+        {
+            RELATIVE_TO_PARENTS,
+            RELATIVE_TO_ABSOLUTE
+        };
+        
+        /** Set the light sources's ReferenceFrame, either to be relative to its
+          * parent reference frame, or relative to an absolute coordinate
+          * frame. RELATIVE_TO_PARENTS is the default.
+          * Note: setting the ReferenceFrame to be RELATIVE_TO_ABSOLUTE will
+          * also set the CullingActive flag on the light source, and hence all
+          * of its parents, to false, thereby disabling culling of it and
+          * all its parents.  This is neccessary to prevent inappropriate
+          * culling, but may impact cull times if the absolute light source is
+          * deep in the scene graph.  It is therefore recommend to only use
+          * absolute light source at the top of the scene. */
+        void setReferenceFrame(ReferenceFrame rf);
+        
+        ReferenceFrame getReferenceFrame() const { return _referenceFrame; }
+
+        /** Set the attached light.*/
+        void setLight(Light* light);
+
+        /** Get the attached light.*/
+        inline Light* getLight() { return _light.get(); }
+
+        /** Get the const attached light.*/
+        inline const Light* getLight() const { return _light.get(); }
+
+        /** Set the GLModes on StateSet associated with the LightSource.*/
+        void setStateSetModes(StateSet&,StateAttribute::GLModeValue) const;
+
+        /** Set up the local StateSet */
+        void setLocalStateSetModes(StateAttribute::GLModeValue=StateAttribute::ON);
+
+    protected:
+
+        virtual ~LightSource();
+
+        virtual bool computeBound() const;
+
+        StateAttribute::GLModeValue     _value;
+        ref_ptr<Light>                  _light;
+
+        ReferenceFrame                  _referenceFrame;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/LineStipple
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/LineStipple (revision 2773)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/LineStipple (revision 2773)
@@ -0,0 +1,75 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_LINESTIPPLE
+#define OSG_LINESTIPPLE 1
+
+#include <osg/StateAttribute>
+
+namespace osg {
+
+class SG_EXPORT LineStipple : public StateAttribute
+{
+    public :
+
+        LineStipple();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        LineStipple(const LineStipple& lw,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+          StateAttribute(lw,copyop),
+          _factor(lw._factor),
+          _pattern(lw._pattern) {}
+
+        META_StateAttribute(osg, LineStipple, LINESTIPPLE);
+
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const StateAttribute& sa) const
+        {
+            // check the types are equal and then create the rhs variable
+            // used by the COMPARE_StateAttribute_Paramter macro's below.
+            COMPARE_StateAttribute_Types(LineStipple,sa)
+
+            // compare each paramter in turn against the rhs.
+            COMPARE_StateAttribute_Parameter(_factor)
+            COMPARE_StateAttribute_Parameter(_pattern)
+
+            return 0; // passed all the above comparison macro's, must be equal.
+        }
+        
+        virtual bool getModeUsage(ModeUsage& usage) const
+        {
+            usage.usesMode(GL_LINE_STIPPLE);
+            return true;
+        }
+
+        void setFactor(GLint factor);
+        inline GLint getFactor() const { return _factor; }
+
+        void setPattern(GLushort pattern);
+        inline GLushort getPattern() const { return _pattern; }
+
+        virtual void apply(State& state) const;
+
+
+    protected :
+
+        virtual ~LineStipple();
+
+        GLint           _factor;
+        GLushort	_pattern;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Point
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Point (revision 2773)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Point (revision 2773)
@@ -0,0 +1,96 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_POINT
+#define OSG_POINT 1
+
+#include <osg/Vec3>
+#include <osg/StateAttribute>
+
+namespace osg {
+
+/** Point - encapsulates the OpenGL point smoothing and size state.*/
+class SG_EXPORT Point : public StateAttribute
+{
+    public :
+
+        Point();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        Point(const Point& point,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            StateAttribute(point,copyop),
+            _size(point._size),
+            _fadeThresholdSize(point._fadeThresholdSize),
+            _distanceAttenuation(point._distanceAttenuation),
+            _minSize(point._minSize),
+            _maxSize(point._maxSize) {}
+
+        META_StateAttribute(osg, Point, POINT);
+        
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const StateAttribute& sa) const
+        {
+            // check the types are equal and then create the rhs variable
+            // used by the COMPARE_StateAttribute_Paramter macro's below.
+            COMPARE_StateAttribute_Types(Point,sa)
+
+            // compare each paramter in turn against the rhs.
+            COMPARE_StateAttribute_Parameter(_size)
+            COMPARE_StateAttribute_Parameter(_fadeThresholdSize)
+            COMPARE_StateAttribute_Parameter(_distanceAttenuation)
+            COMPARE_StateAttribute_Parameter(_minSize)
+            COMPARE_StateAttribute_Parameter(_maxSize)
+
+            return 0; // passed all the above comparison macro's, must be equal.
+        }
+
+        virtual bool getModeUsage(ModeUsage& usage) const
+        {
+            usage.usesMode(GL_POINT_SMOOTH);
+            return true;
+        }
+
+        void setSize(float size);
+        inline float getSize() const { return _size; }
+
+        void setFadeThresholdSize(float fadeThresholdSize);
+        inline float getFadeThresholdSize() const { return _fadeThresholdSize; }
+
+        void setDistanceAttenuation(const Vec3& distanceAttenuation);
+        inline const Vec3& getDistanceAttenuation() const { return _distanceAttenuation; }
+
+        void setMinSize(float minSize);
+        inline float getMinSize() const {return _minSize;}
+
+        void setMaxSize(float maxSize);
+        inline float getMaxSize() const {return _maxSize;}
+
+        virtual void apply(State& state) const;
+
+        static void init_GL_EXT();
+
+    protected :
+
+        virtual ~Point();
+
+        float       _size;
+        float       _fadeThresholdSize;
+        Vec3        _distanceAttenuation;
+        float        _minSize;
+        float        _maxSize;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Math
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Math (revision 3035)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Math (revision 3035)
@@ -0,0 +1,198 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef __OSG_MATH
+#define __OSG_MATH
+
+#include <math.h>
+
+// for OSX users :
+// comment in if you want backwards compatibility with 10.1.x versions
+// otherwise you'll have problems with missing floorf and __isnan*()
+// #define APPLE_PRE_10_2
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1300)
+    #include <float.h>
+#endif
+
+
+#if (defined(WIN32) && !(defined(_MSC_VER) && (_MSC_VER >= 1300)) && !defined(__MINGW32__) ) || \
+    defined (sun) || \
+    defined (__APPLE__)
+    
+
+    #include <float.h>
+
+
+    // PJA MAC OSX
+    // This appears to be the simplest way to get these defined under MACOSX
+    // where they arent in math.h
+
+    #ifndef acosf
+    #define acosf (float)acos
+    #endif
+
+    #ifndef asinf
+    #define asinf (float)asin
+    #endif
+
+    #ifndef cosf
+    #define cosf (float)cos
+    #endif
+
+    #ifndef sinf
+    #define sinf (float)sin
+    #endif
+
+    #ifndef logf
+    #define logf (float)log
+    #endif
+
+    #ifndef powf
+    #define powf (float)pow
+    #endif
+
+    #ifndef sqrtf
+    #define sqrtf (float)sqrt
+    #endif
+    
+    #ifndef fabsf
+    #define fabsf (float)fabs
+    #endif
+
+    #ifndef atan2f
+    #define atan2f (float)atan2
+    #endif
+
+#endif
+
+#if (defined(WIN32) && !(defined(_MSC_VER) && (_MSC_VER >= 1300)) && !defined(__MINGW32__) ) || \
+    defined (sun)
+
+    #ifndef isnanf
+    #define isnanf (float)isnan
+    #endif
+
+#endif
+
+#if (defined(WIN32) && !(defined(_MSC_VER) && (_MSC_VER >= 1300)) && !defined(__MINGW32__) ) || \
+    defined (sun) || \
+    defined (__hpux__) || \
+    defined (APPLE_PRE_10_2)
+
+    #ifndef floorf
+    #define floorf (float)floor
+    #endif
+
+#endif
+
+namespace osg {
+
+// define the stand trig values
+#ifdef PI
+#undef PI
+#undef PI_2
+#undef PI_4
+#endif
+const double PI   = 3.14159265358979323846;
+const double PI_2 = 1.57079632679489661923;
+const double PI_4 = 0.78539816339744830962;
+
+/** return the minimum of two values, equivilant to std::min.
+  * std::min not used because of STL implementation under IRIX contains no std::min.*/
+template<typename T>
+inline T absolute(T v) { return v<(T)0?-v:v; }
+
+/** return true if float lhs and rhs are equivalent, meaning that the difference between then is less than an epsilon value which default to 1e-6.*/
+inline float equivalent(float lhs,float rhs,float epsilon=1e-6) { float delta = rhs-lhs; return delta<0.0f?delta>=-epsilon:delta<=epsilon; }
+
+/** return true if double lhs and rhs are equivalent, meaning that the difference between then is less than an epsilon value which default to 1e-6.*/
+inline double equivalent(double lhs,double rhs,double epsilon=1e-6) { double delta = rhs-lhs; return delta<0.0?delta>=-epsilon:delta<=epsilon; }
+
+/** return the minimum of two values, equivilant to std::min.
+  * std::min not used because of STL implementation under IRIX contains no std::min.*/
+template<typename T>
+inline T minimum(T lhs,T rhs) { return lhs<rhs?lhs:rhs; }
+
+/** return the maximum of two values, equivilant to std::max.
+  * std::max not used because of STL implementation under IRIX contains no std::max.*/
+template<typename T>
+inline T maximum(T lhs,T rhs) { return lhs>rhs?lhs:rhs; }
+
+template<typename T>
+inline T clampTo(T v,T minimum,T maximum) { return v<minimum?minimum:v>maximum?maximum:v; }
+
+template<typename T>
+inline T clampAbove(T v,T minimum) { return v<minimum?minimum:v; }
+
+template<typename T>
+inline T clampBelow(T v,T maximum) { return v>maximum?maximum:v; }
+
+template<typename T>
+inline T clampBetween(T v,T minimum, T maximum) { return clampBelow(clampAbove(v,minimum),maximum); }
+
+template<typename T>
+inline T sign(T v) { return v<(T)0?(T)-1:(T)1; }
+
+template<typename T>
+inline T square(T v) { return v*v; }
+
+template<typename T>
+inline T signedSquare(T v) { return v<(T)0?-v*v:v*v;; }
+
+inline float inDegrees(float angle) { return angle*(float)PI/180.0f; }
+inline double inDegrees(double angle) { return angle*PI/180.0; }
+
+template<typename T>
+inline T inRadians(T angle) { return angle; }
+
+inline float DegreesToRadians(float angle) { return angle*(float)PI/180.0f; }
+inline double DegreesToRadians(double angle) { return angle*PI/180.0; }
+
+inline float RadiansToDegrees(float angle) { return angle*180.0f/(float)PI; }
+inline double RadiansToDegrees(double angle) { return angle*180.0/PI; }
+
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__MWERKS__)
+    inline bool isNaN(float v) { return _isnan(v)!=0; }
+    inline bool isNaN(double v) { return _isnan(v)!=0; }
+#else
+    # if defined(__APPLE__) && !defined (APPLE_PRE_10_2)
+        inline bool isNaN(float v) { return __isnanf(v); }
+        inline bool isNaN(double v) { return __isnand(v); }
+    #else
+        inline bool isNaN(float v) { return isnan(v); }
+        inline bool isNaN(double v) { return isnan(v); }
+    #endif
+#endif
+
+
+/** compute the volume of tetrahedron */
+template<typename T>
+inline float computeVolume(const T& a,const T& b,const T& c,const T& d)
+{
+    return fabsf(((b-c)^(a-b))*(d-b));
+}
+
+/** compute the volume of prism */
+template<typename T>
+inline float computeVolume(const T& f1,const T& f2,const T& f3,
+                           const T& b1,const T& b2,const T& b3)
+{
+    return computeVolume(f1,f2,f3,b1)+
+           computeVolume(b1,b2,b3,f2)+
+           computeVolume(b1,b3,f2,f3);
+}
+
+}
+
+#endif  // __OSG_MATH
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TexGen
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TexGen (revision 2773)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TexGen (revision 2773)
@@ -0,0 +1,124 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_TEXGEN
+#define OSG_TEXGEN 1
+
+#include <osg/Plane>
+#include <osg/StateAttribute>
+
+namespace osg {
+
+#ifndef GL_NORMAL_MAP_ARB
+#define GL_NORMAL_MAP_ARB                   0x8511
+#endif
+
+#ifndef GL_REFLECTION_MAP_ARB
+#define GL_REFLECTION_MAP_ARB               0x8512
+#endif
+
+/** TexGen - encapsulates the OpenGL glTexGen (texture coordinate generation) state.*/
+class SG_EXPORT TexGen : public StateAttribute
+{
+    public :
+    
+        TexGen();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        TexGen(const TexGen& texgen,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            StateAttribute(texgen,copyop),
+            _mode(texgen._mode),
+            _plane_s(texgen._plane_s),
+            _plane_t(texgen._plane_t),
+            _plane_r(texgen._plane_r),
+            _plane_q(texgen._plane_q) {}
+
+        META_StateAttribute(osg, TexGen, TEXGEN);
+        
+        virtual bool isTextureAttribute() const { return true; }
+
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const StateAttribute& sa) const
+        {
+            // check the types are equal and then create the rhs variable
+            // used by the COMPARE_StateAttribute_Paramter macro's below.
+            COMPARE_StateAttribute_Types(TexGen,sa)
+
+            // compare each paramter in turn against the rhs.
+            COMPARE_StateAttribute_Parameter(_mode)
+            COMPARE_StateAttribute_Parameter(_plane_s)
+            COMPARE_StateAttribute_Parameter(_plane_t)
+            COMPARE_StateAttribute_Parameter(_plane_r)
+            COMPARE_StateAttribute_Parameter(_plane_q)
+
+            return 0; // passed all the above comparison macro's, must be equal.
+        }
+
+        virtual bool getModeUsage(ModeUsage& usage) const
+        {
+            usage.usesTextureMode(GL_TEXTURE_GEN_S);
+            usage.usesTextureMode(GL_TEXTURE_GEN_T);
+
+            // Not happy with turning all tex gen paramters on
+            // as the OSG currently only supports 2D textures and therefore
+            // only S and T will only be required, R&Q would be redundant...
+            // So commenting out the following until OSG supports 3D textures.
+            // I plan to revamp the OpenGL state management later so will
+            // tidy up then.  Robert Osfield. Jan 2001.
+            
+            // The tidy up is now happening, but will have a think before
+            // resolving the below parameters.
+
+            usage.usesTextureMode(GL_TEXTURE_GEN_R);
+            usage.usesTextureMode(GL_TEXTURE_GEN_Q);
+            return true;
+        }
+
+        virtual void apply(State& state) const;
+
+        enum Mode {
+            OBJECT_LINEAR  = GL_OBJECT_LINEAR,
+            EYE_LINEAR     = GL_EYE_LINEAR,
+            SPHERE_MAP     = GL_SPHERE_MAP,
+            NORMAL_MAP     = GL_NORMAL_MAP_ARB,
+            REFLECTION_MAP = GL_REFLECTION_MAP_ARB
+        };
+
+        inline void setMode( Mode mode ) { _mode = mode; }
+
+        Mode getMode() const { return _mode; }
+
+        enum Coord {
+	  S, T, R, Q
+        };
+
+        void setPlane(Coord which, const Plane& plane);
+
+        Plane& getPlane(Coord which);
+
+        const Plane& getPlane(Coord which) const;
+
+    protected :
+
+        virtual ~TexGen( void );
+
+        Mode _mode;
+
+        /// additional texgen coefficents for GL_OBJECT_PLANE or GL_EYE_PLANE,
+        Plane _plane_s, _plane_t, _plane_r, _plane_q;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Geometry
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Geometry (revision 3140)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Geometry (revision 3140)
@@ -0,0 +1,403 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_GEOMETRY
+#define OSG_GEOMETRY 1
+
+#include <osg/Drawable>
+#include <osg/Vec2>
+#include <osg/Vec3>
+#include <osg/Vec4>
+#include <osg/Array>
+#include <osg/PrimitiveSet>
+
+namespace osg {
+
+
+class SG_EXPORT Geometry : public Drawable
+{
+    public:
+
+        Geometry();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        Geometry(const Geometry& geometry,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+            
+        virtual Object* cloneType() const { return new Geometry(); }
+        virtual Object* clone(const CopyOp& copyop) const { return new Geometry(*this,copyop); }        
+        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Geometry*>(obj)!=NULL; }
+        virtual const char* libraryName() const { return "osg"; }
+        virtual const char* className() const { return "Geometry"; }
+
+        virtual Geometry* asGeometry() { return this; }
+        virtual const Geometry* asGeometry() const { return this; }
+
+        bool empty() const;
+
+        enum AttributeBinding
+        {
+            BIND_OFF=0,
+            BIND_OVERALL,
+            BIND_PER_PRIMITIVE_SET,
+            BIND_PER_PRIMITIVE,
+            BIND_PER_VERTEX
+        };
+               
+        struct ArrayData
+        {
+            ArrayData():
+                binding(BIND_OFF),
+                normalize(GL_FALSE),
+                offset(0) {}
+                
+            ArrayData(const ArrayData& data,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+            ArrayData(Array* a, AttributeBinding b, GLboolean n = GL_FALSE):
+                array(a),
+                indices(0),
+                binding(b),
+                normalize(n),
+                offset(0) {}
+
+            ArrayData(Array* a, IndexArray* i, AttributeBinding b, GLboolean n = GL_FALSE):
+                array(a),
+                indices(i),
+                binding(b),
+                normalize(n),
+                offset(0) {}
+
+            ArrayData& operator = (const ArrayData& rhs)
+            {
+                array = rhs.array;
+                indices = rhs.indices;
+                binding = rhs.binding;
+                normalize = rhs.normalize;
+                offset = rhs.offset;
+                return *this;
+            }
+            
+            inline bool empty() const { return !array.valid(); } 
+
+            ref_ptr<Array>          array;
+            ref_ptr<IndexArray>     indices;
+            AttributeBinding        binding;
+            GLboolean               normalize;
+            mutable unsigned int    offset;
+        };
+        
+        struct Vec3ArrayData
+        {
+            Vec3ArrayData():
+                binding(BIND_OFF),
+                normalize(GL_FALSE),
+                offset(0) {}
+                
+            Vec3ArrayData(const Vec3ArrayData& data,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+            Vec3ArrayData(Vec3Array* a, AttributeBinding b, GLboolean n = GL_FALSE):
+                array(a),
+                indices(0),
+                binding(b),
+                normalize(n),
+                offset(0) {}
+
+            Vec3ArrayData(Vec3Array* a, IndexArray* i, AttributeBinding b, GLboolean n = GL_FALSE):
+                array(a),
+                indices(i),
+                binding(b),
+                normalize(n),
+                offset(0) {}
+
+            Vec3ArrayData& operator = (const Vec3ArrayData& rhs)
+            {
+                array = rhs.array;
+                indices = rhs.indices;
+                binding = rhs.binding;
+                normalize = rhs.normalize;
+                offset = rhs.offset;
+                return *this;
+            }
+
+            inline bool empty() const { return !array.valid(); } 
+
+            ref_ptr<Vec3Array>          array;
+            ref_ptr<IndexArray>     indices;
+            AttributeBinding        binding;
+            GLboolean               normalize;
+            mutable unsigned int    offset;
+        };
+
+        /** static ArrayData which is returned get getTexCoordData(i) const and getVertexAttribData(i) const 
+          * when i is out of range.*/
+        static const ArrayData s_InvalidArrayData;
+        
+        typedef std::vector< ArrayData >  ArrayList;
+               
+
+        void setVertexArray(Array* array) { _vertexData.array = array; dirtyDisplayList(); dirtyBound();     }
+        Array* getVertexArray() { return _vertexData.array.get(); }
+        const Array* getVertexArray() const  { return _vertexData.array.get(); }
+
+        void setVertexIndices(IndexArray* array) { _vertexData.indices = array; computeFastPathsUsed(); dirtyDisplayList(); dirtyBound(); }
+        IndexArray* getVertexIndices() { return _vertexData.indices.get(); }
+        const IndexArray* getVertexIndices() const  { return _vertexData.indices.get(); }
+
+        void setVertexData(const ArrayData& arrayData) { _vertexData = arrayData; }
+        ArrayData& getVertexData() { return _vertexData; }
+        const ArrayData& getVertexData() const { return _vertexData; }
+        
+
+        void setNormalBinding(AttributeBinding ab) { _normalData.binding = ab; dirtyDisplayList(); computeFastPathsUsed(); }
+        AttributeBinding getNormalBinding() const { return _normalData.binding; }
+
+        void setNormalArray(Vec3Array* array) { _normalData.array = array; if (!_normalData.array.valid()) _normalData.binding=BIND_OFF; computeFastPathsUsed(); dirtyDisplayList(); }
+        Vec3Array* getNormalArray() { return _normalData.array.get(); }
+        const Vec3Array* getNormalArray() const { return _normalData.array.get(); }
+
+        void setNormalIndices(IndexArray* array) { _normalData.indices = array; computeFastPathsUsed(); dirtyDisplayList(); }
+        IndexArray* getNormalIndices() { return _normalData.indices.get(); }
+        const IndexArray* getNormalIndices() const { return _normalData.indices.get(); }
+
+        void setNormalData(const Vec3ArrayData& arrayData) { _normalData = arrayData; }
+        Vec3ArrayData& getNormalData() { return _normalData; }
+        const Vec3ArrayData& getNormalData() const { return _normalData; }
+
+
+
+        void setColorBinding(AttributeBinding ab) { _colorData.binding = ab; computeFastPathsUsed();}
+        AttributeBinding getColorBinding() const { return _colorData.binding; }
+
+        void setColorArray(Array* array) { _colorData.array = array;  if (!_colorData.array.valid()) _colorData.binding=BIND_OFF; computeFastPathsUsed(); dirtyDisplayList(); }
+        Array* getColorArray() { return _colorData.array.get(); }
+        const Array* getColorArray() const { return _colorData.array.get(); }
+
+        void setColorIndices(IndexArray* array) { _colorData.indices = array;  computeFastPathsUsed(); dirtyDisplayList(); }
+        IndexArray* getColorIndices() { return _colorData.indices.get(); }
+        const IndexArray* getColorIndices() const { return _colorData.indices.get(); }
+
+        void setColorData(const ArrayData& arrayData) { _colorData = arrayData; }
+        ArrayData& getColorData() { return _colorData; }
+        const ArrayData& getColorData() const { return _colorData; }
+
+
+        void setSecondaryColorBinding(AttributeBinding ab) { _secondaryColorData.binding = ab; computeFastPathsUsed();}
+        AttributeBinding getSecondaryColorBinding() const { return _secondaryColorData.binding; }
+
+        void setSecondaryColorArray(Array* array) { _secondaryColorData.array = array;  if (!_secondaryColorData.array.valid()) _secondaryColorData.binding=BIND_OFF; computeFastPathsUsed(); dirtyDisplayList(); }
+        Array* getSecondaryColorArray() { return _secondaryColorData.array.get(); }
+        const Array* getSecondaryColorArray() const { return _secondaryColorData.array.get(); }
+
+        void setSecondaryColorIndices(IndexArray* array) { _secondaryColorData.indices = array;  computeFastPathsUsed(); dirtyDisplayList(); }
+        IndexArray* getSecondaryColorIndices() { return _secondaryColorData.indices.get(); }
+        const IndexArray* getSecondaryColorIndices() const { return _secondaryColorData.indices.get(); }
+
+        void setSecondaryColorData(const ArrayData& arrayData) { _secondaryColorData = arrayData; }
+        ArrayData& getSecondaryColorData() { return _secondaryColorData; }
+        const ArrayData& getSecondaryColorData() const { return _secondaryColorData; }
+
+
+        void setFogCoordBinding(AttributeBinding ab) { _fogCoordData.binding = ab; computeFastPathsUsed();}
+        AttributeBinding getFogCoordBinding() const { return _fogCoordData.binding; }
+
+        void setFogCoordArray(Array* array) { _fogCoordData.array = array; if (!_fogCoordData.array.valid()) _fogCoordData.binding=BIND_OFF; dirtyDisplayList(); }
+        Array* getFogCoordArray() { return _fogCoordData.array.get(); }
+        const Array* getFogCoordArray() const { return _fogCoordData.array.get(); }
+
+        void setFogCoordIndices(IndexArray* array) { _fogCoordData.indices = array; dirtyDisplayList(); }
+        IndexArray* getFogCoordIndices() { return _fogCoordData.indices.get(); }
+        const IndexArray* getFogCoordIndices() const { return _fogCoordData.indices.get(); }
+
+        void setFogCoordData(const ArrayData& arrayData) { _fogCoordData = arrayData; }
+        ArrayData& getFogCoordData() { return _fogCoordData; }
+        const ArrayData& getFogCoordData() const { return _fogCoordData; }
+        
+        
+
+        void setTexCoordArray(unsigned int unit,Array*);
+        Array* getTexCoordArray(unsigned int unit);
+        const Array* getTexCoordArray(unsigned int unit) const;
+        
+        void setTexCoordIndices(unsigned int unit,IndexArray*);
+        IndexArray* getTexCoordIndices(unsigned int unit);
+        const IndexArray* getTexCoordIndices(unsigned int unit) const;
+
+        void setTexCoordData(unsigned int index,const ArrayData& arrayData);
+        ArrayData& getTexCoordData(unsigned int index);
+        const ArrayData& getTexCoordData(unsigned int index) const;
+
+        unsigned int getNumTexCoordArrays() const {  return _texCoordList.size(); }
+        ArrayList& getTexCoordArrayList() { return _texCoordList; }
+        const ArrayList& getTexCoordArrayList() const { return _texCoordList; }
+
+
+
+        void setVertexAttribArray(unsigned int index,Array* array);
+        Array *getVertexAttribArray(unsigned int index);
+        const Array *getVertexAttribArray(unsigned int index) const;
+
+        void setVertexAttribIndices(unsigned int index,IndexArray* array);
+        IndexArray* getVertexAttribIndices(unsigned int index);
+        const IndexArray* getVertexAttribIndices(unsigned int index) const;
+
+        void setVertexAttribBinding(unsigned int index,AttributeBinding ab);
+        AttributeBinding getVertexAttribBinding(unsigned int index) const;
+
+        void setVertexAttribNormalize(unsigned int index,GLboolean norm);
+        GLboolean getVertexAttribNormalize(unsigned int index) const;
+
+        void setVertexAttribData(unsigned int index,const ArrayData& arrayData);
+        ArrayData& getVertexAttribData(unsigned int index);
+        const ArrayData& getVertexAttribData(unsigned int index) const;
+
+        unsigned int getNumVertexAttribArrays() const { return _vertexAttribList.size(); }
+        ArrayList& getVertexAttribArrayList() { return _vertexAttribList; }
+        const ArrayList& getVertexAttribArrayList() const { return _vertexAttribList; }
+
+
+
+        typedef std::vector< ref_ptr<PrimitiveSet> > PrimitiveSetList;
+
+        void setPrimitiveSetList(const PrimitiveSetList& primitives) { _primitives = primitives; dirtyDisplayList(); dirtyBound(); }
+        PrimitiveSetList& getPrimitiveSetList() { return _primitives; }
+        const PrimitiveSetList& getPrimitiveSetList() const { return _primitives; }
+
+        unsigned int getNumPrimitiveSets() const { return _primitives.size(); }
+        PrimitiveSet* getPrimitiveSet(unsigned int pos) { return _primitives[pos].get(); }
+        const PrimitiveSet* getPrimitiveSet(unsigned int pos) const { return _primitives[pos].get(); }
+        
+        /** Add a primitive set to the geometry.*/
+        bool addPrimitiveSet(PrimitiveSet* primitiveset);
+        
+        /** Set a primitive set to the specified position in geometry's primitive set list.*/
+        bool setPrimitiveSet(unsigned int i,PrimitiveSet* primitiveset);
+        
+        /** Insert a primitive set to the specified position in geometry's primitive set list.*/
+        bool insertPrimitiveSet(unsigned int i,PrimitiveSet* primitiveset);
+        
+        /** Remove primitive set(s) from the specified position in geometry's primitive set list.*/
+        bool removePrimitiveSet(unsigned int i,unsigned int numElementsToRemove=1);
+
+        /** Get the index number of a primitive set, return a value between
+          * 0 and getNumPrimitiveSet()-1 if found, if not found then return getNumPrimitiveSet().
+          * When checking for a valid find value use if ((value=geoemtry->getPrimitiveSetIndex(primitive))!=geometry.getNumPrimitiveSet()) as*/
+        unsigned int getPrimitiveSetIndex(const PrimitiveSet* primitiveset) const;
+
+
+        /** Set whether fast paths should be used when supported.*/
+        void setFastPathHint(bool on) {  _fastPathHint = on; }
+
+        /** Get whether fast paths should be used when supported.*/
+        bool getFastPathHint() const { return _fastPathHint; }
+
+        /** return true if OpenGL fast paths will be used with drawing this Geometry.
+          * Fast paths use vertex arrays, and glDrawArrays/glDrawElements.  Slow paths
+          * use glBegin()/glVertex.../glEnd(). Use of per primitive bindings or per vertex indexed
+          * arrays will drop the rendering path off the fast path.*/
+        inline bool areFastPathsUsed() const { return _fastPath && _fastPathHint; }
+
+        bool computeFastPathsUsed();
+
+        bool verifyBindings() const;
+
+        void computeCorrectBindingsAndArraySizes();
+
+
+        bool suitableForOptimization() const;
+
+        void copyToAndOptimize(Geometry& target);
+
+        void computeInternalOptimizedGeometry();
+
+        void removeInternalOptimizedGeometry() { _internalOptimizedGeometry = 0; }
+
+        void setInternalOptimizedGeometry(osg::Geometry* geometry) { _internalOptimizedGeometry = geometry; }
+
+        osg::Geometry* getInternalOptimizedGeometry() { return _internalOptimizedGeometry.get(); }
+
+        const osg::Geometry* getInternalOptimizedGeometry() const { return _internalOptimizedGeometry.get(); }
+
+
+        /** draw Geometry directly ignoring an OpenGL display list which could be attached.
+          * This is the internal draw method which does the drawing itself,
+          * and is the method to override when deriving from Geometry for user-drawn objects.
+          */
+        virtual void drawImplementation(State& state) const;
+
+        /** return true, osg::Geometry does support accept(AttributeFunctor&).*/
+        virtual bool supports(AttributeFunctor&) const { return true; }
+
+        /** accept an AttributeFunctor and call its methods to tell it about the interal attributes that this Drawable has.*/
+        virtual void accept(AttributeFunctor& af);
+
+        /** return true, osg::Geometry does support accept(ConstAttributeFunctor&).*/
+        virtual bool supports(ConstAttributeFunctor&) const { return true; }
+
+        /** accept an ConstAttributeFunctor and call its methods to tell it about the interal attributes that this Drawable has.*/
+        virtual void accept(ConstAttributeFunctor& af) const;
+
+        /** return true, osg::Geometry does support accept(PrimitiveFunctor&) .*/
+        virtual bool supports(PrimitiveFunctor&) const { return true; }
+
+        /** accept a PrimitiveFunctor and call its methods to tell it about the interal primitives that this Drawable has.*/
+        virtual void accept(PrimitiveFunctor& pf) const;
+
+        /** return true, osg::Geometry does support accept(PrimitiveIndexFunctor&) .*/
+        virtual bool supports(PrimitiveIndexFunctor&) const { return true; }
+
+        /** accept a PrimitiveFunctor and call its methods to tell it about the interal primitives that this Drawable has.*/
+        virtual void accept(PrimitiveIndexFunctor& pf) const;
+
+
+    protected:
+
+        Geometry& operator = (const Geometry&) { return *this;}
+
+        virtual ~Geometry();
+       
+        bool verifyBindings(const ArrayData& arrayData) const;
+        bool verifyBindings(const Vec3ArrayData& arrayData) const;
+        
+        void computeCorrectBindingsAndArraySizes(ArrayData& arrayData,const char* arrayName);
+        void computeCorrectBindingsAndArraySizes(Vec3ArrayData& arrayData,const char* arrayName);
+        
+
+        PrimitiveSetList                _primitives;
+        ArrayData                       _vertexData;
+        Vec3ArrayData                   _normalData;
+        ArrayData                       _colorData;
+        ArrayData                       _secondaryColorData;
+        ArrayData                       _fogCoordData;
+        ArrayList                       _texCoordList;
+        ArrayList                       _vertexAttribList;
+
+        mutable bool                    _fastPath;
+        bool                            _fastPathHint;
+
+        ref_ptr<Geometry>               _internalOptimizedGeometry;
+};
+
+/** Convenience function to be used for creating quad geometry with texture coords.
+  * Tex coords go from left bottom (l,b) to right top (r,t).*/
+extern SG_EXPORT Geometry* createTexturedQuadGeometry(const Vec3& corner,const Vec3& widthVec,const Vec3& heightVec, float l, float b, float r, float t);
+
+/** Convenience function to be used for creating quad geometry with texture coords.
+  * Tex coords go from bottom left (0,0) to top right (s,t).*/
+inline Geometry* createTexturedQuadGeometry(const Vec3& corner,const Vec3& widthVec,const Vec3& heightVec, float s=1.0f, float t=1.0f)
+{
+    return createTexturedQuadGeometry(corner,widthVec,heightVec, 0.0f, 0.0f, s, t);
+}
+
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/StateSet
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/StateSet (revision 3159)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/StateSet (revision 3159)
@@ -0,0 +1,278 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_STATESET
+#define OSG_STATESET 1
+
+#include <osg/Object>
+#include <osg/StateAttribute>
+#include <osg/ref_ptr>
+
+#include <map>
+#include <vector>
+#include <string>
+
+#ifndef GL_RESCALE_NORMAL
+// allow compilation against GL1.1 headers.
+#define GL_RESCALE_NORMAL                 0x803A
+#endif
+
+namespace osg {
+
+/**
+Encapsulates OpenGL state modes and attributes. 
+Used to specific textures etc of osg::Drawable's which hold references
+to a single osg::StateSet.  StateSet can be shared between Drawable's
+and is recommend if possible as it minimize expensive state changes
+in the graphics pipeline.
+*/
+class SG_EXPORT StateSet : public Object
+{
+    public :
+    
+            
+        StateSet();
+        StateSet(const StateSet&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+        virtual Object* cloneType() const { return new StateSet(); }
+        virtual Object* clone(const CopyOp& copyop) const { return new StateSet(*this,copyop); }
+        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const StateSet*>(obj)!=NULL; }
+        virtual const char* libraryName() const { return "osg"; }
+        virtual const char* className() const { return "StateSet"; }
+
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        int compare(const StateSet& rhs,bool compareAttributeContents=false) const;
+        
+        bool operator <  (const StateSet& rhs) const { return compare(rhs)<0; }
+        bool operator == (const StateSet& rhs) const { return compare(rhs)==0; }
+        bool operator != (const StateSet& rhs) const { return compare(rhs)!=0; }
+
+        /** set all the modes to on or off so that it defines a 
+            complete state, typically used for a default global state.*/
+        void setGlobalDefaults();
+
+        /** set all the modes to inherit, typically used to signify
+            nodes which inherit all of their modes for the global state.*/
+        void setAllToInherit();
+        
+       /** merge this stateset with stateset rhs, this overrides
+          * the rhs if OVERRIDE is specified, otherwise rhs takes precedence.*/
+        void merge(const StateSet& rhs);
+
+        /** a container to map GLModes to their respective GLModeValues.*/
+        typedef std::map<StateAttribute::GLMode,StateAttribute::GLModeValue>  ModeList;
+
+        /** set this StateSet to contain specified GLMode and value.*/
+        void setMode(StateAttribute::GLMode mode, StateAttribute::GLModeValue value);
+        
+        /** set this StateSet to inherit specified GLMode type from parents.
+          * has the effect of deleting any GlMode of specified type from StateSet.*/
+        void setModeToInherit(StateAttribute::GLMode mode);
+
+        /** get specified GLModeValue for specified GLMode.
+          * returns INHERIT if no GLModeValue is contained within StateSet.*/
+        StateAttribute::GLModeValue getMode(StateAttribute::GLMode mode) const;
+
+        /** return the list of all GLModes contained in this StateSet.*/
+        inline ModeList& getModeList() { return _modeList; }
+
+        /** return the const list of all GLModes contained in this const StateSet.*/
+        inline const ModeList& getModeList() const { return _modeList; }
+
+
+
+        /** simple pairing between an attribute and its override flag.*/
+        typedef std::pair<ref_ptr<StateAttribute>,StateAttribute::OverrideValue> RefAttributePair;
+        /** a container to map StateAttribyte::Types to their respective RefAttributePair.*/
+        typedef std::map<StateAttribute::Type,RefAttributePair>                  AttributeList;
+
+        /** set this StateSet to contain specified attribute and override flag.*/
+        void setAttribute(StateAttribute *attribute, StateAttribute::OverrideValue value=StateAttribute::OFF);
+        /** set this StateSet to contain specified attribute and set the associated GLMode's to specified value.*/
+        void setAttributeAndModes(StateAttribute *attribute, StateAttribute::GLModeValue value=StateAttribute::ON);
+        /** set this StateSet to inherit specified attribute type from parents.
+          * has the effect of deleting any state attributes of specified type from StateSet.*/
+        void setAttributeToInherit(StateAttribute::Type type);
+
+        /** get specified StateAttribute for specified type.
+          * returns NULL if no type is contained within StateSet.*/
+        StateAttribute* getAttribute(StateAttribute::Type type);
+
+        /** get specified const StateAttribute for specified type.
+          * returns NULL if no type is contained within const StateSet.*/
+        const StateAttribute* getAttribute(StateAttribute::Type type) const;
+
+        /** get specified RefAttributePair for specified type.
+          * returns NULL if no type is contained within StateSet.*/
+        const RefAttributePair* getAttributePair(StateAttribute::Type type) const;
+        
+        /** return the list of all StateAttributes contained in this StateSet.*/
+        inline AttributeList& getAttributeList() { return _attributeList; }
+
+        /** return the const list of all StateAttributes contained in this const StateSet.*/
+        inline const AttributeList& getAttributeList() const { return _attributeList; }
+
+
+
+        typedef std::vector<ModeList>       TextureModeList;
+
+        /** set this StateSet to contain specified GLMode and value.*/
+        void setTextureMode(unsigned int unit,StateAttribute::GLMode mode, StateAttribute::GLModeValue value);
+        /** set this StateSet to inherit specified GLMode type from parents.
+          * has the effect of deleting any GlMode of specified type from StateSet.*/
+        void setTextureModeToInherit(unsigned int unit,StateAttribute::GLMode mode);
+
+        /** get specified GLModeValue for specified GLMode.
+          * returns INHERIT if no GLModeValue is contained within StateSet.*/
+        StateAttribute::GLModeValue getTextureMode(unsigned int unit,StateAttribute::GLMode mode) const;
+
+        /** return the list of all Texture related GLModes contained in this StateSet.*/
+        inline TextureModeList& getTextureModeList() { return _textureModeList; }
+
+        /** return the const list of all Texture related GLModes contained in this const StateSet.*/
+        inline const TextureModeList& getTextureModeList() const  { return _textureModeList; }
+
+
+        typedef std::vector<AttributeList>  TextureAttributeList;
+
+        /** set this StateSet to contain specified attribute and override flag.*/
+        void setTextureAttribute(unsigned int unit,StateAttribute *attribute, StateAttribute::OverrideValue value=StateAttribute::OFF);
+        /** set this StateSet to contain specified attribute and set the associated GLMode's to specified value.*/
+        void setTextureAttributeAndModes(unsigned int unit,StateAttribute *attribute, StateAttribute::GLModeValue value=StateAttribute::ON);
+        /** set this StateSet to inherit specified attribute type from parents.
+          * has the effect of deleting any state attributes of specified type from StateSet.*/
+        void setTextureAttributeToInherit(unsigned int unit,StateAttribute::Type type);
+
+        /** get specified Texture related StateAttribute for specified type.
+          * returns NULL if no type is contained within StateSet.*/
+        StateAttribute* getTextureAttribute(unsigned int unit,StateAttribute::Type type);
+
+        /** get specified Texture related const StateAttribute for specified type.
+          * returns NULL if no type is contained within const StateSet.*/
+        const StateAttribute* getTextureAttribute(unsigned int unit,StateAttribute::Type type) const;
+
+        /** get specified Texture related RefAttributePair for specified type.
+          * returns NULL if no type is contained within StateSet.*/
+        const RefAttributePair* getTextureAttributePair(unsigned int unit,StateAttribute::Type type) const;
+        
+        /** return the list of all Texture related StateAttributes contained in this StateSet.*/
+        inline TextureAttributeList& getTextureAttributeList() { return _textureAttributeList; }
+
+        /** return the const list of all Texture related StateAttributes contained in this const StateSet.*/
+        inline const TextureAttributeList& getTextureAttributeList() const { return _textureAttributeList; }
+
+
+        void setAssociatedModes(const StateAttribute* attribute, StateAttribute::GLModeValue value);
+        
+        void setAssociatedTextureModes(unsigned int unit,const StateAttribute* attribute, StateAttribute::GLModeValue value);
+
+        enum RenderingHint
+        {
+            DEFAULT_BIN = 0,
+            OPAQUE_BIN = 1,
+            TRANSPARENT_BIN = 2
+        };
+        
+        /** set the RenderingHint of the StateSet.
+          * RenderingHint is used by osgUtil::Renderer to determine which
+          * draw bin to drop associated osg::Drawables in. For opaque
+          * objects OPAQUE_BIN would typical used, which TRANSPARENT_BIN
+          * should be used for objects which need to be depth sorted.*/
+        void setRenderingHint(int hint);
+
+        /** get the RenderingHint of the StateSet.*/
+        inline int getRenderingHint() const      { return _renderingHint; }
+
+        enum RenderBinMode
+        {
+            INHERIT_RENDERBIN_DETAILS,
+            USE_RENDERBIN_DETAILS,
+            OVERRIDE_RENDERBIN_DETAILS,
+            ENCLOSE_RENDERBIN_DETAILS
+        };
+
+        /** set the render bin details.*/
+        void setRenderBinDetails(int binNum,const std::string& binName,RenderBinMode mode=USE_RENDERBIN_DETAILS);
+                
+        /** set the render bin details to inherit.*/
+        void setRenderBinToInherit();
+        
+        /** get the render bin mode.*/
+        inline RenderBinMode getRenderBinMode() const { return _binMode; }
+
+        /** get whether the render bin details are set and should be used.*/
+        inline bool useRenderBinDetails() const { return _binMode!=INHERIT_RENDERBIN_DETAILS; }
+
+        /** get the render bin number.*/
+        inline int getBinNumber() const { return _binNum; }
+
+        /** get the render bin name.*/
+        inline const std::string& getBinName() const { return _binName; }
+
+        
+        /** call compile on all StateAttributes contained within this StateSet.*/
+        void compileGLObjects(State& state) const;
+
+        /** call release on all StateAttributes contained within this StateSet.*/
+        virtual void releaseGLObjects(State* state=0) const;
+
+    protected :
+
+
+        virtual ~StateSet();
+
+        StateSet& operator = (const StateSet&) { return *this; }
+        
+        ModeList                            _modeList;
+        AttributeList                       _attributeList;
+
+        TextureModeList                     _textureModeList;
+        TextureAttributeList                _textureAttributeList;
+        
+        inline ModeList& getOrCreateTextureModeList(unsigned int unit)
+        {
+            if (unit>=_textureModeList.size()) _textureModeList.resize(unit+1);
+            return _textureModeList[unit];
+        }
+        
+        inline AttributeList& getOrCreateTextureAttributeList(unsigned int unit)
+        {
+            if (unit>=_textureAttributeList.size()) _textureAttributeList.resize(unit+1);
+            return _textureAttributeList[unit];
+        }
+        
+        int compareModes(const ModeList& lhs,const ModeList& rhs);
+        int compareAttributePtrs(const AttributeList& lhs,const AttributeList& rhs);
+        int compareAttributeContents(const AttributeList& lhs,const AttributeList& rhs);
+
+        void setMode(ModeList& modeList,StateAttribute::GLMode mode, StateAttribute::GLModeValue value);
+        void setModeToInherit(ModeList& modeList,StateAttribute::GLMode mode);
+        StateAttribute::GLModeValue getMode(const ModeList& modeList,StateAttribute::GLMode mode) const;
+
+        void setAttribute(AttributeList& attributeList,StateAttribute *attribute, const StateAttribute::OverrideValue value=StateAttribute::OFF);
+
+        StateAttribute* getAttribute(AttributeList& attributeList,const StateAttribute::Type type);
+        const StateAttribute* getAttribute(const AttributeList& attributeList,const StateAttribute::Type type) const;
+        const RefAttributePair* getAttributePair(const AttributeList& attributeList,const StateAttribute::Type type) const;
+
+        int                                 _renderingHint;
+
+        RenderBinMode                       _binMode;
+        int                                 _binNum;
+        std::string                         _binName;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/AnimationPath
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/AnimationPath (revision 3230)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/AnimationPath (revision 3230)
@@ -0,0 +1,279 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_ANIMATIONPATH
+#define OSG_ANIMATIONPATH 1
+
+#include <map>
+#include <istream>
+#include <float.h>
+
+#include <osg/Matrixf>
+#include <osg/Matrixd>
+#include <osg/Quat>
+#include <osg/NodeCallback>
+
+namespace osg {
+
+/** AnimationPath for specify the time varying transformation pathway to use when update camera and model objects.
+  * Subclassed from Transform::ComputeTransformCallback allows AnimationPath to
+  * be attached directly to Transform nodes to move subgraphs around the scene.
+*/
+class SG_EXPORT AnimationPath : public virtual osg::Object
+{
+    public:
+    
+        AnimationPath():_loopMode(LOOP) {}
+
+        AnimationPath(const AnimationPath& ap, const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            Object(ap,copyop),
+            _timeControlPointMap(ap._timeControlPointMap),
+            _loopMode(ap._loopMode) {}
+
+        META_Object(osg,AnimationPath);
+
+        struct ControlPoint
+        {
+            ControlPoint():
+                _scale(1.0f,1.0f,1.0f) {}
+
+            ControlPoint(const osg::Vec3d& position):
+                _position(position),
+                _rotation(),
+                _scale(1.0f,1.0f,1.0f) {}
+
+            ControlPoint(const osg::Vec3d& position, const osg::Quat& rotation):
+                _position(position),
+                _rotation(rotation),
+                _scale(1.0f,1.0f,1.0f) {}
+
+            ControlPoint(const osg::Vec3d& position, const osg::Quat& rotation, const osg::Vec3d& scale):
+                _position(position),
+                _rotation(rotation),
+                _scale(scale) {}
+        
+            osg::Vec3d _position;
+            osg::Quat _rotation;
+            osg::Vec3d _scale;
+
+
+            inline void interpolate(float ratio,const ControlPoint& first, const ControlPoint& second)
+            {
+                float one_minus_ratio = 1.0f-ratio;
+                _position = first._position*one_minus_ratio + second._position*ratio;
+                _rotation.slerp(ratio,first._rotation,second._rotation);
+                _scale = first._scale*one_minus_ratio + second._scale*ratio;
+            }
+            
+            inline void getMatrix(Matrixf& matrix) const
+            {
+                matrix.makeScale(_scale);
+                matrix.postMult(osg::Matrixf::rotate(_rotation));
+                matrix.postMult(osg::Matrixf::translate(_position));
+            }
+
+            inline void getMatrix(Matrixd& matrix) const
+            {
+                matrix.makeScale(_scale);
+                matrix.postMult(osg::Matrixd::rotate(_rotation));
+                matrix.postMult(osg::Matrixd::translate(_position));
+            }
+
+            inline void getInverse(Matrixf& matrix) const
+            {
+                matrix.makeScale(1.0f/_scale.x(),1.0f/_scale.y(),1.0f/_scale.y());
+                matrix.preMult(osg::Matrixf::rotate(_rotation.inverse()));
+                matrix.preMult(osg::Matrixf::translate(-_position));
+            }
+
+            inline void getInverse(Matrixd& matrix) const
+            {
+                matrix.makeScale(1.0f/_scale.x(),1.0f/_scale.y(),1.0f/_scale.y());
+                matrix.preMult(osg::Matrixd::rotate(_rotation.inverse()));
+                matrix.preMult(osg::Matrixd::translate(-_position));
+            }
+        };
+        
+
+        /** get the transformation matrix for a point in time.*/        
+        bool getMatrix(double time,Matrixf& matrix) const
+        {
+            ControlPoint cp;
+            if (!getInterpolatedControlPoint(time,cp)) return false;
+            cp.getMatrix(matrix);
+            return true;
+        }
+
+        /** get the transformation matrix for a point in time.*/        
+        bool getMatrix(double time,Matrixd& matrix) const
+        {
+            ControlPoint cp;
+            if (!getInterpolatedControlPoint(time,cp)) return false;
+            cp.getMatrix(matrix);
+            return true;
+        }
+
+        /** get the inverse transformation matrix for a point in time.*/        
+        bool getInverse(double time,Matrixf& matrix) const
+        {
+            ControlPoint cp;
+            if (!getInterpolatedControlPoint(time,cp)) return false;
+            cp.getInverse(matrix);
+            return true;
+        }
+        
+        bool getInverse(double time,Matrixd& matrix) const
+        {
+            ControlPoint cp;
+            if (!getInterpolatedControlPoint(time,cp)) return false;
+            cp.getInverse(matrix);
+            return true;
+        }
+
+        /** get the local ControlPoint frame for a point in time.*/
+        virtual bool getInterpolatedControlPoint(double time,ControlPoint& controlPoint) const;
+        
+        void insert(double time,const ControlPoint& controlPoint);
+        
+        double getFirstTime() const { if (!_timeControlPointMap.empty()) return _timeControlPointMap.begin()->first; else return 0.0;}
+        double getLastTime() const { if (!_timeControlPointMap.empty()) return _timeControlPointMap.rbegin()->first; else return 0.0;}
+        double getPeriod() const { return getLastTime()-getFirstTime();}
+        
+        enum LoopMode
+        {
+            SWING,
+            LOOP,
+            NO_LOOPING
+        };
+        
+        void setLoopMode(LoopMode lm) { _loopMode = lm; }
+        
+        LoopMode getLoopMode() const { return _loopMode; }
+
+
+        typedef std::map<double,ControlPoint> TimeControlPointMap;
+        
+        TimeControlPointMap& getTimeControlPointMap() { return _timeControlPointMap; }
+        
+        const TimeControlPointMap& getTimeControlPointMap() const { return _timeControlPointMap; }
+        
+        bool empty() const { return _timeControlPointMap.empty(); }
+
+        /** read the anumation path from a flat ascii file stream.*/
+        void read(std::istream& in);
+
+        /** write the anumation path to a flat ascii file stream.*/
+        void write(std::ostream& out) const;
+
+    protected:
+    
+        virtual ~AnimationPath() {}
+
+        TimeControlPointMap _timeControlPointMap;
+        LoopMode            _loopMode;
+
+};
+
+
+class SG_EXPORT AnimationPathCallback : public NodeCallback
+{
+    public:
+
+        AnimationPathCallback():
+            _pivotPoint(0.0f,0.0f,0.0f),
+            _useInverseMatrix(false),
+            _timeOffset(0.0),
+            _timeMultiplier(1.0),
+            _firstTime(DBL_MAX),
+            _latestTime(0.0),
+            _pause(false),
+            _pauseTime(0.0) {}
+
+        AnimationPathCallback(const AnimationPathCallback& apc,const CopyOp& copyop):
+            NodeCallback(apc,copyop),
+            _animationPath(apc._animationPath),
+            _pivotPoint(apc._pivotPoint),
+            _useInverseMatrix(apc._useInverseMatrix),
+            _timeOffset(apc._timeOffset),
+            _timeMultiplier(apc._timeMultiplier),
+            _firstTime(apc._firstTime),
+            _latestTime(apc._latestTime),
+            _pause(apc._pause),
+            _pauseTime(apc._pauseTime) {}
+
+        
+        META_Object(osg,AnimationPathCallback);
+
+        AnimationPathCallback(AnimationPath* ap,double timeOffset=0.0f,double timeMultiplier=1.0f):
+            _animationPath(ap),
+            _pivotPoint(0.0f,0.0f,0.0f),
+            _useInverseMatrix(false),
+            _timeOffset(timeOffset),
+            _timeMultiplier(timeMultiplier),
+            _firstTime(DBL_MAX),
+            _latestTime(0.0),
+            _pause(false),
+            _pauseTime(0.0) {}
+
+            
+        void setAnimationPath(AnimationPath* path) { _animationPath = path; }
+        AnimationPath* getAnimationPath() { return _animationPath.get(); }
+        const AnimationPath* getAnimationPath() const { return _animationPath.get(); }
+
+        inline void setPivotPoint(const Vec3d& pivot) { _pivotPoint = pivot; }
+        inline const Vec3d& getPivotPoint() const { return _pivotPoint; }
+
+        void setUseInverseMatrix(bool useInverseMatrix) { _useInverseMatrix = useInverseMatrix; }
+        bool getUseInverseMatrix() const { return _useInverseMatrix; }
+
+        void setTimeOffset(double offset) { _timeOffset = offset; }
+        double getTimeOffset() const { return _timeOffset; }
+        
+        void setTimeMultiplier(double multiplier) { _timeMultiplier = multiplier; }
+        double getTimeMultiplier() const { return _timeMultiplier; }
+
+
+        void reset();
+
+        void setPause(bool pause);
+
+        /** get the animation time that is used to specify the position along the AnimationPath.
+          * Animation time is computed from the formula ((_latestTime-_firstTime)-_timeOffset)*_timeMultiplier.*/
+        double getAnimationTime() const;
+
+        /** implements the callback*/
+        virtual void operator()(Node* node, NodeVisitor* nv);
+        
+        void update(osg::Node& node);
+
+    public:
+
+        ref_ptr<AnimationPath>  _animationPath;
+        osg::Vec3d              _pivotPoint;
+        bool                    _useInverseMatrix;
+        double                  _timeOffset;
+        double                  _timeMultiplier;
+        double                  _firstTime;
+        double                  _latestTime;
+        bool                    _pause;
+        double                  _pauseTime;
+
+    protected:
+    
+        ~AnimationPathCallback(){}
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Group
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Group (revision 2607)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Group (revision 2607)
@@ -0,0 +1,137 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_GROUP
+#define OSG_GROUP 1
+
+#include <osg/Node>
+#include <osg/NodeVisitor>
+
+namespace osg {
+
+typedef std::vector< ref_ptr<Node> > NodeList;
+
+/** General group node which maintains a list of children.
+    Children are reference counted. This allows children to be shared
+    with memory management handled automatically via osg::Referenced.
+*/
+class SG_EXPORT Group : public Node
+{
+    public :
+
+
+        Group();
+        
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        Group(const Group&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+        META_Node(osg, Group);
+
+        virtual Group* asGroup() { return this; }
+        virtual const Group* asGroup() const { return this; }
+
+        virtual void traverse(NodeVisitor& nv);
+
+        /** Add Node to Group.
+         *  If node is not NULL and is not contained in Group then increment its  
+         *  reference count, add it to the child list and dirty the bounding 
+         *  sphere to force it to recompute on next getBound() and return true for success.
+         *  Otherwise return false. Scene nodes can't be added as child nodes.
+         */
+        virtual bool addChild( Node *child );
+
+        /** Insert Node to Group at specific location.
+         *  The new child node is inserted into the child list
+         *  before the node at the specified index.  No nodes
+         *  are removed from the group with this operation. 
+         */
+        virtual bool insertChild( unsigned int index, Node *child );
+
+        /** Remove Node from Group.
+         *  If Node is contained in Group then remove it from the child
+         *  list, decrement its reference count, and dirty the 
+         *  bounding sphere to force it to recompute on next getBound() and
+         *  return true for success.  If Node is not found then return false
+         *  and do not change the reference count of the Node.
+         */
+        virtual bool removeChild( Node *child );
+
+        virtual bool removeChild(unsigned int pos,unsigned int numChildrenToRemove=1);
+
+        /** Replace specified Node with another Node.
+          * Equivalent to setChild(getChildIndex(orignChild),node), 
+          * see docs for setChild for futher details on implementation.*/
+        virtual bool replaceChild( Node *origChild, Node* newChild );
+
+        /** return the number of chilren nodes.*/
+        inline unsigned int getNumChildren() const { return _children.size(); }
+
+        /** set child node at position i.
+         *  return true if set correctly, false on failure (if node==NULL || i is out of range).
+         *  When set can be successful applied, the algorithm is : decrement the reference count origNode and increments the
+         *  reference count of newNode, and dirty the bounding sphere
+         *  to force it to recompute on next getBound() and returns true.
+         *  If origNode is not found then return false and do not 
+         *  add newNode.  If newNode is NULL then return false and do
+         *  not remove origNode. Also returns false if newChild is a Scene node.
+         */
+        virtual bool setChild( unsigned  int i, Node* node );
+
+        /** return child node at position i.*/
+        inline Node* getChild( unsigned  int i ) { return _children[i].get(); }
+
+        /** return child node at position i.*/
+        inline const Node* getChild( unsigned  int i ) const { return _children[i].get(); }
+
+        /** return true if node is contained within Group.*/
+        inline bool containsNode( const Node* node ) const
+        {
+            
+            for (NodeList::const_iterator itr=_children.begin();
+                 itr!=_children.end();
+                 ++itr)
+            {
+                if (itr->get()==node) return true;
+            }
+            return false;
+        }
+
+        /** Get the index number of child, return a value between
+          * 0 and _children.size()-1 if found, if not found then
+          * return _children.size().*/
+        inline unsigned int getChildIndex( const Node* node ) const
+        {
+            for (unsigned int childNum=0;childNum<_children.size();++childNum)
+            {
+                if (_children[childNum]==node) return childNum;
+            }
+            return _children.size(); // node not found.
+        }
+
+    protected:
+
+        virtual ~Group();
+
+        virtual bool computeBound() const;
+        
+        virtual void childRemoved(unsigned int /*pos*/, unsigned int /*numChildrenToRemove*/) {}
+        virtual void childInserted(unsigned int /*pos*/) {}
+
+        NodeList _children;
+
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TextureCubeMap
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TextureCubeMap (revision 3190)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TextureCubeMap (revision 3190)
@@ -0,0 +1,179 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_TEXTURECUBEMAP
+#define OSG_TEXTURECUBEMAP 1
+
+#include <osg/Texture>
+
+#ifndef GL_TEXTURE_CUBE_MAP
+#define GL_TEXTURE_CUBE_MAP 0x8513
+#endif
+
+namespace osg {
+
+/** TextureCubeMap state class which encapsulates OpenGl texture cubemap functionality.*/
+class SG_EXPORT TextureCubeMap : public Texture
+{
+
+    public :
+        
+        TextureCubeMap();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        TextureCubeMap(const TextureCubeMap& cm,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+        META_StateAttribute(osg, TextureCubeMap,TEXTURE);
+        
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const StateAttribute& rhs) const;
+
+        virtual bool getModeUsage(ModeUsage& usage) const
+        {
+            usage.usesTextureMode(GL_TEXTURE_CUBE_MAP);
+            return true;
+        }
+
+        enum Face {
+            POSITIVE_X=0,
+            NEGATIVE_X=1,
+            POSITIVE_Y=2,
+            NEGATIVE_Y=3,
+            POSITIVE_Z=4,
+            NEGATIVE_Z=5
+        };
+
+        /** Set the texture image for specified face. */
+        virtual void setImage(unsigned int face, Image* image);
+
+        /** Get the texture image for specified face. */
+        virtual Image* getImage(unsigned int face);
+
+        /** Get the const texture image for specified face. */
+        virtual const Image* getImage(unsigned int face) const;
+
+        /** Get the number of images that can be assigned to the Texture. */
+        virtual unsigned int getNumImages() const { return 6; }
+
+        inline unsigned int& getModifiedTag(unsigned int face,unsigned int contextID) const
+        {
+            // get the modified tag for the current contextID.
+            return _modifiedTag[face][contextID];
+        }
+
+        /** Set the texture width and height. If width or height are zero then
+          * the repsective size value is calculated from the source image sizes. */
+        inline void setTextureSize(int width, int height) const
+        {
+            _textureWidth = width;
+            _textureHeight = height;
+        }
+
+        /** Get the texture subload width. */
+        inline void getTextureSize(int& width, int& height) const
+        {
+            width = _textureWidth;
+            height = _textureHeight;
+        }
+
+
+        class SG_EXPORT SubloadCallback : public Referenced
+        {
+            public:
+                virtual void load(const TextureCubeMap& texture,State& state) const = 0;
+                virtual void subload(const TextureCubeMap& texture,State& state) const = 0;
+        };
+        
+        void setSubloadCallback(SubloadCallback* cb) { _subloadCallback = cb;; }
+        
+        SubloadCallback* getSubloadCallback() { return _subloadCallback.get(); }
+
+        const SubloadCallback* getSubloadCallback() const { return _subloadCallback.get(); }
+
+
+        /** Set the number of mip map levels the the texture has been created with,
+            should only be called within an osg::Texuture::apply() and custom OpenGL texture load.*/
+        void setNumMipmapLevels(unsigned int num) const { _numMipmapLevels=num; }
+
+        /** Get the number of mip map levels the the texture has been created with.*/
+        unsigned int getNumMipmapLevels() const { return _numMipmapLevels; }        
+
+        /** On first apply (unless already compiled), create the minmapped 
+          * texture and bind it, subsequent apply will simple bind to texture.*/
+        virtual void apply(State& state) const;
+        
+
+        /** Extensions class which encapsulates the querring of extensions and
+          * associated function pointers, and provide convinience wrappers to 
+          * check for the extensions or use the associated functions.*/        
+        class SG_EXPORT Extensions : public osg::Referenced
+        {
+            public:
+                Extensions();
+
+                Extensions(const Extensions& rhs);
+                
+                void lowestCommonDenominator(const Extensions& rhs);
+                
+                void setupGLExtenions();
+
+                void setCubeMapSupported(bool flag) { _isCubeMapSupported=flag; }
+                bool isCubeMapSupported() const { return _isCubeMapSupported; }
+
+            protected:
+
+                ~Extensions() {}
+                
+                bool    _isCubeMapSupported;
+
+        };
+        
+        /** Function to call to get the extension of a specified context.
+          * If the Exentsion object for that context has not yet been created then 
+          * and the 'createIfNotInitalized' flag been set to false then returns NULL.
+          * If 'createIfNotInitalized' is true then the Extensions object is 
+          * automatically created.  However, in this case the extension object 
+          * only be created with the graphics context associated with ContextID..*/
+        static Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized);
+
+        /** setExtensions allows users to override the extensions across graphics contexts.
+          * typically used when you have different extensions supported across graphics pipes
+          * but need to ensure that they all use the same low common denominator extensions.*/
+        static void setExtensions(unsigned int contextID,Extensions* extensions);
+
+
+    protected :
+
+        virtual ~TextureCubeMap();
+        
+        bool imagesValid() const;
+        
+        virtual void computeInternalFormat() const;
+
+        ref_ptr<Image> _images[6];
+
+        // subloaded images can have different texture and image sizes.
+        mutable GLsizei _textureWidth, _textureHeight;
+        
+        // number of mip map levels the the texture has been created with,        
+        mutable GLsizei _numMipmapLevels;
+
+        ref_ptr<SubloadCallback> _subloadCallback;
+
+        typedef buffered_value<unsigned int> ImageModifiedTag;
+        mutable ImageModifiedTag _modifiedTag[6];
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TriangleIndexFunctor
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TriangleIndexFunctor (revision 3208)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TriangleIndexFunctor (revision 3208)
@@ -0,0 +1,329 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_TRIANGLINDEXEFUNCTOR
+#define OSG_TRIANGLINDEXEFUNCTOR 1
+
+#include <osg/Drawable>
+#include <osg/Notify>
+
+namespace osg {
+
+template<class T>
+class TriangleIndexFunctor : public Drawable::PrimitiveIndexFunctor, public T
+{
+public:
+
+
+    virtual void setVertexArray(unsigned int,const Vec2*) 
+    {
+    }
+
+    virtual void setVertexArray(unsigned int ,const Vec3* )
+    {
+    }
+
+    virtual void setVertexArray(unsigned int,const Vec4* ) 
+    {
+    }
+
+    virtual void begin(GLenum mode)
+    {
+        _modeCache = mode;
+        _indexCache.clear();
+    }
+
+    virtual void vertex(unsigned int vert)
+    {
+        _indexCache.push_back(vert);
+    }
+
+    virtual void end()
+    {
+        if (!_indexCache.empty())
+        {
+            drawElements(_modeCache,_indexCache.size(),&_indexCache.front());
+        }
+    }
+
+    virtual void drawArrays(GLenum mode,GLint first,GLsizei count)
+    {
+        switch(mode)
+        {
+            case(GL_TRIANGLES):
+            {
+                unsigned int pos=first;
+                for(GLsizei i=2;i<count;i+=3,pos+=3)
+                {
+                    this->operator()(pos,pos+1,pos+2);
+                }
+                break;
+            }
+            case(GL_TRIANGLE_STRIP):
+             {
+                unsigned int pos=first;
+                for(GLsizei i=2;i<count;++i,++pos)
+                {
+		    if ((i%2)) this->operator()(pos,pos+2,pos+1);
+		    else       this->operator()(pos,pos+1,pos+2);
+                }
+                break;
+            }
+            case(GL_QUADS):
+            {
+                unsigned int pos=first;
+                for(GLsizei i=3;i<count;i+=4,pos+=4)
+                {
+                    this->operator()(pos,pos+1,pos+2);
+                    this->operator()(pos,pos+2,pos+3);
+                }
+                break;
+            }
+            case(GL_QUAD_STRIP):
+            {
+                unsigned int pos=first;
+                for(GLsizei i=3;i<count;i+=2,pos+=2)
+                {
+                    this->operator()(pos,pos+1,pos+2);
+                    this->operator()(pos+1,pos+3,pos+2);
+                }
+                break;
+            }
+            case(GL_POLYGON): // treat polygons as GL_TRIANGLE_FAN
+            case(GL_TRIANGLE_FAN):
+            {
+                unsigned int pos=first+1;
+                for(GLsizei i=2;i<count;++i,++pos)
+                {
+                    this->operator()(first,pos,pos+1);
+                }
+                break;
+            }
+            case(GL_POINTS):
+            case(GL_LINES):
+            case(GL_LINE_STRIP):
+            case(GL_LINE_LOOP):
+            default:
+                // can't be converted into to triangles.
+                break;
+        }
+    }
+    
+    virtual void drawElements(GLenum mode,GLsizei count,const GLubyte* indices)
+    {
+        if (indices==0 || count==0) return;
+
+        typedef const GLubyte* IndexPointer;
+    
+        switch(mode)
+        {
+            case(GL_TRIANGLES):
+            {
+                IndexPointer ilast = &indices[count];
+                for(IndexPointer  iptr=indices;iptr<ilast;iptr+=3)
+                    this->operator()(*iptr,*(iptr+1),*(iptr+2));
+                break;
+            }
+            case(GL_TRIANGLE_STRIP):
+            {
+                IndexPointer iptr = indices;
+                for(GLsizei i=2;i<count;++i,++iptr)
+                {
+		    if ((i%2)) this->operator()(*(iptr),*(iptr+2),*(iptr+1));
+		    else       this->operator()(*(iptr),*(iptr+1),*(iptr+2));
+                }
+                break;
+            }
+            case(GL_QUADS):
+            {
+                IndexPointer iptr = indices;
+                for(GLsizei i=3;i<count;i+=4,iptr+=4)
+                {
+                    this->operator()(*(iptr),*(iptr+1),*(iptr+2));
+                    this->operator()(*(iptr),*(iptr+2),*(iptr+3));
+                }
+                break;
+            }
+            case(GL_QUAD_STRIP):
+            {
+                IndexPointer iptr = indices;
+                for(GLsizei i=3;i<count;i+=2,iptr+=2)
+                {
+                    this->operator()(*(iptr),*(iptr+1),*(iptr+2));
+                    this->operator()(*(iptr+1),*(iptr+3),*(iptr+2));
+                }
+                break;
+            }
+            case(GL_POLYGON): // treat polygons as GL_TRIANGLE_FAN
+            case(GL_TRIANGLE_FAN):
+            {
+                IndexPointer iptr = indices;
+                unsigned int first = *iptr;
+                ++iptr;
+                for(GLsizei i=2;i<count;++i,++iptr)
+                {
+                    this->operator()(first,*(iptr),*(iptr+1));
+                }
+                break;
+            }
+            case(GL_POINTS):
+            case(GL_LINES):
+            case(GL_LINE_STRIP):
+            case(GL_LINE_LOOP):
+            default:
+                // can't be converted into to triangles.
+                break;
+        }
+    }    
+
+    virtual void drawElements(GLenum mode,GLsizei count,const GLushort* indices)
+    {
+        if (indices==0 || count==0) return;
+
+        typedef const GLushort* IndexPointer;
+    
+        switch(mode)
+        {
+            case(GL_TRIANGLES):
+            {
+                IndexPointer ilast = &indices[count];
+                for(IndexPointer  iptr=indices;iptr<ilast;iptr+=3)
+                    this->operator()(*iptr,*(iptr+1),*(iptr+2));
+                break;
+            }
+            case(GL_TRIANGLE_STRIP):
+            {
+                IndexPointer iptr = indices;
+                for(GLsizei i=2;i<count;++i,++iptr)
+                {
+		    if ((i%2)) this->operator()(*(iptr),*(iptr+2),*(iptr+1));
+		    else       this->operator()(*(iptr),*(iptr+1),*(iptr+2));
+                }
+                break;
+            }
+            case(GL_QUADS):
+            {
+                IndexPointer iptr = indices;
+                for(GLsizei i=3;i<count;i+=4,iptr+=4)
+                {
+                    this->operator()(*(iptr),*(iptr+1),*(iptr+2));
+                    this->operator()(*(iptr),*(iptr+2),*(iptr+3));
+                }
+                break;
+            }
+            case(GL_QUAD_STRIP):
+            {
+                IndexPointer iptr = indices;
+                for(GLsizei i=3;i<count;i+=2,iptr+=2)
+                {
+                    this->operator()(*(iptr),*(iptr+1),*(iptr+2));
+                    this->operator()(*(iptr+1),*(iptr+3),*(iptr+2));
+                }
+                break;
+            }
+            case(GL_POLYGON): // treat polygons as GL_TRIANGLE_FAN
+            case(GL_TRIANGLE_FAN):
+            {
+                IndexPointer iptr = indices;
+                unsigned int first = *iptr;
+                ++iptr;
+                for(GLsizei i=2;i<count;++i,++iptr)
+                {
+                    this->operator()(first,*(iptr),*(iptr+1));
+                }
+                break;
+            }
+            case(GL_POINTS):
+            case(GL_LINES):
+            case(GL_LINE_STRIP):
+            case(GL_LINE_LOOP):
+            default:
+                // can't be converted into to triangles.
+                break;
+        }
+    }    
+
+    virtual void drawElements(GLenum mode,GLsizei count,const GLuint* indices)
+    {
+        if (indices==0 || count==0) return;
+    
+        typedef const GLuint* IndexPointer;
+    
+        switch(mode)
+        {
+            case(GL_TRIANGLES):
+            {
+                IndexPointer ilast = &indices[count];
+                for(IndexPointer  iptr=indices;iptr<ilast;iptr+=3)
+                    this->operator()(*iptr,*(iptr+1),*(iptr+2));
+                break;
+            }
+            case(GL_TRIANGLE_STRIP):
+            {
+                IndexPointer iptr = indices;
+                for(GLsizei i=2;i<count;++i,++iptr)
+                {
+		    if ((i%2)) this->operator()(*(iptr),*(iptr+2),*(iptr+1));
+		    else       this->operator()(*(iptr),*(iptr+1),*(iptr+2));
+                }
+                break;
+            }
+            case(GL_QUADS):
+            {
+                IndexPointer iptr = indices;
+                for(GLsizei i=3;i<count;i+=4,iptr+=4)
+                {
+                    this->operator()(*(iptr),*(iptr+1),*(iptr+2));
+                    this->operator()(*(iptr),*(iptr+2),*(iptr+3));
+                }
+                break;
+            }
+            case(GL_QUAD_STRIP):
+            {
+                IndexPointer iptr = indices;
+                for(GLsizei i=3;i<count;i+=2,iptr+=2)
+                {
+                    this->operator()(*(iptr),*(iptr+1),*(iptr+2));
+                    this->operator()(*(iptr+1),*(iptr+3),*(iptr+2));
+                }
+                break;
+            }
+            case(GL_POLYGON): // treat polygons as GL_TRIANGLE_FAN
+            case(GL_TRIANGLE_FAN):
+            {
+                IndexPointer iptr = indices;
+                unsigned int first = *iptr;
+                ++iptr;
+                for(GLsizei i=2;i<count;++i,++iptr)
+                {
+                    this->operator()(first,*(iptr),*(iptr+1));
+                }
+                break;
+            }
+            case(GL_POINTS):
+            case(GL_LINES):
+            case(GL_LINE_STRIP):
+            case(GL_LINE_LOOP):
+            default:
+                // can't be converted into to triangles.
+                break;
+        }
+    }    
+
+    GLenum               _modeCache;
+    std::vector<GLuint>  _indexCache;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/PolygonOffset
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/PolygonOffset (revision 2773)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/PolygonOffset (revision 2773)
@@ -0,0 +1,79 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_POLYGONOFFSET
+#define OSG_POLYGONOFFSET 1
+
+#include <osg/StateAttribute>
+
+namespace osg {
+
+/** PolygonOffset - encapsulates the OpenGL glPolygonOffset state.*/
+class SG_EXPORT PolygonOffset : public StateAttribute
+{
+    public :
+
+        PolygonOffset();
+
+        PolygonOffset(float factor, float units);
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        PolygonOffset(const PolygonOffset& po,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            StateAttribute(po,copyop),
+            _factor(po._factor),
+            _units(po._units) {}
+
+        META_StateAttribute(osg, PolygonOffset, POLYGONOFFSET);
+
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const StateAttribute& sa) const
+        {
+            // check the types are equal and then create the rhs variable
+            // used by the COMPARE_StateAttribute_Paramter macro's below.
+            COMPARE_StateAttribute_Types(PolygonOffset,sa)
+
+            // compare each paramter in turn against the rhs.
+            COMPARE_StateAttribute_Parameter(_factor)
+            COMPARE_StateAttribute_Parameter(_units)
+
+            return 0; // passed all the above comparison macro's, must be equal.
+        }
+
+        virtual bool getModeUsage(ModeUsage& usage) const
+        {
+            usage.usesMode(GL_POLYGON_OFFSET_FILL);
+            usage.usesMode(GL_POLYGON_OFFSET_LINE);
+            usage.usesMode(GL_POLYGON_OFFSET_POINT);
+            return true;
+        }
+
+        inline void setFactor(float factor) { _factor = factor; }
+        inline float getFactor() const { return _factor; }
+        
+        inline void setUnits(float units) { _units = units; }
+        inline float getUnits() const { return _units; }
+
+        virtual void apply(State& state) const;
+
+    protected :
+
+        virtual ~PolygonOffset();
+
+        float       _factor;
+        float       _units;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec2
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec2 (revision 3008)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec2 (revision 3008)
@@ -0,0 +1,25 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_VEC2
+#define OSG_VEC2 1
+
+#include <osg/Vec2f>
+
+namespace osg {
+
+    typedef Vec2f Vec2;
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ArgumentParser
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ArgumentParser (revision 2831)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ArgumentParser (revision 2831)
@@ -0,0 +1,181 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_ARGUMENTPARSER
+#define OSG_ARGUMENTPARSER 1
+
+#include <osg/Export>
+
+#include <map>
+#include <string>
+#include <ostream>
+
+namespace osg {
+
+// forward declare
+class ApplicationUsage;
+
+class SG_EXPORT ArgumentParser
+{
+    public:
+
+        class Parameter
+        {
+        public:
+            enum ParameterType
+            {
+                FLOAT_PARAMETER,
+                DOUBLE_PARAMETER,
+                INT_PARAMETER,
+                UNSIGNED_INT_PARAMETER,
+                STRING_PARAMETER,
+            };
+        
+            union ValueUnion
+            {
+                float*          _float;
+                double*         _double;
+                int*            _int;
+                unsigned int*   _uint;
+                std::string*    _string;
+            };
+
+            Parameter(float& value) { _type = FLOAT_PARAMETER; _value._float = &value; }
+                
+            Parameter(double& value) { _type = DOUBLE_PARAMETER; _value._double = &value; }
+
+            Parameter(int& value) { _type = INT_PARAMETER; _value._int = &value; }
+
+            Parameter(unsigned int& value)  { _type = UNSIGNED_INT_PARAMETER; _value._uint = &value; }
+            
+            Parameter(std::string& value) { _type = STRING_PARAMETER; _value._string = &value; }
+
+            bool valid(const char* str) const;
+            bool assign(const char* str);
+
+        protected:
+        
+            ParameterType   _type;
+            ValueUnion      _value;
+        };
+
+        /** return return true if specified string is an option in the form of -option or --option .*/
+        static bool isOption(const char* str);
+        
+        /** return return true if string is any other string apart from an option.*/
+        static bool isString(const char* str);
+        
+        /** return return true if specified parameter is an number.*/
+        static bool isNumber(const char* str);
+
+    public:
+
+        ArgumentParser(int* argc,char **argv);
+
+        void setApplicationUsage(ApplicationUsage* usage) { _usage = usage; }
+        ApplicationUsage* getApplicationUsage() { return _usage; }
+        const ApplicationUsage* getApplicationUsage() const { return _usage; }
+
+        /** return the argument count.*/
+        int& argc() { return *_argc; }
+
+        /** return the argument array.*/
+        char** argv() { return _argv; }
+
+        /** return char* argument at specificed position.*/
+        char* operator [] (int pos) { return _argv[pos]; }
+
+        /** return const char* argument at specificed position.*/
+        const char* operator [] (int pos) const { return _argv[pos]; }
+
+        /** return the application name, as specified by argv[0] */
+        std::string getApplicationName() const;
+
+        /** return the position of an occurance of a string in the argument list.
+          * return -1 when no string is found.*/      
+        int find(const std::string& str) const;
+
+        /** return return true if specified parameter is an option in the form of -option or --option .*/
+        bool isOption(int pos) const;
+        
+        /** return return true if specified parameter is an string, which can be any other string apart from an option.*/
+        bool isString(int pos) const;
+        
+        /** return return true if specified parameter is an number.*/
+        bool isNumber(int pos) const;
+        
+        bool containsOptions() const;
+
+        /** remove one or more arguments from the argv argument list, and decrement the argc respectively.*/
+        void remove(int pos,int num=1);
+        
+        /** return true if specified argument matches string.*/        
+        bool match(int pos, const std::string& str) const;
+
+        /** search for an occurance of a string in the argument list, on sucess
+          * remove that occurance from the list and return true, otherwise return false.*/
+        bool read(const std::string& str);
+        bool read(const std::string& str, Parameter value1);
+        bool read(const std::string& str, Parameter value1, Parameter value2);
+        bool read(const std::string& str, Parameter value1, Parameter value2, Parameter value3);
+        bool read(const std::string& str, Parameter value1, Parameter value2, Parameter value3, Parameter value4);
+
+
+        /** if the argument value at the position pos matches specified string, and subsequent
+          * paramters are also matched then set the paramter values and remove the from the list of arguments.*/
+        bool read(int pos, const std::string& str);
+        bool read(int pos, const std::string& str, Parameter value1);
+        bool read(int pos, const std::string& str, Parameter value1, Parameter value2);
+        bool read(int pos, const std::string& str, Parameter value1, Parameter value2, Parameter value3);
+        bool read(int pos, const std::string& str, Parameter value1, Parameter value2, Parameter value3, Parameter value4);
+
+
+        enum ErrorSeverity
+        {
+            BENIGN = 0,
+            CRITICAL = 1
+        };
+
+        typedef std::map<std::string,ErrorSeverity> ErrorMessageMap;
+
+        /** return the error flag, true if an error has occured when reading arguments.*/
+        bool errors(ErrorSeverity severity=BENIGN) const;
+
+        /** report an error message by adding to the ErrorMessageMap.*/
+        void reportError(const std::string& message,ErrorSeverity severity=CRITICAL);
+
+        /** for each remaining option report it as an unrecongnized.*/
+        void reportRemainingOptionsAsUnrecognized(ErrorSeverity severity=BENIGN);
+        
+        /** return the error message, if any has occured.*/
+        ErrorMessageMap& getErrorMessageMap() { return _errorMessageMap; }
+      
+        /** return the error message, if any has occured.*/
+        const ErrorMessageMap& getErrorMessageMap() const { return _errorMessageMap; }
+
+        /** write out error messages at an above specified .*/
+        void writeErrorMessages(std::ostream& output,ErrorSeverity sevrity=BENIGN);
+
+  
+  protected:
+        
+        int*                _argc;
+        char**              _argv;
+        ErrorMessageMap     _errorMessageMap;
+        ApplicationUsage*   _usage;
+        
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec3
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec3 (revision 3008)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec3 (revision 3008)
@@ -0,0 +1,25 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_VEC3
+#define OSG_VEC3 1
+
+#include <osg/Vec3f>
+
+namespace osg {
+
+    typedef Vec3f Vec3;
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TexGenNode
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TexGenNode (revision 3077)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TexGenNode (revision 3077)
@@ -0,0 +1,61 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_TexGenNode
+#define OSG_TexGenNode 1
+
+#include <osg/Group>
+#include <osg/TexGen>
+
+namespace osg {
+
+/** Node for defining the position of TexGen in the scene.*/
+class SG_EXPORT TexGenNode : public Group
+{
+
+    public:
+
+        TexGenNode();
+        TexGenNode(TexGen* texgen);
+
+        TexGenNode(const TexGenNode& tgb, const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+        META_Node(osg, TexGenNode);
+	
+        
+        void setTextureUnit(unsigned int textureUnit) { _textureUnit = textureUnit; }
+
+        unsigned int getTextureUnit() const { return _textureUnit; }
+
+        /** Set the TexGen.*/
+        void setTexGen(TexGen* texgen);
+        
+        /** Get the TexGen.*/
+        inline TexGen* getTexGen() { return _texgen.get(); }
+
+        /** Get the const TexGen.*/
+        inline const TexGen* getTexGen() const { return _texgen.get(); }
+
+
+    protected:
+
+        virtual ~TexGenNode();
+
+        unsigned int _textureUnit;
+        StateAttribute::GLModeValue _value;
+        osg::ref_ptr<TexGen> _texgen;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Shape
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Shape (revision 3212)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Shape (revision 3212)
@@ -0,0 +1,656 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_SHAPE
+#define OSG_SHAPE 1
+
+#include <osg/Object>
+#include <osg/Vec3>
+#include <osg/Quat>
+#include <osg/Plane>
+#include <osg/Array>
+
+namespace osg {
+
+// forward decare visitors.
+class ShapeVisitor;
+class ConstShapeVisitor;
+
+
+/** META_StateAttribute macro define the standard clone, isSameKindAs,
+  * className and getType methods.
+  * Use when subclassing from Object to make it more convinient to define 
+  * the standard pure virtual methods which are required for all Object 
+  * subclasses.*/
+#define META_Shape(library,name) \
+        virtual osg::Object* cloneType() const { return new name(); } \
+        virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new name (*this,copyop); } \
+        virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const name *>(obj)!=NULL; } \
+        virtual const char* libraryName() const { return #library; } \
+        virtual const char* className() const { return #name; } \
+        virtual void accept(osg::ShapeVisitor& sv) { sv.apply(*this); } \
+        virtual void accept(osg::ConstShapeVisitor& csv) const { csv.apply(*this); }
+	
+/** Base class for all shape types. 
+  * Shapes are used to either for culling and collision detection or
+  * to define the geometric shape of procedurally generate Geometry.
+*/
+class SG_EXPORT Shape : public Object
+{
+    public:
+
+        Shape() {}
+        
+        Shape(const Shape& sa,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 
+            Object(sa,copyop) {}
+        
+        /** Clone the type of an attribute, with Object* return type.
+            Must be defined by derived classes.*/
+        virtual Object* cloneType() const = 0;
+
+        /** Clone an attribute, with Object* return type.
+            Must be defined by derived classes.*/
+        virtual Object* clone(const CopyOp&) const = 0;
+
+
+        /** return true if this and obj are of the same kind of object.*/
+        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Shape*>(obj)!=NULL; }
+
+        /** return the name of the attribute's library.*/
+        virtual const char* libraryName() const { return "osg"; }
+
+        /** return the name of the attribute's class type.*/
+        virtual const char* className() const { return "Shape"; }
+
+    	/** accept a non const shape visitor which can be used on non const shape objects.
+            Must be defined by derived classes.*/
+    	virtual void accept(ShapeVisitor&)=0;
+	
+    	/** accept a const shape visitor which can be used on const shape objects.
+            Must be defined by derived classes.*/
+    	virtual void accept(ConstShapeVisitor&) const =0;
+
+    protected:
+    
+    	virtual ~Shape();
+};
+
+// forward declartions of Shape types.
+class Sphere;
+class Box;
+class Cone;
+class Cylinder;
+class Capsule;
+class InfinitePlane;
+
+class TriangleMesh;
+class ConvexHull;
+class HeightField;
+
+class CompositeShape;
+
+class ShapeVisitor
+{
+    public:
+    
+    	ShapeVisitor() {}
+    
+    	virtual void apply(Sphere&) {}
+    	virtual void apply(Box&) {}
+    	virtual void apply(Cone&) {}
+    	virtual void apply(Cylinder&) {}
+    	virtual void apply(Capsule&) {}
+    	virtual void apply(InfinitePlane&) {}
+
+    	virtual void apply(TriangleMesh&) {}
+    	virtual void apply(ConvexHull&) {}
+    	virtual void apply(HeightField&) {}
+
+    	virtual void apply(CompositeShape&) {}
+};
+
+class ConstShapeVisitor
+{
+    public:
+    
+    	ConstShapeVisitor() {}
+
+    	virtual void apply(const Sphere&) {}
+    	virtual void apply(const Box&) {}
+    	virtual void apply(const Cone&) {}
+    	virtual void apply(const Cylinder&) {}
+    	virtual void apply(const Capsule&) {}
+    	virtual void apply(const InfinitePlane&) {}
+
+    	virtual void apply(const TriangleMesh&) {}
+    	virtual void apply(const ConvexHull&) {}
+    	virtual void apply(const HeightField&) {}
+
+    	virtual void apply(const CompositeShape&) {}
+};
+
+class Sphere : public Shape
+{
+    public:
+    	
+        Sphere():
+	    _center(0.0f,0.0f,0.0f),
+	    _radius(1.0f) {}
+	
+        Sphere(const osg::Vec3& center,float radius):
+	    _center(center),
+	    _radius(radius) {}
+
+        Sphere(const Sphere& sphere,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            Shape(sphere,copyop),
+	    _center(sphere._center),
+	    _radius(sphere._radius) {}
+        
+    	META_Shape(osg, Sphere);
+	
+	inline bool valid() const { return _radius>=0.0f; }
+	
+	inline void set(const Vec3& center,float radius)
+	{
+	    _center = center;
+	    _radius = radius;
+	}
+
+	inline void setCenter(const Vec3& center) { _center = center; }
+	inline const Vec3& getCenter() const { return _center; }
+	
+	inline void setRadius(float radius) { _radius = radius; }
+	inline float getRadius() const { return _radius; }
+
+    protected:
+    
+    	virtual ~Sphere() {}
+    
+    	Vec3    _center;
+	float	_radius;
+	
+};
+
+class Box : public Shape
+{
+    public:
+    	
+        Box():
+	    _center(0.0f,0.0f,0.0f),
+	    _halfLengths(0.5f,0.5f,0.5f) {}
+	
+        Box(const osg::Vec3& center,float width):
+	    _center(center),
+	    _halfLengths(width*0.5f,width*0.5f,width*0.5f) {}
+
+        Box(const osg::Vec3& center,float lengthX,float lengthY, float lengthZ):
+	    _center(center),
+	    _halfLengths(lengthX*0.5f,lengthY*0.5f,lengthZ*0.5f) {}
+
+        Box(const Box& box,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 
+            Shape(box,copyop),
+	    _center(box._center),
+	    _halfLengths(box._halfLengths),
+    	    _rotation(box._rotation) {}
+        
+    	META_Shape(osg, Box);
+	
+	inline bool valid() const { return _halfLengths.x()>=0.0f; }
+	
+	inline void set(const Vec3& center,const Vec3& halfLengths)
+	{
+	    _center = center;
+	    _halfLengths = halfLengths;
+	}
+
+	inline void setCenter(const Vec3& center) { _center = center; }
+	inline const Vec3& getCenter() const { return _center; }
+	
+	inline void setHalfLengths(const Vec3& halfLengths) { _halfLengths = halfLengths; }
+	inline const Vec3& getHalfLengths() const { return _halfLengths; }
+	
+    	inline void setRotation(const Quat& quat) { _rotation = quat; }
+    	inline const Quat&  getRotation() const { return _rotation; }
+    	inline Matrix getRotationMatrix() const { return Matrix(_rotation); }
+    	inline bool zeroRotation() const { return _rotation.zeroRotation(); } 
+
+    protected:
+    
+    	virtual ~Box() {}
+    
+    	Vec3    _center;
+    	Vec3    _halfLengths;
+    	Quat	_rotation;	
+	
+};
+
+
+
+class Cone : public Shape
+{
+    public:
+    	
+        Cone():
+	    _center(0.0f,0.0f,0.0f),
+	    _radius(1.0f),
+	    _height(1.0f) {}
+	
+        Cone(const osg::Vec3& center,float radius,float height):
+	    _center(center),
+	    _radius(radius),
+	    _height(height) {}
+
+        Cone(const Cone& cone,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 
+            Shape(cone,copyop),
+	    _center(cone._center),
+	    _radius(cone._radius),
+	    _height(cone._height),
+	    _rotation(cone._rotation) {}
+        
+    	META_Shape(osg, Cone);
+	
+	inline bool valid() const { return _radius>=0.0f; }
+	
+	inline void set(const Vec3& center,float radius, float height)
+	{
+	    _center = center;
+	    _radius = radius;
+	    _height = height;
+	}
+
+	inline void setCenter(const Vec3& center) { _center = center; }
+	inline const Vec3& getCenter() const { return _center; }
+	
+	inline void setRadius(float radius) { _radius = radius; }
+	inline float getRadius() const { return _radius; }
+
+	inline void setHeight(float height) { _height = height; }
+	inline float getHeight() const { return _height; }
+
+    	inline void setRotation(const Quat& quat) { _rotation = quat; }
+    	inline const Quat& getRotation() const { return _rotation; }
+    	inline Matrix getRotationMatrix() const { return Matrix(_rotation); }
+    	inline bool zeroRotation() const { return _rotation.zeroRotation(); } 
+	
+	inline float getBaseOffsetFactor() const { return 0.25f; } 
+	inline float getBaseOffset() const { return -getBaseOffsetFactor()*getHeight(); } 
+
+    protected:
+    
+    	virtual ~Cone() {}
+    
+    	Vec3    _center;
+	float 	_radius;
+	float	_height;
+	
+    	Quat	_rotation;	
+};
+
+class Cylinder : public Shape
+{
+    public:
+    	
+        Cylinder():
+	    _center(0.0f,0.0f,0.0f),
+	    _radius(1.0f),
+	    _height(1.0f) {}
+	
+        Cylinder(const osg::Vec3& center,float radius,float height):
+	    _center(center),
+	    _radius(radius),
+	    _height(height) {}
+
+        Cylinder(const Cylinder& cylinder,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 
+            Shape(cylinder,copyop),
+	    _center(cylinder._center),
+	    _radius(cylinder._radius),
+	    _height(cylinder._height),
+	    _rotation(cylinder._rotation) {}
+        
+    	META_Shape(osg, Cylinder);
+	
+	inline bool valid() const { return _radius>=0.0f; }
+	
+	inline void set(const Vec3& center,float radius, float height)
+	{
+	    _center = center;
+	    _radius = radius;
+	    _height = height;
+	}
+
+	inline void setCenter(const Vec3& center) { _center = center; }
+	inline const Vec3& getCenter() const { return _center; }
+	
+	inline void setRadius(float radius) { _radius = radius; }
+	inline float getRadius() const { return _radius; }
+
+	inline void setHeight(float height) { _height = height; }
+	inline float getHeight() const { return _height; }
+
+    	inline void setRotation(const Quat& quat) { _rotation = quat; }
+    	inline const Quat& getRotation() const { return _rotation; }
+    	inline Matrix getRotationMatrix() const { return Matrix(_rotation); }
+    	bool zeroRotation() const { return _rotation.zeroRotation(); } 
+
+    protected:
+    
+    	virtual ~Cylinder() {}
+    
+    	Vec3    _center;
+	float 	_radius;
+	float	_height;
+	
+    	Quat	_rotation;	
+};
+
+class Capsule : public Shape
+{
+    public:
+    	
+        Capsule():
+	    _center(0.0f,0.0f,0.0f),
+	    _radius(1.0f),
+	    _height(1.0f) {}
+	
+        Capsule(const osg::Vec3& center,float radius,float height):
+	    _center(center),
+	    _radius(radius),
+	    _height(height) {}
+
+        Capsule(const Capsule& capsule,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 
+            Shape(capsule,copyop),
+	    _center(capsule._center),
+	    _radius(capsule._radius),
+	    _height(capsule._height),
+	    _rotation(capsule._rotation) {}
+        
+    	META_Shape(osg, Capsule);
+	
+	inline bool valid() const { return _radius>=0.0f; }
+	
+	inline void set(const Vec3& center,float radius, float height)
+	{
+	    _center = center;
+	    _radius = radius;
+	    _height = height;
+	}
+
+	inline void setCenter(const Vec3& center) { _center = center; }
+	inline const Vec3& getCenter() const { return _center; }
+	
+	inline void setRadius(float radius) { _radius = radius; }
+	inline float getRadius() const { return _radius; }
+
+	inline void setHeight(float height) { _height = height; }
+	inline float getHeight() const { return _height; }
+
+    	inline void setRotation(const Quat& quat) { _rotation = quat; }
+    	inline const Quat& getRotation() const { return _rotation; }
+    	inline Matrix getRotationMatrix() const { return Matrix(_rotation); }
+    	bool zeroRotation() const { return _rotation.zeroRotation(); } 
+
+    protected:
+    
+    	virtual ~Capsule() {}
+    
+    	Vec3    _center;
+	float 	_radius;
+	float	_height;
+	
+    	Quat	_rotation;	
+};
+
+class InfinitePlane : public Shape, public Plane
+{
+    public:
+    	InfinitePlane() {}
+	
+        InfinitePlane(const InfinitePlane& plane,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 
+            Shape(plane,copyop),
+            Plane(plane) {}
+
+     	META_Shape(osg, InfinitePlane);
+     	
+     protected:
+     
+        virtual ~InfinitePlane() {}
+};
+
+class TriangleMesh : public Shape
+{
+    public:
+    
+    	TriangleMesh() {}
+
+        TriangleMesh(const TriangleMesh& mesh,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 
+            Shape(mesh,copyop),
+	    _vertices(mesh._vertices),
+	    _indices(mesh._indices) {}
+        
+    	META_Shape(osg, TriangleMesh);
+	
+	
+	void setVertices(Vec3Array* vertices) { _vertices = vertices; }
+	Vec3Array* getVertices() { return _vertices.get(); }
+	const Vec3Array* getVertices() const { return _vertices.get(); }
+	
+	
+	void setIndices(IndexArray* indices) { _indices = indices; }
+	IndexArray* getIndices() { return _indices.get(); }
+	const IndexArray* getIndices() const { return _indices.get(); }
+	
+    protected:
+    
+    	~TriangleMesh() {}
+	
+	ref_ptr<Vec3Array> _vertices;
+	ref_ptr<IndexArray> _indices;
+    	
+};
+
+class ConvexHull : public TriangleMesh
+{
+    public:
+    
+    	ConvexHull() {}
+	
+        ConvexHull(const ConvexHull& hull,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 
+            TriangleMesh(hull,copyop) {}
+        
+    	META_Shape(osg, TriangleMesh);
+	
+    protected:
+    
+    	~ConvexHull() {}
+};
+
+class SG_EXPORT HeightField : public Shape
+{
+    public:
+    
+    	HeightField():
+	    _columns(0),
+	    _rows(0),
+	    _origin(0.0f,0.0f,0.0f),
+	    _dx(1.0f),
+	    _dy(1.0f),
+            _skirtHeight(0.0f),
+            _borderWidth(0) {}
+
+        HeightField(const HeightField& mesh,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 
+            Shape(mesh,copyop),
+	    _columns(mesh._columns),
+	    _rows(mesh._rows),
+	    _origin(mesh._origin),
+	    _dx(mesh._dx),
+	    _dy(mesh._dy),
+            _skirtHeight(mesh._skirtHeight),
+            _borderWidth(mesh._borderWidth),
+            _heights(mesh._heights) {}
+        
+    	META_Shape(osg, HeightField)
+
+    	typedef std::vector<float> HeightList;
+
+    	void allocate(unsigned int numColumns,unsigned int numRows);
+
+	// deprecated.
+    	void allocateGrid(unsigned int numColumns,unsigned int numRows) { allocate(numColumns,numRows); }
+
+	inline unsigned int getNumColumns() const { return _columns; }
+	inline unsigned int getNumRows() const { return _rows; }
+
+    	inline void setOrigin(const osg::Vec3& origin) { _origin = origin; }
+    	inline const osg::Vec3& getOrigin() const { return _origin; }
+
+	inline void setXInterval(float dx) { _dx = dx; }
+	inline float getXInterval() const { return _dx; }
+
+	inline void setYInterval(float dy) { _dy = dy; }
+	inline float getYInterval() const { return _dy; }
+
+	
+        /** Set the height of the skirt to render around the edge of HeightField.
+          * The skirt is used as a means of disguising edge boundaries between adjacent HeightField, particular
+          * of ones with different resolutions.*/
+        void setSkirtHeight(float skirtHeight) { _skirtHeight = skirtHeight; }
+        
+        /** Get the height of the skirt to render around the edge of HeightField.*/
+        float getSkirtHeight() const { return _skirtHeight; }
+        
+        /** Set the width in number of cells in from the edge that the height field should be rendered from.
+          * This exists to allow gradient and curvature continutity to be maintained between adjacent HeightField, where
+          * the border cells will overlap adjacent HeightField.*/
+        void setBorderWidth(unsigned int borderWidth) { _borderWidth = borderWidth; }
+
+        /** Get the width in number of cells in from the edge that the height field should be rendered from.*/
+        unsigned int getBorderWidth() const { return _borderWidth; }
+
+    	inline void setRotation(const Quat& quat) { _rotation = quat; }
+    	inline const Quat& getRotation() const { return _rotation; }
+    	inline Matrix getRotationMatrix() const { return Matrix(_rotation); }
+    	inline bool zeroRotation() const { return _rotation.zeroRotation(); } 
+        
+
+	inline void setHeight(unsigned int c,unsigned int r,float value)
+	{
+	   _heights[c+r*_columns] = value;
+	}
+
+	inline float& getHeight(unsigned int c,unsigned int r)
+	{
+	   return _heights[c+r*_columns];
+	}
+
+	inline float getHeight(unsigned int c,unsigned int r) const
+	{
+	   return _heights[c+r*_columns];
+	}
+
+	HeightList& getHeightList() { return _heights; }
+	const HeightList& getHeightList() const { return _heights; }
+
+        inline Vec3 getVertex(unsigned int c,unsigned int r) const
+        {
+            return Vec3(_origin.x()+getXInterval()*(float)c,
+                        _origin.y()+getYInterval()*(float)r,
+                        _origin.z()+_heights[c+r*_columns]);  
+        }
+        
+        Vec3 getNormal(unsigned int c,unsigned int r) const;
+
+    protected:
+    
+    	virtual ~HeightField();
+
+    	unsigned int    _columns,_rows;
+
+	osg::Vec3       _origin;
+	float	        _dx;
+	float	        _dy;
+	
+        float           _skirtHeight;
+        unsigned int    _borderWidth;
+
+	Quat            _rotation;
+	HeightList      _heights;
+        
+};
+
+typedef HeightField Grid;
+
+
+class CompositeShape : public Shape
+{
+    public:
+
+
+    
+    	typedef std::vector< ref_ptr<Shape> > ChildList;
+    
+    	CompositeShape() {}
+
+        CompositeShape(const CompositeShape& cs,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 
+            Shape(cs,copyop),
+	    _children(cs._children) {}
+        
+    	META_Shape(osg, CompositeShape);
+
+    	/** Set the shape that encloses all of the children.*/	
+	void setShape(Shape* shape) { _shape = shape; }
+
+    	/** Get the shape that encloses all of the children.*/	
+	Shape* getShape() { return _shape.get(); }
+
+    	/** Get the const shape that encloses all of the children.*/	
+	const Shape* getShape() const { return _shape.get(); }
+	
+	/** Get the number of children of this composite shape.*/
+	unsigned int getNumChildren() const { return _children.size(); }
+	
+	/** Get a child.*/
+	Shape* getChild(unsigned int i) { return _children[i].get(); }
+
+	/** Get a const child.*/
+	const Shape* getChild(unsigned int i) const { return _children[i].get(); }
+
+	/** Add a child to the list.*/
+	void addChild(Shape* shape) { _children.push_back(shape); }
+	
+	/** remove a child from the list.*/
+	void removeChild(unsigned int i) { _children.erase(_children.begin()+i); }
+
+	/** find the index number of child, if child is not found then it returns getNumChildren(),
+	  * so should be used in similar sytle of STL's result!=end().*/ 
+	unsigned int findChildNo(Shape* shape) const
+        { 
+            for (unsigned int childNo=0;childNo<_children.size();++childNo)
+            {
+                if (_children[childNo]==shape) return childNo;
+            }
+            return _children.size(); // node not found.
+
+        }
+	
+    protected:
+    
+    	~CompositeShape() {}
+
+    	ref_ptr<Shape>	_shape;
+	ChildList   	_children;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/BlendFunc
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/BlendFunc (revision 2773)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/BlendFunc (revision 2773)
@@ -0,0 +1,109 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_BLENDFUNC
+#define OSG_BLENDFUNC 1
+
+#include <osg/StateAttribute>
+
+
+#ifndef GL_VERSION_1_2
+#define GL_CONSTANT_COLOR                 0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR       0x8002
+#define GL_CONSTANT_ALPHA                 0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA       0x8004
+#define GL_BLEND_COLOR                    0x8005
+#endif
+
+
+
+namespace osg {
+
+/** BlendFunc - encapsulates the OpenGL blend/transparency state.*/
+class SG_EXPORT BlendFunc : public StateAttribute
+{
+    public :
+
+        BlendFunc();
+        
+        BlendFunc(GLenum source, GLenum destination);
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        BlendFunc(const BlendFunc& trans,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            StateAttribute(trans,copyop),
+            _source_factor(trans._source_factor),
+            _destination_factor(trans._destination_factor) {}
+
+        META_StateAttribute(osg, BlendFunc,BLENDFUNC);
+        
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const StateAttribute& sa) const
+        {
+            // check the types are equal and then create the rhs variable
+            // used by the COMPARE_StateAttribute_Paramter macro's below.
+            COMPARE_StateAttribute_Types(BlendFunc,sa)
+
+            // compare each paramter in turn against the rhs.
+            COMPARE_StateAttribute_Parameter(_source_factor)
+            COMPARE_StateAttribute_Parameter(_destination_factor)
+
+            return 0; // passed all the above comparison macro's, must be equal.
+        }
+
+        virtual bool getModeUsage(ModeUsage& usage) const
+        {
+            usage.usesMode(GL_BLEND);
+            return true;
+        }
+
+        enum BlendFuncMode {
+            DST_ALPHA                = GL_DST_ALPHA,
+            DST_COLOR                = GL_DST_COLOR,
+            ONE                      = GL_ONE,
+            ONE_MINUS_DST_ALPHA      = GL_ONE_MINUS_DST_ALPHA,
+            ONE_MINUS_DST_COLOR      = GL_ONE_MINUS_DST_COLOR,
+            ONE_MINUS_SRC_ALPHA      = GL_ONE_MINUS_SRC_ALPHA,
+            ONE_MINUS_SRC_COLOR      = GL_ONE_MINUS_SRC_COLOR,
+            SRC_ALPHA                = GL_SRC_ALPHA,
+            SRC_ALPHA_SATURATE       = GL_SRC_ALPHA_SATURATE,
+            SRC_COLOR                = GL_SRC_COLOR,
+            CONSTANT_ALPHA           = GL_CONSTANT_ALPHA,
+            ONE_MINUS_CONSTANT_ALPHA = GL_ONE_MINUS_CONSTANT_ALPHA,
+            ZERO                     = GL_ZERO
+        };
+
+        inline void setFunction( GLenum source, GLenum destination )
+        {
+            _source_factor = source;
+            _destination_factor = destination;
+        }
+
+        void setSource(GLenum source) { _source_factor = source; }
+        inline GLenum getSource() const { return _source_factor; }
+        
+        void setDestination(GLenum destination) { _destination_factor = destination; }
+        inline GLenum getDestination() const { return _destination_factor; }
+
+        virtual void apply(State& state) const;
+
+    protected :
+
+        virtual ~BlendFunc();
+
+        GLenum _source_factor;
+        GLenum _destination_factor;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ref_ptr
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ref_ptr (revision 2025)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ref_ptr (revision 2025)
@@ -0,0 +1,101 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_REF_PTR
+#define OSG_REF_PTR 1
+
+namespace osg {
+
+/** Smart pointer for handling referenced counted objects.*/
+template<class T>
+class ref_ptr
+{
+
+    public:
+        typedef T element_type;
+
+        ref_ptr() :_ptr(0L) {}
+        ref_ptr(T* t):_ptr(t)              { if (_ptr) _ptr->ref(); }
+        ref_ptr(const ref_ptr& rp):_ptr(rp._ptr)  { if (_ptr) _ptr->ref(); }
+        ~ref_ptr()                           { if (_ptr) _ptr->unref(); _ptr=0; }
+
+        inline ref_ptr& operator = (const ref_ptr& rp)
+        {
+            if (_ptr==rp._ptr) return *this;
+            T* tmp_ptr = _ptr;
+            _ptr = rp._ptr;
+            if (_ptr) _ptr->ref();
+            // unref second to prevent any deletion of any object which might
+            // be referenced by the other object. i.e rp is child of the
+            // original _ptr.
+            if (tmp_ptr) tmp_ptr->unref();
+            return *this;
+        }
+
+        inline ref_ptr& operator = (T* ptr)
+        {
+            if (_ptr==ptr) return *this;
+            T* tmp_ptr = _ptr;
+            _ptr = ptr;
+            if (_ptr) _ptr->ref();
+            // unref second to prevent any deletion of any object which might
+            // be referenced by the other object. i.e rp is child of the
+            // original _ptr.
+            if (tmp_ptr) tmp_ptr->unref();
+            return *this;
+        }
+
+        // comparison operators for ref_ptr.
+        inline bool operator == (const ref_ptr& rp) const { return (_ptr==rp._ptr); }
+        inline bool operator != (const ref_ptr& rp) const { return (_ptr!=rp._ptr); }
+        inline bool operator < (const ref_ptr& rp) const { return (_ptr<rp._ptr); }
+        inline bool operator > (const ref_ptr& rp) const { return (_ptr>rp._ptr); }
+
+        // comparion operator for const T*.
+        inline bool operator == (const T* ptr) const { return (_ptr==ptr); }
+        inline bool operator != (const T* ptr) const { return (_ptr!=ptr); }
+        inline bool operator < (const T* ptr) const { return (_ptr<ptr); }
+        inline bool operator > (const T* ptr) const { return (_ptr>ptr); }
+
+
+        inline T& operator*()  { return *_ptr; }
+
+        inline const T& operator*() const { return *_ptr; }
+
+        inline T* operator->() { return _ptr; }
+
+        inline const T* operator->() const   { return _ptr; }
+
+	inline bool operator!() const	{ return _ptr==0L; }
+
+	inline bool valid() const	{ return _ptr!=0L; }
+        
+        inline T* get() { return _ptr; }
+
+        inline const T* get() const { return _ptr; }
+
+        /** take control over the object pointed to by ref_ptr, unreference but do not delete even if ref count goes to 0,
+          * return the pointer to the object.
+          * Note, do not use this unless you are 100% sure your code handles the deletion of the object correctly, and
+          * only use when absolutely required.*/
+        inline T* take() { return release();}
+
+        inline T* release() { T* tmp=_ptr; if (_ptr) _ptr->unref_nodelete(); _ptr=0; return tmp;}
+
+    private:
+        T* _ptr;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec4
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec4 (revision 3008)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec4 (revision 3008)
@@ -0,0 +1,25 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_VEC4
+#define OSG_VEC4 1
+
+#include <osg/Vec4f>
+
+namespace osg {
+
+    typedef Vec4f Vec4;
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Stencil
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Stencil (revision 2773)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Stencil (revision 2773)
@@ -0,0 +1,154 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_STENCIL
+#define OSG_STENCIL 1
+
+#include <osg/StateAttribute>
+
+namespace osg {
+
+/** Encapsulate OpenGL glStencilFunc/Op/Mask functions.
+*/     
+class SG_EXPORT Stencil : public StateAttribute
+{
+    public :
+    
+    
+        Stencil();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        Stencil(const Stencil& stencil,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            StateAttribute(stencil,copyop),
+            _func(stencil._func),
+            _funcRef(stencil._funcRef),
+            _funcMask(stencil._funcMask),
+            _sfail(stencil._sfail),
+            _zfail(stencil._zfail),
+            _zpass(stencil._zpass),
+            _writeMask(stencil._writeMask) {}
+
+
+        META_StateAttribute(osg, Stencil, STENCIL);
+        
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const StateAttribute& sa) const
+        {
+            // check the types are equal and then create the rhs variable
+            // used by the COMPARE_StateAttribute_Paramter macro's below.
+            COMPARE_StateAttribute_Types(Stencil,sa)
+
+            // compare each paramter in turn against the rhs.
+            COMPARE_StateAttribute_Parameter(_func)
+            COMPARE_StateAttribute_Parameter(_funcRef)
+            COMPARE_StateAttribute_Parameter(_funcMask)
+            COMPARE_StateAttribute_Parameter(_sfail)
+            COMPARE_StateAttribute_Parameter(_zfail)
+            COMPARE_StateAttribute_Parameter(_zpass)
+            COMPARE_StateAttribute_Parameter(_writeMask)
+
+            return 0; // passed all the above comparison macro's, must be equal.
+        }
+
+        virtual bool getModeUsage(ModeUsage& usage) const
+        {
+            usage.usesMode(GL_STENCIL_TEST);
+            return true;
+        }
+
+        enum Function
+        {
+            NEVER = GL_NEVER,
+            LESS = GL_LESS,
+            EQUAL = GL_EQUAL,
+            LEQUAL = GL_LEQUAL,
+            GREATER = GL_GREATER,
+            NOTEQUAL = GL_NOTEQUAL,
+            GEQUAL = GL_GEQUAL,
+            ALWAYS = GL_ALWAYS
+        };
+
+        inline void setFunction(Function func,int ref,unsigned int mask)
+        {
+            _func = func;
+            _funcRef = ref;
+            _funcMask = mask;
+        }
+        
+        inline Function getFunction() const { return _func; }
+        
+        inline int getFunctionRef() const { return _funcRef; }
+
+        inline unsigned int getFunctionMask() const { return _funcMask; }
+        
+        
+        enum Operation 
+        {
+            KEEP = GL_KEEP,
+            ZERO = GL_ZERO,
+            REPLACE = GL_REPLACE,
+            INCR = GL_INCR,
+            DECR = GL_DECR,
+            INVERT = GL_INVERT
+        };
+        
+        /** set the operations to apply when the various stencil and depth 
+          * tests fail or pass.  First parameter is to control the operation
+          * when the stencil test fails.  The second parameter is to control the
+          * operation when the stencil test passes, but depth test fails. The
+          * third parameter controls the operation when both the stencil test
+          * and depth pass.  Ordering of parameter is the same as if using
+          * glStencilOp(,,).*/
+        inline void setOperation(Operation sfail, Operation zfail, Operation zpass)
+        {
+            _sfail = sfail;
+            _zfail = zfail;
+            _zpass = zpass;
+        }
+        
+        /** get the operation when the stencil test fails.*/
+        inline Operation getStencilFailOperation() const { return _sfail; }
+        
+        /** get the operation when the stencil test passes but the depth test fails*/
+        inline Operation getStencilPassAndDepthFailOperation() const { return _zfail; }
+        
+        /** get the operation when both the stencil test and the depth test pass*/
+        inline Operation getStencilPassAndDepthPassOperation() const { return _zpass; }
+        
+
+        inline void setWriteMask(unsigned int mask) { _writeMask = mask; }
+        
+        inline unsigned int getWriteMask() const { return _writeMask; }
+
+
+        virtual void apply(State& state) const;
+
+    protected:
+    
+        virtual ~Stencil();
+
+        Function            _func;
+        int                 _funcRef;
+        unsigned int        _funcMask;
+        
+        Operation           _sfail;
+        Operation           _zfail;
+        Operation           _zpass;
+        
+        unsigned int        _writeMask;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/AlphaFunc
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/AlphaFunc (revision 3105)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/AlphaFunc (revision 3105)
@@ -0,0 +1,98 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_ALPHAFUNC
+#define OSG_ALPHAFUNC 1
+
+#include <osg/StateAttribute>
+
+namespace osg {
+
+/** Encapsulate OpenGL glAlphaFunc.
+*/     
+class SG_EXPORT AlphaFunc : public StateAttribute
+{
+    public :
+    
+        enum ComparisonFunction {
+            NEVER = GL_NEVER,
+            LESS = GL_LESS,
+            EQUAL = GL_EQUAL,
+            LEQUAL = GL_LEQUAL,
+            GREATER = GL_GREATER,
+            NOTEQUAL = GL_NOTEQUAL,
+            GEQUAL = GL_GEQUAL,
+            ALWAYS = GL_ALWAYS
+        };
+
+
+        AlphaFunc();
+        
+        AlphaFunc(ComparisonFunction func,float ref):
+            _comparisonFunc(func),
+            _referenceValue(ref) {}
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        AlphaFunc(const AlphaFunc& af,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            StateAttribute(af,copyop),
+            _comparisonFunc(af._comparisonFunc),
+            _referenceValue(af._referenceValue) {}
+        
+        META_StateAttribute(osg, AlphaFunc,ALPHAFUNC);
+        
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const StateAttribute& sa) const
+        {
+            // check the types are equal and then create the rhs variable
+            // used by the COMPARE_StateAttribute_Paramter macro's below.
+            COMPARE_StateAttribute_Types(AlphaFunc,sa)
+
+            // compare each paramter in turn against the rhs.
+            COMPARE_StateAttribute_Parameter(_comparisonFunc)
+            COMPARE_StateAttribute_Parameter(_referenceValue)
+
+            return 0; // passed all the above comparison macro's, must be equal.
+        }
+
+        virtual bool getModeUsage(ModeUsage& usage) const
+        {
+            usage.usesMode(GL_ALPHA_TEST);
+            return true;
+        }
+
+        inline void setFunction(ComparisonFunction func,float ref)
+        {
+            _comparisonFunc = func;
+            _referenceValue = ref;
+        }
+        
+        inline void setFunction(ComparisonFunction func) { _comparisonFunc=func; }
+        inline ComparisonFunction getFunction() const { return _comparisonFunc; }
+        
+        inline void setReferenceValue(float value) { _referenceValue=value; }
+        inline float getReferenceValue() const { return _referenceValue; }
+        
+        virtual void apply(State& state) const;
+
+    protected:
+    
+        virtual ~AlphaFunc();
+
+        ComparisonFunction _comparisonFunc;
+        float _referenceValue;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TexMat
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TexMat (revision 1529)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TexMat (revision 1529)
@@ -0,0 +1,74 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_TEXMAT
+#define OSG_TEXMAT 1
+
+#include <osg/StateAttribute>
+#include <osg/Matrix>
+
+namespace osg {
+
+/** Texture Matrix state class for encapsulating OpenGL texture matrix functionality.*/
+class SG_EXPORT TexMat : public StateAttribute
+{
+    public :
+
+        TexMat();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        TexMat(const TexMat& texmat,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            StateAttribute(texmat,copyop),
+            _matrix(texmat._matrix) {}
+
+        META_StateAttribute(osg, TexMat, TEXMAT);
+        
+        virtual bool isTextureAttribute() const { return true; }
+
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const StateAttribute& sa) const
+        {
+            // check the types are equal and then create the rhs variable
+            // used by the COMPARE_StateAttribute_Paramter macro's below.
+            COMPARE_StateAttribute_Types(TexMat,sa)
+
+            // compare each paramter in turn against the rhs.
+            COMPARE_StateAttribute_Parameter(_matrix)
+
+            return 0; // passed all the above comparison macro's, must be equal.
+        }
+
+        /** Set the texture matrix */
+        inline void setMatrix(const Matrix& matrix) { _matrix = matrix; }
+
+        /** Get the texture matrix */
+        inline Matrix& getMatrix() { return _matrix; }
+
+        /** Get the const texture matrix */
+        inline const Matrix& getMatrix() const { return _matrix; }
+
+        /** apply as OpenGL texture matrix.*/
+        virtual void apply(State& state) const;
+
+    protected:
+
+        virtual ~TexMat( void );
+
+        Matrix _matrix;
+
+};
+
+}
+
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/CoordinateSystemNode
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/CoordinateSystemNode (revision 3243)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/CoordinateSystemNode (revision 3243)
@@ -0,0 +1,226 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_COORDINATESYSTEMNODE
+#define OSG_COORDINATESYSTEMNODE 1
+
+#include <osg/Group>
+#include <osg/Matrixd>
+
+namespace osg
+{
+
+const double WGS_84_RADIUS_EQUATOR = 6378137.0;
+const double WGS_84_RADIUS_POLAR = 6356752.3142;
+
+/** EllipsoidModel encapsulates the ellipsoid used to model astral bodies such as plants, moon etc.*/
+class EllipsoidModel : public Object
+{
+    public:
+
+
+        EllipsoidModel(double radiusEquator = WGS_84_RADIUS_EQUATOR,
+                           double radiusPolar = WGS_84_RADIUS_POLAR):
+            _radiusEquator(radiusEquator),
+            _radiusPolar(radiusPolar) { computeCoefficients(); }
+
+        EllipsoidModel(const EllipsoidModel& et,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            Object(et,copyop),
+            _radiusEquator(et._radiusEquator),
+            _radiusPolar(et._radiusPolar) { computeCoefficients(); }
+
+        META_Object(osg,EllipsoidModel);
+
+        void setRadiusEquator(double radius) { _radiusEquator = radius; computeCoefficients(); }
+        double getRadiusEquator() const { return _radiusEquator; }
+
+        void setRadiusPolar(double radius) { _radiusPolar = radius; computeCoefficients(); }
+        double getRadiusPolar() const { return _radiusPolar; }
+
+        inline void convertLatLongHeightToXYZ(double latitude, double longitude, double height,
+                                              double& X, double& Y, double& Z) const;
+
+        inline void convertXYZToLatLongHeight(double X, double Y, double Z,
+                                              double& latitude, double& longitude, double& height) const;
+
+        inline void computeLocalToWorldTransformFromLatLongHeight(double latitude, double longitude, double height, osg::Matrixd& localToWorld) const;
+
+        inline void computeLocalToWorldTransformFromXYZ(double X, double Y, double Z, osg::Matrixd& localToWorld) const;
+
+        inline osg::Vec3d computeLocalUpVector(double X, double Y, double Z) const;
+
+    protected:
+
+        void computeCoefficients()
+        {
+            double flattening = (_radiusEquator-_radiusPolar)/_radiusEquator;
+            _eccentricitySquared = 2*flattening - flattening*flattening;
+        }
+
+        double _radiusEquator;
+        double _radiusPolar;
+        double _eccentricitySquared;
+
+};
+
+/** CoordinateFrame encapsulate the orientiation of east, north and up.*/ 
+typedef Matrixd CoordinateFrame;
+
+/** CoordinateSystem encapsulate the coordinate system that associated with objects in a scene.
+    For an overview of common earth bases coordinate systems see http://www.colorado.edu/geography/gcraft/notes/coordsys/coordsys_f.html */
+class SG_EXPORT CoordinateSystemNode : public Group
+{
+    public:
+
+        CoordinateSystemNode();
+
+        CoordinateSystemNode(const std::string& format, const std::string& cs);
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        CoordinateSystemNode(const CoordinateSystemNode&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
+        
+        META_Node(osg,CoordinateSystemNode);
+        
+        
+        /** Set the coordinate system node up by copy the format, coordinate system string, and ellipsoid model of another coordinate system node.*/
+        void set(const CoordinateSystemNode& csn);
+                
+        /** Set the coordinate system format string. Typical values would be WKT, PROJ4, USGS etc.*/
+        void setFormat(const std::string& format) { _format = format; }
+        
+        /** Get the coordinate system format string.*/
+        const std::string& getFormat() const { return _format; }
+
+        /** Set the CoordinateSystem reference string, should be stored form consistent with the Format.*/
+        void setCoordinateSystem(const std::string& cs) { _cs = cs; }
+        
+        /** Get the CoordinateSystem reference string.*/
+        const std::string& getCoordinateSystem() const { return _cs; }
+        
+        
+        /** set EllipsoidModel to describe the model used to map lat, long and height into geocentric XYZ and back. */
+        void setEllipsoidModel(EllipsoidModel* ellipsode) { _ellipsoidModel = ellipsode; }
+        
+        /** get the EllipsoidModel.*/
+        EllipsoidModel* getEllipsoidModel() { return _ellipsoidModel.get(); }
+        
+        /** get the const EllipsoidModel.*/
+        const EllipsoidModel* getEllipsoidModel() const { return _ellipsoidModel.get(); }
+        
+        /** compute the local coorindate frame for specified point.*/
+        CoordinateFrame computeLocalCoordinateFrame(const Vec3d& position) const;
+        
+        /** compute the local coorindate frame for specified point.*/
+        osg::Vec3d computeLocalUpVector(const Vec3d& position) const;
+
+    protected:
+
+        virtual ~CoordinateSystemNode() {}
+                
+        std::string             _format;
+        std::string             _cs;
+        ref_ptr<EllipsoidModel> _ellipsoidModel;
+
+};
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// implement inline methods.
+//
+inline void EllipsoidModel::convertLatLongHeightToXYZ(double latitude, double longitude, double height,
+                                      double& X, double& Y, double& Z) const
+{
+    // for details on maths see http://www.colorado.edu/geography/gcraft/notes/datum/gif/llhxyz.gif
+    double sin_latitude = sin(latitude);
+    double cos_latitude = cos(latitude);
+    double N = _radiusEquator / sqrt( 1.0 - _eccentricitySquared*sin_latitude*sin_latitude);
+    X = (N+height)*cos_latitude*cos(longitude);
+    Y = (N+height)*cos_latitude*sin(longitude);
+    Z = (N*(1-_eccentricitySquared)+height)*sin_latitude;
+}
+
+
+inline void EllipsoidModel::convertXYZToLatLongHeight(double X, double Y, double Z,
+                                      double& latitude, double& longitude, double& height) const
+{
+    // http://www.colorado.edu/geography/gcraft/notes/datum/gif/xyzllh.gif
+    double p = sqrt(X*X + Y*Y);
+    double theta = atan(Z*_radiusEquator/ (p*_radiusPolar));
+    double eDashSquared = (_radiusEquator*_radiusEquator - _radiusPolar*_radiusPolar)/
+                          (_radiusPolar*_radiusPolar);
+
+    double sin_theta = sin(theta);
+    double cos_theta = cos(theta);
+
+    latitude = atan( (Z + eDashSquared*_radiusPolar*sin_theta*sin_theta*sin_theta) /
+                     (p - _eccentricitySquared*_radiusEquator*cos_theta*cos_theta*cos_theta) );
+    longitude = atan2(Y,X);
+
+    double sin_latitude = sin(latitude);
+    double N = _radiusEquator / sqrt( 1.0 - _eccentricitySquared*sin_latitude*sin_latitude);
+
+    height = p/cos(latitude) - N;
+}
+
+inline void EllipsoidModel::computeLocalToWorldTransformFromLatLongHeight(double latitude, double longitude, double height, osg::Matrixd& localToWorld) const
+{
+    double X, Y, Z;
+    convertLatLongHeightToXYZ(latitude,longitude,height,X,Y,Z);
+    computeLocalToWorldTransformFromXYZ(X,Y,Z,localToWorld);
+}
+
+inline void EllipsoidModel::computeLocalToWorldTransformFromXYZ(double X, double Y, double Z, osg::Matrixd& localToWorld) const
+{
+    localToWorld.makeTranslate(X,Y,Z);
+
+
+    // normalize X,Y,Z
+    double inverse_length = 1.0/sqrt(X*X + Y*Y + Z*Z);
+    
+    X *= inverse_length;
+    Y *= inverse_length;
+    Z *= inverse_length;
+
+    double length_XY = sqrt(X*X + Y*Y);
+    double inverse_length_XY = 1.0/length_XY;
+
+    // Vx = |(-Y,X,0)|
+    localToWorld(0,0) = -Y*inverse_length_XY;
+    localToWorld(0,1) = X*inverse_length_XY;
+    localToWorld(0,2) = 0.0;
+
+    // Vy = /(-Z*X/(sqrt(X*X+Y*Y), -Z*Y/(sqrt(X*X+Y*Y),sqrt(X*X+Y*Y))| 
+    double Vy_x = -Z*X*inverse_length_XY;
+    double Vy_y = -Z*Y*inverse_length_XY;
+    double Vy_z = length_XY;
+    inverse_length = 1.0/sqrt(Vy_x*Vy_x + Vy_y*Vy_y + Vy_z*Vy_z);            
+    localToWorld(1,0) = Vy_x*inverse_length;
+    localToWorld(1,1) = Vy_y*inverse_length;
+    localToWorld(1,2) = Vy_z*inverse_length;
+
+    // Vz = (X,Y,Z)
+    localToWorld(2,0) = X;
+    localToWorld(2,1) = Y;
+    localToWorld(2,2) = Z;
+}
+
+inline osg::Vec3d EllipsoidModel::computeLocalUpVector(double X, double Y, double Z) const
+{
+    osg::Vec3 normal(X,Y,Z);
+    normal.normalize();
+    return normal;
+}
+
+}
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec3d
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec3d (revision 3230)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec3d (revision 3230)
@@ -0,0 +1,205 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_VEC3D
+#define OSG_VEC3D 1
+
+#include <osg/Vec3f>
+
+namespace osg {
+
+/** General purpose double triple for use as vertices, vectors and normals.
+    Provides general maths operations from addition through to cross products.
+    No support yet added for double * Vec3d - is it necessary?
+    Need to define a non-member non-friend operator*  etc.
+   			     Vec3d * double is okay
+*/
+
+class Vec3d
+{
+    public:
+
+        typedef double value_type;
+        value_type _v[3];
+
+        Vec3d() { _v[0]=0.0; _v[1]=0.0; _v[2]=0.0;}
+
+        inline Vec3d(const Vec3f& vec) { _v[0]=vec._v[0]; _v[1]=vec._v[1]; _v[2]=vec._v[2];}
+        
+        inline operator Vec3f() const { return Vec3f(static_cast<float>(_v[0]),static_cast<float>(_v[1]),static_cast<float>(_v[2]));}
+
+        Vec3d(value_type x,value_type y,value_type z) { _v[0]=x; _v[1]=y; _v[2]=z; }
+
+	inline bool operator == (const Vec3d& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1] && _v[2]==v._v[2]; }
+        
+        inline bool operator != (const Vec3d& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1] || _v[2]!=v._v[2]; }
+
+	inline bool operator <  (const Vec3d& v) const
+        {
+            if (_v[0]<v._v[0]) return true;
+            else if (_v[0]>v._v[0]) return false;
+            else if (_v[1]<v._v[1]) return true;
+            else if (_v[1]>v._v[1]) return false;
+            else return (_v[2]<v._v[2]);
+        }
+
+        inline value_type* ptr() { return _v; }
+        inline const value_type* ptr() const { return _v; }
+
+        inline void set( value_type x, value_type y, value_type z)
+        {
+            _v[0]=x; _v[1]=y; _v[2]=z;
+        }
+
+        inline void set( const Vec3d& rhs)
+        {
+            _v[0]=rhs._v[0]; _v[1]=rhs._v[1]; _v[2]=rhs._v[2];
+        }
+
+        inline value_type& operator [] (int i) { return _v[i]; }
+        inline value_type operator [] (int i) const { return _v[i]; }
+
+        inline value_type& x() { return _v[0]; }
+        inline value_type& y() { return _v[1]; }
+        inline value_type& z() { return _v[2]; }
+
+        inline value_type x() const { return _v[0]; }
+        inline value_type y() const { return _v[1]; }
+        inline value_type z() const { return _v[2]; }
+
+        inline bool valid() const { return !isNaN(); }
+        inline bool isNaN() const { return osg::isNaN(_v[0]) || osg::isNaN(_v[1]) || osg::isNaN(_v[2]); }
+
+        /// dot product
+        inline value_type operator * (const Vec3d& rhs) const
+        {
+            return _v[0]*rhs._v[0]+_v[1]*rhs._v[1]+_v[2]*rhs._v[2];
+        }
+
+        /// cross product
+        inline const Vec3d operator ^ (const Vec3d& rhs) const
+        {
+            return Vec3d(_v[1]*rhs._v[2]-_v[2]*rhs._v[1],
+                _v[2]*rhs._v[0]-_v[0]*rhs._v[2] ,
+                _v[0]*rhs._v[1]-_v[1]*rhs._v[0]);
+        }
+
+        /// multiply by scalar
+        inline const Vec3d operator * (value_type rhs) const
+        {
+            return Vec3d(_v[0]*rhs, _v[1]*rhs, _v[2]*rhs);
+        }
+
+        /// unary multiply by scalar
+        inline Vec3d& operator *= (value_type rhs)
+        {
+            _v[0]*=rhs;
+            _v[1]*=rhs;
+            _v[2]*=rhs;
+            return *this;
+        }
+
+        /// divide by scalar
+        inline const Vec3d operator / (value_type rhs) const
+        {
+            return Vec3d(_v[0]/rhs, _v[1]/rhs, _v[2]/rhs);
+        }
+
+        /// unary divide by scalar
+        inline Vec3d& operator /= (value_type rhs)
+        {
+            _v[0]/=rhs;
+            _v[1]/=rhs;
+            _v[2]/=rhs;
+            return *this;
+        }
+
+        /// binary vector add
+        inline const Vec3d operator + (const Vec3d& rhs) const
+        {
+            return Vec3d(_v[0]+rhs._v[0], _v[1]+rhs._v[1], _v[2]+rhs._v[2]);
+        }
+
+        /** unary vector add.  Slightly more efficient because no temporary
+            intermediate object*/
+        inline Vec3d& operator += (const Vec3d& rhs)
+        {
+            _v[0] += rhs._v[0];
+            _v[1] += rhs._v[1];
+            _v[2] += rhs._v[2];
+            return *this;
+        }
+
+        /// binary vector subtract
+        inline const Vec3d operator - (const Vec3d& rhs) const
+        {
+            return Vec3d(_v[0]-rhs._v[0], _v[1]-rhs._v[1], _v[2]-rhs._v[2]);
+        }
+
+        /// unary vector subtract
+        inline Vec3d& operator -= (const Vec3d& rhs)
+        {
+            _v[0]-=rhs._v[0];
+            _v[1]-=rhs._v[1];
+            _v[2]-=rhs._v[2];
+            return *this;
+        }
+
+        /// negation operator.  Returns the negative of the Vec3d
+        inline const Vec3d operator - () const
+        {
+            return Vec3d (-_v[0], -_v[1], -_v[2]);
+        }
+
+        /// Length of the vector = sqrt( vec . vec )
+        inline value_type length() const
+        {
+            return sqrt( _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] );
+        }
+
+        /// Length squared of the vector = vec . vec
+        inline value_type length2() const
+        {
+            return _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2];
+        }
+
+        /** normalize the vector so that it has length unity
+            returns the previous length of the vector*/
+        inline value_type normalize()
+        {
+            value_type norm = Vec3d::length();
+            if (norm>0.0)
+            {
+                value_type inv = 1.0/norm;
+                _v[0] *= inv;
+                _v[1] *= inv;
+                _v[2] *= inv;
+            }                
+            return( norm );
+        }
+
+	friend inline std::ostream& operator << (std::ostream& output, const Vec3d& vec);
+
+};	// end of class Vec3d
+
+inline std::ostream& operator << (std::ostream& output, const Vec3d& vec)
+{
+    output << vec._v[0] << " "
+           << vec._v[1] << " "
+           << vec._v[2];
+    return output; 	// to enable cascading
+}
+
+}	// end of namespace osg
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Matrix
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Matrix (revision 2242)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Matrix (revision 2242)
@@ -0,0 +1,36 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_MATRIX
+#define OSG_MATRIX 1
+
+#include <osg/Matrixd>
+#include <osg/Matrixf>
+
+#define OSG_USE_DOUBLE_MATRICES 1
+
+namespace osg {
+
+#ifdef OSG_USE_DOUBLE_MATRICES
+    typedef Matrixd Matrix;
+    typedef RefMatrixd RefMatrix;
+#else
+    typedef Matrixf Matrix;
+    typedef RefMatrixf RefMatrix;
+
+#endif
+
+} //namespace osg
+
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/VertexProgram
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/VertexProgram (revision 3159)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/VertexProgram (revision 3159)
@@ -0,0 +1,276 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_VERTEXPROGRAM
+#define OSG_VERTEXPROGRAM 1
+
+#include <osg/StateAttribute>
+#include <osg/Vec4>
+#include <osg/Matrix>
+#include <osg/buffered_value>
+
+#include <map>
+#include <string>
+
+// if not defined by gl.h use the definition found in:
+// http://oss.sgi.com/projects/ogl-sample/registry/ARB/vertex_program.txt
+#ifndef GL_ARB_vertex_program
+#define GL_VERTEX_PROGRAM_ARB                              0x8620
+#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB                   0x8642
+#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB                     0x8643
+#define GL_COLOR_SUM_ARB                                   0x8458
+#define GL_PROGRAM_FORMAT_ASCII_ARB                        0x8875
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB                 0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB                    0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB                  0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB                    0x8625
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB              0x886A
+#define GL_CURRENT_VERTEX_ATTRIB_ARB                       0x8626
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB                 0x8645
+#define GL_PROGRAM_LENGTH_ARB                              0x8627
+#define GL_PROGRAM_FORMAT_ARB                              0x8876
+#define GL_PROGRAM_BINDING_ARB                             0x8677
+#define GL_PROGRAM_INSTRUCTIONS_ARB                        0x88A0
+#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB                    0x88A1
+#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB                 0x88A2
+#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB             0x88A3
+#define GL_PROGRAM_TEMPORARIES_ARB                         0x88A4
+#define GL_MAX_PROGRAM_TEMPORARIES_ARB                     0x88A5
+#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB                  0x88A6
+#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB              0x88A7
+#define GL_PROGRAM_PARAMETERS_ARB                          0x88A8
+#define GL_MAX_PROGRAM_PARAMETERS_ARB                      0x88A9
+#define GL_PROGRAM_NATIVE_PARAMETERS_ARB                   0x88AA
+#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB               0x88AB
+#define GL_PROGRAM_ATTRIBS_ARB                             0x88AC
+#define GL_MAX_PROGRAM_ATTRIBS_ARB                         0x88AD
+#define GL_PROGRAM_NATIVE_ATTRIBS_ARB                      0x88AE
+#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB                  0x88AF
+#define GL_PROGRAM_ADDRESS_REGISTERS_ARB                   0x88B0
+#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB               0x88B1
+#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB            0x88B2
+#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB        0x88B3
+#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB                0x88B4
+#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB                  0x88B5
+#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB                 0x88B6
+#define GL_PROGRAM_STRING_ARB                              0x8628
+#define GL_PROGRAM_ERROR_POSITION_ARB                      0x864B
+#define GL_CURRENT_MATRIX_ARB                              0x8641
+#define GL_TRANSPOSE_CURRENT_MATRIX_ARB                    0x88B7
+#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB                  0x8640
+#define GL_MAX_VERTEX_ATTRIBS_ARB                          0x8869
+#define GL_MAX_PROGRAM_MATRICES_ARB                        0x862F
+#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB              0x862E
+#define GL_PROGRAM_ERROR_STRING_ARB                        0x8874
+#define GL_MATRIX0_ARB                                     0x88C0
+#define GL_MATRIX1_ARB                                     0x88C1
+#define GL_MATRIX2_ARB                                     0x88C2
+#define GL_MATRIX3_ARB                                     0x88C3
+#define GL_MATRIX4_ARB                                     0x88C4
+#define GL_MATRIX5_ARB                                     0x88C5
+#define GL_MATRIX6_ARB                                     0x88C6
+#define GL_MATRIX7_ARB                                     0x88C7
+#define GL_MATRIX8_ARB                                     0x88C8
+#define GL_MATRIX9_ARB                                     0x88C9
+#define GL_MATRIX10_ARB                                    0x88CA
+#define GL_MATRIX11_ARB                                    0x88CB
+#define GL_MATRIX12_ARB                                    0x88CC
+#define GL_MATRIX13_ARB                                    0x88CD
+#define GL_MATRIX14_ARB                                    0x88CE
+#define GL_MATRIX15_ARB                                    0x88CF
+#define GL_MATRIX16_ARB                                    0x88D0
+#define GL_MATRIX17_ARB                                    0x88D1
+#define GL_MATRIX18_ARB                                    0x88D2
+#define GL_MATRIX19_ARB                                    0x88D3
+#define GL_MATRIX20_ARB                                    0x88D4
+#define GL_MATRIX21_ARB                                    0x88D5
+#define GL_MATRIX22_ARB                                    0x88D6
+#define GL_MATRIX23_ARB                                    0x88D7
+#define GL_MATRIX24_ARB                                    0x88D8
+#define GL_MATRIX25_ARB                                    0x88D9
+#define GL_MATRIX26_ARB                                    0x88DA
+#define GL_MATRIX27_ARB                                    0x88DB
+#define GL_MATRIX28_ARB                                    0x88DC
+#define GL_MATRIX29_ARB                                    0x88DD
+#define GL_MATRIX30_ARB                                    0x88DE
+#define GL_MATRIX31_ARB                                    0x88DF
+#endif
+
+
+namespace osg {
+
+
+
+/** VertexProgram - encapsulates the OpenGL ARB vertex program state.*/
+class SG_EXPORT VertexProgram : public StateAttribute
+{
+    public:
+
+        VertexProgram();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        VertexProgram(const VertexProgram& vp,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+        META_StateAttribute(osg, VertexProgram, VERTEXPROGRAM);
+
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const osg::StateAttribute& sa) const
+        {
+            // check the types are equal and then create the rhs variable
+            // used by the COMPARE_StateAttribute_Paramter macro's below.
+            COMPARE_StateAttribute_Types(VertexProgram,sa)
+
+            // compare each paramter in turn against the rhs.
+            COMPARE_StateAttribute_Parameter(_vertexProgram)
+
+            return 0; // passed all the above comparison macro's, must be equal.
+        }
+
+        virtual bool getModeUsage(ModeUsage& usage) const
+        {
+            usage.usesMode(GL_VERTEX_PROGRAM_ARB);
+            return true;
+        }
+
+        // data access methods.
+
+        /** Get the handle to the vertex program id for the current context.*/
+        inline GLuint& getVertexProgramID(unsigned int contextID) const
+        {
+            return _vertexProgramIDList[contextID];
+        }
+
+        /** Set the vertex program using C++ style string.*/
+        inline void setVertexProgram( const std::string& program )
+        {
+            _vertexProgram = program;
+            dirtyVertexProgramObject();
+        }
+        
+        /** Set the vertex program using a C style string.*/
+        inline void setVertexProgram( const char* program ) 
+        { 
+            _vertexProgram = program; 
+            dirtyVertexProgramObject();
+        }
+        /** Get the vertex program.*/
+        inline const std::string& getVertexProgram() const { return _vertexProgram; }
+
+        /** Program Parameters */
+        inline void setProgramLocalParameter(const GLuint index, const Vec4& p)
+        {
+            _programLocalParameters[index] = p;
+        }
+
+        /** Matrix */
+        inline void setMatrix(const GLenum mode, const Matrix& matrix)
+        {
+            _matrixList[mode] = matrix;
+        }
+
+        /** Force a recompile on next apply() of associated OpenGL vertex program objects.*/
+        void dirtyVertexProgramObject();        
+
+        /** use deleteVertexProgramObject instead of glDeletePrograms to allow
+          * OpenGL Vertex Program objects to cached until they can be deleted
+          * by the OpenGL context in which they were created, specified
+          * by contextID.*/
+        static void deleteVertexProgramObject(unsigned int contextID,GLuint handle);
+
+        /** flush all the cached vertex programs which need to be deleted
+          * in the OpenGL context related to contextID.*/
+        static void flushDeletedVertexProgramObjects(unsigned int contextID,double currentTime, double& availableTime);
+
+        virtual void apply(State& state) const;
+
+        virtual void compileGLObjects(State& state) const { apply(state); }
+
+        /** release an OpenGL objects in specified graphics context if State
+            object is passed, otherwise release OpenGL objexts for all graphics context if
+            State object pointer NULL.*/
+        virtual void releaseGLObjects(State* state=0) const;
+
+        /** Extensions class which encapsulates the querring of extensions and
+          * associated function pointers, and provide convinience wrappers to 
+          * check for the extensions or use the associated functions.*/        
+        class SG_EXPORT Extensions : public osg::Referenced
+        {
+            public:
+                Extensions();
+
+                Extensions(const Extensions& rhs);
+                
+                void lowestCommonDenominator(const Extensions& rhs);
+                
+                void setupGLExtenions();
+
+                void setVertexProgramSupported(bool flag) { _isVertexProgramSupported=flag; }
+                bool isVertexProgramSupported() const { return _isVertexProgramSupported; }
+
+                void glBindProgram(GLenum target, GLuint id) const;
+                void glGenPrograms(GLsizei n, GLuint *programs) const;
+                void glDeletePrograms(GLsizei n, GLuint *programs) const;
+                void glProgramString(GLenum target, GLenum format, GLsizei len, const void *string) const; 
+                void glProgramLocalParameter4fv(GLenum target, GLuint index, const GLfloat *params) const;
+
+            protected:
+
+                ~Extensions() {}
+                
+                bool _isVertexProgramSupported;
+                
+                void* _glBindProgram;
+                void* _glGenPrograms;
+                void *_glDeletePrograms;
+                void* _glProgramString;
+                void* _glProgramLocalParameter4fv;
+ 
+        };
+        
+        /** Function to call to get the extension of a specified context.
+          * If the Exentsion object for that context has not yet been created then 
+          * and the 'createIfNotInitalized' flag been set to false then returns NULL.
+          * If 'createIfNotInitalized' is true then the Extensions object is 
+          * automatically created.  However, in this case the extension object 
+          * only be created with the graphics context associated with ContextID..*/
+        static Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized);
+
+        /** setExtensions allows users to override the extensions across graphics contexts.
+          * typically used when you have different extensions supported across graphics pipes
+          * but need to ensure that they all use the same low common denominator extensions.*/
+        static void setExtensions(unsigned int contextID,Extensions* extensions);
+
+
+    protected:
+
+
+        virtual ~VertexProgram();
+
+        typedef buffered_value<GLuint> VertexProgramIDList;
+        mutable VertexProgramIDList _vertexProgramIDList;
+
+        std::string     _vertexProgram;
+
+        typedef std::map<GLuint,Vec4> LocalParamList;
+        LocalParamList  _programLocalParameters;
+
+        typedef std::map<GLenum,Matrix> MatrixList;
+        MatrixList  _matrixList;
+};
+
+
+
+}
+
+#endif
+
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TexEnvCombine
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TexEnvCombine (revision 2491)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/TexEnvCombine (revision 2491)
@@ -0,0 +1,275 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_TEXENVCOMBINE
+#define OSG_TEXENVCOMBINE 1
+
+#include <osg/GL>
+#include <osg/StateAttribute>
+#include <osg/Vec4>
+
+// if not defined by gl.h use the definition found in:
+// http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_env_combine.txt
+#ifndef GL_ARB_texture_env_combine
+#define GL_COMBINE_ARB                                     0x8570
+#define GL_COMBINE_RGB_ARB                                 0x8571
+#define GL_COMBINE_ALPHA_ARB                               0x8572
+#define GL_SOURCE0_RGB_ARB                                 0x8580
+#define GL_SOURCE1_RGB_ARB                                 0x8581
+#define GL_SOURCE2_RGB_ARB                                 0x8582
+#define GL_SOURCE0_ALPHA_ARB                               0x8588
+#define GL_SOURCE1_ALPHA_ARB                               0x8589
+#define GL_SOURCE2_ALPHA_ARB                               0x858A
+#define GL_OPERAND0_RGB_ARB                                0x8590
+#define GL_OPERAND1_RGB_ARB                                0x8591
+#define GL_OPERAND2_RGB_ARB                                0x8592
+#define GL_OPERAND0_ALPHA_ARB                              0x8598
+#define GL_OPERAND1_ALPHA_ARB                              0x8599
+#define GL_OPERAND2_ALPHA_ARB                              0x859A
+#define GL_RGB_SCALE_ARB                                   0x8573
+#define GL_ADD_SIGNED_ARB                                  0x8574
+#define GL_INTERPOLATE_ARB                                 0x8575
+#define GL_SUBTRACT_ARB                                    0x84E7
+#define GL_CONSTANT_ARB                                    0x8576
+#define GL_PRIMARY_COLOR_ARB                               0x8577
+#define GL_PREVIOUS_ARB                                    0x8578
+#endif
+
+#ifndef GL_ARB_texture_env_dot3
+#define GL_DOT3_RGB_ARB                                    0x86AE
+#define GL_DOT3_RGBA_ARB                                   0x86AF
+#endif
+
+#ifndef GL_TEXTURE0
+#define GL_TEXTURE0 0x84C0
+#endif
+
+namespace osg {
+
+/** TexEnvCombine - encapsulates the OpenGL glTexEnvCombine (texture environment) state.*/
+class SG_EXPORT TexEnvCombine : public StateAttribute
+{
+    public :
+
+        TexEnvCombine();
+        
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        TexEnvCombine(const TexEnvCombine& texenv,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            StateAttribute(texenv,copyop),
+            _needsTexEnvCrossbar(texenv._needsTexEnvCrossbar),
+            _combine_RGB(texenv._combine_RGB),
+            _combine_Alpha(texenv._combine_Alpha),
+            _source0_RGB(texenv._source0_RGB),
+            _source1_RGB(texenv._source1_RGB),
+            _source2_RGB(texenv._source2_RGB),
+            _source0_Alpha(texenv._source0_Alpha),
+            _source1_Alpha(texenv._source1_Alpha),
+            _source2_Alpha(texenv._source2_Alpha),
+            _operand0_RGB(texenv._operand0_RGB),
+            _operand1_RGB(texenv._operand1_RGB),
+            _operand2_RGB(texenv._operand2_RGB),
+            _operand0_Alpha(texenv._operand0_Alpha),
+            _operand1_Alpha(texenv._operand1_Alpha),
+            _operand2_Alpha(texenv._operand2_Alpha),
+            _scale_RGB(texenv._scale_RGB),
+            _scale_Alpha(texenv._scale_Alpha),
+            _constantColor(texenv._constantColor) {}
+
+
+        META_StateAttribute(osg, TexEnvCombine, TEXENV);
+
+
+        virtual bool isTextureAttribute() const { return true; }
+
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const StateAttribute& sa) const
+        {
+            // check the types are equal and then create the rhs variable
+            // used by the COMPARE_StateAttribute_Paramter macro's below.
+            COMPARE_StateAttribute_Types(TexEnvCombine,sa)
+
+            // compare each paramter in turn against the rhs.
+            COMPARE_StateAttribute_Parameter(_needsTexEnvCrossbar)
+            COMPARE_StateAttribute_Parameter(_combine_RGB)
+            COMPARE_StateAttribute_Parameter(_combine_Alpha)
+            COMPARE_StateAttribute_Parameter(_source0_RGB)
+            COMPARE_StateAttribute_Parameter(_source1_RGB)
+            COMPARE_StateAttribute_Parameter(_source2_RGB)
+            COMPARE_StateAttribute_Parameter(_source0_Alpha)
+            COMPARE_StateAttribute_Parameter(_source1_Alpha)
+            COMPARE_StateAttribute_Parameter(_source2_Alpha)
+            COMPARE_StateAttribute_Parameter(_operand0_RGB)
+            COMPARE_StateAttribute_Parameter(_operand1_RGB)
+            COMPARE_StateAttribute_Parameter(_operand2_RGB)
+            COMPARE_StateAttribute_Parameter(_operand0_Alpha)
+            COMPARE_StateAttribute_Parameter(_operand1_Alpha)
+            COMPARE_StateAttribute_Parameter(_operand2_Alpha)
+            COMPARE_StateAttribute_Parameter(_scale_RGB)
+            COMPARE_StateAttribute_Parameter(_scale_Alpha)
+            COMPARE_StateAttribute_Parameter(_constantColor)
+
+            return 0; // passed all the above comparison macro's, must be equal.
+        }
+
+
+        enum CombineParam
+        {
+            REPLACE         = GL_REPLACE,
+            MODULATE        = GL_MODULATE,
+            ADD             = GL_ADD,
+            ADD_SIGNED      = GL_ADD_SIGNED_ARB,
+            INTERPOLATE     = GL_INTERPOLATE_ARB,
+            SUBTRACT        = GL_SUBTRACT_ARB,
+            DOT3_RGB        = GL_DOT3_RGB_ARB,
+            DOT3_RGBA       = GL_DOT3_RGBA_ARB
+        };
+
+        void setCombine_RGB(GLint cm);
+        void setCombine_Alpha(GLint cm);
+
+        GLint getCombine_RGB() const { return _combine_RGB; }
+        GLint getCombine_Alpha() const { return _combine_Alpha; }
+        
+        enum SourceParam
+        {
+            CONSTANT        = GL_CONSTANT_ARB,
+            PRIMARY_COLOR   = GL_PRIMARY_COLOR_ARB,
+            PREVIOUS        = GL_PREVIOUS_ARB,
+            TEXTURE         = GL_TEXTURE,
+            TEXTURE0        = GL_TEXTURE0,
+            TEXTURE1        = GL_TEXTURE0+1,
+            TEXTURE2        = GL_TEXTURE0+2,
+            TEXTURE3        = GL_TEXTURE0+3,
+            TEXTURE4        = GL_TEXTURE0+4,
+            TEXTURE5        = GL_TEXTURE0+5,
+            TEXTURE6        = GL_TEXTURE0+6,
+            TEXTURE7        = GL_TEXTURE0+7
+        };
+        
+        void setSource0_RGB(GLint sp);
+        void setSource1_RGB(GLint sp);
+        void setSource2_RGB(GLint sp);
+        
+        void setSource0_Alpha(GLint sp);
+        void setSource1_Alpha(GLint sp);
+        void setSource2_Alpha(GLint sp);
+
+        GLint getSource0_RGB() const { return _source0_RGB; }
+        GLint getSource1_RGB() const { return _source1_RGB; }
+        GLint getSource2_RGB() const { return _source2_RGB; }
+        
+        GLint getSource0_Alpha() const { return _source0_Alpha; }
+        GLint getSource1_Alpha() const { return _source1_Alpha; }
+        GLint getSource2_Alpha() const { return _source2_Alpha; }
+
+        enum OperandParam
+        {
+            SRC_COLOR           = GL_SRC_COLOR,
+            ONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR,
+            SRC_ALPHA           = GL_SRC_ALPHA,
+            ONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA
+        };
+        
+        void setOperand0_RGB(GLint op);
+        void setOperand1_RGB(GLint op);
+        void setOperand2_RGB(GLint op);
+        
+        void setOperand0_Alpha(GLint op);
+        void setOperand1_Alpha(GLint op);
+        void setOperand2_Alpha(GLint op);
+
+        GLint getOperand0_RGB() const { return _operand0_RGB; }
+        GLint getOperand1_RGB() const { return _operand1_RGB; }
+        GLint getOperand2_RGB() const { return _operand2_RGB; }
+        
+        GLint getOperand0_Alpha() const { return _operand0_Alpha; }
+        GLint getOperand1_Alpha() const { return _operand1_Alpha; }
+        GLint getOperand2_Alpha() const { return _operand2_Alpha; }
+
+
+        void setScale_RGB(float scale);
+        void setScale_Alpha(float scale);
+
+        float getScale_RGB() const { return _scale_RGB; }
+        float getScale_Alpha() const { return _scale_Alpha; }
+
+        void setConstantColor( const Vec4& color ) { _constantColor = color; }
+        const Vec4& getConstantColor() const { return _constantColor; }
+
+
+        virtual void apply(State& state) const;
+
+    protected :
+
+        virtual ~TexEnvCombine();
+
+        inline bool needsTexEnvCombiner(GLint value) const
+        {
+            switch(value)
+            {
+                case(CONSTANT):
+                case(PRIMARY_COLOR):
+                case(PREVIOUS):
+                case(TEXTURE):
+                    return false;
+            }
+            return true;
+        }
+
+        void computeNeedoForTexEnvCombiners()
+        {
+            _needsTexEnvCrossbar = (needsTexEnvCombiner(_source0_RGB) ||
+                                    needsTexEnvCombiner(_source1_RGB) ||
+                                    needsTexEnvCombiner(_source2_RGB) ||
+                                    needsTexEnvCombiner(_source0_Alpha) ||
+                                    needsTexEnvCombiner(_source1_Alpha) ||
+                                    needsTexEnvCombiner(_source2_Alpha)); 
+        }
+        
+
+        
+
+
+        bool            _needsTexEnvCrossbar;
+
+        GLint           _combine_RGB;
+        GLint           _combine_Alpha;
+    
+        GLint           _source0_RGB;
+        GLint           _source1_RGB;
+        GLint           _source2_RGB;
+        
+        GLint           _source0_Alpha;
+        GLint           _source1_Alpha;
+        GLint           _source2_Alpha;
+
+
+        GLint           _operand0_RGB;
+        GLint           _operand1_RGB;
+        GLint           _operand2_RGB;
+        
+        GLint           _operand0_Alpha;
+        GLint           _operand1_Alpha;
+        GLint           _operand2_Alpha;
+
+
+        float           _scale_RGB;
+        float           _scale_Alpha;
+        
+        osg::Vec4       _constantColor;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec3f
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec3f (revision 3230)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Vec3f (revision 3230)
@@ -0,0 +1,206 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_VEC3F
+#define OSG_VEC3F 1
+
+#include <ostream>
+
+#include <osg/Math>
+
+namespace osg {
+
+/** General purpose float triple for use as vertices, vectors and normals.
+    Provides general maths operations from addition through to cross products.
+    No support yet added for float * Vec3f - is it necessary?
+    Need to define a non-member non-friend operator*  etc.
+   			     Vec3f * float is okay
+*/
+class Vec3f
+{
+    public:
+
+        typedef float value_type;
+        value_type _v[3];
+
+        Vec3f() { _v[0]=0.0; _v[1]=0.0; _v[2]=0.0;}
+        Vec3f(value_type x,value_type y,value_type z) { _v[0]=x; _v[1]=y; _v[2]=z; }
+
+
+	inline bool operator == (const Vec3f& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1] && _v[2]==v._v[2]; }
+        
+        inline bool operator != (const Vec3f& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1] || _v[2]!=v._v[2]; }
+
+	inline bool operator <  (const Vec3f& v) const
+        {
+            if (_v[0]<v._v[0]) return true;
+            else if (_v[0]>v._v[0]) return false;
+            else if (_v[1]<v._v[1]) return true;
+            else if (_v[1]>v._v[1]) return false;
+            else return (_v[2]<v._v[2]);
+        }
+
+        inline value_type* ptr() { return _v; }
+        inline const value_type* ptr() const { return _v; }
+
+        inline void set( value_type x, value_type y, value_type z)
+        {
+            _v[0]=x; _v[1]=y; _v[2]=z;
+        }
+
+        inline void set( const Vec3f& rhs)
+        {
+            _v[0]=rhs._v[0]; _v[1]=rhs._v[1]; _v[2]=rhs._v[2];
+        }
+
+        inline value_type& operator [] (int i) { return _v[i]; }
+        inline value_type operator [] (int i) const { return _v[i]; }
+
+        inline value_type& x() { return _v[0]; }
+        inline value_type& y() { return _v[1]; }
+        inline value_type& z() { return _v[2]; }
+
+        inline value_type x() const { return _v[0]; }
+        inline value_type y() const { return _v[1]; }
+        inline value_type z() const { return _v[2]; }
+
+        inline bool valid() const { return !isNaN(); }
+        inline bool isNaN() const { return osg::isNaN(_v[0]) || osg::isNaN(_v[1]) || osg::isNaN(_v[2]); }
+
+        /// dot product
+        inline value_type operator * (const Vec3f& rhs) const
+        {
+            return _v[0]*rhs._v[0]+_v[1]*rhs._v[1]+_v[2]*rhs._v[2];
+        }
+
+        /// cross product
+        inline const Vec3f operator ^ (const Vec3f& rhs) const
+        {
+            return Vec3f(_v[1]*rhs._v[2]-_v[2]*rhs._v[1],
+                _v[2]*rhs._v[0]-_v[0]*rhs._v[2] ,
+                _v[0]*rhs._v[1]-_v[1]*rhs._v[0]);
+        }
+
+        /// multiply by scalar
+        inline const Vec3f operator * (value_type rhs) const
+        {
+            return Vec3f(_v[0]*rhs, _v[1]*rhs, _v[2]*rhs);
+        }
+
+        /// unary multiply by scalar
+        inline Vec3f& operator *= (value_type rhs)
+        {
+            _v[0]*=rhs;
+            _v[1]*=rhs;
+            _v[2]*=rhs;
+            return *this;
+        }
+
+        /// divide by scalar
+        inline const Vec3f operator / (value_type rhs) const
+        {
+            return Vec3f(_v[0]/rhs, _v[1]/rhs, _v[2]/rhs);
+        }
+
+        /// unary divide by scalar
+        inline Vec3f& operator /= (value_type rhs)
+        {
+            _v[0]/=rhs;
+            _v[1]/=rhs;
+            _v[2]/=rhs;
+            return *this;
+        }
+
+        /// binary vector add
+        inline const Vec3f operator + (const Vec3f& rhs) const
+        {
+            return Vec3f(_v[0]+rhs._v[0], _v[1]+rhs._v[1], _v[2]+rhs._v[2]);
+        }
+
+        /** unary vector add.  Slightly more efficient because no temporary
+            intermediate object*/
+        inline Vec3f& operator += (const Vec3f& rhs)
+        {
+            _v[0] += rhs._v[0];
+            _v[1] += rhs._v[1];
+            _v[2] += rhs._v[2];
+            return *this;
+        }
+
+        /// binary vector subtract
+        inline const Vec3f operator - (const Vec3f& rhs) const
+        {
+            return Vec3f(_v[0]-rhs._v[0], _v[1]-rhs._v[1], _v[2]-rhs._v[2]);
+        }
+
+        /// unary vector subtract
+        inline Vec3f& operator -= (const Vec3f& rhs)
+        {
+            _v[0]-=rhs._v[0];
+            _v[1]-=rhs._v[1];
+            _v[2]-=rhs._v[2];
+            return *this;
+        }
+
+        /// negation operator.  Returns the negative of the Vec3f
+        inline const Vec3f operator - () const
+        {
+            return Vec3f (-_v[0], -_v[1], -_v[2]);
+        }
+
+        /// Length of the vector = sqrt( vec . vec )
+        inline value_type length() const
+        {
+            return sqrtf( _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] );
+        }
+
+        /// Length squared of the vector = vec . vec
+        inline value_type length2() const
+        {
+            return _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2];
+        }
+
+        /** normalize the vector so that it has length unity
+            returns the previous length of the vector*/
+        inline value_type normalize()
+        {
+            value_type norm = Vec3f::length();
+            if (norm>0.0)
+            {
+                value_type inv = 1.0f/norm;
+                _v[0] *= inv;
+                _v[1] *= inv;
+                _v[2] *= inv;
+            }                
+            return( norm );
+        }
+
+	friend inline std::ostream& operator << (std::ostream& output, const Vec3f& vec);
+
+};	// end of class Vec3f
+
+inline std::ostream& operator << (std::ostream& output, const Vec3f& vec)
+{
+    output << vec._v[0] << " "
+           << vec._v[1] << " "
+           << vec._v[2];
+    return output; 	// to enable cascading
+}
+
+const Vec3f X_AXIS(1.0,0.0,0.0);
+const Vec3f Y_AXIS(0.0,1.0,0.0);
+const Vec3f Z_AXIS(0.0,0.0,1.0);
+
+}	// end of namespace osg
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ClipPlane
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ClipPlane (revision 2773)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ClipPlane (revision 2773)
@@ -0,0 +1,113 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_CLIPPLANE
+#define OSG_CLIPPLANE 1
+
+#include <osg/Plane>
+#include <osg/StateAttribute>
+
+namespace osg {
+
+/** ClipPlane state class which encapsulates OpenGL glClipPlane() functionality.*/
+class SG_EXPORT ClipPlane : public StateAttribute
+{
+    public :
+
+        ClipPlane();
+        inline ClipPlane(unsigned int no,const Vec4& plane)    { setClipPlaneNum(no); setClipPlane(plane); }
+        inline ClipPlane(unsigned int no,const Plane& plane)   { setClipPlaneNum(no); setClipPlane(plane); }
+        inline ClipPlane(unsigned int no,double a,double b,double c,double d)  { setClipPlaneNum(no); setClipPlane(a,b,c,d); }
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        ClipPlane(const ClipPlane& cp,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            StateAttribute(cp,copyop)
+        {
+            _clipPlane[0]=cp._clipPlane[0];
+            _clipPlane[1]=cp._clipPlane[1];
+            _clipPlane[2]=cp._clipPlane[2];
+            _clipPlane[3]=cp._clipPlane[3];
+            _clipPlaneNum=cp._clipPlaneNum;
+        }
+        
+        META_StateAttribute(osg, ClipPlane, (Type)(CLIPPLANE+_clipPlaneNum));
+        
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const StateAttribute& sa) const
+        {
+            // check the types are equal and then create the rhs variable
+            // used by the COMPARE_StateAttribute_Paramter macro's below.
+            COMPARE_StateAttribute_Types(ClipPlane,sa)
+
+            // compare each paramter in turn against the rhs.
+            COMPARE_StateAttribute_Parameter(_clipPlaneNum)
+            COMPARE_StateAttribute_Parameter(_clipPlane[0])
+            COMPARE_StateAttribute_Parameter(_clipPlane[1])
+            COMPARE_StateAttribute_Parameter(_clipPlane[2])
+            COMPARE_StateAttribute_Parameter(_clipPlane[3])
+
+            return 0; // passed all the above comparison macro's, must be equal.
+        }
+
+        virtual bool getModeUsage(ModeUsage& usage) const
+        {
+            usage.usesMode((GLMode)(GL_CLIP_PLANE0+_clipPlaneNum));
+            return true;
+        }
+
+
+	/** Set the clip plane, using a Vec4 to define plane. */
+        void setClipPlane(const Vec4& plane);
+
+	/** Set the clip plane, using a Plane to define plane. */
+        void setClipPlane(const Plane& plane);
+
+	/** Set the clip plane, using a double[4] to define plane. */
+        void setClipPlane(const double* plane);
+
+	/** Set the clip plane, using a a to define plane. */
+        void setClipPlane(double a,double b,double c,double d)
+        {
+            _clipPlane[0]=a;_clipPlane[1]=b;_clipPlane[2]=c;_clipPlane[3]=d;
+        }
+
+	/** Get the clip plane, values entered into a Vec4 passed to the getClipPlane. */
+        void getClipPlane(Vec4& plane) const;
+
+	/** Get the clip plane, values entered into a Plane passed to the getClipPlane. */
+        void getClipPlane(Plane& plane) const;
+
+	/** Get the clip plane, values entered into a double[4] passed to the getClipPlane. */
+        void getClipPlane(double* plane) const;
+
+	/** Set the clip plane number. */
+        void setClipPlaneNum(unsigned int num);
+
+	/** Get the clip plane number. */
+        unsigned int getClipPlaneNum() const;
+
+	/** Apply the clip plane's state to the OpenGL state machine. */
+        virtual void apply(State& state) const;
+
+    protected :
+    
+        virtual ~ClipPlane();
+        
+        double              _clipPlane[4];
+        unsigned int        _clipPlaneNum;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Matrixd
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Matrixd (revision 3008)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Matrixd (revision 3008)
@@ -0,0 +1,615 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_MATRIXD
+#define OSG_MATRIXD 1
+
+#include <osg/Object>
+#include <osg/Vec3f>
+#include <osg/Vec3d>
+#include <osg/Vec4f>
+#include <osg/Vec4d>
+#include <osg/Quat>
+
+#include <string.h>
+
+#include <ostream>
+#include <algorithm>
+
+namespace osg {
+
+class Matrixf;
+
+class SG_EXPORT Matrixd
+{
+
+    public:
+    
+        typedef double value_type;
+
+        inline Matrixd() { makeIdentity(); }
+        inline Matrixd( const Matrixd& mat) { set(mat.ptr()); }
+        Matrixd( const Matrixf& mat );
+        inline explicit Matrixd( float const * const ptr ) { set(ptr); }
+        inline explicit Matrixd( double const * const ptr ) { set(ptr); }
+        inline explicit Matrixd( const Quat& quat ) { set(quat); }
+
+        Matrixd( value_type a00, value_type a01, value_type a02, value_type a03,
+                 value_type a10, value_type a11, value_type a12, value_type a13,
+                 value_type a20, value_type a21, value_type a22, value_type a23,
+                 value_type a30, value_type a31, value_type a32, value_type a33);
+
+        ~Matrixd() {}
+
+        int compare(const Matrixd& m) const { return memcmp(_mat,m._mat,sizeof(_mat)); }
+
+        bool operator < (const Matrixd& m) const { return compare(m)<0; }
+        bool operator == (const Matrixd& m) const { return compare(m)==0; }
+        bool operator != (const Matrixd& m) const { return compare(m)!=0; }
+
+        inline value_type& operator()(int row, int col) { return _mat[row][col]; }
+        inline value_type operator()(int row, int col) const { return _mat[row][col]; }
+
+        inline bool valid() const { return !isNaN(); }
+        inline bool isNaN() const { return osg::isNaN(_mat[0][0]) || osg::isNaN(_mat[0][1]) || osg::isNaN(_mat[0][2]) || osg::isNaN(_mat[0][3]) ||
+                                                 osg::isNaN(_mat[1][0]) || osg::isNaN(_mat[1][1]) || osg::isNaN(_mat[1][2]) || osg::isNaN(_mat[1][3]) ||
+                                                 osg::isNaN(_mat[2][0]) || osg::isNaN(_mat[2][1]) || osg::isNaN(_mat[2][2]) || osg::isNaN(_mat[2][3]) ||
+                                                 osg::isNaN(_mat[3][0]) || osg::isNaN(_mat[3][1]) || osg::isNaN(_mat[3][2]) || osg::isNaN(_mat[3][3]); }
+
+        inline Matrixd& operator = (const Matrixd& rhs)
+        {
+            if( &rhs == this ) return *this;
+            set(rhs.ptr());
+            return *this;
+        }
+        
+        Matrixd& operator = (const Matrixf& other);
+
+        inline void set(const Matrixd& rhs) { set(rhs.ptr()); }
+
+        void set(const Matrixf& rhs);
+
+        inline void set(float const * const ptr)
+        {
+            value_type* local_ptr = (value_type*)_mat;
+            for(int i=0;i<16;++i) local_ptr[i]=(value_type)ptr[i];
+        }
+        
+        inline void set(double const * const ptr)
+        {
+            value_type* local_ptr = (value_type*)_mat;
+            for(int i=0;i<16;++i) local_ptr[i]=(value_type)ptr[i];
+        }
+
+        void set( value_type a00, value_type a01, value_type a02, value_type a03,
+                  value_type a10, value_type a11, value_type a12, value_type a13,
+                  value_type a20, value_type a21, value_type a22, value_type a23,
+                  value_type a30, value_type a31, value_type a32, value_type a33);
+                  
+        void set(const Quat& q);
+        
+        void get(Quat& q) const;
+
+        value_type * ptr() { return (value_type*)_mat; }
+        const value_type * ptr() const { return (const value_type *)_mat; }
+
+        void makeIdentity();
+        
+        void makeScale( const Vec3f& );
+        void makeScale( const Vec3d& );
+        void makeScale( value_type, value_type, value_type );
+        
+        void makeTranslate( const Vec3f& );
+        void makeTranslate( const Vec3d& );
+        void makeTranslate( value_type, value_type, value_type );
+        
+        void makeRotate( const Vec3f& from, const Vec3f& to );
+        void makeRotate( const Vec3d& from, const Vec3d& to );
+        void makeRotate( value_type angle, const Vec3f& axis );
+        void makeRotate( value_type angle, const Vec3d& axis );
+        void makeRotate( value_type angle, value_type x, value_type y, value_type z );
+        void makeRotate( const Quat& );
+        void makeRotate( value_type angle1, const Vec3f& axis1, 
+                         value_type angle2, const Vec3f& axis2,
+                         value_type angle3, const Vec3f& axis3);
+        void makeRotate( value_type angle1, const Vec3d& axis1, 
+                         value_type angle2, const Vec3d& axis2,
+                         value_type angle3, const Vec3d& axis3);
+
+        
+        
+        /** Set to a orthographic projection. See glOrtho for further details.*/
+        void makeOrtho(double left, double right,
+                       double bottom, double top,
+                       double zNear, double zFar);
+
+        /** Get the othorgraphic settings of the orthographic projection matrix. 
+          * Note, if matrix is not an orthographic matrix then invalid values will be returned.*/
+        bool getOrtho(double& left, double& right,
+                      double& bottom, double& top,
+                      double& zNear, double& zFar) const;
+
+        /** Set to a 2D orthographic projection. See glOrtho2D for further details.*/
+        inline void makeOrtho2D(double left, double right,
+                                double bottom, double top)
+        {
+            makeOrtho(left,right,bottom,top,-1.0,1.0);
+        }
+
+
+        /** Set to a perspective projection. See glFrustum for further details.*/
+        void makeFrustum(double left, double right,
+                         double bottom, double top,
+                         double zNear, double zFar);
+
+        /** Get the frustum setting of a perspective projection matrix.
+          * Note, if matrix is not an perspective matrix then invalid values will be returned.*/
+        bool getFrustum(double& left, double& right,
+                        double& bottom, double& top,
+                        double& zNear, double& zFar) const;
+
+        /** Set to a symmetrical perspective projection, See gluPerspective for further details.
+          * Aspect ratio is defined as width/height.*/
+        void makePerspective(double fovy,double aspectRatio,
+                             double zNear, double zFar);
+
+        /** Get the frustum setting of a symetric perspective projection matrix.
+          * Returns false if matrix is not a perspective matrix, where parameter values are undefined. 
+          * Note, if matrix is not a symetric perspective matrix then the shear will be lost.
+          * Asymetric metrices occur when stereo, power walls, caves and reality center display are used.
+          * In these configuration one should use the AsFrustum method instead.*/
+        bool getPerspective(double& fovy,double& aspectRatio,
+                            double& zNear, double& zFar) const;
+
+        /** Set to the position and orientation modelview matrix, using the same convention as gluLookAt. */
+        void makeLookAt(const Vec3d& eye,const Vec3d& center,const Vec3d& up);
+
+        /** Get to the position and orientation of a modelview matrix, using the same convention as gluLookAt. */
+        void getLookAt(Vec3f& eye,Vec3f& center,Vec3f& up,value_type lookDistance=1.0f) const;
+
+        /** Get to the position and orientation of a modelview matrix, using the same convention as gluLookAt. */
+        void getLookAt(Vec3d& eye,Vec3d& center,Vec3d& up,value_type lookDistance=1.0f) const;
+
+        /** invert the matrix rhs. */
+        bool invert( const Matrixd& rhs);
+
+        /** full 4x4 matrix invert. */
+        bool invert_4x4_orig( const Matrixd& );
+
+        /** full 4x4 matrix invert. */
+        bool invert_4x4_new( const Matrixd& );
+
+        //basic utility functions to create new matrices
+	inline static Matrixd identity( void );
+        inline static Matrixd scale( const Vec3f& sv);
+        inline static Matrixd scale( const Vec3d& sv);
+        inline static Matrixd scale( value_type sx, value_type sy, value_type sz);
+        inline static Matrixd translate( const Vec3f& dv);
+        inline static Matrixd translate( const Vec3d& dv);
+        inline static Matrixd translate( value_type x, value_type y, value_type z);
+        inline static Matrixd rotate( const Vec3f& from, const Vec3f& to);
+        inline static Matrixd rotate( const Vec3d& from, const Vec3d& to);
+        inline static Matrixd rotate( value_type angle, value_type x, value_type y, value_type z);
+        inline static Matrixd rotate( value_type angle, const Vec3f& axis);
+        inline static Matrixd rotate( value_type angle, const Vec3d& axis);
+        inline static Matrixd rotate( value_type angle1, const Vec3f& axis1, 
+                                      value_type angle2, const Vec3f& axis2,
+                                      value_type angle3, const Vec3f& axis3);
+        inline static Matrixd rotate( value_type angle1, const Vec3d& axis1, 
+                                      value_type angle2, const Vec3d& axis2,
+                                      value_type angle3, const Vec3d& axis3);
+        inline static Matrixd rotate( const Quat& quat);
+        inline static Matrixd inverse( const Matrixd& matrix);
+        
+        /** Create a orthographic projection. See glOrtho for further details.*/
+        inline static Matrixd ortho(double left, double right,
+                                   double bottom, double top,
+                                   double zNear, double zFar);
+
+        /** Create a 2D orthographic projection. See glOrtho for further details.*/
+        inline static Matrixd ortho2D(double left, double right,
+                                     double bottom, double top);
+
+        /** Create a perspective projection. See glFrustum for further details.*/
+        inline static Matrixd frustum(double left, double right,
+                                     double bottom, double top,
+                                     double zNear, double zFar);
+
+        /** Create a symmetrical perspective projection, See gluPerspective for further details.
+          * Aspect ratio is defined as width/height.*/
+        inline static Matrixd perspective(double fovy,double aspectRatio,
+                                         double zNear, double zFar);
+
+        /** Create the position and orientation as per a camera, using the same convention as gluLookAt. */
+        inline static Matrixd lookAt(const Vec3f& eye,const Vec3f& center,const Vec3f& up);
+
+        /** Create the position and orientation as per a camera, using the same convention as gluLookAt. */
+        inline static Matrixd lookAt(const Vec3d& eye,const Vec3d& center,const Vec3d& up);
+
+
+
+        inline Vec3f preMult( const Vec3f& v ) const;
+        inline Vec3d preMult( const Vec3d& v ) const;
+        inline Vec3f postMult( const Vec3f& v ) const;
+        inline Vec3d postMult( const Vec3d& v ) const;
+        inline Vec3f operator* ( const Vec3f& v ) const;
+        inline Vec3d operator* ( const Vec3d& v ) const;
+        inline Vec4f preMult( const Vec4f& v ) const;
+        inline Vec4d preMult( const Vec4d& v ) const;
+        inline Vec4f postMult( const Vec4f& v ) const;
+        inline Vec4d postMult( const Vec4d& v ) const;
+        inline Vec4f operator* ( const Vec4f& v ) const;
+        inline Vec4d operator* ( const Vec4d& v ) const;
+
+        void setTrans( value_type tx, value_type ty, value_type tz );
+	void setTrans( const Vec3f& v );
+	void setTrans( const Vec3d& v );
+        
+        inline Vec3d getTrans() const { return Vec3d(_mat[3][0],_mat[3][1],_mat[3][2]); } 
+        
+        inline Vec3d getScale() const { return Vec3d(_mat[0][0],_mat[1][1],_mat[2][2]); }
+        
+    	/** apply apply an 3x3 transform of v*M[0..2,0..2]  */
+    	inline static Vec3f transform3x3(const Vec3f& v,const Matrixd& m);
+
+    	/** apply apply an 3x3 transform of v*M[0..2,0..2]  */
+    	inline static Vec3d transform3x3(const Vec3d& v,const Matrixd& m);
+
+    	/** apply apply an 3x3 transform of M[0..2,0..2]*v  */
+    	inline static Vec3f transform3x3(const Matrixd& m,const Vec3f& v);
+
+    	/** apply apply an 3x3 transform of M[0..2,0..2]*v  */
+    	inline static Vec3d transform3x3(const Matrixd& m,const Vec3d& v);
+
+        // basic Matrixd multiplication, our workhorse methods.
+        void mult( const Matrixd&, const Matrixd& );
+        void preMult( const Matrixd& );
+        void postMult( const Matrixd& );
+
+        inline void operator *= ( const Matrixd& other ) 
+        {    if( this == &other ) {
+                Matrixd temp(other);
+                postMult( temp );
+            }
+            else postMult( other ); 
+        }
+
+        inline Matrixd operator * ( const Matrixd &m ) const
+	{
+	    osg::Matrixd r;
+            r.mult(*this,m);
+	    return  r;
+	}
+
+    protected:
+        value_type _mat[4][4];
+
+};
+
+class RefMatrixd : public Object, public Matrixd
+{
+    public:
+    
+        RefMatrixd():Matrixd() {}
+        RefMatrixd( const Matrixd& other) : Matrixd(other) {}
+        RefMatrixd( const Matrixf& other) : Matrixd(other) {}
+        RefMatrixd( const RefMatrixd& other) : Object(other), Matrixd(other) {}
+        explicit RefMatrixd( Matrixd::value_type const * const def ):Matrixd(def) {}
+        RefMatrixd( Matrixd::value_type a00, Matrixd::value_type a01, Matrixd::value_type a02, Matrixd::value_type a03,
+            Matrixd::value_type a10, Matrixd::value_type a11, Matrixd::value_type a12, Matrixd::value_type a13,
+            Matrixd::value_type a20, Matrixd::value_type a21, Matrixd::value_type a22, Matrixd::value_type a23,
+            Matrixd::value_type a30, Matrixd::value_type a31, Matrixd::value_type a32, Matrixd::value_type a33):
+            Matrixd(a00, a01, a02, a03,
+                   a10, a11, a12, a13,
+                   a20, a21, a22, a23,
+                   a30, a31, a32, a33) {}
+
+        virtual Object* cloneType() const { return new RefMatrixd(); } 
+        virtual Object* clone(const CopyOp&) const { return new RefMatrixd(*this); }
+        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const RefMatrixd*>(obj)!=NULL; }
+        virtual const char* libraryName() const { return "osg"; }
+        virtual const char* className() const { return "Matrix"; }
+        
+        
+    protected:
+    
+        virtual ~RefMatrixd() {}
+};
+
+
+//static utility methods
+inline Matrixd Matrixd::identity(void)
+{
+    Matrixd m;
+    m.makeIdentity();
+    return m;
+}
+
+inline Matrixd Matrixd::scale(value_type sx, value_type sy, value_type sz)
+{
+    Matrixd m;
+    m.makeScale(sx,sy,sz);
+    return m;
+}
+
+inline Matrixd Matrixd::scale(const Vec3f& v )
+{
+    return scale(v.x(), v.y(), v.z() );
+}
+
+inline Matrixd Matrixd::scale(const Vec3d& v )
+{
+    return scale(v.x(), v.y(), v.z() );
+}
+
+inline Matrixd Matrixd::translate(value_type tx, value_type ty, value_type tz)
+{
+    Matrixd m;
+    m.makeTranslate(tx,ty,tz);
+    return m;
+}
+
+inline Matrixd Matrixd::translate(const Vec3f& v )
+{
+    return translate(v.x(), v.y(), v.z() );
+}
+
+inline Matrixd Matrixd::translate(const Vec3d& v )
+{
+    return translate(v.x(), v.y(), v.z() );
+}
+
+inline Matrixd Matrixd::rotate( const Quat& q )
+{
+    return Matrixd(q);
+}
+inline Matrixd Matrixd::rotate(value_type angle, value_type x, value_type y, value_type z )
+{
+    Matrixd m;
+    m.makeRotate(angle,x,y,z);
+    return m;
+}
+inline Matrixd Matrixd::rotate(value_type angle, const Vec3f& axis )
+{
+    Matrixd m;
+    m.makeRotate(angle,axis);
+    return m;
+}
+inline Matrixd Matrixd::rotate(value_type angle, const Vec3d& axis )
+{
+    Matrixd m;
+    m.makeRotate(angle,axis);
+    return m;
+}
+inline Matrixd Matrixd::rotate( value_type angle1, const Vec3f& axis1, 
+                              value_type angle2, const Vec3f& axis2,
+                              value_type angle3, const Vec3f& axis3)
+{
+    Matrixd m;
+    m.makeRotate(angle1,axis1,angle2,axis2,angle3,axis3);
+    return m;
+}
+inline Matrixd Matrixd::rotate( value_type angle1, const Vec3d& axis1, 
+                              value_type angle2, const Vec3d& axis2,
+                              value_type angle3, const Vec3d& axis3)
+{
+    Matrixd m;
+    m.makeRotate(angle1,axis1,angle2,axis2,angle3,axis3);
+    return m;
+}
+inline Matrixd Matrixd::rotate(const Vec3f& from, const Vec3f& to )
+{
+    Matrixd m;
+    m.makeRotate(from,to);
+    return m;
+}
+inline Matrixd Matrixd::rotate(const Vec3d& from, const Vec3d& to )
+{
+    Matrixd m;
+    m.makeRotate(from,to);
+    return m;
+}
+
+inline Matrixd Matrixd::inverse( const Matrixd& matrix)
+{
+    Matrixd m;
+    m.invert(matrix);
+    return m;
+}
+
+inline Matrixd Matrixd::ortho(double left, double right,
+                              double bottom, double top,
+                              double zNear, double zFar)
+{
+    Matrixd m;
+    m.makeOrtho(left,right,bottom,top,zNear,zFar);
+    return m;
+}
+
+inline Matrixd Matrixd::ortho2D(double left, double right,
+                                double bottom, double top)
+{
+    Matrixd m;
+    m.makeOrtho2D(left,right,bottom,top);
+    return m;
+}
+
+inline Matrixd Matrixd::frustum(double left, double right,
+                                double bottom, double top,
+                                double zNear, double zFar)
+{
+    Matrixd m;
+    m.makeFrustum(left,right,bottom,top,zNear,zFar);
+    return m;
+}
+
+inline Matrixd Matrixd::perspective(double fovy,double aspectRatio,
+                                  double zNear, double zFar)
+{
+    Matrixd m;
+    m.makePerspective(fovy,aspectRatio,zNear,zFar);
+    return m;
+}
+
+inline Matrixd Matrixd::lookAt(const Vec3f& eye,const Vec3f& center,const Vec3f& up)
+{
+    Matrixd m;
+    m.makeLookAt(eye,center,up);
+    return m;
+}
+
+inline Matrixd Matrixd::lookAt(const Vec3d& eye,const Vec3d& center,const Vec3d& up)
+{
+    Matrixd m;
+    m.makeLookAt(eye,center,up);
+    return m;
+}
+
+inline Vec3f Matrixd::postMult( const Vec3f& v ) const
+{
+    value_type d = 1.0f/(_mat[3][0]*v.x()+_mat[3][1]*v.y()+_mat[3][2]*v.z()+_mat[3][3]) ;
+    return Vec3f( (_mat[0][0]*v.x() + _mat[0][1]*v.y() + _mat[0][2]*v.z() + _mat[0][3])*d,
+        (_mat[1][0]*v.x() + _mat[1][1]*v.y() + _mat[1][2]*v.z() + _mat[1][3])*d,
+        (_mat[2][0]*v.x() + _mat[2][1]*v.y() + _mat[2][2]*v.z() + _mat[2][3])*d) ;
+}
+inline Vec3d Matrixd::postMult( const Vec3d& v ) const
+{
+    value_type d = 1.0f/(_mat[3][0]*v.x()+_mat[3][1]*v.y()+_mat[3][2]*v.z()+_mat[3][3]) ;
+    return Vec3d( (_mat[0][0]*v.x() + _mat[0][1]*v.y() + _mat[0][2]*v.z() + _mat[0][3])*d,
+        (_mat[1][0]*v.x() + _mat[1][1]*v.y() + _mat[1][2]*v.z() + _mat[1][3])*d,
+        (_mat[2][0]*v.x() + _mat[2][1]*v.y() + _mat[2][2]*v.z() + _mat[2][3])*d) ;
+}
+
+inline Vec3f Matrixd::preMult( const Vec3f& v ) const
+{
+    value_type d = 1.0f/(_mat[0][3]*v.x()+_mat[1][3]*v.y()+_mat[2][3]*v.z()+_mat[3][3]) ;
+    return Vec3f( (_mat[0][0]*v.x() + _mat[1][0]*v.y() + _mat[2][0]*v.z() + _mat[3][0])*d,
+        (_mat[0][1]*v.x() + _mat[1][1]*v.y() + _mat[2][1]*v.z() + _mat[3][1])*d,
+        (_mat[0][2]*v.x() + _mat[1][2]*v.y() + _mat[2][2]*v.z() + _mat[3][2])*d);
+}
+inline Vec3d Matrixd::preMult( const Vec3d& v ) const
+{
+    value_type d = 1.0f/(_mat[0][3]*v.x()+_mat[1][3]*v.y()+_mat[2][3]*v.z()+_mat[3][3]) ;
+    return Vec3d( (_mat[0][0]*v.x() + _mat[1][0]*v.y() + _mat[2][0]*v.z() + _mat[3][0])*d,
+        (_mat[0][1]*v.x() + _mat[1][1]*v.y() + _mat[2][1]*v.z() + _mat[3][1])*d,
+        (_mat[0][2]*v.x() + _mat[1][2]*v.y() + _mat[2][2]*v.z() + _mat[3][2])*d);
+}
+
+inline Vec4f Matrixd::postMult( const Vec4f& v ) const
+{
+    return Vec4f( (_mat[0][0]*v.x() + _mat[0][1]*v.y() + _mat[0][2]*v.z() + _mat[0][3]*v.w()),
+        (_mat[1][0]*v.x() + _mat[1][1]*v.y() + _mat[1][2]*v.z() + _mat[1][3]*v.w()),
+        (_mat[2][0]*v.x() + _mat[2][1]*v.y() + _mat[2][2]*v.z() + _mat[2][3]*v.w()),
+        (_mat[3][0]*v.x() + _mat[3][1]*v.y() + _mat[3][2]*v.z() + _mat[3][3]*v.w())) ;
+}
+inline Vec4d Matrixd::postMult( const Vec4d& v ) const
+{
+    return Vec4d( (_mat[0][0]*v.x() + _mat[0][1]*v.y() + _mat[0][2]*v.z() + _mat[0][3]*v.w()),
+        (_mat[1][0]*v.x() + _mat[1][1]*v.y() + _mat[1][2]*v.z() + _mat[1][3]*v.w()),
+        (_mat[2][0]*v.x() + _mat[2][1]*v.y() + _mat[2][2]*v.z() + _mat[2][3]*v.w()),
+        (_mat[3][0]*v.x() + _mat[3][1]*v.y() + _mat[3][2]*v.z() + _mat[3][3]*v.w())) ;
+}
+
+inline Vec4f Matrixd::preMult( const Vec4f& v ) const
+{
+    return Vec4f( (_mat[0][0]*v.x() + _mat[1][0]*v.y() + _mat[2][0]*v.z() + _mat[3][0]*v.w()),
+        (_mat[0][1]*v.x() + _mat[1][1]*v.y() + _mat[2][1]*v.z() + _mat[3][1]*v.w()),
+        (_mat[0][2]*v.x() + _mat[1][2]*v.y() + _mat[2][2]*v.z() + _mat[3][2]*v.w()),
+        (_mat[0][3]*v.x() + _mat[1][3]*v.y() + _mat[2][3]*v.z() + _mat[3][3]*v.w()));
+}
+inline Vec4d Matrixd::preMult( const Vec4d& v ) const
+{
+    return Vec4d( (_mat[0][0]*v.x() + _mat[1][0]*v.y() + _mat[2][0]*v.z() + _mat[3][0]*v.w()),
+        (_mat[0][1]*v.x() + _mat[1][1]*v.y() + _mat[2][1]*v.z() + _mat[3][1]*v.w()),
+        (_mat[0][2]*v.x() + _mat[1][2]*v.y() + _mat[2][2]*v.z() + _mat[3][2]*v.w()),
+        (_mat[0][3]*v.x() + _mat[1][3]*v.y() + _mat[2][3]*v.z() + _mat[3][3]*v.w()));
+}
+inline Vec3f Matrixd::transform3x3(const Vec3f& v,const Matrixd& m)
+{
+    return Vec3f( (m._mat[0][0]*v.x() + m._mat[1][0]*v.y() + m._mat[2][0]*v.z()),
+                 (m._mat[0][1]*v.x() + m._mat[1][1]*v.y() + m._mat[2][1]*v.z()),
+                 (m._mat[0][2]*v.x() + m._mat[1][2]*v.y() + m._mat[2][2]*v.z()));
+}
+inline Vec3d Matrixd::transform3x3(const Vec3d& v,const Matrixd& m)
+{
+    return Vec3d( (m._mat[0][0]*v.x() + m._mat[1][0]*v.y() + m._mat[2][0]*v.z()),
+                 (m._mat[0][1]*v.x() + m._mat[1][1]*v.y() + m._mat[2][1]*v.z()),
+                 (m._mat[0][2]*v.x() + m._mat[1][2]*v.y() + m._mat[2][2]*v.z()));
+}
+
+inline Vec3f Matrixd::transform3x3(const Matrixd& m,const Vec3f& v)
+{
+    return Vec3f( (m._mat[0][0]*v.x() + m._mat[0][1]*v.y() + m._mat[0][2]*v.z()),
+                 (m._mat[1][0]*v.x() + m._mat[1][1]*v.y() + m._mat[1][2]*v.z()),
+                 (m._mat[2][0]*v.x() + m._mat[2][1]*v.y() + m._mat[2][2]*v.z()) ) ;
+}
+inline Vec3d Matrixd::transform3x3(const Matrixd& m,const Vec3d& v)
+{
+    return Vec3d( (m._mat[0][0]*v.x() + m._mat[0][1]*v.y() + m._mat[0][2]*v.z()),
+                 (m._mat[1][0]*v.x() + m._mat[1][1]*v.y() + m._mat[1][2]*v.z()),
+                 (m._mat[2][0]*v.x() + m._mat[2][1]*v.y() + m._mat[2][2]*v.z()) ) ;
+}
+
+
+inline Vec3f operator* (const Vec3f& v, const Matrixd& m )
+{
+	return m.preMult(v);
+}
+inline Vec3d operator* (const Vec3d& v, const Matrixd& m )
+{
+	return m.preMult(v);
+}
+inline Vec4f operator* (const Vec4f& v, const Matrixd& m )
+{
+	return m.preMult(v);
+}
+inline Vec4d operator* (const Vec4d& v, const Matrixd& m )
+{
+	return m.preMult(v);
+}
+
+inline Vec3f Matrixd::operator* (const Vec3f& v) const
+{
+	return postMult(v);
+}
+inline Vec3d Matrixd::operator* (const Vec3d& v) const
+{
+	return postMult(v);
+}
+inline Vec4f Matrixd::operator* (const Vec4f& v) const
+{
+	return postMult(v);
+}
+inline Vec4d Matrixd::operator* (const Vec4d& v) const
+{
+	return postMult(v);
+}
+
+inline std::ostream& operator<< (std::ostream& os, const Matrixd& m )
+{
+    os << "{"<<std::endl;
+    for(int row=0; row<4; ++row) {
+        os << "\t";
+        for(int col=0; col<4; ++col)
+            os << m(row,col) << " ";
+        os << std::endl;
+    }
+    os << "}" << std::endl;
+    return os;
+}
+
+
+} //namespace osg
+
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Notify
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Notify (revision 2786)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Notify (revision 2786)
@@ -0,0 +1,71 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_NOTIFY
+#define OSG_NOTIFY 1
+
+#include <osg/Export>
+
+#include <ostream>
+
+namespace osg {
+
+/** Range of notify levels from DEBUG_FP through to FATAL, ALWAYS
+  * is reserved for forcing the absorption of all messages.  The
+  * keywords are also used verbatim when specified by the environmental
+  * variable OSGNOTIFYLEVEL.  See documentation on osg::notify() for
+  * further details.
+  */
+enum NotifySeverity {
+    ALWAYS=0,
+    FATAL=1,
+    WARN=2,
+    NOTICE=3,
+    INFO=4,
+    DEBUG_INFO=5,
+    DEBUG_FP=6
+};
+
+/** set the notify level, overriding the default or value set by
+  * the environmental variable OSGNOTIFYLEVEL.
+  */
+extern SG_EXPORT void setNotifyLevel(NotifySeverity severity);
+
+/** get the notify level. */
+extern SG_EXPORT NotifySeverity getNotifyLevel();
+
+/** initialize notify level. */
+extern SG_EXPORT bool initNotifyLevel();
+
+/** notify messaging function for providing fatal through to verbose
+  * debugging messages.  Level of messages sent to the console can
+  * be controlled by setting the NotifyLevel either within your 
+  * application or via the an environmental variable. For instance
+  * setenv OSGNOTIFYLEVEL DEBUG (for tsh), export OSGNOTIFYLEVEL=DEBUG
+  * (for bourne shell) or set OSGNOTIFYLEVEL=DEBUG (for Windows) all
+  * set tell the osg to redirect all debugging and more important messages
+  * to the console (useful for debugging :-)  setting ALWAYS will force
+  * all messages to be absorbed, which might be appropriate for final
+  * applications.  Default NotifyLevel is NOTICE.  Check the enum 
+  * NotifySeverity for full range of possibilities.  To use the notify
+  * with your code simply use the notify function as a normal file
+  * stream (like cout) i.e osg::notify(osg::DEBUG) << "Hello Bugs!"<<endl;
+  */
+  
+extern SG_EXPORT std::ostream& notify(const NotifySeverity severity);
+
+inline std::ostream& notify(void) { return notify(osg::INFO); }
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Matrixf
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Matrixf (revision 3182)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Matrixf (revision 3182)
@@ -0,0 +1,615 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_MATRIXF
+#define OSG_MATRIXF 1
+
+#include <osg/Object>
+#include <osg/Vec3f>
+#include <osg/Vec3d>
+#include <osg/Vec4f>
+#include <osg/Vec4d>
+#include <osg/Quat>
+
+#include <string.h>
+
+#include <ostream>
+#include <algorithm>
+
+namespace osg {
+
+class Matrixd;
+
+class SG_EXPORT Matrixf
+{
+
+    public:
+    
+        typedef float value_type;
+
+        inline Matrixf() { makeIdentity(); }
+        inline Matrixf( const Matrixf& mat) { set(mat.ptr()); }
+        Matrixf( const Matrixd& mat );
+        inline explicit Matrixf( float const * const ptr ) { set(ptr); }
+        inline explicit Matrixf( double const * const ptr ) { set(ptr); }
+        inline explicit Matrixf( const Quat& quat ) { set(quat); }
+
+        Matrixf( value_type a00, value_type a01, value_type a02, value_type a03,
+                 value_type a10, value_type a11, value_type a12, value_type a13,
+                 value_type a20, value_type a21, value_type a22, value_type a23,
+                 value_type a30, value_type a31, value_type a32, value_type a33);
+
+        ~Matrixf() {}
+
+        int compare(const Matrixf& m) const { return memcmp(_mat,m._mat,sizeof(_mat)); }
+
+        bool operator < (const Matrixf& m) const { return compare(m)<0; }
+        bool operator == (const Matrixf& m) const { return compare(m)==0; }
+        bool operator != (const Matrixf& m) const { return compare(m)!=0; }
+
+        inline value_type& operator()(int row, int col) { return _mat[row][col]; }
+        inline value_type operator()(int row, int col) const { return _mat[row][col]; }
+
+        inline bool valid() const { return !isNaN(); }
+        inline bool isNaN() const { return osg::isNaN(_mat[0][0]) || osg::isNaN(_mat[0][1]) || osg::isNaN(_mat[0][2]) || osg::isNaN(_mat[0][3]) ||
+                                                 osg::isNaN(_mat[1][0]) || osg::isNaN(_mat[1][1]) || osg::isNaN(_mat[1][2]) || osg::isNaN(_mat[1][3]) ||
+                                                 osg::isNaN(_mat[2][0]) || osg::isNaN(_mat[2][1]) || osg::isNaN(_mat[2][2]) || osg::isNaN(_mat[2][3]) ||
+                                                 osg::isNaN(_mat[3][0]) || osg::isNaN(_mat[3][1]) || osg::isNaN(_mat[3][2]) || osg::isNaN(_mat[3][3]); }
+
+        inline Matrixf& operator = (const Matrixf& rhs)
+        {
+            if( &rhs == this ) return *this;
+            set(rhs.ptr());
+            return *this;
+        }
+        
+        Matrixf& operator = (const Matrixd& other);
+
+        inline void set(const Matrixf& rhs) { set(rhs.ptr()); }
+
+        void set(const Matrixd& rhs);
+
+        inline void set(float const * const ptr)
+        {
+            value_type* local_ptr = (value_type*)_mat;
+            for(int i=0;i<16;++i) local_ptr[i]=(value_type)ptr[i];
+        }
+        
+        inline void set(double const * const ptr)
+        {
+            value_type* local_ptr = (value_type*)_mat;
+            for(int i=0;i<16;++i) local_ptr[i]=(value_type)ptr[i];
+        }
+
+        void set( value_type a00, value_type a01, value_type a02, value_type a03,
+                  value_type a10, value_type a11, value_type a12, value_type a13,
+                  value_type a20, value_type a21, value_type a22, value_type a23,
+                  value_type a30, value_type a31, value_type a32, value_type a33);
+                  
+        void set(const Quat& q);
+        
+        void get(Quat& q) const;
+
+        value_type * ptr() { return (value_type*)_mat; }
+        const value_type * ptr() const { return (const value_type *)_mat; }
+
+        void makeIdentity();
+        
+        void makeScale( const Vec3f& );
+        void makeScale( const Vec3d& );
+        void makeScale( value_type, value_type, value_type );
+        
+        void makeTranslate( const Vec3f& );
+        void makeTranslate( const Vec3d& );
+        void makeTranslate( value_type, value_type, value_type );
+        
+        void makeRotate( const Vec3f& from, const Vec3f& to );
+        void makeRotate( const Vec3d& from, const Vec3d& to );
+        void makeRotate( value_type angle, const Vec3f& axis );
+        void makeRotate( value_type angle, const Vec3d& axis );
+        void makeRotate( value_type angle, value_type x, value_type y, value_type z );
+        void makeRotate( const Quat& );
+        void makeRotate( value_type angle1, const Vec3f& axis1, 
+                         value_type angle2, const Vec3f& axis2,
+                         value_type angle3, const Vec3f& axis3);
+        void makeRotate( value_type angle1, const Vec3d& axis1, 
+                         value_type angle2, const Vec3d& axis2,
+                         value_type angle3, const Vec3d& axis3);
+
+        
+        
+        /** Set to a orthographic projection. See glOrtho for further details.*/
+        void makeOrtho(double left, double right,
+                       double bottom, double top,
+                       double zNear, double zFar);
+
+        /** Get the othorgraphic settings of the orthographic projection matrix. 
+          * Note, if matrix is not an orthographic matrix then invalid values will be returned.*/
+        bool getOrtho(double& left, double& right,
+                      double& bottom, double& top,
+                      double& zNear, double& zFar) const;
+
+        /** Set to a 2D orthographic projection. See glOrtho2D for further details.*/
+        inline void makeOrtho2D(double left, double right,
+                                double bottom, double top)
+        {
+            makeOrtho(left,right,bottom,top,-1.0,1.0);
+        }
+
+
+        /** Set to a perspective projection. See glFrustum for further details.*/
+        void makeFrustum(double left, double right,
+                         double bottom, double top,
+                         double zNear, double zFar);
+
+        /** Get the frustum setting of a perspective projection matrix.
+          * Note, if matrix is not an perspective matrix then invalid values will be returned.*/
+        bool getFrustum(double& left, double& right,
+                        double& bottom, double& top,
+                        double& zNear, double& zFar) const;
+
+        /** Set to a symmetrical perspective projection, See gluPerspective for further details.
+          * Aspect ratio is defined as width/height.*/
+        void makePerspective(double fovy,double aspectRatio,
+                             double zNear, double zFar);
+
+        /** Get the frustum setting of a symetric perspective projection matrix.
+          * Returns false if matrix is not a perspective matrix, where parameter values are undefined. 
+          * Note, if matrix is not a symetric perspective matrix then the shear will be lost.
+          * Asymetric metrices occur when stereo, power walls, caves and reality center display are used.
+          * In these configuration one should use the AsFrustum method instead.*/
+        bool getPerspective(double& fovy,double& aspectRatio,
+                            double& zNear, double& zFar) const;
+
+        /** Set to the position and orientation modelview matrix, using the same convention as gluLookAt. */
+        void makeLookAt(const Vec3d& eye,const Vec3d& center,const Vec3d& up);
+
+        /** Get to the position and orientation of a modelview matrix, using the same convention as gluLookAt. */
+        void getLookAt(Vec3f& eye,Vec3f& center,Vec3f& up,value_type lookDistance=1.0f) const;
+
+        /** Get to the position and orientation of a modelview matrix, using the same convention as gluLookAt. */
+        void getLookAt(Vec3d& eye,Vec3d& center,Vec3d& up,value_type lookDistance=1.0f) const;
+
+        /** invert the matrix rhs. */
+        bool invert( const Matrixf& rhs);
+
+        /** full 4x4 matrix invert. */
+        bool invert_4x4_orig( const Matrixf& );
+
+        /** full 4x4 matrix invert. */
+        bool invert_4x4_new( const Matrixf& );
+
+        //basic utility functions to create new matrices
+	inline static Matrixf identity( void );
+        inline static Matrixf scale( const Vec3f& sv);
+        inline static Matrixf scale( const Vec3d& sv);
+        inline static Matrixf scale( value_type sx, value_type sy, value_type sz);
+        inline static Matrixf translate( const Vec3f& dv);
+        inline static Matrixf translate( const Vec3d& dv);
+        inline static Matrixf translate( value_type x, value_type y, value_type z);
+        inline static Matrixf rotate( const Vec3f& from, const Vec3f& to);
+        inline static Matrixf rotate( const Vec3d& from, const Vec3d& to);
+        inline static Matrixf rotate( value_type angle, value_type x, value_type y, value_type z);
+        inline static Matrixf rotate( value_type angle, const Vec3f& axis);
+        inline static Matrixf rotate( value_type angle, const Vec3d& axis);
+        inline static Matrixf rotate( value_type angle1, const Vec3f& axis1, 
+                                      value_type angle2, const Vec3f& axis2,
+                                      value_type angle3, const Vec3f& axis3);
+        inline static Matrixf rotate( value_type angle1, const Vec3d& axis1, 
+                                      value_type angle2, const Vec3d& axis2,
+                                      value_type angle3, const Vec3d& axis3);
+        inline static Matrixf rotate( const Quat& quat);
+        inline static Matrixf inverse( const Matrixf& matrix);
+        
+        /** Create a orthographic projection. See glOrtho for further details.*/
+        inline static Matrixf ortho(double left, double right,
+                                   double bottom, double top,
+                                   double zNear, double zFar);
+
+        /** Create a 2D orthographic projection. See glOrtho for further details.*/
+        inline static Matrixf ortho2D(double left, double right,
+                                     double bottom, double top);
+
+        /** Create a perspective projection. See glFrustum for further details.*/
+        inline static Matrixf frustum(double left, double right,
+                                     double bottom, double top,
+                                     double zNear, double zFar);
+
+        /** Create a symmetrical perspective projection, See gluPerspective for further details.
+          * Aspect ratio is defined as width/height.*/
+        inline static Matrixf perspective(double fovy,double aspectRatio,
+                                         double zNear, double zFar);
+
+        /** Create the position and orientation as per a camera, using the same convention as gluLookAt. */
+        inline static Matrixf lookAt(const Vec3f& eye,const Vec3f& center,const Vec3f& up);
+
+        /** Create the position and orientation as per a camera, using the same convention as gluLookAt. */
+        inline static Matrixf lookAt(const Vec3d& eye,const Vec3d& center,const Vec3d& up);
+
+
+
+        inline Vec3f preMult( const Vec3f& v ) const;
+        inline Vec3d preMult( const Vec3d& v ) const;
+        inline Vec3f postMult( const Vec3f& v ) const;
+        inline Vec3d postMult( const Vec3d& v ) const;
+        inline Vec3f operator* ( const Vec3f& v ) const;
+        inline Vec3d operator* ( const Vec3d& v ) const;
+        inline Vec4f preMult( const Vec4f& v ) const;
+        inline Vec4d preMult( const Vec4d& v ) const;
+        inline Vec4f postMult( const Vec4f& v ) const;
+        inline Vec4d postMult( const Vec4d& v ) const;
+        inline Vec4f operator* ( const Vec4f& v ) const;
+        inline Vec4d operator* ( const Vec4d& v ) const;
+
+        void setTrans( value_type tx, value_type ty, value_type tz );
+	void setTrans( const Vec3f& v );
+	void setTrans( const Vec3d& v );
+        
+        inline Vec3d getTrans() const { return Vec3d(_mat[3][0],_mat[3][1],_mat[3][2]); } 
+        
+        inline Vec3d getScale() const { return Vec3d(_mat[0][0],_mat[1][1],_mat[2][2]); }
+        
+    	/** apply apply an 3x3 transform of v*M[0..2,0..2]  */
+    	inline static Vec3f transform3x3(const Vec3f& v,const Matrixf& m);
+
+    	/** apply apply an 3x3 transform of v*M[0..2,0..2]  */
+    	inline static Vec3d transform3x3(const Vec3d& v,const Matrixf& m);
+
+    	/** apply apply an 3x3 transform of M[0..2,0..2]*v  */
+    	inline static Vec3f transform3x3(const Matrixf& m,const Vec3f& v);
+
+    	/** apply apply an 3x3 transform of M[0..2,0..2]*v  */
+    	inline static Vec3d transform3x3(const Matrixf& m,const Vec3d& v);
+
+        // basic Matrixf multiplication, our workhorse methods.
+        void mult( const Matrixf&, const Matrixf& );
+        void preMult( const Matrixf& );
+        void postMult( const Matrixf& );
+
+        inline void operator *= ( const Matrixf& other ) 
+        {    if( this == &other ) {
+                Matrixf temp(other);
+                postMult( temp );
+            }
+            else postMult( other ); 
+        }
+
+        inline Matrixf operator * ( const Matrixf &m ) const
+	{
+	    osg::Matrixf r;
+            r.mult(*this,m);
+	    return  r;
+	}
+
+    protected:
+        value_type _mat[4][4];
+
+};
+
+class RefMatrixf : public Object, public Matrixf
+{
+    public:
+    
+        RefMatrixf():Matrixf() {}
+        RefMatrixf( const Matrixf& other) : Matrixf(other) {}
+        RefMatrixf( const Matrixd& other) : Matrixf(other) {}
+        RefMatrixf( const RefMatrixf& other) : Object(other), Matrixf(other) {}
+        explicit RefMatrixf( Matrixf::value_type const * const def ):Matrixf(def) {}
+        RefMatrixf( Matrixf::value_type a00, Matrixf::value_type a01, Matrixf::value_type a02, Matrixf::value_type a03,
+            Matrixf::value_type a10, Matrixf::value_type a11, Matrixf::value_type a12, Matrixf::value_type a13,
+            Matrixf::value_type a20, Matrixf::value_type a21, Matrixf::value_type a22, Matrixf::value_type a23,
+            Matrixf::value_type a30, Matrixf::value_type a31, Matrixf::value_type a32, Matrixf::value_type a33):
+            Matrixf(a00, a01, a02, a03,
+                   a10, a11, a12, a13,
+                   a20, a21, a22, a23,
+                   a30, a31, a32, a33) {}
+
+        virtual Object* cloneType() const { return new RefMatrixf(); } 
+        virtual Object* clone(const CopyOp&) const { return new RefMatrixf(*this); }
+        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const RefMatrixf*>(obj)!=NULL; }
+        virtual const char* libraryName() const { return "osg"; }
+        virtual const char* className() const { return "Matrix"; }
+        
+        
+    protected:
+    
+        virtual ~RefMatrixf() {}
+};
+
+
+//static utility methods
+inline Matrixf Matrixf::identity(void)
+{
+    Matrixf m;
+    m.makeIdentity();
+    return m;
+}
+
+inline Matrixf Matrixf::scale(value_type sx, value_type sy, value_type sz)
+{
+    Matrixf m;
+    m.makeScale(sx,sy,sz);
+    return m;
+}
+
+inline Matrixf Matrixf::scale(const Vec3f& v )
+{
+    return scale(v.x(), v.y(), v.z() );
+}
+
+inline Matrixf Matrixf::scale(const Vec3d& v )
+{
+    return scale(v.x(), v.y(), v.z() );
+}
+
+inline Matrixf Matrixf::translate(value_type tx, value_type ty, value_type tz)
+{
+    Matrixf m;
+    m.makeTranslate(tx,ty,tz);
+    return m;
+}
+
+inline Matrixf Matrixf::translate(const Vec3f& v )
+{
+    return translate(v.x(), v.y(), v.z() );
+}
+
+inline Matrixf Matrixf::translate(const Vec3d& v )
+{
+    return translate(v.x(), v.y(), v.z() );
+}
+
+inline Matrixf Matrixf::rotate( const Quat& q )
+{
+    return Matrixf(q);
+}
+inline Matrixf Matrixf::rotate(value_type angle, value_type x, value_type y, value_type z )
+{
+    Matrixf m;
+    m.makeRotate(angle,x,y,z);
+    return m;
+}
+inline Matrixf Matrixf::rotate(value_type angle, const Vec3f& axis )
+{
+    Matrixf m;
+    m.makeRotate(angle,axis);
+    return m;
+}
+inline Matrixf Matrixf::rotate(value_type angle, const Vec3d& axis )
+{
+    Matrixf m;
+    m.makeRotate(angle,axis);
+    return m;
+}
+inline Matrixf Matrixf::rotate( value_type angle1, const Vec3f& axis1, 
+                              value_type angle2, const Vec3f& axis2,
+                              value_type angle3, const Vec3f& axis3)
+{
+    Matrixf m;
+    m.makeRotate(angle1,axis1,angle2,axis2,angle3,axis3);
+    return m;
+}
+inline Matrixf Matrixf::rotate( value_type angle1, const Vec3d& axis1, 
+                              value_type angle2, const Vec3d& axis2,
+                              value_type angle3, const Vec3d& axis3)
+{
+    Matrixf m;
+    m.makeRotate(angle1,axis1,angle2,axis2,angle3,axis3);
+    return m;
+}
+inline Matrixf Matrixf::rotate(const Vec3f& from, const Vec3f& to )
+{
+    Matrixf m;
+    m.makeRotate(from,to);
+    return m;
+}
+inline Matrixf Matrixf::rotate(const Vec3d& from, const Vec3d& to )
+{
+    Matrixf m;
+    m.makeRotate(from,to);
+    return m;
+}
+
+inline Matrixf Matrixf::inverse( const Matrixf& matrix)
+{
+    Matrixf m;
+    m.invert(matrix);
+    return m;
+}
+
+inline Matrixf Matrixf::ortho(double left, double right,
+                            double bottom, double top,
+                            double zNear, double zFar)
+{
+    Matrixf m;
+    m.makeOrtho(left,right,bottom,top,zNear,zFar);
+    return m;
+}
+
+inline Matrixf Matrixf::ortho2D(double left, double right,
+                              double bottom, double top)
+{
+    Matrixf m;
+    m.makeOrtho2D(left,right,bottom,top);
+    return m;
+}
+
+inline Matrixf Matrixf::frustum(double left, double right,
+                              double bottom, double top,
+                              double zNear, double zFar)
+{
+    Matrixf m;
+    m.makeFrustum(left,right,bottom,top,zNear,zFar);
+    return m;
+}
+
+inline Matrixf Matrixf::perspective(double fovy,double aspectRatio,
+                                  double zNear, double zFar)
+{
+    Matrixf m;
+    m.makePerspective(fovy,aspectRatio,zNear,zFar);
+    return m;
+}
+
+inline Matrixf Matrixf::lookAt(const Vec3f& eye,const Vec3f& center,const Vec3f& up)
+{
+    Matrixf m;
+    m.makeLookAt(eye,center,up);
+    return m;
+}
+
+inline Matrixf Matrixf::lookAt(const Vec3d& eye,const Vec3d& center,const Vec3d& up)
+{
+    Matrixf m;
+    m.makeLookAt(eye,center,up);
+    return m;
+}
+
+inline Vec3f Matrixf::postMult( const Vec3f& v ) const
+{
+    value_type d = 1.0f/(_mat[3][0]*v.x()+_mat[3][1]*v.y()+_mat[3][2]*v.z()+_mat[3][3]) ;
+    return Vec3f( (_mat[0][0]*v.x() + _mat[0][1]*v.y() + _mat[0][2]*v.z() + _mat[0][3])*d,
+        (_mat[1][0]*v.x() + _mat[1][1]*v.y() + _mat[1][2]*v.z() + _mat[1][3])*d,
+        (_mat[2][0]*v.x() + _mat[2][1]*v.y() + _mat[2][2]*v.z() + _mat[2][3])*d) ;
+}
+inline Vec3d Matrixf::postMult( const Vec3d& v ) const
+{
+    value_type d = 1.0f/(_mat[3][0]*v.x()+_mat[3][1]*v.y()+_mat[3][2]*v.z()+_mat[3][3]) ;
+    return Vec3d( (_mat[0][0]*v.x() + _mat[0][1]*v.y() + _mat[0][2]*v.z() + _mat[0][3])*d,
+        (_mat[1][0]*v.x() + _mat[1][1]*v.y() + _mat[1][2]*v.z() + _mat[1][3])*d,
+        (_mat[2][0]*v.x() + _mat[2][1]*v.y() + _mat[2][2]*v.z() + _mat[2][3])*d) ;
+}
+
+inline Vec3f Matrixf::preMult( const Vec3f& v ) const
+{
+    value_type d = 1.0f/(_mat[0][3]*v.x()+_mat[1][3]*v.y()+_mat[2][3]*v.z()+_mat[3][3]) ;
+    return Vec3f( (_mat[0][0]*v.x() + _mat[1][0]*v.y() + _mat[2][0]*v.z() + _mat[3][0])*d,
+        (_mat[0][1]*v.x() + _mat[1][1]*v.y() + _mat[2][1]*v.z() + _mat[3][1])*d,
+        (_mat[0][2]*v.x() + _mat[1][2]*v.y() + _mat[2][2]*v.z() + _mat[3][2])*d);
+}
+inline Vec3d Matrixf::preMult( const Vec3d& v ) const
+{
+    value_type d = 1.0f/(_mat[0][3]*v.x()+_mat[1][3]*v.y()+_mat[2][3]*v.z()+_mat[3][3]) ;
+    return Vec3d( (_mat[0][0]*v.x() + _mat[1][0]*v.y() + _mat[2][0]*v.z() + _mat[3][0])*d,
+        (_mat[0][1]*v.x() + _mat[1][1]*v.y() + _mat[2][1]*v.z() + _mat[3][1])*d,
+        (_mat[0][2]*v.x() + _mat[1][2]*v.y() + _mat[2][2]*v.z() + _mat[3][2])*d);
+}
+
+inline Vec4f Matrixf::postMult( const Vec4f& v ) const
+{
+    return Vec4f( (_mat[0][0]*v.x() + _mat[0][1]*v.y() + _mat[0][2]*v.z() + _mat[0][3]*v.w()),
+        (_mat[1][0]*v.x() + _mat[1][1]*v.y() + _mat[1][2]*v.z() + _mat[1][3]*v.w()),
+        (_mat[2][0]*v.x() + _mat[2][1]*v.y() + _mat[2][2]*v.z() + _mat[2][3]*v.w()),
+        (_mat[3][0]*v.x() + _mat[3][1]*v.y() + _mat[3][2]*v.z() + _mat[3][3]*v.w())) ;
+}
+inline Vec4d Matrixf::postMult( const Vec4d& v ) const
+{
+    return Vec4d( (_mat[0][0]*v.x() + _mat[0][1]*v.y() + _mat[0][2]*v.z() + _mat[0][3]*v.w()),
+        (_mat[1][0]*v.x() + _mat[1][1]*v.y() + _mat[1][2]*v.z() + _mat[1][3]*v.w()),
+        (_mat[2][0]*v.x() + _mat[2][1]*v.y() + _mat[2][2]*v.z() + _mat[2][3]*v.w()),
+        (_mat[3][0]*v.x() + _mat[3][1]*v.y() + _mat[3][2]*v.z() + _mat[3][3]*v.w())) ;
+}
+
+inline Vec4f Matrixf::preMult( const Vec4f& v ) const
+{
+    return Vec4f( (_mat[0][0]*v.x() + _mat[1][0]*v.y() + _mat[2][0]*v.z() + _mat[3][0]*v.w()),
+        (_mat[0][1]*v.x() + _mat[1][1]*v.y() + _mat[2][1]*v.z() + _mat[3][1]*v.w()),
+        (_mat[0][2]*v.x() + _mat[1][2]*v.y() + _mat[2][2]*v.z() + _mat[3][2]*v.w()),
+        (_mat[0][3]*v.x() + _mat[1][3]*v.y() + _mat[2][3]*v.z() + _mat[3][3]*v.w()));
+}
+inline Vec4d Matrixf::preMult( const Vec4d& v ) const
+{
+    return Vec4d( (_mat[0][0]*v.x() + _mat[1][0]*v.y() + _mat[2][0]*v.z() + _mat[3][0]*v.w()),
+        (_mat[0][1]*v.x() + _mat[1][1]*v.y() + _mat[2][1]*v.z() + _mat[3][1]*v.w()),
+        (_mat[0][2]*v.x() + _mat[1][2]*v.y() + _mat[2][2]*v.z() + _mat[3][2]*v.w()),
+        (_mat[0][3]*v.x() + _mat[1][3]*v.y() + _mat[2][3]*v.z() + _mat[3][3]*v.w()));
+}
+inline Vec3f Matrixf::transform3x3(const Vec3f& v,const Matrixf& m)
+{
+    return Vec3f( (m._mat[0][0]*v.x() + m._mat[1][0]*v.y() + m._mat[2][0]*v.z()),
+                 (m._mat[0][1]*v.x() + m._mat[1][1]*v.y() + m._mat[2][1]*v.z()),
+                 (m._mat[0][2]*v.x() + m._mat[1][2]*v.y() + m._mat[2][2]*v.z()));
+}
+inline Vec3d Matrixf::transform3x3(const Vec3d& v,const Matrixf& m)
+{
+    return Vec3d( (m._mat[0][0]*v.x() + m._mat[1][0]*v.y() + m._mat[2][0]*v.z()),
+                 (m._mat[0][1]*v.x() + m._mat[1][1]*v.y() + m._mat[2][1]*v.z()),
+                 (m._mat[0][2]*v.x() + m._mat[1][2]*v.y() + m._mat[2][2]*v.z()));
+}
+
+inline Vec3f Matrixf::transform3x3(const Matrixf& m,const Vec3f& v)
+{
+    return Vec3f( (m._mat[0][0]*v.x() + m._mat[0][1]*v.y() + m._mat[0][2]*v.z()),
+                 (m._mat[1][0]*v.x() + m._mat[1][1]*v.y() + m._mat[1][2]*v.z()),
+                 (m._mat[2][0]*v.x() + m._mat[2][1]*v.y() + m._mat[2][2]*v.z()) ) ;
+}
+inline Vec3d Matrixf::transform3x3(const Matrixf& m,const Vec3d& v)
+{
+    return Vec3d( (m._mat[0][0]*v.x() + m._mat[0][1]*v.y() + m._mat[0][2]*v.z()),
+                 (m._mat[1][0]*v.x() + m._mat[1][1]*v.y() + m._mat[1][2]*v.z()),
+                 (m._mat[2][0]*v.x() + m._mat[2][1]*v.y() + m._mat[2][2]*v.z()) ) ;
+}
+
+
+inline Vec3f operator* (const Vec3f& v, const Matrixf& m )
+{
+	return m.preMult(v);
+}
+inline Vec3d operator* (const Vec3d& v, const Matrixf& m )
+{
+	return m.preMult(v);
+}
+inline Vec4f operator* (const Vec4f& v, const Matrixf& m )
+{
+	return m.preMult(v);
+}
+inline Vec4d operator* (const Vec4d& v, const Matrixf& m )
+{
+	return m.preMult(v);
+}
+
+inline Vec3f Matrixf::operator* (const Vec3f& v) const
+{
+	return postMult(v);
+}
+inline Vec3d Matrixf::operator* (const Vec3d& v) const
+{
+	return postMult(v);
+}
+inline Vec4f Matrixf::operator* (const Vec4f& v) const
+{
+	return postMult(v);
+}
+inline Vec4d Matrixf::operator* (const Vec4d& v) const
+{
+	return postMult(v);
+}
+
+inline std::ostream& operator<< (std::ostream& os, const Matrixf& m )
+{
+    os << "{"<<std::endl;
+    for(int row=0; row<4; ++row) {
+        os << "\t";
+        for(int col=0; col<4; ++col)
+            os << m(row,col) << " ";
+        os << std::endl;
+    }
+    os << "}" << std::endl;
+    return os;
+}
+
+
+} //namespace osg
+
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Transform
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Transform (revision 3006)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Transform (revision 3006)
@@ -0,0 +1,154 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_TRANSFORM
+#define OSG_TRANSFORM 1
+
+#include <osg/Group>
+#include <osg/Matrix>
+
+#ifndef GL_RESCALE_NORMAL
+#define GL_RESCALE_NORMAL                 0x803A
+#endif
+
+namespace osg {
+
+
+
+/** compute the matrix which transforms objects in local coords to world coords,
+  * by accumulating the Transform local to world matrices along the specified node path.*/
+extern SG_EXPORT Matrix computeLocalToWorld(NodePath& nodePath);
+
+/** compute the matrix which transforms objects in world coords to local coords,
+  * by accumulating the Transform world to local matrices along the specified node path.*/
+extern SG_EXPORT Matrix computeWorldToLocal(NodePath& nodePath);
+
+/** compute the matrix which transforms objects in local coords to world coords,
+  * by accumulating the Transform local to world matrices along the specified node path 
+  * the supplied initialial camera modelview .*/
+extern SG_EXPORT Matrix computeLocalToEye(const Matrix& modelview, NodePath& nodePath);
+
+/** compute the matrix which transforms objects in world coords to local coords,
+  * by accumulating the Transform world to local matrices along the specified node path 
+  * the inverse of the supplied initialial camera modelview.*/
+extern SG_EXPORT Matrix computeEyeToLocal(const Matrix& modelview, NodePath& nodePath);
+
+
+/** A Transform is a group node for which all children are transformed by
+  * a 4x4 matrix.  It is often used for positioning objects within a scene,
+  * producing trackball functionality or for animation.
+  *
+  * Transform itself does not provide set/get functions, only the interface
+  * for defining what the 4x4 transformation is.  Subclasses, such as
+  * MatrixTransform and PositionAttitudeTransform support the use of an
+  * osg::Matrix or a osg::Vec3/osg::Quat resprectively.
+  * The Transform node can be customized via the ComputeTransfromCallback
+  * which can be attached to the node.  This might be used to convert from
+  * internal representations of the transformation into generic osg::Matrix
+  * objects which are used during scene grpah traversal, such as
+  * CullTraversal and IntersectionTraversal.
+  *
+  * Note: if the transformation matrix scales the subgraph then the normals
+  * of the underlying geometry will need to be renormalized to be unit
+  * vectors once more.  This can be done transparently through OpenGL's 
+  * use of either GL_NORMALIZE and GL_SCALE_NORMALIZE modes.  For further
+  * background reading see the glNormalize documentation in the OpenGL
+  * Reference Guide (the blue book). To enable it in the OSG, you simply
+  * need to attach a local osg::StateSet to the osg::Transform, and set
+  * the appropriate mode to ON via
+  *   stateset->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
+*/
+class SG_EXPORT Transform : public Group
+{
+    public :
+
+        Transform();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        Transform(const Transform&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+        META_Node(osg, Transform);
+
+        virtual Transform* asTransform() { return this; }
+        virtual const Transform* asTransform() const { return this; }
+
+        virtual MatrixTransform* asMatrixTransform() { return 0; }
+        virtual const MatrixTransform* asMatrixTransform() const { return 0; }
+
+        virtual PositionAttitudeTransform* asPositionAttitudeTransform() { return 0; }
+        virtual const PositionAttitudeTransform* asPositionAttitudeTransform() const { return 0; }
+
+        enum ReferenceFrame
+        {
+            RELATIVE_TO_PARENTS,
+            RELATIVE_TO_ABSOLUTE
+        };
+        
+        /** Set the transform's ReferenceFrame, either to be relative to its
+          * parent reference frame, or relative to an absolute coordinate
+          * frame. RELATIVE_TO_PARENTS is the default.
+          * Note: setting the ReferenceFrame to be RELATIVE_TO_ABSOLUTE will
+          * also set the CullingActive flag on the transform, and hence all
+          * of its parents, to false, thereby disabling culling of it and
+          * all its parents.  This is neccessary to prevent inappropriate
+          * culling, but may impact cull times if the absolute transform is
+          * deep in the scene graph.  It is therefore recommend to only use
+          * absolute Transforms at the top of the scene, for such things as
+          * heads up displays. */
+        void setReferenceFrame(ReferenceFrame rf);
+        
+        ReferenceFrame getReferenceFrame() const { return _referenceFrame; }
+
+        virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const
+        {
+            if (_referenceFrame==RELATIVE_TO_PARENTS)
+            {
+                return false;
+            }
+            else // absolute
+            {
+                matrix.makeIdentity();
+                return true;
+            }
+        }
+        
+        virtual bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor*) const
+        {
+            if (_referenceFrame==RELATIVE_TO_PARENTS)
+            {
+                return false;
+            }
+            else // absolute
+            {
+                matrix.makeIdentity();
+                return true;
+            }
+        }
+
+    protected :
+    
+        virtual ~Transform();
+        
+        /** Overrides Group's computeBound. 
+          * There is no need to override in subclasses from osg::Transform
+          * since this computeBound() uses the underlying matrix (calling
+          * computeMatrix if required.) */
+        virtual bool computeBound() const;
+        
+        ReferenceFrame                      _referenceFrame;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/UByte4
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/UByte4 (revision 2772)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/UByte4 (revision 2772)
@@ -0,0 +1,164 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_UBYTE4
+#define OSG_UBYTE4 1
+
+#include <osg/Vec3>
+
+#include <ostream>
+
+namespace osg {
+
+/** General purpose float quad, uses include representation
+    of colour coordinates.
+    No support yet added for float * UByte4 - is it necessary?
+    Need to define a non-member non-friend operator*  etc.
+   			     UByte4 * float is okay
+*/
+class UByte4
+{
+    public:
+
+	// Methods are defined here so that they are implicitly inlined
+
+        UByte4() { _v[0]=0; _v[1]=0; _v[2]=0; _v[3]=0;}
+        
+        UByte4(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
+        {
+            _v[0]=r; _v[1]=g; _v[2]=b; _v[3]=a;
+        }
+
+        unsigned char _v[4];
+
+        inline bool operator == (const UByte4& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1] && _v[2]==v._v[2] && _v[3]==v._v[3]; }
+
+        inline bool operator != (const UByte4& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1] || _v[2]!=v._v[2] || _v[3]!=v._v[3]; }
+
+        inline bool operator <  (const UByte4& v) const
+        {
+            if (_v[0]<v._v[0]) return true;
+            else if (_v[0]>v._v[0]) return false;
+            else if (_v[1]<v._v[1]) return true;
+            else if (_v[1]>v._v[1]) return false;
+            else if (_v[2]<v._v[2]) return true;
+            else if (_v[2]>v._v[2]) return false;
+            else return (_v[3]<v._v[3]);
+        }
+
+        inline unsigned char* ptr() { return _v; }
+        inline const unsigned char* ptr() const { return _v; }
+
+        inline void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
+        {
+            _v[0]=r; _v[1]=g; _v[2]=b; _v[3]=a;
+        }
+
+        inline unsigned char& operator [] (unsigned int i) { return _v[i]; }
+        inline unsigned char operator [] (unsigned int i) const { return _v[i]; }
+
+        inline unsigned char& r() { return _v[0]; }
+        inline unsigned char& g() { return _v[1]; }
+        inline unsigned char& b() { return _v[2]; }
+        inline unsigned char& a() { return _v[3]; }
+
+        inline unsigned char r() const { return _v[0]; }
+        inline unsigned char g() const { return _v[1]; }
+        inline unsigned char b() const { return _v[2]; }
+        inline unsigned char a() const { return _v[3]; }
+
+        /// multiply by scalar
+        inline UByte4 operator * (float rhs) const
+        {
+            UByte4 col(*this);
+            col *= rhs;
+            return col;
+        }
+
+        /// unary multiply by scalar
+        inline UByte4& operator *= (float rhs)
+        {
+            _v[0]=(unsigned char)((float)_v[0]*rhs);
+            _v[1]=(unsigned char)((float)_v[1]*rhs);
+            _v[2]=(unsigned char)((float)_v[2]*rhs);
+            _v[3]=(unsigned char)((float)_v[3]*rhs);
+            return *this;
+        }
+
+        /// divide by scalar
+        inline UByte4 operator / (float rhs) const
+        {
+            UByte4 col(*this);
+            col /= rhs;
+            return col;
+        }
+
+        /// unary divide by scalar
+        inline UByte4& operator /= (float rhs)
+        {
+            float div = 1.0f/rhs;
+            *this *= div;
+            return *this;
+        }
+
+        /// binary vector add
+        inline UByte4 operator + (const UByte4& rhs) const
+        {
+            return UByte4(_v[0]+rhs._v[0], _v[1]+rhs._v[1],
+		        _v[2]+rhs._v[2], _v[3]+rhs._v[3]);
+        }
+
+        /** unary vector add.  Slightly more efficient because no temporary
+            intermediate object*/
+        inline UByte4& operator += (const UByte4& rhs)
+        {
+            _v[0] += rhs._v[0];
+            _v[1] += rhs._v[1];
+            _v[2] += rhs._v[2];
+            _v[3] += rhs._v[3];
+            return *this;
+        }
+
+        /// binary vector subtract
+        inline UByte4 operator - (const UByte4& rhs) const
+        {
+            return UByte4(_v[0]-rhs._v[0], _v[1]-rhs._v[1],
+		        _v[2]-rhs._v[2], _v[3]-rhs._v[3] );
+        }
+
+        /// unary vector subtract
+        inline UByte4& operator -= (const UByte4& rhs)
+        {
+            _v[0]-=rhs._v[0];
+            _v[1]-=rhs._v[1];
+            _v[2]-=rhs._v[2];
+            _v[3]-=rhs._v[3];
+            return *this;
+        }
+
+        friend inline std::ostream& operator << (std::ostream& output, const UByte4& vec)
+        {
+	    output << (int)vec._v[0] << " "
+                   << (int)vec._v[1] << " "
+                   << (int)vec._v[2] << " "
+                   << (int)vec._v[3];
+	    return output; 	// to enable cascading
+	}
+
+};	// end of class UByte4
+
+
+
+}	// end of namespace osg
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/LOD
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/LOD (revision 3099)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/LOD (revision 3099)
@@ -0,0 +1,141 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_LOD
+#define OSG_LOD 1
+
+#include <osg/Group>
+
+namespace osg {
+
+/** LOD - Level Of Detail group node which allows switching between children
+    depending on distance from eye point.
+    Typical uses are for load balancing - objects further away from
+    the eye point are rendered at a lower level of detail, and at times
+    of high stress on the graphics pipeline lower levels of detail can
+    also be chosen.
+    The children are ordered from most detailed (for close up views) to the least 
+    (see from a distance), and a set of ranges are used to decide which LOD is used 
+    at different view distances, the criteria used is child 'i' is used when 
+    range[i]<dist<range[i+1] is true. This requires there to be n+1 range values where the number of
+    children is n, since no maximum distance of infinity is assumed.  If the number of range values (m)
+    is insufficient then the children m through to n will be ignored, only 0..m-1 will be used
+    during rendering.
+*/
+class SG_EXPORT LOD : public Group
+{
+    public :
+    
+        LOD();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        LOD(const LOD&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+        META_Node(osg, LOD);
+
+        virtual void traverse(NodeVisitor& nv);
+        
+        virtual bool addChild(Node *child);
+
+        virtual bool addChild(Node *child, float min, float max);
+
+        virtual bool removeChild(Node *child);
+
+
+        typedef std::pair<float,float>  MinMaxPair;
+        typedef std::vector<MinMaxPair> RangeList;
+      
+        /** Modes which control how the center of object should be determined when computed which child is active.*/
+        enum CenterMode
+        {
+            USE_BOUNDING_SPHERE_CENTER,
+            USER_DEFINED_CENTER
+        };
+
+        /** Set how the center of object should be determined when computed which child is active.*/
+        void setCenterMode(CenterMode mode) { _centerMode=mode; }
+
+        /** Get how the center of object should be determined when computed which child is active.*/
+        CenterMode getCenterMode() const { return _centerMode; }
+
+        /** Sets the object-space point which defines the center of the osg::LOD.  
+            center is affected by any transforms in the hierarchy above the osg::LOD.*/
+        inline void setCenter(const Vec3& center) { _centerMode=USER_DEFINED_CENTER; _userDefinedCenter = center; }
+        
+        /** return the LOD center point. */
+        inline const Vec3& getCenter() const { if (_centerMode==USER_DEFINED_CENTER) return _userDefinedCenter; else return getBound().center(); }
+
+
+        /** Set the object-space reference radius of the volume enclosed by the LOD. 
+          * Used to detmine the bounding sphere of the LOD in the absense of any children.*/
+        inline void setRadius(float radius) { _radius = radius; }
+        
+        /** Get the object-space radius of the volume enclosed by the LOD.*/
+        inline float getRadius() const { return _radius; }
+
+
+
+        /** Modes that control how the range values should be intepreted when computing which child is active.*/
+        enum RangeMode
+        {
+            DISTANCE_FROM_EYE_POINT,
+            PIXEL_SIZE_ON_SCREEN
+        };
+        
+        /** Set how the range values should be intepreted when computing which child is active.*/
+        void setRangeMode(RangeMode mode) { _rangeMode = mode; }
+
+        /** Get how the range values should be intepreted when computing which child is active.*/
+        RangeMode getRangeMode() const { return _rangeMode; }
+
+
+        /** Sets the min and max visible ranges of range of specifiec child.
+            Values are floating point distance specified in local objects coordinates.*/
+        void setRange(unsigned int childNo, float min,float max);
+        
+        /** returns the min visible range for specified child.*/
+        inline float getMinRange(unsigned int childNo) const { return _rangeList[childNo].first; }
+
+        /** returns the max visible range for specified child.*/
+        inline float getMaxRange(unsigned int childNo) const { return _rangeList[childNo].second; }
+        
+        /** returns the number of ranges currently set. 
+          * An LOD which has been fully set up will have getNumChildren()==getNumRanges(). */
+        inline unsigned int getNumRanges() const { return _rangeList.size(); }
+
+        /** return the list of MinMax ranges for each child.*/
+        inline const RangeList& getRangeList() const { return _rangeList; }
+
+    protected :
+        virtual ~LOD() {}
+
+        virtual bool computeBound() const;
+
+        virtual void childRemoved(unsigned int pos, unsigned int numChildrenToRemove);
+        virtual void childInserted(unsigned int pos);
+
+        virtual void rangeRemoved(unsigned int /*pos*/, unsigned int /*numChildrenToRemove*/) {}
+        virtual void rangeInserted(unsigned int /*pos*/) {}
+
+        CenterMode                      _centerMode;
+        Vec3                            _userDefinedCenter;
+        float                           _radius;
+
+        RangeMode                       _rangeMode;
+        RangeList                       _rangeList;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/CullFace
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/CullFace (revision 2773)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/CullFace (revision 2773)
@@ -0,0 +1,79 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_CULLFACE
+#define OSG_CULLFACE 1
+
+#include <osg/GL>
+#include <osg/StateAttribute>
+
+namespace osg {
+
+/** Class to globally enable/disable OpenGL's polygon culling mode=.
+*/     
+class SG_EXPORT CullFace : public StateAttribute
+{
+    public :
+    
+        enum Mode {
+            FRONT = GL_FRONT,
+            BACK = GL_BACK,
+            FRONT_AND_BACK = GL_FRONT_AND_BACK
+        };
+    
+        CullFace(Mode mode=BACK):
+            _mode(mode) {}
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        CullFace(const CullFace& cf,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            StateAttribute(cf,copyop),
+            _mode(cf._mode) {}
+
+        META_StateAttribute(osg, CullFace, CULLFACE);
+        
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const StateAttribute& sa) const
+        {
+            // check the types are equal and then create the rhs variable
+            // used by the COMPARE_StateAttribute_Paramter macro's below.
+            COMPARE_StateAttribute_Types(CullFace,sa)
+
+            // compare each paramter in turn against the rhs.
+            COMPARE_StateAttribute_Parameter(_mode)
+
+            return 0; // passed all the above comparison macro's, must be equal.
+        }
+
+        virtual bool getModeUsage(ModeUsage& usage) const
+        {
+            usage.usesMode(GL_CULL_FACE);
+            return true;
+        }
+
+        inline void setMode(Mode mode) { _mode = mode; }
+
+        inline Mode getMode() const { return _mode; }
+    
+        virtual void apply(State& state) const;
+        
+    protected:
+    
+        virtual ~CullFace();
+        
+        Mode _mode;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/PagedLOD
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/PagedLOD (revision 3099)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/PagedLOD (revision 3099)
@@ -0,0 +1,110 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_PagedLOD
+#define OSG_PagedLOD 1
+
+#include <osg/LOD>
+
+namespace osg {
+
+/** PagedLOD.
+*/
+class SG_EXPORT PagedLOD : public LOD
+{
+    public :
+    
+        PagedLOD();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        PagedLOD(const PagedLOD&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+        META_Node(osg, PagedLOD);
+        
+        
+
+        virtual void traverse(NodeVisitor& nv);
+        
+        virtual bool addChild(Node *child);
+
+        virtual bool addChild(Node *child, float min, float max);
+
+        virtual bool addChild(Node *child, float min, float max,const std::string& filename, float priorityOffset=0.0f, float priorityScale=1.0f);
+
+        virtual bool removeChild(Node *child);
+        
+        
+        struct PerRangeData
+        {
+            PerRangeData();
+            PerRangeData(const PerRangeData& prd);
+            PerRangeData& operator = (const PerRangeData& prd);
+
+            std::string _filename;
+            float       _priorityOffset;
+            float       _priorityScale;
+            double      _timeStamp;
+        };
+
+        typedef std::vector<PerRangeData> PerRangeDataList;
+
+        void setFileName(unsigned int childNo, const std::string& filename) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._filename=filename; }
+        const std::string& getFileName(unsigned int childNo) const { return _perRangeDataList[childNo]._filename; }
+        unsigned int getNumFileNames() const { return _perRangeDataList.size(); }
+
+
+        void setPriorityOffset(unsigned int childNo, float priorityOffset) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._priorityOffset=priorityOffset; }
+        float getPriorityOffset(unsigned int childNo) const { return _perRangeDataList[childNo]._priorityOffset; }
+        unsigned int getNumPriorityOffsets() const { return _perRangeDataList.size(); }
+
+        void setPriorityScale(unsigned int childNo, float priorityScale) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._priorityScale=priorityScale; }
+        float getPriorityScale(unsigned int childNo) const { return _perRangeDataList[childNo]._priorityScale; }
+        unsigned int getNumPriorityScales() const { return _perRangeDataList.size(); }
+
+
+        void setTimeStamp(unsigned int childNo, double timeStamp) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._timeStamp=timeStamp; }
+        double getTimeStamp(unsigned int childNo) const { return _perRangeDataList[childNo]._timeStamp; }
+        unsigned int getNumTimeStamps() const { return _perRangeDataList.size(); }
+
+
+        /** Set the number of children that the PagedLOD must keep around, even if thay are older than their expiry time.*/
+        inline void setNumChildrenThatCannotBeExpired(unsigned int num) { _numChildrenThatCannotBeExpired = num; }
+
+        /** Get the number of children that the PagedLOD must keep around, even if thay are older than their expiry time.*/
+        unsigned int getNumChildrenThatCannotBeExpired() const { return _numChildrenThatCannotBeExpired; }
+
+        /** Remove the children from the PagedLOD which haven't be visited since specified expiry time.
+            The removed children are added the removeChildren list passed into the method,
+            this allows the children to be deleted later at the callers discression.*/
+        virtual void removeExpiredChildren(double expiryTime,NodeList& removedChildren);
+
+    protected :
+    
+        virtual ~PagedLOD() {}
+
+        virtual void childRemoved(unsigned int pos, unsigned int numChildrenToRemove);
+        virtual void childInserted(unsigned int pos);
+
+        virtual void rangeRemoved(unsigned int pos, unsigned int numChildrenToRemove);
+        virtual void rangeInserted(unsigned int pos);
+        
+        void expandPerRangeDataTo(unsigned int pos);
+
+        unsigned int    _numChildrenThatCannotBeExpired;
+
+        PerRangeDataList    _perRangeDataList;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/State
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/State (revision 3252)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/State (revision 3252)
@@ -0,0 +1,1263 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_STATE
+#define OSG_STATE 1
+
+#include <osg/Export>
+#include <osg/StateSet>
+#include <osg/Matrix>
+
+#include <osg/FrameStamp>
+#include <osg/DisplaySettings>
+#include <osg/Polytope>
+#include <osg/Viewport>
+
+#include <vector>
+#include <map>
+
+namespace osg {
+
+#ifndef GL_TEXTURE0
+#define GL_TEXTURE0 0x84C0
+#endif
+
+#ifndef GL_FOG_COORDINATE_ARRAY
+    #ifdef GL_FOG_COORDINATE_ARRAY_EXT
+        #define GL_FOG_COORDINATE_ARRAY GL_FOG_COORDINATE_ARRAY_EXT
+    #else
+         #define GL_FOG_COORDINATE_ARRAY 0x8457
+    #endif
+#endif
+
+#ifndef GL_SECONDARY_COLOR_ARRAY
+    #ifdef GL_SECONDARY_COLOR_ARRAY_EXT
+        #define GL_SECONDARY_COLOR_ARRAY GL_SECONDARY_COLOR_ARRAY_EXT
+    #else
+         #define GL_SECONDARY_COLOR_ARRAY 0x845E
+    #endif
+#endif
+
+/** macro for use with osg::StateAttrbiute::apply methods for detected and 
+  * reporting OpenGL error messages.*/
+#define OSG_GL_DEBUG(message) \
+    if (state.getFineGrainedErrorDetection()) \
+    { \
+        GLenum errorNo = glGetError(); \
+        if (errorNo!=GL_NO_ERROR) \
+        { \
+            osg::notify(WARN)<<"Warning: detected OpenGL error '"<<gluErrorString(errorNo)<<" "<<message<<endl; \
+        }\
+    }
+
+/** State class for managing a state stack.
+  * Lazy state updating is used to minimize state changes.
+  */
+class SG_EXPORT State : public Referenced
+{
+    public :
+    
+        State();
+
+        /** push stateset onto state stack.*/
+        void pushStateSet(const StateSet* dstate);
+
+        /** pop stateset off state stack.*/
+        void popStateSet();
+       
+        /** pop all stateset's off state stack, ensuring its empty ready for the next frame.
+          * note, to return OpenGL to default state, one should do any state.popAllStatSets(); state.apply().*/
+        void popAllStateSets();
+
+        /** copy the modes and attributes which captures the current state.*/
+        void captureCurrentState(StateSet& stateset) const;
+
+        /** reset the state object to an empty stack.*/
+        void reset();
+        
+        inline const Viewport* getCurrentViewport() const
+        {
+            return static_cast<const Viewport*>(getLastAppliedAttribute(osg::StateAttribute::VIEWPORT));
+        }
+        
+
+        void setInitialViewMatrix(const osg::RefMatrix* matrix);
+
+        inline const osg::Matrix& getInitialViewMatrix() const { return *_initialViewMatrix; }
+        inline const osg::Matrix& getInitialInverseViewMatrix() const { return _initialInverseViewMatrix; }
+
+        inline void applyProjectionMatrix(const osg::RefMatrix* matrix)
+        {
+            if (_projection!=matrix)
+            {
+                glMatrixMode( GL_PROJECTION );
+                if (matrix) 
+                {
+                    _projection=matrix;
+                    glLoadMatrix(matrix->ptr());
+                }
+                else
+                {
+                    _projection=_identity;
+                    glLoadIdentity();
+                }
+                glMatrixMode( GL_MODELVIEW );
+            }
+        }
+        
+        inline const osg::Matrix& getProjectionMatrix() const
+        {
+            return *_projection;
+        }
+
+        inline void applyModelViewMatrix(const osg::RefMatrix* matrix)
+        {
+            if (_modelView!=matrix)
+            {
+                if (matrix)
+                {
+                    _modelView=matrix;
+                    glLoadMatrix(matrix->ptr());
+                }
+                else 
+                {
+                    _modelView=_identity;
+                    glLoadIdentity();
+                }
+            }
+        }
+
+        const osg::Matrix& getModelViewMatrix() const
+        {
+            return *_modelView;
+        }
+
+
+        Polytope getViewFrustum() const;
+
+
+        /** Apply stateset.*/
+        void apply(const StateSet* dstate);
+
+        /** Apply the state.*/
+        void apply();
+
+
+        inline void setGlobalDefaultModeValue(StateAttribute::GLMode mode,bool enabled)
+        {
+            ModeStack& ms = _modeMap[mode];
+            ms.global_default_value = enabled;
+        }
+
+        inline bool getGlobalDefaultModeValue(StateAttribute::GLMode mode)
+        {
+            return _modeMap[mode].global_default_value;
+        }
+
+
+        /** Apply an OpenGL mode if required. */
+        inline bool applyMode(StateAttribute::GLMode mode,bool enabled)
+        {
+            ModeStack& ms = _modeMap[mode];
+            ms.changed = true;    
+            return applyMode(mode,enabled,ms);
+        }
+
+        inline void setGlobalDefaultTextureModeValue(unsigned int unit, StateAttribute::GLMode mode,bool enabled)
+        {
+            ModeMap& modeMap = getOrCreateTextureModeMap(unit);
+            ModeStack& ms = modeMap[mode];
+            ms.global_default_value = enabled;
+        }
+
+        inline bool getGlobalDefaultTextureModeValue(unsigned int unit, StateAttribute::GLMode mode)
+        {
+            ModeMap& modeMap = getOrCreateTextureModeMap(unit);
+            ModeStack& ms = modeMap[mode];
+            return ms.global_default_value;
+        }
+
+        inline bool applyTextureMode(unsigned int unit, StateAttribute::GLMode mode,bool enabled)
+        {
+            if (setActiveTextureUnit(unit))
+            {
+                ModeMap& modeMap = getOrCreateTextureModeMap(unit);
+                ModeStack& ms = modeMap[mode];
+                ms.changed = true;
+                return applyMode(mode,enabled,ms);
+            }
+            else
+                return false;
+        }
+
+        inline void setGlobalDefaultAttribute(const StateAttribute* attribute)
+        {
+            AttributeStack& as = _attributeMap[attribute->getType()];
+            as.global_default_attribute = attribute;
+        }
+
+        inline const StateAttribute* getGlobalDefaultAttribute(StateAttribute::Type type)
+        {
+            AttributeStack& as = _attributeMap[type];
+            return as.global_default_attribute.get();
+        }
+
+        /** Apply an attribute if required. */
+        inline bool applyAttribute(const StateAttribute* attribute)
+        {
+            AttributeStack& as = _attributeMap[attribute->getType()];
+            as.changed = true;
+            return applyAttribute(attribute,as);
+        }
+
+        inline void setGlobalDefaultTextureAttribute(unsigned int unit, const StateAttribute* attribute)
+        {
+            AttributeMap& attributeMap = getOrCreateTextureAttributeMap(unit);
+            AttributeStack& as = attributeMap[attribute->getType()];
+            as.global_default_attribute = attribute;
+        }
+
+        inline const StateAttribute* getGlobalDefaultTextureAttribute(unsigned int unit, StateAttribute::Type type)
+        {
+            AttributeMap& attributeMap = getOrCreateTextureAttributeMap(unit);
+            AttributeStack& as = attributeMap[type];
+            return as.global_default_attribute.get();
+        }
+
+
+        inline bool applyTextureAttribute(unsigned int unit, const StateAttribute* attribute)
+        {
+            if (setActiveTextureUnit(unit))
+            {
+                AttributeMap& attributeMap = getOrCreateTextureAttributeMap(unit);
+                AttributeStack& as = attributeMap[attribute->getType()];
+                as.changed = true;
+                return applyAttribute(attribute,as);
+            }
+            else
+                return false;
+        }
+       
+        /** Mode has been set externally, update state to reflect this setting.*/
+        void haveAppliedMode(StateAttribute::GLMode mode,StateAttribute::GLModeValue value);
+        
+        /** Mode has been set externally, therefore dirty the associated mode in osg::State
+          * so it is applied on next call to osg::State::apply(..)*/
+        void haveAppliedMode(StateAttribute::GLMode mode);
+
+        /** Attribute has been applied externally, update state to reflect this setting.*/
+        void haveAppliedAttribute(const StateAttribute* attribute);
+
+        /** Attribute has been applied externally, 
+          * and therefore this attribute type has been dirtied 
+          * and will need to be re-appplied on next osg::State.apply(..).
+          * note, if you have an osg::StateAttribute which you have applied externally
+          * then use the have_applied(attribute) method as this will the osg::State to
+          * track the current state more accuratly and enable lazy state updating such
+          * that only changed state will be applied.*/
+        void haveAppliedAttribute(StateAttribute::Type type);
+
+        /** Get whether the current specified mode is enabled (true) or disabled (false).*/ 
+        bool getLastAppliedMode(StateAttribute::GLMode mode) const;
+        
+        /** Get the current specified attribute, return NULL is one has not yet been applied.*/ 
+        const StateAttribute* getLastAppliedAttribute(StateAttribute::Type type) const;
+        
+
+
+        /** texture Mode has been set externally, update state to reflect this setting.*/
+        void haveAppliedTextureMode(unsigned int unit, StateAttribute::GLMode mode,StateAttribute::GLModeValue value);
+        
+        /** texture Mode has been set externally, therefore dirty the associated mode in osg::State
+          * so it is applied on next call to osg::State::apply(..)*/
+        void haveAppliedTextureMode(unsigned int unit, StateAttribute::GLMode mode);
+
+        /** texture Attribute has been applied externally, update state to reflect this setting.*/
+        void haveAppliedTextureAttribute(unsigned int unit, const StateAttribute* attribute);
+
+        /** texture Attribute has been applied externally, 
+          * and therefore this attribute type has been dirtied 
+          * and will need to be re-appplied on next osg::State.apply(..).
+          * note, if you have an osg::StateAttribute which you have applied externally
+          * then use the have_applied(attribute) method as this will the osg::State to
+          * track the current state more accuratly and enable lazy state updating such
+          * that only changed state will be applied.*/
+        void haveAppliedTextureAttribute(unsigned int unit, StateAttribute::Type type);
+
+        /** Get whether the current specified texture mode is enabled (true) or disabled (false).*/ 
+        bool getLastAppliedTextureMode(unsigned int unit, StateAttribute::GLMode mode) const;
+        
+        /** Get the current specified texture attribute, return NULL is one has not yet been applied.*/ 
+        const StateAttribute* getLastAppliedTextureAttribute(unsigned int unit, StateAttribute::Type type) const;
+
+
+        /** Dirty the modes previously applied in osg::State.*/
+        void dirtyAllModes();
+
+        /** Dirty the modes attributes previously applied in osg::State.*/
+        void dirtyAllAttributes();
+
+        /** disable the vertex, normal, color, tex coords, secenday color, fog coord and index arrays.*/
+        void disableAllVertexArrays();
+
+        /** dirty the vertex, normal, color, tex coords, secenday color, fog coord and index arrays.*/
+        void dirtyAllVertexArrays();
+
+
+        /** Wrapper around glInterleavedArrays(..).
+          * also resets the internal array points and modes within osg::State to keep the other
+          * vertex array operations consistent. */
+        void setInterleavedArrays( GLenum format, GLsizei stride, const GLvoid* pointer);
+
+
+        /** wrapper around glEnableClientState(GL_VERTEX_ARRAY);glVertexPointer(..);
+          * note, only updates values that change.*/
+        inline void setVertexPointer( GLint size, GLenum type,
+                                      GLsizei stride, const GLvoid *ptr )
+        {
+            if (!_vertexArray._enabled || _vertexArray._dirty)
+            {
+                _vertexArray._enabled = true;
+                glEnableClientState(GL_VERTEX_ARRAY);
+            }
+            //if (_vertexArray._pointer!=ptr || _vertexArray._dirty)
+            {
+                _vertexArray._pointer=ptr;
+                glVertexPointer( size, type, stride, ptr );
+            }
+            _vertexArray._dirty = false;
+        }
+        
+        /** wrapper glDisableClientState(GL_VERTEX_ARRAY).
+          * note, only updates values that change.*/
+        inline void disableVertexPointer()
+        {
+            if (_vertexArray._enabled || _vertexArray._dirty)
+            {
+                _vertexArray._enabled = false;
+                _vertexArray._dirty = false;
+                glDisableClientState(GL_VERTEX_ARRAY);
+            }
+        }
+
+        inline void dirtyVertexPointer()
+        {
+            _vertexArray._pointer = 0; 
+            _vertexArray._dirty = true; 
+        }
+
+        /** wrapper around glEnableClientState(GL_NORMAL_ARRAY);glNormalPointer(..);
+          * note, only updates values that change.*/
+        inline void setNormalPointer( GLenum type, GLsizei stride,
+                                      const GLvoid *ptr )
+        {
+            if (!_normalArray._enabled || _normalArray._dirty)
+            {
+                _normalArray._enabled = true;
+                glEnableClientState(GL_NORMAL_ARRAY);
+            }
+            //if (_normalArray._pointer!=ptr || _normalArray._dirty)
+            {
+                _normalArray._pointer=ptr;
+                glNormalPointer( type, stride, ptr );
+            }
+            _normalArray._dirty = false;
+        }
+
+        /** wrapper around glDisableClientState(GL_NORMAL_ARRAY);
+          * note, only updates values that change.*/
+        inline void disableNormalPointer()
+        {
+            if (_normalArray._enabled || _normalArray._dirty)
+            {
+                _normalArray._enabled = false;
+                _normalArray._dirty = false;
+                glDisableClientState(GL_NORMAL_ARRAY);
+            }
+        }
+
+        inline void dirtyNormalPointer()
+        {
+            _normalArray._pointer = 0;
+            _normalArray._dirty = true;
+        }
+
+        /** wrapper around glEnableClientState(GL_COLOR_ARRAY);glColorPointer(..);
+          * note, only updates values that change.*/
+        inline void setColorPointer( GLint size, GLenum type,
+                                     GLsizei stride, const GLvoid *ptr )
+        {
+            if (!_colorArray._enabled || _colorArray._dirty)
+            {
+                _colorArray._enabled = true;
+                glEnableClientState(GL_COLOR_ARRAY);
+            }
+            //if (_colorArray._pointer!=ptr || _colorArray._dirty)
+            {
+                _colorArray._pointer=ptr;
+                glColorPointer( size, type, stride, ptr );
+            }
+            _colorArray._dirty = false;
+        }
+
+        /** wrapper around glDisableClientState(GL_COLOR_ARRAY);
+          * note, only updates values that change.*/
+        inline void disableColorPointer()
+        {
+            if (_colorArray._enabled || _colorArray._dirty)
+            {
+                _colorArray._enabled = false;
+                _colorArray._dirty = false;
+                glDisableClientState(GL_COLOR_ARRAY);
+            }
+        }
+
+        inline void dirtyColorPointer()
+        { 
+            _colorArray._pointer = 0;
+            _colorArray._dirty = true;
+        }
+
+
+        inline bool isSecondaryColorSupported() const { return _isSecondaryColorSupportResolved?_isSecondaryColorSupported:computeSecondaryColorSupported(); }
+
+        /** wrapper around glEnableClientState(GL_SECONDARY_COLOR_ARRAY);glSecondayColorPointer(..);
+          * note, only updates values that change.*/
+        void setSecondaryColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr );
+
+        /** wrapper around glDisableClientState(GL_SECONDARY_COLOR_ARRAY);
+          * note, only updates values that change.*/
+        inline void disableSecondaryColorPointer()
+        {
+            if (_secondaryColorArray._enabled || _secondaryColorArray._dirty)
+            {
+                _secondaryColorArray._enabled = false;
+                _secondaryColorArray._dirty = false;
+                if (isSecondaryColorSupported()) glDisableClientState(GL_SECONDARY_COLOR_ARRAY);
+            }
+        }
+
+        inline void dirtySecondaryColorPointer()
+        {
+            _secondaryColorArray._pointer = 0;
+            _secondaryColorArray._dirty = true;
+        }
+
+        /** wrapper around glEnableClientState(GL_INDEX_ARRAY);glIndexPointer(..);
+          * note, only updates values that change.*/
+        inline void setIndexPointer( GLenum type, GLsizei stride,
+                              const GLvoid *ptr )
+        {
+            if (!_indexArray._enabled || _indexArray._dirty)
+            {
+                _indexArray._enabled = true;
+                glEnableClientState(GL_INDEX_ARRAY);
+            }
+            //if (_indexArray._pointer!=ptr || _indexArray._dirty)
+            {
+                _indexArray._pointer=ptr;
+                glIndexPointer( type, stride, ptr );
+            }
+            _indexArray._dirty = false;
+        }
+
+        /** wrapper around glDisableClientState(GL_INDEX_ARRAY);
+          * note, only updates values that change.*/
+        inline void disableIndexPointer()
+        {
+            if (_indexArray._enabled || _indexArray._dirty)
+            {
+                _indexArray._enabled = false;
+                _indexArray._dirty = false;
+                glDisableClientState(GL_INDEX_ARRAY);
+            }
+        }
+
+        inline void dirtyIndexPointer()
+        {
+            _indexArray._pointer = 0;
+            _indexArray._dirty = true;
+        }
+
+
+        inline bool isFogCoordSupported() const { return _isFogCoordSupportResolved?_isFogCoordSupported:computeFogCoordSupported(); }
+
+        /** wrapper around glEnableClientState(GL_FOG_COORDINATE_ARRAY);glFogCoordPointer(..);
+          * note, only updates values that change.*/
+        void setFogCoordPointer( GLenum type, GLsizei stride, const GLvoid *ptr );
+
+        /** wrapper around glDisableClientState(GL_FOG_COORDINATE_ARRAY);
+          * note, only updates values that change.*/
+        inline void disableFogCoordPointer()
+        {
+            if (_fogArray._enabled || _fogArray._dirty)
+            {
+                _fogArray._enabled = false;
+                _fogArray._dirty = false;
+                if (isFogCoordSupported()) glDisableClientState(GL_FOG_COORDINATE_ARRAY);
+            }
+        }
+
+        inline void dirtyFogCoordPointer()
+        {
+            _fogArray._pointer = 0;
+            _fogArray._dirty = true;
+        }
+
+
+        /** wrapper around glEnableClientState(GL_TEXTURE_COORD_ARRAY);glTexCoordPointer(..);
+          * note, only updates values that change.*/
+        inline void setTexCoordPointer( unsigned int unit,
+                                        GLint size, GLenum type,
+                                        GLsizei stride, const GLvoid *ptr )
+        {
+            if (setClientActiveTextureUnit(unit))
+            {
+                if ( unit >= _texCoordArrayList.size()) _texCoordArrayList.resize(unit+1);
+                EnabledArrayPair& eap = _texCoordArrayList[unit];
+
+                if (!eap._enabled || eap._dirty)
+                {
+                    eap._enabled = true;
+                    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+                }
+                //if (eap._pointer!=ptr || eap._dirty)
+                {
+                    glTexCoordPointer( size, type, stride, ptr );
+                    eap._pointer = ptr;
+                }
+                eap._dirty = false;
+            }
+        }
+
+        /** wrapper around glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+          * note, only updates values that change.*/
+        inline void disableTexCoordPointer( unsigned int unit )
+        {
+            if (setClientActiveTextureUnit(unit))
+            {
+                if ( unit >= _texCoordArrayList.size()) _texCoordArrayList.resize(unit+1);
+                EnabledArrayPair& eap = _texCoordArrayList[unit];
+
+                if (eap._enabled || eap._dirty)
+                {
+                    eap._enabled = false;
+                    eap._dirty = false;
+                    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+                }
+            }
+        }
+
+        inline void dirtyTexCoordPointer( unsigned int unit )
+        {
+            if ( unit >= _texCoordArrayList.size()) return; // _texCoordArrayList.resize(unit+1);
+            EnabledArrayPair& eap = _texCoordArrayList[unit];
+            eap._pointer = 0;
+            eap._dirty = true;
+        }
+
+
+        inline void disableTexCoordPointersAboveAndIncluding( unsigned int unit )
+        {
+            while (unit<_texCoordArrayList.size())
+            {
+                EnabledArrayPair& eap = _texCoordArrayList[unit];
+                if (eap._enabled || eap._dirty)
+                {
+                    if (setClientActiveTextureUnit(unit))
+                    {
+                        eap._enabled = false;
+                        eap._dirty = false;
+                        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+                    }
+                }
+                ++unit;
+            }
+        }
+
+        inline void dirtyTexCoordPointersAboveAndIncluding( unsigned int unit )
+        {
+            while (unit<_texCoordArrayList.size())
+            {
+                EnabledArrayPair& eap = _texCoordArrayList[unit];
+                eap._pointer = 0;
+                eap._dirty = true;
+                ++unit;
+            }
+        }
+
+        /** set the current tex coord array texture unit, return true if selected, false if selection failed such as when multitexturing is not supported.
+          * note, only updates values that change.*/
+        bool setClientActiveTextureUnit( unsigned int unit );
+
+
+        /** set the current texture unit, return true if selected, false if selection failed such as when multitexturing is not supported.
+          * note, only updates values that change.*/
+        bool setActiveTextureUnit( unsigned int unit );
+        
+        /** wrapper around glEnableVertexAttribArrayARB(index);glVertexAttribPointerARB(..);
+          * note, only updates values that change.*/
+        void setVertexAttribPointer( unsigned int index,
+                                     GLint size, GLenum type, GLboolean normalized, 
+                                     GLsizei stride, const GLvoid *ptr );
+        
+        /** wrapper around DisableVertexAttribArrayARB(index);
+          * note, only updates values that change.*/
+        void disableVertexAttribPointer( unsigned int index );
+      
+        void disableVertexAttribPointersAboveAndIncluding( unsigned int index );
+        
+        inline void dirtyVertexAttribPointersAboveAndIncluding( unsigned int index )
+        {
+            while (index<_vertexAttribArrayList.size())
+            {
+                EnabledArrayPair& eap = _vertexAttribArrayList[index];
+                eap._pointer = 0;
+                eap._dirty = true;
+                ++index;
+            }
+        }
+
+        bool isVertexBufferObjectSupported() const { return _isVertexBufferObjectSupportResolved?_isVertexBufferObjectSupported:computeVertexBufferObjectSupported(); }
+
+
+        /** Set the current OpenGL context uniqueID.
+            Note, it is the application developers responsibility to
+            set up unique ID for each OpenGL context.  This value is
+            then used by osg::StateAttribure's and osg::Drawable's to
+            help manage OpenGL display list and texture binds appropriate
+            for each context, the contextID simply acts as an index local
+            arrays that they maintain for the purpose.
+            Typical settings for contextID are 0,1,2,3... up to the maximum
+            number of graphics contexts you have setup.
+            By default contextID is 0.*/ 
+        inline void setContextID(unsigned int contextID) { _contextID=contextID; }
+
+        /** Get the current OpenGL context unique ID.*/ 
+        inline unsigned int getContextID() const { return _contextID; }
+        
+        
+        /** Set the frame stamp for the current frame.*/
+        inline void setFrameStamp(FrameStamp* fs) { _frameStamp = fs; }
+
+        /** Set the frame stamp for the current frame.*/
+        inline const FrameStamp* getFrameStamp() const { return _frameStamp.get(); }
+        
+                
+        /** Set the DisplaySettings. Note, nothing is applied, the visual settings are just used
+          * used in the State object to pass the current visual settings to Drawables
+          * during rendering. */
+        inline void setDisplaySettings(DisplaySettings* vs) { _displaySettings = vs; }
+        
+        /** Get the DisplaySettings */
+        inline const DisplaySettings* getDisplaySettings() const { return _displaySettings.get(); }
+
+        typedef std::pair<const StateAttribute*,StateAttribute::OverrideValue>  AttributePair;
+        typedef std::vector<AttributePair>                                      AttributeVec;
+        typedef std::vector<StateAttribute::GLModeValue>                        ValueVec;
+        
+        
+        /** Set flag for early termination of the draw traversal.*/
+        void setAbortRenderingPtr(bool* abortPtr) { _abortRenderingPtr = abortPtr; }
+
+        /** Get flag for early termination of the draw traversal, 
+          * if true steps should be taken to complete rendering early.*/
+        bool getAbortRendering() const { return _abortRenderingPtr!=0?(*_abortRenderingPtr):false; }
+
+        void setReportGLErrors(bool flag) { _reportGLErrors = flag; }
+        bool getReportGLErrors() const { return _reportGLErrors; }
+
+        bool checkGLErrors(const char* str) const;
+        bool checkGLErrors(StateAttribute::GLMode mode) const;
+        bool checkGLErrors(const StateAttribute* attribute) const;
+
+    protected:
+
+        virtual ~State();
+
+        unsigned int                _contextID;
+        ref_ptr<FrameStamp>         _frameStamp;
+        
+        ref_ptr<const RefMatrix>    _identity;
+        ref_ptr<const RefMatrix>    _initialViewMatrix;
+        ref_ptr<const RefMatrix>    _projection;
+        ref_ptr<const RefMatrix>    _modelView;
+        
+        Matrix                      _initialInverseViewMatrix;
+
+        ref_ptr<DisplaySettings>    _displaySettings;
+        
+        bool*                       _abortRenderingPtr;
+        bool                        _reportGLErrors;
+
+        struct ModeStack
+        {
+            ModeStack()
+            {
+                changed = false;
+                last_applied_value = false;
+                global_default_value = false;
+            }
+        
+            bool        changed;
+            bool        last_applied_value;
+            bool        global_default_value;
+            ValueVec    valueVec;
+        };
+
+
+
+        struct AttributeStack
+        {
+            AttributeStack()
+            {
+                changed = false;
+                last_applied_attribute = 0L;
+                global_default_attribute = 0L;
+            }
+
+            /** apply an attribute if required, passing in attribute and appropriate attribute stack */
+            bool                    changed;
+            const StateAttribute*   last_applied_attribute;
+            ref_ptr<const StateAttribute> global_default_attribute;
+            AttributeVec            attributeVec;
+        };
+        
+
+        /** apply an OpenGL mode if required, passing in mode, enable flag and appropriate mode stack */
+        inline bool applyMode(StateAttribute::GLMode mode,bool enabled,ModeStack& ms)
+        {
+            if (ms.last_applied_value != enabled)
+            {
+                ms.last_applied_value = enabled;
+
+                if (enabled) glEnable(mode);
+                else glDisable(mode);
+
+                if (_reportGLErrors) checkGLErrors(mode);
+
+                return true;
+            }
+            else
+                return false;
+        }
+
+
+        /** apply an attribute if required, passing in attribute and appropriate attribute stack */
+        inline bool applyAttribute(const StateAttribute* attribute,AttributeStack& as)
+        {
+            if (as.last_applied_attribute != attribute)
+            {
+                if (!as.global_default_attribute.valid()) as.global_default_attribute = dynamic_cast<StateAttribute*>(attribute->cloneType());
+
+                as.last_applied_attribute = attribute;
+                attribute->apply(*this);
+                
+                if (_reportGLErrors) checkGLErrors(attribute);
+                
+                return true;
+            }
+            else
+                return false;
+        }
+
+        inline bool applyGlobalDefaultAttribute(AttributeStack& as)
+        {
+            if (as.last_applied_attribute != as.global_default_attribute.get())
+            {
+                as.last_applied_attribute = as.global_default_attribute.get();
+                if (as.global_default_attribute.valid())
+                {
+                    as.global_default_attribute->apply(*this);
+                    if (_reportGLErrors) checkGLErrors(as.global_default_attribute.get());
+                }
+                return true;
+            }
+            else
+                return false;
+        }
+        
+
+        typedef std::map<StateAttribute::GLMode,ModeStack>      ModeMap;
+        typedef std::vector<ModeMap>                            TextureModeMapList;
+
+        typedef std::map<StateAttribute::Type,AttributeStack>   AttributeMap;
+        typedef std::vector<AttributeMap>                       TextureAttributeMapList;
+
+        typedef std::vector<const StateSet*>                    StateSetStack;
+        typedef std::vector<ref_ptr<const Matrix> >             MatrixStack;
+
+        ModeMap                                                 _modeMap;
+        AttributeMap                                            _attributeMap;
+
+        TextureModeMapList                                      _textureModeMapList;
+        TextureAttributeMapList                                 _textureAttributeMapList;
+       
+        StateSetStack                                           _drawStateStack;
+        
+        struct EnabledArrayPair
+        {
+            EnabledArrayPair():_dirty(true),_enabled(false),_normalized(0),_pointer(0) {}
+            EnabledArrayPair(const EnabledArrayPair& eap):_dirty(eap._dirty), _enabled(eap._enabled),_normalized(eap._normalized),_pointer(eap._pointer) {}
+            EnabledArrayPair& operator = (const EnabledArrayPair& eap) { _dirty=eap._dirty; _enabled=eap._enabled; _normalized=eap._normalized;_pointer=eap._pointer; return *this; }
+            
+            bool            _dirty;
+            bool            _enabled;
+            GLboolean       _normalized;
+            const GLvoid*   _pointer;
+        };
+        
+        typedef std::vector<EnabledArrayPair>                   EnabledTexCoordArrayList;
+        typedef std::vector<EnabledArrayPair>                   EnabledVertexAttribArrayList;
+
+        EnabledArrayPair                _vertexArray;
+        EnabledArrayPair                _normalArray;
+        EnabledArrayPair                _colorArray;
+        EnabledArrayPair                _secondaryColorArray;
+        EnabledArrayPair                _indexArray;
+        EnabledArrayPair                _fogArray;
+        EnabledTexCoordArrayList        _texCoordArrayList;
+        EnabledVertexAttribArrayList    _vertexAttribArrayList;
+
+        unsigned int                    _currentActiveTextureUnit;
+        unsigned int                    _currentClientActiveTextureUnit;
+        
+        inline ModeMap& getOrCreateTextureModeMap(unsigned int unit)
+        {        
+            if (unit>=_textureModeMapList.size()) _textureModeMapList.resize(unit+1);
+            return _textureModeMapList[unit];
+        }
+
+
+        inline AttributeMap& getOrCreateTextureAttributeMap(unsigned int unit)
+        {        
+            if (unit>=_textureAttributeMapList.size()) _textureAttributeMapList.resize(unit+1);
+            return _textureAttributeMapList[unit];
+        }
+        
+        inline void pushModeList(ModeMap& modeMap,const StateSet::ModeList& modeList);
+        inline void pushAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList);
+        
+        inline void popModeList(ModeMap& modeMap,const StateSet::ModeList& modeList);
+        inline void popAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList);
+
+        inline void applyModeList(ModeMap& modeMap,const StateSet::ModeList& modeList);
+        inline void applyAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList);
+        
+        inline void applyModeMap(ModeMap& modeMap);
+        inline void applyAttributeMap(AttributeMap& attributeMap);
+
+        void haveAppliedMode(ModeMap& modeMap,StateAttribute::GLMode mode,StateAttribute::GLModeValue value);
+        void haveAppliedMode(ModeMap& modeMap,StateAttribute::GLMode mode);
+        void haveAppliedAttribute(AttributeMap& attributeMap,const StateAttribute* attribute);
+        void haveAppliedAttribute(AttributeMap& attributeMap,StateAttribute::Type type);
+        bool getLastAppliedMode(const ModeMap& modeMap,StateAttribute::GLMode mode) const;
+        const StateAttribute* getLastAppliedAttribute(const AttributeMap& attributeMap,StateAttribute::Type type) const;
+
+
+        mutable bool _isSecondaryColorSupportResolved;
+        mutable bool _isSecondaryColorSupported;
+        bool computeSecondaryColorSupported() const;
+
+        mutable bool _isFogCoordSupportResolved;
+        mutable bool _isFogCoordSupported;
+        bool computeFogCoordSupported() const;
+
+        mutable bool _isVertexBufferObjectSupportResolved;
+        mutable bool _isVertexBufferObjectSupported;
+        bool computeVertexBufferObjectSupported() const;
+
+};
+
+inline void State::pushModeList(ModeMap& modeMap,const StateSet::ModeList& modeList)
+{
+    for(StateSet::ModeList::const_iterator mitr=modeList.begin();
+        mitr!=modeList.end();
+        ++mitr)
+    {
+        // get the mode stack for incomming GLmode {mitr->first}.
+        ModeStack& ms = modeMap[mitr->first];
+        if (ms.valueVec.empty())
+        {
+            // first pair so simply push incomming pair to back.
+            ms.valueVec.push_back(mitr->second);
+        }
+        else if ((ms.valueVec.back() & StateAttribute::OVERRIDE) && !(mitr->second & StateAttribute::PROTECTED)) // check the existing override flag 
+        {
+            // push existing back since override keeps the previoius value.
+            ms.valueVec.push_back(ms.valueVec.back());
+        }
+        else 
+        {
+            // no override on so simply push incomming pair to back.
+            ms.valueVec.push_back(mitr->second);
+        }
+        ms.changed = true;
+    }
+}
+
+inline void State::pushAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList)
+{
+    for(StateSet::AttributeList::const_iterator aitr=attributeList.begin();
+        aitr!=attributeList.end();
+        ++aitr)
+    {
+        // get the attribute stack for incomming type {aitr->first}.
+        AttributeStack& as = attributeMap[aitr->first];
+        if (as.attributeVec.empty())
+        {
+            // first pair so simply push incomming pair to back.
+            as.attributeVec.push_back(
+                AttributePair(aitr->second.first.get(),aitr->second.second));
+        }
+        else if ((as.attributeVec.back().second & StateAttribute::OVERRIDE) && !(aitr->second.second & StateAttribute::PROTECTED)) // check the existing override flag 
+        {
+            // push existing back since override keeps the previoius value.
+            as.attributeVec.push_back(as.attributeVec.back());
+        }
+        else 
+        {
+            // no override on so simply push incomming pair to back.
+            as.attributeVec.push_back(
+                AttributePair(aitr->second.first.get(),aitr->second.second));
+        }
+        as.changed = true;
+    }
+}
+
+inline void State::popModeList(ModeMap& modeMap,const StateSet::ModeList& modeList)
+{
+    for(StateSet::ModeList::const_iterator mitr=modeList.begin();
+        mitr!=modeList.end();
+        ++mitr)
+    {
+        // get the mode stack for incomming GLmode {mitr->first}.
+        ModeStack& ms = modeMap[mitr->first];
+        if (!ms.valueVec.empty())
+        {
+            ms.valueVec.pop_back();
+        }
+        ms.changed = true;
+    }
+}
+
+inline void State::popAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList)
+{
+    for(StateSet::AttributeList::const_iterator aitr=attributeList.begin();
+        aitr!=attributeList.end();
+        ++aitr)
+    {
+        // get the attribute stack for incomming type {aitr->first}.
+        AttributeStack& as = attributeMap[aitr->first];
+        if (!as.attributeVec.empty())
+        {
+            as.attributeVec.pop_back();
+        }
+        as.changed = true;
+    }
+}
+
+inline void State::applyModeList(ModeMap& modeMap,const StateSet::ModeList& modeList)
+{
+    StateSet::ModeList::const_iterator ds_mitr = modeList.begin();
+    ModeMap::iterator this_mitr=modeMap.begin();
+
+    while (this_mitr!=modeMap.end() && ds_mitr!=modeList.end())
+    {
+        if (this_mitr->first<ds_mitr->first)
+        {
+
+            // note GLMode = this_mitr->first
+            ModeStack& ms = this_mitr->second;
+            if (ms.changed)
+            {
+                ms.changed = false;
+                if (!ms.valueVec.empty())
+                {
+                    bool new_value = ms.valueVec.back() & StateAttribute::ON;
+                    applyMode(this_mitr->first,new_value,ms);
+                }
+                else
+                {
+                    // assume default of disabled.
+                    applyMode(this_mitr->first,ms.global_default_value,ms);
+
+                }
+
+            }
+
+            ++this_mitr;
+
+        }
+        else if (ds_mitr->first<this_mitr->first)
+        {
+
+            // ds_mitr->first is a new mode, therefore 
+            // need to insert a new mode entry for ds_mistr->first.
+            ModeStack& ms = modeMap[ds_mitr->first];
+
+            bool new_value = ds_mitr->second & StateAttribute::ON;
+            applyMode(ds_mitr->first,new_value,ms);
+
+            // will need to disable this mode on next apply so set it to changed.
+            ms.changed = true;
+
+            ++ds_mitr;
+
+        }
+        else
+        {
+            // this_mitr & ds_mitr refer to the same mode, check the overide
+            // if any otherwise just apply the incomming mode.
+
+            ModeStack& ms = this_mitr->second;
+
+            if (!ms.valueVec.empty() && (ms.valueVec.back() & StateAttribute::OVERRIDE) && !(ds_mitr->second & StateAttribute::PROTECTED))
+            {
+                // override is on, there just treat as a normal apply on modes.
+
+                if (ms.changed)
+                {
+                    ms.changed = false;
+                    bool new_value = ms.valueVec.back() & StateAttribute::ON;
+                    applyMode(this_mitr->first,new_value,ms);
+
+                }
+            }
+            else
+            {
+                // no override on or no previous entry, therefore consider incomming mode.
+                bool new_value = ds_mitr->second & StateAttribute::ON;
+                if (applyMode(ds_mitr->first,new_value,ms))
+                {
+                    ms.changed = true;
+                }
+            }
+
+            ++this_mitr;
+            ++ds_mitr;
+        }
+    }
+
+    // iterator over the remaining state modes to apply any previous changes.
+    for(;
+        this_mitr!=modeMap.end();
+        ++this_mitr)
+    {
+        // note GLMode = this_mitr->first
+        ModeStack& ms = this_mitr->second;
+        if (ms.changed)
+        {
+            ms.changed = false;
+            if (!ms.valueVec.empty())
+            {
+                bool new_value = ms.valueVec.back() & StateAttribute::ON;
+                applyMode(this_mitr->first,new_value,ms);
+            }
+            else
+            {
+                // assume default of disabled.
+                applyMode(this_mitr->first,ms.global_default_value,ms);
+
+            }
+
+        }
+    }        
+
+    // iterator over the remaining incomming modes to apply any new mode.
+    for(;
+        ds_mitr!=modeList.end();
+        ++ds_mitr)
+    {
+        ModeStack& ms = modeMap[ds_mitr->first];
+
+        bool new_value = ds_mitr->second & StateAttribute::ON;
+        applyMode(ds_mitr->first,new_value,ms);
+
+        // will need to disable this mode on next apply so set it to changed.
+        ms.changed = true;
+    }
+}
+
+inline void State::applyAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList)
+{
+    StateSet::AttributeList::const_iterator ds_aitr=attributeList.begin();
+
+    AttributeMap::iterator this_aitr=attributeMap.begin();
+
+    while (this_aitr!=attributeMap.end() && ds_aitr!=attributeList.end())
+    {
+        if (this_aitr->first<ds_aitr->first)
+        {
+
+            // note attribute type = this_aitr->first
+            AttributeStack& as = this_aitr->second;
+            if (as.changed)
+            {
+                as.changed = false;
+                if (!as.attributeVec.empty())
+                {
+                    const StateAttribute* new_attr = as.attributeVec.back().first;
+                    applyAttribute(new_attr,as);
+                }
+                else
+                {
+                    applyGlobalDefaultAttribute(as);
+                }
+            }
+
+            ++this_aitr;
+
+        }
+        else if (ds_aitr->first<this_aitr->first)
+        {
+
+            // ds_mitr->first is a new attribute, therefore 
+            // need to insert a new attribute entry for ds_aistr->first.
+            AttributeStack& as = attributeMap[ds_aitr->first];
+
+            const StateAttribute* new_attr = ds_aitr->second.first.get();
+            applyAttribute(new_attr,as);
+
+            // will need to disable this mode on next apply so set it to changed.
+            as.changed = true;
+
+            ++ds_aitr;
+
+        }
+        else
+        {
+            // this_mitr & ds_mitr refer to the same attribute, check the overide
+            // if any otherwise just apply the incomming attribute
+
+            AttributeStack& as = this_aitr->second;
+
+            if (!as.attributeVec.empty() && (as.attributeVec.back().second & StateAttribute::OVERRIDE) && !(ds_aitr->second.second & StateAttribute::PROTECTED))
+            {
+                // override is on, there just treat as a normal apply on modes.
+
+                if (as.changed)
+                {
+                    as.changed = false;
+                    const StateAttribute* new_attr = as.attributeVec.back().first;
+                    applyAttribute(new_attr,as);
+                }
+            }
+            else
+            {
+                // no override on or no previous entry, therefore consider incomming mode.
+                const StateAttribute* new_attr = ds_aitr->second.first.get();
+                if (applyAttribute(new_attr,as))
+                {
+                    as.changed = true;
+                }
+            }
+
+            ++this_aitr;
+            ++ds_aitr;
+        }
+    }
+
+    // iterator over the remaining state modes to apply any previous changes.
+    for(;
+        this_aitr!=attributeMap.end();
+        ++this_aitr)
+    {
+        // note attribute type = this_aitr->first
+        AttributeStack& as = this_aitr->second;
+        if (as.changed)
+        {
+            as.changed = false;
+            if (!as.attributeVec.empty())
+            {
+                const StateAttribute* new_attr = as.attributeVec.back().first;
+                applyAttribute(new_attr,as);
+            }
+            else
+            {
+                applyGlobalDefaultAttribute(as);
+            }
+        }
+    }        
+
+    // iterator over the remaining incomming modes to apply any new mode.
+    for(;
+        ds_aitr!=attributeList.end();
+        ++ds_aitr)
+    {
+        // ds_mitr->first is a new attribute, therefore 
+        // need to insert a new attribute entry for ds_aistr->first.
+        AttributeStack& as = attributeMap[ds_aitr->first];
+
+        const StateAttribute* new_attr = ds_aitr->second.first.get();
+        applyAttribute(new_attr,as);
+
+        // will need to update this attribute on next apply so set it to changed.
+        as.changed = true;
+    }
+
+}
+
+inline void State::applyModeMap(ModeMap& modeMap)
+{
+    for(ModeMap::iterator mitr=modeMap.begin();
+        mitr!=modeMap.end();
+        ++mitr)
+    {
+        // note GLMode = mitr->first
+        ModeStack& ms = mitr->second;
+        if (ms.changed)
+        {
+            ms.changed = false;
+            if (!ms.valueVec.empty())
+            {
+                bool new_value = ms.valueVec.back() & StateAttribute::ON;
+                applyMode(mitr->first,new_value,ms);
+            }
+            else
+            {
+                // assume default of disabled.
+                applyMode(mitr->first,ms.global_default_value,ms);
+            }
+            
+        }
+    }        
+}
+
+inline void State::applyAttributeMap(AttributeMap& attributeMap)
+{
+    for(AttributeMap::iterator aitr=attributeMap.begin();
+        aitr!=attributeMap.end();
+        ++aitr)
+    {
+        AttributeStack& as = aitr->second;
+        if (as.changed)
+        {
+            as.changed = false;
+            if (!as.attributeVec.empty())
+            {
+                const StateAttribute* new_attr = as.attributeVec.back().first;
+                applyAttribute(new_attr,as);
+            }
+            else
+            {
+                applyGlobalDefaultAttribute(as);
+            }
+            
+        }
+    }        
+}
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Timer
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Timer (revision 2878)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Timer (revision 2878)
@@ -0,0 +1,238 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_TIMER
+#define OSG_TIMER 1
+
+#include <osg/Export>
+
+
+#if defined(_MSC_VER)
+    namespace osg {
+        typedef __int64 Timer_t;
+    }
+#elif defined(__linux) || defined(__FreeBSD__) || defined(__CYGWIN__)|| defined(__MINGW32__)
+    namespace osg {
+        typedef unsigned long long Timer_t;
+    }
+#elif defined(__sgi)
+    namespace osg {
+        typedef unsigned long long Timer_t;
+    }
+#elif defined(unix)
+    namespace osg {
+        typedef unsigned long long Timer_t;
+    }
+#elif defined __APPLE__ || defined macintosh
+    namespace osg {
+        typedef double Timer_t;
+    }
+#else
+    #include <ctime>
+    namespace osg {
+        typedef std::clock_t Timer_t;
+    }
+#endif
+
+namespace osg {
+
+/** A high resolution, low latency time stamper.*/
+class SG_EXPORT Timer {
+
+    public:
+
+        Timer();
+        ~Timer() {}
+
+        static const Timer* instance();
+
+        inline Timer_t tick() const;
+        
+        inline double delta_s( Timer_t t1, Timer_t t2 ) const { return (double)(t2 - t1)*_secsPerTick; }
+        inline double delta_m( Timer_t t1, Timer_t t2 ) const { return delta_s(t1,t2)*1e3; }
+        inline double delta_u( Timer_t t1, Timer_t t2 ) const { return delta_s(t1,t2)*1e6; }
+        inline double delta_n( Timer_t t1, Timer_t t2 ) const { return delta_s(t1,t2)*1e9; }
+        
+        inline double getSecondsPerTick() const { return _secsPerTick; }
+
+    protected :
+
+        double                          _secsPerTick;
+        bool                            _useStandardClock;
+       
+#       ifdef __sgi
+        unsigned long*                  _clockAddress_32;
+        unsigned long long*             _clockAddress_64;
+        int                             _cycleCntrSize;
+    // for SGI machines with 32 bit clocks.
+        mutable unsigned long           _lastClockValue;
+        mutable unsigned long long      _rollOver;
+#       endif
+        
+};
+
+}
+
+#if defined(_MSC_VER)
+
+    #include <time.h>
+    #pragma optimize("",off)
+
+    namespace osg{
+
+        inline Timer_t Timer::tick( void ) const
+        {
+            if (_useStandardClock) return clock();
+
+            volatile Timer_t ts;
+            volatile unsigned int HighPart;
+            volatile unsigned int LowPart;
+            _asm
+            {
+                xor eax, eax        //  Used when QueryPerformanceCounter()
+                xor edx, edx        //  not supported or minimal overhead
+                _emit 0x0f          //  desired
+                _emit 0x31          //
+                mov HighPart,edx
+                mov LowPart,eax
+            }
+            //ts = LowPart | HighPart >> 32;
+            *((unsigned int*)&ts) = LowPart;
+            *((unsigned int*)&ts+1) = HighPart;
+            return ts;
+        }
+
+    }
+    #pragma optimize("",on)
+
+#elif defined(__MINGW32__)
+
+    #include <sys/time.h>
+
+    #define CLK(x)      __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x))
+    namespace osg{
+
+    inline Timer_t Timer::tick() const
+    {
+        if (_useStandardClock)
+            return clock();
+        else
+        {
+            Timer_t x;CLK(x);return x;
+        }
+    }
+
+    }
+
+#elif defined(__linux) || defined(__FreeBSD__) || defined(__CYGWIN__)
+
+    #include <sys/time.h>
+
+#ifdef __ia64
+    #define CLK(x)        ((x)=0)
+#else
+    #define CLK(x)      __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x))
+#endif
+
+    namespace osg{
+
+        inline Timer_t Timer::tick() const
+        {
+            if (_useStandardClock)
+            {
+                struct timeval tv;
+                gettimeofday(&tv, NULL);
+                return ((osg::Timer_t)tv.tv_sec)*1000000+(osg::Timer_t)tv.tv_usec;
+            }
+            else
+            {
+                Timer_t x;CLK(x);return x;
+            }
+        }
+
+    }
+  
+#elif defined(__sgi)
+
+    #include <sys/types.h>
+    #include <sys/time.h>
+
+    namespace osg{
+
+        inline  Timer_t Timer::tick() const
+        {
+            if (_useStandardClock)
+            {
+                struct timeval tv;
+                gettimeofday(&tv, NULL);
+                return ((osg::Timer_t)tv.tv_sec)*1000000+(osg::Timer_t)tv.tv_usec;
+            }
+            else
+            {
+                if ( _clockAddress_64 )
+                    return *_clockAddress_64;
+                else
+                {
+                    unsigned long clockValue = *_clockAddress_32;
+                    if( _lastClockValue > clockValue )
+                    {
+                        # ifdef __GNUC__
+                        _rollOver += 0x100000000LL;
+                        #else
+                        _rollOver += 0x100000000L;
+                        #endif
+                    }
+                    _lastClockValue = clockValue;
+                    return _rollOver + clockValue;
+                }
+            }
+        }
+    }
+    
+#elif defined (__APPLE__) || defined (macintosh)
+
+    #include <sys/time.h>
+
+    namespace osg{
+        inline Timer_t Timer::tick() const
+        {
+            // Always uses std::clock()
+            struct timeval tv;
+            gettimeofday(&tv, NULL);
+            return ((osg::Timer_t)tv.tv_sec)*1000000+(osg::Timer_t)tv.tv_usec;
+        }
+    }
+#elif defined(unix)
+
+    #include <sys/time.h>
+
+    namespace osg{
+        inline  Timer_t Timer::tick() const
+        {
+            struct timeval tv;
+            gettimeofday(&tv, NULL);
+            return ((osg::Timer_t)tv.tv_sec)*1000000+(osg::Timer_t)tv.tv_usec;
+        }
+    }
+
+#else
+
+    // no choice, always use std::clock()
+    namespace osg{
+
+        inline  Timer_t Timer::tick( void ) const { return std::clock(); }
+    }
+
+#endif
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ConvexPlanarOccluder
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ConvexPlanarOccluder (revision 3212)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ConvexPlanarOccluder (revision 3212)
@@ -0,0 +1,66 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_CONVEXPLANAROCCLUDER
+#define OSG_CONVEXPLANAROCCLUDER 1
+
+#include <osg/ConvexPlanarPolygon>
+#include <osg/Object>
+
+namespace osg {
+
+class OccluderVolume;
+
+/** A class for representing convex clipping volumes made up.
+  * When adding planes, their normals should point inwards (into the volume) */
+class SG_EXPORT ConvexPlanarOccluder : public Object
+{
+
+    public:
+
+        ConvexPlanarOccluder():Object() {}
+        ConvexPlanarOccluder(const ConvexPlanarOccluder& cpo,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            Object(cpo,copyop),
+            _occluder(cpo._occluder),
+            _holeList(cpo._holeList) {}
+        
+        META_Object(osg,ConvexPlanarOccluder);
+
+        void setOccluder(const ConvexPlanarPolygon& cpp) { _occluder = cpp; }
+        
+        ConvexPlanarPolygon& getOccluder() { return _occluder; }
+
+        const ConvexPlanarPolygon& getOccluder() const { return _occluder; }
+        
+        
+
+        typedef std::vector<ConvexPlanarPolygon> HoleList;
+
+        void addHole(const ConvexPlanarPolygon& cpp) { _holeList.push_back(cpp); }
+
+        HoleList& getHoleList() { return _holeList; }
+        
+        const HoleList& getHoleList() const { return _holeList; }
+
+    protected:
+
+        ~ConvexPlanarOccluder(); // {}
+
+        ConvexPlanarPolygon _occluder;
+        HoleList _holeList;
+
+};
+
+}	// end of namespace
+
+#endif 
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/PrimitiveSet
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/PrimitiveSet (revision 3093)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/PrimitiveSet (revision 3093)
@@ -0,0 +1,436 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_PRIMTIVESET
+#define OSG_PRIMTIVESET 1
+
+#include <osg/Drawable>
+
+namespace osg {
+
+#ifndef _MSC_VER
+
+typedef std::vector<GLsizei> VectorSizei;
+typedef std::vector<GLubyte> VectorUByte;
+typedef std::vector<GLushort> VectorUShort;
+typedef std::vector<GLuint> VectorUInt;
+
+#else // _MSC_VER
+
+// Following Vector wrapper classes are work arounds for MS linker problems with
+// multiply implemented methods.
+//
+// An alternative, sent in by Clay Fowler, is workaround in VS to prevent the problem:
+// the following changes have to be made to the project to make it compile, 
+// but NO changes are required to the actual source code:
+// In the osgUtil project, go to the project properties, select the Linker/Command Line property page, 
+// and add the following switch in the "Additional Options" field:
+// FORCE:MULTIPLE
+
+class VectorSizei: public std::vector<GLsizei> {
+	typedef std::vector<value_type> inherited;
+public:
+	VectorSizei(): inherited() {}
+	explicit VectorSizei(size_type n): inherited(n) {}
+	VectorSizei(const VectorSizei &copy): inherited(copy) {}
+	//VectorSizei(value_type *beg_, value_type *end_): inherited(beg_, end_) {}
+	template<class InputIterator>
+	VectorSizei(InputIterator beg_, InputIterator end_): inherited(beg_, end_) {}
+};
+
+class VectorUByte: public std::vector<GLubyte> {
+	typedef std::vector<value_type> inherited;
+public:
+	VectorUByte(): inherited() {}
+	explicit VectorUByte(size_type n): inherited(n) {}
+	VectorUByte(const VectorUByte &copy): inherited(copy) {}
+	//VectorUByte(value_type *beg_, value_type *end_): inherited(beg_, end_) {}
+	template<class InputIterator>
+	VectorUByte(InputIterator beg_, InputIterator end_): inherited(beg_, end_) {}
+};
+
+class VectorUShort: public std::vector<GLushort> {
+	typedef std::vector<value_type> inherited;
+public:
+	VectorUShort(): inherited() {}
+	explicit VectorUShort(size_type n): inherited(n) {}
+	VectorUShort(const VectorUShort &copy): inherited(copy) {}
+	//VectorUShort(value_type *beg_, value_type *end_): inherited(beg_, end_) {}
+	template<class InputIterator>
+	VectorUShort(InputIterator beg_, InputIterator end_): inherited(beg_, end_) {}
+};
+
+class VectorUInt: public std::vector<GLuint> {
+	typedef std::vector<value_type> inherited;
+public:
+	VectorUInt(): inherited() {}
+	explicit VectorUInt(size_type n): inherited(n) {}
+	VectorUInt(const VectorUInt &copy): inherited(copy) {}
+	//VectorUInt(value_type *beg_, value_type *end_): inherited(beg_, end_) {}
+	template<class InputIterator>
+	VectorUInt(InputIterator beg_, InputIterator end_): inherited(beg_, end_) {}
+};
+
+#endif
+
+
+class PrimitiveSet : public Object
+{
+    public:
+    
+        enum Type
+        {
+            PrimitiveType,
+            DrawArraysPrimitiveType,
+            DrawArrayLengthsPrimitiveType,
+            DrawElementsUBytePrimitiveType,
+            DrawElementsUShortPrimitiveType,
+            DrawElementsUIntPrimitiveType
+        };
+
+        enum Mode
+        {
+            POINTS = GL_POINTS,
+            LINES = GL_LINES,
+            LINE_STRIP = GL_LINE_STRIP,
+            LINE_LOOP = GL_LINE_LOOP,
+            TRIANGLES = GL_TRIANGLES,
+            TRIANGLE_STRIP = GL_TRIANGLE_STRIP,
+            TRIANGLE_FAN = GL_TRIANGLE_FAN,
+            QUADS = GL_QUADS,
+            QUAD_STRIP = GL_QUAD_STRIP,
+            POLYGON = GL_POLYGON
+        };
+
+        PrimitiveSet(Type primType=PrimitiveType,GLenum mode=0):
+            _primitiveType(primType),
+            _mode(mode) {}
+    
+        PrimitiveSet(const PrimitiveSet& prim,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            Object(prim,copyop),
+            _primitiveType(prim._primitiveType),
+            _mode(prim._mode) {}
+
+        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const PrimitiveSet*>(obj)!=NULL; }
+        virtual const char* libraryName() const { return "osg"; }
+        virtual const char* className() const { return "PrimitiveSet"; }
+        
+        Type getType() const { return _primitiveType; }
+        
+        void setMode(GLenum mode) { _mode = mode; }
+        GLenum getMode() const { return _mode; }
+
+        virtual void draw(State& state, bool useVertexBufferObjects) const = 0;
+        
+        virtual void accept(Drawable::PrimitiveFunctor& functor) const = 0;
+        virtual void accept(Drawable::PrimitiveIndexFunctor& functor) const = 0;
+        
+        virtual unsigned int index(unsigned int pos) const = 0;
+        virtual unsigned int getNumIndices() const = 0;
+        virtual void offsetIndices(int offset) = 0;
+
+        virtual unsigned int getNumPrimitives() const 
+        {
+            switch(_mode)
+            {
+                case(POINTS): return getNumIndices();
+                case(LINES): return getNumIndices()/2;
+                case(TRIANGLES): return getNumIndices()/3;
+                case(QUADS): return getNumIndices()/4;
+                case(LINE_STRIP):
+                case(LINE_LOOP):
+                case(TRIANGLE_STRIP):
+                case(TRIANGLE_FAN):
+                case(QUAD_STRIP):
+                case(POLYGON): return 1;
+            }
+            return 0;
+        }
+
+    protected:
+
+        virtual ~PrimitiveSet() {}
+
+        Type    _primitiveType;
+        GLenum  _mode;
+};
+
+class SG_EXPORT DrawArrays : public PrimitiveSet
+{
+    public:
+
+        DrawArrays(GLenum mode=0):
+            PrimitiveSet(DrawArraysPrimitiveType,mode),
+            _first(0),
+            _count(0) {}
+    
+        DrawArrays(GLenum mode, GLint first, GLsizei count):
+            PrimitiveSet(DrawArraysPrimitiveType,mode),
+            _first(first),
+            _count(count) {}
+
+        DrawArrays(const DrawArrays& da,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            PrimitiveSet(da,copyop),
+            _first(da._first),
+            _count(da._count) {}
+
+        virtual Object* cloneType() const { return new DrawArrays(); }
+        virtual Object* clone(const CopyOp& copyop) const { return new DrawArrays(*this,copyop); }        
+        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawArrays*>(obj)!=NULL; }
+        virtual const char* libraryName() const { return "osg"; }
+        virtual const char* className() const { return "DrawArrays"; }
+        
+
+        void set(GLenum mode,GLint first, GLsizei count)
+        {
+            _mode = mode;
+            _first = first;
+            _count = count;
+        }
+
+        void setFirst(GLint first) { _first = first; }
+        GLint getFirst() const { return _first; }
+        
+        void setCount(GLsizei count) { _count = count; }
+        GLsizei getCount() const { return _count; }
+
+        virtual void draw(State& state, bool useVertexBufferObjects) const;
+        
+        virtual void accept(Drawable::PrimitiveFunctor& functor) const;
+        virtual void accept(Drawable::PrimitiveIndexFunctor& functor) const;
+        
+        virtual unsigned int getNumIndices() const { return _count; }
+        virtual unsigned int index(unsigned int pos) const { return _first+pos; }
+        virtual void offsetIndices(int offset) { _first += offset; }
+
+    protected:
+
+        virtual ~DrawArrays() {}
+
+        GLint   _first;
+        GLsizei _count;
+};
+
+class SG_EXPORT DrawArrayLengths : public PrimitiveSet, public VectorSizei
+{
+    public:
+
+        DrawArrayLengths(GLenum mode=0):
+            PrimitiveSet(DrawArrayLengthsPrimitiveType,mode),
+            _first(0) {}
+    
+        DrawArrayLengths(const DrawArrayLengths& dal,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            PrimitiveSet(dal,copyop),
+            VectorSizei(dal),
+            _first(dal._first) {}
+
+        DrawArrayLengths(GLenum mode, GLint first, unsigned int no, GLsizei* ptr) : 
+            PrimitiveSet(DrawArrayLengthsPrimitiveType,mode),
+            VectorSizei(ptr,ptr+no),
+            _first(first) {}
+
+        DrawArrayLengths(GLenum mode,GLint first, unsigned int no) : 
+            PrimitiveSet(DrawArrayLengthsPrimitiveType,mode),
+            VectorSizei(no),
+            _first(first) {}
+
+        DrawArrayLengths(GLenum mode,GLint first) : 
+            PrimitiveSet(DrawArrayLengthsPrimitiveType,mode),
+            VectorSizei(),
+            _first(first) {}
+
+
+        virtual Object* cloneType() const { return new DrawArrayLengths(); }
+        virtual Object* clone(const CopyOp& copyop) const { return new DrawArrayLengths(*this,copyop); }        
+        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawArrayLengths*>(obj)!=NULL; }
+        virtual const char* libraryName() const { return "osg"; }
+        virtual const char* className() const { return "DrawArrayLengths"; }
+        
+
+        void setFirst(GLint first) { _first = first; }
+        GLint getFirst() const { return _first; }
+        
+        virtual void draw(State& state, bool useVertexBufferObjects) const;
+        
+        virtual void accept(Drawable::PrimitiveFunctor& functor) const;
+        virtual void accept(Drawable::PrimitiveIndexFunctor& functor) const;
+        
+        virtual unsigned int getNumIndices() const;
+        virtual unsigned int index(unsigned int pos) const { return _first+pos; }
+        virtual void offsetIndices(int offset) { _first += offset; }
+
+        virtual unsigned int getNumPrimitives() const 
+        {
+            switch(_mode)
+            {
+                case(POINTS): return getNumIndices();
+                case(LINES): return getNumIndices()/2;
+                case(TRIANGLES): return getNumIndices()/3;
+                case(QUADS): return getNumIndices()/4;
+                case(LINE_STRIP):
+                case(LINE_LOOP):
+                case(TRIANGLE_STRIP):
+                case(TRIANGLE_FAN):
+                case(QUAD_STRIP):
+                case(POLYGON): return size();
+            }
+            return 0;
+        }
+
+    protected:
+
+        virtual ~DrawArrayLengths() {}
+
+        GLint   _first;
+};
+
+class SG_EXPORT DrawElementsUByte : public PrimitiveSet, public VectorUByte
+{
+    public:
+
+        DrawElementsUByte(GLenum mode=0):
+            PrimitiveSet(DrawElementsUBytePrimitiveType,mode) {}
+    
+        DrawElementsUByte(const DrawElementsUByte& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            PrimitiveSet(array,copyop),
+            VectorUByte(array) {}
+
+        DrawElementsUByte(GLenum mode,unsigned int no,GLubyte* ptr) : 
+            PrimitiveSet(DrawElementsUBytePrimitiveType,mode),
+            VectorUByte(ptr,ptr+no) {}
+
+        DrawElementsUByte(GLenum mode,unsigned int no) : 
+            PrimitiveSet(DrawElementsUBytePrimitiveType,mode),
+            VectorUByte(no) {}
+
+        virtual Object* cloneType() const { return new DrawElementsUByte(); }
+        virtual Object* clone(const CopyOp& copyop) const { return new DrawElementsUByte(*this,copyop); }        
+        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawElementsUByte*>(obj)!=NULL; }
+        virtual const char* libraryName() const { return "osg"; }
+        virtual const char* className() const { return "DrawElementsUByte"; }
+
+        virtual void draw(State& state, bool useVertexBufferObjects) const ;
+        
+        virtual void accept(Drawable::PrimitiveFunctor& functor) const;
+        virtual void accept(Drawable::PrimitiveIndexFunctor& functor) const;
+
+        virtual unsigned int getNumIndices() const { return size(); }
+        virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
+        virtual void offsetIndices(int offset);
+
+    protected:
+
+        typedef osg::buffered_value<GLuint> GLObjectList;
+        mutable GLObjectList    _vboList;
+
+        virtual ~DrawElementsUByte() {}
+};
+
+
+class SG_EXPORT DrawElementsUShort : public PrimitiveSet, public VectorUShort
+{
+    public:
+
+        DrawElementsUShort(GLenum mode=0):
+            PrimitiveSet(DrawElementsUShortPrimitiveType,mode) {}
+    
+        DrawElementsUShort(const DrawElementsUShort& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            PrimitiveSet(array,copyop),
+            VectorUShort(array) {}
+
+        DrawElementsUShort(GLenum mode,unsigned int no,GLushort* ptr) : 
+            PrimitiveSet(DrawElementsUShortPrimitiveType,mode),
+            VectorUShort(ptr,ptr+no) {}
+
+        DrawElementsUShort(GLenum mode,unsigned int no) : 
+            PrimitiveSet(DrawElementsUShortPrimitiveType,mode),
+            VectorUShort(no) {}
+
+        template <class InputIterator>
+        DrawElementsUShort(GLenum mode, InputIterator first,InputIterator last) : 
+            PrimitiveSet(DrawElementsUShortPrimitiveType,mode),
+            VectorUShort(first,last) {}
+
+        virtual Object* cloneType() const { return new DrawElementsUShort(); }
+        virtual Object* clone(const CopyOp& copyop) const { return new DrawElementsUShort(*this,copyop); }        
+        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawElementsUShort*>(obj)!=NULL; }
+        virtual const char* libraryName() const { return "osg"; }
+        virtual const char* className() const { return "DrawElementsUShort"; }
+
+        virtual void draw(State& state, bool useVertexBufferObjects) const;
+        
+        virtual void accept(Drawable::PrimitiveFunctor& functor) const;
+        virtual void accept(Drawable::PrimitiveIndexFunctor& functor) const;
+
+        virtual unsigned int getNumIndices() const { return size(); }
+        virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
+        virtual void offsetIndices(int offset);
+
+    protected:
+
+        typedef osg::buffered_value<GLuint> GLObjectList;
+        mutable GLObjectList    _vboList;
+
+        virtual ~DrawElementsUShort() {}
+};
+
+class SG_EXPORT DrawElementsUInt : public PrimitiveSet, public VectorUInt
+{
+    public:
+
+        DrawElementsUInt(GLenum mode=0):
+            PrimitiveSet(DrawElementsUIntPrimitiveType,mode) {}
+    
+        DrawElementsUInt(const DrawElementsUInt& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            PrimitiveSet(array,copyop),
+            VectorUInt(array) {}
+
+        DrawElementsUInt(GLenum mode,unsigned int no,GLuint* ptr) : 
+            PrimitiveSet(DrawElementsUIntPrimitiveType,mode),
+            VectorUInt(ptr,ptr+no) {}
+
+        DrawElementsUInt(GLenum mode,unsigned int no) : 
+            PrimitiveSet(DrawElementsUIntPrimitiveType,mode),
+            VectorUInt(no) {}
+
+        template <class InputIterator>
+        DrawElementsUInt(GLenum mode, InputIterator first,InputIterator last) : 
+            PrimitiveSet(DrawElementsUIntPrimitiveType,mode),
+            VectorUInt(first,last) {}
+
+        virtual Object* cloneType() const { return new DrawElementsUInt(); }
+        virtual Object* clone(const CopyOp& copyop) const { return new DrawElementsUInt(*this,copyop); }        
+        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawElementsUInt*>(obj)!=NULL; }
+        virtual const char* libraryName() const { return "osg"; }
+        virtual const char* className() const { return "DrawElementsUInt"; }
+
+        virtual void draw(State& state, bool useVertexBufferObjects) const;
+        
+        virtual void accept(Drawable::PrimitiveFunctor& functor) const;
+        virtual void accept(Drawable::PrimitiveIndexFunctor& functor) const;
+
+        virtual unsigned int getNumIndices() const { return size(); }
+        virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
+        virtual void offsetIndices(int offset);
+
+    protected:
+
+        typedef osg::buffered_value<GLuint> GLObjectList;
+        mutable GLObjectList    _vboList;
+
+        virtual ~DrawElementsUInt() {}
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Version
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Version (revision 1712)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/Version (revision 1712)
@@ -0,0 +1,46 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_VERSION_
+#define OSG_VERSION_ 1
+
+#include <osg/Export>
+
+extern "C" {
+
+/**
+ * osgGetVersion() returns the library version number.
+ * Numbering convention : OpenSceneGraph-0.8-31 will return 0.8.31 from osgGetVersion.
+ *
+ * This C function can be also used to check for the existence of the OpenSceneGraph
+ * library using autoconf and its m4 macro AC_CHECK_LIB.
+ *
+ * Here is the code to add to your configure.in:
+ \verbatim
+ #
+ # Check for the OpenSceneGraph (OSG) library
+ #
+ AC_CHECK_LIB(osg, osgGetVersion, ,
+    [AC_MSG_ERROR(OpenSceneGraph library not found. See http://www.openscenegraph.org)],)
+ \endverbatim
+*/
+extern SG_EXPORT const char* osgGetVersion();
+
+/**
+ * osgGetLibraryName() returns the library name in human friendly form.
+*/
+extern SG_EXPORT const char* osgGetLibraryName();
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/LightModel
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/LightModel (revision 1529)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/LightModel (revision 1529)
@@ -0,0 +1,95 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_LIGHTMODEL
+#define OSG_LIGHTMODEL 1
+
+#include <osg/StateAttribute>
+#include <osg/Vec4>
+
+namespace osg {
+
+class SG_EXPORT LightModel : public StateAttribute
+{
+    public :
+
+        LightModel();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        LightModel(const LightModel& lw,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+          StateAttribute(lw,copyop),
+          _ambient(lw._ambient),
+          _colorControl(lw._colorControl),
+          _localViewer(lw._localViewer),
+          _twoSided(lw._twoSided) {}
+
+
+        META_StateAttribute(osg, LightModel, LIGHTMODEL);
+
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const StateAttribute& sa) const
+        {
+            // check the types are equal and then create the rhs variable
+            // used by the COMPARE_StateAttribute_Paramter macro's below.
+            COMPARE_StateAttribute_Types(LightModel,sa)
+
+            // compare each paramter in turn against the rhs.
+            COMPARE_StateAttribute_Parameter(_ambient)
+            COMPARE_StateAttribute_Parameter(_colorControl)
+            COMPARE_StateAttribute_Parameter(_localViewer)
+            COMPARE_StateAttribute_Parameter(_twoSided)
+
+            return 0; // passed all the above comparison macro's, must be equal.
+        }
+
+
+        void setAmbientIntensity(const osg::Vec4& ambient) { _ambient = ambient; }
+        const osg::Vec4& getAmbientIntensity() const { return _ambient; }
+
+
+        enum ColorControl
+        {
+            SEPARATE_SPECULAR_COLOR,
+            SINGLE_COLOR
+        };
+        
+        void setColorControl(ColorControl cc) { _colorControl = cc; }
+        inline ColorControl getColorControl() const { return _colorControl; }
+
+
+        void setLocalViewer(bool localViewer) { _localViewer=localViewer; }
+        inline bool getLocalViewer() const { return _localViewer; }
+
+
+        void setTwoSided(bool twoSided) { _twoSided = twoSided; }
+        inline bool getTwoSided() const { return _twoSided; }
+
+
+
+        virtual void apply(State& state) const;
+
+
+    protected :
+
+        virtual ~LightModel();
+
+        osg::Vec4 _ambient;
+        ColorControl _colorControl;
+        bool _localViewer;
+        bool _twoSided;
+
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/FragmentProgram
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/FragmentProgram (revision 3159)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/FragmentProgram (revision 3159)
@@ -0,0 +1,282 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_FRAGMENTPROGRAM
+#define OSG_FRAGMENTPROGRAM 1
+
+#include <osg/StateAttribute>
+#include <osg/Vec4>
+#include <osg/Matrix>
+#include <osg/buffered_value>
+
+#include <map>
+#include <string>
+
+// if not defined by gl.h use the definition found in:
+// http://oss.sgi.com/projects/ogl-sample/registry/ARB/fragment_program.txt
+#ifndef GL_ARB_fragment_program
+#define GL_FRAGMENT_PROGRAM_ARB                            0x8804
+#define GL_PROGRAM_FORMAT_ASCII_ARB                        0x8875
+#define GL_PROGRAM_LENGTH_ARB                              0x8627
+#define GL_PROGRAM_FORMAT_ARB                              0x8876
+#define GL_PROGRAM_BINDING_ARB                             0x8677
+#define GL_PROGRAM_INSTRUCTIONS_ARB                        0x88A0
+#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB                    0x88A1
+#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB                 0x88A2
+#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB             0x88A3
+#define GL_PROGRAM_TEMPORARIES_ARB                         0x88A4
+#define GL_MAX_PROGRAM_TEMPORARIES_ARB                     0x88A5
+#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB                  0x88A6
+#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB              0x88A7
+#define GL_PROGRAM_PARAMETERS_ARB                          0x88A8
+#define GL_MAX_PROGRAM_PARAMETERS_ARB                      0x88A9
+#define GL_PROGRAM_NATIVE_PARAMETERS_ARB                   0x88AA
+#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB               0x88AB
+#define GL_PROGRAM_ATTRIBS_ARB                             0x88AC
+#define GL_MAX_PROGRAM_ATTRIBS_ARB                         0x88AD
+#define GL_PROGRAM_NATIVE_ATTRIBS_ARB                      0x88AE
+#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB                  0x88AF
+#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB                0x88B4
+#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB                  0x88B5
+#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB                 0x88B6
+#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB                    0x8805
+#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB                    0x8806
+#define GL_PROGRAM_TEX_INDIRECTIONS_ARB                    0x8807
+#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB             0x8808
+#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB             0x8809
+#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB             0x880A
+#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB                0x880B
+#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB                0x880C
+#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB                0x880D
+#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB         0x880E
+#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB         0x880F
+#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB         0x8810
+#define GL_PROGRAM_STRING_ARB                              0x8628
+#define GL_PROGRAM_ERROR_POSITION_ARB                      0x864B
+#define GL_CURRENT_MATRIX_ARB                              0x8641
+#define GL_TRANSPOSE_CURRENT_MATRIX_ARB                    0x88B7
+#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB                  0x8640
+#define GL_MAX_PROGRAM_MATRICES_ARB                        0x862F
+#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB              0x862E
+#define GL_MAX_TEXTURE_COORDS_ARB                          0x8871
+#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB                     0x8872
+#define GL_PROGRAM_ERROR_STRING_ARB                        0x8874
+#define GL_MATRIX0_ARB                                     0x88C0
+#define GL_MATRIX1_ARB                                     0x88C1
+#define GL_MATRIX2_ARB                                     0x88C2
+#define GL_MATRIX3_ARB                                     0x88C3
+#define GL_MATRIX4_ARB                                     0x88C4
+#define GL_MATRIX5_ARB                                     0x88C5
+#define GL_MATRIX6_ARB                                     0x88C6
+#define GL_MATRIX7_ARB                                     0x88C7
+#define GL_MATRIX8_ARB                                     0x88C8
+#define GL_MATRIX9_ARB                                     0x88C9
+#define GL_MATRIX10_ARB                                    0x88CA
+#define GL_MATRIX11_ARB                                    0x88CB
+#define GL_MATRIX12_ARB                                    0x88CC
+#define GL_MATRIX13_ARB                                    0x88CD
+#define GL_MATRIX14_ARB                                    0x88CE
+#define GL_MATRIX15_ARB                                    0x88CF
+#define GL_MATRIX16_ARB                                    0x88D0
+#define GL_MATRIX17_ARB                                    0x88D1
+#define GL_MATRIX18_ARB                                    0x88D2
+#define GL_MATRIX19_ARB                                    0x88D3
+#define GL_MATRIX20_ARB                                    0x88D4
+#define GL_MATRIX21_ARB                                    0x88D5
+#define GL_MATRIX22_ARB                                    0x88D6
+#define GL_MATRIX23_ARB                                    0x88D7
+#define GL_MATRIX24_ARB                                    0x88D8
+#define GL_MATRIX25_ARB                                    0x88D9
+#define GL_MATRIX26_ARB                                    0x88DA
+#define GL_MATRIX27_ARB                                    0x88DB
+#define GL_MATRIX28_ARB                                    0x88DC
+#define GL_MATRIX29_ARB                                    0x88DD
+#define GL_MATRIX30_ARB                                    0x88DE
+#define GL_MATRIX31_ARB                                    0x88DF
+
+#endif
+
+
+namespace osg {
+
+
+
+/** FragmentProgram - encapsulates the OpenGL ARB fragment program state.*/
+class SG_EXPORT FragmentProgram : public StateAttribute
+{
+    public:
+
+        FragmentProgram();
+
+        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
+        FragmentProgram(const FragmentProgram& vp,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+        META_StateAttribute(osg, FragmentProgram, FRAGMENTPROGRAM);
+
+        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
+        virtual int compare(const osg::StateAttribute& sa) const
+        {
+            // check the types are equal and then create the rhs variable
+            // used by the COMPARE_StateAttribute_Paramter macro's below.
+            COMPARE_StateAttribute_Types(FragmentProgram,sa)
+
+            // compare each paramter in turn against the rhs.
+            COMPARE_StateAttribute_Parameter(_fragmentProgram)
+
+            return 0; // passed all the above comparison macro's, must be equal.
+        }
+
+        virtual bool getModeUsage(ModeUsage& usage) const
+        {
+            usage.usesMode(GL_FRAGMENT_PROGRAM_ARB);
+            return true;
+        }
+
+        // data access methods.
+
+        /** Get the handle to the fragment program id for the current context.*/
+        inline GLuint& getFragmentProgramID(unsigned int contextID) const
+        {
+            return _fragmentProgramIDList[contextID];
+        }
+
+        /** Set the fragment program using C++ style string.*/
+        inline void setFragmentProgram( const std::string& program )
+        {
+            _fragmentProgram = program;
+            dirtyFragmentProgramObject();
+        }
+        
+        /** Set the fragment program using a C style string.*/
+        inline void setFragmentProgram( const char* program ) 
+        { 
+            _fragmentProgram = program; 
+            dirtyFragmentProgramObject();
+        }
+        /** Get the fragment program.*/
+        inline const std::string& getFragmentProgram() const { return _fragmentProgram; }
+
+        /** Set Program Parameters */
+        inline void setProgramLocalParameter(const GLuint index, const Vec4& p)
+        {
+            _programLocalParameters[index] = p;
+        }
+
+        typedef std::map<GLuint,Vec4> LocalParamList;
+
+        /** Get list of Program Parameters */
+        inline LocalParamList& getLocalParamList() { return _programLocalParameters; }
+
+		  /** Get const list of Program Parameters */
+        inline const LocalParamList& getLocalParamList() const { return _programLocalParameters; }
+
+        /** Matrix */
+        inline void setMatrix(const GLenum mode, const Matrix& matrix)
+        {
+            _matrixList[mode] = matrix;
+        }
+
+        /** Force a recompile on next apply() of associated OpenGL vertex program objects.*/
+        void dirtyFragmentProgramObject();        
+
+        /** use deleteFragmentProgramObject instead of glDeletePrograms to allow
+          * OpenGL Fragment Program objects to cached until they can be deleted
+          * by the OpenGL context in which they were created, specified
+          * by contextID.*/
+        static void deleteFragmentProgramObject(unsigned int contextID,GLuint handle);
+
+        /** flush all the cached fragment programs which need to be deleted
+          * in the OpenGL context related to contextID.*/
+        static void flushDeletedFragmentProgramObjects(unsigned int contextID,double currentTime, double& availableTime);
+
+        virtual void apply(State& state) const;
+
+        virtual void compileGLObjects(State& state) const { apply(state); }
+
+        /** release an OpenGL objects in specified graphics context if State
+            object is passed, otherwise release OpenGL objexts for all graphics context if
+            State object pointer NULL.*/
+        virtual void releaseGLObjects(State* state=0) const;
+
+        /** Extensions class which encapsulates the querring of extensions and
+          * associated function pointers, and provide convinience wrappers to 
+          * check for the extensions or use the associated functions.*/        
+        class SG_EXPORT Extensions : public osg::Referenced
+        {
+            public:
+                Extensions();
+
+                Extensions(const Extensions& rhs);
+                
+                void lowestCommonDenominator(const Extensions& rhs);
+                
+                void setupGLExtenions();
+
+                void setFragmentProgramSupported(bool flag) { _isFragmentProgramSupported=flag; }
+                bool isFragmentProgramSupported() const { return _isFragmentProgramSupported; }
+
+                void glBindProgram(GLenum target, GLuint id) const;
+                void glGenPrograms(GLsizei n, GLuint *programs) const;
+                void glDeletePrograms(GLsizei n, GLuint *programs) const;
+                void glProgramString(GLenum target, GLenum format, GLsizei len, const void *string) const; 
+                void glProgramLocalParameter4fv(GLenum target, GLuint index, const GLfloat *params) const;
+
+            protected:
+
+                ~Extensions() {}
+                
+                bool _isFragmentProgramSupported;
+                
+                void* _glBindProgram;
+                void* _glGenPrograms;
+                void *_glDeletePrograms;
+                void* _glProgramString;
+                void* _glProgramLocalParameter4fv;
+         };
+        
+        /** Function to call to get the extension of a specified context.
+          * If the Exentsion object for that context has not yet been created then 
+          * and the 'createIfNotInitalized' flag been set to false then returns NULL.
+          * If 'createIfNotInitalized' is true then the Extensions object is 
+          * automatically created.  However, in this case the extension object 
+          * only be created with the graphics context associated with ContextID..*/
+        static Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized);
+
+        /** setExtensions allows users to override the extensions across graphics contexts.
+          * typically used when you have different extensions supported across graphics pipes
+          * but need to ensure that they all use the same low common denominator extensions.*/
+        static void setExtensions(unsigned int contextID,Extensions* extensions);
+
+
+    protected:
+
+
+        virtual ~FragmentProgram();
+
+        typedef buffered_value<GLuint> FragmentProgramIDList;
+        mutable FragmentProgramIDList _fragmentProgramIDList;
+
+        std::string     _fragmentProgram;
+
+        LocalParamList  _programLocalParameters;
+
+        typedef std::map<GLenum,Matrix> MatrixList;
+        MatrixList  _matrixList;
+};
+
+
+
+}
+
+#endif
+
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ClearNode
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ClearNode (revision 1529)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ClearNode (revision 1529)
@@ -0,0 +1,68 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_CLEARNODE
+#define OSG_CLEARNODE 1
+
+#include <osg/Group>
+#include <osg/Vec4>
+
+namespace osg {
+
+/** ClearNode is a Group node which controls the clearing of the color and depth
+  * buffers at the start of each frame.
+  * The earth sky by default is empty and simply holds the clear color of
+  * the background. However, if the uses wants to add their own clearing of
+  * the color and depth buffers then the children can be added, and the
+  * background clear turned off. The ClearNode by default has StateSet attached
+  * to it which sets the default ClearNode bin number to -1, so that all drawables
+  * below it are placed in a separate bin from the rest of the scene graph, and
+  * are rendered prior to standard opaque and transparent drawables.
+*/
+class SG_EXPORT ClearNode : public Group
+{
+    public :
+        
+        ClearNode();
+
+        ClearNode(const ClearNode& es, const CopyOp& copyop=CopyOp::SHALLOW_COPY):
+            Group(es,copyop),
+            _requiresClear(es._requiresClear),
+            _clearColor(es._clearColor) {}  
+
+
+        META_Node(osg, ClearNode);
+
+	/** Sets the flag which control whether a glClear is required at the beginning of each frame. */
+        inline void setRequiresClear(bool requiresClear) { _requiresClear = requiresClear; }
+
+	/** Gets the flag which control whether a glClear is required at the beginning of each frame. */
+        inline bool getRequiresClear() const { return _requiresClear; }
+
+	/** Sets the clear color. */
+        inline void setClearColor(const Vec4& color) { _clearColor = color; }
+
+	/** Returns the clear color. */
+        inline const Vec4& getClearColor() const { return _clearColor; }
+
+    protected :
+    
+        virtual ~ClearNode() {}
+        
+        bool _requiresClear;
+        Vec4 _clearColor;  
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ClipNode
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ClipNode (revision 3065)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/ClipNode (revision 3065)
@@ -0,0 +1,87 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_CLIPNODE
+#define OSG_CLIPNODE 1
+
+#include <osg/Group>
+#include <osg/ClipPlane>
+
+namespace osg {
+
+/** Node for defining the position of ClipPlanes in the scene.*/
+class SG_EXPORT ClipNode : public Group
+{
+
+    public:
+
+        typedef std::vector<ref_ptr<ClipPlane> > ClipPlaneList;
+
+
+        ClipNode();
+
+        ClipNode(const ClipNode& es, const CopyOp& copyop=CopyOp::SHALLOW_COPY);
+
+        META_Node(osg, ClipNode);
+	
+	/** Create a 6 clip planes to create a clip box.*/
+	void createClipBox(const BoundingBox& bb,unsigned int clipPlaneNumberBase=0);
+
+
+        /** Add a ClipPlane to a ClipNode. Return true if plane is added, 
+          * return false if plane already exists in ClipNode, or clipplane is false.*/
+        bool addClipPlane(ClipPlane* clipplane);
+
+        /** Remove ClipPlane from a ClipNode. Return true if plane is removed, 
+          * return false if plane does not exists in ClipNode.*/
+        bool removeClipPlane(ClipPlane* clipplane);
+
+        /** Remove ClipPlane, at specified index, from a ClipNode. Return true if plane is removed, 
+          * return false if plane does not exists in ClipNode.*/
+        bool removeClipPlane(unsigned int pos);
+
+        /** return the number of ClipPlanes.*/
+        inline unsigned  int getNumClipPlanes() const { return _planes.size(); }
+
+
+        /** Get ClipPlane at specificed index position.*/
+        inline ClipPlane* getClipPlane(unsigned int pos) { return _planes[pos].get(); }
+
+        /** Get const ClipPlane at specificed index position.*/
+        inline const ClipPlane* getClipPlane(unsigned int pos) const { return _planes[pos].get(); }
+
+        /** Get the ClipPlaneList.*/
+        inline ClipPlaneList& getClipPlaneList() { return _planes; }
+
+        /** Get the const ClipPlaneList.*/
+        inline const ClipPlaneList& getClipPlaneList() const { return _planes; }
+
+        /** Set the GLModes on StateSet associated with the ClipPlanes.*/
+        void setStateSetModes(StateSet&,StateAttribute::GLModeValue) const;
+
+        /** Set up the local StateSet */
+        void setLocalStateSetModes(StateAttribute::GLModeValue=StateAttribute::ON);
+
+    protected:
+
+        virtual ~ClipNode();
+
+        virtual bool computeBound() const;
+
+        StateAttribute::GLModeValue _value;
+        ClipPlaneList _planes;
+};
+
+}
+
+#endif
Index: /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/UnitTestFramework
===================================================================
--- /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/UnitTestFramework (revision 2786)
+++ /OpenSceneGraph/tags/OpenSceneGraph_0_9_7_release_revision_2/include/osg/UnitTestFramework (revision 2786)
@@ -0,0 +1,586 @@
+/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
+ *
+ * This library is open source and may be redistributed and/or modified under  
+ * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
+ * (at your option) any later version.  The full license is in LICENSE file
+ * included with this distribution, and on the openscenegraph.org website.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * OpenSceneGraph Public License for more details.
+*/
+
+#ifndef OSG_UNITTESTFRAMEWORK
+#define OSG_UNITTESTFRAMEWORK 1
+
+#include <osg/Export>
+#include <osg/Referenced>
+#include <osg/ref_ptr>
+#include <osg/Timer>
+#include <osg/Notify>
+
+#include <string>
+#include <vector>
+#include <list>
+#include <fstream>
+
+namespace osgUtx{
+
+class TestVisitor;
+
+/**
+Test, an abstract base class, is the Composite pattern's \em component
+class for our graph of test cases, and defines the basic interface
+for all Test components. It is a referent, and may be pointed
+to by an osg::ref_ptr.
+*/
+class SG_EXPORT Test: public osg::Referenced
+{
+    public:
+
+    typedef TestVisitor Visitor;    // Test is redundant
+
+    Test( const std::string& sName ) : _name( sName ) {}
+
+    const std::string& name() const { return _name; }
+
+    virtual bool accept( Visitor& ) = 0;
+
+    protected:
+
+        virtual ~Test() {}
+
+    std::string _name;
+};
+
+
+/**
+TestContext wraps up information which is passed to tests as they are run,
+and may contain test-specific information or 'global' test objects, such
+as an output stream for verbose output during the running of tests.
+
+\todo Improve the output stream code by providing a filtering stream.
+*/
+class SG_EXPORT TestContext
+{
+public:
+
+    TestContext();
+
+    bool shouldStop()    { return false; }
+    bool isVerbose()    { return true; }
+
+    enum TraceLevel{
+        Off,        ///< All tracing turned off
+        Results,    ///< Output results only
+        Full        ///< Full test diagnostic output
+    };
+
+    void setTraceLevel(TraceLevel tl);
+    TraceLevel getTraceLevel() const;
+
+    std::ostream& tout(TraceLevel tl=Full) const;
+
+private:
+
+    TestContext(const TestContext&);
+    TestContext operator=(const TestContext&);
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+    class SG_EXPORT TraceStream{
+
+    public:
+        TraceStream(std::ostream& o=osg::notify(osg::NOTICE), TraceLevel tl=Results);
+        ~TraceStream();
+
+        void setTraceLevel(TraceLevel tl);
+        TraceLevel getTraceLevel() const;
+
+        std::ostream& stream(TraceLevel tl);
+
+    private:
+
+        TraceLevel    _traceLevel;
+        std::ostream*    _outputStreamPtr;
+        std::ofstream    _nullStream;
+    };
+
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+    mutable TraceStream _tout;
+
+};
+
+
+class TestSuite;
+class TestCase;
+
+/**
+Visits while maintaining the current hierarchical context. Also allows
+the traversal to be short-cicuited at any point during the visitation.
+*/
+class TestVisitor
+{
+    public:
+
+    //..Should we enter this node and its children?
+    virtual bool visitEnter( TestSuite* ) { return true; }
+
+    //..Returns true to continue to next Leaf
+    virtual bool visit( TestCase* ) = 0;
+
+    //..Returns true to continue to next Composite
+    virtual bool visitLeave( TestSuite* ) { return true; }
+        
+    protected:
+
+    TestVisitor() {}
+    TestVisitor( const TestVisitor& ) {}
+    virtual ~TestVisitor()    {}
+};
+
+/**
+TestCase, is the supplies the interface for a Composite pattern's
+\em leaf class, though it is not a leaf in itself.
+*/
+class TestCase : public Test
+{
+    public:
+
+    typedef TestContext Context; // Test in TestContext? is redundant
+
+    TestCase( const std::string& sName ) : Test( sName ) {}
+
+    virtual bool accept( Visitor& v ) { return v.visit( this ); }
+
+    virtual void run( const Context& ) = 0;  // Subclass OSGUTX_EXPORT Responsibility
+
+    protected:
+
+        virtual ~TestCase() {}
+};
+
+/**
+Base class catchable for the exception's which may be thrown to
+indicate problems during the run of a TestCase.
+*/
+class TestX
+{
+    public:
+
+    TestX(const std::string& s):_what(s)    {}
+    virtual ~TestX() {}
+
+    const std::string& what() const { return _what; }
+
+    private:
+    std::string    _what;
+};
+
+/**
+A TestFailureX indicates a failure in the tested component.
+*/
+class TestFailureX: public TestX
+{
+    public:
+    TestFailureX(const std::string& s):TestX(s)    {}
+};
+
+/**
+A TestErrorX indicates an error while testing a component,
+which prevents the test from being run; it does not indicate
+a problem with the component, but rather a problem during the
+run which prevents the component from being tested.
+*/
+class TestErrorX: public TestX
+{
+    public:
+    TestErrorX(const std::string& s):TestX(s)    {}
+};
+
+/**
+TestCase_ is a class template for a leaf TestCase, which allows TestFixture
+classes to be easily collected into the tree of tests, and have their public
+test methods called. It is worth noting that, for a given TestCase_, an
+instance of the test fixture class will be constructed pior to the
+test method being called, and destructed afterwards. This prevents 'leakage'
+of information from one test case to the next.
+*/
+template< typename FixtureT >
+class TestCase_ : public TestCase
+{
+    typedef void (FixtureT::*TestMethodPtr)( const Context& );
+
+    public:
+
+    // Constructor adds the TestMethod pointer
+    TestCase_( const std::string& sName, TestMethodPtr pTestMethod ) :
+            TestCase( sName ),
+            _pTestMethod( pTestMethod )
+    {
+    }
+
+    // Create a TestFixture instance and invoke TestMethod?
+    virtual void run( const Context& ctx )
+    {
+        ( FixtureT().*_pTestMethod )( ctx );
+    }
+
+    protected:
+
+        virtual ~TestCase_() {}
+
+    TestMethodPtr _pTestMethod;
+};
+
+/**
+A TestSuite is the \em composite component of the Composite pattern,
+and allows aggregation of Tests into hierarchies.
+*/
+class SG_EXPORT TestSuite : public Test
+{
+    public:
+
+    TestSuite( const std::string& name );
+
+    /** Adds a Test to the suite. */
+    void add( Test* pTest );
+
+    /**
+    @returns    The immediate child denoted by name, or 0 if not found.
+    */
+    Test* findChild(const std::string& name);
+
+    virtual bool accept( Test::Visitor& v );
+
+    protected:
+
+        virtual ~TestSuite() {}
+
+    typedef std::vector< osg::ref_ptr<Test> > Tests;
+    Tests _tests;  // Collection of Suites and/o