2013-11-20 11:09:27 +01:00
|
|
|
#ifndef PHYSICS_API_H
|
|
|
|
#define PHYSICS_API_H
|
|
|
|
|
2013-11-21 15:19:32 +01:00
|
|
|
#include "OysterCollision3D.h"
|
2013-11-20 11:09:27 +01:00
|
|
|
#include "OysterMath.h"
|
|
|
|
|
2013-11-25 12:21:44 +01:00
|
|
|
#if defined PHYSICS_DLL_EXPORT
|
|
|
|
#define PHYSICS_DLL_USAGE __declspec(dllexport)
|
2013-11-25 11:47:42 +01:00
|
|
|
#else
|
2013-11-25 12:21:44 +01:00
|
|
|
#define PHYSICS_DLL_USAGE __declspec(dllimport)
|
2013-11-25 11:47:42 +01:00
|
|
|
#endif
|
|
|
|
|
2013-11-20 11:09:27 +01:00
|
|
|
namespace Oyster
|
|
|
|
{
|
|
|
|
namespace Physics
|
|
|
|
{
|
|
|
|
class API;
|
2013-11-21 17:22:13 +01:00
|
|
|
class ICustomBody;
|
2013-11-20 11:09:27 +01:00
|
|
|
|
2013-11-21 15:19:32 +01:00
|
|
|
enum UpdateState
|
|
|
|
{
|
2013-11-28 10:26:29 +01:00
|
|
|
UpdateState_resting,
|
|
|
|
UpdateState_altered
|
2013-11-21 15:19:32 +01:00
|
|
|
};
|
|
|
|
|
2013-11-20 11:09:27 +01:00
|
|
|
namespace Constant
|
|
|
|
{
|
2013-11-25 08:57:47 +01:00
|
|
|
const float gravity_constant = (const float)6.67284e-11; //!< The _big_G_! ( N(m/kg)^2 ) Used in real gravityforcefields.
|
2013-11-20 11:09:27 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 12:21:44 +01:00
|
|
|
class PHYSICS_DLL_USAGE MomentOfInertia
|
2013-11-22 11:17:14 +01:00
|
|
|
{
|
2013-11-22 11:52:45 +01:00
|
|
|
public:
|
2013-11-25 12:21:44 +01:00
|
|
|
static ::Oyster::Math::Float4x4 & CreateSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius);
|
2013-11-22 11:52:45 +01:00
|
|
|
|
2013-11-25 12:21:44 +01:00
|
|
|
static ::Oyster::Math::Float4x4 & CreateHollowSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius);
|
2013-11-22 11:52:45 +01:00
|
|
|
|
2013-11-25 12:21:44 +01:00
|
|
|
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 );
|
2013-11-22 11:52:45 +01:00
|
|
|
|
2013-11-25 12:21:44 +01:00
|
|
|
static ::Oyster::Math::Float4x4 & CreateCylinderMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float radius );
|
2013-11-22 11:52:45 +01:00
|
|
|
|
2013-11-25 12:21:44 +01:00
|
|
|
static ::Oyster::Math::Float4x4 & CreateRodMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float length );
|
2013-11-22 11:52:45 +01:00
|
|
|
};
|
2013-11-22 11:17:14 +01:00
|
|
|
|
2013-11-25 12:21:44 +01:00
|
|
|
class PHYSICS_DLL_USAGE API
|
2013-11-20 11:09:27 +01:00
|
|
|
{
|
|
|
|
public:
|
2013-11-28 11:58:46 +01:00
|
|
|
struct SimpleBodyDescription;
|
|
|
|
struct SphericalBodyDescription;
|
|
|
|
|
2013-11-25 16:57:38 +01:00
|
|
|
typedef void (*EventAction_Destruction)( ::Utility::DynamicMemory::UniquePointer<ICustomBody> proto );
|
2013-11-20 11:09:27 +01:00
|
|
|
|
2013-11-25 08:57:47 +01:00
|
|
|
/** Gets the Physics instance. */
|
2013-11-25 12:21:44 +01:00
|
|
|
static API & Instance();
|
2013-11-20 11:09:27 +01:00
|
|
|
|
2013-11-26 13:27:34 +01:00
|
|
|
/********************************************************
|
|
|
|
* Clears all content and reset Engine assetts such as buffers.
|
|
|
|
* @param numObjects: The predicted max number of active objects.
|
|
|
|
* @param numGravityWells: The predicted max number of active gravity wells.
|
|
|
|
* @param worldSize: The size of acceptable physics space.
|
|
|
|
********************************************************/
|
|
|
|
virtual void Init( unsigned int numObjects, unsigned int numGravityWells , const ::Oyster::Math::Float3 &worldSize ) = 0;
|
|
|
|
|
2013-11-25 08:57:47 +01:00
|
|
|
/********************************************************
|
|
|
|
* Sets the time length of each physics update frame.
|
|
|
|
********************************************************/
|
|
|
|
virtual void SetDeltaTime( float seconds ) = 0;
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Sets the Gravityconstant in the physics that will be
|
|
|
|
* used in ForceField calculations.
|
|
|
|
* @param g: Default is the real world Constant::gravity_constant [N(m/kg)^2]
|
|
|
|
********************************************************/
|
2013-11-20 11:09:27 +01:00
|
|
|
virtual void SetGravityConstant( float g ) = 0;
|
2013-11-25 08:57:47 +01:00
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Sets the function that will be called by the engine
|
|
|
|
* whenever an object is being destroyed for some reason.
|
|
|
|
* - Because DestroyObject(...) were called.
|
|
|
|
* - Out of memory forced engine to destroy an object.
|
2013-11-28 10:26:29 +01:00
|
|
|
* @param functionPointer: If NULL, an empty default function will be set.
|
2013-11-25 08:57:47 +01:00
|
|
|
********************************************************/
|
2013-11-28 10:26:29 +01:00
|
|
|
virtual void SetSubscription( EventAction_Destruction functionPointer ) = 0;
|
2013-11-20 11:09:27 +01:00
|
|
|
|
2013-11-25 08:57:47 +01:00
|
|
|
/********************************************************
|
|
|
|
* Triggers the engine to run next update frame.
|
|
|
|
* All accumulated forces and changes will be consumed.
|
|
|
|
* EventAction functions might be called.
|
|
|
|
********************************************************/
|
2013-11-20 11:09:27 +01:00
|
|
|
virtual void Update() = 0;
|
|
|
|
|
2013-11-25 08:57:47 +01:00
|
|
|
/********************************************************
|
|
|
|
* An object in limbo state will be ignored during the physics frame Update.
|
2013-11-25 10:54:27 +01:00
|
|
|
* @param objRef: A pointer to the ICustomBody representing a physical object.
|
2013-11-25 08:57:47 +01:00
|
|
|
* @return true if object is in limbo state.
|
|
|
|
********************************************************/
|
2013-11-25 10:54:27 +01:00
|
|
|
virtual bool IsInLimbo( const ICustomBody* objRef ) = 0;
|
2013-11-25 08:57:47 +01:00
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* An object in limbo state will be ignored during the physics frame Update.
|
|
|
|
* This will put an object in Limbo state.
|
2013-11-25 10:54:27 +01:00
|
|
|
* @param objRef: A pointer to the ICustomBody representing a physical object.
|
2013-11-25 08:57:47 +01:00
|
|
|
********************************************************/
|
2013-11-25 10:54:27 +01:00
|
|
|
virtual void MoveToLimbo( const ICustomBody* objRef ) = 0;
|
2013-11-25 08:57:47 +01:00
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* An object in limbo state will be ignored during the physics frame Update.
|
|
|
|
* This will clear the accumulated force/torque and remove the Limbo state.
|
2013-11-25 10:54:27 +01:00
|
|
|
* @param objRef: A pointer to the ICustomBody representing a physical object.
|
2013-11-25 08:57:47 +01:00
|
|
|
********************************************************/
|
2013-11-25 10:54:27 +01:00
|
|
|
virtual void ReleaseFromLimbo( const ICustomBody* objRef ) = 0;
|
2013-11-20 11:09:27 +01:00
|
|
|
|
2013-11-25 08:57:47 +01:00
|
|
|
/********************************************************
|
|
|
|
* Introduces a new object into the engine.
|
|
|
|
* @param handle: A pointer along with the responsibility to delete.
|
|
|
|
********************************************************/
|
2013-11-25 10:54:27 +01:00
|
|
|
virtual void AddObject( ::Utility::DynamicMemory::UniquePointer<ICustomBody> handle ) = 0;
|
2013-11-25 08:57:47 +01:00
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Fetches and removes an object from the engine.
|
|
|
|
* Will not call the provided EventAction_Destruction method.
|
2013-11-25 10:54:27 +01:00
|
|
|
* @param objRef: A pointer to the ICustomBody representing a physical object.
|
2013-11-25 08:57:47 +01:00
|
|
|
* @return A pointer along with the responsibility to delete. NULL if faulty objRef.
|
|
|
|
********************************************************/
|
2013-11-25 10:54:27 +01:00
|
|
|
virtual ::Utility::DynamicMemory::UniquePointer<ICustomBody> ExtractObject( const ICustomBody* objRef ) = 0;
|
2013-11-25 08:57:47 +01:00
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Removes an object from the engine.
|
|
|
|
* Will call the provided EventAction_Destruction method. Not if objRef is faulty.
|
2013-11-25 10:54:27 +01:00
|
|
|
* @param objRef: A pointer to the ICustomBody representing a physical object.
|
2013-11-25 08:57:47 +01:00
|
|
|
********************************************************/
|
2013-11-25 10:54:27 +01:00
|
|
|
virtual void DestroyObject( const ICustomBody* objRef ) = 0;
|
2013-11-21 17:22:13 +01:00
|
|
|
|
2013-11-25 08:57:47 +01:00
|
|
|
/********************************************************
|
|
|
|
* Apply force on an object.
|
2013-11-25 10:54:27 +01:00
|
|
|
* @param objRef: A pointer to the ICustomBody representing a physical object.
|
2013-11-25 08:57:47 +01:00
|
|
|
* @param worldPos: Relative to the world origo. (Not relative to object) [m]
|
|
|
|
* @param worldF: Vector with the direction and magnitude of the force. [N]
|
|
|
|
********************************************************/
|
2013-11-25 10:54:27 +01:00
|
|
|
virtual void ApplyForceAt( const ICustomBody* objRef, const ::Oyster::Math::Float3 &worldPos, const ::Oyster::Math::Float3 &worldF ) = 0;
|
2013-11-26 13:27:34 +01:00
|
|
|
|
2013-11-25 08:57:47 +01:00
|
|
|
/********************************************************
|
|
|
|
* Apply force on an object.
|
2013-11-25 10:54:27 +01:00
|
|
|
* @param objRefA: A pointer to the ICustomBody representing a physical object.
|
|
|
|
* @param objRefB: A pointer to the ICustomBody representing a physical object.
|
2013-11-25 08:57:47 +01:00
|
|
|
* @param deltaWhen: The elapsed simulation time since last update frame. [s]
|
|
|
|
* @param worldPointOfContact: Point of Collision, relative to the world origo. (Not relative to the objects) [m]
|
|
|
|
********************************************************/
|
2013-11-25 10:54:27 +01:00
|
|
|
virtual void ApplyCollisionResponse( const ICustomBody* objRefA, const ICustomBody* objRefB, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) = 0;
|
2013-11-21 17:22:13 +01:00
|
|
|
|
2013-11-25 08:57:47 +01:00
|
|
|
/********************************************************
|
|
|
|
* Sets the MomentOfInertia tensor matrix of an object without changing it's angular velocity.
|
|
|
|
* Noticeable effect: The angular momentum will change. Changing the amount of kinetic energy.
|
2013-11-25 10:54:27 +01:00
|
|
|
* @param objRef: A pointer to the ICustomBody representing a physical object.
|
2013-11-25 08:57:47 +01:00
|
|
|
* @param localI: The tensor matrix relative to the axises of the object. @see MomentOfInertia namespace.
|
|
|
|
********************************************************/
|
2013-11-25 10:54:27 +01:00
|
|
|
virtual void SetMomentOfInertiaTensor_KeepVelocity( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &localI ) = 0;
|
2013-11-25 08:57:47 +01:00
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Sets the MomentOfInertia tensor matrix of an object without changing it's angular momentum.
|
|
|
|
* Noticeable effect: The angular velocity will change. Can be used to create slow effects.
|
2013-11-25 10:54:27 +01:00
|
|
|
* @param objRef: A pointer to the ICustomBody representing a physical object.
|
2013-11-25 08:57:47 +01:00
|
|
|
* @param localI: The tensor matrix relative to the axises of the object. @see MomentOfInertia namespace.
|
|
|
|
********************************************************/
|
2013-11-25 10:54:27 +01:00
|
|
|
virtual void SetMomentOfInertiaTensor_KeepMomentum( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &localI ) = 0;
|
2013-11-25 08:57:47 +01:00
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Sets the mass of an object without changing it's linear velocity.
|
|
|
|
* Noticeable effect: The linear momentum will change. Changing the amount of kinetic energy.
|
2013-11-25 10:54:27 +01:00
|
|
|
* @param objRef: A pointer to the ICustomBody representing a physical object.
|
2013-11-25 08:57:47 +01:00
|
|
|
* @param m: [kg]
|
|
|
|
********************************************************/
|
2013-11-25 10:54:27 +01:00
|
|
|
virtual void SetMass_KeepVelocity( const ICustomBody* objRef, ::Oyster::Math::Float m ) = 0;
|
2013-11-25 08:57:47 +01:00
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Sets the mass of an object without changing it's linear velocity.
|
|
|
|
* Noticeable effect: The linear velocity will change. Can be used to create slow effects.
|
2013-11-25 10:54:27 +01:00
|
|
|
* @param objRef: A pointer to the ICustomBody representing a physical object.
|
2013-11-25 08:57:47 +01:00
|
|
|
* @param m: [kg]
|
|
|
|
********************************************************/
|
2013-11-25 10:54:27 +01:00
|
|
|
virtual void SetMass_KeepMomentum( const ICustomBody* objRef, ::Oyster::Math::Float m ) = 0;
|
2013-11-25 08:57:47 +01:00
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Instantly moves an object.
|
2013-11-25 10:54:27 +01:00
|
|
|
* @param objRef: A pointer to the ICustomBody representing a physical object.
|
2013-11-25 08:57:47 +01:00
|
|
|
* @param worldPos: Relative to the world origo. (Not relative to object) [m]
|
|
|
|
********************************************************/
|
2013-11-25 10:54:27 +01:00
|
|
|
virtual void SetCenter( const ICustomBody* objRef, const ::Oyster::Math::Float3 &worldPos ) = 0;
|
2013-11-25 08:57:47 +01:00
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Instantly redirects object.
|
2013-11-25 10:54:27 +01:00
|
|
|
* @param objRef: A pointer to the ICustomBody representing a physical object.
|
2013-11-25 08:57:47 +01:00
|
|
|
* @param rotation: New rotation.
|
|
|
|
********************************************************/
|
2013-11-25 10:54:27 +01:00
|
|
|
virtual void SetRotation( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &rotation ) = 0;
|
2013-11-25 08:57:47 +01:00
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Instantly moves and redirects object.
|
2013-11-25 10:54:27 +01:00
|
|
|
* @param objRef: A pointer to the ICustomBody representing a physical object.
|
2013-11-25 08:57:47 +01:00
|
|
|
* @param orientation: New orientation.
|
|
|
|
********************************************************/
|
2013-11-25 10:54:27 +01:00
|
|
|
virtual void SetOrientation( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &orientation ) = 0;
|
2013-11-25 08:57:47 +01:00
|
|
|
|
2013-11-26 13:27:34 +01:00
|
|
|
/********************************************************
|
|
|
|
* Resizes the boundingBox.
|
|
|
|
* @param objRef: A pointer to the ICustomBody representing a physical object.
|
|
|
|
* @param size: New size of this [m]
|
|
|
|
********************************************************/
|
|
|
|
virtual void SetSize( const ICustomBody* objRef, const ::Oyster::Math::Float3 &size ) = 0;
|
|
|
|
|
2013-11-25 08:57:47 +01:00
|
|
|
/********************************************************
|
|
|
|
* Creates a new dynamically allocated object that can be used as a component for more complex ICustomBodies.
|
2013-11-28 11:58:46 +01:00
|
|
|
* @param desc: @see API::SimpleBodyDescription
|
|
|
|
* @return A pointer along with the responsibility to delete.
|
|
|
|
********************************************************/
|
|
|
|
virtual ::Utility::DynamicMemory::UniquePointer<ICustomBody> CreateRigidBody( const SimpleBodyDescription &desc ) const = 0;
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Creates a new dynamically allocated object that can be used as a component for more complex ICustomBodies.
|
|
|
|
* @param desc: @see API::SphericalBodyDescription
|
2013-11-25 08:57:47 +01:00
|
|
|
* @return A pointer along with the responsibility to delete.
|
|
|
|
********************************************************/
|
2013-11-28 11:58:46 +01:00
|
|
|
virtual ::Utility::DynamicMemory::UniquePointer<ICustomBody> CreateRigidBody( const SphericalBodyDescription &desc ) const = 0;
|
|
|
|
|
2013-11-21 17:22:13 +01:00
|
|
|
protected:
|
|
|
|
virtual ~API() {}
|
2013-11-20 11:09:27 +01:00
|
|
|
};
|
|
|
|
|
2013-11-25 13:46:05 +01:00
|
|
|
//! The root interface for all physical representations processable by the engine.
|
2013-11-25 12:21:44 +01:00
|
|
|
class PHYSICS_DLL_USAGE ICustomBody
|
2013-11-20 11:09:27 +01:00
|
|
|
{
|
|
|
|
public:
|
2013-11-28 10:26:29 +01:00
|
|
|
enum SubscriptMessage
|
|
|
|
{
|
|
|
|
SubscriptMessage_none,
|
|
|
|
SubscriptMessage_ignore_collision_response
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef SubscriptMessage (*EventAction_Collision)( const ICustomBody *proto, const ICustomBody *deuter );
|
|
|
|
|
2013-11-21 17:22:13 +01:00
|
|
|
virtual ~ICustomBody() {};
|
2013-11-21 15:19:32 +01:00
|
|
|
|
2013-11-25 11:35:38 +01:00
|
|
|
/********************************************************
|
|
|
|
* Creates a complete copy of the current (type)object.
|
|
|
|
* @return An ICustomBody pointer along with the responsibility to delete.
|
|
|
|
********************************************************/
|
2013-11-21 17:22:13 +01:00
|
|
|
virtual ::Utility::DynamicMemory::UniquePointer<ICustomBody> Clone() const = 0;
|
2013-11-25 13:46:05 +01:00
|
|
|
|
2013-11-26 13:27:34 +01:00
|
|
|
/********************************************************
|
|
|
|
* @return true if Engine should apply gravity on this object.
|
|
|
|
********************************************************/
|
|
|
|
virtual bool IsAffectedByGravity() const = 0;
|
|
|
|
|
2013-11-25 13:46:05 +01:00
|
|
|
/********************************************************
|
|
|
|
* Performs a detailed Intersect test and returns if, when and where.
|
|
|
|
* @param object: What this is intersect testing against.
|
2013-11-25 16:35:56 +01:00
|
|
|
* @param timeStepLength: The value set by API::SetDeltaTime(...)
|
|
|
|
* @param deltaWhen: Time in seconds since last update frame til timeOfContact. 0.0f <= deltaWhen <= timeStepLength
|
2013-11-25 13:46:05 +01:00
|
|
|
* @param worldPointOfContact: Where at timeOfContact, this and object touches eachother.
|
|
|
|
* @return true if this truly intersects with object.
|
|
|
|
********************************************************/
|
2013-11-25 16:35:56 +01:00
|
|
|
virtual bool Intersects( const ICustomBody &object, ::Oyster::Math::Float timeStepLength, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const = 0;
|
2013-11-25 13:46:05 +01:00
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* param shape: Any defined sample shape.
|
|
|
|
* @return true if this truly intersects with shape.
|
|
|
|
********************************************************/
|
2013-11-21 17:22:13 +01:00
|
|
|
virtual bool Intersects( const ::Oyster::Collision3D::ICollideable &shape ) const = 0;
|
|
|
|
|
2013-11-25 13:46:05 +01:00
|
|
|
/********************************************************
|
|
|
|
* Required by Engine's Collision Search.
|
|
|
|
* @param targetMem: Provided memory that written into and then returned.
|
|
|
|
* @return a sphere shape that contains the ICustomBody.
|
|
|
|
********************************************************/
|
|
|
|
virtual ::Oyster::Collision3D::Sphere & GetBoundingSphere( ::Oyster::Collision3D::Sphere &targetMem = ::Oyster::Collision3D::Sphere() ) const = 0;
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Required by Engine's Collision Responsing.
|
|
|
|
* @param worldPos: Should be worldPointOfContact from Intersects( ... )
|
|
|
|
* @param targetMem: Provided memory that written into and then returned.
|
|
|
|
* @return a surface normal in worldSpace.
|
|
|
|
********************************************************/
|
|
|
|
virtual ::Oyster::Math::Float3 & GetNormalAt( const ::Oyster::Math::Float3 &worldPos, ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const = 0;
|
|
|
|
|
2013-11-26 13:27:34 +01:00
|
|
|
/********************************************************
|
|
|
|
* The gravity normal will have same direction as the total gravity force pulling on this and have the magnitude of 1.0f.
|
|
|
|
* @param targetMem: Provided memory that written into and then returned.
|
|
|
|
* @return a normalized vector in worldSpace. Exception: Null vector if no gravity been applied.
|
|
|
|
********************************************************/
|
|
|
|
virtual ::Oyster::Math::Float3 & GetGravityNormal( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const = 0;
|
|
|
|
|
2013-11-25 13:46:05 +01:00
|
|
|
/********************************************************
|
|
|
|
* The world position of this center of gravity.
|
|
|
|
* @param targetMem: Provided memory that written into and then returned.
|
|
|
|
* @return a position in worldSpace.
|
|
|
|
********************************************************/
|
|
|
|
virtual ::Oyster::Math::Float3 & GetCenter( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const = 0;
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* @param targetMem: Provided memory that written into and then returned.
|
|
|
|
* @return a copy of this's rotation matrix.
|
|
|
|
********************************************************/
|
|
|
|
virtual ::Oyster::Math::Float4x4 & GetRotation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const = 0;
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* @param targetMem: Provided memory that written into and then returned.
|
|
|
|
* @return a copy of this's orientation matrix.
|
|
|
|
********************************************************/
|
|
|
|
virtual ::Oyster::Math::Float4x4 & GetOrientation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const = 0;
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* @param targetMem: Provided memory that written into and then returned.
|
|
|
|
* @return a copy of this's view matrix.
|
|
|
|
********************************************************/
|
|
|
|
virtual ::Oyster::Math::Float4x4 & GetView( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const = 0;
|
2013-11-21 17:22:13 +01:00
|
|
|
|
2013-11-25 13:46:05 +01:00
|
|
|
/********************************************************
|
2013-11-26 13:27:34 +01:00
|
|
|
* To not be called if is in Engine
|
2013-11-25 13:46:05 +01:00
|
|
|
* Is called during API::Update
|
|
|
|
********************************************************/
|
2013-11-21 17:22:13 +01:00
|
|
|
virtual UpdateState Update( ::Oyster::Math::Float timeStepLength ) = 0;
|
2013-11-26 13:27:34 +01:00
|
|
|
|
2013-11-28 10:26:29 +01:00
|
|
|
/********************************************************
|
|
|
|
* Sets the function that will be called by the engine
|
|
|
|
* whenever a collision occurs.
|
|
|
|
* @param functionPointer: If NULL, an empty default function will be set.
|
|
|
|
********************************************************/
|
|
|
|
virtual void SetSubscription( EventAction_Collision functionPointer ) = 0;
|
|
|
|
|
2013-11-26 13:27:34 +01:00
|
|
|
/********************************************************
|
|
|
|
* @param ignore: True if Engine should not apply Gravity.
|
|
|
|
********************************************************/
|
|
|
|
virtual void SetGravity( bool ignore) = 0;
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Used by Engine
|
|
|
|
* @param normalizedVector: Should have same direction as the pullinggravity.
|
|
|
|
********************************************************/
|
|
|
|
virtual void SetGravityNormal( const ::Oyster::Math::Float3 &normalizedVector ) = 0;
|
|
|
|
|
2013-11-25 13:46:05 +01:00
|
|
|
/********************************************************
|
2013-11-26 13:27:34 +01:00
|
|
|
* To not be called if is in Engine
|
2013-11-25 13:46:05 +01:00
|
|
|
* Use API::SetMomentOfInertiaTensor_KeepVelocity(...) instead
|
|
|
|
********************************************************/
|
2013-11-21 17:22:13 +01:00
|
|
|
virtual void SetMomentOfInertiaTensor_KeepVelocity( const ::Oyster::Math::Float4x4 &localI ) = 0;
|
2013-11-25 13:46:05 +01:00
|
|
|
|
|
|
|
/********************************************************
|
2013-11-26 13:27:34 +01:00
|
|
|
* To not be called if is in Engine
|
2013-11-25 13:46:05 +01:00
|
|
|
* Use API::SetMomentOfInertiaTensor_KeepMomentum(...)
|
|
|
|
********************************************************/
|
2013-11-21 17:22:13 +01:00
|
|
|
virtual void SetMomentOfInertiaTensor_KeepMomentum( const ::Oyster::Math::Float4x4 &localI ) = 0;
|
2013-11-25 13:46:05 +01:00
|
|
|
|
|
|
|
/********************************************************
|
2013-11-26 13:27:34 +01:00
|
|
|
* To not be called if is in Engine
|
2013-11-25 13:46:05 +01:00
|
|
|
* Use API::SetMass_KeepVelocity(...)
|
|
|
|
********************************************************/
|
2013-11-21 17:22:13 +01:00
|
|
|
virtual void SetMass_KeepVelocity( ::Oyster::Math::Float m ) = 0;
|
2013-11-25 13:46:05 +01:00
|
|
|
|
|
|
|
/********************************************************
|
2013-11-26 13:27:34 +01:00
|
|
|
* To not be called if is in Engine
|
2013-11-25 13:46:05 +01:00
|
|
|
* Use API::SetMass_KeepMomentum(...)
|
|
|
|
********************************************************/
|
2013-11-21 17:22:13 +01:00
|
|
|
virtual void SetMass_KeepMomentum( ::Oyster::Math::Float m ) = 0;
|
2013-11-25 13:46:05 +01:00
|
|
|
|
|
|
|
/********************************************************
|
2013-11-26 13:27:34 +01:00
|
|
|
* To not be called if is in Engine
|
2013-11-25 13:46:05 +01:00
|
|
|
* Use API::SetCenter(...)
|
|
|
|
********************************************************/
|
2013-11-21 17:22:13 +01:00
|
|
|
virtual void SetCenter( const ::Oyster::Math::Float3 &worldPos ) = 0;
|
2013-11-25 13:46:05 +01:00
|
|
|
|
|
|
|
/********************************************************
|
2013-11-26 13:27:34 +01:00
|
|
|
* To not be called if is in Engine
|
2013-11-25 13:46:05 +01:00
|
|
|
* Use API::SetRotation(...)
|
|
|
|
********************************************************/
|
2013-11-21 17:22:13 +01:00
|
|
|
virtual void SetRotation( const ::Oyster::Math::Float4x4 &rotation ) = 0;
|
2013-11-25 13:46:05 +01:00
|
|
|
|
|
|
|
/********************************************************
|
2013-11-26 13:27:34 +01:00
|
|
|
* To not be called if is in Engine
|
2013-11-25 13:46:05 +01:00
|
|
|
* Use API::SetOrientation(...)
|
|
|
|
********************************************************/
|
2013-11-21 17:22:13 +01:00
|
|
|
virtual void SetOrientation( const ::Oyster::Math::Float4x4 &orientation ) = 0;
|
2013-11-26 13:27:34 +01:00
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* To not be called if is in Engine
|
|
|
|
* Use API::SetSize(...)
|
|
|
|
********************************************************/
|
|
|
|
virtual void SetSize( const ::Oyster::Math::Float3 &size ) = 0;
|
2013-11-20 11:09:27 +01:00
|
|
|
};
|
2013-11-28 11:58:46 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
};
|
2013-11-21 17:22:13 +01:00
|
|
|
}
|
2013-11-20 11:09:27 +01:00
|
|
|
}
|
|
|
|
#endif
|