Added more API & ICustomBody methods
API::Init ICustomBody::SetSubscription Gravity related calls moved DLLMain.cpp
This commit is contained in:
parent
2890c2a9ea
commit
29362c8c60
|
@ -152,12 +152,14 @@
|
|||
<ClInclude Include="Implementation\Octree.h" />
|
||||
<ClInclude Include="Implementation\PhysicsAPI_Impl.h" />
|
||||
<ClInclude Include="Implementation\SimpleRigidBody.h" />
|
||||
<ClInclude Include="Implementation\SphericalRigidBody.h" />
|
||||
<ClInclude Include="PhysicsAPI.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Implementation\DLLMain.cpp" />
|
||||
<ClCompile Include="Implementation\PhysicsAPI_Impl.cpp" />
|
||||
<ClCompile Include="Implementation\SimpleRigidBody.cpp" />
|
||||
<ClCompile Include="DLLMain.cpp" />
|
||||
<ClCompile Include="Implementation\SphericalRigidBody.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
<ClInclude Include="Implementation\SimpleRigidBody.h">
|
||||
<Filter>Header Files\Implementation</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Implementation\SphericalRigidBody.h">
|
||||
<Filter>Header Files\Implementation</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Implementation\PhysicsAPI_Impl.cpp">
|
||||
|
@ -38,7 +41,10 @@
|
|||
<ClCompile Include="Implementation\SimpleRigidBody.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DLLMain.cpp">
|
||||
<ClCompile Include="Implementation\DLLMain.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Implementation\SphericalRigidBody.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
|
|
|
@ -57,6 +57,11 @@ API_Impl::API_Impl()
|
|||
|
||||
API_Impl::~API_Impl() {}
|
||||
|
||||
void API_Impl::Init( unsigned int numObjects, unsigned int numGravityWells , const Float3 &worldSize )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
void API_Impl::SetDeltaTime( float deltaTime )
|
||||
{
|
||||
updateFrameLength = deltaTime;
|
||||
|
@ -155,6 +160,11 @@ void API_Impl::SetOrientation( const ICustomBody* objRef, const Float4x4 &orient
|
|||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
void API_Impl::SetSize( const ICustomBody* objRef, const Float3 &size )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
UniquePointer<ICustomBody> API_Impl::CreateSimpleRigidBody() const
|
||||
{
|
||||
return new SimpleRigidBody();
|
||||
|
|
|
@ -13,6 +13,8 @@ namespace Oyster
|
|||
API_Impl();
|
||||
virtual ~API_Impl();
|
||||
|
||||
void Init( unsigned int numObjects, unsigned int numGravityWells , const ::Oyster::Math::Float3 &worldSize );
|
||||
|
||||
void SetDeltaTime( float deltaTime );
|
||||
void SetGravityConstant( float g );
|
||||
void SetAction( EventAction_Collision functionPointer );
|
||||
|
@ -38,6 +40,7 @@ namespace Oyster
|
|||
void SetCenter( const ICustomBody* objRef, const ::Oyster::Math::Float3 &worldPos );
|
||||
void SetRotation( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &rotation );
|
||||
void SetOrientation( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &orientation );
|
||||
void SetSize( const ICustomBody* objRef, const ::Oyster::Math::Float3 &size );
|
||||
|
||||
::Utility::DynamicMemory::UniquePointer<ICustomBody> CreateSimpleRigidBody() const;
|
||||
private:
|
||||
|
|
|
@ -7,7 +7,11 @@ using namespace ::Oyster::Collision3D;
|
|||
using namespace ::Utility::DynamicMemory;
|
||||
using namespace ::Utility::Value;
|
||||
|
||||
SimpleRigidBody::SimpleRigidBody() : previous(), current() {}
|
||||
SimpleRigidBody::SimpleRigidBody()
|
||||
: previous(), current(),
|
||||
gravityNormal(0.0f),
|
||||
subscribeCollision(true),
|
||||
ignoreGravity(false) {}
|
||||
|
||||
SimpleRigidBody::~SimpleRigidBody() {}
|
||||
|
||||
|
@ -18,7 +22,12 @@ UniquePointer<ICustomBody> SimpleRigidBody::Clone() const
|
|||
|
||||
bool SimpleRigidBody::IsSubscribingCollisions() const
|
||||
{ // Assumption
|
||||
return true;
|
||||
return this->subscribeCollision;
|
||||
}
|
||||
|
||||
bool SimpleRigidBody::IsAffectedByGravity() const
|
||||
{
|
||||
return !this->ignoreGravity;
|
||||
}
|
||||
|
||||
bool SimpleRigidBody::Intersects( const ICustomBody &object, Float timeStepLength, Float &deltaWhen, Float3 &worldPointOfContact ) const
|
||||
|
@ -51,6 +60,11 @@ Float3 & SimpleRigidBody::GetNormalAt( const Float3 &worldPos, Float3 &targetMem
|
|||
return targetMem = (worldPos - this->current.box.center).GetNormalized();
|
||||
}
|
||||
|
||||
Float3 & SimpleRigidBody::GetGravityNormal( Float3 &targetMem ) const
|
||||
{
|
||||
return targetMem = this->gravityNormal;
|
||||
}
|
||||
|
||||
Float3 & SimpleRigidBody::GetCenter( Float3 &targetMem ) const
|
||||
{
|
||||
return targetMem = this->current.box.center;
|
||||
|
@ -81,6 +95,22 @@ UpdateState SimpleRigidBody::Update( Float timeStepLength )
|
|||
return this->current == this->previous ? resting : altered;
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetGravity( bool ignore)
|
||||
{
|
||||
this->ignoreGravity = ignore;
|
||||
this->gravityNormal = Float3::null;
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetGravityNormal( const Float3 &normalizedVector )
|
||||
{
|
||||
this->gravityNormal = normalizedVector;
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetSubscription( bool subscribeCollision )
|
||||
{
|
||||
this->subscribeCollision = subscribeCollision;
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetMomentOfInertiaTensor_KeepVelocity( const Float4x4 &localI )
|
||||
{
|
||||
this->current.SetMomentOfInertia_KeepVelocity( localI );
|
||||
|
@ -114,4 +144,9 @@ void SimpleRigidBody::SetRotation( const Float4x4 &rotation )
|
|||
void SimpleRigidBody::SetOrientation( const Float4x4 &orientation )
|
||||
{
|
||||
this->current.SetOrientation( orientation );
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetSize( const Float3 &size )
|
||||
{
|
||||
this->current.SetSize( size );
|
||||
}
|
|
@ -15,11 +15,13 @@ namespace Oyster { namespace Physics
|
|||
::Utility::DynamicMemory::UniquePointer<ICustomBody> Clone() const;
|
||||
|
||||
bool IsSubscribingCollisions() const;
|
||||
bool IsAffectedByGravity() const;
|
||||
bool Intersects( const ICustomBody &object, ::Oyster::Math::Float timeStepLength, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const;
|
||||
bool Intersects( const ::Oyster::Collision3D::ICollideable &shape ) const;
|
||||
|
||||
::Oyster::Collision3D::Sphere & GetBoundingSphere( ::Oyster::Collision3D::Sphere &targetMem = ::Oyster::Collision3D::Sphere() ) const;
|
||||
::Oyster::Math::Float3 & GetNormalAt( const ::Oyster::Math::Float3 &worldPos, ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const;
|
||||
::Oyster::Math::Float3 & GetGravityNormal( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const;
|
||||
::Oyster::Math::Float3 & GetCenter( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const;
|
||||
::Oyster::Math::Float4x4 & GetRotation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
|
||||
::Oyster::Math::Float4x4 & GetOrientation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
|
||||
|
@ -27,6 +29,9 @@ namespace Oyster { namespace Physics
|
|||
|
||||
UpdateState Update( ::Oyster::Math::Float timeStepLength );
|
||||
|
||||
void SetGravity( bool ignore);
|
||||
void SetGravityNormal( const ::Oyster::Math::Float3 &normalizedVector );
|
||||
void SetSubscription( bool subscribeCollision );
|
||||
void SetMomentOfInertiaTensor_KeepVelocity( const ::Oyster::Math::Float4x4 &localI );
|
||||
void SetMomentOfInertiaTensor_KeepMomentum( const ::Oyster::Math::Float4x4 &localI );
|
||||
void SetMass_KeepVelocity( ::Oyster::Math::Float m );
|
||||
|
@ -34,9 +39,12 @@ namespace Oyster { namespace Physics
|
|||
void SetCenter( const ::Oyster::Math::Float3 &worldPos );
|
||||
void SetRotation( const ::Oyster::Math::Float4x4 &rotation );
|
||||
void SetOrientation( const ::Oyster::Math::Float4x4 &orientation );
|
||||
void SetSize( const ::Oyster::Math::Float3 &size );
|
||||
|
||||
private:
|
||||
::Oyster::Physics3D::RigidBody previous, current;
|
||||
::Oyster::Math::Float3 gravityNormal;
|
||||
bool subscribeCollision, ignoreGravity;
|
||||
};
|
||||
} }
|
||||
|
||||
|
|
|
@ -51,6 +51,14 @@ namespace Oyster
|
|||
/** Gets the Physics instance. */
|
||||
static API & Instance();
|
||||
|
||||
/********************************************************
|
||||
* 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;
|
||||
|
||||
/********************************************************
|
||||
* Sets the time length of each physics update frame.
|
||||
********************************************************/
|
||||
|
@ -133,7 +141,7 @@ namespace Oyster
|
|||
* @param worldF: Vector with the direction and magnitude of the force. [N]
|
||||
********************************************************/
|
||||
virtual void ApplyForceAt( const ICustomBody* objRef, const ::Oyster::Math::Float3 &worldPos, const ::Oyster::Math::Float3 &worldF ) = 0;
|
||||
|
||||
|
||||
/********************************************************
|
||||
* Apply force on an object.
|
||||
* @param objRefA: A pointer to the ICustomBody representing a physical object.
|
||||
|
@ -196,6 +204,13 @@ namespace Oyster
|
|||
********************************************************/
|
||||
virtual void SetOrientation( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &orientation ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* 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;
|
||||
|
||||
/********************************************************
|
||||
* Creates a new dynamically allocated object that can be used as a component for more complex ICustomBodies.
|
||||
* @return A pointer along with the responsibility to delete.
|
||||
|
@ -223,6 +238,11 @@ namespace Oyster
|
|||
********************************************************/
|
||||
virtual bool IsSubscribingCollisions() const = 0;
|
||||
|
||||
/********************************************************
|
||||
* @return true if Engine should apply gravity on this object.
|
||||
********************************************************/
|
||||
virtual bool IsAffectedByGravity() const = 0;
|
||||
|
||||
/********************************************************
|
||||
* Performs a detailed Intersect test and returns if, when and where.
|
||||
* @param object: What this is intersect testing against.
|
||||
|
@ -254,6 +274,13 @@ namespace Oyster
|
|||
********************************************************/
|
||||
virtual ::Oyster::Math::Float3 & GetNormalAt( const ::Oyster::Math::Float3 &worldPos, ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const = 0;
|
||||
|
||||
/********************************************************
|
||||
* 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;
|
||||
|
||||
/********************************************************
|
||||
* The world position of this center of gravity.
|
||||
* @param targetMem: Provided memory that written into and then returned.
|
||||
|
@ -280,52 +307,74 @@ namespace Oyster
|
|||
virtual ::Oyster::Math::Float4x4 & GetView( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const = 0;
|
||||
|
||||
/********************************************************
|
||||
* To be only called by Engine
|
||||
* To not be called if is in Engine
|
||||
* Is called during API::Update
|
||||
********************************************************/
|
||||
virtual UpdateState Update( ::Oyster::Math::Float timeStepLength ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* @param ignore: True if Engine should not apply Gravity.
|
||||
********************************************************/
|
||||
virtual void SetGravity( bool ignore) = 0;
|
||||
|
||||
/********************************************************
|
||||
* To be only called by Engine
|
||||
* Used by Engine
|
||||
* @param normalizedVector: Should have same direction as the pullinggravity.
|
||||
********************************************************/
|
||||
virtual void SetGravityNormal( const ::Oyster::Math::Float3 &normalizedVector ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* @param subscribeCollision: If is true, engine will call EventAction_Collision when this collides.
|
||||
********************************************************/
|
||||
virtual void SetSubscription( bool subscribeCollision ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* To not be called if is in Engine
|
||||
* Use API::SetMomentOfInertiaTensor_KeepVelocity(...) instead
|
||||
********************************************************/
|
||||
virtual void SetMomentOfInertiaTensor_KeepVelocity( const ::Oyster::Math::Float4x4 &localI ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* To be only called by Engine
|
||||
* To not be called if is in Engine
|
||||
* Use API::SetMomentOfInertiaTensor_KeepMomentum(...)
|
||||
********************************************************/
|
||||
virtual void SetMomentOfInertiaTensor_KeepMomentum( const ::Oyster::Math::Float4x4 &localI ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* To be only called by Engine
|
||||
* To not be called if is in Engine
|
||||
* Use API::SetMass_KeepVelocity(...)
|
||||
********************************************************/
|
||||
virtual void SetMass_KeepVelocity( ::Oyster::Math::Float m ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* To be only called by Engine
|
||||
* To not be called if is in Engine
|
||||
* Use API::SetMass_KeepMomentum(...)
|
||||
********************************************************/
|
||||
virtual void SetMass_KeepMomentum( ::Oyster::Math::Float m ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* To be only called by Engine
|
||||
* To not be called if is in Engine
|
||||
* Use API::SetCenter(...)
|
||||
********************************************************/
|
||||
virtual void SetCenter( const ::Oyster::Math::Float3 &worldPos ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* To be only called by Engine
|
||||
* To not be called if is in Engine
|
||||
* Use API::SetRotation(...)
|
||||
********************************************************/
|
||||
virtual void SetRotation( const ::Oyster::Math::Float4x4 &rotation ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* To be only called by Engine
|
||||
* To not be called if is in Engine
|
||||
* Use API::SetOrientation(...)
|
||||
********************************************************/
|
||||
virtual void SetOrientation( const ::Oyster::Math::Float4x4 &orientation ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* To not be called if is in Engine
|
||||
* Use API::SetSize(...)
|
||||
********************************************************/
|
||||
virtual void SetSize( const ::Oyster::Math::Float3 &size ) = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue