فهرست منبع

It can compile but it has bugs
*Added the controller that affects the lights
*Added ToDo file
*Misc changes

Panagiotis Christopoulos Charitos 16 سال پیش
والد
کامیت
913c82bb6c
6فایلهای تغییر یافته به همراه46 افزوده شده و 11 حذف شده
  1. 1 0
      ToDo.txt
  2. 19 5
      src/resources/light_mtl.h
  3. 4 4
      src/resources/resource.h
  4. 0 1
      src/resources/texture.cpp
  5. 2 1
      src/scene/controller.h
  6. 20 0
      src/scene/light_controller.h

+ 1 - 0
ToDo.txt

@@ -0,0 +1 @@
+Make controllers generic

+ 19 - 5
src/resources/light_mtl.h

@@ -13,17 +13,31 @@ class texture_t;
 class light_mtl_t: public resource_t
 {
 	// data
-	PROPERTY_R( vec3_t, diffuse_col, GetDiffuseColor );
-	PROPERTY_R( vec3_t, specular_col, GetSpecularColor );
+	PROPERTY_R( vec3_t, diffuse_col, GetDiffuseColor )
+	PROPERTY_R( vec3_t, specular_col, GetSpecularColor )
+	PROPERTY_R( vec3_t, radius, GetRadius ) ///< For point lights
+	PROPERTY_R( bool, casts_shadow, CastsShadow ) ///< For spot lights
+	PROPERTY_R( float, distance, GetDistance ) ///< For spot lights. A.K.A.: camera's zfar
+	PROPERTY_R( float, fov_x, GetFovX ) ///< For spot lights
+	PROPERTY_R( float, fov_y, GetFovY ) ///< For spot lights
 		
 	private:
-		texture_t* texture;
+		texture_t* texture; ///< For spot lights
 	public:
-		const texture_t* GetTexture() const { DEBUG_ERR(texture==NULL); return texture; }
+		const texture_t& GetTexture() const { DEBUG_ERR(texture==NULL); return *texture; }
 	
 	// funcs	
 	public:
-		light_mtl_t(): diffuse_col(0.5), specular_col(0.5), texture(NULL) {}
+		light_mtl_t(): 
+			diffuse_col(0.5),
+			specular_col(0.5),
+			radius(1.0),
+			casts_shadow(false),
+			distance(3.0),
+			fov_x(m::PI/4.0),
+			fov_y(m::PI/4.0),
+			texture(NULL) 
+		{}
 		virtual ~light_mtl_t() { /* ToDo */ }
 		bool Load( const char* filename );
 		void Unload();

+ 4 - 4
src/resources/resource.h

@@ -5,6 +5,8 @@
 #include "engine_class.h"
 #include "util.h"
 
+
+// forward decls
 class texture_t;
 class material_t;
 class shader_prog_t;
@@ -13,8 +15,6 @@ class skeleton_t;
 class skel_anim_t;
 class light_mtl_t;
 
-
-// forward decl
 namespace rsrc {
 template< typename type_t > class container_t;
 }
@@ -52,7 +52,7 @@ class resource_t
 
 
 /// resource namespace
-namespace rsrc { // begin namesapce
+namespace rsrc {
 
 
 extern container_t<texture_t>     textures;
@@ -64,7 +64,7 @@ extern container_t<skel_anim_t>   skel_anims;
 extern container_t<light_mtl_t>   light_mtls;
 
 
-/// resource container class
+/// resource container template class
 template<typename type_t> class container_t: public vec_t<type_t*>
 {
 	private:

+ 0 - 1
src/resources/texture.cpp

@@ -1,7 +1,6 @@
 #include <fstream>
 #include <SDL/SDL_image.h>
 #include "texture.h"
-#include "resource.h"
 #include "renderer.h"
 
 

+ 2 - 1
src/scene/controller.h

@@ -14,7 +14,8 @@ class controller_t
 			CT_SKEL,
 			CT_MATERIAL,
 			CT_LIGHT_MTL,
-			CT_TRF
+			CT_TRF,
+			CT_LIGHT
 		};
 	
 	PROPERTY_R( type_e, type, GetType ) ///< Once the type is set nothing can change it

+ 20 - 0
src/scene/light_controller.h

@@ -0,0 +1,20 @@
+#ifndef _LIGHT_CONTROLLER_H_
+#define _LIGHT_CONTROLLER_H_
+
+#include "common.h"
+#include "controller.h"
+
+
+class light_t;
+
+
+class light_controller_t: public controller_t
+{
+	public:
+		light_t* light;
+		
+		light_controller_t( light_t* light_ ): controller(CT_LIGHT), light(light_) {}
+		void Update( float ) { /* ToDo */ }
+}
+
+#endif