Просмотр исходного кода

It can compile and its working ok (for now)
*Renamed hundlers to app
*Renamed light_mtl to the more generic light_props

Panagiotis Christopoulos Charitos 16 лет назад
Родитель
Сommit
73961f7cb6

+ 3 - 0
shaders/dp_generic.glsl

@@ -2,6 +2,9 @@
 
 #pragma anki include "shaders/hw_skinning.glsl"
 
+uniform vec3 position;
+uniform vec2 tex_coords;
+
 varying vec2 tex_coords_v2f;
 
 void main()

+ 31 - 23
src/main.cpp

@@ -9,9 +9,8 @@
 #include "gmath.h"
 #include "renderer.h"
 #include "hud.h"
-#include "handlers.h"
+#include "app.h"
 #include "particles.h"
-#include "primitives.h"
 #include "texture.h"
 #include "mesh.h"
 #include "light.h"
@@ -29,7 +28,7 @@
 #include "skel_controller.h"
 #include "skel_anim_controller.h"
 #include "skel_node.h"
-#include "light_mtl.h"
+#include "light_props.h"
 
 
 // map (hard coded)
@@ -37,7 +36,7 @@ camera_t* main_cam;
 mesh_node_t* floor__,* sarge,* horse;
 skel_model_node_t* imp;
 point_light_t* point_lights[10];
-spot_light_t* projlights[2];
+spot_light_t* spot_lights[2];
 
 
 //=====================================================================================================================================
@@ -53,8 +52,8 @@ void Init()
 	srand( unsigned(time(NULL)) );
 	MathSanityChecks();
 
-	hndl::InitWindow( r::w, r::h, "AnKi Engine" );
-	uint ticks = hndl::GetTicks();
+	app::InitWindow( r::w, r::h, "AnKi Engine" );
+	uint ticks = app::GetTicks();
 
 	r::Init();
 	hud::Init();
@@ -67,9 +66,15 @@ void Init()
 
 	// lights
 	point_lights[0] = new point_light_t();
-	point_lights[0]->light_mtl = rsrc::light_mtls.Load( "maps/temple/light0.lmtl" );
+	point_lights[0]->Init( "maps/temple/light0.light" );
 	point_lights[0]->SetLocalTransformation( vec3_t( -1.0, 2.4, 1.0 ), mat3_t::GetIdentity(), 1.0 );
-	point_lights[0]->radius = 2.0;
+	point_lights[1] = new point_light_t();
+	point_lights[1]->Init( "maps/temple/light1.light" );
+	point_lights[1]->SetLocalTransformation( vec3_t( 2.5, 1.4, 1.0 ), mat3_t::GetIdentity(), 1.0 );
+
+	spot_lights[0] = new spot_light_t();
+	spot_lights[0]->Init( "maps/temple/light2.light" );
+	spot_lights[0]->SetLocalTransformation( vec3_t( 1.3, 4.3, 3.0 ), mat3_t( euler_t(ToRad(-20), ToRad(20), 0.0) ), 1.0 );
 
 	// horse
 	horse = new mesh_node_t();
@@ -81,6 +86,11 @@ void Init()
 	sarge->Init( "meshes/sarge/sarge.mesh" );
 	sarge->SetLocalTransformation( vec3_t( 0, -2.8, 1.0 ), mat3_t( euler_t(-m::PI/2, 0.0, 0.0) ), 0.1 );
 	
+	// floor
+	floor__ = new mesh_node_t();
+	floor__->Init( "maps/temple/Cube.019.mesh" );
+	floor__->SetLocalTransformation( vec3_t(0.0, -0.19, 0.0), mat3_t( euler_t(-m::PI/2, 0.0, 0.0) ), 0.8 );
+
 	// imp	
 	imp = new skel_model_node_t();
 	imp->Init( "models/imp/imp.smdl" );
@@ -89,17 +99,15 @@ void Init()
 	imp->mesh_nodes[0]->skel_controller->skel_node->skel_anim_controller->step = 0.8;
 
 
