diff --git a/Code/GamePhysics/GamePhysics.vcxproj b/Code/GamePhysics/GamePhysics.vcxproj
index 540002a1..06e64fd1 100644
--- a/Code/GamePhysics/GamePhysics.vcxproj
+++ b/Code/GamePhysics/GamePhysics.vcxproj
@@ -91,9 +91,12 @@
Disabled
$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;%(AdditionalIncludeDirectories)
_WINDLL;PHYSICS_DLL_EXPORT;%(PreprocessorDefinitions)
+ false
true
+
+
@@ -102,9 +105,12 @@
Disabled
$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;%(AdditionalIncludeDirectories)
_WINDLL;PHYSICS_DLL_EXPORT;%(PreprocessorDefinitions)
+ false
true
+
+
@@ -115,11 +121,14 @@
true
$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;%(AdditionalIncludeDirectories)
_WINDLL;PHYSICS_DLL_EXPORT;%(PreprocessorDefinitions)
+ false
true
true
true
+
+
@@ -130,11 +139,14 @@
true
$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;%(AdditionalIncludeDirectories)
_WINDLL;PHYSICS_DLL_EXPORT;%(PreprocessorDefinitions)
+ false
true
true
true
+
+
@@ -154,6 +166,8 @@
+
+
diff --git a/Code/GamePhysics/GamePhysics.vcxproj.filters b/Code/GamePhysics/GamePhysics.vcxproj.filters
index 694a8ec7..15221691 100644
--- a/Code/GamePhysics/GamePhysics.vcxproj.filters
+++ b/Code/GamePhysics/GamePhysics.vcxproj.filters
@@ -36,6 +36,12 @@
Header Files\Implementation
+
+ Header Files\Include
+
+
+ Header Files\Include
+
diff --git a/Code/GamePhysics/Implementation/SimpleRigidBody.cpp b/Code/GamePhysics/Implementation/SimpleRigidBody.cpp
index ea75ffe3..934c843f 100644
--- a/Code/GamePhysics/Implementation/SimpleRigidBody.cpp
+++ b/Code/GamePhysics/Implementation/SimpleRigidBody.cpp
@@ -42,6 +42,23 @@ UniquePointer SimpleRigidBody::Clone() const
return new SimpleRigidBody( *this );
}
+SimpleRigidBody::State SimpleRigidBody::GetState() const
+{
+ return State( this->rigid.box.boundingOffset, this->rigid.box.center, AngularAxis(this->rigid.box.rotation).xyz );
+}
+
+SimpleRigidBody::State & SimpleRigidBody::GetState( SimpleRigidBody::State &targetMem ) const
+{
+ return targetMem = State( this->rigid.box.boundingOffset, this->rigid.box.center, AngularAxis(this->rigid.box.rotation).xyz );
+}
+
+void SimpleRigidBody::SetState( const SimpleRigidBody::State &state )
+{ /** @todo TODO: temporary solution! Need to know it's occtree */
+ this->rigid.box.boundingOffset = state.GetReach();
+ this->rigid.box.center = state.GetCenterPosition();
+ this->rigid.box.rotation = state.GetRotation();
+}
+
void SimpleRigidBody::CallSubscription( const ICustomBody *proto, const ICustomBody *deuter )
{
this->collisionAction( proto, deuter );
diff --git a/Code/GamePhysics/Implementation/SimpleRigidBody.h b/Code/GamePhysics/Implementation/SimpleRigidBody.h
index 5e05c9d7..774420c5 100644
--- a/Code/GamePhysics/Implementation/SimpleRigidBody.h
+++ b/Code/GamePhysics/Implementation/SimpleRigidBody.h
@@ -15,6 +15,10 @@ namespace Oyster { namespace Physics
::Utility::DynamicMemory::UniquePointer Clone() const;
+ State GetState() const;
+ State & GetState( State &targetMem ) const;
+ void SetState( const State &state );
+
void CallSubscription( const ICustomBody *proto, const ICustomBody *deuter );
bool IsAffectedByGravity() const;
bool Intersects( const ICustomBody &object, ::Oyster::Math::Float timeStepLength, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const;
diff --git a/Code/GamePhysics/Implementation/SphericalRigidBody.cpp b/Code/GamePhysics/Implementation/SphericalRigidBody.cpp
index 03ed7d2a..34160192 100644
--- a/Code/GamePhysics/Implementation/SphericalRigidBody.cpp
+++ b/Code/GamePhysics/Implementation/SphericalRigidBody.cpp
@@ -44,6 +44,23 @@ UniquePointer SphericalRigidBody::Clone() const
return new SphericalRigidBody( *this );
}
+SphericalRigidBody::State SphericalRigidBody::GetState() const
+{
+ return State( this->rigid.box.boundingOffset, this->rigid.box.center, AngularAxis(this->rigid.box.rotation).xyz );
+}
+
+SphericalRigidBody::State & SphericalRigidBody::GetState( SphericalRigidBody::State &targetMem ) const
+{
+ return targetMem = State( this->rigid.box.boundingOffset, this->rigid.box.center, AngularAxis(this->rigid.box.rotation).xyz );
+}
+
+void SphericalRigidBody::SetState( const SphericalRigidBody::State &state )
+{ /** @todo TODO: temporary solution! Need to know it's occtree */
+ this->rigid.box.boundingOffset = state.GetReach();
+ this->rigid.box.center = state.GetCenterPosition();
+ this->rigid.box.rotation = state.GetRotation();
+}
+
void SphericalRigidBody::CallSubscription( const ICustomBody *proto, const ICustomBody *deuter )
{
this->collisionAction( proto, deuter );
diff --git a/Code/GamePhysics/Implementation/SphericalRigidBody.h b/Code/GamePhysics/Implementation/SphericalRigidBody.h
index a25cba2c..1aca514d 100644
--- a/Code/GamePhysics/Implementation/SphericalRigidBody.h
+++ b/Code/GamePhysics/Implementation/SphericalRigidBody.h
@@ -16,6 +16,10 @@ namespace Oyster { namespace Physics
::Utility::DynamicMemory::UniquePointer Clone() const;
+ State GetState() const;
+ State & GetState( State &targetMem = State() ) const;
+ void SetState( const State &state );
+
void CallSubscription( const ICustomBody *proto, const ICustomBody *deuter );
bool IsAffectedByGravity() const;
bool Intersects( const ICustomBody &object, ::Oyster::Math::Float timeStepLength, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const;
diff --git a/Code/GamePhysics/PhysicsAPI.h b/Code/GamePhysics/PhysicsAPI.h
index cd720abd..387bf0e6 100644
--- a/Code/GamePhysics/PhysicsAPI.h
+++ b/Code/GamePhysics/PhysicsAPI.h
@@ -1,4 +1,4 @@
- #ifndef PHYSICS_API_H
+#ifndef PHYSICS_API_H
#define PHYSICS_API_H
#include "OysterCollision3D.h"
@@ -17,6 +17,13 @@ namespace Oyster
class API;
class ICustomBody;
+ namespace Struct
+ {
+ struct SimpleBodyDescription;
+ struct SphericalBodyDescription;
+ struct CustomBodyState;
+ }
+
enum UpdateState
{
UpdateState_resting,
@@ -32,7 +39,7 @@ namespace Oyster
{
public:
static ::Oyster::Math::Float4x4 & CreateSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() );
-
+
static ::Oyster::Math::Float4x4 & CreateHollowSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() );
static ::Oyster::Math::Float4x4 & CreateCuboidMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float width, const ::Oyster::Math::Float depth, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() );
@@ -45,8 +52,8 @@ namespace Oyster
class PHYSICS_DLL_USAGE API
{
public:
- struct SimpleBodyDescription;
- struct SphericalBodyDescription;
+ typedef Struct::SimpleBodyDescription SimpleBodyDescription;
+ typedef Struct::SphericalBodyDescription SphericalBodyDescription;
typedef void (*EventAction_Destruction)( ::Utility::DynamicMemory::UniquePointer proto );
@@ -237,6 +244,9 @@ namespace Oyster
};
typedef SubscriptMessage (*EventAction_Collision)( const ICustomBody *proto, const ICustomBody *deuter );
+ typedef Struct::SimpleBodyDescription SimpleBodyDescription;
+ typedef Struct::SphericalBodyDescription SphericalBodyDescription;
+ typedef Struct::CustomBodyState State;
virtual ~ICustomBody() {};
@@ -251,6 +261,21 @@ namespace Oyster
********************************************************/
virtual void CallSubscription( const ICustomBody *proto, const ICustomBody *deuter ) = 0;
+ /********************************************************
+ * @todo TODO: need doc
+ ********************************************************/
+ virtual State GetState() const = 0;
+
+ /********************************************************
+ * @todo TODO: need doc
+ ********************************************************/
+ virtual State & GetState( State &targetMem ) const = 0;
+
+ /********************************************************
+ * @todo TODO: need doc
+ ********************************************************/
+ virtual void SetState( const State &state ) = 0;
+
/********************************************************
* @return true if Engine should apply gravity on this object.
********************************************************/
@@ -397,48 +422,9 @@ namespace Oyster
********************************************************/
virtual void SetMomentum( const ::Oyster::Math::Float3 &worldG ) = 0;
};
-
- struct API::SimpleBodyDescription
- {
- ::Oyster::Math::Float4x4 rotation;
- ::Oyster::Math::Float3 centerPosition;
- ::Oyster::Math::Float3 size;
- ::Oyster::Math::Float mass;
- ::Oyster::Math::Float4x4 inertiaTensor;
- ICustomBody::EventAction_Collision subscription;
- bool ignoreGravity;
-
- SimpleBodyDescription()
- {
- this->rotation = ::Oyster::Math::Float4x4::identity;
- this->centerPosition = ::Oyster::Math::Float3::null;
- this->size = ::Oyster::Math::Float3( 1.0f );
- this->mass = 12.0f;
- this->inertiaTensor = ::Oyster::Math::Float4x4::identity;
- this->subscription = NULL;
- this->ignoreGravity = false;
- }
- };
-
- struct API::SphericalBodyDescription
- {
- ::Oyster::Math::Float4x4 rotation;
- ::Oyster::Math::Float3 centerPosition;
- ::Oyster::Math::Float radius;
- ::Oyster::Math::Float mass;
- ICustomBody::EventAction_Collision subscription;
- bool ignoreGravity;
-
- SphericalBodyDescription()
- {
- this->rotation = ::Oyster::Math::Float4x4::identity;
- this->centerPosition = ::Oyster::Math::Float3::null;
- this->radius = 0.5f;
- this->mass = 10.0f;
- this->subscription = NULL;
- this->ignoreGravity = false;
- }
- };
}
}
+
+#include "PhysicsStructs.h"
+
#endif
\ No newline at end of file
diff --git a/Code/GamePhysics/PhysicsStructs-Impl.h b/Code/GamePhysics/PhysicsStructs-Impl.h
new file mode 100644
index 00000000..3de46ee2
--- /dev/null
+++ b/Code/GamePhysics/PhysicsStructs-Impl.h
@@ -0,0 +1,117 @@
+#ifndef PHYSICS_STRUCTS_IMPL_H
+#define PHYSICS_STRUCTS_IMPL_H
+
+#include "PhysicsStructs.h"
+
+namespace Oyster { namespace Physics
+{
+ namespace Struct
+ {
+ inline SimpleBodyDescription::SimpleBodyDescription()
+ {
+ this->rotation = ::Oyster::Math::Float4x4::identity;
+ this->centerPosition = ::Oyster::Math::Float3::null;
+ this->size = ::Oyster::Math::Float3( 1.0f );
+ this->mass = 12.0f;
+ this->inertiaTensor = ::Oyster::Math::Float4x4::identity;
+ this->subscription = NULL;
+ this->ignoreGravity = false;
+ }
+
+ inline SphericalBodyDescription::SphericalBodyDescription()
+ {
+ this->rotation = ::Oyster::Math::Float4x4::identity;
+ this->centerPosition = ::Oyster::Math::Float3::null;
+ this->radius = 0.5f;
+ this->mass = 10.0f;
+ this->subscription = NULL;
+ this->ignoreGravity = false;
+ }
+
+
+ inline CustomBodyState::CustomBodyState( const ::Oyster::Math::Float3 &reach, const ::Oyster::Math::Float3 ¢erPos, const ::Oyster::Math::Float3 &rotation )
+ {
+ this->reach = ::Oyster::Math::Float4( reach, 0.0f );
+ this->centerPos = ::Oyster::Math::Float4( centerPos, 1.0f );
+ this->angularAxis = ::Oyster::Math::Float4( rotation, 0.0f );
+ this->isSpatiallyAltered = this->isDisturbed = false;
+ }
+
+ inline CustomBodyState & CustomBodyState::operator = ( const CustomBodyState &state )
+ {
+ this->reach = state.reach;
+ this->centerPos = state.centerPos;
+ this->angularAxis = state.angularAxis;
+
+ this->isSpatiallyAltered = state.isSpatiallyAltered;
+ this->isDisturbed = state.isDisturbed;
+ return *this;
+ }
+
+ inline const ::Oyster::Math::Float4 & CustomBodyState::GetReach() const
+ {
+ return this->reach;
+ }
+
+ inline ::Oyster::Math::Float4 CustomBodyState::GetSize() const
+ {
+ return 2.0f * this->GetReach();
+ }
+
+ inline const ::Oyster::Math::Float4 & CustomBodyState::GetCenterPosition() const
+ {
+ return this->centerPos;
+ }
+
+ inline const ::Oyster::Math::Float4 & CustomBodyState::GetAngularAxis() const
+ {
+ return this->angularAxis;
+ }
+
+ inline ::Oyster::Math::Float4x4 CustomBodyState::GetRotation() const
+ {
+ return ::Oyster::Math3D::RotationMatrix( this->GetAngularAxis().xyz );
+ }
+
+ inline void CustomBodyState::SetSize( const ::Oyster::Math::Float3 &size )
+ {
+ this->SetReach( 0.5f * size );
+ }
+
+ inline void CustomBodyState::SetReach( const ::Oyster::Math::Float3 &halfSize )
+ {
+ this->reach.xyz = halfSize;
+ this->reach = ::Utility::Value::Max( this->reach, ::Oyster::Math::Float4::null );
+ this->isSpatiallyAltered = this->isDisturbed = true;
+ }
+
+ inline void CustomBodyState::SetCenterPosition( const ::Oyster::Math::Float3 ¢erPos )
+ {
+ this->centerPos.xyz = centerPos;
+ this->isSpatiallyAltered = this->isDisturbed = true;
+ }
+
+ inline void CustomBodyState::SetRotation( const ::Oyster::Math::Float3 &angularAxis )
+ {
+ this->angularAxis.xyz = angularAxis;
+ this->isSpatiallyAltered = this->isDisturbed = true;
+ }
+
+ inline void CustomBodyState::SetRotation( const ::Oyster::Math::Float4x4 &rotation )
+ {
+ this->SetRotation( ::Oyster::Math3D::AngularAxis(rotation).xyz );
+ }
+
+ inline bool CustomBodyState::IsSpatiallyAltered() const
+ {
+ return this->isSpatiallyAltered;
+ }
+
+ inline bool CustomBodyState::IsDisturbed() const
+ {
+ return this->isDisturbed;
+ }
+ }
+} }
+
+#endif
\ No newline at end of file
diff --git a/Code/GamePhysics/PhysicsStructs.h b/Code/GamePhysics/PhysicsStructs.h
new file mode 100644
index 00000000..c1f74640
--- /dev/null
+++ b/Code/GamePhysics/PhysicsStructs.h
@@ -0,0 +1,70 @@
+#ifndef PHYSICS_STRUCTS_H
+#define PHYSICS_STRUCTS_H
+
+#include "OysterMath.h"
+#include "PhysicsAPI.h"
+
+namespace Oyster { namespace Physics
+{
+ namespace Struct
+ {
+ struct SimpleBodyDescription
+ {
+ ::Oyster::Math::Float4x4 rotation;
+ ::Oyster::Math::Float3 centerPosition;
+ ::Oyster::Math::Float3 size;
+ ::Oyster::Math::Float mass;
+ ::Oyster::Math::Float4x4 inertiaTensor;
+ ::Oyster::Physics::ICustomBody::EventAction_Collision subscription;
+ bool ignoreGravity;
+
+ SimpleBodyDescription();
+ };
+
+ struct SphericalBodyDescription
+ {
+ ::Oyster::Math::Float4x4 rotation;
+ ::Oyster::Math::Float3 centerPosition;
+ ::Oyster::Math::Float radius;
+ ::Oyster::Math::Float mass;
+ ::Oyster::Physics::ICustomBody::EventAction_Collision subscription;
+ bool ignoreGravity;
+
+ SphericalBodyDescription();
+ };
+
+ struct CustomBodyState
+ {
+ public:
+ CustomBodyState( const ::Oyster::Math::Float3 &reach = ::Oyster::Math::Float3::null,
+ const ::Oyster::Math::Float3 ¢erPos = ::Oyster::Math::Float3::null,
+ const ::Oyster::Math::Float3 &rotation = ::Oyster::Math::Float3::null );
+
+ CustomBodyState & operator = ( const CustomBodyState &state );
+
+ const ::Oyster::Math::Float4 & GetReach() const;
+ ::Oyster::Math::Float4 GetSize() const;
+ const ::Oyster::Math::Float4 & GetCenterPosition() const;
+ const ::Oyster::Math::Float4 & GetAngularAxis() const;
+ ::Oyster::Math::Float4x4 GetRotation() const;
+
+ void SetSize( const ::Oyster::Math::Float3 &size );
+ void SetReach( const ::Oyster::Math::Float3 &halfSize );
+ void SetCenterPosition( const ::Oyster::Math::Float3 ¢erPos );
+ void SetRotation( const ::Oyster::Math::Float3 &angularAxis );
+ void SetRotation( const ::Oyster::Math::Float4x4 &rotation );
+
+ bool IsSpatiallyAltered() const;
+ bool IsDisturbed() const;
+
+ private:
+ ::Oyster::Math::Float4 reach, centerPos, angularAxis;
+
+ bool isSpatiallyAltered, isDisturbed;
+ };
+ }
+} }
+
+#include "PhysicsStructs-Impl.h"
+
+#endif
\ No newline at end of file
diff --git a/Code/OysterMath/LinearMath.h b/Code/OysterMath/LinearMath.h
index 0495939d..8bca1c19 100644
--- a/Code/OysterMath/LinearMath.h
+++ b/Code/OysterMath/LinearMath.h
@@ -11,6 +11,27 @@
#include "Quaternion.h"
#include
+namespace std
+{
+ template
+ inline ::LinearAlgebra::Vector2 asin( const ::LinearAlgebra::Vector2 &vec )
+ {
+ return ::LinearAlgebra::Vector2( asin(vec.x), asin(vec.y) );
+ }
+
+ template
+ inline ::LinearAlgebra::Vector3 asin( const ::LinearAlgebra::Vector3 &vec )
+ {
+ return ::LinearAlgebra::Vector3( asin(vec.x), asin(vec.y), asin(vec.z) );
+ }
+
+ template
+ inline ::LinearAlgebra::Vector4 asin( const ::LinearAlgebra::Vector4 &vec )
+ {
+ return ::LinearAlgebra::Vector4( asin(vec.x), asin(vec.y), asin(vec.z), asin(vec.w) );
+ }
+}
+
// x2
template
@@ -233,6 +254,18 @@ namespace LinearAlgebra2D
namespace LinearAlgebra3D
{
+ template
+ inline ::LinearAlgebra::Vector4 AngularAxis( const ::LinearAlgebra::Matrix3x3 &rotationMatrix )
+ {
+ return ::std::asin( ::LinearAlgebra::Vector4(rotationMatrix.v[1].z, rotationMatrix.v[2].x, rotationMatrix.v[0].y, 1) );
+ }
+
+ template
+ inline ::LinearAlgebra::Vector4 AngularAxis( const ::LinearAlgebra::Matrix4x4 &rotationMatrix )
+ {
+ return ::std::asin( ::LinearAlgebra::Vector4(rotationMatrix.v[1].z, rotationMatrix.v[2].x, rotationMatrix.v[0].y, 1) );
+ }
+
template
inline ::LinearAlgebra::Matrix4x4 & TranslationMatrix( const ::LinearAlgebra::Vector3 &position, ::LinearAlgebra::Matrix4x4 &targetMem = ::LinearAlgebra::Matrix4x4() )
{
@@ -286,7 +319,9 @@ namespace LinearAlgebra3D
template
inline ::LinearAlgebra::Matrix3x3 & RotationMatrix_AxisZ( const ScalarType &radian, ::LinearAlgebra::Matrix3x3 &targetMem = ::LinearAlgebra::Matrix3x3() )
- { return ::LinearAlgebra2D::RotationMatrix( radian, targetMem ); }
+ {
+ return ::LinearAlgebra2D::RotationMatrix( radian, targetMem );
+ }
template
inline ::LinearAlgebra::Matrix4x4 & RotationMatrix_AxisZ( const ScalarType &radian, ::LinearAlgebra::Matrix4x4 &targetMem = ::LinearAlgebra::Matrix4x4() )
@@ -300,7 +335,21 @@ namespace LinearAlgebra3D
}
template
- ::LinearAlgebra::Matrix4x4 & RotationMatrix( const ::LinearAlgebra::Vector3 &normalizedAxis, const ScalarType &radian, ::LinearAlgebra::Matrix4x4 &targetMem )
+ inline ::LinearAlgebra::Matrix4x4 RotationMatrix( const ::LinearAlgebra::Vector3 &angularAxis )
+ {
+ ScalarType radian = angularAxis.GetMagnitude();
+ if( radian != 0 )
+ {
+ return RotationMatrix( angularAxis / radian, radian );
+ }
+ else
+ {
+ return ::LinearAlgebra::Matrix4x4::identity;
+ }
+ }
+
+ template
+ ::LinearAlgebra::Matrix4x4 & RotationMatrix( const ::LinearAlgebra::Vector3 &normalizedAxis, const ScalarType &radian, ::LinearAlgebra::Matrix4x4 &targetMem = ::LinearAlgebra::Matrix4x4() )
{ /// TODO: not verified
ScalarType r = radian * 0.5f,
s = std::sin( r ),
@@ -462,7 +511,7 @@ namespace LinearAlgebra3D
::LinearAlgebra::Matrix4x4 & ProjectionMatrix_Perspective( const ScalarType &vertFoV, const ScalarType &aspect, const ScalarType &nearClip, const ScalarType &farClip, ::LinearAlgebra::Matrix4x4 &targetMem = ::LinearAlgebra::Matrix4x4() )
{
ScalarType fov = 1 / ::std::tan( vertFoV * 0.5f ),
- dDepth = farClip / (farClip - nearClip);
+ dDepth = farClip / (farClip - nearClip);
return targetMem = ::LinearAlgebra::Matrix4x4( fov / aspect, 0, 0, 0,
0, fov, 0, 0,
0, 0, dDepth, -(dDepth * nearClip),
@@ -473,7 +522,7 @@ namespace LinearAlgebra3D
::LinearAlgebra::Matrix4x4 & ProjectionMatrix_Perspective( const ScalarType &left, const ScalarType &right, const ScalarType &top, const ScalarType &bottom, const ScalarType &nearClip, const ScalarType &farClip, ::LinearAlgebra::Matrix4x4 &targetMem = ::LinearAlgebra::Matrix4x4() )
{ /** @todo TODO: not tested */
ScalarType fov = 1 / ::std::tan( vertFoV * 0.5f ),
- dDepth = farClip / (farClip - nearClip);
+ dDepth = farClip / (farClip - nearClip);
return targetMem = ::LinearAlgebra::Matrix4x4( 2*nearClip/(right - left), 0, -(right + left)/(right - left), 0,
0, 2*nearClip/(top - bottom), -(top + bottom)/(top - bottom), 0,
0, 0, dDepth, -(dDepth * nearClip),
diff --git a/Code/OysterMath/OysterMath.cpp b/Code/OysterMath/OysterMath.cpp
index 421ebc0b..cf9fa8ae 100644
--- a/Code/OysterMath/OysterMath.cpp
+++ b/Code/OysterMath/OysterMath.cpp
@@ -81,20 +81,45 @@ namespace Oyster { namespace Math2D
namespace Oyster { namespace Math3D
{
+ Float4 AngularAxis( const Float3x3 &rotationMatrix )
+ {
+ return ::LinearAlgebra3D::AngularAxis( rotationMatrix );
+ }
+
+ Float4 AngularAxis( const Float4x4 &rotationMatrix )
+ {
+ return ::LinearAlgebra3D::AngularAxis( rotationMatrix );
+ }
+
Float4x4 & TranslationMatrix( const Float3 &position, Float4x4 &targetMem )
- { return ::LinearAlgebra3D::TranslationMatrix( position, targetMem ); }
+ {
+ return ::LinearAlgebra3D::TranslationMatrix( position, targetMem );
+ }
Float4x4 & RotationMatrix_AxisX( const Float &radian, Float4x4 &targetMem )
- { return ::LinearAlgebra3D::RotationMatrix_AxisX( radian, targetMem ); }
+ {
+ return ::LinearAlgebra3D::RotationMatrix_AxisX( radian, targetMem );
+ }
Float4x4 & RotationMatrix_AxisY( const Float &radian, Float4x4 &targetMem )
- { return ::LinearAlgebra3D::RotationMatrix_AxisY( radian, targetMem ); }
+ {
+ return ::LinearAlgebra3D::RotationMatrix_AxisY( radian, targetMem );
+ }
Float4x4 & RotationMatrix_AxisZ( const Float &radian, Float4x4 &targetMem )
- { return ::LinearAlgebra3D::RotationMatrix_AxisZ( radian, targetMem ); }
+ {
+ return ::LinearAlgebra3D::RotationMatrix_AxisZ( radian, targetMem );
+ }
+
+ Float4x4 & RotationMatrix( const Float3 &angularAxis, Float4x4 &targetMem )
+ {
+ return targetMem = ::LinearAlgebra3D::RotationMatrix( angularAxis );
+ }
Float4x4 & RotationMatrix( const Float &radian, const Float3 &normalizedAxis, Float4x4 &targetMem )
- { return ::LinearAlgebra3D::RotationMatrix( normalizedAxis, radian, targetMem ); }
+ {
+ return ::LinearAlgebra3D::RotationMatrix( normalizedAxis, radian, targetMem );
+ }
Float3x3 & InverseRotationMatrix( const Float3x3 &rotation, Float3x3 &targetMem )
{
diff --git a/Code/OysterMath/OysterMath.h b/Code/OysterMath/OysterMath.h
index ab3b307f..72fe7478 100644
--- a/Code/OysterMath/OysterMath.h
+++ b/Code/OysterMath/OysterMath.h
@@ -147,6 +147,12 @@ namespace Oyster { namespace Math3D /// Oyster's native math library specialized
{
using namespace ::Oyster::Math; // deliberate inheritance from ::Oyster::Math namespace
+ //! Extracts the angularAxis from rotationMatrix
+ Float4 AngularAxis( const Float3x3 &rotationMatrix );
+
+ //! Extracts the angularAxis from rotationMatrix
+ Float4 AngularAxis( const Float4x4 &rotationMatrix );
+
/// Sets and returns targetMem to a translationMatrix with position as translation.
Float4x4 & TranslationMatrix( const Float3 &position, Float4x4 &targetMem = Float4x4() );
@@ -159,6 +165,9 @@ namespace Oyster { namespace Math3D /// Oyster's native math library specialized
/// Sets and returns targetMem as an counterclockwise rotation matrix around the global Z-axis
Float4x4 & RotationMatrix_AxisZ( const Float &radian, Float4x4 &targetMem = Float4x4() );
+ /// Sets and returns targetMem as an counterclockwise rotation matrix around the angularAxis.
+ Float4x4 & RotationMatrix( const Float3 &angularAxis, Float4x4 &targetMem = Float4x4() );
+
/// Sets and returns targetMem as an counterclockwise rotation matrix around the normalizedAxis.
/// Please make sure normalizedAxis is normalized.
Float4x4 & RotationMatrix( const Float &radian, const Float3 &normalizedAxis, Float4x4 &targetMem = Float4x4() );