Browse Source

Non important changes
+ Doxygen macro to unroll PROPERTY_*
+ Properties in App
+ Misc info messages

Panagiotis Christopoulos Charitos 15 years ago
parent
commit
40be2f7b0e

+ 2 - 3
build/debug/gen.cfg.py

@@ -1,7 +1,7 @@
 sourcePaths = [ "../../src/Math/", "../../src/Tokenizer/", "../../src/Misc/", "../../src/", "../../src/Renderer/", "../../src/Scene/", "../../src/Ui/", "../../src/Resources/", "../../src/Util/", "../../src/Controllers/", "../../src/Physics/", "../../src/Renderer/BufferObjects/" ]
 
-include_paths = list(sourcePaths)
-include_paths.extend( [ "../../../bullet_svn/src/" ] ) # the bullet svn path
+includePaths = list(sourcePaths)
+includePaths.extend( [ "../../../bullet_svn/src/" ] ) # the bullet svn path
 
 precompiledHeaders = []
 executableName = "AnKi.bin"
@@ -9,5 +9,4 @@ compiler = "g++"
 commonFlags = ""
 compilerFlags = "-c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -pipe -O0 -g3 -pg `sdl-config --cflags` -fsingle-precision-constant -D_DEBUG_ -D_TERMINAL_COLORING__ -D_PLATFORM_LINUX_"
 precompiledHeadersFlags = "-x c++-header"
-#linkerFlags = "-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 -lpthread -lGL -ljpeg -lpng -ltiff -lesd -lcaca -laa -ldirectfb -laudio -lpulse-simple" # a few libs are now static
 linkerFlags = "-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" # a few libs are now static

+ 2 - 1
build/genmakefile.py

@@ -15,6 +15,7 @@ compilerFlags = ""
 precompiledHeadersFlags = ""
 linkerFlags = ""
 sourceFilesRegExpr = r".*\.[c++|cpp|cc|cxx|C|c]"
+includePaths = []
 
 
 #======================================================================================================================================
@@ -156,7 +157,7 @@ masterStr += "LFLAGS = $(COMMONFLAGS) " + linkerFlags + "\n"
 masterStr += "EXECUTABLE = " + executableName + "\n"
 
 masterStr += "INCPATH = "
-for path in include_paths:
+for path in includePaths:
 	masterStr += "-I" + path + " "
 	compilerFlags += " -I" + path + " "
 masterStr += "\n"

+ 2 - 1
docs/Doxyfile

@@ -1277,7 +1277,8 @@ INCLUDE_FILE_PATTERNS  =
 # undefined via #undef or recursively expanded use the := operator 
 # instead of the = operator.
 
-PREDEFINED             = 
+PREDEFINED             = "PROPERTY_RW(x,y,z,w)=x y;" \
+                         "PROPERTY_R(x,y,z)=x y;"
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
 # this tag can be used to specify a list of macro names that should be expanded. 

+ 4 - 4
src/Controllers/Controller.cpp

@@ -5,12 +5,12 @@
 Controller::Controller( Type type_ ): 
 	type(type_) 
 {
-	DEBUG_ERR( app->scene == NULL );
-	app->scene->registerController( this );
+	DEBUG_ERR( app->getScene() == NULL );
+	app->getScene()->registerController( this );
 }
 
 Controller::~Controller()
 {
-	DEBUG_ERR( app->scene == NULL );
-	app->scene->unregisterController( this );
+	DEBUG_ERR( app->getScene() == NULL );
+	app->getScene()->unregisterController( this );
 }

+ 23 - 18
src/Main.cpp

@@ -63,7 +63,7 @@ Vec<btRigidBody*> boxes;
 
 void initPhysics()
 {
-	btDiscreteDynamicsWorld* dynamicsWorld = app->scene->getPhyWorld()->getDynamicsWorld();
+	btDiscreteDynamicsWorld* dynamicsWorld = app->getScene()->getPhyWorld()->getDynamicsWorld();
 
 	btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
 
@@ -119,17 +119,21 @@ void initPhysics()
 			{
 				for(int j = 0;j<ARRAY_SIZE_Z;j++)
 				{
-					startTransform.setOrigin(SCALING*btVector3(
+					/*startTransform.setOrigin(SCALING*btVector3(
 										btScalar(2.0*i + start_x),
 										btScalar(20+2.0*k + start_y),
-										btScalar(2.0*j + start_z)));
+										btScalar(2.0*j + start_z)));*/
 
 
 					//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
 					MeshNode* crate = new MeshNode;
 					crate->init( "models/crate0/crate0.mesh" );
 					crate->scaleLspace = 1.11;
-					MotionState* myMotionState = new MotionState( startTransform, crate);
+
+					Transform trf( SCALING*Vec3(2.0*i + start_x, 20+2.0*k + start_y, 2.0*j + start_z), Mat3::getIdentity(), 1.0 );
+					body = app->getScene()->getPhyWorld()->createNewRigidBody( mass, trf, colShape, crate );
+
+					/*MotionState* myMotionState = new MotionState( startTransform, crate);
 					btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,colShape,localInertia);
 					//btRigidBody* body = new btRigidBody(rbInfo);
 					body = new btRigidBody(rbInfo);
@@ -140,7 +144,7 @@ void initPhysics()
 
 
 					dynamicsWorld->addRigidBody(body);
-					//body->setGravity( toBt( Vec3( Util::randRange(-1.0, 1.0), Util::randRange(-1.0, 1.0), Util::randRange(-1.0, 1.0) ) ) );
+					//body->setGravity( toBt( Vec3( Util::randRange(-1.0, 1.0), Util::randRange(-1.0, 1.0), Util::randRange(-1.0, 1.0) ) ) );*/
 					boxes.push_back( body );
 				}
 			}
@@ -171,10 +175,11 @@ void init()
 	Ui::init();
 
 	// camera
-	app->activeCam = new Camera( R::aspectRatio*toRad(60.0), toRad(60.0), 0.5, 200.0 );
-	app->activeCam->moveLocalY( 3.0 );
-	app->activeCam->moveLocalZ( 5.7 );
-	app->activeCam->moveLocalX( -0.3 );
+	Camera* cam = new Camera( R::aspectRatio*toRad(60.0), toRad(60.0), 0.5, 200.0 );
+	cam->moveLocalY( 3.0 );
+	cam->moveLocalZ( 5.7 );
+	cam->moveLocalX( -0.3 );
+	app->setActiveCam( cam );
 
 	// lights
 	point_lights[0] = new PointLight();
@@ -231,7 +236,7 @@ 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" };
-	app->scene->skybox.load( skybox_fnames );
+	app->getScene()->skybox.load( skybox_fnames );
 
 
 	initPhysics();
@@ -263,9 +268,9 @@ int main( int /*argc*/, char* /*argv*/[] )
 		float scale = 0.01;
 
 		// move the camera
-		static Node* mover = app->activeCam;
+		static Node* mover = app->getActiveCam();
 
-		if( I::keys[ SDLK_1 ] ) mover = app->activeCam;
+		if( I::keys[ SDLK_1 ] ) mover = app->getActiveCam();
 		if( I::keys[ SDLK_2 ] ) mover = point_lights[0];
 		if( I::keys[ SDLK_3 ] ) mover = spot_lights[0];
 		if( I::keys[ SDLK_4 ] ) mover = point_lights[1];
@@ -297,7 +302,7 @@ int main( int /*argc*/, char* /*argv*/[] )
 		if( I::keys[SDLK_PAGEUP] ) mover->scaleLspace += scale ;
 		if( I::keys[SDLK_PAGEDOWN] ) mover->scaleLspace -= scale ;
 
-		if( I::keys[SDLK_k] ) app->activeCam->lookAtPoint( point_lights[0]->translationWspace );
+		if( I::keys[SDLK_k] ) app->getActiveCam()->lookAtPoint( point_lights[0]->translationWspace );
 
 
 		if( I::keys[SDLK_o] == 1 )
@@ -314,15 +319,15 @@ int main( int /*argc*/, char* /*argv*/[] )
 		//static_cast<btRigidBody*>(dynamicsWorld->getCollisionObjectArray()[1])->getMotionState()->setWorldTransform( toBt(point_lights[0]->transformationWspace) );
 		//dynamicsWorld->getCollisionObjectArray()[3]->setWorldTransform( toBt(point_lights[0]->transformationWspace) );
 
-		app->scene->updateAllControllers();
-		app->scene->updateAllWorldStuff();
+		app->getScene()->updateAllControllers();
+		app->getScene()->updateAllWorldStuff();
 
 		//partEmitter->update();
 
-		app->scene->getPhyWorld()->getDynamicsWorld()->stepSimulation( app->timerTick );
-		app->scene->getPhyWorld()->getDynamicsWorld()->debugDrawWorld();
+		app->getScene()->getPhyWorld()->getDynamicsWorld()->stepSimulation( app->timerTick );
+		app->getScene()->getPhyWorld()->getDynamicsWorld()->debugDrawWorld();
 
-		R::render( *app->activeCam );
+		R::render( *app->getActiveCam() );
 
 		//map.octree.root->bounding_box.render();
 

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

@@ -153,7 +153,7 @@ inline Mat4::Mat4( float f )
 // constructor [Transform]
 inline Mat4::Mat4( const Transform& t )
 {
-	ME = Mat4( t.translation, Mat3(t.rotation), t.scale );
+	ME = Mat4( t.getOrigin(), Mat3(t.getRotation()), t.getScale() );
 }
 
 // 4x4 + 4x4

+ 4 - 4
src/Math/Transform.h

@@ -13,11 +13,11 @@ namespace M {
  */
 class Transform
 {
+	PROPERTY_RW( Mat3, rotation, setRotation, getRotation ) ///< Property
+	PROPERTY_RW( Vec3, origin, setOrigin, getOrigin ) ///< Property
+	PROPERTY_RW( float, scale, setScale, getScale ) ///< Property
+
 	public:
-		// data members
-		Mat3  rotation;
-		Vec3  translation;
-		float scale;
 		// constructors
 		explicit Transform();
 		         Transform( const Transform& b );

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

@@ -13,20 +13,20 @@ inline Transform::Transform()
 
 // constructor [Transform]
 inline Transform::Transform( const Transform& b ):
-	rotation(b.rotation), translation(b.translation)
+	rotation(b.rotation), origin(b.origin)
 {}
 
 // constructor [Mat4]
 inline Transform::Transform( const Mat4& m4 )
 {
 	rotation = m4.getRotationPart();
-	translation = m4.getTranslationPart();
+	origin = m4.getTranslationPart();
 	scale = 1.0;
 }
 
 // constructor [Vec3, Quat, float]
 inline Transform::Transform( const Vec3& origin, const Mat3& rotation_, float scale_ ):
-	rotation(rotation_), translation(origin), scale(scale_)
+	rotation(rotation_), origin(origin), scale(scale_)
 {}
 
 // setIdentity

+ 1 - 1
src/Misc/skybox.cpp

@@ -63,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 ) / app->scene->getAmbientCol())[0] );
+	glUniform3fv( shader->getUniVar("sceneAmbientCol").getLoc(), 1, &(Vec3( 1.0, 1.0, 1.0 ) / app->getScene()->getAmbientCol())[0] );
 
 	// set the rotation matrix
 	Mat3 tmp( rotation );

+ 2 - 2
src/Physics/PhyConversions.h

@@ -66,8 +66,8 @@ inline btQuaternion toBt( const Quat& q )
 inline btTransform toBt( const Transform& trf )
 {
 	btTransform r;
-	r.setOrigin( toBt(trf.translation) );
-	r.setRotation( toBt( Quat(trf.rotation) ) );
+	r.setOrigin( toBt(trf.getOrigin()) );
+	r.setRotation( toBt( Quat(trf.getRotation()) ) );
 	return r;
 }
 

+ 8 - 3
src/Physics/PhyWorld.cpp

@@ -4,9 +4,10 @@
 //=====================================================================================================================================
 // createNewRigidBody                                                                                                                 =
 //=====================================================================================================================================
-btRigidBody* PhyWorld::createNewRigidBody( float mass, const Transform& startTransform, btCollisionShape* shape, Node* node )
+btRigidBody* PhyWorld::createNewRigidBody( float mass, const Transform& startTransform, btCollisionShape* shape, Node* node, int group,
+                                           int mask )
 {
-	DEBUG_ERR( (!shape || shape->getShapeType() != INVALID_SHAPE_PROXYTYPE) )
+	DEBUG_ERR( shape==NULL || shape->getShapeType()==INVALID_SHAPE_PROXYTYPE )
 
 	//rigidbody is dynamic if and only if mass is non zero, otherwise static
 	bool isDynamic = (mass != 0.0);
@@ -23,7 +24,11 @@ btRigidBody* PhyWorld::createNewRigidBody( float mass, const Transform& startTra
 	btRigidBody* body = new btRigidBody( cInfo );
 	body->setContactProcessingThreshold( defaultContactProcessingThreshold );
 
-	dynamicsWorld->addRigidBody( body );
+	if( mask==-1 & group==-1 )
+		dynamicsWorld->addRigidBody( body );
+	else
+		dynamicsWorld->addRigidBody( body, group, mask );
+
 	return body;
 }
 

+ 4 - 1
src/Physics/PhyWorld.h

@@ -46,9 +46,12 @@ class PhyWorld
 		 * @param startTransform The initial position and orientation
 		 * @param shape The collision shape
 		 * @param node The scene node the body moves
+		 * @param group The group of the body. Leave it blank if there is no group
+		 * @param mask The mask of the body. Leave it blank if there is no mask
 		 * @return A new rigid body
 		 */
-		static btRigidBody* createNewRigidBody( float mass, const Transform& startTransform, btCollisionShape* shape, Node* node );
+		btRigidBody* createNewRigidBody( float mass, const Transform& startTransform, btCollisionShape* shape, Node* node, int group=-1,
+		                                 int mask=-1 );
 };
 
 #endif

+ 2 - 2
src/Renderer/Bs.cpp

@@ -63,9 +63,9 @@ void runStage( const Camera& cam )
 
 
 	// render the meshes
-	for( uint i=0; i<app->scene->meshNodes.size(); i++ )
+	for( uint i=0; i<app->getScene()->meshNodes.size(); i++ )
 	{
-		MeshNode* meshNode = app->scene->meshNodes[i];
+		MeshNode* meshNode = app->getScene()->meshNodes[i];
 		if( meshNode->material->blends && !meshNode->material->blends )
 		{
 			fbo.bind();

+ 2 - 2
src/Renderer/Bs2.cpp

@@ -87,9 +87,9 @@ void runStage2( const Camera& cam )
 
 
 	// render the meshes
-	for( uint i=0; i<app->scene->meshNodes.size(); i++ )
+	for( uint i=0; i<app->getScene()->meshNodes.size(); i++ )
 	{
-		MeshNode* mesh_node = app->scene->meshNodes[i];
+		MeshNode* mesh_node = app->getScene()->meshNodes[i];
 		if( mesh_node->material->refracts )
 		{
 			// write to the rFbo

+ 10 - 10
src/Renderer/Dbg.cpp

@@ -148,20 +148,20 @@ void runStage( const Camera& cam )
 	glDisable( GL_BLEND );
 
 	//R::renderGrid();
-	for( uint i=0; i<app->scene->nodes.size(); i++ )
+	for( uint i=0; i<app->getScene()->nodes.size(); i++ )
 	{
 		if
 		(
-			(app->scene->nodes[i]->type == Node::NT_LIGHT && showLights) ||
-			(app->scene->nodes[i]->type == Node::NT_CAMERA && showCameras) ||
-			app->scene->nodes[i]->type == Node::NT_PARTICLE_EMITTER
+			(app->getScene()->nodes[i]->type == Node::NT_LIGHT && showLights) ||
+			(app->getScene()->nodes[i]->type == Node::NT_CAMERA && showCameras) ||
+			app->getScene()->nodes[i]->type == Node::NT_PARTICLE_EMITTER
 		)
 		{
-			app->scene->nodes[i]->render();
+			app->getScene()->nodes[i]->render();
 		}
-		else if( app->scene->nodes[i]->type == Node::NT_SKELETON && showSkeletons )
+		else if( app->getScene()->nodes[i]->type == Node::NT_SKELETON && showSkeletons )
 		{
-			SkelNode* skel_node = static_cast<SkelNode*>( app->scene->nodes[i] );
+			SkelNode* skel_node = static_cast<SkelNode*>( app->getScene()->nodes[i] );
 			glDisable( GL_DEPTH_TEST );
 			skel_node->render();
 			glEnable( GL_DEPTH_TEST );
@@ -196,7 +196,7 @@ void runStage( const Camera& cam )
 	float r = 1.2;
 
 	Vec4 p = Vec4( c, 1.0 );
-	p = app->activeCam->getProjectionMatrix() * (app->activeCam->getViewMatrix() * p);
+	p = app->getActiveCam()->getProjectionMatrix() * (app->getActiveCam()->getViewMatrix() * p);
 	p /= p.w;
 	//p = p/2 + 0.5;
 
@@ -429,7 +429,7 @@ static void renderSun()
 {
 	glPushMatrix();
 
-	R::multMatrix( Mat4( app->scene->getSunPos(), Mat3::getIdentity(), 50.0 ) );
+	R::multMatrix( Mat4( app->getScene()->getSunPos(), Mat3::getIdentity(), 50.0 ) );
 
 	R::color3( Vec3(1.0, 1.0, 0.0) );
 	R::Dbg::renderSphere( 1.0/8.0, 8 );
@@ -447,7 +447,7 @@ static void renderSun()
 	glLoadIdentity();
 
 
-	Vec4 p = Vec4( app->scene->getSunPos(), 1.0 );
+	Vec4 p = Vec4( app->getScene()->getSunPos(), 1.0 );
 	p = mainCam->getProjectionMatrix() * (mainCam->getViewMatrix() * p);
 	p /= p.w;
 	p = p/2 + 0.5;

+ 3 - 3
src/Renderer/Is.cpp

@@ -532,7 +532,7 @@ void runStage( const Camera& cam )
 	glDisable( GL_DEPTH_TEST );
 
 	// ambient pass
-	ambientPass( cam, app->scene->getAmbientCol() );
+	ambientPass( cam, app->getScene()->getAmbientCol() );
 
 	// light passes
 	glEnable( GL_BLEND );
@@ -542,9 +542,9 @@ void runStage( const Camera& cam )
 	CalcPlanes( cam );
 
 	// for all lights
-	for( uint i=0; i<app->scene->lights.size(); i++ )
+	for( uint i=0; i<app->getScene()->lights.size(); i++ )
 	{
-		const Light& light = *app->scene->lights[i];
+		const Light& light = *app->getScene()->lights[i];
 		switch( light.type )
 		{
 			case Light::LT_POINT:

+ 2 - 2
src/Renderer/IsShadows.cpp

@@ -96,9 +96,9 @@ void runPass( const Camera& cam )
 	glEnable( GL_POLYGON_OFFSET_FILL );
 
 	// render all meshes
-	for( uint i=0; i<app->scene->meshNodes.size(); i++ )
+	for( uint i=0; i<app->getScene()->meshNodes.size(); i++ )
 	{
-		MeshNode* mesh_node = app->scene->meshNodes[i];
+		MeshNode* mesh_node = app->getScene()->meshNodes[i];
 		if( mesh_node->material->blends || mesh_node->material->refracts ) continue;
 
 		DEBUG_ERR( mesh_node->material->dpMtl == NULL );

+ 3 - 3
src/Renderer/Ms.cpp

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

+ 1 - 1
src/Renderer/PpsLscatt.cpp

@@ -89,7 +89,7 @@ void runPass( const Camera& cam )
 	sProg.locTexUnit( isFaiUniLoc, R::Is::fai, 1 );
 
 	// pass the light
-	Vec4 p = Vec4( app->scene->getSunPos(), 1.0 );
+	Vec4 p = Vec4( app->getScene()->getSunPos(), 1.0 );
 	p = cam.getProjectionMatrix() * (cam.getViewMatrix() * p);
 	p /= p.w;
 	p = p/2 + 0.5;

+ 1 - 1
src/Renderer/Renderer.cpp

@@ -112,7 +112,7 @@ void init()
 	glewInit();
 
 	// print GL info
-	cout << "OpenGL info: OGL_" << glGetString(GL_VERSION) << " GLSL_" << glGetString(GL_SHADING_LANGUAGE_VERSION) << endl;
+	INFO( "OpenGL info: OGL " << glGetString(GL_VERSION) << ", GLSL " << glGetString(GL_SHADING_LANGUAGE_VERSION) );
 
 	if( !glewIsSupported("GL_VERSION_2_1") )
 		WARNING( "OpenGL ver 2.1 not supported. The application may crash (and burn)" );

+ 4 - 4
src/Scene/Node.cpp

@@ -22,8 +22,8 @@ void Node::commonConstructorCode()
 	rotationWspace = Mat3::getIdentity();
 	bvolumeLspace = NULL;
 
-	DEBUG_ERR( app->scene == NULL );
-	app->scene->registerNode( this );
+	DEBUG_ERR( app->getScene() == NULL );
+	app->getScene()->registerNode( this );
 }
 
 
@@ -32,8 +32,8 @@ void Node::commonConstructorCode()
 //=====================================================================================================================================
 Node::~Node()
 {
-	DEBUG_ERR( app->scene == NULL );
-	app->scene->unregisterNode( this );
+	DEBUG_ERR( app->getScene() == NULL );
+	app->getScene()->unregisterNode( this );
 }
 
 

+ 2 - 8
src/Scene/ParticleEmitter.cpp

@@ -51,15 +51,9 @@ void ParticleEmitter::init( const char* filename )
 	for( uint i=0; i<maxNumOfParticles; i++ )
 	{
 		particles[i] = new Particle;
-
 		float mass = Util::randRange( minParticleMass, maxParticleMass );
-		btVector3 localInertia;
-		colShape->calculateLocalInertia( mass, localInertia );
-		MotionState* mState = new MotionState( btTransform::getIdentity(), particles[i] );
-		btRigidBody::btRigidBodyConstructionInfo rbInfo( mass, mState, colShape, localInertia );
-		btRigidBody* body = new btRigidBody( rbInfo );
-		particles[i]->body = body;
-		app->scene->getPhyWorld()->getDynamicsWorld()->addRigidBody( body, PhyWorld::CG_PARTICLE, PhyWorld::CG_MAP );
+		btRigidBody* body = app->getScene()->getPhyWorld()->createNewRigidBody( mass, Transform::getIdentity(), colShape, particles[i],
+		                                                                   PhyWorld::CG_PARTICLE, PhyWorld::CG_MAP );
 		body->forceActivationState( DISABLE_SIMULATION );
 	}
 }

+ 17 - 7
src/Util/App.cpp

@@ -1,13 +1,20 @@
 #include <GL/glew.h>
+#include <sstream>
 #include "App.h"
 #include "Scene.h"
 
+bool App::isCreated = false;
 
 //=====================================================================================================================================
 // Constructor                                                                                                                        =
 //=====================================================================================================================================
 App::App()
 {
+	if( isCreated )
+		FATAL( "You cannot create a second App instance" )
+
+	isCreated = true;
+
 	scene = new Scene;
 	activeCam = NULL;
 
@@ -18,7 +25,7 @@ App::App()
 
 
 	timerTick = 1000/40; // in ms. 1000/Hz
-	uint time = 0;
+	time = 0;
 }
 
 
@@ -34,7 +41,7 @@ void App::initWindow()
 	char charBuff [256];
 	if( SDL_VideoDriverName(charBuff, sizeof(charBuff)) != NULL )
 	{
-		PRINT( "The video driver name is " << charBuff );
+		INFO( "Video driver name: " << charBuff );
 	}
 	else
 	{
@@ -131,14 +138,17 @@ void App::waitForNextFrame()
 //=====================================================================================================================================
 void App::printAppInfo()
 {
-	cout << "App info: ";
+	stringstream msg;
+	msg << "App info: ";
 	#if defined( _DEBUG_ )
-		cout << "Debug ";
+		msg << "Debug, ";
 	#else
-		cout << "Release ";
+		msg << "Release, ";
 	#endif
-	cout << "GLEW_" << glewGetString(GLEW_VERSION) << " ";
+	msg << "GLEW " << glewGetString(GLEW_VERSION) << ", ";
 	const SDL_version* v = SDL_Linked_Version();
-	cout << "SDL_" << int(v->major) << '.' << int(v->minor) << '.' <<  int(v->patch) << endl;
+	msg << "SDL " << int(v->major) << '.' << int(v->minor) << '.' << int(v->patch);
+
+	INFO( msg.str() )
 }
 

+ 13 - 6
src/Util/App.h

@@ -5,12 +5,19 @@
 #include "Common.h"
 
 
+/**
+ * @brief This class contains all the global objects of the application. Its also responsible for some of the SDL stuff.
+ * It should be singleton
+ */
 class App
 {
-	PROPERTY_R( uint, desktopW, getDesktopW )
-	PROPERTY_R( uint, desktopH, getDesktopH )
+	PROPERTY_R( uint, desktopW, getDesktopW ) ///< Property: The desktop width at App initialization
+	PROPERTY_R( uint, desktopH, getDesktopH ) ///< Property: The desktop height at App initialization
+	PROPERTY_RW( class Scene*, scene, setScene, getScene ) ///< Property: Pointer to the current scene
+	PROPERTY_RW( class Camera*, activeCam, setActiveCam, getActiveCam ) ///< Property: Pointer to the current camera
 
 	private:
+		static bool isCreated; ///< A flag to ensure one @ref App instance
 		uint time;
 		SDL_Surface* mainSurf;
 		SDL_Surface* iconImage;
@@ -20,17 +27,17 @@ class App
 		uint windowW;
 		uint windowH;
 
-		class Scene*  scene;
-		class Camera* activeCam;
-
 		App();
+		~App() {}
 		void initWindow();
 		void quitApp( int code );
 		void waitForNextFrame();
 		void togleFullScreen();
 		static void printAppInfo();
 
-		/// Gets the number of milliseconds since SDL library initialization
+		/**
+		 * @return Returns the number of milliseconds since SDL library initialization
+		 */
 		static uint getTicks() { return SDL_GetTicks(); }
 };
 

+ 6 - 0
src/Util/Common.h

@@ -72,6 +72,9 @@ extern string getFunctionFromPrettyFunction( const char* pretty_function );
 #define GENERAL_ERR( x, y, col ) \
 	cerr << col << x << " (" << __FILENAME__ << ":" << __LINE__ << " " << __G_FUNCTION__ << "): " << y << COL_DEFAULT << endl;
 
+#define GENERAL_MSG( x, y, col ) \
+	cout << col << x << " (" << __FILENAME__ << ":" << __LINE__ << " " << __G_FUNCTION__ << "): " << y << COL_DEFAULT << endl;
+
 /// in ERROR you can write something like this: ERROR( "tralala" << 10 << ' ' )
 #define ERROR( x ) GENERAL_ERR( "Error", x, COL_ERROR )
 
@@ -81,6 +84,9 @@ extern string getFunctionFromPrettyFunction( const char* pretty_function );
 /// FATAL ERROR
 #define FATAL( x ) { GENERAL_ERR( "Fatal", x << ". Bye!", COL_FATAL ); exit( EXIT_FAILURE ); };
 
+/// INFO
+#define INFO( x ) { GENERAL_MSG( "Info", x, COL_INFO ) }
+
 /// DEBUG_ERR
 #ifdef _DEBUG_
 	#define DEBUG_ERR( x ) \