Procházet zdrojové kódy

Added RTTI for various Material/Shader classes

Marko Pintera před 13 roky
rodič
revize
4071a77c19

+ 4 - 0
CamelotRenderer/CamelotRenderer.vcxproj

@@ -121,10 +121,12 @@
     <ClInclude Include="Include\CmInput.h" />
     <ClInclude Include="Include\CmInput.h" />
     <ClInclude Include="Include\CmInputHandler.h" />
     <ClInclude Include="Include\CmInputHandler.h" />
     <ClInclude Include="Include\CmMaterial.h" />
     <ClInclude Include="Include\CmMaterial.h" />
+    <ClInclude Include="Include\CmMaterialRTTI.h" />
     <ClInclude Include="Include\CmMesh.h" />
     <ClInclude Include="Include\CmMesh.h" />
     <ClInclude Include="Include\CmMeshData.h" />
     <ClInclude Include="Include\CmMeshData.h" />
     <ClInclude Include="Include\CmMeshDataRTTI.h" />
     <ClInclude Include="Include\CmMeshDataRTTI.h" />
     <ClInclude Include="Include\CmPass.h" />
     <ClInclude Include="Include\CmPass.h" />
+    <ClInclude Include="Include\CmPassRTTI.h" />
     <ClInclude Include="Include\CmPrerequisites.h" />
     <ClInclude Include="Include\CmPrerequisites.h" />
     <ClInclude Include="Include\CmRenderable.h" />
     <ClInclude Include="Include\CmRenderable.h" />
     <ClInclude Include="Include\CmRenderableRTTI.h" />
     <ClInclude Include="Include\CmRenderableRTTI.h" />
@@ -145,7 +147,9 @@
     <ClInclude Include="Include\CmResources.h" />
     <ClInclude Include="Include\CmResources.h" />
     <ClInclude Include="Include\CmResourcesRTTI.h" />
     <ClInclude Include="Include\CmResourcesRTTI.h" />
     <ClInclude Include="Include\CmSceneManager.h" />
     <ClInclude Include="Include\CmSceneManager.h" />
+    <ClInclude Include="Include\CmShaderRTTI.h" />
     <ClInclude Include="Include\CmSpecificImporter.h" />
     <ClInclude Include="Include\CmSpecificImporter.h" />
+    <ClInclude Include="Include\CmTechniqueRTTI.h" />
     <ClInclude Include="Include\CmTexture.h" />
     <ClInclude Include="Include\CmTexture.h" />
     <ClInclude Include="Include\CmTextureManager.h" />
     <ClInclude Include="Include\CmTextureManager.h" />
     <ClInclude Include="Include\CmTextureRTTI.h" />
     <ClInclude Include="Include\CmTextureRTTI.h" />

+ 12 - 0
CamelotRenderer/CamelotRenderer.vcxproj.filters

@@ -289,6 +289,18 @@
     <ClInclude Include="Include\CmResourcesRTTI.h">
     <ClInclude Include="Include\CmResourcesRTTI.h">
       <Filter>Header Files\RTTI</Filter>
       <Filter>Header Files\RTTI</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="Include\CmPassRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmTechniqueRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmShaderRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmMaterialRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CamelotRenderer.cpp">
     <ClCompile Include="Source\CamelotRenderer.cpp">

+ 20 - 1
CamelotRenderer/Include/CmMaterial.h

@@ -1,10 +1,11 @@
 #pragma once
 #pragma once
 
 
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
+#include "CmResource.h"
 
 
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
-	class Material
+	class Material : public Resource
 	{
 	{
 		struct ParamsPerPass
 		struct ParamsPerPass
 		{
 		{
@@ -14,6 +15,13 @@ namespace CamelotEngine
 		};
 		};
 
 
 	public:
 	public:
+		Material() {}
+
+		/**
+		 * @brief	Overridden from Resource.
+		 */
+		virtual void initImpl() { }
+
 		/**
 		/**
 		 * @brief	Sets a shader that will be used by the material. 
 		 * @brief	Sets a shader that will be used by the material. 
 		 * 			Shaders best technique will be retrieved and used in all subsequent Material
 		 * 			Shaders best technique will be retrieved and used in all subsequent Material
@@ -24,6 +32,8 @@ namespace CamelotEngine
 		 */
 		 */
 		void setShader(ShaderPtr shader);
 		void setShader(ShaderPtr shader);
 
 
+		ShaderPtr getShader() const { return mShader; }
+
 		void setTexture(const String& name, TextureRef& value);
 		void setTexture(const String& name, TextureRef& value);
 		void setFloat(const String& name, float value);
 		void setFloat(const String& name, float value);
 		void setColor(const String& name, const Color& value);
 		void setColor(const String& name, const Color& value);
@@ -73,5 +83,14 @@ namespace CamelotEngine
 				}
 				}
 			}
 			}
 		}
 		}
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+		
+	public:
+		friend class MaterialRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;	
 	};
 	};
 }
 }

+ 44 - 0
CamelotRenderer/Include/CmMaterialRTTI.h

@@ -0,0 +1,44 @@
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRTTIType.h"
+#include "CmMaterial.h"
+
+namespace CamelotEngine
+{
+	class CM_EXPORT MaterialRTTI : public RTTIType<Material, Resource, MaterialRTTI>
+	{
+	private:
+		ShaderPtr getShader(Material* obj)
+		{
+			return obj->getShader();
+		}
+
+		void setShader(Material* obj,  ShaderPtr val)
+		{
+			obj->setShader(val);
+		}
+
+	public:
+		MaterialRTTI()
+		{
+			addReflectablePtrField("mShader", 0, &MaterialRTTI::getShader, &MaterialRTTI::setShader);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "Material";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_Material;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			return std::shared_ptr<Material>(new Material());
+		}
+	};
+}

+ 12 - 22
CamelotRenderer/Include/CmPass.h

@@ -3,6 +3,7 @@
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
 #include "CmCommon.h"
 #include "CmCommon.h"
 #include "CmColor.h"
 #include "CmColor.h"
+#include "CmIReflectable.h"
 
 
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
@@ -13,12 +14,9 @@ namespace CamelotEngine
         Each pass is a programmable pass (meaning it does
         Each pass is a programmable pass (meaning it does
         use either a vertex and fragment program, or both).
         use either a vertex and fragment program, or both).
     */
     */
-	class CM_EXPORT Pass
+	class CM_EXPORT Pass : public IReflectable
     {
     {
     protected:
     protected:
-        const Technique* mParent;
-        unsigned short mIndex; // pass index
-        String mName; // optional name for the pass
         //-------------------------------------------------------------------------
         //-------------------------------------------------------------------------
         // Blending factors
         // Blending factors
         SceneBlendFactor mSourceBlendFactor;
         SceneBlendFactor mSourceBlendFactor;
@@ -82,14 +80,12 @@ namespace CamelotEngine
 		float mPointSize;
 		float mPointSize;
 		float mPointMinSize;
 		float mPointMinSize;
 		float mPointMaxSize;
 		float mPointMaxSize;
-	public:
-		typedef set<Pass*>::type PassSet;
     public:
     public:
 		CM_MUTEX(mGpuProgramChangeMutex)
 		CM_MUTEX(mGpuProgramChangeMutex)
         /// Default constructor
         /// Default constructor
-		Pass(const Technique* parent, unsigned short index);
+		Pass();
         /// Copy constructor
         /// Copy constructor
-        Pass(const Technique* parent, unsigned short index, const Pass& oth );
+        Pass(const Pass& oth );
         /// Operator = overload
         /// Operator = overload
         Pass& operator=(const Pass& oth);
         Pass& operator=(const Pass& oth);
         virtual ~Pass();
         virtual ~Pass();
@@ -101,17 +97,6 @@ namespace CamelotEngine
         /// Returns true if this pass uses a programmable geometry pipeline
         /// Returns true if this pass uses a programmable geometry pipeline
         bool hasGeometryProgram(void) const { return mGeometryProgram != nullptr; }
         bool hasGeometryProgram(void) const { return mGeometryProgram != nullptr; }
 
 
-        /// Gets the index of this Pass in the parent Technique
-        unsigned short getIndex(void) const { return mIndex; }
-        /* Set the name of the pass
-        @remarks
-        The name of the pass is optional.  Its useful in material scripts where a material could inherit
-        from another material and only want to modify a particular pass.
-        */
-        void setName(const String& name);
-        /// get the name of the pass
-        const String& getName(void) const { return mName; }
-
         /** Gets the point size of the pass.
         /** Gets the point size of the pass.
 		@remarks
 		@remarks
 			This property determines what point size is used to render a point
 			This property determines what point size is used to render a point
@@ -463,9 +448,6 @@ namespace CamelotEngine
         */
         */
 		bool getTransparentSortingForced(void) const;
 		bool getTransparentSortingForced(void) const;
 
 
-		/// Gets the parent Technique
-        const Technique* getParent(void) const { return mParent; }
-
 		/** Sets the details of the vertex program to use.
 		/** Sets the details of the vertex program to use.
 		*/
 		*/
 		void setVertexProgram(GpuProgramRef gpuProgram);
 		void setVertexProgram(GpuProgramRef gpuProgram);
@@ -486,5 +468,13 @@ namespace CamelotEngine
 		
 		
 		/** Gets the geometry program used by this pass, only available after _load(). */
 		/** Gets the geometry program used by this pass, only available after _load(). */
 		const GpuProgramRef& getGeometryProgram(void) const;
 		const GpuProgramRef& getGeometryProgram(void) const;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+	public:
+		friend class PassRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;	
     };
     };
 }
 }

+ 154 - 0
CamelotRenderer/Include/CmPassRTTI.h

@@ -0,0 +1,154 @@
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRTTIType.h"
+#include "CmPass.h"
+
+namespace CamelotEngine
+{
+	class CM_EXPORT PassRTTI : public RTTIType<Pass, IReflectable, PassRTTI>
+	{
+	private:
+		SceneBlendFactor& getSourceBlendFactor(Pass* obj) { return obj->mSourceBlendFactor; }
+		void setSourceBlendFactor(Pass* obj, SceneBlendFactor& val) { obj->mSourceBlendFactor = val; } 
+
+		SceneBlendFactor& getDestBlendFactor(Pass* obj) { return obj->mDestBlendFactor; }
+		void setDestBlendFactor(Pass* obj, SceneBlendFactor& val) { obj->mDestBlendFactor = val; } 
+
+		SceneBlendFactor& getSourceBlendFactorAlpha(Pass* obj) { return obj->mSourceBlendFactorAlpha; }
+		void setSourceBlendFactorAlpha(Pass* obj, SceneBlendFactor& val) { obj->mSourceBlendFactorAlpha = val; } 
+
+		SceneBlendFactor& getDestBlendFactorAlpha(Pass* obj) { return obj->mDestBlendFactorAlpha; }
+		void setDestBlendFactorAlpha(Pass* obj, SceneBlendFactor& val) { obj->mDestBlendFactorAlpha = val; } 
+
+		bool& getSeparateBlend(Pass* obj) { return obj->mSeparateBlend; }
+		void setSeparateBlend(Pass* obj, bool& val) { obj->mSeparateBlend = val; } 
+
+		SceneBlendOperation& getBlendOperation(Pass* obj) { return obj->mBlendOperation; }
+		void setBlendOperation(Pass* obj, SceneBlendOperation& val) { obj->mBlendOperation = val; } 
+
+		SceneBlendOperation& getAlphaBlendOperation(Pass* obj) { return obj->mAlphaBlendOperation; }
+		void setAlphaBlendOperation(Pass* obj, SceneBlendOperation& val) { obj->mAlphaBlendOperation = val; } 
+
+		bool& getSeparateBlendOperation(Pass* obj) { return obj->mSeparateBlendOperation; }
+		void setSeparateBlendOperation(Pass* obj, bool& val) { obj->mSeparateBlendOperation = val; } 
+
+		bool& getDepthCheck(Pass* obj) { return obj->mDepthCheck; }
+		void setDepthCheck(Pass* obj, bool& val) { obj->mDepthCheck = val; } 
+
+		bool& getDepthWrite(Pass* obj) { return obj->mDepthWrite; }
+		void setDepthWrite(Pass* obj, bool& val) { obj->mDepthWrite = val; } 
+
+		CompareFunction& getCompareFunction(Pass* obj) { return obj->mDepthFunc; }
+		void setCompareFunction(Pass* obj, CompareFunction& val) { obj->mDepthFunc = val; } 
+
+		float& getDepthBiasConstant(Pass* obj) { return obj->mDepthBiasConstant; }
+		void setDepthBiasConstant(Pass* obj, float& val) { obj->mDepthBiasConstant = val; } 
+
+		float& getDepthBiasSlopeScale(Pass* obj) { return obj->mDepthBiasSlopeScale; }
+		void setDepthBiasSlopeScale(Pass* obj, float& val) { obj->mDepthBiasSlopeScale = val; } 
+
+		float& getDepthBiasPerIteration(Pass* obj) { return obj->mDepthBiasPerIteration; }
+		void setDepthBiasPerIteration(Pass* obj, float& val) { obj->mDepthBiasPerIteration = val; } 
+
+		bool& getColourWrite(Pass* obj) { return obj->mColourWrite; }
+		void setColourWrite(Pass* obj, bool& val) { obj->mColourWrite = val; } 
+
+		CompareFunction& getAlphaRejectFunc(Pass* obj) { return obj->mAlphaRejectFunc; }
+		void setAlphaRejectFunc(Pass* obj, CompareFunction& val) { obj->mAlphaRejectFunc = val; } 
+
+		UINT8& getAlphaRejectVal(Pass* obj) { return obj->mAlphaRejectVal; }
+		void setAlphaRejectVal(Pass* obj, UINT8& val) { obj->mAlphaRejectVal = val; } 
+
+		bool& getAlphaToCoverageEnabled(Pass* obj) { return obj->mAlphaToCoverageEnabled; }
+		void setAlphaToCoverageEnabled(Pass* obj, bool& val) { obj->mAlphaToCoverageEnabled = val; } 
+
+		bool& getTransparentSorting(Pass* obj) { return obj->mTransparentSorting; }
+		void setTransparentSorting(Pass* obj, bool& val) { obj->mTransparentSorting = val; } 
+
+		bool& getTransparentSortingForced(Pass* obj) { return obj->mTransparentSortingForced; }
+		void setTransparentSortingForced(Pass* obj, bool& val) { obj->mTransparentSortingForced = val; } 
+
+		CullingMode& getCullMode(Pass* obj) { return obj->mCullMode; }
+		void setCullMode(Pass* obj, CullingMode& val) { obj->mCullMode = val; } 
+
+		PolygonMode& getPolygonMode(Pass* obj) { return obj->mPolygonMode; }
+		void setPolygonMode(Pass* obj, PolygonMode& val) { obj->mPolygonMode = val; } 
+
+		size_t& getPassIterationCount(Pass* obj) { return obj->mPassIterationCount; }
+		void setPassIterationCount(Pass* obj, size_t& val) { obj->mPassIterationCount = val; } 
+
+		float& getPointSize(Pass* obj) { return obj->mPointSize; }
+		void setPointSize(Pass* obj, float& val) { obj->mPointSize = val; } 
+
+		float& getPointMinSize(Pass* obj) { return obj->mPointMinSize; }
+		void setPointMinSize(Pass* obj, float& val) { obj->mPointMinSize = val; } 
+
+		float& getPointMaxSize(Pass* obj) { return obj->mPointMaxSize; }
+		void setPointMaxSize(Pass* obj, float& val) { obj->mPointMaxSize = val; } 
+
+		GpuProgramRef& getVertexProgram(Pass* obj) { return obj->mVertexProgram; }
+		void setVertexProgram(Pass* obj, GpuProgramRef& val) { obj->mVertexProgram = val; } 
+
+		GpuProgramRef& getFragmentProgram(Pass* obj) { return obj->mFragmentProgram; }
+		void setFragmentProgram(Pass* obj, GpuProgramRef& val) { obj->mFragmentProgram = val; } 
+
+		GpuProgramRef& getGeometryProgram(Pass* obj) { return obj->mGeometryProgram; }
+		void setGeometryProgram(Pass* obj, GpuProgramRef& val) { obj->mGeometryProgram = val; } 
+	public:
+		PassRTTI()
+		{
+			addPlainField("mSourceBlendFactor", 0, &PassRTTI::getSourceBlendFactor, &PassRTTI::setSourceBlendFactor);
+			addPlainField("mDestBlendFactor", 1, &PassRTTI::getDestBlendFactor, &PassRTTI::setDestBlendFactor);
+			addPlainField("mSourceBlendFactorAlpha", 2, &PassRTTI::getSourceBlendFactorAlpha, &PassRTTI::setSourceBlendFactorAlpha);
+			addPlainField("mDestBlendFactorAlpha", 3, &PassRTTI::getDestBlendFactorAlpha, &PassRTTI::setDestBlendFactorAlpha);
+
+			addPlainField("mSeparateBlend", 4, &PassRTTI::getSeparateBlend, &PassRTTI::setSeparateBlend);
+			addPlainField("mBlendOperation", 5, &PassRTTI::getBlendOperation, &PassRTTI::setBlendOperation);
+			addPlainField("mAlphaBlendOperation", 6, &PassRTTI::getAlphaBlendOperation, &PassRTTI::setAlphaBlendOperation);
+			addPlainField("mSeparateBlendOperation", 7, &PassRTTI::getSeparateBlendOperation, &PassRTTI::setSeparateBlendOperation);
+
+			addPlainField("mDepthCheck", 8, &PassRTTI::getDepthCheck, &PassRTTI::setDepthCheck);
+			addPlainField("mDepthWrite", 9, &PassRTTI::getDepthWrite, &PassRTTI::setDepthWrite);
+			addPlainField("mDepthFunc", 10, &PassRTTI::getCompareFunction, &PassRTTI::setCompareFunction);
+			addPlainField("mDepthBiasConstant", 11, &PassRTTI::getDepthBiasConstant, &PassRTTI::setDepthBiasConstant);
+			addPlainField("mDepthBiasSlopeScale", 12, &PassRTTI::getDepthBiasSlopeScale, &PassRTTI::setDepthBiasSlopeScale);
+			addPlainField("mDepthBiasPerIteration", 13, &PassRTTI::getDepthBiasPerIteration, &PassRTTI::setDepthBiasPerIteration);
+
+			addPlainField("mColourWrite", 14, &PassRTTI::getColourWrite, &PassRTTI::setColourWrite);
+			addPlainField("mAlphaRejectFunc", 15, &PassRTTI::getAlphaRejectFunc, &PassRTTI::setAlphaRejectFunc);
+			addPlainField("mAlphaRejectVal", 16, &PassRTTI::getAlphaRejectVal, &PassRTTI::setAlphaRejectVal);
+			addPlainField("mAlphaToCoverageEnabled", 17, &PassRTTI::getAlphaToCoverageEnabled, &PassRTTI::setAlphaToCoverageEnabled);
+			addPlainField("mTransparentSorting", 18, &PassRTTI::getTransparentSorting, &PassRTTI::setTransparentSorting);
+			addPlainField("mTransparentSortingForced", 19, &PassRTTI::getTransparentSortingForced, &PassRTTI::setTransparentSortingForced);
+
+			addPlainField("mCullMode", 20, &PassRTTI::getCullMode, &PassRTTI::setCullMode);
+			addPlainField("mPolygonMode", 21, &PassRTTI::getPolygonMode, &PassRTTI::setPolygonMode);
+			addPlainField("mPassIterationCount", 22, &PassRTTI::getPassIterationCount, &PassRTTI::setPassIterationCount);
+
+			addPlainField("mPointSize", 23, &PassRTTI::getPointSize, &PassRTTI::setPointSize);
+			addPlainField("mPointMinSize", 24, &PassRTTI::getPointMinSize, &PassRTTI::setPointMinSize);
+			addPlainField("mPointMaxSize", 25, &PassRTTI::getPointMaxSize, &PassRTTI::setPointMaxSize);
+
+			addReflectableField("mVertexProgram", 26, &PassRTTI::getVertexProgram, &PassRTTI::setVertexProgram);
+			addReflectableField("mFragmentProgram", 27, &PassRTTI::getFragmentProgram, &PassRTTI::setFragmentProgram);
+			addReflectableField("mGeometryProgram", 28, &PassRTTI::getGeometryProgram, &PassRTTI::setGeometryProgram);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "Pass";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_Pass;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			return std::shared_ptr<Pass>(new Pass());
+		}
+	};
+}

+ 5 - 1
CamelotRenderer/Include/CmPrerequisites.h

@@ -161,7 +161,11 @@ namespace CamelotEngine
 		TID_GpuProgram = 1010,
 		TID_GpuProgram = 1010,
 		TID_ResourceRefData = 1011,
 		TID_ResourceRefData = 1011,
 		TID_CgProgram = 1012,
 		TID_CgProgram = 1012,
-		TID_ResourceMetaData = 1013
+		TID_ResourceMetaData = 1013,
+		TID_Pass = 1014,
+		TID_Technique = 1015,
+		TID_Shader = 1016,
+		TID_Material = 1017
 	};
 	};
 }
 }
 
 

+ 21 - 1
CamelotRenderer/Include/CmShader.h

@@ -1,6 +1,7 @@
 #pragma once
 #pragma once
 
 
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
+#include "CmResource.h"
 
 
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
@@ -13,11 +14,16 @@ namespace CamelotEngine
 	 *			system, render manager and other properties. So make sure to add most important techniques
 	 *			system, render manager and other properties. So make sure to add most important techniques
 	 *			first so you make sure they are used if they are supported.
 	 *			first so you make sure they are used if they are supported.
 	 */
 	 */
-	class CM_EXPORT Shader
+	class CM_EXPORT Shader : public Resource
 	{
 	{
 	public:
 	public:
 		Shader(const String& name);
 		Shader(const String& name);
 
 
+		/**
+		 * @brief	Inherited from Resource.
+		 */
+		virtual void initImpl();
+
 		TechniquePtr addTechnique(const String& renderSystem, const String& renderer);
 		TechniquePtr addTechnique(const String& renderSystem, const String& renderer);
 		
 		
 		void removeTechnique(UINT32 idx);
 		void removeTechnique(UINT32 idx);
@@ -34,5 +40,19 @@ namespace CamelotEngine
 	private:
 	private:
 		String mName;
 		String mName;
 		vector<TechniquePtr>::type mTechniques;
 		vector<TechniquePtr>::type mTechniques;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+		
+		/**
+		 * @brief	Serialization only
+		 */
+		Shader() {}
+
+	public:
+		friend class ShaderRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;	
 	};
 	};
 }
 }