-	// floor
-	floor__ = new mesh_node_t();
-	floor__->Init( "maps/temple/Cube.019.mesh" );
-	floor__->SetLocalTransformation( vec3_t(0.0), mat3_t( euler_t(-m::PI/2, 0.0, 0.0) ), 0.8 );
+
 
 
 	const char* skybox_fnames [] = { "textures/env/hellsky4_forward.tga", "textures/env/hellsky4_back.tga", "textures/env/hellsky4_left.tga",
 																	 "textures/env/hellsky4_right.tga", "textures/env/hellsky4_up.tga", "textures/env/hellsky4_down.tga" };
 	scene::skybox.Load( skybox_fnames );
 
-	PRINT( "Engine initialization ends (" << hndl::GetTicks()-ticks << ")" );
+	PRINT( "Engine initialization ends (" << app::GetTicks()-ticks << ")" );
+	cerr.flush();
 }
 
 
@@ -111,10 +119,10 @@ int main( int /*argc*/, char* /*argv*/[] )
 	Init();
 
 	PRINT( "Entering main loop" );
-	int ticks = hndl::GetTicks();
+	int ticks = app::GetTicks();
 	do
 	{
-		int ticks_ = hndl::GetTicks();
+		int ticks_ = app::GetTicks();
 		i::HandleEvents();
 		r::PrepareNextFrame();
 
@@ -127,9 +135,9 @@ int main( int /*argc*/, char* /*argv*/[] )
 
 		if( i::keys[ SDLK_1 ] ) mover = main_cam;
 		if( i::keys[ SDLK_2 ] ) mover = point_lights[0];
-		if( i::keys[ SDLK_3 ] ) mover = projlights[0];
+		if( i::keys[ SDLK_3 ] ) mover = spot_lights[0];
 		if( i::keys[ SDLK_4 ] ) mover = point_lights[1];
-		if( i::keys[ SDLK_5 ] ) mover = projlights[1];
+		if( i::keys[ SDLK_5 ] ) mover = spot_lights[1];
 		if( i::keys[ SDLK_m ] == 1 ) i::warp_mouse = !i::warp_mouse;
 
 		if( i::keys[SDLK_a] ) mover->MoveLocalX( -dist );
@@ -172,13 +180,13 @@ int main( int /*argc*/, char* /*argv*/[] )
 		hud::SetColor( vec4_t(1.0, 1.0, 1.0, 1.0) );
 		hud::SetPos( -0.98, 0.95 );
 		hud::SetFontWidth( 0.03 );
-		hud::Printf( "frame:%d time:%dms\n", r::frames_num, hndl::GetTicks()-ticks_ );
+		hud::Printf( "frame:%d time:%dms\n", r::frames_num, app::GetTicks()-ticks_ );
 		//hud::Print( "Movement keys: arrows,w,a,s,d,q,e,shift,space\nSelect objects: keys 1 to 5\n" );
 		hud::Printf( "Mover: Pos(%.2f %.2f %.2f) Angs(%.2f %.2f %.2f)", mover->translation_wspace.x, mover->translation_wspace.y, mover->translation_wspace.z,
 								 ToDegrees(euler_t(mover->rotation_wspace).x), ToDegrees(euler_t(mover->rotation_wspace).y), ToDegrees(euler_t(mover->rotation_wspace).z) );
 
 		if( i::keys[SDLK_ESCAPE] ) break;
-		if( i::keys[SDLK_F11] ) hndl::TogleFullScreen();
+		if( i::keys[SDLK_F11] ) app::TogleFullScreen();
 		if( i::keys[SDLK_F12] == 1 ) r::TakeScreenshot("gfx/screenshot.jpg");
 
 		/*char str[128];
@@ -188,18 +196,18 @@ int main( int /*argc*/, char* /*argv*/[] )
 		// std stuff follow
 		SDL_GL_SwapBuffers();
 		r::PrintLastError();
-		if( 0 )
+		if( 1 )
 		{
 			if( r::frames_num == 10 ) r::TakeScreenshot("gfx/screenshot.tga");
-			hndl::WaitForNextFrame();
+			app::WaitForNextFrame();
 		}
 		else
 			if( r::frames_num == 5000 ) break;
 	}while( true );
-	PRINT( "Exiting main loop (" << hndl::GetTicks()-ticks << ")" );
+	PRINT( "Exiting main loop (" << app::GetTicks()-ticks << ")" );
 
 
 	PRINT( "Exiting..." );
