parent
d5414d1443
commit
55879138c4
25
DanBias.sln
25
DanBias.sln
|
@ -25,7 +25,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetworkDependencies", "Netw
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameLogic", "GameLogic\GameLogic.vcxproj", "{B1195BB9-B3A5-47F0-906C-8DEA384D1520}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameLogic", "GameLogic\GameLogic.vcxproj", "{B1195BB9-B3A5-47F0-906C-8DEA384D1520}"
|
||||||
EndProject
|
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
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
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|Win32.Build.0 = Debug|Win32
|
||||||
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|x64.ActiveCfg = Debug|x64
|
{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.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.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.ActiveCfg = Release|Win32
|
||||||
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Win32.Build.0 = Release|Win32
|
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Win32.Build.0 = Release|Win32
|
||||||
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|x64.ActiveCfg = Release|Win32
|
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|x64.ActiveCfg = Release|Win32
|
||||||
{9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||||
{9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||||
{9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Debug|Win32.ActiveCfg = Debug|Win32
|
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Debug|Win32.Build.0 = Debug|Win32
|
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Debug|x64.ActiveCfg = Debug|x64
|
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Debug|x64.Build.0 = Debug|x64
|
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
||||||
{9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Mixed Platforms.Build.0 = Release|Win32
|
||||||
{9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Release|Mixed Platforms.Build.0 = Release|Win32
|
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Release|Win32.ActiveCfg = Release|Win32
|
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Win32.Build.0 = Release|Win32
|
||||||
{9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Release|Win32.Build.0 = Release|Win32
|
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|x64.ActiveCfg = Release|Win32
|
||||||
{9C60E0F4-9DD5-48FC-A5A4-F3B0CC92367B}.Release|x64.ActiveCfg = Release|Win32
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
@ -138,6 +138,9 @@
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\GamePhysics\GamePhysics.vcxproj">
|
||||||
|
<Project>{104fa3e9-94d9-4e1d-a941-28a03bc8a095}</Project>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
|
|
@ -144,6 +144,9 @@
|
||||||
<Project>{4285bd3f-3c6c-4670-b7af-a29afef5f6a8}</Project>
|
<Project>{4285bd3f-3c6c-4670-b7af-a29afef5f6a8}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Include\GamePhysics.h" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
|
|
@ -19,5 +19,13 @@
|
||||||
<Filter Include="Source Files\Implementation">
|
<Filter Include="Source Files\Implementation">
|
||||||
<UniqueIdentifier>{cac9a78f-f09b-4850-b1aa-ea87e8368678}</UniqueIdentifier>
|
<UniqueIdentifier>{cac9a78f-f09b-4850-b1aa-ea87e8368678}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="Header Files\Include">
|
||||||
|
<UniqueIdentifier>{792daa4b-b2f7-4664-9529-71a929365274}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Include\GamePhysics.h">
|
||||||
|
<Filter>Header Files\Include</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -298,7 +298,7 @@ namespace LinearAlgebra3D
|
||||||
if( radian > 0 )
|
if( radian > 0 )
|
||||||
{
|
{
|
||||||
radian = ::std::sqrt( radian );
|
radian = ::std::sqrt( radian );
|
||||||
return OrientationMatrix( sumDeltaAngularAxis / radian, radian, targetMem );
|
return OrientationMatrix( sumDeltaAngularAxis / radian, radian, sumTranslation, targetMem );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -353,13 +353,16 @@ namespace LinearAlgebra3D
|
||||||
0, nearClip*c, 1 );
|
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+ )
|
* Creates a perspective projection matrix designed for DirectX enviroment.
|
||||||
aspect; is the screenratio width/height (example 16/9 or 16/10 )
|
* @param vertFoV; is the vertical field of vision in radians. (lookup FoV Hor+ )
|
||||||
nearClip: Distance to the nearClippingPlane
|
* @param aspect; is the screenratio width/height (example 16/9 or 16/10 )
|
||||||
farClip: Distance to the farClippingPlane
|
* @param nearClip: Distance to the nearClippingPlane
|
||||||
targetMem; is set to a perspective transform matrix and then returned.
|
* @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<typename ScalarType>
|
template<typename ScalarType>
|
||||||
::LinearAlgebra::Matrix4x4<ScalarType> & ProjectionMatrix_Perspective( const ScalarType &vertFoV, const ScalarType &aspect, const ScalarType &nearClip, const ScalarType &farClip, ::LinearAlgebra::Matrix4x4<ScalarType> &targetMem = ::LinearAlgebra::Matrix4x4<ScalarType>() )
|
::LinearAlgebra::Matrix4x4<ScalarType> & ProjectionMatrix_Perspective( const ScalarType &vertFoV, const ScalarType &aspect, const ScalarType &nearClip, const ScalarType &farClip, ::LinearAlgebra::Matrix4x4<ScalarType> &targetMem = ::LinearAlgebra::Matrix4x4<ScalarType>() )
|
||||||
{ /** @todo TODO: not tested */
|
{ /** @todo TODO: not tested */
|
||||||
|
|
|
@ -82,5 +82,7 @@ namespace Oyster { namespace Math3D
|
||||||
{ return ::LinearAlgebra3D::ProjectionMatrix_Perspective( verticalFoV, aspectRatio, nearClip, farClip, targetMem ); }
|
{ return ::LinearAlgebra3D::ProjectionMatrix_Perspective( verticalFoV, aspectRatio, nearClip, farClip, targetMem ); }
|
||||||
|
|
||||||
Float3 VectorProjection( const Float3 &vector, const Float3 &axis )
|
Float3 VectorProjection( const Float3 &vector, const Float3 &axis )
|
||||||
{ return ::LinearAlgebra3D::VectorProjection( vector, axis ); }
|
{
|
||||||
|
return ::LinearAlgebra3D::VectorProjection( vector, axis );
|
||||||
|
}
|
||||||
} }
|
} }
|
|
@ -179,7 +179,7 @@ namespace LinearAlgebra
|
||||||
|
|
||||||
// Vector2<ScalarType> ///////////////////////////////////////
|
// Vector2<ScalarType> ///////////////////////////////////////
|
||||||
|
|
||||||
template<typename ScalarType> const Vector2<ScalarType> Vector2<ScalarType>::null = Vector2<ScalarType>( );
|
template<typename ScalarType> const Vector2<ScalarType> Vector2<ScalarType>::null = Vector2<ScalarType>( 0, 0 );
|
||||||
template<typename ScalarType> const Vector2<ScalarType> Vector2<ScalarType>::standard_unit_x = Vector2<ScalarType>( 1, 0 );
|
template<typename ScalarType> const Vector2<ScalarType> Vector2<ScalarType>::standard_unit_x = Vector2<ScalarType>( 1, 0 );
|
||||||
template<typename ScalarType> const Vector2<ScalarType> Vector2<ScalarType>::standard_unit_y = Vector2<ScalarType>( 0, 1 );
|
template<typename ScalarType> const Vector2<ScalarType> Vector2<ScalarType>::standard_unit_y = Vector2<ScalarType>( 0, 1 );
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ namespace LinearAlgebra
|
||||||
|
|
||||||
// Vector3<ScalarType> ///////////////////////////////////////
|
// Vector3<ScalarType> ///////////////////////////////////////
|
||||||
|
|
||||||
template<typename ScalarType> const Vector3<ScalarType> Vector3<ScalarType>::null = Vector3<ScalarType>( );
|
template<typename ScalarType> const Vector3<ScalarType> Vector3<ScalarType>::null = Vector3<ScalarType>( 0, 0, 0 );
|
||||||
template<typename ScalarType> const Vector3<ScalarType> Vector3<ScalarType>::standard_unit_x = Vector3<ScalarType>( 1, 0, 0 );
|
template<typename ScalarType> const Vector3<ScalarType> Vector3<ScalarType>::standard_unit_x = Vector3<ScalarType>( 1, 0, 0 );
|
||||||
template<typename ScalarType> const Vector3<ScalarType> Vector3<ScalarType>::standard_unit_y = Vector3<ScalarType>( 0, 1, 0 );
|
template<typename ScalarType> const Vector3<ScalarType> Vector3<ScalarType>::standard_unit_y = Vector3<ScalarType>( 0, 1, 0 );
|
||||||
template<typename ScalarType> const Vector3<ScalarType> Vector3<ScalarType>::standard_unit_z = Vector3<ScalarType>( 0, 0, 1 );
|
template<typename ScalarType> const Vector3<ScalarType> Vector3<ScalarType>::standard_unit_z = Vector3<ScalarType>( 0, 0, 1 );
|
||||||
|
@ -509,7 +509,7 @@ namespace LinearAlgebra
|
||||||
|
|
||||||
// Vector4<ScalarType> ///////////////////////////////////////
|
// Vector4<ScalarType> ///////////////////////////////////////
|
||||||
|
|
||||||
template<typename ScalarType> const Vector4<ScalarType> Vector4<ScalarType>::null = Vector4<ScalarType>( );
|
template<typename ScalarType> const Vector4<ScalarType> Vector4<ScalarType>::null = Vector4<ScalarType>( 0, 0, 0, 0 );
|
||||||
template<typename ScalarType> const Vector4<ScalarType> Vector4<ScalarType>::standard_unit_x = Vector4<ScalarType>( 1, 0, 0, 0 );
|
template<typename ScalarType> const Vector4<ScalarType> Vector4<ScalarType>::standard_unit_x = Vector4<ScalarType>( 1, 0, 0, 0 );
|
||||||
template<typename ScalarType> const Vector4<ScalarType> Vector4<ScalarType>::standard_unit_y = Vector4<ScalarType>( 0, 1, 0, 0 );
|
template<typename ScalarType> const Vector4<ScalarType> Vector4<ScalarType>::standard_unit_y = Vector4<ScalarType>( 0, 1, 0, 0 );
|
||||||
template<typename ScalarType> const Vector4<ScalarType> Vector4<ScalarType>::standard_unit_z = Vector4<ScalarType>( 0, 0, 1, 0 );
|
template<typename ScalarType> const Vector4<ScalarType> Vector4<ScalarType>::standard_unit_z = Vector4<ScalarType>( 0, 0, 1, 0 );
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "Box.h"
|
#include "Box.h"
|
||||||
#include "..\OysterCollision3D.h"
|
#include "OysterCollision3D.h"
|
||||||
|
|
||||||
using namespace ::Oyster::Collision3D;
|
using namespace ::Oyster::Collision3D;
|
||||||
using namespace ::Oyster::Math3D;
|
using namespace ::Oyster::Math3D;
|
|
@ -3,7 +3,7 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "BoxAxisAligned.h"
|
#include "BoxAxisAligned.h"
|
||||||
#include "..\OysterCollision3D.h"
|
#include "OysterCollision3D.h"
|
||||||
|
|
||||||
using namespace ::Oyster::Collision3D;
|
using namespace ::Oyster::Collision3D;
|
||||||
using namespace ::Oyster::Math3D;
|
using namespace ::Oyster::Math3D;
|
|
@ -6,7 +6,7 @@
|
||||||
#define OYSTER_PHYSICS_3D_FLUID_DRAG_H
|
#define OYSTER_PHYSICS_3D_FLUID_DRAG_H
|
||||||
|
|
||||||
#include "OysterMath.h"
|
#include "OysterMath.h"
|
||||||
#include "..\OysterPhysics3D.h"
|
#include "OysterPhysics3D.h"
|
||||||
|
|
||||||
namespace Oyster { namespace Physics3D
|
namespace Oyster { namespace Physics3D
|
||||||
{
|
{
|
|
@ -3,7 +3,7 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "Frustrum.h"
|
#include "Frustrum.h"
|
||||||
#include "..\OysterCollision3D.h"
|
#include "OysterCollision3D.h"
|
||||||
|
|
||||||
using namespace Oyster::Math;
|
using namespace Oyster::Math;
|
||||||
using namespace Oyster::Collision3D;
|
using namespace Oyster::Collision3D;
|
|
@ -3,7 +3,7 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "Line.h"
|
#include "Line.h"
|
||||||
#include "..\OysterCollision3D.h"
|
#include "OysterCollision3D.h"
|
||||||
|
|
||||||
using namespace ::Oyster::Collision3D;
|
using namespace ::Oyster::Collision3D;
|
||||||
using namespace ::Oyster::Math3D;
|
using namespace ::Oyster::Math3D;
|
|
@ -2,7 +2,7 @@
|
||||||
// Created by Dan Andersson 2013
|
// Created by Dan Andersson 2013
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "..\OysterCollision3D.h"
|
#include "OysterCollision3D.h"
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
|
@ -6,17 +6,17 @@
|
||||||
#ifndef OYSTER_COLLISION_3D_UTILITY_H
|
#ifndef OYSTER_COLLISION_3D_UTILITY_H
|
||||||
#define OYSTER_COLLISION_3D_UTILITY_H
|
#define OYSTER_COLLISION_3D_UTILITY_H
|
||||||
|
|
||||||
#include "Collision\ICollideable.h"
|
#include "ICollideable.h"
|
||||||
#include "Collision\Universe.h"
|
#include "Universe.h"
|
||||||
#include "Collision\Point.h"
|
#include "Point.h"
|
||||||
#include "Collision\Ray.h"
|
#include "Ray.h"
|
||||||
#include "Collision\Sphere.h"
|
#include "Sphere.h"
|
||||||
#include "Collision\Plane.h"
|
#include "Plane.h"
|
||||||
//#include "Collision\Triangle.h"
|
//#include "Triangle.h"
|
||||||
#include "Collision\BoxAxisAligned.h"
|
#include "BoxAxisAligned.h"
|
||||||
#include "Collision\Box.h"
|
#include "Box.h"
|
||||||
#include "Collision\Frustrum.h"
|
#include "Frustrum.h"
|
||||||
#include "Collision\Line.h"
|
#include "Line.h"
|
||||||
|
|
||||||
namespace Oyster { namespace Collision3D { namespace Utility
|
namespace Oyster { namespace Collision3D { namespace Utility
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,81 +17,166 @@ namespace Oyster { namespace Physics3D
|
||||||
* @todo TODO: improve doc
|
* @todo TODO: improve doc
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
inline ::Oyster::Math::Float LinearKineticEnergy( const ::Oyster::Math::Float &mass, const ::Oyster::Math::Float3 &linearVelocity )
|
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.
|
* Returns the angular kinetic energy of a mass in rotation.
|
||||||
* @todo TODO: improve doc
|
* @todo TODO: improve doc
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
inline ::Oyster::Math::Float AngularKineticEnergy( const ::Oyster::Math::Float &momentOfInertia, const ::Oyster::Math::Float3 &angularVelocity )
|
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.
|
* Returns the linear momentum of a mass in motion.
|
||||||
* @todo TODO: improve doc
|
* @todo TODO: improve doc
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
inline ::Oyster::Math::Float3 LinearMomentum( const ::Oyster::Math::Float &mass, const ::Oyster::Math::Float3 &linearVelocity )
|
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.
|
* Returns the linear velocity of a mass with momentum.
|
||||||
* @todo TODO: improve doc
|
* @todo TODO: improve doc
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
inline ::Oyster::Math::Float3 LinearVelocity( const ::Oyster::Math::Float &mass, const ::Oyster::Math::Float3 &linearMomentum )
|
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.
|
* Returns the local angular momentum of a mass in rotation.
|
||||||
* @todo TODO: improve doc
|
* @todo TODO: improve doc
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
inline ::Oyster::Math::Float3 AngularMomentum( const ::Oyster::Math::Float &momentOfInertia, const ::Oyster::Math::Float3 &angularVelocity )
|
inline ::Oyster::Math::Float3 AngularMomentum( const ::Oyster::Math::Float4x4 &momentOfInertia, const ::Oyster::Math::Float3 &angularVelocity )
|
||||||
{ return momentOfInertia * angularVelocity; }
|
{
|
||||||
|
return ( momentOfInertia * ::Oyster::Math::Float4(angularVelocity, 0.0f) ).xyz;
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* Returns the local tangential momentum at localPos, of a mass in rotation.
|
* Returns the local tangential momentum at localPos, of a mass in rotation.
|
||||||
* @todo TODO: improve doc
|
* @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() )
|
inline ::Oyster::Math::Float3 TangentialLinearMomentum( const ::Oyster::Math::Float3 &angularMomentum, const ::Oyster::Math::Float3 &localOffset )
|
||||||
{ return targetMem = localAngularMomentum * ::Oyster::Math::Float3( -localPosition.y, localPosition.x ); }
|
{
|
||||||
|
return angularMomentum.Cross( localOffset );
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* Returns the local tangential momentum at localPos, of a mass in rotation.
|
* Returns the local tangential momentum at localPos, of a mass in rotation.
|
||||||
* @todo TODO: improve doc
|
* @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() )
|
inline ::Oyster::Math::Float3 TangentialLinearMomentum( const ::Oyster::Math::Float4x4 &momentOfInertia, const ::Oyster::Math::Float3 &angularVelocity, const ::Oyster::Math::Float3 &localOffset )
|
||||||
{ return targetMem = AngularMomentum( momentOfInertia, angularVelocity ).Cross( localPosition ); }
|
{
|
||||||
|
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.
|
* Returns the local angular velocity of a mass in rotation.
|
||||||
* @todo TODO: improve doc
|
* @todo TODO: improve doc
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
inline ::Oyster::Math::Float3 AngularVelocity( const ::Oyster::Math::Float &momentOfInertia, const ::Oyster::Math::Float3 &angularMomentum )
|
inline ::Oyster::Math::Float3 AngularVelocity( const ::Oyster::Math::Float4x4 &momentOfInertiaInversed, const ::Oyster::Math::Float3 &angularMomentum )
|
||||||
{ return angularMomentum / momentOfInertia; }
|
{
|
||||||
|
return ( momentOfInertiaInversed * ::Oyster::Math::Float4( angularMomentum, 0.0f ) ).xyz;
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* Returns the local tangential velocity at localPos, of a mass in rotation.
|
* Returns the local tangential velocity at localPos, of a mass in rotation.
|
||||||
* @todo TODO: improve doc
|
* @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() )
|
inline ::Oyster::Math::Float3 TangentialLinearVelocity( const ::Oyster::Math::Float3 &angularVelocity, const ::Oyster::Math::Float3 &offset )
|
||||||
{ return targetMem = angularVelocity.Cross( localPosition ); }
|
{
|
||||||
|
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
|
* @todo TODO: improve doc
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
inline ::Oyster::Math::Float3 LinearImpulseAcceleration( ::Oyster::Math::Float mass, const ::Oyster::Math::Float3 &impulseForce )
|
inline ::Oyster::Math::Float3 LinearImpulseAcceleration( ::Oyster::Math::Float mass, const ::Oyster::Math::Float3 &impulseForce )
|
||||||
{ return impulseForce / mass; }
|
{
|
||||||
|
return impulseForce / mass;
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
*
|
*
|
||||||
* @todo TODO: improve doc
|
* @todo TODO: improve doc
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
inline ::Oyster::Math::Float3 ImpulseForce( ::Oyster::Math::Float mass, const ::Oyster::Math::Float3 &linearImpulseAcceleration )
|
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
|
namespace MomentOfInertia
|
||||||
{ /// Library of Formulas to calculate moment of inerta for simple shapes
|
{ /// Library of Formulas to calculate moment of inerta for simple shapes
|
||||||
/** @todo TODO: add MomentOfInertia formulas */
|
/** @todo TODO: add MomentOfInertia tensor formulas */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} }
|
} }
|
||||||
|
|
|
@ -137,41 +137,6 @@
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="Collision\Box.cpp" />
|
|
||||||
<ClCompile Include="Collision\BoxAxisAligned.cpp" />
|
|
||||||
<ClCompile Include="Collision\ICollideable.cpp" />
|
|
||||||
<ClCompile Include="Collision\OysterCollision3D.cpp" />
|
|
||||||
<ClCompile Include="Collision\Frustrum.cpp" />
|
|
||||||
<ClCompile Include="Collision\Line.cpp" />
|
|
||||||
<ClCompile Include="Collision\Plane.cpp" />
|
|
||||||
<ClCompile Include="Collision\Point.cpp" />
|
|
||||||
<ClCompile Include="Collision\Ray.cpp" />
|
|
||||||
<ClCompile Include="Collision\Sphere.cpp" />
|
|
||||||
<ClCompile Include="Collision\Universe.cpp" />
|
|
||||||
<ClCompile Include="Physics\FluidDrag.cpp" />
|
|
||||||
<ClCompile Include="Physics\Particle.cpp" />
|
|
||||||
<ClCompile Include="Physics\RigidBody.cpp" />
|
|
||||||
<ClCompile Include="Physics\Spring.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="Collision\Box.h" />
|
|
||||||
<ClInclude Include="Collision\BoxAxisAligned.h" />
|
|
||||||
<ClInclude Include="Collision\Frustrum.h" />
|
|
||||||
<ClInclude Include="Collision\ICollideable.h" />
|
|
||||||
<ClInclude Include="Collision\Line.h" />
|
|
||||||
<ClInclude Include="Collision\Plane.h" />
|
|
||||||
<ClInclude Include="Collision\Point.h" />
|
|
||||||
<ClInclude Include="Collision\Ray.h" />
|
|
||||||
<ClInclude Include="Collision\Sphere.h" />
|
|
||||||
<ClInclude Include="Collision\Universe.h" />
|
|
||||||
<ClInclude Include="OysterCollision3D.h" />
|
|
||||||
<ClInclude Include="OysterPhysics3D.h" />
|
|
||||||
<ClInclude Include="Physics\FluidDrag.h" />
|
|
||||||
<ClInclude Include="Physics\Particle.h" />
|
|
||||||
<ClInclude Include="Physics\RigidBody.h" />
|
|
||||||
<ClInclude Include="Physics\Spring.h" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Misc\Misc.vcxproj">
|
<ProjectReference Include="..\Misc\Misc.vcxproj">
|
||||||
<Project>{2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee}</Project>
|
<Project>{2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee}</Project>
|
||||||
|
@ -180,6 +145,41 @@
|
||||||
<Project>{f10cbc03-9809-4cba-95d8-327c287b18ee}</Project>
|
<Project>{f10cbc03-9809-4cba-95d8-327c287b18ee}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Box.h" />
|
||||||
|
<ClInclude Include="BoxAxisAligned.h" />
|
||||||
|
<ClInclude Include="FluidDrag.h" />
|
||||||
|
<ClInclude Include="Frustrum.h" />
|
||||||
|
<ClInclude Include="ICollideable.h" />
|
||||||
|
<ClInclude Include="Line.h" />
|
||||||
|
<ClInclude Include="OysterCollision3D.h" />
|
||||||
|
<ClInclude Include="OysterPhysics3D.h" />
|
||||||
|
<ClInclude Include="Particle.h" />
|
||||||
|
<ClInclude Include="Plane.h" />
|
||||||
|
<ClInclude Include="Point.h" />
|
||||||
|
<ClInclude Include="Ray.h" />
|
||||||
|
<ClInclude Include="RigidBody.h" />
|
||||||
|
<ClInclude Include="Sphere.h" />
|
||||||
|
<ClInclude Include="Spring.h" />
|
||||||
|
<ClInclude Include="Universe.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Box.cpp" />
|
||||||
|
<ClCompile Include="BoxAxisAligned.cpp" />
|
||||||
|
<ClCompile Include="FluidDrag.cpp" />
|
||||||
|
<ClCompile Include="Frustrum.cpp" />
|
||||||
|
<ClCompile Include="ICollideable.cpp" />
|
||||||
|
<ClCompile Include="Line.cpp" />
|
||||||
|
<ClCompile Include="OysterCollision3D.cpp" />
|
||||||
|
<ClCompile Include="Particle.cpp" />
|
||||||
|
<ClCompile Include="Plane.cpp" />
|
||||||
|
<ClCompile Include="Point.cpp" />
|
||||||
|
<ClCompile Include="Ray.cpp" />
|
||||||
|
<ClCompile Include="RigidBody.cpp" />
|
||||||
|
<ClCompile Include="Sphere.cpp" />
|
||||||
|
<ClCompile Include="Spring.cpp" />
|
||||||
|
<ClCompile Include="Universe.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
|
|
@ -27,100 +27,100 @@
|
||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Collision\Box.cpp">
|
<ClInclude Include="Universe.h">
|
||||||
<Filter>Source Files\Collision</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Collision\BoxAxisAligned.cpp">
|
|
||||||
<Filter>Source Files\Collision</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Collision\Frustrum.cpp">
|
|
||||||
<Filter>Source Files\Collision</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Collision\Line.cpp">
|
|
||||||
<Filter>Source Files\Collision</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Collision\Plane.cpp">
|
|
||||||
<Filter>Source Files\Collision</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Collision\Point.cpp">
|
|
||||||
<Filter>Source Files\Collision</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Collision\Ray.cpp">
|
|
||||||
<Filter>Source Files\Collision</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Collision\Sphere.cpp">
|
|
||||||
<Filter>Source Files\Collision</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Collision\Universe.cpp">
|
|
||||||
<Filter>Source Files\Collision</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Collision\OysterCollision3D.cpp">
|
|
||||||
<Filter>Source Files\Collision</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Physics\FluidDrag.cpp">
|
|
||||||
<Filter>Source Files\Physics</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Physics\Particle.cpp">
|
|
||||||
<Filter>Source Files\Physics</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Physics\RigidBody.cpp">
|
|
||||||
<Filter>Source Files\Physics</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Physics\Spring.cpp">
|
|
||||||
<Filter>Source Files\Physics</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Collision\ICollideable.cpp">
|
|
||||||
<Filter>Source Files\Collision</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="Collision\Box.h">
|
|
||||||
<Filter>Header Files\Collision</Filter>
|
<Filter>Header Files\Collision</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Collision\BoxAxisAligned.h">
|
<ClInclude Include="Box.h">
|
||||||
<Filter>Header Files\Collision</Filter>
|
<Filter>Header Files\Collision</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Collision\Frustrum.h">
|
<ClInclude Include="BoxAxisAligned.h">
|
||||||
<Filter>Header Files\Collision</Filter>
|
<Filter>Header Files\Collision</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Collision\ICollideable.h">
|
<ClInclude Include="Frustrum.h">
|
||||||
<Filter>Header Files\Collision</Filter>
|
<Filter>Header Files\Collision</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Collision\Line.h">
|
<ClInclude Include="ICollideable.h">
|
||||||
<Filter>Header Files\Collision</Filter>
|
<Filter>Header Files\Collision</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Collision\Plane.h">
|
<ClInclude Include="Line.h">
|
||||||
<Filter>Header Files\Collision</Filter>
|
<Filter>Header Files\Collision</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Collision\Point.h">
|
|
||||||
<Filter>Header Files\Collision</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Collision\Ray.h">
|
|
||||||
<Filter>Header Files\Collision</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Collision\Sphere.h">
|
|
||||||
<Filter>Header Files\Collision</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Collision\Universe.h">
|
|
||||||
<Filter>Header Files\Collision</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Physics\FluidDrag.h">
|
|
||||||
<Filter>Header Files\Physics</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Physics\Particle.h">
|
|
||||||
<Filter>Header Files\Physics</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Physics\RigidBody.h">
|
|
||||||
<Filter>Header Files\Physics</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Physics\Spring.h">
|
|
||||||
<Filter>Header Files\Physics</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="OysterCollision3D.h">
|
<ClInclude Include="OysterCollision3D.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files\Collision</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Plane.h">
|
||||||
|
<Filter>Header Files\Collision</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Point.h">
|
||||||
|
<Filter>Header Files\Collision</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Ray.h">
|
||||||
|
<Filter>Header Files\Collision</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Sphere.h">
|
||||||
|
<Filter>Header Files\Collision</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Spring.h">
|
||||||
|
<Filter>Header Files\Physics</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="FluidDrag.h">
|
||||||
|
<Filter>Header Files\Physics</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="OysterPhysics3D.h">
|
<ClInclude Include="OysterPhysics3D.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files\Physics</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Particle.h">
|
||||||
|
<Filter>Header Files\Physics</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="RigidBody.h">
|
||||||
|
<Filter>Header Files\Physics</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Box.cpp">
|
||||||
|
<Filter>Source Files\Collision</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="BoxAxisAligned.cpp">
|
||||||
|
<Filter>Source Files\Collision</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Frustrum.cpp">
|
||||||
|
<Filter>Source Files\Collision</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ICollideable.cpp">
|
||||||
|
<Filter>Source Files\Collision</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Line.cpp">
|
||||||
|
<Filter>Source Files\Collision</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="OysterCollision3D.cpp">
|
||||||
|
<Filter>Source Files\Collision</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Plane.cpp">
|
||||||
|
<Filter>Source Files\Collision</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Point.cpp">
|
||||||
|
<Filter>Source Files\Collision</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Ray.cpp">
|
||||||
|
<Filter>Source Files\Collision</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Sphere.cpp">
|
||||||
|
<Filter>Source Files\Collision</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Universe.cpp">
|
||||||
|
<Filter>Source Files\Collision</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="FluidDrag.cpp">
|
||||||
|
<Filter>Source Files\Physics</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Spring.cpp">
|
||||||
|
<Filter>Source Files\Physics</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="RigidBody.cpp">
|
||||||
|
<Filter>Source Files\Physics</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Particle.cpp">
|
||||||
|
<Filter>Source Files\Physics</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -6,8 +6,8 @@
|
||||||
#define OYSTER_PHYSICS_3D_PARTICLE_H
|
#define OYSTER_PHYSICS_3D_PARTICLE_H
|
||||||
|
|
||||||
#include "OysterMath.h"
|
#include "OysterMath.h"
|
||||||
#include "..\OysterCollision3D.h"
|
#include "OysterCollision3D.h"
|
||||||
#include "..\OysterPhysics3D.h"
|
#include "OysterPhysics3D.h"
|
||||||
|
|
||||||
namespace Oyster { namespace Physics3D
|
namespace Oyster { namespace Physics3D
|
||||||
{
|
{
|
|
@ -3,7 +3,7 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "Plane.h"
|
#include "Plane.h"
|
||||||
#include "..\OysterCollision3D.h"
|
#include "OysterCollision3D.h"
|
||||||
|
|
||||||
using namespace ::Oyster::Collision3D;
|
using namespace ::Oyster::Collision3D;
|
||||||
using namespace ::Oyster::Math;
|
using namespace ::Oyster::Math;
|
|
@ -3,7 +3,7 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "Point.h"
|
#include "Point.h"
|
||||||
#include "..\OysterCollision3D.h"
|
#include "OysterCollision3D.h"
|
||||||
|
|
||||||
using namespace ::Oyster::Collision3D;
|
using namespace ::Oyster::Collision3D;
|
||||||
using namespace ::Oyster::Math3D;
|
using namespace ::Oyster::Math3D;
|
|
@ -3,7 +3,7 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "Ray.h"
|
#include "Ray.h"
|
||||||
#include "..\OysterCollision3D.h"
|
#include "OysterCollision3D.h"
|
||||||
|
|
||||||
using namespace ::Oyster::Collision3D;
|
using namespace ::Oyster::Collision3D;
|
||||||
using namespace ::Oyster::Math3D;
|
using namespace ::Oyster::Math3D;
|
|
@ -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<Float>::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
|
||||||
|
|
||||||
|
}
|
|
@ -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
|
|
@ -1,5 +1,5 @@
|
||||||
#include "Sphere.h"
|
#include "Sphere.h"
|
||||||
#include "..\OysterCollision3D.h"
|
#include "OysterCollision3D.h"
|
||||||
|
|
||||||
using namespace ::Oyster::Collision3D;
|
using namespace ::Oyster::Collision3D;
|
||||||
using namespace ::Oyster::Math;
|
using namespace ::Oyster::Math;
|
|
@ -1,5 +1,5 @@
|
||||||
#include "Universe.h"
|
#include "Universe.h"
|
||||||
#include "..\OysterCollision3D.h"
|
#include "OysterCollision3D.h"
|
||||||
|
|
||||||
using namespace ::Oyster::Collision3D;
|
using namespace ::Oyster::Collision3D;
|
||||||
using namespace ::Utility::Memory;
|
using namespace ::Utility::Memory;
|
Loading…
Reference in New Issue