Index: trunk/VUT/work/ogre_changes/OgreMain/include/OgreSceneNode.h
===================================================================
--- trunk/VUT/work/ogre_changes/OgreMain/include/OgreSceneNode.h	(revision 61)
+++ trunk/VUT/work/ogre_changes/OgreMain/include/OgreSceneNode.h	(revision 154)
@@ -444,9 +444,16 @@
 		void setLastRendered(int frameid);
 
+		/** Sets scene node id 
+		@param the id
+		*/
+		void setId(int id);
+		/** see set */
+		int getId(void);
+
 	protected:
 		int mLastVisited;
 		bool mVisible;
 		int mLastRendered;
-
+		int mId;
 #endif //GTP_VISIBILITY_MODIFIED_OGRE
 
Index: trunk/VUT/work/ogre_changes/OgreMain/include/OgreRenderTarget.h
===================================================================
--- trunk/VUT/work/ogre_changes/OgreMain/include/OgreRenderTarget.h	(revision 154)
+++ trunk/VUT/work/ogre_changes/OgreMain/include/OgreRenderTarget.h	(revision 154)
@@ -0,0 +1,338 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+    (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2005 The OGRE Team
+Also see acknowledgements in Readme.html
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program 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 GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+#ifndef __RenderTarget_H__
+#define __RenderTarget_H__
+
+#include "OgrePrerequisites.h"
+
+#include "OgreString.h"
+#include "OgreTextureManager.h"
+#include "OgreViewport.h"
+#include "OgreTimer.h"
+
+/* Define the number of priority groups for the render system's render targets. */
+#ifndef OGRE_NUM_RENDERTARGET_GROUPS
+	#define OGRE_NUM_RENDERTARGET_GROUPS 10
+	#define OGRE_DEFAULT_RT_GROUP 4
+	#define OGRE_REND_TO_TEX_RT_GROUP 2
+#endif
+
+namespace Ogre {
+
+    /** A 'canvas' which can receive the results of a rendering
+        operation.
+        @remarks
+            This abstract class defines a common root to all targets of rendering operations. A
+            render target could be a window on a screen, or another
+            offscreen surface like a texture or bump map etc.
+        @author
+            Steven Streeting
+        @version
+            1.0
+     */
+    class _OgreExport RenderTarget
+    {
+    public:
+        enum StatFlags
+        {
+            SF_NONE           = 0,
+            SF_FPS            = 1,
+            SF_AVG_FPS        = 2,
+            SF_BEST_FPS       = 4,
+            SF_WORST_FPS      = 8,
+            SF_TRIANGLE_COUNT = 16,
+            SF_ALL            = 0xFFFF
+        };
+
+        struct FrameStats
+        {
+            float lastFPS;
+            float avgFPS;
+            float bestFPS;
+            float worstFPS;
+            unsigned long bestFrameTime;
+            unsigned long worstFrameTime;
+            size_t triangleCount;
+        };
+
+        RenderTarget();
+        virtual ~RenderTarget();
+
+        /// Retrieve target's name.
+        virtual const String& getName(void) const;
+
+        /// Retrieve information about the render target.
+        virtual void getMetrics(unsigned int& width, unsigned int& height, unsigned int& colourDepth);
+
+        virtual unsigned int getWidth(void) const;
+        virtual unsigned int getHeight(void) const;
+        virtual unsigned int getColourDepth(void) const;
+
+        /** Tells the target to update it's contents.
+            @remarks
+                If OGRE is not running in an automatic rendering loop
+                (started using Root::startRendering),
+                the user of the library is responsible for asking each render
+                target to refresh. This is the method used to do this. It automatically
+                re-renders the contents of the target using whatever cameras have been
+                pointed at it (using Camera::setRenderTarget).
+            @par
+                This allows OGRE to be used in multi-windowed utilities
+                and for contents to be refreshed only when required, rather than
+                constantly as with the automatic rendering loop.
+        */
+        virtual void update(void);
+
+        /** Adds a viewport to the rendering target.
+            @remarks
+                A viewport is the rectangle into which redering output is sent. This method adds
+                a viewport to the render target, rendering from the supplied camera. The
+                rest of the parameters are only required if you wish to add more than one viewport
+                to a single rendering target. Note that size information passed to this method is
+                passed as a parametric, i.e. it is relative rather than absolute. This is to allow
+                viewports to automatically resize along with the target.
+            @param
+                cam The camera from which the viewport contents will be rendered (mandatory)
+            @param
+                ZOrder The relative order of the viewport with others on the target (allows overlapping
+                viewports i.e. picture-in-picture). Higher ZOrders are on top of lower ones. The actual number
+                is irrelevant, only the relative ZOrder matters (you can leave gaps in the numbering)
+            @param
+                left The relative position of the left of the viewport on the target, as a value between 0 and 1.
+            @param
+                top The relative position of the top of the viewport on the target, as a value between 0 and 1.
+            @param
+                width The relative width of the viewport on the target, as a value between 0 and 1.
+            @param
+                height The relative height of the viewport on the target, as a value between 0 and 1.
+        */
+        virtual Viewport* addViewport(Camera* cam, int ZOrder = 0, float left = 0.0f, float top = 0.0f ,
+            float width = 1.0f, float height = 1.0f);
+
+        /** Returns the number of viewports attached to this target.*/
+        virtual unsigned short getNumViewports(void) const;
+
+        /** Retrieves a pointer to the viewport with the given index. */
+        virtual Viewport* getViewport(unsigned short index);
+
+        /** Removes a viewport at a given ZOrder.
+        */
+        virtual void removeViewport(int ZOrder);
+
+        /** Removes all viewports on this target.
+        */
+        virtual void removeAllViewports(void);
+
+        /** Retieves details of current rendering performance.
+            @remarks
+                If the user application wishes to do it's own performance
+                display, or use performance for some other means, this
+                method allows it to retrieve the statistics.
+                @param
+                    lastFPS Pointer to a float to receive the number of frames per second (FPS)
+                    based on the last frame rendered.
+                @param
+                    avgFPS Pointer to a float to receive the FPS rating based on an average of all
+                    the frames rendered since rendering began (the call to
+                    Root::startRendering).
+                @param
+                    bestFPS Pointer to a float to receive the best FPS rating that has been achieved
+                    since rendering began.
+                @param
+                    worstFPS Pointer to a float to receive the worst FPS rating seen so far.
+        */
+        virtual void getStatistics(float& lastFPS, float& avgFPS,
+            float& bestFPS, float& worstFPS) const;  // Access to stats
+
+        virtual const FrameStats& getStatistics(void) const;
+
+        /** Individual stats access - gets the number of frames per second (FPS) based on the last frame rendered.
+        */
+        virtual float getLastFPS() const;
+
+        /** Individual stats access - gets the average frames per second (FPS) since call to Root::startRendering.
+        */
+        virtual float getAverageFPS() const;
+
+        /** Individual stats access - gets the best frames per second (FPS) since call to Root::startRendering.
+        */
+        virtual float getBestFPS() const;
+
+        /** Individual stats access - gets the worst frames per second (FPS) since call to Root::startRendering.
+        */
+        virtual float getWorstFPS() const;
+
+        /** Individual stats access - gets the best frame time
+        */
+        virtual float getBestFrameTime() const;
+
+        /** Individual stats access - gets the worst frame time
+        */
+        virtual float getWorstFrameTime() const;
+
+        /** Resets saved frame-rate statistices.
+        */
+        virtual void resetStatistics(void);
+
+        /** Gets a custom (maybe platform-specific) attribute.
+            @remarks
+                This is a nasty way of satisfying any API's need to see platform-specific details.
+                It horrid, but D3D needs this kind of info. At least it's abstracted.
+            @param
+                name The name of the attribute.
+            @param
+                pData Pointer to memory of the right kind of structure to receive the info.
+        */
+        virtual void getCustomAttribute(const String& name, void* pData);
+
+        /** Adds debug text to this window. */
+        virtual void setDebugText(const String& text);
+
+		/** Returns the debug text. */
+		const String& getDebugText() const;
+
+        /** Add a listener to this RenderTarget which will be called back before & after rendering.
+        @remarks
+            If you want notifications before and after a target is updated by the system, use
+            this method to register your own custom RenderTargetListener class. This is useful
+            for potentially adding your own manual rendering commands before and after the
+            'normal' system rendering.
+        @par NB this should not be used for frame-based scene updates, use Root::addFrameListener for that.
+        */
+        virtual void addListener(RenderTargetListener* listener);
+        /** Removes a RenderTargetListener previously registered using addListener. */
+        virtual void removeListener(RenderTargetListener* listener);
+        /** Removes all listeners from this instance. */
+        virtual void removeAllListeners(void);
+
+		/** Sets the priority of this render target in relation to the others. 
+        @remarks
+            This can be used in order to schedule render target updates. Lower
+            priorities will be rendered first. Note that the priority must be set
+            at the time the render target is attached to the render system, changes
+            afterwards will not affect the ordering.
+        */
+        virtual void setPriority( uchar priority ) { mPriority = priority; }
+        /** Gets the priority of a render target. */
+		virtual uchar getPriority() const { return mPriority; }
+
+        /** Used to retrieve or set the active state of the render target.
+        */
+        virtual bool isActive() const;
+
+        /** Used to set the active state of the render target.
+        */
+        virtual void setActive( bool state );
+
+        /** Sets whether this target should be automatically updated if Ogre's rendering
+            loop or Root::_updateAllRenderTargets is being used.
+        @remarks
+            By default, if you use Ogre's own rendering loop (Root::startRendering)
+            or call Root::_updateAllRenderTargets, all render targets are updated 
+            automatically. This method allows you to control that behaviour, if 
+            for example you have a render target which you only want to update periodically.
+        @param autoupdate If true, the render target is updated during the automatic render
+            loop or when Root::_updateAllRenderTargets is called. If false, the 
+            target is only updated when its update() method is called explicitly.
+        */
+        virtual void setAutoUpdated(bool autoupdate);
+        /** Gets whether this target is automatically updated if Ogre's rendering
+            loop or Root::_updateAllRenderTargets is being used.
+        */
+        virtual bool isAutoUpdated(void) const;
+
+        /** Writes the current contents of the render target to the named file. */
+        virtual void writeContentsToFile(const String& filename) = 0;
+
+#ifdef GTP_VISIBILITY_MODIFIED_OGRE
+		virtual uchar *getBufferContents(int &dimx, int &dimy) { return NULL; };
+#endif // GTP_VISIBILITY_MODIFIED_OGRE
+
+	/** Writes the current contents of the render target to the (PREFIX)(time-stamp)(SUFFIX) file.
+		@returns the name of the file used.*/
+	virtual String writeContentsToTimestampedFile(const String& filenamePrefix, const String& filenameSuffix);
+
+		virtual bool requiresTextureFlipping() const = 0;
+
+		/** Gets the number of triangles rendered in the last update() call. */
+		virtual size_t getTriangleCount(void) const;
+        /** Utility method to notify a render target that a camera has been removed, 
+        incase it was referring to it as a viewer. 
+        */
+        virtual void _notifyCameraRemoved(const Camera* cam);
+
+        /** Indicates whether this target is the primary window. The
+            primary window is special in that it is destroyed when 
+            ogre is shut down, and cannot be destroyed directly.
+            This is the case because it holds the context for vertex,
+            index buffers and textures.
+        */
+        virtual bool isPrimary(void) const;
+
+    protected:
+        /// The name of this target.
+        String mName;
+		/// The priority of the render target.
+		uchar mPriority;
+
+        unsigned int mWidth;
+        unsigned int mHeight;
+        unsigned int mColourDepth;
+        bool mIsDepthBuffered;
+
+        // Stats
+		FrameStats mStats;
+        
+        Timer* mTimer ;
+        String mDebugText;
+        unsigned long mLastSecond;
+        unsigned long mLastTime;
+        size_t mFrameCount;
+
+        bool mActive;
+        bool mAutoUpdate;
+
+        void updateStats(void);
+
+        typedef std::map<int, Viewport*, std::less<int> > ViewportList;
+        /// List of viewports, map on Z-order
+        ViewportList mViewportList;
+
+        typedef std::vector<RenderTargetListener*> RenderTargetListenerList;
+        RenderTargetListenerList mListeners;
+
+        /// internal method for firing events
+        virtual void firePreUpdate(void);
+        /// internal method for firing events
+        virtual void firePostUpdate(void);
+        /// internal method for firing events
+        virtual void fireViewportPreUpdate(Viewport* vp);
+        /// internal method for firing events
+        virtual void fireViewportPostUpdate(Viewport* vp);
+    };
+
+} // Namespace
+
+#endif
Index: trunk/VUT/work/ogre_changes/OgreMain/src/OgreSceneNode.cpp
===================================================================
--- trunk/VUT/work/ogre_changes/OgreMain/src/OgreSceneNode.cpp	(revision 61)
+++ trunk/VUT/work/ogre_changes/OgreMain/src/OgreSceneNode.cpp	(revision 154)
@@ -42,5 +42,5 @@
 	mYawFixed(false), mAutoTrackTarget(0), mIsInSceneGraph(false)
 #ifdef GTP_VISIBILITY_MODIFIED_OGRE
-	, mLastVisited(0), mVisible(false), mLastRendered(-1)
+	, mLastVisited(0), mVisible(false), mLastRendered(-1), mId(-1)
 #endif //GTP_VISIBILITY_MODIFIED_OGRE
     {
@@ -53,5 +53,5 @@
 	mAutoTrackTarget(0), mIsInSceneGraph(false)
 	#ifdef GTP_VISIBILITY_MODIFIED_OGRE
-	, mLastVisited(0), mVisible(false)
+	, mLastVisited(0), mVisible(false), mId(-1)
 	#endif //GTP_VISIBILITY_MODIFIED_OGRE
     {
@@ -641,4 +641,14 @@
 		mLastRendered = frameid;
 	}
+	//-----------------------------------------------------------------------
+	void SceneNode::setId(int id)
+	{
+		mId = id;
+	}
+	//-----------------------------------------------------------------------
+	int SceneNode::getId(void)
+	{
+		return mId;
+	}
 	#endif //GTP_VISIBILITY_MODIFIED_OGRE
 }
Index: trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/include/OgreOctree.h
===================================================================
--- trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/include/OgreOctree.h	(revision 135)
+++ trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/include/OgreOctree.h	(revision 154)
@@ -192,4 +192,12 @@
 	void _updateBounds();
 
+	/** Sets scene node id 
+	@param the id
+	*/
+	void setId(int id);
+	
+	/** see set */
+	int getId(void);
+
 protected:
 	
@@ -201,4 +209,5 @@
 	bool mVisible;
 	int mDepth;
+	int mId;
 
 #endif // GTP_VISIBILITY_MODIFIED_OGRE
Index: trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/include/OgreTerrainRenderable.h
===================================================================
--- trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/include/OgreTerrainRenderable.h	(revision 131)
+++ trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/include/OgreTerrainRenderable.h	(revision 154)
@@ -47,4 +47,8 @@
 
 #define MORPH_CUSTOM_PARAM_ID 77
+
+#ifdef GTP_VISIBILITY_MODIFIED_OGRE
+#define MAX_RENDERLEVEL_INDEX 15
+#endif // GTP_VISIBILITY_MODIFIED_OGRE
 
 namespace Ogre
@@ -293,7 +297,12 @@
         /// Get the static list of indexes cached (internal use only)
         static TerrainBufferCache& _getIndexCache(void) {return msIndexCache;}
-		// index of renderlevel of current pass
-		static int getCurrentRenderLevelIndex() {return msCurrentRenderLevelIndex;}
-		static void setCurrentRenderLevelIndex(int index) {msCurrentRenderLevelIndex = index;}
+
+#ifdef GTP_VISIBILITY_MODIFIED_OGRE
+		// index of renderlevel used for current pass
+		static int getCurrentRenderLevelIndex();
+		// returns index of renderlevel
+		static void setCurrentRenderLevelIndex(int index);
+#endif // GTP_VISIBILITY_MODIFIED_OGRE
+
     protected:
 		// index of renderlevel of current pass
@@ -355,6 +364,11 @@
         VertexData* mTerrain;
 
-        /// The current LOD level: for multiple passes, up to 10 renderlevels can be saved
-        int mRenderLevel[10];
+        /// The current LOD level
+#ifdef GTP_VISIBILITY_MODIFIED_OGRE
+        int mRenderLevel[MAX_RENDERLEVEL_INDEX];
+#else
+		int mRenderLevel;
+#endif // GTP_VISIBILITY_MODIFIED_OGRE
+
         /// The previous 'next' LOD level down, for frame coherency
         int mLastNextLevel; 
Index: trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctree.cpp
===================================================================
--- trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctree.cpp	(revision 139)
+++ trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctree.cpp	(revision 154)
@@ -88,5 +88,5 @@
       mHalfSize( 0, 0, 0 )
 #ifdef GTP_VISIBILITY_MODIFIED_OGRE
-	, mLastVisited(0), mVisible(false), mLastRendered(-1)
+	, mLastVisited(0), mVisible(false), mLastRendered(-1), mId(-1)
 #endif //GTP_VISIBILITY_MODIFIED_OGRE
 {
@@ -271,4 +271,14 @@
 	}
  }