-	hndl::QuitApp( EXIT_SUCCESS );
+	app::QuitApp( EXIT_SUCCESS );
 	return 0;
 }

+ 8 - 8
src/renderer/r_is.cpp

@@ -11,7 +11,7 @@ The file contains functions and vars used for the deferred shading illumination
 #include "scene.h"
 #include "r_private.h"
 #include "fbo.h"
-#include "light_mtl.h"
+#include "light_props.h"
 
 namespace r {
 namespace is {
@@ -336,8 +336,8 @@ static void PointLightPass( const camera_t& cam, const point_light_t& light )
 	vec3_t light_pos_eye_space = light.translation_wspace.GetTransformed( cam.GetViewMatrix() );
 	glUniform3fv( shader.GetUniformLocation(5), 1, &light_pos_eye_space[0] );
 	glUniform1f( shader.GetUniformLocation(6), 1.0/light.radius );
-	glUniform3fv( shader.GetUniformLocation(7), 1, &vec3_t(light.light_mtl->GetDiffuseColor())[0] );
-	glUniform3fv( shader.GetUniformLocation(8), 1, &vec3_t(light.light_mtl->GetSpecularColor())[0] );
+	glUniform3fv( shader.GetUniformLocation(7), 1, &vec3_t(light.light_props->GetDiffuseColor())[0] );
+	glUniform3fv( shader.GetUniformLocation(8), 1, &vec3_t(light.light_props->GetSpecularColor())[0] );
 
 	//** render quad **
 	glEnableVertexAttribArray( shader.GetAttributeLocation(0) );
@@ -397,8 +397,8 @@ static void SpotLightPass( const camera_t& cam, const spot_light_t& light )
 	shdr->LocTexUnit( shdr->GetUniformLocation(2), r::ms::specular_fai, 2 );
 	shdr->LocTexUnit( shdr->GetUniformLocation(3), r::ms::depth_fai, 3 );
 
-	if( light.light_mtl->GetTexture() == NULL )
-		ERROR( "No texture is attached to the light. light_mtl name: " << light.light_mtl->GetName() );
+	if( light.light_props->GetTexture() == NULL )
+		ERROR( "No texture is attached to the light. light_props name: " << light.light_props->GetName() );
 
 	// the planes
 	//glUniform2fv( shdr->GetUniformLocation("planes"), 1, &planes[0] );
@@ -408,11 +408,11 @@ static void SpotLightPass( const camera_t& cam, const spot_light_t& light )
 	vec3_t light_pos_eye_space = light.translation_wspace.GetTransformed( cam.GetViewMatrix() );
 	glUniform3fv( shdr->GetUniformLocation(5), 1, &light_pos_eye_space[0] );
 	glUniform1f( shdr->GetUniformLocation(6), 1.0/light.GetDistance() );
-	glUniform3fv( shdr->GetUniformLocation(7), 1, &vec3_t(light.light_mtl->GetDiffuseColor())[0] );
-	glUniform3fv( shdr->GetUniformLocation(8), 1, &vec3_t(light.light_mtl->GetSpecularColor())[0] );
+	glUniform3fv( shdr->GetUniformLocation(7), 1, &vec3_t(light.light_props->GetDiffuseColor())[0] );
+	glUniform3fv( shdr->GetUniformLocation(8), 1, &vec3_t(light.light_props->GetSpecularColor())[0] );
 
 	// set the light texture
-	shdr->LocTexUnit( shdr->GetUniformLocation(9), *light.light_mtl->GetTexture(), 4 );
+	shdr->LocTexUnit( shdr->GetUniformLocation(9), *light.light_props->GetTexture(), 4 );
 	// before we render disable anisotropic in the light.texture because it produces artefacts. ToDo: see if this is unececeary in future drivers
 	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
 	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );

+ 16 - 16
src/renderer/r_ms.cpp

@@ -75,16 +75,16 @@ void Init()
 //=====================================================================================================================================
 void RunStage( const camera_t& cam )
 {
-#if defined( _EARLY_Z_ )
-	// run the early z pass
-	r::ms::earlyz::RunPass( cam );
-#endif
+	#if defined( _EARLY_Z_ )
+		// run the early z pass
+		r::ms::earlyz::RunPass( cam );
+	#endif
 
 	fbo.Bind();
 
-#if !defined( _EARLY_Z_ )
-	glClear( GL_DEPTH_BUFFER_BIT );
-#endif
+	#if !defined( _EARLY_Z_ )
+		glClear( GL_DEPTH_BUFFER_BIT );
+	#endif
 	r::SetProjectionViewMatrices( cam );
 	r::SetViewport( 0, 0, r::w * r::rendering_quality, r::h * r::rendering_quality );
 
@@ -92,15 +92,15 @@ void RunStage( const camera_t& cam )
 	scene::skybox.Render( cam.GetViewMatrix().GetRotationPart() );
 	//glDepthFunc( GL_LEQUAL );
 
-#if defined( _EARLY_Z_ )
-	glDepthMask( false );
-	glDepthFunc( GL_EQUAL );
-#endif
+	#if defined( _EARLY_Z_ )
+		glDepthMask( false );
+		glDepthFunc( GL_EQUAL );
+	#endif
 
 	// render the meshes
 	for( uint i=0; i<scene::mesh_nodes.size(); i++ )
 	{
-		mesh_node_t* mesh_node = scene::mesh_nodes[0];
+		mesh_node_t* mesh_node = scene::mesh_nodes[i];
 		if( mesh_node->material->blends ) continue;
 		mesh_node->material->Setup();
 		mesh_node->Render();
@@ -109,10 +109,10 @@ void RunStage( const camera_t& cam )
 	glPolygonMode( GL_FRONT, GL_FILL ); // the rendering above fucks the polygon mode
 
 
-#if defined( _EARLY_Z_ )
-	glDepthMask( true );
-	glDepthFunc( GL_LESS );
-#endif
+	#if defined( _EARLY_Z_ )
+		glDepthMask( true );
+		glDepthFunc( GL_LESS );
+	#endif
 
 	fbo.Unbind();
 }

+ 63 - 3
src/resources/light_mtl.cpp → src/resources/light_props.cpp

@@ -1,4 +1,4 @@
-#include "light_mtl.h"
+#include "light_props.h"
 #include "parser.h"
 #include "texture.h"
 
@@ -6,7 +6,7 @@
 //=====================================================================================================================================
 // Load                                                                                                                               =
 //=====================================================================================================================================
-bool light_mtl_t::Load( const char* filename )
+bool light_props_t::Load( const char* filename )
 {
 scanner_t scanner;
 	if( !scanner.LoadFile( filename ) ) return false;
@@ -27,6 +27,66 @@ scanner_t scanner;
 		{
 			ParseArrOfNumbers<float>( scanner, true, true, 3, &specular_col[0] );
 		}
+		//** RADIUS **
+		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "RADIUS" ) )
+		{
+			token = &scanner.GetNextToken();
+			if( token->code != scanner_t::TC_NUMBER )
+			{
+				PARSE_ERR_EXPECTED( "number" );
+				return false;
+			}
+
+			radius = (token->type == scanner_t::DT_FLOAT) ? token->value.float_ : float(token->value.int_);
+		}
+		//** CASTS_SHADOW **
+		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "CASTS_SHADOW" ) )
+		{
+			token = &scanner.GetNextToken();
+			if( token->code != scanner_t::TC_NUMBER || token->type != scanner_t::DT_INT )
+			{
+				PARSE_ERR_EXPECTED( "number" );
+				return false;
+			}
+
+			casts_shadow = token->value.int_;
+		}
+		//** DISTANCE **
+		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "DISTANCE" ) )
+		{
+			token = &scanner.GetNextToken();
+			if( token->code != scanner_t::TC_NUMBER )
+			{
+				PARSE_ERR_EXPECTED( "number" );
+				return false;
+			}
+
+			distance = (token->type == scanner_t::DT_FLOAT) ? token->value.float_ : float(token->value.int_);
+		}
+		//** FOV_X **
+		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "FOV_X" ) )
+		{
+			token = &scanner.GetNextToken();
+			if( token->code != scanner_t::TC_NUMBER )
+			{
+				PARSE_ERR_EXPECTED( "number" );
+				return false;
+			}
+
+			fov_x = (token->type == scanner_t::DT_FLOAT) ? token->value.float_ : float(token->value.int_);
+		}
+		//** FOV_Y **
+		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "FOV_Y" ) )
+		{
+			token = &scanner.GetNextToken();
+			if( token->code != scanner_t::TC_NUMBER )
+			{
+				PARSE_ERR_EXPECTED( "number" );
+				return false;
+			}
+
+			fov_y = (token->type == scanner_t::DT_FLOAT) ? token->value.float_ : float(token->value.int_);
+		}
 		//** TEXTURE **
 		else if( token->code == scanner_t::TC_IDENTIFIER && !strcmp( token->value.string, "TEXTURE" ) )
 		{
@@ -60,7 +120,7 @@ scanner_t scanner;
 //=====================================================================================================================================
 // Unload                                                                                                                             =
 //=====================================================================================================================================
-void light_mtl_t::Unload()
+void light_props_t::Unload()
 {
 	if( texture != NULL )
 		rsrc::textures.Unload( texture );

+ 8 - 8
src/resources/light_mtl.h → src/resources/light_props.h

@@ -1,5 +1,5 @@
-#ifndef _LIGHT_MTL_H_
-#define _LIGHT_MTL_H_
+#ifndef _LIGHT_PROPS_H_
+#define _LIGHT_PROPS_H_
 
 #include "common.h"
 #include "resource.h"
@@ -9,13 +9,13 @@
 class texture_t;
 
 
-/// Light material resource
-class light_mtl_t: public resource_t
+/// Light properties resource
+class light_props_t: public resource_t
 {
 	// data
 	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( float, 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
@@ -24,11 +24,11 @@ class light_mtl_t: public resource_t
 	private:
 		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(): 
+		light_props_t():
 			diffuse_col(0.5),
 			specular_col(0.5),
 			radius(1.0),
@@ -38,7 +38,7 @@ class light_mtl_t: public resource_t
 			fov_y(m::PI/4.0),
 			texture(NULL) 
 		{}
-		virtual ~light_mtl_t() { /* ToDo */ }
+		virtual ~light_props_t() { /* ToDo */ }
 		bool Load( const char* filename );
 		void Unload();
 };

+ 3 - 2
src/resources/material.h

@@ -86,7 +86,8 @@ class material_t: public resource_t
 		bool wireframe;
 		bool casts_shadow; ///< Used in EarlyZ and in shadowmapping passes
 
-		struct
+		// for depth passing
+		/*struct
 		{
 			shader_prog_t* shader_prog; ///< Depth pass shader program
 			texture_t* alpha_testing_map;
@@ -106,7 +107,7 @@ class material_t: public resource_t
 			{
 				int alpha_testing_map;
 			} uni_locs;
-		} dp;
+		} dp;*/
 
 		/**
 		 * Used mainly in depth passes. If the grass_map pointer is != NULL then the entity is "grass like".

+ 9 - 0
src/resources/mesh.cpp

@@ -25,6 +25,15 @@ bool mesh_t::Load( const char* filename )
 	}
 	material_name = token->value.string;
 
+	//** DP_MATERIAL **
+	/*token = &scanner.GetNextToken();
+	if( token->code != scanner_t::TC_STRING )
+	{
+		PARSE_ERR_EXPECTED( "string" );
+		return false;
+	}
+	dp_material_name = token->value.string;*/
+
 	//** VERTS **
 	// verts num
 	token = &scanner.GetNextToken();

+ 8 - 1
src/resources/mesh.h

@@ -3,7 +3,6 @@
 
 #include "common.h"
 #include "gmath.h"
-#include "primitives.h"
 #include "vbo.h"
 #include "resource.h"
 #include "collision.h"
@@ -25,6 +24,13 @@ class mesh_t: public resource_t
 				float weights[MAX_BONES_PER_VERT];
 		};
 
+		class triangle_t
+		{
+			public:
+				uint   vert_ids[3]; // an array with the vertex indexes in the mesh class
+				vec3_t normal;
+		};
+
 		vec_t<vec3_t>          vert_coords;
 		vec_t<vec3_t>          vert_normals;
 		vec_t<vec4_t>          vert_tangents;
@@ -44,6 +50,7 @@ class mesh_t: public resource_t
 		} vbos;
 
 		string material_name;
+		string dp_material_name;
 
 		bsphere_t bsphere;
 

+ 2 - 2
src/resources/resource.cpp

@@ -4,7 +4,7 @@
 #include "shader_prog.h"
 #include "mesh.h"
 #include "skel_anim.h"
-#include "light_mtl.h"
+#include "light_props.h"
 
 
 namespace rsrc {
@@ -21,6 +21,6 @@ container_t<material_t>    materials;
 container_t<mesh_t>        meshes;
 container_t<skeleton_t>    skeletons;
 container_t<skel_anim_t>   skel_anims;
-container_t<light_mtl_t>   light_mtls;
+container_t<light_props_t> light_props;
 
 } // end namespace

+ 3 - 3
src/resources/resource.h

@@ -13,7 +13,7 @@ class shader_prog_t;
 class mesh_t;
 class skeleton_t;
 class skel_anim_t;
-class light_mtl_t;
+class light_props_t;
 
 namespace rsrc {
 template< typename type_t > class container_t;
@@ -39,7 +39,7 @@ class resource_t
 	friend class rsrc::container_t<skeleton_t>;
 	friend class rsrc::container_t<mesh_t>;
 	friend class rsrc::container_t<skel_anim_t>;
-	friend class rsrc::container_t<light_mtl_t>;
+	friend class rsrc::container_t<light_props_t>;
 	friend class shader_prog_t;
 
 	public:
@@ -61,7 +61,7 @@ extern container_t<material_t>    materials;
 extern container_t<mesh_t>        meshes;
 extern container_t<skeleton_t>    skeletons;
 extern container_t<skel_anim_t>   skel_anims;
-extern container_t<light_mtl_t>   light_mtls;
+extern container_t<light_props_t> light_props;
 
 
 /// resource container template class

+ 24 - 7
src/scene/light.cpp

@@ -1,15 +1,32 @@
 #include "light.h"
 #include "collision.h"
 #include "renderer.h"
-#include "light_mtl.h"
+#include "light_props.h"
 
 
 //=====================================================================================================================================
-// Init                                                                                                                               =
+// Init [point_light_t]                                                                                                               =
 //=====================================================================================================================================
-void light_t::Init( const char* filename )
+void point_light_t::Init( const char* filename )
 {
-	light_mtl = rsrc::light_mtls.Load( filename );
+	light_props = rsrc::light_props.Load( filename );
+	radius = light_props->GetRadius();
+}
+
+
+//=====================================================================================================================================
+// Init [spot_light_t]                                                                                                                =
+//=====================================================================================================================================
+void spot_light_t::Init( const char* filename )
+{
+	light_props = rsrc::light_props.Load( filename );
+	camera.SetAll( light_props->GetFovX(), light_props->GetFovY(), 0.2, light_props->GetDistance() );
+	casts_shadow = light_props->CastsShadow();
+	if( light_props->GetTexture() == NULL )
+	{
+		ERROR( "Light properties \"" << light_props->GetName() << "\" do not have a texture" );
+		return;
+	}
 }
 
 
@@ -18,7 +35,7 @@ void light_t::Init( const char* filename )
 //=====================================================================================================================================
 void light_t::Deinit()
 {
-	rsrc::light_mtls.Unload( light_mtl );
+	rsrc::light_props.Unload( light_props );
 }
 
 
@@ -42,7 +59,7 @@ static void RenderSphere( const mat4_t& tsl, const vec3_t& col )
 //=====================================================================================================================================
 void point_light_t::Render()
 {
-	RenderSphere( transformation_wspace, light_mtl->GetDiffuseColor() );
+	RenderSphere( transformation_wspace, light_props->GetDiffuseColor() );
 }
 
 
@@ -51,5 +68,5 @@ void point_light_t::Render()
 //=====================================================================================================================================
 void spot_light_t::Render()
 {
-	RenderSphere( transformation_wspace, light_mtl->GetDiffuseColor() );
+	RenderSphere( transformation_wspace, light_props->GetDiffuseColor() );
 }

+ 5 - 3
src/scene/light.h

@@ -22,7 +22,7 @@ Specular intensity of material: Sm
 #include "node.h"
 #include "camera.h"
 
-class light_mtl_t;
+class light_props_t;
 
 
 /// light_t (A)
@@ -32,10 +32,10 @@ class light_t: public node_t
 		enum type_e { LT_POINT, LT_SPOT };
 
 		type_e type;
-		light_mtl_t* light_mtl; ///< Later we will add a controller
+		light_props_t* light_props; ///< Later we will add a controller
 	
 		light_t( type_e type_ ): node_t(NT_LIGHT), type(type_) {}
-		void Init( const char* );
+		//void Init( const char* );
 		void Deinit();
 };
 
@@ -47,6 +47,7 @@ class point_light_t: public light_t
 		float radius;
 
 		point_light_t(): light_t(LT_POINT) {}
+		void Init( const char* );
 		void Render();
 };
 
