Sfoglia il codice sorgente

python: exposing some scene stuff

Panagiotis Christopoulos Charitos 14 anni fa
parent
commit
64dd1621d7

File diff suppressed because it is too large
+ 0 - 0
build/debug/Makefile


+ 1 - 1
src/Main.cpp

@@ -291,7 +291,7 @@ void mainLoopExtra()
 
 
 	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_T))
 	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_T))
 	{
 	{
-		pentagram->getModelPatchNodees()[0]->getCpMtlRun().getUserDefinedVarByName("specularCol").get<Vec3>() = Vec3(10.0, -1.6, 1.6);
+		pentagram->getModelPatchNodees()[0]->setUserDefVar(PatchNode::MT_BOTH, "specularCol", Vec3(10.0, -1.6, 1.6));
 		pentagram->getModelPatchNodees()[0]->getCpMtlRun().getUserDefinedVarByName("shininess").get<float>() = 10.0;
 		pentagram->getModelPatchNodees()[0]->getCpMtlRun().getUserDefinedVarByName("shininess").get<float>() = 10.0;
 	}
 	}
 
 

+ 11 - 0
src/Scene/MaterialRuntime/MaterialRuntime.h

@@ -31,6 +31,10 @@ class MaterialRuntime
 		const MtlUserDefinedVarRuntime& getUserDefinedVarByName(const char* name) const;
 		const MtlUserDefinedVarRuntime& getUserDefinedVarByName(const char* name) const;
 
 
 		const Material& getMaterial() const {return mtl;}
 		const Material& getMaterial() const {return mtl;}
+
+		/// @todo
+		template<typename Type>
+		void setUserDefVar(const char* name, const Type& value);
 		/// @}
 		/// @}
 
 
 	private:
 	private:
@@ -40,4 +44,11 @@ class MaterialRuntime
 };
 };
 
 
 
 
+template<typename Type>
+void MaterialRuntime::setUserDefVar(const char* name, const Type& value)
+{
+	getUserDefinedVarByName(name).get<Type>() = value;
+}
+
+
 #endif
 #endif

+ 28 - 1
src/Scene/PatchNode.h

@@ -8,10 +8,10 @@
 #include "RsrcPtr.h"
 #include "RsrcPtr.h"
 #include "ModelPatch.h"
 #include "ModelPatch.h"
 #include "RenderableNode.h"
 #include "RenderableNode.h"
+#include "MaterialRuntime.h"
 
 
 
 
 class Material;
 class Material;
-class MaterialRuntime;
 
 
 
 
 /// Inherited by ModelPatchNode and SkinPatchNode. It contains common code, the derived classes are responsible to
 /// Inherited by ModelPatchNode and SkinPatchNode. It contains common code, the derived classes are responsible to
@@ -19,6 +19,14 @@ class MaterialRuntime;
 class PatchNode: public RenderableNode
 class PatchNode: public RenderableNode
 {
 {
 	public:
 	public:
+		/// Passed as parameter in setUserDefVar
+		enum MaterialType
+		{
+			MT_COLOR_PASS,
+			MT_DEPTH_PASS,
+			MT_BOTH
+		};
+
 		PatchNode(const ModelPatch& modelPatch, SceneNode* parent);
 		PatchNode(const ModelPatch& modelPatch, SceneNode* parent);
 
 
 		/// Do nothing
 		/// Do nothing
@@ -38,6 +46,10 @@ class PatchNode: public RenderableNode
 		const Vao& getCpVao() const {return cpVao;}
 		const Vao& getCpVao() const {return cpVao;}
 		const Vao& getDpVao() const {return dpVao;}
 		const Vao& getDpVao() const {return dpVao;}
 		uint getVertIdsNum() const {return rsrc.getMesh().getVertIdsNum();}
 		uint getVertIdsNum() const {return rsrc.getMesh().getVertIdsNum();}
+
+		/// @todo
+		template<typename Type>
+		void setUserDefVar(MaterialType mt, const char* name, const Type& value);
 		/// @}
 		/// @}
 
 
 	protected:
 	protected:
@@ -52,4 +64,19 @@ class PatchNode: public RenderableNode
 };
 };
 
 
 
 
+template<typename Type>
+void PatchNode::setUserDefVar(MaterialType mt, const char* name, const Type& value)
+{
+	if(mt == MT_COLOR_PASS || mt == MT_BOTH)
+	{
+		cpMtlRun->setUserDefVar(name, value);
+	}
+
+	if(mt == MT_DEPTH_PASS || mt == MT_BOTH)
+	{
+		dpMtlRun->setUserDefVar(name, value);
+	}
+}
+
+
 #endif
 #endif

+ 12 - 0
src/Scripting/Scene/Camera.bpi.cpp

@@ -0,0 +1,12 @@
+#include "ScriptingCommon.h"
+#include "Camera.h"
+
+
+WRAP(Camera)
+{
+	class_<Camera, noncopyable>("Camera", no_init)
+		.def("setFovX", &Camera::setFovX)
+		.def("getFovX", &Camera::getFovX)
+	;
+}
+

+ 3 - 0
src/Scripting/Scene/Scene.bpi.cpp

@@ -8,6 +8,9 @@ WRAP(Scene)
 		.def("setAmbientCol", &Scene::setAmbientCol)
 		.def("setAmbientCol", &Scene::setAmbientCol)
 		.def("getAmbientCol", (const Vec3& (Scene::*)() const)(&Scene::getAmbientCol),
 		.def("getAmbientCol", (const Vec3& (Scene::*)() const)(&Scene::getAmbientCol),
 		     return_value_policy<reference_existing_object>())
 		     return_value_policy<reference_existing_object>())
+
+		.def("getCameras", (Scene::Types<Camera>::Container& (Scene::*)())(&Scene::getCameras),
+		     return_value_policy<reference_existing_object>())
 	;
 	;
 }
 }
 
 

Some files were not shown because too many files changed in this diff