Browse Source

Refactoring

Panagiotis Christopoulos Charitos 14 years ago
parent
commit
f8ec079d6c
92 changed files with 1149 additions and 633 deletions
  1. 57 43
      shaders/MsMpGeneric.glsl
  2. 3 3
      src/Core/App.cpp
  3. 4 0
      src/Core/Globals.h
  4. 3 2
      src/Events/MainRendererPpsHdr.cpp
  5. 5 1
      src/GfxApi/BufferObjects/BufferObject.cpp
  6. 24 14
      src/GfxApi/BufferObjects/BufferObject.h
  7. 2 1
      src/GfxApi/BufferObjects/Fbo.cpp
  8. 3 1
      src/GfxApi/BufferObjects/Fbo.h
  9. 10 6
      src/GfxApi/BufferObjects/Vao.cpp
  10. 27 15
      src/GfxApi/BufferObjects/Vao.h
  11. 16 8
      src/GfxApi/BufferObjects/Vbo.h
  12. 8 4
      src/GfxApi/GlException.h
  13. 2 1
      src/GfxApi/GlStateMachine.h
  14. 17 17
      src/Main.cpp
  15. 3 3
      src/Math/Vec3.inl.h
  16. 17 9
      src/Misc/Parser.h
  17. 12 6
      src/Misc/Parser.inl.h
  18. 15 5
      src/Misc/PropertyTree.cpp
  19. 5 1
      src/Misc/PropertyTree.h
  20. 23 11
      src/Renderer/Bl.cpp
  21. 12 4
      src/Renderer/Bl.h
  22. 16 90
      src/Renderer/Bs.cpp
  23. 8 2
      src/Renderer/Bs.h
  24. 34 19
      src/Renderer/Dbg.cpp
  25. 17 7
      src/Renderer/Dbg.h
  26. 5 0
      src/Renderer/Drawers/CollisionDbgDrawer.cpp
  27. 11 3
      src/Renderer/Drawers/CollisionDbgDrawer.h
  28. 31 19
      src/Renderer/Drawers/PhyDbgDrawer.cpp
  29. 31 8
      src/Renderer/Drawers/PhyDbgDrawer.h
  30. 14 5
      src/Renderer/Drawers/SceneDbgDrawer.cpp
  31. 14 6
      src/Renderer/Drawers/SceneDbgDrawer.h
  32. 47 23
      src/Renderer/Drawers/SceneDrawer.cpp
  33. 22 9
      src/Renderer/Drawers/SceneDrawer.h
  34. 10 3
      src/Renderer/Ez.cpp
  35. 8 2
      src/Renderer/Ez.h
  36. 14 4
      src/Renderer/Hdr.cpp
  37. 12 4
      src/Renderer/Hdr.h
  38. 8 4
      src/Renderer/Is.cpp
  39. 16 6
      src/Renderer/Is.h
  40. 24 9
      src/Renderer/MainRenderer.cpp
  41. 20 9
      src/Renderer/MainRenderer.h
  42. 36 17
      src/Renderer/Ms.cpp
  43. 8 2
      src/Renderer/Ms.h
  44. 24 10
      src/Renderer/Pps.cpp
  45. 10 3
      src/Renderer/Pps.h
  46. 22 9
      src/Renderer/Renderer.cpp
  47. 8 2
      src/Renderer/Renderer.h
  48. 11 3
      src/Renderer/RendererInitializer.h
  49. 8 2
      src/Renderer/RenderingPass.h
  50. 22 10
      src/Renderer/SkinsDeformer.cpp
  51. 8 2
      src/Renderer/SkinsDeformer.h
  52. 26 10
      src/Renderer/Sm.cpp
  53. 31 13
      src/Renderer/Sm.h
  54. 34 15
      src/Renderer/Smo.cpp
  55. 10 4
      src/Renderer/Smo.h
  56. 15 5
      src/Renderer/Ssao.cpp
  57. 8 2
      src/Renderer/Ssao.h
  58. 2 1
      src/Resources/Extension.cpp
  59. 2 1
      src/Resources/Extension.h
  60. 33 0
      src/Resources/SProgLoader.h
  61. 53 29
      src/Resources/ShaderPrePreprocessor.cpp
  62. 7 4
      src/Resources/ShaderPrePreprocessor.h
  63. 5 3
      src/Scene/Camera.h
  64. 5 3
      src/Scene/Light.h
  65. 3 3
      src/Scene/ModelNode.h
  66. 3 2
      src/Scene/ModelPatchNode.cpp
  67. 3 3
      src/Scene/OrthographicCamera.h
  68. 1 1
      src/Scene/Particle.cpp
  69. 9 9
      src/Scene/ParticleEmitterNode.cpp
  70. 8 7
      src/Scene/ParticleEmitterNode.h
  71. 2 2
      src/Scene/PatchNode.cpp
  72. 3 3
      src/Scene/PerspectiveCamera.h
  73. 6 1
      src/Scene/PointLight.h
  74. 4 3
      src/Scene/RenderableNode.h
  75. 5 3
      src/Scene/Scene.cpp
  76. 3 3
      src/Scene/Scene.h
  77. 3 3
      src/Scene/SceneNode.cpp
  78. 7 6
      src/Scene/SceneNode.h
  79. 4 4
      src/Scene/SkelAnimModelNodeCtrl.cpp
  80. 6 3
      src/Scene/SkinNode.h
  81. 8 8
      src/Scene/SkinPatchNode.cpp
  82. 0 1
      src/Scene/SkinPatchNode.h
  83. 6 1
      src/Scene/SpotLight.h
  84. 8 0
      src/Scene/VisibilityInfo.cpp
  85. 3 0
      src/Scene/VisibilityInfo.h
  86. 5 2
      src/Scripting/Core/Globals.bpi.cpp
  87. 9 9
      src/Scripting/Renderer/Bl.bpi.cpp
  88. 3 3
      src/Scripting/Renderer/Dbg.bpi.cpp
  89. 9 8
      src/Scripting/Renderer/Hdr.bpi.cpp
  90. 4 2
      src/Scripting/Renderer/MainRenderer.bpi.cpp
  91. 3 3
      src/Scripting/Renderer/Pps.bpi.cpp
  92. 3 3
      src/Scripting/Renderer/Renderer.bpi.cpp

+ 57 - 43
shaders/MsMpGeneric.glsl

@@ -1,10 +1,11 @@
 /// @file
 /// 
-/// This a generic shader to fill the deferred shading buffers. You can always build your own if you dont need to write
-/// in all the buffers
+/// This a generic shader to fill the deferred shading buffers. You can always 
+/// build your own if you dont need to write in all the buffers
 /// 
 /// Control defines:
-/// DIFFUSE_MAPPING, NORMAL_MAPPING, SPECULAR_MAPPING, PARALLAX_MAPPING, ENVIRONMENT_MAPPING, ALPHA_TESTING
+/// DIFFUSE_MAPPING, NORMAL_MAPPING, SPECULAR_MAPPING, PARALLAX_MAPPING, 
+/// ENVIRONMENT_MAPPING, ALPHA_TESTING
  
 #if defined(ALPHA_TESTING) && !defined(DIFFUSE_MAPPING)
 	#error "Cannot have ALPHA_TESTING without DIFFUSE_MAPPING"
@@ -59,9 +60,9 @@ out vec3 vVertPosViewSpace; ///< For env mapping. AKA view vector
 
 
 
-//======================================================================================================================
-// main                                                                                                                =
-//======================================================================================================================
+//==============================================================================
+// main                                                                        =
+//==============================================================================
 void main()
 {
 	// calculate the vert pos, normal and tangent
@@ -93,12 +94,15 @@ void main()
 
 #pragma anki fragShaderBegins
 
-/// @note The process of calculating the diffuse color for the diffuse MSFAI is divided into two parts. The first
-/// happens before the normal calculation and the other just after it. In the first part we read the texture (or the
-/// gl_Color) and we set the _diffColl_. In case of grass we discard. In the second part we calculate a SEM color and
-/// we combine it with the _diffColl_. We cannot put the second part before normal calculation because SEM needs
-/// the _normal_. Also we cannot put the first part after normal calculation because in case of grass we will waste
-/// calculations for the normal. For that two reasons we split the diffuse calculations in two parts
+/// @note The process of calculating the diffuse color for the diffuse MSFAI is 
+/// divided into two parts. The first happens before the normal calculation and 
+/// the other just after it. In the first part we read the texture (or the 
+/// gl_Color) and we set the _diffColl_. In case of grass we discard. In the 
+/// second part we calculate a SEM color and we combine it with the _diffColl_. 
+/// We cannot put the second part before normal calculation because SEM needs
+/// the _normal_. Also we cannot put the first part after normal calculation 
+/// because in case of grass we will waste calculations for the normal. For 
+/// that two reasons we split the diffuse calculations in two parts
 
 #pragma anki include "shaders/Pack.glsl"
 
@@ -122,7 +126,8 @@ uniform float shininess = 50.0;
 uniform vec3 diffuseCol = vec3(1.0, 0.0, 1.0);
 uniform vec3 specularCol = vec3(1.0, 0.0, 1.0);
 #if defined(ALPHA_TESTING)
-	uniform float alphaTestingTolerance = 0.5; ///< Below this value the pixels are getting discarded 
+	/// Below this value the pixels are getting discarded 
+	uniform float alphaTestingTolerance = 0.5; 
 #endif
 uniform float blurring = 0.0;
 
@@ -141,25 +146,26 @@ layout(location = 2) out vec4 fMsSpecularFai;
 const float MAX_SHININESS = 128.0;
 
 
-//======================================================================================================================
-// Normal funcs                                                                                                        =
-//======================================================================================================================
+//==============================================================================
+// Normal funcs                                                                =
+//==============================================================================
 /// @param[in] normal The fragment's normal in view space
 /// @param[in] tangent The tangent
 /// @param[in] tangent Extra stuff for the tangent
 /// @param[in] map The map
 /// @param[in] texCoords Texture coordinates
-vec3 getNormalUsingMap(in vec3 normal, in vec3 tangent, in float tangentW, in sampler2D map, in vec2 texCoords)
+vec3 getNormalUsingMap(in vec3 normal, in vec3 tangent, in float tangentW, 
+	in sampler2D map, in vec2 texCoords)
 {
-		vec3 n = normalize(normal);
-		vec3 t = normalize(tangent);
-		vec3 b = cross(n, t) * tangentW;
+	vec3 n = normalize(normal);
+	vec3 t = normalize(tangent);
+	vec3 b = cross(n, t) * tangentW;
 
-		mat3 tbnMat = mat3(t, b, n);
+	mat3 tbnMat = mat3(t, b, n);
 
-		vec3 nAtTangentspace = (texture2D(map, texCoords).rgb - 0.5) * 2.0;
+	vec3 nAtTangentspace = (texture2D(map, texCoords).rgb - 0.5) * 2.0;
 
-		return normalize(tbnMat * nAtTangentspace);
+	return normalize(tbnMat * nAtTangentspace);
 }
 
 /// Just normalize
@@ -169,9 +175,9 @@ vec3 getNormalSimple(in vec3 normal)
 }
 
 
-//======================================================================================================================
-// doEnvMapping                                                                                                        =
-//======================================================================================================================
+//==============================================================================
+// doEnvMapping                                                                =
+//==============================================================================
 /// Environment mapping calculations
 /// @param[in] vertPosViewSpace Fragment position in view space
 /// @param[in] normal Fragment's normal in view space as well
@@ -179,8 +185,8 @@ vec3 getNormalSimple(in vec3 normal)
 /// @return The color
 vec3 doEnvMapping(in vec3 vertPosViewSpace, in vec3 normal, in sampler2D map)
 {
-	// In case of normal mapping I could play with vertex's normal but this gives better results and its allready
-	// computed
+	// In case of normal mapping I could play with vertex's normal but this 
+	// gives better results and its allready computed
 	
 	vec3 u = normalize(vertPosViewSpace);
 	vec3 r = reflect(u, normal);
@@ -193,10 +199,11 @@ vec3 doEnvMapping(in vec3 vertPosViewSpace, in vec3 normal, in sampler2D map)
 }
 
 
-//======================================================================================================================
-// doAlpha                                                                                                             =
-//======================================================================================================================
-/// Using a 4-channel texture and a tolerance discard the fragment if the texture's alpha is less than the tolerance
+//==============================================================================
+// doAlpha                                                                     =
+//==============================================================================
+/// Using a 4-channel texture and a tolerance discard the fragment if the 
+/// texture's alpha is less than the tolerance
 /// @param[in] map The diffuse map
 /// @param[in] tolerance Tolerance value
 /// @param[in] texCoords Texture coordinates
@@ -212,14 +219,15 @@ vec3 doAlpha(in sampler2D map, in float tolerance, in vec2 texCoords)
 }
 
 
-//======================================================================================================================
-// main                                                                                                                =
-//======================================================================================================================
+//==============================================================================
+// main                                                                        =
+//==============================================================================
 void main()
 {
 	//
 	// Paralax Mapping Calculations
-	// The code below reads the height map, makes some calculations and returns a new texCoords
+	// The code below reads the height map, makes some calculations and returns 
+	// a new texCoords
 	//
 	#if defined(PARALLAX_MAPPING)
 		/*const float _scale = 0.04;
@@ -260,13 +268,15 @@ void main()
 
 	//
 	// Diffuse Calculations (Part I)
-	// Get the color from the diffuse map and discard if alpha testing is on and alpha is zero
+	// Get the color from the diffuse map and discard if alpha testing is on 
+	// and alpha is zero
 	//
 	vec3 _diffColl_;
 	#if defined(DIFFUSE_MAPPING)
 
 		#if defined(ALPHA_TESTING)
-			_diffColl_ = doAlpha(diffuseMap, alphaTestingTolerance, _superTexCoords_);
+			_diffColl_ = doAlpha(diffuseMap, alphaTestingTolerance, 
+				_superTexCoords_);
 		#else // no alpha
 			_diffColl_ = texture2D(diffuseMap, _superTexCoords_).rgb;
 		#endif
@@ -279,10 +289,12 @@ void main()
 
 	//
 	// Normal Calculations
-	// Either use a normap map and make some calculations or use the vertex normal
+	// Either use a normap map and make some calculations or use the vertex 
+	// normal
 	//
 	#if defined(NORMAL_MAPPING)
-		vec3 _normal_ = getNormalUsingMap(vNormal, vTangent, vTangentW, normalMap, _superTexCoords_);
+		vec3 _normal_ = getNormalUsingMap(vNormal, vTangent, vTangentW, 
+			normalMap, _superTexCoords_);
 	#else
 		vec3 _normal_ = getNormalSimple(vNormal);
 	#endif
@@ -290,7 +302,8 @@ void main()
 
 	//
 	// Diffuse Calculations (Part II)
-	// If SEM is enabled make some calculations (using the vVertPosViewSpace, environmentMap and the _normal_) and
+	// If SEM is enabled make some calculations (using the vVertPosViewSpace, 
+	// environmentMap and the _normal_) and
 	// combine colors of SEM and the _diffColl_
 	//
 	#if defined(ENVIRONMENT_MAPPING)
@@ -303,8 +316,9 @@ void main()
 	// Specular Calculations
 	//
 	#if defined(SPECULAR_MAPPING)
-		vec4 _specularCol_ = vec4(texture2D(specularMap, _superTexCoords_).rgb * specularCol,
-		                                    shininess / MAX_SHININESS);
+		vec4 _specularCol_ = vec4(
+			texture2D(specularMap, _superTexCoords_).rgb * specularCol,
+			shininess / MAX_SHININESS);
 	#else // no specular map
 		vec4 _specularCol_ = vec4(specularCol, shininess / MAX_SHININESS);
 	#endif

+ 3 - 3
src/Core/App.cpp

@@ -118,7 +118,7 @@ void App::init(int argc, char* argv[])
 	initRenderer();
 	JobManagerSingleton::getInstance().init(4);
 	SceneSingleton::getInstance().getPhysMasterContainer().setDebugDrawer(
-		new PhyDbgDrawer);
+		new R::PhyDbgDrawer(R::MainRendererSingleton::getInstance().getDbg()));
 
 	// other
 	activeCam = NULL;
@@ -214,7 +214,7 @@ void App::initDirs()
 //==============================================================================
 void App::initRenderer()
 {
-	RendererInitializer initializer;
+	R::RendererInitializer initializer;
 	initializer.ms.ez.enabled = true;
 	initializer.dbg.enabled = true;
 	initializer.is.sm.bilinearEnabled = true;
@@ -235,7 +235,7 @@ void App::initRenderer()
 	initializer.pps.bl.sideBlurFactor = 1.0;
 	initializer.mainRendererQuality = 1.0;
 
-	MainRendererSingleton::getInstance().init(initializer);
+	R::MainRendererSingleton::getInstance().init(initializer);
 }
 
 

+ 4 - 0
src/Core/Globals.h

@@ -5,7 +5,11 @@
 
 
 typedef Singleton<class Logger> LoggerSingleton;
+
+namespace R {
 typedef Singleton<class MainRenderer> MainRendererSingleton;
+}
+
 typedef Singleton<class Input> InputSingleton;
 typedef Singleton<class ResourceManager> ResourceManagerSingleton;
 typedef Singleton<class Scene> SceneSingleton;

+ 3 - 2
src/Events/MainRendererPpsHdr.cpp

@@ -17,7 +17,8 @@ MainRendererPpsHdr::MainRendererPpsHdr(float startTime, float duration,
 	finalData.blurringIterationsNum = blurringIterationsNum_;
 	finalData.blurringDist = blurringDist_;
 
-	const Hdr& hdr = MainRendererSingleton::getInstance().getPps().getHdr();
+	const R::Hdr& hdr =
+		R::MainRendererSingleton::getInstance().getPps().getHdr();
 	originalData.exposure = hdr.getExposure();
 	originalData.blurringIterationsNum = hdr.getBlurringIterationsNum();
 	originalData.blurringDist = hdr.getBlurringDist();
@@ -54,7 +55,7 @@ void MainRendererPpsHdr::updateSp(float /*prevUpdateTime*/, float crntTime)
 	float d = crntTime - getStartTime(); // delta
 	float dp = d / getDuration(); // delta as percentage
 
-	Hdr& hdr = MainRendererSingleton::getInstance().getPps().getHdr();
+	R::Hdr& hdr = R::MainRendererSingleton::getInstance().getPps().getHdr();
 
 	hdr.setExposure(interpolate(originalData.exposure, finalData.exposure, dp));
 

+ 5 - 1
src/GfxApi/BufferObjects/BufferObject.cpp

