2013-11-06 22:52:00 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
// Created by Dan Andersson 2013
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#pragma once
|
2013-11-10 02:28:07 +01:00
|
|
|
#ifndef OYSTER_COLLISION_3D_BOX_H
|
|
|
|
#define OYSTER_COLLISION_3D_BOX_H
|
2013-11-06 22:52:00 +01:00
|
|
|
|
|
|
|
#include "OysterMath.h"
|
|
|
|
#include "ICollideable.h"
|
|
|
|
|
2014-02-03 15:48:42 +01:00
|
|
|
namespace Oyster
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
2014-02-03 15:48:42 +01:00
|
|
|
namespace Collision3D
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
2014-02-03 15:48:42 +01:00
|
|
|
class Box : public ICollideable
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
2014-02-03 15:48:42 +01:00
|
|
|
public:
|
|
|
|
union
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
2014-02-03 15:48:42 +01:00
|
|
|
struct{ ::Oyster::Math::Float4x4 rotation; ::Oyster::Math::Float4 center, boundingOffset; };
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
::Oyster::Math::Float4 xAxis;
|
|
|
|
::Oyster::Math::Float4 yAxis;
|
|
|
|
::Oyster::Math::Float4 zAxis;
|
|
|
|
};
|
|
|
|
char byte[sizeof(::Oyster::Math::Float4x4) + 2*sizeof(::Oyster::Math::Float4)];
|
2013-11-06 22:52:00 +01:00
|
|
|
};
|
|
|
|
|
2014-02-03 15:48:42 +01:00
|
|
|
Box( );
|
|
|
|
Box( const ::Oyster::Math::Float4x4 &rotation, const ::Oyster::Math::Float3 &worldPos, const ::Oyster::Math::Float3 &size );
|
|
|
|
Box( const ::Oyster::Math::Float4x4 &rotation, const ::Oyster::Math::Float4 &worldPos, const ::Oyster::Math::Float4 &size );
|
|
|
|
virtual ~Box( );
|
|
|
|
|
|
|
|
Box & operator = ( const Box &box );
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2014-02-03 15:48:42 +01:00
|
|
|
virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const;
|
|
|
|
bool Intersects( const ICollideable &target ) const;
|
|
|
|
bool Intersects( const ICollideable &target, ::Oyster::Math::Float4 &worldPointOfContact ) const;
|
|
|
|
bool Contains( const ICollideable &target ) const;
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2014-02-03 15:48:42 +01:00
|
|
|
::Oyster::Math::Float TimeOfContact( const ICollideable &deuterStart, const ICollideable &deuterEnd ) const;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Math
|
|
|
|
{
|
|
|
|
/********************************************************************
|
|
|
|
* Normalized Linear Interpolation
|
|
|
|
********************************************************************/
|
|
|
|
::Oyster::Collision3D::Box & Nlerp( const ::Oyster::Collision3D::Box &start, const ::Oyster::Collision3D::Box &end, ::Oyster::Math::Float t, ::Oyster::Collision3D::Box &targetMem = ::Oyster::Collision3D::Box() );
|
|
|
|
}
|
|
|
|
}
|
2013-11-06 22:52:00 +01:00
|
|
|
|
|
|
|
#endif
|