Jelajahi Sumber

Work on the new codding style

Panagiotis Christopoulos Charitos 16 tahun lalu
induk
melakukan
ac7050cad9
88 mengubah file dengan 3103 tambahan dan 3079 penghapusan
  1. 617 599
      build/debug/Makefile
  2. 17 17
      src/controllers/SkelAnimCtrl.cpp
  3. 5 5
      src/controllers/SkelAnimCtrl.h
  4. 28 25
      src/main.cpp
  5. 6 6
      src/math/Axisang.h
  6. 14 14
      src/math/Axisang.inl.h
  7. 4 4
      src/math/Euler.h
  8. 6 6
      src/math/Euler.inl.h
  9. 99 0
      src/math/Mat3.h
  10. 128 128
      src/math/Mat3.inl.h
  11. 98 0
      src/math/Mat4.h
  12. 109 109
      src/math/Mat4.inl.h
  13. 19 0
      src/math/Math.h
  14. 9 0
      src/math/MathDfltHeader.h
  15. 15 0
      src/math/MathForwardDecls.h
  16. 43 0
      src/math/MathFuncs.h
  17. 20 22
      src/math/MathFuncs.inl.h
  18. 57 0
      src/math/Quat.h
  19. 67 67
      src/math/Quat.inl.h
  20. 75 0
      src/math/Vec2.h
  21. 246 0
      src/math/Vec2.inl.h
  22. 91 0
      src/math/Vec3.h
  23. 347 0
      src/math/Vec3.inl.h
  24. 73 0
      src/math/Vec4.h
  25. 258 0
      src/math/Vec4.inl.h
  26. 0 15
      src/math/forward_decls.h
  27. 0 19
      src/math/gmath.h
  28. 0 9
      src/math/m_dflt_header.h
  29. 0 45
      src/math/m_misc.h
  30. 0 99
      src/math/mat3.h
  31. 0 98
      src/math/mat4.h
  32. 0 57
      src/math/quat.h
  33. 0 75
      src/math/vec2.h
  34. 0 246
      src/math/vec2.inl.h
  35. 0 91
      src/math/vec3.h
  36. 0 347
      src/math/vec3.inl.h
  37. 0 73
      src/math/vec4.h
  38. 0 258
      src/math/vec4.inl.h
  39. 5 5
      src/renderer/r_dbg.cpp
  40. 15 15
      src/renderer/r_is.cpp
  41. 1 1
      src/renderer/r_ms.cpp
  42. 1 1
      src/renderer/r_pps_lscatt.cpp
  43. 1 1
      src/renderer/r_pps_ssao.cpp
  44. 19 19
      src/renderer/renderer.cpp
  45. 8 8
      src/renderer/renderer.h
  46. 4 4
      src/renderer2/r_is.cpp
  47. 1 1
      src/renderer2/r_ms.cpp
  48. 18 18
      src/renderer2/renderer.cpp
  49. 5 5
      src/resources/LightProps.h
  50. 5 5
      src/resources/Material.h
  51. 39 39
      src/resources/Mesh.cpp
  52. 6 6
      src/resources/Mesh.h
  53. 3 3
      src/resources/Path.h
  54. 3 3
      src/resources/Resource.h
  55. 6 6
      src/resources/ShaderParser.cpp
  56. 2 2
      src/resources/ShaderProg.cpp
  57. 1 1
      src/resources/SkelAnim.cpp
  58. 3 3
      src/resources/SkelAnim.h
  59. 6 6
      src/resources/Skeleton.cpp
  60. 9 9
      src/resources/Skeleton.h
  61. 1 1
      src/resources/Texture.cpp
  62. 25 25
      src/scene/Camera.cpp
  63. 7 7
      src/scene/Camera.h
  64. 1 1
      src/scene/Light.cpp
  65. 9 9
      src/scene/Node.cpp
  66. 10 10
      src/scene/Node.h
  67. 2 2
      src/scene/Scene.h
  68. 2 2
      src/scene/SkelNode.cpp
  69. 1 1
      src/scene/SkelNode.h
  70. 2 2
      src/ui/ui.cpp
  71. 3 3
      src/ui/ui.h
  72. 187 187
      src/uncategorized/collision.cpp
  73. 53 53
      src/uncategorized/collision.h
  74. 12 12
      src/uncategorized/input.cpp
  75. 4 4
      src/uncategorized/input.h
  76. 4 4
      src/uncategorized/map.cpp
  77. 24 24
      src/uncategorized/particles.cpp
  78. 5 5
      src/uncategorized/particles.h
  79. 6 6
      src/uncategorized/skybox.cpp
  80. 2 2
      src/uncategorized/skybox.h
  81. 66 17
      src/utility/Util.cpp
  82. 22 0
      src/utility/Util.h
  83. 27 15
      src/utility/app.cpp
  84. 9 9
      src/utility/app.h
  85. 0 53
      src/utility/common.cpp
  86. 6 9
      src/utility/common.h
  87. 1 1
      src/utility/u_string.h
  88. 0 20
      src/utility/util.h

File diff ditekan karena terlalu besar
+ 617 - 599
build/debug/Makefile


+ 17 - 17
src/controllers/SkelAnimCtrl.cpp

@@ -55,8 +55,8 @@ void SkelAnimCtrl::interpolate( SkelAnim* animation, float frame )
 	{
 		const SkelAnim::BoneAnim& banim = animation->bones[i];
 
-		mat3_t& local_rot = boneRotations[i];
-		vec3_t& local_transl = boneTranslations[i];
+		Mat3& local_rot = boneRotations[i];
+		Vec3& local_transl = boneTranslations[i];
 
 		// if the bone has animations then slerp and lerp to find the rotation and translation
 		if( banim.keyframes.size() != 0 )
@@ -65,20 +65,20 @@ void SkelAnimCtrl::interpolate( SkelAnim* animation, float frame )
 			const SkelAnim::BonePose& r_bpose = banim.keyframes[r_pose];
 
 			// rotation
-			const quat_t& q0 = l_bpose.rotation;
-			const quat_t& q1 = r_bpose.rotation;
-			local_rot = mat3_t( q0.Slerp(q1, t) );
+			const Quat& q0 = l_bpose.rotation;
+			const Quat& q1 = r_bpose.rotation;
+			local_rot = Mat3( q0.slerp(q1, t) );
 
 			// translation
-			const vec3_t& v0 = l_bpose.translation;
-			const vec3_t& v1 = r_bpose.translation;
-			local_transl = v0.Lerp( v1, t );
+			const Vec3& v0 = l_bpose.translation;
+			const Vec3& v1 = r_bpose.translation;
+			local_transl = v0.lerp( v1, t );
 		}
 		// else put the idents
 		else
 		{
-			local_rot = mat3_t::GetIdentity();
-			local_transl = vec3_t( 0.0, 0.0, 0.0 );
+			local_rot = Mat3::getIdentity();
+			local_transl = Vec3( 0.0, 0.0, 0.0 );
 		}
 	}
 }
@@ -105,11 +105,11 @@ void SkelAnimCtrl::updateBoneTransforms()
 
 		// bone.final_transform = MA * ANIM * MAi
 		// where MA is bone matrix at armature space and ANIM the interpolated transformation.
-		CombineTransformations( boneTranslations[bone_id], boneRotations[bone_id],
+		combineTransformations( boneTranslations[bone_id], boneRotations[bone_id],
 		                        boned.tslSkelSpaceInv, boned.rotSkelSpaceInv,
 		                        boneTranslations[bone_id], boneRotations[bone_id] );
 
-		CombineTransformations( boned.tslSkelSpace, boned.rotSkelSpace,
+		combineTransformations( boned.tslSkelSpace, boned.rotSkelSpace,
 		                        boneTranslations[bone_id], boneRotations[bone_id],
 		                        boneTranslations[bone_id], boneRotations[bone_id] );
 
@@ -117,7 +117,7 @@ void SkelAnimCtrl::updateBoneTransforms()
 		if( boned.parent )
 		{
 			// bone.final_final_transform = parent.transf * bone.final_transform
-			CombineTransformations( boneTranslations[boned.parent->id], boneRotations[boned.parent->id],
+			combineTransformations( boneTranslations[boned.parent->id], boneRotations[boned.parent->id],
 		                          boneTranslations[bone_id], boneRotations[bone_id],
 		                          boneTranslations[bone_id], boneRotations[bone_id] );
 		}
@@ -138,11 +138,11 @@ void SkelAnimCtrl::deform()
 
 	for( uint i=0; i<skeleton->bones.size(); i++ )
 	{
-		const mat3_t& rot = boneRotations[ i ];
-		const vec3_t& transl = boneTranslations[ i ];
+		const Mat3& rot = boneRotations[ i ];
+		const Vec3& transl = boneTranslations[ i ];
 
-		heads[i] = skeleton->bones[i].head.GetTransformed( transl, rot );
-		tails[i] = skeleton->bones[i].tail.GetTransformed( transl, rot );
+		heads[i] = skeleton->bones[i].head.getTransformed( transl, rot );
+		tails[i] = skeleton->bones[i].tail.getTransformed( transl, rot );
 	}
 }
 

+ 5 - 5
src/controllers/SkelAnimCtrl.h

@@ -3,7 +3,7 @@
 
 #include "common.h"
 #include "Controller.h"
-#include "gmath.h"
+#include "Math.h"
 
 class Skeleton;
 class SkelAnim;
@@ -21,10 +21,10 @@ class SkelAnimCtrl: public Controller
 	public:
 		SkelAnim*  skelAnim; ///< Skeleton animation resource
 		SkelNode*  skelNode;
-		Vec<vec3_t> heads;
-		Vec<vec3_t> tails;
-		Vec<mat3_t> boneRotations;
-		Vec<vec3_t> boneTranslations;
+		Vec<Vec3> heads;
+		Vec<Vec3> tails;
+		Vec<Mat3> boneRotations;
+		Vec<Vec3> boneTranslations;
 		float step;
 		float frame;
 

+ 28 - 25
src/main.cpp

@@ -6,7 +6,7 @@
 
 #include "input.h"
 #include "Camera.h"
-#include "gmath.h"
+#include "Math.h"
 #include "renderer.h"
 #include "ui.h"
 #include "app.h"
@@ -179,14 +179,14 @@ void Init()
 	srand( unsigned(time(NULL)) );
 	mathSanityChecks();
 
-	app::InitWindow();
-	uint ticks = app::GetTicks();
+	app::initWindow();
+	uint ticks = app::getTicks();
 
 	r::Init();
 	ui::Init();
 
 	// camera
-	main_cam = new Camera( r::aspect_ratio*ToRad(60.0), ToRad(60.0), 0.5, 100.0 );
+	main_cam = new Camera( r::aspect_ratio*toRad(60.0), toRad(60.0), 0.5, 100.0 );
 	main_cam->moveLocalY( 3.0 );
 	main_cam->moveLocalZ( 5.7 );
 	main_cam->moveLocalX( -0.3 );
@@ -194,38 +194,38 @@ void Init()
 	// lights
 	point_lights[0] = new PointLight();
 	point_lights[0]->init( "maps/temple/light0.light" );
-	point_lights[0]->setLocalTransformation( vec3_t( -1.0, 2.4, 1.0 ), mat3_t::GetIdentity(), 1.0 );
+	point_lights[0]->setLocalTransformation( Vec3( -1.0, 2.4, 1.0 ), Mat3::getIdentity(), 1.0 );
 	point_lights[1] = new PointLight();
 	point_lights[1]->init( "maps/temple/light1.light" );
-	point_lights[1]->setLocalTransformation( vec3_t( 2.5, 1.4, 1.0 ), mat3_t::GetIdentity(), 1.0 );
+	point_lights[1]->setLocalTransformation( Vec3( 2.5, 1.4, 1.0 ), Mat3::getIdentity(), 1.0 );
 
 	spot_lights[0] = new SpotLight();
 	spot_lights[0]->init( "maps/temple/light2.light" );
-	spot_lights[0]->setLocalTransformation( vec3_t( 1.3, 4.3, 3.0 ), mat3_t( Euler(ToRad(-20), ToRad(20), 0.0) ), 1.0 );
+	spot_lights[0]->setLocalTransformation( Vec3( 1.3, 4.3, 3.0 ), Mat3( Euler(toRad(-20), toRad(20), 0.0) ), 1.0 );
 	spot_lights[1] = new SpotLight();
 	spot_lights[1]->init( "maps/temple/light3.light" );
-	spot_lights[1]->setLocalTransformation( vec3_t( -2.3, 6.3, 2.9 ), mat3_t( Euler(ToRad(-70), ToRad(-20), 0.0) ), 1.0 );
+	spot_lights[1]->setLocalTransformation( Vec3( -2.3, 6.3, 2.9 ), Mat3( Euler(toRad(-70), toRad(-20), 0.0) ), 1.0 );
 
 	// horse
 	horse = new MeshNode();
 	horse->init( "meshes/horse/horse.mesh" );
-	horse->setLocalTransformation( vec3_t( -2, 0, 1 ), mat3_t( Euler(-m::PI/2, 0.0, 0.0) ), 0.5 );
+	horse->setLocalTransformation( Vec3( -2, 0, 1 ), Mat3( Euler(-M::PI/2, 0.0, 0.0) ), 0.5 );
 	
 	// sarge
 	sarge = new MeshNode();
 	sarge->init( "meshes/sphere/sphere16.mesh" );
-	//sarge->setLocalTransformation( vec3_t( 0, -2.8, 1.0 ), mat3_t( Euler(-m::PI/2, 0.0, 0.0) ), 1.1 );
-	sarge->setLocalTransformation( vec3_t( 0, 2.0, 2.0 ), mat3_t::GetIdentity(), 0.4 );
+	//sarge->setLocalTransformation( Vec3( 0, -2.8, 1.0 ), Mat3( Euler(-M::PI/2, 0.0, 0.0) ), 1.1 );
+	sarge->setLocalTransformation( Vec3( 0, 2.0, 2.0 ), Mat3::getIdentity(), 0.4 );
 	
 	// floor
 	floor__ = new MeshNode();
 	floor__->init( "maps/temple/Cube.019.mesh" );
-	floor__->setLocalTransformation( vec3_t(0.0, -0.19, 0.0), mat3_t( Euler(-m::PI/2, 0.0, 0.0) ), 0.8 );
+	floor__->setLocalTransformation( Vec3(0.0, -0.19, 0.0), Mat3( Euler(-M::PI/2, 0.0, 0.0) ), 0.8 );
 
 	// imp	
 	imp = new skelModelNode();
 	imp->init( "models/imp/imp.smdl" );
-	imp->setLocalTransformation( vec3_t( 0.0, 2.11, 0.0 ), mat3_t( Euler(-m::PI/2, 0.0, 0.0) ), 0.7 );
+	imp->setLocalTransformation( Vec3( 0.0, 2.11, 0.0 ), Mat3( Euler(-M::PI/2, 0.0, 0.0) ), 0.7 );
 	imp->meshNodes[0]->meshSkelCtrl->skelNode->skelAnimCtrl->skelAnim = rsrc::skel_anims.load( "models/imp/walk.imp.anim" );
 	imp->meshNodes[0]->meshSkelCtrl->skelNode->skelAnimCtrl->step = 0.8;
 
@@ -238,7 +238,7 @@ void Init()
 																	 "textures/env/hellsky4_right.tga", "textures/env/hellsky4_up.tga", "textures/env/hellsky4_down.tga" };
 	scene::skybox.load( skybox_fnames );
 
-	PRINT( "Engine initialization ends (" << app::GetTicks()-ticks << ")" );
+	PRINT( "Engine initialization ends (" << app::getTicks()-ticks << ")" );
 	cerr.flush();
 }
 
@@ -248,20 +248,23 @@ void Init()
 //=====================================================================================================================================
 int main( int /*argc*/, char* /*argv*/[] )
 {
+	float f = M::sin( 10.0 );
+	PRINT( f );
+
 	app::printAppInfo();
 
 	Init();
 
 	PRINT( "Entering main loop" );
-	int ticks = app::GetTicks();
+	int ticks = app::getTicks();
 	do
 	{
-		int ticks_ = app::GetTicks();
+		int ticks_ = app::getTicks();
 		i::HandleEvents();
 		r::PrepareNextFrame();
 
 		float dist = 0.2;
-		float ang = ToRad(3.0);
+		float ang = toRad(3.0);
 		float scale = 0.01;
 
 		// move the camera
@@ -300,7 +303,7 @@ int main( int /*argc*/, char* /*argv*/[] )
 
 		if( i::keys[SDLK_k] ) main_cam->lookAtPoint( point_lights[0]->translationWspace );
 
-		mover->rotationLspace.Reorthogonalize();
+		mover->rotationLspace.reorthogonalize();
 
 
 		scene::updateAllControllers();
@@ -313,16 +316,16 @@ int main( int /*argc*/, char* /*argv*/[] )
 		//map.octree.root->bounding_box.render();
 
 		// print some debug stuff
-		ui::SetColor( vec4_t(1.0, 1.0, 1.0, 1.0) );
+		ui::SetColor( Vec4(1.0, 1.0, 1.0, 1.0) );
 		ui::SetPos( -0.98, 0.95 );
 		ui::SetFontWidth( 0.03 );
-		ui::printf( "frame:%d time:%dms\n", r::frames_num, app::GetTicks()-ticks_ );
+		ui::printf( "frame:%d time:%dms\n", r::frames_num, app::getTicks()-ticks_ );
 		//ui::print( "Movement keys: arrows,w,a,s,d,q,e,shift,space\nSelect objects: keys 1 to 5\n" );
 		ui::printf( "Mover: Pos(%.2f %.2f %.2f) Angs(%.2f %.2f %.2f)", mover->translationWspace.x, mover->translationWspace.y, mover->translationWspace.z,
-								 ToDegrees(Euler(mover->rotationWspace).x), ToDegrees(Euler(mover->rotationWspace).y), ToDegrees(Euler(mover->rotationWspace).z) );
+								 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];
@@ -338,15 +341,15 @@ int main( int /*argc*/, char* /*argv*/[] )
 		if( 1 )
 		{
 			//if( r::frames_num == 10 ) r::TakeScreenshot("gfx/screenshot.tga");
-			app::WaitForNextFrame();
+			app::waitForNextFrame();
 		}
 		else
 			if( r::frames_num == 5000 ) break;
 	}while( true );
-	PRINT( "Exiting main loop (" << app::GetTicks()-ticks << ")" );
+	PRINT( "Exiting main loop (" << app::getTicks()-ticks << ")" );
 
 
 	PRINT( "Exiting..." );
-	app::QuitApp( EXIT_SUCCESS );
+	app::quitApp( EXIT_SUCCESS );
 	return 0;
 }

+ 6 - 6
src/math/Axisang.h

@@ -2,10 +2,10 @@
 #define _AXISANG_H_
 
 #include "common.h"
