Index: osgVisual/include/cluster/dataIO_cluster.h
===================================================================
--- osgVisual/include/cluster/dataIO_cluster.h	(revision 32)
+++ osgVisual/include/cluster/dataIO_cluster.h	(revision 32)
@@ -0,0 +1,122 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include "osg/referenced"
+
+#include "dataIO_slot.h"
+
+#include "dataIO_transportContainer.h"
+
+
+namespace osgVisual
+{
+
+/**
+ * \brief This class is the interface definition class for valid cluster implementations.
+ * 
+ * This class is an abstract class, thus cannot be instantiated. Derive this class for usage.
+ * 
+ * @author Torben Dannhauer
+ * @date  Feb 2010
+ */ 
+class dataIO_cluster :	public osg::Referenced
+{
+public:
+	/**
+	 * \brief Empty constructor.
+	 * 
+	 */ 
+	dataIO_cluster() {}
+
+	/**
+	 * \brief Empty destructor
+	 * 
+	 * @return 
+	 */ 
+	virtual ~dataIO_cluster() {}
+
+	/**
+	 * \brief Pure virtual function for initialization. Must be implemented in derived class.
+	 * 
+	 */ 
+	virtual void init( osg::ArgumentParser& arguments_, osgVisual::dataIO_transportContainer* sendContainer_, bool compressionEnabled_, bool asAscii_ ) = 0;
+
+
+	virtual void shutdown() = 0;
+
+	/**
+	 * \brief This function sets the current transportContainer the cluster should send.
+	 * 
+	 * The previous container is removed, if set. (smartpointer, will delete itself.). If the cluster is in slave mode, the send_container is ignored.
+	 * 
+	 * @param sendContainer_ : New container to set.
+	 */ 
+	void setSendTransportContainer( osgVisual::dataIO_transportContainer* sendContainer_ ) {sendContainer=sendContainer_;}
+
+	/**
+	 * \brief Pure virtual function for sending TO_OBJ values via cluster to slave. Must be implemented in derived class.
+	 * 
+	 * @return : See derived class.
+	 */ 
+	virtual bool sendTO_OBJvaluesToSlaves() = 0;
+
+	/**
+	 * \brief Pure virtual function for reading TO_OBJ values from master. Must be implemented in derived class.
+	 * 
+	 * @return : See derived class.
+	 */ 
+	virtual bool readTO_OBJvaluesFromMaster() = 0;
+
+	/**
+	 * \brief Pure virtual function for reporting slave as ready to swap. Must be implemented in derived class.
+	 * 
+	 */ 
+	virtual void reportAsReadyToSwap() = 0;
+
+	/**
+	 * \brief Pure virtual function for waiting as slave for swap command. Must be implemented in derived class.
+	 * 
+	 * @return : See derived class.
+	 */ 
+	virtual bool waitForSwap() = 0;
+
+	/**
+	 * \brief Pure virtual function for waiting as master for all slaves reported as ready to swap. Must be implemented in derived class.
+	 * 
+	 * @return : See derived class.
+	 */ 
+	virtual bool waitForAllReadyToSwap() = 0;
+
+	/**
+	 * \brief Pure virtual function for sending swap command to all slaves. Must be implemented in derived class.
+	 * 
+	 * @return : See derived class.
+	 */ 
+	virtual bool sendSwapCommand() = 0;
+
+	/**
+	 * This enum defines the three modi of the cluster engine.
+	 */ 
+	enum clustermode {MASTER, SLAVE, STANDALONE};
+
+
+
+protected:
+	osg::ref_ptr<osgVisual::dataIO_transportContainer> sendContainer;
+};
+
+}	// END NAMESPACE
Index: osgVisual/include/cluster/dataIO_clusterDummy.h
===================================================================
--- osgVisual/include/cluster/dataIO_clusterDummy.h	(revision 32)
+++ osgVisual/include/cluster/dataIO_clusterDummy.h	(revision 32)
@@ -0,0 +1,52 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include <osg/notify>
+#include <osg/ArgumentParser>
+
+#include <dataIO_cluster.h>
+
+namespace osgVisual
+{
+
+/**
+ * \brief This class is a dummy class for the cluster.
+ * 
+ * All functions which are called always return true and send a debug string to stdout to announce that they were called.
+ * 
+ * @author Torben Dannhauer
+ * @date  Sep 2009
+ */ 
+class dataIO_clusterDummy :	public dataIO_cluster
+{
+public:
+	dataIO_clusterDummy();
+	virtual ~dataIO_clusterDummy(void);
+
+	void init( osg::ArgumentParser& arguments_, osgVisual::dataIO_transportContainer* sendContainer_, bool compressionEnabled_, bool asAscii_ );
+	void shutdown();
+
+	void init();
+	bool sendTO_OBJvaluesToSlaves();
+	bool readTO_OBJvaluesFromMaster();
+	void reportAsReadyToSwap();
+	bool waitForSwap();
+	bool waitForAllReadyToSwap();
+	bool sendSwapCommand();
+};
+
+} //END NAMESPACE
Index: osgVisual/include/cluster/dataIO_clusterUDP.h
===================================================================
--- osgVisual/include/cluster/dataIO_clusterUDP.h	(revision 32)
+++ osgVisual/include/cluster/dataIO_clusterUDP.h	(revision 32)
@@ -0,0 +1,67 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include "dataIO_cluster.h"
+
+#include <osg/notify>
+#include <osg/ArgumentParser>
+#include <osgDB/Registry>
+#include <osgDB/ReaderWriter>
+#include <iostream>
+
+#include "dataIO_clusterUDP_Transmission.h"
+
+namespace osgVisual
+{
+
+/**
+ * \brief This is a UDP implementation of dataIO_cluster..
+ * 
+ * This class uses UDP to fullfil the functions of dataIO_cluster.
+ * It sends the clusterdata via UDP Broadcast into the network to any listening client.
+ * 
+ * 
+ * \todo Add getHorizonColor to transport it to slave for consistent fog.
+ * @author Torben Dannhauer
+ * @date  Feb 2010
+ */ 
+class dataIO_clusterUDP :	public dataIO_cluster
+{
+public:
+	dataIO_clusterUDP();
+	virtual ~dataIO_clusterUDP(void);
+
+	void init( osg::ArgumentParser& arguments_, osgVisual::dataIO_transportContainer* sendContainer_, bool compressionEnabled_, bool asAscii_ );
+	void shutdown();
+
+	bool sendTO_OBJvaluesToSlaves();
+	bool readTO_OBJvaluesFromMaster();
+	void reportAsReadyToSwap();
+	bool waitForSwap();
+	bool waitForAllReadyToSwap();
+	bool sendSwapCommand();
+
+private:
+	bool compressionEnabled;
+	osg::ref_ptr<osgDB::Options> readOptions;
+	osg::ref_ptr<osgDB::Options> writeOptions;
+	osg::ref_ptr<osgDB::ReaderWriter> rw;
+	osg::ref_ptr<osgVisual::Broadcaster> broadcaster;
+	osg::ref_ptr<osgVisual::Receiver> receiver;
+};
+
+}	// END NAMESPACE
Index: osgVisual/include/cluster/dataIO_clusterUDP_Transmission.h
===================================================================
--- osgVisual/include/cluster/dataIO_clusterUDP_Transmission.h	(revision 32)
+++ osgVisual/include/cluster/dataIO_clusterUDP_Transmission.h	(revision 32)
@@ -0,0 +1,107 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+
+#include <osg/Referenced>
+#include <osg/Notify>
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <string.h>
+#include <winsock2.h>
+#include <stdio.h>
+#include <string.h>
+#include <iostream>
+#include <sstream>
+
+
+namespace osgVisual
+{
+
+////////////////////////////////////////////////////////////
+// Broadcaster
+//
+// Class definition for broadcasting a buffer to a LAN
+//
+
+class Broadcaster : public osg::Referenced
+{
+public :
+	Broadcaster();
+	~Broadcaster();
+
+	// Initialize Broadcaster and its socket.
+	bool init(const short port_ = 0);
+
+	// Set a recipient host.  If this is used, the Broadcaster
+	// no longer broadcasts, but rather directs UDP packets at
+	// host.
+	void setDestinationHost( const char *hostname ); 
+
+	// Send/broadcasts the buffer
+	void transmitBuffer( const char* buffer, const unsigned int size );
+
+private :
+
+    SOCKET _so;	// Socket-Handle
+
+    bool _initialized;	// Initialized Flag
+    short _port;		// Socketport
+
+    SOCKADDR_IN saddr;	// Datenstruktur zum Verwalten der SocketDaten der Protokollfamilie (Port, IP etc.)
+
+    unsigned long _destinationAddress;	// Destinationaddress
+
+	WORD requestedWSAVersion;
+};
+
+///////////////////////////////////////////////////////////
+// Receiver
+//
+// Class definition for the recipient of a broadcasted message
+//
+class Receiver : public osg::Referenced
+{
+ public :
+
+	Receiver();
+	~Receiver();
+
+	// Initialize Reciever and its socket.
+	bool init( const short port_ );
+
+	/**
+	 * \brief Sync does a blocking wait to recieve next message
+	 * 
+	 * Why max Datagram size of ~65000 bytes : http://www.erg.abdn.ac.uk/users/gorry/eg3567/inet-pages/udp.html
+	 * Good introduction into WSA sockets: http://www.htwm.de/~win/vorlesungen/sockets.pdf
+	 * 
+	 * 
+	 * @param writeInto_ : Stringstream to write socket data into
+	 */ 
+	void waitBlockingforSocketData( std::stringstream& writeInto_ );
+
+ private :
+    SOCKET _so;	// Socket-Handle
+    SOCKADDR_IN saddr;
+	char buffer[65000];
+    bool _initialized;	// Initialized-Flag
+	WORD requestedWSAVersion;
+};	
+
+}	// END NAMESPACE
Index: osgVisual/include/core/visual_core.h
===================================================================
--- osgVisual/include/core/visual_core.h	(revision 32)
+++ osgVisual/include/core/visual_core.h	(revision 32)
@@ -0,0 +1,163 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include <osg/Referenced>
+#include <osg/notify>
+
+#include <osgViewer/Viewer>
+
+#include <osgDB/ReadFile>
+
+// OSG eventhandler
+#include <osgViewer/ViewerEventHandlers>
+
+// OSG manipulator
+#include <osgGA/TrackballManipulator>
+#include <osgGA/FlightManipulator>
+#include <osgGA/DriveManipulator>
+#include <osgGA/KeySwitchMatrixManipulator>
+#include <osgGA/StateSetManipulator>
+#include <osgGA/AnimationPathManipulator>
+#include <osgGA/TerrainManipulator>
+#include <osgGA/NodeTrackerManipulator>
+
+// Spacenavigator manipulator
+#ifdef USE_SPACENAVIGATOR
+#include <manip_spaceMouse.h>
+#include <manip_nodeTrackerSpaceMouse.h>
+#include <manip_freeSpaceMouse.h>
+#endif
+
+// Object mounted manipulator
+#include <manip_objectMounted.h>
+
+#ifdef USE_DISTORTION
+// Distortion
+#include <visual_distortion.h>
+#endif
+
+#ifdef USE_SKY_SILVERLINING
+// Sky
+#include <visual_skySilverlining.h>
+#endif
+
+// DataIO
+#include <visual_dataIO.h>
+#include <object_updater.h>
+
+// visual_object
+#include <visual_object.h>
+
+// visual_hud
+#include <visual_hud.h>
+#include <visual_debug_hud.h>
+
+// visual_draw2D
+#include <visual_draw2D.h>
+#include <visual_draw3D.h>
+
+// visual util
+#include <visual_util.h>
+
+// visual_vista2D
+#ifdef USE_VISTA2D
+#include <visual_vista2D.h>
+#endif
+
+// Test
+#include <dataIO_transportContainer.h>
+#include <osgDB/OutputStream>
+#include <iostream>
+
+
+
+namespace osgVisual
+{
+
+class visual_core : public osg::Referenced
+{
+public:
+	visual_core(osg::ArgumentParser& arguments_);
+	void initialize();
+	void shutdown();
+
+	void addManipulators();
+	void processCommandlineArguments();
+	bool loadTerrain(osg::ArgumentParser& arguments_);
+	bool checkCommandlineArgumentsForFinalErrors();
+
+	void setupScenery();
+	
+protected:
+	virtual ~visual_core(void);
+
+
+private:
+	void mainLoop();
+
+	/**
+	 * Argument object, with contains all commandline arguments, which where called during programm sstartup
+	 */ 
+	osg::ArgumentParser& arguments;
+
+	/**
+	 * This CSN is at the top node on the complete scenery. Only the nodes for distortion are located above this node.
+	 */ 
+	osg::ref_ptr<osg::CoordinateSystemNode> rootNode;
+
+	/**
+	 * Reference pointer to the viewer instance. The viewer is the core of the graphical subsystem.
+	 */ 
+	osg::ref_ptr<osgViewer::Viewer> viewer;
+
+#ifdef USE_SPACENAVIGATOR
+	/**
+	 * Spacemouse node tracker manipulator
+	 */ 
+	osg::ref_ptr<NodeTrackerSpaceMouse> mouseTrackerManip;
+#endif
+
+	/**
+	 * This Matrix manipulator is used for controlling Camera by Nodes.
+	 */ 
+	osg::ref_ptr<objectMountedManipulator> objectMountedCameraManip;
+
+	/**
+	 * Space mouse hardware driver instance
+	 */ 
+	SpaceMouse* mouse;
+
+#ifdef USE_SKY_SILVERLINING
+	/**
+	 * Silverlining Sky instance
+	 */ 
+	osg::ref_ptr<visual_skySilverLining> sky;
+#endif
+
+#ifdef USE_DISTORTION
+	/**
+	 * Distortion instance.
+	 */ 
+	osg::ref_ptr<visual_distortion> distortion;
+#endif
+
+	osg::ref_ptr<visual_object> testObj;
+
+	osg::ref_ptr<osgGA::NodeTrackerManipulator> nt;
+};
+
+}	// END NAMESPACE
Index: osgVisual/include/dataIO/dataIO_executer.h
===================================================================
--- osgVisual/include/dataIO/dataIO_executer.h	(revision 32)
+++ osgVisual/include/dataIO/dataIO_executer.h	(revision 32)
@@ -0,0 +1,74 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include <osg/Node>
+#include <osgDB/ObjectWrapper>
+#include <osgDB/InputStream>
+#include <osgDB/OutputStream>
+
+#include <string>
+
+namespace osgVisual {
+
+class dataIO_executer : public osg::Node
+{
+public:
+	dataIO_executer() {id=DO_NOTHING;}
+	~dataIO_executer() {}
+
+	// Standart functions of the base-class, required for serialization
+	//// Copy constructor using CopyOp to manage deep vs shallow copy.
+	dataIO_executer(const dataIO_executer& ex, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : osg::Node(ex, copyop) {} 
+	//// osg::Objects functions
+	osg::Object* cloneType() const { return new dataIO_executer (); }
+	osg::Object* clone(const osg::CopyOp& copyop) const { return new dataIO_executer (*this,copyop); }
+	bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const dataIO_executer *>(obj)!=NULL; }
+	const char* className() const { return "dataIO_executer"; }
+	const char* libraryName() const { return "osgVisual"; }
+
+	typedef std::vector<double> parameterList;
+	enum executerID {
+		GET_HAT,
+		GET_HOT,
+		GET_LAT,
+		GET_LON,
+		IS_COLLISION, 
+		IS_INSIDE_CLOUD,
+		IS_WIND,
+		IS_PRECIPITATION,
+		DO_NOTHING
+	};
+	
+
+private: 
+	executerID id;
+	parameterList doubleParameter;
+	std::string stringParameter;
+
+// Access functions for Serializer
+public:
+	void setexecuterID(executerID id_) {id=id_;}
+	executerID getexecuterID() const {return id;}
+
+	void setDoubleParameter(const parameterList& doubleParameter_) {doubleParameter=doubleParameter_;}
+	const parameterList& getDoubleParameter() const {return doubleParameter;}
+
+	void setStringParameter(const std::string& stringParameter_) {stringParameter=stringParameter_;}
+	const std::string& getStringParameter() const {return stringParameter;}
+};
+
+} // END NAMESPACE
Index: osgVisual/include/dataIO/dataIO_slot.h
===================================================================
--- osgVisual/include/dataIO/dataIO_slot.h	(revision 32)
+++ osgVisual/include/dataIO/dataIO_slot.h	(revision 32)
@@ -0,0 +1,89 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include <osg/Object>
+#include <osgDB/ObjectWrapper>
+#include <osgDB/InputStream>
+#include <osgDB/OutputStream>
+
+#include <string>
+
+
+namespace osgVisual {
+
+class dataIO_slot : public osg::Object
+{
+public:
+	META_Object(osgVisual,dataIO_slot);
+	dataIO_slot(const osgVisual::dataIO_slot& slot_, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
+            Object(slot_,copyop),
+			direction(slot_.direction),
+			variableType(slot_.variableType),
+			variableName(slot_.variableName),
+			value(slot_.value),
+			sValue(slot_.sValue){}
+
+	dataIO_slot(){};
+	~dataIO_slot(){};
+
+	dataIO_slot & operator=(const dataIO_slot &rhs)
+	{
+		direction=rhs.direction;
+		variableType=rhs.variableType;
+		variableName=rhs.variableName;
+		value=rhs.value;
+		sValue=rhs.sValue;	
+
+		return *this;
+	}
+
+
+	/**
+	 * This enums defines the data flow direction of a slot.
+	 */ 
+	enum dataDirection {TO_OBJ, FROM_OBJ};
+
+	/**
+	 * This enum defines the two valid valuetypes.
+	 */ 
+	enum varType {DOUBLE, STRING};
+
+	dataDirection direction;
+	varType variableType;
+	std::string variableName;
+	double value;
+	std::string sValue;
+
+
+// Access functions for Serializer
+	void setdataDirection(dataDirection direction_){direction=direction_;}
+	dataDirection getdataDirection() const {return direction;}
+
+	void setvarType(varType variableType_){variableType=variableType_;}
+	varType getvarType() const {return variableType;}
+
+	const std::string& getVariableName() const {return variableName;}
+	void setVariableName(const std::string& variableName_){variableName=variableName_;}
+
+	double getValue() const {return value;}
+	void setValue(double value_){value=value_;}
+
+	const std::string& getSValue() const {return sValue;}
+	void setSValue(const std::string& sValue_){sValue=sValue_;}
+};
+
+}	// END NAMESPACE
Index: osgVisual/include/dataIO/dataIO_transportContainer.h
===================================================================
--- osgVisual/include/dataIO/dataIO_transportContainer.h	(revision 32)
+++ osgVisual/include/dataIO/dataIO_transportContainer.h	(revision 32)
@@ -0,0 +1,78 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include <osg/Object>
+#include <osg/Matrixd>
+
+#include <dataIO_executer.h>
+#include <dataIO_slot.h>
+
+#include <vector>
+
+namespace osgVisual {
+
+class dataIO_transportContainer : public osg::Object
+{
+public:
+	META_Object(osgVisual,dataIO_transportContainer);	// Required for serializer
+	dataIO_transportContainer(const osgVisual::dataIO_transportContainer& tC_, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):	// Required for serializer
+			Object(tC_,copyop),
+			frameID(tC_.frameID),
+			viewMatrix(tC_.viewMatrix),
+			executer(tC_.executer),
+			ioSlots(tC_.ioSlots){}
+	dataIO_transportContainer(){}
+	virtual ~dataIO_transportContainer(){}
+
+
+
+
+	typedef std::vector<osg::ref_ptr<dataIO_executer> > executerList;
+	typedef std::vector<osg::ref_ptr<dataIO_slot> > slotList;
+
+private:
+	int frameID;
+	osg::Matrixd viewMatrix;
+	executerList executer;
+	slotList ioSlots;
+
+// Access functions for Serializer
+public:
+	int getFrameID() const {return frameID;}
+	void setFrameID(int frameID_ ){frameID=frameID_;}
+
+	void setViewMatrix(const osg::Matrixd& viewMatrix_){viewMatrix=viewMatrix_;}
+	const osg::Matrixd& getViewMatrix() const {return viewMatrix;}
+
+	void setExecuter(const executerList& executer_) {executer=executer_;}
+	const executerList& getExecuter() const {return executer;}
+
+	void setIOSlots(const slotList& ioSlots_) {ioSlots=ioSlots_;}
+	const slotList& getIOSlots() const {return ioSlots;}
+
+
+
+	// Usage functions
+	void addExecuter( osg::ref_ptr<dataIO_executer> executerToAdd_ ) {executer.push_back(executerToAdd_);}
+	void removeAllExecuter() { executer.clear();}
+
+	void addSlot( osg::ref_ptr<dataIO_slot> slotToAdd_ ) {ioSlots.push_back(slotToAdd_);}
+	void removeAllSlots() {ioSlots.clear();}
+
+};
+
+} // END NAMESPACE
Index: osgVisual/include/dataIO/visual_dataIO.h
===================================================================
--- osgVisual/include/dataIO/visual_dataIO.h	(revision 32)
+++ osgVisual/include/dataIO/visual_dataIO.h	(revision 32)
@@ -0,0 +1,164 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include <osg/notify>
+#include <osg/referenced>
+#include <osg/ArgumentParser>
+
+#include <osgViewer/Viewer>
+
+// Cluster einbinden
+#ifdef USE_CLUSTER_DUMMY
+	#include <dataIO_clusterDummy.h>
+#endif
+#ifdef USE_CLUSTER_UDP
+	#include <dataIO_clusterUDP.h>
+#endif
+
+//ExtLink einbinden
+#ifdef USE_EXTLINK_DUMMY
+	#include <dataIO_extLinkDummy.h>
+#endif
+#ifdef USE_EXTLINK_VCL
+	#include <dataIO_extLinkVCL.h>
+#endif
+
+
+// slot and transportContainer definitions
+#include <dataIO_slot.h>
+#include <dataIO_transportContainer.h>
+
+#include <vector>
+
+
+
+
+namespace osgVisual {
+
+/**
+ * \brief Zentrale Klasse für Datenanbindung des Sichtsystemnodes an das Gesamtsichtsystem bzw. dem Simulator.
+ * 
+ * Damit nur eine Klasse instantiiert werden kann, ist diese Klasse als Singleton realisiert.
+ * 
+ * 
+ * @author Torben Dannhauer
+ * @date  Nov 2009
+ */ 
+class visual_dataIO : public osg::Referenced
+{
+private:
+	class dataIO_eventCallback : public osg::NodeCallback
+	{
+	public: 
+		/**
+		 * \brief Constructor, for setting the member variables.
+		 * 
+		 * @param viewer_ : Pointer to the viewer.
+		 * @param sceneCamera_ : Pointer to the scene camera.
+		 */ 
+		dataIO_eventCallback(visual_dataIO* dataIO_):dataIO(dataIO_){};
+
+		/**
+		 * \brief This function is execute d as callback during update traversal.
+		 * 
+		 */ 
+		virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
+	private:
+		visual_dataIO* dataIO;
+	};
+	osg::ref_ptr<dataIO_eventCallback> eventCallback;
+
+
+	class dataIO_finalDrawCallback : public osg::Camera::DrawCallback
+	{
+	public:
+		/**
+		 * \brief Constructor
+		 * 
+		 */ 
+		dataIO_finalDrawCallback::dataIO_finalDrawCallback(visual_dataIO* dataIO_):dataIO(dataIO_){};
+		
+		/**
+		 * \brief Operator executed at callback
+		 * 
+		 */ 
+		virtual void operator () (const osg::Camera& camera) const;
+	private:
+		visual_dataIO* dataIO;
+	};
+
+	osg::ref_ptr<dataIO_finalDrawCallback> finalDrawCallback;
+
+	// Make Constructor private to prevent creating instances via ptr* = new ..().
+	visual_dataIO();
+	// Make Copy-Constructor private to prevent getting instances via copying dataIO instance.
+	visual_dataIO(const visual_dataIO& cc);
+
+	osg::ref_ptr<dataIO_extLink> extLink;
+	osg::ref_ptr<dataIO_cluster> cluster;
+
+	/**
+	 * Referenced Pointer to the applications viewer.
+	 */ 
+	osg::ref_ptr<osgViewer::Viewer> viewer;
+
+	osg::ref_ptr<osgVisual::dataIO_transportContainer> slotContainer;
+
+	/**
+	 * List of SLOT variables dataIO provides.
+	 */ 
+	std::vector<dataIO_slot> dataSlots;
+
+	friend dataIO_eventCallback;
+	friend dataIO_finalDrawCallback;
+
+public:
+	// Public destructor to allow singleton cleanup from extern
+	~visual_dataIO();
+
+	/**
+	 * \brief This function returns an pointer to the singleton instalce of dataIO. If now instance exist, it will be instantiated silently.
+	 * 
+	 * After instantiation, dataIO still needs to bei initiialized to configure working mode etc!
+	 * 
+	 * @return : Pointer to the instance. 
+	 */ 
+	static visual_dataIO* getInstance();
+
+	void init(osgViewer::Viewer* viewer_,osg::ArgumentParser& arguments_);
+	void shutdown();
+	bool isMaster(){if (clusterMode==osgVisual::dataIO_cluster::MASTER) return true; else return false;};
+	bool isSlave(){if (clusterMode==osgVisual::dataIO_cluster::SLAVE) return true; else return false;};
+	bool isStandalone(){if (clusterMode==osgVisual::dataIO_cluster::STANDALONE) return true; else return false;};
+
+
+// SLOT Access functions
+	void* getSlotPointer(std::string slotName_, osgVisual::dataIO_slot::dataDirection direction_, osgVisual::dataIO_slot::varType variableTyp_ );
+	double getSlotDataAsDouble(std::string variableName_, osgVisual::dataIO_slot::dataDirection direction_ );
+	std::string getSlotDataAsString(std::string variableName_, osgVisual::dataIO_slot::dataDirection direction_ );
+	void setSlotData(std::string variableName_, osgVisual::dataIO_slot::dataDirection direction_, std::string sValue_ );
+	void setSlotData(std::string variableName_, osgVisual::dataIO_slot::dataDirection direction_, double value_ );
+
+	int getSlotNum() {return dataSlots.size();}
+
+	osgVisual::dataIO_cluster::clustermode clusterMode;
+
+	bool initialized;
+};
+
+
+} // END namespace osgVisual
Index: osgVisual/include/distortion/visual_distortion.h
===================================================================
--- osgVisual/include/distortion/visual_distortion.h	(revision 32)
+++ osgVisual/include/distortion/visual_distortion.h	(revision 32)
@@ -0,0 +1,480 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include <osg/NodeCallback>
+#include <osg/Node>
+#include <osg/Geode>
+#include <osg/Geometry>
+#include <osg/Texture2D>
+#include <osg/TextureRectangle>
+#include <osg/Notify>
+#include <osg/Referenced>
+
+#include <osgViewer/Viewer>
+
+#include <osgDB/ReadFile>
+#include <osgDB/FileUtils>
+
+#include <osgGA/GUIEventHandler>
+#include <osgGA/GUIActionAdapter>
+
+#include <string>
+#include <iostream>
+#include <fstream>
+
+
+namespace osgVisual
+{
+
+
+//class CameraConfigParser;
+
+/**
+ * \brief This class distorts and blends the rendered image for projection in curved screens and multi channel setups.
+ * 
+ * @todo Distortion algorithm seems to be erronous, small artefact lines are visible.
+ * 
+ * @author Torben Dannhauer
+ * @date  Jul 2009
+ */ 
+class visual_distortion : public osg::Node
+{
+public:
+	/**
+	 * \brief Constructor
+	 * 
+	 */ 
+	visual_distortion(osgViewer::Viewer* viewer_, osg::ArgumentParser& arguments_);
+
+	/**
+	 * \brief Destructor
+	 * 
+	 */ 
+	virtual ~visual_distortion(void);
+
+	/**
+	 * \brief This function parses the arguments for distortion relevant parameters.
+	 * 
+	 * @return : True if parsing was successful.
+	 */ 
+	bool processCommandlineparameters();
+
+	/**
+	 * \brief This function initializes the distortion node and creates the distortion camera and scene graph.
+	 * 
+	 * @param subgraph : Undistorted scene graph.
+	 * @param clearColor : Clear color for distortion.
+	 * @return : Group node which contains the distortion and the undistorted scene graph.
+	 */ 
+	osg::Group* initialize(osg::Group* subgraph, const osg::Vec4& clearColor );
+
+	/**
+	 * \brief This function shuts the distortion module down.
+	 * 
+	 */ 
+	void shutdown();
+
+	/**
+	 * \brief This function enabels or disables the distortion
+	 */ 
+	void toggleDistortion();
+
+	/**
+	 * \brief This functions returns a pointer to the scene camera, which renders the undistorted scene (PRE_RENDER).
+	 * 
+	 * @return Pointer to the scene camera.
+	 */ 
+	osg::Camera* getSceneCamera() {return sceneCamera;};
+
+	/**
+	 * \brief This function returns the distortedSceneGraph if the distortion module is initialized.
+	 * 
+	 * @return NULL if not Initialized, Otherwith the distorted sceneGraph.
+	 */ 
+	osg::Group* getDistortedSceneGraph() { if(initialized) return distortedGraph; else return NULL;};
+
+	/**
+	 * \brief The function returns the frustum values which are parsed by the nested cameraConfigParser class.
+	 * 
+	 * @return : Vector of double values which represent the frustum dataset. The order is the standart glu order.
+	 */ 
+	std::vector<double> getFrustumDataset() {return parser->getFrustumDataset();};
+			
+	/**
+	 * \brief This function returns the retation values for the rendering camera for XYZ axis in degree.
+	 * 
+	 * @return : Vector of double values which represent the rotation values for XYZ axis in degree.
+	 */ 
+	std::vector<double> getRotationDataset() {return parser->getRotationDataset();};
+
+	/**
+	 * \brief This function returns the translation values for the rendering camera along the XYZ axis in meter.
+	 * 
+	 * @return : Vector of double values which represent the translation values for XYZ axis in meter.
+	 */ 
+	std::vector<double> getTranslationDataset() {return parser->getTranslationDataset();};
+
+private:
+	/**
+	 * \brief Callback class for update callback.
+	 * 
+	 * This nested class is used for updating the distortion node every frame by installing this class as updateCallback for the distortion node.
+	 * @author Torben Dannhauer
+	 * @date  Jul 2009
+	 */ 
+	class distortionUpdateCallback : public osg::NodeCallback
+	{
+	public: 
+		/**
+		 * \brief Constructor, for setting the member variables.
+		 * 
+		 * @param viewer_ : Pointer to the viewer.
+		 * @param sceneCamera_ : Pointer to the scene camera.
+		 */ 
+		distortionUpdateCallback(osgViewer::Viewer* viewer_, osg::Camera* sceneCamera_)
+			: viewer(viewer_), sceneCamera(sceneCamera_) {};
+
+		/**
+		 * \brief This function is executed as callback during update traversal.
+		 * 
+		 */ 
+		virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
+	private:
+		/**
+		 * Referenced Pointer to the applications viewer.
+		 */ 
+		osg::ref_ptr<osgViewer::Viewer> viewer;
+
+		/**
+		 * Referenced Pointer to the scene camera.
+		 */ 
+		osg::ref_ptr<osg::Camera> sceneCamera;
+	};
+
+	/**
+	 * \brief This nested class is a keyboard event adapter which allows distortion toggle. It never blocks the key event, therefore multiple events on a single key are possible.
+	 * 
+	 * @author Torben Dannhauer
+	 * @date  Jul 2009
+	 */ 
+	class ToggleDistortionKBEventHandler : public osgGA::GUIEventHandler
+	{
+	public:
+		/**
+		 * \brief Constructor
+		 * 
+		 * @param distortion_ : Pointer to the distortion class.
+		 * @param viewer_ : Reference to the applications viewer.
+		 */ 
+		ToggleDistortionKBEventHandler(visual_distortion* distortion_): distortion(distortion_) {}
+
+		/**
+		 * \brief This function is executed if an keyboard event appears
+		 * 
+		 * @param ea : GUI event adapter.
+		 * @param : GUI action adapter.
+		 * @return : Returns always false to pass the event to other event adapter if installed.
+		 */    
+		virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&)
+		{
+			if ( ea.getEventType() == osgGA::GUIEventAdapter::KEYDOWN &&  ea.getKey() == 'd' )
+			{
+				distortion->toggleDistortion();
+				return false;
+			}
+			else
+				return false;	// return false means: hand over the event to the next Eventhandler.  True means: absorb the event.
+		}
+
+	private:
+		/**
+		 * Pointer to he distortion class. INside this EventHandler a Referenced Pointer ist _NOT_ used, 
+		 * because a circulare reference (distortion->kBEventHandler, kbEventHandler->distortion) would block both pointer to unref.
+		 */ 
+		visual_distortion* distortion;
+	};
+
+	/**
+	 * \brief This nested class reads the Projection Designer's project file and extracts the frustum, translation and rotation values
+	 * 
+	 * @author Torben Dannhauer
+	 * @date  Aug 2009
+	 */ 
+	class CameraConfigParser : public osg::Referenced
+	{
+	public:
+		CameraConfigParser(void)
+		{
+			configParsed = false;
+			frustumValues.clear();
+			rotationValues.clear();
+			rotationValues.resize(3,0);
+			translationValues.clear();
+			translationValues.resize(3,0);
+		}
+
+		virtual ~CameraConfigParser(void) {};
+
+		bool parseConfigFile(const char * filename)
+		{
+		  if (! osgDB::fileExists(filename) )
+		  {
+			  OSG_NOTIFY( osg::FATAL ) << "ERROR: File '" << filename << "' does not exist." << std::endl;
+			  return false;
+		  }
+
+		  frustumValues.clear();
+		  rotationValues.clear();
+		  rotationValues.resize(3,0);
+		  translationValues.clear();
+		  translationValues.resize(3,0);
+
+		  std::string line;
+		  std::ifstream configFile (filename);
+
+		  if (configFile.is_open())
+		  {
+			while (! configFile.eof() )
+			{
+			  getline (configFile,line);
+			  //cout << line << endl;
+
+			  // Auf Frustum untersuchen
+			  if( line.find("Frustum") != std::string::npos )
+			  {
+				  extractFrustum(line);
+			  }
+
+			  // Auf Rotation untersuchen
+			  if( line.find("Rotate") != std::string::npos )
+			  {
+				 extractRotation(line);
+			  }
+
+			  // Auf Translation untersuchens
+			  if( line.find("Translate") != std::string::npos )
+			  {
+				 extractTranslation(line);
+			  }
+
+			}
+			configFile.close();
+			configParsed = true;
+			return true;
+		  }
+		  else 
+		  {
+			  OSG_NOTIFY( osg::FATAL ) << "Unable to open file:" << filename << std::endl;
+			  frustumValues.clear();
+			  configParsed = false;
+			  return false;
+		  }
+		}
+
+		bool extractFrustum(std::string data_)
+		{
+			data_.replace(0,16,"");		// Delete leading spaces and "Frustum"
+			data_.replace(data_.length()-1,1,"");	// Delete trailing ";"
+			for( int i=0; i<6; i++)
+			{
+				size_t pos = data_.find(" ");    // Position of first value in string
+				if( pos == -1) pos = data_.length();
+				frustumValues.push_back( atof( data_.substr(0, pos).data() ) );
+				data_.replace(0,pos+1,"");
+			}
+			return true;
+		}
+
+		bool extractRotation(std::string data_)
+		{
+			data_.replace(0,15,"");		// Delete leading spaces and "Rotate"
+			data_.replace(data_.length()-1,1,"");	// Delete trailing ";"
+
+			size_t valuePos = data_.find(" ");    // First Value is RotationValue
+			std::string axis = data_.substr( valuePos+1);
+			switch(axis.find("1"))
+			{
+				case 0: rotationValues[0] = atof( data_.substr(0, valuePos).data() ); // X-Axis
+					break;
+				case 2: rotationValues[1] = atof( data_.substr(0, valuePos).data() ); // Y-Axis
+					break;
+				case 4: rotationValues[2] = atof( data_.substr(0, valuePos).data() ); // Z-Axis
+					break;
+			};
+			return true;
+		}
+
+		bool extractTranslation(std::string data_)
+		{
+			data_.replace(0,18,"");		// Delete leading spaces and "Translate"
+			data_.replace(data_.length()-1,1,"");	// Delete trailing ";"
+			for( unsigned int i=0;i<translationValues.size(); i++)
+			{
+				size_t valuePos = data_.find(" ");
+				std::string value = data_.substr(0, valuePos);
+				data_.replace(0,valuePos+1,"");
+				translationValues[i] = atof( value.data() );
+			}
+			return true;
+		}
+
+		std::vector<double> getFrustumDataset() {return(frustumValues);}
+			
+		std::vector<double> getRotationDataset() {return(rotationValues);}
+
+		std::vector<double> getTranslationDataset() {return(translationValues);}
+
+		bool isConfigParsed() {return configParsed;};
+	private:
+		bool configParsed;
+		std::vector<double> frustumValues;
+		std::vector<double> rotationValues;
+		std::vector<double> translationValues;
+	};
+
+
+
+	/**
+	 * Updatecallback as member variable of this class.
+	 */ 
+	osg::ref_ptr<distortionUpdateCallback> updateCallback;
+
+	/**
+	 * Keyboard Eventhandler for distortion toggle.
+	 */ 
+	//osg::ref_ptr<ToggleDistortionKBEventHandler> kBEventHandler;
+	ToggleDistortionKBEventHandler* kBEventHandler;
+
+	/**
+	 * \brief This functions creates the distortion environment.
+	 * 
+	 * @param subgraph : Undistorted scene graph to distort.
+	 * @param clearColor : OpenGL clear color to use for the distortion.
+	 * @return : Group node which contains the distortion and the undistorted scene graph.
+	 */ 
+	osg::Group* createPreRenderSubGraph(osg::Group* subgraph, const osg::Vec4& clearColor );
+
+	/**
+	 * \brief This function loads a shader source file
+	 * 
+	 * @param shader : Shader to load source in
+	 * @param fileName : Filename of shader source file.
+	 * @return : Returns true if successful.
+	 */ 
+	bool loadShaderSource( osg::Shader* shader, const std::string& fileName );
+
+	/**
+	 * \brief This function loads a shader Texture file
+	 * 
+	 * @param fileName : Texture file to load.
+	 * @return : Returns the loaded Texture.
+	 */ 
+	osg::Texture* loadTexture( const std::string& fileName );
+	
+	/**
+	 * Referenced Pointer to the loaded distortion Map
+	 */ 
+	osg::ref_ptr<osg::Texture> distortMapTexture;
+
+	/**
+	 * Referenced Pointer to the loaded blend map
+	 */ 
+	osg::ref_ptr<osg::Texture> blendMapTexture;
+
+
+	/**
+	 * Flag which indicates the initialization status
+	 */ 
+	bool initialized;
+
+	/**
+	 * Flag that indicates if distortion is actually enabled. This is imported for the toggleDistortion() function.
+	 */ 
+	bool distortionEnabled;
+
+	/**
+	 * Reference pointer to the distorted scene graph.
+	 */ 
+	osg::ref_ptr<osg::Group> distortedGraph;
+
+	/**
+	 * Reference pointer to the undistorted scene graph.
+	 */ 
+	osg::ref_ptr<osg::Group> cleanGraph;
+
+	/**
+	 * Reference pointer to the scen camera (PRE_RENDER)
+	 */ 
+	osg::ref_ptr<osg::Camera> sceneCamera;
+
+	/**
+	 * Referenced pointer to the main applications viewer
+	 */ 
+	osg::ref_ptr<osgViewer::Viewer> viewer;
+
+	/**
+	 * Parser object for parsing the camera configuration file which controlls frustum and camera PAT
+	 */ 
+	osg::ref_ptr<CameraConfigParser> parser;
+
+	/**
+	 * Texture width for render to texture (RTT).
+	 */ 
+	unsigned tex_width;
+
+	/**
+	 * Texture height for using render to texture (RTT).
+	 */ 
+    unsigned tex_height;
+
+	/**
+	 * Indicates of texture rectangle should be used.
+	 */ 
+	bool useTextureRectangle;
+
+	/**
+	 * Indicates if shader distortion should be used.
+	 */ 
+	bool useShaderDistortion;
+
+	/**
+	 * Indicates if high definition rendering shold be used.
+	 */ 
+	bool useHDR;
+
+	/**
+	 * Filename of the distorion map.
+	 */ 
+	std::string distortMapFileName;
+
+	/**
+	 * Filename of the blend map.
+	 */ 
+	std::string blendMapFileName;
+
+	/**
+	 * Target implementation which should be used to distort.
+	 */ 
+	osg::Camera::RenderTargetImplementation renderImplementation;
+
+	/**
+	 * Reference to the global ArgumentParser.
+	 */ 
+	osg::ArgumentParser& arguments;
+};
+
+}	// END NAMESPACE
Index: osgVisual/include/draw2D/visual_debug_hud.h
===================================================================
--- osgVisual/include/draw2D/visual_debug_hud.h	(revision 32)
+++ osgVisual/include/draw2D/visual_debug_hud.h	(revision 32)
@@ -0,0 +1,129 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include <sstream>
+#include <iostream>
+#include <iomanip>
+
+#include <osg/NodeCallback>
+
+#include <visual_draw2D.h>
+#include <visual_util.h>
+
+
+namespace osgVisual
+{
+
+/**
+ * \brief This class prints debug information about LAT, LON, HAT, HOT on screen.
+ * 
+ * 
+ * @author Torben Dannhauer
+ * @date  Jan 2010
+ */ 
+class visual_debug_hud : public osg::Geode
+{
+public:
+	/**
+	 * \brief Empty Constructor.
+	 * 
+	 */ 
+	visual_debug_hud(void);
+
+	/**
+	 * \brief Empty Destructor.
+	 * 
+	 */ 
+	~visual_debug_hud(void);
+
+	/**
+	 * \brief This function initializes the HUD.
+	 * 
+	 * @param viewer_ : Pointer to the viewer instance to get screen size and screen width.
+	 * @param rootNode_ : Pointer to the rootnode of the Scene, which should be a CSN
+	 * @return : True if initialization was successful.
+	 */ 
+	bool init(osgViewer::Viewer *viewer_, osg::CoordinateSystemNode* rootNode_ );
+
+	void shutdown();
+
+private:
+	/**
+	 * \brief This function contains the code to display in the HUD.
+	 * 
+	 * 
+	 * @return Pointer to the Geode which contains the HUD content.
+	 */ 
+	osg::ref_ptr<osg::Geode> addContent();
+
+	/**
+	 * This variable contains the width of the rendering screen during the initialization of this node.
+	 */ 
+	int screen_width;
+
+	/**
+	 * This variable contains the height of the rendering screen during the initialization of this node.
+	 */ 
+	int screen_height;
+
+
+
+	class HudUpdateCallback : public osg::NodeCallback
+	{
+	public:
+		/**
+		 * \brief Constructor
+		 * 
+		 * @param csn_ : Pointer to the Coordinate System Node. Necessary to extract lat, lon and height of the camera position.
+		 * @param sceneCamera_ : Pointer to the scene camera (undistorted camera, type PRE_RENDER)
+		 * @param sky_ : Pointer to the sky system.
+		 */ 
+		HudUpdateCallback(osg::CoordinateSystemNode* csn_, osg::Camera* sceneCamera_)
+			: csn(csn_), sceneCamera(sceneCamera_) {};
+
+		/**
+		 * \brief This function is executed as callback during traversal. It updates values to display.
+		 * 
+		 */ 
+		virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
+	private:
+		/**
+		 * Referenced pointer to the Coordinate System Node. Necessary to extract lat, lon and height of the camera position.
+		 */ 
+		osg::ref_ptr<osg::CoordinateSystemNode> csn;
+		
+		/**
+		 * Referenced pointer to the scene camera (undistorted camera, type PRE_RENDER)
+		 */ 
+		osg::ref_ptr<osg::Camera> sceneCamera;
+
+	};	// Nested class END
+
+	/**
+	 * Referenced Pointer to the updatecallback, which is installed at this node. 
+	 */ 
+	osg::ref_ptr<HudUpdateCallback> updateCallback;
+
+	bool isInitialized;
+
+	osg::ref_ptr<osgText::Text> textLat, textLon, textAlt, textHat, textHot;
+
+	// Friend classes
+	friend class HudUpdateCallback; // Damit der Callback auf alle Member zugreifen kann wie wenn er in der Klasse sitzen würde.
+}; 
+
+}	// END NAMESPACE
Index: osgVisual/include/draw2D/visual_draw2D.h
===================================================================
--- osgVisual/include/draw2D/visual_draw2D.h	(revision 32)
+++ osgVisual/include/draw2D/visual_draw2D.h	(revision 32)
@@ -0,0 +1,165 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include <osg/Referenced>
+#include <osg/Geometry>
+#include <osg/Geode>
+#include <osg/CoordinateSystemNode>
+#include <osgText/Text>
+#include <osgViewer/Viewer>
+#include <osg/MatrixTransform>
+
+#include <visual_util.h>
+
+
+namespace osgVisual
+{
+
+/**
+ * \brief This class is the interface to place 2D drawings in screen coordinates over the rendered 3D scene, but before POST_RENDER actions like distortion.
+ * 
+ * This class is realized as singleton to make sure that only one interface controls the 2D drawing.
+ * It is derived vom osg::Geode to be includable into the scenegraph. At every frame, callbacks are possible to use for updating 2D drawings dynamically.
+ * 
+ * If you wish dynamic content in your drawings, implement callbacks in your content geodes. This class is not capable of callbacks, because it is not added into the scenegraph.
+ * 
+ * 
+ * @author Torben Dannhauer
+ * @date  Sep 2009
+ */ 
+class visual_draw2D : public osg::Referenced
+{
+private:
+	/**
+	 * \brief Constructor : Private accessible to prevent instantiation of thsi class by external caller.
+	 * 
+	 */ 
+	visual_draw2D(void);
+
+	/**
+	 * \brief Copy-Constructor: Private accessible to prevent copies (from outside) of this class.
+	 * 
+	 * @param cc : Instance to copy. Not relevant because this funtion is not implemented. If this function is not definied,
+	 * the compiler would create a public accessible dafault copy constructor.
+	 */ 
+	visual_draw2D(const visual_draw2D& cc);
+
+public:
+	/**
+	 * \brief Destructor: Public accessible to allow external functions to clean up this singleton.
+	 * 
+	 */ 
+	~visual_draw2D(void);
+
+	/**
+	 * \brief This function returns the singleton instance for usage.
+	 * 
+	 * @return Pointer to the instance.
+	 */ 
+	static visual_draw2D* getInstance();
+
+	/**
+	 * \brief This function initilizes the 2DDraw interface.
+	 * 
+	 * @param sceneGraphRoot_ : Scene root to add the 2D drawings to.
+	 * @param viewer_ : Applications main viewer to get the screen resolution
+	 * @return : True if successful.
+	 */ 
+	bool init( osg::CoordinateSystemNode *sceneGraphRoot_, osgViewer::Viewer *viewer_ );
+
+	/**
+	 * \brief This function shut "drawing interface down.
+	 * 
+	 * It removes all drawables and shuts them down to allow them to uninstall their updater. 
+	 * 
+	 */ 
+	void shutdown();
+
+	/**
+	 * \brief Call this function to add a Geode with drawables which contain 2d content.
+	 * 
+	 * @param content_ : Geode with drawables to add.
+	 * @param name_ : Name to set the geode to for further identification.
+	 * @param renderBinDetail_ : Renderbin to add the content to. 99 is the default for HUD
+	 * @return : true of adding was successful.
+	 */ 
+	bool addDrawContent( osg::Geode* content_, std::string name_,int renderBinDetail_ = 99 );
+
+	/**
+	 * \brief This function returns a content geode if the name matches the specified one.
+	 * 
+	 * @param name_ : content to search after.
+	 * @return : Pointer to the found geode. If no Node with that name is found, NULL is returned.
+	 */ 
+	osg::Geode* getDrawContent( std::string name_ );
+
+	/**
+	 * \brief This function removes Drawcontent specified by name_.
+	 * 
+	 * @param name_ : Name of drawcontent to remove.
+	 * @return : Returns true if drawcontent was found and successfully removed.
+	 */ 
+	bool removeDrawContent( std::string name_ );
+	
+	/**
+	 * \brief This function removes all drawContents.
+	 * 
+	 */ 
+	void removeAllDrawContents();
+
+	/**
+	 * \brief This function returns the number of registered drawContents.
+	 * 
+	 * @return : Number of registered drawContents.
+	 */ 
+	inline int getDrawContentNum();
+
+private:
+	/**
+	 * This camera ist NESTED_RENDER and renders all "D drawings.
+	 * 
+	 * It is rendered after the 3D scene but before POST_RENDER cameras like distortion.
+	 */ 
+	osg::ref_ptr<osg::Camera> camera;
+
+	/**
+	 * This Modelviewematrix is the parent for all geodes which contain 2D drawings. To be known by the addContent() funtion, it is a classwide member attribute.
+	 */ 
+	osg::ref_ptr<osg::MatrixTransform> draw2DModelViewMatrix;
+
+	/**
+	 * This Projectionmatrix connects the global scenegraph with the 2D modelview matrix. It is used to disconnect the 2D drawing subgraph from the global scenegrpah on shutdown.
+	 */ 
+	osg::ref_ptr<osg::Projection> draw2DProjectionMatrix;
+
+	/**
+	 * This flag indicated whether the draw2D interface is initialized. 
+	 */ 
+	bool initialized;
+
+	/**
+	 * This variable contains the width of the rendering screen during the initialization of this node.
+	 */ 
+	int screen_width;
+
+	/**
+	 * This variable contains the height of the rendering screen during the initialization of this node.
+	 */ 
+	int screen_height;
+};
+
+}	// END NAMESPACE
Index: osgVisual/include/draw2D/visual_hud.h
===================================================================
--- osgVisual/include/draw2D/visual_hud.h	(revision 32)
+++ osgVisual/include/draw2D/visual_hud.h	(revision 32)
@@ -0,0 +1,78 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include <visual_draw2D.h>
+
+
+namespace osgVisual
+{
+
+/**
+ * \brief This class demonstrates how to build a Head Up Display.
+ * 
+ * Replace addContent() to integrate own content.
+ * 
+ * @todo : Check, if the update logic should be implemtented in draw2D or here in.
+ * 
+ * @author Torben Dannhauer
+ * @date  Sep 2009
+ */ 
+class visual_hud : public osg::Geode
+{
+public:
+	/**
+	 * \brief Empty Constructor.
+	 * 
+	 */ 
+	visual_hud(void);
+
+	/**
+	 * \brief Empty Destructor.
+	 * 
+	 */ 
+	~visual_hud(void);
+
+	/**
+	 * \brief This function initializes the HUD.
+	 * 
+	 * @param viewer_ : Pointer to the viewer instance to get screen size and screen width.
+	 * @return : True if initialization was successful.
+	 */ 
+	bool init(osgViewer::Viewer *viewer_ );
+
+private:
+	/**
+	 * \brief This function contains the code to display in the HUD.
+	 * 
+	 * Subclass this function to integrate own content.
+	 * 
+	 * @return Pointer to the Geode which contains the HUD content.
+	 */ 
+	osg::ref_ptr<osg::Geode> addContent();
+
+	/**
+	 * This variable contains the width of the rendering screen during the initialization of this node.
+	 */ 
+	int screen_width;
+
+	/**
+	 * This variable contains the height of the rendering screen during the initialization of this node.
+	 */ 
+	int screen_height;
+}; 
+
+}	// END NAMESPACE
Index: osgVisual/include/draw3D/visual_draw3D.h
===================================================================
--- osgVisual/include/draw3D/visual_draw3D.h	(revision 32)
+++ osgVisual/include/draw3D/visual_draw3D.h	(revision 32)
@@ -0,0 +1,36 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include <osg/CoordinateSystemNode>
+#include <osg/Geode>
+#include <osg/Geometry>
+#include <osg/Node>
+
+#include <osgViewer/Viewer>
+
+namespace osgVisual
+{
+
+class visual_draw3D : public osg::Node
+{
+public:
+	visual_draw3D(void);
+	virtual ~visual_draw3D(void);
+	void init( osg::CoordinateSystemNode* rootNode_, osgViewer::Viewer *viewer_ );
+};
+
+}	// END NAMESPACE
Index: osgVisual/include/extLink/dataIO_extLink.h
===================================================================
--- osgVisual/include/extLink/dataIO_extLink.h	(revision 32)
+++ osgVisual/include/extLink/dataIO_extLink.h	(revision 32)
@@ -0,0 +1,92 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include <osg/Referenced>
+#include <osg/Node>
+#include <dataIO_slot.h>
+
+
+namespace osgVisual
+{ 
+
+/**
+ * \brief This class is the interface definition class for valid externalLink (extLink) implementations.
+ * 
+ * This class is an abstract class, thus cannot be instantiated. Derive this class for usage.
+ * 
+ * @author Torben Dannhauer
+ * @date  Sep 2009
+ */ 
+
+class dataIO_extLink : public osg::Referenced
+{
+public:
+	/**
+	 * \brief Empty constructor
+	 * 
+	 */ 
+	dataIO_extLink(std::vector<osgVisual::dataIO_slot>& dataSlots_) : dataSlots(dataSlots_){}
+
+	/**
+	 * \brief Empty destructor
+	 * 
+	 * @return 
+	 */ 
+	virtual ~dataIO_extLink() {}
+
+	/**
+	 * \brief Pure virtual function for initialization. Must be implemented in derived class.
+	 * 
+	 */ 
+	virtual void init() = 0;
+
+	virtual void shutdown() = 0;
+
+	/**
+	 * \brief Pure virtual function for reading TO_OBJ values form the external link. Must be implemented in derived class.
+	 * 
+	 * @return : See derived class.
+	 */ 
+	virtual bool readTO_OBJvalues() = 0;
+
+	/**
+	 * \brief Pure virtual function for writing return values back to the external link. Must be implemented in derived class.
+	 * 
+	 * @return : See derived class.
+	 */ 
+	virtual bool writebackFROM_OBJvalues() = 0;
+
+protected:
+	/**
+	 * Nested external link for more then one external source.
+	 */ 
+	osg::ref_ptr<dataIO_extLink> extLink;
+
+	/**
+	 * Flag to indicate if this class is initialized.
+	 */ 
+	bool initialized;
+
+	/**
+	 * Reference to dataIO's central managed dataSlots.
+	 * This central dataSlot array is filled with available slots by this extLink class.
+	 */ 
+	std::vector<dataIO_slot>& dataSlots;
+ 
+};
+
+}	// END NAMESPACE
Index: osgVisual/include/extLink/dataIO_extLinkDummy.h
===================================================================
--- osgVisual/include/extLink/dataIO_extLinkDummy.h	(revision 32)
+++ osgVisual/include/extLink/dataIO_extLinkDummy.h	(revision 32)
@@ -0,0 +1,46 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include <dataIO_extLink.h>
+#include <osg/Notify>
+
+namespace osgVisual
+{
+
+/**
+ * \brief This class is a dummy class for the externalLink.
+ * 
+ * All functions which are called always return true and send a debug string to stdout to announce that they were called.
+ * 
+ * @author Torben Dannhauer
+ * @date  Sep 2009
+ */ 
+class dataIO_extLinkDummy :	public dataIO_extLink
+{
+public:
+	dataIO_extLinkDummy(std::vector<dataIOSlot>& dataSlots_);
+	virtual ~dataIO_extLinkDummy(void);
+
+	void init();
+	void shutdown();
+
+	bool readTO_OBJvalues();
+	bool writebackFROM_OBJvalues();
+	void provideSlots();
+};
+
+}	// END NAMESPACE
Index: osgVisual/include/extLink/dataIO_extLinkVCL.h
===================================================================
--- osgVisual/include/extLink/dataIO_extLinkVCL.h	(revision 32)
+++ osgVisual/include/extLink/dataIO_extLinkVCL.h	(revision 32)
@@ -0,0 +1,96 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include <dataIO_extLink.h>
+#include <osg/notify>
+#include <osgDB/FileUtils>
+#include <winsock2.h>
+
+// VCL
+//// To keep the VS 2005 Solution file clean from VCL dependencies: Link dependencies here:
+#ifndef _DEBUG
+#pragma comment ( lib, "../VCL_1.0.3.4/source/3rdParty/expatpp/lib/releasemtdll/libexpatMT.lib" )
+#pragma comment ( lib, "../VCL_1.0.3.4/source/3rdParty/expatpp/lib/releasemtdll/expatpp.lib" )
+#pragma comment ( lib, "../VCL_1.0.3.4/source/lib/VCL1_34.lib" )
+#endif
+#ifdef _DEBUG
+#pragma comment ( lib, "../VCL_1.0.3.4/source/3rdParty/expatpp/lib/debugmtdll/libexpatMT_d.lib" )
+#pragma comment ( lib, "../VCL_1.0.3.4/source/3rdParty/expatpp/lib/debugmtdll/expatpp_d.lib" )
+#pragma comment ( lib, "../VCL_1.0.3.4/source/lib/VCL1_34D.lib" )
+#endif
+//// include VCL header
+#ifdef WIN32
+#include <wtypes.h>
+#endif
+#include "VCLDefinitions.h"
+#include "VCLIO.h"
+#include "VCLIOChannel.h"
+#include "VCLIOChannelEntry.h"
+#include "VCLVariable.h"
+#include "VCLSocketDefs.h"
+#include <conio.h>
+#include "stdlib.h"
+#include <iostream>
+
+
+namespace osgVisual
+{ 
+
+/**
+ * \brief This class is a VCL-based implementation of the externalLink.
+
+ * 
+ * @author Torben Dannhauer
+ * @date  Nov 2009
+ */ 
+class dataIO_extLinkVCL :	public dataIO_extLink
+{
+public:
+	dataIO_extLinkVCL(std::vector<dataIO_slot>& dataSlots_);
+	virtual ~dataIO_extLinkVCL(void);
+
+	void init();
+	void shutdown();
+
+	bool readTO_OBJvalues();
+	bool writebackFROM_OBJvalues();
+
+private:
+	CVCLVariable<double> SAENGER1_POS_LAT;
+    CVCLVariable<double> SAENGER1_POS_LON;
+    CVCLVariable<double> SAENGER1_POS_ALT; 
+	CVCLVariable<double> SAENGER1_ROT_X;
+    CVCLVariable<double> SAENGER1_ROT_Y;
+    CVCLVariable<double> SAENGER1_ROT_Z;
+
+	CVCLVariable<double> SAENGER2_POS_LAT;
+    CVCLVariable<double> SAENGER2_POS_LON;
+    CVCLVariable<double> SAENGER2_POS_ALT; 
+	CVCLVariable<double> SAENGER2_ROT_X;
+    CVCLVariable<double> SAENGER2_ROT_Y;
+    CVCLVariable<double> SAENGER2_ROT_Z;
+
+	CVCLVariable<double> SAENGER_POS_LAT;
+    CVCLVariable<double> SAENGER_POS_LON;
+    CVCLVariable<double> SAENGER_POS_ALT; 
+	CVCLVariable<double> SAENGER_ROT_X;
+    CVCLVariable<double> SAENGER_ROT_Y;
+    CVCLVariable<double> SAENGER_ROT_Z;
+
+};
+
+}	// END NAMESPACE
Index: osgVisual/include/extLink/manip_extLink.h
===================================================================
--- osgVisual/include/extLink/manip_extLink.h	(revision 32)
+++ osgVisual/include/extLink/manip_extLink.h	(revision 32)
@@ -0,0 +1,103 @@
+#pragma once 
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include <visual_object.h>
+
+
+
+namespace osgVisual
+{ 
+
+/**
+ * \brief This class is a free spacemouse manipulator. It uses the 3DConnexion SpaceNavigator, which interface is implemented in manip_spaceMouse.h
+ * 
+ * @author Torben Dannhauer
+ * @date  Aug 2009
+ */ 
+class extLinkManipulator : public osgGA::MatrixManipulator
+{
+    public:
+		/**
+		 * \brief Constructor
+		 * 
+		 */ 
+        extLinkManipulator();
+
+		/**
+		 * \brief This function returns the classname.
+		 * 
+		 * @return Classname of this manipulator.
+		 */ 
+        virtual const char* className() const { return "extLinkManipulator"; }
+
+		/**
+		 * \brief Set the position of the matrix manipulator using a 4x4 Matrix.
+		 * 
+		 * @param matrix : Matrix to set.
+		 */ 
+        virtual void setByMatrix(const osg::Matrixd& matrix);
+
+		/**
+		 * \brief Set the position of the matrix manipulator using a 4x4 Matrix.
+		 * 
+		 * @param matrix : Inverse Matrix to set.
+		 */ 
+        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;
+
+		/**
+		 * \brief Start/restart the manipulator.
+		 * 
+		 * No further implementation
+		 * 
+		 * @param ea : GUI eventadapter to use for initialization. 
+		 * @param us : GUI actionadapter to use for initialization. 
+		 */ 
+        virtual void init(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us);
+
+        /** handle events, return true if handled, false otherwise.*/
+        virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us);
+
+        /** Get the keyboard and mouse usage of this manipulator.*/
+        virtual void getUsage(osg::ApplicationUsage& usage) const;
+
+		virtual void setAttachedObject( 
+			visual_object* object_ ) {attachedObject = object_;};
+
+		virtual osgVisual::visual_object* getAttachedObject() {return attachedObject.get();};
+
+
+    protected:
+		/**
+		 * \brief Destructor. Because it is protected, no explicit delete myPointer by external caller is possible.
+		 * This forces the class to be used with osg::ref pointers.
+		 */ 
+        virtual ~extLinkManipulator();
+
+		osg::Matrixd manipMatrix;
+	
+
+		osg::ref_ptr<osgVisual::visual_object> attachedObject;
+};
+
+}	// END NAMESPACE
+
Index: osgVisual/include/manip_ObjectMounted/manip_objectMounted.h
===================================================================
--- osgVisual/include/manip_ObjectMounted/manip_objectMounted.h	(revision 32)
+++ osgVisual/include/manip_ObjectMounted/manip_objectMounted.h	(revision 32)
@@ -0,0 +1,106 @@
+#pragma once 
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include <osgGA/MatrixManipulator>
+
+#include <osg/Quat>
+#include <osg/observer_ptr>
+
+#include <visual_object.h>
+
+
+namespace osgVisual
+{ 
+
+/**
+ * \brief This class is a free spacemouse manipulator. It uses the 3DConnexion SpaceNavigator, which interface is implemented in manip_spaceMouse.h
+ * 
+ * @author Torben Dannhauer
+ * @date  Aug 2009
+ */ 
+class objectMountedManipulator : public osgGA::MatrixManipulator
+{
+    public:
+		/**
+		 * \brief Constructor
+		 * 
+		 */ 
+        objectMountedManipulator();
+
+		/**
+		 * \brief This function returns the classname.
+		 * 
+		 * @return Classname of this manipulator.
+		 */ 
+        virtual const char* className() const { return "objectMountedManipulator"; }
+
+		/**
+		 * \brief Set the position of the matrix manipulator using a 4x4 Matrix.
+		 * 
+		 * @param matrix : Matrix to set.
+		 */ 
+        virtual void setByMatrix(const osg::Matrixd& matrix);
+
+		/**
+		 * \brief Set the position of the matrix manipulator using a 4x4 Matrix.
+		 * 
+		 * @param matrix : Inverse Matrix to set.
+		 */ 
+        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;
+
+		/**
+		 * \brief Start/restart the manipulator.
+		 * 
+		 * No further implementation
+		 * 
+		 * @param ea : GUI eventadapter to use for initialization. 
+		 * @param us : GUI actionadapter to use for initialization. 
+		 */ 
+        virtual void init(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us);
+
+        /** handle events, return true if handled, false otherwise.*/
+        virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us);
+
+        /** Get the keyboard and mouse usage of this manipulator.*/
+        virtual void getUsage(osg::ApplicationUsage& usage) const;
+
+		virtual void setAttachedObject( 
+			osgVisual::visual_object* object_ ) {attachedObject = object_;};
+
+		virtual osgVisual::visual_object* getAttachedObject() {return attachedObject.get();};
+
+
+    protected:
+		/**
+		 * \brief Destructor. Because it is protected, no explicit delete myPointer by external caller is possible.
+		 * This forces the class to be used with osg::ref pointers.
+		 */ 
+        virtual ~objectMountedManipulator();
+
+		osg::Matrixd manipMatrix;
+	
+
+		osg::ref_ptr<osgVisual::visual_object> attachedObject;
+};
+
+}	// END NAMESPACE
Index: osgVisual/include/manip_Spacemouse/manip_freeSpaceMouse.h
===================================================================
--- osgVisual/include/manip_Spacemouse/manip_freeSpaceMouse.h	(revision 32)
+++ osgVisual/include/manip_Spacemouse/manip_freeSpaceMouse.h	(revision 32)
@@ -0,0 +1,146 @@
+#pragma once 
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+// Spacemouse implementation
+#include <manip_spaceMouse.h>
+
+// OSG includes
+#include <osgGA/MatrixManipulator>
+#include <osgGA/GUIEventAdapter>
+#include <osgGA/GUIActionAdapter>
+
+#include <osg/Quat>
+#include <osg/Notify>
+#include <osg/BoundsChecking>
+#include <osg/observer_ptr>
+
+
+namespace osgVisual
+{ 
+
+/**
+ * \brief This class is a free spacemouse manipulator. It uses the 3DConnexion SpaceNavigator, which interface is implemented in manip_spaceMouse.h
+ * 
+ * @author Torben Dannhauer
+ * @date  Aug 2009
+ */ 
+class FreeManipulator : public osgGA::MatrixManipulator
+{
+    public:
+		/**
+		 * \brief Constructor
+		 * 
+		 * @param spacemouse : Pointer to the space mouse driver instance.
+		 */ 
+        FreeManipulator(SpaceMouse* spacemouse);
+
+		/**
+		 * \brief This function returns the classname.
+		 * 
+		 * @return Classname of this manipulator.
+		 */ 
+        virtual const char* className() const { return "FreeManipulator"; }
+
+		/**
+		 * \brief Set the position of the matrix manipulator using a 4x4 Matrix.
+		 * 
+		 * @param matrix : Matrix to set.
+		 */ 
+        virtual void setByMatrix(const osg::Matrixd& matrix);
+
+		/**
+		 * \brief Set the position of the matrix manipulator using a 4x4 Matrix.
+		 * 
+		 * @param matrix : Inverse Matrix to set.
+		 */ 
+        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;
+
+		/**
+		 * \brief Start/restart the manipulator.
+		 * 
+		 * No further implementation
+		 * 
+		 * @param ea : GUI eventadapter to use for initialization. 
+		 * @param us : GUI actionadapter to use for initialization. 
+		 */ 
+        virtual void init(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us);
+
+        /** handle events, return true if handled, false otherwise.*/
+        virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us);
+
+        /** Get the keyboard and mouse usage of this manipulator.*/
+        virtual void getUsage(osg::ApplicationUsage& usage) const;
+
+        void setTrackNode(osg::Node* node);
+        osg::Node* getTrackNode() {  return _trackNodePath.empty() ? 0 : _trackNodePath.back().get();  }
+
+        void computeNodeWorldToLocal(osg::Matrixd& worldToLocal) const;
+        void computeNodeLocalToWorld(osg::Matrixd& localToWorld) const;
+        bool validateNodePath() const;
+        osg::NodePath getNodePath() const;
+
+        typedef std::vector< osg::observer_ptr<osg::Node> >   ObserverNodePath;
+
+        ObserverNodePath      _trackNodePath;
+
+
+        void setTrackNodePath(const osg::NodePath& nodePath)
+        {
+           _trackNodePath.clear();
+           _trackNodePath.reserve(nodePath.size());
+           std::copy(nodePath.begin(), nodePath.end(), std::back_inserter(_trackNodePath));
+        }
+
+        osg::Vec3 getTrackNodeCenter();
+
+    protected:
+		/**
+		 * \brief Destructor. Because it is protected, no explicit delete myPointer by external caller is possible.
+		 * This forces the class to be used with osg::ref pointers.
+		 */ 
+        virtual ~FreeManipulator();
+
+		/**
+		 * \brief This function queries the space mouse driver instance and calculates the resultung movement of the manipulator.
+		 * 
+		 * @return : True if calculation was successful.
+		 */ 
+        bool calcMovement();
+
+		/**
+		 * Position of the manipulator.
+		 */ 
+        osg::Vec3d  _position;
+
+		/**
+		 * Attitude of the manipulator.
+		 */ 
+        osg::Quat   _attitude;
+
+		/**
+		 * Pointer to the space mouse driver instance.
+		 */ 
+        SpaceMouse* _spaceMouse;
+};
+
+}	// END NAMESPACE
Index: osgVisual/include/manip_Spacemouse/manip_nodeTrackerSpaceMouse.h
===================================================================
--- osgVisual/include/manip_Spacemouse/manip_nodeTrackerSpaceMouse.h	(revision 32)
+++ osgVisual/include/manip_Spacemouse/manip_nodeTrackerSpaceMouse.h	(revision 32)
@@ -0,0 +1,284 @@
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include <osgGA/MatrixManipulator>
+
+#include <osg/ObserverNodePath>
+#include <osg/Quat>
+#include <osg/Notify>
+#include <osg/Transform>
+
+// Spacemouse implementation
+#include <manip_spaceMouse.h>
+
+
+
+using namespace osgGA;
+
+namespace osgVisual
+{ 
+
+/**
+ * \brief This class provides a nodetracker manipulator controlled be a Space Navigator(SN) 3D mouse by 3DConnexion.
+ * 
+ * This nodetracker is similar to standard osg nodetracker manipulator with the difference,
+ * that the camera is not controlled by mouse but by the Space Navigator.
+ * 
+ * NodeTrackerSpaceMouse provides two modi: Using Space Navigator to control the camera movement, or using Space Navigator to control camera position.
+ * The first one holds camera position if the SN is released to it's origin position, the latter one returns camera position to origin if SN is released and returned to origin ("autohoming").
+ * You can switch between both modi with Space.
+ * 
+ * To toggle between the tracking modes NODE_CENTER, NODE_CENTER_AND_AZIM and NODE_CENTER_AND_ROTATION, press 'm'.
+ * 
+ * To toggle adjustment of angular velocity by distance to tracked node, press 'n'.
+ * 
+ * @author Torben Dannhauer
+ * @date  Apr 2010
+ */ 
+class NodeTrackerSpaceMouse : public osgGA::MatrixManipulator
+{
+    public:
+		/**
+		 * \brief Constructor
+		 * 
+		 * @param spacemouse : Pointer to the driver interface class.
+		 */ 
+        NodeTrackerSpaceMouse(SpaceMouse* spacemouse); 
+
+		/**
+		 * \brief This function returns the class name.
+		 * 
+		 * @return : Char array of the class name.
+		 */ 
+        virtual const char* className() const { return "NodeTrackerSpaceMouse"; }
+
+
+        void setTrackNodePath(const osg::NodePath& nodePath) { _trackNodePath.setNodePath(nodePath); }
+        void setTrackNodePath(const osg::ObserverNodePath& nodePath) { _trackNodePath = nodePath; }
+        osg::ObserverNodePath& getTrackNodePath() { return _trackNodePath; }
+
+        void setTrackNode(osg::Node* node);
+        osg::Node* getTrackNode();
+        const osg::Node* getTrackNode() const;
+
+		/**
+		 * Lists the tracking modes the nodetracker can provide.
+		 */ 
+        enum TrackerMode 
+        {
+            /** Track the center of the node's bounding sphere, but not rotations of the node.  
+              * For databases which have a CoordinateSystemNode, the orientation is kept relative the coordinate frame if the center of the node.
+              */
+            NODE_CENTER,
+            /** Track the center of the node's bounding sphere, and the azimuth rotation (about the z axis of the current coordinate frame).
+              * For databases which have a CoordinateSystemNode, the orientation is kept relative the coordinate frame if the center of the node.
+              */
+            NODE_CENTER_AND_AZIM,
+            /** Tack the center of the node's bounding sphere, and the all rotations of the node.
+              */
+            NODE_CENTER_AND_ROTATION
+        };
+        
+		/**
+		 * \brief Sets the tracking mode.
+		 * 
+		 * See TrackerMode
+		 * 
+		 * @param mode : Mode to set
+		 */ 
+        void setTrackerMode(TrackerMode mode);
+
+		/**
+		 * \brief Returns current tracking mode.
+		 * 
+		 * @return : Current tracking mode.
+		 */ 
+        TrackerMode getTrackerMode() const { return _trackerMode; }
+
+
+		/**
+		 * Lists the rotation modes the nodetracker provides.
+		 * 
+		 * At the moment, only ELEVATION_AZIM is supported, TRACKBALL is blocked to prevent software crashes.
+		 */ 
+        enum RotationMode 
+        {
+            /** Use a trackball style manipulation of the view direction w.r.t the tracked orientation.
+              */
+            TRACKBALL,
+            /** Allow the elevation and azimuth angles to be adjust w.r.t the tracked orientation.
+              */
+            ELEVATION_AZIM
+        };
+        
+		/**
+		 * \brief Sets the rotation mode.
+		 * 
+		 * See RotationMode
+		 * 
+		 * @param mode : Mode to set.
+		 */ 
+        void setRotationMode(RotationMode mode);
+
+		/**
+		 * \brief Returns curent rotation mode.
+		 * 
+		 * See RotationMode
+		 * 
+		 * @return : Current rotation 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 stereo convergence.*/
+        virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const { return osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE; }
+
+        /** Get the FusionDistanceValue. Used by SceneView for setting up stereo 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();
+
+        virtual void computeHomePosition();
+
+        /** 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 ~NodeTrackerSpaceMouse();
+
+        /** Reset the internal GUIEvent stack.*/
+        void flushMouseEventStack();
+
+        /** Add the current mouse GUIEvent to internal stack.*/
+        void addMouseEvent(const GUIEventAdapter& ea);
+
+        void computeNodeCenterAndRotation(osg::Vec3d& center, osg::Quat& rotation) 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();
+
+		/**
+		 * \brief Retieves the movements from driver interface and calculates manipulator movements.
+		 * 
+		 * @return : True on success.
+		 */ 
+		bool calcMovementSpaceMouse();
+        
+        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();
+
+		/** Empty */
+        void clampOrientation();
+
+
+        // Internal event stack comprising last two mouse events.
+        osg::ref_ptr<const GUIEventAdapter> _ga_t1;
+        osg::ref_ptr<const GUIEventAdapter> _ga_t0;
+
+		/**
+		 * Pointer to node to track.
+		 */ 
+        osg::observer_ptr<osg::Node> _node;
+
+        osg::ObserverNodePath   _trackNodePath;
+
+		/**
+		 * Current Trackermode. See TrackerMode. 
+		 */ 
+        TrackerMode             _trackerMode;
+
+		/**
+		 * Curent Rotation Mode. See RotationMode.
+		 */ 
+        RotationMode            _rotationMode;
+
+        bool                    _thrown;
+
+		/**
+		 * Indicates if auto homing is enabled.
+		 */ 
+		bool					_autohoming;
+		
+		/**
+		 * Indiccates if nodetracker is initialized.
+		 */ 
+		bool					_ah_init;
+
+		/**
+		 * Indicates if angular velocity is adjusted by distance to tracked node.
+		 */ 
+		bool					_distanceDependendAV;
+
+        osg::Quat               _nodeRotation;
+        osg::Quat               _rotation;
+        float                   _distance;
+		float					_lastDistance;
+
+		/** 
+		 * Pointer to Space Navigator interfacce class.
+		 */ 
+		SpaceMouse* _spaceMouse;
+
+		/**
+		 * Discances in translation and rotation of Space Navigator. Used for non-autohoming modus.
+		 */ 
+		double TZ, RX, RY, RZ;
+
+};
+
+}	//	END NAMESPACE
+
Index: osgVisual/include/manip_Spacemouse/manip_spaceMouse.h
===================================================================
--- osgVisual/include/manip_Spacemouse/manip_spaceMouse.h	(revision 32)
+++ osgVisual/include/manip_Spacemouse/manip_spaceMouse.h	(revision 32)
@@ -0,0 +1,92 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+
+namespace osgVisual
+{ 
+
+/**
+ * \brief This class interfaces osg to the device driver of 3Dconnexions Space Navigator
+ * 
+ * @author Marius Heise
+ * @date  Apr 2009
+ */ 
+class SpaceMouse
+{
+public:
+	/**
+	 * \brief Constructor
+	 * 
+	 */ 
+    SpaceMouse();
+
+	/**
+	 * \brief Destructor
+	 * 
+	 * @return 
+	 */ 
+    virtual ~SpaceMouse();
+
+	/**
+	 * \brief This function initializes the device driver.
+	 * 
+	 * @return : 1=sucess, 0=failure.
+	 */ 
+    int initialize();
+
+	/**
+	 * \brief This function shuts the device driver down.
+	 * 
+	 */ 
+    void shutdown();
+
+	/**
+	 * \brief This function writes the detected translation of all three axes to the specified variables.
+	 * 
+	 * @param dX : delta translation along X axis.
+	 * @param dY : delta translation along Y axis.
+	 * @param dZ : delta translation along Y axis.
+	 * @return : 1=sucess, 0=failure.
+	 */ 
+    int getTranslations(double& dX, double& dY, double& dZ);
+
+	/**
+	 * \brief This function writes the detected rotation of all three axes to the specified variables.
+	 * 
+	 * @param dX : delta translation along X axis.
+	 * @param dY : delta translation along Y axis.
+	 * @param dZ : delta translation along Y axis.
+	 * @return : 1=sucess, 0=failure.
+	 */ 
+    int getRotations(double& dX, double& dY, double& dZ);
+
+private:
+	/**
+	 * \brief Device driver class
+	 * 
+	 * @author Unknown/Marius Heise
+	 * @date  Apr 2009
+	 */ 
+	class SpaceMouseImpl;
+
+	/**
+	 * Pointer to the device driver class.
+	 */ 
+    SpaceMouseImpl* _spaceMouseImpl;
+};
+
+}	// END NAMESPACE
Index: osgVisual/include/object/object_updater.h
===================================================================
--- osgVisual/include/object/object_updater.h	(revision 32)
+++ osgVisual/include/object/object_updater.h	(revision 32)
@@ -0,0 +1,101 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include <osg/Node>
+#include <osg/Notify>
+#include <visual_object.h>
+
+namespace osgVisual
+{ 
+class visual_object;	// Forward declaration
+
+
+/**
+ * \brief This class is the base class for visual_object updater.
+ * 
+ * This base implementation updates the object position with the slotnames
+ *  object_->getName()+"_POS_LAT", object_->getName()+"_POS_LON", object_->getName()+"_POS_ALT",
+ * object_->getName()+"_ROT_X", object_->getName()+"_ROT_Y", object_->getName()+"_ROT_Z", 
+ * 
+ * To implement custom updaters, please derive from this class and overwrite the functions preUpdate(..) and postUpdate(..).
+ * Take care to call nested preUpdater and postUpdater to allow updater chains.
+ * 
+ * @author Torben Dannhauer
+ * @date  Apr 2010
+ */ 
+class object_updater : public osg::Node
+{
+public:
+	/**
+	 * \brief Empty constructor
+	 * 
+	 * @param object_ : Pointer to the object, calling the constructor (currently not used)
+	 */ 
+	object_updater(osgVisual::visual_object* object_ );
+
+	/**
+	 * \brief Empty destructor
+	 * 
+	 * @return 
+	 */ 
+	virtual ~object_updater(void);
+
+	/**
+	 * \brief This function is called by visual_object before rendering (preFrame).
+	 * 
+	 * This updater function should be used to update the objects state like size, position, attitude etc.
+	 * 
+	 * @param object_ : Pointer to the object calling this updater.
+	 */ 
+	virtual void preUpdate(osgVisual::visual_object* object_ );
+
+	/**
+	 * \brief This function is called by visual_object after rendering (postFrame).
+	 * 
+	 * This updater function should be used for all actions which require the object status of that frame like HAT/HOT etc.
+	 * 
+	 * @param object_ : Pointer to the object calling this updater.
+	 */ 
+	virtual void postUpdate(osgVisual::visual_object* object_);
+
+	/**
+	 * \brief Returns pointer to this updater.
+	 * 
+	 * This function is used for updater list management.
+	 * 
+	 * @return : Pointer to this updater.
+	 */ 
+	object_updater* getPointer(){return this;};
+
+	/**
+	 * \brief This function adds an object_updater as nested updater.
+	 * 
+	 * The nested Updater will be executed in pre and post traversal after this updater.
+	 * 
+	 * @param updater_ 
+	 */ 
+	void addUpdater( object_updater* updater_ );
+
+protected:
+	/**
+	 * Pointer to nested updater.
+	 */ 
+	osg::ref_ptr<object_updater> updater;
+
+};
+
+}	// END NAMESPACE
Index: osgVisual/include/object/visual_object.h
===================================================================
--- osgVisual/include/object/visual_object.h	(revision 32)
+++ osgVisual/include/object/visual_object.h	(revision 32)
@@ -0,0 +1,454 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include <osg/MatrixTransform>
+#include <osg/Matrix>
+#include <osg/NodeCallback>
+#include <osg/CoordinateSystemNode>
+#include <osg/Notify>
+
+#include <osgDB/ReadFile>
+#include <osgDB/FileUtils>
+
+#include <osgText/Text>
+
+#include <osgGA/MatrixManipulator>
+
+#include <object_updater.h>
+#include <visual_dataIO.h>
+#include <visual_util.h>
+
+#include <string.h>
+#include <iostream>
+
+namespace osgVisual
+{
+class visual_objectPositionCallback;
+class object_updater;
+}
+
+/**
+ * \brief Standard namespace of osgVisual
+ * 
+ */ 
+namespace osgVisual
+{
+
+/**
+ * \brief This class provides object management for displaying objects in the 3D scene.
+ * 
+ * It allows to control an object in position, attitude and size. To control this object automatically, use object_updaters.
+ * To object itself is invisible, you have to connect a visible geometry to this object.
+ * To display geometries, it provides function to load geometries by geometry pointer or filename.
+ * To correct wrong coordinate frames in the geometries to display,
+ * you can configure a geometry off set in translation in translation and rotation
+ * For object mounted camera, you can configure the camera offset in rotation and translation.
+ * 
+ * Derive from this class to implement your custom visual_object.
+ * 
+ * \todo: Labelmanagement to allow to display a label attached to this object: set/unset label, size, color, offset to object, LOD for label display.
+ * 
+ * @author Torben Dannhauer
+ * @date  Apr 2010
+ */ 
+class visual_object  : public osg::MatrixTransform
+{
+public:
+	/**
+	 * \brief Constuctor: Adds this object to the scenegraph,
+	 * initializes this object and installs the callback to calculate its local to world matrix
+	 * 
+	 * @param sceneRoot_ : Scenegraph to add this object to.
+	 * @param nodeName_ : Name of this object, is used for further identification.
+	 */ 
+	visual_object( osg::CoordinateSystemNode* sceneRoot_, std::string nodeName_ );
+	
+	/**
+	 * \brief Empty destructor.
+	 * 
+	 */ 
+	~visual_object();
+
+
+/** @name Position and attitude
+ *  These functions control objects position and attitude
+ */
+/*@{*/
+
+	/**
+	 * \brief This function updates the objects position and attitude. 
+	 * 
+	 * @param lat_ : Latitude to set.
+	 * @param lon_ : Longitude to set.
+	 * @param alt_ : Altitude over ellipsoid to set.
+	 * @param azimuthAngle_psi_ : Psi angle () to set. 
+	 * @param pitchAngle_theta_ : Theta angle () to set.
+	 * @param bankAngle_phi_ : Phi angle () to set.
+	 * 
+	 * All angles are rad!
+	 * 
+	 * \todo: Erklären welche Wirkung die drei Winkel haben.
+	 */ 
+	void setNewPositionAttitude( double lat_, double lon_, double alt_, double azimuthAngle_psi_, double pitchAngle_theta_, double bankAngle_phi_ );
+	
+	/**
+	 * \brief This function updates the objects position.
+	 * 
+	 * @param lat_ : Latitude to set.
+	 * @param lon_ : Longitude to set.
+	 * @param alt_ : Altitude over ellipsoid to set.
+	 */ 
+	void setNewPosition( double lat_, double lon_, double alt_ );
+
+	/**
+	 * \brief This function updates the objects attitude.
+	 * 
+	 * @param azimuthAngle_psi_ : Psi angle () to set. 
+	 * @param pitchAngle_theta_ : Theta angle () to set.
+	 * @param bankAngle_phi_ : Phi angle () to set.
+	 * 
+	 * All angles are rad!
+	 * 
+	 * \todo: Erklären welche Wirkung die drei Winkel haben.
+	 */ 
+	void setNewAttitude( double azimuthAngle_psi_, double pitchAngle_theta_, double bankAngle_phi_ );
+/*@}*/
+/** @name Geometry management
+ *  These functions control which geometry visual_object should display.
+ */
+/*@{*/
+	/**
+	 * \brief This function configures the geometry offset
+	 * 
+	 * @param rotX_ : Geometry rotation along the X axis.
+	 * @param rotY_ : Geometry rotation along the Y axis.
+	 * @param rotZ_ : Geometry rotation along the Z axis.
+	 * 
+	 * It rotates along the axis of the visual_object, not along the geometry axis!
+	 * 
+	 * \todo: Erklären, welche Achsen welche Richtung sind.
+	 */ 
+	void setGeometryOffset( double rotX_, double rotY_, double rotZ_ );
+
+	/**
+	 * \brief This function set the scale to all 3 axis. Use this function to scale objects without distortion.
+	 * 
+	 * @param scale_ : Scale to set for every axis.
+	 */ 
+	void setScale( double scale_ );
+
+	/**
+	 * \brief This function sets the scale factor for all 3 axis independently.
+	 * 
+	 * @param scaleX_ : Scalefactor along X axis.
+	 * @param scaleY_ : Scalefactor along Y axis.
+	 * @param scaleZ_ : Scalefactor along Z axis.
+	 */ 
+	void setScale( double scaleX_, double scaleY_, double scaleZ_ );
+
+	/**
+	 * \brief this function loads a geometry from a file and connects it to this visual_object. All filetypes OSG is aware of can be used.
+	 * 
+	 * @param filename_ : File to load and connect.
+	 * @return : True if loading was successfully
+	 */ 
+	bool loadGeometry( std::string filename_);
+
+	/**
+	 * \brief This function connects a geometry to this visual_object.
+	 * 
+	 * @param geometry_ : Geometry to connect.
+	 * @return : True if successful.
+	 */ 
+	bool setGeometry(osg::Node* geometry_);
+
+	/**
+	 * \brief This function disconnects the connected object.
+	 * 
+	 */ 
+	void unsetGeometry();
+
+	/**
+	 * \brief This function returns the pointer to the loaded geometry.
+	 *
+	 * It returns NULL if no geometry is connected.
+	 * 
+	 * @return : Pointer to the geometry if loaded, otherwise NULL.
+	 */ 
+	osg::Node* getGeometry(){return geometry;}
+
+/*@}*/
+/** @name Object updater
+ *  These functions control objects updater.
+ */
+/*@{*/
+	/**
+	 * \brief This function adds an Updater to this object.
+	 * 
+	 * The updaters postUpdate und preUpdate functions are executed during eventTraversal traversal.
+	 * The preUdate is executed before the objects matrix is calculated from position, the postUpdate is executed after the matrix calculation. 
+	 * 
+	 * @param updater_ : Updater to add.
+	 */ 
+	void addUpdater( object_updater* updater_ );
+
+	/**
+	 * \brief Removes all updater from the visual_object. 
+	 * 
+	 */ 
+	void clearAllUpdater();
+
+	/**
+	 * \brief This function returns a vector containing pointer to all updater of the object.
+	 * 
+	 * @return : vector with pointers to all object_updater.
+	 */ 
+	std::vector<object_updater*> getUpdaterList();
+
+/*@}*/
+/** @name Camera management
+ *  These functions control the camera attitude and position.
+ */
+/*@{*/
+	/**
+	 * \brief This function returns the camera matrix of the scene camera.
+	 * 
+	 * @return : Camera matrix
+	 */ 
+	osg::Matrixd& getCameraMatrix() {return cameraMatrix;};
+
+	/**
+	 * \brief This function rotates and translate the objects camera position.
+	 * 
+	 *  The translation coordinate frame is object fixed, the rotation coordinate frame is camera fixed.
+	 * 
+	 * @param x_ : Translation along object's x axis.
+	 * @param y_ : Translation along object's y axis.
+	 * @param z_ : Translation along object's z axis (positive axis points downwards).
+	 * @param rotX_ : Rotation around camera's x axis in [rad].
+	 * @param rotY_ : Rotation around camera's y axis in [rad]. 
+	 * @param rotZ_ : Rotation around camera's z axis in [rad].
+	 */ 
+	void setCameraOffset(double x_, double y_, double z_, double rotX_, double rotY_, double rotZ_);
+
+	/**
+	 * \brief This function configures the camera offset rotation in that object.
+	 * 
+	 * The coordinate frame for this rotation is camera fixed, NOT object fixed 
+	 * (e.g. rotation around x axis (bank) rotatates always around the cameras visual axis, 
+	 * independent from pitch or azimuth)
+	 * 
+	 * @param rotX_ : Rotation around camera's x axis in [rad].
+	 * @param rotY_ : Rotation around camera's y axis in [rad]. 
+	 * @param rotZ_ : Rotation around camera's z axis in [rad].
+	 */ 
+	void setCameraOffsetRotation(double rotX_, double rotY_, double rotZ_);
+
+	/**
+	 * \brief This function configures the camera offset translation in that object.
+	 * 
+	 * @param x_ : Translate in longitudinal direction. x>0: Camera is in front if the ob
+	 * ject, x<0 behind the object.
+	 * @param y_ : Translate in transversal direction. x>0: Camera is right of the object, x<0 left of the object.
+	 * @param z_ : Translate in vertical direction. x>0: Camera is below the Object, x<0 above the object. (Positiv Z axis points downwards!)
+	 */ 
+	void setCameraOffsetTranslation( double x_, double y_, double z_);
+
+/*@}*/
+/** @name Label management
+ *  These functions allow to display labels attached to visual_object.
+ */
+/*@{*/
+	/**
+	 * \brief This Function removes all labels attached to this object.
+	 * 
+	 */ 
+	void clearLabels();
+
+	/**
+	 * \brief This function adds a label to the object.  
+	 * 
+	 * @param idString_ : Identifiy string, which is used to find and manipulate the label later.
+	 * @param label_ : Message to display as label.
+	 * @param color_ : Textcolor. Defaults to white.
+	 * @param offset_ : Offset im meter in the objects local coordinate frame
+	 */ 
+	void addLabel(std::string idString_, std::string label_, osg::Vec4 color_ = osg::Vec4(1.0f,1.0f,1.0f,1.0f), osg::Vec3 offset_ = osg::Vec3(0,0,0));
+	
+	/**
+	 * \brief This function removes the specified label.
+	 * 
+	 * @param idString_ : idString of the label to remove.
+	 * @return : True if a label with the specified idString_ was found, false if no label with that idString was found.
+	 */ 
+	bool removeLabel(std::string idString_);
+
+	/**
+	 * \brief Update the message of the label specified with the idString_.
+	 * 
+	 * @param idString_ : idString of the label to update.
+	 * @param label_ : New message to set.
+	 * @return : Return true if the specified label was found, return false if the specified label was not found.
+	 */ 
+	bool updateLabelText(std::string idString_, std::string label_);
+
+	/**
+	 * \brief returns the message string of the specified label.
+	 * 
+	 * @param idString_ : idString of the label to return message.
+	 * @return : Pointer to the Label (osgText::Text) if found, otherwise NULL
+	 */ 
+	osgText::Text* getLabel(std::string idString_); 
+
+	/**
+	 * \brief This functions sets the draw mode of the specified label.
+	 * 
+	 * @param idString_ : Label to configure.
+	 * @param drawAsOverlay : Set true to draw the label always over the scene. Set false to draw it 3D into the scene (maybe occluded party by objects)
+	 * @return : Return true if the specified label was found, return false if the specified label was not found. 
+	 */ 
+	bool setDrawLabelAsOverlay(std::string idString_, bool drawAsOverlay);
+
+	/**
+	 * \brief This function returns if the specified label is configured as overlay.
+	 * 
+	 * @param idString_ : Label to configure.
+	 * @return : True if configured as overlay, false if configured for simple draw
+	 */ 
+	bool getDrawLabelAsOverlay(std::string idString_ );
+/*@}*/
+
+protected:
+	/**
+	 * \brief Callback class for updating the visual_object while traversing the scenegraph in the event stage.
+	 * 
+	 * @author Torben Dannhauer
+	 * @date  Jul 2009
+	 */ 
+	class visual_objectPositionCallback : public osg::NodeCallback
+	{
+	public:
+		/**
+		 * \brief Constructor: Empty
+		 * 
+		 */ 
+		visual_objectPositionCallback()
+		{
+		   // nothing
+		}
+	    
+		/**
+		 * \brief This function is executed by the callback during update traversal.
+		 * 
+		 */ 
+		virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
+	};
+
+	osg::Vec3 upVector;
+	
+// Position
+	/**
+	 * Latitude of the object.
+	 */ 
+	double lat;
+
+	/**
+	 * Longitude of the object.
+	 */ 
+	double lon;
+
+	/**
+	 * Altitude of the object over the ellipsoid. 
+	 */ 
+	double alt;
+
+// Attitude
+	/**
+	 * Azimuth angle (Rotation along Z axis, "heading") of the object 
+	 */ 
+	double azimuthAngle_psi;
+
+	/**
+	 * Pitch ("nose relative to horizon") angle of the object 
+	 */ 
+	double pitchAngle_theta;
+
+	/**
+	 * Bank angle of the object.
+	 */ 
+	double bankAngle_phi;
+
+// Scale
+	/**
+	 * Object scale along X axis.
+	 */ 
+	double scaleX;
+
+	/**
+	 * Object scale along Y axis.
+	 */ 
+	double scaleY;
+
+	/**
+	 * Object scale along Z axis.
+	 */ 
+	double scaleZ;
+
+// Camera offset
+	/**
+	 * This is the matrix containing the camera position for the  manipulators
+	 */ 
+	osg::Matrixd cameraMatrix;
+
+	/**
+	 * This is the camera matrix containing offset translation
+	 */ 
+	osg::Matrix cameraTranslationOffset;
+
+	/**
+	 * This is the camera matrix containing offset rotation
+	 */ 
+	osg::Matrix cameraRotationOffset;
+
+	/**
+	 * Geometry offset (If a model's coordinate system has wrong orientation.)
+	 */ 
+	osg::Quat geometry_offset_rotation;	
+
+	/**
+	 * Pointer to the geometry, associated with this object.
+	 */ 
+	osg::ref_ptr<osg::Group> geometry;
+
+	/**
+	 * Pointer to the updater class which updates this visual_object.
+	 */ 
+	osg::ref_ptr<object_updater> updater;
+
+// Labels
+	/**
+	 * Pointer to the labels group which holds all labels associated with this object.
+	 */ 
+	osg::ref_ptr<osg::Geode> labels;
+
+	// Friend classes
+	friend class visual_objectPositionCallback; // To allow the callback access to all member variables.
+	friend class object_updater;	// To allow updater to modify all members.
+
+};
+
+} // END NAMESPACE
Index: osgVisual/include/sky_Silverlining/skySilverLining_AtmosphereReference.h
===================================================================
--- osgVisual/include/sky_Silverlining/skySilverLining_AtmosphereReference.h	(revision 32)
+++ osgVisual/include/sky_Silverlining/skySilverLining_AtmosphereReference.h	(revision 32)
@@ -0,0 +1,57 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+ * 
+ * This file is based on the OSG example of the Silverlining SDK:
+ * Copyright (c) 2008 Sundog Software, LLC. All rights reserved worldwide.
+*/
+
+#include <SilverLining.h>
+#include <osg/Referenced>
+
+
+namespace osgVisual
+{
+
+/**
+ * \brief This class holds the pointer to the atmosphere object and is bound to the rendering camera. 
+ * 
+ * This way all rendered elements can access the atmosphere. It also mirrors the atmosphere's init status 
+ * to prevent crashing by access to the uninitialized object.
+ * 
+ * @author Torben Dannhauer
+ * @date  Sep 2009
+ */ 
+class skySilverLining_atmosphereReference : public osg::Referenced
+{
+public:
+	/**
+	 * Pointer to the atmosphere object.
+	 */ 
+	SilverLining::Atmosphere *atmosphere;
+
+	/**
+	 * This flag indicates whether the atmosphere is initialized and the pointer is valid.
+	 */ 
+	bool atmosphereInitialized;
+
+	/**
+	 * \brief Constructor to init the values.
+	 * 
+	 */ 
+	skySilverLining_atmosphereReference() : atmosphereInitialized(false), atmosphere(0) {};
+};
+
+}	// END NAMESPACE
Index: osgVisual/include/sky_Silverlining/skySilverLining_ProjectionMatrixCallback.h
===================================================================
--- osgVisual/include/sky_Silverlining/skySilverLining_ProjectionMatrixCallback.h	(revision 32)
+++ osgVisual/include/sky_Silverlining/skySilverLining_ProjectionMatrixCallback.h	(revision 32)
@@ -0,0 +1,297 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+ * 
+ * This file is based on the OSG example of the Silverlining SDK:
+ * Copyright (c) 2008 Sundog Software, LLC. All rights reserved worldwide.
+*/
+
+#include <SilverLining.h>
+#include <osg/Camera>
+#include <osg/CullSettings>
+#include <osgAnimation/Animation>
+#include <skySilverLining_skyDrawable.h>
+#include <visual_util.h>
+
+
+
+namespace osgVisual
+{
+
+/**
+ * \brief This class intercepts OSG's method for automatically computing the near and far clip planes, taking into
+    account SilverLining's objects in the scene (sky box, clouds, and possibly an atmospheric limb.)
+ * 
+ * @todo : Create interface to control nearplane while tracking near plane.
+ * 
+ * @author Torben Dannhauer
+ * @date  Sep 2009
+ */ 
+class skySilverLining_projectionMatrixCallback : public osg::CullSettings::ClampProjectionMatrixCallback 
+{
+public:
+	/**
+	 * \brief Constructor : Initializes the attributes with valid values.
+	 * 
+	 * @todo : why is CSN required.
+	 * 
+	 * @param atm : Pointer to the atmosphere object.
+	 * @param cam : Pointer to the rendering camera.
+	 * @param csn_ : Pointer to the coordinatesystemode.
+	 */ 
+	skySilverLining_projectionMatrixCallback(SilverLining::Atmosphere *atm, osg::Camera *cam, osg::CoordinateSystemNode *csn_) : osg::CullSettings::ClampProjectionMatrixCallback(),
+        atmosphere(atm), camera(cam), csn(csn_), skyDrawable(0), minFar(90000), maxNear(2)
+    {
+        stockCullVisitor = osgUtil::CullVisitor::create();
+		//stockCullVisitor->setNearFarRatio( 0.00005 );
+
+		samplerClipPlanes = new osgAnimation::Vec2LinearSampler;
+		keys = samplerClipPlanes->getOrCreateKeyframeContainer();
+
+		//											Flughöhe				near		far
+		keys->push_back(osgAnimation::Vec2Keyframe(      0.0, osg::Vec2(     1.0,     80000.0)));
+		keys->push_back(osgAnimation::Vec2Keyframe(     50.0, osg::Vec2(     5.0,     90000.0)));
+	//keys->push_back(osgAnimation::Vec2Keyframe(    500.0, osg::Vec2(     5.0,    100000.0)));
+	//keys->push_back(osgAnimation::Vec2Keyframe(   1000.0, osg::Vec2(    10.0,    100000.0)));
+	//keys->push_back(osgAnimation::Vec2Keyframe(  10000.0, osg::Vec2(   100.0,   1000000.0)));
+	//keys->push_back(osgAnimation::Vec2Keyframe(1000000.0, osg::Vec2(100000.0, 200000000.0)));
+		keys->push_back(osgAnimation::Vec2Keyframe(    500.0, osg::Vec2(     5.0,    100000.0)));
+		keys->push_back(osgAnimation::Vec2Keyframe(   1000.0, osg::Vec2(    10.0,    100000.0)));
+		keys->push_back(osgAnimation::Vec2Keyframe(  10000.0, osg::Vec2(   50.0,   1000000.0)));
+		keys->push_back(osgAnimation::Vec2Keyframe(1000000.0, osg::Vec2(100.0, 200000000.0)));
+
+    }
+
+	/**
+	 * \brief This functions sets the pointer to the skyDrawable. This pointer is requiered to adjust the skybox size.
+	 * 
+	 * @param sd : Pointer to the skyDrawable to store.
+	 */ 
+	void setSkyDrawable(skySilverLining_skyDrawable *sd) {skyDrawable = sd;}
+
+protected:
+	/**
+	 * \brief Implementation for float values to clamp the projection matrix.
+	 * 
+	 * @param projection : Projection Matrix.
+	 * @param znear : Near value of the projection matrix.
+	 * @param zfar : Far value of the projection matrix.
+	 * @return : True if successful
+	 */ 
+    bool clampProjectionMatrixImplementation(osg::Matrixf& projection, double& znear, double& zfar) const
+    {
+   	   computeNearFar( znear, zfar );
+	   //OSG_NOTIFY( osg::ALWAYS ) << "znear: " << znear << ", zfar: " << zfar << std::endl;
+
+	   if (skyDrawable)
+	   {
+	       skyDrawable->setSkyboxSize(((zfar - znear) * 0.5 + znear) * 2.0);
+	   }
+		
+	   double fovy, ar, zn, zf;
+       camera->getProjectionMatrixAsPerspective(fovy, ar, zn, zf);
+	   camera->setProjectionMatrixAsPerspective(fovy, ar, znear, zfar);
+
+		return true;
+    }
+
+	/**
+	 * \brief Implementation for double values to clamp the projection matrix.
+	 * 
+	 * @param projection : Projection Matrix.
+	 * @param znear : Near value of the projection matrix.
+	 * @param zfar : Far value of the projection matrix.
+	 * @return : True if successful
+	 */ 
+    bool clampProjectionMatrixImplementation(osg::Matrixd& projection, double& znear, double& zfar) const
+    {
+	   computeNearFar( znear, zfar );
+	   //OSG_NOTIFY( osg::ALWAYS ) << "znear: " << znear << ", zfar: " << zfar << std::endl;
+
+	   if (skyDrawable)
+	   {
+	       skyDrawable->setSkyboxSize(((zfar - znear) * 0.5 + znear) * 2.0);
+	   }
+		
+	   double fovy, ar, zn, zf;
+       camera->getProjectionMatrixAsPerspective(fovy, ar, zn, zf);
+	   //OSG_NOTIFY( osg::ALWAYS ) << "znear: " << znear << ", zfar: " << zfar << ", zn: " << zn << std::endl; 
+	   camera->setProjectionMatrixAsPerspective(fovy, ar, znear, zfar);
+
+		return true;
+    }
+
+	/**
+	 * \brief This function computes the near and far value against the cloud objects of silverlining.
+	 * 
+	 * @param znear : Referenced to store the calculated near value into.
+	 * @param zfar : Referenced to store the calculated far value into.
+	 */ 
+    void computeNearFarClouds(double &znear, double &zfar) const
+    {
+		const double fudge = 5000.0;
+        double minDist = 1E10; double maxDist = -1E10;
+
+		// Retrieve all atmosphere objects.
+        std::vector<SilverLining::ObjectHandle> &objects = atmosphere->GetObjects();
+		int size = objects.size();
+		
+		osg::Vec3d eye, dirVector, upVector;
+		camera->getViewMatrixAsLookAt(eye,dirVector,upVector); // Get XYZ from camera
+		//osg::Vec3d camPos = camera->getViewMatrix().getTrans();
+		osg::Vec3d camPos = eye;
+        osg::Vec3d up = camPos;
+        up.normalize();
+        osg::Vec3d down = up * -1.0;
+
+		double dToOrigin = camPos.length();
+
+		// Calculations if atmopshere is rendered from space
+		bool hasLimb = atmosphere->GetConfigOptionBoolean("enable-atmosphere-from-space");
+		if (hasLimb)
+		{
+			// Compute distance to edge of atmospheric limb
+			double earthRadius = atmosphere->GetConfigOptionDouble("earth-radius-meters");
+			double atmosphereHeight = earthRadius + atmosphere->GetConfigOptionDouble("atmosphere-height");
+			double atmosphereThickness = atmosphere->GetConfigOptionDouble("atmosphere-scale-height-meters") + earthRadius;
+			if (dToOrigin > atmosphereThickness) // Bail if limb not rendered
+			{
+				double dToLimbEdge = sqrt(dToOrigin * dToOrigin + atmosphereHeight * atmosphereHeight);
+				maxDist = dToLimbEdge;
+				double dToLimbBase = sqrt(dToOrigin * dToOrigin + earthRadius * earthRadius);
+				minDist = dToLimbBase;
+			}
+		}
+
+		// Walk through all objects and check if they influence the near plane or far plane
+        std::vector<SilverLining::ObjectHandle>::iterator it;
+        for (it = objects.begin(); it != objects.end(); it++)
+        {
+            float ox, oy, oz;
+            atmosphere->GetObjectPosition(*it, ox, oy, oz);
+            osg::Vec3d oPos(ox, oy, oz);
+            double oHeight = oPos.length();
+            osg::Vec3d testVec = camPos;
+			// Compare distance to origin of the camera and the object. wenn objecte nah aneinander: 
+			//vertikal shiften, um eine erkennbare Distanz errechnen zu können.
+            if (dToOrigin > oHeight)
+            {
+                testVec = camPos + down * 100.0; // 100 for floating point precision problems
+            }
+            else
+            {
+                testVec = camPos + up * 100.0;
+            }
+            
+            const double farFarAway = 500000;
+
+            double dist = atmosphere->GetObjectDistance(*it, testVec.x(), testVec.y(), testVec.z(),
+				(float)camPos.x(), (float)camPos.y(), (float)camPos.z());
+
+
+            if (dist < farFarAway) // an intersection was found
+            {
+                if (dist < minDist) minDist = dist;
+                if (dist > maxDist) maxDist = dist;
+            }
+        }	// For (all objects) END
+
+        double fovy, ar, zn, zf;
+        camera->getProjectionMatrixAsPerspective(fovy, ar, zn, zf);
+        double halfFovx = (fovy * ar) * 0.5;
+        minDist *= cos(halfFovx * (3.14159265 / 180.0));
+
+        znear = minDist - fudge;
+        zfar = maxDist + fudge;
+
+		//clamp the near plane if low above ground.
+	    double x,y,z,hat;
+	    util::getXYZofCamera( camera, x, y, z );
+		if( util::queryHeightAboveTerrainInWorld( hat, csn, x, y, z ) )
+		{
+			if (hat < 80 )	
+			{
+				znear = maxNear;
+			}
+		}
+	    //OSG_NOTIFY( osg::ALWAYS ) << "Near: " << znear << ", Far: " << zfar << std::endl;
+    }
+
+	void computeNearFar( double& near_, double& far_ ) const
+	{
+		double x,y,z,hat;
+		near_ = 2;
+		far_ = 125000;
+	    util::getXYZofCamera( camera, x, y, z );
+		if( util::queryHeightAboveTerrainInWorld( hat, csn, x, y, z ) )
+		{
+			osg::Vec2 planesNearFar;
+			samplerClipPlanes->getValueAt(hat, planesNearFar);
+
+			near_ = planesNearFar.x();
+			far_  = planesNearFar.y();
+
+			//OSG_NOTIFY( osg::ALWAYS ) << "hat: " << hat << ", near: " << near_ << ", far: " << far_ << std::endl;
+		} // IF HAT END
+		else 
+			OSG_NOTIFY( osg::FATAL ) << "ERROR: Unable to Compute NearFar!" << std::endl;
+
+		if (near_ < 0.5 ) near_ = 0.5;
+	}
+
+    
+	/**
+	 * Pointer to the Cullvisitor which applies the projection matrix.
+	 */ 
+	osgUtil::CullVisitor *stockCullVisitor;
+
+	/**
+	 * Pointer to silverlinings atmosphere instance.
+	 */ 
+    SilverLining::Atmosphere *atmosphere;
+
+	/**
+	 * Pointer to the camera on which the callback is installed
+	 */ 
+    osg::Camera *camera;
+
+	/**
+	 * Pointer to the skyDrawable
+	 */ 
+	skySilverLining_skyDrawable *skyDrawable;
+
+	/**
+	 * ?
+	 * @todo: wofür ist diese variable nötig?
+	 */ 
+	osg::CoordinateSystemNode *csn;
+
+
+	osg::ref_ptr<osgAnimation::Vec2LinearSampler> samplerClipPlanes;
+	osg::ref_ptr<osgAnimation::Vec2KeyframeContainer> keys;
+
+	/**
+	 * Minimal far distance. The far plane is never nearer than this value.
+	 */ 
+	double minFar;
+
+	/**
+	 * Maximal near distance. The near plane is never farther than this value. 
+	 * It is used to clamp the near plane on a fix near value if the camera is low above ground
+	 */ 
+	double maxNear;
+};
+
+}	// END NAMESPACE
Index: osgVisual/include/sky_Silverlining/skySilverLining_cloudsDrawable.h
===================================================================
--- osgVisual/include/sky_Silverlining/skySilverLining_cloudsDrawable.h	(revision 32)
+++ osgVisual/include/sky_Silverlining/skySilverLining_cloudsDrawable.h	(revision 32)
@@ -0,0 +1,102 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+ * 
+ * This file is based on the OSG example of the Silverlining SDK:
+ * Copyright (c) 2008 Sundog Software, LLC. All rights reserved worldwide.
+*/
+
+#include <osg/Drawable>
+#include <osgViewer/Viewer>
+#include <SilverLining.h>
+
+
+
+class SilverLining::Atmosphere;
+
+namespace osgVisual
+{
+/**
+ * \brief This class wraps Silverlining's endFrame() function which render clouds, fog and finishes the frame.
+ * 
+ * @author Torben Dannhauer
+ * @date  Sep 2009
+ */ 
+class skySilverLining_cloudsDrawable : public osg::Drawable
+{
+public:
+	/**
+	 * \brief Constructor : Initializes attributes.
+	 * 
+	 */ 
+    skySilverLining_cloudsDrawable();
+
+	/**
+	 * \brief Constructor : Initializes attributes.
+	 * 
+	 * @param view : Pointer to the viewer instance.
+	 */ 
+	skySilverLining_cloudsDrawable(osgViewer::Viewer* view);
+
+	/**
+	 * \brief This function checks if this object is the same kind as the specified one.
+	 * 
+	 * This function is required by subclassing osg::Drawable.
+	 * 
+	 * @param obj : object to compare this type to.
+	 * @return : True if it is the same kind.
+	 */ 
+    virtual bool isSameKindAs(const Object* obj) const {
+        return dynamic_cast<const skySilverLining_cloudsDrawable*>(obj)!=NULL;
+    }
+
+	/**
+	 * \brief This function clones this class/type.
+	 * 
+	 * This function is required by subclassing osg::Drawable.
+	 * 
+	 * @return : Cloned instance.
+	 */ 
+    virtual Object* cloneType() const {
+        return new skySilverLining_cloudsDrawable();
+    }
+
+	/**
+	 * \brief This function clones this class/type.
+	 * 
+	 * This function is required by subclassing osg::Drawable.
+	 * 
+	 * @param copyop : Copy operator flag which indicates how to clone.
+	 * @return : Cloned instance.
+	 */ 
+    virtual Object* clone(const osg::CopyOp& copyop) const {
+        return new skySilverLining_cloudsDrawable();
+    }
+
+	/**
+	 * \brief Draw implementation which will be drawn every frame and is the true payload of thes class.
+	 * 
+	 * @param renderInfo : rendering information.. (?)
+	 */ 
+    virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
+
+protected:
+	/**
+	 * Pointer to the viewer instance.
+	 */ 
+    osgViewer::Viewer* _view;
+};
+
+}	// END NAMESPACE
Index: osgVisual/include/sky_Silverlining/skySilverLining_skyDrawable.h
===================================================================
--- osgVisual/include/sky_Silverlining/skySilverLining_skyDrawable.h	(revision 32)
+++ osgVisual/include/sky_Silverlining/skySilverLining_skyDrawable.h	(revision 32)
@@ -0,0 +1,75 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+ * 
+ * This file is based on the OSG example of the Silverlining SDK:
+ * Copyright (c) 2008 Sundog Software, LLC. All rights reserved worldwide.
+*/
+
+
+
+#include <osg/Drawable>
+#include <osgViewer/Viewer>
+#include <OpenThreads/ScopedLock>
+#include <OpenThreads/Mutex>
+
+#include <skySilverLining_cloudLayerSlot.h>
+
+#include <SilverLining.h>
+#include <iostream>
+
+namespace osgVisual
+{
+
+class skySilverLining_atmosphereReference;
+
+class skySilverLining_skyDrawable : public osg::Drawable
+{
+public:
+	skySilverLining_skyDrawable();
+	skySilverLining_skyDrawable(osgViewer::Viewer* view);
+
+    virtual bool isSameKindAs(const Object* obj) const {
+        return dynamic_cast<const skySilverLining_skyDrawable*>(obj)!=NULL;
+    }
+    virtual Object* cloneType() const {
+        return new skySilverLining_skyDrawable();
+    }
+    virtual Object* clone(const osg::CopyOp& copyop) const {
+        return new skySilverLining_skyDrawable();
+    }
+
+	void setSkyboxSize(double size) {_skyboxSize = size;}
+
+    virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
+
+	void addCloudLayer(cloudLayerSlot *cloudLayerSlot_);
+
+protected:
+	void setLighting(SilverLining::Atmosphere *atm) const;
+	void setSceneFog(SilverLining::Atmosphere *atmosphere) const;
+	static void initializeSilverLining(skySilverLining_atmosphereReference *ar);
+	void seedAndAddCloudLayers(SilverLining::Atmosphere *atmosphere);
+
+    osgViewer::Viewer* _view;
+	double _skyboxSize;
+
+private:
+	OpenThreads::Mutex cloudLayersToAddMutex;
+	mutable std::vector<cloudLayerSlot*> cloudLayerSlots;
+	bool newCloudLayersToAdd;
+};
+
+}	// END NAMESPACE
Index: osgVisual/include/sky_Silverlining/skySilverlining_cloudLayerSlot.h
===================================================================
--- osgVisual/include/sky_Silverlining/skySilverlining_cloudLayerSlot.h	(revision 32)
+++ osgVisual/include/sky_Silverlining/skySilverlining_cloudLayerSlot.h	(revision 32)
@@ -0,0 +1,86 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+ * 
+ * This file is based on the OSG example of the Silverlining SDK:
+ * Copyright (c) 2008 Sundog Software, LLC. All rights reserved worldwide.
+*/
+
+#include <SilverLining.h>
+#include <string>
+
+
+namespace osgVisual
+{
+
+/**
+ * \brief This class represents a single cloudlayer slot which contains a cloud layer and corresponding additional information.
+ * 
+ * @author Torben Dannhauer
+ * @date  Sep 2009
+ */ 
+class cloudLayerSlot
+{
+public:
+	/**
+	 * \brief Construtor, which initializes the cloudlayer information with valid default values.
+	 * 
+	 */ 
+	cloudLayerSlot() 
+	{
+		slot_id = -1;
+		used = false;
+		enabled = false;
+		cloudLayerHandle = -1;
+		cloudLayerPointer = NULL;
+		typeName = "";
+	};
+
+	/**
+	 * ID of the cloudlayer slot.
+	 */ 
+	int slot_id;
+
+	/**
+	 * This flag indicates if the cloudlayer slot is in use.
+	 * 
+	 * @todo : Explain diff to 'enabled'.
+	 */ 
+	bool used;
+
+	/**
+	 * This flag indicates if the cloudlayer slot is enabled.
+	 * 
+	 * @todo : Explain diff to 'used'.
+	 */ 
+	bool enabled;
+
+	/**
+	 * This variable contains silverlining's cloudlayer handle-ID.
+	 */ 
+	int cloudLayerHandle;
+
+	/**
+	 * Pointer to the cloudlayer object.
+	 */ 
+	SilverLining::CloudLayer *cloudLayerPointer;
+
+	/**
+	 * Literal name of the cloudlayer type. e.g. CUMULUS_MEDIOCRIS.
+	 */ 
+	std::string typeName;
+};
+
+}	// END NAMESPACE
Index: osgVisual/include/sky_Silverlining/visual_skySilverLining.h
===================================================================
--- osgVisual/include/sky_Silverlining/visual_skySilverLining.h	(revision 32)
+++ osgVisual/include/sky_Silverlining/visual_skySilverLining.h	(revision 32)
@@ -0,0 +1,621 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+ * 
+ * This file is based on the OSG example of the Silverlining SDK:
+ * Copyright (c) 2008 Sundog Software, LLC. All rights reserved worldwide.
+*/
+
+#include <osg/NodeCallback>
+#include <osg/Geode>
+
+#include <SilverLining.h>
+#include <MillisecondTimer.h>
+#include <windows.h>
+#include <skySilverLining_skyDrawable.h>
+#include <skySilverLining_cloudsDrawable.h>
+#include <skySilverLining_AtmosphereReference.h>
+#include <skySilverLining_ProjectionMatrixCallback.h>
+#include <skySilverLining_cloudLayerSlot.h>
+
+#include <visual_util.h>
+
+namespace osgVisual
+{
+
+#define MAX_CLOUDLAYER_SLOTS 5 
+/**
+ * \brief This class is the container class for the sky, stars and clouds
+ * 
+ * This class is the container class for the sky, stars and clouds. It is responsible for initialization and updating of the sky system.
+ * It is realized as Geode that it is possible to install an updateCallback on this class.
+ * This way, the sky position is always updated during update traversal of the scene graph.
+ * 
+ * The NodeCallback class is nested into this class that no external user can use this callback.
+ * 
+ * @todo Add Cloudlayer->set/getalpha() function
+ * @todo Terrain shadows do not exist
+ * @todo Calibrate visual range with test objects. Populate a Lookuptable to use for true visibility ranges.
+ * @todo Implement an abstract sky interface class to allow other sky implementations than silverlining with identical interfaces
+ * 
+ * @author Torben Dannhauer
+ * @date  Jul 2009
+ */ 
+class visual_skySilverLining : public osg::Geode
+{
+public:
+	/**
+	 * \brief Constructor.
+	 * 
+	 * @param viewer_ : Pointer to the applications viewer
+	 */ 
+	visual_skySilverLining(osgViewer::Viewer* viewer_);
+
+	/**
+	 * \brief Destrcutor: The updateCallback is removed and the atmosphere, if instantiated.
+	 * 
+	 */ 
+	virtual ~visual_skySilverLining(void);
+
+	/**
+	 * \brief Returns a Pointer to the atmosphere object.
+	 * 
+	 * @return Pointer to the atmosphere object.
+	 */ 
+	SilverLining::Atmosphere* getAtmosphere() {return atmosphere;};
+
+	/**
+	 * \brief Checks if the sky system is initialized.
+	 * 
+	 * Checks if the sky system is initialized. If not, it makes a deep lookup at the main cameras userdata, if atmosphere is initialized.
+	 * If this returns true, the local variable is updated with ne new initialize status. If this deep lookup returns false, this method returns also false
+	 * asks the cameras user data if initialzed. If that is
+	 * 
+	 * @return : Returns the status of initialization.
+	 */ 
+	bool isInitialized();
+	
+	/**
+	 * \brief This function initializes the sky framework if its used with a PRE_RENDER camera like the distortion module.
+	 * 
+	 * @param distortedRoot : osg::Group* which is the rootNode over distortion and scene
+	 * @param sceneGraphRoot : osg::Group* which is the rootNode and coordinateSystemNode of the scene.
+	 */ 
+	void init(osg::Group *distortedRoot, osg::CoordinateSystemNode *sceneGraphRoot);
+
+	/**
+	 * \brief This function initializes the sky framework if it's used with the main camera (without any PRE_RENDER camera like the distortion module).
+	 * 
+	 * @param sceneGraphRoot : osg::Group* which is the rootNode and coordinateSystemNode of the scene.
+	 */ 
+	void init(osg::CoordinateSystemNode *sceneGraphRoot);
+
+	/**
+	 * \brief This function can be called by the updateCallback. If the postInitialization for adding clouds etc. has be called already, this function will skip.
+	 * 
+	 * If this function is called before sky is initalized, all actions are skipped.
+	 * A standart usage is adding objects like clouds and winds, configuring time, location and visibility.
+	 * 
+	 */ 
+	void postInit();
+
+	/**
+	 * \brief This function shuts the sky framework down.
+	 * 
+	 */ 
+	void shutdown();
+
+
+/** @name Time
+ *  The following functions control the simulated time and date. 
+ */
+//@{
+	/**
+	 * \brief Sets the new Date and Time to the sky system. 
+	 * 
+	 * Update is only performed if the sky systme is initialized.
+	 * 
+	 * @param year_ : Year to set. SilverLining can only handle Gregorian calendar years, which means that years before 1582 will not be accurately simulated.
+	 * @param month_ : Month to set. Ranging from 1 (Jan) to 12 (Dec)
+	 * @param day_ : Day to set Ranging from 1 to 31
+	 * @param hour_ : Hour to set. Ranging from 0 to 23
+	 * @param minute_ : Minute to set. Ranging from 0 to 59.
+	 * @param second_ : Second to set. Ranging from 0 to 59.
+	 * @param daylightSaving_ : Configures, if the configured DateTime is in daylight savings or without daylight savings.
+	 * @param timezoneOffset_ : Configures the timezone. Hour offset from GMT, ignoring daylight savings time.
+	 */ 
+	void setDateTime( int year_, int month_, int day_, int hour_, int minute_, int second_, bool daylightSaving_, double timezoneOffset_ );
+
+	/**
+	 * \brief Set time for the sky system.
+	 * 
+	 * @param hour_ : Hour to set. Ranging from 0 to 23
+	 * @param minute_ : Minute to set. Ranging from 0 to 59.
+	 * @param second_ : Second to set. Ranging from 0 to 59.
+	 */ 
+	void setTime( int hour_, int minute_, int second_ );
+
+	/**
+	 * \brief Sets the date for the sky system.
+	 * 
+	 * @param year_ : Year to set. SilverLining can only handle Gregorian calendar years, which means that years before 1582 will not be accurately simulated.
+	 * @param month_ : Month to set. Ranging from 1 (Jan) to 12 (Dec)
+	 * @param day_ : Day to set Ranging from 1 to 31
+	 */ 
+	void setDate( int year_, int month_, int day_ );
+
+	/**
+	 * \brief Configures the date and time by epoche (Seconds elapsed since midnight, January 1, 1970 UTC) 
+	 * 
+	 * This function ignores the daylight savings and timezone.
+	 * 
+	 * @param secondsSince1970_ : Seconds elapsed since midnight, January 1, 1970 UTC
+	 */ 
+	void setDateByEpoch(int secondsSince1970_ );
+
+//@}
+
+/** @name Location
+ *  The following functions control the location to simulate. 
+ */
+//@{
+	/**
+	 * \brief Configures the sky system to simulate a specific location.
+	 * 
+	 * @param lat_ : Latitude in radians
+	 * @param lon_ : Longitude in radians
+	 * @param alt_ : Altimeter in meters above see level.
+	 */ 
+	void setLocation(double lat_, double lon_, double alt_);
+//@}
+
+/** @name Visibility and Haze
+ *  The following functions control the atmosperic effects like visibility range and haze. 
+ */
+//@{
+	/**
+	 * \brief This functions sets the visibility range in meters to simulate.
+	 * 
+	 * @param visibility_ : Visibility range in meters.
+	 */ 
+	void setVisibility(double visibility_);
+
+	/**
+	 * \brief This function returns the visibility range in meters which is simulated. 
+	 * 
+	 * @return : Visibility range in meters.
+	 */ 
+	double getVisibility();
+
+	/**
+	 * \brief This function sets the haze factor to simulate. 
+	 * 
+	 * 1 = Pure air, range 256 km
+	 * 2 = very clear, range 50 km
+	 * 3 = clear, range 15 km
+	 * 7 = light haze, range 8 km
+	 * 20 = haze, range 3 km
+	 * 50 = thin fog, range 2 km
+	 * 
+	 * @param turbidity_ : Haze factor to simulate. 
+	 */ 
+	void setTurbidity(double turbidity_);
+
+	/**
+	 * \brief This function returns the simulated haze factor.
+	 * 
+	 * @return : Haze factor.
+	 */ 
+	double getTurbidity();
+//@}
+
+/** @name Light pollution
+ *  The following functions control the light pollution to simulate at night. 
+ */
+//@{
+	/**
+	 * \brief This functions sets the light pollution in Watt/m2 
+	 * 
+	 * @param lightPollution_ : Light pollution to set.
+	 */ 
+	void setLightPollution(double lightPollution_);
+
+	/**
+	 * \brief This function returns the simulated light pollution in Watt/m2.
+	 * 
+	 * @return : Light pollution in Watt/m2
+	 */ 
+	double getLightPollution();
+//@}
+
+/** @name Clouds
+ *  The following functions control the available slots for cloudLayer. In each slot a cloud layer can be adde and its perscpitation or
+ * baseAltitude updated. All other values are not updateable, therefore a delete and recreation of the cloud layer would be necessary. 
+ */
+//@{
+	/**
+	 * \brief This function adds a Cloudlayer to a sepcified SLOT. If the slot is used, this function returns immediately.
+	 * 
+	 * If the slot number is out of range, nothing happens.
+	 * 
+	 * Currently supported CloudTypes are:
+	 *
+	 * \li CloudTypes::CIRROCUMULUS - High planar cloud puffs.
+	 * \li CloudTypes::CIRRUS_FIBRATUS - High, wispy cirrus clouds.
+     * \li CloudTypes::NIMBOSTRATUS - Low stratus decks.
+     * \li CloudTypes::CUMULONIMBUS_CAPPILATUS - A large thunderhead with lightning and rain.
+     * \li CloudTypes::CUMULUS_MEDIOCRIS - Small, puffy clouds.
+     * \li CloudTypes::CUMULUS_CONGESTUS - Larger cumulus clouds with flattened bottoms.
+     * \li CloudTypes::CUMULUS_MEDIOCRIS_INFINITE - A cumulus mediocris layer where the clouds wrap around
+     *  the camera location at all times, to create the illusion of an infinitely large cloud layer.
+     * \li CloudTypes::CUMULUS_CONGESTUS_INFINITE - A cumulus congestus layer where the clouds wrap around
+     *  the camera location at all times, to create the illusion of an infinitely large cloud layer.
+	 * 
+	 * @param slot_ : Slot to use.
+	 * @param baseLength_ : Baselength in meter of the cloud layer to generate.
+	 * @param baseWidth_ : Basewideth in meter of the cloud layer to generate.
+	 * @param thickness_ : Thicknes of the could layer in meter.
+	 * @param baseHeight_ : Height of the cloud base in WGS84.
+	 * @param density_ : Coverage of the cloud layer in percent (0.0 - 1.0).
+	 * @param cloudtype_ : Type of the cloudlayer to generate.
+	 */ 
+	void addCloudLayer(int slot_, double baseLength_, double baseWidth_, double thickness_, double baseHeight_, double density_, CloudTypes cloudtype_ );
+
+	/**
+	 * \brief This function remove the cloudlayer in the specified slot and marks the slot as free.
+	 * 
+	 * If the slot number is out of range, nothing happens.
+	 * 
+	 * @param slot_ : Slot number to clean 
+	 */ 
+	void removeCloudLayer( int slot_ );
+	
+	/**
+	 * \brief This function removes the cloud layers from all slots
+	 * 
+	 */ 
+	void clearAllSlots();
+
+	/**
+	 * \brief This function returns a pointer to the cloudLayer this slot contains.
+	 * 
+	 * If the slot number is out of range, nothing happens.
+	 * 
+	 * @param slot_ : Slot to query for it's cloudLayer pointer.
+	 * @return : Pointer to the contained cloud layer.
+	 */ 
+	SilverLining::CloudLayer* getCloudLayer( int slot_ );
+	
+	/**
+	 * \brief This function configure the cloud layer als enabled (show clouds) or disabled (hide clouds).
+	 * 
+	 * If the slot number is out of range, nothing happens.
+	 * 
+	 * @param slot_ : Cloudlayer to hide/show.
+	 * @param enabled_ : Control where hide or show should be configured.
+	 */ 
+	void setEnabled(int slot_, bool enabled_ );
+
+	/**
+	 * \brief This function returns if the specified cloud layer is en- or disabled (hidden or shown).
+	 * 
+	 * If the slot number is out of range, nothing happens.
+	 * 
+	 * @param slot_ : Slot zu query.
+	 * @return : true if clouds are visible, false if clouds are hidden.
+	 */ 
+	bool isEnabled( int slot_ );
+
+	/**
+	 * \brief This functions fade the clouds in or out, depending on the visibility tsatus before.
+	 * 
+	 * If the slot number is out of range, nothing happens.
+	 * 
+	 * @param slot_ : Slot to fade.
+	 * @param fadetimeMS_ : Milliseconds to fade the cloud layer.
+	 */ 
+	void fadeVisibility( int slot_, int fadetimeMS_);
+
+	/**
+	 * \brief 
+	 * 
+	 * If the slot number is out of range, nothing happens.
+	 * 
+	 * @param slot_ 
+	 * @return : String with the literal name of the cloud layer type.
+	 */ 
+	std::string getCloudLayerTypeName( int slot_ );
+
+//@}
+
+/** @name Wind
+ *  Description of wind. Attention: Wind volumes are not geocentric: If far enough away from upvector location, the earth will curve away under the wind volume.
+ */
+//@{
+	/**
+	 * \brief This function adds a wind volume to the scene, with the specified characteristics.
+	 * 
+	 * @param bottom_ : Height in WGS84 in metern of the wind volumes bottom. 
+	 * @param top_ : Height in WGS84 in metern of the wind volumes top. 
+	 * @param speed_ : Windspeed in the wind volume in meter per seconds.
+	 * @param direction_ : Wind direction in the wind volume in degree (wind origin, not wind destination).
+	 * 
+	 */ 
+	void addWindVolume(double bottom_, double top_, double speed_, int direction_);
+
+	/**
+	 * \brief This function deletes all wind volumes.
+	 * 
+	 */ 
+	void clearAllWindVolumes();
+
+	/**
+	 * \brief This functions checks wether the specified altitude in MSL is inside a wind volume.
+	 * 
+	 * If multiple wind volumes are nested, this function returns the first matching wind volume.
+	 * Because geocentric wind is not implemented, the altitude information is always base on the location where the wind was added.
+	 * To avoid multiple winds, don't use nested wind volumes.
+	 * 
+	 * @param height_ : Height in meters in WGS84 to check for wind.
+	 * @param bottom_ : If checking altitude is inside a volume, the bottom altitude of the volume in meters above MSL is written into, otherwise -1.
+	 * @param top_ : If checking altitude is inside a volume, the top altitude of the volume in meters above MSL is written into, otherwise -1.
+	 * @param speed_ : If checking altitude is inside a volume, the wind speed in the wind volume is written into, otherwise -1.
+	 * @param direction_ : If checking altitude is inside a volume, the wind direction (0 deg = from north, 90 deg = from east) in the wind volume is written into, otherwise -1.
+	 * @return : True if checking altitude is inside a wind volume, otherwise false.
+	 */ 
+	bool insideWind(double height_, double& bottom_, double& top_, double& speed_, double& direction_);
+
+	
+//@}
+
+/** @name Precipitation
+ *  The following functions control the rate and type of precipitation. It is possible to configure it on an global or a per cloud basis. 
+ */
+//@{
+	// Per SLOT
+	/**
+	 * \brief This functions enables the specified precipitation rate and precipitation type at the specified cloudLayer slot.
+	 * 
+	 * @param slot_ : CloudLayer slot to enable precipitation in.
+	 * @param rate_mmPerHour_rain_ : Precipitation rate in mm/hour of rain.
+	 * @param rate_mmPerHour_drySnow_ : Precipitation rate in mm/hour of dry snow.
+	 * @param rate_mmPerHour_wetSnow_ : Precipitation rate in mm/hour of wet snow.
+	 * @param rate_mmPerHour_sleet_ : Precipitation rate in mm/hour of sleet.
+	 */ 
+	void setSlotPrecipitation( int slot_, double rate_mmPerHour_rain_, double rate_mmPerHour_drySnow_, double rate_mmPerHour_wetSnow_, double rate_mmPerHour_sleet_ );
+
+	/**
+	 * \brief This function retrieves the precipitation of a cloudlayer slot.
+	 * 
+	 * @param slot_ : Slot to check for precipitation. 
+	 * @param rate_mmPerHour_rain : Precipitation rate in mm/hour of rain.
+	 * @param rate_mmPerHour_drySnow : Precipitation rate in mm/hour of dry snow.
+	 * @param rate_mmPerHour_wetSnow : Precipitation rate in mm/hour of wet snow.
+	 * @param rate_mmPerHour_sleet : Precipitation rate in mm/hour of sleet.
+	 * @return : True if cloudLayer has precipitation.
+	 */ 
+	bool getSlotPrecipitation( int slot_, double& rate_mmPerHour_rain, double& rate_mmPerHour_drySnow, double& rate_mmPerHour_wetSnow, double& rate_mmPerHour_sleet );
+	
+	/**
+	 * \brief This function checks a specified location for precipitation at the specified cloudLayer slot.
+	 * 
+	 * @param slot_ : CloudLayer slot to check for specification.
+	 * @param rate_mmPerHour_rain : Precipitation rate in mm/hour of rain.
+	 * @param rate_mmPerHour_drySnow : Precipitation rate in mm/hour of dry snow.
+	 * @param rate_mmPerHour_wetSnow : Precipitation rate in mm/hour of wet snow.
+	 * @param rate_mmPerHour_sleet : Precipitation rate in mm/hour of sleet.
+	 * @param lat_ : Latitude to check for precipitation. If it defaults to -1, the internal sky latitude will be used.
+	 * @param lon_ : Longitude to check for precipitation. If it defaults to -1, the internal sky longitude will be used.
+	 * @param height_ : Height in WGS84 to check for precipitation. If it defaults to -1, the internal sky height will be used.
+	 * @return : Returns true if precipitation at the specified location is true.  
+	 */ 
+	bool getSlotPrecipitationAtLocation( int slot_, double& rate_mmPerHour_rain, double& rate_mmPerHour_drySnow, double& rate_mmPerHour_wetSnow, double& rate_mmPerHour_sleet, double lat_=-1, double lon_=-1, double height_=-1 );
+
+	/**
+	 * \brief This function clears all types of precipitation of the specified slot.
+	 * 
+	 * @param slot_ : Slot toe clear precipitation.
+	 */ 
+	void clearAllPrecipitation( int slot_ );
+
+	// Global
+	/**
+	 * \brief This function clears the global precipitation.
+	 * 
+	 */ 
+	void clearGlobalPrecipitation();
+
+	/**
+	 * \brief This function sets the cloud independent, global precipitation.
+	 * 
+	 * @param rate_mmPerHour_rain_ : Precipitation rate in mm/hour of rain.
+	 * @param rate_mmPerHour_drySnow_ : Precipitation rate in mm/hour of dry snow.
+	 * @param rate_mmPerHour_wetSnow_ : Precipitation rate in mm/hour of wet snow.
+	 * @param rate_mmPerHour_sleet_ : Precipitation rate in mm/hour of sleet.
+	 */ 
+	void setGlobalPrecipitation( double rate_mmPerHour_rain_, double rate_mmPerHour_drySnow_, double rate_mmPerHour_wetSnow_, double rate_mmPerHour_sleet_ );
+	
+	// Misc
+	/**
+	 * \brief This function returns the overall precipitation rate of all cloud dependent precipitation.
+	 * 
+	 * This function adds the precipitation of all cloudLayer seperated for all types of precipitation.
+	 * Global precipitation is ignored, because precipitation without clouds is artificial and only reasonable for visualiszation purposes.
+	 * 
+	 * @param rate_mmPerHour_rain : Precipitation rate in mm/hour of rain.
+	 * @param rate_mmPerHour_drySnow : Precipitation rate in mm/hour of dry snow.
+	 * @param rate_mmPerHour_wetSnow : Precipitation rate in mm/hour of wet snow.
+	 * @param rate_mmPerHour_sleet : Precipitation rate in mm/hour of sleet.
+	 * @param lat_ : Latitude to check for precipitation. If it defaults to -1, the internal sky latitude will be used.
+	 * @param lon_ : Longitude to check for precipitation. If it defaults to -1, the internal sky longitude will be used.
+	 * @param height_ : Height in WGS84 to check for precipitation. If it defaults to -1, the internal sky height will be used.
+	 * @return : True if precipitation lookup was successful.
+	 */ 
+	bool getOverallPrecipitationAtLocation( double& rate_mmPerHour_rain, double& rate_mmPerHour_drySnow, double& rate_mmPerHour_wetSnow, double& rate_mmPerHour_sleet, double lat_=-1, double lon_=-1, double height_=-1 );
+//@}
+
+
+
+
+
+private:
+	/**
+	 * \brief Nested Callback class
+	 * 
+	 * @author Torben Dannhauer
+	 * @date  Jul 2009
+	 */ 
+	class skyUpdateCallback : public osg::NodeCallback
+	{
+	public:
+		/**
+		 * \brief Constructor
+		 * 
+		 * @param csn_ : Pointer to the Coordinate System Node. Necessary to extract lat, lon and height of the camera position.
+		 * @param sceneCamera_ : Pointer to the scene camera (undistorted camera, type PRE_RENDER)
+		 * @param sky_ : Pointer to the sky system.
+		 */ 
+		skyUpdateCallback(osg::CoordinateSystemNode* csn_, osg::Camera* sceneCamera_, visual_skySilverLining* sky_)
+			: csn(csn_), sceneCamera(sceneCamera_), sky(sky_) {};
+
+		/**
+		 * \brief This function is executed as callback during traversal. It updates the skys displayed location.
+		 * 
+		 */ 
+		virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
+	private:
+		/**
+		 * Referenced pointer to the Coordinate System Node. Necessary to extract lat, lon and height of the camera position.
+		 */ 
+		osg::ref_ptr<osg::CoordinateSystemNode> csn;
+		
+		/**
+		 * Referenced pointer to the scene camera (undistorted camera, type PRE_RENDER)
+		 */ 
+		osg::ref_ptr<osg::Camera> sceneCamera;
+
+		/**
+		 * Referenced pointer to the sky system.
+		 */ 
+		osg::ref_ptr<visual_skySilverLining> sky;
+	};	// Nested class END
+
+	/**
+	 * \brief This function updates the atmosphere's upVector, 
+	 * if delta_lat or delta_lon (from the existing location
+	 * and the location of the last upVector update) is larger than N degree.
+	 * If an update is requiered, the existing location is noted as the last update location.
+	 * 
+	 * Iis called by this->setLocation.
+	 * 
+	 */ 
+	void updateUpVector();
+
+	/**
+	 * Pointer to the atmosphere object of Silverlining.
+	 */ 
+	SilverLining::Atmosphere *atmosphere;
+
+	/**
+	 * Referenced Pointer to the viewer
+	 */ 
+	osg::ref_ptr<osgViewer::Viewer> viewer;
+
+	/**
+	 * Referenced Pointer to the camera which pre renders the scene
+	 */ 
+	osg::ref_ptr<osg::Camera> sceneCamera;
+ 
+	/**
+	 * Referenced Pointer to the coordinate system node. Required for WGS84 transformations.
+	 */ 
+	osg::ref_ptr<osg::CoordinateSystemNode> sceneRoot;
+
+	/**
+	 * Referenced Pointer to the updatecallback, which is installed at this node. 
+	 */ 
+	osg::ref_ptr<skyUpdateCallback> updateCallback;
+
+	/**
+	 * Referenced Pointer to the ProjectionMatrix callback.
+	 */ 
+	osg::ref_ptr<skySilverLining_projectionMatrixCallback> cb;
+
+	/**
+	 * Referenced Pointer to the sky Drawable, which renders the skybox.
+	 */ 
+	osg::ref_ptr<skySilverLining_skyDrawable> skyDrawable;
+
+	/**
+	 * Referenced Pointer to the cloudsDrawable, which renders the clouds.
+	 */ 
+	osg::ref_ptr<skySilverLining_cloudsDrawable> cloudsDrawable;
+
+	/**
+	 * Flag which contains if the sky system is initialized. This status is only a local
+	 * copy if the cameras userdata which contain the primary information if the sky system is initialized
+	 */ 
+	bool atmosphereInitialized;
+
+	/**
+	 * This variable indicates whether postinit() was called already.
+	 */ 
+	bool postInitialized;
+
+	/**
+	 * This vector contains all available slots for cloud layer.
+	 */ 
+	std::vector<cloudLayerSlot> cloudLayerSlots;
+
+		/**
+	 * Latitude, which mirrors the latitude of the last sky update. This is neccesary if any weather effect is added to calculate the earth radius on that location for appropriate level above MSL
+	 */ 
+	double lat;
+
+	/**
+	 * Longitude, which mirrors the latitude of the last sky update. This is neccesary if any weather effect is added to calculate the earth radius on that location for appropriate level above MSL
+	 */ 
+	double lon;
+
+	/**
+	 * Height, which mirrors the height of the last sky update.
+	 */ 
+	double height;
+
+	/**
+	 * This variable contains the latitude of the last upVector update.
+	 */ 
+	double upVectorLat;
+
+	/**
+	 * This variable contains the longitude of the last upVector update.
+	 */ 
+	double upVectorLon;
+
+};
+
+using namespace SilverLining;
+
+class MyMillisecondTimer : public SilverLining::MillisecondTimer
+{
+public:
+	virtual unsigned long GetMilliseconds() const
+        {
+			return timeGetTime() * 50;
+        }
+};
+
+
+} // END NAMESPACE
Index: osgVisual/include/util/visual_util.h
===================================================================
--- osgVisual/include/util/visual_util.h	(revision 32)
+++ osgVisual/include/util/visual_util.h	(revision 32)
@@ -0,0 +1,219 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include <string.h>
+#include <iostream>
+
+
+#include <osg/Node>
+#include <osg/Group>
+#include <osg/Geode>
+#include <osg/CoordinateSystemNode>
+#include <osg/ShapeDrawable>
+
+#include <osgViewer/Viewer>
+
+#ifdef FUNFUNCTIONS_ENABLED
+#ifdef WIN32
+#include <osgViewer/api/Win32/GraphicsHandleWin32>
+#include "C:\\Program Files/Microsoft SDKs/Windows/v6.1/Include/dwmapi.h"
+#pragma comment ( lib, "C:\\Program Files/Microsoft SDKs/Windows/v6.1/Lib/dwmapi.lib" )
+#endif
+#endif
+
+#include <OpenThreads/ReentrantMutex>
+
+#include <osgUtil/LineSegmentIntersector>
+
+namespace osgVisual
+{ 
+
+/**
+ * \brief This class provides utility functions. 
+ * 
+ * The utility functions are implemented as static functions if possible for easy use in other classes.
+ * 
+ * \todo check why lineIntersector is unstable, check if newer and better system is available.
+ * 
+ * @author Torben Dannhauer
+ * @date  Jul 2009
+ */ 
+class util
+{
+public:
+	/**
+	 * \brief Construtor
+	 * 
+	 */ 
+	util();
+
+	/**
+	 * \brief Destructor
+	 * 
+	 */ 
+	~util();
+
+	/**
+	 * \brief This functions searches in the scene graph for a node with a name
+	 * 
+	 * This function searches in the scene graph unter the node "currNode" for a node named like the given search name.
+	 * The functions returns the first node with that name.
+	 * 
+	 * @param searchName_ : Nodename to search for
+	 * @param currNode_ : Scene graph to search in.
+	 * @return : if Node found: Pointer to the node. If not found: NULL
+	 */ 
+	static osg::Node* findNamedNode(const std::string& searchName_, osg::Node* currNode_);
+
+	/**
+	 * \brief This function creates a red cylinder of the specified size tor testing purposes.
+	 * 
+	 * @param length_ : Length of the cylinder in meter.
+	 * @param width_ : Diameter of the cylinder in meter.
+	 * @param offset_ : Offset of the cylinder's origin in meter.
+	 * @return : Referenced Pointer off the Geode with the created cylinder.
+	 */ 
+	static osg::ref_ptr<osg::Geode> getDemoCylinder(double length_, double width_, osg::Vec3 offset_ = osg::Vec3(0.0, 0.0, 0.0) );
+	
+	/**
+	 * \brief This function creates a red sphere of the specified size tor testing purposes.
+	 * 
+	 * @param radius_ : Radius of the sphere in meter.
+	 * @param offset_ : Offset of the sphere's origin in meter.
+	 * @return : Referenced Pointer off the Geode with the created cylinder.
+	 */ 
+	static osg::ref_ptr<osg::Geode> getDemoSphere(double radius_, osg::Vec3 offset_ = osg::Vec3(0.0, 0.0, 0.0) );
+
+	/**
+	 * \brief This functions searches the scene graph for intersections of a line between two points and the model.
+	 * 
+	 * @param start_ : Point 1 for the intersection line
+	 * @param end_ : Point 2 for the intersection line
+	 * @param intersection_ : vektor to the intersection point if any is found.
+	 * @param node_ : Node which is the root of the scene graph to check for intersections
+	 * @param intersectTraversalMask_ : Bitwise mask wich controls which nodes should be checked for intersections (e.g. to check only terrain but not clouds or sky)
+	 * @return returns : True if an intersection is found. 
+	 */ 
+	static bool intersect(const osg::Vec3d& start_, const osg::Vec3d& end_, osg::Vec3d& intersection_, osg::Node* node_, osg::Node::NodeMask intersectTraversalMask_=0xffffffff );
+
+	/**
+	 * \brief This function queries the height of terrain (hot) at a specified location.
+	 * 
+	 * @param hot_ : Reference to write the calculated hot into.
+	 * @param rootNode_ : Node which is the root of the scene graph to calculate the hot.
+	 * @param lat_ : Latitude of the position to calculate the hot.
+	 * @param lon_ : Longitude of the position to calculate the hot.
+	 * @param traversalMask_ : Bitwise mask wich controls which nodes should be checked for hot (e.g. to check only terrain but not clouds or sky)
+	 * @return : True if hot calculation successful.
+	 */ 
+	static bool queryHeightOfTerrain(double& hot_, osg::Node* rootNode_, double lat_, double lon_, osg::Node::NodeMask traversalMask_=0xffffffff);
+
+	/**
+	 * \brief This function queries the height above terrain (hat) at a specified location in WGS84 coordinates.
+	 * 
+	 * @param hat_ : Reference to write the calculated hat into.
+	 * @param rootNode_ : Node which is the root of the scene graph to calculate the hat.
+	 * @param lat_ : Latitude of the position to calculate the hat. (e.g. lat of camera)
+	 * @param lon_ : Longitude of the position to calculate the hat.(e.g. lon of camera)
+	 * @param height_ : Height of the position to calculate the hat.(e.g. height of camera).
+	 * @param traversalMask_ : Bitwise mask wich controls which nodes should be checked for hat (e.g. to check only terrain but not clouds or sky)
+	 * @return :  True if hat calculation successful.
+	 */ 
+	static bool queryHeightAboveTerrainInWGS84(double& hat_, osg::Node* rootNode_, double lat_, double lon_, double height_, osg::Node::NodeMask traversalMask_=0xffffffff);
+
+	/**
+	 * \brief This function queries the height above terrain (hat) at a specified location in world coordinates.
+	 * 
+	 * @param hat_ : Reference to write the calculated hat into.
+	 * @param rootNode_ : Node which is the root of the scene graph to calculate the hat.
+	 * @param x_ : First value of the pointer which points to the position to calculate hat for.
+	 * @param y_ : Second value of the pointer which points to the position to calculate hat for. 
+	 * @param z_ : Third value of the pointer which points to the position to calculate hat for.
+	 * @param traversalMask_ : Bitwise mask wich controls which nodes should be checked for hat (e.g. to check only terrain but not clouds or sky)
+	 * @return :  True if hat calculation successful. 
+	 */ 
+	static bool queryHeightAboveTerrainInWorld(double& hat_, osg::Node* rootNode_, double x_, double y_, double z_, osg::Node::NodeMask traversalMask_=0xffffffff);
+
+	/**
+	 * \brief This function calculates the earth readius (vector length in world coordiantes from origin to location) at the specified location.
+	 * 
+	 * @param lat_ : Latitude in radians.
+	 * @param lon_ : Longitude in radians.
+	 * @param rootNode_ : Root node of the scene which coordinate system node should be used.
+	 * @param radius_ : Calculated earth readius in meter.
+	 * @return : True if calculation successful.
+	 */ 
+	static bool calculateEarthRadiusAtWGS84Coordinate(double lat_, double lon_, osg::Node* rootNode_, double& radius_);
+
+	/**
+	 * \brief This function converts a WGS84 position into global OpenGL XYZ coordinates.
+	 * 
+	 * @param lat_ : Latitude of the position to calculate XYZ.
+	 * @param lon_ : Longitude of the position to calculate XYZ.
+	 * @param height_ : Height of the position to calculate XYZ.
+	 * @param rootNode_ : Node which is the root of the scene graph to calculate XYZ.
+	 * @param x_ : X Coordinate in global OpenGL coordinates.
+	 * @param y_ : Y Coordinate in global OpenGL coordinates.
+	 * @param z_ : Z Coordinate in global OpenGL coordinates.
+	 * @return : True if calculation successful.
+	 */ 
+	static bool calculateXYZAtWGS84Coordinate(double lat_, double lon_, double height_, osg::Node* rootNode_, double& x_, double& y_, double& z_);
+
+	/**
+	 * \brief This function calculates lat, lon and height of a specified camera by a specified coordinate system node. 
+	 * 
+	 * @param camera_ : Camera node which position should be calculated.
+	 * @param rootNode_ : rootNode of the scene.
+	 * @param lat_ : Latitude variable to save value in.
+	 * @param lon_ : Longitude variable to save value in.
+	 * @param height_ : Height: variable to save value in.
+	 * @return : True if calculation was successful.
+	 */ 
+	static bool getWGS84ofCamera( osg::Camera* camera_, osg::Node* rootNode_, double& lat_, double& lon_, double& height_ ); 
+
+	/**
+	 * \brief This function returns the global XYZ coordinates of the specified camera.
+	 * 
+	 * @param camera_ : Camera to return the position.
+	 * @param x_ : X coordinate.
+	 * @param y_ : Y coordinate.
+	 * @param z_ : Z coordinate.
+	 */ 
+	static void getXYZofCamera( osg::Camera* camera_, double& x_, double& y_, double& z_ ); 
+
+	/**
+	 * \brief This function disables the close button on the openGL's windowdecoration
+	 * 
+	 * To be honest, this function is only to play, I have found it on http://forum.openscenegraph.org and found it interesting enought to play along ;)
+	 * 
+	 * @param viewer_ : Pointer to the applications viewer
+	 * @return : true if successful
+	 */ 
+	static bool removeClosebuttonOnGLWindow(osgViewer::Viewer* viewer_);
+
+	/**
+	 * \brief This function make the backgroud of the GL window blurred transparent, if an backgroud with alpha is set.
+	 * 
+	 * To be honest, this function is only to play, I have found it on http://forum.openscenegraph.org and found it interesting enought to play along ;)
+	 * 
+	 * @param viewer_ : Pointer to the applications viewer
+	 * @return : true if successful
+	 */ 
+	static bool setTransparentWindowBackground(osgViewer::Viewer* viewer_);
+};
+
+} //END NAMESPACE
Index: osgVisual/include/vista2D/visual_vista2D.h
===================================================================
--- osgVisual/include/vista2D/visual_vista2D.h	(revision 32)
+++ osgVisual/include/vista2D/visual_vista2D.h	(revision 32)
@@ -0,0 +1,113 @@
+#pragma once
+/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
+ *
+ * This library is based on OpenSceneGraph, 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.
+ *
+ * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
+ * You have to aquire licenses for all used proprietary modules.
+ * 
+ * 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.
+*/
+
+#include "VistaView.h"
+
+#include <osg/Drawable>
+#include <osg/Geode>
+#include <osg/Projection>
+#include <osg/MatrixTransform>
+#include <osg/CoordinateSystemNode>
+
+#include <osgDB/FileUtils>
+
+
+namespace osgVisual
+{
+
+/**
+ * \brief This class integrates Vista2D by Wetzel Technology into OSG.
+ * 
+ * It wraps vista2D's OpenGL interface to be usable as a standart OSG Node. The Vista2D nodekit performs auto-linking
+ * againt the Vista2D library, therefore only three shared libraries have to be copied to the binary folder of the project.
+ * 
+ * Vista2D ist a software to design HID. This Nodekit enables OSG to display Vista2D project files.
+ * 
+ * Please copy the following files to the binary folder of you application if you intend to use this nodekit:
+ * libView.dll
+ * fontLib.dll
+ * freetype6.dll
+ * 
+ * The implementation of this class is based on osg::Drawable. The drawimplementations contains the Vista2D wrap.
+ *  
+ * @author Torben Dannhauer
+ * @date  Sep 2009
+ */ 
+class visual_vista2D : public osg::Drawable
+{
+public:
+	/**
+	 * \brief Construtor: Creates a Vista2D environment which should be wrapt by this node.
+	 * 
+	 */ 
+	visual_vista2D(void);
+
+	/**
+	 * \brief Empty destructor.
+	 * 
+	 */ 
+	~visual_vista2D(void);
+
+	/**
+	 * \brief This static function must be called to instantiate a vista2D project.
+	 * 
+	 * @param vista2DFilename_ : Vista2D project file to display.
+	 * @param sceneGraphRoot_ : Scenegraph to add the vista2D note as child.
+	 * @return : True if successful.
+	 */ 
+	static bool createVistaOverlay( std::string vista2DFilename_, osg::CoordinateSystemNode *sceneGraphRoot_ );
+
+	/**
+	 * \brief This function is requiered by subclassing osg::Drawable.
+	 * 
+	 * @return : Cloned object.
+	 */ 
+	osg::Object* cloneType() const;
+
+	/**
+	 * \brief This function is requiered by subclassing osg::Drawable.
+	 * 
+	 * @param : Copyoperator how to copy the object
+	 * @return : Cloned object.
+	 */ 
+	osg::Object* clone(const osg::CopyOp&) const;
+
+private:
+	/**
+	 * \brief This function initialized the visual_vista2D object after instantiation by createVistaOverlay()
+	 * 
+	 * @param vista2DFilename_ : Vista2D project file to instantiate.
+	 */ 
+	void init(std::string vista2DFilename_);
+
+	/**
+	 * \brief This function implements the pure OpenGL draw by calling Vista2D's draw funtion.
+	 * 
+	 * Because Visrta2D manipulates OpenGLs stateset, this function saves the
+	 * OSG statset at the beginning and restores it after the drawing of Vista2D 
+	 * 
+	 * @param renderInfo : Renderinfo of the drawing
+	 */ 
+	void drawImplementation(osg::RenderInfo& renderInfo) const;
+	
+	/**
+	 * Pointer to Vista2D's view instance.
+	 */ 
+	Vista2D::VistaView* view;
+}; 
+
+}	// END NAMESPACE