+ 55 - 0
CamelotRenderer/Include/CmShaderRTTI.h

@@ -0,0 +1,55 @@
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRTTIType.h"
+#include "CmShader.h"
+
+namespace CamelotEngine
+{
+	class CM_EXPORT ShaderRTTI : public RTTIType<Shader, Resource, ShaderRTTI>
+	{
+	private:
+		TechniquePtr getTechnique(Shader* obj, UINT32 idx)
+		{
+			return obj->mTechniques[idx];
+		}
+
+		void setTechnique(Shader* obj, UINT32 idx, TechniquePtr val)
+		{
+			obj->mTechniques[idx] = val;
+		}
+
+		UINT32 getTechniqueArraySize(Shader* obj)
+		{
+			return obj->mTechniques.size();
+		}
+
+		void setTechniqueArraySize(Shader* obj, UINT32 size)
+		{
+			obj->mTechniques.resize(size);
+		}
+
+	public:
+		ShaderRTTI()
+		{
+			addReflectablePtrArrayField("mTechniques", 0, &ShaderRTTI::getTechnique, &ShaderRTTI::getTechniqueArraySize, 
+				&ShaderRTTI::setTechnique, &ShaderRTTI::setTechniqueArraySize);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "Shader";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_Shader;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			return std::shared_ptr<Shader>(new Shader());
+		}
+	};
+}