@@ -23,7 +23,11 @@ void BufferObject::create(GLenum target_, uint sizeInBytes_,
 {
 	ASSERT(!isCreated());
 	// unacceptable usage_
-	ASSERT(usage_ == GL_STREAM_DRAW || usage_ == GL_STATIC_DRAW || usage_ == GL_DYNAMIC_DRAW);
+
+	ASSERT(usage_ == GL_STREAM_DRAW ||
+		usage_ == GL_STATIC_DRAW ||
+		usage_ == GL_DYNAMIC_DRAW);
+
 	ASSERT(sizeInBytes_ > 0); // unacceptable sizeInBytes
 
 	usage = usage_;

+ 24 - 14
src/GfxApi/BufferObjects/BufferObject.h

@@ -6,14 +6,16 @@
 #include "Util/StdTypes.h"
 
 
-/// A wrapper for OpenGL buffer objects (vertex arrays, texture buffers etc) to prevent us from making idiotic errors
+/// A wrapper for OpenGL buffer objects (vertex arrays, texture buffers etc)
+/// to prevent us from making idiotic errors
 class BufferObject
 {
 	public:
 		BufferObject(): glId(0) {}
 
 		/// Default constructor @see create
-		BufferObject(GLenum target, uint sizeInBytes, const void* dataPtr, GLenum usage);
+		BufferObject(GLenum target, uint sizeInBytes,
+			const void* dataPtr, GLenum usage);
 
 		/// It deletes the BO from the GL context
 		virtual ~BufferObject();
@@ -32,20 +34,26 @@ class BufferObject
 		/// Unbind BO
 		void unbind() const;
 
-		/// Creates a new BO with the given parameters and checks if everything went OK. Throws exception if fails
+		/// Creates a new BO with the given parameters and checks if everything
+		/// went OK. Throws exception if fails
 		/// @param target Depends on the BO
-		/// @param sizeInBytes The size of the buffer that we will allocate in bytes
-		/// @param dataPtr Points to the data buffer to copy to the VGA memory. Put NULL if you want just to allocate memory
-		/// @param usage It should be: GL_STREAM_DRAW or GL_STATIC_DRAW or GL_DYNAMIC_DRAW only!!!!!!!!!
+		/// @param sizeInBytes The size of the buffer that we will allocate in
+		/// bytes
+		/// @param dataPtr Points to the data buffer to copy to the VGA memory.
+		/// Put NULL if you want just to allocate memory
+		/// @param usage It should be: GL_STREAM_DRAW or GL_STATIC_DRAW or
+		/// GL_DYNAMIC_DRAW only!!!!!!!!!
 		/// @exception Exception
-		void create(GLenum target, uint sizeInBytes, const void* dataPtr, GLenum usage);
+		void create(GLenum target, uint sizeInBytes, const void* dataPtr,
+			GLenum usage);
 
 		/// Delete the BO
 		void deleteBuff();
 
-		/// Write data to buffer. This means that maps the BO to local memory, writes the local memory and unmaps it.
-		/// Throws exception if the given size and the BO size are not equal. It throws an exception if the usage is
-		/// GL_STATIC_DRAW
+		/// Write data to buffer. This means that maps the BO to local memory,
+		/// writes the local memory and unmaps it. Throws exception if the
+		/// given size and the BO size are not equal. It throws an exception if
+		/// the usage is GL_STATIC_DRAW
 		/// @param[in] buff The buffer to copy to BO
 		void write(void* buff);
 
@@ -61,8 +69,9 @@ class BufferObject
 	private:
 		uint glId; ///< The OpenGL id of the BO
 
-		/// Used in glBindBuffer(target, glId) and its for easy access so we wont have to query the GL driver. Its the type
-		/// of the buffer eg GL_TEXTURE_BUFFER or GL_ELEMENT_ARRAY_BUFFER etc
+		/// Used in glBindBuffer(target, glId) and its for easy access so we
+		/// wont have to query the GL driver. Its the type of the buffer eg
+		/// GL_TEXTURE_BUFFER or GL_ELEMENT_ARRAY_BUFFER etc
 		GLenum target;
 
 		GLenum usage; ///< GL_STREAM_DRAW or GL_STATIC_DRAW or GL_DYNAMIC_DRAW
@@ -74,8 +83,9 @@ class BufferObject
 // Inlines                                                                     =
 //==============================================================================
 
-inline BufferObject::BufferObject(GLenum target, uint sizeInBytes, const void* dataPtr, GLenum usage):
-	glId(0)
+inline BufferObject::BufferObject(GLenum target, uint sizeInBytes,
+	const void* dataPtr, GLenum usage)
+:	glId(0)
 {
 	create(target, sizeInBytes, dataPtr, usage);
 }

+ 2 - 1
src/GfxApi/BufferObjects/Fbo.cpp

@@ -26,7 +26,8 @@ void Fbo::checkIfGood() const
 
 	if(status != GL_FRAMEBUFFER_COMPLETE)
 	{
-		throw EXCEPTION("FBO is incomplete: " + boost::lexical_cast<std::string>(status));
+		throw EXCEPTION("FBO is incomplete: " +
+			boost::lexical_cast<std::string>(status));
 	}
 }
 

+ 3 - 1
src/GfxApi/BufferObjects/Fbo.h

@@ -72,7 +72,9 @@ inline void Fbo::bind(GLenum target_)
 {
 	ASSERT(isCreated());
 	target = target_;
-	ASSERT(target == GL_DRAW_FRAMEBUFFER || target == GL_READ_FRAMEBUFFER || target == GL_FRAMEBUFFER);
+	ASSERT(target == GL_DRAW_FRAMEBUFFER ||
+		target == GL_READ_FRAMEBUFFER ||
+		target == GL_FRAMEBUFFER);
 	glBindFramebuffer(target, glId);
 }
 

+ 10 - 6
src/GfxApi/BufferObjects/Vao.cpp

@@ -17,8 +17,9 @@ Vao::~Vao()
 //==============================================================================
 // attachArrayBufferVbo                                                        =
 //==============================================================================
-void Vao::attachArrayBufferVbo(const Vbo& vbo, uint attribVarLocation, GLint size, GLenum type,
-		                       GLboolean normalized, GLsizei stride, const GLvoid* pointer)
+void Vao::attachArrayBufferVbo(const Vbo& vbo, uint attribVarLocation,
+	GLint size, GLenum type, GLboolean normalized, GLsizei stride,
+	const GLvoid* pointer)
 {
 	ASSERT(isCreated());
 	if(vbo.getBufferTarget() != GL_ARRAY_BUFFER)
@@ -30,7 +31,8 @@ void Vao::attachArrayBufferVbo(const Vbo& vbo, uint attribVarLocation, GLint siz
 
 	bind();
 	vbo.bind();
-	glVertexAttribPointer(attribVarLocation, size, type, normalized, stride, pointer);
+	glVertexAttribPointer(attribVarLocation, size, type, normalized,
+		stride, pointer);
 	glEnableVertexAttribArray(attribVarLocation);
 	vbo.unbind();
 	unbind();
@@ -42,10 +44,12 @@ void Vao::attachArrayBufferVbo(const Vbo& vbo, uint attribVarLocation, GLint siz
 //==============================================================================
 // attachArrayBufferVbo                                                        =
 //==============================================================================
-void Vao::attachArrayBufferVbo(const Vbo& vbo, const SProgAttribVar& attribVar, GLint size, GLenum type,
-		                       GLboolean normalized, GLsizei stride, const GLvoid* pointer)
+void Vao::attachArrayBufferVbo(const Vbo& vbo, const SProgAttribVar& attribVar,
+	GLint size, GLenum type, GLboolean normalized, GLsizei stride,
+	const GLvoid* pointer)
 {
-	attachArrayBufferVbo(vbo, attribVar.getLoc(), size, type, normalized, stride, pointer);
+	attachArrayBufferVbo(vbo, attribVar.getLoc(), size, type, normalized,
+		stride, pointer);
 }
 
 

+ 27 - 15
src/GfxApi/BufferObjects/Vao.h

@@ -30,29 +30,41 @@ class Vao
 		/// Destroy
 		void destroy();
 
-		/// Attach an array buffer VBO. See @link http://www.opengl.org/sdk/docs/man3/xhtml/glVertexAttribPointer.xml 
+		/// Attach an array buffer VBO. See @link
+		/// http://www.opengl.org/sdk/docs/man3/xhtml/glVertexAttribPointer.xml
 		/// @endlink
 		/// @param vbo The VBO to attach
 		/// @param attribVar For the shader attribute location
-		/// @param size Specifies the number of components per generic vertex attribute. Must be 1, 2, 3, 4
+		/// @param size Specifies the number of components per generic vertex
+		/// attribute. Must be 1, 2, 3, 4
 		/// @param type GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT etc
-		/// @param normalized Specifies whether fixed-point data values should be normalized
-		/// @param stride Specifies the byte offset between consecutive generic vertex attributes
-		/// @param pointer Specifies a offset of the first component of the first generic vertex attribute in the array
-		void attachArrayBufferVbo(const Vbo& vbo, const SProgAttribVar& attribVar, GLint size, GLenum type,
-		                          GLboolean normalized, GLsizei stride, const GLvoid* pointer);
-
-		/// Attach an array buffer VBO. See @link http://www.opengl.org/sdk/docs/man3/xhtml/glVertexAttribPointer.xml
+		/// @param normalized Specifies whether fixed-point data values should
+		/// be normalized
+		/// @param stride Specifies the byte offset between consecutive generic
+		/// vertex attributes
+		/// @param pointer Specifies a offset of the first component of the
+		/// first generic vertex attribute in the array
+		void attachArrayBufferVbo(const Vbo& vbo,
+			const SProgAttribVar& attribVar, GLint size, GLenum type,
+			GLboolean normalized, GLsizei stride, const GLvoid* pointer);
+
+		/// Attach an array buffer VBO. See @link
+		/// http://www.opengl.org/sdk/docs/man3/xhtml/glVertexAttribPointer.xml
 		/// @endlink
 		/// @param vbo The VBO to attach
 		/// @param attribVarLocation Shader attribute location
-		/// @param size Specifies the number of components per generic vertex attribute. Must be 1, 2, 3, 4
+		/// @param size Specifies the number of components per generic vertex
+		/// attribute. Must be 1, 2, 3, 4
 		/// @param type GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT etc
-		/// @param normalized Specifies whether fixed-point data values should be normalized
-		/// @param stride Specifies the byte offset between consecutive generic vertex attributes
-		/// @param pointer Specifies a offset of the first component of the first generic vertex attribute in the array
-		void attachArrayBufferVbo(const Vbo& vbo, uint attribVarLocation, GLint size, GLenum type,
-		                          GLboolean normalized, GLsizei stride, const GLvoid* pointer);
+		/// @param normalized Specifies whether fixed-point data values should
+		/// be normalized
+		/// @param stride Specifies the byte offset between consecutive generic
+		/// vertex attributes
+		/// @param pointer Specifies a offset of the first component of the
+		/// first generic vertex attribute in the array
+		void attachArrayBufferVbo(const Vbo& vbo, uint attribVarLocation,
+			GLint size, GLenum type, GLboolean normalized, GLsizei stride,
+			const GLvoid* pointer);
 
 		/// Attach an element array buffer VBO
 		void attachElementArrayBufferVbo(const Vbo& vbo);

+ 16 - 8
src/GfxApi/BufferObjects/Vbo.h

@@ -4,33 +4,41 @@
 #include "BufferObject.h"
 
 
-/// This is a wrapper for Vertex Buffer Objects to prevent us from making idiotic errors
+/// This is a wrapper for Vertex Buffer Objects to prevent us from making
+/// idiotic errors
 class Vbo: public BufferObject
 {
 	public:
 		Vbo() {}
 
 		/// Adds an extra check in target_ @see BufferObject::BufferObject
-		Vbo(GLenum target_, uint sizeInBytes, const void* dataPtr, GLenum usage_);
+		Vbo(GLenum target_, uint sizeInBytes, const void* dataPtr,
+			GLenum usage_);
 
-		/// Unbinds all VBOs, meaning both GL_ARRAY_BUFFER and GL_ELEMENT_ARRAY_BUFFER targets
+		/// Unbinds all VBOs, meaning both GL_ARRAY_BUFFER and
+		/// GL_ELEMENT_ARRAY_BUFFER targets
 		static void unbindAllTargets();
 
-		/// The same as BufferObject::create but it only accepts GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER in target
+		/// The same as BufferObject::create but it only accepts
+		/// GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER in target
 		/// @see BufferObject::create
-		void create(GLenum target, uint sizeInBytes, const void* dataPtr, GLenum usage);
+		void create(GLenum target, uint sizeInBytes, const void* dataPtr,
+			GLenum usage);
 };
 
 
-inline Vbo::Vbo(GLenum target_, uint sizeInBytes_, const void* dataPtr_, GLenum usage_)
+inline Vbo::Vbo(GLenum target_, uint sizeInBytes_, const void* dataPtr_,
+	GLenum usage_)
 {
 	create(target_, sizeInBytes_, dataPtr_, usage_);
 }
 
 
-inline void Vbo::create(GLenum target_, uint sizeInBytes_, const void* dataPtr_, GLenum usage_)
+inline void Vbo::create(GLenum target_, uint sizeInBytes_,
+	const void* dataPtr_, GLenum usage_)
 {
-	ASSERT(target_ == GL_ARRAY_BUFFER || target_ == GL_ELEMENT_ARRAY_BUFFER); // unacceptable target_
+	// unacceptable target_
+	ASSERT(target_ == GL_ARRAY_BUFFER || target_ == GL_ELEMENT_ARRAY_BUFFER);
 	BufferObject::create(target_, sizeInBytes_, dataPtr_, usage_);
 }
 

+ 8 - 4
src/GfxApi/GlException.h

@@ -6,8 +6,10 @@
 #include "Util/Exception.h"
 
 
-/// The function throws an exception if there is an OpenGL error. Use it with the ON_GL_FAIL_THROW_EXCEPTION macro
-inline void glConditionalThrowException(const char* file, int line, const char* func)
+/// The function throws an exception if there is an OpenGL error. Use it with
+/// the ON_GL_FAIL_THROW_EXCEPTION macro
+inline void glConditionalThrowException(const char* file, int line,
+	const char* func)
 {
 	GLenum errId = glGetError();
 	if(errId == GL_NO_ERROR)
@@ -16,11 +18,13 @@ inline void glConditionalThrowException(const char* file, int line, const char*
 	}
 
 	const char* glerr = reinterpret_cast<const char*>(gluErrorString(errId));
-	throw Exception(std::string("OpenGL exception: ") + glerr, file, line, func);
+	throw Exception(std::string("OpenGL exception: ") + glerr, file, line,
+		func);
 }
 
 
-#define ON_GL_FAIL_THROW_EXCEPTION() glConditionalThrowException(__FILE__, __LINE__, __func__)
+#define ON_GL_FAIL_THROW_EXCEPTION() \
+	glConditionalThrowException(__FILE__, __LINE__, __func__)
 
 
 #endif

+ 2 - 1
src/GfxApi/GlStateMachine.h

@@ -16,7 +16,8 @@ class GlStateMachine
 		/// Sync the local members with the opengl ones
 		void sync();
 
-		/// @name Set the Fixed Function Pipeline, Call the OpenGL functions only when needed
+		/// @name Set the Fixed Function Pipeline, Call the OpenGL functions
+		/// only when needed
 		/// @{
 		void enable(GLenum flag, bool enable = true);
 		void disable(GLenum flag) {enable(flag, false);}

+ 17 - 17
src/Main.cpp

@@ -19,7 +19,7 @@
 #include "Resources/SkelAnim.h"
 #include "Resources/LightRsrc.h"
 #include "Misc/Parser.h"
-#include "Scene/ParticleEmitter.h"
+#include "Scene/ParticleEmitterNode.h"
 #include "Physics/Character.h"
 #include "Renderer/Renderer.h"
 #include "Renderer/RendererInitializer.h"
@@ -51,7 +51,7 @@ SkinNode* imp;
 //SkelModelNode* imp;
 PointLight* point_lights[10];
 SpotLight* spot_lights[2];
-ParticleEmitter* partEmitter;
+ParticleEmitterNode* partEmitter;
 Phys::Character* character;
 
 Ui::Painter* painter;
@@ -131,8 +131,8 @@ void init()
 
 	// camera
 	PerspectiveCamera* cam = new PerspectiveCamera(false, NULL);
-	//cam->setAll(toRad(100.0), toRad(100.0) / MainRendererSingleton::getInstance().getAspectRatio(), 0.5, 200.0);
-	cam->setAll(MainRendererSingleton::getInstance().getAspectRatio()*toRad(60.0), toRad(60.0), 0.5, 200.0);
+	//cam->setAll(toRad(100.0), toRad(100.0) / R::MainRendererSingleton::getInstance().getAspectRatio(), 0.5, 200.0);
+	cam->setAll(R::MainRendererSingleton::getInstance().getAspectRatio()*toRad(60.0), toRad(60.0), 0.5, 200.0);
 	cam->moveLocalY(3.0);
 	cam->moveLocalZ(5.7);
 	cam->moveLocalX(-0.3);
@@ -143,40 +143,40 @@ void init()
 	ocam->setAll(-1, 1, 1.0, -1.0, 0.1, 10.0);
 
 	// lights
-	point_lights[0] = new PointLight();
+	point_lights[0] = new PointLight(false, NULL);
 	point_lights[0]->init("maps/temple/light0.light");
 	point_lights[0]->setLocalTransform(Transform(Vec3(-1.0, 2.4, 1.0), Mat3::getIdentity(), 1.0));
-	point_lights[1] = new PointLight();
+	point_lights[1] = new PointLight(false, NULL);
 	point_lights[1]->init("maps/temple/light1.light");
 	point_lights[1]->setLocalTransform(Transform(Vec3(2.5, 1.4, 1.0), Mat3::getIdentity(), 1.0));
 
-	spot_lights[0] = new SpotLight();
+	spot_lights[0] = new SpotLight(false, NULL);
 	spot_lights[0]->init("maps/temple/light2.light");
 	spot_lights[0]->setLocalTransform(Transform(Vec3(1.3, 4.3, 3.0), Mat3(Euler(toRad(-20), toRad(20), 0.0)), 1.0));
-	spot_lights[1] = new SpotLight();
+	spot_lights[1] = new SpotLight(false, NULL);
 	spot_lights[1]->init("maps/temple/light3.light");
 	spot_lights[1]->setLocalTransform(Transform(Vec3(-2.3, 6.3, 2.9), Mat3(Euler(toRad(-70), toRad(-20), 0.0)), 1.0));
 
 
 	// horse
-	horse = new ModelNode();
+	horse = new ModelNode(false, NULL);
 	horse->init("meshes/horse/horse.mdl");
 	horse->setLocalTransform(Transform(Vec3(-2, 0, 0), Mat3::getIdentity(), 1.0));
 
 	// Pentagram
-	pentagram = new ModelNode();
+	pentagram = new ModelNode(false, NULL);
 	pentagram->init("models/pentagram/pentagram.mdl");
 	pentagram->setLocalTransform(Transform(Vec3(2, 0, 0), Mat3::getIdentity(), 1.0));
 
 	// Sponza
-	ModelNode* sponza = new ModelNode();
+	ModelNode* sponza = new ModelNode(false, NULL);
 	//sponza->init("maps/sponza/sponza.mdl");
 	sponza->init("maps/sponza-crytek/sponza_crytek.mdl");
 	sponza->setLocalTransform(Transform(Vec3(0.0), Mat3::getIdentity(), 0.05));
 
 
 	// Imp
-	imp = new SkinNode();
+	imp = new SkinNode(false, NULL);
 	imp->setLocalTransform(Transform(Vec3(0.0, 2.0, 0.0), Mat3::getIdentity(), 0.7));
 	imp->init("models/imp/imp.skin");
 	imp->skelAnimModelNodeCtrl = new SkelAnimModelNodeCtrl(*imp);
@@ -225,7 +225,7 @@ void init()
 	//node->setLocalTransform(Transform(Vec3(0.0, -0.0, 0.0), Mat3::getIdentity(), 0.01));
 
 	// particle emitter
-	partEmitter = new ParticleEmitter;
+	partEmitter = new ParticleEmitterNode(false, NULL);
 	partEmitter->init("asdf");
 	partEmitter->getLocalTransform().setOrigin(Vec3(3.0, 0.0, 0.0));
 
@@ -316,7 +316,7 @@ void mainLoopExtra()
 	/*if(InputSingleton::getInstance().getKey(SDL_SCANCODE_F) == 1)
 	{
 		Event::ManagerSingleton::getInstance().createEvent(Event::MainRendererPpsHdr(HighRezTimer::getCrntTime() + 5,
-			5, MainRendererSingleton::getInstance().getPps().getHdr().getExposure() + 20.0, 3, 1.4));
+			5, R::MainRendererSingleton::getInstance().getPps().getHdr().getExposure() + 20.0, 3, 1.4));
 	}*/
 
 
@@ -380,7 +380,7 @@ void mainLoop()
 		SceneSingleton::getInstance().doVisibilityTests(*AppSingleton::getInstance().getActiveCam());
 		SceneSingleton::getInstance().updateAllControllers();
 		Event::ManagerSingleton::getInstance().updateAllEvents(prevUpdateTime, crntTime);
-		MainRendererSingleton::getInstance().render(*AppSingleton::getInstance().getActiveCam());
+		R::MainRendererSingleton::getInstance().render(*AppSingleton::getInstance().getActiveCam());
 
 		painter->setPosition(Vec2(0.0, 0.1));
 		painter->setColor(Vec4(1.0));
@@ -399,7 +399,7 @@ void mainLoop()
 
 		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_F12) == 1)
 		{
-			MainRendererSingleton::getInstance().takeScreenshot("gfx/screenshot.jpg");
+			R::MainRendererSingleton::getInstance().takeScreenshot("gfx/screenshot.jpg");
 		}
 
 		AppSingleton::getInstance().swapBuffers();
@@ -433,7 +433,7 @@ void mainLoop()
 			SDL_Delay((AppSingleton::getInstance().getTimerTick() - timer.getElapsedTime()) * 1000.0);
 		}
 
-		/*if(MainRendererSingleton::getInstance().getFramesNum() == 100)
+		/*if(R::MainRendererSingleton::getInstance().getFramesNum() == 100)
 		{
 			break;
 		}*/

+ 3 - 3
src/Math/Vec3.inl.h

@@ -69,7 +69,7 @@ inline Vec3::Vec3(const Quat& q)
 }
 
 //==============================================================================
-// Accessors                                                                            =
+// Accessors                                                                   =
 //==============================================================================
 
 inline float& Vec3::x()
@@ -422,8 +422,8 @@ inline Vec3 Vec3::getTransformed(const Mat4& transform) const
 		Vec4 v4((*this), 1.0);
 		for(int i = 0; i < 3; i++)
 		{
-			_mm_store_ss(&out[i], _mm_dp_ps(transform.getMm(i), v4.getMm(),
-				0xF1));
+			_mm_store_ss(&out[i], _mm_dp_ps(transform.getMm(i),
+				v4.getMm(), 0xF1));
 		}
 		return out;
 	#else

+ 17 - 9
src/Misc/Parser.h

@@ -6,7 +6,8 @@
 #include "Util/Scanner/Scanner.h"
 
 
-/// It contains some functions and macros that are used pretty often while parsing
+/// It contains some functions and macros that are used pretty often while
+/// parsing
 namespace Parser {
 
 /// Parser macros
@@ -15,25 +16,29 @@ namespace Parser {
 	boost::lexical_cast<std::string>(scanner.getLineNumber()) + "): " + x)
 
 #define PARSER_EXCEPTION_EXPECTED(x) \
-	PARSER_EXCEPTION("Expected " + x + " and not " + scanner.getCrntToken().getInfoStr())
+	PARSER_EXCEPTION("Expected " + x + " and not " + \
+		scanner.getCrntToken().getInfoStr())
 
 #define PARSER_EXCEPTION_UNEXPECTED() \
 	PARSER_EXCEPTION("Unexpected token " + scanner.getCrntToken().getInfoStr())
 
 
-/// This template func is used for a common operation of parsing arrays of numbers
+/// This template func is used for a common operation of parsing arrays of
+/// numbers
 ///
-/// It parses expressions like this one: { 10 -0.2 123.e-10 -0x0FF } and stores the result in the arr array. The
-/// acceptable types (typename Type) are integer or floating point types
+/// It parses expressions like this one: { 10 -0.2 123.e-10 -0x0FF } and stores
+/// the result in the arr array. The acceptable types (typename Type) are
+/// integer or floating point types
 ///
 /// @param scanner The scanner that we will use
-/// @param bracket If true the array starts and ends with brackets eg { 10 0 -1 }
+/// @param bracket If true the array starts and ends with brackets eg {10 0 -1}
 /// @param signs If true the array has numbers that may contain sign
 /// @param size The count of numbers of the array wa want to parse
 /// @param arr The array that the func returns the numbers
 /// @exception Exception
 template <typename Type>
-void parseArrOfNumbers(Scanner::Scanner& scanner, bool bracket, bool signs, uint size, Type* arr);
+void parseArrOfNumbers(Scanner::Scanner& scanner, bool bracket, bool signs,
+	uint size, Type* arr);
 
 /// Parse a single number
 /// @param scanner The scanner that we will use
@@ -42,7 +47,8 @@ void parseArrOfNumbers(Scanner::Scanner& scanner, bool bracket, bool signs, uint
 template <typename Type>
 void parseNumber(Scanner::Scanner& scanner, bool sign, Type& out);
 
-/// Parses a math structure (Vec3, Vec4, Mat3 etc) with leading and following brackets. Eg {0.1 0.2 0.3}
+/// Parses a math structure (Vec3, Vec4, Mat3 etc) with leading and following
+/// brackets. Eg {0.1 0.2 0.3}
 template <typename Type>
 void parseMathVector(Scanner::Scanner& scanner, Type& out);
 
@@ -50,7 +56,8 @@ void parseMathVector(Scanner::Scanner& scanner, Type& out);
 extern bool parseBool(Scanner::Scanner& scanner);
 
 /// Parse identifier
-extern std::string parseIdentifier(Scanner::Scanner& scanner, const char* expectedIdentifier = NULL);
+extern std::string parseIdentifier(Scanner::Scanner& scanner,
+	const char* expectedIdentifier = NULL);
 
 /// Is identifier
 extern bool isIdentifier(const Scanner::Token* token, const char* str);
@@ -58,6 +65,7 @@ extern bool isIdentifier(const Scanner::Token* token, const char* str);
 /// Parse string
 extern std::string parseString(Scanner::Scanner& scanner);
 
+
 } // end namespace Parser
 
 

+ 12 - 6
src/Misc/Parser.inl.h

@@ -10,7 +10,8 @@ namespace Parser {
 // parseArrOfNumbers                                                           =
 //==============================================================================
 template <typename Type>
-void parseArrOfNumbers(Scanner::Scanner& scanner, bool bracket, bool signs, uint size, Type* arr)
+void parseArrOfNumbers(Scanner::Scanner& scanner, bool bracket, bool signs,
+	uint size, Type* arr)
 {
 	const Scanner::Token* token;
 
@@ -117,12 +118,14 @@ void parseNumber(Scanner::Scanner& scanner, bool sign, Type& out)
 
 		if(token->getDataType() == Scanner::DT_FLOAT)
 		{
-			double d = negative ? -token->getValue().getFloat() : token->getValue().getFloat();
+			double d = negative ? -token->getValue().getFloat() :
+				token->getValue().getFloat();
 			out = static_cast<Type>(d);
 		}
 		else
 		{
-			ulong l = negative ? -token->getValue().getInt() : token->getValue().getInt();
+			ulong l = negative ? -token->getValue().getInt() :
+				token->getValue().getInt();
 			out = static_cast<Type>(l);
 		}
 	}
@@ -203,7 +206,8 @@ inline bool parseBool(Scanner::Scanner& scanner)
 //==============================================================================
 // parseIdentifier                                                             =
 //==============================================================================
-inline std::string parseIdentifier(Scanner::Scanner& scanner, const char* expectedIdentifier)
+inline std::string parseIdentifier(Scanner::Scanner& scanner,
+	const char* expectedIdentifier)
 {
 	const Scanner::Token* token = &scanner.getNextToken();
 	if(token->getCode() != Scanner::TC_IDENTIFIER)
@@ -218,7 +222,8 @@ inline std::string parseIdentifier(Scanner::Scanner& scanner, const char* expect
 		}
 	}
 
-	if(expectedIdentifier != NULL && strcmp(token->getValue().getString(), expectedIdentifier))
+	if(expectedIdentifier != NULL &&
+		strcmp(token->getValue().getString(), expectedIdentifier))
 	{
 		throw PARSER_EXCEPTION_EXPECTED("identifier " + expectedIdentifier);
 	}
@@ -232,7 +237,8 @@ inline std::string parseIdentifier(Scanner::Scanner& scanner, const char* expect
 //==============================================================================
 inline bool isIdentifier(const Scanner::Token* token, const char* str)
 {
-	return token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), str);
+	return token->getCode() == Scanner::TC_IDENTIFIER &&
+		!strcmp(token->getValue().getString(), str);
 }
 
 

+ 15 - 5
src/Misc/PropertyTree.cpp

@@ -21,7 +21,8 @@ bool getBool(const boost::property_tree::ptree& pt, const char* tag)
 	}
 	else
 	{
-		throw EXCEPTION("Expected true or false for tag " + tag + " and not " + str);
+		throw EXCEPTION("Expected true or false for tag " + tag +
+			" and not " + str);
 	}
 }
 