+//-----------------------------------------------------------------------
+void Octree::setId(int id)
+{
+	mId = id;
+}
+//-----------------------------------------------------------------------
+int Octree::getId()
+{
+	return mId;
+}
 #endif //GTP_VISIBILITY_MODIFIED_OGRE
 }
Index: trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreTerrainRenderable.cpp
===================================================================
--- trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreTerrainRenderable.cpp	(revision 139)
+++ trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreTerrainRenderable.cpp	(revision 154)
@@ -58,5 +58,8 @@
     bool TerrainRenderable::mLevelInit = false;
     const TerrainOptions* TerrainRenderable::msOptions = 0;
+
+#ifdef GTP_VISIBILITY_MODIFIED_OGRE
 	int TerrainRenderable::msCurrentRenderLevelIndex = 0;
+#endif // GTP_VISIBILITY_MODIFIED_OGRE
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
@@ -177,10 +180,12 @@
         mInit = true;
 
-//#ifdef GTP_VISIBILITY_MODIFIED_OGRE
-		// for up to 10 passes
-		for (int i = 0; i < 10; ++i)
+#ifdef GTP_VISIBILITY_MODIFIED_OGRE
+		for (int i = 0; i < MAX_RENDERLEVEL_INDEX; ++i)
 		{
 			mRenderLevel[i] = 1;
 		}