+ 16 - 1
CamelotRenderer/Include/CmTechnique.h

@@ -1,10 +1,11 @@
 #pragma once
 #pragma once
 
 
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
+#include "CmIReflectable.h"
 
 
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
-	class CM_EXPORT Technique
+	class CM_EXPORT Technique : public IReflectable
 	{
 	{
 	public:
 	public:
 		Technique(const String& renderSystem, const String& renderer);
 		Technique(const String& renderSystem, const String& renderer);
@@ -22,5 +23,19 @@ namespace CamelotEngine
 		String mRenderer;
 		String mRenderer;
 
 
 		vector<PassPtr>::type mPasses;
 		vector<PassPtr>::type mPasses;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+		
+		/**
+		 * @brief	Serialization only constructor.
+		 */
+		Technique() {}
+
+	public:
+		friend class TechniqueRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;	
 	};
 	};
 }
 }

+ 63 - 0
CamelotRenderer/Include/CmTechniqueRTTI.h

@@ -0,0 +1,63 @@
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRTTIType.h"
+#include "CmTechnique.h"
+
+namespace CamelotEngine
+{
+	class CM_EXPORT TechniqueRTTI : public RTTIType<Technique, IReflectable, TechniqueRTTI>
+	{
+	private:
+		String& getRenderSystem(Technique* obj) { return obj->mRenderSystem; }
+		void setRenderSystem(Technique* obj, String& val) { obj->mRenderSystem = val; } 
+
+		String& getRenderer(Technique* obj) { return obj->mRenderer; }
+		void setRenderer(Technique* obj, String& val) { obj->mRenderer = val; } 
+
+		PassPtr getPass(Technique* obj, UINT32 idx)
+		{
+			return obj->mPasses[idx];
+		}
+
+		void setPass(Technique* obj, UINT32 idx, PassPtr val)
+		{
+			obj->mPasses[idx] = val;
+		}
+
+		UINT32 getPassArraySize(Technique* obj)
+		{
+			return obj->mPasses.size();
+		}
+
+		void setPassArraySize(Technique* obj, UINT32 size)
+		{
+			obj->mPasses.resize(size);
+		}
+
+	public:
+		TechniqueRTTI()
+		{
+			addPlainField("mRenderSystem", 0, &TechniqueRTTI::getRenderSystem, &TechniqueRTTI::setRenderSystem);
+			addPlainField("mRenderer", 1, &TechniqueRTTI::getRenderer, &TechniqueRTTI::setRenderer);
+
+			addReflectablePtrArrayField("mPasses", 2, &TechniqueRTTI::getPass, &TechniqueRTTI::getPassArraySize, &TechniqueRTTI::setPass, &TechniqueRTTI::setPassArraySize);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "Technique";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_Technique;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			return std::shared_ptr<Technique>(new Technique());
+		}
+	};
+}

+ 1 - 1
CamelotRenderer/Include/CmTextureRTTI.h

@@ -40,7 +40,7 @@ namespace CamelotEngine
 
 
 		void setTextureData(Texture* obj, UINT32 face, TextureDataPtr data)
 		void setTextureData(Texture* obj, UINT32 face, TextureDataPtr data)
 		{
 		{
-			return obj->setTextureData(face, data);
+			obj->setTextureData(face, data);
 		}
 		}
 
 
 		UINT32 getTextureDataArraySize(Texture* obj)
 		UINT32 getTextureDataArraySize(Texture* obj)

+ 11 - 0
CamelotRenderer/Source/CmMaterial.cpp