@@ -61,6 +62,7 @@ class spot_light_t: public light_t
 		spot_light_t(): light_t(LT_SPOT), casts_shadow(false) { AddChild( &camera ); }
 		float GetDistance() const { return camera.GetZFar(); }
 		void  SetDistance( float d ) { camera.SetZFar(d); }
+		void  Init( const char* );
 		void  Render();
 };
 

+ 4 - 1
src/scene/scene.cpp

@@ -5,6 +5,7 @@
 #include "mesh_node.h"
 #include "light.h"
 #include "controller.h"
+#include "material.h"
 
 namespace scene {
 
@@ -157,9 +158,11 @@ void UpdateAllControllers()
 		for( vec_t<controller_t*>::iterator it1=node->controllers.begin(); it1!=node->controllers.end(); it1++ )
 			(*it1)->Update( 0.0 );
 	}*/
-	
+
 	for( vec_t<controller_t*>::iterator it=controllers.begin(); it!=controllers.end(); it++ )
+	{
 		(*it)->Update( 0.0 );
+	}
 }
 
 

+ 15 - 0
src/scene/skel_anim_controller.cpp

@@ -5,6 +5,20 @@
 #include "renderer.h"
 
 
+//=====================================================================================================================================
+// skel_anim_controller_t                                                                                                             =
+//=====================================================================================================================================
+skel_anim_controller_t::skel_anim_controller_t( skel_node_t* skel_node_ ):
+	controller_t(CT_SKEL_ANIM),
+	skel_node( skel_node_ )
+{
+	heads.resize( skel_node->skeleton->bones.size() );
+	tails.resize( skel_node->skeleton->bones.size() );
+	bone_rotations.resize( skel_node->skeleton->bones.size() );
+	bone_translations.resize( skel_node->skeleton->bones.size() );
+}
+
+
 //=====================================================================================================================================
 // Interpolate                                                                                                                        =
 //=====================================================================================================================================