@@ -29,7 +30,8 @@ bool getBool(const boost::property_tree::ptree& pt, const char* tag)
 //==============================================================================
 // getBoolOptional                                                             =
 //==============================================================================
-extern boost::optional<bool> getBoolOptional(const boost::property_tree::ptree& pt, const char* tag)
+extern boost::optional<bool> getBoolOptional(
+	const boost::property_tree::ptree& pt, const char* tag)
 {
 	boost::optional<std::string> str = pt.get_optional<std::string>(tag);
 	if(str)
@@ -44,7 +46,8 @@ extern boost::optional<bool> getBoolOptional(const boost::property_tree::ptree&
 		}
 		else
 		{
-			throw EXCEPTION("Expected true or false for tag " + tag + " and not " + str.get());
+			throw EXCEPTION("Expected true or false for tag " + tag +
+				" and not " + str.get());
 		}
 	}
 	return boost::optional<bool>();
@@ -76,7 +79,10 @@ Vec2 getVec2(const boost::property_tree::ptree& pt)
 Vec3 getVec3(const boost::property_tree::ptree& pt)
 {
 	const boost::property_tree::ptree& tree = pt.get_child("vec3");
-	return Vec3(tree.get<float>("x"), tree.get<float>("y"), tree.get<float>("z"));
+	return Vec3(
+		tree.get<float>("x"),
+		tree.get<float>("y"),
+		tree.get<float>("z"));
 }
 
 
@@ -86,7 +92,11 @@ Vec3 getVec3(const boost::property_tree::ptree& pt)
 Vec4 getVec4(const boost::property_tree::ptree& pt)
 {
 	const boost::property_tree::ptree& tree = pt.get_child("vec4");
-	return Vec4(tree.get<float>("x"), tree.get<float>("y"), tree.get<float>("z"), tree.get<float>("w"));
+	return Vec4(
+		tree.get<float>("x"),
+		tree.get<float>("y"),
+		tree.get<float>("z"),
+		tree.get<float>("w"));
 }
 
 

+ 5 - 1
src/Misc/PropertyTree.h

@@ -8,6 +8,7 @@
 
 namespace PropertyTree {
 
+
 /// Get a bool from a ptree or throw exception if not found or incorrect.
 /// Get something like this: @code<tag>true</tag>@endcode
 /// @param[in] pt The ptree
@@ -18,7 +19,8 @@ extern bool getBool(const boost::property_tree::ptree& pt, const char* tag);
 /// Get something like this: @code<tag>true</tag>@endcode
 /// @param[in] pt The ptree
 /// @param[in] tag The name of tha tag
-extern boost::optional<bool> getBoolOptional(const boost::property_tree::ptree& pt, const char* tag);
+extern boost::optional<bool> getBoolOptional(
+	const boost::property_tree::ptree& pt, const char* tag);
 
 /// Get a @code<float>0.0</float>@endcode
 extern float getFloat(const boost::property_tree::ptree& pt);
@@ -32,6 +34,8 @@ extern Vec3 getVec3(const boost::property_tree::ptree& pt);
 /// Get a @code<vec4><x>0.0</x><y>0.0</y><z>0.0</z><w>0.0</w></vec4>@endcode
 extern Vec4 getVec4(const boost::property_tree::ptree& pt);
 
+
 } // end namespace
 
+
 #endif

+ 23 - 11
src/Renderer/Bl.cpp

@@ -4,6 +4,9 @@
 #include "Resources/ShaderProg.h"
 
 
+namespace R {
+
+
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
@@ -29,19 +32,23 @@ void Bl::init(const RendererInitializer& initializer)
 	// Horizontal
 	try
 	{
-		Renderer::createFai(r.getWidth(), r.getHeight(), GL_RGB, GL_RGB, GL_FLOAT, blurFai);
+		Renderer::createFai(r.getWidth(), r.getHeight(), GL_RGB, GL_RGB,
+			GL_FLOAT, blurFai);
 
 		hBlurFbo.create();
 		hBlurFbo.bind();
 		hBlurFbo.setNumOfColorAttachements(1);
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, blurFai.getGlId(), 0);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+			GL_TEXTURE_2D, blurFai.getGlId(), 0);
 	}
 	catch(std::exception& e)
 	{
-		throw EXCEPTION("Cannot create horizontal blur post-processing stage FBO: " + e.what());
+		throw EXCEPTION("Cannot create horizontal blur post-processing stage "
+			"FBO: " + e.what());
 	}
 
-	hBlurSProg.loadRsrc(ShaderProg::createSrcCodeToCache("shaders/PpsBlurGeneric.glsl", "#define HPASS\n").c_str());
+	hBlurSProg.loadRsrc(ShaderProg::createSrcCodeToCache(
+		"shaders/PpsBlurGeneric.glsl", "#define HPASS\n").c_str());
 
 	// Vertical
 	try
@@ -49,15 +56,17 @@ void Bl::init(const RendererInitializer& initializer)
 		vBlurFbo.create();
 		vBlurFbo.bind();
 		vBlurFbo.setNumOfColorAttachements(1);
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
-		                       r.getPps().getPostPassFai().getGlId(), 0);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+			GL_TEXTURE_2D, r.getPps().getPostPassFai().getGlId(), 0);
 	}
 	catch(std::exception& e)
 	{
-		throw EXCEPTION("Cannot create vertical blur post-processing stage FBO: " + e.what());
+		throw EXCEPTION("Cannot create vertical blur post-processing stage "
+			"FBO: " + e.what());
 	}
 
-	vBlurSProg.loadRsrc(ShaderProg::createSrcCodeToCache("shaders/PpsBlurGeneric.glsl", "#define VPASS\n").c_str());
+	vBlurSProg.loadRsrc(ShaderProg::createSrcCodeToCache(
+		"shaders/PpsBlurGeneric.glsl", "#define VPASS\n").c_str());
 
 	// Side blur
 	try
@@ -65,12 +74,13 @@ void Bl::init(const RendererInitializer& initializer)
 		sideBlurFbo.create();
 		sideBlurFbo.bind();
 		sideBlurFbo.setNumOfColorAttachements(1);
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
-							   r.getMs().getNormalFai().getGlId(), 0);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+			GL_TEXTURE_2D, r.getMs().getNormalFai().getGlId(), 0);
 	}
 	catch(std::exception& e)
 	{
-		throw EXCEPTION("Cannot create side blur post-processing stage FBO: " + e.what());
+		throw EXCEPTION("Cannot create side blur post-processing stage FBO: " +
+			e.what());
 	}
 
 	sideBlurMap.loadRsrc("engine-rsrc/side-blur.png");
@@ -149,3 +159,5 @@ void Bl::run()
 	runBlur();
 }
 
+
+} // end namespace

+ 12 - 4
src/Renderer/Bl.h

@@ -1,5 +1,5 @@
-#ifndef BL_H
-#define BL_H
+#ifndef R_BL_H
+#define R_BL_H
 
 #include "RenderingPass.h"
 #include "Util/Accessors.h"
@@ -11,6 +11,9 @@
 class ShaderProg;
 
 
+namespace R {
+
+
 class Bl: private RenderingPass
 {
 	public:
@@ -21,8 +24,10 @@ class Bl: private RenderingPass
 		/// @name Accessors
 		/// @{
 		GETTER_SETTER_BY_VAL(bool, enabled, isEnabled, setEnabled)
-		GETTER_SETTER_BY_VAL(uint, blurringIterationsNum, getBlurringIterationsNum, setBlurringIterationsNum)
-		GETTER_SETTER_BY_VAL(float, sideBlurFactor, getSideBlurFactor, setSideBlurFactor)
+		GETTER_SETTER_BY_VAL(uint, blurringIterationsNum,
+			getBlurringIterationsNum, setBlurringIterationsNum)
+		GETTER_SETTER_BY_VAL(float, sideBlurFactor, getSideBlurFactor,
+			setSideBlurFactor)
 		/// @}
 
 	private:
@@ -46,4 +51,7 @@ class Bl: private RenderingPass
 };
 
 
+} // end namespace
+
+
 #endif

+ 16 - 90
src/Renderer/Bs.cpp

@@ -9,6 +9,9 @@
 #include "Resources/Mesh.h"
 
 
+namespace R {
+
+
 //==============================================================================
 // Destructor                                                                  =
 //==============================================================================
@@ -28,10 +31,10 @@ void Bs::createFbo()
 
 		fbo.setNumOfColorAttachements(1);
 
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
-		                       r.getPps().getPrePassFai().getGlId(), 0);
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D,
-		                       r.getMs().getDepthFai().getGlId(), 0);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+			GL_TEXTURE_2D, r.getPps().getPrePassFai().getGlId(), 0);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
+			GL_TEXTURE_2D, r.getMs().getDepthFai().getGlId(), 0);
 
 		fbo.checkIfGood();
 
@@ -56,9 +59,10 @@ void Bs::createRefractFbo()
 
 		refractFbo.setNumOfColorAttachements(1);
 
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, refractFai.getGlId(), 0);
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D,
-		                       r.getMs().getDepthFai().getGlId(), 0);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+			GL_TEXTURE_2D, refractFai.getGlId(), 0);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
+			GL_TEXTURE_2D, r.getMs().getDepthFai().getGlId(), 0);
 
 		refractFbo.checkIfGood();
 
@@ -77,7 +81,8 @@ void Bs::createRefractFbo()
 void Bs::init(const RendererInitializer& /*initializer*/)
 {
 	createFbo();
-	Renderer::createFai(r.getWidth(), r.getHeight(), GL_RGBA8, GL_RGBA, GL_FLOAT, refractFai);
+	Renderer::createFai(r.getWidth(), r.getHeight(), GL_RGBA8, GL_RGBA,
+		GL_FLOAT, refractFai);
 	createRefractFbo();
 	refractSProg.loadRsrc("shaders/BsRefract.glsl");
 }
@@ -88,87 +93,8 @@ void Bs::init(const RendererInitializer& /*initializer*/)
 //==============================================================================
 void Bs::run()
 {
-	/*Renderer::setViewport(0, 0, r.getWidth(), r.getHeight());
+	/// @todo
+}
 
-	glDepthMask(false);
 
-	// render the models
-	Scene::Types<ModelNode>::ConstIterator it = SceneSingleton::getInstance().getModelNodes().begin();
-	for(; it != SceneSingleton::getInstance().getModelNodes().end(); ++it)
-	{
-		const ModelNode& mn = *(*it);
-		boost::ptr_vector<ModelNodePatch>::const_iterator it = mn.getModelPatchNodes().begin();
-		for(; it != mn.getModelPatchNodes().end(); it++)
-		{
-			const ModelNodePatch& sm = *it;
-
-			if(!sm.getCpMtl().renderInBlendingStage())
-			{
-				continue;
-			}
-
-			// refracts ?
-			if(sm.getCpMtl().getStdUniVar(Material::SUV_PPS_PRE_PASS_FAI))
-			{
-				//
-				// Stage 0: Render to the temp FAI
-				//
-				refractFbo.bind();
-
-				glEnable(GL_STENCIL_TEST);
-				glClear(GL_STENCIL_BUFFER_BIT);
-				glStencilFunc(GL_ALWAYS, 0x1, 0x1);
-				glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
-
-				r.setupShaderProg(sm.getCpMtl(), mn, r.getCamera());
-				GlStateMachineSingleton::getInstance().enable(GL_BLEND, false); // a hack
-
-				sm.getCpVao().bind();
-				glDrawElements(GL_TRIANGLES, sm.getModelPatchRsrc().getMesh().getVertIdsNum(), GL_UNSIGNED_SHORT, 0);
-				sm.getCpVao().unbind();
-
-				//
-				// Stage 1: Render the temp FAI to prePassFai
-				//
-				fbo.bind();
-
-				glStencilFunc(GL_EQUAL, 0x1, 0x1);
-				glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
-
-				if(sm.getCpMtl().isBlendingEnabled())
-				{
-					GlStateMachineSingleton::getInstance().enable(GL_BLEND, true);
-					glBlendFunc(sm.getCpMtl().getBlendingSfactor(), sm.getCpMtl().getBlendingDfactor());
-				}
-				else
-				{
-					GlStateMachineSingleton::getInstance().enable(GL_BLEND, false);
-				}
-
-				refractSProg->bind();
-				refractSProg->findUniVar("fai")->setTexture(refractFai, 0);
-
-				r.drawQuad();
-
-				// cleanup
-				glStencilFunc(GL_ALWAYS, 0x1, 0x1);
-				glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
-				glClear(GL_STENCIL_BUFFER_BIT);
-				glDisable(GL_STENCIL_TEST);
-			}
-			// no rafraction
-			else
-			{
-				r.setupShaderProg(sm.getCpMtl(), mn, r.getCamera());
-
-				sm.getCpVao().bind();
-				glDrawElements(GL_TRIANGLES, sm.getModelPatchRsrc().getMesh().getVertIdsNum(), GL_UNSIGNED_SHORT, 0);
-				sm.getCpVao().unbind();
-			}
-		} // end for all subModels
-	} // end for all modelNodes
-
-	glDepthMask(true);
-	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // the rendering above fucks the polygon mode
-	Fbo::unbind();*/
-}
+} // end namesapce

+ 8 - 2
src/Renderer/Bs.h

@@ -1,5 +1,5 @@
-#ifndef BS_H
-#define BS_H
+#ifndef R_BS_H
+#define R_BS_H
 
 #include "RenderingPass.h"
 #include "GfxApi/BufferObjects/Fbo.h"
@@ -10,6 +10,9 @@
 class ShaderProg;
 
 
+namespace R {
+
+
 /// Blending stage.
 /// The objects that blend must be handled differently
 class Bs: public RenderingPass
@@ -32,4 +35,7 @@ class Bs: public RenderingPass
 };
 
 
+} // end namespace
+
+
 #endif

+ 34 - 19
src/Renderer/Dbg.cpp

@@ -4,7 +4,7 @@
 #include "Scene/Scene.h"
 #include "Scene/Camera.h"
 #include "Scene/Light.h"
-#include "Scene/ParticleEmitter.h"
+#include "Scene/ParticleEmitterNode.h"
 #include "RendererInitializer.h"
 #include "Drawers/SceneDbgDrawer.h"
 #include "Scene/SkinNode.h"
@@ -12,6 +12,9 @@
 #include <boost/foreach.hpp>
 
 
+namespace R {
+
+
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
@@ -89,7 +92,7 @@ void Dbg::renderGrid()
 
 
 //==============================================================================
-// drawSphere                                                                =
+// drawSphere                                                                  =
 //==============================================================================
 void Dbg::drawSphere(float radius, int complexity)
 {
@@ -98,7 +101,8 @@ void Dbg::drawSphere(float radius, int complexity)
 	//
 	// Pre-calculate the sphere points5
 	//
-	std::map<uint, Vec<Vec3> >::iterator it = complexityToPreCalculatedSphere.find(complexity);
+	std::map<uint, Vec<Vec3> >::iterator it =
+		complexityToPreCalculatedSphere.find(complexity);
 
 	if(it != complexityToPreCalculatedSphere.end()) // Found
 	{
@@ -176,7 +180,8 @@ void Dbg::drawCube(float size)
 		Vec3(maxPos.x(), minPos.y(), minPos.z())   // right bottom back
 	}};
 
-	boost::array<uint, 24> indeces = {{0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7}};
+	boost::array<uint, 24> indeces = {{0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6,
+		7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7}};
 
 	begin();
 		BOOST_FOREACH(uint id, indeces)
@@ -204,10 +209,10 @@ void Dbg::init(const RendererInitializer& initializer)
 
 		fbo.setNumOfColorAttachements(1);
 
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
-		                       r.getPps().getPostPassFai().getGlId(), 0);
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,  GL_TEXTURE_2D, r.getMs().getDepthFai().getGlId(),
-		                       0);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+			GL_TEXTURE_2D, r.getPps().getPostPassFai().getGlId(), 0);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
+			GL_TEXTURE_2D, r.getMs().getDepthFai().getGlId(), 0);
 
 		fbo.checkIfGood();
 		fbo.unbind();
@@ -225,13 +230,16 @@ void Dbg::init(const RendererInitializer& initializer)
 	//
 	// VAO & VBOs
 	//
-	positionsVbo.create(GL_ARRAY_BUFFER, sizeof(positions), NULL, GL_DYNAMIC_DRAW);
+	positionsVbo.create(GL_ARRAY_BUFFER, sizeof(positions), NULL,
+		GL_DYNAMIC_DRAW);
 	colorsVbo.create(GL_ARRAY_BUFFER, sizeof(colors), NULL, GL_DYNAMIC_DRAW);
 	vao.create();
 	const int positionAttribLoc = 0;
-	vao.attachArrayBufferVbo(positionsVbo, positionAttribLoc, 3, GL_FLOAT, GL_FALSE, 0, NULL);
+	vao.attachArrayBufferVbo(positionsVbo, positionAttribLoc, 3, GL_FLOAT,
+		GL_FALSE, 0, NULL);
 	const int colorAttribLoc = 1;
-	vao.attachArrayBufferVbo(colorsVbo, colorAttribLoc, 3, GL_FLOAT, GL_FALSE, 0, NULL);
+	vao.attachArrayBufferVbo(colorsVbo, colorAttribLoc, 3, GL_FLOAT, GL_FALSE,
+		0, NULL);
 
 	//
 	// Rest
@@ -264,7 +272,8 @@ void Dbg::run()
 	setModelMat(Mat4::getIdentity());
 	renderGrid();
 
