Index: GTP/trunk/App/Demos/Illum/Ogre/src/Common/include/SceneSerializer.h
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/src/Common/include/SceneSerializer.h	(revision 1079)
+++ GTP/trunk/App/Demos/Illum/Ogre/src/Common/include/SceneSerializer.h	(revision 1079)
@@ -0,0 +1,53 @@
+#include "Ogre.h"
+
+using namespace Ogre;
+
+enum SceneScriptSection
+{
+	SSS_NONE,
+	SSS_MESH,
+	SSS_ENTITY		
+};
+
+struct SceneScriptContext 
+{
+	SceneScriptSection section;
+	size_t lineNo;
+	String filename;
+	SceneManager* sceneManager;
+	String entityName;
+	String meshName;
+	Entity* entity;
+	SceneNode* sceneNode;
+	std::map<String, String> meshFiles;	
+};
+
+typedef bool (*SCENE_ATTRIBUTE_PARSER)(String& params, SceneScriptContext& context);
+
+class SceneSerializer
+{
+protected:
+	/// Keyword-mapped attribute parsers.
+    typedef std::map<String, SCENE_ATTRIBUTE_PARSER> AttribParserList;
+
+	SceneScriptContext mScriptContext;
+	/** internal method for parsing a material
+       @returns true if it expects the next line to be a {
+    */
+    bool parseScriptLine(String& line);
+	/** internal method for finding & invoking an attribute parser. */
+    bool invokeParser(String& line, AttribParserList& parsers);
+
+	/// Parsers for the root of the material script
+    AttribParserList mRootAttribParsers;
+    /// Parsers for the material section of a script
+    AttribParserList mMeshAttribParsers;
+    /// Parsers for the technique section of a script
+    AttribParserList mEntityAttribParsers;
+
+public:
+
+	SceneSerializer(SceneManager* sm);
+	void parseScript(DataStreamPtr& stream, const String& groupName);
+
+};
Index: GTP/trunk/App/Demos/Illum/Ogre/src/Common/src/SceneSerializer.cpp
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/src/Common/src/SceneSerializer.cpp	(revision 1079)
+++ GTP/trunk/App/Demos/Illum/Ogre/src/Common/src/SceneSerializer.cpp	(revision 1079)
@@ -0,0 +1,215 @@
+#include "SceneSerializer.h"
+
+void logParseError(const String& error, const SceneScriptContext& context)
+{    
+        LogManager::getSingleton().logMessage(
+                    "Error at line " + StringConverter::toString(context.lineNo) + 
+                    " of " + context.filename + ": " + error);        
+}
+
+bool parseMeshFileName(String& params, SceneScriptContext& context)
+{
+	if(params == "")
+		logParseError("Error reading mesh filename!", context);
+
+	StringUtil::trim(params);
+	context.meshFiles[context.meshName] = params;
+
+	return false;
+}
+
+bool parseMeshName(String& params, SceneScriptContext& context)
+{
+	if(params == "")
+		logParseError("No mesh name given!", context);
+
+	//create the Entity with the given mesh, attach to a scene node
+	StringUtil::trim(params);
+	String meshfilename = context.meshFiles[params];
+	context.entity = context.sceneManager->createEntity(context.entityName, meshfilename);
+	SceneNode* root = context.sceneManager->getRootSceneNode();
+	context.sceneNode = root->createChildSceneNode(context.entityName);
+	context.sceneNode->attachObject(context.entity);
+
+    return false;
+}
+
+bool parseTransform(String& params, SceneScriptContext& context)
+{
+	Matrix4 transformMatrix = StringConverter::parseMatrix4(params);
+	context.sceneNode->setOrientation(transformMatrix.extractQuaternion());
+	Vector4 x(1,0,0,0);
+	x = transformMatrix * x;
+	Vector4 y(0,1,0,0);
+	y = transformMatrix * y;
+	Vector4 z(0,0,1,0);
+	z = transformMatrix * z;
+	context.sceneNode->scale((Vector3(x.x,x.y,x.z)).length(),
+								(Vector3(y.x,y.y,y.z)).length(),
+								(Vector3(z.x,z.y,z.z)).length());
+	context.sceneNode->translate(transformMatrix.getTrans());
+	return false;
+}
+
+bool parseMesh(String& params, SceneScriptContext& context)
+{
+	if(params == "")
+		logParseError("No mesh name given!", context);
+	
+	StringUtil::trim(params);
+	context.meshName = params;
+	context.section = SSS_MESH;
+	return true;
+}
+
+bool parseEntity(String& params, SceneScriptContext& context)
+{
+	if(params == "")
+		logParseError("No entity name given!", context);
+	
+	StringUtil::trim(params);
+	context.entityName = params;
+	context.section = SSS_ENTITY;
+	return true;
+}
+
+SceneSerializer::SceneSerializer(SceneManager* sm)
+{
+	mScriptContext.sceneManager = sm;
+	mScriptContext.section = SSS_NONE;
+
+	mRootAttribParsers.insert(AttribParserList::value_type("mesh", (SCENE_ATTRIBUTE_PARSER)parseMesh));
+	mRootAttribParsers.insert(AttribParserList::value_type("entity", (SCENE_ATTRIBUTE_PARSER)parseEntity));
+	
+	mMeshAttribParsers.insert(AttribParserList::value_type("ogrefile", (SCENE_ATTRIBUTE_PARSER)parseMeshFileName));
+
+	mEntityAttribParsers.insert(AttribParserList::value_type("mesh", (SCENE_ATTRIBUTE_PARSER)parseMeshName));
+	mEntityAttribParsers.insert(AttribParserList::value_type("transformation", (SCENE_ATTRIBUTE_PARSER)parseTransform));
+
+}
+
+ void SceneSerializer::parseScript(DataStreamPtr& stream, const String& groupName)
+ {
+    //String line;
+    bool nextIsOpenBrace = false;
+
+    mScriptContext.section = SSS_NONE;        
+    mScriptContext.lineNo = 0;		
+    mScriptContext.filename = stream->getName();
+	
+	char buffer[500];
+	//String summ = stream->getAsString();
+
+    while(!stream->eof())
+    {
+
+		stream->readLine(buffer, 500);
+				
+        String line = buffer;
+		StringUtil::trim(line,true, true);
+		
+        mScriptContext.lineNo++;
+        
+        // DEBUG LINE
+        // LogManager::getSingleton().logMessage("About to attempt line(#" + 
+        //    StringConverter::toString(mScriptContext.lineNo) + "): " + line);
+
+        // Ignore comments & blanks
+        if (!(line.length() == 0 || line.substr(0,2) == "//"))
+        {
+            if (nextIsOpenBrace)
+            {
+                // NB, parser will have changed context already
+                if (line != "{")
+                {
+                    logParseError("Expecting '{' but got " +
+                        line + " instead.", mScriptContext);
+                }
+                nextIsOpenBrace = false;
+            }
+            else
+            {
+                nextIsOpenBrace = parseScriptLine(line);
+            }
+
+        }
+    }
+
+    // Check all braces were closed
+    if (mScriptContext.section != SSS_NONE)
+    {
+        logParseError("Unexpected end of file.", mScriptContext);
+    }	
+
+  }
+
+ bool SceneSerializer::parseScriptLine(String& line)
+{
+    switch(mScriptContext.section)
+    {
+		case SSS_NONE:
+			if (line == "}")
+			{
+				logParseError("Unexpected terminating brace.", mScriptContext);
+				return false;
+			}
+			else
+			{
+				// find & invoke a parser
+				return invokeParser(line, mRootAttribParsers); 
+			}
+			break;
+		case SSS_MESH:
+			if (line == "}")
+			{
+				mScriptContext.section = SSS_NONE;
+				mScriptContext.meshName = "";
+				return false;
+			}
+			else
+			{
+				// find & invoke a parser
+				return invokeParser(line, mMeshAttribParsers); 
+			}
+			break;
+		case SSS_ENTITY:
+			if (line == "}")
+			{
+				// End of technique
+				mScriptContext.section = SSS_NONE;
+				mScriptContext.entity = 0;
+				mScriptContext.entityName = "";
+				mScriptContext.sceneNode = 0;
+				return false;
+			}
+			else
+			{
+				// find & invoke a parser
+				return invokeParser(line, mEntityAttribParsers); 
+			}
+			break;
+	}
+}
+
+bool SceneSerializer::invokeParser(String& line, AttribParserList& parsers)
+{
+    // First, split line on first divisor only
+    StringVector splitCmd(StringUtil::split(line, " \t", 1));
+
+    // Find attribute parser
+    AttribParserList::iterator iparser = parsers.find(splitCmd[0]);
+    if (iparser == parsers.end())
+    {
+        // BAD command. BAD!
+        logParseError("Unrecognised command: " + splitCmd[0], mScriptContext);
+        return false;
+    }
+    else
+    {
+        String cmd;
+        if(splitCmd.size() >= 2)
+            cmd = splitCmd[1];
+        // Use parser, make sure we have 2 params before using splitCmd[1]
+        return iparser->second( cmd, mScriptContext );
+    }
+}
Index: GTP/trunk/App/Demos/Illum/Ogre/src/GameToolsRaytraceDemo/src/GameToolsRaytraceDemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/src/GameToolsRaytraceDemo/src/GameToolsRaytraceDemo.cpp	(revision 777)
+++ GTP/trunk/App/Demos/Illum/Ogre/src/GameToolsRaytraceDemo/src/GameToolsRaytraceDemo.cpp	(revision 1079)
@@ -42,5 +42,5 @@
 {
 	if(strCmdLine[0] == '1')
-		HighQuality = true;
+		stereo = true;
 	
     // Create application object