@@ -36,6 +50,7 @@ void skel_anim_controller_t::Interpolate( skel_anim_t* animation, float frame )
 
 
 	// now for all bones update bone's poses
+	DEBUG_ERR( bone_rotations.size()<1 );
 	for( uint i=0; i<bone_rotations.size(); i++ )
 	{
 		const skel_anim_t::bone_anim_t& banim = skel_anim->bones[i];

+ 1 - 1
src/scene/skel_anim_controller.h

@@ -28,7 +28,7 @@ class skel_anim_controller_t: public controller_t
 		float step;
 		float frame;
 
-		skel_anim_controller_t( skel_node_t* skel_node_ ): controller_t(CT_SKEL_ANIM), skel_node( skel_node_ ) {}
+		skel_anim_controller_t( skel_node_t* skel_node_ );
 		void Update( float time );
 };
 

+ 7 - 5
src/scene/skel_node.cpp

@@ -9,9 +9,9 @@
 // skel_node_t                                                                                                                        =
 //=====================================================================================================================================
 skel_node_t::skel_node_t(): 
-	node_t( NT_SKELETON )
+	node_t( NT_SKELETON ),
+	skel_anim_controller( NULL )
 {
-	skel_anim_controller = new skel_anim_controller_t(this); // It allways have a controller
 }
 
 
@@ -21,8 +21,10 @@ skel_node_t::skel_node_t():
 void skel_node_t::Init( const char* filename )
 {
 	skeleton = rsrc::skeletons.Load( filename );
+	skel_anim_controller = new skel_anim_controller_t( this );
 }
 
+
 //=====================================================================================================================================
 // Deinit                                                                                                                             =
 //=====================================================================================================================================
@@ -47,13 +49,13 @@ void skel_node_t::Render()
 	{
 		glColor3fv( &vec3_t( 1.0, 1.0, 1.0 )[0] );
 		glBegin( GL_POINTS );
-			glVertex3fv( &skel_anim_controller->heads[0][0] );
+			glVertex3fv( &skel_anim_controller->heads[i][0] );
 		glEnd();
 
 		glBegin( GL_LINES );
-			glVertex3fv( &skel_anim_controller->heads[0][0] );
+			glVertex3fv( &skel_anim_controller->heads[i][0] );
 			glColor3fv( &vec3_t( 1.0, 0.0, 0.0 )[0] );
-			glVertex3fv( &skel_anim_controller->tails[0][0] );
+			glVertex3fv( &skel_anim_controller->tails[i][0] );
 		glEnd();
 	}
 

+ 1 - 1
src/uncategorized/input.cpp

@@ -103,7 +103,7 @@ void HandleEvents()
 			}
 
 			case SDL_QUIT:
-				hndl::QuitApp(1);
+				app::QuitApp(1);
 				break;
 		}
 	}

+ 1 - 1
src/uncategorized/input.h

@@ -3,7 +3,7 @@
 
 #include <SDL/SDL.h>
 #include "common.h"
-#include "handlers.h"
+#include "app.h"
 #include "gmath.h"
 
 /// input namespace

+ 1 - 1
src/uncategorized/particles.cpp

@@ -21,7 +21,7 @@ void particle_t::Render()
 	--life;
 
 	// calc new pos
-	float dt = ( float(hndl::timer_tick)/1000 );
+	float dt = ( float(app::timer_tick)/1000 );
 	vec3_t s_vel; // sigma velocity
 	s_vel = vec3_t( 0.0, 0.0, 0.0 );
 	for( int i=0; i<PARTICLE_VELS_NUM; i++ )

+ 1 - 2
src/uncategorized/particles.h

@@ -3,8 +3,7 @@
 
 #include "common.h"
 #include "gmath.h"
-#include "primitives.h"
-#include "handlers.h"
+#include "app.h"
 #include "object.h"
 
 #define PARTICLE_VELS_NUM 2

+ 0 - 49
src/uncategorized/primitives.h

@@ -1,49 +0,0 @@
-#ifndef _PRIMITIVES_H_
-#define _PRIMITIVES_H_
-
-#include <math.h>
-#include "common.h"
-#include "gmath.h"
-#include "engine_class.h"
-
-// vertex_t
-class vertex_t
-{
-	public:
-		vec3_t coords;
-		vec3_t normal;
-};
-
-// triangle_t
-class triangle_t
-{
-	public:
-		uint   vert_ids[3]; // an array with the vertex indexes in the mesh class
-		vec3_t normal;
-};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#endif