+#else
+		mRenderLevel = 1;
+#endif // GTP_VISIBILITY_MODIFIED_OGRE
 
         mMinLevelDistSqr = new Real[ msOptions->maxGeoMipMapLevel ];
@@ -330,5 +335,9 @@
         if ( mForcedRenderLevel >= 0 )
         {
+#ifdef GTP_VISIBILITY_MODIFIED_OGRE
             mRenderLevel[msCurrentRenderLevelIndex] = mForcedRenderLevel;
+#else
+			mRenderLevel = mForcedRenderLevel;
+#endif // GTP_VISIBILITY_MODIFIED_OGRE
             return ;
         }
@@ -339,5 +348,9 @@
         Real L = diff.squaredLength();
 
-		mRenderLevel[msCurrentRenderLevelIndex] = -1;
+#ifdef GTP_VISIBILITY_MODIFIED_OGRE
+            mRenderLevel[msCurrentRenderLevelIndex] = -1;;
+#else
+			mRenderLevel = -1;
+#endif // GTP_VISIBILITY_MODIFIED_OGRE
 
         for ( int i = 0; i < msOptions->maxGeoMipMapLevel; i++ )
@@ -345,16 +358,30 @@
             if ( mMinLevelDistSqr[ i ] > L )
             {
+#ifdef GTP_VISIBILITY_MODIFIED_OGRE
                 mRenderLevel[msCurrentRenderLevelIndex] = i - 1;
+#else
+			mRenderLevel = i - 1;
+#endif // GTP_VISIBILITY_MODIFIED_OGRE
                 break;
             }
         }
 
+#ifdef GTP_VISIBILITY_MODIFIED_OGRE
         if ( getRenderLevel() < 0 )
             mRenderLevel[msCurrentRenderLevelIndex] = msOptions->maxGeoMipMapLevel - 1;
+#else
+		if ( mRenderLevel < 0 )
+            mRenderLevel = msOptions->maxGeoMipMapLevel - 1;
+#endif // GTP_VISIBILITY_MODIFIED_OGRE
 
         if (msOptions->lodMorph)
         {
             // Get the next LOD level down
+#ifdef GTP_VISIBILITY_MODIFIED_OGRE
             int nextLevel = mNextLevelDown[getRenderLevel()];
+#else
+			int nextLevel = mNextLevelDown;
+#endif // GTP_VISIBILITY_MODIFIED_OGRE
+            
             if (nextLevel == 0)
             {
@@ -668,6 +695,9 @@
     void TerrainRenderable::_adjustRenderLevel( int i )
     {
-
+#ifdef GTP_VISIBILITY_MODIFIED_OGRE
         mRenderLevel[msCurrentRenderLevelIndex] = i;
+#else
+		mRenderLevel = i;
+#endif // GTP_VISIBILITY_MODIFIED_OGRE
     }
     //-----------------------------------------------------------------------
@@ -1469,5 +1499,19 @@
 
     }
-
+#ifdef GTP_VISIBILITY_MODIFIED_OGRE
+	//-----------------------------------------------------------------------
+	int TerrainRenderable::getCurrentRenderLevelIndex() 
+	{
+		return msCurrentRenderLevelIndex;
+	}
+	//-----------------------------------------------------------------------
+	void TerrainRenderable::setCurrentRenderLevelIndex(int index)
+	{
+		if (index > MAX_RENDERLEVEL_INDEX)
+			index = 0;
+
+		msCurrentRenderLevelIndex = index;
+	}
+#endif // GTP_VISIBILITY_MODIFIED_OGRE
 
 } //namespace