-	BOOST_FOREACH(const SceneNode* node, SceneSingleton::getInstance().getAllNodes())
+	BOOST_FOREACH(const SceneNode* node,
+		SceneSingleton::getInstance().getAllNodes())
 	{
 		/*if(!node->isVisible())
 		{
@@ -276,18 +285,18 @@ void Dbg::run()
 		{
 			case SceneNode::SNT_CAMERA:
 				sceneDbgDrawer.drawCamera(static_cast<const Camera&>(*node));
-				//collisionDbgDrawer.draw(static_cast<const Camera&>(*node).wspaceFrustumPlanes[0]);
 				break;
 			case SceneNode::SNT_LIGHT:
 				sceneDbgDrawer.drawLight(static_cast<const Light&>(*node));
 				break;
 			case SceneNode::SNT_PARTICLE_EMITTER:
-				sceneDbgDrawer.drawParticleEmitter(static_cast<const ParticleEmitter&>(*node));
+				sceneDbgDrawer.drawParticleEmitter(static_cast<const ParticleEmitterNode&>(*node));
 				break;
 			case SceneNode::SNT_RENDERABLE:
 				/*if(showVisibilityBoundingShapesFlag)
 				{
-					const RenderableNode& rnode = static_cast<const RenderableNode&>(*node);
+					const RenderableNode& rnode =
+						static_cast<const RenderableNode&>(*node);
 					collisionDbgDrawer.draw(rnode. getVisibilityShapeWSpace());
 				}*/
 				break;
@@ -310,7 +319,8 @@ void Dbg::run()
 	/*setColor(Vec3(1));
 	Obb obb(Vec3(0.0), Mat3::getIdentity(), Vec3(1.0, 2.0, 1.0));
 	Obb obb2(Vec3(0.0), Mat3::getIdentity(), Vec3(1.0, 1.5, 1.0));
-	obb = obb.getTransformed(SceneSingleton::getInstance().getAllNodes()[1]->getWorldTransform());
+	obb = obb.getTransformed(SceneSingleton::getInstance().getAllNodes()[1]->
+		getWorldTransform());
 	collisionDbgDrawer.draw(obb.getCompoundShape(obb2));
 	collisionDbgDrawer.draw(obb);
 	collisionDbgDrawer.draw(obb2);
@@ -339,7 +349,8 @@ void Dbg::run()
 
 	Vec3 er = obb.getRotation() * obb.getExtend();
 
-	boost::array<uint, 24> indeces = {{0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7}};
+	boost::array<uint, 24> indeces = {{0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6,
+		7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7}};
 
 	BOOST_FOREACH(uint id, indeces)
 	{
@@ -349,7 +360,8 @@ void Dbg::run()
 	///////////////
 
 
-	SceneSingleton::getInstance().getPhysMasterContainer().getWorld().debugDrawWorld();
+	SceneSingleton::getInstance().getPhysMasterContainer().getWorld().
+		debugDrawWorld();
 	// Physics
 	/*glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
 	setModelMat(Mat4::getIdentity());
@@ -363,7 +375,8 @@ void Dbg::run()
 //==============================================================================
 void Dbg::setModelMat(const Mat4& modelMat_)
 {
-	ASSERT(pointIndex == 0); // This means that the func called after begin and before end
+	ASSERT(pointIndex == 0); // This means that the func called after begin
+	                         // and before end
 	modelMat = modelMat_;
 }
 
@@ -409,3 +422,5 @@ void Dbg::pushBackVertex(const Vec3& pos)
 	++pointIndex;
 }
 
+
+} // end namespace

+ 17 - 7
src/Renderer/Dbg.h

@@ -1,5 +1,5 @@
-#ifndef DBG_H
-#define DBG_H
+#ifndef R_DBG_H
+#define R_DBG_H
 
 #include <boost/array.hpp>
 #include <map>
@@ -15,6 +15,9 @@
 #include "Util/Accessors.h"
 
 
+namespace R {
+
+
 /// Debugging stage
 class Dbg: public RenderingPass
 {
@@ -31,7 +34,8 @@ class Dbg: public RenderingPass
 		/// @name Accessors
 		/// @{
 		GETTER_SETTER_BY_VAL(bool, enabled, isEnabled, setEnabled)
-		GETTER_SETTER_BY_VAL(bool, showSkeletonsEnabled, isShowSkeletonsEnabled, setShowSkeletonsEnabled)
+		GETTER_SETTER_BY_VAL(bool, showSkeletonsEnabled,
+			isShowSkeletonsEnabled, setShowSkeletonsEnabled)
 		/// @todo add others
 		/// @}
 
@@ -40,8 +44,10 @@ class Dbg: public RenderingPass
 		void begin(); ///< Initiates the draw
 		void end(); ///< Draws
 		void pushBackVertex(const Vec3& pos); ///< Something like glVertex
-		void setColor(const Vec3& col) {crntCol = col;} ///< Something like glColor
-		void setColor(const Vec4& col) {crntCol = Vec3(col);} ///< Something like glColor
+		/// Something like glColor
+		void setColor(const Vec3& col) {crntCol = col;}
+		/// Something like glColor
+		void setColor(const Vec4& col) {crntCol = Vec3(col);}
 		void setModelMat(const Mat4& modelMat);
 		/// @}
 
@@ -67,10 +73,14 @@ class Dbg: public RenderingPass
 		CollisionDbgDrawer collisionDbgDrawer;
 
 
-		/// This is a container of some precalculated spheres. Its a map that from sphere complexity it returns a vector
-		/// of lines (Vec3s in pairs)
+		/// This is a container of some precalculated spheres. Its a map that
+		/// from sphere complexity it returns a vector of lines (Vec3s in
+		/// pairs)
 		std::map<uint, Vec<Vec3> > complexityToPreCalculatedSphere;
 };
 
 
+} // end namespace
+
+
 #endif

+ 5 - 0
src/Renderer/Drawers/CollisionDbgDrawer.cpp

@@ -2,6 +2,8 @@
 #include "../Dbg.h"
 #include "Collision/Collision.h"
 
+namespace R {
+
 
 //==============================================================================
 // draw (Sphere)                                                               =
@@ -61,3 +63,6 @@ void CollisionDbgDrawer::draw(const Col::Plane& plane)
 	dbg.setModelMat(trf);
 	dbg.renderGrid();
 }
+
+
+} // end namespace

+ 11 - 3
src/Renderer/Drawers/CollisionDbgDrawer.h

@@ -1,8 +1,7 @@
-#ifndef COLLISION_DBG_DRAWER_H
-#define COLLISION_DBG_DRAWER_H
+#ifndef R_COLLISION_DBG_DRAWER_H
+#define R_COLLISION_DBG_DRAWER_H
 
 
-class Dbg;
 namespace Col {
 class Sphere;
 class Obb;
@@ -10,6 +9,12 @@ class Plane;
 }
 
 
+namespace R {
+
+
+class Dbg;
+
+
 /// Contains methods to render the collision shapes
 class CollisionDbgDrawer
 {
@@ -31,4 +36,7 @@ class CollisionDbgDrawer
 };
 
 
+} // end namespace
+
+
 #endif

+ 31 - 19
src/Renderer/Drawers/PhyDbgDrawer.cpp

@@ -1,34 +1,39 @@
 #include "PhyDbgDrawer.h"
-#include "../MainRenderer.h"
+#include "../Dbg.h"
 #include "Physics/Convertors.h"
 #include "Core/Logger.h"
-#include "Core/Globals.h"
+
+
+namespace R {
 
 
 //==============================================================================
 // drawLine                                                                    =
 //==============================================================================
-void PhyDbgDrawer::drawLine(const btVector3& from, const btVector3& to, const btVector3& color)
+void PhyDbgDrawer::drawLine(const btVector3& from, const btVector3& to,
+	const btVector3& color)
 {
-	MainRendererSingleton::getInstance().getDbg().drawLine(toAnki(from), toAnki(to), Vec4(toAnki(color), 1.0));
+	dbg.drawLine(toAnki(from), toAnki(to), Vec4(toAnki(color), 1.0));
 }
 
 
 //==============================================================================
 // drawSphere                                                                  =
 //==============================================================================
-void PhyDbgDrawer::drawSphere(btScalar radius, const btTransform& transform, const btVector3& color)
+void PhyDbgDrawer::drawSphere(btScalar radius, const btTransform& transform,
+	const btVector3& color)
 {
-	MainRendererSingleton::getInstance().getDbg().setColor(toAnki(color));
-	MainRendererSingleton::getInstance().getDbg().setModelMat(Mat4(toAnki(transform)));
-	MainRendererSingleton::getInstance().getDbg().drawSphere(radius);
+	dbg.setColor(toAnki(color));
+	dbg.setModelMat(Mat4(toAnki(transform)));
+	dbg.drawSphere(radius);
 }
 
 
 //==============================================================================
 // drawBox                                                                     =
 //==============================================================================
-void PhyDbgDrawer::drawBox(const btVector3& min, const btVector3& max, const btVector3& color)
+void PhyDbgDrawer::drawBox(const btVector3& min, const btVector3& max,
+	const btVector3& color)
 {
 	Mat4 trf(Mat4::getIdentity());
 	trf(0, 0) = max.getX() - min.getX();
@@ -37,16 +42,17 @@ void PhyDbgDrawer::drawBox(const btVector3& min, const btVector3& max, const btV
 	trf(0, 3) = (max.getX() + min.getX()) / 2.0;
 	trf(1, 3) = (max.getY() + min.getY()) / 2.0;
 	trf(2, 3) = (max.getZ() + min.getZ()) / 2.0;
-	MainRendererSingleton::getInstance().getDbg().setModelMat(trf);
-	MainRendererSingleton::getInstance().getDbg().setColor(toAnki(color));
-	MainRendererSingleton::getInstance().getDbg().drawCube(1.0);
+	dbg.setModelMat(trf);
+	dbg.setColor(toAnki(color));
+	dbg.drawCube(1.0);
 }
 
 
 //==============================================================================
 // drawBox                                                                     =
 //==============================================================================
-void PhyDbgDrawer::drawBox(const btVector3& min, const btVector3& max, const btTransform& trans, const btVector3& color)
+void PhyDbgDrawer::drawBox(const btVector3& min, const btVector3& max,
+	const btTransform& trans, const btVector3& color)
 {
 	Mat4 trf(Mat4::getIdentity());
 	trf(0, 0) = max.getX() - min.getX();
@@ -56,17 +62,18 @@ void PhyDbgDrawer::drawBox(const btVector3& min, const btVector3& max, const btT
 	trf(1, 3) = (max.getY() + min.getY()) / 2.0;
 	trf(2, 3) = (max.getZ() + min.getZ()) / 2.0;
 	trf = Mat4::combineTransformations(Mat4(toAnki(trans)), trf);
-	MainRendererSingleton::getInstance().getDbg().setModelMat(trf);
-	MainRendererSingleton::getInstance().getDbg().setColor(toAnki(color));
-	MainRendererSingleton::getInstance().getDbg().drawCube(1.0);
+	dbg.setModelMat(trf);
+	dbg.setColor(toAnki(color));
+	dbg.drawCube(1.0);
 }
 
 
 //==============================================================================
 // drawContactPoint                                                            =
 //==============================================================================
-void PhyDbgDrawer::drawContactPoint(const btVector3& /*pointOnB*/, const btVector3& /*normalOnB*/,
-                                          btScalar /*distance*/, int /*lifeTime*/, const btVector3& /*color*/)
+void PhyDbgDrawer::drawContactPoint(const btVector3& /*pointOnB*/,
+	const btVector3& /*normalOnB*/,
+	btScalar /*distance*/, int /*lifeTime*/, const btVector3& /*color*/)
 {
 	//WARNING("Unimplemented");
 }
@@ -84,7 +91,12 @@ void PhyDbgDrawer::reportErrorWarning(const char* warningString)
 //==============================================================================
 // draw3dText                                                                  =
 //==============================================================================
-void PhyDbgDrawer::draw3dText(const btVector3& /*location*/, const char* /*textString*/)
+void PhyDbgDrawer::draw3dText(const btVector3& /*location*/,
+	const char* /*textString*/)
 {
 	//WARNING("Unimplemented");
 }
+
+
+} // end namespace
+

+ 31 - 8
src/Renderer/Drawers/PhyDbgDrawer.h

@@ -1,19 +1,38 @@
-#ifndef PHY_DBG_DRAWER_H
-#define PHY_DBG_DRAWER_H
+#ifndef R_PHY_DBG_DRAWER_H
+#define R_PHY_DBG_DRAWER_H
 
 #include <LinearMath/btIDebugDraw.h>
 
 
