diff --git a/DanBias.sln b/DanBias.sln
index af80c6a1..f22bf384 100644
--- a/DanBias.sln
+++ b/DanBias.sln
@@ -25,7 +25,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetworkDependencies", "Netw
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameLogic", "GameLogic\GameLogic.vcxproj", "{B1195BB9-B3A5-47F0-906C-8DEA384D1520}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tester", "Tester\Tester.vcxproj", "{9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GamePhysics", "GamePhysics\GamePhysics.vcxproj", "{104FA3E9-94D9-4E1D-A941-28A03BC8A095}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -163,22 +163,21 @@ Global
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Win32.Build.0 = Debug|Win32
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|x64.ActiveCfg = Debug|x64
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|x64.Build.0 = Debug|x64
- {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|x64.Deploy.0 = Debug|x64
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+ {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Mixed Platforms.Build.0 = Release|Win32
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Win32.ActiveCfg = Release|Win32
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Win32.Build.0 = Release|Win32
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|x64.ActiveCfg = Release|Win32
- {9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
- {9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Debug|Mixed Platforms.Build.0 = Debug|Win32
- {9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Debug|Win32.ActiveCfg = Debug|Win32
- {9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Debug|Win32.Build.0 = Debug|Win32
- {9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Debug|x64.ActiveCfg = Debug|x64
- {9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Debug|x64.Build.0 = Debug|x64
- {9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Release|Mixed Platforms.ActiveCfg = Release|Win32
- {9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Release|Mixed Platforms.Build.0 = Release|Win32
- {9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Release|Win32.ActiveCfg = Release|Win32
- {9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Release|Win32.Build.0 = Release|Win32
- {9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Release|x64.ActiveCfg = Release|Win32
+ {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
+ {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Mixed Platforms.Build.0 = Debug|Win32
+ {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Win32.ActiveCfg = Debug|Win32
+ {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Win32.Build.0 = Debug|Win32
+ {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|x64.ActiveCfg = Debug|x64
+ {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+ {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Mixed Platforms.Build.0 = Release|Win32
+ {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Win32.ActiveCfg = Release|Win32
+ {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Win32.Build.0 = Release|Win32
+ {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/GameLogic/GameLogic.vcxproj b/GameLogic/GameLogic.vcxproj
index beb08cbb..d65db31d 100644
--- a/GameLogic/GameLogic.vcxproj
+++ b/GameLogic/GameLogic.vcxproj
@@ -138,6 +138,9 @@
+
+ {104fa3e9-94d9-4e1d-a941-28a03bc8a095}
+
diff --git a/GamePhysics/GamePhysics.vcxproj b/GamePhysics/GamePhysics.vcxproj
index 78b667ef..e5df8043 100644
--- a/GamePhysics/GamePhysics.vcxproj
+++ b/GamePhysics/GamePhysics.vcxproj
@@ -144,6 +144,9 @@
{4285bd3f-3c6c-4670-b7af-a29afef5f6a8}
+
+
+
diff --git a/GamePhysics/GamePhysics.vcxproj.filters b/GamePhysics/GamePhysics.vcxproj.filters
index 435a7286..b8f7f1a0 100644
--- a/GamePhysics/GamePhysics.vcxproj.filters
+++ b/GamePhysics/GamePhysics.vcxproj.filters
@@ -19,5 +19,13 @@
{cac9a78f-f09b-4850-b1aa-ea87e8368678}
+
+ {792daa4b-b2f7-4664-9529-71a929365274}
+
+
+
+
+ Header Files\Include
+
\ No newline at end of file
diff --git a/GamePhysics/Include/GamePhysics.h b/GamePhysics/Include/GamePhysics.h
new file mode 100644
index 00000000..e69de29b
diff --git a/OysterMath/LinearMath.h b/OysterMath/LinearMath.h
index 8ee69154..a0dba20e 100644
--- a/OysterMath/LinearMath.h
+++ b/OysterMath/LinearMath.h
@@ -298,7 +298,7 @@ namespace LinearAlgebra3D
if( radian > 0 )
{
radian = ::std::sqrt( radian );
- return OrientationMatrix( sumDeltaAngularAxis / radian, radian, targetMem );
+ return OrientationMatrix( sumDeltaAngularAxis / radian, radian, sumTranslation, targetMem );
}
else
{
@@ -353,13 +353,16 @@ namespace LinearAlgebra3D
0, nearClip*c, 1 );
}
- /* Creates a perspective projection matrix designed for DirectX enviroment.
- vertFoV; is the vertical field of vision in radians. (lookup FoV Hor+ )
- aspect; is the screenratio width/height (example 16/9 or 16/10 )
- nearClip: Distance to the nearClippingPlane
- farClip: Distance to the farClippingPlane
- targetMem; is set to a perspective transform matrix and then returned.
- */
+ /*******************************************************************
+ * Creates a perspective projection matrix designed for DirectX enviroment.
+ * @param vertFoV; is the vertical field of vision in radians. (lookup FoV Hor+ )
+ * @param aspect; is the screenratio width/height (example 16/9 or 16/10 )
+ * @param nearClip: Distance to the nearClippingPlane
+ * @param farClip: Distance to the farClippingPlane
+ * @param targetMem; is set to a perspective transform matrix and then returned.
+ * @return targetMem
+ * @test Compare with transposed D3D counterpart
+ *******************************************************************/
template
::LinearAlgebra::Matrix4x4 & ProjectionMatrix_Perspective( const ScalarType &vertFoV, const ScalarType &aspect, const ScalarType &nearClip, const ScalarType &farClip, ::LinearAlgebra::Matrix4x4 &targetMem = ::LinearAlgebra::Matrix4x4() )
{ /** @todo TODO: not tested */
diff --git a/OysterMath/OysterMath.cpp b/OysterMath/OysterMath.cpp
index 4ec6da58..24266a37 100644
--- a/OysterMath/OysterMath.cpp
+++ b/OysterMath/OysterMath.cpp
@@ -82,5 +82,7 @@ namespace Oyster { namespace Math3D
{ return ::LinearAlgebra3D::ProjectionMatrix_Perspective( verticalFoV, aspectRatio, nearClip, farClip, targetMem ); }
Float3 VectorProjection( const Float3 &vector, const Float3 &axis )
- { return ::LinearAlgebra3D::VectorProjection( vector, axis ); }
+ {
+ return ::LinearAlgebra3D::VectorProjection( vector, axis );
+ }
} }
\ No newline at end of file
diff --git a/OysterMath/Vector.h b/OysterMath/Vector.h
index 256effe9..901ea5e4 100644
--- a/OysterMath/Vector.h
+++ b/OysterMath/Vector.h
@@ -179,7 +179,7 @@ namespace LinearAlgebra
// Vector2 ///////////////////////////////////////
- template const Vector2 Vector2::null = Vector2( );
+ template const Vector2 Vector2::null = Vector2( 0, 0 );
template const Vector2 Vector2::standard_unit_x = Vector2( 1, 0 );
template const Vector2 Vector2::standard_unit_y = Vector2( 0, 1 );
@@ -337,7 +337,7 @@ namespace LinearAlgebra
// Vector3 ///////////////////////////////////////
- template const Vector3 Vector3::null = Vector3( );
+ template const Vector3 Vector3::null = Vector3( 0, 0, 0 );
template const Vector3 Vector3::standard_unit_x = Vector3( 1, 0, 0 );
template const Vector3 Vector3::standard_unit_y = Vector3( 0, 1, 0 );
template const Vector3 Vector3::standard_unit_z = Vector3( 0, 0, 1 );
@@ -509,7 +509,7 @@ namespace LinearAlgebra
// Vector4 ///////////////////////////////////////
- template const Vector4 Vector4::null = Vector4( );
+ template const Vector4 Vector4::null = Vector4( 0, 0, 0, 0 );
template const Vector4 Vector4::standard_unit_x = Vector4( 1, 0, 0, 0 );
template const Vector4 Vector4::standard_unit_y = Vector4( 0, 1, 0, 0 );
template const Vector4 Vector4::standard_unit_z = Vector4( 0, 0, 1, 0 );
diff --git a/OysterPhysics3D/Collision/Box.cpp b/OysterPhysics3D/Box.cpp
similarity index 98%
rename from OysterPhysics3D/Collision/Box.cpp
rename to OysterPhysics3D/Box.cpp
index 9c27ed63..9ba1bb28 100644
--- a/OysterPhysics3D/Collision/Box.cpp
+++ b/OysterPhysics3D/Box.cpp
@@ -3,7 +3,7 @@
/////////////////////////////////////////////////////////////////////
#include "Box.h"
-#include "..\OysterCollision3D.h"
+#include "OysterCollision3D.h"
using namespace ::Oyster::Collision3D;
using namespace ::Oyster::Math3D;
diff --git a/OysterPhysics3D/Collision/Box.h b/OysterPhysics3D/Box.h
similarity index 100%
rename from OysterPhysics3D/Collision/Box.h
rename to OysterPhysics3D/Box.h
diff --git a/OysterPhysics3D/Collision/BoxAxisAligned.cpp b/OysterPhysics3D/BoxAxisAligned.cpp
similarity index 98%
rename from OysterPhysics3D/Collision/BoxAxisAligned.cpp
rename to OysterPhysics3D/BoxAxisAligned.cpp
index ae5ebafe..b745646f 100644
--- a/OysterPhysics3D/Collision/BoxAxisAligned.cpp
+++ b/OysterPhysics3D/BoxAxisAligned.cpp
@@ -3,7 +3,7 @@
/////////////////////////////////////////////////////////////////////
#include "BoxAxisAligned.h"
-#include "..\OysterCollision3D.h"
+#include "OysterCollision3D.h"
using namespace ::Oyster::Collision3D;
using namespace ::Oyster::Math3D;
diff --git a/OysterPhysics3D/Collision/BoxAxisAligned.h b/OysterPhysics3D/BoxAxisAligned.h
similarity index 100%
rename from OysterPhysics3D/Collision/BoxAxisAligned.h
rename to OysterPhysics3D/BoxAxisAligned.h
diff --git a/OysterPhysics3D/Physics/FluidDrag.cpp b/OysterPhysics3D/FluidDrag.cpp
similarity index 100%
rename from OysterPhysics3D/Physics/FluidDrag.cpp
rename to OysterPhysics3D/FluidDrag.cpp
diff --git a/OysterPhysics3D/Physics/FluidDrag.h b/OysterPhysics3D/FluidDrag.h
similarity index 97%
rename from OysterPhysics3D/Physics/FluidDrag.h
rename to OysterPhysics3D/FluidDrag.h
index 70cfdf66..64522c25 100644
--- a/OysterPhysics3D/Physics/FluidDrag.h
+++ b/OysterPhysics3D/FluidDrag.h
@@ -6,7 +6,7 @@
#define OYSTER_PHYSICS_3D_FLUID_DRAG_H
#include "OysterMath.h"
-#include "..\OysterPhysics3D.h"
+#include "OysterPhysics3D.h"
namespace Oyster { namespace Physics3D
{
diff --git a/OysterPhysics3D/Collision/Frustrum.cpp b/OysterPhysics3D/Frustrum.cpp
similarity index 99%
rename from OysterPhysics3D/Collision/Frustrum.cpp
rename to OysterPhysics3D/Frustrum.cpp
index b13c257a..837ba579 100644
--- a/OysterPhysics3D/Collision/Frustrum.cpp
+++ b/OysterPhysics3D/Frustrum.cpp
@@ -3,7 +3,7 @@
/////////////////////////////////////////////////////////////////////
#include "Frustrum.h"
-#include "..\OysterCollision3D.h"
+#include "OysterCollision3D.h"
using namespace Oyster::Math;
using namespace Oyster::Collision3D;
diff --git a/OysterPhysics3D/Collision/Frustrum.h b/OysterPhysics3D/Frustrum.h
similarity index 100%
rename from OysterPhysics3D/Collision/Frustrum.h
rename to OysterPhysics3D/Frustrum.h
diff --git a/OysterPhysics3D/Collision/ICollideable.cpp b/OysterPhysics3D/ICollideable.cpp
similarity index 100%
rename from OysterPhysics3D/Collision/ICollideable.cpp
rename to OysterPhysics3D/ICollideable.cpp
diff --git a/OysterPhysics3D/Collision/ICollideable.h b/OysterPhysics3D/ICollideable.h
similarity index 100%
rename from OysterPhysics3D/Collision/ICollideable.h
rename to OysterPhysics3D/ICollideable.h
diff --git a/OysterPhysics3D/Collision/Line.cpp b/OysterPhysics3D/Line.cpp
similarity index 97%
rename from OysterPhysics3D/Collision/Line.cpp
rename to OysterPhysics3D/Line.cpp
index 989fb55b..2afa69d8 100644
--- a/OysterPhysics3D/Collision/Line.cpp
+++ b/OysterPhysics3D/Line.cpp
@@ -3,7 +3,7 @@
/////////////////////////////////////////////////////////////////////
#include "Line.h"
-#include "..\OysterCollision3D.h"
+#include "OysterCollision3D.h"
using namespace ::Oyster::Collision3D;
using namespace ::Oyster::Math3D;
diff --git a/OysterPhysics3D/Collision/Line.h b/OysterPhysics3D/Line.h
similarity index 100%
rename from OysterPhysics3D/Collision/Line.h
rename to OysterPhysics3D/Line.h
diff --git a/OysterPhysics3D/Collision/OysterCollision3D.cpp b/OysterPhysics3D/OysterCollision3D.cpp
similarity index 99%
rename from OysterPhysics3D/Collision/OysterCollision3D.cpp
rename to OysterPhysics3D/OysterCollision3D.cpp
index d5295e33..5cb5a1bc 100644
--- a/OysterPhysics3D/Collision/OysterCollision3D.cpp
+++ b/OysterPhysics3D/OysterCollision3D.cpp
@@ -2,7 +2,7 @@
// Created by Dan Andersson 2013
/////////////////////////////////////////////////////////////////////
-#include "..\OysterCollision3D.h"
+#include "OysterCollision3D.h"
#include "Utilities.h"
#include
diff --git a/OysterPhysics3D/OysterCollision3D.h b/OysterPhysics3D/OysterCollision3D.h
index 405d3013..24d6a568 100644
--- a/OysterPhysics3D/OysterCollision3D.h
+++ b/OysterPhysics3D/OysterCollision3D.h
@@ -6,17 +6,17 @@
#ifndef OYSTER_COLLISION_3D_UTILITY_H
#define OYSTER_COLLISION_3D_UTILITY_H
-#include "Collision\ICollideable.h"
-#include "Collision\Universe.h"
-#include "Collision\Point.h"
-#include "Collision\Ray.h"
-#include "Collision\Sphere.h"
-#include "Collision\Plane.h"
-//#include "Collision\Triangle.h"
-#include "Collision\BoxAxisAligned.h"
-#include "Collision\Box.h"
-#include "Collision\Frustrum.h"
-#include "Collision\Line.h"
+#include "ICollideable.h"
+#include "Universe.h"
+#include "Point.h"
+#include "Ray.h"
+#include "Sphere.h"
+#include "Plane.h"
+//#include "Triangle.h"
+#include "BoxAxisAligned.h"
+#include "Box.h"
+#include "Frustrum.h"
+#include "Line.h"
namespace Oyster { namespace Collision3D { namespace Utility
{
diff --git a/OysterPhysics3D/OysterPhysics3D.h b/OysterPhysics3D/OysterPhysics3D.h
index 6b7ec136..e31aa17b 100644
--- a/OysterPhysics3D/OysterPhysics3D.h
+++ b/OysterPhysics3D/OysterPhysics3D.h
@@ -17,81 +17,166 @@ namespace Oyster { namespace Physics3D
* @todo TODO: improve doc
******************************************************************/
inline ::Oyster::Math::Float LinearKineticEnergy( const ::Oyster::Math::Float &mass, const ::Oyster::Math::Float3 &linearVelocity )
- { return (0.5f * mass) * linearVelocity.Dot( linearVelocity ); }
+ {
+ return (0.5f * mass) * linearVelocity.Dot( linearVelocity );
+ }
/******************************************************************
* Returns the angular kinetic energy of a mass in rotation.
* @todo TODO: improve doc
******************************************************************/
inline ::Oyster::Math::Float AngularKineticEnergy( const ::Oyster::Math::Float &momentOfInertia, const ::Oyster::Math::Float3 &angularVelocity )
- { return (0.5f * momentOfInertia) * angularVelocity.Dot( angularVelocity ); }
+ {
+ return (0.5f * momentOfInertia) * angularVelocity.Dot( angularVelocity );
+ }
/******************************************************************
* Returns the linear momentum of a mass in motion.
* @todo TODO: improve doc
******************************************************************/
inline ::Oyster::Math::Float3 LinearMomentum( const ::Oyster::Math::Float &mass, const ::Oyster::Math::Float3 &linearVelocity )
- { return mass * linearVelocity; }
+ {
+ return mass * linearVelocity;
+ }
/******************************************************************
* Returns the linear velocity of a mass with momentum.
* @todo TODO: improve doc
******************************************************************/
inline ::Oyster::Math::Float3 LinearVelocity( const ::Oyster::Math::Float &mass, const ::Oyster::Math::Float3 &linearMomentum )
- { return linearMomentum / mass; }
+ {
+ return linearMomentum / mass;
+ }
/******************************************************************
* Returns the local angular momentum of a mass in rotation.
* @todo TODO: improve doc
******************************************************************/
- inline ::Oyster::Math::Float3 AngularMomentum( const ::Oyster::Math::Float &momentOfInertia, const ::Oyster::Math::Float3 &angularVelocity )
- { return momentOfInertia * angularVelocity; }
+ inline ::Oyster::Math::Float3 AngularMomentum( const ::Oyster::Math::Float4x4 &momentOfInertia, const ::Oyster::Math::Float3 &angularVelocity )
+ {
+ return ( momentOfInertia * ::Oyster::Math::Float4(angularVelocity, 0.0f) ).xyz;
+ }
/******************************************************************
* Returns the local tangential momentum at localPos, of a mass in rotation.
* @todo TODO: improve doc
******************************************************************/
- inline ::Oyster::Math::Float3 & TangentialLinearMomentum( const ::Oyster::Math::Float &localAngularMomentum, const ::Oyster::Math::Float3 &localPosition, ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() )
- { return targetMem = localAngularMomentum * ::Oyster::Math::Float3( -localPosition.y, localPosition.x ); }
+ inline ::Oyster::Math::Float3 TangentialLinearMomentum( const ::Oyster::Math::Float3 &angularMomentum, const ::Oyster::Math::Float3 &localOffset )
+ {
+ return angularMomentum.Cross( localOffset );
+ }
/******************************************************************
* Returns the local tangential momentum at localPos, of a mass in rotation.
* @todo TODO: improve doc
******************************************************************/
- inline ::Oyster::Math::Float3 & TangentialLinearMomentum( const ::Oyster::Math::Float &momentOfInertia, const ::Oyster::Math::Float3 &angularVelocity, const ::Oyster::Math::Float3 &localPosition, ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() )
- { return targetMem = AngularMomentum( momentOfInertia, angularVelocity ).Cross( localPosition ); }
+ inline ::Oyster::Math::Float3 TangentialLinearMomentum( const ::Oyster::Math::Float4x4 &momentOfInertia, const ::Oyster::Math::Float3 &angularVelocity, const ::Oyster::Math::Float3 &localOffset )
+ {
+ return TangentialLinearMomentum( AngularMomentum(momentOfInertia, angularVelocity), localOffset );
+ }
+
+ /******************************************************************
+ * Returns the local impulse force at localPos, of a mass in angular acceleration.
+ * @todo TODO: improve doc
+ ******************************************************************/
+ inline ::Oyster::Math::Float3 TangentialImpulseForce( const ::Oyster::Math::Float3 &impulseTorque, const ::Oyster::Math::Float3 &localOffset )
+ {
+ return impulseTorque.Cross( localOffset );
+ }
+
+ /******************************************************************
+ *
+ * @todo TODO: improve doc
+ ******************************************************************/
+ inline ::Oyster::Math::Float3 AngularImpulseAcceleration( const ::Oyster::Math::Float4x4 &momentOfInertiaInversed, const ::Oyster::Math::Float3 &impulseTorque )
+ {
+ return ( momentOfInertiaInversed * ::Oyster::Math::Float4( impulseTorque, 0.0f ) ).xyz;
+ }
+
+ /******************************************************************
+ *
+ * @todo TODO: improve doc
+ ******************************************************************/
+ inline ::Oyster::Math::Float3 AngularImpulseAcceleration( const ::Oyster::Math::Float3 &linearImpulseAcceleration, const ::Oyster::Math::Float3 &offset )
+ {
+ return offset.Cross( linearImpulseAcceleration );
+ }
+
+ /******************************************************************
+ * Returns the local impulse acceleration at localPos, of a mass in angular acceleration.
+ * @todo TODO: improve doc
+ ******************************************************************/
+ inline ::Oyster::Math::Float3 TangentialImpulseAcceleration( const ::Oyster::Math::Float4x4 &momentOfInertiaInversed, const ::Oyster::Math::Float3 &impulseTorque, const ::Oyster::Math::Float3 &localOffset )
+ {
+ return AngularImpulseAcceleration( momentOfInertiaInversed, impulseTorque ).Cross( localOffset );
+ }
/******************************************************************
* Returns the local angular velocity of a mass in rotation.
* @todo TODO: improve doc
******************************************************************/
- inline ::Oyster::Math::Float3 AngularVelocity( const ::Oyster::Math::Float &momentOfInertia, const ::Oyster::Math::Float3 &angularMomentum )
- { return angularMomentum / momentOfInertia; }
+ inline ::Oyster::Math::Float3 AngularVelocity( const ::Oyster::Math::Float4x4 &momentOfInertiaInversed, const ::Oyster::Math::Float3 &angularMomentum )
+ {
+ return ( momentOfInertiaInversed * ::Oyster::Math::Float4( angularMomentum, 0.0f ) ).xyz;
+ }
/******************************************************************
* Returns the local tangential velocity at localPos, of a mass in rotation.
* @todo TODO: improve doc
******************************************************************/
- inline ::Oyster::Math::Float3 & TangentialLinearVelocity( const ::Oyster::Math::Float3 &angularVelocity, const ::Oyster::Math::Float3 &localPosition, ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() )
- { return targetMem = angularVelocity.Cross( localPosition ); }
+ inline ::Oyster::Math::Float3 TangentialLinearVelocity( const ::Oyster::Math::Float3 &angularVelocity, const ::Oyster::Math::Float3 &offset )
+ {
+ return angularVelocity.Cross( offset );
+ }
+
+ /******************************************************************
+ * Returns the local tangential velocity at localPos, of a mass in rotation.
+ * @todo TODO: improve doc
+ ******************************************************************/
+ inline ::Oyster::Math::Float3 TangentialLinearVelocity( const ::Oyster::Math::Float4x4 &momentOfInertiaInversed, const ::Oyster::Math::Float3 &angularMomentum, const ::Oyster::Math::Float3 &offset )
+ {
+ return TangentialLinearVelocity( AngularVelocity(momentOfInertiaInversed, angularMomentum), offset );
+ }
/******************************************************************
*
* @todo TODO: improve doc
******************************************************************/
inline ::Oyster::Math::Float3 LinearImpulseAcceleration( ::Oyster::Math::Float mass, const ::Oyster::Math::Float3 &impulseForce )
- { return impulseForce / mass; }
+ {
+ return impulseForce / mass;
+ }
/******************************************************************
*
* @todo TODO: improve doc
******************************************************************/
inline ::Oyster::Math::Float3 ImpulseForce( ::Oyster::Math::Float mass, const ::Oyster::Math::Float3 &linearImpulseAcceleration )
- { return linearImpulseAcceleration * mass; }
+ {
+ return linearImpulseAcceleration * mass;
+ }
+
+ /******************************************************************
+ *
+ * @todo TODO: improve doc
+ ******************************************************************/
+ inline ::Oyster::Math::Float3 ImpulseTorque( const ::Oyster::Math::Float3 & offset, const ::Oyster::Math::Float3 &impulseForce )
+ {
+ return offset.Cross( impulseForce );
+ }
+
+ /******************************************************************
+ * T = I*a
+ * @todo TODO: improve doc
+ ******************************************************************/
+ inline ::Oyster::Math::Float3 ImpulseTorque( const ::Oyster::Math::Float4x4 & momentOfInertia, const ::Oyster::Math::Float3 &angularImpulseAcceleration )
+ {
+ return ( momentOfInertia * ::Oyster::Math::Float4(angularImpulseAcceleration, 0.0f) ).xyz;
+ }
namespace MomentOfInertia
{ /// Library of Formulas to calculate moment of inerta for simple shapes
- /** @todo TODO: add MomentOfInertia formulas */
+ /** @todo TODO: add MomentOfInertia tensor formulas */
}
}
} }
diff --git a/OysterPhysics3D/OysterPhysics3D.vcxproj b/OysterPhysics3D/OysterPhysics3D.vcxproj
index 2cb566d1..c36fded5 100644
--- a/OysterPhysics3D/OysterPhysics3D.vcxproj
+++ b/OysterPhysics3D/OysterPhysics3D.vcxproj
@@ -137,41 +137,6 @@
true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee}
@@ -180,6 +145,41 @@
{f10cbc03-9809-4cba-95d8-327c287b18ee}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/OysterPhysics3D/OysterPhysics3D.vcxproj.filters b/OysterPhysics3D/OysterPhysics3D.vcxproj.filters
index b4f1cf5c..e3a8a70d 100644
--- a/OysterPhysics3D/OysterPhysics3D.vcxproj.filters
+++ b/OysterPhysics3D/OysterPhysics3D.vcxproj.filters
@@ -27,100 +27,100 @@
-
- Source Files\Collision
-
-
- Source Files\Collision
-
-
- Source Files\Collision
-
-
- Source Files\Collision
-
-
- Source Files\Collision
-
-
- Source Files\Collision
-
-
- Source Files\Collision
-
-
- Source Files\Collision
-
-
- Source Files\Collision
-
-
- Source Files\Collision
-
-
- Source Files\Physics
-
-
- Source Files\Physics
-
-
- Source Files\Physics
-
-
- Source Files\Physics
-
-
- Source Files\Collision
-
-
-
-
+
Header Files\Collision
-
+
Header Files\Collision
-
+
Header Files\Collision
-
+
Header Files\Collision
-
+
Header Files\Collision
-
+
Header Files\Collision
-
- Header Files\Collision
-
-
- Header Files\Collision
-
-
- Header Files\Collision
-
-
- Header Files\Collision
-
-
- Header Files\Physics
-
-
- Header Files\Physics
-
-
- Header Files\Physics
-
-
- Header Files\Physics
-
- Header Files
+ Header Files\Collision
+
+
+ Header Files\Collision
+
+
+ Header Files\Collision
+
+
+ Header Files\Collision
+
+
+ Header Files\Collision
+
+
+ Header Files\Physics
+
+
+ Header Files\Physics
- Header Files
+ Header Files\Physics
+
+
+ Header Files\Physics
+
+
+ Header Files\Physics
+
+
+ Source Files\Collision
+
+
+ Source Files\Collision
+
+
+ Source Files\Collision
+
+
+ Source Files\Collision
+
+
+ Source Files\Collision
+
+
+ Source Files\Collision
+
+
+ Source Files\Collision
+
+
+ Source Files\Collision
+
+
+ Source Files\Collision
+
+
+ Source Files\Collision
+
+
+ Source Files\Collision
+
+
+ Source Files\Physics
+
+
+ Source Files\Physics
+
+
+ Source Files\Physics
+
+
+ Source Files\Physics
+
+
\ No newline at end of file
diff --git a/OysterPhysics3D/Physics/Particle.cpp b/OysterPhysics3D/Particle.cpp
similarity index 100%
rename from OysterPhysics3D/Physics/Particle.cpp
rename to OysterPhysics3D/Particle.cpp
diff --git a/OysterPhysics3D/Physics/Particle.h b/OysterPhysics3D/Particle.h
similarity index 96%
rename from OysterPhysics3D/Physics/Particle.h
rename to OysterPhysics3D/Particle.h
index 4c619749..18c31eba 100644
--- a/OysterPhysics3D/Physics/Particle.h
+++ b/OysterPhysics3D/Particle.h
@@ -6,8 +6,8 @@
#define OYSTER_PHYSICS_3D_PARTICLE_H
#include "OysterMath.h"
-#include "..\OysterCollision3D.h"
-#include "..\OysterPhysics3D.h"
+#include "OysterCollision3D.h"
+#include "OysterPhysics3D.h"
namespace Oyster { namespace Physics3D
{
diff --git a/OysterPhysics3D/Collision/Plane.cpp b/OysterPhysics3D/Plane.cpp
similarity index 98%
rename from OysterPhysics3D/Collision/Plane.cpp
rename to OysterPhysics3D/Plane.cpp
index 374ad605..3c89975b 100644
--- a/OysterPhysics3D/Collision/Plane.cpp
+++ b/OysterPhysics3D/Plane.cpp
@@ -3,7 +3,7 @@
/////////////////////////////////////////////////////////////////////
#include "Plane.h"
-#include "..\OysterCollision3D.h"
+#include "OysterCollision3D.h"
using namespace ::Oyster::Collision3D;
using namespace ::Oyster::Math;
diff --git a/OysterPhysics3D/Collision/Plane.h b/OysterPhysics3D/Plane.h
similarity index 100%
rename from OysterPhysics3D/Collision/Plane.h
rename to OysterPhysics3D/Plane.h
diff --git a/OysterPhysics3D/Collision/Point.cpp b/OysterPhysics3D/Point.cpp
similarity index 97%
rename from OysterPhysics3D/Collision/Point.cpp
rename to OysterPhysics3D/Point.cpp
index 3673dc2c..562e7e98 100644
--- a/OysterPhysics3D/Collision/Point.cpp
+++ b/OysterPhysics3D/Point.cpp
@@ -3,7 +3,7 @@
/////////////////////////////////////////////////////////////////////
#include "Point.h"
-#include "..\OysterCollision3D.h"
+#include "OysterCollision3D.h"
using namespace ::Oyster::Collision3D;
using namespace ::Oyster::Math3D;
diff --git a/OysterPhysics3D/Collision/Point.h b/OysterPhysics3D/Point.h
similarity index 100%
rename from OysterPhysics3D/Collision/Point.h
rename to OysterPhysics3D/Point.h
diff --git a/OysterPhysics3D/Collision/Ray.cpp b/OysterPhysics3D/Ray.cpp
similarity index 98%
rename from OysterPhysics3D/Collision/Ray.cpp
rename to OysterPhysics3D/Ray.cpp
index 99c8094a..7675fad7 100644
--- a/OysterPhysics3D/Collision/Ray.cpp
+++ b/OysterPhysics3D/Ray.cpp
@@ -3,7 +3,7 @@
/////////////////////////////////////////////////////////////////////
#include "Ray.h"
-#include "..\OysterCollision3D.h"
+#include "OysterCollision3D.h"
using namespace ::Oyster::Collision3D;
using namespace ::Oyster::Math3D;
diff --git a/OysterPhysics3D/Collision/Ray.h b/OysterPhysics3D/Ray.h
similarity index 100%
rename from OysterPhysics3D/Collision/Ray.h
rename to OysterPhysics3D/Ray.h
diff --git a/OysterPhysics3D/RigidBody.cpp b/OysterPhysics3D/RigidBody.cpp
new file mode 100644
index 00000000..306a0bf6
--- /dev/null
+++ b/OysterPhysics3D/RigidBody.cpp
@@ -0,0 +1,435 @@
+/////////////////////////////////////////////////////////////////////
+// Created by Dan Andersson & Robin Engman 2013
+/////////////////////////////////////////////////////////////////////
+
+#include "RigidBody.h"
+#include "Utilities.h"
+
+using namespace ::Oyster::Collision3D;
+using namespace ::Oyster::Physics3D;
+using namespace ::Oyster::Math3D;
+
+RigidBody::RigidBody( const Box &b, Float m )
+ : box(b), angularMomentum(0.0f), linearMomentum(0.0f), impulseTorqueSum(0.0f), impulseForceSum(0.0f)
+{ // by Dan Andersson
+ if( m != 0.0f )
+ {
+ this->mass = m;
+ }
+ else
+ {
+ this->mass = ::Utility::Value::numeric_limits::epsilon();
+ }
+
+ this->momentOfInertiaTensor = Float4x4::identity;
+}
+
+RigidBody & RigidBody::operator = ( const RigidBody &body )
+{ // by Dan Andersson
+ this->box = body.box;
+ this->angularMomentum = body.angularMomentum;
+ this->linearMomentum = body.linearMomentum;
+ this->impulseTorqueSum = body.impulseTorqueSum;
+ this->impulseForceSum = body.impulseForceSum;
+ this->mass = body.mass;
+ this->momentOfInertiaTensor = body.momentOfInertiaTensor;
+ return *this;
+}
+
+void RigidBody::Update_LeapFrog( Float deltaTime )
+{ // by Dan Andersson: Euler leap frog update when Runga Kutta is not needed
+
+ // updating the linear
+ // dv = dt * a = dt * F / m
+ // ds = dt * avg_v
+ Float3 deltaLinearVelocity = this->impulseForceSum;
+ deltaLinearVelocity *= (deltaTime / this->mass);
+ Float3 deltaPos = deltaTime * ::Utility::Value::AverageWithDelta( Formula::LinearVelocity(this->mass, this->linearMomentum), deltaLinearVelocity );
+
+ // updating the angular
+ // dw = dt * a = dt * ( I^-1 * T )
+ // rotation = dt * avg_w
+ Float4x4 inversedMomentOfInertiaTensor = this->momentOfInertiaTensor.GetInverse();
+ Float3 deltaAngularVelocity = Formula::AngularImpulseAcceleration( inversedMomentOfInertiaTensor, this->impulseTorqueSum ); // I^-1 * T
+ deltaAngularVelocity *= deltaTime;
+ Float3 rotationAxis = ::Utility::Value::AverageWithDelta( Formula::AngularVelocity(inversedMomentOfInertiaTensor,this->angularMomentum), deltaAngularVelocity );
+
+ Float deltaRadian = rotationAxis.Dot( rotationAxis );
+ if( deltaRadian != 0.0f )
+ { // branch depending if there is rotation
+ deltaRadian = ::std::sqrt( deltaRadian );
+ rotationAxis /= deltaRadian;
+
+ // using rotationAxis, deltaRadian and deltaPos to create a matrix to transform the orientation matrix
+ this->box.orientation = OrientationMatrix( rotationAxis, deltaRadian, deltaPos ) * this->box.orientation;
+ }
+ else
+ { // no rotation, only use deltaPos to translate the RigidBody
+ this->box.center += deltaPos;
+ }
+
+ // update movements and clear impulses
+ this->linearMomentum += Formula::LinearMomentum( this->mass, deltaLinearVelocity );
+ this->impulseForceSum = Float3::null;
+ this->angularMomentum += Formula::AngularMomentum( this->momentOfInertiaTensor, deltaAngularVelocity );
+ this->impulseTorqueSum = Float3::null;
+}
+
+void RigidBody::ApplyImpulseForce( const Float3 &f )
+{ // by Dan Andersson
+ this->impulseForceSum += f;
+}
+
+void RigidBody::ApplyImpulseForceAt_Local( const Float3 &localForce, const Float3 &localOffset )
+{ // by Dan Andersson
+ if( localOffset != Float3::null )
+ {
+ this->impulseForceSum += VectorProjection( localForce, localOffset );
+ this->impulseTorqueSum += Formula::ImpulseTorque( localOffset, localForce );
+ }
+ else
+ {
+ this->impulseForceSum += localForce;
+ }
+}
+
+void RigidBody::ApplyImpulseForceAt_World( const Float3 &worldForce, const Float3 &worldPos )
+{ // by Dan Andersson
+ Float4x4 view = this->GetView();
+ this->ApplyImpulseForceAt_Local( (view * Float4(worldForce, 0.0f)).xyz,
+ (view * Float4(worldPos, 1.0f)).xyz ); // should not be any disform thus result.w = 1.0f
+}
+
+void RigidBody::ApplyLinearImpulseAcceleration( const Float3 &a )
+{ // by Dan Andersson
+ this->impulseForceSum += Formula::ImpulseForce( this->mass, a );
+}
+
+void RigidBody::ApplyLinearImpulseAccelerationAt_Local( const Float3 &localImpulseLinearAcc, const Float3 &localOffset )
+{ // by Dan Andersson
+ if( localOffset != Float3::null )
+ {
+ this->impulseForceSum += Formula::ImpulseForce( this->mass, VectorProjection(localImpulseLinearAcc, localOffset) );
+
+ // tanAcc = angularAcc x localPosition
+ // angularAcc = localPosition x tanAcc = localPosition x linearAcc
+ // T = I * angularAcc
+ this->impulseTorqueSum += Formula::ImpulseTorque( this->momentOfInertiaTensor, Formula::AngularImpulseAcceleration(localImpulseLinearAcc, localOffset) );
+ }
+ else
+ {
+ this->impulseForceSum += Formula::ImpulseForce( this->mass, localImpulseLinearAcc );
+ }
+}
+
+void RigidBody::ApplyLinearImpulseAccelerationAt_World( const Float3 &worldImpulseLinearAcc, const Float3 &worldPos )
+{ // by Dan Andersson
+ Float4x4 view = this->GetView();
+ this->ApplyLinearImpulseAccelerationAt_Local( (view * Float4(worldImpulseLinearAcc, 0.0f)).xyz,
+ (view * Float4(worldPos, 1.0f)).xyz ); // should not be any disform thus result.w = 1.0f
+}
+
+void RigidBody::ApplyImpulseTorque( const Float3 &t )
+{ // by Dan Andersson
+ this->impulseTorqueSum += t;
+}
+
+void RigidBody::ApplyAngularImpulseAcceleration( const Float3 &a )
+{ // by Dan Andersson
+ this->impulseTorqueSum += Formula::ImpulseTorque( this->momentOfInertiaTensor, a );
+}
+
+Float4x4 & RigidBody::AccessOrientation()
+{ // by Dan Andersson
+ return this->box.orientation;
+}
+
+const Float4x4 & RigidBody::AccessOrientation() const
+{ // by Dan Andersson
+ return this->box.orientation;
+}
+
+Float3 & RigidBody::AccessBoundingReach()
+{ // by Dan Andersson
+ return this->box.boundingOffset;
+}
+
+const Float3 & RigidBody::AccessBoundingReach() const
+{ // by Dan Andersson
+ return this->box.boundingOffset;
+}
+
+Float3 & RigidBody::AccessCenter()
+{ // by Dan Andersson
+ return this->box.center;
+}
+
+const Float3 & RigidBody::AccessCenter() const
+{ // by Dan Andersson
+ return this->box.center;
+}
+
+const Float4x4 & RigidBody::GetMomentOfInertia() const
+{ // by Dan Andersson
+ return this->momentOfInertiaTensor;
+}
+
+const Float & RigidBody::GetMass() const
+{ // by Dan Andersson
+ return this->mass;
+}
+
+const Float4x4 & RigidBody::GetOrientation() const
+{ // by Dan Andersson
+ return this->box.orientation;
+}
+
+Float4x4 RigidBody::GetView() const
+{ // by Dan Andersson
+ return InverseOrientationMatrix( this->box.orientation );
+}
+
+const Float3 & RigidBody::GetBoundingReach() const
+{ // by Dan Andersson
+ return this->box.boundingOffset;
+}
+
+Float3 RigidBody::GetSize() const
+{ // by Dan Andersson
+ return 2.0f * this->box.boundingOffset;
+}
+
+const Float3 & RigidBody::GetCenter() const
+{ // by Dan Andersson
+ return this->box.center;
+}
+
+const Float3 & RigidBody::GetImpulsTorque() const
+{ // by Dan Andersson
+ return this->impulseTorqueSum;
+}
+
+const Float3 & RigidBody::GetAngularMomentum() const
+{ // by Dan Andersson
+ return this->angularMomentum;
+}
+
+Float3 RigidBody::GetAngularImpulseAcceleration() const
+{ // by Dan Andersson
+ return Formula::AngularImpulseAcceleration( this->momentOfInertiaTensor.GetInverse(), this->impulseTorqueSum );
+}
+
+Float3 RigidBody::GetAngularVelocity() const
+{ // by Dan Andersson
+ return Formula::AngularVelocity( this->momentOfInertiaTensor.GetInverse(), this->angularMomentum );
+}
+
+const Float3 & RigidBody::GetImpulseForce() const
+{ // by Dan Andersson
+ return this->impulseForceSum;
+}
+
+const Float3 & RigidBody::GetLinearMomentum() const
+{ // by Dan Andersson
+ return this->linearMomentum;
+}
+
+Float3 RigidBody::GetLinearImpulseAcceleration() const
+{ // by Dan Andersson
+ return Formula::LinearImpulseAcceleration( this->mass, this->impulseForceSum );
+}
+
+Float3 RigidBody::GetLinearVelocity() const
+{ // by Dan Andersson
+ return Formula::LinearVelocity( this->mass, this->linearMomentum );
+}
+
+Float3 RigidBody::GetTangentialImpulseForceAt_Local( const Float3 &localPos ) const
+{ // by Dan Andersson
+ return Formula::TangentialImpulseForce( this->impulseTorqueSum, localPos );
+}
+
+Float3 RigidBody::GetTangentialImpulseForceAt_World( const Float3 &worldPos ) const
+{ // by Dan Andersson
+ return this->GetTangentialImpulseForceAt_Local( (this->GetView() * Float4(worldPos, 1.0f)).xyz ); // should not be any disform thus result.w = 1.0f
+}
+
+Float3 RigidBody::GetTangentialLinearMomentumAt_Local( const Float3 &localPos ) const
+{ // by Dan Andersson
+ return Formula::TangentialLinearMomentum( this->angularMomentum, localPos );
+}
+
+Float3 RigidBody::GetTangentialLinearMomentumAt_World( const Float3 &worldPos ) const
+{ // by Dan Andersson
+ return this->GetTangentialLinearMomentumAt_Local( (this->GetView() * Float4(worldPos, 1.0f)).xyz ); // should not be any disform thus result.w = 1.0f
+}
+
+Float3 RigidBody::GetTangentialImpulseAccelerationAt_Local( const Float3 &localPos ) const
+{ // by Dan Andersson
+ return Formula::TangentialImpulseAcceleration( this->momentOfInertiaTensor.GetInverse(), this->impulseTorqueSum, localPos );
+}
+
+Float3 RigidBody::GetTangentialImpulseAccelerationAt_World( const Float3 &worldPos ) const
+{ // by Dan Andersson
+ return this->GetTangentialImpulseAccelerationAt_Local( (this->GetView() * Float4(worldPos, 1.0f)).xyz ); // should not be any disform thus result.w = 1.0f
+}
+
+Float3 RigidBody::GetTangentialLinearVelocityAt_Local( const Float3 &localPos ) const
+{ // by Dan Andersson
+ return Formula::TangentialLinearVelocity( this->momentOfInertiaTensor.GetInverse(), this->angularMomentum, localPos );
+}
+
+Float3 RigidBody::GetTangentialLinearVelocityAt_World( const Float3 &worldPos ) const
+{ // by Dan Andersson
+ return this->GetTangentialLinearVelocityAt_Local( (this->GetView() * Float4(worldPos, 1.0f)).xyz ); // should not be any disform thus result.w = 1.0f
+}
+
+Float3 RigidBody::GetImpulseForceAt_Local( const Float3 &pos ) const
+{ // by
+ return Float3::null;
+}
+
+Float3 RigidBody::GetImpulseForceAt_World( const Float3 &pos ) const
+{ // by
+ return Float3::null;
+}
+
+Float3 RigidBody::GetLinearMomentumAt_Local( const Float3 &pos ) const
+{ // by
+ return Float3::null;
+}
+
+Float3 RigidBody::GetLinearMomentumAt_World( const Float3 &pos ) const
+{ // by
+ return Float3::null;
+}
+
+Float3 RigidBody::GetImpulseAccelerationAt_Local( const Float3 &pos ) const
+{ // by
+ return Float3::null;
+}
+
+Float3 RigidBody::GetImpulseAccelerationAt_World( const Float3 &pos ) const
+{ // by
+ return Float3::null;
+}
+
+Float3 RigidBody::GetLinearVelocityAt_Local( const Float3 &pos ) const
+{ // by
+ return Float3::null;
+}
+
+Float3 RigidBody::GetLinearVelocityAt_World( const Float3 &pos ) const
+{ // by
+ return Float3::null;
+}
+
+void RigidBody::SetMomentOfInertia( const Float4x4 &i )
+{ // by
+
+}
+
+void RigidBody::SetMass_KeepVelocity( const Float &m )
+{ // by
+
+}
+
+void RigidBody::SetMass_KeepMomentum( const Float &m )
+{ // by
+
+}
+
+void RigidBody::SetOrientation( const Float4x4 &o )
+{ // by
+
+}
+
+void RigidBody::SetSize( const Float3 &widthHeight )
+{ // by
+
+}
+
+void RigidBody::SetCenter( const Float3 &p )
+{ // by
+
+}
+
+void RigidBody::SetImpulsTorque( const Float3 &t )
+{ // by
+
+}
+
+void RigidBody::SetAngularMomentum( const Float3 &h )
+{ // by
+
+}
+
+void RigidBody::SetAngularImpulseAcceleration( const Float3 &a )
+{ // by
+
+}
+
+void RigidBody::SetAngularVelocity( const Float3 &w )
+{ // by
+
+}
+
+void RigidBody::SetImpulseForce( const Float3 &f )
+{ // by
+
+}
+
+void RigidBody::SetLinearMomentum( const Float3 &g )
+{ // by
+
+}
+
+void RigidBody::SetLinearImpulseAcceleration( const Float3 &a )
+{ // by
+
+}
+
+void RigidBody::SetLinearVelocity( const Float3 &v )
+{ // by
+
+}
+
+void RigidBody::SetImpulseForceAt_Local( const Float3 &localForce, const Float3 &localPos )
+{ // by
+
+}
+
+void RigidBody::SetImpulseForceAt_World( const Float3 &worldForce, const Float3 &worldPos )
+{ // by
+
+}
+
+void RigidBody::SetLinearMomentumAt_Local( const Float3 &g, const Float3 &pos )
+{ // by
+
+}
+
+void RigidBody::SetLinearMomentumAt_World( const Float3 &g, const Float3 &pos )
+{ // by
+
+}
+
+void RigidBody::SetImpulseAccelerationAt_Local( const Float3 &a, const Float3 &pos )
+{ // by
+
+}
+
+void RigidBody::SetImpulseAccelerationAt_World( const Float3 &a, const Float3 &pos )
+{ // by
+
+}
+
+void RigidBody::SetLinearVelocityAt_Local( const Float3 &v, const Float3 &pos )
+{ // by
+
+}
+
+void RigidBody::SetLinearVelocityAt_World( const Float3 &v, const Float3 &pos )
+{ // by
+
+}
\ No newline at end of file
diff --git a/OysterPhysics3D/RigidBody.h b/OysterPhysics3D/RigidBody.h
new file mode 100644
index 00000000..bb0dcc7d
--- /dev/null
+++ b/OysterPhysics3D/RigidBody.h
@@ -0,0 +1,137 @@
+/////////////////////////////////////////////////////////////////////
+// Created by Dan Andersson 2013
+/////////////////////////////////////////////////////////////////////
+
+#ifndef OYSTER_PHYSICS_3D_RIGIDBODY_H
+#define OYSTER_PHYSICS_3D_RIGIDBODY_H
+
+#include "OysterMath.h"
+#include "OysterCollision3D.h"
+#include "OysterPhysics3D.h"
+
+namespace Oyster { namespace Physics3D
+{
+ struct RigidBody
+ { /// A struct of a simple rigid body.
+ public:
+ ::Oyster::Collision3D::Box box; /// Contains data representing physical presence.
+ ::Oyster::Math::Float3 angularMomentum, /// The angular momentum H (Nm*s) around an parallell axis.
+ linearMomentum, /// The linear momentum G (kg*m/s).
+ impulseTorqueSum, /// The impulse torque T (Nm) that will be consumed each update.
+ impulseForceSum; /// The impulse force F (N) that will be consumed each update.
+
+ RigidBody( const ::Oyster::Collision3D::Box &box = ::Oyster::Collision3D::Box(), ::Oyster::Math::Float mass = 1.0f );
+
+ RigidBody & operator = ( const RigidBody &body );
+
+ void Update_LeapFrog( ::Oyster::Math::Float deltaTime );
+ void ApplyImpulseForce( const ::Oyster::Math::Float3 &f );
+ void ApplyImpulseForceAt_Local( const ::Oyster::Math::Float3 &f, const ::Oyster::Math::Float3 &pos );
+ void ApplyImpulseForceAt_World( const ::Oyster::Math::Float3 &f, const ::Oyster::Math::Float3 &pos ); /// ApplyImpulseForce_LocalPos is preferred
+ void ApplyLinearImpulseAcceleration( const ::Oyster::Math::Float3 &a );
+ void ApplyLinearImpulseAccelerationAt_Local( const ::Oyster::Math::Float3 &a, const ::Oyster::Math::Float3 &pos );
+ void ApplyLinearImpulseAccelerationAt_World( const ::Oyster::Math::Float3 &a, const ::Oyster::Math::Float3 &pos ); /// ApplyLinearImpulseAcceleration_LocalPos is preferred
+ void ApplyImpulseTorque( const ::Oyster::Math::Float3 &t );
+ void ApplyAngularImpulseAcceleration( const ::Oyster::Math::Float3 &a );
+
+ // ACCESS METHODS /////////////////////////////
+
+ ::Oyster::Math::Float4x4 & AccessOrientation();
+ const ::Oyster::Math::Float4x4 & AccessOrientation() const;
+ ::Oyster::Math::Float3 & AccessBoundingReach();
+ const ::Oyster::Math::Float3 & AccessBoundingReach() const;
+ ::Oyster::Math::Float3 & AccessCenter();
+ const ::Oyster::Math::Float3 & AccessCenter() const;
+
+ // GET METHODS ////////////////////////////////
+
+ const ::Oyster::Math::Float4x4 & GetMomentOfInertia() const;
+ const ::Oyster::Math::Float & GetMass() const;
+
+ const ::Oyster::Math::Float4x4 & GetOrientation() const;
+ ::Oyster::Math::Float4x4 GetView() const;
+ const ::Oyster::Math::Float4x4 & GetToWorldMatrix() const;
+ ::Oyster::Math::Float4x4 GetToLocalMatrix() const;
+
+ const ::Oyster::Math::Float3 & GetBoundingReach() const;
+ ::Oyster::Math::Float3 GetSize() const;
+
+ const ::Oyster::Math::Float3 & GetCenter() const;
+
+ const ::Oyster::Math::Float3 & GetImpulsTorque() const;
+ const ::Oyster::Math::Float3 & GetAngularMomentum() const;
+ ::Oyster::Math::Float3 GetAngularImpulseAcceleration() const;
+ ::Oyster::Math::Float3 GetAngularVelocity() const;
+
+ const ::Oyster::Math::Float3 & GetImpulseForce() const;
+ const ::Oyster::Math::Float3 & GetLinearMomentum() const;
+ ::Oyster::Math::Float3 GetLinearImpulseAcceleration() const;
+ ::Oyster::Math::Float3 GetLinearVelocity() const;
+
+ ::Oyster::Math::Float3 GetTangentialImpulseForceAt_Local( const ::Oyster::Math::Float3 &pos ) const;
+ ::Oyster::Math::Float3 GetTangentialImpulseForceAt_World( const ::Oyster::Math::Float3 &pos ) const;
+ ::Oyster::Math::Float3 GetTangentialLinearMomentumAt_Local( const ::Oyster::Math::Float3 &pos ) const;
+ ::Oyster::Math::Float3 GetTangentialLinearMomentumAt_World( const ::Oyster::Math::Float3 &pos ) const;
+ ::Oyster::Math::Float3 GetTangentialImpulseAccelerationAt_Local( const ::Oyster::Math::Float3 &pos ) const;
+ ::Oyster::Math::Float3 GetTangentialImpulseAccelerationAt_World( const ::Oyster::Math::Float3 &pos ) const;
+ ::Oyster::Math::Float3 GetTangentialLinearVelocityAt_Local( const ::Oyster::Math::Float3 &pos ) const;
+ ::Oyster::Math::Float3 GetTangentialLinearVelocityAt_World( const ::Oyster::Math::Float3 &pos ) const;
+
+ ::Oyster::Math::Float3 GetImpulseForceAt_Local( const ::Oyster::Math::Float3 &pos ) const;
+ ::Oyster::Math::Float3 GetImpulseForceAt_World( const ::Oyster::Math::Float3 &pos ) const;
+ ::Oyster::Math::Float3 GetLinearMomentumAt_Local( const ::Oyster::Math::Float3 &pos ) const;
+ ::Oyster::Math::Float3 GetLinearMomentumAt_World( const ::Oyster::Math::Float3 &pos ) const;
+ ::Oyster::Math::Float3 GetImpulseAccelerationAt_Local( const ::Oyster::Math::Float3 &pos ) const;
+ ::Oyster::Math::Float3 GetImpulseAccelerationAt_World( const ::Oyster::Math::Float3 &pos ) const;
+ ::Oyster::Math::Float3 GetLinearVelocityAt_Local( const ::Oyster::Math::Float3 &pos ) const;
+ ::Oyster::Math::Float3 GetLinearVelocityAt_World( const ::Oyster::Math::Float3 &pos ) const;
+
+ // SET METHODS ////////////////////////////////
+
+ void SetMomentOfInertia( const ::Oyster::Math::Float4x4 &i );
+ void SetMass_KeepVelocity( const ::Oyster::Math::Float &m );
+ void SetMass_KeepMomentum( const ::Oyster::Math::Float &m );
+
+ void SetOrientation( const ::Oyster::Math::Float4x4 &o );
+ void SetSize( const ::Oyster::Math::Float3 &widthHeight );
+ void SetCenter( const ::Oyster::Math::Float3 &p );
+
+ void SetImpulsTorque( const ::Oyster::Math::Float3 &t );
+ void SetAngularMomentum( const ::Oyster::Math::Float3 &h );
+ void SetAngularImpulseAcceleration( const ::Oyster::Math::Float3 &a );
+ void SetAngularVelocity( const ::Oyster::Math::Float3 &w );
+
+ void SetImpulseForce( const ::Oyster::Math::Float3 &f );
+ void SetLinearMomentum( const ::Oyster::Math::Float3 &g );
+ void SetLinearImpulseAcceleration( const ::Oyster::Math::Float3 &a );
+ void SetLinearVelocity( const ::Oyster::Math::Float3 &v );
+
+ void SetImpulseForceAt_Local( const ::Oyster::Math::Float3 &f, const ::Oyster::Math::Float3 &pos );
+ void SetImpulseForceAt_World( const ::Oyster::Math::Float3 &f, const ::Oyster::Math::Float3 &pos );
+ void SetLinearMomentumAt_Local( const ::Oyster::Math::Float3 &g, const ::Oyster::Math::Float3 &pos );
+ void SetLinearMomentumAt_World( const ::Oyster::Math::Float3 &g, const ::Oyster::Math::Float3 &pos );
+ void SetImpulseAccelerationAt_Local( const ::Oyster::Math::Float3 &a, const ::Oyster::Math::Float3 &pos );
+ void SetImpulseAccelerationAt_World( const ::Oyster::Math::Float3 &a, const ::Oyster::Math::Float3 &pos );
+ void SetLinearVelocityAt_Local( const ::Oyster::Math::Float3 &v, const ::Oyster::Math::Float3 &pos );
+ void SetLinearVelocityAt_World( const ::Oyster::Math::Float3 &v, const ::Oyster::Math::Float3 &pos );
+
+ private:
+ ::Oyster::Math::Float mass; /// m (kg)
+ ::Oyster::Math::Float4x4 momentOfInertiaTensor; /// I (Nm*s) Tensor matrix ( only need to be 3x3 matrix, but is 4x4 for future hardware acceleration )
+ };
+
+ // INLINE IMPLEMENTATIONS ///////////////////////////////////////
+
+ inline const ::Oyster::Math::Float4x4 & RigidBody::GetToWorldMatrix() const
+ {
+ return this->GetOrientation();
+ }
+
+ inline ::Oyster::Math::Float4x4 RigidBody::GetToLocalMatrix() const
+ {
+ return this->GetView();
+ }
+
+} }
+
+#endif
diff --git a/OysterPhysics3D/Collision/Sphere.cpp b/OysterPhysics3D/Sphere.cpp
similarity index 98%
rename from OysterPhysics3D/Collision/Sphere.cpp
rename to OysterPhysics3D/Sphere.cpp
index 2250aa04..b0f14cf3 100644
--- a/OysterPhysics3D/Collision/Sphere.cpp
+++ b/OysterPhysics3D/Sphere.cpp
@@ -1,5 +1,5 @@
#include "Sphere.h"
-#include "..\OysterCollision3D.h"
+#include "OysterCollision3D.h"
using namespace ::Oyster::Collision3D;
using namespace ::Oyster::Math;
diff --git a/OysterPhysics3D/Collision/Sphere.h b/OysterPhysics3D/Sphere.h
similarity index 100%
rename from OysterPhysics3D/Collision/Sphere.h
rename to OysterPhysics3D/Sphere.h
diff --git a/OysterPhysics3D/Physics/Spring.cpp b/OysterPhysics3D/Spring.cpp
similarity index 100%
rename from OysterPhysics3D/Physics/Spring.cpp
rename to OysterPhysics3D/Spring.cpp
diff --git a/OysterPhysics3D/Physics/Spring.h b/OysterPhysics3D/Spring.h
similarity index 100%
rename from OysterPhysics3D/Physics/Spring.h
rename to OysterPhysics3D/Spring.h
diff --git a/OysterPhysics3D/Collision/Universe.cpp b/OysterPhysics3D/Universe.cpp
similarity index 95%
rename from OysterPhysics3D/Collision/Universe.cpp
rename to OysterPhysics3D/Universe.cpp
index 4a8bcf94..ee02144b 100644
--- a/OysterPhysics3D/Collision/Universe.cpp
+++ b/OysterPhysics3D/Universe.cpp
@@ -1,5 +1,5 @@
#include "Universe.h"
-#include "..\OysterCollision3D.h"
+#include "OysterCollision3D.h"
using namespace ::Oyster::Collision3D;
using namespace ::Utility::Memory;
diff --git a/OysterPhysics3D/Collision/Universe.h b/OysterPhysics3D/Universe.h
similarity index 100%
rename from OysterPhysics3D/Collision/Universe.h
rename to OysterPhysics3D/Universe.h