Index: trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctreeSceneManager.cpp
===================================================================
--- trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctreeSceneManager.cpp	(revision 139)
+++ trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctreeSceneManager.cpp	(revision 154)
@@ -318,4 +318,5 @@
 #ifdef GTP_VISIBILITY_MODIFIED_OGRE
 	mNumOctreeNodes = 1;
+	mOctree->setId(mNumOctreeNodes);
 #endif // GTP_VISIBILITY_MODIFIED_OGRE
     mMaxDepth = depth;
@@ -468,5 +469,5 @@
             octant -> mChildren[ x ][ y ][ z ] = new Octree( octant );
 #ifdef GTP_VISIBILITY_MODIFIED_OGRE
-	mNumOctreeNodes ++;
+	mOctree->setId(++ mNumOctreeNodes);
 #endif // GTP_VISIBILITY_MODIFIED_OGRE
 
@@ -1032,4 +1033,5 @@
 #ifdef GTP_VISIBILITY_MODIFIED_OGRE
 	mNumOctreeNodes = 1;
+	mOctree->setId(mNumOctreeNodes);
 #endif // GTP_VISIBILITY_MODIFIED_OGRE
     mOctree->mBox = box;
Index: trunk/VUT/work/ogre_changes/RenderSystems/GL/include/OgreSDLWindow.h
===================================================================
--- trunk/VUT/work/ogre_changes/RenderSystems/GL/include/OgreSDLWindow.h	(revision 154)
+++ trunk/VUT/work/ogre_changes/RenderSystems/GL/include/OgreSDLWindow.h	(revision 154)
@@ -0,0 +1,74 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+    (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2005 The OGRE Team
+Also see acknowledgements in Readme.html
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program 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 GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#ifndef __SDLWindow_H__
+#define __SDLWindow_H__
+
+#include "OgreSDLPrerequisites.h"
+#include "OgreRenderWindow.h"
+
+namespace Ogre {
+    class SDLWindow : public RenderWindow
+    {
+    private:
+        SDL_Surface* mScreen;
+        bool mActive;
+        bool mClosed;
+            
+        // Process pending events
+        void processEvents(void);
+    public:
+        SDLWindow();
+        ~SDLWindow();
+
+		void create(const String& name, unsigned int width, unsigned int height,
+	            bool fullScreen, const NameValuePairList *miscParams);
+        /** Overridden - see RenderWindow */
+        void destroy(void);
+        /** Overridden - see RenderWindow */
+        bool isActive(void) const;
+        /** Overridden - see RenderWindow */
+        bool isClosed(void) const;
+        /** Overridden - see RenderWindow */
+        void reposition(int left, int top);
+        /** Overridden - see RenderWindow */
+        void resize(unsigned int width, unsigned int height);
+        /** Overridden - see RenderWindow */
+        void swapBuffers(bool waitForVSync);
+
+        /** Overridden - see RenderTarget.
+        */
+        void writeContentsToFile(const String& filename);
+
+#ifdef GTP_VISIBILITY_MODIFIED_OGRE
+		uchar *getBufferContents(int &dimx, int &dimy) {dimx = dimy = 0; return NULL; };
+#endif // GTP_VISIBILITY_MODIFIED_OGRE
+
+		bool requiresTextureFlipping() const { return false; }
+    };
+}
+
+#endif
+
Index: trunk/VUT/work/ogre_changes/RenderSystems/Direct3D7/include/OgreD3D7Texture.h
===================================================================
--- trunk/VUT/work/ogre_changes/RenderSystems/Direct3D7/include/OgreD3D7Texture.h	(revision 154)
+++ trunk/VUT/work/ogre_changes/RenderSystems/Direct3D7/include/OgreD3D7Texture.h	(revision 154)
@@ -0,0 +1,230 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+    (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2005 The OGRE Team
+Also see acknowledgements in Readme.html
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program 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 GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+#ifndef _D3DTexture_H__
+#define _D3DTexture_H__
+
+#include "OgreD3D7Prerequisites.h"
+#include "OgreTexture.h"
+#include "OgreRenderTarget.h"
+#include "OgreRenderTexture.h"
+#include "OgreRenderTargetListener.h"
+#include "OgreD3D7HardwarePixelBuffer.h"
+
+namespace Ogre {
+
+    /** Direct3D7-specific texture resource implementation. 
+    */
+    class D3DTexture : public Texture
+    {
+    public:
+        // Constructor, called from D3DTextureManager
+        D3DTexture(ResourceManager* creator, const String& name, ResourceHandle handle,
+            const String& group, bool isManual, ManualResourceLoader* loader, 
+            IDirect3DDevice7 * lpDirect3dDevice);
+        virtual ~D3DTexture();
+
+        virtual void loadImage( const Image &img );
+		virtual void loadImage3D( const Image imgs[]);
+        virtual void copyToTexture(TexturePtr& target );
+
+        /// D3D-specific member that returns the underlying surface.
+        LPDIRECTDRAWSURFACE7 getDDSurface(void);
+
+        /// @copydoc Texture::createInternalResources
+        void createInternalResources(void);
+
+		/// @copydoc Texture::getBuffer
+		HardwarePixelBufferSharedPtr getBuffer(size_t face, size_t mipmap);
+
+		/// Static pixelformat functions
+		static D3DX_SURFACEFORMAT OgreFormat_to_D3DXFormat( PixelFormat format );
+		static PixelFormat closestD3DXFormat( PixelFormat format );
+		static bool OgreFormat_to_DDPixelFormat( PixelFormat format, DDPIXELFORMAT & out );
+    protected:
+        IDirect3DDevice7 * mD3DDevice;       ///< A pointer to the Direct3D device.
+        IDirectDrawSurface7 * mSurface;      ///< Surface of the (first) device-specific texture.
+		/// cube texture individual face names
+		String mCubeFaceNames[6];
+		/// Vector of pointers to subsurfaces
+		typedef std::vector<HardwarePixelBufferSharedPtr> SurfaceList;
+		SurfaceList						mSurfaceList;
+	
+
+        /// @copydoc Resource::loadImpl
+        void loadImpl(void);
+        /// @copydoc Resource::unloadImpl
+        void unloadImpl(void);
+		
+		void createSurface2D(void);
+		void createSurface3D(void);
+
+		/// internal method, return a D3D pixel format for texture creation
+		void _chooseD3DFormat(DDPIXELFORMAT &ddpf);
+
+		/// internal method, construct full cube texture face names from a given string
+		void _constructCubeFaceNames(const String name);
+
+		/// internal method, the cube map face name for the spec. face index
+		String _getCubeFaceName(unsigned char face) const
+		{ assert(face < 6); return mCubeFaceNames[face]; }
+
+		// Create the list of surfaces
+		void _createSurfaceList();
+    };
+
+    /** Specialisation of SharedPtr to allow SharedPtr to be assigned to D3DTexturePtr 
+    @note Has to be a subclass since we need operator=.
+    We could templatise this instead of repeating per Resource subclass, 
+    except to do so requires a form VC6 does not support i.e.
+    ResourceSubclassPtr<T> : public SharedPtr<T>
+    */
+    class D3DTexturePtr : public SharedPtr<D3DTexture> 
+    {
+    public:
+        D3DTexturePtr() : SharedPtr<D3DTexture>() {}
+        explicit D3DTexturePtr(D3DTexture* rep) : SharedPtr<D3DTexture>(rep) {}
+        D3DTexturePtr(const D3DTexturePtr& r) : SharedPtr<D3DTexture>(r) {} 
+        D3DTexturePtr(const ResourcePtr& r) : SharedPtr<D3DTexture>()
+        {
+			// lock & copy other mutex pointer
+			OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
+			OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
+            pRep = static_cast<D3DTexture*>(r.getPointer());
+            pUseCount = r.useCountPointer();
+            if (pUseCount)
+            {
+                ++(*pUseCount);
+            }
+        }
+
+        /// Operator used to convert a ResourcePtr to a D3DTexturePtr
+        D3DTexturePtr& operator=(const ResourcePtr& r)
+        {
+            if (pRep == static_cast<D3DTexture*>(r.getPointer()))
+                return *this;
+            release();
+			// lock & copy other mutex pointer
+			OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
+			OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
+            pRep = static_cast<D3DTexture*>(r.getPointer());
+            pUseCount = r.useCountPointer();
+            if (pUseCount)
+            {
+                ++(*pUseCount);
+            }
+            return *this;
+        }
+        /// Operator used to convert a TexturePtr to a D3DTexturePtr
+        D3DTexturePtr& operator=(const TexturePtr& r)
+        {
+            if (pRep == static_cast<D3DTexture*>(r.getPointer()))
+                return *this;
+            release();
+            pRep = static_cast<D3DTexture*>(r.getPointer());
+            pUseCount = r.useCountPointer();
+            if (pUseCount)
+            {
+                ++(*pUseCount);
+            }
+            return *this;
+        }
+    };
+
+
+    /// D3D7 implementation of RenderTexture
+    class D3D7RenderTexture : public RenderTexture
+    {
+    public:
+        D3D7RenderTexture( const String & name, 
+			unsigned int width, unsigned int height,
+			TextureType texType, PixelFormat internalFormat, 
+			const NameValuePairList *misc )
+			: RenderTexture( name, width, height, texType, internalFormat )
+        {
+            mPrivateTex = TextureManager::getSingleton().createManual(mName + 
+                "_PRIVATE##", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
+                texType, mWidth, mHeight, 0, internalFormat, TU_RENDERTARGET);
+            mPrivateTex->createInternalResources();
+        }
+
+		virtual ~D3D7RenderTexture()
+		{
+			mPrivateTex->unload();
+			TextureManager::getSingleton().remove(mPrivateTex->getName());
+		}
+
+		bool requiresTextureFlipping() const { return false; }
+
+        virtual void getCustomAttribute( const String& name, void* pData )
+        {
+            if( name == "DDBACKBUFFER" )
+            {
+                LPDIRECTDRAWSURFACE7 *pSurf = (LPDIRECTDRAWSURFACE7*)pData;
+
+                *pSurf = mPrivateTex->getDDSurface();
+                return;
+            }
+            else if( name == "DDFRONTBUFFER" )
+            {
+                LPDIRECTDRAWSURFACE7 *pSurf = (LPDIRECTDRAWSURFACE7*)pData;
+
+                *pSurf = mPrivateTex->getDDSurface();
+                return;
+            }
+            else if( name == "HWND" )
+            {
+                HWND *pHwnd = (HWND*)pData;
+
+                *pHwnd = NULL;
+                return;
+            }
+            else if( name == "isTexture" )
+            {
+                bool *b = reinterpret_cast< bool * >( pData );
+                *b = true;
+
+                return;
+            }
+        }
+        virtual void writeContentsToFile( const String & filename ) {}
+
+#ifdef GTP_VISIBILITY_MODIFIED_OGRE
+		uchar *getBufferContents(int &dimx, int &dimy) { dimx = dimy = 0; return NULL; };
+#endif // GTP_VISIBILITY_MODIFIED_OGRE
+
+    protected:
+        /// The texture to which rendering takes place.
+        D3DTexturePtr mPrivateTex;
+
+    protected:
+        virtual void _copyToTexture()
+        {
+            // Copy the newly-rendered data to the public texture surface.
+            mPrivateTex->copyToTexture( mTexture );
+        }
+    };
+}
+
+#endif
Index: trunk/VUT/work/ogre_changes/RenderSystems/Direct3D9/include/OgreD3D9Texture.h
===================================================================
--- trunk/VUT/work/ogre_changes/RenderSystems/Direct3D9/include/OgreD3D9Texture.h	(revision 153)
+++ trunk/VUT/work/ogre_changes/RenderSystems/Direct3D9/include/OgreD3D9Texture.h	(revision 154)
@@ -311,5 +311,5 @@
 
 #ifdef GTP_VISIBILITY_MODIFIED_OGRE
-		uchar *getBufferContents(int &dimx, int &dimy) { return NULL; };
+		uchar *getBufferContents(int &dimx, int &dimy) { dimx = dimy = 0; return NULL; };
 #endif // GTP_VISIBILITY_MODIFIED_OGRE
 