+ 2 - 2
src/uncategorized/handlers.cpp → src/utility/app.cpp

@@ -1,6 +1,6 @@
-#include "handlers.h"
+#include "app.h"
 
-namespace hndl { // begin of namespace
+namespace app { // begin of namespace
 
 
 static SDL_Surface* main_surf;

+ 3 - 3
src/uncategorized/handlers.h → src/utility/app.h

@@ -1,10 +1,10 @@
-#ifndef _HANDLERS_H_
-#define _HANDLERS_H_
+#ifndef _APP_H_
+#define _APP_H_
 
 #include <SDL/SDL.h>
 #include "common.h"
 
-namespace hndl {
+namespace app {
 
 
 extern uint timer_tick;

+ 1 - 1
src/utility/common.h

@@ -74,7 +74,7 @@ extern string GetFunctionFromPrettyFunction( const char* pretty_function );
 #endif
 
 #define GENERAL_ERR( x, y, col ) \
-	cerr << col << "**" << x << "** (" << __FILENAME__ << ":" << __LINE__ << " " << __G_FUNCTION__ << "): " << y << COL_DEFAULT << endl;
+	cout << col << "**" << x << "** (" << __FILENAME__ << ":" << __LINE__ << " " << __G_FUNCTION__ << "): " << y << COL_DEFAULT << endl;
 
 /// in ERROR you can write something like this: ERROR( "tralala" << 10 << ' ' )
 #define ERROR( x ) GENERAL_ERR( "ERROR", x, COL_ERROR )