-/// An implementation of btIDebugDraw used for debugging Bullet. See Bullet docs for details
+namespace R {
+
+
+class Dbg;
+
+
+/// An implementation of btIDebugDraw used for debugging Bullet. See Bullet
+/// docs for details
 class PhyDbgDrawer: public btIDebugDraw
 {
 	public:
-		void drawLine(const btVector3& from, const btVector3& to, const btVector3& color);
-		void drawContactPoint(const btVector3& pointOnB, const btVector3& normalOnB, btScalar distance, int lifeTime,
+		PhyDbgDrawer(Dbg& dbg_): dbg(dbg_) {}
+
+		void drawLine(const btVector3& from, const btVector3& to,
+			const btVector3& color);
+
+		void drawContactPoint(const btVector3& pointOnB,
+			const btVector3& normalOnB, btScalar distance, int lifeTime,
 			const btVector3& color);
-		void drawSphere(btScalar radius, const btTransform& transform, const btVector3& color);
-		void drawBox(const btVector3& bbMin, const btVector3& bbMax, const btVector3& color);
-		void drawBox(const btVector3& bbMin, const btVector3& bbMax, const btTransform& trans, const btVector3& color);
+
+		void drawSphere(btScalar radius, const btTransform& transform,
+			const btVector3& color);
+
+		void drawBox(const btVector3& bbMin, const btVector3& bbMax,
+			const btVector3& color);
+
+		void drawBox(const btVector3& bbMin, const btVector3& bbMax,
+			const btTransform& trans, const btVector3& color);
+
 		void reportErrorWarning(const char* warningString);
 		void draw3dText(const btVector3& location, const char* textString);
 		void setDebugMode(int debugMode_) {debugMode = debugMode_;}
@@ -21,7 +40,11 @@ class PhyDbgDrawer: public btIDebugDraw
 
 	private:
 		int debugMode;
+		Dbg& dbg;
 };
 
 
+} // end namespace
+
+
 #endif

+ 14 - 5
src/Renderer/Drawers/SceneDbgDrawer.cpp

@@ -2,12 +2,15 @@
 #include "../Dbg.h"
 #include "Scene/Camera.h"
 #include "Scene/Light.h"
-#include "Scene/ParticleEmitter.h"
+#include "Scene/ParticleEmitterNode.h"
 #include "Scene/SkinNode.h"
 #include "Scene/PerspectiveCamera.h"
 #include "Scene/OrthographicCamera.h"
 
 
+namespace R {
+
+
 //==============================================================================
 // drawCamera                                                                  =
 //==============================================================================
@@ -17,14 +20,16 @@ void SceneDbgDrawer::drawCamera(const Camera& cam) const
 	{
 		case Camera::CT_PERSPECTIVE:
 		{
-			const PerspectiveCamera& pcam = static_cast<const PerspectiveCamera&>(cam);
+			const PerspectiveCamera& pcam =
+				static_cast<const PerspectiveCamera&>(cam);
 			drawPerspectiveCamera(pcam);
 			break;
 		}
 
 		case Camera::CT_ORTHOGRAPHIC:
 		{
-			const OrthographicCamera& ocam = static_cast<const OrthographicCamera&>(cam);
+			const OrthographicCamera& ocam =
+				static_cast<const OrthographicCamera&>(cam);
 			drawOrthographicCamera(ocam);
 			break;
 		}
@@ -70,7 +75,8 @@ void SceneDbgDrawer::drawPerspectiveCamera(const PerspectiveCamera& cam) const
 //==============================================================================
 // drawOrthographicCamera                                                      =
 //==============================================================================
-void SceneDbgDrawer::drawOrthographicCamera(const OrthographicCamera& ocam) const
+void SceneDbgDrawer::drawOrthographicCamera(
+	const OrthographicCamera& ocam) const
 {
 	dbg.setColor(Vec4(0.0, 1.0, 0.0, 1.0));
 	dbg.setModelMat(Mat4(ocam.getWorldTransform()));
@@ -122,7 +128,7 @@ void SceneDbgDrawer::drawLight(const Light& light) const
 //==============================================================================
 // drawParticleEmitter                                                         =
 //==============================================================================
-void SceneDbgDrawer::drawParticleEmitter(const ParticleEmitter& pe) const
+void SceneDbgDrawer::drawParticleEmitter(const ParticleEmitterNode& pe) const
 {
 	dbg.setColor(Vec4(1.0));
 	dbg.setModelMat(Mat4(pe.getWorldTransform()));
@@ -146,3 +152,6 @@ void SceneDbgDrawer::drawSkinNodeSkeleton(const SkinNode& sn) const
 	}
 	dbg.end();
 }
+
+
+} // end namespace

+ 14 - 6
src/Renderer/Drawers/SceneDbgDrawer.h

@@ -1,16 +1,21 @@
-#ifndef SCENE_DBG_DRAWER_H
-#define SCENE_DBG_DRAWER_H
+#ifndef R_SCENE_DBG_DRAWER_H
+#define R_SCENE_DBG_DRAWER_H
 
 
-class Dbg;
 class Camera;
 class Light;
-class ParticleEmitter;
+class ParticleEmitterNode;
 class SkinNode;
 class PerspectiveCamera;
 class OrthographicCamera;
 
 
+namespace R {
+
+
+class Dbg;
+
+
 /// This is a drawer for some scene nodes that need debug
 class SceneDbgDrawer
 {
@@ -24,8 +29,8 @@ class SceneDbgDrawer
 		/// Draw a Light
 		virtual void drawLight(const Light& light) const;
 
-		/// Draw a ParticleEmitter
-		virtual void drawParticleEmitter(const ParticleEmitter& pe) const;
+		/// Draw a ParticleEmitterNode
+		virtual void drawParticleEmitter(const ParticleEmitterNode& pe) const;
 
 		/// Draw a skeleton
 		virtual void drawSkinNodeSkeleton(const SkinNode& pe) const;
@@ -38,4 +43,7 @@ class SceneDbgDrawer
 };
 
 
+} // end namespace
+
+
 #endif

+ 47 - 23
src/Renderer/Drawers/SceneDrawer.cpp

@@ -10,12 +10,16 @@
 #include "GfxApi/GlStateMachine.h"
 
 
+namespace R {
+
+
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
-SceneDrawer::UsrDefVarVisitor::UsrDefVarVisitor(const MaterialRuntimeUserDefinedVar& udvr_,
-                                                const Renderer& r_, uint& texUnit_):
-	udvr(udvr_),
+SceneDrawer::UsrDefVarVisitor::UsrDefVarVisitor(
+	const MaterialRuntimeUserDefinedVar& udvr_,
+	const Renderer& r_, uint& texUnit_)
+:	udvr(udvr_),
 	r(r_),
 	texUnit(texUnit_)
 {}
@@ -43,7 +47,8 @@ void SceneDrawer::UsrDefVarVisitor::operator()(const RsrcPtr<Texture>* x) const
 
 
 template<>
-void SceneDrawer::UsrDefVarVisitor::operator()(const MtlUserDefinedVar::Fai& x) const
+void SceneDrawer::UsrDefVarVisitor::operator()(
+	const MtlUserDefinedVar::Fai& x) const
 {
 	switch(x)
 	{
@@ -70,8 +75,9 @@ void SceneDrawer::UsrDefVarVisitor::operator()(const MtlUserDefinedVar::Fai& x)
 //==============================================================================
 // setupShaderProg                                                             =
 //==============================================================================
-void SceneDrawer::setupShaderProg(const MaterialRuntime& mtlr, const Transform& nodeWorldTransform, const Camera& cam,
-                                  const Renderer& r, float blurring)
+void SceneDrawer::setupShaderProg(const MaterialRuntime& mtlr,
+	const Transform& nodeWorldTransform, const Camera& cam,
+	const Renderer& r, float blurring)
 {
 	uint textureUnit = 0;
 
@@ -80,13 +86,15 @@ void SceneDrawer::setupShaderProg(const MaterialRuntime& mtlr, const Transform&
 	//
 	// FFP stuff
 	//
-	GlStateMachineSingleton::getInstance().enable(GL_BLEND, mtlr.isBlendingEnabled());
+	GlStateMachineSingleton::getInstance().enable(GL_BLEND,
+		mtlr.isBlendingEnabled());
 	if(mtlr.isBlendingEnabled())
 	{
 		glBlendFunc(mtlr.getBlendingSfactor(), mtlr.getBlendingDfactor());
 	}
 
-	GlStateMachineSingleton::getInstance().enable(GL_DEPTH_TEST, mtlr.isDepthTestingEnabled());
+	GlStateMachineSingleton::getInstance().enable(GL_DEPTH_TEST,
+		mtlr.isDepthTestingEnabled());
 
 	if(mtlr.isWireframeEnabled())
 	{
@@ -147,7 +155,8 @@ void SceneDrawer::setupShaderProg(const MaterialRuntime& mtlr, const Transform&
 
 	if(mtlr.getStdUniVar(Material::SUV_VIEWPROJECTION_MAT))
 	{
-		mtlr.getStdUniVar(Material::SUV_VIEWPROJECTION_MAT)->set(&r.getViewProjectionMat());
+		mtlr.getStdUniVar(Material::SUV_VIEWPROJECTION_MAT)->set(
+			&r.getViewProjectionMat());
 	}
 
 	if(mtlr.getStdUniVar(Material::SUV_NORMAL_MAT))
@@ -159,7 +168,8 @@ void SceneDrawer::setupShaderProg(const MaterialRuntime& mtlr, const Transform&
 	if(mtlr.getStdUniVar(Material::SUV_MODELVIEWPROJECTION_MAT))
 	{
 		modelViewProjectionMat = projectionMat * modelViewMat;
-		mtlr.getStdUniVar(Material::SUV_MODELVIEWPROJECTION_MAT)->set(&modelViewProjectionMat);
+		mtlr.getStdUniVar(Material::SUV_MODELVIEWPROJECTION_MAT)->set(
+			&modelViewProjectionMat);
 	}
 
 
@@ -168,37 +178,44 @@ void SceneDrawer::setupShaderProg(const MaterialRuntime& mtlr, const Transform&
 	//
 	if(mtlr.getStdUniVar(Material::SUV_MS_NORMAL_FAI))
 	{
-		mtlr.getStdUniVar(Material::SUV_MS_NORMAL_FAI)->set(r.getMs().getNormalFai(), textureUnit++);
+		mtlr.getStdUniVar(Material::SUV_MS_NORMAL_FAI)->set(
+			r.getMs().getNormalFai(), textureUnit++);
 	}
 
 	if(mtlr.getStdUniVar(Material::SUV_MS_DIFFUSE_FAI))
 	{
-		mtlr.getStdUniVar(Material::SUV_MS_DIFFUSE_FAI)->set(r.getMs().getDiffuseFai(), textureUnit++);
+		mtlr.getStdUniVar(Material::SUV_MS_DIFFUSE_FAI)->set(
+			r.getMs().getDiffuseFai(), textureUnit++);
 	}
 
 	if(mtlr.getStdUniVar(Material::SUV_MS_SPECULAR_FAI))
 	{
-		mtlr.getStdUniVar(Material::SUV_MS_SPECULAR_FAI)->set(r.getMs().getSpecularFai(), textureUnit++);
+		mtlr.getStdUniVar(Material::SUV_MS_SPECULAR_FAI)->set(
+			r.getMs().getSpecularFai(), textureUnit++);
 	}
 
 	if(mtlr.getStdUniVar(Material::SUV_MS_DEPTH_FAI))
 	{
-		mtlr.getStdUniVar(Material::SUV_MS_DEPTH_FAI)->set(r.getMs().getDepthFai(), textureUnit++);
+		mtlr.getStdUniVar(Material::SUV_MS_DEPTH_FAI)->set(
+			r.getMs().getDepthFai(), textureUnit++);
 	}
 
 	if(mtlr.getStdUniVar(Material::SUV_IS_FAI))
 	{
-		mtlr.getStdUniVar(Material::SUV_IS_FAI)->set(r.getIs().getFai(), textureUnit++);
+		mtlr.getStdUniVar(Material::SUV_IS_FAI)->set(r.getIs().getFai(),
+			textureUnit++);
 	}
 
 	if(mtlr.getStdUniVar(Material::SUV_PPS_PRE_PASS_FAI))
 	{
-		mtlr.getStdUniVar(Material::SUV_PPS_PRE_PASS_FAI)->set(r.getPps().getPrePassFai(), textureUnit++);
+		mtlr.getStdUniVar(Material::SUV_PPS_PRE_PASS_FAI)->set(
+			r.getPps().getPrePassFai(), textureUnit++);
 	}
 
 	if(mtlr.getStdUniVar(Material::SUV_PPS_POST_PASS_FAI))
 	{
-		mtlr.getStdUniVar(Material::SUV_PPS_POST_PASS_FAI)->set(r.getPps().getPostPassFai(), textureUnit++);
+		mtlr.getStdUniVar(Material::SUV_PPS_POST_PASS_FAI)->set(
+			r.getPps().getPostPassFai(), textureUnit++);
 	}
 
 
@@ -229,9 +246,11 @@ void SceneDrawer::setupShaderProg(const MaterialRuntime& mtlr, const Transform&
 	//
 	// set user defined vars
 	//
-	BOOST_FOREACH(const MaterialRuntimeUserDefinedVar& udvr, mtlr.getUserDefinedVars())
+	BOOST_FOREACH(const MaterialRuntimeUserDefinedVar& udvr,
+		mtlr.getUserDefinedVars())
 	{
-		boost::apply_visitor(UsrDefVarVisitor(udvr, r, textureUnit), udvr.getDataVariant());
+		boost::apply_visitor(UsrDefVarVisitor(udvr, r, textureUnit),
+			udvr.getDataVariant());
 	}
 
 	ON_GL_FAIL_THROW_EXCEPTION();
@@ -241,8 +260,8 @@ void SceneDrawer::setupShaderProg(const MaterialRuntime& mtlr, const Transform&
 //==============================================================================
 // renderRenderableNode                                                        =
 //==============================================================================
-void SceneDrawer::renderRenderableNode(const RenderableNode& renderable, const Camera& cam,
-                                       RenderingPassType rtype) const
+void SceneDrawer::renderRenderableNode(const RenderableNode& renderable,
+	const Camera& cam, RenderingPassType rtype) const
 {
 	const MaterialRuntime* mtlr;
 	const Vao* vao;
@@ -255,7 +274,7 @@ void SceneDrawer::renderRenderableNode(const RenderableNode& renderable, const C
 			vao = &renderable.getCpVao();
 
 			blurring = (renderable.getWorldTransform().getOrigin() -
-			            renderable.getPrevWorldTransform().getOrigin()).getLength();
+				renderable.getPrevWorldTransform().getOrigin()).getLength();
 
 			break;
 
@@ -268,6 +287,11 @@ void SceneDrawer::renderRenderableNode(const RenderableNode& renderable, const C
 	setupShaderProg(*mtlr, renderable.getWorldTransform(), cam, r, blurring);
 
 	vao->bind();
-	glDrawElements(GL_TRIANGLES, renderable.getVertIdsNum(), GL_UNSIGNED_SHORT, 0);
+	glDrawElements(GL_TRIANGLES, renderable.getVertIdsNum(),
+		GL_UNSIGNED_SHORT, 0);
 	vao->unbind();
 }
+
+
+} // end namespace
+

+ 22 - 9
src/Renderer/Drawers/SceneDrawer.h

@@ -1,5 +1,5 @@
-#ifndef SCENE_DRAWER_H
-#define SCENE_DRAWER_H
+#ifndef R_SCENE_DRAWER_H
+#define R_SCENE_DRAWER_H
 
 #include <boost/variant.hpp>
 #include "Math/Math.h"
@@ -7,13 +7,18 @@
 
 
 class RenderableNode;
-class Renderer;
 class Camera;
 class Material;
 class MaterialRuntime;
 class MaterialRuntimeUserDefinedVar;
 
 
+namespace R {
+
+
+class Renderer;
+
+
 /// It includes all the functions to render a RenderableNode
 class SceneDrawer
 {
@@ -27,7 +32,8 @@ class SceneDrawer
 		/// The one and only contructor
 		SceneDrawer(const Renderer& r_): r(r_) {}
 
-		void renderRenderableNode(const RenderableNode& renderable, const Camera& cam, RenderingPassType rtype) const;
+		void renderRenderableNode(const RenderableNode& renderable,
+			const Camera& cam, RenderingPassType rtype) const;
 
 	private:
 		/// Set the uniform using this visitor
@@ -38,7 +44,8 @@ class SceneDrawer
 				const Renderer& r;
 				uint& texUnit;
 
-				UsrDefVarVisitor(const MaterialRuntimeUserDefinedVar& udvr, const Renderer& r, uint& texUnit);
+				UsrDefVarVisitor(const MaterialRuntimeUserDefinedVar& udvr,
+					const Renderer& r, uint& texUnit);
 
 				template<typename Type>
 				void operator()(const Type& x) const;
@@ -46,19 +53,25 @@ class SceneDrawer
 				void operator()(const RsrcPtr<Texture>* x) const;
 		};
 
-		const Renderer& r; ///< Keep it here cause the class wants a few stuff from it
+		const Renderer& r; ///< Keep it here cause the class wants a few stuff
+		                   ///< from it
 
 		/// This function:
 		/// - binds the shader program
 		/// - loads the uniforms
 		/// - sets the GL state
 		/// @param mtlr The material runtime
-		/// @param nodeWorldTransform The world transformation to pass to the shader
+		/// @param nodeWorldTransform The world transformation to pass to the
+		/// shader
 		/// @param cam Needed for some matrices (view & projection)
 		/// @param r The renderer, needed for some FAIs and some matrices
-		static void setupShaderProg(const MaterialRuntime& mtlr, const Transform& nodeWorldTransform,
-		                            const Camera& cam, const Renderer& r, float blurring = 0.0);
+		static void setupShaderProg(const MaterialRuntime& mtlr,
+			const Transform& nodeWorldTransform,
+			const Camera& cam, const Renderer& r, float blurring = 0.0);
 };
 
 
+} // end namespace
+
+
 #endif

+ 10 - 3
src/Renderer/Ez.cpp

@@ -5,6 +5,9 @@
 #include "RendererInitializer.h"
 
 
+namespace R {
+
+
 //==============================================================================
 // init                                                                        =
 //==============================================================================
@@ -27,8 +30,8 @@ void Ez::init(const RendererInitializer& initializer)
 
 		fbo.setNumOfColorAttachements(0);
 
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D,
-		                       r.getMs().getDepthFai().getGlId(), 0);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
+			GL_TEXTURE_2D, r.getMs().getDepthFai().getGlId(), 0);
 
 		fbo.checkIfGood();
 
@@ -65,8 +68,12 @@ void Ez::run()
 
 	BOOST_FOREACH(const RenderableNode* node, cam.getVisibleMsRenderableNodes())
 	{
-		r.getSceneDrawer().renderRenderableNode(*node, cam, SceneDrawer::RPT_DEPTH);
+		r.getSceneDrawer().renderRenderableNode(*node, cam,
+			SceneDrawer::RPT_DEPTH);
 	}
 
 	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
 }
+
+
+} // end namespace

+ 8 - 2
src/Renderer/Ez.h

@@ -1,11 +1,14 @@
-#ifndef EZ_H
-#define EZ_H
+#ifndef R_EZ_H
+#define R_EZ_H
 
 #include "RenderingPass.h"
 #include "GfxApi/BufferObjects/Fbo.h"
 #include "Util/Accessors.h"
 
 
+namespace R {
+
+
 /// Material stage EarlyZ pass
 class Ez: public RenderingPass
 {
@@ -23,4 +26,7 @@ class Ez: public RenderingPass
 };
 
 
+} // end namespace
+
+
 #endif

+ 14 - 4
src/Renderer/Hdr.cpp

@@ -4,6 +4,9 @@
 #include "RendererInitializer.h"
 
 
+namespace R {
+
+
 //==============================================================================
 // initFbo                                                                    =
 //==============================================================================
@@ -25,7 +28,8 @@ void Hdr::initFbo(Fbo& fbo, Texture& fai)
 		Renderer::createFai(width, height, GL_RGB, GL_RGB, GL_FLOAT, fai);
 
 		// attach
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fai.getGlId(), 0);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+			GL_TEXTURE_2D, fai.getGlId(), 0);
 
 		// test if success
 		fbo.checkIfGood();
@@ -35,7 +39,8 @@ void Hdr::initFbo(Fbo& fbo, Texture& fai)
 	}
 	catch(std::exception& e)
 	{
-		throw EXCEPTION("Cannot create deferred shading post-processing stage HDR passes FBO: " + e.what());
+		throw EXCEPTION("Cannot create deferred shading post-processing "
+			"stage HDR passes FBO: " + e.what());
 	}
 }
 
@@ -70,10 +75,12 @@ void Hdr::init(const RendererInitializer& initializer)
 	const char* SHADER_FILENAME = "shaders/GaussianBlurGeneric.glsl";
 
 	std::string pps = "#define HPASS\n#define COL_RGB\n";
-	hblurSProg.loadRsrc(ShaderProg::createSrcCodeToCache(SHADER_FILENAME, pps.c_str()).c_str());
+	hblurSProg.loadRsrc(ShaderProg::createSrcCodeToCache(SHADER_FILENAME,
+		pps.c_str()).c_str());
 
 	pps = "#define VPASS\n#define COL_RGB\n";
-	vblurSProg.loadRsrc(ShaderProg::createSrcCodeToCache(SHADER_FILENAME, pps.c_str()).c_str());
+	vblurSProg.loadRsrc(ShaderProg::createSrcCodeToCache(SHADER_FILENAME,
+		pps.c_str()).c_str());
 }
 
 
@@ -137,3 +144,6 @@ void Hdr::run()
 	// end
 	glBindFramebuffer(GL_FRAMEBUFFER, 0); // Bind the window framebuffer
 }
+
+
+} // end namespace

+ 12 - 4
src/Renderer/Hdr.h

@@ -1,5 +1,5 @@
-#ifndef HDR_H
-#define HDR_H
+#ifndef R_HDR_H
+#define R_HDR_H
 
 #include "RenderingPass.h"
 #include "GfxApi/BufferObjects/Fbo.h"
@@ -11,6 +11,9 @@
 class ShaderProg;
 
 
+namespace R {
+
+
 /// High dynamic range lighting pass
 class Hdr: private RenderingPass
 {
@@ -22,8 +25,10 @@ class Hdr: private RenderingPass
 		/// @name Accessors
 		/// @{
 		GETTER_SETTER_BY_VAL(float, exposure, getExposure, setExposure)
-		GETTER_SETTER_BY_VAL(uint, blurringIterationsNum, getBlurringIterationsNum, setBlurringIterationsNum)
-		GETTER_SETTER_BY_VAL(float, blurringDist, getBlurringDist, setBlurringDist)
+		GETTER_SETTER_BY_VAL(uint, blurringIterationsNum,
+			getBlurringIterationsNum, setBlurringIterationsNum)
+		GETTER_SETTER_BY_VAL(float, blurringDist, getBlurringDist,
+			setBlurringDist)
 
 		GETTER_R_BY_VAL(bool, enabled, isEnabled);
 		GETTER_R_BY_VAL(float, renderingQuality, getRenderingQuality)
@@ -52,4 +57,7 @@ class Hdr: private RenderingPass
 };
 
 
+} // end namespace
+
+
 #endif

+ 8 - 4
src/Renderer/Is.cpp

@@ -16,6 +16,9 @@
 #include "Scene/Scene.h"
 
 
+namespace R {
+
+
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
@@ -294,10 +297,8 @@ void Is::copyDepth()
 {
 	readFbo.bind(GL_READ_FRAMEBUFFER);
 	writeFbo.bind(GL_DRAW_FRAMEBUFFER);
-	glBlitFramebuffer(0, 0, r.getWidth(), r.getHeight(),
-	                  0, 0, r.getWidth(), r.getHeight(),
-	                  GL_DEPTH_BUFFER_BIT,
-	                  GL_NEAREST);
+	glBlitFramebuffer(0, 0, r.getWidth(), r.getHeight(), 0, 0, r.getWidth(),
+	    r.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST);
 }
 
 
@@ -347,3 +348,6 @@ void Is::run()
 
 	ON_GL_FAIL_THROW_EXCEPTION();
 }
+
+
+} // end namespace

+ 16 - 6
src/Renderer/Is.h

@@ -1,5 +1,5 @@
-#ifndef IS_H
-#define IS_H
+#ifndef R_IS_H
+#define R_IS_H
 
 #include "RenderingPass.h"
 #include "GfxApi/BufferObjects/Fbo.h"
@@ -17,6 +17,9 @@ class PointLight;
 class SpotLight;
 
 
+namespace R {
+
+
 /// Illumination stage
 class Is: private RenderingPass
 {
@@ -39,10 +42,14 @@ class Is: private RenderingPass
 		Texture copyMsDepthFai;
 		Fbo readFbo;
 		Fbo writeFbo;
-		RsrcPtr<ShaderProg> ambientPassSProg; ///< Illumination stage ambient pass shader program
-		RsrcPtr<ShaderProg> pointLightSProg; ///< Illumination stage point light shader program
-		RsrcPtr<ShaderProg> spotLightNoShadowSProg; ///< Illumination stage spot light w/o shadow shader program
-		RsrcPtr<ShaderProg> spotLightShadowSProg; ///< Illumination stage spot light w/ shadow shader program
+		/// Illumination stage ambient pass shader program
+		RsrcPtr<ShaderProg> ambientPassSProg;
+		/// Illumination stage point light shader program
+		RsrcPtr<ShaderProg> pointLightSProg;
+		/// Illumination stage spot light w/o shadow shader program
+		RsrcPtr<ShaderProg> spotLightNoShadowSProg;
+		/// Illumination stage spot light w/ shadow shader program
+		RsrcPtr<ShaderProg> spotLightShadowSProg;
 
 		/// The ambient pass
 		void ambientPass(const Vec3& color);
@@ -64,4 +71,7 @@ class Is: private RenderingPass
 };
 
 
+} // end namespace
+
+
 #endif

+ 24 - 9
src/Renderer/MainRenderer.cpp

@@ -12,6 +12,9 @@
 #include "Core/Logger.h"
 
 
+namespace R {
+
+
 //==============================================================================
 // init                                                                        =
 //==============================================================================
@@ -27,8 +30,10 @@ void MainRenderer::init(const RendererInitializer& initializer_)
 	//
 	RendererInitializer initializer = initializer_;
 	renderingQuality = initializer.mainRendererQuality;
-	initializer.width = AppSingleton::getInstance().getWindowWidth() * renderingQuality;
-	initializer.height = AppSingleton::getInstance().getWindowHeight() * renderingQuality;
+	initializer.width = AppSingleton::getInstance().getWindowWidth() *
+		renderingQuality;
+	initializer.height = AppSingleton::getInstance().getWindowHeight() *
+		renderingQuality;
 	Renderer::init(initializer);
 	dbg.init(initializer);
 	INFO("Main renderer initialized");
@@ -50,8 +55,10 @@ void MainRenderer::initGl()
 	glGetError();
 
 	// print GL info
-	INFO("OpenGL info: OGL " << reinterpret_cast<const char*>(glGetString(GL_VERSION)) <<
-	     ", GLSL " << reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
+	INFO("OpenGL info: OGL " <<
+		reinterpret_cast<const char*>(glGetString(GL_VERSION)) <<
+		", GLSL " << reinterpret_cast<const char*>(
+			glGetString(GL_SHADING_LANGUAGE_VERSION)));
 
 	// get max texture units
 	//glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxColorAtachments);
@@ -98,7 +105,8 @@ void MainRenderer::render(Camera& cam_)
 	//
 	glBindFramebuffer(GL_FRAMEBUFFER, 0); // Bind the window framebuffer
 
-	setViewport(0, 0, AppSingleton::getInstance().getWindowWidth(), AppSingleton::getInstance().getWindowHeight());
+	setViewport(0, 0, AppSingleton::getInstance().getWindowWidth(),
+		AppSingleton::getInstance().getWindowHeight());
 	GlStateMachineSingleton::getInstance().enable(GL_DEPTH_TEST, false);
 	GlStateMachineSingleton::getInstance().enable(GL_BLEND, false);
 	sProg->bind();
@@ -123,7 +131,8 @@ void MainRenderer::takeScreenshotTga(const char* filename)
 	}
 
 	// write headers
-	unsigned char tgaHeaderUncompressed[12] = {0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+	unsigned char tgaHeaderUncompressed[12] = {0, 0, 2, 0, 0, 0, 0, 0,
+		0, 0, 0, 0};
 	unsigned char header[6];
 
 	header[1] = getWidth() / 256;
@@ -139,7 +148,8 @@ void MainRenderer::takeScreenshotTga(const char* filename)
 	// write the buffer
 	char* buffer = (char*)calloc(getWidth()*getHeight()*3, sizeof(char));
 
-	glReadPixels(0, 0, getWidth(), getHeight(), GL_BGR, GL_UNSIGNED_BYTE, buffer);
+	glReadPixels(0, 0, getWidth(), getHeight(), GL_BGR, GL_UNSIGNED_BYTE,
+		buffer);
 	fs.write(buffer, getWidth()*getHeight()*3);
 
 	// end
@@ -179,14 +189,16 @@ void MainRenderer::takeScreenshotJpeg(const char* filename)
 
 	// read from OGL
 	char* buffer = (char*)malloc(getWidth()*getHeight()*3*sizeof(char));
-	glReadPixels(0, 0, getWidth(), getHeight(), GL_RGB, GL_UNSIGNED_BYTE, buffer);
+	glReadPixels(0, 0, getWidth(), getHeight(), GL_RGB, GL_UNSIGNED_BYTE,
+		buffer);
 
 	// write buffer to file
 	JSAMPROW row_pointer;
 
 	while(cinfo.next_scanline < cinfo.image_height)
 	{
-		row_pointer = (JSAMPROW) &buffer[(getHeight()-1-cinfo.next_scanline)*3*getWidth()];
+		row_pointer = (JSAMPROW)&buffer[(getHeight() - 1 -
+			cinfo.next_scanline) * 3 * getWidth()];
 		jpeg_write_scanlines(&cinfo, &row_pointer, 1);
 	}
 
@@ -222,3 +234,6 @@ void MainRenderer::takeScreenshot(const char* filename)
 	//INFO("Screenshot \"" << filename << "\" saved");
 }
 
+
+} // end namespace
+

+ 20 - 9
src/Renderer/MainRenderer.h

@@ -1,10 +1,13 @@
-#ifndef MAIN_RENDERER_H
-#define MAIN_RENDERER_H
+#ifndef R_MAIN_RENDERER_H
+#define R_MAIN_RENDERER_H
 
 #include "Renderer.h"
 #include "Util/Singleton.h"
 
 
+namespace R {
+
+
 /// Main onscreen renderer
 class MainRenderer: public Renderer
 {
@@ -15,19 +18,23 @@ class MainRenderer: public Renderer
 
 		/// @name Setters & getters
 		/// @{
-		GETTER_SETTER_BY_VAL(int, screenshotJpegQuality, getScreenshotJpegQuality, setScreenshotJpegQuality)
+		GETTER_SETTER_BY_VAL(int, screenshotJpegQuality,
+			getScreenshotJpegQuality, setScreenshotJpegQuality)
 		GETTER_R_BY_VAL(float, renderingQuality, getRenderingQuality)
 		GETTER_RW(Dbg, dbg, getDbg)
 		/// @}
 
-		/// The same as Renderer::init but with additional initialization. @see Renderer::init
+		/// The same as Renderer::init but with additional initialization.
+		/// @see Renderer::init
 		void init(const RendererInitializer& initializer);
 
-		/// The same as Renderer::render but in addition it renders the final FAI to the framebuffer
+		/// The same as Renderer::render but in addition it renders the final
+		/// FAI to the framebuffer
 		/// @param cam @see Renderer::render
 		void render(Camera& cam);
 
-		/// Save the color buffer to a tga (lossless & uncompressed & slow) or jpeg (lossy & compressed/// fast)
+		/// Save the color buffer to a tga (lossless & uncompressed & slow)
+		/// or jpeg (lossy & compressed fast)
 		/// @param filename The file to save
 		void takeScreenshot(const char* filename);
 
@@ -38,10 +45,11 @@ class MainRenderer: public Renderer
 		/// @}
 
 		RsrcPtr<ShaderProg> sProg; ///< Final pass' shader program
-		int screenshotJpegQuality; ///< The quality of the JPEG screenshots. From 0 to 100
+		int screenshotJpegQuality; ///< The quality of the JPEG screenshots.
+		                           ///< From 0 to 100
 
-		/// The global rendering quality of the raster image. Its a percentage of the application's window size. From
-		/// 0.0(low) to 1.0(high)
+		/// The global rendering quality of the raster image. Its a percentage
+		/// of the application's window size. From 0.0(low) to 1.0(high)
 		float renderingQuality;
 
 		void takeScreenshotTga(const char* filename);
@@ -56,4 +64,7 @@ inline MainRenderer::MainRenderer():
 {}
 
 
+} // end namespace
+
+
 #endif

+ 36 - 17
src/Renderer/Ms.cpp

@@ -6,11 +6,14 @@
 #include "Scene/RenderableNode.h"
 
 
+namespace R {
+
+
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
-Ms::Ms(Renderer& r_):
-	RenderingPass(r_),
+Ms::Ms(Renderer& r_)
+:	RenderingPass(r_),
 	ez(r_)
 {}
 
@@ -38,20 +41,30 @@ void Ms::init(const RendererInitializer& initializer)
 
 		// create the FAIs
 
-		Renderer::createFai(r.getWidth(), r.getHeight(), GL_RGB16F, GL_RGB, GL_FLOAT, normalFai);
-		Renderer::createFai(r.getWidth(), r.getHeight(), GL_RGB8, GL_RGB, GL_FLOAT, diffuseFai);
-		Renderer::createFai(r.getWidth(), r.getHeight(), GL_RGBA8, GL_RGBA, GL_FLOAT, specularFai);
-		Renderer::createFai(r.getWidth(), r.getHeight(), GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL,
-		                    GL_UNSIGNED_INT_24_8, depthFai);
+		Renderer::createFai(r.getWidth(), r.getHeight(), GL_RGB16F,
+			GL_RGB, GL_FLOAT, normalFai);
+		Renderer::createFai(r.getWidth(), r.getHeight(), GL_RGB8,
+			GL_RGB, GL_FLOAT, diffuseFai);
+		Renderer::createFai(r.getWidth(), r.getHeight(), GL_RGBA8,
+			GL_RGBA, GL_FLOAT, specularFai);
+		Renderer::createFai(r.getWidth(), r.getHeight(),
+			GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL,
+			GL_UNSIGNED_INT_24_8, depthFai);
 
 		// attach the buffers to the FBO
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, normalFai.getGlId(), 0);
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, diffuseFai.getGlId(), 0);
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, specularFai.getGlId(), 0);
-
-		//glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthFai.getGlId(), 0);
-		//glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depthFai.getGlId(), 0);
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depthFai.getGlId(), 0);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+			GL_TEXTURE_2D, normalFai.getGlId(), 0);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1,
+			GL_TEXTURE_2D, diffuseFai.getGlId(), 0);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2,
+			GL_TEXTURE_2D, specularFai.getGlId(), 0);
+
+		//glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
+		//	GL_TEXTURE_2D, depthFai.getGlId(), 0);
+		//glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
+		//	GL_TEXTURE_2D, depthFai.getGlId(), 0);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
+			GL_TEXTURE_2D, depthFai.getGlId(), 0);
 
 		// test if success
 		fbo.checkIfGood();
@@ -61,7 +74,8 @@ void Ms::init(const RendererInitializer& initializer)
 	}
 	catch(std::exception& e)
 	{
-		throw EXCEPTION("Cannot create deferred shading material stage FBO: " + e.what());
+		throw EXCEPTION("Cannot create deferred shading material stage FBO: " +
+			e.what());
 	}
 
 	ez.init(initializer);
@@ -101,9 +115,11 @@ void Ms::run()
 	//glClear(GL_COLOR_BUFFER_BIT);
 
 	// render all
-	BOOST_FOREACH(const RenderableNode* node, r.getCamera().getVisibleMsRenderableNodes())
+	BOOST_FOREACH(const RenderableNode* node,
+		r.getCamera().getVisibleMsRenderableNodes())
 	{
-		r.getSceneDrawer().renderRenderableNode(*node, r.getCamera(), SceneDrawer::RPT_COLOR);
+		r.getSceneDrawer().renderRenderableNode(*node, r.getCamera(),
+			SceneDrawer::RPT_COLOR);
 	}
 
 	// restore depth
@@ -116,3 +132,6 @@ void Ms::run()
 	fbo.unbind();
 	ON_GL_FAIL_THROW_EXCEPTION();
 }
+
+
+} // end namespace

+ 8 - 2
src/Renderer/Ms.h

@@ -1,5 +1,5 @@
-#ifndef MS_H
-#define MS_H
+#ifndef R_MS_H
+#define R_MS_H
 
 #include "RenderingPass.h"
 #include "Resources/Texture.h"
@@ -8,6 +8,9 @@
 #include "Ez.h"
 
 
+namespace R {
+
+
 /// Material stage
 class Ms: public RenderingPass
 {
@@ -36,4 +39,7 @@ class Ms: public RenderingPass
 };
 
 
+} // end namespace
+
+
 #endif

+ 24 - 10
src/Renderer/Pps.cpp

@@ -5,11 +5,14 @@
 #include "RendererInitializer.h"
 
 
+namespace R {
+
+
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
-Pps::Pps(Renderer& r_):
-	RenderingPass(r_),
+Pps::Pps(Renderer& r_)
+:	RenderingPass(r_),
 	hdr(r_),
 	ssao(r_),
 	bl(r_)
@@ -41,14 +44,17 @@ void Pps::init(const RendererInitializer& initializer)
 		prePassFbo.create();
 		prePassFbo.bind();
 		prePassFbo.setNumOfColorAttachements(1);
-		Renderer::createFai(r.getWidth(), r.getHeight(), GL_RGB, GL_RGB, GL_FLOAT, prePassFai);
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, prePassFai.getGlId(), 0);
+		Renderer::createFai(r.getWidth(), r.getHeight(), GL_RGB, GL_RGB,
+			GL_FLOAT, prePassFai);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+			GL_TEXTURE_2D, prePassFai.getGlId(), 0);
 		prePassFbo.checkIfGood();
 		prePassFbo.unbind();
 	}
 	catch(std::exception& e)
 	{
-		throw EXCEPTION("Cannot create pre-pass post-processing stage FBO: " + e.what());
+		throw EXCEPTION("Cannot create pre-pass post-processing stage FBO: " +
+			e.what());
 	}
 
 	// SProg
@@ -58,7 +64,8 @@ void Pps::init(const RendererInitializer& initializer)
 		pps += "#define SSAO_ENABLED\n";
 	}
 
-	prePassSProg.loadRsrc(ShaderProg::createSrcCodeToCache("shaders/PpsPrePass.glsl", pps.c_str()).c_str());
+	prePassSProg.loadRsrc(ShaderProg::createSrcCodeToCache(
+		"shaders/PpsPrePass.glsl", pps.c_str()).c_str());
 
 	//
 	// Init post pass
@@ -70,14 +77,17 @@ void Pps::init(const RendererInitializer& initializer)
 		postPassFbo.create();
 		postPassFbo.bind();
 		postPassFbo.setNumOfColorAttachements(1);
-		Renderer::createFai(r.getWidth(), r.getHeight(), GL_RGB, GL_RGB, GL_FLOAT, postPassFai);
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, postPassFai.getGlId(), 0);
+		Renderer::createFai(r.getWidth(), r.getHeight(), GL_RGB, GL_RGB,
+			GL_FLOAT, postPassFai);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+			GL_TEXTURE_2D, postPassFai.getGlId(), 0);
 		postPassFbo.checkIfGood();
 		postPassFbo.unbind();
 	}
 	catch(std::exception& e)
 	{
-		throw EXCEPTION("Cannot create post-pass post-processing stage FBO: " + e.what());
+		throw EXCEPTION("Cannot create post-pass post-processing stage FBO: " +
+			e.what());
 	}
 
 	// SProg
@@ -88,7 +98,8 @@ void Pps::init(const RendererInitializer& initializer)
 		pps += "#define HDR_ENABLED\n";
 	}
 
-	postPassSProg.loadRsrc(ShaderProg::createSrcCodeToCache("shaders/PpsPostPass.glsl", pps.c_str()).c_str());
+	postPassSProg.loadRsrc(ShaderProg::createSrcCodeToCache(
+		"shaders/PpsPostPass.glsl", pps.c_str()).c_str());
 
 	//
 	// Init Bl after
@@ -158,3 +169,6 @@ void Pps::runPostPass()
 	//
 	bl.run();
 }
+
+
+} // end namespace

+ 10 - 3
src/Renderer/Pps.h

@@ -1,5 +1,5 @@
-#ifndef PPS_H
-#define PPS_H
+#ifndef R_PPS_H
+#define R_PPS_H
 
 #include "RenderingPass.h"
 #include "GfxApi/BufferObjects/Fbo.h"
@@ -13,9 +13,13 @@
 class ShaderProg;
 
 
+namespace R {
+
+
 /// Post-processing stage.
 ///
-/// This stage is divided into 2 two parts. The first happens before blending stage and the second after.
+/// This stage is divided into 2 two parts. The first happens before blending
+/// stage and the second after.
 class Pps: private RenderingPass
 {
 	public:
@@ -53,4 +57,7 @@ class Pps: private RenderingPass
 };
 
 
+} // end namespace
+
+
 #endif

+ 22 - 9
src/Renderer/Renderer.cpp

@@ -4,6 +4,9 @@
 #include "Scene/PerspectiveCamera.h"
 
 
+namespace R {
+
+
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
@@ -43,14 +46,18 @@ void Renderer::init(const RendererInitializer& initializer)
 	bs.init(initializer);
 
 	// quad VBOs and VAO
-	float quadVertCoords[][2] = {{1.0, 1.0}, {0.0, 1.0}, {0.0, 0.0}, {1.0, 0.0}};
-	quadPositionsVbo.create(GL_ARRAY_BUFFER, sizeof(quadVertCoords), quadVertCoords, GL_STATIC_DRAW);
+	float quadVertCoords[][2] = {{1.0, 1.0}, {0.0, 1.0}, {0.0, 0.0},
+		{1.0, 0.0}};
+	quadPositionsVbo.create(GL_ARRAY_BUFFER, sizeof(quadVertCoords),
+		quadVertCoords, GL_STATIC_DRAW);
 
 	ushort quadVertIndeces[2][3] = {{0, 1, 3}, {1, 2, 3}}; // 2 triangles
-	quadVertIndecesVbo.create(GL_ELEMENT_ARRAY_BUFFER, sizeof(quadVertIndeces), quadVertIndeces, GL_STATIC_DRAW);
+	quadVertIndecesVbo.create(GL_ELEMENT_ARRAY_BUFFER, sizeof(quadVertIndeces),
+		quadVertIndeces, GL_STATIC_DRAW);
 
 	quadVao.create();
-	quadVao.attachArrayBufferVbo(quadPositionsVbo, 0, 2, GL_FLOAT, false, 0, NULL);
+	quadVao.attachArrayBufferVbo(quadPositionsVbo, 0, 2, GL_FLOAT, false, 0,
+		NULL);
 	quadVao.attachElementArrayBufferVbo(quadVertIndecesVbo);
 
 	// Other
@@ -102,8 +109,8 @@ void Renderer::drawQuad()
 //==============================================================================
 // unproject                                                                   =
 //==============================================================================
-Vec3 Renderer::unproject(const Vec3& windowCoords, const Mat4& modelViewMat, const Mat4& projectionMat,
-                         const int view[4])
+Vec3 Renderer::unproject(const Vec3& windowCoords, const Mat4& modelViewMat,
+	const Mat4& projectionMat, const int view[4])
 {
 	Mat4 invPm = projectionMat * modelViewMat;
 	invPm.invert();
@@ -124,7 +131,8 @@ Vec3 Renderer::unproject(const Vec3& windowCoords, const Mat4& modelViewMat, con
 //==============================================================================
 // createFai                                                                   =
 //==============================================================================
-void Renderer::createFai(uint width, uint height, int internalFormat, int format, int type, Texture& fai)
+void Renderer::createFai(uint width, uint height, int internalFormat,
+	int format, int type, Texture& fai)
 {
 	Texture::Initializer init;
 	init.width = width;
@@ -158,8 +166,13 @@ void Renderer::calcPlanes(const Vec2& cameraRange, Vec2& planes)
 //==============================================================================
 // calcLimitsOfNearPlane                                                       =
 //==============================================================================
-void Renderer::calcLimitsOfNearPlane(const PerspectiveCamera& pcam, Vec2& limitsOfNearPlane)
+void Renderer::calcLimitsOfNearPlane(const PerspectiveCamera& pcam,
+	Vec2& limitsOfNearPlane)
 {
 	limitsOfNearPlane.y() = pcam.getZNear() * tan(0.5 * pcam.getFovY());
-	limitsOfNearPlane.x() = limitsOfNearPlane.y() * (pcam.getFovX() / pcam.getFovY());
+	limitsOfNearPlane.x() = limitsOfNearPlane.y() *
+		(pcam.getFovX() / pcam.getFovY());
 }
+
+
+} // end namespace

+ 8 - 2
src/Renderer/Renderer.h

@@ -1,5 +1,5 @@
-#ifndef RENDERER_H
-#define RENDERER_H
+#ifndef R_RENDERER_H
+#define R_RENDERER_H
 
 #include "Math/Math.h"
 #include "GfxApi/BufferObjects/Fbo.h"
@@ -24,6 +24,9 @@ struct RendererInitializer;
 class ModelNode;
 
 
+namespace R {
+
+
 /// Offscreen renderer
 /// It is a class and not a namespace because we may need external renderers
 /// for security cameras for example
@@ -161,4 +164,7 @@ inline void Renderer::setViewport(uint x, uint y, uint w, uint h)
 }
 
 
+} // end namespace
+
+
 #endif

+ 11 - 3
src/Renderer/RendererInitializer.h

@@ -1,10 +1,14 @@
-#ifndef RENDERER_INITIALIZER_H
-#define RENDERER_INITIALIZER_H
+#ifndef R_RENDERER_INITIALIZER_H
+#define R_RENDERER_INITIALIZER_H
 
 #include <cstring>
 
 
-/// A struct to initialize the renderer. It contains a few extra params for the MainRenderer
+namespace R {
+
+
+/// A struct to initialize the renderer. It contains a few extra params for
+/// the MainRenderer
 struct RendererInitializer
 {
 	// Ms
@@ -80,4 +84,8 @@ struct RendererInitializer
 	}
 };
 
+
+} // end namespace
+
+
 #endif

+ 8 - 2
src/Renderer/RenderingPass.h

@@ -1,5 +1,8 @@
-#ifndef RENDERING_PASS_H
-#define RENDERING_PASS_H
+#ifndef R_RENDERING_PASS_H
+#define R_RENDERING_PASS_H
+
+
+namespace R {
 
 
 class Renderer;
@@ -20,4 +23,7 @@ class RenderingPass
 };
 
 
+} // end namespace
+
+
 #endif

+ 22 - 10
src/Renderer/SkinsDeformer.cpp

@@ -4,6 +4,9 @@
 #include "Scene/SkinNode.h"
 
 
+namespace R {
+
+
 //==============================================================================
 // init                                                                        =
 //==============================================================================
@@ -22,8 +25,10 @@ void SkinsDeformer::init()
 //==============================================================================
 void SkinsDeformer::deform(SkinPatchNode& node)
 {
-	ASSERT(node.getParent() != NULL); // The SkinPatchNode are always have parent
-	ASSERT(static_cast<SceneNode*>(node.getParent())->getSceneNodeType() == SceneNode::SNT_SKIN);
+	ASSERT(node.getParent() != NULL); // The SkinPatchNode are always have
+	                                  // parent
+	ASSERT(static_cast<SceneNode*>(node.getParent())->getSceneNodeType() ==
+		SceneNode::SNT_SKIN);
 
 	SkinNode* skinNode = static_cast<SkinNode*>(node.getParent());
 
@@ -44,26 +49,31 @@ void SkinsDeformer::deform(SkinPatchNode& node)
 	sProg->bind();
 
 	// Uniforms
-	sProg->findUniVar("skinningRotations")->set(&skinNode->getBoneRotations()[0],
-	                                                           skinNode->getBoneRotations().size());
+	sProg->findUniVar("skinningRotations")->set(
+		&skinNode->getBoneRotations()[0], skinNode->getBoneRotations().size());
 
-	sProg->findUniVar("skinningTranslations")->set(&skinNode->getBoneTranslations()[0],
-	                                                              skinNode->getBoneTranslations().size());
+	sProg->findUniVar("skinningTranslations")->set(
+		&skinNode->getBoneTranslations()[0],
+		skinNode->getBoneTranslations().size());
 
 	node.getTfVao().bind();
 
 	// TF
-	glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, node.getTfVbo(SkinPatchNode::TFV_POSITIONS).getGlId());
+	glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0,
+		node.getTfVbo(SkinPatchNode::TFV_POSITIONS).getGlId());
 
 	if(sProg == tfHwSkinningAllSProg.get())
 	{
-		glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 1, node.getTfVbo(SkinPatchNode::TFV_NORMALS).getGlId());
-		glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 2, node.getTfVbo(SkinPatchNode::TFV_TANGENTS).getGlId());
+		glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 1,
+			node.getTfVbo(SkinPatchNode::TFV_NORMALS).getGlId());
+		glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 2,
+			node.getTfVbo(SkinPatchNode::TFV_TANGENTS).getGlId());
 	}
 
 	//glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, this->Query);
 	glBeginTransformFeedback(GL_POINTS);
-		glDrawArrays(GL_POINTS, 0, node.getModelPatchRsrc().getMesh().getVertsNum());
+		glDrawArrays(GL_POINTS, 0,
+		node.getModelPatchRsrc().getMesh().getVertsNum());
 	glEndTransformFeedback();
 	//glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
 
@@ -71,6 +81,8 @@ void SkinsDeformer::deform(SkinPatchNode& node)
 }
 
 
+} // end namespace
+
 
 
 

+ 8 - 2
src/Renderer/SkinsDeformer.h

@@ -1,5 +1,5 @@
-#ifndef SKINS_DEFORMER_H
-#define SKINS_DEFORMER_H
+#ifndef R_SKINS_DEFORMER_H
+#define R_SKINS_DEFORMER_H
 
 #include "Resources/RsrcPtr.h"
 
@@ -8,6 +8,9 @@ class ShaderProg;
 class SkinPatchNode;
 
 
+namespace R {
+
+
 /// @todo
 class SkinsDeformer
 {
@@ -31,4 +34,7 @@ class SkinsDeformer
 };
 
 
+} // end namespace
+
+
 #endif

+ 26 - 10
src/Renderer/Sm.cpp

@@ -10,6 +10,9 @@
 #include "RendererInitializer.h"
 
 
+namespace R {
+
+
 //==============================================================================
 // init                                                                        =
 //==============================================================================
@@ -31,7 +34,10 @@ void Sm::init(const RendererInitializer& initializer)
 	initLevel(resolution, level0Distance, bilinearEnabled, levels[0]);
 	for(uint i = 1; i < levels.size(); i++)
 	{
-		initLevel(levels[i - 1].resolution / 2, levels[i - 1].distance * 2.0, bilinearEnabled, levels[i]);
+		initLevel(levels[i - 1].resolution / 2,
+			levels[i - 1].distance * 2.0,
+			bilinearEnabled,
+			levels[i]);
 	}
 }
 
@@ -52,8 +58,8 @@ void Sm::initLevel(uint resolution, float distance, bool bilinear, Level& level)
 		level.fbo.bind();
 
 		// texture
-		Renderer::createFai(level.resolution, level.resolution, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT,
-		                    GL_FLOAT, level.shadowMap);
+		Renderer::createFai(level.resolution, level.resolution,
+			GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT, level.shadowMap);
 		if(level.bilinear)
 		{
 			level.shadowMap.setFiltering(Texture::TFT_LINEAR);
@@ -62,12 +68,16 @@ void Sm::initLevel(uint resolution, float distance, bool bilinear, Level& level)
 		{
 			level.shadowMap.setFiltering(Texture::TFT_NEAREST);
 		}
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE,
+			GL_COMPARE_R_TO_TEXTURE);
 		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
 		/*
-		 * If you dont want to use the FFP for comparing the shadowmap (the above two lines) then you can make the comparison
-		 * inside the glsl shader. The GL_LEQUAL means that: shadow = (R <= Dt) ? 1.0 : 0.0; . The R is given by:
-		 * R = _tex_coord2.z/_tex_coord2.w; and the Dt = shadow2D(shadow_depth_map, _shadow_uv).r (see lp_generic.frag).
+		 * If you dont want to use the FFP for comparing the shadowmap
+		 * (the above two lines) then you can make the comparison
+		 * inside the glsl shader. The GL_LEQUAL means that:
+		 * shadow = (R <= Dt) ? 1.0 : 0.0; . The R is given by:
+		 * R = _tex_coord2.z/_tex_coord2.w; and the
+		 * Dt = shadow2D(shadow_depth_map, _shadow_uv).r (see lp_generic.frag).
 		 * Hardware filters like GL_LINEAR cannot be applied.
 		 */
 
@@ -75,7 +85,8 @@ void Sm::initLevel(uint resolution, float distance, bool bilinear, Level& level)
 		level.fbo.setNumOfColorAttachements(0);
 
 		// attach the texture
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, level.shadowMap.getGlId(), 0);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
+			GL_TEXTURE_2D, level.shadowMap.getGlId(), 0);
 
 		// test if success
 		level.fbo.checkIfGood();
@@ -133,14 +144,16 @@ void Sm::run(const Light& light, float distance)
 	glEnable(GL_POLYGON_OFFSET_FILL);
 
 	// render all
-	BOOST_FOREACH(const RenderableNode* node, light.getVisibleMsRenderableNodes())
+	BOOST_FOREACH(const RenderableNode* node,
+		light.getVisibleMsRenderableNodes())
 	{
 		switch(light.getType())
 		{
 			case Light::LT_SPOT:
 			{
 				const SpotLight& sl = static_cast<const SpotLight&>(light);
-				r.getSceneDrawer().renderRenderableNode(*node, sl.getCamera(), SceneDrawer::RPT_DEPTH);
+				r.getSceneDrawer().renderRenderableNode(*node, sl.getCamera(),
+					SceneDrawer::RPT_DEPTH);
 				break;
 			}
 
@@ -157,3 +170,6 @@ void Sm::run(const Light& light, float distance)
 	// FBO
 	crntLevel->fbo.unbind();
 }
+
+
+} // end namespace

+ 31 - 13
src/Renderer/Sm.h

@@ -1,5 +1,5 @@
-#ifndef SM_H
-#define SM_H
+#ifndef R_SM_H
+#define R_SM_H
 
 #include "RenderingPass.h"
 #include "GfxApi/BufferObjects/Fbo.h"
@@ -11,6 +11,9 @@
 class Light;
 
 
+namespace R {
+
+
 /// Shadowmapping pass
 class Sm: private RenderingPass
 {
@@ -28,37 +31,52 @@ class Sm: private RenderingPass
 
 		void init(const RendererInitializer& initializer);
 
-		/// Render the scene only with depth and store the result in the shadowMap
+		/// Render the scene only with depth and store the result in the
+		/// shadowMap
 		/// @param[in] light The light
-		/// @param[in] distance The distance between the viewers camera and the light
+		/// @param[in] distance The distance between the viewers camera and the
+		/// light
 		void run(const Light& light, float distance);
 
 	private:
 		/// The shadowmap levels of detail
-		/// It starts from level 0 which is the detailed one and moves to lower resolution shadowmaps. When the
-		/// distance between the viewer's camera and the light is getting bigger then a higher level will be used
+		/// It starts from level 0 which is the detailed one and moves to lower
+		/// resolution shadowmaps. When the distance between the viewer's
+		/// camera and the light is getting bigger then a higher level will be
+		/// used
 		struct Level
 		{
 			Fbo fbo; ///< Illumination stage shadowmapping FBO
 			Texture shadowMap; ///< The shadowmap for that level
 			uint resolution; ///< The shadowmap's resolution
 			bool bilinear; ///< Enable bilinar filtering in shadowmap
-			/// The maximum distance that this level applies. The distance is between the viewer's camera and the light
+			/// The maximum distance that this level applies. The distance is
+			/// between the viewer's camera and the light
 			float distance;
 		};
 
-		boost::array<Level, 4> levels; ///< The levels of detail. The 0 is the detailed one
+		boost::array<Level, 4> levels; ///< The levels of detail. The 0 is the
+		                               ///< detailed one
 		Level* crntLevel; ///< Current level of detail. Assigned by run
 
 		bool enabled; ///< If false then disable SM at all
-		bool pcfEnabled; ///< Enable Percentage Closer Filtering for all the levels
-		bool bilinearEnabled; ///< Shadowmap bilinear filtering for the first level. Better quality
-		int resolution; ///< Shadowmap resolution of the first level. The higher the better but slower
-		float level0Distance; ///< The distance of the first level. @see Level::distance
+		/// Enable Percentage Closer Filtering for all the levels
+		bool pcfEnabled;
+		/// Shadowmap bilinear filtering for the first level. Better quality
+		bool bilinearEnabled;
+		/// Shadowmap resolution of the first level. The higher the better but
+		/// slower
+		int resolution;
+		/// The distance of the first level. @see Level::distance
+		float level0Distance;
 
 		/// Initialize a level
-		static void initLevel(uint resolution, float maxDistance, bool bilinear, Level& level);
+		static void initLevel(uint resolution, float maxDistance,
+			bool bilinear, Level& level);
 };
 
 
+} // end namespace
+
+
 #endif

+ 34 - 15
src/Renderer/Smo.cpp

@@ -12,6 +12,9 @@
 #include "Resources/Mesh.h"
 
 
+namespace R {
+
+
 const float THRESHOLD = 0.2;
 
 
@@ -43,9 +46,11 @@ void Smo::init(const RendererInitializer& /*initializer*/)
 	// Sphere
 	sphereGeom.mesh.loadRsrc("engine-rsrc/sphere.mesh");
 	sphereGeom.vao.create();
-	sphereGeom.vao.attachArrayBufferVbo(sphereGeom.mesh->getVbo(Mesh::VBO_VERT_POSITIONS),
-										*sProg->findAttribVar("position"), 3, GL_FLOAT, GL_FALSE, 0, NULL);
-	sphereGeom.vao.attachElementArrayBufferVbo(sphereGeom.mesh->getVbo(Mesh::VBO_VERT_INDECES));
+	sphereGeom.vao.attachArrayBufferVbo(
+		sphereGeom.mesh->getVbo(Mesh::VBO_VERT_POSITIONS),
+		*sProg->findAttribVar("position"), 3, GL_FLOAT, GL_FALSE, 0, NULL);
+	sphereGeom.vao.attachElementArrayBufferVbo(
+		sphereGeom.mesh->getVbo(Mesh::VBO_VERT_INDECES));
 
 	// Cameras
 	initCamGeom();
@@ -57,15 +62,18 @@ void Smo::init(const RendererInitializer& /*initializer*/)
 //==============================================================================
 void Smo::initCamGeom()
 {
-	boost::array<const char*, Camera::CT_NUM> files = {{"engine-rsrc/pyramid.mesh", "engine-rsrc/cube.mesh"}};
+	boost::array<const char*, Camera::CT_NUM> files = {{
+		"engine-rsrc/pyramid.mesh", "engine-rsrc/cube.mesh"}};
 
 	for(uint i = 0; i < Camera::CT_NUM; i++)
 	{
 		camGeom[i].mesh.loadRsrc(files[i]);
 		camGeom[i].vao.create();
-		camGeom[i].vao.attachArrayBufferVbo(camGeom[i].mesh->getVbo(Mesh::VBO_VERT_POSITIONS),
-		                                    *sProg->findAttribVar("position"), 3, GL_FLOAT, GL_FALSE, 0, NULL);
-		camGeom[i].vao.attachElementArrayBufferVbo(camGeom[i].mesh->getVbo(Mesh::VBO_VERT_INDECES));
+		camGeom[i].vao.attachArrayBufferVbo(
+			camGeom[i].mesh->getVbo(Mesh::VBO_VERT_POSITIONS),
+			*sProg->findAttribVar("position"), 3, GL_FLOAT, GL_FALSE, 0, NULL);
+		camGeom[i].vao.attachElementArrayBufferVbo(
+			camGeom[i].mesh->getVbo(Mesh::VBO_VERT_INDECES));
 	}
 }
 
@@ -120,7 +128,8 @@ void Smo::run(const PointLight& light)
 {
 	const Vec3& o = light.getWorldTransform().getOrigin();
 	const Vec3& c = r.getCamera().getWorldTransform().getOrigin();
-	bool inside =  (o - c).getLength() <= (light.getRadius() + r.getCamera().getZNear() + THRESHOLD);
+	bool inside =  (o - c).getLength() <=
+		(light.getRadius() + r.getCamera().getZNear() + THRESHOLD);
 
 	// set GL state
 	setUpGl(inside);
@@ -128,13 +137,15 @@ void Smo::run(const PointLight& light)
 	// set shared prog
 	const float SCALE = 1.0; // we scale the sphere a little
 	sProg->bind();
-	Mat4 modelMat = Mat4(light.getWorldTransform().getOrigin(), Mat3::getIdentity(), light.getRadius() * SCALE);
+	Mat4 modelMat = Mat4(light.getWorldTransform().getOrigin(),
+		Mat3::getIdentity(), light.getRadius() * SCALE);
 	Mat4 trf = r.getViewProjectionMat() * modelMat;
 	sProg->findUniVar("modelViewProjectionMat")->set(&trf);
 
 	// render sphere to the stencil buffer
 	sphereGeom.vao.bind();
-	glDrawElements(GL_TRIANGLES, sphereGeom.mesh->getVertIdsNum(), GL_UNSIGNED_SHORT, 0);
+	glDrawElements(GL_TRIANGLES, sphereGeom.mesh->getVertIdsNum(),
+		GL_UNSIGNED_SHORT, 0);
 	sphereGeom.vao.unbind();
 
 	// restore GL
@@ -164,16 +175,20 @@ void Smo::run(const SpotLight& light)
 	{
 		case Camera::CT_PERSPECTIVE:
 		{
-			const PerspectiveCamera& pcam = static_cast<const PerspectiveCamera&>(lcam);
-			localMat(0, 0) = tan(pcam.getFovX() / 2.0) * pcam.getZFar(); // Scale in x
-			localMat(1, 1) = tan(pcam.getFovY() / 2.0) * pcam.getZFar(); // Scale in y
+			const PerspectiveCamera& pcam =
+				static_cast<const PerspectiveCamera&>(lcam);
+			// Scale in x
+			localMat(0, 0) = tan(pcam.getFovX() / 2.0) * pcam.getZFar();
+			// Scale in y
+			localMat(1, 1) = tan(pcam.getFovY() / 2.0) * pcam.getZFar();
 			localMat(2, 2) = pcam.getZFar(); // Scale in z
 			break;
 		}
 
 		case Camera::CT_ORTHOGRAPHIC:
 		{
-			const OrthographicCamera& ocam = static_cast<const OrthographicCamera&>(lcam);
+			const OrthographicCamera& ocam =
+				static_cast<const OrthographicCamera&>(lcam);
 			Vec3 tsl;
 			float left = ocam.getLeft();
 			float right = ocam.getRight();
@@ -213,9 +228,13 @@ void Smo::run(const SpotLight& light)
 	//mesh->get
 
 	cg.vao.bind();
-	glDrawElements(GL_TRIANGLES, cg.mesh->getVertIdsNum(), GL_UNSIGNED_SHORT, 0);
+	glDrawElements(GL_TRIANGLES, cg.mesh->getVertIdsNum(),
+		GL_UNSIGNED_SHORT, 0);
 	cg.vao.unbind();
 
 	// restore GL state
 	restoreGl(inside);
 }
+
+
+} // end namespace

+ 10 - 4
src/Renderer/Smo.h

@@ -1,5 +1,5 @@
-#ifndef SMO_H
-#define SMO_H
+#ifndef R_SMO_H
+#define R_SMO_H
 
 #include "RenderingPass.h"
 #include "GfxApi/BufferObjects/Fbo.h"
@@ -14,6 +14,9 @@ class PointLight;
 class SpotLight;
 
 
+namespace R {
+
+
 /// Stencil masking optimizations
 class Smo: public RenderingPass
 {
@@ -37,8 +40,8 @@ class Smo: public RenderingPass
 
 		Geom sphereGeom;
 
-		/// An array of geometry stuff. For perspective cameras the shape is a pyramid, see the blend file with the
-		/// vertex positions
+		/// An array of geometry stuff. For perspective cameras the shape is a
+		/// pyramid, see the blend file with the vertex positions
 		boost::array<Geom, Camera::CT_NUM> camGeom;
 
 		RsrcPtr<ShaderProg> sProg;
@@ -50,4 +53,7 @@ class Smo: public RenderingPass
 };
 
 
+} // end namespace
+
+
 #endif

+ 15 - 5
src/Renderer/Ssao.cpp

@@ -6,6 +6,9 @@
 #include "Scene/PerspectiveCamera.h"
 
 
+namespace R {
+
+
 //==============================================================================
 // createFbo                                                                   =
 //==============================================================================
@@ -27,7 +30,8 @@ void Ssao::createFbo(Fbo& fbo, Texture& fai)
 		Renderer::createFai(width, height, GL_RED, GL_RED, GL_FLOAT, fai);
 
 		// attach
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fai.getGlId(), 0);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+			GL_TEXTURE_2D, fai.getGlId(), 0);
 
 		// test if success
 		fbo.checkIfGood();
@@ -37,7 +41,8 @@ void Ssao::createFbo(Fbo& fbo, Texture& fai)
 	}
 	catch(std::exception& e)
 	{
-		throw EXCEPTION("Cannot create deferred shading post-processing stage SSAO blur FBO: " + e.what());
+		throw EXCEPTION("Cannot create deferred shading post-processing "
+			"stage SSAO blur FBO: " + e.what());
 	}
 }
 
@@ -73,10 +78,12 @@ void Ssao::init(const RendererInitializer& initializer)
 	const char* SHADER_FILENAME = "shaders/GaussianBlurGeneric.glsl";
 
 	std::string pps = "#define HPASS\n#define COL_R\n";
-	hblurSProg.loadRsrc(ShaderProg::createSrcCodeToCache(SHADER_FILENAME, pps.c_str()).c_str());
+	hblurSProg.loadRsrc(
+		ShaderProg::createSrcCodeToCache(SHADER_FILENAME, pps.c_str()).c_str());
 
 	pps = "#define VPASS\n#define COL_R\n";
-	vblurSProg.loadRsrc(ShaderProg::createSrcCodeToCache(SHADER_FILENAME, pps.c_str()).c_str());
+	vblurSProg.loadRsrc(
+		ShaderProg::createSrcCodeToCache(SHADER_FILENAME, pps.c_str()).c_str());
 
 	//
 	// noise map
@@ -121,7 +128,8 @@ void Ssao::run()
 	ssaoSProg->findUniVar("limitsOfNearPlane")->set(&r.getLimitsOfNearPlane());
 
 	// limitsOfNearPlane2
-	ssaoSProg->findUniVar("limitsOfNearPlane2")->set(&r.getLimitsOfNearPlane2());
+	ssaoSProg->findUniVar("limitsOfNearPlane2")->set(
+		&r.getLimitsOfNearPlane2());
 
 	// zNear
 	float zNear = cam.getZNear();
@@ -182,3 +190,5 @@ void Ssao::run()
 	glBindFramebuffer(GL_FRAMEBUFFER, 0); // Bind the window framebuffer
 }
 
+
+} // end namespace

+ 8 - 2
src/Renderer/Ssao.h

@@ -1,5 +1,5 @@
-#ifndef SSAO_H
-#define SSAO_H
+#ifndef R_SSAO_H
+#define R_SSAO_H
 
 #include "RenderingPass.h"
 #include "GfxApi/BufferObjects/Fbo.h"
@@ -10,6 +10,9 @@
 #include "GfxApi/BufferObjects/Vao.h"
 
 
+namespace R {
+
+
 /// Screen space ambient occlusion pass
 ///
 /// Three passes:
@@ -49,4 +52,7 @@ class Ssao: private RenderingPass
 };
 
 
+} // end namespace
+
+
 #endif

+ 2 - 1
src/Resources/Extension.cpp

@@ -19,7 +19,8 @@ void Extension::load(const char* /*filename*/)
 	foobarPtr = (int(*)(void*))(dlsym(libHandle, "FooBar"));
 	if(foobarPtr == NULL)
 	{
-		throw EXCEPTION("File \"" + filename + "\": \"FooBar\" entry symbol not found: " + dlerror());
+		throw EXCEPTION("File \"" + filename +
+			"\": \"FooBar\" entry symbol not found: " + dlerror());
 	}*/
 }
 

+ 2 - 1
src/Resources/Extension.h

@@ -16,7 +16,8 @@ class Extension
 		~Extension();
 		void load(const char* filename);
 		/*template<typename Type>
-		int FooBar(Type* ptr) { DEBUG_ERR(foobarPtr==NULL); return (*foobarPtr)(reinterpret_cast<Type*>(ptr)); }*/
+		int FooBar(Type* ptr) { DEBUG_ERR(foobarPtr==NULL);
+			return (*foobarPtr)(reinterpret_cast<Type*>(ptr)); }*/
 };
 
 

+ 33 - 0
src/Resources/SProgLoader.h

@@ -0,0 +1,33 @@
+#ifndef S_PROG_LOADER_H
+#define S_PROG_LOADER_H
+
+
+namespace boost { namespace property_tree {
+class ptree;
+}}
+
+
+class SProgLoader
+{
+	public:
+		SProgLoader() {}
+		SProgLoader(const char* filename) {parseFile(filename);}
+		SProgLoader(const boost::property_tree::ptree& pt) {parsePtree(pt);}
+		~SProgLoader();
+
+		void parseFile(const char* filename);
+		void parsePtree(const boost::property_tree::ptree& pt);
+
+	private:
+		struct Output
+		{
+			Vec<std::string> tfbVaryings; ///< Names and and ids for transform
+			                              ///< feedback varyings
+			std::string vertShaderSource; ///< The vert shader source
+			std::string geomShaderSource; ///< The geom shader source
+			std::string fragShaderSource; ///< The frag shader source
+		};
+};
+
+
+#endif

+ 53 - 29
src/Resources/ShaderPrePreprocessor.cpp

@@ -9,7 +9,8 @@
 #include "Util/Exception.h"
 
 
-static const char* MULTIPLE_DEF_MSG = " already defined in the same place. Check for circular or multiple includance";
+static const char* MULTIPLE_DEF_MSG = " already defined in the same place. "
+	"Check for circular or multiple includance";
 
 
 //==============================================================================
