Browse Source

*Added the Transform class in Math
*Make the Scene a class
*Made the App a class
*Added a custom MotionState in Physics

Panagiotis Christopoulos Charitos 16 năm trước cách đây
mục cha
commit
a10d01f1c5

+ 2 - 0
TODO

@@ -2,3 +2,5 @@
 *Changes in the blending objects problem. The BS will become one stage and the PPS will be divided in two steps. The first will apply the SSAO and the EdgeAA in the IS_FAI and the second will do the rest
 *See this to improve uniform handling http://www.opengl.org/wiki/GLSL_Uniforms
 *The second Physics demo: Create a box that is geting moved by the user. It has to interact with the other boxes
+*Create custom motion states in bullet that have as a member a Node. Then go though every motion state and update the Node's trf
+*Replace the rotations in Node with Quaternions

+ 91 - 46
build/debug/Makefile

@@ -4,7 +4,7 @@ CFLAGS = $(COMMONFLAGS) -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -pi
 PHFLAGS = $(CFLAGS) -x c++-header
 LFLAGS = $(COMMONFLAGS) -rdynamic -L../../../bullet_svn/src/BulletSoftBody -L../../../bullet_svn/src/BulletDynamics -L../../../bullet_svn/src/BulletCollision -L../../../bullet_svn/src/LinearMath -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lSDL_image -lGLU -Wl,-Bdynamic -lSDL -lGL -ljpeg -lpng -ltiff
 EXECUTABLE = AnKi.bin
-INCPATH = -I../../src/Math/ -I../../src/Tokenizer/ -I../../src/Misc/ -I../../src/ -I../../src/Renderer/ -I../../src/Scene/ -I../../src/Ui/ -I../../src/Resources/ -I../../src/Util/ -I../../src/Controllers/ -I../../../bullet_svn/src/ 
+INCPATH = -I../../src/Math/ -I../../src/Tokenizer/ -I../../src/Misc/ -I../../src/ -I../../src/Renderer/ -I../../src/Scene/ -I../../src/Ui/ -I../../src/Resources/ -I../../src/Util/ -I../../src/Controllers/ -I../../src/Physics/ -I../../../bullet_svn/src/ 
 SOURCES = ../../src/Tokenizer//Scanner.cpp ../../src/Misc//skybox.cpp ../../src/Misc//particles.cpp ../../src/Misc//memory.cpp ../../src/Misc//collision.cpp ../../src/Misc//map.cpp ../../src//Main.cpp ../../src/Renderer//PpsHdr.cpp ../../src/Renderer//Pps.cpp ../../src/Renderer//Bs.cpp ../../src/Renderer//IsShadows.cpp ../../src/Renderer//MsEarlyz.cpp ../../src/Renderer//Renderer.cpp ../../src/Renderer//Is.cpp ../../src/Renderer//PpsLscatt.cpp ../../src/Renderer//Ms.cpp ../../src/Renderer//BulletDebuger.cpp ../../src/Renderer//Bs2.cpp ../../src/Renderer//PpsSsao.cpp ../../src/Renderer//Dbg.cpp ../../src/Scene//MeshNode.cpp ../../src/Scene//SkelNode.cpp ../../src/Scene//Node.cpp ../../src/Scene//SkelModelNode.cpp ../../src/Scene//Light.cpp ../../src/Scene//Camera.cpp ../../src/Scene//Scene.cpp ../../src/Ui//Ui.cpp ../../src/Resources//Material.cpp ../../src/Resources//ShaderProg.cpp ../../src/Resources//Texture.cpp ../../src/Resources//SkelAnim.cpp ../../src/Resources//Extension.cpp ../../src/Resources//Skeleton.cpp ../../src/Resources//Resource.cpp ../../src/Resources//LightProps.cpp ../../src/Resources//Mesh.cpp ../../src/Resources//ShaderPrePreprocessor.cpp ../../src/Util//Input.cpp ../../src/Util//App.cpp ../../src/Util//Common.cpp ../../src/Util//Util.cpp ../../src/Controllers//Controller.cpp ../../src/Controllers//SkelAnimCtrl.cpp 
 OBJECTS = Scanner.o skybox.o particles.o memory.o collision.o map.o Main.o PpsHdr.o Pps.o Bs.o IsShadows.o MsEarlyz.o Renderer.o Is.o PpsLscatt.o Ms.o BulletDebuger.o Bs2.o PpsSsao.o Dbg.o MeshNode.o SkelNode.o Node.o SkelModelNode.o Light.o Camera.o Scene.o Ui.o Material.o ShaderProg.o Texture.o SkelAnim.o Extension.o Skeleton.o Resource.o LightProps.o Mesh.o ShaderPrePreprocessor.o Input.o App.o Common.o Util.o Controller.o SkelAnimCtrl.o 
 PRECOMPILED_HEADERS = 
@@ -35,10 +35,12 @@ skybox.o: ../../src/Misc//skybox.cpp ../../src/Misc//skybox.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/Resource.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/Resource.h \
  ../../src/Renderer/Renderer.h ../../src/Resources/ShaderProg.h \
  ../../src/Scene/Camera.h ../../src/Misc/collision.h \
- ../../src/Scene/Node.h ../../src/Scene/Scene.h ../../src/Misc/skybox.h
+ ../../src/Scene/Node.h ../../src/Scene/Scene.h ../../src/Misc/skybox.h \
+ ../../src/Util/App.h
 	@echo Compiling ../../src/Misc//skybox.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/Misc//skybox.cpp -o skybox.o
 
@@ -62,7 +64,8 @@ collision.o: ../../src/Misc//collision.cpp ../../src/Misc//collision.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Renderer/Renderer.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Renderer/Renderer.h \
  ../../src/Resources/ShaderProg.h ../../src/Resources/Resource.h \
  ../../src/Util/Util.h ../../src/Util/Common.h ../../src/Scene/Camera.h \
  ../../src/Misc/collision.h ../../src/Scene/Node.h
@@ -81,7 +84,8 @@ map.o: ../../src/Misc//map.cpp ../../src/Misc//map.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/Mesh.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/Mesh.h \
  ../../src/Renderer/Vbo.h ../../src/Resources/Resource.h \
  ../../src/Util/Util.h ../../src/Util/Common.h ../../src/Misc/collision.h \
  ../../src/Tokenizer/Scanner.h ../../src/Tokenizer/Parser.h \
@@ -102,7 +106,8 @@ Main.o: ../../src//Main.cpp ../../src/Util/Common.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Scene/Camera.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Scene/Camera.h \
  ../../src/Misc/collision.h ../../src/Scene/Node.h \
  ../../src/Renderer/Renderer.h ../../src/Resources/ShaderProg.h \
  ../../src/Resources/Resource.h ../../src/Util/Util.h ../../src/Ui/Ui.h \
@@ -248,6 +253,8 @@ Main.o: ../../src//Main.cpp ../../src/Util/Common.h \
  ../../../bullet_svn/src/BulletDynamics/Dynamics/btRigidBody.h \
  ../../src/Renderer/BulletDebuger.h \
  ../../../bullet_svn/src/LinearMath/btIDebugDraw.h \
+ ../../src/Physics/MotionState.h ../../src/Physics/PhyCommon.h \
+ ../../src/Physics/MotionState.h ../../src/Scene/Node.h \
  ../../src/Resources/ShaderPrePreprocessor.h
 	@echo Compiling ../../src//Main.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src//Main.cpp -o Main.o
@@ -263,7 +270,8 @@ PpsHdr.o: ../../src/Renderer//PpsHdr.cpp ../../src/Renderer//Renderer.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/ShaderProg.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/ShaderProg.h \
  ../../src/Resources/Resource.h ../../src/Util/Util.h \
  ../../src/Util/Common.h ../../src/Scene/Camera.h \
  ../../src/Misc/collision.h ../../src/Scene/Node.h \
@@ -284,7 +292,8 @@ Pps.o: ../../src/Renderer//Pps.cpp ../../src/Renderer//Renderer.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/ShaderProg.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/ShaderProg.h \
  ../../src/Resources/Resource.h ../../src/Util/Util.h \
  ../../src/Util/Common.h ../../src/Scene/Camera.h \
  ../../src/Misc/collision.h ../../src/Scene/Node.h \
@@ -304,7 +313,8 @@ Bs.o: ../../src/Renderer//Bs.cpp ../../src/Renderer//Renderer.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/ShaderProg.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/ShaderProg.h \
  ../../src/Resources/Resource.h ../../src/Util/Util.h \
  ../../src/Util/Common.h ../../src/Scene/Camera.h \
  ../../src/Misc/collision.h ../../src/Scene/Node.h \