-#include "forward_decls.h"
+#include "MathForwardDecls.h"
 
 
-namespace m {
+namespace M {
 
 
 class Axisang
@@ -13,13 +13,13 @@ class Axisang
 	public:
 		// data members
 		float ang;
-		vec3_t axis;
+		Vec3 axis;
 		// constructors & distructors
 		explicit Axisang();
 		         Axisang( const Axisang& b );
-		explicit Axisang( float rad, const vec3_t& axis_ );
-		explicit Axisang( const quat_t& q );
-		explicit Axisang( const mat3_t& m3 );
+		explicit Axisang( float rad, const Vec3& axis_ );
+		explicit Axisang( const Quat& q );
+		explicit Axisang( const Mat3& m3 );
 };
 
 

+ 14 - 14
src/math/Axisang.inl.h

@@ -1,6 +1,6 @@
-#include "m_dflt_header.h"
+#include "MathDfltHeader.h"
 
-namespace m {
+namespace M {
 
 
 // constructor []
@@ -14,33 +14,33 @@ inline Axisang::Axisang( const Axisang& b )
 {}
 
 // constructor [float, axis]
-inline Axisang::Axisang( float rad, const vec3_t& axis_ )
+inline Axisang::Axisang( float rad, const Vec3& axis_ )
 	: ang(rad), axis(axis_)
 {}
 
 // constructor [quat]
-inline Axisang::Axisang( const quat_t& q )
+inline Axisang::Axisang( const Quat& q )
 {
 	ang = 2.0*acos( q.w );
-	float length = sqrt( 1.0 - q.w*q.w );
-	if( IsZero(length) )
-		axis = vec3_t(0.0);
+	float length = M::sqrt( 1.0 - q.w*q.w );
+	if( isZero(length) )
+		axis = Vec3(0.0);
 	else
 	{
 		length = 1.0/length;
-		axis = vec3_t( q.x*length, q.y*length, q.z*length );
+		axis = Vec3( q.x*length, q.y*length, q.z*length );
 	}
 }
 
 // constructor [mat3]
-inline Axisang::Axisang( const mat3_t& m3 )
+inline Axisang::Axisang( const Mat3& m3 )
 {
 	if( (fabs(m3(0,1)-m3(1,0))< EPSILON)  && (fabs(m3(0,2)-m3(2,0))< EPSILON)  && (fabs(m3(1,2)-m3(2,1))< EPSILON) )
 	{
 
 		if( (fabs(m3(0,1)+m3(1,0)) < 0.1 ) && (fabs(m3(0,2)+m3(2,0)) < 0.1) && (fabs(m3(1,2)+m3(2,1)) < 0.1) && (fabs(m3(0,0)+m3(1,1)+m3(2,2))-3) < 0.1 )
 		{
-			axis = vec3_t( 1.0, 0.0, 0.0 );
+			axis = Vec3( 1.0, 0.0, 0.0 );
 			ang = 0.0;
 			return;
 		}
@@ -48,17 +48,17 @@ inline Axisang::Axisang( const mat3_t& m3 )
 		ang = PI;
 		axis.x = (m3(0,0)+1)/2;
 		if( axis.x > 0.0 )
-			axis.x = sqrt(axis.x);
+			axis.x = M::sqrt(axis.x);
 		else
 			axis.x = 0;
 		axis.y = (m3(1,1)+1)/2;
 		if( axis.y > 0 )
-			axis.y = sqrt(axis.y);
+			axis.y = M::sqrt(axis.y);
 		else
 			axis.y = 0;
 		axis.z = (m3(2,2)+1)/2;
 		if( axis.z > 0 )
-			axis.z = sqrt(axis.z);
+			axis.z = M::sqrt(axis.z);
 		else
 			axis.z = 0.0;
 
@@ -79,7 +79,7 @@ inline Axisang::Axisang( const mat3_t& m3 )
 		return;
 	}
 
-	float s = sqrt((m3(2,1) - m3(1,2))*(m3(2,1) - m3(1,2))+(m3(0,2) - m3(2,0))*(m3(0,2) - m3(2,0))+(m3(1,0) - m3(0,1))*(m3(1,0) - m3(0,1)));
+	float s = M::sqrt((m3(2,1) - m3(1,2))*(m3(2,1) - m3(1,2))+(m3(0,2) - m3(2,0))*(m3(0,2) - m3(2,0))+(m3(1,0) - m3(0,1))*(m3(1,0) - m3(0,1)));
 
 	if( fabs(s) < 0.001 ) s = 1;
 

+ 4 - 4
src/math/Euler.h

@@ -2,10 +2,10 @@
 #define _EULER_H_
 
 #include "common.h"
-#include "forward_decls.h"
+#include "MathForwardDecls.h"
 
 
-namespace m {
+namespace M {
 
 
 class Euler
@@ -26,8 +26,8 @@ class Euler
 		explicit Euler();
 		explicit Euler( float x, float y, float z  );
 		         Euler( const Euler& b );
-		explicit Euler( const quat_t& q );
-		explicit Euler( const mat3_t& m3 );
+		explicit Euler( const Quat& q );
+		explicit Euler( const Mat3& m3 );
 		// other
 		void print() const;
 };

+ 6 - 6
src/math/Euler.inl.h

@@ -1,7 +1,7 @@
-#include "m_dflt_header.h"
+#include "MathDfltHeader.h"
 
 
-namespace m {
+namespace M {
 
 
 // accessors
@@ -61,7 +61,7 @@ inline Euler::Euler( const Euler& b )
 {}
 
 // constructor [quat]
-inline Euler::Euler( const quat_t& q )
+inline Euler::Euler( const Quat& q )
 {
 	float test = q.x*q.y + q.z*q.w;
 	if( test > 0.499 )
@@ -88,16 +88,16 @@ inline Euler::Euler( const quat_t& q )
 }
 
 // constructor [mat3]
-inline Euler::Euler( const mat3_t& m3 )
+inline Euler::Euler( const Mat3& m3 )
 {
 	float cx, sx;
 	float cy, sy;
 	float cz, sz;
 
 	sy = m3(0,2);
-	cy = sqrt( 1.0 - sy*sy );
+	cy = M::sqrt( 1.0 - sy*sy );
 	// normal case
-	if ( !IsZero( cy ) )
+	if ( !isZero( cy ) )
 	{
 		float factor = 1.0/cy;
 		sx = -m3(1,2) * factor;

+ 99 - 0
src/math/Mat3.h

@@ -0,0 +1,99 @@
+#ifndef _MAT3_H_
+#define _MAT3_H_
+
+#include "common.h"
+#include "MathForwardDecls.h"
+
+
+namespace M {
+
+
+class Mat3
+{
+	private:
+		// data members
+		union
+		{
+			float arr1[9];
+			float arr2[3][3];
+		};
+
+	public:
+		// accessors
+		float& operator ()( const uint i, const uint j );
+		const float& operator ()( const uint i, const uint j ) const;
+		float& operator []( const uint i);
+		const float& operator []( const uint i) const;
+		// constructors & distructors
+		explicit Mat3() {};
+		explicit Mat3( float f );
+		explicit Mat3( float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22 );
+		explicit Mat3( float arr [] );
+		         Mat3( const Mat3& b );
+		explicit Mat3( const Quat& q ); // 12 muls, 12 adds
+		explicit Mat3( const Euler& eu );
+		explicit Mat3( const Axisang& axisang );
+		// ops with mat3
+		Mat3  operator + ( const Mat3& b ) const;
+		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 );
+		Mat3  operator / ( const Mat3& b ) const;
+		Mat3& operator /=( const Mat3& b );
+		// ops with float
+		Mat3  operator + ( float f ) const;
+		Mat3& operator +=( float f );
+		Mat3  operator - ( float f ) const;
+		Mat3& operator -=( float f );
+		Mat3  operator * ( float f ) const;
+		Mat3& operator *=( float f );
+		Mat3  operator / ( float f ) const;
+		Mat3& operator /=( float f );
+		// ops with others
+		Vec3  operator * ( const Vec3& b ) const;  // 9 muls, 6 adds
+		// comparision
+		bool operator ==( const Mat3& b ) const;
+		bool operator !=( const Mat3& b ) const;
+		// other
+		void  setRows( const Vec3& a, const Vec3& b, const Vec3& c );
+		void  setRow( const uint i, const Vec3& v );
+		void  getRows( Vec3& a, Vec3& b, Vec3& c ) const;
+		Vec3  getRow( const uint i ) const;
+		void  setColumns( const Vec3& a, const Vec3& b, const Vec3& c );
+		void  setColumn( const uint i, const Vec3& v );
+		void  getColumns( Vec3& a, Vec3& b, Vec3& c ) const;
+		Vec3  getColumn( const uint i ) const;
+		void  setRotationX( float rad );
+		void  setRotationY( float rad );
+		void  setRotationZ( float rad );
+		void  rotateXAxis( float rad ); // it rotates "this" in the axis defined by the rotation AND not the world axis
+		void  rotateYAxis( float rad );
+		void  rotateZAxis( float rad );
+		void  transpose();
+		Mat3  getTransposed() const;
+		void  reorthogonalize();
+		void  print() const;
+		float getDet() const;
+		void  invert();
+		Mat3  getInverse() const;
+		static const Mat3& getZero();
+		static const Mat3& getIdentity();		
+};
+
+
+// other operators
+extern Mat3 operator +( float f, const Mat3& m3 );
+extern Mat3 operator -( float f, const Mat3& m3 );
+extern Mat3 operator *( float f, const Mat3& m3 );
+extern Mat3 operator /( float f, const Mat3& m3 );
+
+
+} // end namespace
+
+
+#include "Mat3.inl.h"
+
+
+#endif

+ 128 - 128
src/math/mat3.inl.h → src/math/Mat3.inl.h

@@ -1,41 +1,41 @@
-#include "m_dflt_header.h"
+#include "MathDfltHeader.h"
 
 
 #define ME (*this)
 
 
-namespace m {
+namespace M {
 
 // accessors
-inline float& mat3_t::operator ()( const uint i, const uint j )
+inline float& Mat3::operator ()( const uint i, const uint j )
 {
 	return arr2[i][j];
 }
 
-inline const float& mat3_t::operator ()( const uint i, const uint j ) const
+inline const float& Mat3::operator ()( const uint i, const uint j ) const
 {
 	return arr2[i][j]; 
 }
 
-inline float& mat3_t::operator []( const uint i)
+inline float& Mat3::operator []( const uint i)
 {
 	return arr1[i];
 }
 
-inline const float& mat3_t::operator []( const uint i) const
+inline const float& Mat3::operator []( const uint i) const
 {
 	return arr1[i];
 }
 
 // constructor [float[]]
-inline mat3_t::mat3_t( float arr [] )
+inline Mat3::Mat3( float arr [] )
 {
 	for( int i=0; i<9; i++ )
 		ME[i] = arr[i];
 }
 
 // constructor [float...........float]
-inline mat3_t::mat3_t( float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22 )
+inline Mat3::Mat3( float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22 )
 {
 	ME(0,0) = m00;
 	ME(0,1) = m01;
@@ -49,16 +49,16 @@ inline mat3_t::mat3_t( float m00, float m01, float m02, float m10, float m11, fl
 }
 
 // constructor [mat3]
-inline mat3_t::mat3_t( const mat3_t& b )
+inline Mat3::Mat3( const Mat3& b )
 {
 	for( int i=0; i<9; i++ )
 		ME[i] = b[i];
 }
 
 // constructor [quat]
-inline mat3_t::mat3_t( const quat_t& q )
+inline Mat3::Mat3( const Quat& q )
 {
-	DEBUG_ERR( !IsZero( 1.0f - q.Length()) ); // Not normalized quat
+	DEBUG_ERR( !isZero( 1.0f - q.getLength()) ); // Not normalized quat
 
 	float xs, ys, zs, wx, wy, wz, xx, xy, xz, yy, yz, zz;
 
@@ -89,7 +89,7 @@ inline mat3_t::mat3_t( const quat_t& q )
 }
 
 // constructor [euler]
-inline mat3_t::mat3_t( const Euler& e )
+inline Mat3::Mat3( const Euler& e )
 {
 	float ch, sh, ca, sa, cb, sb;
   sinCos( e.heading(), sh, ch );
@@ -108,15 +108,15 @@ inline mat3_t::mat3_t( const Euler& e )
 }
 
 // constructor [axisang]
-inline mat3_t::mat3_t( const Axisang& axisang )
+inline Mat3::Mat3( const Axisang& axisang )
 {
-	DEBUG_ERR( !IsZero( 1.0-axisang.axis.Length() ) ); // Not normalized axis
+	DEBUG_ERR( !isZero( 1.0-axisang.axis.getLength() ) ); // Not normalized axis
 
 	float c, s;
 	sinCos( axisang.ang, s, c );
 	float t = 1.0 - c;
 
-	const vec3_t& axis = axisang.axis;
+	const Vec3& axis = axisang.axis;
 	ME(0,0) = c + axis.x*axis.x*t;
 	ME(1,1) = c + axis.y*axis.y*t;
 	ME(2,2) = c + axis.z*axis.z*t;
@@ -135,23 +135,23 @@ inline mat3_t::mat3_t( const Axisang& axisang )
 }
 
 // constructor [float]
-inline mat3_t::mat3_t( float f )
+inline Mat3::Mat3( float f )
 {
 	for( int i=0; i<9; i++ )
 			ME[i] = f;
 }
 
 // 3x3 + 3x3
-inline mat3_t mat3_t::operator +( const mat3_t& b ) const
+inline Mat3 Mat3::operator +( const Mat3& b ) const
 {
-	mat3_t c;
+	Mat3 c;
 	for( int i=0; i<9; i++ )
 		c[i] = ME[i] + b[i];
 	return c;
 }
 
 // 3x3 += 3x3
-inline mat3_t& mat3_t::operator +=( const mat3_t& b )
+inline Mat3& Mat3::operator +=( const Mat3& b )
 {
 	for( int i=0; i<9; i++ )
 		ME[i] += b[i];
@@ -159,16 +159,16 @@ inline mat3_t& mat3_t::operator +=( const mat3_t& b )
 }
 
 // 3x3 - 3x3
-inline mat3_t mat3_t::operator -( const mat3_t& b ) const
+inline Mat3 Mat3::operator -( const Mat3& b ) const
 {
-	mat3_t c;
+	Mat3 c;
 	for( int i=0; i<9; i++ )
 		c[i] = ME[i] - b[i];
 	return c;
 }
 
 // 3x3 -= 3x3
-inline mat3_t& mat3_t::operator -=( const mat3_t& b )
+inline Mat3& Mat3::operator -=( const Mat3& b )
 {
 	for( int i=0; i<9; i++ )
 		ME[i] -= b[i];
@@ -176,9 +176,9 @@ inline mat3_t& mat3_t::operator -=( const mat3_t& b )
 }
 
 // 3x3 * 3x3
-inline mat3_t mat3_t::operator *( const mat3_t& b ) const
+inline Mat3 Mat3::operator *( const Mat3& b ) const
 {
-	mat3_t c;
+	Mat3 c;
 	c(0, 0) = ME(0, 0)*b(0, 0) + ME(0, 1)*b(1, 0) + ME(0, 2)*b(2, 0);
 	c(0, 1) = ME(0, 0)*b(0, 1) + ME(0, 1)*b(1, 1) + ME(0, 2)*b(2, 1);
 	c(0, 2) = ME(0, 0)*b(0, 2) + ME(0, 1)*b(1, 2) + ME(0, 2)*b(2, 2);
@@ -192,29 +192,29 @@ inline mat3_t mat3_t::operator *( const mat3_t& b ) const
 }
 
 // 3x3 *= 3x3
-inline mat3_t& mat3_t::operator *=( const mat3_t& b )
+inline Mat3& Mat3::operator *=( const Mat3& b )
 {
 	ME = ME * b;
 	return ME;
 }
 
 // 3x3 + float
-inline mat3_t mat3_t::operator +( float f ) const
+inline Mat3 Mat3::operator +( float f ) const
 {
-	mat3_t c;
+	Mat3 c;
 	for( uint i=0; i<9; i++ )
 		c[i] = ME[i] + f;
 	return c;
 }
 
 // float + 3x3
-inline mat3_t operator +( float f, const mat3_t& m3 )
+inline Mat3 operator +( float f, const Mat3& m3 )
 {
 	return m3+f;
 }
 
 // 3x3 += float
-inline mat3_t& mat3_t::operator +=( float f )
+inline Mat3& Mat3::operator +=( float f )
 {
 	for( uint i=0; i<9; i++ )
 		ME[i] += f;
@@ -222,25 +222,25 @@ inline mat3_t& mat3_t::operator +=( float f )
 }
 
 // 3x3 - float
-inline mat3_t mat3_t::operator -( float f ) const
+inline Mat3 Mat3::operator -( float f ) const
 {
-	mat3_t c;
+	Mat3 c;
 	for( uint i=0; i<9; i++ )
 		c[i] = ME[i] - f;
 	return c;
 }
 
 // float - 3x3
-inline mat3_t operator -( float f, const mat3_t& m3 )
+inline Mat3 operator -( float f, const Mat3& m3 )
 {
-	mat3_t out;
+	Mat3 out;
 	for( uint i=0; i<9; i++ )
 		out[i] = f - m3[i];
 	return out;
 }
 
 // 3x3 -= float
-inline mat3_t& mat3_t::operator -=( float f )
+inline Mat3& Mat3::operator -=( float f )
 {
 	for( uint i=0; i<9; i++ )
 		ME[i] -= f;
@@ -248,25 +248,25 @@ inline mat3_t& mat3_t::operator -=( float f )
 }
 
 // 3x3 * float
-inline mat3_t mat3_t::operator *( float f ) const
+inline Mat3 Mat3::operator *( float f ) const
 {
-	mat3_t c;
+	Mat3 c;
 	for( uint i=0; i<9; i++ )
 		c[i] = ME[i] * f;
 	return c;
 }
 
 // float * 3x3
-inline mat3_t operator *( float f, const mat3_t& m3 )
+inline Mat3 operator *( float f, const Mat3& m3 )
 {
-	mat3_t out;
+	Mat3 out;
 	for( uint i=0; i<9; i++ )
 		out[i] = f * m3[i];
 	return out;
 }
 
 // 3x3 *= float
-inline mat3_t& mat3_t::operator *=( float f )
+inline Mat3& Mat3::operator *=( float f )
 {
 	for( uint i=0; i<9; i++ )
 		ME[i] *= f;
@@ -274,25 +274,25 @@ inline mat3_t& mat3_t::operator *=( float f )
 }
 
 // 3x3 / float
-inline mat3_t mat3_t::operator /( float f ) const
+inline Mat3 Mat3::operator /( float f ) const
 {
-	mat3_t c;
+	Mat3 c;
 	for( uint i=0; i<9; i++ )
 		c[i] = ME[i] / f;
 	return c;
 }
 
 // float / 3x3
-inline mat3_t operator /( float f, const mat3_t& m3 )
+inline Mat3 operator /( float f, const Mat3& m3 )
 {
-	mat3_t out;
+	Mat3 out;
 	for( uint i=0; i<9; i++ )
 		out[i] = f / m3[i];
 	return out;
 }
 
 // 3x3 / float (self)
-inline mat3_t& mat3_t::operator /=( float f )
+inline Mat3& Mat3::operator /=( float f )
 {
 	for( uint i=0; i<9; i++ )
 		ME[i] /= f;
@@ -300,9 +300,9 @@ inline mat3_t& mat3_t::operator /=( float f )
 }
 
 // 3x3 * vec3 (cross products with rows)
-inline vec3_t mat3_t::operator *( const vec3_t& b ) const
+inline Vec3 Mat3::operator *( const Vec3& b ) const
 {
-	return vec3_t(
+	return Vec3(
 		ME(0, 0)*b.x + ME(0, 1)*b.y + ME(0, 2)*b.z,
 		ME(1, 0)*b.x + ME(1, 1)*b.y + ME(1, 2)*b.z,
 		ME(2, 0)*b.x + ME(2, 1)*b.y + ME(2, 2)*b.z
@@ -310,23 +310,23 @@ inline vec3_t mat3_t::operator *( const vec3_t& b ) const
 }
 
 // ==
-inline bool mat3_t::operator ==( const mat3_t& b ) const
+inline bool Mat3::operator ==( const Mat3& b ) const
 {
 	for( int i=0; i<9; i++ )
-		if( !IsZero( ME[i]-b[i] ) ) return false;
+		if( !isZero( ME[i]-b[i] ) ) return false;
 	return true;
 }
 
 // !=
-inline bool mat3_t::operator !=( const mat3_t& b ) const
+inline bool Mat3::operator !=( const Mat3& b ) const
 {
 	for( int i=0; i<9; i++ )
-		if( !IsZero( ME[i]-b[i] ) ) return true;
+		if( !isZero( ME[i]-b[i] ) ) return true;
 	return false;
 }
 
-// SetRows
-inline void mat3_t::SetRows( const vec3_t& a, const vec3_t& b, const vec3_t& c )
+// setRows
+inline void Mat3::setRows( const Vec3& a, const Vec3& b, const Vec3& c )
 {
 	ME(0,0) = a.x;
 	ME(0,1) = a.y;
@@ -339,8 +339,8 @@ inline void mat3_t::SetRows( const vec3_t& a, const vec3_t& b, const vec3_t& c )
 	ME(2,2) = c.z;
 }
 
-// SetColumns
-inline void mat3_t::SetColumns( const vec3_t& a, const vec3_t& b, const vec3_t& c )
+// setColumns
+inline void Mat3::setColumns( const Vec3& a, const Vec3& b, const Vec3& c )
 {
 	ME(0,0) = a.x;
 	ME(1,0) = a.y;
@@ -353,8 +353,8 @@ inline void mat3_t::SetColumns( const vec3_t& a, const vec3_t& b, const vec3_t&
 	ME(2,2) = c.z;
 }
 
-// GetRows
-inline void mat3_t::GetRows( vec3_t& a, vec3_t& b, vec3_t& c ) const
+// getRows
+inline void Mat3::getRows( Vec3& a, Vec3& b, Vec3& c ) const
 {
 	a.x = ME(0,0);
 	a.y = ME(0,1);
@@ -367,8 +367,8 @@ inline void mat3_t::GetRows( vec3_t& a, vec3_t& b, vec3_t& c ) const
 	c.z = ME(2,2);
 }
 
-// GetColumns
-inline void mat3_t::GetColumns( vec3_t& a, vec3_t& b, vec3_t& c ) const
+// getColumns
+inline void Mat3::getColumns( Vec3& a, Vec3& b, Vec3& c ) const
 {
 	a.x = ME(0,0);
 	a.y = ME(1,0);
@@ -381,36 +381,36 @@ inline void mat3_t::GetColumns( vec3_t& a, vec3_t& b, vec3_t& c ) const
 	c.z = ME(2,2);
 }
 
-// SetRow
-inline void mat3_t::SetRow( const uint i, const vec3_t& v )
+// setRow
+inline void Mat3::setRow( const uint i, const Vec3& v )
 {
 	ME(i,0)=v.x;
 	ME(i,1)=v.y;
 	ME(i,2)=v.z;
 }
 
-// GetRow
-inline vec3_t mat3_t::GetRow( const uint i ) const
+// getRow
+inline Vec3 Mat3::getRow( const uint i ) const
 {
-	return vec3_t( ME(i,0), ME(i,1), ME(i,2) );
+	return Vec3( ME(i,0), ME(i,1), ME(i,2) );
 }
 
-// SetColumn
-inline void mat3_t::SetColumn( const uint i, const vec3_t& v )
+// setColumn
+inline void Mat3::setColumn( const uint i, const Vec3& v )
 {
 	ME(0,i)=v.x;
 	ME(1,i)=v.y;
 	ME(2,i)=v.z;
 }
 
-// GetColumn
-inline vec3_t mat3_t::GetColumn( const uint i ) const
+// getColumn
+inline Vec3 Mat3::getColumn( const uint i ) const
 {
-	return vec3_t( ME(0,i), ME(1,i), ME(2,i) );
+	return Vec3( ME(0,i), ME(1,i), ME(2,i) );
 }
 
-// SetRotationX
-inline void mat3_t::SetRotationX( float rad )
+// setRotationX
+inline void Mat3::setRotationX( float rad )
 {
 	float sintheta, costheta;
 	sinCos( rad, sintheta, costheta );
@@ -426,8 +426,8 @@ inline void mat3_t::SetRotationX( float rad )
 	ME(2,2) = costheta;
 }
 
-// SetRotationY
-inline void mat3_t::SetRotationY( float rad )
+// setRotationY
+inline void Mat3::setRotationY( float rad )
 {
 	float sintheta, costheta;
 	sinCos( rad, sintheta, costheta );
@@ -444,7 +444,7 @@ inline void mat3_t::SetRotationY( float rad )
 }
 
 // loadRotationZ
-inline void mat3_t::SetRotationZ( float rad )
+inline void Mat3::setRotationZ( float rad )
 {
 	float sintheta, costheta;
 	sinCos( rad, sintheta, costheta );
@@ -460,25 +460,25 @@ inline void mat3_t::SetRotationZ( float rad )
 	ME(2,2) = 1.0f;
 }
 
-// RotateXAxis
+// rotateXAxis
 /* the slow code is in comments and above the comments the optimized one
 If we analize the mat3 we can extract the 3 unit vectors rotated by the mat3. The 3 rotated vectors are in mat's colomns.
-This means that: mat3.colomn[0] == i*mat3. RotateXAxis() rotates rad angle not from i vector (aka x axis) but
+This means that: mat3.colomn[0] == i*mat3. rotateXAxis() rotates rad angle not from i vector (aka x axis) but
 from the vector from colomn 0*/
-inline void mat3_t::RotateXAxis( float rad )
+inline void Mat3::rotateXAxis( float rad )
 {
 	float sina, cosa;
 	sinCos( rad, sina, cosa );
 
-	/*vec3_t x_axis, y_axis, z_axis;
-	GetColumns( x_axis, y_axis, z_axis );*/
+	/*Vec3 x_axis, y_axis, z_axis;
+	getColumns( x_axis, y_axis, z_axis );*/
 
 	// z_axis = z_axis*cosa - y_axis*sina;
 	ME(0,2) = ME(0,2)*cosa - ME(0,1)*sina;
 	ME(1,2) = ME(1,2)*cosa - ME(1,1)*sina;
 	ME(2,2) = ME(2,2)*cosa - ME(2,1)*sina;
 
-	// z_axis.Normalize();
+	// z_axis.normalize();
 	float len = invSqrt( ME(0,2)*ME(0,2) + ME(1,2)*ME(1,2) + ME(2,2)*ME(2,2) );
 	ME(0,2) *= len;
 	ME(1,2) *= len;
@@ -489,31 +489,31 @@ inline void mat3_t::RotateXAxis( float rad )
 	ME(1,1) = ME(2,2)*ME(0,0) - ME(0,2)*ME(2,0);
 	ME(2,1) = ME(0,2)*ME(1,0) - ME(1,2)*ME(0,0);
 
-	// y_axis.Normalize();
+	// y_axis.normalize();
 	/*len = invSqrt( ME(0,1)*ME(0,1) + ME(1,1)*ME(1,1) + ME(2,1)*ME(2,1) );
 	ME(0,1) *= len;
 	ME(1,1) *= len;
 	ME(2,1) *= len;*/
 
-	// SetColumns( x_axis, y_axis, z_axis );
+	// setColumns( x_axis, y_axis, z_axis );
 
 }
 
-// RotateYAxis
-inline void mat3_t::RotateYAxis( float rad )
+// rotateYAxis
+inline void Mat3::rotateYAxis( float rad )
 {
 	float sina, cosa;
 	sinCos( rad, sina, cosa );
 
-	/*vec3_t x_axis, y_axis, z_axis;
-	GetColumns( x_axis, y_axis, z_axis );*/
+	/*Vec3 x_axis, y_axis, z_axis;
+	getColumns( x_axis, y_axis, z_axis );*/
 
 	// z_axis = z_axis*cosa + x_axis*sina;
 	ME(0,2) = ME(0,2)*cosa + ME(0,0)*sina;
 	ME(1,2) = ME(1,2)*cosa + ME(1,0)*sina;
 	ME(2,2) = ME(2,2)*cosa + ME(2,0)*sina;
 
-	// z_axis.Normalize();
+	// z_axis.normalize();
 	float len = invSqrt( ME(0,2)*ME(0,2) + ME(1,2)*ME(1,2) + ME(2,2)*ME(2,2) );
 	ME(0,2) *= len;
 	ME(1,2) *= len;
@@ -524,31 +524,31 @@ inline void mat3_t::RotateYAxis( float rad )
 	ME(1,0) = ME(0,2)*ME(2,1) - ME(2,2)*ME(0,1);
 	ME(2,0) = ME(1,2)*ME(0,1) - ME(0,2)*ME(1,1);
 
-	// x_axis.Normalize();
+	// x_axis.normalize();
 	/*len = invSqrt( ME(0,0)*ME(0,0) + ME(1,0)*ME(1,0) + ME(2,0)*ME(2,0) );
 	ME(0,0) *= len;
 	ME(1,0) *= len;
 	ME(2,0) *= len;*/
 
-	// SetColumns( x_axis, y_axis, z_axis );
+	// setColumns( x_axis, y_axis, z_axis );
 }
 
 
-// RotateZAxis
-inline void mat3_t::RotateZAxis( float rad )
+// rotateZAxis
+inline void Mat3::rotateZAxis( float rad )
 {
 	float sina, cosa;
 	sinCos( rad, sina, cosa );
 
-	/*vec3_t x_axis, y_axis, z_axis;
-	GetColumns( x_axis, y_axis, z_axis );*/
+	/*Vec3 x_axis, y_axis, z_axis;
+	getColumns( x_axis, y_axis, z_axis );*/
 
 	// x_axis = x_axis*cosa + y_axis*sina;
 	ME(0,0) = ME(0,0)*cosa + ME(0,1)*sina;
 	ME(1,0) = ME(1,0)*cosa + ME(1,1)*sina;
 	ME(2,0) = ME(2,0)*cosa + ME(2,1)*sina;
 
-	// x_axis.Normalize();
+	// x_axis.normalize();
 	float len = invSqrt( ME(0,0)*ME(0,0) + ME(1,0)*ME(1,0) + ME(2,0)*ME(2,0) );
 	ME(0,0) *= len;
 	ME(1,0) *= len;
@@ -559,17 +559,17 @@ inline void mat3_t::RotateZAxis( float rad )
 	ME(1,1) = ME(2,2)*ME(0,0) - ME(0,2)*ME(2,0);
 	ME(2,1) = ME(0,2)*ME(1,0) - ME(1,2)*ME(0,0);
 
-	// y_axis.Normalize();
+	// y_axis.normalize();
 	/*len = invSqrt( ME(0,1)*ME(0,1) + ME(1,1)*ME(1,1) + ME(2,1)*ME(2,1) );
 	ME(0,1) *= len;
 	ME(1,1) *= len;
 	ME(2,1) *= len;*/
 
-	//SetColumns( x_axis, y_axis, z_axis );
+	//setColumns( x_axis, y_axis, z_axis );
 }
 
-// Transpose
-inline void mat3_t::Transpose()
+// transpose
+inline void Mat3::transpose()
 {
 	float temp = ME(0,1);
 	ME(0,1) = ME(1,0);
@@ -582,10 +582,10 @@ inline void mat3_t::Transpose()
 	ME(2,1) = temp;
 }
 
-// Transposed
-inline mat3_t mat3_t::GetTransposed() const
+// transposed
+inline Mat3 Mat3::getTransposed() const
 {
-	mat3_t m3;
+	Mat3 m3;
 	m3[0] = ME[0];
 	m3[1] = ME[3];
 	m3[2] = ME[6];
@@ -598,34 +598,34 @@ inline mat3_t mat3_t::GetTransposed() const
 	return m3;
 }
 
-// Reorthogonalize
-inline void mat3_t::Reorthogonalize()
+// reorthogonalize
+inline void Mat3::reorthogonalize()
 {
 	// method 1: standard orthogonalization method
-	/*mat3_t correction_m3 =
+	/*Mat3 correction_m3 =
 	(
-		(mat3_t::ident * 3.0f) -
-		(ME * ME.Transposed())
+		(Mat3::ident * 3.0f) -
+		(ME * ME.transposed())
 	) * 0.5f;
 
 	ME = correction_m3 * ME;*/
 
 	// method 2: Gram-Schmidt method with a twist for z_axis
-	vec3_t x_axis, y_axis, z_axis;
-	GetColumns( x_axis, y_axis, z_axis );
+	Vec3 x_axis, y_axis, z_axis;
+	getColumns( x_axis, y_axis, z_axis );
 
-	x_axis.Normalize();
+	x_axis.normalize();
 
-	y_axis = y_axis - ( x_axis * x_axis.Dot(y_axis) );
-	y_axis.Normalize();
+	y_axis = y_axis - ( x_axis * x_axis.dot(y_axis) );
+	y_axis.normalize();
 
-	z_axis = x_axis.Cross(y_axis);
+	z_axis = x_axis.cross(y_axis);
 
-	SetColumns( x_axis, y_axis, z_axis );
+	setColumns( x_axis, y_axis, z_axis );
 }
 
 // print
-inline void mat3_t::print() const
+inline void Mat3::print() const
 {
 	for( int i=0; i<3; i++ )
 	{
@@ -637,7 +637,7 @@ inline void mat3_t::print() const
 }
 
 // Determinant
-inline float mat3_t::Det() const
+inline float Mat3::getDet() const
 {
 	/* accurate method:
 	return ME(0, 0)*ME(1, 1)*ME(2, 2) + ME(0, 1)*ME(1, 2)*ME(2, 0) + ME(0, 2)*ME(1, 0)*ME(2, 1)
@@ -647,11 +647,11 @@ inline float mat3_t::Det() const
 	ME(0, 2)*( ME(0, 1)*ME(2, 1) - ME(1, 1)*ME(2, 0) );
 }
 
-// GetInverse
-// using Gramer's method ( Inv(A) = ( 1/Det(A) ) * Adj(A)  )
-inline mat3_t mat3_t::GetInverse() const
+// getInverse
+// using Gramer's method ( Inv(A) = ( 1/getDet(A) ) * Adj(A)  )
+inline Mat3 Mat3::getInverse() const
 {
-	mat3_t result;
+	Mat3 result;
 
 	// compute determinant
 	float cofactor0 = ME(1,1)*ME(2,2) - ME(1,2)*ME(2,1);
@@ -659,7 +659,7 @@ inline mat3_t mat3_t::GetInverse() const
 	float cofactor6 = ME(0,1)*ME(1,2) - ME(0,2)*ME(1,1);
 	float det = ME(0,0)*cofactor0 + ME(1,0)*cofactor3 + ME(2,0)*cofactor6;
 
-	DEBUG_ERR( IsZero( det ) ); // Cannot invert det == 0
+	DEBUG_ERR( isZero( det ) ); // Cannot invert det == 0
 
 	// create adjoint matrix and multiply by 1/det to get inverse
 	float invDet = 1.0f/det;
@@ -678,24 +678,24 @@ inline mat3_t mat3_t::GetInverse() const
 	return result;
 }
 
-// Invert
+// invert
 // see above
-inline void mat3_t::Invert()
+inline void Mat3::invert()
 {
-	ME = GetInverse();
+	ME = getInverse();
 }
 
-// GetZero
-inline const mat3_t& mat3_t::GetZero()
+// getZero
+inline const Mat3& Mat3::getZero()
 {
-	static mat3_t zero( 0.0 );
+	static Mat3 zero( 0.0 );
 	return zero;
 }
 
-// GetIdentity
-inline const mat3_t& mat3_t::GetIdentity()
+// getIdentity
+inline const Mat3& Mat3::getIdentity()
 {
-	static mat3_t ident( 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 );
+	static Mat3 ident( 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 );
 	return ident;
 }
 

+ 98 - 0
src/math/Mat4.h

@@ -0,0 +1,98 @@
+#ifndef _MAT4_H_
+#define _MAT4_H_
+
+#include "common.h"
+#include "MathForwardDecls.h"
+
+
+namespace M {
+
+
+class Mat4
+{
+	private:
+		union
+		{
+			float arr1[16];
+			float arr2[4][4];
+		};
+
+	public:
+		// access to the data
+		float& operator ()( const uint i, const uint j );
+		const float& operator ()( const uint i, const uint j ) const;
+		float& operator []( const uint i);
+		const float& operator []( const uint i) const;
+		// constructors & distructors
+		explicit Mat4() {}
+		explicit Mat4( float f );
+		explicit Mat4( float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33 );
+		explicit Mat4( const float arr [] );
+		         Mat4( const Mat4& b );
+		explicit Mat4( const Mat3& m3 );
+		explicit Mat4( const Vec3& v );
+		explicit Mat4( const Vec4& v );
+		explicit Mat4( const Vec3& transl, const Mat3& rot );
+		explicit Mat4( const Vec3& transl, const Mat3& rot, float scale );
+		// ops with same type
+		Mat4  operator + ( const Mat4& b ) const;
+		Mat4& operator +=( const Mat4& b );
+		Mat4  operator - ( const Mat4& b ) const;
+		Mat4& operator -=( const Mat4& b );
+		Mat4  operator * ( const Mat4& b ) const;
+		Mat4& operator *=( const Mat4& b );
+		Mat4  operator / ( const Mat4& b ) const;
+		Mat4& operator /=( const Mat4& b );
+		// ops with float
+		Mat4  operator + ( float f ) const;
+		Mat4& operator +=( float f );
+		Mat4  operator - ( float f ) const;
+		Mat4& operator -=( float f );
+		Mat4  operator * ( float f ) const;
+		Mat4& operator *=( float f );
+		Mat4  operator / ( float f ) const;
+		Mat4& operator /=( float f );
+		// ops with other types
+		Vec4  operator * ( const Vec4& v4 ) const; // 16 muls, 12 adds
+		// comparision
+		bool operator ==( const Mat4& b ) const;
+		bool operator !=( const Mat4& b ) const;
+		// other
+		void  setRows( const Vec4& a, const Vec4& b, const Vec4& c, const Vec4& d );
+		void  setRow( uint i, const Vec4& v );
+		void  setColumns( const Vec4& a, const Vec4& b, const Vec4& c, const Vec4& d );
+		void  setColumn( uint i, const Vec4& v );
+		void  setRotationPart( const Mat3& m3 );
+		void  setTranslationPart( const Vec4& v4 );
+		Mat3  getRotationPart() const;
+		void  setTranslationPart( const Vec3& v3 );
+		Vec3  getTranslationPart() const;
+		void  transpose();
+		Mat4  getTransposed() const;
+		void  print() const;
+		float getDet() const;
+		void  invert();
+		Mat4  getInverse() const;
+		Mat4  getInverseTransformation() const;
+		Mat4  lerp( const Mat4& b, float t ) const;
+		static Mat4 combineTransformations( const Mat4& m0, const Mat4& m1 );  // 12 muls, 27 adds. Something like m4 = m0 * m1 ...
+		                                                                       // ...but without touching the 4rth row and allot faster
+		static const Mat4& getIdentity();
+		static const Mat4& getZero();
+};
+
+
+// other operators
+extern Mat4 operator +( float f, const Mat4& m4 );
+extern Mat4 operator -( float f, const Mat4& m4 );
+extern Mat4 operator *( float f, const Mat4& m4 );
+extern Mat4 operator /( float f, const Mat4& m4 );
+
+
+} // end namespace
+
+
+#include "Mat4.inl.h"
+
+
+#endif

+ 109 - 109
src/math/mat4.inl.h → src/math/Mat4.inl.h

@@ -1,48 +1,48 @@
-#include "m_dflt_header.h"
+#include "MathDfltHeader.h"
 
 
 #define ME (*this)
 
 
-namespace m {
+namespace M {
 
 // accessors
-inline float& mat4_t::operator ()( const uint i, const uint j )
+inline float& Mat4::operator ()( const uint i, const uint j )
 {
 	return arr2[i][j];
 }
 
-inline const float& mat4_t::operator ()( const uint i, const uint j ) const
+inline const float& Mat4::operator ()( const uint i, const uint j ) const
 {
 	return arr2[i][j];
 }
 
-inline float& mat4_t::operator []( const uint i) 
+inline float& Mat4::operator []( const uint i) 
 { 
 	return arr1[i]; 
 }
 
-inline const float& mat4_t::operator []( const uint i) const 
+inline const float& Mat4::operator []( const uint i) const 
 { 
 	return arr1[i]; 
 }
 
 // constructor [mat4]
-inline mat4_t::mat4_t( const mat4_t& b )
+inline Mat4::Mat4( const Mat4& b )
 {
 	for( int i=0; i<16; i++ )
 		ME[i] = b[i];
 }
 
 // constructor [float[]]
-inline mat4_t::mat4_t( const float arr_ [] )
+inline Mat4::Mat4( const float arr_ [] )
 {
 	for( int i=0; i<16; i++ )
 		ME[i] = arr_[i];
 }
 
 // constructor [float..........]
-inline mat4_t::mat4_t( float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33 )
+inline Mat4::Mat4( float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33 )
 {
 	ME(0,0) = m00;
 	ME(0,1) = m01;
@@ -63,7 +63,7 @@ inline mat4_t::mat4_t( float m00, float m01, float m02, float m03, float m10, fl
 }
 
 // constructor [mat3]
-inline mat4_t::mat4_t( const mat3_t& m3 )
+inline Mat4::Mat4( const Mat3& m3 )
 {
 	ME(0,0) = m3(0,0);
 	ME(0,1) = m3(0,1);
@@ -79,7 +79,7 @@ inline mat4_t::mat4_t( const mat3_t& m3 )
 }
 
 // constructor [vec3]
-inline mat4_t::mat4_t( const vec3_t& v )
+inline Mat4::Mat4( const Vec3& v )
 {
 	ME(0, 0) = 1.0;
 	ME(0, 1) = 0.0;
@@ -100,7 +100,7 @@ inline mat4_t::mat4_t( const vec3_t& v )
 }
 
 // constructor [vec4]
-inline mat4_t::mat4_t( const vec4_t& v )
+inline Mat4::Mat4( const Vec4& v )
 {
 	ME(0, 0) = 1.0;
 	ME(0, 1) = 0.0;
@@ -121,46 +121,46 @@ inline mat4_t::mat4_t( const vec4_t& v )
 }
 
 // constructor [vec3, mat3]
-inline mat4_t::mat4_t( const vec3_t& transl, const mat3_t& rot )
+inline Mat4::Mat4( const Vec3& transl, const Mat3& rot )
 {
-	SetRotationPart(rot);
-	SetTranslationPart(transl);
+	setRotationPart(rot);
+	setTranslationPart(transl);
 	ME(3,0) = ME(3,1) = ME(3,2) = 0.0;
 	ME(3,3) = 1.0;
 }
 
 // constructor [vec3, mat3, float]
-inline mat4_t::mat4_t( const vec3_t& translate, const mat3_t& rotate, float scale )
+inline Mat4::Mat4( const Vec3& translate, const Mat3& rotate, float scale )
 {
-	if( !IsZero( scale-1.0 ) )
-		SetRotationPart( rotate*scale );
+	if( !isZero( scale-1.0 ) )
+		setRotationPart( rotate*scale );
 	else
-		SetRotationPart( rotate );
+		setRotationPart( rotate );
 
-	SetTranslationPart( translate );
+	setTranslationPart( translate );
 
 	ME(3,0) = ME(3,1) = ME(3,2) = 0.0;
 	ME(3,3) = 1.0;
 }
 
 // constructor [float]
-inline mat4_t::mat4_t( float f )
+inline Mat4::Mat4( float f )
 {
 	for( int i=0; i<16; i++ )
 		ME[i] = f;
 }
 
 // 4x4 + 4x4
-inline mat4_t mat4_t::operator +( const mat4_t& b ) const
+inline Mat4 Mat4::operator +( const Mat4& b ) const
 {
-	mat4_t c;
+	Mat4 c;
 	for( int i=0; i<16; i++ )
 		c[i] = ME[i] + b[i];
 	return c;
 }
 
 // 4x4 + 4x4 (self)
-inline mat4_t& mat4_t::operator +=( const mat4_t& b )
+inline Mat4& Mat4::operator +=( const Mat4& b )
 {
 	for( int i=0; i<16; i++ )
 		ME[i] += b[i];
@@ -168,16 +168,16 @@ inline mat4_t& mat4_t::operator +=( const mat4_t& b )
 }
 
 // 4x4 - 4x4
-inline mat4_t mat4_t::operator -( const mat4_t& b ) const
+inline Mat4 Mat4::operator -( const Mat4& b ) const
 {
-	mat4_t c;
+	Mat4 c;
 	for( int i=0; i<16; i++ )
 		c[i] = ME[i] - b[i];
 	return c;
 }
 
 // 4x4 - 4x4 (self)
-inline mat4_t& mat4_t::operator -=( const mat4_t& b )
+inline Mat4& Mat4::operator -=( const Mat4& b )
 {
 	for( int i=0; i<16; i++ )
 		ME[i] -= b[i];
@@ -185,9 +185,9 @@ inline mat4_t& mat4_t::operator -=( const mat4_t& b )
 }
 
 // 4x4 * 4x4
-inline mat4_t mat4_t::operator *( const mat4_t& b ) const
+inline Mat4 Mat4::operator *( const Mat4& b ) const
 {
-	mat4_t c;
+	Mat4 c;
 	c(0,0) = ME(0,0)*b(0,0) + ME(0,1)*b(1,0) + ME(0,2)*b(2,0) + ME(0,3)*b(3,0);
 	c(0,1) = ME(0,0)*b(0,1) + ME(0,1)*b(1,1) + ME(0,2)*b(2,1) + ME(0,3)*b(3,1);
 	c(0,2) = ME(0,0)*b(0,2) + ME(0,1)*b(1,2) + ME(0,2)*b(2,2) + ME(0,3)*b(3,2);
@@ -208,32 +208,32 @@ inline mat4_t mat4_t::operator *( const mat4_t& b ) const
 }
 
 // 4x4 * 4x4 (self)
-inline mat4_t& mat4_t::operator *=( const mat4_t& b )
+inline Mat4& Mat4::operator *=( const Mat4& b )
 {
 	ME = ME * b;
 	return ME;
 }
 
 // ==
-inline bool mat4_t::operator ==( const mat4_t& b ) const
+inline bool Mat4::operator ==( const Mat4& b ) const
 {
 	for( int i=0; i<16; i++ )
-		if( !IsZero( ME[i]-b[i] ) ) return false;
+		if( !isZero( ME[i]-b[i] ) ) return false;
 	return true;
 }
 
 // !=
-inline bool mat4_t::operator !=( const mat4_t& b ) const
+inline bool Mat4::operator !=( const Mat4& b ) const
 {
 	for( int i=0; i<16; i++ )
-		if( !IsZero( ME[i]-b[i] ) ) return true;
+		if( !isZero( ME[i]-b[i] ) ) return true;
 	return false;
 }
 
 // 4x4 * vec4
-inline vec4_t mat4_t::operator *( const vec4_t& b ) const
+inline Vec4 Mat4::operator *( const Vec4& b ) const
 {
-	return vec4_t(
+	return Vec4(
 		ME(0,0)*b.x + ME(0,1)*b.y + ME(0,2)*b.z + ME(0,3)*b.w,
 		ME(1,0)*b.x + ME(1,1)*b.y + ME(1,2)*b.z + ME(1,3)*b.w,
 		ME(2,0)*b.x + ME(2,1)*b.y + ME(2,2)*b.z + ME(2,3)*b.w,
@@ -242,22 +242,22 @@ inline vec4_t mat4_t::operator *( const vec4_t& b ) const
 }
 
 // 4x4 + float
-inline mat4_t mat4_t::operator +( float f ) const
+inline Mat4 Mat4::operator +( float f ) const
 {
-	mat4_t c;
+	Mat4 c;
 	for( int i=0; i<16; i++ )
 		c[i] = ME[i] + f;
 	return c;
 }
 
 // float + 4x4
-inline mat4_t operator +( float f, const mat4_t& m4 )
+inline Mat4 operator +( float f, const Mat4& m4 )
 {
 	return m4+f;
 }
 
 // 4x4 + float (self)
-inline mat4_t& mat4_t::operator +=( float f )
+inline Mat4& Mat4::operator +=( float f )
 {
 	for( int i=0; i<16; i++ )
 		ME[i] += f;
@@ -265,25 +265,25 @@ inline mat4_t& mat4_t::operator +=( float f )
 }
 
 // 4x4 - float
-inline mat4_t mat4_t::operator -( float f ) const
+inline Mat4 Mat4::operator -( float f ) const
 {
-	mat4_t c;
+	Mat4 c;
 	for( int i=0; i<16; i++ )
 		c[i] = ME[i] - f;
 	return c;
 }
 
 // float - 4x4
-inline mat4_t operator -( float f, const mat4_t& m4 )
+inline Mat4 operator -( float f, const Mat4& m4 )
 {
-	mat4_t out;
+	Mat4 out;
 	for( int i=0; i<16; i++ )
 		out[i] = f- m4[i];
 	return out;
 }
 
 // 4x4 - float (self)
-inline mat4_t& mat4_t::operator -=( float f )
+inline Mat4& Mat4::operator -=( float f )
 {
 	for( int i=0; i<16; i++ )
 		ME[i] -= f;
@@ -291,22 +291,22 @@ inline mat4_t& mat4_t::operator -=( float f )
 }
 
 // 4x4 * float
-inline mat4_t mat4_t::operator *( float f ) const
+inline Mat4 Mat4::operator *( float f ) const
 {
-	mat4_t c;
+	Mat4 c;
 	for( int i=0; i<16; i++ )
 		c[i] = ME[i] * f;
 	return c;
 }
 
 // float * 4x4
-inline mat4_t operator *( float f, const mat4_t& m4 )
+inline Mat4 operator *( float f, const Mat4& m4 )
 {
 	return m4*f;
 }
 
 // 4x4 *= float
-inline mat4_t& mat4_t::operator *=( float f )
+inline Mat4& Mat4::operator *=( float f )
 {
 	for( int i=0; i<16; i++ )
 		ME[i] *= f;
@@ -314,33 +314,33 @@ inline mat4_t& mat4_t::operator *=( float f )
 }
 
 // 4x4 / float
-inline mat4_t mat4_t::operator /( float f ) const
+inline Mat4 Mat4::operator /( float f ) const
 {
-	mat4_t c;
+	Mat4 c;
 	for( int i=0; i<16; i++ )
 		c[i] = ME[i] / f;
 	return c;
 }
 
 // float / 4x4
-inline mat4_t operator /( float f, const mat4_t& m4 )
+inline Mat4 operator /( float f, const Mat4& m4 )
 {
-	mat4_t out;
+	Mat4 out;
 	for( uint i=0; i<9; i++ )
 		out[i] = f / m4[i];
 	return out;
 }
 
 // 4x4 /= float
-inline mat4_t& mat4_t::operator /=( float f )
+inline Mat4& Mat4::operator /=( float f )
 {
 	for( int i=0; i<16; i++ )
 		ME[i] /= f;
 	return ME;
 }
 
-// SetRows
-inline void mat4_t::SetRows( const vec4_t& a, const vec4_t& b, const vec4_t& c, const vec4_t& d )
+// setRows
+inline void Mat4::setRows( const Vec4& a, const Vec4& b, const Vec4& c, const Vec4& d )
 {
 	ME(0,0) = a.x;
 	ME(0,1) = a.y;
@@ -360,8 +360,8 @@ inline void mat4_t::SetRows( const vec4_t& a, const vec4_t& b, const vec4_t& c,
 	ME(3,3) = d.w;
 }
 
-// SetRow
-inline void mat4_t::SetRow( uint i, const vec4_t& v )
+// setRow
+inline void Mat4::setRow( uint i, const Vec4& v )
 {
 	DEBUG_ERR( i > 3 );
 	ME(i,0) = v.x;
@@ -370,8 +370,8 @@ inline void mat4_t::SetRow( uint i, const vec4_t& v )
 	ME(i,3) = v.w;
 }
 
-// SetColumns
-inline void mat4_t::SetColumns( const vec4_t& a, const vec4_t& b, const vec4_t& c, const vec4_t& d )
+// setColumns
+inline void Mat4::setColumns( const Vec4& a, const Vec4& b, const Vec4& c, const Vec4& d )
 {
 	ME(0,0) = a.x;
 	ME(1,0) = a.y;
@@ -391,8 +391,8 @@ inline void mat4_t::SetColumns( const vec4_t& a, const vec4_t& b, const vec4_t&
 	ME(3,3) = d.w;
 }
 
-// SetColumn
-inline void mat4_t::SetColumn( uint i, const vec4_t& v )
+// setColumn
+inline void Mat4::setColumn( uint i, const Vec4& v )
 {
 	DEBUG_ERR( i > 3 );
 	ME(0,i) = v.x;
@@ -401,8 +401,8 @@ inline void mat4_t::SetColumn( uint i, const vec4_t& v )
 	ME(3,i) = v.w;
 }
 
-// Transpose
-inline void mat4_t::Transpose()
+// transpose
+inline void Mat4::transpose()
 {
 	float tmp = ME(0,1);
 	ME(0,1) = ME(1,0);
@@ -424,11 +424,11 @@ inline void mat4_t::Transpose()
 	ME(3,2) = tmp;
 }
 
-// GetTransposed
+// getTransposed
 // return the transposed
-inline mat4_t mat4_t::GetTransposed() const
+inline Mat4 Mat4::getTransposed() const
 {
-	mat4_t m4;
+	Mat4 m4;
 	m4[0] = ME[0];
 	m4[1] = ME[4];
 	m4[2] = ME[8];
@@ -448,8 +448,8 @@ inline mat4_t mat4_t::GetTransposed() const
 	return m4;
 }
 
-// SetRotationPart
-inline void mat4_t::SetRotationPart( const mat3_t& m3 )
+// setRotationPart
+inline void Mat4::setRotationPart( const Mat3& m3 )
 {
 	ME(0,0) = m3(0,0);
 	ME(0,1) = m3(0,1);
@@ -462,10 +462,10 @@ inline void mat4_t::SetRotationPart( const mat3_t& m3 )
 	ME(2,2) = m3(2,2);
 }
 
-// GetRotationPart
-inline mat3_t mat4_t::GetRotationPart() const
+// getRotationPart
+inline Mat3 Mat4::getRotationPart() const
 {
-	mat3_t m3;
+	Mat3 m3;
 	m3(0,0) = ME(0,0);
 	m3(0,1) = ME(0,1);
 	m3(0,2) = ME(0,2);
@@ -478,8 +478,8 @@ inline mat3_t mat4_t::GetRotationPart() const
 	return m3;
 }
 
-// SetTranslationPart
-inline void mat4_t::SetTranslationPart( const vec4_t& v )
+// setTranslationPart
+inline void Mat4::setTranslationPart( const Vec4& v )
 {
 	ME(0, 3) = v.x;
 	ME(1, 3) = v.y;
@@ -487,36 +487,36 @@ inline void mat4_t::SetTranslationPart( const vec4_t& v )
 	ME(3, 3) = v.w;
 }
 
-// SetTranslationPart
-inline void mat4_t::SetTranslationPart( const vec3_t& v )
+// setTranslationPart
+inline void Mat4::setTranslationPart( const Vec3& v )
 {
 	ME(0, 3) = v.x;
 	ME(1, 3) = v.y;
 	ME(2, 3) = v.z;
 }
 
-// GetTranslationPart
-inline vec3_t mat4_t::GetTranslationPart() const
+// getTranslationPart
+inline Vec3 Mat4::getTranslationPart() const
 {
-	return vec3_t( ME(0, 3), ME(1, 3), ME(2, 3) );
+	return Vec3( ME(0, 3), ME(1, 3), ME(2, 3) );
 }
 
-// GetIdentity
-inline const mat4_t& mat4_t::GetIdentity()
+// getIdentity
+inline const Mat4& Mat4::getIdentity()
 {
-	static mat4_t ident( 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 );
+	static Mat4 ident( 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 );
 	return ident;
 }
 
-// GetZero
-inline const mat4_t& mat4_t::GetZero()
+// getZero
+inline const Mat4& Mat4::getZero()
 {
-	static mat4_t zero( 0.0 );
+	static Mat4 zero( 0.0 );
 	return zero;
 }
 
 // print
-inline void mat4_t::print() const
+inline void Mat4::print() const
 {
 	cout << fixed;
 	for( int i=0; i<4; i++ )
@@ -534,7 +534,7 @@ inline void mat4_t::print() const
 }
 
 // Determinant
-inline float mat4_t::Det() const
+inline float Mat4::getDet() const
 {
 	return
 	ME(0, 3)*ME(1, 2)*ME(2, 1)*ME(3, 0) - ME(0, 2)*ME(1, 3)*ME(2, 1)*ME(3, 0) -
@@ -551,20 +551,20 @@ inline float mat4_t::Det() const
 	ME(0, 1)*ME(1, 0)*ME(2, 2)*ME(3, 3) + ME(0, 0)*ME(1, 1)*ME(2, 2)*ME(3, 3);
 }
 
-// Invert
-inline void mat4_t::Invert()
+// invert
+inline void Mat4::invert()
 {
-	ME = GetInverse();
+	ME = getInverse();
 }
 
 // Inverted
-inline mat4_t mat4_t::GetInverse() const
+inline Mat4 Mat4::getInverse() const
 {
 	float tmp[12];
 	float det;
-	const mat4_t& in = ME;
+	const Mat4& in = ME;
 
-	mat4_t m4;
+	Mat4 m4;
 
 
 	tmp[0] = in(2,2) * in(3,3);
@@ -630,40 +630,40 @@ inline mat4_t mat4_t::GetInverse() const
 
 	det = ME(0,0)*m4(0,0)+ME(1,0)*m4(0,1)+ME(2,0)*m4(0,2)+ME(3,0)*m4(0,3);
 
-	DEBUG_ERR( IsZero( det ) ); // Cannot invert, det == 0
+	DEBUG_ERR( isZero( det ) ); // Cannot invert, det == 0
 	det = 1/det;
 	m4 *= det;
 	return m4;
 }
 
 
-// GetInverseTransformation
-inline mat4_t mat4_t::GetInverseTransformation() const
+// getInverseTransformation
+inline Mat4 Mat4::getInverseTransformation() const
 {
-	mat3_t inverted_rot = (GetRotationPart()).GetTransposed();
-	vec3_t inverted_tsl = GetTranslationPart();
+	Mat3 inverted_rot = (getRotationPart()).getTransposed();
+	Vec3 inverted_tsl = getTranslationPart();
 	inverted_tsl = -( inverted_rot * inverted_tsl );
-	return mat4_t( inverted_tsl, inverted_rot );
+	return Mat4( inverted_tsl, inverted_rot );
 }
 
-// Lerp
-inline mat4_t mat4_t::Lerp( const mat4_t& b, float t ) const
+// lerp
+inline Mat4 Mat4::lerp( const Mat4& b, float t ) const
 {
 	return (ME*(1.0-t))+(b*t);
 }
 
-// CombineTransformations
-inline mat4_t mat4_t::CombineTransformations( const mat4_t& m0, const mat4_t& m1 )
+// combineTransformations
+inline Mat4 Mat4::combineTransformations( const Mat4& m0, const Mat4& m1 )
 {
 	/* the clean code is:
-	mat3_t rot = m0.GetRotationPart() * m1.GetRotationPart();  // combine the rotations
-	vec3_t tra = (m1.GetTranslationPart()).Transformed( m0.GetTranslationPart(), m0.GetRotationPart(), 1.0 );
-	return mat4_t( tra, rot );
+	Mat3 rot = m0.getRotationPart() * m1.getRotationPart();  // combine the rotations
+	Vec3 tra = (m1.getTranslationPart()).Transformed( m0.getTranslationPart(), m0.getRotationPart(), 1.0 );
+	return Mat4( tra, rot );
 	and the optimized: */
-	DEBUG_ERR( !IsZero( m0(3,0)+m0(3,1)+m0(3,2)+m0(3,3)-1.0 ) ||
-	           !IsZero( m1(3,0)+m1(3,1)+m1(3,2)+m1(3,3)-1.0 ) ); // one of the 2 mat4 doesnt represent transformation
+	DEBUG_ERR( !isZero( m0(3,0)+m0(3,1)+m0(3,2)+m0(3,3)-1.0 ) ||
+	           !isZero( m1(3,0)+m1(3,1)+m1(3,2)+m1(3,3)-1.0 ) ); // one of the 2 mat4 doesnt represent transformation
 
-	mat4_t m4;
+	Mat4 m4;
 
 	m4(0, 0) = m0(0, 0)*m1(0, 0) + m0(0, 1)*m1(1, 0) + m0(0, 2)*m1(2, 0);
 	m4(0, 1) = m0(0, 0)*m1(0, 1) + m0(0, 1)*m1(1, 1) + m0(0, 2)*m1(2, 1);

+ 19 - 0
src/math/Math.h

@@ -0,0 +1,19 @@
+#ifndef _MATH_H_
+#define _MATH_H_
+
+
+#include <math.h>
+#include "Vec2.h"
+#include "Vec3.h"
+#include "Vec4.h"
+#include "Quat.h"
+#include "Axisang.h"
+#include "Euler.h"
+#include "Mat3.h"
+#include "Mat4.h"
+#include "MathFuncs.h"
+
+using namespace M;
+
+
+#endif

+ 9 - 0
src/math/MathDfltHeader.h

@@ -0,0 +1,9 @@
+#include "Vec2.h"
+#include "Vec3.h"
+#include "Vec4.h"
+#include "Quat.h"
+#include "Axisang.h"
+#include "Euler.h"
+#include "Mat3.h"
+#include "Mat4.h"
+#include "MathFuncs.h"

+ 15 - 0
src/math/MathForwardDecls.h

@@ -0,0 +1,15 @@
+#ifndef _MATHFORWARDDECLS_H_
+#define _MATHFORWARDDECLS_H_
+
+namespace M {
+	class Vec2;
+	class Vec3;
+	class Vec4;
+	class Quat;
+	class Euler;
+	class Axisang;
+	class Mat3;
+	class Mat4;
+}
+
+#endif

+ 43 - 0
src/math/MathFuncs.h

@@ -0,0 +1,43 @@
+#ifndef _MATHFUNCS_H_
+#define _MATHFUNCS_H_
+
+#include "common.h"
+#include "MathForwardDecls.h"
+
+
+namespace M {
+
+
+const float PI = 3.14159265358979323846;
+const float EPSILON = 1.0e-6;
+
+
+void  mathSanityChecks();
+void  sinCos( float rad, float& sin_, float& cos_ );
+float invSqrt( float f );
+float sqrt( float f );
+float toRad( float degrees );
+float toDegrees( float rad );
+float sin( float rad );
+float cos( float rad );
+bool  isZero( float f );
+
+/**
+ * combineTransformations
+ * mat4(t0,r0,s0)*mat4(t1,r1,s1) == mat4(tf,rf,sf)
+ */
+void combineTransformations( const Vec3& t0, const Mat3& r0, float s0,
+                             const Vec3& t1, const Mat3& r1, float s1,
+                             Vec3& tf, Mat3& rf, float& sf );
+
+/// combineTransformations as the above but without scale
+void combineTransformations( const Vec3& t0, const Mat3& r0, const Vec3& t1, const Mat3& r1, Vec3& tf, Mat3& rf);
+
+
+} // end namespace
+
+
+#include "MathFuncs.inl.h"
+
+
+#endif

+ 20 - 22
src/math/m_misc.inl.h → src/math/MathFuncs.inl.h

@@ -1,7 +1,7 @@
-#include "m_dflt_header.h"
+#include "MathDfltHeader.h"
 
 
-namespace m {
+namespace M {
 
 
 // mathSanityChecks
@@ -9,8 +9,8 @@ namespace m {
 inline void mathSanityChecks()
 {
 	const int fs = sizeof(float); // float size
-	if( sizeof(vec2_t)!=fs*2 || sizeof(vec3_t)!=fs*3 || sizeof(vec4_t)!=fs*4 || sizeof(quat_t)!=fs*4 || sizeof(Euler)!=fs*3 ||
-	    sizeof(mat3_t)!=fs*9 || sizeof(mat4_t)!=fs*16 )
+	if( sizeof(Vec2)!=fs*2 || sizeof(Vec3)!=fs*3 || sizeof(Vec4)!=fs*4 || sizeof(Quat)!=fs*4 || sizeof(Euler)!=fs*3 ||
+	    sizeof(Mat3)!=fs*9 || sizeof(Mat4)!=fs*16 )
 		FATAL("Your compiler does class alignment. Quiting");
 }
 
@@ -62,8 +62,8 @@ inline static float PolynomialSinQuadrant(float a)
 inline void sinCos( float a, float& sina, float& cosa )
 {
 #ifdef _DEBUG_
-	sina = sin(a);
-	cosa = cos(a);
+	sina = M::sin(a);
+	cosa = M::cos(a);
 #else
 	bool negative = false;
 	if (a < 0.0)
@@ -111,31 +111,29 @@ inline void sinCos( float a, float& sina, float& cosa )
 //=====================================================================================================================================
 // Small funcs                                                                                                                        =
 //=====================================================================================================================================
-inline float sqrt( float f ) { return 1/invSqrt(f); }
-inline float ToRad( float degrees ) { return degrees*(PI/180.0); }
-inline float ToDegrees( float rad ) { return rad*(180.0/PI); }
-inline float Sin( float rad ) { return sin(rad); }
-inline float Cos( float rad ) { return cos(rad); }
-inline bool  IsZero( float f ) { return ( fabs(f) < EPSILON ); }
-inline float Max( float a, float b ) { return (a>b) ? a : b; }
-inline float Min( float a, float b ) { return (a<b) ? a : b; }
+inline float sqrt( float f ) { PRINT("LALA") return 1/invSqrt(f); }
+inline float toRad( float degrees ) { return degrees*(PI/180.0); }
+inline float toDegrees( float rad ) { return rad*(180.0/PI); }
+inline float sin( float rad ) { return ::sin(rad); }
+inline float cos( float rad ) { return ::cos(rad); }
+inline bool  isZero( float f ) { return ( fabs(f) < EPSILON ); }
 
 
-//  CombineTransformations
+//  combineTransformations
 //  mat4(t0,r0,s0)*mat4(t1,r1,s1) == mat4(tf,rf,sf)
-inline void CombineTransformations( const vec3_t& t0, const mat3_t& r0, float s0,
-                                      const vec3_t& t1, const mat3_t& r1, float s1,
-                                      vec3_t& tf, mat3_t& rf, float& sf )
+inline void combineTransformations( const Vec3& t0, const Mat3& r0, float s0,
+                                    const Vec3& t1, const Mat3& r1, float s1,
+                                    Vec3& tf, Mat3& rf, float& sf )
 {
-	tf = t1.GetTransformed( t0, r0, s0 );
+	tf = t1.getTransformed( t0, r0, s0 );
 	rf = r0 * r1;
 	sf = s0 * s1;
 }
 
-//  CombineTransformations as the above but without scale
-inline void CombineTransformations( const vec3_t& t0, const mat3_t& r0, const vec3_t& t1, const mat3_t& r1, vec3_t& tf, mat3_t& rf)
+//  combineTransformations as the above but without scale
+inline void combineTransformations( const Vec3& t0, const Mat3& r0, const Vec3& t1, const Mat3& r1, Vec3& tf, Mat3& rf)
 {
-	tf = t1.GetTransformed( t0, r0 );
+	tf = t1.getTransformed( t0, r0 );
 	rf = r0 * r1;
 }
 

+ 57 - 0
src/math/Quat.h

@@ -0,0 +1,57 @@
+#ifndef _QUAT_H_
+#define _QUAT_H_
+
+#include "common.h"
+#include "MathForwardDecls.h"
+
+
+namespace M {
+
+
+class Quat
+{
+	public:
+		// data members
+		float x, y, z, w;
+		static Quat zero;
+		static Quat ident;
+		// constructors & distructors
+		explicit Quat();
+		explicit Quat( float f );
+		explicit Quat( float x, float y, float z, float w );
+		explicit Quat( const Vec2& v2, float z, float w );
+		explicit Quat( const Vec3& v3, float w );
+		explicit Quat( const Vec4& v4 );
+		         Quat( const Quat& b );
+		explicit Quat( const Mat3& m3 );
+		explicit Quat( const Euler& eu );
+		explicit Quat( const Axisang& axisang );
+		// ops with same
+		Quat  operator * ( const Quat& b ) const;
+		Quat& operator *=( const Quat& b );
+		// comparision
+		bool operator ==( const Quat& b ) const;
+		bool operator !=( const Quat& b ) const;
+		// other
+		void  setFrom2Vec3( const Vec3& v0, const Vec3& v1 ); ///< calculates a quat from v0 to v1
+		float getLength() const;
+		void  invert();
+		void  conjugate();
+		Quat  getConjugated() const;
+		void  normalize();
+		Quat  getNormalized() const;
+		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 );
+};
+
+
+} // end namespace
+
+
+#include "Quat.inl.h"
+
+
+#endif

+ 67 - 67
src/math/quat.inl.h → src/math/Quat.inl.h

@@ -1,48 +1,48 @@
-#include "m_dflt_header.h"
+#include "MathDfltHeader.h"
 
 
 #define ME (*this)
 
-namespace m {
+namespace M {
 
 
 // constructor []
-inline quat_t::quat_t()
+inline Quat::Quat()
 	: x(0.0), y(0.0), z(0.0), w(1.0)
 {}
 
 // constructor [float]
-inline quat_t::quat_t( float f )
+inline Quat::Quat( float f )
 	: x(f), y(f), z(f), w(f)
 {}
 
 // constructor [float, float, float, float]
-inline quat_t::quat_t( float x_, float y_, float z_, float w_ )
+inline Quat::Quat( float x_, float y_, float z_, float w_ )
 	: x(x_), y(y_), z(z_), w(w_)
 {}
 
 // constructor [vec2, float, float]
-inline quat_t::quat_t( const vec2_t& v2, float z_, float w_ )
+inline Quat::Quat( const Vec2& v2, float z_, float w_ )
 	: x(v2.x), y(v2.y), z(z_), w(w_)
 {}
 
 // constructor [vec3, float]
-inline quat_t::quat_t( const vec3_t& v3, float w_ )
+inline Quat::Quat( const Vec3& v3, float w_ )
 	: x(v3.x), y(v3.y), z(v3.z), w(w_)
 {}
 
 // constructor [vec4]
-inline quat_t::quat_t( const vec4_t& v4 )
+inline Quat::Quat( const Vec4& v4 )
 	: x(v4.x), y(v4.y), z(v4.z), w(v4.w)
 {}
 
 // constructor [quat]
-inline quat_t::quat_t( const quat_t& b )
+inline Quat::Quat( const Quat& b )
 	: x(b.x), y(b.y), z(b.z), w(b.w)
 {}
 
 // constructor [mat3]
-inline quat_t::quat_t( const mat3_t& m3 )
+inline Quat::Quat( const Mat3& m3 )
 {
 	float trace = m3(0, 0) + m3(1, 1) + m3(2, 2) + 1.0;
 	if( trace > EPSILON )
@@ -83,7 +83,7 @@ inline quat_t::quat_t( const mat3_t& m3 )
 }
 
 // constructor [euler]
-inline quat_t::quat_t( const Euler& eu )
+inline Quat::Quat( const Euler& eu )
 {
 	float cx, sx;
 	sinCos( eu.heading()*0.5, sx, cx );
@@ -103,10 +103,10 @@ inline quat_t::quat_t( const Euler& eu )
 }
 
 // constructor [euler]
-inline quat_t::quat_t( const Axisang& axisang )
+inline Quat::Quat( const Axisang& axisang )
 {
-	float lengthsq = axisang.axis.LengthSquared();
-	if( IsZero( lengthsq ) )
+	float lengthsq = axisang.axis.getLengthSquared();
+	if( isZero( lengthsq ) )
 	{
 		ME = ident;
 		return;
@@ -126,9 +126,9 @@ inline quat_t::quat_t( const Axisang& axisang )
 }
 
 // *
-inline quat_t quat_t::operator *( const quat_t& b ) const
+inline Quat Quat::operator *( const Quat& b ) const
 {
-	return quat_t(
+	return Quat(
 		 x * b.w + y * b.z - z * b.y + w * b.x,
 		-x * b.z + y * b.w + z * b.x + w * b.y,
 		 x * b.y - y * b.x + z * b.w + w * b.z,
@@ -137,140 +137,140 @@ inline quat_t quat_t::operator *( const quat_t& b ) const
 }
 
 // *=
-inline quat_t& quat_t::operator *=( const quat_t& b )
+inline Quat& Quat::operator *=( const Quat& b )
 {
 	ME = ME * b;
 	return ME;
 }
 
 // ==
-inline bool quat_t::operator ==( const quat_t& b ) const
+inline bool Quat::operator ==( const Quat& b ) const
 {
-	return ( IsZero(x-b.x) && IsZero(y-b.y) && IsZero(z-b.z) && IsZero(w-b.w) ) ? true : false;
+	return ( isZero(x-b.x) && isZero(y-b.y) && isZero(z-b.z) && isZero(w-b.w) ) ? true : false;
 }
 
 // !=
-inline bool quat_t::operator !=( const quat_t& b ) const
+inline bool Quat::operator !=( const Quat& b ) const
 {
-	return ( IsZero(x-b.x) && IsZero(y-b.y) && IsZero(z-b.z) && IsZero(w-b.w) ) ? false : true;
+	return ( isZero(x-b.x) && isZero(y-b.y) && isZero(z-b.z) && isZero(w-b.w) ) ? false : true;
 }
 
-// Conjugate
-inline void quat_t::Conjugate()
+// conjugate
+inline void Quat::conjugate()
 {
 	x = -x;
 	y = -y;
 	z = -z;
 }
 
-// Conjugated
-inline quat_t quat_t::Conjugated() const
+// getConjugated
+inline Quat Quat::getConjugated() const
 {
-	return quat_t( -x, -y, -z, w );
+	return Quat( -x, -y, -z, w );
 }
 
 // Normalized
-inline quat_t quat_t::GetNormalized() const
+inline Quat Quat::getNormalized() const
 {
-	return quat_t( vec4_t(ME).GetNormalized() );
+	return Quat( Vec4(ME).getNormalized() );
 }
 
-// Normalize
-inline void quat_t::Normalize()
+// normalize
+inline void Quat::normalize()
 {
-	ME = GetNormalized();
+	ME = getNormalized();
 }
 
-// Length
-inline float quat_t::Length() const
+// getLength
+inline float Quat::getLength() const
 {
-	return sqrt( w*w + x*x + y*y + z*z );
+	return M::sqrt( w*w + x*x + y*y + z*z );
 }
 
-// Invert
-inline void quat_t::Invert()
+// invert
+inline void Quat::invert()
 {
 	float norm = w*w + x*x + y*y + z*z;
 
-	DEBUG_ERR( IsZero(norm) ); // Norm is zero
+	DEBUG_ERR( isZero(norm) ); // Norm is zero
 
 	float normi = 1.0 / norm;
-	ME = quat_t( -normi*x, -normi*y, -normi*z, normi*w );
+	ME = Quat( -normi*x, -normi*y, -normi*z, normi*w );
 }
 
 // print
-inline void quat_t::print() const
+inline void Quat::print() const
 {
 	cout << fixed << "(w,x,y,z) = " << w << ' ' << x << ' ' << y << ' ' << z  << '\n' << endl;
 }
 
 // CalcFromVecVec
-inline void quat_t::CalcFrom2Vec3( const vec3_t& from, const vec3_t& to )
+inline void Quat::setFrom2Vec3( const Vec3& from, const Vec3& to )
 {
-	vec3_t axis( from.Cross(to) );
-	ME = quat_t( axis.x, axis.y, axis.z, from.Dot(to) );
-	Normalize();
+	Vec3 axis( from.cross(to) );
+	ME = Quat( axis.x, axis.y, axis.z, from.dot(to) );
+	normalize();
 	w += 1.0;
 
 	if( w <= EPSILON )
 	{
 		if( from.z*from.z > from.x*from.x )
-			ME = quat_t( 0.0, from.z, -from.y, 0.0 );
+			ME = Quat( 0.0, from.z, -from.y, 0.0 );
 		else
-			ME = quat_t( from.y, -from.x, 0.0, 0.0 );
+			ME = Quat( from.y, -from.x, 0.0, 0.0 );
 	}
-	Normalize();
+	normalize();
 }
 
 // Rotated
-inline quat_t quat_t::GetRotated( const quat_t& b ) const
+inline Quat Quat::getRotated( const Quat& b ) const
 {
 	return ME * b;
 }
 
-// Rotate
-inline void quat_t::Rotate( const quat_t& b )
+// rotate
+inline void Quat::rotate( const Quat& b )
 {
-	ME = GetRotated( b );
+	ME = getRotated( b );
 }
 
-// Dot
-inline float quat_t::Dot( const quat_t& b ) const
+// dot
+inline float Quat::dot( const Quat& b ) const
 {
 	return w*b.w + x*b.x + y*b.y + z*b.z;
 }
 
 // SLERP
-inline quat_t quat_t::Slerp( const quat_t& q1_, float t ) const
+inline Quat Quat::slerp( const Quat& q1_, float t ) const
 {
-	const quat_t& q0 = ME;
-	quat_t q1( q1_ );
+	const Quat& q0 = ME;
+	Quat q1( q1_ );
 	float cos_half_theta = q0.w*q1.w + q0.x*q1.x + q0.y*q1.y + q0.z*q1.z;
 	if( cos_half_theta < 0.0 )
 	{
-		q1 = quat_t( -vec4_t(q1) ); // quat changes
+		q1 = Quat( -Vec4(q1) ); // quat changes
 		cos_half_theta = -cos_half_theta;
 	}
 	if( fabs(cos_half_theta) >= 1.0f )
 	{
-		return quat_t( q0 );
+		return Quat( q0 );
 	}
 
 	float half_theta = acos( cos_half_theta );
-	float sin_half_theta = sqrt(1.0 - cos_half_theta*cos_half_theta);
+	float sinhalf_theta = M::sqrt(1.0 - cos_half_theta*cos_half_theta);
 
-	if( fabs(sin_half_theta) < 0.001 )
+	if( fabs(sinhalf_theta) < 0.001 )
 	{
-		return quat_t( (vec4_t(q0) + vec4_t(q1))*0.5 );
+		return Quat( (Vec4(q0) + Vec4(q1))*0.5 );
 	}
-	float ratio_a = sin((1.0 - t) * half_theta) / sin_half_theta;
-	float ratio_b = sin(t * half_theta) / sin_half_theta;
-	vec4_t tmp, tmp1, sum;
-	tmp = vec4_t(q0)*ratio_a;
-	tmp1 = vec4_t(q1)*ratio_b;
+	float ratio_a = sin((1.0 - t) * half_theta) / sinhalf_theta;
+	float ratio_b = sin(t * half_theta) / sinhalf_theta;
+	Vec4 tmp, tmp1, sum;
+	tmp = Vec4(q0)*ratio_a;
+	tmp1 = Vec4(q1)*ratio_b;
 	sum = tmp + tmp1;
-	sum.Normalize();
-	return quat_t( sum );
+	sum.normalize();
+	return Quat( sum );
 }
 
 

+ 75 - 0
src/math/Vec2.h

@@ -0,0 +1,75 @@
+#ifndef _VEC2_H_
+#define _VEC2_H_
+
+#include "common.h"
+#include "MathForwardDecls.h"
+
+
+namespace M {
+
+
+class Vec2
+{
+	public:
+		// data members
+		float x, y;
+		static const Vec2 zero;
+		static const Vec2 one;
+		// accessors
+		float& operator []( uint i );
+		float  operator []( uint i ) const;
+		// constructors & distructors
+		explicit Vec2();
+		explicit Vec2( float f );
+		explicit Vec2( float x, float y );
+		         Vec2( const Vec2& b );
+		explicit Vec2( const Vec3& v3 );
+		explicit Vec2( const Vec4& v4 );
+		// ops with same type
+		Vec2  operator + ( const Vec2& b ) const;
+		Vec2& operator +=( const Vec2& b );
+		Vec2  operator - ( const Vec2& b ) const;
+		Vec2& operator -=( const Vec2& b );
+		Vec2  operator * ( const Vec2& b ) const;
+		Vec2& operator *=( const Vec2& b );
+		Vec2  operator / ( const Vec2& b ) const;
+		Vec2& operator /=( const Vec2& b );
+		Vec2  operator - () const;
+		// ops with float
+		Vec2  operator + ( float f ) const;
+		Vec2& operator +=( float f );
+		Vec2  operator - ( float f ) const;
+		Vec2& operator -=( float f );
+		Vec2  operator * ( float f ) const;
+		Vec2& operator *=( float f );
+		Vec2  operator / ( float f ) const;
+		Vec2& operator /=( float f );
+		// comparision
+		bool operator ==( const Vec2& b ) const;
+		bool operator !=( const Vec2& b ) const;
+		// other
+		static Vec2 getZero();
+		static Vec2 getOne();
+		float  getLength() const;
+		void   setZero();
+		void   normalize();
+		Vec2   getNormalized() const;
+		float  dot( const Vec2& b ) const;
+		void   print() const;
+};
+
+
+// other operators
+extern Vec2 operator +( float f, const Vec2& v2 );
+extern Vec2 operator -( float f, const Vec2& v2 );
+extern Vec2 operator *( float f, const Vec2& v2 );
+extern Vec2 operator /( float f, const Vec2& v2 );
+
+
+} // end namespace
+
+
+#include "Vec2.inl.h"
+
+
+#endif

+ 246 - 0
src/math/Vec2.inl.h

@@ -0,0 +1,246 @@
+#include "MathDfltHeader.h"
+
+
+#define ME (*this)
+
+namespace M {
+
+// accessors
+inline float& Vec2::operator []( uint i )
+{
+	return (&x)[i];
+}
+
+inline float Vec2::operator []( uint i ) const
+{
+	return (&x)[i];
+}
+
+// constructor []
+inline Vec2::Vec2()
+	: x(0.0), y(0.0)
+{}
+
+// constructor [float, float]
+inline Vec2::Vec2( float x_, float y_ )
+	: x(x_), y(y_)
+{}
+
+// constructor [float]
+inline Vec2::Vec2( float f ): x(f), y(f)
+{}
+
+// constructor [vec2]
+inline Vec2::Vec2( const Vec2& b ): x(b.x), y(b.y)
+{}
+
+// constructor [vec3]
+inline Vec2::Vec2( const Vec3& v3 ): x(v3.x), y(v3.y)
+{}
+
+// constructor [vec4]
+inline Vec2::Vec2( const Vec4& v4 ): x(v4.x), y(v4.y)
+{}
+
+// +
+inline Vec2 Vec2::operator +( const Vec2& b ) const
+{
+	return Vec2( x+b.x, y+b.y );
+}
+
+// +=
+inline Vec2& Vec2::operator +=( const Vec2& b )
+{
+	x += b.x;
+	y += b.y;
+	return ME;
+}
+
+// -
+inline Vec2 Vec2::operator -( const Vec2& b ) const
+{
+	return Vec2( x-b.x, y-b.y );
+}
+
+// -=
+inline Vec2& Vec2::operator -=( const Vec2& b )
+{
+	x -= b.x;
+	y -= b.y;
+	return ME;
+}
+
+// *
+inline Vec2 Vec2::operator *( const Vec2& b ) const
+{
+	return Vec2( x*b.x, y*b.y );
+}
+
+// *=
+inline Vec2& Vec2::operator *=( const Vec2& b )
+{
+	x *= b.x;
+	y *= b.y;
+	return ME;
+}
+
+// /
+inline Vec2 Vec2::operator /( const Vec2& b ) const
+{
+	return Vec2( x/b.x, y/b.y );
+}
+
+// /=
+inline Vec2& Vec2::operator /=( const Vec2& b )
+{
+	x /= b.x;
+	y /= b.y;
+	return ME;
+}
+
+// negative
+inline Vec2 Vec2::operator -() const
+{
+	return Vec2( -x, -y );
+}
+
+// ==
+inline bool Vec2::operator ==( const Vec2& b ) const
+{
+	return ( isZero(x-b.x) && isZero(y-b.y) ) ? true : false;
+}
+
+// !=
+inline bool Vec2::operator !=( const Vec2& b ) const
+{
+	return ( isZero(x-b.x) && isZero(y-b.y) ) ? false : true;
+}
+
+// vec2 + float
+inline Vec2 Vec2::operator +( float f ) const
+{
+	return ME + Vec2(f);
+}
+
+// float + vec2
+inline Vec2 operator +( float f, const Vec2& v2 )
+{
+	return v2+f;
+}
+
+// vec2 += float
+inline Vec2& Vec2::operator +=( float f )
+{
+	ME += Vec2(f);
+	return ME;
+}
+
+// vec2 - float
+inline Vec2 Vec2::operator -( float f ) const
+{
+	return ME - Vec2(f);
+}
+
+// float - vec2
+inline Vec2 operator -( float f, const Vec2& v2 )
+{
+	return Vec2( f-v2.x, f-v2.y );
+}
+
+// vec2 -= float
+inline Vec2& Vec2::operator -=( float f )
+{
+	ME -= Vec2(f);
+	return ME;
+}
+
+// vec2 * float
+inline Vec2 Vec2::operator *( float f ) const
+{
+	return ME * Vec2(f);
+}
+
+// float * vec2
+inline Vec2 operator *( float f, const Vec2& v2 )
+{
+	return v2*f;
+}
+
+// vec2 *= float
+inline Vec2& Vec2::operator *=( float f )
+{
+	ME *= Vec2(f);
+	return ME;
+}
+
+// vec2 / float
+inline Vec2 Vec2::operator /( float f ) const
+{
+	return ME / Vec2(f);
+}
+
+// float / vec2
+inline Vec2 operator /( float f, const Vec2& v2 )
+{
+	return Vec2( f/v2.x, f/v2.y );
+}
+
+// vec2 /= float
+inline Vec2& Vec2::operator /=( float f )
+{
+	ME /= Vec2(f);
+	return ME;
+}
+
+// getLength
+inline float Vec2::getLength() const
+{
+	return M::sqrt( x*x + y*y );
+}
+
+// set to zero
+inline void Vec2::setZero()
+{
+	x = y = 0.0;
+}
+
+// normalize
+inline void Vec2::normalize()
+{
+	ME *= invSqrt( x*x + y*y );
+}
+
+// Normalized (return the normalized)
+inline Vec2 Vec2::getNormalized() const
+{
+	return ME * invSqrt( x*x + y*y );
+}
+
+// dot
+inline float Vec2::dot( const Vec2& b ) const
+{
+	return x*b.x + y*b.y;
+}
+
+// getZero
+inline Vec2 Vec2::getZero()
+{
+	return Vec2(0.0);
+}
+
+// getOne
+inline Vec2 Vec2::getOne()
+{
+	return Vec2(1.0);
+}
+
+// print
+inline void Vec2::print() const
+{
+	for( int i=0; i<2; i++ )
+		cout << fixed << ME[i] << ' ';
+	cout << "\n" << endl;
+}
+
+
+} // end namespace

+ 91 - 0
src/math/Vec3.h

@@ -0,0 +1,91 @@
+#ifndef _VEC3_H_
+#define _VEC3_H_
+
+#include "common.h"
+#include "MathForwardDecls.h"
+
+
+namespace M {
+
+
+class Vec3
+{
+	public:
+		// data members
+		float x, y, z;
+		// accessors
+		float& operator []( uint i );
+		float  operator []( uint i ) const;
+		// constructors & distructors
+		explicit Vec3();
+		explicit Vec3( float f );
+		explicit Vec3( float x, float y, float z );
+		explicit Vec3( const Vec2& v2, float z );
+		         Vec3( const Vec3& b );
+		explicit Vec3( const Vec4& v4 );
+		explicit Vec3( const Quat& q );
+		// ops with same type
+		Vec3  operator + ( const Vec3& b ) const;
+		Vec3& operator +=( const Vec3& b );
+		Vec3  operator - ( const Vec3& b ) const;
+		Vec3& operator -=( const Vec3& b );
+		Vec3  operator * ( const Vec3& b ) const;
+		Vec3& operator *=( const Vec3& b );
+		Vec3  operator / ( const Vec3& b ) const;
+		Vec3& operator /=( const Vec3& b );
+		Vec3  operator - () const; // return the negative
+		// ops with float
+		Vec3  operator + ( float f ) const;
+		Vec3& operator +=( float f );
+		Vec3  operator - ( float f ) const;
+		Vec3& operator -=( float f );
+		Vec3  operator * ( float f ) const;
+		Vec3& operator *=( float f );
+		Vec3  operator / ( float f ) const;
+		Vec3& operator /=( float f );
+		// ops with other types
+		Vec3  operator * ( const Mat3& m3 ) const;
+		// comparision
+		bool operator ==( const Vec3& b ) const;
+		bool operator !=( const Vec3& b ) const;
+		// other
+		float dot( const Vec3& b ) const;
+		Vec3  cross( const Vec3& b ) const;
+		float getLength() const;
+		float getLengthSquared() const;
+		float getDistanceSquared( const Vec3& b ) const;
+		void  normalize();
+		Vec3  getNormalized() const;
+		Vec3  getProjection( const Vec3& to_this ) const;
+		Vec3  getRotated( const Quat& q ) const; // returns q * this * q.Conjucated() aka returns a rotated this. 18 muls, 12 adds
+		void  rotate( const Quat& q );
+		Vec3  lerp( const Vec3& v1, float t ) const; // return lerp( this, v1, t )
+		void  print() const;
+		// transformations. The faster way is by far the mat4 * vec3 or the Transformed( Vec3, Mat3 )
+		Vec3  getTransformed( const Vec3& translate, const Mat3& rotate, float scale ) const;
+		void  transform( const Vec3& translate, const Mat3& rotate, float scale );
+		Vec3  getTransformed( const Vec3& translate, const Mat3& rotate ) const;
+		void  transform( const Vec3& translate, const Mat3& rotate );
+		Vec3  getTransformed( const Vec3& translate, const Quat& rotate, float scale ) const;
+		void  transform( const Vec3& translate, const Quat& rotate, float scale );
+		Vec3  getTransformed( const Vec3& translate, const Quat& rotate ) const;
+		void  transform( const Vec3& translate, const Quat& rotate );
+		Vec3  getTransformed( const Mat4& transform ) const;  // 9 muls, 9 adds
+		void  transform( const Mat4& transform );
+};
+
+
+// other operators
+extern Vec3 operator +( float f, const Vec3& v );
+extern Vec3 operator -( float f, const Vec3& v );
+extern Vec3 operator *( float f, const Vec3& v );
+extern Vec3 operator /( float f, const Vec3& v );
+
+
+} // end namespace
+
+
+#include "Vec3.inl.h"
+
+
+#endif

+ 347 - 0
src/math/Vec3.inl.h

@@ -0,0 +1,347 @@
+#include "MathDfltHeader.h"
+
+
+#define ME (*this)
+
+
+namespace M {
+
+
+// accessors
+inline float& Vec3::operator []( uint i )
+{
+	return (&x)[i];
+}
+
+inline float Vec3::operator []( uint i ) const
+{
+	return (&x)[i];
+}
+
+// constructor []
+inline Vec3::Vec3()
+	: x(0.0), y(0.0), z(0.0)
+{}
+
+// constructor [float, float, float]
+inline Vec3::Vec3( float x_, float y_, float z_ )
+	: x(x_), y(y_), z(z_)
+{}
+
+// constructor [float]
+inline Vec3::Vec3( float f )
+	: x(f), y(f), z(f)
+{}
+
+// constructor [vec3]
+inline Vec3::Vec3( const Vec3& b )
+	: x(b.x), y(b.y), z(b.z)
+{}
+
+// constructor [vec2, float]
+inline Vec3::Vec3( const Vec2& v2, float z_ )
+	: x(v2.x), y(v2.y), z(z_)
+{}
+
+// constructor [vec4]
+inline Vec3::Vec3( const Vec4& v4 )
+	: x(v4.x), y(v4.y), z(v4.z)
+{}
+
+// constructor [quat]
+inline Vec3::Vec3( const Quat& q )
+	: x(q.x), y(q.y), z(q.z)
+{}
+
+// +
+inline Vec3 Vec3::operator +( const Vec3& b ) const
+{
+	return Vec3( x+b.x, y+b.y, z+b.z );
+}
+
+// +=
+inline Vec3& Vec3::operator +=( const Vec3& b )
+{
+	x += b.x;
+	y += b.y;
+	z += b.z;
+	return ME;
+}
+
+// -
+inline Vec3 Vec3::operator -( const Vec3& b ) const
+{
+	return Vec3( x-b.x, y-b.y, z-b.z );
+}
+
+// -=
+inline Vec3& Vec3::operator -=( const Vec3& b )
+{
+	x -= b.x;
+	y -= b.y;
+	z -= b.z;
+	return ME;
+}
+
+// *
+inline Vec3 Vec3::operator *( const Vec3& b ) const
+{
+	return Vec3( x*b.x, y*b.y, z*b.z );
+}
+
+// *=
+inline Vec3& Vec3::operator *=( const Vec3& b )
+{
+	x *= b.x;
+	y *= b.y;
+	z *= b.z;
+	return ME;
+}
+
+// /
+inline Vec3 Vec3::operator /( const Vec3& b ) const
+{
+	return Vec3( x/b.x, y/b.y, z/b.z );
+}
+
+// /=
+inline Vec3& Vec3::operator /=( const Vec3& b )
+{
+	x /= b.x;
+	y /= b.y;
+	z /= b.z;
+	return ME;
+}
+
+// negative
+inline Vec3 Vec3::operator -() const
+{
+	return Vec3( -x, -y, -z );
+}
+
+// ==
+inline bool Vec3::operator ==( const Vec3& b ) const
+{
+	return ( isZero(x-b.x) && isZero(y-b.y) && isZero(z-b.z) ) ? true : false;
+}
+
+// !=
+inline bool Vec3::operator !=( const Vec3& b ) const
+{
+	return ( isZero(x-b.x) && isZero(y-b.y) && isZero(z-b.z) ) ? false : true;
+}
+
+// vec3 + float
+inline Vec3 Vec3::operator +( float f ) const
+{
+	return ME + Vec3(f);
+}
+
+// float + vec3
+inline Vec3 operator +( float f, const Vec3& v )
+{
+	return v+f;
+}
+
+// vec3 += float
+inline Vec3& Vec3::operator +=( float f )
+{
+	ME += Vec3(f);
+	return ME;
+}
+
+// vec3 - float
+inline Vec3 Vec3::operator -( float f ) const
+{
+	return ME - Vec3(f);
+}
+
+// float - vec3
+inline Vec3 operator -( float f, const Vec3& v )
+{
+	return Vec3(f-v.x, f-v.y, f-v.z);
+}
+
+// vec3 -= float
+inline Vec3& Vec3::operator -=( float f )
+{
+	ME -= Vec3(f);
+	return ME;
+}
+
+// vec3 * float
+inline Vec3 Vec3::operator *( float f ) const
+{
+	return ME * Vec3(f);
+}
+
+// float * vec3
+inline Vec3 operator *( float f, const Vec3& v )
+{
+	return v*f;
+}
+
+// vec3 *= float
+inline Vec3& Vec3::operator *=( float f )
+{
+	ME *= Vec3(f);
+	return ME;
+}
+
+// vec3 / float
+inline Vec3 Vec3::operator /( float f ) const
+{
+	return ME / Vec3(f);
+}
+
+// float / vec3
+inline Vec3 operator /( float f, const Vec3& v )
+{
+	return Vec3(f/v.x, f/v.y, f/v.z);
+}
+
+// vec3 /= float
+inline Vec3& Vec3::operator /=( float f )
+{
+	ME /= Vec3(f);
+	return ME;
+}
+
+// dot
+inline float Vec3::dot( const Vec3& b ) const
+{
+	return x*b.x + y*b.y + z*b.z;
+}
+
+// cross prod
+inline Vec3 Vec3::cross( const Vec3& b ) const
+{
+	return Vec3( y*b.z-z*b.y, z*b.x-x*b.z, x*b.y-y*b.x );
+}
+
+// getLength
+inline float Vec3::getLength() const
+{
+	return M::sqrt( x*x + y*y + z*z );
+}
+
+// getLengthSquared
+inline float Vec3::getLengthSquared() const
+{
+	return x*x + y*y + z*z;
+}
+
+// getDistanceSquared
+inline float Vec3::getDistanceSquared( const Vec3& b ) const
+{
+	return (ME-b).getLengthSquared();
+}
+
+// normalize
+inline void Vec3::normalize()
+{
+	ME *= invSqrt( x*x + y*y + z*z );
+}
+
+// Normalized (return the normalized)
+inline Vec3 Vec3::getNormalized() const
+{
+	return ME * invSqrt( x*x + y*y + z*z );
+}
+
+// getProjection
+inline Vec3 Vec3::getProjection( const Vec3& to_this ) const
+{
+	return to_this * ( ME.dot(to_this)/(to_this.dot(to_this)) );
+}
+
+// Rotated
+inline Vec3 Vec3::getRotated( const Quat& q ) const
+{
+	DEBUG_ERR( !isZero(1.0f-q.getLength()) ); // Not normalized quat
+
+	/*float vmult = 2.0f*(q.x*x + q.y*y + q.z*z);
+	float crossmult = 2.0*q.w;
+	float pmult = crossmult*q.w - 1.0;
+
+	return Vec3( pmult*x + vmult*q.x + crossmult*(q.y*z - q.z*y),
+							   pmult*y + vmult*q.y + crossmult*(q.z*x - q.x*z),
+	               pmult*z + vmult*q.z + crossmult*(q.x*y - q.y*x) );*/
+	Vec3 q_xyz( q );
+	return ME + q_xyz.cross( q_xyz.cross(ME) + ME*q.w ) * 2.0;
+}
+
+// rotate
+inline void Vec3::rotate( const Quat& q )
+{
+	ME = getRotated(q);
+}
+
+// print
+inline void Vec3::print() const
+{
+	for( int i=0; i<3; i++ )
+		cout << fixed << ME[i] << " ";
+	cout << "\n" << endl;
+}
+
+// lerp
+inline Vec3 Vec3::lerp( const Vec3& v1, float t ) const
+{
+	return (ME*(1.0f-t))+(v1*t);
+}
+
+// getTransformed [mat3]
+inline Vec3 Vec3::getTransformed( const Vec3& translate, const Mat3& rotate, float scale ) const
+{
+	return (rotate * (ME * scale)) + translate;
+}
+
+// transform [mat3]
+inline void Vec3::transform( const Vec3& translate, const Mat3& rotate, float scale )
+{
+	ME = getTransformed( translate, rotate, scale );
+}
+
+// getTransformed [mat3] no scale
+inline Vec3 Vec3::getTransformed( const Vec3& translate, const Mat3& rotate ) const
+{
+	return (rotate * ME) + translate;
+}
+
+// transform [mat3] no scale
+inline void Vec3::transform( const Vec3& translate, const Mat3& rotate )
+{
+	ME = getTransformed( translate, rotate );
+}
+
+// getTransformed [quat]
+inline Vec3 Vec3::getTransformed( const Vec3& translate, const Quat& rotate, float scale ) const
+{
+	return (ME * scale).getRotated(rotate) + translate;
+}
+
+// transform [quat3] no scale
+inline void Vec3::transform( const Vec3& translate, const Quat& rotate, float scale )
+{
+	ME = getTransformed( translate, rotate, scale );
+}
+
+// getTransformed [mat4]
+inline Vec3 Vec3::getTransformed( const Mat4& transform ) const
+{
+	return Vec3(
+		transform(0,0)*x + transform(0,1)*y + transform(0,2)*z + transform(0,3),
+		transform(1,0)*x + transform(1,1)*y + transform(1,2)*z + transform(1,3),
+		transform(2,0)*x + transform(2,1)*y + transform(2,2)*z + transform(2,3)
+	);
+}
+
+// getTransformed [mat4]
+inline void Vec3::transform( const Mat4& transform )
+{
+	ME = getTransformed( transform );
+}
+
+
+} // end namespace

+ 73 - 0
src/math/Vec4.h

@@ -0,0 +1,73 @@
+#ifndef _VEC4_H_
+#define _VEC4_H_
+
+#include "common.h"
+#include "MathForwardDecls.h"
+
+
+namespace M {
+
+
+class Vec4
+{
+	public:
+		// data members
+		float x, y, z, w;
+		// accessors
+		float& operator []( uint i );
+		float  operator []( uint i ) const;
+		// constructors & distructors
+		explicit Vec4();
+		explicit Vec4( float f );
+		explicit Vec4( float x, float y, float z, float w );
+		explicit Vec4( const Vec2& v2, float z, float w );
+		explicit Vec4( const Vec3& v3, float w );
+		         Vec4( const Vec4& b );
+		explicit Vec4( const Quat& q );
+		// ops with same
+		Vec4  operator + ( const Vec4& b ) const;
+		Vec4& operator +=( const Vec4& b );
+		Vec4  operator - ( const Vec4& b ) const;
+		Vec4& operator -=( const Vec4& b );
+		Vec4  operator * ( const Vec4& b ) const;
+		Vec4& operator *=( const Vec4& b );
+		Vec4  operator / ( const Vec4& b ) const;
+		Vec4& operator /=( const Vec4& b );
+		Vec4  operator - () const;
+		// ops with float
+		Vec4  operator + ( float f ) const;
+		Vec4& operator +=( float f );
+		Vec4  operator - ( float f ) const;
+		Vec4& operator -=( float f );
+		Vec4  operator * ( float f ) const;
+		Vec4& operator *=( float f );
+		Vec4  operator / ( float f ) const;
+		Vec4& operator /=( float f );
+		// ops with other
+		Vec4  operator * ( const Mat4& m4 ) const;
+		// comparision
+		bool operator ==( const Vec4& b ) const;
+		bool operator !=( const Vec4& b ) const;
+		// other
+		float getLength() const;
+		Vec4  getNormalized() const;
+		void  normalize();
+		void  print() const;
+		float dot( const Vec4& b ) const;
+};
+
+
+// other operators
+extern Vec4 operator +( float f, const Vec4& v4 );
+extern Vec4 operator -( float f, const Vec4& v4 );
+extern Vec4 operator *( float f, const Vec4& v4 );
+extern Vec4 operator /( float f, const Vec4& v4 );
+
+
+} // end namespace
+
+
+#include "Vec4.inl.h"
+
+
+#endif

+ 258 - 0
src/math/Vec4.inl.h

@@ -0,0 +1,258 @@
+#include "MathDfltHeader.h"
+
+
+#define ME (*this)
+
+
+namespace M {
+
+
+// accessors
+inline float& Vec4::operator []( uint i )
+{
+	return (&x)[i];
+}
+
+inline float Vec4::operator []( uint i ) const
+{
+	return (&x)[i];
+}
+
+// constructor []
+inline Vec4::Vec4()
+	: x(0.0), y(0.0), z(0.0), w(0.0)
+{}
+
+// constructor [float]
+inline Vec4::Vec4( float f )
+	: x(f), y(f), z(f), w(f)
+{}
+
+// constructor [float, float, float, float]
+inline Vec4::Vec4( float x_, float y_, float z_, float w_ )
+	: x(x_), y(y_), z(z_), w(w_)
+{}
+
+// constructor [vec2, float, float]
+inline Vec4::Vec4( const Vec2& v2, float z_, float w_ )
+	: x(v2.x), y(v2.y), z(z_), w(w_)
+{}
+
+// constructor [vec3, float]
+inline Vec4::Vec4( const Vec3& v3, float w_ )
+	: x(v3.x), y(v3.y), z(v3.z), w(w_)
+{}
+
+// constructor [vec4]
+inline Vec4::Vec4( const Vec4& b )
+	: x(b.x), y(b.y), z(b.z), w(b.w)
+{}
+
+// constructor [quat]
+inline Vec4::Vec4( const Quat& q )
+	: x(q.x), y(q.y), z(q.z), w(q.w)
+{}
+
+// +
+inline Vec4 Vec4::operator +( const Vec4& b ) const
+{
+	return Vec4( x+b.x, y+b.y, z+b.z, w+b.w );
+}
+
+// +=
+inline Vec4& Vec4::operator +=( const Vec4& b )
+{
+	x += b.x;
+	y += b.y;
+	z += b.z;
+	w += b.w;
+	return ME;
+}
+
+// -
+inline Vec4 Vec4::operator -( const Vec4& b ) const
+{
+	return Vec4( x-b.x, y-b.y, z-b.z, w-b.w );
+}
+
+// -=
+inline Vec4& Vec4::operator -=( const Vec4& b )
+{
+	x -= b.x;
+	y -= b.y;
+	z -= b.z;
+	w -= b.w;
+	return ME;
+}
+
+// *
+inline Vec4 Vec4::operator *( const Vec4& b ) const
+{
+	return Vec4( x*b.x, y*b.y, z*b.z, w*b.w );
+}
+
+// *=
+inline Vec4& Vec4::operator *=( const Vec4& b )
+{
+	x *= b.x;
+	y *= b.y;
+	z *= b.z;
+	w *= b.w;
+	return ME;
+}
+
+// /
+inline Vec4 Vec4::operator /( const Vec4& b ) const
+{
+	return Vec4( x/b.x, y/b.y, z/b.z, w/b.w );
+}
+
+// /=
+inline Vec4& Vec4::operator /=( const Vec4& b )
+{
+	x /= b.x;
+	y /= b.y;
+	z /= b.z;
+	w /= b.w;
+	return ME;
+}
+
+// negative
+inline Vec4 Vec4::operator -() const
+{
+	return Vec4( -x, -y, -z, -w );
+}
+
+// ==
+inline bool Vec4::operator ==( const Vec4& b ) const
+{
+	return ( isZero(x-b.x) && isZero(y-b.y) && isZero(z-b.z) && isZero(w-b.w) ) ? true : false;
+}
+
+// !=
+inline bool Vec4::operator !=( const Vec4& b ) const
+{
+	return ( isZero(x-b.x) && isZero(y-b.y) && isZero(z-b.z) && isZero(w-b.w) ) ? false : true;
+}
+
+// vec4 + float
+inline Vec4 Vec4::operator +( float f ) const
+{
+	return ME + Vec4(f);
+}
+
+// float + vec4
+inline Vec4 operator +( float f, const Vec4& v4 )
+{
+	return v4+f;
+}
+
+// vec4 += float
+inline Vec4& Vec4::operator +=( float f )
+{
+	ME += Vec4(f);
+	return ME;
+}
+
+// vec4 - float
+inline Vec4 Vec4::operator -( float f ) const
+{
+	return ME - Vec4(f);
+}
+
+// float - vec4
+inline Vec4 operator -( float f, const Vec4& v4 )
+{
+	return Vec4( f-v4.x, f-v4.y, f-v4.z, f-v4.w );
+}
+
+// vec4 -= float
+inline Vec4& Vec4::operator -=( float f )
+{
+	ME -= Vec4(f);
+	return ME;
+}
+
+// vec4 * float
+inline Vec4 Vec4::operator *( float f ) const
+{
+	return ME * Vec4(f);
+}
+
+// float * vec4
+inline Vec4 operator *( float f, const Vec4& v4 )
+{
+	return v4*f;
+}
+
+// vec4 *= float
+inline Vec4& Vec4::operator *=( float f )
+{
+	ME *= Vec4(f);
+	return ME;
+}
+
+// vec4 / float
+inline Vec4 Vec4::operator /( float f ) const
+{
+	return ME / Vec4(f);
+}
+
+// float / vec4
+inline Vec4 operator /( float f, const Vec4& v4 )
+{
+	return Vec4( f/v4.x, f/v4.y, f/v4.z, f/v4.w );
+}
+
+// vec4 /= float
+inline Vec4& Vec4::operator /=( float f )
+{
+	ME /= Vec4(f);
+	return ME;
+}
+
+// vec4 * mat4
+inline Vec4 Vec4::operator *( const Mat4& m4 ) const
+{
+	return Vec4(
+		x*m4(0,0) + y*m4(1,0) + z*m4(2,0) + w*m4(3,0),
+		x*m4(0,1) + y*m4(1,1) + z*m4(2,1) + w*m4(3,1),
+		x*m4(0,2) + y*m4(1,2) + z*m4(2,2) + w*m4(3,2),
+		x*m4(0,3) + y*m4(1,3) + z*m4(2,3) + w*m4(3,3)
+	);
+}
+
+// dot
+inline float Vec4::dot( const Vec4& b ) const
+{
+	return x*b.x + y*b.y + z*b.z + w*b.w;
+}
+
+// getLength
+inline float Vec4::getLength() const
+{
+	return M::sqrt( x*x + y*y + z*z + w*w );
+}
+
+// Normalized
+inline Vec4 Vec4::getNormalized() const
+{
+	return ME * invSqrt( x*x +y*y + z*z + w*w );
+}
+
+// normalize
+inline void Vec4::normalize()
+{
+	ME *= invSqrt( x*x +y*y + z*z + w*w );
+}
+
+// print
+inline void Vec4::print() const
+{
+	for( int i=0; i<4; i++ )
+		cout << fixed << ME[i] << " ";
+	cout << "\n" << endl;
+}
+
+
+} // end namespace

+ 0 - 15
src/math/forward_decls.h

@@ -1,15 +0,0 @@
-#ifndef _FORWARD_DECLS_H_
-#define _FORWARD_DECLS_H_
-
-namespace m {
-	class vec2_t;
-	class vec3_t;
-	class vec4_t;
-	class quat_t;
-	class Euler;
-	class Axisang;
-	class mat3_t;
-	class mat4_t;
-}
-
-#endif

+ 0 - 19
src/math/gmath.h

@@ -1,19 +0,0 @@
-#ifndef _GMATH_H_
-#define _GMATH_H_
-
-
-#include <math.h>
-#include "vec2.h"
-#include "vec3.h"
-#include "vec4.h"
-#include "quat.h"
-#include "Axisang.h"
-#include "Euler.h"
-#include "mat3.h"
-#include "mat4.h"
-#include "m_misc.h"
-
-using namespace m;
-
-
-#endif

+ 0 - 9
src/math/m_dflt_header.h

@@ -1,9 +0,0 @@
-#include "vec2.h"
-#include "vec3.h"
-#include "vec4.h"
-#include "quat.h"
-#include "Axisang.h"
-#include "Euler.h"
-#include "mat3.h"
-#include "mat4.h"
-#include "m_misc.h"

+ 0 - 45
src/math/m_misc.h

@@ -1,45 +0,0 @@
-#ifndef _M_MISC_H_
-#define _M_MISC_H_
-
-#include "common.h"
-#include "forward_decls.h"
-
-
-namespace m {
-
-
-const float PI = 3.14159265358979323846;
-const float EPSILON = 1.0e-6;
-
-
-void  mathSanityChecks();
-void  sinCos( float rad, float& sin_, float& cos_ );
-float invSqrt( float f );
-float sqrt( float f );
-float ToRad( float degrees );
-float ToDegrees( float rad );
-float Sin( float rad );
-float Cos( float rad );
-bool  IsZero( float f );
-float Max( float a, float b );
-float Min( float a, float b );
-
-/**
- * CombineTransformations
- * mat4(t0,r0,s0)*mat4(t1,r1,s1) == mat4(tf,rf,sf)
- */
-void CombineTransformations( const vec3_t& t0, const mat3_t& r0, float s0,
-                             const vec3_t& t1, const mat3_t& r1, float s1,
-                             vec3_t& tf, mat3_t& rf, float& sf );
-
-/// CombineTransformations as the above but without scale
-void CombineTransformations( const vec3_t& t0, const mat3_t& r0, const vec3_t& t1, const mat3_t& r1, vec3_t& tf, mat3_t& rf);
-
-
-} // end namespace
-
-
-#include "m_misc.inl.h"
-
-
-#endif

+ 0 - 99
src/math/mat3.h

@@ -1,99 +0,0 @@
-#ifndef _MAT3_H_
-#define _MAT3_H_
-
-#include "common.h"
-#include "forward_decls.h"
-
-
-namespace m {
-
-
-class mat3_t
-{
-	private:
-		// data members
-		union
-		{
-			float arr1[9];
-			float arr2[3][3];
-		};
-
-	public:
-		// accessors
-		float& operator ()( const uint i, const uint j );
-		const float& operator ()( const uint i, const uint j ) const;
-		float& operator []( const uint i);
-		const float& operator []( const uint i) const;
-		// constructors & distructors
-		explicit mat3_t() {};
-		explicit mat3_t( float f );
-		explicit mat3_t( float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22 );
-		explicit mat3_t( float arr [] );
-		         mat3_t( const mat3_t& b );
-		explicit mat3_t( const quat_t& q ); // 12 muls, 12 adds
-		explicit mat3_t( const Euler& eu );
-		explicit mat3_t( const Axisang& axisang );
-		// ops with mat3
-		mat3_t  operator + ( const mat3_t& b ) const;
-		mat3_t& operator +=( const mat3_t& b );
-		mat3_t  operator - ( const mat3_t& b ) const;
-		mat3_t& operator -=( const mat3_t& b );
-		mat3_t  operator * ( const mat3_t& b ) const; // 27 muls, 18 adds
-		mat3_t& operator *=( const mat3_t& b );
-		mat3_t  operator / ( const mat3_t& b ) const;
-		mat3_t& operator /=( const mat3_t& b );
-		// ops with float
-		mat3_t  operator + ( float f ) const;
-		mat3_t& operator +=( float f );
-		mat3_t  operator - ( float f ) const;
-		mat3_t& operator -=( float f );
-		mat3_t  operator * ( float f ) const;
-		mat3_t& operator *=( float f );
-		mat3_t  operator / ( float f ) const;
-		mat3_t& operator /=( float f );
-		// ops with others
-		vec3_t  operator * ( const vec3_t& b ) const;  // 9 muls, 6 adds
-		// comparision
-		bool operator ==( const mat3_t& b ) const;
-		bool operator !=( const mat3_t& b ) const;
-		// other
-		void   SetRows( const vec3_t& a, const vec3_t& b, const vec3_t& c );
-		void   SetRow( const uint i, const vec3_t& v );
-		void   GetRows( vec3_t& a, vec3_t& b, vec3_t& c ) const;
-		vec3_t GetRow( const uint i ) const;
-		void   SetColumns( const vec3_t& a, const vec3_t& b, const vec3_t& c );
-		void   SetColumn( const uint i, const vec3_t& v );
-		void   GetColumns( vec3_t& a, vec3_t& b, vec3_t& c ) const;
-		vec3_t GetColumn( const uint i ) const;
-		void   SetRotationX( float rad );
-		void   SetRotationY( float rad );
-		void   SetRotationZ( float rad );
-		void   RotateXAxis( float rad ); // it rotates "this" in the axis defined by the rotation AND not the world axis
-		void   RotateYAxis( float rad );
-		void   RotateZAxis( float rad );
-		void   Transpose();
-		mat3_t GetTransposed() const;
-		void   Reorthogonalize();
-		void   print() const;
-		float  Det() const;
-		void   Invert();
-		mat3_t GetInverse() const;
-		static const mat3_t& GetZero();
-		static const mat3_t& GetIdentity();		
-};
-
-
-// other operators
-extern mat3_t operator +( float f, const mat3_t& m3 );
-extern mat3_t operator -( float f, const mat3_t& m3 );
-extern mat3_t operator *( float f, const mat3_t& m3 );
-extern mat3_t operator /( float f, const mat3_t& m3 );
-
-
-} // end namespace
-
-
-#include "mat3.inl.h"
-
-
-#endif

+ 0 - 98
src/math/mat4.h

@@ -1,98 +0,0 @@
-#ifndef _MAT4_H_
-#define _MAT4_H_
-
-#include "common.h"
-#include "forward_decls.h"
-
-
-namespace m {
-
-
-class mat4_t
-{
-	private:
-		union
-		{
-			float arr1[16];
-			float arr2[4][4];
-		};
-
-	public:
-		// access to the data
-		float& operator ()( const uint i, const uint j );
-		const float& operator ()( const uint i, const uint j ) const;
-		float& operator []( const uint i);
-		const float& operator []( const uint i) const;
-		// constructors & distructors
-		explicit mat4_t() {}
-		explicit mat4_t( float f );
-		explicit mat4_t( float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33 );
-		explicit mat4_t( const float arr [] );
-		         mat4_t( const mat4_t& b );
-		explicit mat4_t( const mat3_t& m3 );
-		explicit mat4_t( const vec3_t& v );
-		explicit mat4_t( const vec4_t& v );
-		explicit mat4_t( const vec3_t& transl, const mat3_t& rot );
-		explicit mat4_t( const vec3_t& transl, const mat3_t& rot, float scale );
-		// ops with same type
-		mat4_t  operator + ( const mat4_t& b ) const;
-		mat4_t& operator +=( const mat4_t& b );
-		mat4_t  operator - ( const mat4_t& b ) const;
-		mat4_t& operator -=( const mat4_t& b );
-		mat4_t  operator * ( const mat4_t& b ) const;
-		mat4_t& operator *=( const mat4_t& b );
-		mat4_t  operator / ( const mat4_t& b ) const;
-		mat4_t& operator /=( const mat4_t& b );
-		// ops with float
-		mat4_t  operator + ( float f ) const;
-		mat4_t& operator +=( float f );
-		mat4_t  operator - ( float f ) const;
-		mat4_t& operator -=( float f );
-		mat4_t  operator * ( float f ) const;
-		mat4_t& operator *=( float f );
-		mat4_t  operator / ( float f ) const;
-		mat4_t& operator /=( float f );
-		// ops with other types
-		vec4_t  operator * ( const vec4_t& v4 ) const; // 16 muls, 12 adds
-		// comparision
-		bool operator ==( const mat4_t& b ) const;
-		bool operator !=( const mat4_t& b ) const;
-		// other
-		void   SetRows( const vec4_t& a, const vec4_t& b, const vec4_t& c, const vec4_t& d );
-		void   SetRow( uint i, const vec4_t& v );
-		void   SetColumns( const vec4_t& a, const vec4_t& b, const vec4_t& c, const vec4_t& d );
-		void   SetColumn( uint i, const vec4_t& v );
-		void   SetRotationPart( const mat3_t& m3 );
-		void   SetTranslationPart( const vec4_t& v4 );
-		mat3_t GetRotationPart() const;
-		void   SetTranslationPart( const vec3_t& v3 );
-		vec3_t GetTranslationPart() const;
-		void   Transpose();
-		mat4_t GetTransposed() const;
-		void   print() const;
-		float  Det() const;
-		void   Invert();
-		mat4_t GetInverse() const;
-		mat4_t GetInverseTransformation() const;
-		mat4_t Lerp( const mat4_t& b, float t ) const;
-		static mat4_t CombineTransformations( const mat4_t& m0, const mat4_t& m1 );  // 12 muls, 27 adds. Something like m4 = m0 * m1 ...
-		                                                                             // ...but without touching the 4rth row and allot faster
-		static const mat4_t& GetIdentity();
-		static const mat4_t& GetZero();
-};
-
-
-// other operators
-extern mat4_t operator +( float f, const mat4_t& m4 );
-extern mat4_t operator -( float f, const mat4_t& m4 );
-extern mat4_t operator *( float f, const mat4_t& m4 );
-extern mat4_t operator /( float f, const mat4_t& m4 );
-
-
-} // end namespace
-
-
-#include "mat4.inl.h"
-
-
-#endif

+ 0 - 57
src/math/quat.h

@@ -1,57 +0,0 @@
-#ifndef _QUAT_H_
-#define _QUAT_H_
-
-#include "common.h"
-#include "forward_decls.h"
-
-
-namespace m {
-
-
-class quat_t
-{
-	public:
-		// data members
-		float x, y, z, w;
-		static quat_t zero;
-		static quat_t ident;
-		// constructors & distructors
-		explicit quat_t();
-		explicit quat_t( float f );
-		explicit quat_t( float x, float y, float z, float w );
-		explicit quat_t( const vec2_t& v2, float z, float w );
-		explicit quat_t( const vec3_t& v3, float w );
-		explicit quat_t( const vec4_t& v4 );
-		         quat_t( const quat_t& b );
-		explicit quat_t( const mat3_t& m3 );
-		explicit quat_t( const Euler& eu );
-		explicit quat_t( const Axisang& axisang );
-		// ops with same
-		quat_t  operator * ( const quat_t& b ) const;
-		quat_t& operator *=( const quat_t& b );
-		// comparision
-		bool operator ==( const quat_t& b ) const;
-		bool operator !=( const quat_t& b ) const;
-		// other
-		void   CalcFrom2Vec3( const vec3_t& v0, const vec3_t& v1 ); // calculates the quat from v0 to v1
-		float  Length() const;
-		void   Invert();
-		void   Conjugate();
-		quat_t Conjugated() const;
-		void   Normalize();
-		quat_t GetNormalized() const;
-		void   print() const;
-		float  Dot( const quat_t& b ) const;
-		quat_t Slerp( const quat_t& q1, float t ) const; // returns Slerp( this, q1, t )
-		quat_t GetRotated( const quat_t& b ) const;
-		void   Rotate( const quat_t& b );
-};
-
-
-} // end namespace
-
-
-#include "quat.inl.h"
-
-
-#endif

+ 0 - 75
src/math/vec2.h

@@ -1,75 +0,0 @@
-#ifndef _VEC2_H_
-#define _VEC2_H_
-
-#include "common.h"
-#include "forward_decls.h"
-
-
-namespace m {
-
-
-class vec2_t
-{
-	public:
-		// data members
-		float x, y;
-		static const vec2_t zero;
-		static const vec2_t one;
-		// accessors
-		float& operator []( uint i );
-		float  operator []( uint i ) const;
-		// constructors & distructors
-		explicit vec2_t();
-		explicit vec2_t( float f );
-		explicit vec2_t( float x, float y );
-		         vec2_t( const vec2_t& b );
-		explicit vec2_t( const vec3_t& v3 );
-		explicit vec2_t( const vec4_t& v4 );
-		// ops with same type
-		vec2_t  operator + ( const vec2_t& b ) const;
-		vec2_t& operator +=( const vec2_t& b );
-		vec2_t  operator - ( const vec2_t& b ) const;
-		vec2_t& operator -=( const vec2_t& b );
-		vec2_t  operator * ( const vec2_t& b ) const;
-		vec2_t& operator *=( const vec2_t& b );
-		vec2_t  operator / ( const vec2_t& b ) const;
-		vec2_t& operator /=( const vec2_t& b );
-		vec2_t  operator - () const;
-		// ops with float
-		vec2_t  operator + ( float f ) const;
-		vec2_t& operator +=( float f );
-		vec2_t  operator - ( float f ) const;
-		vec2_t& operator -=( float f );
-		vec2_t  operator * ( float f ) const;
-		vec2_t& operator *=( float f );
-		vec2_t  operator / ( float f ) const;
-		vec2_t& operator /=( float f );
-		// comparision
-		bool operator ==( const vec2_t& b ) const;
-		bool operator !=( const vec2_t& b ) const;
-		// other
-		static vec2_t GetZero();
-		static vec2_t GetOne();
-		float  Length() const;
-		void   SetZero();
-		void   Normalize();
-		vec2_t GetNormalized() const;
-		float  Dot( const vec2_t& b ) const;
-		void   print() const;
-};
-
-
-// other operators
-extern vec2_t operator +( float f, const vec2_t& v2 );
-extern vec2_t operator -( float f, const vec2_t& v2 );
-extern vec2_t operator *( float f, const vec2_t& v2 );
-extern vec2_t operator /( float f, const vec2_t& v2 );
-
-
-} // end namespace
-
-
-#include "vec2.inl.h"
-
-
-#endif

+ 0 - 246
src/math/vec2.inl.h

@@ -1,246 +0,0 @@
-#include "m_dflt_header.h"
-
-
-#define ME (*this)
-
-namespace m {
-
-// accessors
-inline float& vec2_t::operator []( uint i )
-{
-	return (&x)[i];
-}
-
-inline float vec2_t::operator []( uint i ) const
-{
-	return (&x)[i];
-}
-
-// constructor []
-inline vec2_t::vec2_t()
-	: x(0.0), y(0.0)
-{}
-
-// constructor [float, float]
-inline vec2_t::vec2_t( float x_, float y_ )
-	: x(x_), y(y_)
-{}
-
-// constructor [float]
-inline vec2_t::vec2_t( float f ): x(f), y(f)
-{}
-
-// constructor [vec2]
-inline vec2_t::vec2_t( const vec2_t& b ): x(b.x), y(b.y)
-{}
-
-// constructor [vec3]
-inline vec2_t::vec2_t( const vec3_t& v3 ): x(v3.x), y(v3.y)
-{}
-
-// constructor [vec4]
-inline vec2_t::vec2_t( const vec4_t& v4 ): x(v4.x), y(v4.y)
-{}
-
-// +
-inline vec2_t vec2_t::operator +( const vec2_t& b ) const
-{
-	return vec2_t( x+b.x, y+b.y );
-}
-
-// +=
-inline vec2_t& vec2_t::operator +=( const vec2_t& b )
-{
-	x += b.x;
-	y += b.y;
-	return ME;
-}
-
-// -
-inline vec2_t vec2_t::operator -( const vec2_t& b ) const
-{
-	return vec2_t( x-b.x, y-b.y );
-}
-
-// -=
-inline vec2_t& vec2_t::operator -=( const vec2_t& b )
-{
-	x -= b.x;
-	y -= b.y;
-	return ME;
-}
-
-// *
-inline vec2_t vec2_t::operator *( const vec2_t& b ) const
-{
-	return vec2_t( x*b.x, y*b.y );
-}
-
-// *=
-inline vec2_t& vec2_t::operator *=( const vec2_t& b )
-{
-	x *= b.x;
-	y *= b.y;
-	return ME;
-}
-
-// /
-inline vec2_t vec2_t::operator /( const vec2_t& b ) const
-{
-	return vec2_t( x/b.x, y/b.y );
-}
-
-// /=
-inline vec2_t& vec2_t::operator /=( const vec2_t& b )
-{
-	x /= b.x;
-	y /= b.y;
-	return ME;
-}
-
-// negative
-inline vec2_t vec2_t::operator -() const
-{
-	return vec2_t( -x, -y );
-}
-
-// ==
-inline bool vec2_t::operator ==( const vec2_t& b ) const
-{
-	return ( IsZero(x-b.x) && IsZero(y-b.y) ) ? true : false;
-}
-
-// !=
-inline bool vec2_t::operator !=( const vec2_t& b ) const
-{
-	return ( IsZero(x-b.x) && IsZero(y-b.y) ) ? false : true;
-}
-
-// vec2 + float
-inline vec2_t vec2_t::operator +( float f ) const
-{
-	return ME + vec2_t(f);
-}
-
-// float + vec2
-inline vec2_t operator +( float f, const vec2_t& v2 )
-{
-	return v2+f;
-}
-
-// vec2 += float
-inline vec2_t& vec2_t::operator +=( float f )
-{
-	ME += vec2_t(f);
-	return ME;
-}
-
-// vec2 - float
-inline vec2_t vec2_t::operator -( float f ) const
-{
-	return ME - vec2_t(f);
-}
-
-// float - vec2
-inline vec2_t operator -( float f, const vec2_t& v2 )
-{
-	return vec2_t( f-v2.x, f-v2.y );
-}
-
-// vec2 -= float
-inline vec2_t& vec2_t::operator -=( float f )
-{
-	ME -= vec2_t(f);
-	return ME;
-}
-
-// vec2 * float
-inline vec2_t vec2_t::operator *( float f ) const
-{
-	return ME * vec2_t(f);
-}
-
-// float * vec2
-inline vec2_t operator *( float f, const vec2_t& v2 )
-{
-	return v2*f;
-}
-
-// vec2 *= float
-inline vec2_t& vec2_t::operator *=( float f )
-{
-	ME *= vec2_t(f);
-	return ME;
-}
-
-// vec2 / float
-inline vec2_t vec2_t::operator /( float f ) const
-{
-	return ME / vec2_t(f);
-}
-
-// float / vec2
-inline vec2_t operator /( float f, const vec2_t& v2 )
-{
-	return vec2_t( f/v2.x, f/v2.y );
-}
-
-// vec2 /= float
-inline vec2_t& vec2_t::operator /=( float f )
-{
-	ME /= vec2_t(f);
-	return ME;
-}
-
-// Length
-inline float vec2_t::Length() const
-{
-	return sqrt( x*x + y*y );
-}
-
-// set to zero
-inline void vec2_t::SetZero()
-{
-	x = y = 0.0;
-}
-
-// Normalize
-inline void vec2_t::Normalize()
-{
-	ME *= invSqrt( x*x + y*y );
-}
-
-// Normalized (return the normalized)
-inline vec2_t vec2_t::GetNormalized() const
-{
-	return ME * invSqrt( x*x + y*y );
-}
-
-// Dot
-inline float vec2_t::Dot( const vec2_t& b ) const
-{
-	return x*b.x + y*b.y;
-}
-
-// GetZero
-inline vec2_t vec2_t::GetZero()
-{
-	return vec2_t(0.0);
-}
-
-// GetOne
-inline vec2_t vec2_t::GetOne()
-{
-	return vec2_t(1.0);
-}
-
-// print
-inline void vec2_t::print() const
-{
-	for( int i=0; i<2; i++ )
-		cout << fixed << ME[i] << ' ';
-	cout << "\n" << endl;
-}
-
-
-} // end namespace

+ 0 - 91
src/math/vec3.h

@@ -1,91 +0,0 @@
-#ifndef _VEC3_H_
-#define _VEC3_H_
-
-#include "common.h"
-#include "forward_decls.h"
-
-
-namespace m {
-
-
-class vec3_t
-{
-	public:
-		// data members
-		float x, y, z;
-		// accessors
-		float& operator []( uint i );
-		float  operator []( uint i ) const;
-		// constructors & distructors
-		explicit vec3_t();
-		explicit vec3_t( float f );
-		explicit vec3_t( float x, float y, float z );
-		explicit vec3_t( const vec2_t& v2, float z );
-		         vec3_t( const vec3_t& b );
-		explicit vec3_t( const vec4_t& v4 );
-		explicit vec3_t( const quat_t& q );
-		// ops with same type
-		vec3_t  operator + ( const vec3_t& b ) const;
-		vec3_t& operator +=( const vec3_t& b );
-		vec3_t  operator - ( const vec3_t& b ) const;
-		vec3_t& operator -=( const vec3_t& b );
-		vec3_t  operator * ( const vec3_t& b ) const;
-		vec3_t& operator *=( const vec3_t& b );
-		vec3_t  operator / ( const vec3_t& b ) const;
-		vec3_t& operator /=( const vec3_t& b );
-		vec3_t  operator - () const; // return the negative
-		// ops with float
-		vec3_t  operator + ( float f ) const;
-		vec3_t& operator +=( float f );
-		vec3_t  operator - ( float f ) const;
-		vec3_t& operator -=( float f );
-		vec3_t  operator * ( float f ) const;
-		vec3_t& operator *=( float f );
-		vec3_t  operator / ( float f ) const;
-		vec3_t& operator /=( float f );
-		// ops with other types
-		vec3_t  operator * ( const mat3_t& m3 ) const;
-		// comparision
-		bool operator ==( const vec3_t& b ) const;
-		bool operator !=( const vec3_t& b ) const;
-		// other
-		float  Dot( const vec3_t& b ) const;
-		vec3_t Cross( const vec3_t& b ) const;
-		float  Length() const;
-		float  LengthSquared() const;
-		float  DistanceSquared( const vec3_t& b ) const;
-		void   Normalize();
-		vec3_t GetNormalized() const;
-		vec3_t Project( const vec3_t& to_this ) const;
-		vec3_t GetRotated( const quat_t& q ) const; // returns q * this * q.Conjucated() aka returns a rotated this. 18 muls, 12 adds
-		void   Rotate( const quat_t& q );
-		vec3_t Lerp( const vec3_t& v1, float t ) const; // return Lerp( this, v1, t )
-		void   print() const;
-		// transformations. The faster way is by far the mat4 * vec3 or the Transformed( vec3_t, mat3_t )
-		vec3_t GetTransformed( const vec3_t& translate, const mat3_t& rotate, float scale ) const;
-		void   Transform( const vec3_t& translate, const mat3_t& rotate, float scale );
-		vec3_t GetTransformed( const vec3_t& translate, const mat3_t& rotate ) const;
-		void   Transform( const vec3_t& translate, const mat3_t& rotate );
-		vec3_t GetTransformed( const vec3_t& translate, const quat_t& rotate, float scale ) const;
-		void   Transform( const vec3_t& translate, const quat_t& rotate, float scale );
-		vec3_t GetTransformed( const vec3_t& translate, const quat_t& rotate ) const;
-		void   Transform( const vec3_t& translate, const quat_t& rotate );
-		vec3_t GetTransformed( const mat4_t& transform ) const;  // 9 muls, 9 adds
-		void   Transform( const mat4_t& transform );
-};
-
-
-// other operators
-extern vec3_t operator +( float f, const vec3_t& v );
-extern vec3_t operator -( float f, const vec3_t& v );
-extern vec3_t operator *( float f, const vec3_t& v );
-extern vec3_t operator /( float f, const vec3_t& v );
-
-
-} // end namespace
-
-
-#include "vec3.inl.h"
-
-
-#endif

+ 0 - 347
src/math/vec3.inl.h

@@ -1,347 +0,0 @@
-#include "m_dflt_header.h"
-
-
-#define ME (*this)
-
-
-namespace m {
-
-
-// accessors
-inline float& vec3_t::operator []( uint i )
-{
-	return (&x)[i];
-}
-
-inline float vec3_t::operator []( uint i ) const
-{
-	return (&x)[i];
-}
-
-// constructor []
-inline vec3_t::vec3_t()
-	: x(0.0), y(0.0), z(0.0)
-{}
-
-// constructor [float, float, float]
-inline vec3_t::vec3_t( float x_, float y_, float z_ )
-	: x(x_), y(y_), z(z_)
-{}
-
-// constructor [float]
-inline vec3_t::vec3_t( float f )
-	: x(f), y(f), z(f)
-{}
-
-// constructor [vec3]
-inline vec3_t::vec3_t( const vec3_t& b )
-	: x(b.x), y(b.y), z(b.z)
-{}
-
-// constructor [vec2, float]
-inline vec3_t::vec3_t( const vec2_t& v2, float z_ )
-	: x(v2.x), y(v2.y), z(z_)
-{}
-
-// constructor [vec4]
-inline vec3_t::vec3_t( const vec4_t& v4 )
-	: x(v4.x), y(v4.y), z(v4.z)
-{}
-
-// constructor [quat]
-inline vec3_t::vec3_t( const quat_t& q )
-	: x(q.x), y(q.y), z(q.z)
-{}
-
-// +
-inline vec3_t vec3_t::operator +( const vec3_t& b ) const
-{
-	return vec3_t( x+b.x, y+b.y, z+b.z );
-}
-
-// +=
-inline vec3_t& vec3_t::operator +=( const vec3_t& b )
-{
-	x += b.x;
-	y += b.y;
-	z += b.z;
-	return ME;
-}
-
-// -
-inline vec3_t vec3_t::operator -( const vec3_t& b ) const
-{
-	return vec3_t( x-b.x, y-b.y, z-b.z );
-}
-
-// -=
-inline vec3_t& vec3_t::operator -=( const vec3_t& b )
-{
-	x -= b.x;
-	y -= b.y;
-	z -= b.z;
-	return ME;
-}
-
-// *
-inline vec3_t vec3_t::operator *( const vec3_t& b ) const
-{
-	return vec3_t( x*b.x, y*b.y, z*b.z );
-}
-
-// *=
-inline vec3_t& vec3_t::operator *=( const vec3_t& b )
-{
-	x *= b.x;
-	y *= b.y;
-	z *= b.z;
-	return ME;
-}
-
-// /
-inline vec3_t vec3_t::operator /( const vec3_t& b ) const
-{
-	return vec3_t( x/b.x, y/b.y, z/b.z );
-}
-
-// /=
-inline vec3_t& vec3_t::operator /=( const vec3_t& b )
-{
-	x /= b.x;
-	y /= b.y;
-	z /= b.z;
-	return ME;
-}
-
-// negative
-inline vec3_t vec3_t::operator -() const
-{
-	return vec3_t( -x, -y, -z );
-}
-
-// ==
-inline bool vec3_t::operator ==( const vec3_t& b ) const
-{
-	return ( IsZero(x-b.x) && IsZero(y-b.y) && IsZero(z-b.z) ) ? true : false;
-}
-
-// !=
-inline bool vec3_t::operator !=( const vec3_t& b ) const
-{
-	return ( IsZero(x-b.x) && IsZero(y-b.y) && IsZero(z-b.z) ) ? false : true;
-}
-
-// vec3 + float
-inline vec3_t vec3_t::operator +( float f ) const
-{
-	return ME + vec3_t(f);
-}
-
-// float + vec3
-inline vec3_t operator +( float f, const vec3_t& v )
-{
-	return v+f;
-}
-
-// vec3 += float
-inline vec3_t& vec3_t::operator +=( float f )
-{
-	ME += vec3_t(f);
-	return ME;
-}
-
-// vec3 - float
-inline vec3_t vec3_t::operator -( float f ) const
-{
-	return ME - vec3_t(f);
-}
-
-// float - vec3
-inline vec3_t operator -( float f, const vec3_t& v )
-{
-	return vec3_t(f-v.x, f-v.y, f-v.z);
-}
-
-// vec3 -= float
-inline vec3_t& vec3_t::operator -=( float f )
-{
-	ME -= vec3_t(f);
-	return ME;
-}
-
-// vec3 * float
-inline vec3_t vec3_t::operator *( float f ) const
-{
-	return ME * vec3_t(f);
-}
-
-// float * vec3
-inline vec3_t operator *( float f, const vec3_t& v )
-{
-	return v*f;
-}
-
-// vec3 *= float
-inline vec3_t& vec3_t::operator *=( float f )
-{
-	ME *= vec3_t(f);
-	return ME;
-}
-
-// vec3 / float
-inline vec3_t vec3_t::operator /( float f ) const
-{
-	return ME / vec3_t(f);
-}
-
-// float / vec3
-inline vec3_t operator /( float f, const vec3_t& v )
-{
-	return vec3_t(f/v.x, f/v.y, f/v.z);
-}
-
-// vec3 /= float
-inline vec3_t& vec3_t::operator /=( float f )
-{
-	ME /= vec3_t(f);
-	return ME;
-}
-
-// Dot
-inline float vec3_t::Dot( const vec3_t& b ) const
-{
-	return x*b.x + y*b.y + z*b.z;
-}
-
-// cross prod
-inline vec3_t vec3_t::Cross( const vec3_t& b ) const
-{
-	return vec3_t( y*b.z-z*b.y, z*b.x-x*b.z, x*b.y-y*b.x );
-}
-
-// Length
-inline float vec3_t::Length() const
-{
-	return sqrt( x*x + y*y + z*z );
-}
-
-// LengthSquared
-inline float vec3_t::LengthSquared() const
-{
-	return x*x + y*y + z*z;
-}
-
-// DistanceSquared
-inline float vec3_t::DistanceSquared( const vec3_t& b ) const
-{
-	return (ME-b).LengthSquared();
-}
-
-// Normalize
-inline void vec3_t::Normalize()
-{
-	ME *= invSqrt( x*x + y*y + z*z );
-}
-
-// Normalized (return the normalized)
-inline vec3_t vec3_t::GetNormalized() const
-{
-	return ME * invSqrt( x*x + y*y + z*z );
-}
-
-// Project
-inline vec3_t vec3_t::Project( const vec3_t& to_this ) const
-{
-	return to_this * ( ME.Dot(to_this)/(to_this.Dot(to_this)) );
-}
-
-// Rotated
-inline vec3_t vec3_t::GetRotated( const quat_t& q ) const
-{
-	DEBUG_ERR( !IsZero(1.0f-q.Length()) ); // Not normalized quat
-
-	/*float vmult = 2.0f*(q.x*x + q.y*y + q.z*z);
-	float crossmult = 2.0*q.w;
-	float pmult = crossmult*q.w - 1.0;
-
-	return vec3_t( pmult*x + vmult*q.x + crossmult*(q.y*z - q.z*y),
-							   pmult*y + vmult*q.y + crossmult*(q.z*x - q.x*z),
-	               pmult*z + vmult*q.z + crossmult*(q.x*y - q.y*x) );*/
-	vec3_t q_xyz( q );
-	return ME + q_xyz.Cross( q_xyz.Cross(ME) + ME*q.w ) * 2.0;
-}
-
-// Rotate
-inline void vec3_t::Rotate( const quat_t& q )
-{
-	ME = GetRotated(q);
-}
-
-// print
-inline void vec3_t::print() const
-{
-	for( int i=0; i<3; i++ )
-		cout << fixed << ME[i] << " ";
-	cout << "\n" << endl;
-}
-
-// Lerp
-inline vec3_t vec3_t::Lerp( const vec3_t& v1, float t ) const
-{
-	return (ME*(1.0f-t))+(v1*t);
-}
-
-// GetTransformed [mat3]
-inline vec3_t vec3_t::GetTransformed( const vec3_t& translate, const mat3_t& rotate, float scale ) const
-{
-	return (rotate * (ME * scale)) + translate;
-}
-
-// Transform [mat3]
-inline void vec3_t::Transform( const vec3_t& translate, const mat3_t& rotate, float scale )
-{
-	ME = GetTransformed( translate, rotate, scale );
-}
-
-// GetTransformed [mat3] no scale
-inline vec3_t vec3_t::GetTransformed( const vec3_t& translate, const mat3_t& rotate ) const
-{
-	return (rotate * ME) + translate;
-}
-
-// Transform [mat3] no scale
-inline void vec3_t::Transform( const vec3_t& translate, const mat3_t& rotate )
-{
-	ME = GetTransformed( translate, rotate );
-}
-
-// GetTransformed [quat]
-inline vec3_t vec3_t::GetTransformed( const vec3_t& translate, const quat_t& rotate, float scale ) const
-{
-	return (ME * scale).GetRotated(rotate) + translate;
-}
-
-// Transform [quat3] no scale
-inline void vec3_t::Transform( const vec3_t& translate, const quat_t& rotate, float scale )
-{
-	ME = GetTransformed( translate, rotate, scale );
-}
-
-// GetTransformed [mat4]
-inline vec3_t vec3_t::GetTransformed( const mat4_t& transform ) const
-{
-	return vec3_t(
-		transform(0,0)*x + transform(0,1)*y + transform(0,2)*z + transform(0,3),
-		transform(1,0)*x + transform(1,1)*y + transform(1,2)*z + transform(1,3),
-		transform(2,0)*x + transform(2,1)*y + transform(2,2)*z + transform(2,3)
-	);
-}
-
-// GetTransformed [mat4]
-inline void vec3_t::Transform( const mat4_t& transform )
-{
-	ME = GetTransformed( transform );
-}
-
-
-} // end namespace

+ 0 - 73
src/math/vec4.h

@@ -1,73 +0,0 @@
-#ifndef _VEC4_H_
-#define _VEC4_H_
-
-#include "common.h"
-#include "forward_decls.h"
-
-
-namespace m {
-
-
-class vec4_t
-{
-	public:
-		// data members
-		float x, y, z, w;
-		// accessors
-		float& operator []( uint i );
-		float  operator []( uint i ) const;
-		// constructors & distructors
-		explicit vec4_t();
-		explicit vec4_t( float f );
-		explicit vec4_t( float x, float y, float z, float w );
-		explicit vec4_t( const vec2_t& v2, float z, float w );
-		explicit vec4_t( const vec3_t& v3, float w );
-		         vec4_t( const vec4_t& b );
-		explicit vec4_t( const quat_t& q );
-		// ops with same
-		vec4_t  operator + ( const vec4_t& b ) const;
-		vec4_t& operator +=( const vec4_t& b );
-		vec4_t  operator - ( const vec4_t& b ) const;
-		vec4_t& operator -=( const vec4_t& b );
-		vec4_t  operator * ( const vec4_t& b ) const;
-		vec4_t& operator *=( const vec4_t& b );
-		vec4_t  operator / ( const vec4_t& b ) const;
-		vec4_t& operator /=( const vec4_t& b );
-		vec4_t  operator - () const;
-		// ops with float
-		vec4_t  operator + ( float f ) const;
-		vec4_t& operator +=( float f );
-		vec4_t  operator - ( float f ) const;
-		vec4_t& operator -=( float f );
-		vec4_t  operator * ( float f ) const;
-		vec4_t& operator *=( float f );
-		vec4_t  operator / ( float f ) const;
-		vec4_t& operator /=( float f );
-		// ops with other
-		vec4_t  operator * ( const mat4_t& m4 ) const;
-		// comparision
-		bool operator ==( const vec4_t& b ) const;
-		bool operator !=( const vec4_t& b ) const;
-		// other
-		float  Length() const;
-		vec4_t GetNormalized() const;
-		void   Normalize();
-		void   print() const;
-		float  Dot( const vec4_t& b ) const;
-};
-
-
-// other operators
-extern vec4_t operator +( float f, const vec4_t& v4 );
-extern vec4_t operator -( float f, const vec4_t& v4 );
-extern vec4_t operator *( float f, const vec4_t& v4 );
-extern vec4_t operator /( float f, const vec4_t& v4 );
-
-
-} // end namespace
-
-
-#include "vec4.inl.h"
-
-
-#endif

+ 0 - 258
src/math/vec4.inl.h

@@ -1,258 +0,0 @@
-#include "m_dflt_header.h"
-
-
-#define ME (*this)
-
-
-namespace m {
-
-
-// accessors
-inline float& vec4_t::operator []( uint i )
-{
-	return (&x)[i];
-}
-
-inline float vec4_t::operator []( uint i ) const
-{
-	return (&x)[i];
-}
-
-// constructor []
-inline vec4_t::vec4_t()
-	: x(0.0), y(0.0), z(0.0), w(0.0)
-{}
-
-// constructor [float]
-inline vec4_t::vec4_t( float f )
-	: x(f), y(f), z(f), w(f)
-{}
-
-// constructor [float, float, float, float]
-inline vec4_t::vec4_t( float x_, float y_, float z_, float w_ )
-	: x(x_), y(y_), z(z_), w(w_)
-{}
-
-// constructor [vec2, float, float]
-inline vec4_t::vec4_t( const vec2_t& v2, float z_, float w_ )
-	: x(v2.x), y(v2.y), z(z_), w(w_)
-{}
-
-// constructor [vec3, float]
-inline vec4_t::vec4_t( const vec3_t& v3, float w_ )
-	: x(v3.x), y(v3.y), z(v3.z), w(w_)
-{}
-
-// constructor [vec4]
-inline vec4_t::vec4_t( const vec4_t& b )
-	: x(b.x), y(b.y), z(b.z), w(b.w)
-{}
-
-// constructor [quat]
-inline vec4_t::vec4_t( const quat_t& q )
-	: x(q.x), y(q.y), z(q.z), w(q.w)
-{}
-
-// +
-inline vec4_t vec4_t::operator +( const vec4_t& b ) const
-{
-	return vec4_t( x+b.x, y+b.y, z+b.z, w+b.w );
-}
-
-// +=
-inline vec4_t& vec4_t::operator +=( const vec4_t& b )
-{
-	x += b.x;
-	y += b.y;
-	z += b.z;
-	w += b.w;
-	return ME;
-}
-
-// -
-inline vec4_t vec4_t::operator -( const vec4_t& b ) const
-{
-	return vec4_t( x-b.x, y-b.y, z-b.z, w-b.w );
-}
-
-// -=
-inline vec4_t& vec4_t::operator -=( const vec4_t& b )
-{
-	x -= b.x;
-	y -= b.y;
-	z -= b.z;
-	w -= b.w;
-	return ME;
-}
-
-// *
-inline vec4_t vec4_t::operator *( const vec4_t& b ) const
-{
-	return vec4_t( x*b.x, y*b.y, z*b.z, w*b.w );
-}
-
-// *=
-inline vec4_t& vec4_t::operator *=( const vec4_t& b )
-{
-	x *= b.x;
-	y *= b.y;
-	z *= b.z;
-	w *= b.w;
-	return ME;
-}
-
-// /
-inline vec4_t vec4_t::operator /( const vec4_t& b ) const
-{
-	return vec4_t( x/b.x, y/b.y, z/b.z, w/b.w );
-}
-
-// /=
-inline vec4_t& vec4_t::operator /=( const vec4_t& b )
-{
-	x /= b.x;
-	y /= b.y;
-	z /= b.z;
-	w /= b.w;
-	return ME;
-}
-
-// negative
-inline vec4_t vec4_t::operator -() const
-{
-	return vec4_t( -x, -y, -z, -w );
-}
-
-// ==
-inline bool vec4_t::operator ==( const vec4_t& b ) const
-{
-	return ( IsZero(x-b.x) && IsZero(y-b.y) && IsZero(z-b.z) && IsZero(w-b.w) ) ? true : false;
-}
-
-// !=
-inline bool vec4_t::operator !=( const vec4_t& b ) const
-{
-	return ( IsZero(x-b.x) && IsZero(y-b.y) && IsZero(z-b.z) && IsZero(w-b.w) ) ? false : true;
-}
-
-// vec4 + float
-inline vec4_t vec4_t::operator +( float f ) const
-{
-	return ME + vec4_t(f);
-}
-
-// float + vec4
-inline vec4_t operator +( float f, const vec4_t& v4 )
-{
-	return v4+f;
-}
-
-// vec4 += float
-inline vec4_t& vec4_t::operator +=( float f )
-{
-	ME += vec4_t(f);
-	return ME;
-}
-
-// vec4 - float
-inline vec4_t vec4_t::operator -( float f ) const
-{
-	return ME - vec4_t(f);
-}
-
-// float - vec4
-inline vec4_t operator -( float f, const vec4_t& v4 )
-{
-	return vec4_t( f-v4.x, f-v4.y, f-v4.z, f-v4.w );
-}
-
-// vec4 -= float
-inline vec4_t& vec4_t::operator -=( float f )
-{
-	ME -= vec4_t(f);
-	return ME;
-}
-
-// vec4 * float
-inline vec4_t vec4_t::operator *( float f ) const
-{
-	return ME * vec4_t(f);
-}
-
-// float * vec4
-inline vec4_t operator *( float f, const vec4_t& v4 )
-{
-	return v4*f;
-}
-
-// vec4 *= float
-inline vec4_t& vec4_t::operator *=( float f )
-{
-	ME *= vec4_t(f);
-	return ME;
-}
-
-// vec4 / float
-inline vec4_t vec4_t::operator /( float f ) const
-{
-	return ME / vec4_t(f);
-}
-
-// float / vec4
-inline vec4_t operator /( float f, const vec4_t& v4 )
-{
-	return vec4_t( f/v4.x, f/v4.y, f/v4.z, f/v4.w );
-}
-
-// vec4 /= float
-inline vec4_t& vec4_t::operator /=( float f )
-{
-	ME /= vec4_t(f);
-	return ME;
-}
-
-// vec4 * mat4
-inline vec4_t vec4_t::operator *( const mat4_t& m4 ) const
-{
-	return vec4_t(
-		x*m4(0,0) + y*m4(1,0) + z*m4(2,0) + w*m4(3,0),
-		x*m4(0,1) + y*m4(1,1) + z*m4(2,1) + w*m4(3,1),
-		x*m4(0,2) + y*m4(1,2) + z*m4(2,2) + w*m4(3,2),
-		x*m4(0,3) + y*m4(1,3) + z*m4(2,3) + w*m4(3,3)
-	);
-}
-
-// Dot
-inline float vec4_t::Dot( const vec4_t& b ) const
-{
-	return x*b.x + y*b.y + z*b.z + w*b.w;
-}
-
-// Length
-inline float vec4_t::Length() const
-{
-	return sqrt( x*x + y*y + z*z + w*w );
-}
-
-// Normalized
-inline vec4_t vec4_t::GetNormalized() const
-{
-	return ME * invSqrt( x*x +y*y + z*z + w*w );
-}
-
-// Normalize
-inline void vec4_t::Normalize()
-{
-	ME *= invSqrt( x*x +y*y + z*z + w*w );
-}
-
-// print
-inline void vec4_t::print() const
-{
-	for( int i=0; i<4; i++ )
-		cout << fixed << ME[i] << " ";
-	cout << "\n" << endl;
-}
-
-
-} // end namespace

+ 5 - 5
src/renderer/r_dbg.cpp

@@ -258,7 +258,7 @@ void RenderQuad( float w, float h )
 	float uvs [][2] = { {1.0,1.0}, {0.0,1.0}, {0.0,0.0}, {1.0,0.0} };
 
 	glBegin( GL_QUADS );
-		glNormal3fv( &(-vec3_t( 0.0, 0.0, 1.0 ))[0] );
+		glNormal3fv( &(-Vec3( 0.0, 0.0, 1.0 ))[0] );
 		glTexCoord2fv( uvs[0] );
 		glVertex2fv( points[0] );
 		glTexCoord2fv( uvs[1] );
@@ -403,9 +403,9 @@ static void RenderSun()
 {
 	glPushMatrix();
 
-	r::MultMatrix( mat4_t( scene::SunPos(), mat3_t::GetIdentity(), 50.0 ) );
+	r::MultMatrix( Mat4( scene::SunPos(), Mat3::getIdentity(), 50.0 ) );
 
-	r::Color3( vec3_t(1.0, 1.0, 0.0) );
+	r::Color3( Vec3(1.0, 1.0, 0.0) );
 	r::dbg::RenderSphere( 1.0/8.0, 8 );
 
 	glPopMatrix();
@@ -421,14 +421,14 @@ static void RenderSun()
 	glLoadIdentity();
 
 
-	vec4_t p = vec4_t( scene::SunPos(), 1.0 );
+	Vec4 p = Vec4( scene::SunPos(), 1.0 );
 	p = main_cam->getProjectionMatrix() * (main_cam->getViewMatrix() * p);
 	p /= p.w;
 	p = p/2 + 0.5;
 
 	glPointSize( 10 );
 	glBegin( GL_POINTS );
-		r::Color3( vec3_t(0.0,1.0,0.0) );
+		r::Color3( Vec3(0.0,1.0,0.0) );
 		glVertex3fv( &p[0] );
 	glEnd();
 

+ 15 - 15
src/renderer/r_is.cpp

@@ -37,8 +37,8 @@ static ShaderProg* shdr_is_lp_spot_light_s;
 
 // the bellow are used to speedup the calculation of the frag pos (view space) inside the shader. This is done by precompute the
 // view vectors each for one corner of the screen and tha planes used to compute the frag_pos_view_space.z from the depth value.
-static vec3_t view_vectors[4];
-static vec2_t planes;
+static Vec3 view_vectors[4];
+static Vec2 planes;
 
 
 /*
@@ -61,7 +61,7 @@ static void InitSMOUVS()
 static void DrawSMOUVS( const PointLight& light )
 {
 	const float scale = 1.2;
-	r::MultMatrix( mat4_t( light.translationWspace, mat3_t::GetIdentity(), light.radius*scale ) );
+	r::MultMatrix( Mat4( light.translationWspace, Mat3::getIdentity(), light.radius*scale ) );
 
 	r::NoShaders();
 
@@ -95,12 +95,12 @@ static void CalcViewVector( const Camera& cam )
 		view_vectors[i] = cam.getViewMatrix() * view_vectors[i];
 		The original code is the above 3 lines. The optimized follows:*/
 
-		vec3_t vec;
+		Vec3 vec;
 		vec.x = (2.0*(pixels[i][0]-viewport[0]))/viewport[2] - 1.0;
 		vec.y = (2.0*(pixels[i][1]-viewport[1]))/viewport[3] - 1.0;
 		vec.z = 1.0;
 
-		view_vectors[i] = vec.GetTransformed( cam.getInvProjectionMatrix() );
+		view_vectors[i] = vec.getTransformed( cam.getInvProjectionMatrix() );
 		// end of optimized code
 	}
 }
@@ -182,7 +182,7 @@ void Init()
 AmbientPass                                                                                                                           =
 =======================================================================================================================================
 */
-static void AmbientPass( const Camera& /*cam*/, const vec3_t& color )
+static void AmbientPass( const Camera& /*cam*/, const Vec3& color )
 {
 	glDisable( GL_BLEND );
 
@@ -190,7 +190,7 @@ static void AmbientPass( const Camera& /*cam*/, const vec3_t& color )
 	shdr_is_ambient->bind();
 
 	// set the uniforms
-	glUniform3fv( shdr_is_ambient->GetUniLoc(0), 1, &((vec3_t)color)[0] );
+	glUniform3fv( shdr_is_ambient->GetUniLoc(0), 1, &((Vec3)color)[0] );
 	shdr_is_ambient->locTexUnit( shdr_is_ambient->GetUniLoc(1), r::ms::diffuse_fai, 0 );
 
 	// Draw quad
@@ -336,11 +336,11 @@ static void PointLightPass( const Camera& cam, const PointLight& light )
 	shader.locTexUnit( shader.GetUniLoc(3), r::ms::depth_fai, 3 );
 	glUniform2fv( shader.GetUniLoc(4), 1, &planes[0] );
 
-	vec3_t light_pos_eye_space = light.translationWspace.GetTransformed( cam.getViewMatrix() );
+	Vec3 light_pos_eye_space = light.translationWspace.getTransformed( cam.getViewMatrix() );
 	glUniform3fv( shader.GetUniLoc(5), 1, &light_pos_eye_space[0] );
 	glUniform1f( shader.GetUniLoc(6), 1.0/light.radius );
-	glUniform3fv( shader.GetUniLoc(7), 1, &vec3_t(light.lightProps->getDiffuseColor())[0] );
-	glUniform3fv( shader.GetUniLoc(8), 1, &vec3_t(light.lightProps->getSpecularColor())[0] );
+	glUniform3fv( shader.GetUniLoc(7), 1, &Vec3(light.lightProps->getDiffuseColor())[0] );
+	glUniform3fv( shader.GetUniLoc(8), 1, &Vec3(light.lightProps->getSpecularColor())[0] );
 
 	//** render quad **
 	glEnableVertexAttribArray( shader.getAttribLoc(0) );
@@ -408,11 +408,11 @@ static void SpotLightPass( const Camera& cam, const SpotLight& light )
 	glUniform2fv( shdr->GetUniLoc(4), 1, &planes[0] );
 
 	// the light params
-	vec3_t light_pos_eye_space = light.translationWspace.GetTransformed( cam.getViewMatrix() );
+	Vec3 light_pos_eye_space = light.translationWspace.getTransformed( cam.getViewMatrix() );
 	glUniform3fv( shdr->GetUniLoc(5), 1, &light_pos_eye_space[0] );
 	glUniform1f( shdr->GetUniLoc(6), 1.0/light.getDistance() );
-	glUniform3fv( shdr->GetUniLoc(7), 1, &vec3_t(light.lightProps->getDiffuseColor())[0] );
-	glUniform3fv( shdr->GetUniLoc(8), 1, &vec3_t(light.lightProps->getSpecularColor())[0] );
+	glUniform3fv( shdr->GetUniLoc(7), 1, &Vec3(light.lightProps->getDiffuseColor())[0] );
+	glUniform3fv( shdr->GetUniLoc(8), 1, &Vec3(light.lightProps->getSpecularColor())[0] );
 
 	// set the light texture
 	shdr->locTexUnit( shdr->GetUniLoc(9), *light.lightProps->getTexture(), 4 );
@@ -424,8 +424,8 @@ static void SpotLightPass( const Camera& cam, const SpotLight& light )
 	//** set texture matrix for shadowmap projection **
 	// Bias * P_light * V_light * inv( V_cam )
 	//const float mBias[] = {0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0};
-	static mat4_t bias_m4( 0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0 );
-	mat4_t tex_projection_mat;
+	static Mat4 bias_m4( 0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0 );
+	Mat4 tex_projection_mat;
 	tex_projection_mat = bias_m4 * light.camera.getProjectionMatrix() * light.camera.getViewMatrix() * cam.transformationWspace;
 	glUniformMatrix4fv( shdr->GetUniLoc(10), 1, true, &tex_projection_mat[0] );
 

+ 1 - 1
src/renderer/r_ms.cpp

@@ -94,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() );
+	scene::skybox.Render( cam.getViewMatrix().getRotationPart() );
 	//glDepthFunc( GL_LEQUAL );
 
 	#if defined( _EARLY_Z_ )

+ 1 - 1
src/renderer/r_pps_lscatt.cpp

@@ -89,7 +89,7 @@ void RunPass( const Camera& cam )
 	shdr->locTexUnit( is_fai_uni_loc, r::is::fai, 1 );
 
 	// pass the light
-	vec4_t p = vec4_t( scene::SunPos(), 1.0 );
+	Vec4 p = Vec4( scene::SunPos(), 1.0 );
 	p = cam.getProjectionMatrix() * (cam.getViewMatrix() * p);
 	p /= p.w;
 	p = p/2 + 0.5;

+ 1 - 1
src/renderer/r_pps_ssao.cpp

@@ -135,7 +135,7 @@ void RunPass( const Camera& cam )
 
 	// fill SSAO FAI
 	shdr_ppp_ssao->bind();
-	glUniform2fv( shdr_ppp_ssao->GetUniLoc(0), 1, &(vec2_t(cam.getZNear(), cam.getZFar()))[0] );
+	glUniform2fv( shdr_ppp_ssao->GetUniLoc(0), 1, &(Vec2(cam.getZNear(), cam.getZFar()))[0] );
 	shdr_ppp_ssao->locTexUnit( shdr_ppp_ssao->GetUniLoc(1), ms::depth_fai, 0 );
 	shdr_ppp_ssao->locTexUnit( shdr_ppp_ssao->GetUniLoc(2), *noise_map, 1 );
 	shdr_ppp_ssao->locTexUnit( shdr_ppp_ssao->GetUniLoc(3), ms::normal_fai, 2 );

+ 19 - 19
src/renderer/renderer.cpp

@@ -75,28 +75,28 @@ static void BuildStdShaderPreProcStr()
 	tmp += "precision lowp float;\n";
 	tmp += "#pragma optimize(on)\n";
 	tmp += "#pragma debug(off)\n";
-	tmp += "#define R_W " + FloatToStr(r::w) + "\n";
-	tmp += "#define R_H " + FloatToStr(r::h) + "\n";
-	//tmp += "#define R_Q " + FloatToStr(r::rendering_quality) + "\n";
-	tmp += "#define SHADOWMAP_SIZE " + IntToStr(r::is::shadows::shadow_resolution) + "\n";
+	tmp += "#define R_W " + Util::floatToStr(r::w) + "\n";
+	tmp += "#define R_H " + Util::floatToStr(r::h) + "\n";
+	//tmp += "#define R_Q " + floatToStr(r::rendering_quality) + "\n";
+	tmp += "#define SHADOWMAP_SIZE " + Util::intToStr(r::is::shadows::shadow_resolution) + "\n";
 	if( r::is::shadows::pcf )
 		tmp += "#define _SHADOW_MAPPING_PCF_\n";
 	if( r::pps::ssao::enabled )
 	{
 		tmp += "#define _SSAO_\n";
-		tmp += "#define SSAO_RENDERING_QUALITY " + FloatToStr(r::pps::ssao::rendering_quality) + "\n";
+		tmp += "#define SSAO_RENDERING_QUALITY " + Util::floatToStr(r::pps::ssao::rendering_quality) + "\n";
 	}
 	if( r::pps::edgeaa::enabled )
 		tmp += "#define _EDGEAA_\n";
 	if( r::pps::hdr::enabled )
 	{
 		tmp += "#define _HDR_\n";
-		tmp += "#define HDR_RENDERING_QUALITY " + FloatToStr(r::pps::hdr::rendering_quality) + "\n";
+		tmp += "#define HDR_RENDERING_QUALITY " + Util::floatToStr(r::pps::hdr::rendering_quality) + "\n";
 	}
 	if( r::pps::lscatt::enabled )
 	{
 		tmp += "#define _LSCATT_\n";
-		tmp += "#define LSCATT_RENDERING_QUALITY " + FloatToStr(r::pps::lscatt::rendering_quality) + "\n";
+		tmp += "#define LSCATT_RENDERING_QUALITY " + Util::floatToStr(r::pps::lscatt::rendering_quality) + "\n";
 	}
 }
 
@@ -129,8 +129,8 @@ void Init()
 	if( !glewIsSupported("GL_ARB_vertex_buffer_object") )
 		WARNING( "Vertex Buffer Objects not supported. The application may crash (and burn)" );
 
-	w = app::window_w /* * rendering_quality*/;
-	h = app::window_h /* * rendering_quality*/;
+	w = app::windowW /* * rendering_quality*/;
+	h = app::windowH /* * rendering_quality*/;
 	aspect_ratio = float(w)/h;
 
 	glClearColor( 0.1, 0.1, 0.1, 0.0 );
@@ -195,8 +195,8 @@ void Render( const Camera& cam )
 	r::bs::RunStage2( cam );
 	r::dbg::RunStage( cam );
 
-	//r::SetViewport( 0, 0, app::window_w, app::window_h );
-	r::SetViewport( 0, 0, app::window_w, app::window_h );
+	//r::SetViewport( 0, 0, app::windowW, app::windowH );
+	r::SetViewport( 0, 0, app::windowW, app::windowH );
 
 	glDisable( GL_DEPTH_TEST );
 	glDisable( GL_BLEND );
@@ -258,20 +258,20 @@ my version of gluUnproject
 =======================================================================================================================================
 */
 bool Unproject( float winX, float winY, float winZ, // window screen coords
-                const mat4_t& modelview_mat, const mat4_t& projection_mat, const int* view,
+                const Mat4& modelview_mat, const Mat4& projection_mat, const int* view,
                 float& objX, float& objY, float& objZ )
 {
-	mat4_t inv_pm = projection_mat * modelview_mat;
-	inv_pm.Invert();
+	Mat4 inv_pm = projection_mat * modelview_mat;
+	inv_pm.invert();
 
 	// the vec is in ndc space meaning: -1<=vec.x<=1 -1<=vec.y<=1 -1<=vec.z<=1
-	vec4_t vec;
+	Vec4 vec;
 	vec.x = (2.0*(winX-view[0]))/view[2] - 1.0;
 	vec.y = (2.0*(winY-view[1]))/view[3] - 1.0;
 	vec.z = 2.0*winZ - 1.0;
 	vec.w = 1.0;
 
-	vec4_t final = inv_pm * vec;
+	Vec4 final = inv_pm * vec;
 	final /= final.w;
 	objX = final.x;
 	objY = final.y;
@@ -285,7 +285,7 @@ bool Unproject( float winX, float winY, float winZ, // window screen coords
 Ortho                                                                                                                                 =
 =======================================================================================================================================
 */
-mat4_t Ortho( float left, float right, float bottom, float top, float near, float far )
+Mat4 Ortho( float left, float right, float bottom, float top, float near, float far )
 {
 	float difx = right-left;
 	float dify = top-bottom;
@@ -293,7 +293,7 @@ mat4_t Ortho( float left, float right, float bottom, float top, float near, floa
 	float tx = -(right+left) / difx;
 	float ty = -(top+bottom) / dify;
 	float tz = -(far+near) / difz;
-	mat4_t m;
+	Mat4 m;
 
 	m(0,0) = 2.0 / difx;
 	m(0,1) = 0.0;
@@ -453,7 +453,7 @@ TakeScreenshot
 */
 void TakeScreenshot( const char* filename )
 {
-	char* ext = util::GetFileExtension( filename );
+	char* ext = Util::getFileExtension( filename );
 	bool ret;
 
 	// exec from this extension

+ 8 - 8
src/renderer/renderer.h

@@ -5,7 +5,7 @@
 #include <GL/glew.h>
 #include <GL/gl.h>
 #include <GL/glu.h>
-#include "gmath.h"
+#include "Math.h"
 #include "ShaderProg.h"
 #include "Camera.h"
 
@@ -42,7 +42,7 @@ inline const string& GetStdShaderPreprocDefines() { extern string std_shader_pre
 extern void Render( const Camera& cam ); ///< The spine function of the renderer
 
 extern void SetGLState_Wireframe();
-extern void SetGLState_WireframeDotted();
+extern void SetGLState_Wireframedotted();
 extern void SetGLState_Solid();
 extern void SetGLState_AlphaSolid();
 
@@ -50,14 +50,14 @@ extern void SetGLState_AlphaSolid();
 //extern
 
 // ogl and glu wrappers
-inline void   MultMatrix( const mat4_t& m4 ) { glMultMatrixf( &(m4.GetTransposed())(0,0) ); } ///< OpenGL wrapper
-inline void   loadMatrix( const mat4_t& m4 ) { glLoadMatrixf( &(m4.GetTransposed())(0,0) ); } ///< OpenGL wrapper
+inline void   MultMatrix( const Mat4& m4 ) { glMultMatrixf( &(m4.getTransposed())(0,0) ); } ///< OpenGL wrapper
+inline void   loadMatrix( const Mat4& m4 ) { glLoadMatrixf( &(m4.getTransposed())(0,0) ); } ///< OpenGL wrapper
 
-inline void   Color3( const vec3_t& v ) { glColor3fv( &((vec3_t&)v)[0] ); } ///< OpenGL wrapper
-inline void   Color4( const vec4_t& v ) { glColor4fv( &((vec4_t&)v)[0] ); } ///< OpenGL wrapper
+inline void   Color3( const Vec3& v ) { glColor3fv( &((Vec3&)v)[0] ); } ///< OpenGL wrapper
+inline void   Color4( const Vec4& v ) { glColor4fv( &((Vec4&)v)[0] ); } ///< OpenGL wrapper
 inline void   NoShaders() { ShaderProg::unbind(); } ///< unbind shaders
-extern bool   Unproject( float winX, float winY, float winZ, const mat4_t& modelview_mat, const mat4_t& projection_mat, const int* view, float& objX, float& objY, float& objZ ); ///< My version of gluUnproject
-extern mat4_t Ortho( float left, float right, float bottom, float top, float near, float far );
+extern bool   Unproject( float winX, float winY, float winZ, const Mat4& modelview_mat, const Mat4& projection_mat, const int* view, float& objX, float& objY, float& objZ ); ///< My version of gluUnproject
+extern Mat4 Ortho( float left, float right, float bottom, float top, float near, float far );
 
 // Matrix stuff
 extern void SetProjectionMatrix( const Camera& cam );

+ 4 - 4
src/renderer2/r_is.cpp

@@ -23,7 +23,7 @@ void renderer_t::illumination_stage_t::point_light_pass_t::InitSMOUVS()
 void renderer_t::illumination_stage_t::point_light_pass_t::DrawSMOUVS( const PointLight& light )
 {
 	const float scale = 1.2;
-	renderer.matrices.model = mat4_t( light.translationWspace, mat3_t::GetIdentity(), light.radius*scale );
+	renderer.matrices.model = Mat4( light.translationWspace, Mat3::getIdentity(), light.radius*scale );
 
 	shader_progs.smouvs.bind();
 
@@ -59,12 +59,12 @@ void renderer_t::illumination_stage_t::CalcViewVector()
 		view_vectors[i] = cam.getViewMatrix() * view_vectors[i];
 		The original code is the above 3 lines. The optimized follows:
 
-		vec3_t vec;
+		Vec3 vec;
 		vec.x = (2.0*(pixels[i][0]-viewport[0]))/viewport[2] - 1.0;
 		vec.y = (2.0*(pixels[i][1]-viewport[1]))/viewport[3] - 1.0;
 		vec.z = 1.0;
 
-		view_vectors[i] = vec.GetTransformed( renderer.camera->getInvProjectionMatrix() );
+		view_vectors[i] = vec.getTransformed( renderer.camera->getInvProjectionMatrix() );
 		// end of optimized code
 	}
 }
@@ -103,7 +103,7 @@ void renderer_t::illumination_stage_t::ambient_pass_t::Run() const
 	shaderProg.bind();
 
 	// set the uniforms
-	glUniform3fv( shaderProg.getUniLoc(0), 1, &((vec3_t)scene::GetAmbientColor())[0] );
+	glUniform3fv( shaderProg.getUniLoc(0), 1, &((Vec3)scene::GetAmbientColor())[0] );
 	shaderProg.locTexUnit( shaderProg.getUniLoc(1), renderer.ms.fais.diffuse, 0 );
 
 	// Draw quad

+ 1 - 1
src/renderer2/r_ms.cpp

@@ -55,7 +55,7 @@ void renderer_t::material_stage_t::Run() const
 	renderer.SetViewport( 0, 0, renderer.width, renderer.height );
 
 	//glEnable( GL_DEPTH_TEST );
-	scene::skybox.render( renderer.camera->getViewMatrix().GetRotationPart() );
+	scene::skybox.render( renderer.camera->getViewMatrix().getRotationPart() );
 	//glDepthFunc( GL_LEQUAL );
 
 

+ 18 - 18
src/renderer2/renderer.cpp

@@ -10,32 +10,32 @@ float renderer_t::quad_vert_cords [][2] = { {1.0,1.0}, {0.0,1.0}, {0.0,0.0}, {1.
 //=====================================================================================================================================
 void renderer_t::UpdateMatrices()
 {
-	const mat4_t& M = matrices.model;
-	const mat4_t& V = matrices.view;
-	const mat4_t& P = matrices.projection;
-	mat4_t& MV = matrices.model_view;
-	mat4_t& MVP = matrices.model_view_projection;
-	mat3_t& N = matrices.normal;
-
-	mat4_t& Mi = matrices.model_inv;
-	mat4_t& Vi = matrices.view_inv;
-	mat4_t& Pi = matrices.projection_inv;
-	mat4_t& MVi = matrices.model_view_inv;
-	mat4_t& MVPi = matrices.model_view_projection_inv;
-	mat3_t& Ni = matrices.normal_inv;
+	const Mat4& M = matrices.model;
+	const Mat4& V = matrices.view;
+	const Mat4& P = matrices.projection;
+	Mat4& MV = matrices.model_view;
+	Mat4& MVP = matrices.model_view_projection;
+	Mat3& N = matrices.normal;
+
+	Mat4& Mi = matrices.model_inv;
+	Mat4& Vi = matrices.view_inv;
+	Mat4& Pi = matrices.projection_inv;
+	Mat4& MVi = matrices.model_view_inv;
+	Mat4& MVPi = matrices.model_view_projection_inv;
+	Mat3& Ni = matrices.normal_inv;
 
 	// matrices
 	MV = V * M;
 	MVP = P * MV;
-	N = MV.GetRotationPart();
+	N = MV.getRotationPart();
 
 	// inv matrices
-	Mi = M.GetInverseTransformation();
-	Vi = V.GetInverseTransformation();
-	Pi = P.GetInverse();
+	Mi = M.getInverseTransformation();
+	Vi = V.getInverseTransformation();
+	Pi = P.getInverse();
 	MV = Mi * Vi;
 	MVPi = MVi * Pi;
-	Ni = MVi.GetRotationPart();
+	Ni = MVi.getRotationPart();
 }
 
 

+ 5 - 5
src/resources/LightProps.h

@@ -3,7 +3,7 @@
 
 #include "common.h"
 #include "Resource.h"
-#include "gmath.h"
+#include "Math.h"
 
 
 class Texture;
@@ -13,8 +13,8 @@ class Texture;
 class LightProps: public Resource
 {
 	// data
-	PROPERTY_R( vec3_t, diffuseCol, getDiffuseColor )
-	PROPERTY_R( vec3_t, specularCol, getSpecularColor )
+	PROPERTY_R( Vec3, diffuseCol, getDiffuseColor )
+	PROPERTY_R( Vec3, specularCol, getSpecularColor )
 	PROPERTY_R( float, radius, getRadius ) ///< For point lights
 	PROPERTY_R( bool, castsShadow_, castsShadow ) ///< For spot lights
 	PROPERTY_R( float, distance, getDistance ) ///< For spot lights. A.K.A.: camera's zFar
@@ -34,8 +34,8 @@ class LightProps: public Resource
 			radius(1.0),
 			castsShadow_(false),
 			distance(3.0),
-			fovX(m::PI/4.0),
-			fovY(m::PI/4.0),
+			fovX(M::PI/4.0),
+			fovY(M::PI/4.0),
 			texture(NULL) 
 		{}
 		virtual ~LightProps() { /* ToDo */ }

+ 5 - 5
src/resources/Material.h

@@ -2,7 +2,7 @@
 #define _MATERIAL_H_
 
 #include "common.h"
-#include "gmath.h"
+#include "Math.h"
 #include "Resource.h"
 
 /// Mesh material resource
@@ -25,13 +25,13 @@ class Material: public Resource
 					VT_VEC4
 				};
 
-				struct Value       // unfortunately we cannot use union because of vec3_t and vec4_t
+				struct Value       // unfortunately we cannot use union because of Vec3 and Vec4
 				{
 					Texture* texture;
 					float    float_;
-					vec2_t   vec2;
-					vec3_t   vec3;
-					vec4_t   vec4;
+					Vec2   vec2;
+					Vec3   vec3;
+					Vec4   vec4;
 					Value(): texture(NULL) {}
 				};
 

+ 39 - 39
src/resources/Mesh.cpp

@@ -197,13 +197,13 @@ void Mesh::createFaceNormals()
 	for( uint i=0; i<tris.size(); i++ )
 	{
 		Triangle& tri = tris[i];
-		const vec3_t& v0 = vertCoords[ tri.vertIds[0] ];
-		const vec3_t& v1 = vertCoords[ tri.vertIds[1] ];
-		const vec3_t& v2 = vertCoords[ tri.vertIds[2] ];
+		const Vec3& v0 = vertCoords[ tri.vertIds[0] ];
+		const Vec3& v1 = vertCoords[ tri.vertIds[1] ];
+		const Vec3& v2 = vertCoords[ tri.vertIds[2] ];
 
-		tri.normal = ( v1 - v0 ).Cross( v2 - v0 );
+		tri.normal = ( v1 - v0 ).cross( v2 - v0 );
 
-		tri.normal.Normalize();
+		tri.normal.normalize();
 	}
 }
 
@@ -216,7 +216,7 @@ void Mesh::createVertNormals()
 	vertNormals.resize( vertCoords.size() ); // alloc
 
 	for( uint i=0; i<vertCoords.size(); i++ )
-		vertNormals[i] = vec3_t( 0.0, 0.0, 0.0 );
+		vertNormals[i] = Vec3( 0.0, 0.0, 0.0 );
 
 	for( uint i=0; i<tris.size(); i++ )
 	{
@@ -227,7 +227,7 @@ void Mesh::createVertNormals()
 	}
 
 	for( uint i=0; i<vertNormals.size(); i++ )
-		vertNormals[i].Normalize();
+		vertNormals[i].normalize();
 }
 
 
@@ -238,12 +238,12 @@ void Mesh::createVertTangents()
 {
 	vertTangents.resize( vertCoords.size() ); // alloc
 
-	Vec<vec3_t> bitagents( vertCoords.size() );
+	Vec<Vec3> bitagents( vertCoords.size() );
 
 	for( uint i=0; i<vertTangents.size(); i++ )
 	{
-		vertTangents[i] = vec4_t( 0.0 );
-		bitagents[i] = vec3_t( 0.0 );
+		vertTangents[i] = Vec4( 0.0 );
+		bitagents[i] = Vec3( 0.0 );
 	}
 
 	for( uint i=0; i<tris.size(); i++ )
@@ -252,27 +252,27 @@ void Mesh::createVertTangents()
 		const int i0 = tri.vertIds[0];
 		const int i1 = tri.vertIds[1];
 		const int i2 = tri.vertIds[2];
-		const vec3_t& v0 = vertCoords[ i0 ];
-		const vec3_t& v1 = vertCoords[ i1 ];
-		const vec3_t& v2 = vertCoords[ i2 ];
-		vec3_t edge01 = v1 - v0;
-		vec3_t edge02 = v2 - v0;
-		vec2_t uvedge01 = texCoords[i1] - texCoords[i0];
-		vec2_t uvedge02 = texCoords[i2] - texCoords[i0];
+		const Vec3& v0 = vertCoords[ i0 ];
+		const Vec3& v1 = vertCoords[ i1 ];
+		const Vec3& v2 = vertCoords[ i2 ];
+		Vec3 edge01 = v1 - v0;
+		Vec3 edge02 = v2 - v0;
+		Vec2 uvedge01 = texCoords[i1] - texCoords[i0];
+		Vec2 uvedge02 = texCoords[i2] - texCoords[i0];
 
 
 		float det = (uvedge01.y * uvedge02.x) - (uvedge01.x * uvedge02.y);
-		DEBUG_ERR( IsZero(det) );
+		DEBUG_ERR( isZero(det) );
 		det = 1.0f / det;
 
-		vec3_t t = ( edge02 * uvedge01.y - edge01 * uvedge02.y ) * det;
-		vec3_t b = ( edge02 * uvedge01.x - edge01 * uvedge02.x ) * det;
-		t.Normalize();
-		b.Normalize();
+		Vec3 t = ( edge02 * uvedge01.y - edge01 * uvedge02.y ) * det;
+		Vec3 b = ( edge02 * uvedge01.x - edge01 * uvedge02.x ) * det;
+		t.normalize();
+		b.normalize();
 
-		vertTangents[i0] += vec4_t(t, 1.0);
-		vertTangents[i1] += vec4_t(t, 1.0);
-		vertTangents[i2] += vec4_t(t, 1.0);
+		vertTangents[i0] += Vec4(t, 1.0);
+		vertTangents[i1] += Vec4(t, 1.0);
+		vertTangents[i2] += Vec4(t, 1.0);
 
 		bitagents[i0] += b;
 		bitagents[i1] += b;
@@ -281,18 +281,18 @@ void Mesh::createVertTangents()
 
 	for( uint i=0; i<vertTangents.size(); i++ )
 	{
-		vec3_t t = vec3_t(vertTangents[i]);
-		const vec3_t& n = vertNormals[i];
-		vec3_t& b = bitagents[i];
+		Vec3 t = Vec3(vertTangents[i]);
+		const Vec3& n = vertNormals[i];
+		Vec3& b = bitagents[i];
 
-		//t = t - n * n.Dot(t);
-		t.Normalize();
+		//t = t - n * n.dot(t);
+		t.normalize();
 
-		b.Normalize();
+		b.normalize();
 
-		float w = ( (n.Cross(t)).Dot( b ) < 0.0) ? 1.0 : -1.0;
+		float w = ( (n.cross(t)).dot( b ) < 0.0) ? 1.0 : -1.0;
 
-		vertTangents[i] = vec4_t( t, w );
+		vertTangents[i] = Vec4( t, w );
 	}
 
 	bitagents.clear();
@@ -304,15 +304,15 @@ void Mesh::createVertTangents()
 //=====================================================================================================================================
 void Mesh::createVBOs()
 {
-	vbos.vertIndeces.Create( GL_ELEMENT_ARRAY_BUFFER, vertIndeces.GetSizeInBytes(), &vertIndeces[0], GL_STATIC_DRAW );
-	vbos.vertCoords.Create( GL_ARRAY_BUFFER, vertCoords.GetSizeInBytes(), &vertCoords[0], GL_STATIC_DRAW );
-	vbos.vertNormals.Create( GL_ARRAY_BUFFER, vertNormals.GetSizeInBytes(), &vertNormals[0], GL_STATIC_DRAW );
+	vbos.vertIndeces.Create( GL_ELEMENT_ARRAY_BUFFER, vertIndeces.getSizeInBytes(), &vertIndeces[0], GL_STATIC_DRAW );
+	vbos.vertCoords.Create( GL_ARRAY_BUFFER, vertCoords.getSizeInBytes(), &vertCoords[0], GL_STATIC_DRAW );
+	vbos.vertNormals.Create( GL_ARRAY_BUFFER, vertNormals.getSizeInBytes(), &vertNormals[0], GL_STATIC_DRAW );
 	if( vertTangents.size() > 1 )
-		vbos.vertTangents.Create( GL_ARRAY_BUFFER, vertTangents.GetSizeInBytes(), &vertTangents[0], GL_STATIC_DRAW );
+		vbos.vertTangents.Create( GL_ARRAY_BUFFER, vertTangents.getSizeInBytes(), &vertTangents[0], GL_STATIC_DRAW );
 	if( texCoords.size() > 1 )
-		vbos.texCoords.Create( GL_ARRAY_BUFFER, texCoords.GetSizeInBytes(), &texCoords[0], GL_STATIC_DRAW );
+		vbos.texCoords.Create( GL_ARRAY_BUFFER, texCoords.getSizeInBytes(), &texCoords[0], GL_STATIC_DRAW );
 	if( vertWeights.size() > 1 )
-		vbos.vertWeights.Create( GL_ARRAY_BUFFER, vertWeights.GetSizeInBytes(), &vertWeights[0], GL_STATIC_DRAW );
+		vbos.vertWeights.Create( GL_ARRAY_BUFFER, vertWeights.getSizeInBytes(), &vertWeights[0], GL_STATIC_DRAW );
 }
 
 

+ 6 - 6
src/resources/Mesh.h

@@ -2,7 +2,7 @@
 #define _MESH_H_
 
 #include "common.h"
-#include "gmath.h"
+#include "Math.h"
 #include "vbo.h"
 #include "Resource.h"
 #include "collision.h"
@@ -28,13 +28,13 @@ class Mesh: public Resource
 		{
 			public:
 				uint   vertIds[3]; // an array with the vertex indexes in the mesh class
-				vec3_t normal;
+				Vec3 normal;
 		};
 
-		Vec<vec3_t>       vertCoords;
-		Vec<vec3_t>       vertNormals;
-		Vec<vec4_t>       vertTangents;
-		Vec<vec2_t>       texCoords;    ///< One for every vert so we can use vertex arrays
+		Vec<Vec3>       vertCoords;
+		Vec<Vec3>       vertNormals;
+		Vec<Vec4>       vertTangents;
+		Vec<Vec2>       texCoords;    ///< One for every vert so we can use vertex arrays
 		Vec<VertexWeight> vertWeights;
 		Vec<Triangle>     tris;
 		Vec<ushort>       vertIndeces; ///< Used for vertex arrays

+ 3 - 3
src/resources/Path.h

@@ -3,15 +3,15 @@
 
 #include "common.h"
 #include "Resource.h"
-#include "gmath.h"
+#include "Math.h"
 
 
 /// Path resource
 class Path: public Resource
 {
 	public:
-		Vec<vec3_t> positions; ///< AKA translations
-		Vec<mat3_t> rotations;
+		Vec<Vec3> positions; ///< AKA translations
+		Vec<Mat3> rotations;
 		Vec<float>  scales;
 		float         step;
 

+ 3 - 3
src/resources/Resource.h

@@ -3,7 +3,7 @@
 
 #include "common.h"
 #include "engine_class.h"
-#include "util.h"
+#include "Util.h"
 
 
 // forward decls
@@ -135,8 +135,8 @@ template<typename Type> class Container: public Vec<Type*>
 		 */
 		Type* load( const char* fname )
 		{
-			char* name = util::CutPath( fname );
-			string path = util::GetPath( fname );
+			char* name = Util::cutPath( fname );
+			string path = Util::getPath( fname );
 			Iterator it = findByNameAndPath( name, path.c_str() );
 
 			// if allready loaded then inc the users and return the pointer

+ 6 - 6
src/resources/ShaderParser.cpp

@@ -2,7 +2,7 @@
 #include "ShaderParser.h"
 #include "Scanner.h"
 #include "parser.h"
-#include "util.h"
+#include "Util.h"
 
 
 //=====================================================================================================================================
@@ -54,7 +54,7 @@ Vec<ShaderParser::ShaderVarPragma>::iterator ShaderParser::findShaderVar( Vec<Sh
 bool ShaderParser::parseFileForPragmas( const string& filename, int id )
 {
 	// load file in lines
-	Vec<string> lines = util::GetFileLines( filename.c_str() );
+	Vec<string> lines = Util::getFileLines( filename.c_str() );
 	if( lines.size() < 1 )
 	{
 		ERROR( "Cannot parse file \"" << filename << "\"" );
@@ -100,7 +100,7 @@ bool ShaderParser::parseFileForPragmas( const string& filename, int id )
 						vertShaderBegins.definedInFile = filename;
 						vertShaderBegins.definedInLine = scanner.getLineNmbr();
 						vertShaderBegins.globalLine = sourceLines.size() + 1;
-						sourceLines.push_back( string("#line ") + IntToStr(scanner.getLineNmbr()) + ' ' + IntToStr(id) + " // " + lines[scanner.getLineNmbr()-1] );
+						sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNmbr()) + ' ' + Util::intToStr(id) + " // " + lines[scanner.getLineNmbr()-1] );
 						// stop play
 					}
 /* fragShaderBegins */
@@ -122,7 +122,7 @@ bool ShaderParser::parseFileForPragmas( const string& filename, int id )
 						fragShaderBegins.definedInFile = filename;
 						fragShaderBegins.definedInLine = scanner.getLineNmbr();
 						fragShaderBegins.globalLine = sourceLines.size() + 1;
-						sourceLines.push_back( string("#line ") + IntToStr(scanner.getLineNmbr()) + ' ' + IntToStr(id) + " // " + lines[scanner.getLineNmbr()-1] );
+						sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNmbr()) + ' ' + Util::intToStr(id) + " // " + lines[scanner.getLineNmbr()-1] );
 						// stop play
 					}
 /* include */
@@ -133,9 +133,9 @@ bool ShaderParser::parseFileForPragmas( const string& filename, int id )
 						{
 							// play
 							//int line = sourceLines.size();
-							sourceLines.push_back( string("#line 0 ") + IntToStr(id+1) + " // " + lines[scanner.getLineNmbr()-1] );
+							sourceLines.push_back( string("#line 0 ") + Util::intToStr(id+1) + " // " + lines[scanner.getLineNmbr()-1] );
 							if( !parseFileForPragmas( token->value.string, id+1 ) ) return false;
-							sourceLines.push_back( string("#line ") + IntToStr(scanner.getLineNmbr()) + ' ' + IntToStr(id) +  " // end of " + lines[scanner.getLineNmbr()-1] );
+							sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNmbr()) + ' ' + Util::intToStr(id) +  " // end of " + lines[scanner.getLineNmbr()-1] );
 							// stop play
 						}
 						else

+ 2 - 2
src/resources/ShaderProg.cpp

@@ -226,8 +226,8 @@ bool ShaderProg::customload( const char* filename, const char* extra_source )
 {
 	if( getName().length() == 0 )
 	{
-		name = util::CutPath( filename );
-		path = util::GetPath( filename );
+		name = Util::cutPath( filename );
+		path = Util::getPath( filename );
 	}
 
 	ShaderParser pars;

+ 1 - 1
src/resources/SkelAnim.cpp

@@ -55,7 +55,7 @@ bool SkelAnim::load( const char* filename )
 				// parse the quat
 				float tmp[4];
 				if( !ParseArrOfNumbers( scanner, false, true, 4, &tmp[0] ) ) return false;
-				bones[i].keyframes[j].rotation = quat_t( tmp[1], tmp[2], tmp[3], tmp[0] );
+				bones[i].keyframes[j].rotation = Quat( tmp[1], tmp[2], tmp[3], tmp[0] );
 
 				// parse the vec3
 				if( !ParseArrOfNumbers( scanner, false, true, 3, &bones[i].keyframes[j].translation[0] ) ) return false;

+ 3 - 3
src/resources/SkelAnim.h

@@ -3,7 +3,7 @@
 
 #include "common.h"
 #include "Resource.h"
-#include "gmath.h"
+#include "Math.h"
 
 
 /// Skeleton animation
@@ -14,8 +14,8 @@ class SkelAnim: public Resource
 		class BonePose
 		{
 			public:
-				quat_t rotation;
-				vec3_t translation;
+				Quat rotation;
+				Vec3 translation;
 		};
 
 

+ 6 - 6
src/resources/Skeleton.cpp

@@ -44,15 +44,15 @@ bool Skeleton::load( const char* filename )
 		if( !ParseArrOfNumbers<float>( scanner, false, true, 3, &bone.tail[0] ) ) return false;
 
 		// matrix
-		mat4_t m4;
+		Mat4 m4;
 		if( !ParseArrOfNumbers<float>( scanner, false, true, 16, &m4[0] ) ) return false;
 
 		// matrix for real
-		bone.rotSkelSpace = m4.GetRotationPart();
-		bone.tslSkelSpace = m4.GetTranslationPart();
-		mat4_t MAi( m4.GetInverse() );
-		bone.rotSkelSpaceInv = MAi.GetRotationPart();
-		bone.tslSkelSpaceInv = MAi.GetTranslationPart();
+		bone.rotSkelSpace = m4.getRotationPart();
+		bone.tslSkelSpace = m4.getTranslationPart();
+		Mat4 MAi( m4.getInverse() );
+		bone.rotSkelSpaceInv = MAi.getRotationPart();
+		bone.tslSkelSpaceInv = MAi.getTranslationPart();
 
 		// parent
 		token = &scanner.getNextToken();

+ 9 - 9
src/resources/Skeleton.h

@@ -2,7 +2,7 @@
 #define _SKELETON_H_
 
 #include "common.h"
-#include "gmath.h"
+#include "Math.h"
 #include "Resource.h"
 #include "engine_class.h"
 
@@ -20,17 +20,17 @@ class Skeleton: public Resource
 				Bone* parent;
 				Bone* childs[ MAX_CHILDS_PER_BONE ];
 				ushort  childsNum;
-				vec3_t  head;
-				vec3_t  tail;
+				Vec3  head;
+				Vec3  tail;
 
 				/* The rotation and translation that transform the bone from bone space to armature space. Meaning that if
-				MA = TRS(rotSkelSpace, tslSkelSpace) then head = MA * vec3_t(0.0, length, 0.0) and tail = MA * vec3_t( 0.0, 0.0, 0.0 )
-				We also keep the inverted ones for fast calculations. rotSkelSpaceInv = MA.Inverted().GetRotationPart() and NOT
+				MA = TRS(rotSkelSpace, tslSkelSpace) then head = MA * Vec3(0.0, length, 0.0) and tail = MA * Vec3( 0.0, 0.0, 0.0 )
+				We also keep the inverted ones for fast calculations. rotSkelSpaceInv = MA.Inverted().getRotationPart() and NOT
 				rotSkelSpaceInv = rotSkelSpace.GetInverted() */
-				mat3_t rotSkelSpace;
-				vec3_t tslSkelSpace;
-				mat3_t rotSkelSpaceInv;
-				vec3_t tslSkelSpaceInv;
+				Mat3 rotSkelSpace;
+				Vec3 tslSkelSpace;
+				Mat3 rotSkelSpaceInv;
+				Vec3 tslSkelSpaceInv;
 
 				 Bone() {}
 				~Bone() {}

+ 1 - 1
src/resources/Texture.cpp

@@ -263,7 +263,7 @@ bool Image::loadPNG( const char* filename )
 bool Image::load( const char* filename )
 {
 	// get the extension
-	char* ext = util::GetFileExtension( filename );
+	char* ext = Util::getFileExtension( filename );
 
 	// load from this extension
 	if( strcmp( ext, "tga" ) == 0 )

+ 25 - 25
src/scene/Camera.cpp

@@ -38,7 +38,7 @@ void Camera::render()
 
 	//glLineWidth( 2.0 );
 
-	glColor3fv( &vec3_t(1.0,0.0,1.0)[0] );
+	glColor3fv( &Vec3(1.0,0.0,1.0)[0] );
 	glBegin( GL_LINES );
 		glVertex3fv( &points[0][0] );
 		glVertex3fv( &points[1][0] );
@@ -70,13 +70,13 @@ void Camera::render()
 //=====================================================================================================================================
 // lookAtPoint                                                                                                                        =
 //=====================================================================================================================================
-void Camera::lookAtPoint( const vec3_t& point )
+void Camera::lookAtPoint( const Vec3& point )
 {
-	const vec3_t& j = vec3_t( 0.0, 1.0, 0.0 );
-	vec3_t vdir = (point - translationLspace).GetNormalized();
-	vec3_t vup = j - vdir * j.Dot(vdir);
-	vec3_t vside = vdir.Cross( vup );
-	rotationLspace.SetColumns( vside, vup, -vdir );
+	const Vec3& j = Vec3( 0.0, 1.0, 0.0 );
+	Vec3 vdir = (point - translationLspace).getNormalized();
+	Vec3 vup = j - vdir * j.dot(vdir);
+	Vec3 vside = vdir.cross( vup );
+	rotationLspace.setColumns( vside, vup, -vdir );
 }
 
 
@@ -89,20 +89,20 @@ void Camera::calcLSpaceFrustumPlanes()
 
 	sinCos( PI+fovX/2, s, c );
 	// right
-	lspaceFrustumPlanes[FP_RIGHT] = plane_t( vec3_t(c, 0.0, s), 0.0 );
+	lspaceFrustumPlanes[FP_RIGHT] = plane_t( Vec3(c, 0.0, s), 0.0 );
 	// left
-	lspaceFrustumPlanes[FP_LEFT] = plane_t( vec3_t(-c, 0.0, s), 0.0 );
+	lspaceFrustumPlanes[FP_LEFT] = plane_t( Vec3(-c, 0.0, s), 0.0 );
 
 	sinCos( (3*PI-fovY)*0.5, s, c );
 	// top
-	lspaceFrustumPlanes[FP_TOP] = plane_t( vec3_t(0.0, s, c), 0.0 );
+	lspaceFrustumPlanes[FP_TOP] = plane_t( Vec3(0.0, s, c), 0.0 );
 	// bottom
-	lspaceFrustumPlanes[FP_BOTTOM] = plane_t( vec3_t(0.0, -s, c), 0.0 );
+	lspaceFrustumPlanes[FP_BOTTOM] = plane_t( Vec3(0.0, -s, c), 0.0 );
 
 	// near
-	lspaceFrustumPlanes[FP_NEAR] = plane_t( vec3_t( 0.0, 0.0, -1.0 ), zNear );
+	lspaceFrustumPlanes[FP_NEAR] = plane_t( Vec3( 0.0, 0.0, -1.0 ), zNear );
 	// far
-	lspaceFrustumPlanes[FP_FAR] = plane_t( vec3_t( 0.0, 0.0, 1.0 ), -zFar );
+	lspaceFrustumPlanes[FP_FAR] = plane_t( Vec3( 0.0, 0.0, 1.0 ), -zFar );
 }
 
 
@@ -137,7 +137,7 @@ bool Camera::insideFrustum( const bvolume_t& bvol ) const
 bool Camera::insideFrustum( const Camera& cam ) const
 {
 	//** get five points. These points are the tips of the given camera **
-	vec3_t points[5];
+	Vec3 points[5];
 
 	// get 3 sample floats
 	float x = cam.getZFar() / tan( (PI-cam.getFovX())/2 );
@@ -145,15 +145,15 @@ bool Camera::insideFrustum( const Camera& cam ) const
 	float z = -cam.getZFar();
 
 	// the actual points in local space
-	points[0] = vec3_t( x, y, z ); // top right
-	points[1] = vec3_t( -x, y, z ); // top left
-	points[2] = vec3_t( -x, -y, z ); // bottom left
-	points[3] = vec3_t( x, -y, z ); // bottom right
-	points[4] = vec3_t( cam.translationWspace ); // eye (allready in world space)
+	points[0] = Vec3( x, y, z ); // top right
+	points[1] = Vec3( -x, y, z ); // top left
+	points[2] = Vec3( -x, -y, z ); // bottom left
+	points[3] = Vec3( x, -y, z ); // bottom right
+	points[4] = Vec3( cam.translationWspace ); // eye (allready in world space)
 
 	// transform them to the given camera's world space (exept the eye)
 	for( uint i=0; i<4; i++ )
-		points[i].Transform( cam.translationWspace, cam.rotationWspace, cam.scaleWspace );
+		points[i].transform( cam.translationWspace, cam.rotationWspace, cam.scaleWspace );
 
 
 	//** the collision code **
@@ -197,7 +197,7 @@ void Camera::calcProjectionMatrix()
 	projectionMat(3,2) = -1.0;
 	projectionMat(3,3) = 0.0;
 
-	invProjectionMat = projectionMat.GetInverse();
+	invProjectionMat = projectionMat.getInverse();
 }
 
 
@@ -207,16 +207,16 @@ void Camera::calcProjectionMatrix()
 void Camera::updateViewMatrix()
 {
 	/* The point at which the camera looks:
-	vec3_t viewpoint = translationLspace + z_axis;
+	Vec3 viewpoint = translationLspace + z_axis;
 	as we know the up vector, we can easily use gluLookAt:
 	gluLookAt( translationLspace.x, translationLspace.x, translationLspace.z, z_axis.x, z_axis.y, z_axis.z, y_axis.x, y_axis.y, y_axis.z );
 	*/
 
 
 	// The view matrix is: Mview = camera.world_transform.Inverted(). Bus instead of inverting we do the following:
-	mat3_t cam_inverted_rot = rotationWspace.GetTransposed();
-	vec3_t cam_inverted_tsl = -( cam_inverted_rot * translationWspace );
-	viewMat = mat4_t( cam_inverted_tsl, cam_inverted_rot );
+	Mat3 cam_inverted_rot = rotationWspace.getTransposed();
+	Vec3 cam_inverted_tsl = -( cam_inverted_rot * translationWspace );
+	viewMat = Mat4( cam_inverted_tsl, cam_inverted_rot );
 }
 
 

+ 7 - 7
src/scene/Camera.h

@@ -30,15 +30,15 @@ class Camera: public Node
 		plane_t wspaceFrustumPlanes[6];
 
 		// matrices
-		mat4_t projectionMat;
-		mat4_t viewMat;
+		Mat4 projectionMat;
+		Mat4 viewMat;
 		/**
 		 * Used in deferred shading for the calculation of view vector (see CalcViewVector). The reason we store this matrix here is
 		 * that we dont want it to be re-calculated all the time but only when the projection params (fovX, fovY, zNear, zFar) change.
 		 * Fortunately the projection params change rarely. Note that the Camera as we all know re-calculates the matreces only when the
 		 * parameteres change!!
 		 */
-		mat4_t invProjectionMat;
+		Mat4 invProjectionMat;
 
 		// misc
 		void calcProjectionMatrix();
@@ -68,12 +68,12 @@ class Camera: public Node
 		float getFovY () const { return fovY; }
 		float getZNear() const { return zNear; }
 		float getZFar () const { return zFar; }
-		const mat4_t& getProjectionMatrix() const { return projectionMat; }
-		const mat4_t& getViewMatrix() const { return viewMat; }
-		const mat4_t& getInvProjectionMatrix() const { return invProjectionMat; } // see the declaration of invProjectionMat for info
+		const Mat4& getProjectionMatrix() const { return projectionMat; }
+		const Mat4& getViewMatrix() const { return viewMat; }
+		const Mat4& getInvProjectionMatrix() const { return invProjectionMat; } // see the declaration of invProjectionMat for info
 
 		// misc
-		void lookAtPoint( const vec3_t& point );
+		void lookAtPoint( const Vec3& point );
 		void updateWorldStuff();
 		void render();
 		void init( const char* ) {}

+ 1 - 1
src/scene/Light.cpp

@@ -42,7 +42,7 @@ void Light::deinit()
 //=====================================================================================================================================
 // RenderSphere                                                                                                                       =
 //=====================================================================================================================================
-static void RenderSphere( const mat4_t& tsl, const vec3_t& col )
+static void RenderSphere( const Mat4& tsl, const Vec3& col )
 {
 	glPushMatrix();
 	r::MultMatrix( tsl );

+ 9 - 9
src/scene/Node.cpp

@@ -18,12 +18,12 @@ void Node::commonConstructorCode()
 {
 	parent = NULL;
 	isGroupNode = false;
-	translationLspace = vec3_t( 0.0 );
+	translationLspace = Vec3( 0.0 );
 	scaleLspace = 1.0;
-	rotationLspace = mat3_t::GetIdentity();
-	translationWspace = vec3_t( 0.0 );
+	rotationLspace = Mat3::getIdentity();
+	translationWspace = Vec3( 0.0 );
 	scaleWspace = 1.0;
-	rotationWspace = mat3_t::GetIdentity();
+	rotationWspace = Mat3::getIdentity();
 	bvolumeLspace = NULL;
 
 	scene::registerNode( this );
@@ -49,7 +49,7 @@ void Node::updateWorldTransform()
 		scaleWspace = parent->scaleWspace * scaleLspace;
 		rotationWspace = parent->rotationWspace * rotationLspace;
 		translationWspace = translationLspace.Transformed( parent->translationWspace, parent->rotationWspace, parent->scaleWspace ); */
-		CombineTransformations( parent->translationWspace, parent->rotationWspace, parent->scaleWspace,
+		combineTransformations( parent->translationWspace, parent->rotationWspace, parent->scaleWspace,
 		                        translationLspace, rotationLspace, scaleLspace,
 		                        translationWspace, rotationWspace, scaleWspace );
 	}
@@ -60,7 +60,7 @@ void Node::updateWorldTransform()
 		translationWspace = translationLspace;
 	}
 
-	transformationWspace = mat4_t( translationWspace, rotationWspace, scaleWspace );
+	transformationWspace = Mat4( translationWspace, rotationWspace, scaleWspace );
 
 
 	// transform the bvolume
@@ -104,19 +104,19 @@ void Node::updateWorldTransform()
 //=====================================================================================================================================
 void Node::moveLocalX( float distance )
 {
-	vec3_t x_axis = rotationLspace.GetColumn(0);
+	Vec3 x_axis = rotationLspace.getColumn(0);
 	translationLspace += x_axis * distance;
 }
 
 void Node::moveLocalY( float distance )
 {
-	vec3_t y_axis = rotationLspace.GetColumn(1);
+	Vec3 y_axis = rotationLspace.getColumn(1);
 	translationLspace += y_axis * distance;
 }
 
 void Node::moveLocalZ( float distance )
 {
-	vec3_t z_axis = rotationLspace.GetColumn(2);
+	Vec3 z_axis = rotationLspace.getColumn(2);
 	translationLspace += z_axis * distance;
 }
 

+ 10 - 10
src/scene/Node.h

@@ -3,7 +3,7 @@
 
 #include <memory>
 #include "common.h"
-#include "gmath.h"
+#include "Math.h"
 
 
 class bvolume_t;
@@ -25,15 +25,15 @@ class Node
 			NT_SKEL_MODEL
 		};
 
-		vec3_t translationLspace;
-		mat3_t rotationLspace;
+		Vec3 translationLspace;
+		Mat3 rotationLspace;
 		float  scaleLspace;
 
-		vec3_t translationWspace;
-		mat3_t rotationWspace;
+		Vec3 translationWspace;
+		Mat3 rotationWspace;
 		float  scaleWspace;
 
-		mat4_t transformationWspace;
+		Mat4 transformationWspace;
 
 		Node* parent;
 		Vec<Node*> childs;
@@ -58,15 +58,15 @@ class Node
 		virtual void deinit() = 0;
 		virtual void updateWorldStuff() { updateWorldTransform(); } ///< This update happens only when the object gets moved. Override it if you want more
 		void updateWorldTransform();
-		void rotateLocalX( float ang_degrees ) { rotationLspace.RotateXAxis( ang_degrees ); }
-		void rotateLocalY( float ang_degrees ) { rotationLspace.RotateYAxis( ang_degrees ); }
-		void rotateLocalZ( float ang_degrees ) { rotationLspace.RotateZAxis( ang_degrees ); }
+		void rotateLocalX( float ang_degrees ) { rotationLspace.rotateXAxis( ang_degrees ); }
+		void rotateLocalY( float ang_degrees ) { rotationLspace.rotateYAxis( ang_degrees ); }
+		void rotateLocalZ( float ang_degrees ) { rotationLspace.rotateZAxis( ang_degrees ); }
 		void moveLocalX( float distance );
 		void moveLocalY( float distance );
 		void moveLocalZ( float distance );
 		void addChild( Node* node );
 		void removeChild( Node* node );
-		void setLocalTransformation( const vec3_t& t, const mat3_t& r, float s ) { translationLspace=t; rotationLspace=r; scaleLspace=s; }
+		void setLocalTransformation( const Vec3& t, const Mat3& r, float s ) { translationLspace=t; rotationLspace=r; scaleLspace=s; }
 };
 
 

+ 2 - 2
src/scene/Scene.h

@@ -17,8 +17,8 @@ namespace scene {
 
 // misc
 extern skybox_t skybox;
-inline vec3_t GetAmbientColor() { return vec3_t( 0.1, 0.05, 0.05 )*1; }
-inline vec3_t SunPos() { return vec3_t( 0.0, 1.0, -1.0 ) * 50.0; }
+inline Vec3 GetAmbientColor() { return Vec3( 0.1, 0.05, 0.05 )*1; }
+inline Vec3 SunPos() { return Vec3( 0.0, 1.0, -1.0 ) * 50.0; }
 
 // funcs
 extern void registerNode( Node* node );

+ 2 - 2
src/scene/SkelNode.cpp

@@ -47,14 +47,14 @@ void SkelNode::render()
 
 	for( uint i=0; i<skeleton->bones.size(); i++ )
 	{
-		glColor3fv( &vec3_t( 1.0, 1.0, 1.0 )[0] );
+		glColor3fv( &Vec3( 1.0, 1.0, 1.0 )[0] );
 		glBegin( GL_POINTS );
 			glVertex3fv( &skelAnimCtrl->heads[i][0] );
 		glEnd();
 
 		glBegin( GL_LINES );
 			glVertex3fv( &skelAnimCtrl->heads[i][0] );
-			glColor3fv( &vec3_t( 1.0, 0.0, 0.0 )[0] );
+			glColor3fv( &Vec3( 1.0, 0.0, 0.0 )[0] );
 			glVertex3fv( &skelAnimCtrl->tails[i][0] );
 		glEnd();
 	}

+ 1 - 1
src/scene/SkelNode.h

@@ -4,7 +4,7 @@
 #include "common.h"
 #include "Node.h"
 #include "Controller.h"
-#include "gmath.h"
+#include "Math.h"
 
 class Skeleton;
 class SkelAnimCtrl;

+ 2 - 2
src/ui/ui.cpp

@@ -165,7 +165,7 @@ void Init()
 	shader = rsrc::shaders.load( "shaders/txt.glsl" );
 	SetPos( 0.0f, 0.0f );
 	SetFontWidth( 0.05f );
-	SetColor( vec4_t(1.0f, 1.0f, 1.0f, 1.0f) );
+	SetColor( Vec4(1.0f, 1.0f, 1.0f, 1.0f) );
 	italic = false;
 }
 
@@ -182,7 +182,7 @@ void SetFontWidth( float w_ )
 
 
 // SetColor
-void SetColor( const vec4_t& color_ )
+void SetColor( const Vec4& color_ )
 {
 	for( int i=0; i<4; i++ )
 		color[i] = color_[i];

+ 3 - 3
src/ui/ui.h

@@ -3,15 +3,15 @@
 
 #include "common.h"
 
-namespace m {
-	class vec4_t;
+namespace M {
+	class Vec4;
 }
 
 namespace ui { // begin namespace
 
 
 extern void Init(); // exec after init SDL
-extern void SetColor( const m::vec4_t& color );
+extern void SetColor( const M::Vec4& color );
 extern void SetPos( float x_, float y_ );
 extern void SetFontWidth( float w_ );
 extern void printf( const char* format, ... );

File diff ditekan karena terlalu besar
+ 187 - 187
src/uncategorized/collision.cpp


+ 53 - 53
src/uncategorized/collision.h

@@ -10,7 +10,7 @@ move bvolume2 for the seperation. The impact_point is a point between inside the
 */
 
 #include "common.h"
-#include "gmath.h"
+#include "Math.h"
 
 class lineseg_t;
 class ray_t;
@@ -60,10 +60,10 @@ class bvolume_t
 		        bool Intersects( const bvolume_t& bv )   const;        ///< Abstract intersection test
 
 		// SeperationTests
-		virtual bool SeperationTest( const bsphere_t&, vec3_t&, vec3_t&, float& ) const { ERROR("N.A."); return false; }
-		virtual bool SeperationTest( const aabb_t&, vec3_t&, vec3_t&, float& )    const { ERROR("N.A."); return false; }
-		virtual bool SeperationTest( const obb_t&, vec3_t&, vec3_t&, float& )     const { ERROR("N.A."); return false; }
-		        bool SeperationTest( const bvolume_t& bv, vec3_t& normal, vec3_t& impact_point, float& depth ) const; ///< Abstract seperation test
+		virtual bool SeperationTest( const bsphere_t&, Vec3&, Vec3&, float& ) const { ERROR("N.A."); return false; }
+		virtual bool SeperationTest( const aabb_t&, Vec3&, Vec3&, float& )    const { ERROR("N.A."); return false; }
+		virtual bool SeperationTest( const obb_t&, Vec3&, Vec3&, float& )     const { ERROR("N.A."); return false; }
+		        bool SeperationTest( const bvolume_t& bv, Vec3& normal, Vec3& impact_point, float& depth ) const; ///< Abstract seperation test
 };
 
 
@@ -76,19 +76,19 @@ class lineseg_t: public bvolume_t
 {
 	public:
 		// data members
-		vec3_t origin; // P0
-		vec3_t dir;    // P1 = origin+dir so dir = P1-origin
+		Vec3 origin; // P0
+		Vec3 dir;    // P1 = origin+dir so dir = P1-origin
 
 		// constructors & distructors
 		lineseg_t(): bvolume_t(LINE_SEG) {}
 		lineseg_t( const lineseg_t& b ): bvolume_t(LINE_SEG) { (*this)=b; }
-		lineseg_t( const vec3_t& origin_, const vec3_t& dir_ ): bvolume_t(LINE_SEG) { origin=origin_; dir=dir_; }
+		lineseg_t( const Vec3& origin_, const Vec3& dir_ ): bvolume_t(LINE_SEG) { origin=origin_; dir=dir_; }
 
 		// operators
 		lineseg_t& operator =( const lineseg_t& b ) { origin=b.origin; dir=b.dir; return (*this); }
 
 		// std funcs
-		lineseg_t Transformed( const vec3_t& translate, const mat3_t& rotate, float scale ) const;
+		lineseg_t Transformed( const Vec3& translate, const Mat3& rotate, float scale ) const;
 		void Render();
 		float PlaneTest( const plane_t& ) const;
 		bool Intersects( const bsphere_t& sphere ) const;
@@ -102,14 +102,14 @@ class lineseg_t: public bvolume_t
 		2) When we talk about distances we calc the distance between the point|line|ray etc and the P0 OR P1. For example the dist
 		between a point and P0 or P1 depending of t_c
 		*/
-		float  LengthSquared() const { return dir.LengthSquared(); }
-		float  Length() const { return dir.Length(); }
+		float  LengthSquared() const { return dir.getLengthSquared(); }
+		float  Length() const { return dir.getLength(); }
 		float  DistanceSquared( const lineseg_t& seg, float& s_c, float& t_c ) const;   ///< Dist with another segment
 		float  DistanceSquared( const ray_t& ray, float& s_c, float& t_c ) const;       ///< Dist with a ray
-		float  DistanceSquared( const vec3_t& point, float& t_c ) const;                ///< Dist with a point.
-		void   ClosestPoints( const lineseg_t& seg, vec3_t& point0, vec3_t& point1 ) const; ///< Closest points between this and another seg
-		void   ClosestPoints( const ray_t& ray, vec3_t& point0, vec3_t& point1 ) const;     ///< Closest points between this and a ray
-		vec3_t ClosestPoints( const vec3_t& point ) const;                                  ///< Closest points between this and a poin
+		float  DistanceSquared( const Vec3& point, float& t_c ) const;                ///< Dist with a point.
+		void   ClosestPoints( const lineseg_t& seg, Vec3& point0, Vec3& point1 ) const; ///< Closest points between this and another seg
+		void   ClosestPoints( const ray_t& ray, Vec3& point0, Vec3& point1 ) const;     ///< Closest points between this and a ray
+		Vec3 ClosestPoints( const Vec3& point ) const;                                  ///< Closest points between this and a poin
 };
 
 
@@ -122,19 +122,19 @@ class ray_t: bvolume_t
 {
 	public:
 		// data members
-		vec3_t origin;
-		vec3_t dir; ///< Normalized vec3_t
+		Vec3 origin;
+		Vec3 dir; ///< Normalized Vec3
 
 		// constructors & distructors
 		ray_t(): bvolume_t(RAY) {}
 		ray_t( const ray_t& b ): bvolume_t(RAY) { (*this)=b; }
-		ray_t( const vec3_t& origin_, const vec3_t& dir_ ): bvolume_t(RAY), origin(origin_), dir(dir_) {}
+		ray_t( const Vec3& origin_, const Vec3& dir_ ): bvolume_t(RAY), origin(origin_), dir(dir_) {}
 
 		// operators
 		ray_t& operator =( const ray_t& b ) { origin=b.origin; dir=b.dir; return (*this); }
 
 		// std funcs
-		ray_t Transformed( const vec3_t& translate, const mat3_t& rotate, float scale ) const;
+		ray_t Transformed( const Vec3& translate, const Mat3& rotate, float scale ) const;
 		void Render();
 		float PlaneTest( const plane_t& ) const;
 		bool Intersects( const bsphere_t& sphere ) const;
@@ -143,8 +143,8 @@ class ray_t: bvolume_t
 
 		// other funcs
 		float  DistanceSquared( const ray_t& ray, float& s_c, float& t_c ) const;   // this and another ray
-		void   ClosestPoints( const ray_t& ray, vec3_t& point0, vec3_t& point1 ) const;   // this and another ray
-		vec3_t ClosestPoint( const vec3_t& point ) const;                                 // this and point
+		void   ClosestPoints( const ray_t& ray, Vec3& point0, Vec3& point1 ) const;   // this and another ray
+		Vec3 ClosestPoint( const Vec3& point ) const;                                 // this and point
 };
 
 
@@ -157,39 +157,39 @@ class plane_t: public bvolume_t
 {
 	public:
 		// data members
-		vec3_t normal;
+		Vec3 normal;
 		float  offset;
 
 		// constructors & distructors
 		plane_t(): bvolume_t(PLANE) {}
 		plane_t( const plane_t& b ): bvolume_t(PLANE) { (*this)=b; }
-		plane_t( const vec3_t& normal_, float offset_ ): bvolume_t(PLANE), normal(normal_), offset(offset_) {}
-		plane_t( const vec3_t& p0, const vec3_t& p1, const vec3_t& p2 ): bvolume_t(PLANE) { Set(p0,p1,p2); }
+		plane_t( const Vec3& normal_, float offset_ ): bvolume_t(PLANE), normal(normal_), offset(offset_) {}
+		plane_t( const Vec3& p0, const Vec3& p1, const Vec3& p2 ): bvolume_t(PLANE) { Set(p0,p1,p2); }
 		plane_t( float a, float b, float c, float d ): bvolume_t(PLANE) { Set(a,b,c,d); }
 
 		// operators
 		plane_t& operator =( const plane_t& b ) { normal=b.normal; offset=b.offset; return (*this); }
 
 		// std funcs
-		plane_t Transformed( const vec3_t& translate, const mat3_t& rotate, float scale ) const;
+		plane_t Transformed( const Vec3& translate, const Mat3& rotate, float scale ) const;
 		void Render();
 
 		// other funcs
-		void Set( const vec3_t& p0, const vec3_t& p1, const vec3_t& p2 ); ///< Set the plane from 3 vectors
+		void Set( const Vec3& p0, const Vec3& p1, const Vec3& p2 ); ///< Set the plane from 3 vectors
 		void Set( float a, float b, float c, float d ); ///< Set from plane where plane equation is ax+by+cz+d
 
 		/**
 		 * It gives the distance between a point and a plane. if returns >0 then the point lies in front of the plane, if <0 then it
 		 * is behind and if =0 then it is co-planar
 		 */
-		float Test( const vec3_t& point ) const { return normal.Dot(point) - offset; }
+		float Test( const Vec3& point ) const { return normal.dot(point) - offset; }
 
-		float Distance( const vec3_t& point ) const { return fabs( Test(point) ); }
+		float Distance( const Vec3& point ) const { return fabs( Test(point) ); }
 
 		/**
 		 * Returns the perpedicular point of a given point in this plane. Plane's normal and returned-point are perpedicular
 		 */
-		vec3_t ClosestPoint( const vec3_t& point ) const { return point - normal*Test(point); };
+		Vec3 ClosestPoint( const Vec3& point ) const { return point - normal*Test(point); };
 };
 
 
@@ -202,19 +202,19 @@ class bsphere_t: public bvolume_t
 {
 	public:
 		// data members
-		vec3_t center;
+		Vec3 center;
 		float radius;
 
 		// constructors & distractor
 		bsphere_t(): bvolume_t(BSPHERE) {}
 		bsphere_t( const bsphere_t& other ): bvolume_t(BSPHERE) { (*this) = other; }
-		bsphere_t( const vec3_t& center_, float radius_ ): bvolume_t(BSPHERE), center(center_), radius(radius_) {}
+		bsphere_t( const Vec3& center_, float radius_ ): bvolume_t(BSPHERE), center(center_), radius(radius_) {}
 
 		// operators
 		bsphere_t& operator =( const bsphere_t& other ) { center=other.center; radius=other.radius; return (*this); }
 
 		// std funcs
-		bsphere_t Transformed( const vec3_t& translate, const mat3_t& rotate, float scale ) const;
+		bsphere_t Transformed( const Vec3& translate, const Mat3& rotate, float scale ) const;
 		void Render();
 		float PlaneTest( const plane_t& plane ) const;
 		bool Intersects( const ray_t& ray ) const;
@@ -222,9 +222,9 @@ class bsphere_t: public bvolume_t
 		bool Intersects( const bsphere_t& sphere ) const;
 		bool Intersects( const aabb_t& aabb ) const;
 		bool Intersects( const obb_t& obb ) const;
-		bool SeperationTest( const bsphere_t& sphere, vec3_t& normal, vec3_t& impact_point, float& depth ) const;
-		bool SeperationTest( const aabb_t& aabb, vec3_t& normal, vec3_t& impact_point, float& depth ) const;
-		bool SeperationTest( const obb_t& obb, vec3_t& normal, vec3_t& impact_point, float& depth ) const;
+		bool SeperationTest( const bsphere_t& sphere, Vec3& normal, Vec3& impact_point, float& depth ) const;
+		bool SeperationTest( const aabb_t& aabb, Vec3& normal, Vec3& impact_point, float& depth ) const;
+		bool SeperationTest( const obb_t& obb, Vec3& normal, Vec3& impact_point, float& depth ) const;
 
 		// other funcs
 		void Set( const void* pointer, uint stride, int count ); ///< Set from vec3 array
@@ -240,19 +240,19 @@ class aabb_t: public bvolume_t
 {
 	public:
 		// data members
-		vec3_t min;
-		vec3_t max;
+		Vec3 min;
+		Vec3 max;
 
 		// constructors & destractor
 		aabb_t(): bvolume_t(AABB) {}
 		aabb_t( const aabb_t& other ): bvolume_t(AABB) { (*this) = other; }
-		aabb_t( const vec3_t& min_, const vec3_t& max_ ): bvolume_t(AABB), min(min_), max(max_) { DEBUG_ERR( max.x<min.x || max.y<min.y || max.z<min.z ) }
+		aabb_t( const Vec3& min_, const Vec3& max_ ): bvolume_t(AABB), min(min_), max(max_) { DEBUG_ERR( max.x<min.x || max.y<min.y || max.z<min.z ) }
 
 		// operators
 		aabb_t& operator =( const aabb_t& other ) { min=other.min; max=other.max; return (*this); }
 
 		// std funcs
-		aabb_t Transformed( const vec3_t& translate, const mat3_t& rotate, float scale ) const;
+		aabb_t Transformed( const Vec3& translate, const Mat3& rotate, float scale ) const;
 		void Render();
 		float PlaneTest( const plane_t& plane ) const;
 		bool Intersects( const ray_t& ray ) const;
@@ -260,9 +260,9 @@ class aabb_t: public bvolume_t
 		bool Intersects( const bsphere_t& sphere ) const;
 		bool Intersects( const aabb_t& aabb ) const;
 		bool Intersects( const obb_t& obb ) const;
-		bool SeperationTest( const bsphere_t& sphere, vec3_t& normal, vec3_t& impact_point, float& depth ) const;
-		bool SeperationTest( const aabb_t& aabb, vec3_t& normal, vec3_t& impact_point, float& depth ) const;
-		bool SeperationTest( const obb_t& oob, vec3_t& normal, vec3_t& impact_point, float& depth ) const;
+		bool SeperationTest( const bsphere_t& sphere, Vec3& normal, Vec3& impact_point, float& depth ) const;
+		bool SeperationTest( const aabb_t& aabb, Vec3& normal, Vec3& impact_point, float& depth ) const;
+		bool SeperationTest( const obb_t& oob, Vec3& normal, Vec3& impact_point, float& depth ) const;
 
 		// other funcs
 		void Set( const void* pointer, uint stride, int count ); ///< Set from vec3 array
@@ -278,20 +278,20 @@ class obb_t: public bvolume_t
 {
 	public:
 		// data members
-		vec3_t center;
-		mat3_t rotation;
-		vec3_t extends;
+		Vec3 center;
+		Mat3 rotation;
+		Vec3 extends;
 
 		// constructors & destractor
 		obb_t(): bvolume_t(OBB) {}
 		obb_t( const obb_t& other ): bvolume_t(OBB) { (*this)=other; }
-		obb_t( const vec3_t& c_, const mat3_t& r_, const vec3_t& e_ ): bvolume_t(OBB) { center=c_; rotation=r_; extends=e_; }
+		obb_t( const Vec3& c_, const Mat3& r_, const Vec3& e_ ): bvolume_t(OBB) { center=c_; rotation=r_; extends=e_; }
 
 		// operators
 		obb_t& operator =( const obb_t& other ) { center=other.center; rotation=other.rotation; extends=other.extends; return (*this); }
 
 		// std funcs
-		obb_t Transformed( const vec3_t& translate, const mat3_t& rotate, float scale ) const;
+		obb_t Transformed( const Vec3& translate, const Mat3& rotate, float scale ) const;
 		void  Render();
 		float PlaneTest( const plane_t& plane ) const;
 		bool Intersects( const ray_t& ray ) const;
@@ -299,10 +299,10 @@ class obb_t: public bvolume_t
 		bool Intersects( const bsphere_t& sphere ) const;
 		bool Intersects( const aabb_t& aabb ) const;
 		bool Intersects( const obb_t& obb ) const;
-		bool SeperationTest( const bvolume_t& bv, vec3_t& normal, vec3_t& impact_point, float& depth ) const;
-		bool SeperationTest( const bsphere_t& sphere, vec3_t& normal, vec3_t& impact_point, float& depth ) const;
-		bool SeperationTest( const aabb_t& /*aabb*/, vec3_t& /*normal*/, vec3_t& /*impact_point*/, float& /*depth*/ ) const { ERROR("ToDo") return false; }
-		bool SeperationTest( const obb_t& /*obb*/, vec3_t& /*normal*/, vec3_t& /*impact_point*/, float& /*depth*/ ) const { ERROR("ToDo") return false; }
+		bool SeperationTest( const bvolume_t& bv, Vec3& normal, Vec3& impact_point, float& depth ) const;
+		bool SeperationTest( const bsphere_t& sphere, Vec3& normal, Vec3& impact_point, float& depth ) const;
+		bool SeperationTest( const aabb_t& /*aabb*/, Vec3& /*normal*/, Vec3& /*impact_point*/, float& /*depth*/ ) const { ERROR("ToDo") return false; }
+		bool SeperationTest( const obb_t& /*obb*/, Vec3& /*normal*/, Vec3& /*impact_point*/, float& /*depth*/ ) const { ERROR("ToDo") return false; }
 
 		// other funcs
 		void Set( const void* pointer, uint stride, int count ); ///< Set from vec3 array
@@ -318,11 +318,11 @@ collision triangle
 {
 	public:
 		// data members
-		vec3_t a, b, c;
+		Vec3 a, b, c;
 
 		// constructors & destractor
 		cTriangle() {}
-		cTriangle( const vec3_t& a_, const vec3_t& b_, const vec3_t& c_ ): a(a_), b(b_), c(c_) {}
+		cTriangle( const Vec3& a_, const Vec3& b_, const Vec3& c_ ): a(a_), b(b_), c(c_) {}
 		cTriangle( const  )
 
 		// operators

+ 12 - 12
src/uncategorized/input.cpp

@@ -13,9 +13,9 @@ data vars
 */
 short keys [SDLK_LAST];  // shows the current key state. 0: unpressed, 1: pressed once, n is >1: kept pressed 'n' times continucely
 short mouse_btns [8];    // mouse btns. Supporting 3 btns & wheel. Works the same as above
-vec2_t mouse_pos_ndc;    // the coords are in the ndc space
-vec2_t mouse_pos;        // the coords are in the window space
-vec2_t mouse_velocity;
+Vec2 mouse_pos_ndc;    // the coords are in the ndc space
+Vec2 mouse_pos;        // the coords are in the window space
+Vec2 mouse_velocity;
 
 bool warp_mouse = false;
 bool hide_cursor = true;
@@ -30,8 +30,8 @@ void Reset( void )
 {
 	memset( keys, 0, sizeof(keys) );
 	memset(mouse_btns, 0, sizeof(mouse_btns) );
-	mouse_pos_ndc.SetZero();
-	mouse_velocity.SetZero();
+	mouse_pos_ndc.setZero();
+	mouse_velocity.setZero();
 }
 
 
@@ -56,7 +56,7 @@ void HandleEvents()
 	}
 
 
-	mouse_velocity.SetZero();
+	mouse_velocity.setZero();
 
 	SDL_Event event_;
 	while( SDL_PollEvent(&event_) )
@@ -81,21 +81,21 @@ void HandleEvents()
 
 			case SDL_MOUSEMOTION:
 			{
-				vec2_t prev_mouse_pos_ndc( mouse_pos_ndc );
+				Vec2 prev_mouse_pos_ndc( mouse_pos_ndc );
 
 				mouse_pos.x = event_.button.x;
 				mouse_pos.y = event_.button.y;
 
-				mouse_pos_ndc.x = (2.0f * mouse_pos.x) / (float)app::window_w - 1.0f;
-				mouse_pos_ndc.y = 1.0f - (2.0f * mouse_pos.y) / (float)app::window_h;
+				mouse_pos_ndc.x = (2.0f * mouse_pos.x) / (float)app::windowW - 1.0f;
+				mouse_pos_ndc.y = 1.0f - (2.0f * mouse_pos.y) / (float)app::windowH;
 
 				if( warp_mouse )
 				{
 					// the SDL_WarpMouse pushes an event in the event queue. This check is so we wont process the event of the...
 					// ...SDL_WarpMouse function
-					if( mouse_pos_ndc == vec2_t::GetZero() ) break;
+					if( mouse_pos_ndc == Vec2::getZero() ) break;
 
-					SDL_WarpMouse( app::window_w/2, app::window_h/2);
+					SDL_WarpMouse( app::windowW/2, app::windowH/2);
 				}
 
 				mouse_velocity = mouse_pos_ndc - prev_mouse_pos_ndc;
@@ -103,7 +103,7 @@ void HandleEvents()
 			}
 
 			case SDL_QUIT:
-				app::QuitApp(1);
+				app::quitApp(1);
 				break;
 		}
 	}

+ 4 - 4
src/uncategorized/input.h

@@ -4,7 +4,7 @@
 #include <SDL/SDL.h>
 #include "common.h"
 #include "app.h"
-#include "gmath.h"
+#include "Math.h"
 
 /// input namespace
 namespace i {
@@ -18,9 +18,9 @@ extern short keys [];  ///< Shows the current key state. 0: unpressed, 1: presse
 extern short mouse_btns [];    ///< Mouse btns. Supporting 3 btns & wheel. Works the same as above
 
 // mouse stuff
-extern vec2_t mouse_pos_ndc; ///< The coords are in the NDC space
-extern vec2_t mouse_pos;     ///< The coords are in the window space. (0,0) is in the uper left corner
-extern vec2_t mouse_velocity;
+extern Vec2 mouse_pos_ndc; ///< The coords are in the NDC space
+extern Vec2 mouse_pos;     ///< The coords are in the window space. (0,0) is in the uper left corner
+extern Vec2 mouse_velocity;
 extern bool warp_mouse;
 extern bool hide_cursor;
 

+ 4 - 4
src/uncategorized/map.cpp

@@ -17,14 +17,14 @@ void octree_t::CreateRoot( const Vec<Mesh*>& meshes )
 	DEBUG_ERR( root ); // root should be NULL
 
 	/// get the root's aabb size
-	vec3_t min( numeric_limits<float>::max() ), max( numeric_limits<float>::min() );
+	Vec3 min( numeric_limits<float>::max() ), max( numeric_limits<float>::min() );
 
 	for( uint m=0; m<meshes.size(); m++ )
 	{
 		Mesh* cmesh = meshes[m];
 		for( uint v=0; v<cmesh->vertCoords.size(); v++ )
 		{
-			const vec3_t& vertCoords = cmesh->vertCoords[v];
+			const Vec3& vertCoords = cmesh->vertCoords[v];
 			for( int i=0; i<3; i++ )
 			{
 				if( vertCoords[i] > max[i] )
@@ -145,8 +145,8 @@ uint octree_t::CheckNodeAgainstFrustum( node_t* node, const Camera& cam ) const
 {
 	int points_outside_frustum_num = 0;
 	const aabb_t& box = node->bounding_box;
-	vec3_t box_points[] = { box.max, vec3_t(box.min.x, box.max.y, box.max.z), vec3_t(box.min.x, box.min.y, box.max.z), vec3_t(box.max.x, box.min.y, box.max.z),
-	                        box.min, vec3_t(box.min.x, box.max.y, box.min.z), vec3_t(box.min.x, box.min.y, box.min.z), vec3_t(box.max.x, box.min.y, box.min.z), };
+	Vec3 box_points[] = { box.max, Vec3(box.min.x, box.max.y, box.max.z), Vec3(box.min.x, box.min.y, box.max.z), Vec3(box.max.x, box.min.y, box.max.z),
+	                        box.min, Vec3(box.min.x, box.max.y, box.min.z), Vec3(box.min.x, box.min.y, box.min.z), Vec3(box.max.x, box.min.y, box.min.z), };
 
 	for( int i=0; i<8; i++ )
 	{

+ 24 - 24
src/uncategorized/particles.cpp

@@ -1,7 +1,7 @@
 /*
 #include "particles.h"
 #include "renderer.h"
-#include "util.h"
+#include "Util.h"
 
 using namespace std;
 
@@ -23,8 +23,8 @@ void particle_t::render()
 
 	// calc new pos
 	float dt = ( float(app::timer_tick)/1000 );
-	vec3_t s_vel; // sigma velocity
-	s_vel = vec3_t( 0.0, 0.0, 0.0 );
+	Vec3 s_vel; // sigma velocity
+	s_vel = Vec3( 0.0, 0.0, 0.0 );
 	for( int i=0; i<PARTICLE_VELS_NUM; i++ )
 	{
 		velocity[i] = (acceleration[i] * dt) + velocity[i];
@@ -33,9 +33,9 @@ void particle_t::render()
 
 	translationLspace = s_vel * dt + translationLspace;
 
-	quat_t q;
-	q.CalcFrom2Vec3( vec3_t(1.0, 0.0, 0.0), s_vel );
-	rotationLspace = mat3_t( q );
+	Quat q;
+	q.setFrom2Vec3( Vec3(1.0, 0.0, 0.0), s_vel );
+	rotationLspace = Mat3( q );
 
 	updateWorldTransform();
 
@@ -106,20 +106,20 @@ void particle_emitter_t::init()
 	particle_life[1] = 400;
 	particles_per_frame = 1;
 
-	velocities[VEL0].angs[MIN] = Euler( 0.0, ToRad(-30.0), ToRad(10.0) );
-	velocities[VEL0].angs[MAX] = Euler( 0.0, ToRad(30.0), ToRad(45.0) );
+	velocities[VEL0].angs[MIN] = Euler( 0.0, toRad(-30.0), toRad(10.0) );
+	velocities[VEL0].angs[MAX] = Euler( 0.0, toRad(30.0), toRad(45.0) );
 	velocities[VEL0].magnitude = 5.0f;
 	velocities[VEL0].acceleration_magnitude = -0.1f;
 	velocities[VEL0].rotatable = true;
 
-	velocities[VEL1].angs[MIN] = Euler( 0.0, 0.0, ToRad(270.0) );
-	velocities[VEL1].angs[MAX] = Euler( 0.0, 0.0, ToRad(270.0) );
+	velocities[VEL1].angs[MIN] = Euler( 0.0, 0.0, toRad(270.0) );
+	velocities[VEL1].angs[MAX] = Euler( 0.0, 0.0, toRad(270.0) );
 	velocities[VEL1].magnitude = 0.0f;
 	velocities[VEL1].acceleration_magnitude = 1.0f;
 	velocities[VEL1].rotatable = false;
 
-	particles_translation_lspace[0] = vec3_t( 0.0, 0.0, 0.0 );
-	particles_translation_lspace[1] = vec3_t( 0.0, 0.0, 0.0 );
+	particles_translation_lspace[0] = Vec3( 0.0, 0.0, 0.0 );
+	particles_translation_lspace[1] = Vec3( 0.0, 0.0, 0.0 );
 }
 
 
@@ -131,15 +131,15 @@ ReInitParticle @ particle_emitter_t
 void particle_emitter_t::ReInitParticle( particle_t& particle )
 {
 	// life
-	particle.life = util::RandRange( particle_life[MIN], particle_life[MAX] );
+	particle.life = Util::randRange( particle_life[MIN], particle_life[MAX] );
 
 	// pos
-	particle.translationLspace = vec3_t(
-		util::RandRange( particles_translation_lspace[MIN].x, particles_translation_lspace[MAX].x ),
-		util::RandRange( particles_translation_lspace[MIN].y, particles_translation_lspace[MAX].y ),
-		util::RandRange( particles_translation_lspace[MIN].z, particles_translation_lspace[MAX].z )
+	particle.translationLspace = Vec3(
+		Util::randRange( particles_translation_lspace[MIN].x, particles_translation_lspace[MAX].x ),
+		Util::randRange( particles_translation_lspace[MIN].y, particles_translation_lspace[MAX].y ),
+		Util::randRange( particles_translation_lspace[MIN].z, particles_translation_lspace[MAX].z )
 	);
-	particle.rotationLspace = mat3_t::GetIdentity();
+	particle.rotationLspace = Mat3::getIdentity();
 	particle.scaleLspace = 1.0;
 
 	particle.parent = this;
@@ -154,14 +154,14 @@ void particle_emitter_t::ReInitParticle( particle_t& particle )
 	for( int i=0; i<PARTICLE_VELS_NUM; i++ )
 	{
 		Euler tmp_angs = Euler(
-			util::RandRange( velocities[i].angs[MIN].x, velocities[i].angs[MAX].x ),
-			util::RandRange( velocities[i].angs[MIN].y, velocities[i].angs[MAX].y ),
-			util::RandRange( velocities[i].angs[MIN].z, velocities[i].angs[MAX].z )
+			Util::randRange( velocities[i].angs[MIN].x, velocities[i].angs[MAX].x ),
+			Util::randRange( velocities[i].angs[MIN].y, velocities[i].angs[MAX].y ),
+			Util::randRange( velocities[i].angs[MIN].z, velocities[i].angs[MAX].z )
 		);
-		mat3_t m3;
-		m3 = mat3_t(tmp_angs);
+		Mat3 m3;
+		m3 = Mat3(tmp_angs);
 		if( velocities[i].rotatable ) m3 = rotationWspace * m3;
-		particle.velocity[i] = particle.acceleration[i] = m3 * vec3_t( 1.0, 0.0, 0.0 );
+		particle.velocity[i] = particle.acceleration[i] = m3 * Vec3( 1.0, 0.0, 0.0 );
 		particle.velocity[i] *= velocities[i].magnitude;
 		particle.acceleration[i] *= velocities[i].acceleration_magnitude;
 

+ 5 - 5
src/uncategorized/particles.h

@@ -3,7 +3,7 @@
 #define _PARTICLES_H_
 
 #include "common.h"
-#include "gmath.h"
+#include "Math.h"
 #include "app.h"
 #include "object.h"
 
@@ -17,8 +17,8 @@ particle_t
 class particle_t: public object_t
 {
 	public:
-		vec3_t velocity[PARTICLE_VELS_NUM];
-		vec3_t acceleration[PARTICLE_VELS_NUM];
+		Vec3 velocity[PARTICLE_VELS_NUM];
+		Vec3 acceleration[PARTICLE_VELS_NUM];
 		int life; // frames to death
 
 		particle_t(): object_t(LIGHT) {life = 0;}
@@ -42,7 +42,7 @@ class particle_emitter_t: public object_t
 			float   magnitude;
 			float   acceleration_magnitude;
 			bool    rotatable;
-			vec3_t  vel[2];
+			Vec3  vel[2];
 		};
 
 	public:
@@ -55,7 +55,7 @@ class particle_emitter_t: public object_t
 		int particle_life[2];  // []
 		int particles_per_frame;
 
-		vec3_t particles_translation_lspace[2]; // []
+		Vec3 particles_translation_lspace[2]; // []
 
 		// velocities
 		velocity_t velocities[PARTICLE_VELS_NUM];

+ 6 - 6
src/uncategorized/skybox.cpp

@@ -1,7 +1,7 @@
 #include "skybox.h"
 #include "Resource.h"
 #include "renderer.h"
-#include "gmath.h"
+#include "Math.h"
 #include "Camera.h"
 #include "Scene.h"
 
@@ -51,7 +51,7 @@ bool skybox_t::load( const char* filenames[6] )
 render                                                                                                                                =
 =======================================================================================================================================
 */
-void skybox_t::Render( const mat3_t& rotation )
+void skybox_t::Render( const Mat3& rotation )
 {
 	//glDisable( GL_DEPTH_TEST );
 	glDisable( GL_BLEND );
@@ -62,12 +62,12 @@ void skybox_t::Render( const mat3_t& rotation )
 	glUniform1i( shader->getUniLoc("colormap"), 0 );
 	shader->locTexUnit( shader->getUniLoc("noisemap"), *noise, 1 );
 	glUniform1f( shader->getUniLoc("timer"), (rotation_ang/(2*PI))*100 );
-	glUniform3fv( shader->getUniLoc("scene_ambient_color"), 1, &(vec3_t( 1.0, 1.0, 1.0 ) / scene::GetAmbientColor())[0] );
+	glUniform3fv( shader->getUniLoc("scene_ambient_color"), 1, &(Vec3( 1.0, 1.0, 1.0 ) / scene::GetAmbientColor())[0] );
 
 	// set the rotation matrix
-	mat3_t tmp( rotation );
-	tmp.RotateYAxis(rotation_ang);
-	r::loadMatrix( mat4_t( tmp ) );
+	Mat3 tmp( rotation );
+	tmp.rotateYAxis(rotation_ang);
+	r::loadMatrix( Mat4( tmp ) );
 	rotation_ang += 0.0001;
 	if( rotation_ang >= 2*PI ) rotation_ang = 0.0;
 

+ 2 - 2
src/uncategorized/skybox.h

@@ -3,7 +3,7 @@
 
 #include "common.h"
 #include "Texture.h"
-#include "gmath.h"
+#include "Math.h"
 
 class ShaderProg;
 
@@ -30,7 +30,7 @@ class skybox_t
 		skybox_t() { rotation_ang=0.0; }
 
 		bool load( const char* filenames[6] );
-		void Render( const mat3_t& rotation );
+		void Render( const Mat3& rotation );
 };
 
 

+ 66 - 17
src/utility/util.cpp → src/utility/Util.cpp

@@ -1,19 +1,19 @@
-#include "util.h"
+#include "Util.h"
 #include <math.h>
 
 
-namespace util {
+namespace Util {
 
 //=====================================================================================================================================
-// RandRange                                                                                                                          =
+// randRange                                                                                                                          =
 //=====================================================================================================================================
-int RandRange( int min, int max )
+int randRange( int min, int max )
 {
 	return (rand() % (max-min+1)) + min ;
 }
 
 
-float RandRange( float min, float max )
+float randRange( float min, float max )
 {
 	double d = max - min; // difference
 	if( d==0.0 ) return min;
@@ -32,9 +32,9 @@ float RandRange( float min, float max )
 
 
 //=====================================================================================================================================
-// ReadFile                                                                                                                           =
+// readFile                                                                                                                           =
 //=====================================================================================================================================
-string ReadFile( const char* filename )
+string readFile( const char* filename )
 {
 	ifstream file( filename );
 	if ( !file.is_open() )
@@ -48,9 +48,9 @@ string ReadFile( const char* filename )
 
 
 //=====================================================================================================================================
-// GetFileLines                                                                                                                       =
+// getFileLines                                                                                                                       =
 //=====================================================================================================================================
-Vec<string> GetFileLines( const char* filename )
+Vec<string> getFileLines( const char* filename )
 {
 	Vec<string> lines;
 	ifstream ifs( filename );
@@ -70,10 +70,10 @@ Vec<string> GetFileLines( const char* filename )
 
 
 //=====================================================================================================================================
-// CutPath                                                                                                                            =
+// cutPath                                                                                                                            =
 //=====================================================================================================================================
 /// Used only to cut the path from __FILE__ and return the actual file name and some other cases
-char* CutPath( const char* path )
+char* cutPath( const char* path )
 {
 	char* str = (char*)path + strlen(path) - 1;
 	for(;;)
@@ -86,9 +86,9 @@ char* CutPath( const char* path )
 
 
 //=====================================================================================================================================
-// GetPath                                                                                                                            =
+// getPath                                                                                                                            =
 //=====================================================================================================================================
-string GetPath( const char* path )
+string getPath( const char* path )
 {
 	char* str = (char*)path + strlen(path) - 1;
 	for(;;)
@@ -106,10 +106,10 @@ string GetPath( const char* path )
 
 
 //=====================================================================================================================================
-// GetFunctionFromPrettyFunction                                                                                                      =
+// getFunctionFromPrettyFunction                                                                                                      =
 //=====================================================================================================================================
 /// The function gets __PRETTY_FUNCTION__ and strips it to get only the function name with its namespace
-string GetFunctionFromPrettyFunction( const char* pretty_function )
+string getFunctionFromPrettyFunction( const char* pretty_function )
 {
 	string ret( pretty_function );
 
@@ -127,9 +127,9 @@ string GetFunctionFromPrettyFunction( const char* pretty_function )
 
 
 //=====================================================================================================================================
-// GetFileExtension                                                                                                                   =
+// getFileExtension                                                                                                                   =
 //=====================================================================================================================================
-char* GetFileExtension( const char* path )
+char* getFileExtension( const char* path )
 {
 	char* str = (char*)path + strlen(path) - 1;
 	for(;;)
@@ -145,4 +145,53 @@ char* GetFileExtension( const char* path )
 }
 
 
+//=====================================================================================================================================
+// intToStr                                                                                                                           =
+//=====================================================================================================================================
+string intToStr( int i )
+{
+	char str [256];
+	char* pstr = str + ( (sizeof(str)/sizeof(char)) - 1 );
+	bool negative = false;
+
+	*pstr = '\0';
+
+	if( i < 0 )
+	{
+		i = -i;
+		negative = true;
+	}
+
+	do
+	{
+		--pstr;
+		int remain = i % 10;
+		i = i / 10;
+		*pstr = '0' + remain;
+	} while( i != 0 );
+
+	if( negative )
+	{
+		--pstr;
+		*pstr = '-';
+	}
+
+	return string(pstr);
+}
+
+
+//=====================================================================================================================================
+// floatToStr                                                                                                                         =
+//=====================================================================================================================================
+string floatToStr( float f )
+{
+	char tmp [128];
+
+	sprintf( tmp, "%f", f );
+
+	string s(tmp);
+	return s;
+}
+
+
 }

+ 22 - 0
src/utility/Util.h

@@ -0,0 +1,22 @@
+#ifndef _UTIL_H_
+#define _UTIL_H_
+
+#include "common.h"
+
+namespace Util {
+
+extern int   randRange( int min, int max );
+extern float randRange( float min, float max );
+
+extern string      readFile( const char* filename );
+extern Vec<string> getFileLines( const char* filename );
+extern char*       getFileExtension( const char* path );
+extern char*       cutPath( const char* path );
+extern string      getPath( const char* path );
+extern string      getFunctionFromPrettyFunction( const char* pretty_function );
+extern string      intToStr( int );
+extern string      floatToStr( float );
+
+}
+
+#endif

+ 27 - 15
src/utility/app.cpp

@@ -7,30 +7,42 @@ namespace app { // begin of namespace
 static SDL_Surface* main_surf;
 static SDL_Surface* icon_image;
 
-uint window_w = 1280;
-uint window_h = 800;
+uint windowW = 1280;
+uint windowH = 800;
 
 uint timer_tick = 1000/40; // in ms. 1000/Hz
 static uint time = 0;
 
-uint desktop_w;
-uint desktop_h;
+uint desktopW;
+uint desktopH;
 
 
 /*
 =======================================================================================================================================
-InitWindow                                                                                                                            =
+initWindow                                                                                                                            =
 =======================================================================================================================================
 */
-void InitWindow()
+void initWindow()
 {
 	PRINT( "SDL window initializing..." );
 	SDL_Init( SDL_INIT_VIDEO );
 
+	// print driver name
+	char charBuff [256];
+	if( SDL_VideoDriverName(charBuff, sizeof(charBuff)) != NULL )
+	{
+		PRINT( "The video driver name is " << charBuff );
+	}
+	else
+	{
+		ERROR( "Failed to obtain the video driver name" );
+	}
+
+
 	// get desktop size
 	const SDL_VideoInfo* info = SDL_GetVideoInfo();
-	desktop_w = info->current_w;
-	desktop_h = info->current_h;
+	desktopW = info->current_w;
+	desktopH = info->current_h;
 
 	// the icon
 	icon_image = SDL_LoadBMP("gfx/icon.bmp");
@@ -51,7 +63,7 @@ void InitWindow()
 	SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 );
 
 	// set the surface
-	main_surf = SDL_SetVideoMode( window_w, window_h, 24, SDL_HWSURFACE | SDL_OPENGL );
+	main_surf = SDL_SetVideoMode( windowW, windowH, 24, SDL_HWSURFACE | SDL_OPENGL );
 
 	// move the window
 #ifdef WIN32
@@ -73,10 +85,10 @@ void InitWindow()
 
 /*
 =======================================================================================================================================
-TogleFullScreen                                                                                                                       =
+togleFullScreen                                                                                                                       =
 =======================================================================================================================================
 */
-void TogleFullScreen()
+void togleFullScreen()
 {
 	SDL_WM_ToggleFullScreen( main_surf );
 }
@@ -84,10 +96,10 @@ void TogleFullScreen()
 
 /*
 =======================================================================================================================================
-QuitApp                                                                                                                               =
+quitApp                                                                                                                               =
 =======================================================================================================================================
 */
-void QuitApp( int code )
+void quitApp( int code )
 {
 	SDL_FreeSurface( main_surf );
 	SDL_Quit();
@@ -97,10 +109,10 @@ void QuitApp( int code )
 
 /*
 =======================================================================================================================================
-WaitForNextFrame                                                                                                                      =
+waitForNextFrame                                                                                                                      =
 =======================================================================================================================================
 */
-void WaitForNextFrame()
+void waitForNextFrame()
 {
 	uint now = SDL_GetTicks();
 

+ 9 - 9
src/utility/app.h

@@ -9,19 +9,19 @@ namespace app {
 
 extern uint timer_tick;
 
-extern uint desktop_w;
-extern uint desktop_h;
+extern uint desktopW;
+extern uint desktopH;
 
-extern uint window_w;
-extern uint window_h;
+extern uint windowW;
+extern uint windowH;
 
-extern void InitWindow();
-extern void QuitApp( int code );
-extern void WaitForNextFrame();
-extern void TogleFullScreen();
+extern void initWindow();
+extern void quitApp( int code );
+extern void waitForNextFrame();
+extern void togleFullScreen();
 extern void printAppInfo();
 
-inline uint GetTicks()
+inline uint getTicks()
 {
 	return SDL_GetTicks();
 }

+ 0 - 53
src/utility/common.cpp

@@ -7,59 +7,6 @@
 #include "common.h"
 
 
-/*
-=======================================================================================================================================
-IntToStr                                                                                                                              =
-=======================================================================================================================================
-*/
-string IntToStr( int i )
-{
-	char str [256];
-	char* pstr = str + ( (sizeof(str)/sizeof(char)) - 1 );
-	bool negative = false;
-	
-	*pstr = '\0';
-	
-	if( i < 0 )
-	{
-		i = -i;
-		negative = true;
-	}
-	
-	do
-	{
-		--pstr;
-		int remain = i % 10;
-		i = i / 10;
-		*pstr = '0' + remain;
-	} while( i != 0 );
-	
-	if( negative )
-	{
-		--pstr;
-		*pstr = '-';
-	}
-	
-	return string(pstr);
-}
-
-
-/*
-=======================================================================================================================================
-FloatToStr                                                                                                                            =
-=======================================================================================================================================
-*/
-string FloatToStr( float f )
-{
-	char tmp [128];
-
-	sprintf( tmp, "%f", f );
-
-	string s(tmp);
-	return s;
-}
-
-
 
 /*
 =======================================================================================================================================

+ 6 - 9
src/utility/common.h

@@ -39,23 +39,20 @@ typedef unsigned long int ulong;
 //=====================================================================================================================================
 template<typename Type> class Vec;
 
-extern string        IntToStr( int );
-extern string        FloatToStr( float );
-
 
 //=====================================================================================================================================
 // MACROS                                                                                                                             =
 //=====================================================================================================================================
 
-namespace util {
-extern char*  CutPath( const char* path );
-extern string GetFunctionFromPrettyFunction( const char* pretty_function );
+namespace Util {
+extern char*  cutPath( const char* path );
+extern string getFunctionFromPrettyFunction( const char* pretty_function );
 }
 
-#define __FILENAME__ util::CutPath( __FILE__ )
+#define __FILENAME__ Util::cutPath( __FILE__ )
 
 #ifdef __GNUG__
-	#define __G_FUNCTION__ util::GetFunctionFromPrettyFunction( __PRETTY_FUNCTION__ )
+	#define __G_FUNCTION__ Util::getFunctionFromPrettyFunction( __PRETTY_FUNCTION__ )
 #else
 	#define __G_FUNCTION__ __func__
 #endif
@@ -173,7 +170,7 @@ template<typename Type> class Vec: public vector<Type>
 			return vector<Type>::operator []( n );
 		}
 
-		size_t GetSizeInBytes() const
+		size_t getSizeInBytes() const
 		{
 			return vector<Type>::size() * sizeof(Type);
 		}

+ 1 - 1
src/utility/u_string.h

@@ -269,7 +269,7 @@ class string_t
 			return data;
 		}
 		
-		// Length
+		// getLength
 		uint Length() const
 		{
 			DEBUG_ERR( data!=NULL && length!=strlen(data) );

+ 0 - 20
src/utility/util.h

@@ -1,20 +0,0 @@
-#ifndef _UTIL_H_
-#define _UTIL_H_
-
-#include "common.h"
-
-namespace util {
-
-extern int   RandRange( int min, int max );
-extern float RandRange( float min, float max );
-
-extern string        ReadFile( const char* filename );
-extern Vec<string> GetFileLines( const char* filename );
-extern char*         GetFileExtension( const char* path );
-extern char*         CutPath( const char* path );
-extern string        GetPath( const char* path );
-extern string        GetFunctionFromPrettyFunction( const char* pretty_function );
-
-}
-
-#endif

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini