2013-12-06 09:46:30 +01:00
|
|
|
#ifndef PHYSICS_STRUCTS_H
|
|
|
|
#define PHYSICS_STRUCTS_H
|
|
|
|
|
|
|
|
#include "OysterMath.h"
|
|
|
|
#include "PhysicsAPI.h"
|
2014-01-23 19:13:02 +01:00
|
|
|
#include "Inertia.h"
|
2013-12-06 09:46:30 +01:00
|
|
|
|
|
|
|
namespace Oyster { namespace Physics
|
|
|
|
{
|
|
|
|
namespace Struct
|
|
|
|
{
|
|
|
|
struct SimpleBodyDescription
|
|
|
|
{
|
2014-02-03 15:48:42 +01:00
|
|
|
::Oyster::Math::Float3 rotation;
|
2014-01-28 09:52:58 +01:00
|
|
|
::Oyster::Math::Float3 centerPosition;
|
|
|
|
::Oyster::Math::Float3 size;
|
2013-12-06 09:46:30 +01:00
|
|
|
::Oyster::Math::Float mass;
|
2014-01-21 11:48:04 +01:00
|
|
|
::Oyster::Math::Float restitutionCoeff;
|
|
|
|
::Oyster::Math::Float frictionCoeff_Static;
|
|
|
|
::Oyster::Math::Float frictionCoeff_Dynamic;
|
2014-01-23 19:13:02 +01:00
|
|
|
::Oyster::Physics3D::MomentOfInertia inertiaTensor;
|
2014-01-29 11:22:04 +01:00
|
|
|
::Oyster::Physics::ICustomBody::EventAction_BeforeCollisionResponse subscription_onCollision;
|
|
|
|
::Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse subscription_onCollisionResponse;
|
2014-01-17 16:07:25 +01:00
|
|
|
::Oyster::Physics::ICustomBody::EventAction_Move subscription_onMovement;
|
2013-12-06 09:46:30 +01:00
|
|
|
bool ignoreGravity;
|
|
|
|
|
|
|
|
SimpleBodyDescription();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SphericalBodyDescription
|
|
|
|
{
|
2014-02-03 15:48:42 +01:00
|
|
|
::Oyster::Math::Float3 rotation;
|
2014-01-28 09:52:58 +01:00
|
|
|
::Oyster::Math::Float3 centerPosition;
|
2013-12-06 09:46:30 +01:00
|
|
|
::Oyster::Math::Float radius;
|
|
|
|
::Oyster::Math::Float mass;
|
2014-01-21 11:48:04 +01:00
|
|
|
::Oyster::Math::Float restitutionCoeff;
|
|
|
|
::Oyster::Math::Float frictionCoeff_Static;
|
|
|
|
::Oyster::Math::Float frictionCoeff_Dynamic;
|
2014-01-29 11:22:04 +01:00
|
|
|
::Oyster::Physics::ICustomBody::EventAction_BeforeCollisionResponse subscription_onCollision;
|
|
|
|
::Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse subscription_onCollisionResponse;
|
2014-01-17 16:07:25 +01:00
|
|
|
::Oyster::Physics::ICustomBody::EventAction_Move subscription_onMovement;
|
2013-12-06 09:46:30 +01:00
|
|
|
bool ignoreGravity;
|
|
|
|
|
|
|
|
SphericalBodyDescription();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CustomBodyState
|
|
|
|
{
|
|
|
|
public:
|
2013-12-18 14:16:13 +01:00
|
|
|
CustomBodyState( ::Oyster::Math::Float mass = 1.0f,
|
|
|
|
::Oyster::Math::Float restitutionCoeff = 1.0f,
|
2013-12-19 10:03:56 +01:00
|
|
|
::Oyster::Math::Float staticFrictionCoeff = 1.0f,
|
|
|
|
::Oyster::Math::Float kineticFrictionCoeff = 1.0f,
|
2014-01-23 19:13:02 +01:00
|
|
|
const ::Oyster::Physics3D::MomentOfInertia &inertiaTensor = ::Oyster::Physics3D::MomentOfInertia(),
|
2014-01-28 09:52:58 +01:00
|
|
|
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,
|
|
|
|
const ::Oyster::Math::Float3 &linearMomentum = ::Oyster::Math::Float3::null,
|
|
|
|
const ::Oyster::Math::Float3 &angularMomentum = ::Oyster::Math::Float3::null,
|
|
|
|
const ::Oyster::Math::Float3 &gravityNormal = ::Oyster::Math::Float3::null);
|
2013-12-06 09:46:30 +01:00
|
|
|
|
|
|
|
CustomBodyState & operator = ( const CustomBodyState &state );
|
|
|
|
|
2013-12-18 14:16:13 +01:00
|
|
|
const ::Oyster::Math::Float GetMass() const;
|
|
|
|
const ::Oyster::Math::Float GetRestitutionCoeff() const;
|
2013-12-19 10:03:56 +01:00
|
|
|
const ::Oyster::Math::Float GetFrictionCoeff_Static() const;
|
|
|
|
const ::Oyster::Math::Float GetFrictionCoeff_Kinetic() const;
|
2014-01-23 19:13:02 +01:00
|
|
|
const ::Oyster::Physics3D::MomentOfInertia & GetMomentOfInertia() const;
|
2014-01-28 09:52:58 +01:00
|
|
|
const ::Oyster::Math::Float3 & GetReach() const;
|
|
|
|
::Oyster::Math::Float3 GetSize() const;
|
|
|
|
const ::Oyster::Math::Float3 & GetCenterPosition() const;
|
|
|
|
const ::Oyster::Math::Float3 & GetAngularAxis() const;
|
2013-12-18 14:16:13 +01:00
|
|
|
::Oyster::Math::Float4x4 GetRotation() const;
|
|
|
|
::Oyster::Math::Float4x4 GetOrientation() const;
|
2014-01-28 09:52:58 +01:00
|
|
|
::Oyster::Math::Float4x4 GetOrientation( const ::Oyster::Math::Float3 &offset ) const;
|
2013-12-18 14:16:13 +01:00
|
|
|
::Oyster::Math::Float4x4 GetView() const;
|
2014-01-28 09:52:58 +01:00
|
|
|
::Oyster::Math::Float4x4 GetView( const ::Oyster::Math::Float3 &offset ) const;
|
|
|
|
const ::Oyster::Math::Float3 & GetLinearMomentum() const;
|
|
|
|
::Oyster::Math::Float3 GetLinearMomentum( const ::Oyster::Math::Float3 &at ) const;
|
|
|
|
const ::Oyster::Math::Float3 & GetAngularMomentum() const;
|
|
|
|
const ::Oyster::Math::Float3 & GetLinearImpulse() const;
|
|
|
|
const ::Oyster::Math::Float3 & GetAngularImpulse() const;
|
|
|
|
const ::Oyster::Math::Float3 & GetForward_DeltaPos() const;
|
|
|
|
const ::Oyster::Math::Float3 & GetForward_DeltaAxis() const;
|
|
|
|
const ::Oyster::Math::Float3 & GetGravityNormal() const;
|
2013-12-18 08:57:27 +01:00
|
|
|
|
2013-12-18 14:16:13 +01:00
|
|
|
void SetMass_KeepMomentum( ::Oyster::Math::Float m );
|
|
|
|
void SetMass_KeepVelocity( ::Oyster::Math::Float m );
|
2013-12-18 08:57:27 +01:00
|
|
|
void SetRestitutionCoeff( ::Oyster::Math::Float e );
|
2013-12-19 10:03:56 +01:00
|
|
|
void SetFrictionCoeff( ::Oyster::Math::Float staticU, ::Oyster::Math::Float kineticU );
|
2014-01-23 19:13:02 +01:00
|
|
|
void SetMomentOfInertia_KeepMomentum( const ::Oyster::Physics3D::MomentOfInertia &tensor );
|
|
|
|
void SetMomentOfInertia_KeepVelocity( const ::Oyster::Physics3D::MomentOfInertia &tensor );
|
2014-01-28 09:52:58 +01:00
|
|
|
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 );
|
2014-01-28 09:24:51 +01:00
|
|
|
//void SetRotation( const ::Oyster::Math::Float4x4 &rotation );
|
|
|
|
//void SetOrientation( const ::Oyster::Math::Float4x4 &orientation );
|
|
|
|
void SetOrientation( const ::Oyster::Math::Float3 &angularAxis, const ::Oyster::Math::Float3 &translation );
|
2014-01-28 09:52:58 +01:00
|
|
|
void SetLinearMomentum( const ::Oyster::Math::Float3 &g );
|
|
|
|
void SetAngularMomentum( const ::Oyster::Math::Float3 &h );
|
|
|
|
void SetLinearImpulse( const ::Oyster::Math::Float3 &j );
|
|
|
|
void SetAngularImpulse( const ::Oyster::Math::Float3 &j );
|
|
|
|
void SetGravityNormal( const ::Oyster::Math::Float3 &gravityNormal );
|
2013-12-18 08:57:27 +01:00
|
|
|
|
2014-01-28 09:52:58 +01:00
|
|
|
void AddRotation( const ::Oyster::Math::Float3 &angularAxis );
|
|
|
|
void AddTranslation( const ::Oyster::Math::Float3 &deltaPos );
|
2013-12-18 14:16:13 +01:00
|
|
|
|
2014-01-28 09:52:58 +01:00
|
|
|
void ApplyLinearImpulse( const ::Oyster::Math::Float3 &j );
|
|
|
|
void ApplyAngularImpulse( const ::Oyster::Math::Float3 &j );
|
|
|
|
void ApplyImpulse( const ::Oyster::Math::Float3 &j, const ::Oyster::Math::Float3 &at, const ::Oyster::Math::Float3 &normal );
|
2014-02-09 16:42:26 +01:00
|
|
|
void CustomBodyState::ApplyFriction( const ::Oyster::Math::Float3 &j);
|
2014-01-28 09:52:58 +01:00
|
|
|
void ApplyForwarding( const ::Oyster::Math::Float3 &deltaPos, const ::Oyster::Math::Float3 &deltaAxis );
|
2013-12-06 09:46:30 +01:00
|
|
|
|
|
|
|
bool IsSpatiallyAltered() const;
|
|
|
|
bool IsDisturbed() const;
|
2013-12-20 11:13:44 +01:00
|
|
|
bool IsForwarded() const;
|
2013-12-06 09:46:30 +01:00
|
|
|
|
2014-01-31 13:41:06 +01:00
|
|
|
::Oyster::Math::Float3 linearMomentum;
|
|
|
|
|
2013-12-06 09:46:30 +01:00
|
|
|
private:
|
2013-12-19 10:03:56 +01:00
|
|
|
::Oyster::Math::Float mass, restitutionCoeff, staticFrictionCoeff, kineticFrictionCoeff;
|
2014-01-23 19:13:02 +01:00
|
|
|
::Oyster::Physics3D::MomentOfInertia inertiaTensor;
|
2014-01-28 09:52:58 +01:00
|
|
|
::Oyster::Math::Float3 reach, centerPos, angularAxis;
|
2014-01-31 13:41:06 +01:00
|
|
|
::Oyster::Math::Float3 angularMomentum;
|
2014-01-28 09:52:58 +01:00
|
|
|
::Oyster::Math::Float3 linearImpulse, angularImpulse;
|
|
|
|
::Oyster::Math::Float3 deltaPos, deltaAxis; // Forwarding data sum
|
|
|
|
::Oyster::Math::Float3 gravityNormal;
|
2013-12-06 09:46:30 +01:00
|
|
|
|
2013-12-20 11:13:44 +01:00
|
|
|
bool isSpatiallyAltered, isDisturbed, isForwarded;
|
2013-12-06 09:46:30 +01:00
|
|
|
};
|
2013-12-19 14:30:16 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
###############################################################################
|
|
|
|
Can't define structs inside structs in a union therefor they are declared here.
|
|
|
|
###############################################################################
|
|
|
|
*/
|
|
|
|
struct GravityWell
|
|
|
|
{
|
|
|
|
::Oyster::Math::Float3 position;
|
|
|
|
::Oyster::Math::Float mass;
|
|
|
|
|
|
|
|
GravityWell( );
|
2014-01-09 11:36:55 +01:00
|
|
|
GravityWell( const GravityWell &gravityWell );
|
2014-01-15 10:44:20 +01:00
|
|
|
GravityWell & operator = ( const GravityWell &gravityWell );
|
|
|
|
|
|
|
|
bool operator == ( const GravityWell &gravity ) const;
|
|
|
|
bool operator != ( const GravityWell &gravity ) const;
|
2013-12-19 14:30:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct GravityDirected
|
|
|
|
{
|
|
|
|
::Oyster::Math::Float3 impulse;
|
|
|
|
|
|
|
|
GravityDirected( );
|
2014-01-09 11:36:55 +01:00
|
|
|
GravityDirected( const GravityDirected &gravityDirected );
|
|
|
|
GravityDirected & operator = ( const GravityDirected &gravityDirected );
|
2014-01-15 10:44:20 +01:00
|
|
|
|
|
|
|
bool operator == ( const GravityDirected &gravity ) const;
|
|
|
|
bool operator != ( const GravityDirected &gravity ) const;
|
2013-12-19 14:30:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct GravityDirectedField
|
|
|
|
{
|
|
|
|
::Oyster::Math::Float3 normalizedDirection;
|
|
|
|
::Oyster::Math::Float mass;
|
|
|
|
::Oyster::Math::Float magnitude;
|
|
|
|
|
|
|
|
GravityDirectedField( );
|
2014-01-09 11:36:55 +01:00
|
|
|
GravityDirectedField( const GravityDirectedField &gravityDirectedField );
|
2014-01-15 10:44:20 +01:00
|
|
|
GravityDirectedField & operator = ( const GravityDirectedField &gravityDirectedField );
|
|
|
|
|
|
|
|
bool operator == ( const GravityDirectedField &gravity ) const;
|
|
|
|
bool operator != ( const GravityDirectedField &gravity ) const;
|
2013-12-19 14:30:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Gravity
|
|
|
|
{
|
|
|
|
enum GravityType
|
|
|
|
{
|
|
|
|
GravityType_Undefined = -1,
|
|
|
|
GravityType_Well = 0,
|
|
|
|
GravityType_Directed = 1,
|
|
|
|
GravityType_DirectedField = 2,
|
|
|
|
} gravityType;
|
|
|
|
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
GravityWell well;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
GravityDirected directed;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
GravityDirectedField directedField;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
Gravity( );
|
2014-01-09 11:36:55 +01:00
|
|
|
Gravity( const Gravity &gravity );
|
|
|
|
Gravity & operator = ( const Gravity &gravity );
|
2014-01-15 10:44:20 +01:00
|
|
|
|
|
|
|
bool operator == ( const Gravity &gravity ) const;
|
|
|
|
bool operator != ( const Gravity &gravity ) const;
|
2013-12-19 14:30:16 +01:00
|
|
|
};
|
2013-12-06 09:46:30 +01:00
|
|
|
}
|
|
|
|
} }
|
|
|
|
|
2013-12-19 14:30:16 +01:00
|
|
|
|
2013-12-06 09:46:30 +01:00
|
|
|
#include "PhysicsStructs-Impl.h"
|
|
|
|
|
|
|
|
#endif
|