@@ -7,6 +7,7 @@
 #include "CmRenderSystem.h"
 #include "CmRenderSystem.h"
 #include "CmGpuProgramParams.h"
 #include "CmGpuProgramParams.h"
 #include "CmGpuProgram.h"
 #include "CmGpuProgram.h"
+#include "CmMaterialRTTI.h"
 
 
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
@@ -146,4 +147,14 @@ namespace CamelotEngine
 			renderSystem->bindGpuProgramParameters(GPT_GEOMETRY_PROGRAM, params.mGeomParams, GPV_ALL);
 			renderSystem->bindGpuProgramParameters(GPT_GEOMETRY_PROGRAM, params.mGeomParams, GPV_ALL);
 		}	
 		}	
 	}
 	}
+
+	RTTITypeBase* Material::getRTTIStatic()
+	{
+		return MaterialRTTI::instance();
+	}
+
+	RTTITypeBase* Material::getRTTI() const
+	{
+		return Material::getRTTIStatic();
+	}
 }
 }

+ 16 - 17
CamelotRenderer/Source/CmPass.cpp

@@ -1,13 +1,12 @@
 #include "CmPass.h"
 #include "CmPass.h"
+#include "CmPassRTTI.h"
 #include "CmException.h"
 #include "CmException.h"
 
 
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
     //-----------------------------------------------------------------------------
     //-----------------------------------------------------------------------------
-	Pass::Pass(const Technique* parent, unsigned short index)
-        : mParent(parent)
-		, mIndex(index)
-		, mSourceBlendFactor(SBF_ONE)
+	Pass::Pass()
+		: mSourceBlendFactor(SBF_ONE)
 		, mDestBlendFactor(SBF_ZERO)
 		, mDestBlendFactor(SBF_ZERO)
 		, mSourceBlendFactorAlpha(SBF_ONE)
 		, mSourceBlendFactorAlpha(SBF_ONE)
 		, mDestBlendFactorAlpha(SBF_ZERO)
 		, mDestBlendFactorAlpha(SBF_ZERO)
@@ -34,17 +33,14 @@ namespace CamelotEngine
 		, mPointMinSize(0.0f)
 		, mPointMinSize(0.0f)
 		, mPointMaxSize(0.0f)	
 		, mPointMaxSize(0.0f)	
     {
     {
-        // default name to index
-        mName = toString(mIndex);
+
    }
    }
 
 
     //-----------------------------------------------------------------------------
     //-----------------------------------------------------------------------------
-	Pass::Pass(const Technique *parent, unsigned short index, const Pass& oth)
-        :mParent(parent), mIndex(index), mPassIterationCount(1)
+	Pass::Pass(const Pass& oth)
+        :mPassIterationCount(1)
     {
     {
         *this = oth;
         *this = oth;
-        mParent = parent;
-        mIndex = index;
     }
     }
     //-----------------------------------------------------------------------------
     //-----------------------------------------------------------------------------
     Pass::~Pass()
     Pass::~Pass()
@@ -54,8 +50,6 @@ namespace CamelotEngine
     //-----------------------------------------------------------------------------
     //-----------------------------------------------------------------------------
     Pass& Pass::operator=(const Pass& oth)
     Pass& Pass::operator=(const Pass& oth)
     {
     {
-        mName = oth.mName;
-
 	    // Default blending (overwrite)
 	    // Default blending (overwrite)
 	    mSourceBlendFactor = oth.mSourceBlendFactor;
 	    mSourceBlendFactor = oth.mSourceBlendFactor;
 	    mDestBlendFactor = oth.mDestBlendFactor;
 	    mDestBlendFactor = oth.mDestBlendFactor;
@@ -93,11 +87,6 @@ namespace CamelotEngine
 		return *this;
 		return *this;
     }
     }
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
-    void Pass::setName(const String& name)
-    {
-        mName = name;
-    }
-    //-----------------------------------------------------------------------
     void Pass::setPointSize(float ps)
     void Pass::setPointSize(float ps)
     {
     {
 	    mPointSize = ps;
 	    mPointSize = ps;
@@ -379,4 +368,14 @@ namespace CamelotEngine
 		CM_LOCK_MUTEX(mGpuProgramChangeMutex)
 		CM_LOCK_MUTEX(mGpuProgramChangeMutex)
 		return mGeometryProgram;
 		return mGeometryProgram;
 	}
 	}
+	//----------------------------------------------------------------------
+	RTTITypeBase* Pass::getRTTIStatic()
+	{
+		return PassRTTI::instance();
+	}
+	//----------------------------------------------------------------------
+	RTTITypeBase* Pass::getRTTI() const
+	{
+		return Pass::getRTTIStatic();
+	}
 }
 }

+ 14 - 0
CamelotRenderer/Source/CmShader.cpp

@@ -2,6 +2,7 @@
 #include "CmTechnique.h"
 #include "CmTechnique.h"
 #include "CmException.h"
 #include "CmException.h"
 #include "CmDebug.h"
 #include "CmDebug.h"
+#include "CmShaderRTTI.h"
 
 
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
@@ -11,6 +12,9 @@ namespace CamelotEngine
 
 
 	}
 	}
 
 
+	void Shader::initImpl()
+	{	}
+
 	TechniquePtr Shader::addTechnique(const String& renderSystem, const String& renderer)
 	TechniquePtr Shader::addTechnique(const String& renderSystem, const String& renderer)
 	{
 	{
 		TechniquePtr technique = TechniquePtr(new Technique(renderSystem, renderer));
 		TechniquePtr technique = TechniquePtr(new Technique(renderSystem, renderer));
@@ -59,4 +63,14 @@ namespace CamelotEngine
 
 
 		// TODO - Low priority. Instead of throwing an exception use an extremely simple technique that will be supported almost everywhere as a fallback.
 		// TODO - Low priority. Instead of throwing an exception use an extremely simple technique that will be supported almost everywhere as a fallback.
 	}
 	}
+
+	RTTITypeBase* Shader::getRTTIStatic()
+	{
+		return ShaderRTTI::instance();
+	}
+
+	RTTITypeBase* Shader::getRTTI() const
+	{
+		return Shader::getRTTIStatic();
+	}
 }
 }

+ 12 - 1
CamelotRenderer/Source/CmTechnique.cpp

@@ -5,6 +5,7 @@
 #include "CmRendererManager.h"
 #include "CmRendererManager.h"
 #include "CmPass.h"
 #include "CmPass.h"
 #include "CmRenderer.h"
 #include "CmRenderer.h"
+#include "CmTechniqueRTTI.h"
 
 
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
@@ -16,7 +17,7 @@ namespace CamelotEngine
 
 
 	PassPtr Technique::addPass()
 	PassPtr Technique::addPass()
 	{
 	{
-		PassPtr newPass(new Pass(this, mPasses.size()));
+		PassPtr newPass(new Pass());
 
 
 		mPasses.push_back(newPass);
 		mPasses.push_back(newPass);
 		return newPass;
 		return newPass;
@@ -56,4 +57,14 @@ namespace CamelotEngine
 
 
 		return false;
 		return false;
 	}
 	}
+
+	RTTITypeBase* Technique::getRTTIStatic()
+	{
+		return TechniqueRTTI::instance();
+	}
+
+	RTTITypeBase* Technique::getRTTI() const
+	{
+		return Technique::getRTTIStatic();
+	}
 }
 }

+ 6 - 0
CamelotRenderer/TODO.txt

@@ -15,10 +15,14 @@ High-level TODO:
  - DX11 render system
  - DX11 render system
 
 
 HIGH PRIORITY TODO:
 HIGH PRIORITY TODO:
+ - I need to store material parameters somewhere as well
+  - GpuProgramParams won't work because I want shader parameters to be stored independantly from the shader itself
  - GetRenderOperation doesn't consider sub-meshes
  - GetRenderOperation doesn't consider sub-meshes
  - HLSL & Cg don't handle include files yet
  - HLSL & Cg don't handle include files yet
 
 
 Mid priority TODO:
 Mid priority TODO:
+ - Add a field that tracks % of resource deserialization in BinarySerializer
+
  - Separate render thread
  - Separate render thread
    - CommandBuffer (technically it should be just a RenderQueue I think)
    - CommandBuffer (technically it should be just a RenderQueue I think)
    - Main thread updates components, finds visible meshes and creates render device. At end of execution it fills up render queue
    - Main thread updates components, finds visible meshes and creates render device. At end of execution it fills up render queue
@@ -60,6 +64,8 @@ Optional TODO:
 
 
 After everything is polished:
 After everything is polished:
  - Make sure the renderer can run on a separate thread
  - Make sure the renderer can run on a separate thread
+  - Command buffers that allow dx9, dx11 and opengl all use a separate render thread
+ - Load texture mips separately so we can unload HQ textures from far away objects (like UE3)
  - Get 64bit version working
  - Get 64bit version working
  - Add Unified shader so I can easily switch between HLSL and GLSL shaders (they need same parameters usually, just different code)
  - Add Unified shader so I can easily switch between HLSL and GLSL shaders (they need same parameters usually, just different code)
     - Maybe just add support for Cg and force everyone to use that? - I'd like to be able to just switch out renderer in a single location and that everything keeps on working without 
     - Maybe just add support for Cg and force everyone to use that? - I'd like to be able to just switch out renderer in a single location and that everything keeps on working without