@@ -312,7 +322,8 @@ Bs.o: ../../src/Renderer//Bs.cpp ../../src/Renderer//Renderer.h \
  ../../src/Resources/Texture.h ../../src/Resources/Mesh.h \
  ../../src/Renderer/Vbo.h ../../src/Resources/Resource.h \
  ../../src/Renderer//Fbo.h ../../src/Scene/MeshNode.h \
- ../../src/Resources/Material.h ../../src/Resources/ShaderProg.h
+ ../../src/Resources/Material.h ../../src/Resources/ShaderProg.h \
+ ../../src/Util/App.h
 	@echo Compiling ../../src/Renderer//Bs.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/Renderer//Bs.cpp -o Bs.o
 
@@ -328,14 +339,16 @@ IsShadows.o: ../../src/Renderer//IsShadows.cpp \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/ShaderProg.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/ShaderProg.h \
  ../../src/Resources/Resource.h ../../src/Util/Util.h \
  ../../src/Util/Common.h ../../src/Scene/Camera.h \
  ../../src/Misc/collision.h ../../src/Scene/Node.h \
  ../../src/Resources/Texture.h ../../src/Scene/Scene.h \
  ../../src/Misc/skybox.h ../../src/Resources/Resource.h \
  ../../src/Renderer//Fbo.h ../../src/Resources/Material.h \
- ../../src/Resources/ShaderProg.h ../../src/Scene/MeshNode.h
+ ../../src/Resources/ShaderProg.h ../../src/Scene/MeshNode.h \
+ ../../src/Util/App.h
 	@echo Compiling ../../src/Renderer//IsShadows.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/Renderer//IsShadows.cpp -o IsShadows.o
 
@@ -351,7 +364,8 @@ MsEarlyz.o: ../../src/Renderer//MsEarlyz.cpp \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/ShaderProg.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/ShaderProg.h \
  ../../src/Resources/Resource.h ../../src/Util/Util.h \
  ../../src/Util/Common.h ../../src/Scene/Camera.h \
  ../../src/Misc/collision.h ../../src/Scene/Node.h \
@@ -373,7 +387,8 @@ Renderer.o: ../../src/Renderer//Renderer.cpp \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/ShaderProg.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/ShaderProg.h \
  ../../src/Resources/Resource.h ../../src/Util/Util.h \
  ../../src/Util/Common.h ../../src/Scene/Camera.h \
  ../../src/Misc/collision.h ../../src/Scene/Node.h \
@@ -393,7 +408,8 @@ Is.o: ../../src/Renderer//Is.cpp ../../src/Renderer//Renderer.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/ShaderProg.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/ShaderProg.h \
  ../../src/Resources/Resource.h ../../src/Util/Util.h \
  ../../src/Util/Common.h ../../src/Scene/Camera.h \
  ../../src/Misc/collision.h ../../src/Scene/Node.h \
@@ -401,7 +417,8 @@ Is.o: ../../src/Renderer//Is.cpp ../../src/Renderer//Renderer.h \
  ../../src/Resources/Texture.h ../../src/Resources/Mesh.h \
  ../../src/Renderer/Vbo.h ../../src/Scene/Light.h \
  ../../src/Scene/Camera.h ../../src/Resources/Resource.h \
- ../../src/Renderer//Fbo.h ../../src/Resources/LightProps.h
+ ../../src/Renderer//Fbo.h ../../src/Resources/LightProps.h \
+ ../../src/Util/App.h
 	@echo Compiling ../../src/Renderer//Is.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/Renderer//Is.cpp -o Is.o
 
@@ -417,13 +434,14 @@ PpsLscatt.o: ../../src/Renderer//PpsLscatt.cpp \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/ShaderProg.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/ShaderProg.h \
  ../../src/Resources/Resource.h ../../src/Util/Util.h \
  ../../src/Util/Common.h ../../src/Scene/Camera.h \
  ../../src/Misc/collision.h ../../src/Scene/Node.h \
  ../../src/Resources/Resource.h ../../src/Resources/Texture.h \
  ../../src/Scene/Scene.h ../../src/Misc/skybox.h \
- ../../src/Renderer//Fbo.h
+ ../../src/Renderer//Fbo.h ../../src/Util/App.h
 	@echo Compiling ../../src/Renderer//PpsLscatt.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/Renderer//PpsLscatt.cpp -o PpsLscatt.o
 
@@ -438,7 +456,8 @@ Ms.o: ../../src/Renderer//Ms.cpp ../../src/Renderer//Renderer.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/ShaderProg.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/ShaderProg.h \
  ../../src/Resources/Resource.h ../../src/Util/Util.h \
  ../../src/Util/Common.h ../../src/Scene/Camera.h \
  ../../src/Misc/collision.h ../../src/Scene/Node.h \
@@ -446,7 +465,7 @@ Ms.o: ../../src/Renderer//Ms.cpp ../../src/Renderer//Renderer.h \
  ../../src/Resources/Texture.h ../../src/Resources/Mesh.h \
  ../../src/Renderer/Vbo.h ../../src/Renderer//Fbo.h \
  ../../src/Resources/Material.h ../../src/Resources/ShaderProg.h \
- ../../src/Scene/MeshNode.h
+ ../../src/Scene/MeshNode.h ../../src/Util/App.h
 	@echo Compiling ../../src/Renderer//Ms.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/Renderer//Ms.cpp -o Ms.o
 
@@ -471,7 +490,8 @@ BulletDebuger.o: ../../src/Renderer//BulletDebuger.cpp \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/ShaderProg.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/ShaderProg.h \
  ../../src/Resources/Resource.h ../../src/Util/Util.h \
  ../../src/Util/Common.h ../../src/Scene/Camera.h \
  ../../src/Misc/collision.h ../../src/Scene/Node.h
@@ -489,7 +509,8 @@ Bs2.o: ../../src/Renderer//Bs2.cpp ../../src/Renderer//Renderer.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/ShaderProg.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/ShaderProg.h \
  ../../src/Resources/Resource.h ../../src/Util/Util.h \
  ../../src/Util/Common.h ../../src/Scene/Camera.h \
  ../../src/Misc/collision.h ../../src/Scene/Node.h \
@@ -497,7 +518,8 @@ Bs2.o: ../../src/Renderer//Bs2.cpp ../../src/Renderer//Renderer.h \
  ../../src/Resources/Texture.h ../../src/Resources/Mesh.h \
  ../../src/Renderer/Vbo.h ../../src/Resources/Resource.h \
  ../../src/Renderer//Fbo.h ../../src/Scene/MeshNode.h \
- ../../src/Resources/Material.h ../../src/Resources/ShaderProg.h
+ ../../src/Resources/Material.h ../../src/Resources/ShaderProg.h \
+ ../../src/Util/App.h
 	@echo Compiling ../../src/Renderer//Bs2.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/Renderer//Bs2.cpp -o Bs2.o
 
@@ -512,7 +534,8 @@ PpsSsao.o: ../../src/Renderer//PpsSsao.cpp ../../src/Renderer//Renderer.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/ShaderProg.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/ShaderProg.h \
  ../../src/Resources/Resource.h ../../src/Util/Util.h \
  ../../src/Util/Common.h ../../src/Scene/Camera.h \
  ../../src/Misc/collision.h ../../src/Scene/Node.h \
@@ -533,14 +556,15 @@ Dbg.o: ../../src/Renderer//Dbg.cpp ../../src/Renderer//Renderer.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/ShaderProg.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/ShaderProg.h \
  ../../src/Resources/Resource.h ../../src/Util/Util.h \
  ../../src/Util/Common.h ../../src/Scene/Camera.h \
  ../../src/Misc/collision.h ../../src/Scene/Node.h \
  ../../src/Renderer//Fbo.h ../../src/Scene/Scene.h \
  ../../src/Misc/skybox.h ../../src/Resources/Texture.h \
  ../../src/Scene/Node.h ../../src/Scene/SkelNode.h \
- ../../src/Controllers/Controller.h \
+ ../../src/Controllers/Controller.h ../../src/Util/App.h \
  ../../../bullet_svn/src/btBulletCollisionCommon.h \
  ../../../bullet_svn/src/BulletCollision/CollisionDispatch/btCollisionWorld.h \
  ../../../bullet_svn/src/LinearMath/btVector3.h \
@@ -685,7 +709,8 @@ MeshNode.o: ../../src/Scene//MeshNode.cpp ../../src/Scene//MeshNode.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/Material.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/Material.h \
  ../../src/Resources/Resource.h ../../src/Util/Util.h \
  ../../src/Util/Common.h ../../src/Resources/ShaderProg.h \
  ../../src/Resources/Resource.h ../../src/Resources/Mesh.h \
@@ -710,7 +735,8 @@ SkelNode.o: ../../src/Scene//SkelNode.cpp ../../src/Scene//SkelNode.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Controllers/Controller.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Controllers/Controller.h \
  ../../src/Renderer/Renderer.h ../../src/Resources/ShaderProg.h \
  ../../src/Resources/Resource.h ../../src/Util/Util.h \
  ../../src/Util/Common.h ../../src/Scene/Camera.h \
@@ -731,11 +757,14 @@ Node.o: ../../src/Scene//Node.cpp ../../src/Scene//Node.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Renderer/Renderer.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Renderer/Renderer.h \
  ../../src/Resources/ShaderProg.h ../../src/Resources/Resource.h \
  ../../src/Util/Util.h ../../src/Util/Common.h ../../src/Scene/Camera.h \
  ../../src/Misc/collision.h ../../src/Scene/Node.h \
- ../../src/Controllers/Controller.h
+ ../../src/Controllers/Controller.h ../../src/Scene//Scene.h \
+ ../../src/Misc/skybox.h ../../src/Resources/Texture.h \
+ ../../src/Util/App.h
 	@echo Compiling ../../src/Scene//Node.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/Scene//Node.cpp -o Node.o
 
@@ -752,7 +781,8 @@ SkelModelNode.o: ../../src/Scene//SkelModelNode.cpp \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/Material.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/Material.h \
  ../../src/Resources/Resource.h ../../src/Util/Util.h \
  ../../src/Util/Common.h ../../src/Resources/ShaderProg.h \
  ../../src/Tokenizer/Parser.h ../../src/Tokenizer/Scanner.h \
@@ -776,7 +806,8 @@ Light.o: ../../src/Scene//Light.cpp ../../src/Scene//Light.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Scene//Camera.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Scene//Camera.h \
  ../../src/Misc/collision.h ../../src/Renderer/Renderer.h \
  ../../src/Resources/ShaderProg.h ../../src/Scene/Camera.h \
  ../../src/Resources/LightProps.h
@@ -795,7 +826,8 @@ Camera.o: ../../src/Scene//Camera.cpp ../../src/Scene//Camera.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Scene//Node.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Scene//Node.h \
  ../../src/Renderer/Renderer.h ../../src/Resources/ShaderProg.h \
  ../../src/Resources/Resource.h ../../src/Util/Util.h \
  ../../src/Util/Common.h ../../src/Scene/Camera.h
@@ -815,7 +847,8 @@ Scene.o: ../../src/Scene//Scene.cpp ../../src/Scene//Scene.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Scene//SkelNode.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Scene//SkelNode.h \
  ../../src/Scene//Node.h ../../src/Controllers/Controller.h \
  ../../src/Scene//Camera.h ../../src/Misc/collision.h \
  ../../src/Scene//MeshNode.h ../../src/Resources/Material.h \
@@ -835,7 +868,8 @@ Ui.o: ../../src/Ui//Ui.cpp ../../src/Ui//Ui.h ../../src/Util/Common.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/ShaderProg.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/ShaderProg.h \
  ../../src/Resources/Resource.h ../../src/Util/Util.h \
  ../../src/Util/Common.h ../../src/Scene/Camera.h \
  ../../src/Misc/collision.h ../../src/Scene/Node.h \
@@ -855,7 +889,8 @@ Material.o: ../../src/Resources//Material.cpp \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources//Resource.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources//Resource.h \
  ../../src/Util/Util.h ../../src/Util/Common.h \
  ../../src/Resources//ShaderProg.h ../../src/Tokenizer/Scanner.h \
  ../../src/Tokenizer/Parser.h ../../src/Tokenizer/Scanner.h \
@@ -879,7 +914,8 @@ ShaderProg.o: ../../src/Resources//ShaderProg.cpp \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/ShaderProg.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/ShaderProg.h \
  ../../src/Scene/Camera.h ../../src/Misc/collision.h \
  ../../src/Scene/Node.h ../../src/Resources//ShaderPrePreprocessor.h \
  ../../src/Resources//Texture.h
@@ -900,7 +936,8 @@ Texture.o: ../../src/Resources//Texture.cpp \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/ShaderProg.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/ShaderProg.h \
  ../../src/Resources/Resource.h ../../src/Scene/Camera.h \
  ../../src/Misc/collision.h ../../src/Scene/Node.h
 	@echo Compiling ../../src/Resources//Texture.cpp...
@@ -919,7 +956,8 @@ SkelAnim.o: ../../src/Resources//SkelAnim.cpp \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Tokenizer/Scanner.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Tokenizer/Scanner.h \
  ../../src/Tokenizer/Parser.h ../../src/Tokenizer/Scanner.h
 	@echo Compiling ../../src/Resources//SkelAnim.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/Resources//SkelAnim.cpp -o SkelAnim.o
@@ -943,7 +981,8 @@ Skeleton.o: ../../src/Resources//Skeleton.cpp \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources//Resource.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources//Resource.h \
  ../../src/Util/Util.h ../../src/Util/Common.h \
  ../../src/Tokenizer/Scanner.h ../../src/Tokenizer/Parser.h \
  ../../src/Tokenizer/Scanner.h
@@ -964,7 +1003,8 @@ Resource.o: ../../src/Resources//Resource.cpp \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources//ShaderProg.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources//ShaderProg.h \
  ../../src/Resources//Mesh.h ../../src/Renderer/Vbo.h \
  ../../src/Misc/collision.h ../../src/Resources//SkelAnim.h \
  ../../src/Resources//LightProps.h
@@ -984,7 +1024,8 @@ LightProps.o: ../../src/Resources//LightProps.cpp \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Tokenizer/Parser.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Tokenizer/Parser.h \
  ../../src/Tokenizer/Scanner.h ../../src/Resources//Texture.h
 	@echo Compiling ../../src/Resources//LightProps.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/Resources//LightProps.cpp -o LightProps.o
@@ -1000,7 +1041,8 @@ Mesh.o: ../../src/Resources//Mesh.cpp ../../src/Resources//Mesh.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Renderer/Vbo.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Renderer/Vbo.h \
  ../../src/Resources//Resource.h ../../src/Util/Util.h \
  ../../src/Util/Common.h ../../src/Misc/collision.h \
  ../../src/Renderer/Renderer.h ../../src/Resources/ShaderProg.h \
@@ -1030,7 +1072,8 @@ Input.o: ../../src/Util//Input.cpp ../../src/Util//Input.h \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Renderer/Renderer.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Renderer/Renderer.h \
  ../../src/Resources/ShaderProg.h ../../src/Resources/Resource.h \
  ../../src/Util/Util.h ../../src/Util/Common.h ../../src/Scene/Camera.h \
  ../../src/Misc/collision.h ../../src/Scene/Node.h
@@ -1065,7 +1108,8 @@ Controller.o: ../../src/Controllers//Controller.cpp \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Util/App.h
 	@echo Compiling ../../src/Controllers//Controller.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/Controllers//Controller.cpp -o Controller.o
 
@@ -1082,7 +1126,8 @@ SkelAnimCtrl.o: ../../src/Controllers//SkelAnimCtrl.cpp \
  ../../src/Math/Euler.inl.h ../../src/Math/Mat3.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
- ../../src/Math/MathFuncs.inl.h ../../src/Resources/SkelAnim.h \
+ ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
+ ../../src/Math/Transform.inl.h ../../src/Resources/SkelAnim.h \
  ../../src/Resources/Resource.h ../../src/Util/Util.h \
  ../../src/Util/Common.h ../../src/Scene/SkelNode.h \
  ../../src/Scene/Node.h ../../src/Controllers/Controller.h \

+ 1 - 1
build/debug/gen.cfg.py

@@ -1,4 +1,4 @@
-source_paths = [ "../../src/Math/", "../../src/Tokenizer/", "../../src/Misc/", "../../src/", "../../src/Renderer/", "../../src/Scene/", "../../src/Ui/", "../../src/Resources/", "../../src/Util/", "../../src/Controllers/" ]
+source_paths = [ "../../src/Math/", "../../src/Tokenizer/", "../../src/Misc/", "../../src/", "../../src/Renderer/", "../../src/Scene/", "../../src/Ui/", "../../src/Resources/", "../../src/Util/", "../../src/Controllers/", "../../src/Physics/" ]
 
 include_paths = list(source_paths)
 include_paths.extend( [ "../../../bullet_svn/src/" ] ) # the bullet svn path

+ 5 - 2
src/Controllers/Controller.cpp

@@ -1,13 +1,16 @@
 #include "Controller.h"
 #include "Scene.h"
+#include "App.h"
 
 Controller::Controller( Type type_ ): 
 	type(type_) 
 {
-	Scene::registerController( this );
+	DEBUG_ERR( app->scene == NULL );
+	app->scene->registerController( this );
 }
 
 Controller::~Controller()
 {
-	Scene::unregisterController( this );
+	DEBUG_ERR( app->scene == NULL );
+	app->scene->unregisterController( this );
 }

