Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjManualMeshLoader.h
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjManualMeshLoader.h	(revision 2109)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjManualMeshLoader.h	(revision 2109)
@@ -0,0 +1,24 @@
+#ifndef __IVManualMeshLoader_H__
+#define __IVManualMeshLoader_H__
+
+
+#include "Ogre.h"
+#include "ivmeshdata.h"
+
+
+class __declspec(dllexport) IVManualMeshLoader: public Ogre::ManualResourceLoader
+{
+	public:
+		IVManualMeshLoader();
+		IVManualMeshLoader(IVMeshData *mData);
+		~IVManualMeshLoader(); 
+
+		void loadResource(Ogre::Resource *resource);
+
+		Ogre::AxisAlignedBox *getBoundingBox();
+	private:
+		IVMeshData *data;
+
+};
+
+#endif
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjReader.h
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjReader.h	(revision 2109)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjReader.h	(revision 2109)
@@ -0,0 +1,131 @@
+#ifndef __mIVReader_H__
+#define __mIVReader_H__
+
+
+#include "ivnode.h"
+#include "ivmeshdata.h"
+#include "ivmanualmeshloader.h"
+#include "ogre.h"
+
+#define COMMENTCHAR '#'
+#define BLOCKSIZE 150
+#define BUFFERSIZE 256
+
+
+static const int validIVHeaderCnt = 2;
+
+static const char *validIVHeader[2] = {
+    { "#Inventor V2.1 ascii\n" },
+	{ "#VRML V1.0 ascii\n" },
+};
+
+
+enum IVTokenType
+{
+	IV_TOKEN_INVALID = -1,
+	IV_TOKEN_STRING = 0,
+	IV_TOKEN_INT = 1,
+	IV_TOKEN_REAL = 2,
+	IV_TOKEN_BRACEOPEN = 3,				// {
+	IV_TOKEN_BRACECLOSE = 4,			// }
+	IV_TOKEN_BRACKETOPEN = 5,			// [
+	IV_TOKEN_BRACKETCLOSE = 6,			// ]
+	IV_TOKEN_PARENTHESISOPEN = 7,		// (
+	IV_TOKEN_PARENTHESISCLOSE = 8,		// )
+	IV_TOKEN_DEF = 9,					// DEF
+	IV_TOKEN_USE = 10,					// USE
+};
+
+class __declspec(dllexport) IVMeshListNode
+{
+	public:
+		IVMeshListNode(std::string name, IVManualMeshLoader *loader);
+		~IVMeshListNode();
+
+		void attachNewNode(std::string name, IVManualMeshLoader *loader);
+
+		IVManualMeshLoader *getManualMeshLoader(std::string name);
+
+		IVMeshListNode *next;
+
+	private:
+		std::string name;
+		IVManualMeshLoader *loader;
+};
+
+class __declspec(dllexport) IVDefListNode
+{
+	public:
+		IVDefListNode(std::string name, IVNode *node);
+		~IVDefListNode();
+
+		void attachNewNode(std::string name, IVNode *node);
+
+		IVNode *getDef(std::string name);
+
+		IVDefListNode *next;
+
+	private:
+		std::string name;
+		IVNode *node;
+
+};
+
+class __declspec(dllexport) IVReader
+{
+	public:
+		IVReader();
+		~IVReader();
+
+		void setLog(Ogre::Log *IVLog = NULL);
+
+		bool loadFile(const char* filename);
+		void print();
+//		IVNode *getNode(const char* name);
+
+
+		void buildTree(Ogre::SceneManager *sceneMgr, Ogre::SceneNode *sceneNodeRoot);
+
+		void collapse();
+
+		static std::string intToStr(int num);
+		static std::string realToStr(Ogre::Real num);
+		
+		static Ogre::Log *IVLog;
+
+	private:
+		bool checkHeader(const char *string);
+		char buf[BUFFERSIZE];
+		int bufOffset;
+		bool getNextElement(char *token, IVTokenType *type);
+		void classify(char *token, IVTokenType *type);
+
+		bool isSpace(char c);
+		bool isNewline(char c);
+		bool eof;
+		bool isDigit(char c);
+		bool isHexDigit(char c);
+
+		IVNode *root;
+		FILE* infile;
+
+		static IVMeshListNode *meshList;
+		static void addMeshToList(std::string name, IVManualMeshLoader *loader);
+		
+		static int instanceCnt;
+
+		int treeCnt, nodeCnt, matCnt;
+		char *fileName;
+
+		Ogre::Entity *createEntity(Ogre::SceneManager* sceneMgr, std::string name, IVMeshData *mData, Ogre::Vector3 *translation = NULL);
+
+		void buildTree(Ogre::SceneManager *sceneMgr, Ogre::SceneNode *sceneNodeRoot, IVNode *mIVReaderoot, IVMeshData *mData = NULL, Ogre::Material *material = NULL);
+
+		IVDefListNode *defList;
+		void addDefToList(std::string name, IVNode *node);
+
+
+};
+
+
+#endif
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjNode.h
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjNode.h	(revision 2109)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjNode.h	(revision 2109)
@@ -0,0 +1,59 @@
+#ifndef __IVNode_H__
+#define __IVNode_H__
+
+
+#include <string.h>
+#include <Ogre.h>
+
+enum IVType
+{
+	IV_INVALID = -1,
+	IV_STRING = 0,
+	IV_INT = 1,
+	IV_REAL = 2
+};
+
+
+class IVField
+{
+public:
+	IVField();
+	~IVField();
+
+	char *name;
+	void *value;
+	IVType typ;
+	int cnt;
+	IVField *next;
+};
+
+class __declspec(dllexport) IVNode
+{
+	public:
+		IVNode();
+		IVNode(const char *s);
+		~IVNode();
+
+		void print(int ident=0);
+		void attachNode(IVNode *child);
+		void addField(const char *name, char *value);
+		void addField(const char *name, void *value, int cnt, IVType typ);
+
+		IVNode *getParent() { return parent; }
+		char *getName() { return name; }
+		IVNode *getNodeRecursive(const char *name);
+		IVNode *getNextChildNode(bool reset = false);
+		IVField *getField(const char *name);
+		void *getField(const char *name, IVType *typ, int *cnt);
+
+	private:
+		char *name;
+		IVField *fields;
+		IVNode *parent;
+		IVNode *children;
+		IVNode *next;
+
+		IVNode *actual;
+};
+
+#endif
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjMeshData.h
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjMeshData.h	(revision 2109)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjMeshData.h	(revision 2109)
@@ -0,0 +1,43 @@
+#ifndef __IVMeshData_H__
+#define __IVMeshData_H__
+
+
+#include <Ogre.h>
+
+enum mIVReaderenderOperationType
+{
+	IV_ROT_INVALID = -1,
+	IV_ROT_TRIANGLE_STRIP = 1,
+	IV_ROT_TRIANGLE_LIST = 3,
+	IV_ROT_FACE_SET = 4,
+};
+
+class __declspec(dllexport) IVMeshData
+{
+	public:	
+		IVMeshData();
+		~IVMeshData();
+
+		IVMeshData *expand();
+
+		void collapse();
+		
+		Ogre::Real *vertices, *normals, *texCoords, *indices, *normalIndices, *texCoordIndices;
+		int vcnt, ncnt, tcnt, icnt, nicnt, ticnt;
+		mIVReaderenderOperationType roType;
+		Ogre::AxisAlignedBox *boundingBox;
+
+	private:
+		int getSeparatorCnt(Ogre::Real *data, int end);
+
+		Ogre::Real *expandTriangleStripIndices(Ogre::Real *indices, int icnt, int *icntOut);
+		Ogre::Real *expandFaceSetIndices(Ogre::Real *indices, int icnt, int *icntOut);
+
+		int getNextFaceSize(int start);
+
+		Ogre::AxisAlignedBox *calcBoundingBox();
+
+
+};
+
+#endif
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.vcproj
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.vcproj	(revision 2109)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.vcproj	(revision 2109)
@@ -0,0 +1,373 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="7.10"
+	Name="IVReader"
+	ProjectGUID="{7319E499-473D-4CE5-9983-725D6E68A55D}"
+	Keyword="Win32Proj">
+	<Platforms>
+		<Platform
+			Name="Win32"/>
+	</Platforms>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="..\lib\$(ConfigurationName)"
+			IntermediateDirectory="..\obj\$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;..\include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;IVREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE"
+				MinimalRebuild="TRUE"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="OgreMain_d.lib CEGUIBase_d.lib OgreGUIRenderer_d.lib"
+				OutputFile="$(OutDir)/IVReader.dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;..\..\GtpVisibility\lib\$(ConfigurationName)&quot;;&quot;..\..\lib\$(ConfigurationName)&quot;;&quot;..\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)&quot;"
+				GenerateDebugInformation="TRUE"
+				ProgramDatabaseFile="$(OutDir)/$(ProjectName).pdb"
+				SubSystem="2"
+				ImportLibrary="$(OutDir)/IVReader.lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine="copy $(OutDir)\$(TargetFileName) &quot;$(OGRE_PATH)\Samples\Common\bin\$(ConfigurationName)&quot;"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="..\lib\$(ConfigurationName)"
+			IntermediateDirectory="..\obj\$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;..\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IVREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="OgreMain.lib CEGUIBase.lib OgreGUIRenderer.lib"
+				OutputFile="$(OutDir)/IVReader.dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;..\..\GtpVisibility\lib\$(ConfigurationName)&quot;;&quot;..\..\lib\$(ConfigurationName)&quot;;&quot;..\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)&quot;"
+				GenerateDebugInformation="FALSE"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				ImportLibrary="$(OutDir)/IVReader.lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine="copy $(OutDir)\$(TargetFileName) &quot;$(OGRE_PATH)\Samples\Common\bin\$(ConfigurationName)&quot;"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="mlrt|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;..\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IVREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="OgreMain.lib CEGUIBase.lib OgreGUIRenderer.lib"
+				OutputFile="$(OutDir)/IVReader.dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;..\..\GtpVisibility\lib\$(ConfigurationName)&quot;;&quot;..\..\lib\$(ConfigurationName)&quot;;&quot;..\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)&quot;"
+				GenerateDebugInformation="TRUE"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				ImportLibrary="$(OutDir)/IVReader.lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine="copy $(OutDir)\$(TargetFileName) &quot;$(OGRE_PATH)\Samples\Common\bin\$(ConfigurationName)&quot;"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Release_Internal|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;..\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IVREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="OgreMain.lib CEGUIBase.lib OgreGUIRenderer.lib"
+				OutputFile="$(OutDir)/IVReader.dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;..\..\GtpVisibility\lib\$(ConfigurationName)&quot;;&quot;..\..\lib\$(ConfigurationName)&quot;;&quot;..\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)&quot;"
+				GenerateDebugInformation="TRUE"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				ImportLibrary="$(OutDir)/IVReader.lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine="copy $(OutDir)\$(TargetFileName) &quot;$(OGRE_PATH)\Samples\Common\bin\$(ConfigurationName)&quot;"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Release Internal|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="3"
+				GlobalOptimizations="TRUE"
+				InlineFunctionExpansion="2"
+				EnableIntrinsicFunctions="TRUE"
+				FavorSizeOrSpeed="1"
+				OmitFramePointers="TRUE"
+				EnableFiberSafeOptimizations="TRUE"
+				OptimizeForProcessor="3"
+				OptimizeForWindowsApplication="TRUE"
+				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;..\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IVREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE"
+				StringPooling="TRUE"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="OgreMain.lib CEGUIBase.lib OgreGUIRenderer.lib"
+				OutputFile="$(OutDir)/IVReader.dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\OgreMain\lib\Release&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;..\..\GtpVisibility\lib\Release;..\..\lib\Release;..\lib\Release;&quot;$(OGRE_PATH)\Dependencies\lib\Release&quot;"
+				GenerateDebugInformation="TRUE"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				OptimizeForWindows98="1"
+				ImportLibrary="$(OutDir)/IVReader.lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine="copy $(OutDir)\$(TargetFileName) &quot;$(OGRE_PATH)\Samples\Common\bin\Release&quot;"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Release_qt|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;..\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IVREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="OgreMain.lib CEGUIBase.lib OgreGUIRenderer.lib"
+				OutputFile="$(OutDir)/IVReader.dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;..\..\GtpVisibility\lib\$(ConfigurationName)&quot;;&quot;..\..\lib\$(ConfigurationName)&quot;;&quot;..\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)&quot;"
+				GenerateDebugInformation="FALSE"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				ImportLibrary="$(OutDir)/IVReader.lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine="copy $(OutDir)\$(TargetFileName) &quot;$(OGRE_PATH)\Samples\Common\bin\$(ConfigurationName)&quot;"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+			<File
+				RelativePath="..\src\ivmanualmeshloader.cpp">
+			</File>
+			<File
+				RelativePath="..\src\ivmeshdata.cpp">
+			</File>
+			<File
+				RelativePath="..\src\ivnode.cpp">
+			</File>
+			<File
+				RelativePath="..\src\ivreader.cpp">
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+			<File
+				RelativePath="..\include\ivmanualmeshloader.h">
+			</File>
+			<File
+				RelativePath="..\include\ivmeshdata.h">
+			</File>
+			<File
+				RelativePath="..\include\ivnode.h">
+			</File>
+			<File
+				RelativePath="..\include\ivreader.h">
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjNode.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjNode.cpp	(revision 2109)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjNode.cpp	(revision 2109)
@@ -0,0 +1,215 @@
+#include "ivnode.h"
+#include "ivreader.h"
+
+IVField::IVField()
+{
+	next = NULL;
+	typ = IV_STRING;
+}
+
+
+IVField::~IVField()
+{
+	if (value != NULL) free(value);
+	if (name != NULL) delete [] name;
+//	if (next != NULL) delete next;
+}
+
+
+IVNode::IVNode()
+{
+	parent = children = next = actual = NULL; 
+	name = NULL;
+	fields = NULL;
+}
+
+
+IVNode::IVNode(const char *s)
+{
+	name = new char[strlen(s)+1];
+	strcpy(name, s);
+	parent = children = next = actual = NULL;
+	fields = NULL;	
+}
+
+IVNode::~IVNode()
+{
+	if (name != NULL) delete[] name;
+	if (fields != NULL) 
+	{
+		IVField *help = fields, *delme = NULL;
+		while (help->next != NULL)
+		{
+			delme = help; help = help->next; delete delme;
+		}
+		delete help;
+	}
+	if (children != NULL) 
+	{
+		IVNode *help = children, *delme = NULL;
+		while (help->next != NULL)
+		{
+			delme = help; help = help->next; delete delme;
+		}
+		delete help;
+	}
+//	if (next != NULL) delete next;
+}
+
+
+
+
+void IVNode::attachNode(IVNode *child)
+{
+	if (children == NULL) children = child;
+	else 
+	{
+		IVNode *help = children;
+		while (help->next != NULL) help = help->next;
+		help->next = child;
+	}
+	child->parent = this;
+}
+
+
+void IVNode::print(int ident)
+{
+	if (IVReader::IVLog != NULL)
+	{
+		std::string msg = ""; 
+
+//		for (int i=0; i < ident; i++) fprintf(stdout, " ");
+		for (int i=0; i < ident; i++) msg = msg + " ";
+//		fprintf(stdout, "%s:\n", name);
+		msg = msg + name + ":";
+		IVReader::IVLog->logMessage(msg);
+
+		IVField *help = fields;
+		while (help != NULL)
+		{
+//			for (int i=0; i < ident; i++) fprintf(stdout, " ");
+			msg = "";
+			for (int i=0; i < ident; i++) msg = msg + " ";
+			
+			if (help->typ == IV_STRING)
+			{
+//				fprintf(stdout, "- %s: %s\n", help->name, (char *)help->value);
+				msg = msg + "- " + help->name + ": " + (char *)help->value;
+				IVReader::IVLog->logMessage(msg);
+			}
+			if (help->typ == IV_INT)
+			{
+//				fprintf(stdout, "- %s (%d): ", help->name, help->cnt);
+				msg = msg + "- " + help->name + "(" + IVReader::intToStr(help->cnt) + "): ";
+//				for (int i=0; i < help->cnt; i++) fprintf(stdout, " %d", ((int *)help->value)[i]);
+				for (int i=0; i < help->cnt; i++) msg = msg + " " + IVReader::realToStr(((float *)help->value)[i]);
+//				fprintf(stdout, "\n");
+				IVReader::IVLog->logMessage(msg);
+			}
+			if (help->typ == IV_REAL)
+			{
+//				fprintf(stdout, "- %s (%d):\n", help->name, help->cnt);
+				msg = msg + "- " + help->name + "(" + IVReader::intToStr(help->cnt) + "): ";
+				for (int i=0; i < help->cnt; i++) 
+				{				
+//					fprintf(stdout, " %.3f", ((float *)help->value)[i]);
+					msg = msg + " " + IVReader::realToStr(((float *)help->value)[i]);
+//					if (i % 3 == 2) fprintf(stdout, "\n");
+					if (i % 3 == 2) msg = msg + "\n";
+				}
+//				fprintf(stdout, "\n");
+				IVReader::IVLog->logMessage(msg);
+			}
+			help = help->next;
+		}	
+		if (children != NULL) { children->print(ident+3); }
+		if (next != NULL) next->print(ident);
+	}
+}
+
+void IVNode::addField(const char *name, void *value, int cnt, IVType typ)
+{
+	IVField *newone = new IVField();
+	newone->name = new char[strlen(name)+1];
+	strcpy(newone->name, name);
+/*
+	if (typ == IV_STRING)
+	{
+		newone->value = new char[strlen((char *)value)+1];
+		strcpy((char *)newone->value, (char *)value);
+	} else
+	if ((typ == IV_INT) || (typ == IV_REAL))
+	{
+		newone->value = new Ogre::Real[cnt];
+		memcpy(newone->value, value, cnt*sizeof(Ogre::Real));
+	}
+*/
+	newone->value = value;
+	newone->typ = typ;
+	newone->cnt = cnt;
+	newone->next = NULL;
+
+	if (fields == NULL) fields = newone;
+	else
+	{
+		IVField *help = fields;
+		while (help->next != NULL) help = help->next;
+		help->next = newone;
+	}
+}
+
+
+void IVNode::addField(const char *name, char *value)
+{
+	addField(name, value, 1, IV_STRING);
+}
+
+
+IVNode *IVNode::getNodeRecursive(const char *name)
+{
+	if (strcmp(name, this->name) == 0) return this;
+	if (this->children != NULL)
+	{
+		IVNode *help = this->children->getNodeRecursive(name);
+		if (help != NULL) return help;
+	}
+	if (this->next != NULL) return this->next->getNodeRecursive(name); else return NULL;
+}
+
+
+IVNode *IVNode::getNextChildNode(bool reset)
+{
+	if (reset) actual = this->children;
+	else if (actual == NULL) actual = this->children; else actual = actual->next;
+	return actual;	
+}
+
+
+IVField *IVNode::getField(const char *name)
+{
+	IVField *help = fields;
+	while (help != NULL)
+	{
+		if (strcmp(name, help->name) == 0) return help;
+		help = help->next;
+	}
+	return NULL;
+}
+
+void *IVNode::getField(const char *name, IVType *typ, int *cnt)
+{
+	IVField *help = fields;
+	while (help != NULL)
+	{
+		if (strcmp(name, help->name) == 0) 
+		{
+			*typ = help->typ;
+			*cnt = help->cnt;
+			return help->value;
+		}
+		help = help->next;
+	}
+	*typ = IV_INVALID;
+	*cnt = 0;
+	return NULL;
+}
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjMeshData.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjMeshData.cpp	(revision 2109)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjMeshData.cpp	(revision 2109)
@@ -0,0 +1,266 @@
+#include "ivmeshdata.h"
+#include "ivreader.h"
+
+
+IVMeshData::IVMeshData()
+{ 
+	vertices = normals = texCoords = indices = normalIndices = texCoordIndices = NULL; 
+	vcnt = ncnt = tcnt = icnt = nicnt = ticnt = 0;
+	roType = IV_ROT_INVALID;
+	boundingBox = NULL;
+}
+
+IVMeshData::~IVMeshData()
+{ 
+}
+
+void IVMeshData::collapse()
+{
+	if (indices != NULL)	delete [] indices;
+	if (vertices != NULL)	delete [] vertices;
+	if (normals != NULL)	delete [] normals;
+	if (texCoords != NULL)	delete [] texCoords;
+	if (normalIndices != NULL) delete [] normalIndices;
+	if (texCoordIndices != NULL) delete [] texCoordIndices;
+	if (boundingBox != NULL) delete boundingBox;
+	indices = vertices = normals = texCoords = normalIndices = texCoords = NULL;
+	boundingBox = NULL;
+}
+
+int IVMeshData::getSeparatorCnt(Ogre::Real *data, int end)
+{
+	int cnt = 0;
+	for (int i=0; i < end; i++) if (data[i] < 0.f) cnt++; 
+	return cnt;
+}
+
+Ogre::AxisAlignedBox *IVMeshData::calcBoundingBox()
+{
+	if ((vertices == NULL) || (vcnt <=0)) 
+		return new Ogre::AxisAlignedBox(0, 0, 0, 0, 0, 0);
+
+	Ogre::Real x, y, z, minX, minY, minZ, maxX, maxY, maxZ;
+	minX = minY = minZ = 999999;
+	maxX = maxY = maxZ = -999999;
+	
+	for (int i=0; i<vcnt/3; i++) 
+	{
+		x = vertices[i*3];
+		if (minX > x) minX = x;	if (maxX < x) maxX = x;
+		y = vertices[i*3+1];
+		if (minY > y) minY = y;	if (maxY < y) maxY = y;
+		z = vertices[i*3+2];
+		if (minZ > z) minZ = z;	if (maxZ < z) maxZ = z;
+	}
+	
+	return new Ogre::AxisAlignedBox(minX, minY, minZ, maxX, maxY, maxZ);
+}
+
+
+Ogre::Real *IVMeshData::expandTriangleStripIndices(Ogre::Real *indices, int icnt, int *icntOut)
+{
+	if (indices[icnt-1] >= 0.0)
+		*icntOut = (icnt+1 - 3*(getSeparatorCnt(indices, icnt)+1))*3;
+	else
+		*icntOut = (icnt - 3*getSeparatorCnt(indices, icnt))*3;
+
+	Ogre::Real *indOut = new Ogre::Real[*icntOut];
+
+	int triangleCnt = 0, tc = 0;
+	for (int i=2; i < icnt; i++)
+	{
+		if (indices[i] >= 0)
+		{
+			if (tc % 2 == 0)
+			{
+				indOut[triangleCnt*3]   = indices[i-2]; 
+				indOut[triangleCnt*3+1] = indices[i-1];
+				indOut[triangleCnt*3+2] = indices[i];
+			}
+			else
+			{
+				indOut[triangleCnt*3]   = indices[i]; 
+				indOut[triangleCnt*3+1] = indices[i-1];
+				indOut[triangleCnt*3+2] = indices[i-2];
+			}
+			triangleCnt++; tc++;
+		}
+		else
+		{
+			i += 2; tc = 0;
+		}
+	}
+	return indOut;
+}	
+
+int IVMeshData::getNextFaceSize(int start)
+{
+	for (int i=start; i < icnt; i++) 
+	{
+		if (indices[i] < 0.f) return i - start;
+	}
+	return icnt - start;
+}
+
+Ogre::Real *IVMeshData::expandFaceSetIndices(Ogre::Real *indices, int icnt, int *icntOut)
+{
+	if (indices[icnt-1] >= 0.0)
+		*icntOut = (icnt+1 - 3*(getSeparatorCnt(indices, icnt)+1))*3;
+	else
+		*icntOut = (icnt - 3*getSeparatorCnt(indices, icnt))*3;
+	Ogre::Real *indOut = new Ogre::Real[*icntOut];
+
+	int index = 0, size = 0;
+	for (int i=0; i < icnt; i++)
+	{
+		if ((size = getNextFaceSize(i)) < 3) break;
+		for (int j=0; j < size-2; j++)
+		{
+			indOut[index] = indices[i]; index++;
+			indOut[index] = indices[i+1+j]; index++;
+			indOut[index] = indices[i+2+j]; index++;
+		}
+		i = i + size; 
+	}
+	return indOut;
+}
+
+IVMeshData *IVMeshData::expand()
+{
+	using namespace Ogre;
+
+	IVMeshData *mDataOut = new IVMeshData();
+
+	mDataOut->boundingBox = calcBoundingBox();
+	if ((vertices == NULL) || (vcnt <= 0) || (indices == NULL) || (icnt <= 0))
+	{
+		if (IVReader::IVLog != NULL)
+		{
+			std::string message = "Expand-Error: ((vertices == NULL) || (vcnt <= 0) || (indices == NULL) || (icnt <= 0))";
+			IVReader::IVLog->logMessage(message);
+		}
+	
+		return mDataOut;
+	}
+	bool nOk, tOk, niOk, tiOk, nperv, tperv;
+	nOk = ((normals != NULL) && (ncnt > 0));
+	tOk = ((texCoords != NULL) && (tcnt > 0));
+	nperv = (ncnt == vcnt) && (nicnt != icnt);
+	tperv = (tcnt*3 == vcnt*2) && (ticnt != icnt);
+
+	if ((nOk && !nperv) || (tOk && !tperv)) 
+	{
+		niOk = ((normalIndices != NULL) && (nicnt == icnt));
+		tiOk = ((texCoordIndices != NULL) && (ticnt == icnt));
+
+		if (!nperv && nOk && !niOk) nOk = false;
+		if (!tperv && tOk && !tiOk) tOk = false;
+
+		int sepcnt = getSeparatorCnt(indices, icnt);
+		mDataOut->icnt = icnt;
+		mDataOut->vcnt = (icnt - sepcnt)*3;
+		mDataOut->vertices = new Real[mDataOut->vcnt];
+
+		if (nOk) 
+		{
+			mDataOut->ncnt = mDataOut->vcnt;
+			mDataOut->normals = new Real[mDataOut->ncnt];
+		}
+		if (tOk)
+		{
+			mDataOut->tcnt = (icnt - sepcnt)*2;
+			mDataOut->texCoords = new Real[mDataOut->tcnt];
+		}
+		mDataOut->indices = new Real[mDataOut->icnt];
+
+		int index = 0;
+		for (int i=0; i < icnt; i++)
+		{
+			if (indices[i] >= 0.f)
+			{
+				mDataOut->vertices[index*3]   = vertices[(int)indices[i]*3];
+				mDataOut->vertices[index*3+1] = vertices[(int)indices[i]*3+1];
+				mDataOut->vertices[index*3+2] = vertices[(int)indices[i]*3+2];
+
+				if (nOk)
+				{
+					if (nperv)
+					{
+						mDataOut->normals[index*3]   = normals[(int)indices[i]*3];
+						mDataOut->normals[index*3+1] = normals[(int)indices[i]*3+1];
+						mDataOut->normals[index*3+2] = normals[(int)indices[i]*3+2];
+					}
+					else
+					{
+						mDataOut->normals[index*3]   = normals[(int)normalIndices[i]*3];
+						mDataOut->normals[index*3+1] = normals[(int)normalIndices[i]*3+1];
+						mDataOut->normals[index*3+2] = normals[(int)normalIndices[i]*3+2];
+					}
+				}
+				if (tOk)
+				{
+					if (tperv)
+					{
+						mDataOut->texCoords[index*2]   = texCoords[(int)indices[i]*2];
+						mDataOut->texCoords[index*2+1] = texCoords[(int)indices[i]*2+1];
+					}
+					else
+					{
+						mDataOut->texCoords[index*2]   = texCoords[(int)texCoordIndices[i]*2];
+						mDataOut->texCoords[index*2+1] = texCoords[(int)texCoordIndices[i]*2+1];
+					}
+				}
+
+				mDataOut->indices[i] = index;
+				index++;
+			}
+			else mDataOut->indices[i] = indices[i];
+		}
+	}
+	else
+	{
+		mDataOut->icnt = icnt;
+		mDataOut->indices = new Real[mDataOut->icnt];
+		memcpy(mDataOut->indices, indices, mDataOut->icnt*sizeof(Real));
+
+		mDataOut->vcnt = vcnt;
+		mDataOut->vertices = new Real[mDataOut->vcnt];
+		memcpy(mDataOut->vertices, vertices, mDataOut->vcnt*sizeof(Real));
+
+		if (nOk)
+		{
+			mDataOut->ncnt = ncnt;
+			mDataOut->normals = new Real[mDataOut->ncnt];
+			memcpy(mDataOut->normals, normals, mDataOut->ncnt*sizeof(Real));
+		}
+		if (tOk)
+		{
+			mDataOut->tcnt = tcnt;
+			mDataOut->texCoords = new Real[mDataOut->tcnt];
+			memcpy(mDataOut->texCoords, texCoords, mDataOut->tcnt*sizeof(Real));
+		}
+
+	}
+
+	int icntNew = 0;
+	Real *indicesNew = NULL;
+	mDataOut->roType = roType;
+
+	if (mDataOut->roType == IV_ROT_TRIANGLE_STRIP)	
+	{	
+		indicesNew = expandTriangleStripIndices(mDataOut->indices, mDataOut->icnt, &icntNew);
+	}
+	else if (mDataOut->roType == IV_ROT_FACE_SET)
+	{
+		indicesNew = expandFaceSetIndices(mDataOut->indices, mDataOut->icnt, &icntNew);
+	}
+	else 
+	{
+		return mDataOut;
+	}
+	delete [] mDataOut->indices;
+	mDataOut->indices = indicesNew;
+	mDataOut->icnt = icntNew;
+
+	return mDataOut;
+}
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjManualMeshLoader.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjManualMeshLoader.cpp	(revision 2109)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjManualMeshLoader.cpp	(revision 2109)
@@ -0,0 +1,155 @@
+#include "ivmanualmeshloader.h"
+#include "ivreader.h"
+
+IVManualMeshLoader::IVManualMeshLoader()
+{
+	data = NULL;
+}
+
+
+IVManualMeshLoader::IVManualMeshLoader(IVMeshData *mData)
+{
+	data = mData;
+/*	data = new IVMeshData();
+	if ((mData->indices != NULL) && (mData->icnt > 0))
+	{
+		data->icnt = mData->icnt;
+		data->indices = new Ogre::Real[mData->icnt];
+		memcpy(data->indices, mData->indices, mData->icnt*sizeof(Ogre::Real));
+	}
+	if ((mData->vertices != NULL) && (mData->vcnt > 0))
+	{
+		data->vcnt = mData->vcnt;
+		data->vertices = new Ogre::Real[mData->vcnt];
+		memcpy(data->vertices, mData->vertices, mData->vcnt*sizeof(Ogre::Real));
+	}
+	if ((mData->normals != NULL) && (mData->vcnt > 0))
+	{
+		data->ncnt = mData->ncnt;
+		data->normals = new Ogre::Real[mData->ncnt];
+		memcpy(data->normals, mData->normals, mData->ncnt*sizeof(Ogre::Real));
+	}
+	if ((mData->texCoords != NULL) && (mData->tcnt > 0))
+	{
+		data->tcnt = mData->tcnt;
+		data->texCoords = new Ogre::Real[mData->tcnt];
+		memcpy(data->texCoords, mData->texCoords, mData->tcnt*sizeof(Ogre::Real));
+	}
+	*/
+}
+
+IVManualMeshLoader::~IVManualMeshLoader()
+{
+/*	if (data != NULL)
+	{
+		if (data->vertices != NULL)		delete [] data->vertices;
+		if (data->normals != NULL)		delete [] data->normals;
+		if (data->texCoords != NULL)	delete [] data->texCoords;
+		if (data->indices != NULL)		delete [] data->indices;
+		delete data;
+	}
+	*/
+	if (data != NULL)
+	{
+		data->collapse();
+		delete data;
+	}
+}
+
+
+Ogre::AxisAlignedBox *IVManualMeshLoader::getBoundingBox()
+{
+	return data->boundingBox;
+}
+
+
+void IVManualMeshLoader::loadResource(Ogre::Resource *resource)
+{
+	using namespace Ogre;
+	Mesh *pMesh = (Mesh *) resource;
+
+
+	Vector3 translation = data->boundingBox->getCenter();
+
+	bool nOk = ((data->normals != NULL) && (data->ncnt > 0));
+	bool tOk = ((data->texCoords != NULL) && (data->tcnt > 0));
+	
+	pMesh->sharedVertexData = new VertexData(); 
+
+	VertexDeclaration* vertexDecl = pMesh->sharedVertexData->vertexDeclaration; 
+
+	size_t currOffset = 0; 
+	vertexDecl->addElement(0, currOffset, VET_FLOAT3, VES_POSITION); 
+	currOffset += VertexElement::getTypeSize(VET_FLOAT3); 
+	if (nOk)
+	{
+		vertexDecl->addElement(0, currOffset, VET_FLOAT3, VES_NORMAL); 
+		currOffset += VertexElement::getTypeSize(VET_FLOAT3); 
+	}
+    if (tOk)
+	{
+		vertexDecl->addElement(0, currOffset, VET_FLOAT2, VES_TEXTURE_COORDINATES); 
+		currOffset += VertexElement::getTypeSize(VET_FLOAT2); 
+	}
+
+	pMesh->sharedVertexData->vertexCount = data->vcnt/3; 
+	HardwareVertexBufferSharedPtr vbuf = 
+		HardwareBufferManager::getSingleton(). 
+		createVertexBuffer(vertexDecl->getVertexSize(0), pMesh->sharedVertexData->vertexCount, 
+			HardwareBuffer::HBU_STATIC_WRITE_ONLY, false); 
+
+	VertexBufferBinding* binding = pMesh->sharedVertexData->vertexBufferBinding; 
+	binding->setBinding(0, vbuf); 
+
+	Real* pVertices = static_cast<Real*>(vbuf->lock(HardwareBuffer::HBL_DISCARD)); 
+
+	int offset = 0, size = 3;
+	if (nOk) size += 3;
+	if (tOk) size += 2;
+	for (int i=0; i<data->vcnt/3; i++) 
+	{
+		pVertices[i*size]   = data->vertices[i*3]   - translation.x;
+		pVertices[i*size+1] = data->vertices[i*3+1] - translation.y;
+		pVertices[i*size+2] = data->vertices[i*3+2] - translation.z;
+
+		offset = 3;
+		if (nOk)
+		{
+			pVertices[i*size+offset] = data->normals[i*3];	 offset++;
+			pVertices[i*size+offset] = data->normals[i*3+1]; offset++;
+			pVertices[i*size+offset] = data->normals[i*3+2]; offset++;
+		}
+		if (tOk)
+		{
+			pVertices[i*size+offset] = data->texCoords[i*2];   offset++;
+			pVertices[i*size+offset] = -data->texCoords[i*2+1]; offset++;
+		}
+	}
+
+	vbuf->unlock(); 
+
+
+	SubMesh *pSub = pMesh->createSubMesh(); 
+	pSub->operationType = RenderOperation::OT_TRIANGLE_LIST; //;data->roType;
+	pSub->useSharedVertices = true; 
+
+	pSub->indexData->indexCount = data->icnt; 
+	pSub->indexData->indexBuffer = HardwareBufferManager::getSingleton(). 
+		createIndexBuffer(HardwareIndexBuffer::IT_16BIT, 
+			pSub->indexData->indexCount, HardwareBuffer::HBU_STATIC_WRITE_ONLY, false); 
+
+	HardwareIndexBufferSharedPtr ibuf = pSub->indexData->indexBuffer; 
+	unsigned short* pIndices = static_cast<unsigned short*>(ibuf->lock(HardwareBuffer::HBL_DISCARD)); 
+
+	for (i = 0; i < data->icnt; i++) pIndices[i] = data->indices[i];
+	
+	ibuf->unlock(); 
+		
+	AxisAlignedBox bb(data->boundingBox->getMinimum() - translation, data->boundingBox->getMaximum() - translation);
+	//AxisAlignedBox bb(data->boundingBox->getMinimum(), data->boundingBox->getMaximum());
+	pMesh->_setBounds(bb); 
+	Real radius = data->boundingBox->getMinimum().length();
+	if (data->boundingBox->getMaximum().length() > radius) radius = data->boundingBox->getMaximum().length();
+	pMesh->_setBoundingSphereRadius(radius); 
+
+}
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.cpp	(revision 2109)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.cpp	(revision 2109)
@@ -0,0 +1,777 @@
+#include "IVReader.h"
+#include <string>
+#include <stdlib.h>
+#include <sstream>
+
+IVMeshListNode *IVReader::meshList = NULL;
+int IVReader::instanceCnt = 0;
+Ogre::Log *IVReader::IVLog = NULL;
+
+
+
+IVMeshListNode::IVMeshListNode(std::string name, IVManualMeshLoader *loader)
+{
+	this->name = name;
+	this->loader = loader;
+	next = NULL;
+}
+
+IVMeshListNode::~IVMeshListNode()
+{
+	if (loader != NULL) delete loader;
+}
+
+void IVMeshListNode::attachNewNode(std::string name, IVManualMeshLoader *loader)
+{
+	IVMeshListNode *help = this;
+
+	while (help->next != NULL) help = help->next;
+	help->next = new IVMeshListNode(name, loader);
+}
+
+IVManualMeshLoader *IVMeshListNode::getManualMeshLoader(std::string name)
+{
+	IVMeshListNode *help = this;
+	if (help->name == name) return help->loader;
+	while (help->next != NULL) 
+	{
+		help = help->next;
+		if (help->name == name) return help->loader;
+	}
+	return NULL;
+}
+
+IVDefListNode::IVDefListNode(std::string name, IVNode *node)
+{
+	this->name = name;
+	this->node = node;
+	next = NULL;
+}
+
+IVDefListNode::~IVDefListNode()
+{
+}
+
+void IVDefListNode::attachNewNode(std::string name, IVNode *node)
+{
+	IVDefListNode *help = this;
+
+	while (help->next != NULL) help = help->next;
+	help->next = new IVDefListNode(name, node);
+}
+
+IVNode *IVDefListNode::getDef(std::string name)
+{
+	IVDefListNode *help = this;
+	if (help->name == name) return help->node;
+	while (help->next != NULL) 
+	{
+		help = help->next;
+		if (help->name == name) return help->node;
+	}
+	return NULL;
+}
+
+IVReader::IVReader()
+{	
+	root = NULL; meshList = NULL; defList = NULL; fileName = NULL;
+	instanceCnt++;
+	IVLog = NULL;
+}
+
+IVReader::~IVReader()
+{
+	collapse();
+
+	instanceCnt--;
+	if (instanceCnt == 0) if (meshList != NULL) 
+	{	
+		IVMeshListNode *help = meshList, *delme = NULL;
+		while (help->next != NULL)
+		{
+			delme = help; help = help->next; delete delme;
+		}
+		delete help;
+	}
+}
+
+void IVReader::collapse()
+{
+	if (root != NULL) {	delete root; root = NULL; }
+	if (defList != NULL)
+	{	
+		IVDefListNode *help = defList, *delme = NULL;
+		while (help->next != NULL)
+		{
+			delme = help; help = help->next; delete delme;
+		}
+		delete help;
+		defList = NULL;
+	}
+	if (this->fileName != NULL) { delete [] this->fileName; this->fileName = NULL; }
+
+}
+
+void IVReader::setLog(Ogre::Log *IVLog)
+{
+	this->IVLog = IVLog;
+}
+
+std::string IVReader::intToStr(int num)
+{
+	std::ostringstream myStream; 
+	myStream << num;
+	myStream.flush();
+	
+	return(myStream.str());
+}
+
+std::string IVReader::realToStr(Ogre::Real num)
+{
+	std::ostringstream myStream; 
+	myStream << num;
+	myStream.flush();
+	
+	return(myStream.str());
+}
+
+bool IVReader::loadFile(const char* fileName)
+{
+	std::string message = "trying to load "; message = message + fileName + "...";
+	
+	if (IVLog != NULL) 
+		IVLog->logMessage(message);
+	
+	collapse();
+	this->fileName = new char[strlen(fileName)+1]; strcpy(this->fileName, fileName);
+	treeCnt = 0;
+
+    infile = fopen(fileName, "r"); root = NULL;
+
+	if (infile == NULL)
+	{
+		message = "! Error loading File "; message = message + fileName + " !";
+		if (IVLog != NULL) IVLog->logMessage(message);
+		return false;
+	}
+
+	if ((fgets(buf, BUFFERSIZE, infile) == NULL) && !feof(infile)) 
+	{
+		message = "! Error loading File "; message = message + fileName + " !";
+		if (IVLog != NULL) IVLog->logMessage(message);
+		fclose(infile);
+		return false;
+	}
+
+	if (!checkHeader(buf)) 
+	{
+		message = "! Invalid Header !";
+		if (IVLog != NULL) IVLog->logMessage(message);
+		fclose(infile);
+		return false;
+	}
+
+	IVTokenType tmptyp = IV_TOKEN_INVALID;
+	eof = false;	
+
+	bufOffset = 0;
+	char token[BUFFERSIZE] = "\0", oldtoken[BUFFERSIZE] = "\0", fieldtoken[BUFFERSIZE] = "\0";
+	int level = 0; 
+
+	while (getNextElement(token, &tmptyp)) 
+	{
+		if (tmptyp == IV_TOKEN_BRACEOPEN) 
+		{
+			root = new IVNode(oldtoken);
+			level++;
+			break;
+		}
+
+		strcpy(oldtoken, token);
+	}
+
+	IVNode *actualNode = root, *parent = root, *fieldNode = root, *newNode = NULL;
+	IVTokenType oldtmptyp = tmptyp;
+	bool textfield = false, realfield = false; IVType fieldtyp = IV_INVALID;
+	bool def = false; std::string defLabel;
+	Ogre::Real rblock[BLOCKSIZE]; 
+	float *rvalues;
+	int cnt = 0; int blockcnt = 0;
+	while (getNextElement(token, &tmptyp))
+	{
+		if ((tmptyp == IV_TOKEN_BRACKETOPEN)) 
+			if (!getNextElement(token, &tmptyp)) break;
+		if ((tmptyp == IV_TOKEN_INVALID)) 
+			if (!getNextElement(token, &tmptyp)) break;
+		if (tmptyp == IV_TOKEN_BRACEOPEN) 
+		{
+			actualNode = new IVNode(oldtoken); 
+			if (parent == NULL)
+			{
+				message = "Error loading file "; message = message + fileName + "! Invalid tree structure.";
+				if (IVLog != NULL) IVLog->logMessage(message);
+				fclose(infile);
+				return false;
+			}
+			parent->attachNode(actualNode);
+			parent = actualNode;
+			level++;
+
+			if (def)
+			{
+				addDefToList(defLabel, actualNode);
+				def = false;
+			}
+
+		} else
+		if (tmptyp == IV_TOKEN_BRACECLOSE) 
+		{
+			if (realfield)
+			{
+				if (blockcnt == 0) rvalues = (Ogre::Real *)malloc((cnt)*sizeof(Ogre::Real));
+				else rvalues = (Ogre::Real *)realloc(rvalues, (BLOCKSIZE*(blockcnt) + cnt)*sizeof(Ogre::Real));						
+				memcpy((void *)&rvalues[BLOCKSIZE*blockcnt], rblock, cnt*sizeof(Ogre::Real));
+				fieldNode->addField(fieldtoken, rvalues, BLOCKSIZE*blockcnt+cnt, fieldtyp);
+				realfield = false;
+//				free(rvalues);
+			}
+
+			if (level > 0)
+			{
+				actualNode = parent = actualNode->getParent();
+				level--;
+			}
+		} else
+		{
+			if (oldtmptyp == IV_TOKEN_DEF)
+			{
+				def = true; defLabel = ""; defLabel = defLabel + token;
+			} else
+			if (oldtmptyp == IV_TOKEN_USE)
+			{
+					newNode = new IVNode("USE"); 
+					if (parent == NULL)
+					{
+						message = "Error loading file "; message = message + fileName + "! Invalid tree structure.";
+						if (IVLog != NULL) IVLog->logMessage(message);
+						fclose(infile);
+						return false;
+					}
+					char *s = (char *)malloc(sizeof(char)*(strlen(token)+1));
+					memcpy(s, token, strlen(token));
+					s[strlen(token)] = '\0';
+					newNode->addField("label", s);
+					actualNode->attachNode(newNode);
+			} else
+			if (!def)
+			if (oldtmptyp == IV_TOKEN_STRING)
+			{
+				if (!textfield)
+				{
+					if (tmptyp == IV_TOKEN_STRING)
+					{
+/*						char *s = new char[strlen(token)+1];
+						strcpy(s, token);
+*/						
+						char *s = (char *)malloc(sizeof(char)*(strlen(token)+1));
+						memcpy(s, token, strlen(token));
+						s[strlen(token)] = '\0';
+						actualNode->addField(oldtoken, s);
+//						delete [] s;
+					}
+				}
+				if (!realfield)
+				{
+					if ((tmptyp == IV_TOKEN_REAL) || (tmptyp == IV_TOKEN_INT))
+					{	
+						cnt = 0; blockcnt = 0;
+						char *stopstring;						
+						rblock[0] = strtod(token, &stopstring);
+						cnt++;
+						strcpy(fieldtoken, oldtoken);
+						fieldNode = actualNode;
+					    if (tmptyp == IV_TOKEN_REAL) fieldtyp = IV_REAL;
+						if (tmptyp == IV_TOKEN_INT)	fieldtyp = IV_INT;
+						realfield = true;
+					}
+				}
+				textfield = !textfield;
+			}
+			else 
+			{
+				if (realfield)	
+				{
+					if ((tmptyp == IV_TOKEN_REAL) || (tmptyp == IV_TOKEN_INT))
+					{		
+						char *stopstring;
+						if (cnt >= BLOCKSIZE) 
+						{
+							if (blockcnt == 0) rvalues = (Ogre::Real *)malloc((BLOCKSIZE)*sizeof(Ogre::Real));
+							else rvalues = (Ogre::Real *)realloc(rvalues, (BLOCKSIZE*(blockcnt+1))*sizeof(Ogre::Real));
+							memcpy((void *)&rvalues[BLOCKSIZE*blockcnt], rblock, BLOCKSIZE*sizeof(Ogre::Real));
+							cnt = 0;
+							blockcnt++;
+							
+						}
+						rblock[cnt] = strtod(token, &stopstring);
+						cnt++;
+					    if (tmptyp == IV_TOKEN_REAL) fieldtyp = IV_REAL;
+					}
+					else
+					{
+						if (blockcnt == 0) rvalues = (Ogre::Real *)malloc((cnt)*sizeof(Ogre::Real));
+						else rvalues = (Ogre::Real *)realloc(rvalues, (BLOCKSIZE*(blockcnt) + cnt)*sizeof(Ogre::Real));						
+						memcpy((void *)&rvalues[BLOCKSIZE*blockcnt], rblock, cnt*sizeof(Ogre::Real));
+						fieldNode->addField(fieldtoken, rvalues, BLOCKSIZE*blockcnt+cnt, fieldtyp);
+						realfield = false;
+//						free(rvalues);
+					}
+				}
+				
+				textfield = false;
+			}
+		}
+
+
+		strcpy(oldtoken, token);
+		oldtmptyp = tmptyp;
+	}
+	message = ""; ; message = message + fileName + " loaded.";
+	if (IVLog != NULL) IVLog->logMessage(message);
+	fclose(infile);
+
+	return true;
+}
+
+void IVReader::print()
+{
+	if (root != NULL) root->print();
+}
+
+bool IVReader::checkHeader(const char *string)
+{
+	for (int i=0; i < validIVHeaderCnt; i++)
+		if (strcmp(validIVHeader[i], string) == 0) return true;
+	return false;
+}
+bool IVReader::isSpace(char c)
+{
+	if ((c==' ') || (c=='\t')) return true;
+	return false;
+}
+bool IVReader::isNewline(char c)
+{
+	if (c=='\n') return true;
+	return false;
+}
+bool IVReader::isDigit(char c)
+{
+	if ((c>=48) && (c<=57)) return true;
+	return false;
+}
+bool IVReader::isHexDigit(char c)
+{
+	if ( ((c>=48) && (c<=57)) || ((c>=65) && (c<=70)) || ((c>=97) && (c<=102)) ) return true;
+	return false;
+}
+
+
+bool IVReader::getNextElement(char *token, IVTokenType *type)
+{
+	if (eof) return false;
+	bool quoted = false;
+	while (isSpace(buf[bufOffset])) bufOffset++;
+	int i=0;
+	while ((!isSpace(buf[bufOffset])) || (quoted))
+	{
+		if (!quoted)
+		{
+			if (isNewline(buf[bufOffset]) || (buf[bufOffset] == COMMENTCHAR))
+			{
+				token[i] = '\0'; 
+				classify(token, type);
+				bufOffset = 0;
+				if (fgets(buf, BUFFERSIZE, infile) == NULL) 
+				{			
+					eof = true;
+				}
+				if (i==0) return getNextElement(token, type);
+				return true;
+			}
+			if ((buf[bufOffset] == ',') || (buf[bufOffset] == ']'))
+			{
+				token[i] = '\0';
+				bufOffset++;
+				classify(token, type);
+				return true;
+			}
+		
+			
+
+		} else if (isNewline(buf[bufOffset])) {	eof = true;	}
+
+		
+		token[i] = buf[bufOffset]; 
+		i++;
+		if (buf[bufOffset] == '"') 
+		{
+			quoted = !quoted; i--;
+		}
+		bufOffset++;
+
+		
+	}
+	token[i] = '\0';
+	classify(token, type);
+	return true;
+}
+
+void IVReader::classify(char *token, IVTokenType *type)
+{
+	bool isInt = true, isReal = true;
+	if (!isDigit(token[0]) && (token[0] != '-') && (token[0] != '+')) 
+	{
+		isInt = false; 
+		if (token[0] != '.') isReal = false; 
+	}
+	int i = 1;
+	while ((token[i] != '\0') && isReal)
+	{
+		if (isInt && (i!=2) && !isHexDigit(token[i])) 
+		{
+			isInt = false;
+		}
+		if (isInt && (i==2) && !isHexDigit(token[i]) && (token[i] != 'x') && (token[i] != 'X')) isInt = false;
+		if (isReal && (!isDigit(token[i])) && (token[i] != '.') && (token[i] != 'e') && (token[i] != 'E') && (token[i] != 'd') && (token[i] != 'D') && (token[i] != '-') && (token[i] != '+')) isReal = false;
+		i++;
+	}
+	if (isInt) *type = IV_TOKEN_INT; 
+	else if (isReal) *type = IV_TOKEN_REAL;
+	else *type = IV_TOKEN_STRING;
+
+	if (strcmp(token, "DEF") == 0) *type = IV_TOKEN_DEF;
+	if (strcmp(token, "USE") == 0) *type = IV_TOKEN_USE;
+
+	if (token[1] == '\0')
+	{
+		if (token[0] == '{') *type = IV_TOKEN_BRACEOPEN;
+		if (token[0] == '}') *type = IV_TOKEN_BRACECLOSE;
+		if (token[0] == '[') *type = IV_TOKEN_BRACKETOPEN;
+		if (token[0] == ']') *type = IV_TOKEN_BRACKETCLOSE;
+		if (token[0] == '(') *type = IV_TOKEN_PARENTHESISOPEN;
+		if (token[0] == ')') *type = IV_TOKEN_PARENTHESISCLOSE;
+	}
+	if (token[0] == '\0')
+	{
+		*type = IV_TOKEN_INVALID;
+	}
+
+}
+
+/*
+IVNode *IVReader::getNode(const char* name)
+{
+	return root->getNodeRecursive(name);
+}
+*/
+void IVReader::addMeshToList(std::string name, IVManualMeshLoader *loader)
+{	
+	if (meshList == NULL) 
+	{
+		meshList = new IVMeshListNode(name, loader);
+	}
+	else
+	{
+		meshList->attachNewNode(name, loader);
+	}
+}
+
+void IVReader::addDefToList(std::string name, IVNode *node)
+{	
+	if (defList == NULL) 
+	{
+		defList = new IVDefListNode(name, node);
+	}
+	else
+	{
+		defList->attachNewNode(name, node);
+	}
+}
+
+Ogre::Entity *IVReader::createEntity(Ogre::SceneManager* sceneMgr, std::string name, IVMeshData *mData, Ogre::Vector3 *translation)
+{
+	using namespace Ogre;
+
+	std::string meshName = name.substr(name.find('/',0), name.length()) + "/Mesh";
+	std::string entityName = name + "/Entity";
+
+	Mesh* pMesh = NULL;
+	if ((pMesh = (Mesh *) MeshManager::getSingleton().getByName(meshName).getPointer()) == NULL)
+	{
+
+		IVMeshData *data = mData->expand();
+
+		IVManualMeshLoader *loader	= new IVManualMeshLoader(data);
+
+		if (translation != NULL) *translation = data->boundingBox->getCenter();
+
+//		data->collapse();
+//		delete data;
+
+
+		addMeshToList(meshName, loader);
+
+		Mesh* pMesh = MeshManager::getSingleton().createManual(meshName, "IVGroup", loader).getPointer(); 
+
+		pMesh->load(); 
+		pMesh->touch();
+	}
+	else
+	{
+		if (translation != NULL)
+		{
+			*translation = meshList->getManualMeshLoader(meshName)->getBoundingBox()->getCenter();
+		}
+	}
+
+	Entity *pEntity = sceneMgr->createEntity(entityName, meshName);
+
+
+	if (0) pEntity->setRenderQueueGroup(Ogre::RENDER_QUEUE_MAIN);
+
+	return pEntity;
+}
+
+
+
+void IVReader::buildTree(Ogre::SceneManager* sceneMgr,  Ogre::SceneNode *sceneNodeRoot)
+{
+	using namespace Ogre;
+	if (root == NULL) return;
+
+	std::string s = intToStr(treeCnt) + "/" + fileName + "/Root";
+	SceneNode *actualSceneNode = sceneNodeRoot->createChildSceneNode(s);
+	s = "/"; s = s + fileName + "/RootMaterial";
+	
+	Material* pMaterial = NULL;
+	if ((pMaterial = (Material *) MaterialManager::getSingleton().getByName(s).getPointer()) == NULL)
+	{
+		pMaterial = (Material *)MaterialManager::getSingleton().create(s, "General").getPointer();
+	}
+	pMaterial->load();
+
+	nodeCnt = 1; matCnt = 1;
+	
+
+	buildTree(sceneMgr, actualSceneNode, root, NULL, pMaterial);	
+	treeCnt++; 
+
+
+	std::string message = "Tree of "; message = message + fileName + " built (" + intToStr(nodeCnt) + " Nodes)";
+	if (IVLog != NULL) IVLog->logMessage(message);
+
+}
+
+void IVReader::buildTree(Ogre::SceneManager* sceneMgr,  
+						 Ogre::SceneNode *sceneNodeRoot, 
+						 IVNode *IVReaderoot, IVMeshData *mData, 
+						 Ogre::Material *material)
+{
+	using namespace Ogre;
+
+	Material *newMaterial = NULL;
+
+	bool meshDataCreated = false;
+	if (mData == NULL)
+	{
+		mData = new IVMeshData();
+		meshDataCreated = true;
+	}
+
+	IVType t; int i;
+	
+	IVNode *help = IVReaderoot->getNextChildNode(true);
+	while (help != NULL)
+	{	
+		if (strcmp(help->getName(), "USE") == 0)
+		{
+			char *defLabel = (char *) help->getField("label", &t, &i);
+			if (t == IV_STRING) 
+			{
+				help = defList->getDef(defLabel);
+			}
+		}
+		if ((strcmp(help->getName(), "Separator") == 0) || (strcmp(help->getName(), "TransformSeparator") == 0)) 
+		{
+/*			std::string s = sceneNodeRoot->getName() + "/Sep" + intToStr(nodeCnt);
+			nodeCnt++;
+			SceneNode *actualSceneNode = sceneNodeRoot->createChildSceneNode(s);
+			buildTree(sceneMgr, actualSceneNode, help, mData, actualMaterial);
+*/
+			if (newMaterial == NULL) newMaterial = material;
+			buildTree(sceneMgr, sceneNodeRoot, help, mData, newMaterial);
+		}
+
+		if (strcmp(help->getName(), "Texture2") == 0)
+		{
+			char *textureFileName = (char *) help->getField("filename", &t, &i);
+			if (t == IV_STRING) 
+			{  
+				std::string s = sceneNodeRoot->getName().substr(sceneNodeRoot->getName().find('/',0), sceneNodeRoot->getName().length()) + "/Material" + intToStr(matCnt);
+				matCnt++;
+				if ((newMaterial = (Material *) MaterialManager::getSingleton().getByName(s).getPointer()) == NULL)
+				{
+					newMaterial = (Material *)MaterialManager::getSingleton().create(s, "General").getPointer();
+					newMaterial->getTechnique(0)->getPass(0)->createTextureUnitState(textureFileName);
+				}
+				newMaterial->load();
+				newMaterial->reload();
+			}
+		}
+// can be included
+		if (strcmp(help->getName(), "Material") == 0)
+		{
+			Real *ambientColor = (Real *) help->getField("ambientColor", &t, &i);
+			if ((i != 3) || (t != IV_REAL)) ambientColor = NULL;
+			Real *diffuseColor = (Real *) help->getField("diffuseColor", &t, &i);
+			if ((i != 3) || (t != IV_REAL)) diffuseColor = NULL;
+			Real *specularColor = (Real *) help->getField("specularColor", &t, &i);
+			if ((i != 3) || (t != IV_REAL)) specularColor = NULL;
+			Real *emissiveColor = (Real *) help->getField("emissiveColor", &t, &i);
+			if ((i != 3) || (t != IV_REAL)) emissiveColor = NULL;
+			Real *shininess = (Real *) help->getField("shininess", &t, &i);
+			if ((i != 1) || (t != IV_REAL)) shininess = NULL;
+			Real *transparency = (Real *) help->getField("transparency", &t, &i);
+			if ((i != 1) || (t != IV_REAL)) transparency = NULL;
+
+			if (newMaterial == NULL)
+			{
+				std::string s = sceneNodeRoot->getName().substr(sceneNodeRoot->getName().find('/',0), sceneNodeRoot->getName().length()) + "/Material" + intToStr(matCnt);
+				matCnt++;
+				if ((newMaterial = (Material *) MaterialManager::getSingleton().getByName(s).getPointer()) == NULL)
+				{
+					if (material == NULL) newMaterial = (Material *)MaterialManager::getSingleton().create(s, "General").getPointer();
+					else newMaterial = material->clone(s).getPointer();
+
+					Real alpha = 1.f;
+					if (transparency != NULL) alpha = 1.f - transparency[0];
+					if (ambientColor != NULL) newMaterial->setAmbient(ambientColor[0], ambientColor[1], ambientColor[2]);
+					if (diffuseColor != NULL) newMaterial->setDiffuse(diffuseColor[0], diffuseColor[1], diffuseColor[2], alpha);
+					if (specularColor != NULL) newMaterial->setSpecular(specularColor[0], specularColor[1], specularColor[2], alpha);
+					if (emissiveColor != NULL) newMaterial->setSelfIllumination(emissiveColor[0], emissiveColor[1], emissiveColor[2]);
+					if (shininess != NULL) newMaterial->setShininess(shininess[0]);
+					
+//					if (material->getTechnique(0)->getPass(0)->getNumTextureUnitStates() > 0)							
+//					{
+//						newMaterial->getTechnique(0)->getPass(0)->createTextureUnitState(material->getTechnique(0)->getPass(0)->getTextureUnitState(0)->getTextureName());
+//					}
+				}
+				newMaterial->load();
+				newMaterial->reload();
+			}
+			else
+			{
+				Real alpha = 1.f;
+				if (transparency != NULL) alpha = 1.f - transparency[0];
+				if (ambientColor != NULL) newMaterial->setAmbient(ambientColor[0], ambientColor[1], ambientColor[2]);
+				if (diffuseColor != NULL) newMaterial->setDiffuse(diffuseColor[0], diffuseColor[1], diffuseColor[2], alpha);
+				if (specularColor != NULL) newMaterial->setSpecular(specularColor[0], specularColor[1], specularColor[2], alpha);
+				if (emissiveColor != NULL) newMaterial->setSelfIllumination(emissiveColor[0], emissiveColor[1], emissiveColor[2]);
+				if (shininess != NULL) newMaterial->setShininess(shininess[0]);
+				newMaterial->load();
+			}
+		}
+
+		if (strcmp(help->getName(), "Coordinate3") == 0)
+		{
+			mData->vertices = (Real *) help->getField("point", &t, &mData->vcnt);
+			if ((t != IV_REAL) && (t != IV_INT)) mData->vertices = NULL;
+		}
+		if (strcmp(help->getName(), "Normal") == 0)
+		{
+			mData->normals = (Real *) help->getField("vector", &t, &mData->ncnt);
+			if ((t != IV_REAL) && (t != IV_INT)) mData->normals = NULL;
+		}
+		if (strcmp(help->getName(), "TextureCoordinate2") == 0)
+		{
+			mData->texCoords = (Real *) help->getField("point", &t, &mData->tcnt);
+			if ((t != IV_REAL) && (t != IV_INT)) mData->texCoords = NULL;
+		}
+
+		if (strcmp(help->getName(), "IndexedFaceSet") == 0)
+		{
+			std::string s = sceneNodeRoot->getName() + "/IFS" + intToStr(nodeCnt);
+			nodeCnt++;
+			SceneNode *triangleStripSceneNode = sceneNodeRoot->createChildSceneNode(s);
+
+			mData->indices = (Real *) help->getField("coordIndex", &t, &mData->icnt);
+			if (t != IV_INT) mData->indices = NULL;
+
+			mData->normalIndices = (Real *) help->getField("normalIndex", &t, &mData->nicnt);
+			if (t != IV_INT) mData->normalIndices = NULL;
+		
+			mData->texCoordIndices = (Real *) help->getField("textureCoordIndex", &t, &mData->ticnt);
+			if (t != IV_INT) mData->texCoordIndices = NULL;
+		
+
+			mData->roType = IV_ROT_FACE_SET;		
+	
+			Vector3 translation = Vector3(0,0,0);
+			Entity *pEntity = createEntity(sceneMgr, s, mData, &translation);
+			if (newMaterial == NULL) newMaterial = material;
+			if (newMaterial != NULL) pEntity->setMaterialName(newMaterial->getName());
+				
+			triangleStripSceneNode->attachObject(pEntity);
+			triangleStripSceneNode->translate(translation);		
+
+		}
+
+
+		if (strcmp(help->getName(), "IndexedTriangleStripSet") == 0)
+		{
+			std::string s = sceneNodeRoot->getName() + "/ITS" + intToStr(nodeCnt);
+			nodeCnt++;
+			SceneNode *triangleStripSceneNode = sceneNodeRoot->createChildSceneNode(s);
+		
+			mData->indices = (Real *) help->getField("coordIndex", &t, &mData->icnt);
+			if (t != IV_INT) mData->indices = NULL;
+
+			mData->normalIndices = (Real *) help->getField("normalIndex", &t, &mData->nicnt);
+			if (t != IV_INT) mData->normalIndices = NULL;
+
+			mData->texCoordIndices = (Real *) help->getField("textureCoordIndex", &t, &mData->ticnt);
+			if (t != IV_INT) mData->texCoordIndices = NULL;
+
+			IVNode *n = help->getNextChildNode(true);
+			while ((n != NULL) && (strcmp(help->getName(), "VertexProperty") == 0))
+			{
+				n = help->getNextChildNode();
+			}
+			if (n != NULL)
+			{
+				mData->vertices = (Real *) n->getField("vertex", &t, &mData->vcnt);
+				if ((t != IV_REAL) && (t != IV_INT)) mData->vertices = NULL;
+
+				mData->normals = (Real *) n->getField("normal", &t, &mData->ncnt);
+				if ((t != IV_REAL) && (t != IV_INT)) mData->normals = NULL;
+				mData->texCoords = (Real *) n->getField("texCoord", &t, &mData->tcnt);
+				if ((t != IV_REAL) && (t != IV_INT)) mData->texCoords = NULL;
+			}
+
+			mData->roType = IV_ROT_TRIANGLE_STRIP;		
+
+			Vector3 translation = Vector3(0,0,0);
+			Entity *pEntity = createEntity(sceneMgr, s, mData, &translation);
+			if (newMaterial == NULL) newMaterial = material;
+			if (newMaterial != NULL) pEntity->setMaterialName(newMaterial->getName());
+				
+			triangleStripSceneNode->attachObject(pEntity);
+			triangleStripSceneNode->translate(translation);		
+
+		}
+
+		help = IVReaderoot->getNextChildNode();
+	}
+	if (meshDataCreated) if (mData != NULL) delete mData;
+}
+