@@ -166,7 +167,8 @@ void ShaderPrePreprocessor::parseFileForPragmas(const std::string& filename,
 					{
 						// play
 
-						// its defined in same place so there is probable circular includance
+						// its defined in same place so there is probable
+						// circular includance
 						if(geomShaderBegins.definedInLine ==
 							scanner.getLineNumber() &&
 							geomShaderBegins.definedInFile == filename)
@@ -326,9 +328,11 @@ void ShaderPrePreprocessor::parseFileForPragmas(const std::string& filename,
 							}
 
 							// all ok, push it back
-							output.trffbVaryings.push_back(TrffbVaryingPragma(filename, scanner.getLineNumber(),
-							                                                  varName));
-							sourceLines.push_back(lines[scanner.getLineNumber() - 1]);
+							output.trffbVaryings.push_back(
+								TrffbVaryingPragma(filename,
+								scanner.getLineNumber(), varName));
+							sourceLines.push_back(
+								lines[scanner.getLineNumber() - 1]);
 						}
 						else
 						{
@@ -339,7 +343,7 @@ void ShaderPrePreprocessor::parseFileForPragmas(const std::string& filename,
 					// attribute
 					//
 					else if(token->getCode() == Scanner::TC_IDENTIFIER &&
-					        strcmp(token->getValue().getString(), "attribute") == 0)
+						strcmp(token->getValue().getString(), "attribute") == 0)
 					{
 						throw EXCEPTION("Deprecated feature");
 
@@ -348,42 +352,57 @@ void ShaderPrePreprocessor::parseFileForPragmas(const std::string& filename,
 						{
 							std::string varName = token->getValue().getString();
 							token = &scanner.getNextToken();
-							if(token->getCode() == Scanner::TC_NUMBER && token->getDataType() == Scanner::DT_INT)
+							if(token->getCode() == Scanner::TC_NUMBER &&
+								token->getDataType() == Scanner::DT_INT)
 							{
 								uint loc = token->getValue().getInt();
 
-								// check if already defined and for circular includance
-								Vec<ShaderVarPragma>::const_iterator attrib = findNamed(output.attributes, varName);
+								// check if already defined and for circular
+								// includance
+								Vec<ShaderVarPragma>::const_iterator attrib =
+									findNamed(output.attributes, varName);
 								if(attrib != output.attributes.end())
 								{
-									if(attrib->definedInLine == scanner.getLineNumber() &&
-									   attrib->definedInFile == filename)
+									if(attrib->definedInLine ==
+										scanner.getLineNumber() &&
+										attrib->definedInFile == filename)
 									{
-										throw PARSER_EXCEPTION("\"" + varName + "\"" + MULTIPLE_DEF_MSG);
+										throw PARSER_EXCEPTION("\"" + varName +
+											"\"" + MULTIPLE_DEF_MSG);
 									}
 									else
 									{
-										throw PARSER_EXCEPTION("Attribute \"" + varName + "\" already defined at " +
-										                       attrib->definedInFile + ":" +
-										                       boost::lexical_cast<std::string>(attrib->definedInLine));
+										throw PARSER_EXCEPTION(
+											"Attribute \"" + varName +
+											"\" already defined at " +
+											attrib->definedInFile + ":" +
+											boost::lexical_cast<std::string>(
+											attrib->definedInLine));
 									}
 								}
 								// search if another var has the same loc
-								for(attrib = output.attributes.begin(); attrib != output.attributes.end(); ++attrib)
+								for(attrib = output.attributes.begin();
+									attrib != output.attributes.end(); ++attrib)
 								{
 									if(attrib->customLoc == loc)
 									{
-										throw PARSER_EXCEPTION("The attributes \"" + attrib->name + "\" (" +
-										                       attrib->definedInFile + ":" +
-										                       boost::lexical_cast<std::string>(attrib->definedInLine) +
-										                       ") and \"" + varName + "\" share the same location");
+										throw PARSER_EXCEPTION(
+											"The attributes \"" +
+											attrib->name + "\" (" +
+											attrib->definedInFile + ":" +
+											boost::lexical_cast<std::string>(
+											attrib->definedInLine) +
+											") and \"" + varName +
+											"\" share the same location");
 									}
 								}
 
 								// all ok, push it back
-								output.attributes.push_back(ShaderVarPragma(filename, scanner.getLineNumber(),
-								                                            varName, loc));
-								sourceLines.push_back(lines[scanner.getLineNumber() - 1]);
+								output.attributes.push_back(ShaderVarPragma(
+									filename, scanner.getLineNumber(), varName,
+									loc));
+								sourceLines.push_back(
+									lines[scanner.getLineNumber() - 1]);
 							}
 							else
 							{
@@ -397,12 +416,15 @@ void ShaderPrePreprocessor::parseFileForPragmas(const std::string& filename,
 					}
 					else
 					{
-						throw PARSER_EXCEPTION("#pragma anki followed by incorrect " + token->getInfoStr());
+						throw PARSER_EXCEPTION(
+							"#pragma anki followed by incorrect " +
+							token->getInfoStr());
 					}
 				} // end if anki
 
 				token = &scanner.getNextToken();
-				if(token->getCode()!=Scanner::TC_NEWLINE && token->getCode()!=Scanner::TC_EOF)
+				if(token->getCode()!=Scanner::TC_NEWLINE &&
+					token->getCode()!=Scanner::TC_EOF)
 				{
 					throw PARSER_EXCEPTION_EXPECTED("newline or end of file");
 				}
@@ -486,8 +508,8 @@ void ShaderPrePreprocessor::parseFile(const char* filename)
 			}
 
 			// vert shader code
-			int limit = (geomShaderBegins.definedInLine != -1) ? geomShaderBegins.globalLine-1 :
-			                                                     fragShaderBegins.globalLine-1;
+			int limit = (geomShaderBegins.definedInLine != -1) ?
+				geomShaderBegins.globalLine-1 : fragShaderBegins.globalLine-1;
 			for(int i = vertShaderBegins.globalLine - 1; i < limit; ++i)
 			{
 				output.vertShaderSource += sourceLines[i] + "\n";
@@ -496,14 +518,16 @@ void ShaderPrePreprocessor::parseFile(const char* filename)
 			// geom shader code
 			if(geomShaderBegins.definedInLine != -1)
 			{
-				for(int i = geomShaderBegins.globalLine - 1; i < fragShaderBegins.globalLine - 1; ++i)
+				for(int i = geomShaderBegins.globalLine - 1;
+					i < fragShaderBegins.globalLine - 1; ++i)
 				{
 					output.geomShaderSource += sourceLines[i] + "\n";
 				}
 			}
 
 			// frag shader code
-			for(int i = fragShaderBegins.globalLine - 1; i < int(sourceLines.size()); ++i)
+			for(int i = fragShaderBegins.globalLine - 1;
+				i < int(sourceLines.size()); ++i)
 			{
 				output.fragShaderSource += sourceLines[i] + "\n";
 			}

+ 7 - 4
src/Resources/ShaderPrePreprocessor.h

@@ -46,20 +46,23 @@ class ShaderPrePreprocessor
 			std::string name;
 			uint customLoc;
 
-			ShaderVarPragma(const std::string& definedInFile_, int definedInLine_, const std::string& name_,
-			                uint customLoc_);
+			ShaderVarPragma(const std::string& definedInFile_,
+				int definedInLine_, const std::string& name_,
+				uint customLoc_);
 		};
 
 		struct TrffbVaryingPragma: Pragma
 		{
 			std::string name;
 
-			TrffbVaryingPragma(const std::string& definedInFile_, int definedInLine_, const std::string& name_);
+			TrffbVaryingPragma(const std::string& definedInFile_,
+				int definedInLine_, const std::string& name_);
 		};
 	
 		struct CodeBeginningPragma: Pragma
 		{
-			int globalLine; ///< The line number in the ShaderPrePreprocessor-compatible file
+			/// The line number in the ShaderPrePreprocessor-compatible file
+			int globalLine;
 
 			CodeBeginningPragma(): globalLine(-1) {}
 		};

+ 5 - 3
src/Scene/Camera.h

@@ -37,7 +37,8 @@ class Camera: public SceneNode, public VisibilityInfo
 			FP_NUM
 		};
 
-		Camera(CameraType camType, bool compoundFlag, SceneNode* parent);
+		Camera(CameraType camType, bool inheritParentTrfFlag,
+			SceneNode* parent);
 
 		/// @name Accessors
 		/// @{
@@ -121,8 +122,9 @@ class Camera: public SceneNode, public VisibilityInfo
 
 
 
-inline Camera::Camera(CameraType camType, bool compoundFlag, SceneNode* parent)
-:	SceneNode(SNT_CAMERA, compoundFlag, parent),
+inline Camera::Camera(CameraType camType, bool inheritParentTrfFlag,
+	SceneNode* parent)
+:	SceneNode(SNT_CAMERA, inheritParentTrfFlag, parent),
 	type(camType)
 {
 	name = "Camera:" + name;

+ 5 - 3
src/Scene/Light.h

@@ -33,7 +33,8 @@ class Light: public SceneNode, public VisibilityInfo
 			LT_SPOT
 		};
 
-		Light(LightType type, bool compoundFlag, SceneNode* parent = NULL);
+		Light(LightType type, bool inheritParentTrfFlag,
+			SceneNode* parent);
 		~Light();
 
 		/// @name Accessors
@@ -61,8 +62,9 @@ class Light: public SceneNode, public VisibilityInfo
 };
 
 
-inline Light::Light(LightType type_, bool compoundFlag, SceneNode* parent):
-	SceneNode(SNT_LIGHT, compoundFlag, parent),
+inline Light::Light(LightType type_, bool inheritParentTrfFlag,
+	SceneNode* parent)
+:	SceneNode(SNT_LIGHT, inheritParentTrfFlag, parent),
 	type(type_)
 {}
 

+ 3 - 3
src/Scene/ModelNode.h

@@ -17,7 +17,7 @@ class Model;
 class ModelNode: public SceneNode
 {
 	public:
-		ModelNode(SceneNode* parent = NULL);
+		ModelNode(bool inheritParentTrfFlag, SceneNode* parent);
 		virtual ~ModelNode();
 
 		/// @name Accessors
@@ -43,8 +43,8 @@ class ModelNode: public SceneNode
 };
 
 
-inline ModelNode::ModelNode(SceneNode* parent)
-:	SceneNode(SNT_MODEL, true, parent)
+inline ModelNode::ModelNode(bool inheritParentTrfFlag, SceneNode* parent)
+:	SceneNode(SNT_MODEL, inheritParentTrfFlag, parent)
 {}
 
 

+ 3 - 2
src/Scene/ModelPatchNode.cpp

@@ -10,8 +10,9 @@
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
-ModelPatchNode::ModelPatchNode(const ModelPatch& modelPatch_, ModelNode* parent):
-	PatchNode(modelPatch_, parent),
+ModelPatchNode::ModelPatchNode(const ModelPatch& modelPatch_,
+	ModelNode* parent)
+:	PatchNode(modelPatch_, parent),
 	modelPatch(modelPatch_)
 {
 	boost::array<const Vbo*, Mesh::VBOS_NUM> vboArr;

+ 3 - 3
src/Scene/OrthographicCamera.h

@@ -8,7 +8,7 @@
 class OrthographicCamera: public Camera
 {
 	public:
-		OrthographicCamera(bool compoundFlag, SceneNode* parent);
+		OrthographicCamera(bool inheritParentTrfFlag, SceneNode* parent);
 
 		/// @name Accessors
 		/// @{
@@ -59,9 +59,9 @@ class OrthographicCamera: public Camera
 };
 
 
-inline OrthographicCamera::OrthographicCamera(bool compoundFlag,
+inline OrthographicCamera::OrthographicCamera(bool inheritParentTrfFlag,
 	SceneNode* parent)
-:	Camera(CT_ORTHOGRAPHIC, compoundFlag, parent)
+:	Camera(CT_ORTHOGRAPHIC, inheritParentTrfFlag, parent)
 {
 	name = "OrthographicCamera:" + name;
 }

+ 1 - 1
src/Scene/Particle.cpp

@@ -6,7 +6,7 @@
 // Constructor                                                                 =
 //==============================================================================
 Particle::Particle(float timeOfDeath_, SceneNode* parent):
-	ModelNode(parent),
+	ModelNode(false, parent),
 	timeOfDeath(timeOfDeath_)
 {}
 

+ 9 - 9
src/Scene/ParticleEmitter.cpp → src/Scene/ParticleEmitterNode.cpp

@@ -1,7 +1,7 @@
 #include <boost/foreach.hpp>
 #include <btBulletCollisionCommon.h>
 #include <btBulletDynamicsCommon.h>
-#include "ParticleEmitter.h"
+#include "ParticleEmitterNode.h"
 #include "Particle.h"
 #include "Physics/RigidBody.h"
 #include "Core/App.h"
@@ -9,21 +9,21 @@
 #include "Util/Util.h"
 
 
-btTransform ParticleEmitter::startingTrf(toBt(Mat3::getIdentity()),
+btTransform ParticleEmitterNode::startingTrf(toBt(Mat3::getIdentity()),
 	btVector3(10000000.0, 10000000.0, 10000000.0));
 
 
 //==============================================================================
 // Destructor                                                                  =
 //==============================================================================
-ParticleEmitter::~ParticleEmitter()
+ParticleEmitterNode::~ParticleEmitterNode()
 {}
 
 
 //==============================================================================
 // getRandom                                                                   =
 //==============================================================================
-float ParticleEmitter::getRandom(float initial, float deviation)
+float ParticleEmitterNode::getRandom(float initial, float deviation)
 {
 	return (deviation == 0.0) ?  initial :
 		initial + Util::randFloat(deviation) * 2.0 - deviation;
@@ -33,7 +33,7 @@ float ParticleEmitter::getRandom(float initial, float deviation)
 //==============================================================================
 // getRandom                                                                   =
 //==============================================================================
-Vec3 ParticleEmitter::getRandom(const Vec3& initial, const Vec3& deviation)
+Vec3 ParticleEmitterNode::getRandom(const Vec3& initial, const Vec3& deviation)
 {
 	if(deviation == Vec3(0.0))
 	{
@@ -54,7 +54,7 @@ Vec3 ParticleEmitter::getRandom(const Vec3& initial, const Vec3& deviation)
 //==============================================================================
 // init                                                                        =
 //==============================================================================
-void ParticleEmitter::init(const char* filename)
+void ParticleEmitterNode::init(const char* filename)
 {
 	particleEmitterProps.loadRsrc(filename);
 
@@ -68,7 +68,7 @@ void ParticleEmitter::init(const char* filename)
 
 	for(uint i = 0; i < maxNumOfParticles; i++)
 	{
-		ModelNode* md = new ModelNode(this);
+		ModelNode* md = new ModelNode(false, this);
 		md->init(modelName.c_str());
 		md->setLocalTransform(Transform(Vec3(Util::randFloat(i * 1.0)),
 			Mat3::getIdentity(), 1.0));
@@ -110,9 +110,9 @@ void ParticleEmitter::init(const char* filename)
 //==============================================================================
 // frameUpdate                                                                 =
 //==============================================================================
-void ParticleEmitter::frameUpdate(float prevUpdateTime, float crntTime)
+void ParticleEmitterNode::frameUpdate(float prevUpdateTime, float crntTime)
 {
-	// Opt: We dont have to make extra calculations if the ParticleEmitter's
+	// Opt: We dont have to make extra calculations if the ParticleEmitterNode's
 	// rotation is the identity
 	bool identRot = getWorldTransform().getRotation() == Mat3::getIdentity();
 

+ 8 - 7
src/Scene/ParticleEmitter.h → src/Scene/ParticleEmitterNode.h

@@ -1,5 +1,5 @@
-#ifndef PARTICLE_EMITTER_H
-#define PARTICLE_EMITTER_H
+#ifndef PARTICLE_EMITTER_NODE_H
+#define PARTICLE_EMITTER_NODE_H
 
 #include <boost/ptr_container/ptr_vector.hpp>
 #include <boost/scoped_ptr.hpp>
@@ -15,11 +15,11 @@ class Particle;
 
 /// The particle emitter scene node. This scene node emitts
 /// @ref ParticleEmitter:Particle particle nodes in space.
-class ParticleEmitter: public SceneNode, public ParticleEmitterRsrc
+class ParticleEmitterNode: public SceneNode, public ParticleEmitterRsrc
 {
 	public:
-		ParticleEmitter();
-		virtual ~ParticleEmitter();
+		ParticleEmitterNode(bool inheritParentTrfFlag, SceneNode* parent);
+		virtual ~ParticleEmitterNode();
 
 		void init(const char* filename);
 
@@ -38,8 +38,9 @@ class ParticleEmitter: public SceneNode, public ParticleEmitterRsrc
 };
 
 
-inline ParticleEmitter::ParticleEmitter()
-:	SceneNode(SNT_PARTICLE_EMITTER, false, NULL)
+inline ParticleEmitterNode::ParticleEmitterNode(bool inheritParentTrfFlag,
+	SceneNode* parent)
+:	SceneNode(SNT_PARTICLE_EMITTER, inheritParentTrfFlag, parent)
 {}
 
 

+ 2 - 2
src/Scene/PatchNode.cpp

@@ -6,8 +6,8 @@
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
-PatchNode::PatchNode(const ModelPatch& modelPatch, SceneNode* parent):
-	RenderableNode(parent),
+PatchNode::PatchNode(const ModelPatch& modelPatch, SceneNode* parent)
+:	RenderableNode(true, parent),
 	rsrc(modelPatch)
 {
 	cpMtlRun.reset(new MaterialRuntime(rsrc.getCpMtl()));

+ 3 - 3
src/Scene/PerspectiveCamera.h

@@ -8,7 +8,7 @@
 class PerspectiveCamera: public Camera
 {
 	public:
-		PerspectiveCamera(bool compoundFlag, SceneNode* parent);
+		PerspectiveCamera(bool inheritParentTrfFlag, SceneNode* parent);
 
 		/// @name Accessors
 		/// @{
@@ -43,9 +43,9 @@ class PerspectiveCamera: public Camera
 };
 
 
-inline PerspectiveCamera::PerspectiveCamera(bool compoundFlag,
+inline PerspectiveCamera::PerspectiveCamera(bool inheritParentTrfFlag,
 	SceneNode* parent)
-:	Camera(CT_PERSPECTIVE, compoundFlag, parent)
+:	Camera(CT_PERSPECTIVE, inheritParentTrfFlag, parent)
 {
 	name = "PerspectiveCamera:" + name;
 }

+ 6 - 1
src/Scene/PointLight.h

@@ -8,7 +8,7 @@
 class PointLight: public Light
 {
 	public:
-		PointLight(SceneNode* parent = NULL): Light(LT_POINT, parent) {}
+		PointLight(bool inheritParentTrfFlag, SceneNode* parent);
 		GETTER_SETTER(float, radius, getRadius, setRadius)
 		void init(const char* filename);
 
@@ -17,6 +17,11 @@ class PointLight: public Light
 };
 
 
+inline PointLight::PointLight(bool inheritParentTrfFlag, SceneNode* parent)
+:	Light(LT_POINT, inheritParentTrfFlag, parent)
+{}
+
+
 inline void PointLight::init(const char* filename)
 {
 	Light::init(filename);

+ 4 - 3
src/Scene/RenderableNode.h

@@ -13,7 +13,7 @@ class MaterialRuntime;
 class RenderableNode: public SceneNode
 {
 	public:
-		RenderableNode(SceneNode* parent);
+		RenderableNode(bool inheritParentTrfFlag, SceneNode* parent);
 
 		virtual const Vao& getCpVao() const = 0; ///< Get color pass VAO
 		virtual const Vao& getDpVao() const = 0; ///< Get depth pass VAO
@@ -30,8 +30,9 @@ class RenderableNode: public SceneNode
 };
 
 
-inline RenderableNode::RenderableNode(SceneNode* parent)
-:	SceneNode(SNT_RENDERABLE, false, parent)
+inline RenderableNode::RenderableNode(bool inheritParentTrfFlag,
+	SceneNode* parent)
+:	SceneNode(SNT_RENDERABLE, inheritParentTrfFlag, parent)
 {}
 
 

+ 5 - 3
src/Scene/Scene.cpp

@@ -8,7 +8,7 @@
 #include "Light.h"
 #include "Controller.h"
 #include "Resources/Material.h"
-#include "ParticleEmitter.h"
+#include "ParticleEmitterNode.h"
 #include "ModelNode.h"
 #include "SkinNode.h"
 
@@ -43,7 +43,8 @@ void Scene::registerNode(SceneNode* node)
 			putBackNode(cameras, static_cast<Camera*>(node));
 			break;
 		case SceneNode::SNT_PARTICLE_EMITTER:
-			putBackNode(particleEmitters, static_cast<ParticleEmitter*>(node));
+			putBackNode(particleEmitterNodes,
+				static_cast<ParticleEmitterNode*>(node));
 			break;
 		case SceneNode::SNT_MODEL:
 			putBackNode(modelNodes, static_cast<ModelNode*>(node));
@@ -74,7 +75,8 @@ void Scene::unregisterNode(SceneNode* node)
 			eraseNode(cameras, static_cast<Camera*>(node));
 			break;
 		case SceneNode::SNT_PARTICLE_EMITTER:
-			eraseNode(particleEmitters, static_cast<ParticleEmitter*>(node));
+			eraseNode(particleEmitterNodes,
+				static_cast<ParticleEmitterNode*>(node));
 			break;
 		case SceneNode::SNT_MODEL:
 			eraseNode(modelNodes, static_cast<ModelNode*>(node));

+ 3 - 3
src/Scene/Scene.h

@@ -12,7 +12,7 @@ class SceneNode;
 class Light;
 class Camera;
 class Controller;
-class ParticleEmitter;
+class ParticleEmitterNode;
 class ModelNode;
 class SkinNode;
 
@@ -54,7 +54,7 @@ class Scene
 		GETTER_RW(Types<SceneNode>::Container, nodes, getAllNodes)
 		GETTER_RW(Types<Light>::Container, lights, getLights)
 		GETTER_RW(Types<Camera>::Container, cameras, getCameras)
-		GETTER_RW(Types<ParticleEmitter>::Container, particleEmitters,
+		GETTER_RW(Types<ParticleEmitterNode>::Container, particleEmitterNodes,
 			getParticleEmitters)
 		GETTER_RW(Types<ModelNode>::Container, modelNodes, getModelNodes)
 		GETTER_RW(Types<SkinNode>::Container, skinNodes, getSkinNodes)
@@ -67,7 +67,7 @@ class Scene
 		Types<SceneNode>::Container nodes;
 		Types<Light>::Container lights;
 		Types<Camera>::Container cameras;
-		Types<ParticleEmitter>::Container particleEmitters;
+		Types<ParticleEmitterNode>::Container particleEmitterNodes;
 		Types<ModelNode>::Container modelNodes;
 		Types<SkinNode>::Container skinNodes;
 		Types<Controller>::Container controllers;

+ 3 - 3
src/Scene/SceneNode.cpp

@@ -15,11 +15,11 @@ uint SceneNode::uid = 0;
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
-SceneNode::SceneNode(SceneNodeType type_, bool compoundFlag_,
+SceneNode::SceneNode(SceneNodeType type_, bool inheritParentTrfFlag_,
 	SceneNode* parent)
 :	Object(parent),
 	type(type_),
-	compoundFlag(compoundFlag_)
+	inheritParentTrfFlag(inheritParentTrfFlag_)
 {
 	getWorldTransform().setIdentity();
 	getLocalTransform().setIdentity();
@@ -51,7 +51,7 @@ void SceneNode::updateWorldTransform()
 	{
 		const SceneNode* parent = static_cast<const SceneNode*>(getObjParent());
 
-		if(parent->compoundFlag)
+		if(inheritParentTrfFlag)
 		{
 			worldTransform = parent->getWorldTransform();
 		}

+ 7 - 6
src/Scene/SceneNode.h

@@ -30,7 +30,7 @@ class SceneNode: public Object
 			SNT_RENDERABLE
 		};
 		
-		explicit SceneNode(SceneNodeType type_, bool compoundFlag,
+		explicit SceneNode(SceneNodeType type, bool inheritParentTrfFlag,
 			SceneNode* parent);
 		virtual ~SceneNode();
 		virtual void init(const char*) = 0; ///< init using a script file
@@ -62,10 +62,10 @@ class SceneNode: public Object
 
 		/// This is called every frame
 		virtual void frameUpdate(float /*prevUpdateTime*/,
-			float /*crntTime*/) = 0;
+			float /*crntTime*/) {}
 
 		/// This is called if the node moved
-		virtual void moveUpdate() = 0;
+		virtual void moveUpdate() {}
 		/// @}
 
 		/// @name Mess with the local transform
@@ -95,9 +95,10 @@ class SceneNode: public Object
 		Transform prevWorldTransform;
 
 		SceneNodeType type;
-		/// This means that the children will inherit the world transform of
-		/// this node
-		bool compoundFlag;
+		/// This means that the the node will inherit the world transform of
+		/// its parent (if there is one) and it will not take into account its
+		/// local transform at all
+		bool inheritParentTrfFlag;
 
 		static uint uid; ///< Unique identifier
 

+ 4 - 4
src/Scene/SkelAnimModelNodeCtrl.cpp

@@ -185,16 +185,16 @@ void SkelAnimModelNodeCtrl::update(float)
 	updateBoneTransforms(skinNode.getSkin().getSkeleton(),
 		skinNode.getBoneTranslations(), skinNode.getBoneRotations());
 
-	if(MainRendererSingleton::getInstance().getDbg().isEnabled() &&
-		MainRendererSingleton::getInstance().getDbg().isShowSkeletonsEnabled())
+	if(R::MainRendererSingleton::getInstance().getDbg().isEnabled() &&
+		R::MainRendererSingleton::getInstance().getDbg().isShowSkeletonsEnabled())
 	{
 		deform(skinNode.getSkin().getSkeleton(),
 			skinNode.getBoneTranslations(), skinNode.getBoneRotations(),
 			skinNode.getHeads(), skinNode.getTails());
 	}
 
-	SkinsDeformer& sd =
-		MainRendererSingleton::getInstance().getSkinsDeformer();
+	R::SkinsDeformer& sd =
+		R::MainRendererSingleton::getInstance().getSkinsDeformer();
 
 	BOOST_FOREACH(SkinPatchNode* skinPatchNode, skinNode.getPatcheNodes())
 	{

+ 6 - 3
src/Scene/SkinNode.h

@@ -18,7 +18,7 @@ class SkinNode: public SceneNode
 	public:
 		SkelAnimModelNodeCtrl* skelAnimModelNodeCtrl; ///< @todo fix this crap
 
-		SkinNode(): SceneNode(SNT_SKIN, true, NULL) {}
+		SkinNode(bool inheritParentTrfFlag, SceneNode* parent);
 
 		/// @name Accessors
 		/// @{
@@ -37,8 +37,6 @@ class SkinNode: public SceneNode
 		/// cause its faster that way). The tails come from the previous frame
 		void moveUpdate();
 
-		void frameUpdate(float /*prevUpdateTime*/, float /*crntTime*/) {}
-
 	private:
 		RsrcPtr<Skin> skin; ///< The resource
 		Vec<SkinPatchNode*> patches;
@@ -54,4 +52,9 @@ class SkinNode: public SceneNode
 };
 
 
+inline SkinNode::SkinNode(bool inheritParentTrfFlag, SceneNode* parent)
+:	SceneNode(SNT_SKIN, inheritParentTrfFlag, parent)
+{}
+
+
 #endif

+ 8 - 8
src/Scene/SkinPatchNode.cpp

@@ -9,8 +9,8 @@
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
-SkinPatchNode::SkinPatchNode(const ModelPatch& modelPatch_, SkinNode* parent):
-	PatchNode(modelPatch_, parent)
+SkinPatchNode::SkinPatchNode(const ModelPatch& modelPatch_, SkinNode* parent)
+:	PatchNode(modelPatch_, parent)
 {
 	boost::array<const Vbo*, Mesh::VBOS_NUM> vboArr;
 
@@ -38,7 +38,7 @@ SkinPatchNode::SkinPatchNode(const ModelPatch& modelPatch_, SkinNode* parent):
 		vboArr[Mesh::VBO_VERT_POSITIONS] = &tfVbos[TFV_POSITIONS];
 
 		tfVao.attachArrayBufferVbo(mesh.getVbo(Mesh::VBO_VERT_POSITIONS),
-			SkinsDeformer::TFSPA_POSITION,
+			R::SkinsDeformer::TFSPA_POSITION,
 			3,
 			GL_FLOAT,
 			false,
@@ -57,7 +57,7 @@ SkinPatchNode::SkinPatchNode(const ModelPatch& modelPatch_, SkinNode* parent):
 		vboArr[Mesh::VBO_VERT_NORMALS] = &tfVbos[TFV_NORMALS];
 
 		tfVao.attachArrayBufferVbo(mesh.getVbo(Mesh::VBO_VERT_NORMALS),
-			SkinsDeformer::TFSPA_NORMAL,
+			R::SkinsDeformer::TFSPA_NORMAL,
 			3,
 			GL_FLOAT,
 			false,
@@ -76,7 +76,7 @@ SkinPatchNode::SkinPatchNode(const ModelPatch& modelPatch_, SkinNode* parent):
 		vboArr[Mesh::VBO_VERT_TANGENTS] = &tfVbos[TFV_TANGENTS];
 
 		tfVao.attachArrayBufferVbo(mesh.getVbo(Mesh::VBO_VERT_TANGENTS),
-			SkinsDeformer::TFSPA_TANGENT,
+			R::SkinsDeformer::TFSPA_TANGENT,
 			4,
 			GL_FLOAT,
 			false,
@@ -88,7 +88,7 @@ SkinPatchNode::SkinPatchNode(const ModelPatch& modelPatch_, SkinNode* parent):
 	ASSERT(mesh.getVbo(Mesh::VBO_VERT_WEIGHTS).isCreated());
 
 	tfVao.attachArrayBufferVbo(mesh.getVbo(Mesh::VBO_VERT_WEIGHTS),
-		SkinsDeformer::TFSPA_VERT_WEIGHT_BONES_NUM,
+		R::SkinsDeformer::TFSPA_VERT_WEIGHT_BONES_NUM,
 		1,
 		GL_FLOAT,
 		GL_FALSE,
@@ -97,7 +97,7 @@ SkinPatchNode::SkinPatchNode(const ModelPatch& modelPatch_, SkinNode* parent):
 
 
 	tfVao.attachArrayBufferVbo(mesh.getVbo(Mesh::VBO_VERT_WEIGHTS),
-		SkinsDeformer::TFSPA_VERT_WEIGHT_BONE_IDS,
+		R::SkinsDeformer::TFSPA_VERT_WEIGHT_BONE_IDS,
 		4,
 		GL_FLOAT,
 		GL_FALSE,
@@ -105,7 +105,7 @@ SkinPatchNode::SkinPatchNode(const ModelPatch& modelPatch_, SkinNode* parent):
 		BUFFER_OFFSET(4));
 
 	tfVao.attachArrayBufferVbo(mesh.getVbo(Mesh::VBO_VERT_WEIGHTS),
-		SkinsDeformer::TFSPA_VERT_WEIGHT_WEIGHTS,
+		R::SkinsDeformer::TFSPA_VERT_WEIGHT_WEIGHTS,
 		4,
 		GL_FLOAT,
 		GL_FALSE,

+ 0 - 1
src/Scene/SkinPatchNode.h

@@ -31,7 +31,6 @@ class SkinPatchNode: public PatchNode
 		/// @}
 
 		virtual void moveUpdate() {}
-		virtual void frameUpdate(float /*prevUpdateTime*/, float /*crntTime*/) {}
 
 	private:
 		/// VBOs that contain the deformed vertex attributes

+ 6 - 1
src/Scene/SpotLight.h

@@ -9,7 +9,7 @@
 class SpotLight: public Light
 {
 	public:
-		SpotLight(SceneNode* parent = NULL): Light(LT_SPOT, parent) {}
+		SpotLight(bool inheritParentTrfFlag, SceneNode* parent);
 		~SpotLight() {}
 		void init(const char* filename);
 
@@ -31,4 +31,9 @@ class SpotLight: public Light
 };
 
 
+inline SpotLight::SpotLight(bool inheritParentTrfFlag, SceneNode* parent)
+:	Light(LT_SPOT, inheritParentTrfFlag, parent)
+{}
+
+
 #endif

+ 8 - 0
src/Scene/VisibilityInfo.cpp

@@ -0,0 +1,8 @@
+#include "VisibilityInfo.h"
+
+
+//==============================================================================
+// Destructor                                                                  =
+//==============================================================================
+VisibilityInfo::~VisibilityInfo()
+{}

+ 3 - 0
src/Scene/VisibilityInfo.h

@@ -16,6 +16,9 @@ class SpotLight;
 class VisibilityInfo
 {
 	public:
+		VisibilityInfo() {}
+		~VisibilityInfo();
+
 		/// @name Accessors
 		/// @{
 		GETTER_RW(std::deque<const RenderableNode*>, msRenderableNodes,

+ 5 - 2
src/Scripting/Core/Globals.bpi.cpp

@@ -9,7 +9,10 @@
 
 
 WRAP_SINGLETON(LoggerSingleton)
-WRAP_SINGLETON(MainRendererSingleton)
+
+typedef R::MainRendererSingleton RMainRendererSingleton;
+WRAP_SINGLETON(RMainRendererSingleton)
+
 WRAP_SINGLETON(InputSingleton)
 WRAP_SINGLETON(SceneSingleton)
 WRAP_SINGLETON(AppSingleton)
@@ -21,7 +24,7 @@ WRAP_SINGLETON(EventManagerSingleton)
 void boostPythonWrapAllGlobals()
 {
 	CALL_WRAP(LoggerSingleton);
-	CALL_WRAP(MainRendererSingleton);
+	CALL_WRAP(RMainRendererSingleton);
 	CALL_WRAP(InputSingleton);
 	CALL_WRAP(SceneSingleton);
 	CALL_WRAP(AppSingleton);

+ 9 - 9
src/Scripting/Renderer/Bl.bpi.cpp

@@ -4,16 +4,16 @@
 
 WRAP(Bl)
 {
-	class_<Bl, noncopyable>("Bl", no_init)
-		.def("isEnabled", (bool (Bl::*)() const)(&Bl::isEnabled))
-		.def("setEnabled", &Bl::setEnabled)
+	class_<R::Bl, noncopyable>("Bl", no_init)
+		.def("isEnabled", (bool (R::Bl::*)() const)(&R::Bl::isEnabled))
+		.def("setEnabled", &R::Bl::setEnabled)
 
-		.def("getBlurringIterationsNum", (uint (Bl::*)() const)(
-			&Bl::getBlurringIterationsNum))
-		.def("setBlurringIterationsNum", &Bl::setBlurringIterationsNum)
+		.def("getBlurringIterationsNum", (uint (R::Bl::*)() const)(
+			&R::Bl::getBlurringIterationsNum))
+		.def("setBlurringIterationsNum", &R::Bl::setBlurringIterationsNum)
 
-		.def("getSideBlurFactor", (float (Bl::*)() const)(
-			&Bl::getSideBlurFactor))
-		.def("setSideBlurFactor", &Bl::setSideBlurFactor)
+		.def("getSideBlurFactor", (float (R::Bl::*)() const)(
+			&R::Bl::getSideBlurFactor))
+		.def("setSideBlurFactor", &R::Bl::setSideBlurFactor)
 	;
 }

+ 3 - 3
src/Scripting/Renderer/Dbg.bpi.cpp

@@ -4,8 +4,8 @@
 
 WRAP(Dbg)
 {
-	class_<Dbg, noncopyable>("Dbg", no_init)
-		.def("isEnabled", (bool (Dbg::*)() const)(&Dbg::isEnabled))
-		.def("setEnabled", &Dbg::setEnabled)
+	class_<R::Dbg, noncopyable>("Dbg", no_init)
+		.def("isEnabled", (bool (R::Dbg::*)() const)(&R::Dbg::isEnabled))
+		.def("setEnabled", &R::Dbg::setEnabled)
 	;
 }

+ 9 - 8
src/Scripting/Renderer/Hdr.bpi.cpp

@@ -4,15 +4,16 @@
 
 WRAP(Hdr)
 {
-	class_<Hdr, noncopyable>("Hdr", no_init)
-		.def("getBlurringIterationsNum", (uint (Hdr::*)() const)(
-			&Hdr::getBlurringIterationsNum))
-		.def("setBlurringIterationsNum", &Hdr::setBlurringIterationsNum)
+	class_<R::Hdr, noncopyable>("Hdr", no_init)
+		.def("getBlurringIterationsNum", (uint (R::Hdr::*)() const)(
+			&R::Hdr::getBlurringIterationsNum))
+		.def("setBlurringIterationsNum", &R::Hdr::setBlurringIterationsNum)
 
-		.def("getExposure", (float (Hdr::*)() const)(&Hdr::getExposure))
-		.def("setExposure", &Hdr::setExposure)
+		.def("getExposure", (float (R::Hdr::*)() const)(&R::Hdr::getExposure))
+		.def("setExposure", &R::Hdr::setExposure)
 
-		.def("getBlurringDist", (float (Hdr::*)() const)(&Hdr::getBlurringDist))
-		.def("setBlurringDist", &Hdr::setBlurringDist)
+		.def("getBlurringDist", (float (R::Hdr::*)() const)(
+			&R::Hdr::getBlurringDist))
+		.def("setBlurringDist", &R::Hdr::setBlurringDist)
 	;
 }

+ 4 - 2
src/Scripting/Renderer/MainRenderer.bpi.cpp

@@ -5,8 +5,10 @@
 
 WRAP(MainRenderer)
 {
-	class_<MainRenderer, bases<Renderer>, noncopyable>("MainRenderer", no_init)
-		.def("getDbg", (Dbg& (MainRenderer::*)())(&MainRenderer::getDbg),
+	class_<R::MainRenderer, bases<R::Renderer>, noncopyable>("MainRenderer",
+		no_init)
+		.def("getDbg", (R::Dbg& (R::MainRenderer::*)())(
+			&R::MainRenderer::getDbg),
 			return_value_policy<reference_existing_object>())
 	;
 }

+ 3 - 3
src/Scripting/Renderer/Pps.bpi.cpp

@@ -6,11 +6,11 @@
 
 WRAP(Pps)
 {
-	class_<Pps, noncopyable>("Pps", no_init)
-		.def("getHdr", (Hdr& (Pps::*)())(&Pps::getHdr),
+	class_<R::Pps, noncopyable>("Pps", no_init)
+		.def("getHdr", (R::Hdr& (R::Pps::*)())(&R::Pps::getHdr),
 			return_value_policy<reference_existing_object>())
 
-		.def("getBl", (Bl& (Pps::*)())(&Pps::getBl),
+		.def("getBl", (R::Bl& (R::Pps::*)())(&R::Pps::getBl),
 			return_value_policy<reference_existing_object>())
 	;
 }

+ 3 - 3
src/Scripting/Renderer/Renderer.bpi.cpp

@@ -4,10 +4,10 @@
 
 WRAP(Renderer)
 {
-	typedef Pps& (Renderer::* getPpsAccessor)();
+	typedef R::Pps& (R::Renderer::* getPpsAccessor)();
 
-	class_<Renderer, noncopyable>("Renderer", no_init)
-		.def("getPps", (getPpsAccessor)(&Renderer::getPps),
+	class_<R::Renderer, noncopyable>("Renderer", no_init)
+		.def("getPps", (getPpsAccessor)(&R::Renderer::getPps),
 			return_value_policy<reference_existing_object>())
 	;
 }