+ 19 - 72
src/Main.cpp

@@ -29,10 +29,12 @@
 #include "SkelAnimCtrl.h"
 #include "SkelNode.h"
 #include "LightProps.h"
-#include "btBulletCollisionCommon.h"
-#include "btBulletDynamicsCommon.h"
+#include <btBulletCollisionCommon.h>
+#include <btBulletDynamicsCommon.h>
 #include "BulletDebuger.h"
+#include "MotionState.h"
 
+App* app;
 
 // map (hard coded)
 Camera* mainCam;
@@ -64,9 +66,9 @@ btSequentialImpulseConstraintSolver* sol;
 btDiscreteDynamicsWorld* dynamicsWorld;
 BulletDebuger debugDrawer;
 
-#define ARRAY_SIZE_X 5
-#define ARRAY_SIZE_Y 5
-#define ARRAY_SIZE_Z 5
+#define ARRAY_SIZE_X 1
+#define ARRAY_SIZE_Y 1
+#define ARRAY_SIZE_Z 1
 
 #define MAX_PROXIES (ARRAY_SIZE_X*ARRAY_SIZE_Y*ARRAY_SIZE_Z + 1024)
 
@@ -146,7 +148,7 @@ void initPhysics()
 
 
 					//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
-					btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
+					MotionState* myMotionState = new MotionState(startTransform, floor__);
 					btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,colShape,localInertia);
 					btRigidBody* body = new btRigidBody(rbInfo);
 
@@ -177,11 +179,13 @@ void init()
 	srand( unsigned(time(NULL)) );
 	mathSanityChecks();
 
-	App::initWindow();
-	uint ticks = App::getTicks();
+	app = new App;
+	app->initWindow();
+	uint ticks = app->getTicks();
 
 	R::init();
 	Ui::init();
+	app->scene = new Scene;
 
 	// camera
 	mainCam = new Camera( R::aspectRatio*toRad(60.0), toRad(60.0), 0.5, 200.0 );
@@ -239,70 +243,13 @@ void init()
 
 	const char* skybox_fnames [] = { "textures/env/hellsky4_forward.tga", "textures/env/hellsky4_back.tga", "textures/env/hellsky4_left.tga",
 																	 "textures/env/hellsky4_right.tga", "textures/env/hellsky4_up.tga", "textures/env/hellsky4_down.tga" };
-	Scene::skybox.load( skybox_fnames );
+	app->scene->skybox.load( skybox_fnames );
 
 	PRINT( "Engine initialization ends (" << App::getTicks()-ticks << ")" );
 	cerr.flush();
 }
 
 
-Vec3 toAnki( const btVector3& v )
-{
-	return Vec3( v.x(), v.y(), v.z() );
-}
-
-Vec4 toAnki( const btVector4& v )
-{
-	return Vec4( v.x(), v.y(), v.z(), v.w() );
-}
-
-Mat3 toAnki( const btMatrix3x3& m )
-{
-	Mat3 m3;
-	m3.setRows( toAnki(m[0]), toAnki(m[1]), toAnki(m[2]) );
-	return m3;
-}
-
-Quat toAnki( const btQuaternion& q )
-{
-	return Quat( q.x(), q.y(), q.z(), q.w() );
-}
-
-Mat4 toAnki( const btTransform& t )
-{
-	Mat4 m;
-	t.getOpenGLMatrix( &m[0] );
-	m.transpose();
-	return m;
-}
-
-btVector3 toBt( const Vec3& v )
-{
-	return btVector3( v.x,  v.y, v.z );
-}
-
-btVector4 toBt( const Vec4& v )
-{
-	return btVector4( v.x,  v.y, v.z, v.w );
-}
-
-btMatrix3x3 toBt( const Mat3 m )
-{
-	btMatrix3x3 r;
-	r[0] = toBt(m.getRow(0));
-	r[1] = toBt(m.getRow(1));
-	r[2] = toBt(m.getRow(2));
-	return r;
-}
-
-btTransform toBt( const Mat4& m )
-{
-	btTransform r;
-	r.setFromOpenGLMatrix( &(m.getTransposed())[0] );
-	return r;
-}
-
-
 
 //=====================================================================================================================================
 // main                                                                                                                               =
@@ -364,11 +311,11 @@ int main( int /*argc*/, char* /*argv*/[] )
 		mover->rotationLspace.reorthogonalize();
 
 
-		Scene::updateAllControllers();
-		Scene::updateAllWorldStuff();
+		app->scene->updateAllControllers();
+		app->scene->updateAllWorldStuff();
 
 
-		dynamicsWorld->stepSimulation( App::timerTick );
+		dynamicsWorld->stepSimulation( app->timerTick );
 		dynamicsWorld->debugDrawWorld();
 
 		R::render( *mainCam );
@@ -385,7 +332,7 @@ int main( int /*argc*/, char* /*argv*/[] )
 								 toDegrees(Euler(mover->rotationWspace).x), toDegrees(Euler(mover->rotationWspace).y), toDegrees(Euler(mover->rotationWspace).z) );
 
 		if( I::keys[SDLK_ESCAPE] ) break;
-		if( I::keys[SDLK_F11] ) App::togleFullScreen();
+		if( I::keys[SDLK_F11] ) app->togleFullScreen();
 		if( I::keys[SDLK_F12] == 1 ) R::takeScreenshot("gfx/screenshot.jpg");
 
 		/*char str[128];
@@ -401,7 +348,7 @@ int main( int /*argc*/, char* /*argv*/[] )
 		if( 1 )
 		{
 			//if( R::framesNum == 10 ) R::takeScreenshot("gfx/screenshot.tga");
-			App::waitForNextFrame();
+			app->waitForNextFrame();
 		}
 		else
 			if( R::framesNum == 5000 ) break;
@@ -410,6 +357,6 @@ int main( int /*argc*/, char* /*argv*/[] )
 
 
 	PRINT( "Exiting..." );
-	App::quitApp( EXIT_SUCCESS );
+	app->quitApp( EXIT_SUCCESS );
 	return 0;
 }

+ 1 - 1
src/Math/Mat3.h

@@ -38,7 +38,7 @@ class Mat3
 		Mat3& operator +=( const Mat3& b );
 		Mat3  operator - ( const Mat3& b ) const;
 		Mat3& operator -=( const Mat3& b );
-		Mat3  operator * ( const Mat3& b ) const; // 27 muls, 18 adds
+		Mat3  operator * ( const Mat3& b ) const; ///< 27 muls, 18 adds
 		Mat3& operator *=( const Mat3& b );
 		Mat3  operator / ( const Mat3& b ) const;
 		Mat3& operator /=( const Mat3& b );

+ 1 - 1
src/Math/Mat3.inl.h

@@ -80,7 +80,7 @@ inline Mat3::Mat3( const Quat& q )
 	ME(0,2) = xz + wy;
 
 	ME(1,0) = xy + wz;
-	ME(1,1) = 1.0f - (xx + zz);
+	ME(1,1) = 1.0 - (xx + zz);
 	ME(1,2) = yz - wx;
 
 	ME(2,0) = xz - wy;

+ 1 - 0
src/Math/Mat4.h

@@ -34,6 +34,7 @@ class Mat4
 		explicit Mat4( const Vec4& v );
 		explicit Mat4( const Vec3& transl, const Mat3& rot );
 		explicit Mat4( const Vec3& transl, const Mat3& rot, float scale );
+		explicit Mat4( const Transform& t );
 		// ops with same type
 		Mat4  operator + ( const Mat4& b ) const;
 		Mat4& operator +=( const Mat4& b );

+ 6 - 0
src/Math/Mat4.inl.h

@@ -150,6 +150,12 @@ inline Mat4::Mat4( float f )
 		ME[i] = f;
 }
 
+// constructor [Transform]
+inline Mat4::Mat4( const Transform& t )
+{
+	ME = Mat4( t.getOrigin(), Mat3(t.getRotation()) );
+}
+
 // 4x4 + 4x4
 inline Mat4 Mat4::operator +( const Mat4& b ) const
 {

+ 1 - 0
src/Math/Math.h

@@ -12,6 +12,7 @@
 #include "Mat3.h"
 #include "Mat4.h"
 #include "MathFuncs.h"
+#include "Transform.h"
 
 using namespace M;
 

+ 1 - 0
src/Math/MathDfltHeader.h

@@ -7,3 +7,4 @@
 #include "Mat3.h"
 #include "Mat4.h"
 #include "MathFuncs.h"
+#include "Transform.h"

+ 1 - 0
src/Math/MathForwardDecls.h

@@ -10,6 +10,7 @@ namespace M {
 	class Axisang;
 	class Mat3;
 	class Mat4;
+	class Transform;
 }
 
 #endif

+ 3 - 3
src/Math/Quat.h

@@ -27,7 +27,7 @@ class Quat
 		explicit Quat( const Euler& eu );
 		explicit Quat( const Axisang& axisang );
 		// ops with same
-		Quat  operator * ( const Quat& b ) const;
+		Quat  operator * ( const Quat& b ) const; ///< 16 muls, 12 adds
 		Quat& operator *=( const Quat& b );
 		// comparision
 		bool operator ==( const Quat& b ) const;
@@ -43,8 +43,8 @@ class Quat
 		void  print() const;
 		float dot( const Quat& b ) const;
 		Quat  slerp( const Quat& q1, float t ) const; ///< returns slerp( this, q1, t )
-		Quat  getRotated( const Quat& b ) const;
-		void  rotate( const Quat& b );
+		Quat  getRotated( const Quat& b ) const; ///< The same as Quat * Quat
+		void  rotate( const Quat& b ); ///< @see getRotated
 };
 
 

+ 29 - 0
src/Math/Transform.h

@@ -0,0 +1,29 @@
+#ifndef _TRANSFORM_H_
+#define _TRANSFORM_H_
+
+#include "Common.h"
+#include "MathForwardDecls.h"
+
+
+namespace M {
+
+
+class Transform
+{
+	PROPERTY_RW( Quat, rotation, setRotation, getRotation );
+	PROPERTY_RW( Vec3, translation, setOrigin, getOrigin );
+
+	public:
+		explicit Transform();
+		         Transform( const Transform& b );
+		explicit Transform( const Mat4& m4 );
+};
+
+
+} // end namespace
+
+
+#include "Transform.inl.h"
+
+
+#endif

+ 27 - 0
src/Math/Transform.inl.h

@@ -0,0 +1,27 @@
+#include "MathDfltHeader.h"
+
+
+#define ME (*this)
+
+
+namespace M {
+
+
+// constructor []
+inline Transform::Transform()
+{}
+
+// constructor [Transform]
+inline Transform::Transform( const Transform& b ):
+	rotation(b.rotation), translation(b.translation)
+{}
+
+// constructor [Mat4]
+inline Transform::Transform( const Mat4& m4 )
+{
+	rotation = Quat( m4.getRotationPart() );
+	translation = m4.getTranslationPart();
+}
+
+
+} // end namespace

+ 2 - 1
src/Misc/skybox.cpp

@@ -4,6 +4,7 @@
 #include "Math.h"
 #include "Camera.h"
 #include "Scene.h"
+#include "App.h"
 
 
 static float coords [][4][3] =
@@ -62,7 +63,7 @@ void Skybox::Render( const Mat3& rotation )
 	glUniform1i( shader->getUniVar("colormap").getLoc(), 0 );
 	shader->locTexUnit( shader->getUniVar("noisemap").getLoc(), *noise, 1 );
 	glUniform1f( shader->getUniVar("timer").getLoc(), (rotation_ang/(2*PI))*100 );
-	glUniform3fv( shader->getUniVar("sceneAmbientCol").getLoc(), 1, &(Vec3( 1.0, 1.0, 1.0 ) / Scene::getAmbientColor())[0] );
+	glUniform3fv( shader->getUniVar("sceneAmbientCol").getLoc(), 1, &(Vec3( 1.0, 1.0, 1.0 ) / app->scene->getAmbientCol())[0] );
 
 	// set the rotation matrix
 	Mat3 tmp( rotation );

+ 41 - 0
src/Physics/MotionState.h

@@ -0,0 +1,41 @@
+#ifndef _MOTIONSTATE_H_
+#define _MOTIONSTATE_H_
+
+#include "Common.h"
+#include "PhyCommon.h"
+#include "Node.h"
+
+
+/**
+ *
+ */
+class MotionState: public btMotionState
+{
+	protected:
+		btTransform mPos1;
+		Node* node;
+
+	public:
+		MotionState( const btTransform& initialPos, Node* node_ ):
+			mPos1( initialPos ),
+			node( node_ )
+		{}
+
+		virtual ~MotionState()
+		{}
+
+		virtual void getWorldTransform( btTransform &worldTrans ) const
+		{
+			worldTrans = mPos1;
+		}
+
+		virtual void setWorldTransform( const btTransform &worldTrans )
+		{
+			btQuaternion rot = worldTrans.getRotation();
+			node->rotationLspace = Mat3( Quat( toAnki(rot) ) );
+			btVector3 pos = worldTrans.getOrigin();
+			node->translationLspace = Vec3( toAnki(pos) );
+		}
+};
+
+#endif

+ 71 - 0
src/Physics/PhyCommon.h

@@ -0,0 +1,71 @@
+#ifndef _PHYCOMMON_H_
+#define _PHYCOMMON_H_
+
+#include <btBulletCollisionCommon.h>
+#include <btBulletDynamicsCommon.h>
+#include "Common.h"
+#include "Math.h"
+#include "MotionState.h"
+
+
+
+//=====================================================================================================================================
+// CONVERSIONS FROM BULLET MATH TO ANKI AND THE OPPOSITE                                                                              =
+//=====================================================================================================================================
+inline Vec3 toAnki( const btVector3& v )
+{
+	return Vec3( v.x(), v.y(), v.z() );
+}
+
+inline Vec4 toAnki( const btVector4& v )
+{
+	return Vec4( v.x(), v.y(), v.z(), v.w() );
+}
+
+inline Mat3 toAnki( const btMatrix3x3& m )
+{
+	Mat3 m3;
+	m3.setRows( toAnki(m[0]), toAnki(m[1]), toAnki(m[2]) );
+	return m3;
+}
+
+inline Quat toAnki( const btQuaternion& q )
+{
+	return Quat( q.x(), q.y(), q.z(), q.w() );
+}
+
+inline Mat4 toAnki( const btTransform& t )
+{
+	Mat4 m;
+	t.getOpenGLMatrix( &m[0] );
+	m.transpose();
+	return m;
+}
+
+inline btVector3 toBt( const Vec3& v )
+{
+	return btVector3( v.x,  v.y, v.z );
+}
+
+inline btVector4 toBt( const Vec4& v )
+{
+	return btVector4( v.x,  v.y, v.z, v.w );
+}
+
+inline btMatrix3x3 toBt( const Mat3 m )
+{
+	btMatrix3x3 r;
+	r[0] = toBt(m.getRow(0));
+	r[1] = toBt(m.getRow(1));
+	r[2] = toBt(m.getRow(2));
+	return r;
+}
+
+inline btTransform toBt( const Mat4& m )
+{
+	btTransform r;
+	r.setFromOpenGLMatrix( &(m.getTransposed())[0] );
+	return r;
+}
+
+#endif

+ 6 - 5
src/Renderer/Bs.cpp

@@ -11,6 +11,7 @@
 #include "Fbo.h"
 #include "MeshNode.h"
 #include "Material.h"
+#include "App.h"
 
 
 namespace R {
@@ -62,14 +63,14 @@ void runStage( const Camera& cam )
 
 
 	// render the meshes
-	for( uint i=0; i<Scene::meshNodes.size(); i++ )
+	for( uint i=0; i<app->scene->meshNodes.size(); i++ )
 	{
-		MeshNode* mesh_node = Scene::meshNodes[i];
-		if( mesh_node->material->blends && !mesh_node->material->blends )
+		MeshNode* meshNode = app->scene->meshNodes[i];
+		if( meshNode->material->blends && !meshNode->material->blends )
 		{
 			fbo.bind();
-			mesh_node->material->setup();
-			mesh_node->render();
+			meshNode->material->setup();
+			meshNode->render();
 		}
 
 	}

+ 3 - 2
src/Renderer/Bs2.cpp

@@ -11,6 +11,7 @@
 #include "Fbo.h"
 #include "MeshNode.h"
 #include "Material.h"
+#include "App.h"
 
 
 namespace R {
@@ -86,9 +87,9 @@ void runStage2( const Camera& cam )
 
 
 	// render the meshes
-	for( uint i=0; i<Scene::meshNodes.size(); i++ )
+	for( uint i=0; i<app->scene->meshNodes.size(); i++ )
 	{
-		MeshNode* mesh_node = Scene::meshNodes[i];
+		MeshNode* mesh_node = app->scene->meshNodes[i];
 		if( mesh_node->material->refracts )
 		{
 			// write to the rFbo

+ 9 - 8
src/Renderer/Dbg.cpp

@@ -5,6 +5,7 @@
 #include "Fbo.h"
 #include "Node.h"
 #include "SkelNode.h"
+#include "App.h"
 
 
 #include "btBulletCollisionCommon.h"
@@ -130,19 +131,19 @@ void runStage( const Camera& cam )
 	glDisable( GL_BLEND );
 
 	//R::renderGrid();
-	for( uint i=0; i<Scene::nodes.size(); i++ )
+	for( uint i=0; i<app->scene->nodes.size(); i++ )
 	{
 		if
 		(
-			(Scene::nodes[i]->type == Node::NT_LIGHT && showLights) ||
-			(Scene::nodes[i]->type == Node::NT_CAMERA && showCameras)
+			(app->scene->nodes[i]->type == Node::NT_LIGHT && showLights) ||
+			(app->scene->nodes[i]->type == Node::NT_CAMERA && showCameras)
 		)
 		{
-			Scene::nodes[i]->render();
+			app->scene->nodes[i]->render();
 		}
-		else if( Scene::nodes[i]->type == Node::NT_SKELETON && showSkeletons )
+		else if( app->scene->nodes[i]->type == Node::NT_SKELETON && showSkeletons )
 		{
-			SkelNode* skel_node = static_cast<SkelNode*>( Scene::nodes[i] );
+			SkelNode* skel_node = static_cast<SkelNode*>( app->scene->nodes[i] );
 			glDisable( GL_DEPTH_TEST );
 			skel_node->render();
 			glEnable( GL_DEPTH_TEST );
@@ -354,7 +355,7 @@ static void renderSun()
 {
 	glPushMatrix();
 
-	R::multMatrix( Mat4( Scene::getSunPos(), Mat3::getIdentity(), 50.0 ) );
+	R::multMatrix( Mat4( app->scene->getSunPos(), Mat3::getIdentity(), 50.0 ) );
 
 	R::color3( Vec3(1.0, 1.0, 0.0) );
 	R::Dbg::renderSphere( 1.0/8.0, 8 );
@@ -372,7 +373,7 @@ static void renderSun()
 	glLoadIdentity();
 
 
-	Vec4 p = Vec4( Scene::getSunPos(), 1.0 );
+	Vec4 p = Vec4( app->scene->getSunPos(), 1.0 );
 	p = mainCam->getProjectionMatrix() * (mainCam->getViewMatrix() * p);
 	p /= p.w;
 	p = p/2 + 0.5;

+ 4 - 3
src/Renderer/Is.cpp

@@ -11,6 +11,7 @@ The file contains functions and vars used for the deferred shading illumination
 #include "Scene.h"
 #include "Fbo.h"
 #include "LightProps.h"
+#include "App.h"
 
 namespace R {
 namespace Is {
@@ -531,7 +532,7 @@ void runStage( const Camera& cam )
 	glDisable( GL_DEPTH_TEST );
 
 	// ambient pass
-	ambientPass( cam, Scene::getAmbientColor() );
+	ambientPass( cam, app->scene->getAmbientCol() );
 
 	// light passes
 	glEnable( GL_BLEND );
@@ -541,9 +542,9 @@ void runStage( const Camera& cam )
 	CalcPlanes( cam );
 
 	// for all lights
-	for( uint i=0; i<Scene::lights.size(); i++ )
+	for( uint i=0; i<app->scene->lights.size(); i++ )
 	{
-		const Light& light = *Scene::lights[i];
+		const Light& light = *app->scene->lights[i];
 		switch( light.type )
 		{
 			case Light::LT_POINT:

+ 3 - 2
src/Renderer/IsShadows.cpp

@@ -5,6 +5,7 @@
 #include "Fbo.h"
 #include "Material.h"
 #include "MeshNode.h"
+#include "App.h"
 
 namespace R {
 namespace Is {
@@ -95,9 +96,9 @@ void runPass( const Camera& cam )
 	glEnable( GL_POLYGON_OFFSET_FILL );
 
 	// render all meshes
-	for( uint i=0; i<Scene::meshNodes.size(); i++ )
+	for( uint i=0; i<app->scene->meshNodes.size(); i++ )
 	{
-		MeshNode* mesh_node = Scene::meshNodes[i];
+		MeshNode* mesh_node = app->scene->meshNodes[i];
 		if( mesh_node->material->blends || mesh_node->material->refracts ) continue;
 
 		DEBUG_ERR( mesh_node->material->dpMtl == NULL );

+ 4 - 3
src/Renderer/Ms.cpp

@@ -9,6 +9,7 @@
 #include "Fbo.h"
 #include "Material.h"
 #include "MeshNode.h"
+#include "App.h"
 
 
 namespace R {
@@ -93,7 +94,7 @@ void runStage( const Camera& cam )
 	R::setViewport( 0, 0, R::w, R::h );
 
 	//glEnable( GL_DEPTH_TEST );
-	Scene::skybox.Render( cam.getViewMatrix().getRotationPart() );
+	app->scene->skybox.Render( cam.getViewMatrix().getRotationPart() );
 	//glDepthFunc( GL_LEQUAL );
 
 	#if defined( _EARLY_Z_ )
@@ -102,9 +103,9 @@ void runStage( const Camera& cam )
 	#endif
 
 	// render the meshes
-	for( uint i=0; i<Scene::meshNodes.size(); i++ )
+	for( uint i=0; i<app->scene->meshNodes.size(); i++ )
 	{
-		MeshNode* mesh_node = Scene::meshNodes[i];
+		MeshNode* mesh_node = app->scene->meshNodes[i];
 		DEBUG_ERR( mesh_node->material == NULL );
 		if( mesh_node->material->blends || mesh_node->material->refracts ) continue;
 		mesh_node->material->setup();

+ 2 - 1
src/Renderer/PpsLscatt.cpp

@@ -3,6 +3,7 @@
 #include "Texture.h"
 #include "Scene.h"
 #include "Fbo.h"
+#include "App.h"
 
 namespace R {
 namespace Pps {
@@ -88,7 +89,7 @@ void runPass( const Camera& cam )
 	sProg.locTexUnit( isFaiUniLoc, R::Is::fai, 1 );
 
 	// pass the light
-	Vec4 p = Vec4( Scene::getSunPos(), 1.0 );
+	Vec4 p = Vec4( app->scene->getSunPos(), 1.0 );
 	p = cam.getProjectionMatrix() * (cam.getViewMatrix() * p);
 	p /= p.w;
 	p = p/2 + 0.5;

+ 3 - 3
src/Renderer/Renderer.cpp

@@ -128,8 +128,8 @@ void init()
 	if( !glewIsSupported("GL_ARB_vertex_buffer_object") )
 		WARNING( "Vertex Buffer Objects not supported. The application may crash (and burn)" );
 
-	w = App::windowW /* * renderingQuality*/;
-	h = App::windowH /* * renderingQuality*/;
+	w = app->windowW /* * renderingQuality*/;
+	h = app->windowH /* * renderingQuality*/;
 	aspectRatio = float(w)/h;
 
 	glClearColor( 0.1, 0.1, 0.1, 0.0 );
@@ -195,7 +195,7 @@ void render( const Camera& cam )
 	R::Dbg::runStage( cam );
 
 	//R::setViewport( 0, 0, App::windowW, App::windowH );
-	R::setViewport( 0, 0, App::windowW, App::windowH );
+	R::setViewport( 0, 0, app->windowW, app->windowH );
 
 	glDisable( GL_DEPTH_TEST );
 	glDisable( GL_BLEND );

+ 2 - 3
src/Resources/ShaderProg.cpp

@@ -8,7 +8,6 @@
 #define SHADER_WARNING( x ) WARNING( "Shader (" << getRsrcName() << "): " << x )
 
 
-
 //=====================================================================================================================================
 // createAndCompileShader                                                                                                             =
 //=====================================================================================================================================
@@ -123,7 +122,7 @@ void ShaderProg::getUniAndAttribVars()
 			continue;
 		}
 
-		attribVars.push_back( Var( loc, name_, type, Var::LT_ATTRIBUTE ) );
+		attribVars.push_back( Var( loc, name_, type, Var::SVT_ATTRIBUTE ) );
 		attribNameToVar[ name_ ] = &attribVars.back();
 	}
 
@@ -144,7 +143,7 @@ void ShaderProg::getUniAndAttribVars()
 			continue;
 		}
 
-		uniVars.push_back( Var( loc, name_, type, Var::LT_UNIFORM ) );
+		uniVars.push_back( Var( loc, name_, type, Var::SVT_UNIFORM ) );
 		uniNameToVar[ name_ ] = &uniVars.back();
 	}
 }

+ 4 - 4
src/Resources/ShaderProg.h

@@ -29,14 +29,14 @@ class ShaderProg: public Resource
 			PROPERTY_R( int, loc, getLoc );
 			PROPERTY_R( string, name, getName );
 			PROPERTY_R( GLenum, glDataType, getGlDataType ); ///< GL_FLOAT, GL_FLOAT_VEC2... etc
-			PROPERTY_R( uint, type, getType ); ///< LT_ATTRIBUTE or LT_UNIFORM
+			PROPERTY_R( uint, type, getType ); ///< SVT_ATTRIBUTE or SVT_UNIFORM
 
 			public:
 				enum
 				{
-					LT_ATTRIBUTE,
-					LT_UNIFORM
-				};
+					SVT_ATTRIBUTE,
+					SVT_UNIFORM
+				}; ///< Shader var types
 
 				Var( int loc_, const char* name_, GLenum glDataType_, uint type_ ):
 					loc(loc_), name(name_), glDataType(glDataType_), type(type_)

+ 7 - 8
src/Scene/Node.cpp

@@ -3,12 +3,8 @@
 #include "Renderer.h"
 #include "collision.h"
 #include "Controller.h"
-
-
-namespace Scene
-{
-	extern void registerNode( Node* );
-}
+#include "Scene.h"
+#include "App.h"
 
 
 //=====================================================================================================================================
@@ -17,7 +13,7 @@ namespace Scene
 void Node::commonConstructorCode()
 {
 	parent = NULL;
-	isGroupNode = false;
+	isCompound = false;
 	translationLspace = Vec3( 0.0 );
 	scaleLspace = 1.0;
 	rotationLspace = Mat3::getIdentity();
@@ -26,7 +22,8 @@ void Node::commonConstructorCode()
 	rotationWspace = Mat3::getIdentity();
 	bvolumeLspace = NULL;
 
-	Scene::registerNode( this );
+	DEBUG_ERR( app->scene == NULL );
+	app->scene->registerNode( this );
 }
 
 
@@ -35,6 +32,8 @@ void Node::commonConstructorCode()
 //=====================================================================================================================================
 Node::~Node()
 {
+	DEBUG_ERR( app->scene == NULL );
+	app->scene->unregisterNode( this );
 }
 
 

+ 7 - 7
src/Scene/Node.h

@@ -25,13 +25,13 @@ class Node
 			NT_SKEL_MODEL
 		};
 
-		Vec3 translationLspace;
-		Mat3 rotationLspace;
-		float  scaleLspace;
+		Vec3  translationLspace;
+		Mat3  rotationLspace;
+		float scaleLspace;
 
-		Vec3 translationWspace;
-		Mat3 rotationWspace;
-		float  scaleWspace;
+		Vec3  translationWspace;
+		Mat3  rotationWspace;
+		float scaleWspace;
 
 		Mat4 transformationWspace;
 
@@ -43,7 +43,7 @@ class Node
 		bvolume_t* bvolumeLspace;
 		bvolume_t* bvolumeWspace;
 
-		bool isGroupNode;
+		bool isCompound;
 
 	// funcs
 	private:

+ 20 - 54
src/Scene/Scene.cpp

@@ -7,61 +7,37 @@
 #include "Controller.h"
 #include "Material.h"
 
-namespace Scene {
-
-/*
-=======================================================================================================================================
-DATA                                                                                                                                  =
-=======================================================================================================================================
-*/
-Skybox skybox;
-
-NodeContainer     nodes;
-LightContainer    lights;
-CameraContainer   cameras;
-MeshContainer     meshNodes;
-SkelNodeContainer skelNodes;
-
-Vec<Controller*> controllers;
-
 
 //=====================================================================================================================================
-// Static template funcs                                                                                                              =
+// Constructor                                                                                                                        =
 //=====================================================================================================================================
-template<typename ContainerType, typename Type> static void PutBackNode( ContainerType& container, Type* x )
+Scene::Scene()
 {
-	DEBUG_ERR( std::find( container.begin(), container.end(), x ) != container.end() );
-	container.push_back( x );
-}
-
-template<typename ContainerType, typename Type> static void EraseNode( ContainerType& container, Type* x )
-{
-	typename ContainerType::iterator it = std::find( container.begin(), container.end(), x );
-	DEBUG_ERR( it == container.end() );
-	container.erase( it );
+	ambientCol = Vec3( 0.1, 0.05, 0.05 )*1;
+	sunPos = Vec3( 0.0, 1.0, -1.0 ) * 50.0;
 }
 
 
 //=====================================================================================================================================
 // registerNode                                                                                                                       =
 //=====================================================================================================================================
-void registerNode( Node* node )
+void Scene::registerNode( Node* node )
 {
-	PutBackNode( nodes, node );
+	putBackNode( nodes, node );
 	
 	switch( node->type )
 	{
 		case Node::NT_LIGHT:
-			PutBackNode( lights, static_cast<Light*>(node) );
+			putBackNode( lights, static_cast<Light*>(node) );
 			break;
 		case Node::NT_CAMERA:
-			PutBackNode( cameras, static_cast<Camera*>(node) );
+			putBackNode( cameras, static_cast<Camera*>(node) );
 			break;
 		case Node::NT_MESH:
-			PutBackNode( meshNodes, static_cast<MeshNode*>(node) );
+			putBackNode( meshNodes, static_cast<MeshNode*>(node) );
 			break;
 		case Node::NT_SKELETON:
-			PutBackNode( skelNodes, static_cast<SkelNode*>(node) );
+			putBackNode( skelNodes, static_cast<SkelNode*>(node) );
 			break;
 		case Node::NT_SKEL_MODEL:
 			// ToDo
@@ -73,23 +49,23 @@ void registerNode( Node* node )
 //=====================================================================================================================================
 // unregisterNode                                                                                                                     =
 //=====================================================================================================================================
-void unregisterNode( Node* node )
+void Scene::unregisterNode( Node* node )
 {
-	EraseNode( nodes, node );
+	eraseNode( nodes, node );
 	
 	switch( node->type )
 	{
 		case Node::NT_LIGHT:
-			EraseNode( lights, static_cast<Light*>(node) );
+			eraseNode( lights, static_cast<Light*>(node) );
 			break;
 		case Node::NT_CAMERA:
-			EraseNode( cameras, static_cast<Camera*>(node) );
+			eraseNode( cameras, static_cast<Camera*>(node) );
 			break;
 		case Node::NT_MESH:
-			EraseNode( meshNodes, static_cast<MeshNode*>(node) );
+			eraseNode( meshNodes, static_cast<MeshNode*>(node) );
 			break;
 		case Node::NT_SKELETON:
-			EraseNode( skelNodes, static_cast<SkelNode*>(node) );
+			eraseNode( skelNodes, static_cast<SkelNode*>(node) );
 			break;
 		case Node::NT_SKEL_MODEL:
 			// ToDo
@@ -101,13 +77,13 @@ void unregisterNode( Node* node )
 //=====================================================================================================================================
 // Register and Unregister controllers                                                                                                =
 //=====================================================================================================================================
-void registerController( Controller* controller )
+void Scene::registerController( Controller* controller )
 {
 	DEBUG_ERR( std::find( controllers.begin(), controllers.end(), controller ) != controllers.end() );
 	controllers.push_back( controller );
 }
 
-void unregisterController( Controller* controller )
+void Scene::unregisterController( Controller* controller )
 {
 	Vec<Controller*>::iterator it = std::find( controllers.begin(), controllers.end(), controller );
 	DEBUG_ERR( it == controllers.end() );
@@ -118,7 +94,7 @@ void unregisterController( Controller* controller )
 //=====================================================================================================================================
 // updateAllWorldStuff                                                                                                                =
 //=====================================================================================================================================
-void updateAllWorldStuff()
+void Scene::updateAllWorldStuff()
 {
 	DEBUG_ERR( nodes.size() > 1024 );
 	Node* queue [1024];
@@ -150,20 +126,10 @@ void updateAllWorldStuff()
 //=====================================================================================================================================
 // updateAllControllers                                                                                                               =
 //=====================================================================================================================================
-void updateAllControllers()
+void Scene::updateAllControllers()
 {
-	/*for( NodeContaineR::iterator it=nodes.begin(); it!=nodes.end(); it++ )
-	{
-		Node* node = (*it);
-		for( Vec<Controller*>::iterator it1=node->controllers.begin(); it1!=node->controllers.end(); it1++ )
-			(*it1)->update( 0.0 );
-	}*/
-
 	for( Vec<Controller*>::iterator it=controllers.begin(); it!=controllers.end(); it++ )
 	{
 		(*it)->update( 0.0 );
 	}
 }
-
-
-} // end namespace

+ 45 - 41
src/Scene/Scene.h

@@ -13,47 +13,51 @@ class SkelNode;
 class Controller;
 
 
-namespace Scene {
-
-// misc
-extern Skybox skybox;
-inline Vec3 getAmbientColor() { return Vec3( 0.1, 0.05, 0.05 )*1; }
-inline Vec3 getSunPos() { return Vec3( 0.0, 1.0, -1.0 ) * 50.0; }
-
-// funcs
-extern void registerNode( Node* node );
-extern void unregisterNode( Node* node );
-extern void registerController( Controller* controller );
-extern void unregisterController( Controller* controller );
-
-extern void updateAllWorldStuff();
-extern void updateAllControllers();
-
-
-// Container
-/// entities container class
-template<typename Type> class Container: public Vec<Type*>
+/**
+ *
+ */
+class Scene
 {
-}; // end class Container
-
-
-
-// typedefs
-typedef Container<Node> NodeContainer;
-typedef Container<Light> LightContainer;
-typedef Container<Camera> CameraContainer;
-typedef Container<MeshNode> MeshContainer;
-typedef Container<SkelNode> SkelNodeContainer;
-
-// containers
-extern NodeContainer      nodes;
-extern LightContainer     lights;
-extern CameraContainer    cameras;
-extern MeshContainer      meshNodes;
-extern SkelNodeContainer  skelNodes;
-
-extern Vec<Controller*> controllers;
-
+	PROPERTY_RW( Vec3, ambientCol, setAmbientCol, getAmbientCol )
+	PROPERTY_RW( Vec3, sunPos, setSunPos, getSunPos )
+
+	private:
+		template<typename ContainerType, typename Type> void putBackNode( ContainerType& container, Type* x )
+		{
+			DEBUG_ERR( std::find( container.begin(), container.end(), x ) != container.end() );
+			container.push_back( x );
+		}
+
+		template<typename ContainerType, typename Type> void eraseNode( ContainerType& container, Type* x )
+		{
+			typename ContainerType::iterator it = std::find( container.begin(), container.end(), x );
+			DEBUG_ERR( it == container.end() );
+			container.erase( it );
+		}
+
+	public:
+		template<typename Type> class Container: public Vec<Type*>
+		{}; /// end class Container
+
+		// Vectors of scene's data
+		Container<Node>       nodes;
+		Container<Light>      lights;
+		Container<Camera>     cameras;
+		Container<MeshNode>   meshNodes;
+		Container<SkelNode>   skelNodes;
+		Container<Controller> controllers;
+		Skybox                skybox; // ToDo to be removed
+
+		// The funcs
+		Scene();
+
+		void registerNode( Node* node );
+		void unregisterNode( Node* node );
+		void registerController( Controller* controller );
+		void unregisterController( Controller* controller );
+
+		void updateAllWorldStuff();
+		void updateAllControllers();
+};
 
-} // end namespace
 #endif

+ 1 - 1
src/Scene/SkelModelNode.h

@@ -19,7 +19,7 @@ class SkelModelNode: public Node
 		Vec<MeshNode*> meshNodes;
 		SkelNode*   skelNode;
 		
-		SkelModelNode(): Node(NT_SKEL_MODEL), skelNode(NULL) { isGroupNode = true; }
+		SkelModelNode(): Node(NT_SKEL_MODEL), skelNode(NULL) { isCompound = true; }
 		void init( const char* filename );
 		void deinit() {} ///< Do nothing because it loads no resources
 		void render() {} ///< Do nothing

+ 29 - 38
src/Util/App.cpp

@@ -1,28 +1,27 @@
 #include <GL/glew.h>
 #include "App.h"
 
-namespace App { // begin of namespace
 
+//=====================================================================================================================================
+// Constructor                                                                                                                        =
+//=====================================================================================================================================
+App::App()
+{
+	scene = NULL;
+	activeCam = NULL;
 
-static SDL_Surface* mainSurf;
-static SDL_Surface* iconImage;
-
-uint windowW = 1280;
-uint windowH = 800;
-
-uint timerTick = 1000/40; // in ms. 1000/Hz
-static uint time = 0;
+	windowW = 1280;
+	windowH = 800;
 
-uint desktopW;
-uint desktopH;
+	timerTick = 1000/40; // in ms. 1000/Hz
+	uint time = 0;
+}
 
 
-/*
-=======================================================================================================================================
-initWindow                                                                                                                            =
-=======================================================================================================================================
-*/
-void initWindow()
+//=====================================================================================================================================
+// initWindow                                                                                                                         =
+//=====================================================================================================================================
+void App::initWindow()
 {
 	PRINT( "SDL window initializing..." );
 	SDL_Init( SDL_INIT_VIDEO );
@@ -83,23 +82,19 @@ void initWindow()
 }
 
 
-/*
-=======================================================================================================================================
-togleFullScreen                                                                                                                       =
-=======================================================================================================================================
-*/
-void togleFullScreen()
+//=====================================================================================================================================
+// togleFullScreen                                                                                                                    =
+//=====================================================================================================================================
+void App::togleFullScreen()
 {
 	SDL_WM_ToggleFullScreen( mainSurf );
 }
 
 
-/*
-=======================================================================================================================================
-quitApp                                                                                                                               =
-=======================================================================================================================================
-*/
-void quitApp( int code )
+//=====================================================================================================================================
+// quitApp                                                                                                                            =
+//=====================================================================================================================================
+void App::quitApp( int code )
 {
 	SDL_FreeSurface( mainSurf );
 	SDL_Quit();
@@ -107,12 +102,10 @@ void quitApp( int code )
 }
 
 
-/*
-=======================================================================================================================================
-waitForNextFrame                                                                                                                      =
-=======================================================================================================================================
-*/
-void waitForNextFrame()
+//=====================================================================================================================================
+// waitForNextFrame                                                                                                                   =
+//=====================================================================================================================================
+void App::waitForNextFrame()
 {
 	uint now = SDL_GetTicks();
 
@@ -132,7 +125,7 @@ void waitForNextFrame()
 //=====================================================================================================================================
 // printAppInfo                                                                                                                       =
 //=====================================================================================================================================
-void printAppInfo()
+void App::printAppInfo()
 {
 	cout << "App info: ";
 	#if defined( _DEBUG_ )
@@ -145,5 +138,3 @@ void printAppInfo()
 	cout << "SDL_" << int(v->major) << '.' << int(v->minor) << '.' <<  int(v->patch) << endl;
 }
 
-
-} // end of namespace

+ 27 - 17
src/Util/App.h

@@ -4,29 +4,39 @@
 #include <SDL/SDL.h>
 #include "Common.h"
 
-namespace App {
 
+class Scene;
+class Camera;
 
-extern uint timerTick;
 
-extern uint desktopW;
-extern uint desktopH;
+class App
+{
+	PROPERTY_R( uint, desktopW, getDesktopW )
+	PROPERTY_R( uint, desktopH, getDesktopH )
 
-extern uint windowW;
-extern uint windowH;
+	private:
+		uint time;
+		SDL_Surface* mainSurf;
+		SDL_Surface* iconImage;
 
-extern void initWindow();
-extern void quitApp( int code );
-extern void waitForNextFrame();
-extern void togleFullScreen();
-extern void printAppInfo();
+	public:
+		uint timerTick;
+		uint windowW;
+		uint windowH;
 
-/// Gets the number of milliseconds since SDL library initialization
-inline uint getTicks()
-{
-	return SDL_GetTicks();
-}
+		Scene*  scene;
+		Camera* activeCam;
+
+		App();
+		void initWindow();
+		void quitApp( int code );
+		void waitForNextFrame();
+		void togleFullScreen();
+		static void printAppInfo();
+
+		/// Gets the number of milliseconds since SDL library initialization
+		static uint getTicks() { return SDL_GetTicks(); }
+};
 
 
-} // end namespace
 #endif

+ 7 - 0
src/Util/Common.h

@@ -207,4 +207,11 @@ inline void printMallInfoDiff( const Mallinfo& prev, const Mallinfo& now )
 #endif
 
 
+//=====================================================================================================================================
+//                                                                                                                                    =
+//=====================================================================================================================================
+class App;
+extern App* app;
+
+
 #endif

+ 4 - 4
src/Util/Input.cpp

@@ -86,8 +86,8 @@ void handleEvents()
 				mousePos.x = event_.button.x;
 				mousePos.y = event_.button.y;
 
-				mousePosNdc.x = (2.0f * mousePos.x) / (float)App::windowW - 1.0f;
-				mousePosNdc.y = 1.0f - (2.0f * mousePos.y) / (float)App::windowH;
+				mousePosNdc.x = (2.0f * mousePos.x) / (float)app->windowW - 1.0f;
+				mousePosNdc.y = 1.0f - (2.0f * mousePos.y) / (float)app->windowH;
 
 				if( warpMouse )
 				{
@@ -95,7 +95,7 @@ void handleEvents()
 					// ...SDL_WarpMouse function
 					if( mousePosNdc == Vec2::getZero() ) break;
 
-					SDL_WarpMouse( App::windowW/2, App::windowH/2);
+					SDL_WarpMouse( app->windowW/2, app->windowH/2);
 				}
 
 				mouseVelocity = mousePosNdc - prevMousePosNdc;
@@ -103,7 +103,7 @@ void handleEvents()
 			}
 
 			case SDL_QUIT:
-				App::quitApp(1);
+				app->quitApp(1);
 				break;
 		}
 	}