Merge branch 'Graphics' of https://github.com/dean11/Danbias into MiscBranch
This commit is contained in:
commit
7b0265db1d
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -145,7 +145,11 @@
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Include\GamePhysics.h" />
|
<ClInclude Include="Implementation\PhysicsAPI_Impl.h" />
|
||||||
|
<ClInclude Include="PhysicsAPI.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Implementation\PhysicsAPI_Impl.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
|
|
@ -16,16 +16,21 @@
|
||||||
<Filter Include="Header Files\Implementation">
|
<Filter Include="Header Files\Implementation">
|
||||||
<UniqueIdentifier>{f2cb55b8-47a0-45c7-8dce-5b93f945a57b}</UniqueIdentifier>
|
<UniqueIdentifier>{f2cb55b8-47a0-45c7-8dce-5b93f945a57b}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="Source Files\Implementation">
|
|
||||||
<UniqueIdentifier>{cac9a78f-f09b-4850-b1aa-ea87e8368678}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Header Files\Include">
|
<Filter Include="Header Files\Include">
|
||||||
<UniqueIdentifier>{792daa4b-b2f7-4664-9529-71a929365274}</UniqueIdentifier>
|
<UniqueIdentifier>{792daa4b-b2f7-4664-9529-71a929365274}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Include\GamePhysics.h">
|
<ClInclude Include="PhysicsAPI.h">
|
||||||
<Filter>Header Files\Include</Filter>
|
<Filter>Header Files\Include</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Implementation\PhysicsAPI_Impl.h">
|
||||||
|
<Filter>Header Files\Implementation</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Implementation\PhysicsAPI_Impl.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -0,0 +1,63 @@
|
||||||
|
#include "PhysicsAPI_Impl.h"
|
||||||
|
|
||||||
|
using namespace Oyster;
|
||||||
|
using namespace Physics;
|
||||||
|
|
||||||
|
API_Impl instance;
|
||||||
|
|
||||||
|
API & Instance()
|
||||||
|
{
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
API_Impl::API_Impl()
|
||||||
|
{
|
||||||
|
/** @todo TODO: Fix this constructor.*/
|
||||||
|
}
|
||||||
|
|
||||||
|
API_Impl::~API_Impl()
|
||||||
|
{
|
||||||
|
/** @todo TODO: Fix this destructor.*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void API_Impl::SetDeltaTime( float deltaTime )
|
||||||
|
{
|
||||||
|
/** @todo TODO: Fix this function.*/
|
||||||
|
}
|
||||||
|
void API_Impl::SetGravityConstant( float g )
|
||||||
|
{
|
||||||
|
/** @todo TODO: Fix this function.*/
|
||||||
|
}
|
||||||
|
void API_Impl::SetAction( EventAction_Collision functionPointer )
|
||||||
|
{
|
||||||
|
/** @todo TODO: Fix this function.*/
|
||||||
|
}
|
||||||
|
void API_Impl::SetAction( EventAction_Destruction functionPointer )
|
||||||
|
{
|
||||||
|
/** @todo TODO: Fix this function.*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void API_Impl::Update()
|
||||||
|
{
|
||||||
|
/** @todo TODO: Fix this function.*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void API_Impl::MoveToLimbo( unsigned int objRef )
|
||||||
|
{
|
||||||
|
/** @todo TODO: Fix this function.*/
|
||||||
|
}
|
||||||
|
void API_Impl::ReleaseFromLimbo( unsigned int objRef )
|
||||||
|
{
|
||||||
|
/** @todo TODO: Fix this function.*/
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int API_Impl::AddObject( ::Utility::DynamicMemory::UniquePointer<IRigidBody> handle )
|
||||||
|
{
|
||||||
|
/** @todo TODO: Fix this function.*/
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
void API_Impl::DestroyObject( unsigned int objRef )
|
||||||
|
{
|
||||||
|
/** @todo TODO: Fix this function.*/
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
#ifndef PHYSICS_API_IMPL_H
|
||||||
|
#define PHYSICS_API_IMPL_H
|
||||||
|
|
||||||
|
#include "../PhysicsAPI.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Physics
|
||||||
|
{
|
||||||
|
class API_Impl : public API
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
API_Impl();
|
||||||
|
virtual ~API_Impl();
|
||||||
|
|
||||||
|
void SetDeltaTime( float deltaTime );
|
||||||
|
void SetGravityConstant( float g );
|
||||||
|
void SetAction( EventAction_Collision functionPointer );
|
||||||
|
void SetAction( EventAction_Destruction functionPointer );
|
||||||
|
|
||||||
|
void Update();
|
||||||
|
|
||||||
|
void MoveToLimbo( unsigned int objRef );
|
||||||
|
void ReleaseFromLimbo( unsigned int objRef );
|
||||||
|
|
||||||
|
unsigned int AddObject( ::Utility::DynamicMemory::UniquePointer<IRigidBody> handle );
|
||||||
|
void DestroyObject( unsigned int objRef );
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,76 @@
|
||||||
|
#ifndef PHYSICS_API_H
|
||||||
|
#define PHYSICS_API_H
|
||||||
|
|
||||||
|
#include "OysterCollision3D.h"
|
||||||
|
#include "OysterMath.h"
|
||||||
|
#include "Utilities.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Physics
|
||||||
|
{
|
||||||
|
class API;
|
||||||
|
class IRigidBody;
|
||||||
|
class IParticle;
|
||||||
|
|
||||||
|
enum UpdateState
|
||||||
|
{
|
||||||
|
resting,
|
||||||
|
altered
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace Constant
|
||||||
|
{
|
||||||
|
const float gravity_constant = (const float)6.67284e-11; // The _big_G_! ( N(m/kg)^2 ) Used in real gravityforcefields.
|
||||||
|
}
|
||||||
|
|
||||||
|
class API
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef void (*EventAction_Collision)( unsigned int, unsigned int );
|
||||||
|
typedef void (*EventAction_Destruction)( unsigned int, ::Utility::DynamicMemory::UniquePointer<IRigidBody> );
|
||||||
|
|
||||||
|
static API & Instance();
|
||||||
|
|
||||||
|
virtual void SetDeltaTime( float deltaTime ) = 0;
|
||||||
|
virtual void SetGravityConstant( float g ) = 0;
|
||||||
|
virtual void SetAction( EventAction_Collision functionPointer ) = 0;
|
||||||
|
virtual void SetAction( EventAction_Destruction functionPointer ) = 0;
|
||||||
|
|
||||||
|
virtual void Update() = 0;
|
||||||
|
|
||||||
|
virtual bool IsInLimbo( unsigned int objRef ) = 0;
|
||||||
|
virtual void MoveToLimbo( unsigned int objRef ) = 0;
|
||||||
|
virtual void ReleaseFromLimbo( unsigned int objRef ) = 0;
|
||||||
|
|
||||||
|
virtual unsigned int AddObject( ::Utility::DynamicMemory::UniquePointer<IRigidBody> handle ) = 0;
|
||||||
|
virtual ::Utility::DynamicMemory::UniquePointer<IRigidBody> ExtractObject( unsigned int objRef ) = 0;
|
||||||
|
virtual void DestroyObject( unsigned int objRef ) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IRigidBody
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IRigidBody() {};
|
||||||
|
|
||||||
|
virtual UpdateState Update( ::Oyster::Math::Float timeStepLength ) = 0;
|
||||||
|
|
||||||
|
virtual bool IsSubscribingCollisions() const = 0;
|
||||||
|
virtual bool IsIntersecting( const IRigidBody &object, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) = 0;
|
||||||
|
|
||||||
|
virtual unsigned int GetReference() const = 0;
|
||||||
|
virtual ::Oyster::Collision3D::Sphere & GetBoundingSphere( ::Oyster::Collision3D::Sphere &targetMem = ::Oyster::Collision3D::Sphere() ) const = 0;
|
||||||
|
virtual ::Oyster::Math::Float3 & GetNormalAt( const ::Oyster::Math::Float3 &worldPos, ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IParticle
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Collision
|
||||||
|
{}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -1,9 +1,9 @@
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
|
|
||||||
using namespace Oyster;
|
using namespace Oyster::Graphics;
|
||||||
|
|
||||||
Oyster::Buffer::Buffer()
|
Buffer::Buffer()
|
||||||
{
|
{
|
||||||
mBuffer = NULL;
|
mBuffer = NULL;
|
||||||
}
|
}
|
||||||
|
@ -23,32 +23,32 @@ HRESULT Buffer::Apply(UINT32 misc) const
|
||||||
{
|
{
|
||||||
UINT32 vertexSize = mElementSize;
|
UINT32 vertexSize = mElementSize;
|
||||||
UINT32 offset = 0;
|
UINT32 offset = 0;
|
||||||
Oyster::Core::DeviceContext->IASetVertexBuffers(misc, 1, &mBuffer, &vertexSize, &offset );
|
Core::deviceContext->IASetVertexBuffers(misc, 1, &mBuffer, &vertexSize, &offset );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INDEX_BUFFER:
|
case INDEX_BUFFER:
|
||||||
{
|
{
|
||||||
Oyster::Core::DeviceContext->IASetIndexBuffer(mBuffer, DXGI_FORMAT_R32_UINT, 0);
|
Core::deviceContext->IASetIndexBuffer(mBuffer, DXGI_FORMAT_R32_UINT, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CONSTANT_BUFFER_VS:
|
case CONSTANT_BUFFER_VS:
|
||||||
{
|
{
|
||||||
Oyster::Core::DeviceContext->VSSetConstantBuffers(misc, 1, &mBuffer);
|
Core::deviceContext->VSSetConstantBuffers(misc, 1, &mBuffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CONSTANT_BUFFER_GS:
|
case CONSTANT_BUFFER_GS:
|
||||||
{
|
{
|
||||||
Oyster::Core::DeviceContext->GSSetConstantBuffers(misc, 1, &mBuffer);
|
Core::deviceContext->GSSetConstantBuffers(misc, 1, &mBuffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CONSTANT_BUFFER_PS:
|
case CONSTANT_BUFFER_PS:
|
||||||
{
|
{
|
||||||
Oyster::Core::DeviceContext->PSSetConstantBuffers(misc, 1, &mBuffer);
|
Core::deviceContext->PSSetConstantBuffers(misc, 1, &mBuffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CONSTANT_BUFFER_CS:
|
case CONSTANT_BUFFER_CS:
|
||||||
{
|
{
|
||||||
Oyster::Core::DeviceContext->CSSetConstantBuffers(misc,1,&mBuffer);
|
Core::deviceContext->CSSetConstantBuffers(misc,1,&mBuffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -145,11 +145,11 @@ HRESULT Buffer::Init(const BUFFER_INIT_DESC& initDesc)
|
||||||
data.pSysMem = initDesc.InitData;
|
data.pSysMem = initDesc.InitData;
|
||||||
data.SysMemPitch=0;
|
data.SysMemPitch=0;
|
||||||
data.SysMemSlicePitch = 0;
|
data.SysMemSlicePitch = 0;
|
||||||
hr = Oyster::Core::Device->CreateBuffer(&bufferDesc, &data, &mBuffer);
|
hr = Core::device->CreateBuffer(&bufferDesc, &data, &mBuffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hr = Oyster::Core::Device->CreateBuffer(&bufferDesc, NULL, &mBuffer);
|
hr = Core::device->CreateBuffer(&bufferDesc, NULL, &mBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(FAILED(hr))
|
if(FAILED(hr))
|
||||||
|
@ -173,7 +173,7 @@ void* Buffer::Map()
|
||||||
else if(mUsage == BUFFER_CPU_WRITE_DISCARD) mapType = D3D11_MAP_WRITE_DISCARD;
|
else if(mUsage == BUFFER_CPU_WRITE_DISCARD) mapType = D3D11_MAP_WRITE_DISCARD;
|
||||||
|
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
if(FAILED(hr = Oyster::Core::DeviceContext->Map(
|
if(FAILED(hr = Core::deviceContext->Map(
|
||||||
mBuffer,
|
mBuffer,
|
||||||
0,
|
0,
|
||||||
(D3D11_MAP)mapType,
|
(D3D11_MAP)mapType,
|
||||||
|
@ -194,10 +194,10 @@ void* Buffer::Map()
|
||||||
|
|
||||||
void Buffer::Unmap()
|
void Buffer::Unmap()
|
||||||
{
|
{
|
||||||
Oyster::Core::DeviceContext->Unmap( mBuffer, 0 );
|
Core::deviceContext->Unmap( mBuffer, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
Oyster::Buffer::operator ID3D11Buffer *()
|
Buffer::operator ID3D11Buffer *()
|
||||||
{
|
{
|
||||||
return this->mBuffer;
|
return this->mBuffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,72 +6,74 @@
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
class Buffer
|
namespace Graphics
|
||||||
{
|
{
|
||||||
public:
|
class Buffer
|
||||||
enum BUFFER_TYPE
|
|
||||||
{
|
{
|
||||||
VERTEX_BUFFER,
|
public:
|
||||||
INDEX_BUFFER,
|
enum BUFFER_TYPE
|
||||||
CONSTANT_BUFFER_VS,
|
|
||||||
CONSTANT_BUFFER_GS,
|
|
||||||
CONSTANT_BUFFER_PS,
|
|
||||||
CONSTANT_BUFFER_CS,
|
|
||||||
STRUCTURED_BUFFER,
|
|
||||||
BUFFER_TYPE_COUNT
|
|
||||||
};
|
|
||||||
|
|
||||||
enum BUFFER_USAGE
|
|
||||||
{
|
|
||||||
BUFFER_DEFAULT,
|
|
||||||
BUFFER_STREAM_OUT_TARGET,
|
|
||||||
BUFFER_CPU_WRITE,
|
|
||||||
BUFFER_CPU_WRITE_DISCARD,
|
|
||||||
BUFFER_CPU_READ,
|
|
||||||
BUFFER_USAGE_COUNT,
|
|
||||||
BUFFER_USAGE_IMMUTABLE
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BUFFER_INIT_DESC
|
|
||||||
{
|
|
||||||
BUFFER_TYPE Type;
|
|
||||||
UINT32 NumElements;
|
|
||||||
UINT32 ElementSize;
|
|
||||||
BUFFER_USAGE Usage;
|
|
||||||
void* InitData;
|
|
||||||
|
|
||||||
BUFFER_INIT_DESC()
|
|
||||||
{
|
{
|
||||||
InitData = NULL;
|
VERTEX_BUFFER,
|
||||||
Usage = BUFFER_DEFAULT;
|
INDEX_BUFFER,
|
||||||
}
|
CONSTANT_BUFFER_VS,
|
||||||
|
CONSTANT_BUFFER_GS,
|
||||||
|
CONSTANT_BUFFER_PS,
|
||||||
|
CONSTANT_BUFFER_CS,
|
||||||
|
STRUCTURED_BUFFER,
|
||||||
|
BUFFER_TYPE_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
|
enum BUFFER_USAGE
|
||||||
|
{
|
||||||
|
BUFFER_DEFAULT,
|
||||||
|
BUFFER_STREAM_OUT_TARGET,
|
||||||
|
BUFFER_CPU_WRITE,
|
||||||
|
BUFFER_CPU_WRITE_DISCARD,
|
||||||
|
BUFFER_CPU_READ,
|
||||||
|
BUFFER_USAGE_COUNT,
|
||||||
|
BUFFER_USAGE_IMMUTABLE
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BUFFER_INIT_DESC
|
||||||
|
{
|
||||||
|
BUFFER_TYPE Type;
|
||||||
|
UINT32 NumElements;
|
||||||
|
UINT32 ElementSize;
|
||||||
|
BUFFER_USAGE Usage;
|
||||||
|
void* InitData;
|
||||||
|
|
||||||
|
BUFFER_INIT_DESC()
|
||||||
|
{
|
||||||
|
InitData = NULL;
|
||||||
|
Usage = BUFFER_DEFAULT;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
protected:
|
||||||
|
ID3D11Buffer* mBuffer;
|
||||||
|
BUFFER_TYPE mType;
|
||||||
|
BUFFER_USAGE mUsage;
|
||||||
|
|
||||||
|
UINT32 mElementSize;
|
||||||
|
UINT32 mElementCount;
|
||||||
|
public:
|
||||||
|
Buffer();
|
||||||
|
virtual ~Buffer();
|
||||||
|
|
||||||
|
HRESULT Init(const BUFFER_INIT_DESC& initDesc);
|
||||||
|
|
||||||
|
void* Map();
|
||||||
|
void Unmap();
|
||||||
|
|
||||||
|
operator ID3D11Buffer*();
|
||||||
|
operator const ID3D11Buffer*() const;
|
||||||
|
|
||||||
|
HRESULT Apply(UINT32 misc = 0) const;
|
||||||
|
|
||||||
|
ID3D11Buffer* GetBufferPointer();
|
||||||
|
UINT32 GetVertexSize();
|
||||||
|
UINT32 GetElementCount();
|
||||||
};
|
};
|
||||||
protected:
|
}
|
||||||
ID3D11Buffer* mBuffer;
|
|
||||||
BUFFER_TYPE mType;
|
|
||||||
BUFFER_USAGE mUsage;
|
|
||||||
|
|
||||||
UINT32 mElementSize;
|
|
||||||
UINT32 mElementCount;
|
|
||||||
public:
|
|
||||||
Buffer();
|
|
||||||
virtual ~Buffer();
|
|
||||||
|
|
||||||
HRESULT Init(const BUFFER_INIT_DESC& initDesc);
|
|
||||||
|
|
||||||
void* Map();
|
|
||||||
void Unmap();
|
|
||||||
|
|
||||||
operator ID3D11Buffer*();
|
|
||||||
operator const ID3D11Buffer*() const;
|
|
||||||
|
|
||||||
HRESULT Apply(UINT32 misc = 0) const;
|
|
||||||
|
|
||||||
ID3D11Buffer* GetBufferPointer();
|
|
||||||
UINT32 GetVertexSize();
|
|
||||||
UINT32 GetElementCount();
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,169 +1,25 @@
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
|
|
||||||
using namespace Oyster;
|
using namespace Oyster::Graphics;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
//GPU
|
//GPU
|
||||||
ID3D11Device *Core::Device = NULL;
|
ID3D11Device *Core::device = NULL;
|
||||||
|
|
||||||
//API
|
//API
|
||||||
ID3D11DeviceContext *Core::DeviceContext = NULL;
|
ID3D11DeviceContext *Core::deviceContext = NULL;
|
||||||
|
|
||||||
//SwapChain
|
//SwapChain
|
||||||
IDXGISwapChain* Core::SwapChain = NULL;
|
IDXGISwapChain* Core::swapChain = NULL;
|
||||||
|
|
||||||
std::stringstream Log;
|
std::stringstream Core::log;
|
||||||
|
|
||||||
inline std::stringstream* AccesLog(){return &Log;}
|
ID3D11RenderTargetView* Core::backBufferRTV = NULL;
|
||||||
|
|
||||||
bool Core::Init(bool SingleThreaded, bool Reference,bool ForceDX11)
|
ID3D11UnorderedAccessView* Core::backBufferUAV = NULL;
|
||||||
{
|
|
||||||
UINT createDeviceFlags = 0;
|
|
||||||
|
|
||||||
if( SingleThreaded )
|
ID3D11DepthStencilView* Core::depthStencil = NULL;
|
||||||
createDeviceFlags = ::D3D11_CREATE_DEVICE_SINGLETHREADED;
|
|
||||||
|
|
||||||
::D3D_DRIVER_TYPE driverType = ::D3D_DRIVER_TYPE_HARDWARE;
|
D3D11_VIEWPORT* Core::viewPort = NULL;
|
||||||
|
|
||||||
if(Reference)
|
Oyster::Math::Float2 Core::resolution = Oyster::Math::Float2::null;
|
||||||
driverType = D3D_DRIVER_TYPE_REFERENCE;
|
|
||||||
|
|
||||||
#if defined(DEBUG) || defined(_DEBUG)
|
|
||||||
Log << "DirectX running in debug mode.\n";
|
|
||||||
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
D3D_FEATURE_LEVEL featureLevelsToTry[] =
|
|
||||||
{
|
|
||||||
D3D_FEATURE_LEVEL_11_0,
|
|
||||||
D3D_FEATURE_LEVEL_10_1,
|
|
||||||
D3D_FEATURE_LEVEL_10_0
|
|
||||||
};
|
|
||||||
D3D_FEATURE_LEVEL initiatedFeatureLevel;
|
|
||||||
|
|
||||||
if( FAILED( ::D3D11CreateDevice( NULL, // default adapter
|
|
||||||
driverType,
|
|
||||||
NULL, // no software device
|
|
||||||
createDeviceFlags,
|
|
||||||
featureLevelsToTry, 3, // default feature level array. DX11 support assumed
|
|
||||||
D3D11_SDK_VERSION,
|
|
||||||
&Device, // device
|
|
||||||
&initiatedFeatureLevel,
|
|
||||||
&DeviceContext ) ) ) // context
|
|
||||||
{ // if failed
|
|
||||||
if( DeviceContext ) { DeviceContext->Release(); DeviceContext = NULL; } // safe cleanup
|
|
||||||
if( Device ) { Device->Release(); Device = NULL; } // safe cleanup
|
|
||||||
}
|
|
||||||
|
|
||||||
if( driverType == ::D3D_DRIVER_TYPE_HARDWARE )
|
|
||||||
Log << "D3D_DRIVER_TYPE_HARDWARE support discovered.\n";
|
|
||||||
else
|
|
||||||
Log << "D3D_DRIVER_TYPE_REFERENCE support discovered.\n";
|
|
||||||
|
|
||||||
if( initiatedFeatureLevel == ::D3D_FEATURE_LEVEL_11_0 )
|
|
||||||
{
|
|
||||||
Log << "DirectX Featurelevel 11.0 supported.\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(ForceDX11)
|
|
||||||
return false;
|
|
||||||
if( initiatedFeatureLevel == ::D3D_FEATURE_LEVEL_10_1 )
|
|
||||||
{
|
|
||||||
Log << "DirectX Featurelevel 10.1 supported.\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( initiatedFeatureLevel == ::D3D_FEATURE_LEVEL_10_0 )
|
|
||||||
{
|
|
||||||
Log << "DirectX Featurelevel 10.0 supported.\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(Device)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Core::CreateSwapChain(HWND Window, int NrofBuffers,bool MSAA_Quality,bool Fullscreen)
|
|
||||||
{
|
|
||||||
//generate static Swapchain Desc
|
|
||||||
DXGI_SWAP_CHAIN_DESC desc;
|
|
||||||
desc.OutputWindow=Window;
|
|
||||||
desc.BufferCount=NrofBuffers;
|
|
||||||
desc.Windowed=!Fullscreen;
|
|
||||||
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_UNORDERED_ACCESS;
|
|
||||||
desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
|
||||||
desc.Flags=0;
|
|
||||||
desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
|
||||||
desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
|
|
||||||
desc.BufferDesc.Scaling = DXGI_MODE_SCALING_CENTERED;
|
|
||||||
desc.BufferDesc.RefreshRate.Denominator=1;
|
|
||||||
desc.BufferDesc.RefreshRate.Numerator=60;
|
|
||||||
|
|
||||||
RECT rc;
|
|
||||||
GetClientRect( Window, &rc );
|
|
||||||
int screenWidth = rc.right - rc.left;
|
|
||||||
int screenHeight = rc.bottom - rc.top;
|
|
||||||
|
|
||||||
desc.BufferDesc.Height = screenHeight;
|
|
||||||
desc.BufferDesc.Width = screenWidth;
|
|
||||||
|
|
||||||
//Check and Set multiSampling
|
|
||||||
if(MSAA_Quality)
|
|
||||||
{
|
|
||||||
if(FAILED(Device->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM,4,&desc.SampleDesc.Quality)))
|
|
||||||
{
|
|
||||||
Log<< "Failed to check multisample quality levels (MSAAQuality).\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
desc.SampleDesc.Count=4;
|
|
||||||
--desc.SampleDesc.Quality;
|
|
||||||
Log << "Supported multisample quality levels (MSAAQuality): " << desc.SampleDesc.Quality+1 << "x\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
desc.SampleDesc.Count=1;
|
|
||||||
desc.SampleDesc.Quality=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Get Device Factory
|
|
||||||
::IDXGIDevice *dxgiDevice = NULL;
|
|
||||||
if( FAILED( Device->QueryInterface( __uuidof( IDXGIDevice ), (void**)&dxgiDevice ) ) )
|
|
||||||
{
|
|
||||||
Log << "Failed to Query for the GPU's dxgiDevice.\nFailed to create swapChain for the GPU.\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
::IDXGIAdapter *dxgiAdapter = NULL;
|
|
||||||
if( FAILED( dxgiDevice->GetParent( __uuidof( IDXGIAdapter ), (void**)&dxgiAdapter ) ) )
|
|
||||||
{
|
|
||||||
dxgiDevice->Release();
|
|
||||||
Log << "Failed to get GPU's parent dxgiAdapter.\nFailed to create swapChain for the GPU.\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
dxgiDevice->Release();
|
|
||||||
|
|
||||||
::IDXGIFactory *dxgiFactory = NULL;
|
|
||||||
if( FAILED( dxgiAdapter->GetParent( __uuidof( IDXGIFactory ), (void**)&dxgiFactory ) ) )
|
|
||||||
{
|
|
||||||
dxgiAdapter->Release();
|
|
||||||
Log << "Failed to get GPU's parent dxgiFactory.\nFailed to create swapChain for the GPU.\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
dxgiAdapter->Release();
|
|
||||||
|
|
||||||
//Create SwapChain
|
|
||||||
if( FAILED( dxgiFactory->CreateSwapChain( Device, &desc, &SwapChain ) ) )
|
|
||||||
{
|
|
||||||
dxgiFactory->Release();
|
|
||||||
Log << "Failed to create swapChain for the GPU.\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
dxgiFactory->Release();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
|
@ -7,108 +7,146 @@
|
||||||
#include "CoreIncludes.h"
|
#include "CoreIncludes.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
|
#include "OysterMath.h"
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
class Core
|
namespace Graphics
|
||||||
{
|
{
|
||||||
public:
|
class Core
|
||||||
|
|
||||||
static ID3D11Device* Device;
|
|
||||||
|
|
||||||
static ID3D11DeviceContext* DeviceContext;
|
|
||||||
|
|
||||||
static IDXGISwapChain* SwapChain;
|
|
||||||
|
|
||||||
static std::stringstream* AccesLog();
|
|
||||||
|
|
||||||
static bool Init(bool SingleThreaded,bool Reference,bool ForceDX11);
|
|
||||||
|
|
||||||
static bool CreateSwapChain(HWND Window, int NrofBuffers,bool MSAA_Quality,bool Fullscreen);
|
|
||||||
|
|
||||||
class ShaderManager
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct ShaderEffect
|
|
||||||
|
static ID3D11Device* device;
|
||||||
|
|
||||||
|
static ID3D11DeviceContext* deviceContext;
|
||||||
|
|
||||||
|
static IDXGISwapChain* swapChain;
|
||||||
|
|
||||||
|
static std::stringstream log;
|
||||||
|
|
||||||
|
//BackBufferRTV
|
||||||
|
static ID3D11RenderTargetView* backBufferRTV;
|
||||||
|
//BackBufferUAV
|
||||||
|
static ID3D11UnorderedAccessView* backBufferUAV;
|
||||||
|
//DepthStencil
|
||||||
|
static ID3D11DepthStencilView* depthStencil;
|
||||||
|
//ViewPort
|
||||||
|
static D3D11_VIEWPORT* viewPort;
|
||||||
|
|
||||||
|
static Oyster::Math::Float2 resolution;
|
||||||
|
|
||||||
|
|
||||||
|
class ShaderManager
|
||||||
{
|
{
|
||||||
struct
|
public:
|
||||||
|
struct ShaderEffect
|
||||||
{
|
{
|
||||||
int Pixel,Vertex,Geometry,Compute,Hull,Domain;
|
struct
|
||||||
}Shaders;
|
{
|
||||||
|
int Pixel,Vertex,Geometry,Compute,Hull,Domain;
|
||||||
|
}Shaders;
|
||||||
|
|
||||||
struct IAStage_
|
struct IAStage_
|
||||||
{
|
{
|
||||||
ID3D11InputLayout* Layout;
|
ID3D11InputLayout* Layout;
|
||||||
D3D11_PRIMITIVE_TOPOLOGY Topology;
|
D3D11_PRIMITIVE_TOPOLOGY Topology;
|
||||||
}IAStage;
|
}IAStage;
|
||||||
|
|
||||||
struct RenderStates_
|
struct RenderStates_
|
||||||
{
|
{
|
||||||
ID3D11DepthStencilState *DepthStencil;
|
ID3D11DepthStencilState *DepthStencil;
|
||||||
ID3D11RasterizerState *Rasterizer;
|
ID3D11RasterizerState *Rasterizer;
|
||||||
ID3D11SamplerState **SampleState;
|
ID3D11SamplerState **SampleState;
|
||||||
int SampleCount;
|
int SampleCount;
|
||||||
ID3D11BlendState *BlendState;
|
ID3D11BlendState *BlendState;
|
||||||
}RenderStates;
|
}RenderStates;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
std::vector<Oyster::Buffer*> Vertex;
|
std::vector<Buffer*> Vertex;
|
||||||
std::vector<Oyster::Buffer*> Geometry;
|
std::vector<Buffer*> Geometry;
|
||||||
std::vector<Oyster::Buffer*> Pixel;
|
std::vector<Buffer*> Pixel;
|
||||||
}CBuffers;
|
}CBuffers;
|
||||||
|
|
||||||
ShaderEffect()
|
ShaderEffect()
|
||||||
|
{
|
||||||
|
RenderStates.BlendState=NULL;
|
||||||
|
RenderStates.DepthStencil=NULL;
|
||||||
|
RenderStates.Rasterizer=NULL;
|
||||||
|
RenderStates.SampleState=NULL;
|
||||||
|
RenderStates.SampleCount=0;
|
||||||
|
Shaders.Compute=-1;
|
||||||
|
Shaders.Domain=-1;
|
||||||
|
Shaders.Geometry=-1;
|
||||||
|
Shaders.Hull=-1;
|
||||||
|
Shaders.Pixel=-1;
|
||||||
|
Shaders.Vertex=-1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
enum ShaderType
|
||||||
{
|
{
|
||||||
RenderStates.BlendState=NULL;
|
Vertex,
|
||||||
RenderStates.DepthStencil=NULL;
|
Hull,
|
||||||
RenderStates.Rasterizer=NULL;
|
Domain,
|
||||||
RenderStates.SampleState=NULL;
|
Geometry,
|
||||||
RenderStates.SampleCount=0;
|
Pixel,
|
||||||
Shaders.Compute=-1;
|
Compute
|
||||||
Shaders.Domain=-1;
|
};
|
||||||
Shaders.Geometry=-1;
|
|
||||||
Shaders.Hull=-1;
|
static void SetShaderEffect(ShaderEffect);
|
||||||
Shaders.Pixel=-1;
|
|
||||||
Shaders.Vertex=-1;
|
static void CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout);
|
||||||
}
|
|
||||||
};
|
static bool Init(std::wstring filename, ShaderType type, std::wstring name, bool Precompiled = true);
|
||||||
enum ShaderType
|
|
||||||
{
|
struct Get
|
||||||
Vertex,
|
{
|
||||||
Hull,
|
static int Pixel(std::wstring Name);
|
||||||
Domain,
|
static int Vertex(std::wstring Name);
|
||||||
Geometry,
|
static int Geometry(std::wstring Name);
|
||||||
Pixel,
|
static int Compute(std::wstring Name);
|
||||||
Compute
|
static int Hull(std::wstring Name);
|
||||||
|
static int Domain(std::wstring Name);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Set
|
||||||
|
{
|
||||||
|
static void Pixel(int Index);
|
||||||
|
static void Vertex(int Index);
|
||||||
|
static void Geometry(int Index);
|
||||||
|
static void Compute(int Index);
|
||||||
|
static void Hull(int Index);
|
||||||
|
static void Domain(int Index);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
static void SetShaderEffect(ShaderEffect);
|
//Set resulotion Before Calling Full Init
|
||||||
|
class Init
|
||||||
static void CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout);
|
|
||||||
|
|
||||||
static bool Init(std::wstring filename, ShaderType type, std::wstring name, bool Precompiled = true);
|
|
||||||
|
|
||||||
struct Get
|
|
||||||
{
|
{
|
||||||
static int Pixel(std::wstring Name);
|
public:
|
||||||
static int Vertex(std::wstring Name);
|
enum State
|
||||||
static int Geometry(std::wstring Name);
|
{
|
||||||
static int Compute(std::wstring Name);
|
Sucsess,
|
||||||
static int Hull(std::wstring Name);
|
Fail
|
||||||
static int Domain(std::wstring Name);
|
};
|
||||||
};
|
|
||||||
|
|
||||||
struct Set
|
static State CreateDeviceAndDeviceContext(bool SingleThreaded = true, bool Reference = false, bool ForceDX11 = true);
|
||||||
{
|
|
||||||
static void Pixel(int Index);
|
static State CreateSwapChain(HWND Window, int NrofBuffers,bool MSAA_Quality,bool Fullscreen, Oyster::Math::Float2 Size);
|
||||||
static void Vertex(int Index);
|
|
||||||
static void Geometry(int Index);
|
static State CreateDepthStencil(bool MSAA_Quality, Oyster::Math::Float2 Size);
|
||||||
static void Compute(int Index);
|
|
||||||
static void Hull(int Index);
|
static State CreateBackBufferViews();
|
||||||
static void Domain(int Index);
|
|
||||||
|
static State CreateViewPort(Oyster::Math::Float2 Origin, Oyster::Math::Float2 Size);
|
||||||
|
|
||||||
|
static State FullInit(HWND Window, bool MSAA_Quality, bool Fullscreen);
|
||||||
|
|
||||||
|
static State ReInitialize(HWND Window, bool MSAA_Quality, bool Fullscreen);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
// http://lolengine.net/blog/2011/3/4/fuck-you-microsoft-near-far-macros
|
// http://lolengine.net/blog/2011/3/4/fuck-you-microsoft-near-far-macros
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <D3D11.h>
|
#include <D3D11.h>
|
||||||
#include <d3dCompiler.h>
|
#include <d3dcompiler.h>
|
||||||
|
|
||||||
#pragma comment(lib, "d3d11.lib")
|
#pragma comment(lib, "d3d11.lib")
|
||||||
#pragma comment(lib, "d3dcompiler.lib")
|
#pragma comment(lib, "d3dcompiler.lib")
|
||||||
|
|
|
@ -0,0 +1,337 @@
|
||||||
|
#include "Core.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
Core::Init::State Core::Init::CreateDeviceAndDeviceContext(bool SingleThreaded,bool Reference,bool ForceDX11)
|
||||||
|
{
|
||||||
|
UINT createDeviceFlags = 0;
|
||||||
|
|
||||||
|
if(Core::deviceContext)
|
||||||
|
{
|
||||||
|
Core::deviceContext->Release();
|
||||||
|
delete Core::deviceContext;
|
||||||
|
}
|
||||||
|
if(Core::device)
|
||||||
|
{
|
||||||
|
Core::device->Release();
|
||||||
|
delete Core::device;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if( SingleThreaded )
|
||||||
|
createDeviceFlags = ::D3D11_CREATE_DEVICE_SINGLETHREADED;
|
||||||
|
|
||||||
|
::D3D_DRIVER_TYPE driverType = ::D3D_DRIVER_TYPE_HARDWARE;
|
||||||
|
|
||||||
|
if(Reference)
|
||||||
|
driverType = D3D_DRIVER_TYPE_REFERENCE;
|
||||||
|
|
||||||
|
#if defined(DEBUG) || defined(_DEBUG)
|
||||||
|
log << "DirectX running in debug mode.\n";
|
||||||
|
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
D3D_FEATURE_LEVEL featureLevelsToTry[] =
|
||||||
|
{
|
||||||
|
D3D_FEATURE_LEVEL_11_0,
|
||||||
|
D3D_FEATURE_LEVEL_10_1,
|
||||||
|
D3D_FEATURE_LEVEL_10_0
|
||||||
|
};
|
||||||
|
D3D_FEATURE_LEVEL initiatedFeatureLevel;
|
||||||
|
|
||||||
|
if( FAILED( ::D3D11CreateDevice( NULL, // default adapter
|
||||||
|
driverType,
|
||||||
|
NULL, // no software device
|
||||||
|
createDeviceFlags,
|
||||||
|
featureLevelsToTry, 3, // default feature level array. DX11 support assumed
|
||||||
|
D3D11_SDK_VERSION,
|
||||||
|
&Core::device, // device
|
||||||
|
&initiatedFeatureLevel,
|
||||||
|
&Core::deviceContext ) ) ) // context
|
||||||
|
{ // if failed
|
||||||
|
if( Core::deviceContext ) { Core::deviceContext->Release(); Core::deviceContext = NULL; } // safe cleanup
|
||||||
|
if( Core::device ) { Core::device->Release(); Core::device = NULL; } // safe cleanup
|
||||||
|
}
|
||||||
|
|
||||||
|
if( driverType == ::D3D_DRIVER_TYPE_HARDWARE )
|
||||||
|
log << "D3D_DRIVER_TYPE_HARDWARE support discovered.\n";
|
||||||
|
else
|
||||||
|
log << "D3D_DRIVER_TYPE_REFERENCE support discovered.\n";
|
||||||
|
|
||||||
|
if( initiatedFeatureLevel == ::D3D_FEATURE_LEVEL_11_0 )
|
||||||
|
{
|
||||||
|
log << "DirectX Featurelevel 11.0 supported.\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(ForceDX11)
|
||||||
|
return Init::Fail;
|
||||||
|
if( initiatedFeatureLevel == ::D3D_FEATURE_LEVEL_10_1 )
|
||||||
|
{
|
||||||
|
log << "DirectX Featurelevel 10.1 supported.\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( initiatedFeatureLevel == ::D3D_FEATURE_LEVEL_10_0 )
|
||||||
|
{
|
||||||
|
log << "DirectX Featurelevel 10.0 supported.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(Core::device)
|
||||||
|
return Init::Sucsess;
|
||||||
|
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Core::Init::CreateSwapChain(HWND Window, int NrofBuffers,bool MSAA_Quality,bool Fullscreen, Oyster::Math::Float2 Size)
|
||||||
|
{
|
||||||
|
//generate static Swapchain Desc
|
||||||
|
DXGI_SWAP_CHAIN_DESC desc;
|
||||||
|
desc.OutputWindow=Window;
|
||||||
|
desc.BufferCount=NrofBuffers;
|
||||||
|
desc.Windowed=!Fullscreen;
|
||||||
|
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_UNORDERED_ACCESS;
|
||||||
|
desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
||||||
|
desc.Flags=0;
|
||||||
|
desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
|
||||||
|
desc.BufferDesc.Scaling = DXGI_MODE_SCALING_CENTERED;
|
||||||
|
desc.BufferDesc.RefreshRate.Denominator=1;
|
||||||
|
desc.BufferDesc.RefreshRate.Numerator=60;
|
||||||
|
|
||||||
|
desc.BufferDesc.Height = Size.y;
|
||||||
|
desc.BufferDesc.Width = Size.x;
|
||||||
|
|
||||||
|
if(Core::swapChain)
|
||||||
|
{
|
||||||
|
Core::swapChain->Release();
|
||||||
|
delete Core::swapChain;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Check and Set multiSampling
|
||||||
|
if(MSAA_Quality)
|
||||||
|
{
|
||||||
|
if(FAILED(Core::device->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM,4,&desc.SampleDesc.Quality)))
|
||||||
|
{
|
||||||
|
log<< "Failed to check multisample quality levels (MSAAQuality).\n";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
desc.SampleDesc.Count=4;
|
||||||
|
--desc.SampleDesc.Quality;
|
||||||
|
log << "Supported multisample quality levels (MSAAQuality): " << desc.SampleDesc.Quality+1 << "x\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
desc.SampleDesc.Count=1;
|
||||||
|
desc.SampleDesc.Quality=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get Device Factory
|
||||||
|
::IDXGIDevice *dxgiDevice = NULL;
|
||||||
|
if( FAILED( Core::device->QueryInterface( __uuidof( IDXGIDevice ), (void**)&dxgiDevice ) ) )
|
||||||
|
{
|
||||||
|
log << "Failed to Query for the GPU's dxgiDevice.\nFailed to create swapChain for the GPU.\n";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
::IDXGIAdapter *dxgiAdapter = NULL;
|
||||||
|
if( FAILED( dxgiDevice->GetParent( __uuidof( IDXGIAdapter ), (void**)&dxgiAdapter ) ) )
|
||||||
|
{
|
||||||
|
dxgiDevice->Release();
|
||||||
|
log << "Failed to get GPU's parent dxgiAdapter.\nFailed to create swapChain for the GPU.\n";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
dxgiDevice->Release();
|
||||||
|
|
||||||
|
::IDXGIFactory *dxgiFactory = NULL;
|
||||||
|
if( FAILED( dxgiAdapter->GetParent( __uuidof( IDXGIFactory ), (void**)&dxgiFactory ) ) )
|
||||||
|
{
|
||||||
|
dxgiAdapter->Release();
|
||||||
|
log << "Failed to get GPU's parent dxgiFactory.\nFailed to create swapChain for the GPU.\n";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
dxgiAdapter->Release();
|
||||||
|
|
||||||
|
//Create SwapChain
|
||||||
|
if( FAILED( dxgiFactory->CreateSwapChain( Core::device, &desc, &Core::swapChain ) ) )
|
||||||
|
{
|
||||||
|
dxgiFactory->Release();
|
||||||
|
log << "Failed to create swapChain for the GPU.\n";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
dxgiFactory->Release();
|
||||||
|
|
||||||
|
return Init::Sucsess;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Core::Init::CreateDepthStencil(bool MSAA_Quality, Oyster::Math::Float2 Size)
|
||||||
|
{
|
||||||
|
D3D11_TEXTURE2D_DESC desc;
|
||||||
|
desc.MipLevels=1;
|
||||||
|
desc.ArraySize=1;
|
||||||
|
desc.Format = DXGI_FORMAT_D32_FLOAT;
|
||||||
|
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||||
|
desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
||||||
|
desc.CPUAccessFlags=0;
|
||||||
|
desc.MiscFlags=0;
|
||||||
|
desc.Height = Size.y;
|
||||||
|
desc.Width = Size.x;
|
||||||
|
|
||||||
|
if(Core::depthStencil)
|
||||||
|
{
|
||||||
|
Core::depthStencil->Release();
|
||||||
|
delete Core::depthStencil;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check and Set multiSampling
|
||||||
|
if(MSAA_Quality)
|
||||||
|
{
|
||||||
|
if(FAILED(Core::device->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM,4,&desc.SampleDesc.Quality)))
|
||||||
|
{
|
||||||
|
log<< "Failed to check multisample quality levels (MSAAQuality).\n";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
desc.SampleDesc.Count=4;
|
||||||
|
--desc.SampleDesc.Quality;
|
||||||
|
log << "Supported multisample quality levels (MSAAQuality): " << desc.SampleDesc.Quality+1 << "x\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
desc.SampleDesc.Count=1;
|
||||||
|
desc.SampleDesc.Quality=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ID3D11Texture2D* depthstencil;
|
||||||
|
|
||||||
|
if(FAILED(Core::device->CreateTexture2D(&desc,0,&depthstencil)))
|
||||||
|
return Init::Fail;
|
||||||
|
if(FAILED(Core::device->CreateDepthStencilView(depthstencil,0,&Core::depthStencil)))
|
||||||
|
{
|
||||||
|
depthstencil->Release();
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
depthstencil->Release();
|
||||||
|
|
||||||
|
return Init::Sucsess;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Core::Init::CreateBackBufferViews()
|
||||||
|
{
|
||||||
|
D3D11_UNORDERED_ACCESS_VIEW_DESC descView;
|
||||||
|
ZeroMemory( &descView, sizeof(descView) );
|
||||||
|
descView.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2D;
|
||||||
|
descView.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
descView.Texture2D.MipSlice=0;
|
||||||
|
|
||||||
|
ID3D11Texture2D* backBuffer;
|
||||||
|
if(FAILED(Core::swapChain->GetBuffer(0,__uuidof(ID3D11Texture2D),reinterpret_cast<void**>(&backBuffer))))
|
||||||
|
{
|
||||||
|
log << "Failed to get BackBuffer from Swapchain";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
if(Core::backBufferRTV)
|
||||||
|
{
|
||||||
|
Core::backBufferRTV->Release();
|
||||||
|
delete Core::backBufferRTV;
|
||||||
|
}
|
||||||
|
if(FAILED(Core::device->CreateRenderTargetView(backBuffer,0,&Core::backBufferRTV)))
|
||||||
|
{
|
||||||
|
log << "Failed to create RTV for BackBuffer";
|
||||||
|
backBuffer->Release();
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
if(Core::backBufferUAV)
|
||||||
|
{
|
||||||
|
Core::backBufferUAV->Release();
|
||||||
|
delete Core::backBufferUAV;
|
||||||
|
}
|
||||||
|
if(FAILED(Core::device->CreateUnorderedAccessView(backBuffer,0,&Core::backBufferUAV)))
|
||||||
|
{
|
||||||
|
log << "Failed to create UAV for BackBuffer";
|
||||||
|
backBuffer->Release();
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
backBuffer->Release();
|
||||||
|
|
||||||
|
return Init::Sucsess;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Core::Init::CreateViewPort(Oyster::Math::Float2 Origin, Oyster::Math::Float2 Size)
|
||||||
|
{
|
||||||
|
if(Core::viewPort)
|
||||||
|
delete Core::viewPort;
|
||||||
|
Core::viewPort = new D3D11_VIEWPORT;
|
||||||
|
|
||||||
|
Core::viewPort->TopLeftX = Origin.x;
|
||||||
|
Core::viewPort->TopLeftY = Origin.y;
|
||||||
|
Core::viewPort->Width = Size.x;
|
||||||
|
Core::viewPort->Height = Size.y;
|
||||||
|
Core::viewPort->MinDepth = 0.0f;
|
||||||
|
Core::viewPort->MaxDepth = 1.0f;
|
||||||
|
|
||||||
|
return Init::Sucsess;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Core::Init::FullInit(HWND Window, bool MSAA_Quality, bool Fullscreen)
|
||||||
|
{
|
||||||
|
if(Init::CreateDeviceAndDeviceContext() == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateSwapChain(Window, 1, MSAA_Quality, Fullscreen, Core::resolution) == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateDepthStencil(MSAA_Quality, Core::resolution) == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateBackBufferViews() == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateViewPort(Oyster::Math::Float2::null, Core::resolution) == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Init::Sucsess;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Core::Init::ReInitialize(HWND Window, bool MSAA_Quality, bool Fullscreen)
|
||||||
|
{
|
||||||
|
if(Init::CreateSwapChain(Window, 1, MSAA_Quality, Fullscreen, Core::resolution) == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateDepthStencil(MSAA_Quality, Core::resolution) == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateBackBufferViews() == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateViewPort(Oyster::Math::Float2::null, Core::resolution) == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Init::Sucsess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,347 +5,346 @@ const char* ShaderFunction = "main";
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
bool LoadPrecompiled(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name);
|
namespace Graphics
|
||||||
bool LoadCompile(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name);
|
|
||||||
namespace
|
|
||||||
{
|
{
|
||||||
struct ShaderData
|
bool LoadPrecompiled(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name);
|
||||||
|
bool LoadCompile(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name);
|
||||||
|
namespace
|
||||||
{
|
{
|
||||||
size_t size;
|
struct ShaderData
|
||||||
char* data;
|
{
|
||||||
};
|
size_t size;
|
||||||
std::vector<ID3D11PixelShader*> PS;
|
char* data;
|
||||||
std::map<std::wstring,int> PSMap;
|
};
|
||||||
|
std::vector<ID3D11PixelShader*> PS;
|
||||||
|
std::map<std::wstring,int> PSMap;
|
||||||
|
|
||||||
std::vector<ID3D11GeometryShader*> GS;
|
std::vector<ID3D11GeometryShader*> GS;
|
||||||
std::map<std::wstring,int> GSMap;
|
std::map<std::wstring,int> GSMap;
|
||||||
|
|
||||||
std::vector<ID3D11ComputeShader*> CS;
|
std::vector<ID3D11ComputeShader*> CS;
|
||||||
std::map<std::wstring,int> CSMap;
|
std::map<std::wstring,int> CSMap;
|
||||||
|
|
||||||
std::vector<ID3D11VertexShader*> VS;
|
std::vector<ID3D11VertexShader*> VS;
|
||||||
std::vector<ShaderData> VData;
|
std::vector<ShaderData> VData;
|
||||||
std::map<std::wstring,int> VSMap;
|
std::map<std::wstring,int> VSMap;
|
||||||
}
|
|
||||||
|
|
||||||
#pragma region Init
|
|
||||||
bool Core::ShaderManager::Init(std::wstring filename, ShaderType type, std::wstring name, bool Precompiled)
|
|
||||||
{
|
|
||||||
if(Precompiled)
|
|
||||||
{
|
|
||||||
return LoadPrecompiled(filename, type, name);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
#pragma region Init
|
||||||
|
bool Core::ShaderManager::Init(std::wstring filename, ShaderType type, std::wstring name, bool Precompiled)
|
||||||
{
|
{
|
||||||
return LoadCompile(filename, type, name);
|
if(Precompiled)
|
||||||
|
{
|
||||||
|
return LoadPrecompiled(filename, type, name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return LoadCompile(filename, type, name);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LoadPrecompiled(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name)
|
bool LoadPrecompiled(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name)
|
||||||
{
|
|
||||||
|
|
||||||
std::ifstream stream;
|
|
||||||
ShaderData sd;
|
|
||||||
|
|
||||||
|
|
||||||
//Create Vertex shader and Layout
|
|
||||||
stream.open(filename, std::ifstream::in | std::ifstream::binary);
|
|
||||||
if(stream.good())
|
|
||||||
{
|
{
|
||||||
stream.seekg(0, std::ios::end);
|
|
||||||
sd.size = size_t(stream.tellg());
|
std::ifstream stream;
|
||||||
sd.data = new char[sd.size];
|
ShaderData sd;
|
||||||
stream.seekg(0, std::ios::beg);
|
|
||||||
stream.read(&sd.data[0], sd.size);
|
|
||||||
stream.close();
|
|
||||||
|
|
||||||
|
|
||||||
ID3D11VertexShader* vertex;
|
//Create Vertex shader and Layout
|
||||||
ID3D11GeometryShader* geometry;
|
stream.open(filename, std::ifstream::in | std::ifstream::binary);
|
||||||
ID3D11PixelShader* pixel;
|
if(stream.good())
|
||||||
ID3D11ComputeShader* compute;
|
{
|
||||||
|
stream.seekg(0, std::ios::end);
|
||||||
|
sd.size = size_t(stream.tellg());
|
||||||
|
sd.data = new char[sd.size];
|
||||||
|
stream.seekg(0, std::ios::beg);
|
||||||
|
stream.read(&sd.data[0], sd.size);
|
||||||
|
stream.close();
|
||||||
|
|
||||||
|
|
||||||
|
ID3D11VertexShader* vertex;
|
||||||
|
ID3D11GeometryShader* geometry;
|
||||||
|
ID3D11PixelShader* pixel;
|
||||||
|
ID3D11ComputeShader* compute;
|
||||||
|
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case Core::ShaderManager::ShaderType::Vertex:
|
||||||
|
|
||||||
|
if(VSMap.count(name))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(FAILED(Core::device->CreateVertexShader(sd.data, sd.size, 0, &vertex)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
VSMap[name] = VS.size();
|
||||||
|
VS.push_back(vertex);
|
||||||
|
VData.push_back(sd);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Core::ShaderManager::ShaderType::Hull:
|
||||||
|
case Core::ShaderManager::ShaderType::Domain:
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case Core::ShaderManager::ShaderType::Geometry:
|
||||||
|
|
||||||
|
if(GSMap.count(name))
|
||||||
|
return false;
|
||||||
|
if(FAILED(Core::device->CreateGeometryShader(sd.data, sd.size, 0, &geometry)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
GSMap[name] = GS.size();
|
||||||
|
GS.push_back(geometry);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Core::ShaderManager::ShaderType::Pixel:
|
||||||
|
|
||||||
|
if(PSMap.count(name))
|
||||||
|
return false;
|
||||||
|
if(FAILED(Core::device->CreatePixelShader(sd.data, sd.size, 0, &pixel)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
PSMap[name] = PS.size();
|
||||||
|
PS.push_back(pixel);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Core::ShaderManager::ShaderType::Compute:
|
||||||
|
|
||||||
|
if(CSMap.count(name))
|
||||||
|
return false;
|
||||||
|
if(FAILED(Core::device->CreateComputeShader(sd.data, sd.size, 0, &compute)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
CSMap[name] = CS.size();
|
||||||
|
CS.push_back(compute);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LoadCompile(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name)
|
||||||
|
{
|
||||||
|
/// \todo error reporting
|
||||||
|
ID3D10Blob *Shader,*Error;
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case Core::ShaderManager::ShaderType::Vertex:
|
case Core::ShaderManager::ShaderType::Pixel:
|
||||||
|
|
||||||
if(VSMap.count(name))
|
ID3D11PixelShader* pixel;
|
||||||
return false;
|
|
||||||
|
|
||||||
if(FAILED(Core::Device->CreateVertexShader(sd.data, sd.size, 0, &vertex)))
|
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"ps_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error)))
|
||||||
{
|
{
|
||||||
|
std::string fel = (char*)Error->GetBufferPointer();
|
||||||
|
Error->Release();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
VSMap[name] = VS.size();
|
if(FAILED(Core::device->CreatePixelShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&pixel)))
|
||||||
VS.push_back(vertex);
|
{
|
||||||
VData.push_back(sd);
|
Shader->Release();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Shader->Release();
|
||||||
|
if(!PSMap.count(name))
|
||||||
|
{
|
||||||
|
PSMap[name] = PS.size();
|
||||||
|
PS.push_back(pixel);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PS[PSMap[name]] = pixel;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Core::ShaderManager::ShaderType::Hull:
|
|
||||||
case Core::ShaderManager::ShaderType::Domain:
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
case Core::ShaderManager::ShaderType::Geometry:
|
case Core::ShaderManager::ShaderType::Geometry:
|
||||||
|
|
||||||
if(GSMap.count(name))
|
ID3D11GeometryShader* geometry;
|
||||||
return false;
|
|
||||||
if(FAILED(Core::Device->CreateGeometryShader(sd.data, sd.size, 0, &geometry)))
|
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"gs_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error)))
|
||||||
{
|
{
|
||||||
|
std::string fel = (char*)Error->GetBufferPointer();
|
||||||
|
Error->Release();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
GSMap[name] = GS.size();
|
if(FAILED(Core::device->CreateGeometryShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&geometry)))
|
||||||
GS.push_back(geometry);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Core::ShaderManager::ShaderType::Pixel:
|
|
||||||
|
|
||||||
if(PSMap.count(name))
|
|
||||||
return false;
|
|
||||||
if(FAILED(Core::Device->CreatePixelShader(sd.data, sd.size, 0, &pixel)))
|
|
||||||
{
|
{
|
||||||
|
Shader->Release();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PSMap[name] = PS.size();
|
Shader->Release();
|
||||||
PS.push_back(pixel);
|
if(!GSMap.count(name))
|
||||||
|
{
|
||||||
|
GSMap[name] = GS.size();
|
||||||
|
GS.push_back(geometry);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GS[GSMap[name]] = geometry;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Core::ShaderManager::ShaderType::Compute:
|
case Core::ShaderManager::ShaderType::Vertex:
|
||||||
|
|
||||||
if(CSMap.count(name))
|
ID3D11VertexShader* vertex;
|
||||||
return false;
|
|
||||||
if(FAILED(Core::Device->CreateComputeShader(sd.data, sd.size, 0, &compute)))
|
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"vs_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error)))
|
||||||
{
|
{
|
||||||
|
std::string fel = (char*)Error->GetBufferPointer();
|
||||||
|
Error->Release();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CSMap[name] = CS.size();
|
if(FAILED(Core::device->CreateVertexShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&vertex)))
|
||||||
CS.push_back(compute);
|
{
|
||||||
|
Shader->Release();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(!VSMap.count(name))
|
||||||
|
{
|
||||||
|
VSMap[name] = VS.size();
|
||||||
|
VS.push_back(vertex);
|
||||||
|
ShaderData sd;
|
||||||
|
sd.size = Shader->GetBufferSize();
|
||||||
|
sd.data = new char[sd.size];
|
||||||
|
memcpy(sd.data,Shader->GetBufferPointer(),sd.size);
|
||||||
|
VData.push_back(sd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VS[VSMap[name]] = vertex;
|
||||||
|
delete[] VData[VSMap[name]].data;
|
||||||
|
VData[VSMap[name]].size = Shader->GetBufferSize();
|
||||||
|
VData[VSMap[name]].data = new char[VData[VSMap[name]].size];
|
||||||
|
memcpy(VData[VSMap[name]].data,Shader->GetBufferPointer(),VData[VSMap[name]].size);
|
||||||
|
}
|
||||||
|
|
||||||
|
Shader->Release();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
#pragma endregion
|
||||||
|
|
||||||
|
void Core::ShaderManager::CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout)
|
||||||
{
|
{
|
||||||
return false;
|
if(VertexIndex==-1)
|
||||||
|
{
|
||||||
|
Layout=0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Core::device->CreateInputLayout(desc,ElementCount,VData[VertexIndex].data,VData[VertexIndex].size,&Layout);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LoadCompile(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name)
|
#pragma region Get
|
||||||
{
|
int Core::ShaderManager::Get::Pixel(std::wstring Name)
|
||||||
/// \todo error reporting
|
|
||||||
ID3D10Blob *Shader,*Error;
|
|
||||||
switch(type)
|
|
||||||
{
|
{
|
||||||
case Core::ShaderManager::ShaderType::Pixel:
|
if(PSMap.count(Name))
|
||||||
|
return PSMap[Name];
|
||||||
ID3D11PixelShader* pixel;
|
return -1;
|
||||||
|
|
||||||
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"ps_5_0",0,0,&Shader,&Error)))
|
|
||||||
{
|
|
||||||
std::string fel = (char*)Error->GetBufferPointer();
|
|
||||||
Error->Release();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(FAILED(Oyster::Core::Device->CreatePixelShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&pixel)))
|
|
||||||
{
|
|
||||||
Error->Release();
|
|
||||||
Shader->Release();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Shader->Release();
|
|
||||||
if(!PSMap.count(name))
|
|
||||||
{
|
|
||||||
PSMap[name] = PS.size();
|
|
||||||
PS.push_back(pixel);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PS[PSMap[name]] = pixel;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Core::ShaderManager::ShaderType::Geometry:
|
|
||||||
|
|
||||||
ID3D11GeometryShader* geometry;
|
|
||||||
|
|
||||||
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"gs_5_0",0,0,&Shader,&Error)))
|
|
||||||
{
|
|
||||||
std::string fel = (char*)Error->GetBufferPointer();
|
|
||||||
Error->Release();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(FAILED(Oyster::Core::Device->CreateGeometryShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&geometry)))
|
|
||||||
{
|
|
||||||
Error->Release();
|
|
||||||
Shader->Release();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Shader->Release();
|
|
||||||
if(!GSMap.count(name))
|
|
||||||
{
|
|
||||||
GSMap[name] = GS.size();
|
|
||||||
GS.push_back(geometry);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GS[GSMap[name]] = geometry;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Core::ShaderManager::ShaderType::Vertex:
|
|
||||||
|
|
||||||
ID3D11VertexShader* vertex;
|
|
||||||
|
|
||||||
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"vs_5_0",0,0,&Shader,&Error)))
|
|
||||||
{
|
|
||||||
std::string fel = (char*)Error->GetBufferPointer();
|
|
||||||
Error->Release();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(FAILED(Oyster::Core::Device->CreateVertexShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&vertex)))
|
|
||||||
{
|
|
||||||
Error->Release();
|
|
||||||
Shader->Release();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(!VSMap.count(name))
|
|
||||||
{
|
|
||||||
VSMap[name] = VS.size();
|
|
||||||
VS.push_back(vertex);
|
|
||||||
ShaderData sd;
|
|
||||||
sd.size = Shader->GetBufferSize();
|
|
||||||
sd.data = new char[sd.size];
|
|
||||||
memcpy(sd.data,Shader->GetBufferPointer(),sd.size);
|
|
||||||
VData.push_back(sd);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
VS[VSMap[name]] = vertex;
|
|
||||||
delete[] VData[VSMap[name]].data;
|
|
||||||
VData[VSMap[name]].size = Shader->GetBufferSize();
|
|
||||||
VData[VSMap[name]].data = new char[VData[VSMap[name]].size];
|
|
||||||
memcpy(VData[VSMap[name]].data,Shader->GetBufferPointer(),VData[VSMap[name]].size);
|
|
||||||
}
|
|
||||||
|
|
||||||
Shader->Release();
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#pragma endregion
|
|
||||||
|
|
||||||
void Core::ShaderManager::CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout)
|
int Core::ShaderManager::Get::Vertex(std::wstring Name)
|
||||||
{
|
{
|
||||||
if(VertexIndex==-1)
|
if(VSMap.count(Name))
|
||||||
|
return VSMap[Name];
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int Core::ShaderManager::Get::Geometry(std::wstring Name)
|
||||||
|
{
|
||||||
|
if(GSMap.count(Name))
|
||||||
|
return GSMap[Name];
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Core::ShaderManager::Get::Compute(std::wstring Name)
|
||||||
|
{
|
||||||
|
if(CSMap.count(Name))
|
||||||
|
return CSMap[Name];
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int Core::ShaderManager::Get::Hull(std::wstring Name)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int Core::ShaderManager::Get::Domain(std::wstring Name)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Set
|
||||||
|
/// \todo smart set
|
||||||
|
void Core::ShaderManager::Set::Pixel(int Index)
|
||||||
|
{
|
||||||
|
if(Index==-1)
|
||||||
|
Core::deviceContext->PSSetShader( NULL,NULL,0);
|
||||||
|
else
|
||||||
|
Core::deviceContext->PSSetShader( PS[Index],NULL,0);
|
||||||
|
}
|
||||||
|
void Core::ShaderManager::Set::Vertex(int Index)
|
||||||
|
{
|
||||||
|
if(Index==-1)
|
||||||
|
Core::deviceContext->VSSetShader( NULL,NULL,0);
|
||||||
|
else
|
||||||
|
Core::deviceContext->VSSetShader( VS[Index],NULL,0);
|
||||||
|
}
|
||||||
|
void Core::ShaderManager::Set::Geometry(int Index)
|
||||||
|
{
|
||||||
|
if(Index==-1)
|
||||||
|
Core::deviceContext->GSSetShader( NULL,NULL,0);
|
||||||
|
else
|
||||||
|
Core::deviceContext->GSSetShader( GS[Index],NULL,0);
|
||||||
|
}
|
||||||
|
void Core::ShaderManager::Set::Compute(int Index)
|
||||||
|
{
|
||||||
|
if(Index==-1)
|
||||||
|
Core::deviceContext->CSSetShader( NULL,NULL,0);
|
||||||
|
else
|
||||||
|
Core::deviceContext->CSSetShader( CS[Index],NULL,0);
|
||||||
|
}
|
||||||
|
/// \todo set Hull
|
||||||
|
void Core::ShaderManager::Set::Hull(int Index)
|
||||||
{
|
{
|
||||||
Layout=0;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Device->CreateInputLayout(desc,ElementCount,VData[VertexIndex].data,VData[VertexIndex].size,&Layout);
|
/// \todo set Domain
|
||||||
}
|
void Core::ShaderManager::Set::Domain(int Index)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region Get
|
/// \todo smart Set ie. not resetting the shader
|
||||||
int Core::ShaderManager::Get::Pixel(std::wstring Name)
|
/// \todo research states
|
||||||
{
|
/// \todo smart buffer set
|
||||||
if(PSMap.count(Name))
|
void Core::ShaderManager::SetShaderEffect(ShaderEffect se)
|
||||||
return PSMap[Name];
|
{
|
||||||
return -1;
|
Set::Pixel(se.Shaders.Pixel);
|
||||||
|
Set::Vertex(se.Shaders.Vertex);
|
||||||
|
Set::Geometry(se.Shaders.Geometry);
|
||||||
|
Set::Compute(se.Shaders.Compute);
|
||||||
|
Core::deviceContext->IASetInputLayout(se.IAStage.Layout);
|
||||||
|
Core::deviceContext->IASetPrimitiveTopology(se.IAStage.Topology);
|
||||||
|
for(unsigned int i=0;i<se.CBuffers.Vertex.size();++i)
|
||||||
|
se.CBuffers.Vertex[i]->Apply(i);
|
||||||
|
for(unsigned int i=0;i<se.CBuffers.Geometry.size();++i)
|
||||||
|
se.CBuffers.Geometry[i]->Apply(i);
|
||||||
|
for(unsigned int i=0;i<se.CBuffers.Pixel.size();++i)
|
||||||
|
se.CBuffers.Pixel[i]->Apply(i);
|
||||||
|
Core::deviceContext->RSSetState(se.RenderStates.Rasterizer);
|
||||||
|
Core::deviceContext->PSSetSamplers(0,se.RenderStates.SampleCount,se.RenderStates.SampleState);
|
||||||
|
float test[4] = {0};
|
||||||
|
Core::deviceContext->OMSetBlendState(se.RenderStates.BlendState,test,-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Core::ShaderManager::Get::Vertex(std::wstring Name)
|
|
||||||
{
|
|
||||||
if(VSMap.count(Name))
|
|
||||||
return VSMap[Name];
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
int Core::ShaderManager::Get::Geometry(std::wstring Name)
|
|
||||||
{
|
|
||||||
if(GSMap.count(Name))
|
|
||||||
return GSMap[Name];
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Core::ShaderManager::Get::Compute(std::wstring Name)
|
|
||||||
{
|
|
||||||
if(CSMap.count(Name))
|
|
||||||
return CSMap[Name];
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
int Core::ShaderManager::Get::Hull(std::wstring Name)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
int Core::ShaderManager::Get::Domain(std::wstring Name)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#pragma endregion
|
|
||||||
|
|
||||||
#pragma region Set
|
|
||||||
/// \todo smart set
|
|
||||||
void Core::ShaderManager::Set::Pixel(int Index)
|
|
||||||
{
|
|
||||||
if(Index==-1)
|
|
||||||
DeviceContext->PSSetShader( NULL,NULL,0);
|
|
||||||
else
|
|
||||||
DeviceContext->PSSetShader( PS[Index],NULL,0);
|
|
||||||
}
|
|
||||||
void Core::ShaderManager::Set::Vertex(int Index)
|
|
||||||
{
|
|
||||||
if(Index==-1)
|
|
||||||
DeviceContext->VSSetShader( NULL,NULL,0);
|
|
||||||
else
|
|
||||||
DeviceContext->VSSetShader( VS[Index],NULL,0);
|
|
||||||
}
|
|
||||||
void Core::ShaderManager::Set::Geometry(int Index)
|
|
||||||
{
|
|
||||||
if(Index==-1)
|
|
||||||
DeviceContext->GSSetShader( NULL,NULL,0);
|
|
||||||
else
|
|
||||||
DeviceContext->GSSetShader( GS[Index],NULL,0);
|
|
||||||
}
|
|
||||||
void Core::ShaderManager::Set::Compute(int Index)
|
|
||||||
{
|
|
||||||
if(Index==-1)
|
|
||||||
DeviceContext->CSSetShader( NULL,NULL,0);
|
|
||||||
else
|
|
||||||
DeviceContext->CSSetShader( CS[Index],NULL,0);
|
|
||||||
}
|
|
||||||
/// \todo set Hull
|
|
||||||
void Core::ShaderManager::Set::Hull(int Index)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/// \todo set Domain
|
|
||||||
void Core::ShaderManager::Set::Domain(int Index)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#pragma endregion
|
|
||||||
|
|
||||||
/// \todo smart Set ie. not resetting the shader
|
|
||||||
/// \todo research states
|
|
||||||
/// \todo smart buffer set
|
|
||||||
void Core::ShaderManager::SetShaderEffect(ShaderEffect se)
|
|
||||||
{
|
|
||||||
Set::Pixel(se.Shaders.Pixel);
|
|
||||||
Set::Vertex(se.Shaders.Vertex);
|
|
||||||
Set::Geometry(se.Shaders.Geometry);
|
|
||||||
Set::Compute(se.Shaders.Compute);
|
|
||||||
Oyster::Core::DeviceContext->IASetInputLayout(se.IAStage.Layout);
|
|
||||||
Oyster::Core::DeviceContext->IASetPrimitiveTopology(se.IAStage.Topology);
|
|
||||||
for(unsigned int i=0;i<se.CBuffers.Vertex.size();++i)
|
|
||||||
se.CBuffers.Vertex[i]->Apply(i);
|
|
||||||
for(unsigned int i=0;i<se.CBuffers.Geometry.size();++i)
|
|
||||||
se.CBuffers.Geometry[i]->Apply(i);
|
|
||||||
for(unsigned int i=0;i<se.CBuffers.Pixel.size();++i)
|
|
||||||
se.CBuffers.Pixel[i]->Apply(i);
|
|
||||||
Oyster::Core::DeviceContext->RSSetState(se.RenderStates.Rasterizer);
|
|
||||||
Oyster::Core::DeviceContext->PSSetSamplers(0,se.RenderStates.SampleCount,se.RenderStates.SampleState);
|
|
||||||
float test[4] = {0};
|
|
||||||
Oyster::Core::DeviceContext->OMSetBlendState(se.RenderStates.BlendState,test,-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
#include "..\OysterGraphics\Core\CoreIncludes.h"
|
||||||
|
#include "OysterMath.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Definitions
|
||||||
|
{
|
||||||
|
struct ObjVertex
|
||||||
|
{
|
||||||
|
Oyster::Math::Float3 pos;
|
||||||
|
Oyster::Math::Float2 uv;
|
||||||
|
Oyster::Math::Float3 normal;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VP
|
||||||
|
{
|
||||||
|
Oyster::Math::Matrix V;
|
||||||
|
Oyster::Math::Matrix P;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,157 +9,160 @@
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
class Engine
|
namespace Graphics
|
||||||
{
|
{
|
||||||
private:
|
class Engine
|
||||||
Engine();
|
|
||||||
~Engine();
|
|
||||||
|
|
||||||
public:
|
|
||||||
class Init
|
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
struct Setup
|
|
||||||
{
|
|
||||||
int NrOfBuffers;
|
|
||||||
bool MSAA_Quality;
|
|
||||||
bool Fullscreen;
|
|
||||||
bool SingleThreaded;
|
|
||||||
bool Reference;
|
|
||||||
bool ForceDX11;
|
|
||||||
bool GenerateDepthStencil;
|
|
||||||
bool BindDefault;
|
|
||||||
HWND window;
|
|
||||||
//all but Window params have Default Values
|
|
||||||
Setup()
|
|
||||||
{
|
|
||||||
NrOfBuffers=1;
|
|
||||||
MSAA_Quality = false;
|
|
||||||
Fullscreen = true;
|
|
||||||
SingleThreaded = true;
|
|
||||||
Reference = false;
|
|
||||||
ForceDX11 = false;
|
|
||||||
GenerateDepthStencil = true;
|
|
||||||
BindDefault = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
static bool IsInstanced();
|
|
||||||
|
|
||||||
//Creates Device and DeviceContext, if not Initialized
|
|
||||||
static bool Instance(bool SingleThreaded=true,bool Reference=false,bool ForceDX11=false);
|
|
||||||
static bool HasSwapChain();
|
|
||||||
|
|
||||||
//Creates Swapchain, if not Aready Created
|
|
||||||
static bool CreateSwapChain(HWND Window, int NrofBuffers=1,bool MSAA_Quality=false,bool Fullscreen=true);
|
|
||||||
|
|
||||||
//CreateWindow, if Not Already Created
|
|
||||||
static bool InitializeWindow(const LPCSTR appName, const LPCSTR className,const HINSTANCE &hInstance, const int &nCmdShow, WNDPROC wProc, bool HandleLoop = false );
|
|
||||||
|
|
||||||
//Performs a full initialization of a rendering pipeline, including a Window
|
|
||||||
static bool FullInit(const Setup& setup);
|
|
||||||
struct Buffers
|
|
||||||
{
|
|
||||||
static Buffer* CreateBuffer(const Buffer::BUFFER_INIT_DESC BufferDesc);
|
|
||||||
};
|
|
||||||
private:
|
private:
|
||||||
Init();
|
Engine();
|
||||||
~Init();
|
~Engine();
|
||||||
};
|
|
||||||
|
|
||||||
class States
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
//SSAO Quality
|
/*class Init
|
||||||
static void SetNrOfSSAOSamples(int);
|
|
||||||
static int GetNrOfSSAOSamples();
|
|
||||||
|
|
||||||
//SSAO Frequency
|
|
||||||
static void SetSSAOSampleSpread(int);
|
|
||||||
static int GetSSAOSampleSpread();
|
|
||||||
|
|
||||||
//PointLights
|
|
||||||
static void SetMaxPointlights(int);
|
|
||||||
static int GetMaxPointlights();
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
States();
|
|
||||||
~States();
|
|
||||||
};
|
|
||||||
|
|
||||||
class Render
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Render a number of models, setting the Per model data to the included cBuffer
|
|
||||||
/// specify NULL if no such data exists
|
|
||||||
static void Geometry(const Oyster::Render::Model* models,int count,Oyster::Buffer* cBufferEveryObject, int slot);
|
|
||||||
static void Text(std::string text, Oyster::Math::Float2 size, Oyster::Math::Float3 Pos);
|
|
||||||
//static void TextBox(const Oyster::Render::
|
|
||||||
|
|
||||||
//ensure that a compatible 2D shadereffect is applied
|
|
||||||
static void ScreenQuad(ID3D11ShaderResourceView* srv, float ZPos=1);
|
|
||||||
|
|
||||||
//ensure that a compatible 2D shadereffect is applied and that pos.z is between 0 and 1
|
|
||||||
static void Sprite(ID3D11ShaderResourceView* srv, Oyster::Math::Float2 size, Oyster::Math::Float3 Pos);
|
|
||||||
|
|
||||||
static void PresentScene();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Render();
|
|
||||||
~Render();
|
|
||||||
};
|
|
||||||
|
|
||||||
class PrepareForRendering
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//Binds several rendertargets and a depthstencil
|
|
||||||
static void BindRenderTargets(ID3D11RenderTargetView** RenderTargets,int NrOfTargets,ID3D11DepthStencilView* depth);
|
|
||||||
|
|
||||||
//Binds several Rendertargest and a default depthstencil
|
|
||||||
static void BindRenderTargets(ID3D11RenderTargetView** RenderTargets,int NrOfTargets);
|
|
||||||
|
|
||||||
//Binds the backbuffer and a depthstencil
|
|
||||||
static void BindBackBuffer(ID3D11DepthStencilView* depth);
|
|
||||||
|
|
||||||
//Binds the backbuffer and a default depthstencil
|
|
||||||
static void BindBackBuffer();
|
|
||||||
|
|
||||||
//Binds the backbuffer to the compute shader
|
|
||||||
static void BindBackBufferAsUAV();
|
|
||||||
|
|
||||||
//binds several UAV to the computeshader
|
|
||||||
static void BindUAV(ID3D11UnorderedAccessView** uav, int NrOfUavs);
|
|
||||||
|
|
||||||
//Clears the backbuffer and default depthstencil
|
|
||||||
static void ClearBackBuffer(Math::Float4 color);
|
|
||||||
|
|
||||||
static void Begin2DRender();
|
|
||||||
|
|
||||||
static void Begin2DTextRender();
|
|
||||||
};
|
|
||||||
|
|
||||||
class Pipeline
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
class Deffered_Lightning
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//Basic Setup
|
struct Setup
|
||||||
static void NewFrame(const Float4& Color, const Matrix& View, const Matrix& Projection);
|
{
|
||||||
|
int NrOfBuffers;
|
||||||
|
bool MSAA_Quality;
|
||||||
|
bool Fullscreen;
|
||||||
|
bool SingleThreaded;
|
||||||
|
bool Reference;
|
||||||
|
bool ForceDX11;
|
||||||
|
bool GenerateDepthStencil;
|
||||||
|
bool BindDefault;
|
||||||
|
HWND window;
|
||||||
|
//all but Window params have Default Values
|
||||||
|
Setup()
|
||||||
|
{
|
||||||
|
NrOfBuffers=1;
|
||||||
|
MSAA_Quality = false;
|
||||||
|
Fullscreen = true;
|
||||||
|
SingleThreaded = true;
|
||||||
|
Reference = false;
|
||||||
|
ForceDX11 = false;
|
||||||
|
GenerateDepthStencil = true;
|
||||||
|
BindDefault = true;
|
||||||
|
}
|
||||||
|
|
||||||
//Geometry Pass
|
};
|
||||||
static void BeginRenderGeometry();
|
|
||||||
static void RenderGeometry(const Oyster::Render::Model* models,int count);
|
|
||||||
static void EndRenderGeometry();
|
|
||||||
|
|
||||||
//Lightning Pass
|
static bool IsInstanced();
|
||||||
static void InputPointLights(Oyster::Resources::BufferDefinitions::PointLightDescription *p, int NrOfPointlights );
|
|
||||||
static void RenderLightning();
|
//Creates Device and DeviceContext, if not Initialized
|
||||||
|
static bool Instance(bool SingleThreaded=true,bool Reference=false,bool ForceDX11=false);
|
||||||
|
static bool HasSwapChain();
|
||||||
|
|
||||||
|
//Creates Swapchain, if not Aready Created
|
||||||
|
static bool CreateSwapChain(HWND Window, int NrofBuffers=1,bool MSAA_Quality=false,bool Fullscreen=true);
|
||||||
|
|
||||||
|
//CreateWindow, if Not Already Created
|
||||||
|
static bool InitializeWindow(const LPCSTR appName, const LPCSTR className,const HINSTANCE &hInstance, const int &nCmdShow, WNDPROC wProc, bool HandleLoop = false );
|
||||||
|
|
||||||
|
//Performs a full initialization of a rendering pipeline, including a Window
|
||||||
|
static bool FullInit(const Setup& setup);
|
||||||
|
struct Buffers
|
||||||
|
{
|
||||||
|
static Buffer* CreateBuffer(const Buffer::BUFFER_INIT_DESC BufferDesc);
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
Init();
|
||||||
|
~Init();
|
||||||
|
};*/
|
||||||
|
|
||||||
|
class States
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//SSAO Quality
|
||||||
|
static void SetNrOfSSAOSamples(int);
|
||||||
|
static int GetNrOfSSAOSamples();
|
||||||
|
|
||||||
|
//SSAO Frequency
|
||||||
|
static void SetSSAOSampleSpread(int);
|
||||||
|
static int GetSSAOSampleSpread();
|
||||||
|
|
||||||
|
//PointLights
|
||||||
|
static void SetMaxPointlights(int);
|
||||||
|
static int GetMaxPointlights();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
States();
|
||||||
|
~States();
|
||||||
|
};
|
||||||
|
|
||||||
|
class Render
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/// Render a number of models, setting the Per model data to the included cBuffer
|
||||||
|
/// specify NULL if no such data exists
|
||||||
|
//static void Geometry(const Oyster::Graphics::Render::Model* models,int count,Buffer* cBufferEveryObject, int slot);
|
||||||
|
static void Text(std::string text, Oyster::Math::Float2 size, Oyster::Math::Float3 Pos);
|
||||||
|
//static void TextBox(const Oyster::Render::
|
||||||
|
|
||||||
|
//ensure that a compatible 2D shadereffect is applied
|
||||||
|
static void ScreenQuad(ID3D11ShaderResourceView* srv, float ZPos=1);
|
||||||
|
|
||||||
|
//ensure that a compatible 2D shadereffect is applied and that pos.z is between 0 and 1
|
||||||
|
static void Sprite(ID3D11ShaderResourceView* srv, Oyster::Math::Float2 size, Oyster::Math::Float3 Pos);
|
||||||
|
|
||||||
|
static void PresentScene();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Render();
|
||||||
|
~Render();
|
||||||
|
};
|
||||||
|
|
||||||
|
class PrepareForRendering
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//Binds several rendertargets and a depthstencil
|
||||||
|
static void BindRenderTargets(ID3D11RenderTargetView** RenderTargets,int NrOfTargets,ID3D11DepthStencilView* depth);
|
||||||
|
|
||||||
|
//Binds several Rendertargest and a default depthstencil
|
||||||
|
static void BindRenderTargets(ID3D11RenderTargetView** RenderTargets,int NrOfTargets);
|
||||||
|
|
||||||
|
//Binds the backbuffer and a depthstencil
|
||||||
|
static void BindBackBuffer(ID3D11DepthStencilView* depth);
|
||||||
|
|
||||||
|
//Binds the backbuffer and a default depthstencil
|
||||||
|
static void BindBackBuffer();
|
||||||
|
|
||||||
|
//Binds the backbuffer to the compute shader
|
||||||
|
static void BindBackBufferAsUAV();
|
||||||
|
|
||||||
|
//binds several UAV to the computeshader
|
||||||
|
static void BindUAV(ID3D11UnorderedAccessView** uav, int NrOfUavs);
|
||||||
|
|
||||||
|
//Clears the backbuffer and default depthstencil
|
||||||
|
static void ClearBackBuffer(Math::Float4 color);
|
||||||
|
|
||||||
|
static void Begin2DRender();
|
||||||
|
|
||||||
|
static void Begin2DTextRender();
|
||||||
|
};
|
||||||
|
|
||||||
|
class Pipeline
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
class Deffered_Lightning
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//Basic Setup
|
||||||
|
//static void NewFrame(const Float4& Color, const Matrix& View, const Matrix& Projection);
|
||||||
|
|
||||||
|
//Geometry Pass
|
||||||
|
static void BeginRenderGeometry();
|
||||||
|
//static void RenderGeometry(const Oyster::Graphics::Render::Model* models,int count);
|
||||||
|
static void EndRenderGeometry();
|
||||||
|
|
||||||
|
//Lightning Pass
|
||||||
|
//static void InputPointLights(Oyster::Resources::BufferDefinitions::PointLightDescription *p, int NrOfPointlights );
|
||||||
|
static void RenderLightning();
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,9 +1,9 @@
|
||||||
//Oyster
|
//Oyster
|
||||||
|
|
||||||
// Render
|
// Render
|
||||||
#include "Render\Model.h"
|
//#include "Render\Model.h"
|
||||||
#include "Render\Camera.h"
|
//#include "Render\Camera.h"
|
||||||
#include "Render\TextBox.h"
|
//#include "Render\TextBox.h"
|
||||||
|
|
||||||
// Core
|
// Core
|
||||||
#include "Core\Core.h"
|
#include "Core\Core.h"
|
||||||
|
@ -16,8 +16,8 @@
|
||||||
#include "OysterMath.h"
|
#include "OysterMath.h"
|
||||||
|
|
||||||
// Resources
|
// Resources
|
||||||
#include "Resourses\ShaderEffects.h"
|
//#include "Resourses\ShaderEffects.h"
|
||||||
#include "Resourses\Buffers.h"
|
//#include "Resourses\Buffers.h"
|
||||||
#include "Resourses\PipelineResources.h"
|
//#include "Resourses\PipelineResources.h"
|
||||||
#include "Resourses\GraphicsDefinitions.h"
|
//#include "Resourses\GraphicsDefinitions.h"
|
||||||
#include "Resourses\Manager.h"
|
//#include "Resourses\Manager.h"
|
|
@ -1,268 +1,149 @@
|
||||||
#include "ObjReader.h"
|
#include "OBJReader.h"
|
||||||
#include "Utilities.h"
|
#include "..\Definitions\GraphicalDefinition.h"
|
||||||
#include "..\Core\Core.h"
|
#include <sstream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <map>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Oyster::FileLoaders;
|
OBJReader::OBJReader()
|
||||||
using namespace Oyster;
|
|
||||||
using namespace Oyster::Math;
|
|
||||||
|
|
||||||
ObjReader *ObjReader::LoadFile(std::string fileName, Oyster::Math::Float4x4 transform)
|
|
||||||
{
|
{
|
||||||
static std::map<std::string, ObjReader *> cache;
|
_mPos = 0;
|
||||||
|
_mNormal = 0;
|
||||||
ObjReader *reader = NULL;
|
_mTexel = 0;
|
||||||
|
|
||||||
if (cache.count(fileName))
|
|
||||||
{
|
|
||||||
reader = cache[fileName];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
reader = new ObjReader();
|
|
||||||
reader->ParseFile(fileName, transform);
|
|
||||||
|
|
||||||
cache[fileName] = reader;
|
|
||||||
}
|
|
||||||
|
|
||||||
return reader;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjReader::ObjReader(void)
|
OBJReader::~OBJReader()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OBJReader::readOBJFile( std::wstring fileName )
|
||||||
ObjReader::~ObjReader(void)
|
|
||||||
{
|
{
|
||||||
}
|
std::fstream inStream;
|
||||||
|
std::string typeOfData = " ";
|
||||||
|
float vertexData;
|
||||||
|
std::string face1, face2, face3;
|
||||||
|
|
||||||
void ObjReader::ParseFile(std::string fileName, Float4x4 transform)
|
inStream.open( fileName, std::fstream::in );
|
||||||
{
|
|
||||||
ifstream input;
|
|
||||||
input.open(fileName.c_str());
|
|
||||||
|
|
||||||
if(!input.is_open())
|
if( inStream.is_open() )
|
||||||
{
|
{
|
||||||
return;
|
while( !inStream.eof() )
|
||||||
}
|
|
||||||
|
|
||||||
string path;
|
|
||||||
Utility::String::extractDirPath(path,fileName,'\\');
|
|
||||||
|
|
||||||
std::vector<Vertex> VertexList;
|
|
||||||
std::vector<Float3> vList;
|
|
||||||
std::vector<Float3> nList;
|
|
||||||
std::vector<Float2> uvList;
|
|
||||||
Vertex vertex1, vertex2, vertex3;
|
|
||||||
Float3 face[3];
|
|
||||||
Float3 position, normal;
|
|
||||||
Float2 uv;
|
|
||||||
string s;
|
|
||||||
|
|
||||||
while(!input.eof())
|
|
||||||
{
|
|
||||||
getline(input,s);
|
|
||||||
int offset = (int)s.find(' ');
|
|
||||||
|
|
||||||
if(offset!=-1)
|
|
||||||
{
|
{
|
||||||
string c = s.substr(0,offset);
|
inStream >> typeOfData;
|
||||||
|
|
||||||
if(c=="v")
|
if( typeOfData == "v" )
|
||||||
{
|
{
|
||||||
position = readVertex(offset,s);
|
Oyster::Math::Float3 position;
|
||||||
vList.push_back(position);
|
|
||||||
|
inStream >> vertexData;
|
||||||
|
position.x = vertexData;
|
||||||
|
|
||||||
|
inStream >> vertexData;
|
||||||
|
position.y = vertexData;
|
||||||
|
|
||||||
|
inStream >> vertexData;
|
||||||
|
position.z = vertexData;
|
||||||
|
|
||||||
|
_mVertexCoord.push_back( position );
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(c=="vt")
|
else if( typeOfData == "vt" )
|
||||||
{
|
{
|
||||||
uv = readUV(offset,s);
|
Oyster::Math::Float2 texel;
|
||||||
uvList.push_back(uv);
|
inStream >> vertexData;
|
||||||
|
texel.x = vertexData;
|
||||||
|
|
||||||
|
inStream >> vertexData;
|
||||||
|
texel.y = 1 - vertexData;
|
||||||
|
|
||||||
|
_mVertexTexture.push_back( texel );
|
||||||
}
|
}
|
||||||
else if(c=="vn")
|
else if( typeOfData == "vn" )
|
||||||
{
|
{
|
||||||
normal = readNormal(offset,s);
|
Oyster::Math::Float3 normal;
|
||||||
nList.push_back(normal);
|
inStream >> vertexData;
|
||||||
|
normal.x = vertexData;
|
||||||
|
|
||||||
|
inStream >> vertexData;
|
||||||
|
normal.y = vertexData;
|
||||||
|
|
||||||
|
inStream >> vertexData;
|
||||||
|
normal.z = vertexData;
|
||||||
|
|
||||||
|
_mVertexNormal.push_back( normal );
|
||||||
}
|
}
|
||||||
else if(c=="f")
|
else if( typeOfData == "f" )
|
||||||
{
|
{
|
||||||
readFace(offset, s, face);
|
inStream >> face1;
|
||||||
|
stringSplit( face1 );
|
||||||
|
|
||||||
vertex1.Position = vList[(int)face[0].x];
|
addToOBJarray();
|
||||||
vertex1.UV = uvList[(int)face[0].y];
|
|
||||||
vertex1.Normal = nList[(int)face[0].z];
|
|
||||||
|
|
||||||
vertex2.Position = vList[(int)face[1].x];
|
inStream >> face2;
|
||||||
vertex2.UV = uvList[(int)face[1].y];
|
stringSplit( face2 );
|
||||||
vertex2.Normal = nList[(int)face[1].z];
|
|
||||||
|
|
||||||
vertex3.Position = vList[(int)face[2].x];
|
addToOBJarray();
|
||||||
vertex3.UV = uvList[(int)face[2].y];
|
|
||||||
vertex3.Normal = nList[(int)face[2].z];
|
|
||||||
|
|
||||||
VertexList.push_back(vertex1);
|
inStream >> face3;
|
||||||
VertexList.push_back(vertex3);
|
stringSplit( face3 );
|
||||||
VertexList.push_back(vertex2);
|
|
||||||
}
|
addToOBJarray();
|
||||||
else if(c=="mtllib")
|
|
||||||
{
|
|
||||||
this->materials = GetMaterials(path+s.substr(offset+1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
input.close();
|
inStream.close();
|
||||||
|
}
|
||||||
|
|
||||||
this->numVertices = VertexList.size();
|
Oyster::Graphics::Render::ModelInfo* OBJReader::toModel()
|
||||||
this->vertices = new Vertex[this->numVertices];
|
{
|
||||||
|
Oyster::Graphics::Buffer* b = new Oyster::Graphics::Buffer();
|
||||||
|
Oyster::Graphics::Buffer::BUFFER_INIT_DESC desc;
|
||||||
|
Oyster::Graphics::Render::ModelInfo* modelInfo = new Oyster::Graphics::Render::ModelInfo();
|
||||||
|
|
||||||
for(size_t i=0;i<this->numVertices;++i)
|
desc.ElementSize = 32;
|
||||||
|
desc.InitData = &this->_myOBJ[0];
|
||||||
|
desc.NumElements = this->_myOBJ.size();
|
||||||
|
desc.Type = Oyster::Graphics::Buffer::BUFFER_TYPE::VERTEX_BUFFER;
|
||||||
|
desc.Usage = Oyster::Graphics::Buffer::BUFFER_DEFAULT;
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
|
hr = b->Init(desc);
|
||||||
|
if(FAILED(hr))
|
||||||
{
|
{
|
||||||
vertices[i].Position=Math::transformVector(Math::Float4(VertexList[i].Position,1),transform);
|
//Something isn't okay here
|
||||||
vertices[i].Normal=Math::transformVector(Math::Float4(VertexList[i].Normal,0),transform);
|
|
||||||
vertices[i].UV = VertexList[i].UV;
|
|
||||||
}
|
}
|
||||||
|
modelInfo->Indexed = false;
|
||||||
|
modelInfo->VertexCount = (int)desc.NumElements;
|
||||||
|
modelInfo->Vertices = b;
|
||||||
|
|
||||||
|
|
||||||
|
return modelInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjReader::GetVertexData(Vertex **vertex,int &numVertex, std::map<std::string, ID3D11ShaderResourceView *> &Textures)
|
//Private functions
|
||||||
|
void OBJReader::stringSplit( std::string strToSplit )
|
||||||
{
|
{
|
||||||
numVertex=(int)this->numVertices;
|
char delim = '/';
|
||||||
(*vertex)=this->vertices;
|
std::string vPos, vNormal, vTexel;
|
||||||
Textures = this->materials;
|
std::stringstream aStream(strToSplit);
|
||||||
|
getline( aStream, vPos, delim );
|
||||||
|
getline( aStream, vTexel, delim );
|
||||||
|
getline( aStream, vNormal );
|
||||||
|
|
||||||
|
_mPos = atoi( vPos.c_str() );
|
||||||
|
_mNormal = atoi( vNormal.c_str() );
|
||||||
|
_mTexel = atoi( vTexel.c_str() );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Float3 ObjReader::extract(std::string d)
|
void OBJReader::addToOBJarray()
|
||||||
{
|
{
|
||||||
Float3 data;
|
OBJFormat temp;
|
||||||
int offset=(int)d.find('/');
|
|
||||||
data.x=(float)atoi(d.substr(1,offset).c_str())-1;
|
|
||||||
|
|
||||||
int newOffset = (int)d.find('/',offset+1);
|
temp._d3VertexCoord = _mVertexCoord.at( _mPos - 1 );
|
||||||
string d2=d.substr(offset+1,newOffset-offset-1);
|
temp._d3VertexNormal = _mVertexNormal.at( _mNormal - 1 );
|
||||||
data.y=(float)atoi(d2.c_str())-1;
|
temp._d3VertexTexture = _mVertexTexture.at( _mTexel - 1 );
|
||||||
offset=newOffset;
|
|
||||||
|
|
||||||
newOffset = (int)d.find('/',offset+1);
|
_myOBJ.push_back( temp );
|
||||||
string d3=d.substr(offset+1,newOffset-offset-1);
|
|
||||||
data.z=(float)atoi(d3.c_str())-1;
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
Float3 ObjReader::readVertex(int offset,string s)
|
|
||||||
{
|
|
||||||
int newOffset = (int)s.find(' ',offset+1);
|
|
||||||
Float3 vertex;
|
|
||||||
string d = s.substr(offset,newOffset-offset);
|
|
||||||
vertex.x = (float)atof(d.c_str());
|
|
||||||
offset=newOffset;
|
|
||||||
|
|
||||||
newOffset = (int)s.find(' ',offset+1);
|
|
||||||
vertex.y = (float)atof(s.substr(offset,newOffset-offset).c_str());
|
|
||||||
offset=newOffset;
|
|
||||||
|
|
||||||
newOffset = (int)s.find(' ',offset+1);
|
|
||||||
vertex.z = (float)-atof(s.substr(offset,newOffset-offset).c_str());
|
|
||||||
|
|
||||||
return vertex;
|
|
||||||
}
|
|
||||||
|
|
||||||
Float2 ObjReader::readUV(int offset,string s)
|
|
||||||
{
|
|
||||||
int newOffset = (int)s.find(' ',offset+1);
|
|
||||||
Float2 uv;
|
|
||||||
string d = s.substr(offset,newOffset-offset);
|
|
||||||
uv.x =(float)atof(d.c_str());
|
|
||||||
offset=newOffset;
|
|
||||||
|
|
||||||
newOffset = (int)s.find(' ',offset+1);
|
|
||||||
d = s.substr(offset,newOffset-offset);
|
|
||||||
uv.y =1- (float)atof(d.c_str());
|
|
||||||
offset=newOffset;
|
|
||||||
|
|
||||||
return uv;
|
|
||||||
}
|
|
||||||
|
|
||||||
Float3 ObjReader::readNormal(int offset,string s)
|
|
||||||
{
|
|
||||||
int newOffset = (int)s.find(' ',offset+1);
|
|
||||||
Float3 vertex;
|
|
||||||
string d = s.substr(offset,newOffset-offset);
|
|
||||||
vertex.x = (float)atof(d.c_str());
|
|
||||||
offset=newOffset;
|
|
||||||
|
|
||||||
newOffset = (int)s.find(' ',offset+1);
|
|
||||||
vertex.y = (float)atof(s.substr(offset,newOffset-offset).c_str());
|
|
||||||
offset=newOffset;
|
|
||||||
|
|
||||||
newOffset = (int)s.find(' ',offset+1);
|
|
||||||
vertex.z = (float)-atof(s.substr(offset,newOffset-offset).c_str());
|
|
||||||
|
|
||||||
return vertex;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ObjReader::readFace(int offset,string s, Oyster::Math::Float3 face[3])
|
|
||||||
{
|
|
||||||
int newOffset = (int)s.find(' ',offset+1);
|
|
||||||
string point1 = s.substr(offset,newOffset-offset);
|
|
||||||
|
|
||||||
offset = newOffset;
|
|
||||||
newOffset = (int)s.find(' ',offset+1);
|
|
||||||
string point2 = s.substr(offset,newOffset-offset);
|
|
||||||
|
|
||||||
offset = newOffset;
|
|
||||||
newOffset = (int)s.find(' ',offset+1);
|
|
||||||
string point3 = s.substr(offset,newOffset-offset);
|
|
||||||
|
|
||||||
face[0] = extract(point1);
|
|
||||||
face[1] = extract(point2);
|
|
||||||
face[2] = extract(point3);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::map<std::string, ID3D11ShaderResourceView *> ObjReader::GetMaterials(std::string fileName)
|
|
||||||
{
|
|
||||||
ifstream input;
|
|
||||||
input.open(fileName.c_str());
|
|
||||||
|
|
||||||
std::map<std::string, ID3D11ShaderResourceView *> materials;
|
|
||||||
ID3D11ShaderResourceView *srv;
|
|
||||||
string texture;
|
|
||||||
string s;
|
|
||||||
string path;
|
|
||||||
Utility::String::extractDirPath(path,fileName,'\\');
|
|
||||||
if(!input.is_open())
|
|
||||||
return materials;
|
|
||||||
|
|
||||||
while(!input.eof())
|
|
||||||
{
|
|
||||||
getline(input,s);
|
|
||||||
int offset = (int)s.find(' ');
|
|
||||||
if(offset!=-1)
|
|
||||||
{
|
|
||||||
string c = s.substr(0,offset);
|
|
||||||
if(c=="map_Kd")
|
|
||||||
{
|
|
||||||
texture = path+s.substr(offset+1);
|
|
||||||
D3DX11CreateShaderResourceViewFromFile(Oyster::Core::Device,texture.c_str(), NULL, NULL, &srv, NULL);
|
|
||||||
materials["Diffuse"] = srv;
|
|
||||||
}
|
|
||||||
if(c=="map_G")
|
|
||||||
{
|
|
||||||
texture = path+s.substr(offset+1);
|
|
||||||
D3DX11CreateShaderResourceViewFromFile(Oyster::Core::Device,texture.c_str(), NULL, NULL, &srv, NULL);
|
|
||||||
materials["Glow"] = srv;
|
|
||||||
}
|
|
||||||
if(c=="map_Ks")
|
|
||||||
{
|
|
||||||
texture = path+s.substr(offset+1);
|
|
||||||
D3DX11CreateShaderResourceViewFromFile(Oyster::Core::Device,texture.c_str(), NULL, NULL, &srv, NULL);
|
|
||||||
materials["Specular"] = srv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
input.close();
|
|
||||||
|
|
||||||
return materials;
|
|
||||||
}
|
}
|
|
@ -1,42 +1,55 @@
|
||||||
#pragma once
|
#ifndef OBJREADER_H
|
||||||
#include "..\Core\CoreIncludes.h"
|
#define OBJREADER_H
|
||||||
#include "..\Math\OysterMath.h"
|
#include "..\..\Misc\Utilities.h"
|
||||||
|
#include "..\..\OysterMath\OysterMath.h"
|
||||||
|
#include "..\Model\ModelInfo.h"
|
||||||
|
|
||||||
namespace Oyster
|
//#include <fstream>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class OBJReader
|
||||||
{
|
{
|
||||||
namespace FileLoaders
|
public:
|
||||||
{
|
struct OBJFormat
|
||||||
class ObjReader
|
|
||||||
{
|
{
|
||||||
public:
|
Oyster::Math::Float3 _d3VertexCoord;
|
||||||
struct Vertex
|
Oyster::Math::Float2 _d3VertexTexture;
|
||||||
{
|
Oyster::Math::Float3 _d3VertexNormal;
|
||||||
Oyster::Math::Float3 Position;
|
|
||||||
Oyster::Math::Float3 Normal;
|
|
||||||
Oyster::Math::Float2 UV;
|
|
||||||
};
|
|
||||||
|
|
||||||
static ObjReader *LoadFile(std::string fileName, Oyster::Math::Float4x4 transform = Oyster::Math::Float4x4::identity);
|
|
||||||
|
|
||||||
ObjReader(void);
|
|
||||||
~ObjReader(void);
|
|
||||||
|
|
||||||
void GetVertexData(Vertex **vertex,int &numVertex, std::map<std::string, ID3D11ShaderResourceView *> &textures);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Vertex *vertices;
|
|
||||||
size_t numVertices;
|
|
||||||
std::map<std::string, ID3D11ShaderResourceView *> materials;
|
|
||||||
|
|
||||||
void ParseFile(std::string fileName, Oyster::Math::Float4x4 transform = Oyster::Math::Float4x4::identity);
|
|
||||||
|
|
||||||
Oyster::Math::Float3 extract(std::string d);
|
|
||||||
Oyster::Math::Float3 readVertex(int offset,std::string s);
|
|
||||||
Oyster::Math::Float2 readUV(int offset,std::string s);
|
|
||||||
Oyster::Math::Float3 readNormal(int offset,std::string s);
|
|
||||||
void readFace(int offset,std::string s, Oyster::Math::Float3 face[3]);
|
|
||||||
|
|
||||||
std::map<std::string, ID3D11ShaderResourceView *> GetMaterials(std::string fileName);
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
struct OBJMaterialData
|
||||||
|
{
|
||||||
|
std::string _name;
|
||||||
|
std::string _mapKd;
|
||||||
|
float _kd[3];
|
||||||
|
float _ka[3];
|
||||||
|
float _tf[3];
|
||||||
|
float _ni;
|
||||||
|
|
||||||
|
OBJMaterialData()
|
||||||
|
{
|
||||||
|
_name = " ";
|
||||||
|
_mapKd = " ";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
std::vector<OBJFormat> _myOBJ;
|
||||||
|
private:
|
||||||
|
|
||||||
|
std::vector<Oyster::Math::Float3> _mVertexCoord, _mVertexNormal;
|
||||||
|
std::vector<Oyster::Math::Float2> _mVertexTexture;
|
||||||
|
|
||||||
|
int _mNrOfCoords, _mNrOfNormals, _mNrOfTexels, _mNrOfFaces;
|
||||||
|
int _mPos, _mNormal, _mTexel;
|
||||||
|
void stringSplit( std::string strToSplit );
|
||||||
|
void addToOBJarray();
|
||||||
|
|
||||||
|
public:
|
||||||
|
OBJReader();
|
||||||
|
~OBJReader();
|
||||||
|
|
||||||
|
void readOBJFile( std::wstring fileName);
|
||||||
|
Oyster::Graphics::Render::ModelInfo* toModel();
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif
|
|
@ -11,20 +11,21 @@
|
||||||
//#include "ICollideable.h"
|
//#include "ICollideable.h"
|
||||||
#include "ModelInfo.h"
|
#include "ModelInfo.h"
|
||||||
|
|
||||||
using namespace Oyster::Math;
|
//using namespace Oyster::Math;
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
namespace Render
|
namespace Graphics
|
||||||
{
|
{
|
||||||
|
namespace Render
|
||||||
struct Model
|
|
||||||
{
|
{
|
||||||
ModelInfo* info;
|
struct Model
|
||||||
Float4x4 *World;
|
{
|
||||||
bool Visible;
|
ModelInfo* info;
|
||||||
};
|
Oyster::Math::Float4x4 World;
|
||||||
|
bool Visible;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
|
@ -0,0 +1,32 @@
|
||||||
|
#pragma once
|
||||||
|
#ifndef MODELINFO_h
|
||||||
|
#define MODELINFO_h
|
||||||
|
|
||||||
|
//#include "../Engine.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "..\Core\CoreIncludes.h"
|
||||||
|
#include "..\Core\Buffer.h"
|
||||||
|
//#include "OysterMath.h"
|
||||||
|
//#include "ICollideable.h"
|
||||||
|
|
||||||
|
//using namespace Oyster::Math;
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
struct ModelInfo
|
||||||
|
{
|
||||||
|
std::vector<ID3D11ShaderResourceView*> Material;
|
||||||
|
Buffer *Vertices,*Indecies;
|
||||||
|
bool Indexed;
|
||||||
|
int VertexCount;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,70 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "..\Engine.h"
|
||||||
|
const int MAX_LETTER_COUNT=60;
|
||||||
|
const int TEXT_NR_LETTERS=95;
|
||||||
|
const float TEXT_SIZE=2.5;
|
||||||
|
struct Text2D
|
||||||
|
{
|
||||||
|
Oyster::Math::Float Pos;
|
||||||
|
int offset;
|
||||||
|
float coff;
|
||||||
|
};
|
||||||
|
/*struct TextInstanceData
|
||||||
|
{
|
||||||
|
Oyster::Buffer InstanceBuffer;
|
||||||
|
bool Visible;
|
||||||
|
int NumLetters;
|
||||||
|
Oyster::Math::Float4x4 World;
|
||||||
|
};*/
|
||||||
|
/*struct TextData
|
||||||
|
{
|
||||||
|
Oyster::Math::Float3 pos;
|
||||||
|
Oyster::Math::Float2 uv;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PerCharData
|
||||||
|
{
|
||||||
|
float data;
|
||||||
|
Oyster::Math::Float3 charOffset;
|
||||||
|
};
|
||||||
|
struct TextInstanceData
|
||||||
|
{
|
||||||
|
Oyster::Buffer InstanceBuffer;
|
||||||
|
bool Visible;
|
||||||
|
int NumLetters;
|
||||||
|
Oyster::Math::Float4x4 World;
|
||||||
|
};*/
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
class Textbox
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
static float getCharID(char _in);
|
||||||
|
static HRESULT CreateVertexBuffer();
|
||||||
|
static HRESULT CreateTextfield(int _id);
|
||||||
|
public:
|
||||||
|
//static Oyster::Buffer TextBuffer;
|
||||||
|
//static int NumVertices;
|
||||||
|
//static std::vector<TextInstanceData> TextInstances;
|
||||||
|
static Buffer TextBuffer;
|
||||||
|
static int NumLetters;
|
||||||
|
static ID3D11ShaderResourceView* Texture;
|
||||||
|
|
||||||
|
static bool Init();
|
||||||
|
static bool UpdateTextField(std::string _str);
|
||||||
|
static bool SetTexture(const char* _file);
|
||||||
|
//Updates a textbox with the certain id
|
||||||
|
static void Update(std::string _str, float _scale);
|
||||||
|
//Removes all old instances and recreates it with the input data
|
||||||
|
static HRESULT Reset(int _count, std::string* _str, Float3* _pos);
|
||||||
|
static void Apply(int _id);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -90,11 +90,14 @@
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
</Link>
|
</Link>
|
||||||
|
<ProjectReference>
|
||||||
|
<LinkLibraryDependencies>true</LinkLibraryDependencies>
|
||||||
|
</ProjectReference>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
|
@ -140,31 +143,24 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Core\Buffer.cpp" />
|
<ClCompile Include="Core\Buffer.cpp" />
|
||||||
<ClCompile Include="Core\Core.cpp" />
|
<ClCompile Include="Core\Core.cpp" />
|
||||||
|
<ClCompile Include="Core\Init.cpp" />
|
||||||
<ClCompile Include="Core\ShaderManager.cpp" />
|
<ClCompile Include="Core\ShaderManager.cpp" />
|
||||||
<ClCompile Include="Engine.cpp" />
|
<ClCompile Include="FileLoader\ObjReader.cpp" />
|
||||||
<ClCompile Include="Render\Model.cpp" />
|
<ClCompile Include="Render\Preparations\BasicPreparations.cpp" />
|
||||||
<ClCompile Include="Render\TextBox.cpp" />
|
<ClCompile Include="Render\Rendering\BasicRender.cpp" />
|
||||||
<ClCompile Include="Resourses\Buffers.cpp" />
|
<ClCompile Include="Render\Resources\Resources.cpp" />
|
||||||
<ClCompile Include="Resourses\Manager.cpp" />
|
|
||||||
<ClCompile Include="Resourses\PipelineResources.cpp" />
|
|
||||||
<ClCompile Include="Resourses\ShaderEffects.cpp" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Core\Buffer.h" />
|
<ClInclude Include="Core\Buffer.h" />
|
||||||
<ClInclude Include="Core\Core.h" />
|
<ClInclude Include="Core\Core.h" />
|
||||||
<ClInclude Include="Core\CoreIncludes.h" />
|
<ClInclude Include="Core\CoreIncludes.h" />
|
||||||
<ClInclude Include="Engine.h" />
|
|
||||||
<ClInclude Include="EngineIncludes.h" />
|
|
||||||
<ClInclude Include="FileLoader\ObjReader.h" />
|
<ClInclude Include="FileLoader\ObjReader.h" />
|
||||||
<ClInclude Include="Render\Lights.h" />
|
<ClInclude Include="Model\Model.h" />
|
||||||
<ClInclude Include="Render\Model.h" />
|
<ClInclude Include="Model\ModelInfo.h" />
|
||||||
<ClInclude Include="Render\ModelInfo.h" />
|
<ClInclude Include="Render\Preparations\Preparations.h" />
|
||||||
<ClInclude Include="Render\TextBox.h" />
|
<ClInclude Include="Render\Rendering\Render.h" />
|
||||||
<ClInclude Include="Resourses\Buffers.h" />
|
<ClInclude Include="Definitions\GraphicalDefinition.h" />
|
||||||
<ClInclude Include="Resourses\GraphicsDefinitions.h" />
|
<ClInclude Include="Render\Resources\Resources.h" />
|
||||||
<ClInclude Include="Resourses\Manager.h" />
|
|
||||||
<ClInclude Include="Resourses\PipelineResources.h" />
|
|
||||||
<ClInclude Include="Resourses\ShaderEffects.h" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Misc\Misc.vcxproj">
|
<ProjectReference Include="..\Misc\Misc.vcxproj">
|
||||||
|
@ -175,6 +171,17 @@
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugCameraVertex.hlsl">
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
|
||||||
|
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
</AssemblerOutput>
|
||||||
|
<AssemblerOutputFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
</AssemblerOutputFile>
|
||||||
|
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
|
||||||
|
</FxCompile>
|
||||||
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl">
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl">
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
|
||||||
|
@ -192,6 +199,8 @@
|
||||||
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
|
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
|
||||||
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">main</EntryPointName>
|
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">main</EntryPointName>
|
||||||
|
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
</AssemblerOutput>
|
||||||
</FxCompile>
|
</FxCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|
|
@ -21,30 +21,24 @@
|
||||||
<ClCompile Include="Core\Core.cpp">
|
<ClCompile Include="Core\Core.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Render\Model.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Render\TextBox.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Resourses\Buffers.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Resourses\Manager.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Resourses\PipelineResources.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Resourses\ShaderEffects.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Engine.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Core\ShaderManager.cpp">
|
<ClCompile Include="Core\ShaderManager.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Core\Init.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Render\Rendering\BasicRender.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Render\Preparations\BasicPreparations.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Render\Resources\Resources.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="FileLoader\ObjReader.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Core\Buffer.h">
|
<ClInclude Include="Core\Buffer.h">
|
||||||
|
@ -56,37 +50,22 @@
|
||||||
<ClInclude Include="Core\CoreIncludes.h">
|
<ClInclude Include="Core\CoreIncludes.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Render\Lights.h">
|
<ClInclude Include="Render\Preparations\Preparations.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Render\Model.h">
|
<ClInclude Include="Render\Rendering\Render.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Render\ModelInfo.h">
|
<ClInclude Include="Model\ModelInfo.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Render\TextBox.h">
|
<ClInclude Include="Model\Model.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Resourses\Buffers.h">
|
<ClInclude Include="Render\Resources\Resources.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Resourses\GraphicsDefinitions.h">
|
<ClInclude Include="Definitions\GraphicalDefinition.h">
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Resourses\Manager.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Resourses\PipelineResources.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Resourses\ShaderEffects.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Engine.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="EngineIncludes.h">
|
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="FileLoader\ObjReader.h">
|
<ClInclude Include="FileLoader\ObjReader.h">
|
||||||
|
@ -96,5 +75,6 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugVertex.hlsl" />
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugVertex.hlsl" />
|
||||||
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl" />
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl" />
|
||||||
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugCameraVertex.hlsl" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -0,0 +1,88 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Core\Buffer.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Core\Core.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Core\ShaderManager.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Core\Init.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<ClCompile Include="Render\Rendering\BasicRender.cpp">
|
||||||
|
=======
|
||||||
|
<ClCompile Include="Resources\Resources.cpp">
|
||||||
|
>>>>>>> f08e9491ed00b00aedba0eabf1caed33830fc0e2
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Render\Preparations\BasicPreparations.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<ClCompile Include="Render\Resources\Resources.cpp">
|
||||||
|
=======
|
||||||
|
<ClCompile Include="Render\Rendering\BasicRender.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="FileLoader\ObjReader.cpp">
|
||||||
|
>>>>>>> f08e9491ed00b00aedba0eabf1caed33830fc0e2
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Core\Buffer.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Core\Core.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Core\CoreIncludes.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Render\Preparations\Preparations.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Render\Rendering\Render.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Model\ModelInfo.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Model\Model.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Render\Resources\Resources.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Definitions\GraphicalDefinition.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="FileLoader\ObjReader.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugVertex.hlsl" />
|
||||||
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl" />
|
||||||
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugCameraVertex.hlsl" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,214 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{0EC83E64-230E-48EF-B08C-6AC9651B4F82}</ProjectGuid>
|
||||||
|
<RootNamespace>OysterGraphics</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
<ProjectReference>
|
||||||
|
<LinkLibraryDependencies>true</LinkLibraryDependencies>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>..\OysterPhysic3D\Collision;..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Core\Buffer.cpp" />
|
||||||
|
<ClCompile Include="Core\Core.cpp" />
|
||||||
|
<ClCompile Include="Core\Init.cpp" />
|
||||||
|
<ClCompile Include="Core\ShaderManager.cpp" />
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<ClCompile Include="Render\Preparations\BasicPreparations.cpp" />
|
||||||
|
<ClCompile Include="Render\Rendering\BasicRender.cpp" />
|
||||||
|
<ClCompile Include="Render\Resources\Resources.cpp" />
|
||||||
|
=======
|
||||||
|
<ClCompile Include="FileLoader\ObjReader.cpp" />
|
||||||
|
<ClCompile Include="Render\Preparations\BasicPreparations.cpp" />
|
||||||
|
<ClCompile Include="Render\Rendering\BasicRender.cpp" />
|
||||||
|
<ClCompile Include="Resources\Resources.cpp" />
|
||||||
|
>>>>>>> f08e9491ed00b00aedba0eabf1caed33830fc0e2
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Core\Buffer.h" />
|
||||||
|
<ClInclude Include="Core\Core.h" />
|
||||||
|
<ClInclude Include="Core\CoreIncludes.h" />
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
<ClInclude Include="EngineIncludes.h" />
|
||||||
|
<ClInclude Include="FileLoader\ObjReader.h" />
|
||||||
|
>>>>>>> f08e9491ed00b00aedba0eabf1caed33830fc0e2
|
||||||
|
<ClInclude Include="Model\Model.h" />
|
||||||
|
<ClInclude Include="Model\ModelInfo.h" />
|
||||||
|
<ClInclude Include="Render\Preparations\Preparations.h" />
|
||||||
|
<ClInclude Include="Render\Rendering\Render.h" />
|
||||||
|
<ClInclude Include="Definitions\GraphicalDefinition.h" />
|
||||||
|
<ClInclude Include="Render\Resources\Resources.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Misc\Misc.vcxproj">
|
||||||
|
<Project>{2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\OysterMath\OysterMath.vcxproj">
|
||||||
|
<Project>{f10cbc03-9809-4cba-95d8-327c287b18ee}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugCameraVertex.hlsl">
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
|
||||||
|
</FxCompile>
|
||||||
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl">
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
|
||||||
|
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||||
|
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
|
||||||
|
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">main</EntryPointName>
|
||||||
|
</FxCompile>
|
||||||
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugVertex.hlsl">
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
|
||||||
|
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||||
|
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
|
||||||
|
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">main</EntryPointName>
|
||||||
|
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
</AssemblerOutput>
|
||||||
|
</FxCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
|
@ -1,29 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#ifndef MODELINFO_h
|
|
||||||
#define MODELINFO_h
|
|
||||||
|
|
||||||
//#include "../Engine.h"
|
|
||||||
|
|
||||||
|
|
||||||
#include "..\Core\CoreIncludes.h"
|
|
||||||
#include "..\Core\Buffer.h"
|
|
||||||
//#include "OysterMath.h"
|
|
||||||
//#include "ICollideable.h"
|
|
||||||
|
|
||||||
using namespace Oyster::Math;
|
|
||||||
|
|
||||||
namespace Oyster
|
|
||||||
{
|
|
||||||
namespace Render
|
|
||||||
{
|
|
||||||
struct ModelInfo
|
|
||||||
{
|
|
||||||
std::vector<ID3D11ShaderResourceView*> Material;
|
|
||||||
Oyster::Buffer Vertices,Indecies;
|
|
||||||
bool Indexed;
|
|
||||||
int VertexCount;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
#include "Preparations.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
namespace Preparations
|
||||||
|
{
|
||||||
|
void Basic::BindBackBufferRTV()
|
||||||
|
{
|
||||||
|
BindBackBufferRTV(Core::depthStencil);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic::BindBackBufferRTV(ID3D11DepthStencilView* depthStencil)
|
||||||
|
{
|
||||||
|
Core::deviceContext->OMSetRenderTargets(1,&Core::backBufferRTV,depthStencil);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic::BindBackBufferUAV()
|
||||||
|
{
|
||||||
|
Core::deviceContext->CSSetUnorderedAccessViews(0,1,&Core::backBufferUAV,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic::BindRTV(ID3D11RenderTargetView* RTVs[], int size, bool UseDepthStencil)
|
||||||
|
{
|
||||||
|
if(UseDepthStencil)
|
||||||
|
{
|
||||||
|
BindRTV(RTVs, size, Core::depthStencil);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BindRTV(RTVs, size, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic::BindRTV(ID3D11RenderTargetView* RTVs[], int size,ID3D11DepthStencilView* depthStencil)
|
||||||
|
{
|
||||||
|
Core::deviceContext->OMSetRenderTargets(size,RTVs,depthStencil);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic::BindUAV(ID3D11UnorderedAccessView* UAVs[], int size)
|
||||||
|
{
|
||||||
|
Core::deviceContext->CSSetUnorderedAccessViews(0,size,UAVs,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic::ClearBackBuffer(Oyster::Math::Float4 Color)
|
||||||
|
{
|
||||||
|
ClearRTV(&Core::backBufferRTV, 1,Color);
|
||||||
|
ClearDepthStencil(Core::depthStencil);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic::ClearRTV(ID3D11RenderTargetView* RTVs[], int size,Oyster::Math::Float4 Color)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < size; ++i)
|
||||||
|
{
|
||||||
|
Core::deviceContext->ClearRenderTargetView(RTVs[i],Color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic::ClearDepthStencil(ID3D11DepthStencilView* depthStencil)
|
||||||
|
{
|
||||||
|
Core::deviceContext->ClearDepthStencilView(depthStencil,1,1,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic::SetViewPort()
|
||||||
|
{
|
||||||
|
Core::deviceContext->RSSetViewports(1,Core::viewPort);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef Preparations_h
|
||||||
|
#define Preparations_h
|
||||||
|
|
||||||
|
#include "..\..\Core\Core.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
namespace Preparations
|
||||||
|
{
|
||||||
|
class Basic
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// @brief Binds the backbuffer as a RenderTargetView with the default DepthStencil
|
||||||
|
//! Binds the backbuffer as a RenderTargetView with the default DepthStencil
|
||||||
|
|
||||||
|
static void BindBackBufferRTV();
|
||||||
|
/** @brief Binds the backbuffer as a RenderTargetView with the specified DepthStencil*/
|
||||||
|
static void BindBackBufferRTV(ID3D11DepthStencilView* depthStencil);
|
||||||
|
|
||||||
|
|
||||||
|
/** @brief Binds the backbuffer as a UnorderedAccessView*/
|
||||||
|
static void BindBackBufferUAV();
|
||||||
|
|
||||||
|
/** @brief Binds the specified RenderTargetViews with the default DepthStencil*/
|
||||||
|
static void BindRTV(ID3D11RenderTargetView* RTVs[], int size, bool UseDepthStencil = true);
|
||||||
|
/** @brief Binds the specified RenderTargetViews with the specified DepthStencil*/
|
||||||
|
static void BindRTV(ID3D11RenderTargetView* RTVs[], int size,ID3D11DepthStencilView* depthStencil);
|
||||||
|
|
||||||
|
/** @brief Binds the specified UnorderedAccessViews*/
|
||||||
|
static void BindUAV(ID3D11UnorderedAccessView* UAVs[], int size);
|
||||||
|
|
||||||
|
/** @brief Clear the BackBuffer and the default DepthStencil*/
|
||||||
|
static void ClearBackBuffer(Oyster::Math::Float4 Color);
|
||||||
|
|
||||||
|
/** @brief Clear the specified RenderTargetViews*/
|
||||||
|
static void ClearRTV(ID3D11RenderTargetView* RTVs[], int size,Oyster::Math::Float4 Color);
|
||||||
|
/** @brief Clear the specified DepthStencil*/
|
||||||
|
static void ClearDepthStencil(ID3D11DepthStencilView* depthStencil);
|
||||||
|
|
||||||
|
/** @brief Binds the default ViewPort*/
|
||||||
|
static void SetViewPort();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,63 @@
|
||||||
|
#include "Render.h"
|
||||||
|
#include "../Resources/Resources.h"
|
||||||
|
#include "../../Definitions/GraphicalDefinition.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
namespace Rendering
|
||||||
|
{
|
||||||
|
|
||||||
|
void Basic::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection)
|
||||||
|
{
|
||||||
|
Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(0,0,0,1));
|
||||||
|
Core::ShaderManager::SetShaderEffect(Graphics::Render::Resources::obj);
|
||||||
|
Preparations::Basic::BindBackBufferRTV(nullptr);
|
||||||
|
|
||||||
|
Definitions::VP vp;
|
||||||
|
vp.V = View;
|
||||||
|
vp.P = Projection;
|
||||||
|
|
||||||
|
void* data = Resources::VPData.Map();
|
||||||
|
memcpy(data, &vp, sizeof(Definitions::VP));
|
||||||
|
Resources::VPData.Unmap();
|
||||||
|
|
||||||
|
Resources::VPData.Apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic::RenderScene(Model* models, int count)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
if(models[i].Visible)
|
||||||
|
{
|
||||||
|
void* data = Resources::ModelData.Map();
|
||||||
|
memcpy(data,&(models[i].World),64);
|
||||||
|
Resources::ModelData.Unmap();
|
||||||
|
|
||||||
|
//Set Materials :: NONE
|
||||||
|
|
||||||
|
models[i].info->Vertices->Apply();
|
||||||
|
if(models[i].info->Indexed)
|
||||||
|
{
|
||||||
|
models[i].info->Indecies->Apply();
|
||||||
|
Oyster::Graphics::Core::deviceContext->DrawIndexed(models[i].info->VertexCount,0,0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Oyster::Graphics::Core::deviceContext->Draw(models[i].info->VertexCount,0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void Basic::EndFrame()
|
||||||
|
{
|
||||||
|
Core::swapChain->Present(0,0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "..\..\Core\Core.h"
|
||||||
|
#include "..\Preparations\Preparations.h"
|
||||||
|
#include "..\..\Model\Model.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
namespace Rendering
|
||||||
|
{
|
||||||
|
class Basic
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection);
|
||||||
|
static void RenderScene(Model* models, int count);
|
||||||
|
static void EndFrame();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,105 @@
|
||||||
|
#include "Resources.h"
|
||||||
|
#include "..\OysterGraphics\Definitions\GraphicalDefinition.h"
|
||||||
|
|
||||||
|
const std::wstring PathFromExeToHlsl = L"..\\OysterGraphics\\Shader\\HLSL\\";
|
||||||
|
const std::wstring VertexTransformDebug = L"TransformDebugVertex";
|
||||||
|
const std::wstring VertexDebug = L"DebugVertex";
|
||||||
|
const std::wstring PixelRed = L"DebugPixel";
|
||||||
|
|
||||||
|
typedef Oyster::Graphics::Core::ShaderManager::ShaderType ShaderType;
|
||||||
|
typedef Oyster::Graphics::Core::ShaderManager::Get GetShader;
|
||||||
|
typedef Oyster::Graphics::Core::ShaderManager Shader;
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
Shader::ShaderEffect Resources::obj;
|
||||||
|
Buffer Resources::ModelData = Buffer();
|
||||||
|
Buffer Resources::VPData = Buffer();
|
||||||
|
|
||||||
|
Core::Init::State Resources::Init()
|
||||||
|
{
|
||||||
|
|
||||||
|
#pragma region LoadShaders
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
|
||||||
|
/** Load Vertex Shader for d3dcompile*/
|
||||||
|
Core::ShaderManager::Init(PathFromExeToHlsl + L"SimpleDebug\\" +L"DebugCameraVertex.hlsl",ShaderType::Vertex, VertexTransformDebug, false);
|
||||||
|
Core::ShaderManager::Init(PathFromExeToHlsl + L"SimpleDebug\\" +L"DebugVertex.hlsl",ShaderType::Vertex, VertexDebug, false);
|
||||||
|
|
||||||
|
/** Load Pixel Shader for d3dcompile */
|
||||||
|
Core::ShaderManager::Init(PathFromExeToHlsl + L"SimpleDebug\\" + L"DebugPixel.hlsl", ShaderType::Pixel, PixelRed, false);
|
||||||
|
|
||||||
|
#else
|
||||||
|
/** Load Vertex Shader with Precompiled */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region CreateBuffers
|
||||||
|
Buffer::BUFFER_INIT_DESC desc;
|
||||||
|
desc.ElementSize = sizeof(Oyster::Math::Matrix);
|
||||||
|
desc.NumElements = 1;
|
||||||
|
desc.InitData = NULL;
|
||||||
|
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_VS;
|
||||||
|
desc.Usage = Buffer::BUFFER_USAGE::BUFFER_CPU_WRITE_DISCARD;
|
||||||
|
|
||||||
|
ModelData.Init(desc);
|
||||||
|
|
||||||
|
desc.NumElements = 2;
|
||||||
|
VPData.Init(desc);
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Setup Render States
|
||||||
|
/** @todo Create DX States */
|
||||||
|
|
||||||
|
D3D11_RASTERIZER_DESC rdesc;
|
||||||
|
rdesc.CullMode = D3D11_CULL_NONE;
|
||||||
|
rdesc.FillMode = D3D11_FILL_SOLID;
|
||||||
|
rdesc.FrontCounterClockwise = false;
|
||||||
|
rdesc.DepthBias = 0;
|
||||||
|
rdesc.DepthBiasClamp = 0;
|
||||||
|
rdesc.DepthClipEnable = true;
|
||||||
|
rdesc.SlopeScaledDepthBias = 0;
|
||||||
|
rdesc.ScissorEnable = false;
|
||||||
|
rdesc.MultisampleEnable = false;
|
||||||
|
rdesc.AntialiasedLineEnable = false;
|
||||||
|
|
||||||
|
ID3D11RasterizerState* rs = NULL;
|
||||||
|
Oyster::Graphics::Core::device->CreateRasterizerState(&rdesc,&rs);
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Setup Views
|
||||||
|
/** @todo Create Views */
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Create Shader Effects
|
||||||
|
/** @todo Create ShaderEffects */
|
||||||
|
obj.Shaders.Pixel = GetShader::Pixel(PixelRed);
|
||||||
|
obj.Shaders.Vertex = GetShader::Vertex(VertexTransformDebug);
|
||||||
|
|
||||||
|
D3D11_INPUT_ELEMENT_DESC indesc[] =
|
||||||
|
{
|
||||||
|
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
|
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
|
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0 }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
Shader::CreateInputLayout(indesc,3,GetShader::Vertex(VertexTransformDebug),obj.IAStage.Layout);
|
||||||
|
obj.IAStage.Topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
||||||
|
obj.CBuffers.Vertex.push_back(&VPData);
|
||||||
|
obj.RenderStates.Rasterizer = rs;
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
return Core::Init::Sucsess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef Reources_h
|
||||||
|
#define Reources_h
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include "../OysterGraphics/Core/Core.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
class Resources
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Core::ShaderManager::ShaderEffect obj;
|
||||||
|
static Buffer ModelData;
|
||||||
|
static Buffer VPData;
|
||||||
|
|
||||||
|
static Core::Init::State Init();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,67 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "..\Engine.h"
|
|
||||||
const int MAX_LETTER_COUNT=60;
|
|
||||||
const int TEXT_NR_LETTERS=95;
|
|
||||||
const float TEXT_SIZE=2.5;
|
|
||||||
struct Text2D
|
|
||||||
{
|
|
||||||
Oyster::Math::Float Pos;
|
|
||||||
int offset;
|
|
||||||
float coff;
|
|
||||||
};
|
|
||||||
/*struct TextInstanceData
|
|
||||||
{
|
|
||||||
Oyster::Buffer InstanceBuffer;
|
|
||||||
bool Visible;
|
|
||||||
int NumLetters;
|
|
||||||
Oyster::Math::Float4x4 World;
|
|
||||||
};*/
|
|
||||||
/*struct TextData
|
|
||||||
{
|
|
||||||
Oyster::Math::Float3 pos;
|
|
||||||
Oyster::Math::Float2 uv;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct PerCharData
|
|
||||||
{
|
|
||||||
float data;
|
|
||||||
Oyster::Math::Float3 charOffset;
|
|
||||||
};
|
|
||||||
struct TextInstanceData
|
|
||||||
{
|
|
||||||
Oyster::Buffer InstanceBuffer;
|
|
||||||
bool Visible;
|
|
||||||
int NumLetters;
|
|
||||||
Oyster::Math::Float4x4 World;
|
|
||||||
};*/
|
|
||||||
|
|
||||||
namespace Oyster
|
|
||||||
{
|
|
||||||
namespace Render
|
|
||||||
{
|
|
||||||
class Textbox
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
static float getCharID(char _in);
|
|
||||||
static HRESULT CreateVertexBuffer();
|
|
||||||
static HRESULT CreateTextfield(int _id);
|
|
||||||
public:
|
|
||||||
//static Oyster::Buffer TextBuffer;
|
|
||||||
//static int NumVertices;
|
|
||||||
//static std::vector<TextInstanceData> TextInstances;
|
|
||||||
static Oyster::Buffer TextBuffer;
|
|
||||||
static int NumLetters;
|
|
||||||
static ID3D11ShaderResourceView* Texture;
|
|
||||||
|
|
||||||
static bool Init();
|
|
||||||
static bool UpdateTextField(std::string _str);
|
|
||||||
static bool SetTexture(const char* _file);
|
|
||||||
//Updates a textbox with the certain id
|
|
||||||
static void Update(std::string _str, float _scale);
|
|
||||||
//Removes all old instances and recreates it with the input data
|
|
||||||
static HRESULT Reset(int _count, std::string* _str, Float3* _pos);
|
|
||||||
static void Apply(int _id);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
cbuffer PerFrame : register(b0)
|
||||||
|
{
|
||||||
|
matrix View;
|
||||||
|
float4x4 Projection;
|
||||||
|
}
|
||||||
|
|
||||||
|
cbuffer PerModel : register(b1)
|
||||||
|
{
|
||||||
|
matrix World;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct VertexIn
|
||||||
|
{
|
||||||
|
float3 pos : POSITION;
|
||||||
|
float2 UV : TEXCOORD;
|
||||||
|
float3 normal : NORMAL;
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 main( VertexIn input ) : SV_POSITION
|
||||||
|
{
|
||||||
|
float4 postTransform = float4(input.pos*0.1f,1);
|
||||||
|
postTransform.y += 1.5f;
|
||||||
|
//return postTransform;
|
||||||
|
//return mul(View, float4(input.pos,1));
|
||||||
|
matrix VP = mul(Projection, View);
|
||||||
|
//matrix WVP = mul(World, VP);
|
||||||
|
return mul(VP, float4(input.pos*0.1f,1) );
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
float4 main() : SV_TARGET
|
float4 main() : SV_TARGET0
|
||||||
{
|
{
|
||||||
return float4(1.0f, 0.0f, 0.0f, 1.0f);
|
return float4(1.0f, 0.0f, 0.0f, 1.0f);
|
||||||
}
|
}
|
|
@ -4,75 +4,78 @@
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
class Shader
|
namespace Graphics
|
||||||
{
|
{
|
||||||
public:
|
class Shader
|
||||||
struct ShaderEffect
|
|
||||||
{
|
{
|
||||||
struct
|
public:
|
||||||
|
struct ShaderEffect
|
||||||
{
|
{
|
||||||
int Pixel,Vertex,Geometry,Compute,Hull,Domain;
|
struct
|
||||||
}Shaders;
|
{
|
||||||
struct IAStage_
|
int Pixel,Vertex,Geometry,Compute,Hull,Domain;
|
||||||
|
}Shaders;
|
||||||
|
struct IAStage_
|
||||||
|
{
|
||||||
|
ID3D11InputLayout* Layout;
|
||||||
|
D3D11_PRIMITIVE_TOPOLOGY Topology;
|
||||||
|
}IAStage;
|
||||||
|
struct RenderStates_
|
||||||
|
{
|
||||||
|
ID3D11DepthStencilState *DepthStencil;
|
||||||
|
ID3D11RasterizerState *Rasterizer;
|
||||||
|
ID3D11SamplerState **SampleState;
|
||||||
|
int SampleCount;
|
||||||
|
ID3D11BlendState *BlendState;
|
||||||
|
}RenderStates;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
std::vector<Buffer*> Vertex;
|
||||||
|
std::vector<Buffer*> Geometry;
|
||||||
|
std::vector<Buffer*> Pixel;
|
||||||
|
}CBuffers;
|
||||||
|
ShaderEffect()
|
||||||
|
{
|
||||||
|
RenderStates.BlendState=NULL;
|
||||||
|
RenderStates.DepthStencil=NULL;
|
||||||
|
RenderStates.Rasterizer=NULL;
|
||||||
|
RenderStates.SampleState=NULL;
|
||||||
|
RenderStates.SampleCount=0;
|
||||||
|
Shaders.Compute=-1;
|
||||||
|
Shaders.Domain=-1;
|
||||||
|
Shaders.Geometry=-1;
|
||||||
|
Shaders.Hull=-1;
|
||||||
|
Shaders.Pixel=-1;
|
||||||
|
Shaders.Vertex=-1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
static bool InitShaders(const std::string &name = "..\\Shaders\\ShaderConfig.txt");
|
||||||
|
|
||||||
|
static void SetShaderEffect(ShaderEffect);
|
||||||
|
|
||||||
|
static void CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout);
|
||||||
|
|
||||||
|
struct Set
|
||||||
{
|
{
|
||||||
ID3D11InputLayout* Layout;
|
static void SetPixel(int Index);
|
||||||
D3D11_PRIMITIVE_TOPOLOGY Topology;
|
static void SetVertex(int Index);
|
||||||
}IAStage;
|
static void SetGeometry(int Index);
|
||||||
struct RenderStates_
|
static void SetCompute(int Index);
|
||||||
|
static void SetHull(int Index);
|
||||||
|
static void SetDomain(int Index);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Get
|
||||||
{
|
{
|
||||||
ID3D11DepthStencilState *DepthStencil;
|
static int GetPixel(std::string Name);
|
||||||
ID3D11RasterizerState *Rasterizer;
|
static int GetVertex(std::string Name);
|
||||||
ID3D11SamplerState **SampleState;
|
static int GetGeometry(std::string Name);
|
||||||
int SampleCount;
|
static int GetCompute(std::string Name);
|
||||||
ID3D11BlendState *BlendState;
|
static int GetHull(std::string Name);
|
||||||
}RenderStates;
|
static int GetDomain(std::string Name);
|
||||||
struct
|
};
|
||||||
{
|
|
||||||
std::vector<Buffer*> Vertex;
|
static std::stringstream* AccesLog();
|
||||||
std::vector<Buffer*> Geometry;
|
|
||||||
std::vector<Buffer*> Pixel;
|
|
||||||
}CBuffers;
|
|
||||||
ShaderEffect()
|
|
||||||
{
|
|
||||||
RenderStates.BlendState=NULL;
|
|
||||||
RenderStates.DepthStencil=NULL;
|
|
||||||
RenderStates.Rasterizer=NULL;
|
|
||||||
RenderStates.SampleState=NULL;
|
|
||||||
RenderStates.SampleCount=0;
|
|
||||||
Shaders.Compute=-1;
|
|
||||||
Shaders.Domain=-1;
|
|
||||||
Shaders.Geometry=-1;
|
|
||||||
Shaders.Hull=-1;
|
|
||||||
Shaders.Pixel=-1;
|
|
||||||
Shaders.Vertex=-1;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
static bool InitShaders(const std::string &name = "..\\Shaders\\ShaderConfig.txt");
|
}
|
||||||
|
|
||||||
static void SetShaderEffect(ShaderEffect);
|
|
||||||
|
|
||||||
static void CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout);
|
|
||||||
|
|
||||||
struct Set
|
|
||||||
{
|
|
||||||
static void SetPixel(int Index);
|
|
||||||
static void SetVertex(int Index);
|
|
||||||
static void SetGeometry(int Index);
|
|
||||||
static void SetCompute(int Index);
|
|
||||||
static void SetHull(int Index);
|
|
||||||
static void SetDomain(int Index);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Get
|
|
||||||
{
|
|
||||||
static int GetPixel(std::string Name);
|
|
||||||
static int GetVertex(std::string Name);
|
|
||||||
static int GetGeometry(std::string Name);
|
|
||||||
static int GetCompute(std::string Name);
|
|
||||||
static int GetHull(std::string Name);
|
|
||||||
static int GetDomain(std::string Name);
|
|
||||||
};
|
|
||||||
|
|
||||||
static std::stringstream* AccesLog();
|
|
||||||
};
|
|
||||||
}
|
}
|
|
@ -161,6 +161,32 @@ namespace LinearAlgebra2D
|
||||||
return targetMem = ::LinearAlgebra::Matrix3x3<ScalarType>( c,-s, 0, s, c, 0, 0, 0, 1 );
|
return targetMem = ::LinearAlgebra::Matrix3x3<ScalarType>( c,-s, 0, s, c, 0, 0, 0, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline ::LinearAlgebra::Matrix2x2<ScalarType> & InverseRotationMatrix( const ::LinearAlgebra::Matrix2x2<ScalarType> &rotationMatrix )
|
||||||
|
{
|
||||||
|
return rotationMatrix.GetTranspose();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline ::LinearAlgebra::Matrix3x3<ScalarType> & InverseRotationMatrix( const ::LinearAlgebra::Matrix3x3<ScalarType> &rotationMatrix )
|
||||||
|
{
|
||||||
|
return rotationMatrix.GetTranspose();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline ::LinearAlgebra::Matrix3x3<ScalarType> OrientationMatrix( const ::LinearAlgebra::Matrix2x2<ScalarType> &rotation, const ::LinearAlgebra::Vector2<ScalarType> &translation )
|
||||||
|
{
|
||||||
|
return ::LinearAlgebra::Matrix3x3<ScalarType>( ::LinearAlgebra::Vector3<ScalarType>(rotation.v[0], 0),
|
||||||
|
::LinearAlgebra::Vector3<ScalarType>(rotation.v[1], 0),
|
||||||
|
::LinearAlgebra::Vector3<ScalarType>(translation, 1) );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline ::LinearAlgebra::Matrix3x3<ScalarType> OrientationMatrix( const ::LinearAlgebra::Matrix3x3<ScalarType> &rotation, const ::LinearAlgebra::Vector2<ScalarType> &translation )
|
||||||
|
{
|
||||||
|
return ::LinearAlgebra::Matrix3x3<ScalarType>( rotation.v[0], rotation.v[1], ::LinearAlgebra::Vector3<ScalarType>(translation, 1) );
|
||||||
|
}
|
||||||
|
|
||||||
template<typename ScalarType>
|
template<typename ScalarType>
|
||||||
inline ::LinearAlgebra::Matrix3x3<ScalarType> & OrientationMatrix( const ScalarType &radian, const ::LinearAlgebra::Vector2<ScalarType> &position, ::LinearAlgebra::Matrix3x3<ScalarType> &targetMem = ::LinearAlgebra::Matrix3x3<ScalarType>() )
|
inline ::LinearAlgebra::Matrix3x3<ScalarType> & OrientationMatrix( const ScalarType &radian, const ::LinearAlgebra::Vector2<ScalarType> &position, ::LinearAlgebra::Matrix3x3<ScalarType> &targetMem = ::LinearAlgebra::Matrix3x3<ScalarType>() )
|
||||||
{
|
{
|
||||||
|
@ -197,6 +223,12 @@ namespace LinearAlgebra2D
|
||||||
orientationMatrix.m12, orientationMatrix.m22, -orientationMatrix.v[1].xy.Dot(orientationMatrix.v[2].xy),
|
orientationMatrix.m12, orientationMatrix.m22, -orientationMatrix.v[1].xy.Dot(orientationMatrix.v[2].xy),
|
||||||
0, 0, 1 );
|
0, 0, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline ::LinearAlgebra::Matrix3x3<ScalarType> ExtractRotationMatrix( const ::LinearAlgebra::Matrix3x3<ScalarType> &orientationMatrix )
|
||||||
|
{
|
||||||
|
return ::LinearAlgebra::Matrix3x3<ScalarType>( orientationMatrix.v[0], orientationMatrix.v[1], ::LinearAlgebra::Vector3<ScalarType>::standard_unit_z );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace LinearAlgebra3D
|
namespace LinearAlgebra3D
|
||||||
|
@ -283,6 +315,33 @@ namespace LinearAlgebra3D
|
||||||
return targetMem;
|
return targetMem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline ::LinearAlgebra::Matrix3x3<ScalarType> & InverseRotationMatrix( const ::LinearAlgebra::Matrix3x3<ScalarType> &rotationMatrix )
|
||||||
|
{
|
||||||
|
return rotationMatrix.GetTranspose();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline ::LinearAlgebra::Matrix4x4<ScalarType> & InverseRotationMatrix( const ::LinearAlgebra::Matrix4x4<ScalarType> &rotationMatrix )
|
||||||
|
{
|
||||||
|
return rotationMatrix.GetTranspose();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline ::LinearAlgebra::Matrix4x4<ScalarType> OrientationMatrix( const ::LinearAlgebra::Matrix3x3<ScalarType> &rotation, const ::LinearAlgebra::Vector3<ScalarType> &translation )
|
||||||
|
{
|
||||||
|
return ::LinearAlgebra::Matrix4x4<ScalarType>( ::LinearAlgebra::Vector4<ScalarType>(rotation.v[0], 0),
|
||||||
|
::LinearAlgebra::Vector4<ScalarType>(rotation.v[1], 0),
|
||||||
|
::LinearAlgebra::Vector4<ScalarType>(rotation.v[2], 0),
|
||||||
|
::LinearAlgebra::Vector4<ScalarType>(translation, 1) );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline ::LinearAlgebra::Matrix4x4<ScalarType> OrientationMatrix( const ::LinearAlgebra::Matrix4x4<ScalarType> &rotation, const ::LinearAlgebra::Vector3<ScalarType> &translation )
|
||||||
|
{
|
||||||
|
return ::LinearAlgebra::Matrix4x4<ScalarType>( rotation.v[0], rotation.v[1], rotation.v[2], ::LinearAlgebra::Vector4<ScalarType>(translation, 1) );
|
||||||
|
}
|
||||||
|
|
||||||
template<typename ScalarType>
|
template<typename ScalarType>
|
||||||
::LinearAlgebra::Matrix4x4<ScalarType> & OrientationMatrix( const ::LinearAlgebra::Vector3<ScalarType> &normalizedAxis, const ScalarType &deltaRadian, const ::LinearAlgebra::Vector3<ScalarType> &sumTranslation, ::LinearAlgebra::Matrix4x4<ScalarType> &targetMem = ::LinearAlgebra::Matrix4x4<ScalarType>() )
|
::LinearAlgebra::Matrix4x4<ScalarType> & OrientationMatrix( const ::LinearAlgebra::Vector3<ScalarType> &normalizedAxis, const ScalarType &deltaRadian, const ::LinearAlgebra::Vector3<ScalarType> &sumTranslation, ::LinearAlgebra::Matrix4x4<ScalarType> &targetMem = ::LinearAlgebra::Matrix4x4<ScalarType>() )
|
||||||
{ /** @todo TODO: not tested */
|
{ /** @todo TODO: not tested */
|
||||||
|
@ -327,6 +386,23 @@ namespace LinearAlgebra3D
|
||||||
return targetMem;
|
return targetMem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline ::LinearAlgebra::Matrix4x4<ScalarType> OrientationMatrix_LookAtDirection( const ::LinearAlgebra::Vector3<ScalarType> &normalizedDirection, const ::LinearAlgebra::Vector3<ScalarType> &normalizedUpVector, const ::LinearAlgebra::Vector3<ScalarType> &worldPos )
|
||||||
|
{ // Righthanded system! Forward is considered to be along negative z axis. Up is considered along positive y axis.
|
||||||
|
::LinearAlgebra::Vector3<ScalarType> right = normalizedDirection.Cross( normalizedUpVector ).GetNormalized();
|
||||||
|
return ::LinearAlgebra::Matrix4x4<ScalarType>( ::LinearAlgebra::Vector4<ScalarType>( right, 0.0f ),
|
||||||
|
::LinearAlgebra::Vector4<ScalarType>( right.Cross( normalizedDirection ), 0.0f ),
|
||||||
|
::LinearAlgebra::Vector4<ScalarType>( normalizedDirection, 0.0f ),
|
||||||
|
::LinearAlgebra::Vector4<ScalarType>( worldPos, 1.0f ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline ::LinearAlgebra::Matrix4x4<ScalarType> OrientationMatrix_LookAtPos( const ::LinearAlgebra::Vector3<ScalarType> &worldLookAt, const ::LinearAlgebra::Vector3<ScalarType> &normalizedUpVector, const ::LinearAlgebra::Vector3<ScalarType> &worldPos )
|
||||||
|
{ // Righthanded system! Forward is considered to be along negative z axis. Up is considered along positive y axis.
|
||||||
|
::LinearAlgebra::Vector3<ScalarType> direction = ( worldLookAt - worldPos ).GetNormalized();
|
||||||
|
return OrientationMatrix_LookAtDirection( direction, normalizedUpVector, worldPos );
|
||||||
|
}
|
||||||
|
|
||||||
template<typename ScalarType>
|
template<typename ScalarType>
|
||||||
inline ::LinearAlgebra::Matrix4x4<ScalarType> & InverseOrientationMatrix( const ::LinearAlgebra::Matrix4x4<ScalarType> &orientationMatrix, ::LinearAlgebra::Matrix4x4<ScalarType> &targetMem = ::LinearAlgebra::Matrix4x4<ScalarType>() )
|
inline ::LinearAlgebra::Matrix4x4<ScalarType> & InverseOrientationMatrix( const ::LinearAlgebra::Matrix4x4<ScalarType> &orientationMatrix, ::LinearAlgebra::Matrix4x4<ScalarType> &targetMem = ::LinearAlgebra::Matrix4x4<ScalarType>() )
|
||||||
{
|
{
|
||||||
|
@ -349,6 +425,12 @@ namespace LinearAlgebra3D
|
||||||
return orientationMatrix;
|
return orientationMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline ::LinearAlgebra::Matrix4x4<ScalarType> ExtractRotationMatrix( const ::LinearAlgebra::Matrix4x4<ScalarType> &orientationMatrix )
|
||||||
|
{
|
||||||
|
return ::LinearAlgebra::Matrix4x4<ScalarType>( orientationMatrix.v[0], orientationMatrix.v[1], orientationMatrix.v[2], ::LinearAlgebra::Vector4<ScalarType>::standard_unit_w );
|
||||||
|
}
|
||||||
|
|
||||||
/* Creates an orthographic projection matrix designed for DirectX enviroment.
|
/* Creates an orthographic projection matrix designed for DirectX enviroment.
|
||||||
width; of the projection sample volume.
|
width; of the projection sample volume.
|
||||||
height; of the projection sample volume.
|
height; of the projection sample volume.
|
||||||
|
@ -390,6 +472,10 @@ namespace LinearAlgebra3D
|
||||||
template<typename ScalarType>
|
template<typename ScalarType>
|
||||||
inline ::LinearAlgebra::Vector3<ScalarType> VectorProjection( const ::LinearAlgebra::Vector3<ScalarType> &vector, const ::LinearAlgebra::Vector3<ScalarType> &axis )
|
inline ::LinearAlgebra::Vector3<ScalarType> VectorProjection( const ::LinearAlgebra::Vector3<ScalarType> &vector, const ::LinearAlgebra::Vector3<ScalarType> &axis )
|
||||||
{ return axis * ( vector.Dot(axis) / axis.Dot(axis) ); }
|
{ return axis * ( vector.Dot(axis) / axis.Dot(axis) ); }
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline ::LinearAlgebra::Vector3<ScalarType> NormalProjection( const ::LinearAlgebra::Vector3<ScalarType> &vector, const ::LinearAlgebra::Vector3<ScalarType> &normalizedAxis )
|
||||||
|
{ return normalizedAxis * ( vector.Dot(normalizedAxis) ); }
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
|
|
|
@ -33,17 +33,50 @@ namespace Oyster { namespace Math2D
|
||||||
Float3x3 & RotationMatrix( const Float &radian, Float3x3 &targetMem )
|
Float3x3 & RotationMatrix( const Float &radian, Float3x3 &targetMem )
|
||||||
{ return ::LinearAlgebra2D::RotationMatrix( radian, targetMem ); }
|
{ return ::LinearAlgebra2D::RotationMatrix( radian, targetMem ); }
|
||||||
|
|
||||||
|
Float2x2 & InverseRotationMatrix( const Float2x2 &rotation, Float2x2 &targetMem )
|
||||||
|
{
|
||||||
|
return targetMem = ::LinearAlgebra2D::InverseRotationMatrix( rotation );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float3x3 & InverseRotationMatrix( const Float3x3 &rotation, Float3x3 &targetMem )
|
||||||
|
{
|
||||||
|
return targetMem = ::LinearAlgebra2D::InverseRotationMatrix( rotation );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float3x3 & OrientationMatrix( const Float2x2 &rotation, const Float2 &translation, Float3x3 &targetMem )
|
||||||
|
{
|
||||||
|
return targetMem = ::LinearAlgebra2D::OrientationMatrix( rotation, translation );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float3x3 & OrientationMatrix( const Float3x3 &rotation, const Float2 &translation, Float3x3 &targetMem )
|
||||||
|
{
|
||||||
|
return targetMem = ::LinearAlgebra2D::OrientationMatrix( rotation, translation );
|
||||||
|
}
|
||||||
|
|
||||||
Float3x3 & OrientationMatrix( const Float2 &position, const Float &radian, Float3x3 &targetMem )
|
Float3x3 & OrientationMatrix( const Float2 &position, const Float &radian, Float3x3 &targetMem )
|
||||||
{ return ::LinearAlgebra2D::OrientationMatrix( radian, position, targetMem ); }
|
{
|
||||||
|
return ::LinearAlgebra2D::OrientationMatrix( radian, position, targetMem );
|
||||||
|
}
|
||||||
|
|
||||||
Float3x3 & OrientationMatrix( const Float2 &position, const Float2 &lookAt, Float3x3 &targetMem )
|
Float3x3 & OrientationMatrix( const Float2 &position, const Float2 &lookAt, Float3x3 &targetMem )
|
||||||
{ return ::LinearAlgebra2D::OrientationMatrix( lookAt, position, targetMem ); }
|
{
|
||||||
|
return ::LinearAlgebra2D::OrientationMatrix( lookAt, position, targetMem );
|
||||||
|
}
|
||||||
|
|
||||||
Float3x3 & OrientationMatrix( const Float2 &position, Float radian, const Float2 &localCenterOfRotation, Float3x3 &targetMem )
|
Float3x3 & OrientationMatrix( const Float2 &position, Float radian, const Float2 &localCenterOfRotation, Float3x3 &targetMem )
|
||||||
{ return ::LinearAlgebra2D::OrientationMatrix( radian, position, localCenterOfRotation, targetMem ); }
|
{
|
||||||
|
return ::LinearAlgebra2D::OrientationMatrix( radian, position, localCenterOfRotation, targetMem );
|
||||||
|
}
|
||||||
|
|
||||||
Float3x3 & InverseOrientationMatrix( const Float3x3 &orientationMatrix, Float3x3 &targetMem )
|
Float3x3 & InverseOrientationMatrix( const Float3x3 &orientationMatrix, Float3x3 &targetMem )
|
||||||
{ return ::LinearAlgebra2D::InverseOrientationMatrix( orientationMatrix, targetMem ); }
|
{
|
||||||
|
return ::LinearAlgebra2D::InverseOrientationMatrix( orientationMatrix, targetMem );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float3x3 & ExtractRotationMatrix( const Float3x3 &orientation, Float3x3 &targetMem )
|
||||||
|
{
|
||||||
|
return targetMem = ::LinearAlgebra2D::ExtractRotationMatrix( orientation );
|
||||||
|
}
|
||||||
} }
|
} }
|
||||||
|
|
||||||
namespace Oyster { namespace Math3D
|
namespace Oyster { namespace Math3D
|
||||||
|
@ -63,29 +96,83 @@ namespace Oyster { namespace Math3D
|
||||||
Float4x4 & RotationMatrix( const Float &radian, const Float3 &normalizedAxis, Float4x4 &targetMem )
|
Float4x4 & RotationMatrix( const Float &radian, const Float3 &normalizedAxis, Float4x4 &targetMem )
|
||||||
{ return ::LinearAlgebra3D::RotationMatrix( normalizedAxis, radian, targetMem ); }
|
{ return ::LinearAlgebra3D::RotationMatrix( normalizedAxis, radian, targetMem ); }
|
||||||
|
|
||||||
|
Float3x3 & InverseRotationMatrix( const Float3x3 &rotation, Float3x3 &targetMem )
|
||||||
|
{
|
||||||
|
return targetMem = ::LinearAlgebra3D::InverseRotationMatrix( rotation );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float4x4 & InverseRotationMatrix( const Float4x4 &rotation, Float4x4 &targetMem )
|
||||||
|
{
|
||||||
|
return targetMem = ::LinearAlgebra3D::InverseRotationMatrix( rotation );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float4x4 & OrientationMatrix( const Float3x3 &rotation, const Float3 &translation, Float4x4 &targetMem )
|
||||||
|
{
|
||||||
|
return targetMem = ::LinearAlgebra3D::OrientationMatrix( rotation, translation );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float4x4 & OrientationMatrix( const Float4x4 &rotation, const Float3 &translation, Float4x4 &targetMem )
|
||||||
|
{
|
||||||
|
return targetMem = ::LinearAlgebra3D::OrientationMatrix( rotation, translation );
|
||||||
|
}
|
||||||
|
|
||||||
Float4x4 & OrientationMatrix( const Float3 &normalizedAxis, const Float & deltaRadian, const Float3 &sumTranslation, Float4x4 &targetMem )
|
Float4x4 & OrientationMatrix( const Float3 &normalizedAxis, const Float & deltaRadian, const Float3 &sumTranslation, Float4x4 &targetMem )
|
||||||
{ return ::LinearAlgebra3D::OrientationMatrix( normalizedAxis, deltaRadian, sumTranslation, targetMem ); }
|
{
|
||||||
|
return ::LinearAlgebra3D::OrientationMatrix( normalizedAxis, deltaRadian, sumTranslation, targetMem );
|
||||||
|
}
|
||||||
|
|
||||||
Float4x4 & OrientationMatrix( const Float3 &sumDeltaAngularAxis, const Float3 &sumTranslation, Float4x4 &targetMem )
|
Float4x4 & OrientationMatrix( const Float3 &sumDeltaAngularAxis, const Float3 &sumTranslation, Float4x4 &targetMem )
|
||||||
{ return ::LinearAlgebra3D::OrientationMatrix( sumDeltaAngularAxis, sumTranslation, targetMem ); }
|
{
|
||||||
|
return ::LinearAlgebra3D::OrientationMatrix( sumDeltaAngularAxis, sumTranslation, targetMem );
|
||||||
|
}
|
||||||
|
|
||||||
Float4x4 & OrientationMatrix( const Float3 &sumDeltaAngularAxis, const Float3 &sumTranslation, const Float3 ¢erOfMass, Float4x4 &targetMem )
|
Float4x4 & OrientationMatrix( const Float3 &sumDeltaAngularAxis, const Float3 &sumTranslation, const Float3 ¢erOfMass, Float4x4 &targetMem )
|
||||||
{ return ::LinearAlgebra3D::OrientationMatrix( sumDeltaAngularAxis, sumTranslation, centerOfMass, targetMem ); }
|
{
|
||||||
|
return ::LinearAlgebra3D::OrientationMatrix( sumDeltaAngularAxis, sumTranslation, centerOfMass, targetMem );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float4x4 & OrientationMatrix_LookAtDirection( const Float3 &normalizedDirection, const Float3 &normalizedUpVector, const Float3 &worldPos, Float4x4 &targetMem )
|
||||||
|
{
|
||||||
|
return targetMem = ::LinearAlgebra3D::OrientationMatrix_LookAtDirection( normalizedDirection, normalizedUpVector, worldPos );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float4x4 & OrientationMatrix_LookAtPos( const Float3 &worldLookAt, const Float3 &normalizedUpVector, const Float3 &worldPos, Float4x4 &targetMem )
|
||||||
|
{
|
||||||
|
return targetMem = ::LinearAlgebra3D::OrientationMatrix_LookAtPos( worldLookAt, normalizedUpVector, worldPos );
|
||||||
|
}
|
||||||
|
|
||||||
Float4x4 & InverseOrientationMatrix( const Float4x4 &orientationMatrix, Float4x4 &targetMem )
|
Float4x4 & InverseOrientationMatrix( const Float4x4 &orientationMatrix, Float4x4 &targetMem )
|
||||||
{ return ::LinearAlgebra3D::InverseOrientationMatrix( orientationMatrix, targetMem ); }
|
{
|
||||||
|
return ::LinearAlgebra3D::InverseOrientationMatrix( orientationMatrix, targetMem );
|
||||||
|
}
|
||||||
|
|
||||||
Float4x4 & UpdateOrientationMatrix( const Float3 &deltaPosition, const Float4x4 &deltaRotationMatrix, Float4x4 &orientationMatrix )
|
Float4x4 & UpdateOrientationMatrix( const Float3 &deltaPosition, const Float4x4 &deltaRotationMatrix, Float4x4 &orientationMatrix )
|
||||||
{ return ::LinearAlgebra3D::UpdateOrientationMatrix( deltaPosition, deltaRotationMatrix, orientationMatrix ); }
|
{
|
||||||
|
return ::LinearAlgebra3D::UpdateOrientationMatrix( deltaPosition, deltaRotationMatrix, orientationMatrix );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float4x4 & ExtractRotationMatrix( const Float4x4 &orientation, Float4x4 &targetMem )
|
||||||
|
{
|
||||||
|
return targetMem = ::LinearAlgebra3D::ExtractRotationMatrix( orientation );
|
||||||
|
}
|
||||||
|
|
||||||
Float4x4 & ProjectionMatrix_Orthographic( const Float &width, const Float &height, const Float &nearClip, const Float &farClip, Float4x4 &targetMem )
|
Float4x4 & ProjectionMatrix_Orthographic( const Float &width, const Float &height, const Float &nearClip, const Float &farClip, Float4x4 &targetMem )
|
||||||
{ return ::LinearAlgebra3D::ProjectionMatrix_Orthographic( width, height, nearClip, farClip, targetMem ); }
|
{
|
||||||
|
return ::LinearAlgebra3D::ProjectionMatrix_Orthographic( width, height, nearClip, farClip, targetMem );
|
||||||
|
}
|
||||||
|
|
||||||
Float4x4 & ProjectionMatrix_Perspective( const Float &verticalFoV, const Float &aspectRatio, const Float &nearClip, const Float &farClip, Float4x4 &targetMem )
|
Float4x4 & ProjectionMatrix_Perspective( const Float &verticalFoV, const Float &aspectRatio, const Float &nearClip, const Float &farClip, Float4x4 &targetMem )
|
||||||
{ 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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Float3 NormalProjection( const Float3 &vector, const Float3 &normalizedAxis )
|
||||||
|
{
|
||||||
|
return ::LinearAlgebra3D::NormalProjection( vector, normalizedAxis );
|
||||||
|
}
|
||||||
} }
|
} }
|
|
@ -114,6 +114,18 @@ namespace Oyster { namespace Math2D /// Oyster's native math library specialized
|
||||||
/// Sets and returns targetMem as a counterclockwise rotationMatrix
|
/// Sets and returns targetMem as a counterclockwise rotationMatrix
|
||||||
Float3x3 & RotationMatrix( const Float &radian, Float3x3 &targetMem = Float3x3() );
|
Float3x3 & RotationMatrix( const Float &radian, Float3x3 &targetMem = Float3x3() );
|
||||||
|
|
||||||
|
/// If rotation is assumed to be by all definitions a rotation matrix. Then this is a much faster inverse method.
|
||||||
|
Float2x2 & InverseRotationMatrix( const Float2x2 &rotation, Float2x2 &targetMem = Float2x2() );
|
||||||
|
|
||||||
|
/// If rotation is assumed to be by all definitions a rotation matrix. Then this is a much faster inverse method.
|
||||||
|
Float3x3 & InverseRotationMatrix( const Float3x3 &rotation, Float3x3 &targetMem = Float3x3() );
|
||||||
|
|
||||||
|
/// Sets and returns targetMem as an orientation Matrix composed by the rotation matrix and translation vector
|
||||||
|
Float3x3 & OrientationMatrix( const Float2x2 &rotation, const Float2 &translation, Float3x3 &targetMem = Float3x3() );
|
||||||
|
|
||||||
|
/// Sets and returns targetMem as an orientation Matrix composed by the rotation matrix and translation vector
|
||||||
|
Float3x3 & OrientationMatrix( const Float3x3 &rotation, const Float2 &translation, Float3x3 &targetMem = Float3x3() );
|
||||||
|
|
||||||
/// Sets and returns targetMem as an orientation Matrix with position as translation and radian rotation
|
/// Sets and returns targetMem as an orientation Matrix with position as translation and radian rotation
|
||||||
Float3x3 & OrientationMatrix( const Float2 &position, const Float &radian, Float3x3 &targetMem = Float3x3() );
|
Float3x3 & OrientationMatrix( const Float2 &position, const Float &radian, Float3x3 &targetMem = Float3x3() );
|
||||||
|
|
||||||
|
@ -126,6 +138,9 @@ namespace Oyster { namespace Math2D /// Oyster's native math library specialized
|
||||||
|
|
||||||
/// If orientationMatrix is assumed to be by all definitions a rigid orientation matrix aka rigid body matrix. Then this is a much faster inverse method.
|
/// If orientationMatrix is assumed to be by all definitions a rigid orientation matrix aka rigid body matrix. Then this is a much faster inverse method.
|
||||||
Float3x3 & InverseOrientationMatrix( const Float3x3 &orientationMatrix, Float3x3 &targetMem = Float3x3() );
|
Float3x3 & InverseOrientationMatrix( const Float3x3 &orientationMatrix, Float3x3 &targetMem = Float3x3() );
|
||||||
|
|
||||||
|
/// Returns targetmem after writing the rotation data from orientation, into it.
|
||||||
|
Float3x3 & ExtractRotationMatrix( const Float3x3 &orientation, Float3x3 &targetMem = Float3x3() );
|
||||||
} }
|
} }
|
||||||
|
|
||||||
namespace Oyster { namespace Math3D /// Oyster's native math library specialized for 3D
|
namespace Oyster { namespace Math3D /// Oyster's native math library specialized for 3D
|
||||||
|
@ -148,6 +163,18 @@ namespace Oyster { namespace Math3D /// Oyster's native math library specialized
|
||||||
/// Please make sure normalizedAxis is normalized.
|
/// Please make sure normalizedAxis is normalized.
|
||||||
Float4x4 & RotationMatrix( const Float &radian, const Float3 &normalizedAxis, Float4x4 &targetMem = Float4x4() );
|
Float4x4 & RotationMatrix( const Float &radian, const Float3 &normalizedAxis, Float4x4 &targetMem = Float4x4() );
|
||||||
|
|
||||||
|
/// If rotation is assumed to be by all definitions a rotation matrix. Then this is a much faster inverse method.
|
||||||
|
Float3x3 & InverseRotationMatrix( const Float3x3 &rotation, Float3x3 &targetMem = Float3x3() );
|
||||||
|
|
||||||
|
/// If rotation is assumed to be by all definitions a rotation matrix. Then this is a much faster inverse method.
|
||||||
|
Float4x4 & InverseRotationMatrix( const Float4x4 &rotation, Float4x4 &targetMem = Float4x4() );
|
||||||
|
|
||||||
|
/// Sets and returns targetMem as an orientation Matrix composed by the rotation matrix and translation vector
|
||||||
|
Float4x4 & OrientationMatrix( const Float3x3 &rotation, const Float3 &translation, Float4x4 &targetMem = Float4x4() );
|
||||||
|
|
||||||
|
/// Sets and returns targetMem as an orientation Matrix composed by the rotation matrix and translation vector
|
||||||
|
Float4x4 & OrientationMatrix( const Float4x4 &rotation, const Float3 &translation, Float4x4 &targetMem = Float4x4() );
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
* Sets and returns targetMem as an orientation Matrix
|
* Sets and returns targetMem as an orientation Matrix
|
||||||
* @param normalizedAxis: The normalized vector parallell with the rotationAxis.
|
* @param normalizedAxis: The normalized vector parallell with the rotationAxis.
|
||||||
|
@ -180,6 +207,12 @@ namespace Oyster { namespace Math3D /// Oyster's native math library specialized
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
Float4x4 & OrientationMatrix( const Float3 &sumDeltaAngularAxis, const Float3 &sumTranslation, const Float3 ¢erOfMass, Float4x4 &targetMem = Float4x4() );
|
Float4x4 & OrientationMatrix( const Float3 &sumDeltaAngularAxis, const Float3 &sumTranslation, const Float3 ¢erOfMass, Float4x4 &targetMem = Float4x4() );
|
||||||
|
|
||||||
|
//! @todo TODO: Add documentation and not tested
|
||||||
|
Float4x4 & OrientationMatrix_LookAtDirection( const Float3 &normalizedDirection, const Float3 &normalizedUpVector, const Float3 &worldPos, Float4x4 &targetMem = Float4x4() );
|
||||||
|
|
||||||
|
//! @todo TODO: Add documentation and not tested
|
||||||
|
Float4x4 & OrientationMatrix_LookAtPos( const Float3 &worldLookAt, const Float3 &normalizedUpVector, const Float3 &worldPos, Float4x4 &targetMem = Float4x4() );
|
||||||
|
|
||||||
/// If orientationMatrix is assumed to be by all definitions a rigid orientation matrix aka rigid body matrix. Then this is a much faster inverse method.
|
/// If orientationMatrix is assumed to be by all definitions a rigid orientation matrix aka rigid body matrix. Then this is a much faster inverse method.
|
||||||
Float4x4 & InverseOrientationMatrix( const Float4x4 &orientationMatrix, Float4x4 &targetMem = Float4x4() );
|
Float4x4 & InverseOrientationMatrix( const Float4x4 &orientationMatrix, Float4x4 &targetMem = Float4x4() );
|
||||||
|
|
||||||
|
@ -187,6 +220,9 @@ namespace Oyster { namespace Math3D /// Oyster's native math library specialized
|
||||||
// O1 = T1 * T0 * R1 * R0
|
// O1 = T1 * T0 * R1 * R0
|
||||||
Float4x4 & UpdateOrientationMatrix( const Float3 &deltaPosition, const Float4x4 &deltaRotationMatrix, Float4x4 &orientationMatrix );
|
Float4x4 & UpdateOrientationMatrix( const Float3 &deltaPosition, const Float4x4 &deltaRotationMatrix, Float4x4 &orientationMatrix );
|
||||||
|
|
||||||
|
/// Returns targetmem after writing the rotation data from orientation, into it.
|
||||||
|
Float4x4 & ExtractRotationMatrix( const Float4x4 &orientation, Float4x4 &targetMem = Float4x4() );
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
* Creates an orthographic projection matrix designed for DirectX enviroment.
|
* Creates an orthographic projection matrix designed for DirectX enviroment.
|
||||||
* @param width; of the projection sample volume.
|
* @param width; of the projection sample volume.
|
||||||
|
@ -214,14 +250,21 @@ namespace Oyster { namespace Math3D /// Oyster's native math library specialized
|
||||||
/// returns the component vector of vector that is parallell with axis
|
/// returns the component vector of vector that is parallell with axis
|
||||||
Float3 VectorProjection( const Float3 &vector, const Float3 &axis );
|
Float3 VectorProjection( const Float3 &vector, const Float3 &axis );
|
||||||
|
|
||||||
|
/// returns the component vector of vector that is parallell with axis. Faster than VectorProjection.
|
||||||
|
Float3 NormalProjection( const Float3 &vector, const Float3 &normalizedAxis );
|
||||||
|
|
||||||
/// Helper inline function that sets and then returns targetMem = projection * view
|
/// Helper inline function that sets and then returns targetMem = projection * view
|
||||||
inline Float4x4 & ViewProjectionMatrix( const Float4x4 &view, const Float4x4 &projection, Float4x4 &targetMem = Float4x4() )
|
inline Float4x4 & ViewProjectionMatrix( const Float4x4 &view, const Float4x4 &projection, Float4x4 &targetMem = Float4x4() )
|
||||||
{ return targetMem = projection * view; }
|
{ return targetMem = projection * view; }
|
||||||
|
|
||||||
/// Helper inline function that sets and then returns targetMem = transformer * transformee
|
/** Helper inline function that sets and then returns targetMem = transformer * transformee */
|
||||||
inline Float4x4 & TransformMatrix( const Float4x4 &transformer, const Float4x4 &transformee, Float4x4 &targetMem = Float4x4() )
|
inline Float4x4 & TransformMatrix( const Float4x4 &transformer, const Float4x4 &transformee, Float4x4 &targetMem )
|
||||||
{ return targetMem = transformer * transformee; }
|
{ return targetMem = transformer * transformee; }
|
||||||
|
|
||||||
|
/** Helper inline function that sets and then returns transformer * transformee */
|
||||||
|
inline Float4x4 TransformMatrix( const Float4x4 &transformer, const Float4x4 &transformee )
|
||||||
|
{ return transformer * transformee; }
|
||||||
|
|
||||||
/// Helper inline function that sets and then returns targetMem = transformer * transformee
|
/// Helper inline function that sets and then returns targetMem = transformer * transformee
|
||||||
inline Float4 & TransformVector( const Float4x4 &transformer, const Float4 &transformee, Float4 &targetMem = Float4() )
|
inline Float4 & TransformVector( const Float4x4 &transformer, const Float4 &transformee, Float4 &targetMem = Float4() )
|
||||||
{ return targetMem = transformer * transformee; }
|
{ return targetMem = transformer * transformee; }
|
||||||
|
|
|
@ -8,19 +8,28 @@
|
||||||
using namespace ::Oyster::Collision3D;
|
using namespace ::Oyster::Collision3D;
|
||||||
using namespace ::Oyster::Math3D;
|
using namespace ::Oyster::Math3D;
|
||||||
|
|
||||||
Box::Box( ) : ICollideable(Type_box), orientation(Float4x4::identity), boundingOffset() {}
|
Box::Box( )
|
||||||
Box::Box( const Float4x4 &o, const Float3 &s ) : ICollideable(Type_box), orientation(o), boundingOffset(s*0.5) {}
|
: ICollideable(Type_box), rotation(Float4x4::identity), center(0.0f), boundingOffset(0.5f)
|
||||||
|
{}
|
||||||
|
|
||||||
|
Box::Box( const Float4x4 &r, const Float3 &p, const Float3 &s )
|
||||||
|
: ICollideable(Type_box), rotation(r), center(p), boundingOffset(s*0.5)
|
||||||
|
{}
|
||||||
|
|
||||||
Box::~Box( ) {}
|
Box::~Box( ) {}
|
||||||
|
|
||||||
Box & Box::operator = ( const Box &box )
|
Box & Box::operator = ( const Box &box )
|
||||||
{
|
{
|
||||||
this->orientation = box.orientation;
|
this->rotation = box.rotation;
|
||||||
|
this->center = box.center;
|
||||||
this->boundingOffset = box.boundingOffset;
|
this->boundingOffset = box.boundingOffset;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
::Utility::DynamicMemory::UniquePointer<ICollideable> Box::Clone( ) const
|
::Utility::DynamicMemory::UniquePointer<ICollideable> Box::Clone( ) const
|
||||||
{ return ::Utility::DynamicMemory::UniquePointer<ICollideable>( new Box(*this) ); }
|
{
|
||||||
|
return ::Utility::DynamicMemory::UniquePointer<ICollideable>( new Box(*this) );
|
||||||
|
}
|
||||||
|
|
||||||
bool Box::Intersects( const ICollideable *target ) const
|
bool Box::Intersects( const ICollideable *target ) const
|
||||||
{
|
{
|
||||||
|
@ -31,10 +40,10 @@ bool Box::Intersects( const ICollideable *target ) const
|
||||||
case Type_ray: return Utility::Intersect( *this, *(Ray*)target, ((Ray*)target)->collisionDistance );
|
case Type_ray: return Utility::Intersect( *this, *(Ray*)target, ((Ray*)target)->collisionDistance );
|
||||||
case Type_sphere: return Utility::Intersect( *this, *(Sphere*)target );
|
case Type_sphere: return Utility::Intersect( *this, *(Sphere*)target );
|
||||||
case Type_plane: return Utility::Intersect( *this, *(Plane*)target );
|
case Type_plane: return Utility::Intersect( *this, *(Plane*)target );
|
||||||
case Type_triangle: return false; // TODO: :
|
// case Type_triangle: return false; // TODO: :
|
||||||
case Type_box_axis_aligned: return Utility::Intersect( *this, *(BoxAxisAligned*)target );
|
case Type_box_axis_aligned: return Utility::Intersect( *this, *(BoxAxisAligned*)target );
|
||||||
case Type_box: return Utility::Intersect( *this, *(Box*)target );
|
case Type_box: return Utility::Intersect( *this, *(Box*)target );
|
||||||
case Type_frustrum: return false; // TODO: :
|
// case Type_frustrum: return false; // TODO: :
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,11 +53,11 @@ bool Box::Contains( const ICollideable *target ) const
|
||||||
switch( target->type )
|
switch( target->type )
|
||||||
{
|
{
|
||||||
case Type_point: return Utility::Intersect( *this, *(Point*)target );
|
case Type_point: return Utility::Intersect( *this, *(Point*)target );
|
||||||
case Type_sphere: return false; // TODO:
|
// case Type_sphere: return false; // TODO:
|
||||||
case Type_triangle: return false; // TODO:
|
// case Type_triangle: return false; // TODO:
|
||||||
case Type_box_axis_aligned: return false; // TODO:
|
// case Type_box_axis_aligned: return false; // TODO:
|
||||||
case Type_box: return false; // TODO:
|
// case Type_box: return false; // TODO:
|
||||||
case Type_frustrum: return false; // TODO:
|
// case Type_frustrum: return false; // TODO:
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,19 +16,18 @@ namespace Oyster { namespace Collision3D
|
||||||
public:
|
public:
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
struct{ ::Oyster::Math::Float4x4 orientation; ::Oyster::Math::Float3 boundingOffset; };
|
struct{ ::Oyster::Math::Float4x4 rotation; ::Oyster::Math::Float3 center, boundingOffset; };
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
::Oyster::Math::Float3 xAxis; ::Oyster::Math::Float paddingA;
|
::Oyster::Math::Float3 xAxis; ::Oyster::Math::Float paddingA;
|
||||||
::Oyster::Math::Float3 yAxis; ::Oyster::Math::Float paddingB;
|
::Oyster::Math::Float3 yAxis; ::Oyster::Math::Float paddingB;
|
||||||
::Oyster::Math::Float3 zAxis; ::Oyster::Math::Float paddingC;
|
::Oyster::Math::Float3 zAxis; ::Oyster::Math::Float paddingC;
|
||||||
::Oyster::Math::Float3 center;
|
|
||||||
};
|
};
|
||||||
char byte[sizeof(::Oyster::Math::Float4x4) + sizeof(::Oyster::Math::Float3)];
|
char byte[sizeof(::Oyster::Math::Float4x4) + 2*sizeof(::Oyster::Math::Float3)];
|
||||||
};
|
};
|
||||||
|
|
||||||
Box( );
|
Box( );
|
||||||
Box( const ::Oyster::Math::Float4x4 &orientation, const ::Oyster::Math::Float3 &size );
|
Box( const ::Oyster::Math::Float4x4 &rotation, const ::Oyster::Math::Float3 &worldPos, const ::Oyster::Math::Float3 &size );
|
||||||
virtual ~Box( );
|
virtual ~Box( );
|
||||||
|
|
||||||
Box & operator = ( const Box &box );
|
Box & operator = ( const Box &box );
|
||||||
|
|
|
@ -33,10 +33,10 @@ bool BoxAxisAligned::Intersects( const ICollideable *target ) const
|
||||||
case Type_ray: return Utility::Intersect( *this, *(Ray*)target, ((Ray*)target)->collisionDistance );
|
case Type_ray: return Utility::Intersect( *this, *(Ray*)target, ((Ray*)target)->collisionDistance );
|
||||||
case Type_sphere: return Utility::Intersect( *this, *(Sphere*)target );
|
case Type_sphere: return Utility::Intersect( *this, *(Sphere*)target );
|
||||||
case Type_plane: return Utility::Intersect( *this, *(Plane*)target );
|
case Type_plane: return Utility::Intersect( *this, *(Plane*)target );
|
||||||
case Type_triangle: return false; // TODO:
|
// case Type_triangle: return false; // TODO:
|
||||||
case Type_box_axis_aligned: return Utility::Intersect( *this, *(BoxAxisAligned*)target );
|
case Type_box_axis_aligned: return Utility::Intersect( *this, *(BoxAxisAligned*)target );
|
||||||
case Type_box: return false; // TODO:
|
// case Type_box: return false; // TODO:
|
||||||
case Type_frustrum: return false; // TODO:
|
// case Type_frustrum: return false; // TODO:
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,12 +45,12 @@ bool BoxAxisAligned::Contains( const ICollideable *target ) const
|
||||||
{
|
{
|
||||||
switch( target->type )
|
switch( target->type )
|
||||||
{
|
{
|
||||||
case Type_point: return false; // TODO:
|
// case Type_point: return false; // TODO:
|
||||||
case Type_sphere: return false; // TODO:
|
// case Type_sphere: return false; // TODO:
|
||||||
case Type_triangle: return false; // TODO:
|
// case Type_triangle: return false; // TODO:
|
||||||
case Type_box_axis_aligned: return false; // TODO:
|
// case Type_box_axis_aligned: return false; // TODO:
|
||||||
case Type_box: return false; // TODO:
|
// case Type_box: return false; // TODO:
|
||||||
case Type_frustrum: return false; // TODO:
|
// case Type_frustrum: return false; // TODO:
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -200,11 +200,11 @@ bool Frustrum::Intersects( const ICollideable *target ) const
|
||||||
case Type_ray: return Utility::Intersect( *this, *(Ray*)target, ((Ray*)target)->collisionDistance );
|
case Type_ray: return Utility::Intersect( *this, *(Ray*)target, ((Ray*)target)->collisionDistance );
|
||||||
case Type_sphere: return Utility::Intersect( *this, *(Sphere*)target );
|
case Type_sphere: return Utility::Intersect( *this, *(Sphere*)target );
|
||||||
case Type_plane: return Utility::Intersect( *this, *(Plane*)target );
|
case Type_plane: return Utility::Intersect( *this, *(Plane*)target );
|
||||||
case Type_triangle: return false; // TODO:
|
// case Type_triangle: return false; // TODO:
|
||||||
case Type_box_axis_aligned: return Utility::Intersect( *this, *(BoxAxisAligned*)target );
|
case Type_box_axis_aligned: return Utility::Intersect( *this, *(BoxAxisAligned*)target );
|
||||||
case Type_box: return Utility::Intersect( *this, *(Box*)target );
|
case Type_box: return Utility::Intersect( *this, *(Box*)target );
|
||||||
case Type_frustrum: return Utility::Intersect( *this, *(Frustrum*)target );
|
case Type_frustrum: return Utility::Intersect( *this, *(Frustrum*)target );
|
||||||
case Type_line: return false; // TODO:
|
// case Type_line: return false; // TODO:
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,14 +214,14 @@ bool Frustrum::Contains( const ICollideable *target ) const
|
||||||
switch( target->type )
|
switch( target->type )
|
||||||
{
|
{
|
||||||
case Type_point: return Utility::Intersect( *this, *(Point*)target );
|
case Type_point: return Utility::Intersect( *this, *(Point*)target );
|
||||||
case Type_ray: return false; // TODO:
|
// case Type_ray: return false; // TODO:
|
||||||
case Type_sphere: return false; // TODO:
|
// case Type_sphere: return false; // TODO:
|
||||||
case Type_plane: return false; // TODO:
|
// case Type_plane: return false; // TODO:
|
||||||
case Type_triangle: return false; // TODO:
|
// case Type_triangle: return false; // TODO:
|
||||||
case Type_box_axis_aligned: return false; // TODO:
|
// case Type_box_axis_aligned: return false; // TODO:
|
||||||
case Type_box: return false; // TODO:
|
// case Type_box: return false; // TODO:
|
||||||
case Type_frustrum: return false; // TODO:
|
// case Type_frustrum: return false; // TODO:
|
||||||
case Type_line: return false; // TODO:
|
// case Type_line: return false; // TODO:
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -21,7 +21,7 @@ namespace Oyster { namespace Collision3D /// Contains a collection of 3D shapes
|
||||||
Type_ray,
|
Type_ray,
|
||||||
Type_sphere,
|
Type_sphere,
|
||||||
Type_plane,
|
Type_plane,
|
||||||
Type_triangle,
|
// Type_triangle,
|
||||||
Type_box_axis_aligned,
|
Type_box_axis_aligned,
|
||||||
Type_box,
|
Type_box,
|
||||||
Type_frustrum,
|
Type_frustrum,
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
using namespace Oyster::Math3D;
|
using namespace ::Oyster::Math3D;
|
||||||
|
using namespace ::Utility::Value;
|
||||||
|
|
||||||
namespace Oyster { namespace Collision3D { namespace Utility
|
namespace Oyster { namespace Collision3D { namespace Utility
|
||||||
{
|
{
|
||||||
|
@ -19,13 +20,13 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
||||||
// Float calculations can suffer roundingerrors. Which is where epsilon = 1e-20 comes into the picture
|
// Float calculations can suffer roundingerrors. Which is where epsilon = 1e-20 comes into the picture
|
||||||
inline bool EqualsZero( const Float &value )
|
inline bool EqualsZero( const Float &value )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
return ::Utility::Value::Abs( value ) < epsilon;
|
return Abs( value ) < epsilon;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Float calculations can suffer roundingerrors. Which is where epsilon = 1e-20 comes into the picture
|
// Float calculations can suffer roundingerrors. Which is where epsilon = 1e-20 comes into the picture
|
||||||
inline bool NotEqualsZero( const Float &value )
|
inline bool NotEqualsZero( const Float &value )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
return ::Utility::Value::Abs( value ) > epsilon;
|
return Abs( value ) > epsilon;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true if miss/reject
|
// returns true if miss/reject
|
||||||
|
@ -39,8 +40,8 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
||||||
t2 = e - boundingOffset;
|
t2 = e - boundingOffset;
|
||||||
t1 /= f; t2 /= f;
|
t1 /= f; t2 /= f;
|
||||||
if( t1 > t2 ) ::Utility::Element::Swap( t1, t2 );
|
if( t1 > t2 ) ::Utility::Element::Swap( t1, t2 );
|
||||||
tMin = ::Utility::Value::Max( tMin, t1 );
|
tMin = Max( tMin, t1 );
|
||||||
tMax = ::Utility::Value::Min( tMax, t2 );
|
tMax = Min( tMax, t2 );
|
||||||
if( tMin > tMax ) return true;
|
if( tMin > tMax ) return true;
|
||||||
if( tMax < 0.0f ) return true;
|
if( tMax < 0.0f ) return true;
|
||||||
}
|
}
|
||||||
|
@ -65,101 +66,140 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
Float3 c = (box.maxVertex + box.minVertex) * 0.5f, // box.Center
|
Float3 c = (box.maxVertex + box.minVertex) * 0.5f, // box.Center
|
||||||
h = (box.maxVertex - box.minVertex) * 0.5f; // box.halfSize
|
h = (box.maxVertex - box.minVertex) * 0.5f; // box.halfSize
|
||||||
boxExtend = h.x * ::Utility::Value::Abs(plane.normal.x); // Box max extending towards plane
|
boxExtend = h.x * Abs(plane.normal.x); // Box max extending towards plane
|
||||||
boxExtend += h.y * ::Utility::Value::Abs(plane.normal.y);
|
boxExtend += h.y * Abs(plane.normal.y);
|
||||||
boxExtend += h.z * ::Utility::Value::Abs(plane.normal.z);
|
boxExtend += h.z * Abs(plane.normal.z);
|
||||||
centerDistance = c.Dot(plane.normal) + plane.phasing; // distance between box center and plane
|
centerDistance = c.Dot(plane.normal) + plane.phasing; // distance between box center and plane
|
||||||
}
|
}
|
||||||
|
|
||||||
void Compare( Float &boxExtend, Float ¢erDistance, const Plane &plane, const Box &box )
|
void Compare( Float &boxExtend, Float ¢erDistance, const Plane &plane, const Box &box )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
boxExtend = box.boundingOffset.x * ::Utility::Value::Abs(plane.normal.Dot(box.orientation.v[0].xyz)); // Box max extending towards plane
|
boxExtend = box.boundingOffset.x * Abs(plane.normal.Dot(box.xAxis)); // Box max extending towards plane
|
||||||
boxExtend += box.boundingOffset.y * ::Utility::Value::Abs(plane.normal.Dot(box.orientation.v[1].xyz));
|
boxExtend += box.boundingOffset.y * Abs(plane.normal.Dot(box.yAxis));
|
||||||
boxExtend += box.boundingOffset.z * ::Utility::Value::Abs(plane.normal.Dot(box.orientation.v[2].xyz));
|
boxExtend += box.boundingOffset.z * Abs(plane.normal.Dot(box.zAxis));
|
||||||
|
|
||||||
centerDistance = box.orientation.v[3].xyz.Dot(plane.normal) + plane.phasing; // distance between box center and plane
|
centerDistance = box.center.Dot(plane.normal) + plane.phasing; // distance between box center and plane
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FifteenAxisVsAlignedAxisOverlappingChecks( const Float3 &boundingOffsetA, const Float3 &boundingOffsetB, const Float4x4 &orientationB )
|
bool SeperatingAxisTest_AxisAlignedVsTransformedBox( const Float3 &boundingOffsetA, const Float3 &boundingOffsetB, const Float4x4 &rotationB, const Float3 &worldOffset )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
Float4x4 absOrientationB;
|
|
||||||
{
|
/*****************************************************************
|
||||||
Float4x4 tO = orientationB.GetTranspose();
|
* Uses the Seperating Axis Theorem
|
||||||
absOrientationB.v[0] = ::Utility::Value::Abs(tO.v[0]);
|
* if( |t dot s| > hA dot |s * RA| + hB dot |s * RB| ) then not intersecting
|
||||||
if( absOrientationB.v[0].w > boundingOffsetA.x + boundingOffsetB.Dot(absOrientationB.v[0].xyz) ) return false;
|
* |t dot s| > hA dot |s| + hB dot |s * RB| .. as RA = I
|
||||||
absOrientationB.v[1] = ::Utility::Value::Abs(tO.v[1]);
|
*
|
||||||
if( absOrientationB.v[1].w > boundingOffsetA.y + boundingOffsetB.Dot(absOrientationB.v[1].xyz) ) return false;
|
* t: objectB's offset from objectA [worldOffset]
|
||||||
absOrientationB.v[2] = ::Utility::Value::Abs(tO.v[2]);
|
* s: current comparison axis
|
||||||
if( absOrientationB.v[2].w > boundingOffsetA.z + boundingOffsetB.Dot(absOrientationB.v[2].xyz) ) return false;
|
* hA: boundingReach vector of objectA. Only absolute values is assumed. [boundingOffsetA]
|
||||||
|
* hB: boundingReach vector of objectB. Only absolute values is assumed. [boundingOffsetB]
|
||||||
|
* RA: rotation matrix of objectA. Is identity matrix here, thus omitted.
|
||||||
|
* RB: rotation matrix of objectB. Is transformed into objectA's view at this point. [rotationB]
|
||||||
|
*
|
||||||
|
* Note: s * RB = (RB^T * s)^T = (RB^-1 * s)^T .... vector == vector^T
|
||||||
|
*****************************************************************/
|
||||||
|
|
||||||
|
Float4x4 absRotationB = Abs(rotationB);
|
||||||
|
Float3 absWorldOffset = Abs(worldOffset); // |t|: [absWorldOffset]
|
||||||
|
|
||||||
|
// s = { 1, 0, 0 } [ RA.v[0] ]
|
||||||
|
if( absWorldOffset.x > boundingOffsetA.x + boundingOffsetB.Dot(Float3(absRotationB.v[0].x, absRotationB.v[1].x, absRotationB.v[2].x)) )
|
||||||
|
{ // |t dot s| > hA dot |s| + hB dot |s * RB| -->> t.x > hA.x + hB dot |{RB.v[0].x, RB.v[1].x, RB.v[2].x}|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
absOrientationB.Transpose();
|
// s = { 0, 1, 0 } [ RA.v[1] ]
|
||||||
if( ::Utility::Value::Abs(orientationB.v[3].Dot(orientationB.v[0])) > boundingOffsetB.x + boundingOffsetA.Dot(absOrientationB.v[0].xyz) ) return false;
|
if( absWorldOffset.y > boundingOffsetA.y + boundingOffsetB.Dot(Float3(absRotationB.v[0].y, absRotationB.v[1].y, absRotationB.v[2].y)) )
|
||||||
if( ::Utility::Value::Abs(orientationB.v[3].Dot(orientationB.v[1])) > boundingOffsetB.x + boundingOffsetA.Dot(absOrientationB.v[1].xyz) ) return false;
|
{ // t.y > hA.y + hB dot |{RB.v[0].y, RB.v[1].y, RB.v[2].y}|
|
||||||
if( ::Utility::Value::Abs(orientationB.v[3].Dot(orientationB.v[2])) > boundingOffsetB.x + boundingOffsetA.Dot(absOrientationB.v[2].xyz) ) return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// ( 1,0,0 ) x orientationB.v[0].xyz:
|
// s = { 0, 0, 1 } [ RA.v[2] ]
|
||||||
Float d = boundingOffsetA.y * absOrientationB.v[0].z;
|
if( absWorldOffset.z > boundingOffsetA.z + boundingOffsetB.Dot(Float3(absRotationB.v[0].z, absRotationB.v[1].z, absRotationB.v[2].z)) )
|
||||||
d += boundingOffsetA.z * absOrientationB.v[0].y;
|
{ // t.z > hA.z + hB dot |{RB.v[0].z, RB.v[1].z, RB.v[2].z}|
|
||||||
d += boundingOffsetB.y * absOrientationB.v[2].x;
|
return false;
|
||||||
d += boundingOffsetB.z * absOrientationB.v[1].x;
|
}
|
||||||
if( ::Utility::Value::Abs(orientationB.v[3].z*orientationB.v[0].y - orientationB.v[3].y*orientationB.v[0].z) > d ) return false;
|
|
||||||
|
|
||||||
// ( 1,0,0 ) x orientationB.v[1].xyz:
|
// s = RB.v[0].xyz
|
||||||
d = boundingOffsetA.y * absOrientationB.v[1].z;
|
if( Abs(worldOffset.Dot(rotationB.v[0].xyz)) > boundingOffsetA.Dot(absRotationB.v[0].xyz) + boundingOffsetB.x )
|
||||||
d += boundingOffsetA.z * absOrientationB.v[1].y;
|
{ // |t dot s| > hA dot |s| + hB dot |s * RB| -->> |t dot s| > hA dot |s| + hB dot |{1, 0, 0}| -->> |t dot s| > hA dot |s| + hB.x
|
||||||
d += boundingOffsetB.x * absOrientationB.v[2].x;
|
return false;
|
||||||
d += boundingOffsetB.z * absOrientationB.v[0].x;
|
}
|
||||||
if( ::Utility::Value::Abs(orientationB.v[3].z*orientationB.v[1].y - orientationB.v[3].y*orientationB.v[1].z) > d ) return false;
|
|
||||||
|
|
||||||
// ( 1,0,0 ) x orientationB.v[2].xyz:
|
// s = RB.v[1].xyz
|
||||||
d = boundingOffsetA.y * absOrientationB.v[2].z;
|
if( Abs(worldOffset.Dot(rotationB.v[1].xyz)) > boundingOffsetA.Dot(absRotationB.v[1].xyz) + boundingOffsetB.y )
|
||||||
d += boundingOffsetA.z * absOrientationB.v[2].y;
|
{ // |t dot s| > hA dot |s| + hB.y
|
||||||
d += boundingOffsetB.x * absOrientationB.v[1].x;
|
return false;
|
||||||
d += boundingOffsetB.y * absOrientationB.v[0].x;
|
}
|
||||||
if( ::Utility::Value::Abs(orientationB.v[3].z*orientationB.v[2].y - orientationB.v[3].y*orientationB.v[2].z) > d ) return false;
|
|
||||||
|
|
||||||
// ( 0,1,0 ) x orientationB.v[0].xyz:
|
// s = RB.v[2].xyz
|
||||||
d = boundingOffsetA.x * absOrientationB.v[0].z;
|
if( Abs(worldOffset.Dot(rotationB.v[2].xyz)) > boundingOffsetA.Dot(absRotationB.v[2].xyz) + boundingOffsetB.z )
|
||||||
d += boundingOffsetA.z * absOrientationB.v[0].x;
|
{ // |t dot s| > hA dot |s| + hB.z
|
||||||
d += boundingOffsetB.y * absOrientationB.v[2].y;
|
return false;
|
||||||
d += boundingOffsetB.z * absOrientationB.v[1].y;
|
}
|
||||||
if( ::Utility::Value::Abs(orientationB.v[3].x*orientationB.v[0].z - orientationB.v[3].z*orientationB.v[0].x) > d ) return false;
|
|
||||||
|
|
||||||
// ( 0,1,0 ) x orientationB.v[1].xyz:
|
// s = ( 1,0,0 ) x rotationB.v[0].xyz:
|
||||||
d = boundingOffsetA.x * absOrientationB.v[1].z;
|
Float d = boundingOffsetA.y * absRotationB.v[0].z;
|
||||||
d += boundingOffsetA.z * absOrientationB.v[1].x;
|
d += boundingOffsetA.z * absRotationB.v[0].y;
|
||||||
d += boundingOffsetB.x * absOrientationB.v[2].y;
|
d += boundingOffsetB.y * absRotationB.v[2].x;
|
||||||
d += boundingOffsetB.z * absOrientationB.v[0].y;
|
d += boundingOffsetB.z * absRotationB.v[1].x;
|
||||||
if( ::Utility::Value::Abs(orientationB.v[3].x*orientationB.v[1].z - orientationB.v[3].z*orientationB.v[1].x) > d ) return false;
|
if( Abs(worldOffset.z*rotationB.v[0].y - worldOffset.y*rotationB.v[0].z) > d ) return false;
|
||||||
|
|
||||||
// ( 0,1,0 ) x orientationB.v[2].xyz:
|
// s = ( 1,0,0 ) x rotationB.v[1].xyz:
|
||||||
d = boundingOffsetA.x * absOrientationB.v[2].z;
|
d = boundingOffsetA.y * absRotationB.v[1].z;
|
||||||
d += boundingOffsetA.z * absOrientationB.v[2].x;
|
d += boundingOffsetA.z * absRotationB.v[1].y;
|
||||||
d += boundingOffsetB.x * absOrientationB.v[1].y;
|
d += boundingOffsetB.x * absRotationB.v[2].x;
|
||||||
d += boundingOffsetB.y * absOrientationB.v[0].y;
|
d += boundingOffsetB.z * absRotationB.v[0].x;
|
||||||
if( ::Utility::Value::Abs(orientationB.v[3].x*orientationB.v[2].z - orientationB.v[3].z*orientationB.v[2].x) > d ) return false;
|
if( Abs(worldOffset.z*rotationB.v[1].y - worldOffset.y*rotationB.v[1].z) > d ) return false;
|
||||||
|
|
||||||
// ( 0,0,1 ) x orientationB.v[0].xyz:
|
// s = ( 1,0,0 ) x rotationB.v[2].xyz:
|
||||||
d = boundingOffsetA.x * absOrientationB.v[0].y;
|
d = boundingOffsetA.y * absRotationB.v[2].z;
|
||||||
d += boundingOffsetA.y * absOrientationB.v[0].x;
|
d += boundingOffsetA.z * absRotationB.v[2].y;
|
||||||
d += boundingOffsetB.y * absOrientationB.v[2].z;
|
d += boundingOffsetB.x * absRotationB.v[1].x;
|
||||||
d += boundingOffsetB.z * absOrientationB.v[1].z;
|
d += boundingOffsetB.y * absRotationB.v[0].x;
|
||||||
if( ::Utility::Value::Abs(orientationB.v[3].y*orientationB.v[0].x - orientationB.v[3].x*orientationB.v[0].y) > d ) return false;
|
if( Abs(worldOffset.z*rotationB.v[2].y - worldOffset.y*rotationB.v[2].z) > d ) return false;
|
||||||
|
|
||||||
// ( 0,0,1 ) x orientationB.v[1].xyz:
|
// s = ( 0,1,0 ) x rotationB.v[0].xyz:
|
||||||
d = boundingOffsetA.x * absOrientationB.v[1].y;
|
d = boundingOffsetA.x * absRotationB.v[0].z;
|
||||||
d += boundingOffsetA.y * absOrientationB.v[1].x;
|
d += boundingOffsetA.z * absRotationB.v[0].x;
|
||||||
d += boundingOffsetB.x * absOrientationB.v[2].z;
|
d += boundingOffsetB.y * absRotationB.v[2].y;
|
||||||
d += boundingOffsetB.z * absOrientationB.v[0].z;
|
d += boundingOffsetB.z * absRotationB.v[1].y;
|
||||||
if( ::Utility::Value::Abs(orientationB.v[3].y*orientationB.v[1].x - orientationB.v[3].x*orientationB.v[1].y) > d ) return false;
|
if( Abs(worldOffset.x*rotationB.v[0].z - worldOffset.z*rotationB.v[0].x) > d ) return false;
|
||||||
|
|
||||||
// ( 0,0,1 ) x orientationB.v[2].xyz:
|
// s = ( 0,1,0 ) x rotationB.v[1].xyz:
|
||||||
d = boundingOffsetA.x * absOrientationB.v[2].y;
|
d = boundingOffsetA.x * absRotationB.v[1].z;
|
||||||
d += boundingOffsetA.y * absOrientationB.v[2].x;
|
d += boundingOffsetA.z * absRotationB.v[1].x;
|
||||||
d += boundingOffsetB.x * absOrientationB.v[1].z;
|
d += boundingOffsetB.x * absRotationB.v[2].y;
|
||||||
d += boundingOffsetB.y * absOrientationB.v[0].z;
|
d += boundingOffsetB.z * absRotationB.v[0].y;
|
||||||
if( ::Utility::Value::Abs(orientationB.v[3].y*orientationB.v[2].x - orientationB.v[3].x*orientationB.v[2].y) > d ) return false;
|
if( Abs(worldOffset.x*rotationB.v[1].z - worldOffset.z*rotationB.v[1].x) > d ) return false;
|
||||||
|
|
||||||
|
// s = ( 0,1,0 ) x rotationB.v[2].xyz:
|
||||||
|
d = boundingOffsetA.x * absRotationB.v[2].z;
|
||||||
|
d += boundingOffsetA.z * absRotationB.v[2].x;
|
||||||
|
d += boundingOffsetB.x * absRotationB.v[1].y;
|
||||||
|
d += boundingOffsetB.y * absRotationB.v[0].y;
|
||||||
|
if( Abs(worldOffset.x*rotationB.v[2].z - worldOffset.z*rotationB.v[2].x) > d ) return false;
|
||||||
|
|
||||||
|
// s = ( 0,0,1 ) x rotationB.v[0].xyz:
|
||||||
|
d = boundingOffsetA.x * absRotationB.v[0].y;
|
||||||
|
d += boundingOffsetA.y * absRotationB.v[0].x;
|
||||||
|
d += boundingOffsetB.y * absRotationB.v[2].z;
|
||||||
|
d += boundingOffsetB.z * absRotationB.v[1].z;
|
||||||
|
if( Abs(worldOffset.y*rotationB.v[0].x - worldOffset.x*rotationB.v[0].y) > d ) return false;
|
||||||
|
|
||||||
|
// s = ( 0,0,1 ) x rotationB.v[1].xyz:
|
||||||
|
d = boundingOffsetA.x * absRotationB.v[1].y;
|
||||||
|
d += boundingOffsetA.y * absRotationB.v[1].x;
|
||||||
|
d += boundingOffsetB.x * absRotationB.v[2].z;
|
||||||
|
d += boundingOffsetB.z * absRotationB.v[0].z;
|
||||||
|
if( Abs(worldOffset.y*rotationB.v[1].x - worldOffset.x*rotationB.v[1].y) > d ) return false;
|
||||||
|
|
||||||
|
// s = ( 0,0,1 ) x rotationB.v[2].xyz:
|
||||||
|
d = boundingOffsetA.x * absRotationB.v[2].y;
|
||||||
|
d += boundingOffsetA.y * absRotationB.v[2].x;
|
||||||
|
d += boundingOffsetB.x * absRotationB.v[1].z;
|
||||||
|
d += boundingOffsetB.y * absRotationB.v[0].z;
|
||||||
|
if( Abs(worldOffset.y*rotationB.v[2].x - worldOffset.x*rotationB.v[2].y) > d ) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -353,8 +393,8 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
||||||
|
|
||||||
bool Intersect( const BoxAxisAligned &box, const Sphere &sphere )
|
bool Intersect( const BoxAxisAligned &box, const Sphere &sphere )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
Float3 e = ::Utility::Value::Max( box.minVertex - sphere.center, Float3::null );
|
Float3 e = Max( box.minVertex - sphere.center, Float3::null );
|
||||||
e += ::Utility::Value::Max( sphere.center - box.maxVertex, Float3::null );
|
e += Max( sphere.center - box.maxVertex, Float3::null );
|
||||||
|
|
||||||
if( e.Dot(e) > (sphere.radius * sphere.radius) ) return false;
|
if( e.Dot(e) > (sphere.radius * sphere.radius) ) return false;
|
||||||
return true;
|
return true;
|
||||||
|
@ -385,17 +425,17 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
||||||
|
|
||||||
bool Intersect( const Box &box, const Point &point )
|
bool Intersect( const Box &box, const Point &point )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
Float3 dPos = point.center - box.orientation.v[3].xyz;
|
Float3 dPos = point.center - box.center;
|
||||||
|
|
||||||
Float coordinate = dPos.Dot( box.orientation.v[0].xyz );
|
Float coordinate = dPos.Dot( box.xAxis );
|
||||||
if( coordinate > box.boundingOffset.x ) return false;
|
if( coordinate > box.boundingOffset.x ) return false;
|
||||||
if( coordinate < -box.boundingOffset.x ) return false;
|
if( coordinate < -box.boundingOffset.x ) return false;
|
||||||
|
|
||||||
coordinate = dPos.Dot( box.orientation.v[1].xyz );
|
coordinate = dPos.Dot( box.yAxis );
|
||||||
if( coordinate > box.boundingOffset.y ) return false;
|
if( coordinate > box.boundingOffset.y ) return false;
|
||||||
if( coordinate < -box.boundingOffset.y ) return false;
|
if( coordinate < -box.boundingOffset.y ) return false;
|
||||||
|
|
||||||
coordinate = dPos.Dot( box.orientation.v[2].xyz );
|
coordinate = dPos.Dot( box.zAxis );
|
||||||
if( coordinate > box.boundingOffset.z ) return false;
|
if( coordinate > box.boundingOffset.z ) return false;
|
||||||
if( coordinate < -box.boundingOffset.z ) return false;
|
if( coordinate < -box.boundingOffset.z ) return false;
|
||||||
|
|
||||||
|
@ -419,11 +459,11 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
||||||
|
|
||||||
bool Intersect( const Box &box, const Sphere &sphere )
|
bool Intersect( const Box &box, const Sphere &sphere )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
Float3 e = sphere.center - box.orientation.v[3].xyz,
|
Float3 e = sphere.center - box.center,
|
||||||
centerL = Float3( e.Dot(box.orientation.v[0].xyz), e.Dot(box.orientation.v[1].xyz), e.Dot(box.orientation.v[2].xyz) );
|
centerL = Float3( e.Dot(box.xAxis), e.Dot(box.yAxis), e.Dot(box.zAxis) );
|
||||||
|
|
||||||
e = ::Utility::Value::Max( (box.boundingOffset + centerL)*=-1.0f, Float3::null );
|
e = Max( (box.boundingOffset + centerL)*=-1.0f, Float3::null );
|
||||||
e += ::Utility::Value::Max( centerL - box.boundingOffset, Float3::null );
|
e += Max( centerL - box.boundingOffset, Float3::null );
|
||||||
|
|
||||||
if( e.Dot(e) > (sphere.radius * sphere.radius) ) return false;
|
if( e.Dot(e) > (sphere.radius * sphere.radius) ) return false;
|
||||||
return true;
|
return true;
|
||||||
|
@ -440,20 +480,20 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
||||||
|
|
||||||
bool Intersect( const Box &boxA, const BoxAxisAligned &boxB )
|
bool Intersect( const Box &boxA, const BoxAxisAligned &boxB )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
Float3 alignedOffsetBoundaries = boxB.maxVertex - boxB.minVertex;
|
Float3 alignedOffsetBoundaries = (boxB.maxVertex - boxB.minVertex) * 0.5f,
|
||||||
Float4x4 translated = boxA.orientation;
|
offset = boxA.center - Average( boxB.minVertex, boxB.maxVertex );
|
||||||
translated.v[3].xyz -= boxB.minVertex;
|
return Private::SeperatingAxisTest_AxisAlignedVsTransformedBox( alignedOffsetBoundaries, boxA.boundingOffset, boxA.rotation, offset );
|
||||||
translated.v[3].xyz += alignedOffsetBoundaries * 0.5f;
|
|
||||||
alignedOffsetBoundaries = ::Utility::Value::Abs(alignedOffsetBoundaries);
|
|
||||||
return Private::FifteenAxisVsAlignedAxisOverlappingChecks( alignedOffsetBoundaries, boxA.boundingOffset, translated );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Intersect( const Box &boxA, const Box &boxB )
|
bool Intersect( const Box &boxA, const Box &boxB )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
Float4x4 M;
|
Float4x4 orientationA = OrientationMatrix(boxA.rotation, boxA.center),
|
||||||
InverseOrientationMatrix( boxA.orientation, M );
|
orientationB = OrientationMatrix(boxB.rotation, boxB.center),
|
||||||
TransformMatrix( M, boxB.orientation, M ); /// TODO: not verified
|
invOrientationA = InverseOrientationMatrix( orientationA );
|
||||||
return Private::FifteenAxisVsAlignedAxisOverlappingChecks( boxA.boundingOffset, boxB.boundingOffset, M );
|
|
||||||
|
orientationB = TransformMatrix( invOrientationA, orientationB );
|
||||||
|
|
||||||
|
return Private::SeperatingAxisTest_AxisAlignedVsTransformedBox( boxA.boundingOffset, boxB.boundingOffset, ExtractRotationMatrix(orientationB), orientationB.v[3].xyz );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Intersect( const Frustrum &frustrum, const Point &point )
|
bool Intersect( const Frustrum &frustrum, const Point &point )
|
||||||
|
@ -490,37 +530,37 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
||||||
if( Intersect(frustrum.leftPlane, ray, distance) )
|
if( Intersect(frustrum.leftPlane, ray, distance) )
|
||||||
{
|
{
|
||||||
intersected = true;
|
intersected = true;
|
||||||
connectDistance = ::Utility::Value::Min( connectDistance, distance );
|
connectDistance = Min( connectDistance, distance );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( Intersect(frustrum.rightPlane, ray, distance) )
|
if( Intersect(frustrum.rightPlane, ray, distance) )
|
||||||
{
|
{
|
||||||
intersected = true;
|
intersected = true;
|
||||||
connectDistance = ::Utility::Value::Min( connectDistance, distance );
|
connectDistance = Min( connectDistance, distance );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( Intersect(frustrum.bottomPlane, ray, distance) )
|
if( Intersect(frustrum.bottomPlane, ray, distance) )
|
||||||
{
|
{
|
||||||
intersected = true;
|
intersected = true;
|
||||||
connectDistance = ::Utility::Value::Min( connectDistance, distance );
|
connectDistance = Min( connectDistance, distance );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( Intersect(frustrum.topPlane, ray, distance) )
|
if( Intersect(frustrum.topPlane, ray, distance) )
|
||||||
{
|
{
|
||||||
intersected = true;
|
intersected = true;
|
||||||
connectDistance = ::Utility::Value::Min( connectDistance, distance );
|
connectDistance = Min( connectDistance, distance );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( Intersect(frustrum.nearPlane, ray, distance) )
|
if( Intersect(frustrum.nearPlane, ray, distance) )
|
||||||
{
|
{
|
||||||
intersected = true;
|
intersected = true;
|
||||||
connectDistance = ::Utility::Value::Min( connectDistance, distance );
|
connectDistance = Min( connectDistance, distance );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( Intersect(frustrum.farPlane, ray, distance) )
|
if( Intersect(frustrum.farPlane, ray, distance) )
|
||||||
{
|
{
|
||||||
intersected = true;
|
intersected = true;
|
||||||
connectDistance = ::Utility::Value::Min( connectDistance, distance );
|
connectDistance = Min( connectDistance, distance );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( intersected ) return true;
|
if( intersected ) return true;
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace Oyster { namespace Physics3D
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* Returns the local angular momentum of a mass in rotation.
|
* Returns the world angular momentum of a mass in rotation.
|
||||||
* @todo TODO: improve doc
|
* @todo TODO: improve doc
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
inline ::Oyster::Math::Float3 AngularMomentum( const ::Oyster::Math::Float4x4 &momentOfInertia, const ::Oyster::Math::Float3 &angularVelocity )
|
inline ::Oyster::Math::Float3 AngularMomentum( const ::Oyster::Math::Float4x4 &momentOfInertia, const ::Oyster::Math::Float3 &angularVelocity )
|
||||||
|
@ -58,39 +58,39 @@ namespace Oyster { namespace Physics3D
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* Returns the local angular momentum of a mass in rotation.
|
* Returns the world angular momentum of a mass in rotation.
|
||||||
* @todo TODO: improve doc
|
* @todo TODO: improve doc
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
inline ::Oyster::Math::Float3 AngularMomentum( const ::Oyster::Math::Float3 linearMomentum, const ::Oyster::Math::Float3 &offset )
|
inline ::Oyster::Math::Float3 AngularMomentum( const ::Oyster::Math::Float3 linearMomentum, const ::Oyster::Math::Float3 &worldOffset )
|
||||||
{
|
{
|
||||||
return offset.Cross( linearMomentum );
|
return worldOffset.Cross( linearMomentum );
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* Returns the local tangential momentum at localPos, of a mass in rotation.
|
* Returns the world tangential momentum at worldPos, of a mass in rotation.
|
||||||
* @todo TODO: improve doc
|
* @todo TODO: improve doc
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
inline ::Oyster::Math::Float3 TangentialLinearMomentum( const ::Oyster::Math::Float3 &angularMomentum, const ::Oyster::Math::Float3 &localOffset )
|
inline ::Oyster::Math::Float3 TangentialLinearMomentum( const ::Oyster::Math::Float3 &angularMomentum, const ::Oyster::Math::Float3 &worldOffset )
|
||||||
{
|
{
|
||||||
return angularMomentum.Cross( localOffset );
|
return angularMomentum.Cross( worldOffset );
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* Returns the local tangential momentum at localPos, of a mass in rotation.
|
* Returns the world tangential momentum at worldPos, of a mass in rotation.
|
||||||
* @todo TODO: improve doc
|
* @todo TODO: improve doc
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
inline ::Oyster::Math::Float3 TangentialLinearMomentum( const ::Oyster::Math::Float4x4 &momentOfInertia, const ::Oyster::Math::Float3 &angularVelocity, const ::Oyster::Math::Float3 &localOffset )
|
inline ::Oyster::Math::Float3 TangentialLinearMomentum( const ::Oyster::Math::Float4x4 &momentOfInertia, const ::Oyster::Math::Float3 &angularVelocity, const ::Oyster::Math::Float3 &worldOffset )
|
||||||
{
|
{
|
||||||
return TangentialLinearMomentum( AngularMomentum(momentOfInertia, angularVelocity), localOffset );
|
return TangentialLinearMomentum( AngularMomentum(momentOfInertia, angularVelocity), worldOffset );
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* Returns the local impulse force at localPos, of a mass in angular acceleration.
|
* Returns the world impulse force at worldPos, of a mass in angular acceleration.
|
||||||
* @todo TODO: improve doc
|
* @todo TODO: improve doc
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
inline ::Oyster::Math::Float3 TangentialImpulseForce( const ::Oyster::Math::Float3 &impulseTorque, const ::Oyster::Math::Float3 &localOffset )
|
inline ::Oyster::Math::Float3 TangentialImpulseForce( const ::Oyster::Math::Float3 &impulseTorque, const ::Oyster::Math::Float3 &worldOffset )
|
||||||
{
|
{
|
||||||
return impulseTorque.Cross( localOffset );
|
return impulseTorque.Cross( worldOffset );
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
|
@ -106,22 +106,22 @@ namespace Oyster { namespace Physics3D
|
||||||
*
|
*
|
||||||
* @todo TODO: improve doc
|
* @todo TODO: improve doc
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
inline ::Oyster::Math::Float3 AngularImpulseAcceleration( const ::Oyster::Math::Float3 &linearImpulseAcceleration, const ::Oyster::Math::Float3 &offset )
|
inline ::Oyster::Math::Float3 AngularImpulseAcceleration( const ::Oyster::Math::Float3 &linearImpulseAcceleration, const ::Oyster::Math::Float3 &worldOffset )
|
||||||
{
|
{
|
||||||
return offset.Cross( linearImpulseAcceleration );
|
return worldOffset.Cross( linearImpulseAcceleration );
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* Returns the local impulse acceleration at localPos, of a mass in angular acceleration.
|
* Returns the world impulse acceleration at ( worldOffset = worldPos - body's center of gravity ), of a mass in angular acceleration.
|
||||||
* @todo TODO: improve doc
|
* @todo TODO: improve doc
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
inline ::Oyster::Math::Float3 TangentialImpulseAcceleration( const ::Oyster::Math::Float4x4 &momentOfInertiaInversed, const ::Oyster::Math::Float3 &impulseTorque, const ::Oyster::Math::Float3 &localOffset )
|
inline ::Oyster::Math::Float3 TangentialImpulseAcceleration( const ::Oyster::Math::Float4x4 &worldMomentOfInertiaInversed, const ::Oyster::Math::Float3 &worldImpulseTorque, const ::Oyster::Math::Float3 &worldOffset )
|
||||||
{
|
{
|
||||||
return AngularImpulseAcceleration( momentOfInertiaInversed, impulseTorque ).Cross( localOffset );
|
return AngularImpulseAcceleration( worldMomentOfInertiaInversed, worldImpulseTorque ).Cross( worldOffset );
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* Returns the local angular velocity of a mass in rotation.
|
* Returns the world angular velocity of a mass in rotation.
|
||||||
* @todo TODO: improve doc
|
* @todo TODO: improve doc
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
inline ::Oyster::Math::Float3 AngularVelocity( const ::Oyster::Math::Float4x4 &momentOfInertiaInversed, const ::Oyster::Math::Float3 &angularMomentum )
|
inline ::Oyster::Math::Float3 AngularVelocity( const ::Oyster::Math::Float4x4 &momentOfInertiaInversed, const ::Oyster::Math::Float3 &angularMomentum )
|
||||||
|
@ -130,21 +130,30 @@ namespace Oyster { namespace Physics3D
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* Returns the local tangential velocity at localPos, of a mass in rotation.
|
* Returns the world angular velocity 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 &offset )
|
inline ::Oyster::Math::Float3 AngularVelocity( const ::Oyster::Math::Float3 &linearVelocity, const ::Oyster::Math::Float3 &worldOffset )
|
||||||
{
|
{
|
||||||
return angularVelocity.Cross( offset );
|
return worldOffset.Cross( linearVelocity );
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* Returns the local tangential velocity at localPos, of a mass in rotation.
|
* Returns the world tangential velocity at worldPos, of a mass in rotation.
|
||||||
* @todo TODO: improve doc
|
* @todo TODO: improve doc
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
inline ::Oyster::Math::Float3 TangentialLinearVelocity( const ::Oyster::Math::Float4x4 &momentOfInertiaInversed, const ::Oyster::Math::Float3 &angularMomentum, const ::Oyster::Math::Float3 &offset )
|
inline ::Oyster::Math::Float3 TangentialLinearVelocity( const ::Oyster::Math::Float3 &angularVelocity, const ::Oyster::Math::Float3 &worldOffset )
|
||||||
{
|
{
|
||||||
return TangentialLinearVelocity( AngularVelocity(momentOfInertiaInversed, angularMomentum), offset );
|
return angularVelocity.Cross( worldOffset );
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************
|
||||||
|
* Returns the world tangential velocity at worldPos, 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 &worldOffset )
|
||||||
|
{
|
||||||
|
return TangentialLinearVelocity( AngularVelocity(momentOfInertiaInversed, angularMomentum), worldOffset );
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
|
@ -169,9 +178,9 @@ namespace Oyster { namespace Physics3D
|
||||||
*
|
*
|
||||||
* @todo TODO: improve doc
|
* @todo TODO: improve doc
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
inline ::Oyster::Math::Float3 ImpulseTorque( const ::Oyster::Math::Float3 & impulseForce, const ::Oyster::Math::Float3 &offset )
|
inline ::Oyster::Math::Float3 ImpulseTorque( const ::Oyster::Math::Float3 & impulseForce, const ::Oyster::Math::Float3 &worldOffset )
|
||||||
{
|
{
|
||||||
return offset.Cross( impulseForce );
|
return worldOffset.Cross( impulseForce );
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
|
@ -183,6 +192,12 @@ namespace Oyster { namespace Physics3D
|
||||||
return ( momentOfInertia * ::Oyster::Math::Float4(angularImpulseAcceleration, 0.0f) ).xyz;
|
return ( momentOfInertia * ::Oyster::Math::Float4(angularImpulseAcceleration, 0.0f) ).xyz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline ::Oyster::Math::Float3 Impulse( )
|
||||||
|
{
|
||||||
|
//! @todo TODO: implement calculation for impulse. Hijack Mattias Eriksson
|
||||||
|
return ::Oyster::Math::Float3::null;
|
||||||
|
}
|
||||||
|
|
||||||
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 tensor formulas */
|
/** @todo TODO: add MomentOfInertia tensor formulas */
|
||||||
|
|
|
@ -39,20 +39,21 @@ RigidBody & RigidBody::operator = ( const RigidBody &body )
|
||||||
void RigidBody::Update_LeapFrog( Float deltaTime )
|
void RigidBody::Update_LeapFrog( Float deltaTime )
|
||||||
{ // by Dan Andersson: Euler leap frog update when Runga Kutta is not needed
|
{ // by Dan Andersson: Euler leap frog update when Runga Kutta is not needed
|
||||||
|
|
||||||
|
// Important! The member data is all world data except the Inertia tensor. Thus a new InertiaTensor needs to be created to be compatible with the rest of the world data.
|
||||||
|
Float4x4 wMomentOfInertiaTensor = TransformMatrix( this->box.rotation, this->momentOfInertiaTensor ); // RI
|
||||||
|
|
||||||
// updating the linear
|
// updating the linear
|
||||||
// dv = dt * a = dt * F / m
|
// dG = F * dt
|
||||||
// ds = dt * avg_v
|
// ds = dt * Formula::LinearVelocity( m, avg_G ) = dt * avg_G / m = (dt / m) * avg_G
|
||||||
Float3 deltaLinearVelocity = this->impulseForceSum;
|
Float3 linearImpulse = this->impulseForceSum * deltaTime; // aka deltaLinearMomentum
|
||||||
deltaLinearVelocity *= (deltaTime / this->mass);
|
Float3 deltaPos = ( deltaTime / this->mass ) * ::Utility::Value::AverageWithDelta( this->linearMomentum, linearImpulse );
|
||||||
Float3 deltaPos = deltaTime * ::Utility::Value::AverageWithDelta( Formula::LinearVelocity(this->mass, this->linearMomentum), deltaLinearVelocity );
|
|
||||||
|
|
||||||
// updating the angular
|
// updating the angular
|
||||||
// dw = dt * a = dt * ( I^-1 * T )
|
// dH = T * dt
|
||||||
// rotation = dt * avg_w
|
// dO = dt * Formula::AngularVelocity( (RI)^-1, avg_H ) = dt * (RI)^-1 * avg_H
|
||||||
Float4x4 inversedMomentOfInertiaTensor = this->momentOfInertiaTensor.GetInverse();
|
Float3 angularImpulse = this->impulseTorqueSum * deltaTime; // aka deltaAngularMomentum
|
||||||
Float3 deltaAngularVelocity = Formula::AngularImpulseAcceleration( inversedMomentOfInertiaTensor, this->impulseTorqueSum ); // I^-1 * T
|
Float3 rotationAxis = Formula::AngularVelocity( wMomentOfInertiaTensor.GetInverse(),
|
||||||
deltaAngularVelocity *= deltaTime;
|
::Utility::Value::AverageWithDelta(this->angularMomentum, angularImpulse) );
|
||||||
Float3 rotationAxis = ::Utility::Value::AverageWithDelta( Formula::AngularVelocity(inversedMomentOfInertiaTensor,this->angularMomentum), deltaAngularVelocity );
|
|
||||||
|
|
||||||
Float deltaRadian = rotationAxis.Dot( rotationAxis );
|
Float deltaRadian = rotationAxis.Dot( rotationAxis );
|
||||||
if( deltaRadian != 0.0f )
|
if( deltaRadian != 0.0f )
|
||||||
|
@ -60,95 +61,72 @@ void RigidBody::Update_LeapFrog( Float deltaTime )
|
||||||
deltaRadian = ::std::sqrt( deltaRadian );
|
deltaRadian = ::std::sqrt( deltaRadian );
|
||||||
rotationAxis /= deltaRadian;
|
rotationAxis /= deltaRadian;
|
||||||
|
|
||||||
// using rotationAxis, deltaRadian and deltaPos to create a matrix to update the orientation matrix
|
// using rotationAxis, deltaRadian and deltaPos to create a matrix to update the box
|
||||||
UpdateOrientationMatrix( deltaPos, RotationMatrix(deltaRadian, rotationAxis), this->box.orientation );
|
this->box.center += deltaPos;
|
||||||
|
TransformMatrix( RotationMatrix(deltaRadian, rotationAxis), this->box.rotation, this->box.rotation );
|
||||||
/** @todo TODO: ISSUE! how is momentOfInertiaTensor related to the orientation of the RigidBody? */
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // no rotation, only use deltaPos to translate the RigidBody
|
{ // no rotation, only use deltaPos to translate the RigidBody
|
||||||
this->box.center += deltaPos;
|
this->box.center += deltaPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update movements and clear impulses
|
// update momentums and clear impulseForceSum and impulseTorqueSum
|
||||||
this->linearMomentum += Formula::LinearMomentum( this->mass, deltaLinearVelocity );
|
this->linearMomentum += linearImpulse;
|
||||||
this->impulseForceSum = Float3::null;
|
this->impulseForceSum = Float3::null;
|
||||||
this->angularMomentum += Formula::AngularMomentum( this->momentOfInertiaTensor, deltaAngularVelocity );
|
this->angularMomentum += angularImpulse;
|
||||||
this->impulseTorqueSum = Float3::null;
|
this->impulseTorqueSum = Float3::null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::ApplyImpulseForce( const Float3 &f )
|
void RigidBody::ApplyImpulseForce( const Float3 &worldF )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
this->impulseForceSum += f;
|
this->impulseForceSum += worldF;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::ApplyImpulseForceAt_Local( const Float3 &localForce, const Float3 &localOffset )
|
void RigidBody::ApplyImpulseForceAt( const Float3 &worldF, const Float3 &worldPos )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
if( localOffset != Float3::null )
|
Float3 worldOffset = worldPos - this->box.center;
|
||||||
|
if( worldOffset != Float3::null )
|
||||||
{
|
{
|
||||||
this->impulseForceSum += VectorProjection( localForce, localOffset );
|
this->impulseForceSum += VectorProjection( worldF, worldOffset );
|
||||||
this->impulseTorqueSum += Formula::ImpulseTorque( localForce, localOffset );
|
this->impulseTorqueSum += Formula::ImpulseTorque( worldF, worldOffset );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->impulseForceSum += localForce;
|
this->impulseForceSum += worldF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::ApplyImpulseForceAt_World( const Float3 &worldForce, const Float3 &worldPos )
|
void RigidBody::ApplyLinearImpulseAcceleration( const Float3 &worldA )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
Float4x4 view = this->GetView();
|
this->impulseForceSum += Formula::ImpulseForce( this->mass, worldA );
|
||||||
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 )
|
void RigidBody::ApplyLinearImpulseAccelerationAt( const Float3 &worldA, const Float3 &worldPos )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
this->impulseForceSum += Formula::ImpulseForce( this->mass, a );
|
Float3 worldOffset = worldPos - this->box.center;
|
||||||
}
|
if( worldOffset != Float3::null )
|
||||||
|
|
||||||
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) );
|
this->impulseForceSum += Formula::ImpulseForce( this->mass, VectorProjection(worldA, worldOffset) );
|
||||||
|
|
||||||
// tanAcc = angularAcc x localPosition
|
// tanAcc = angularAcc x localPosition
|
||||||
// angularAcc = localPosition x tanAcc = localPosition x linearAcc
|
// angularAcc = localPosition x tanAcc = localPosition x linearAcc
|
||||||
// T = I * angularAcc
|
// T = I * angularAcc
|
||||||
this->impulseTorqueSum += Formula::ImpulseTorque( this->momentOfInertiaTensor, Formula::AngularImpulseAcceleration(localImpulseLinearAcc, localOffset) );
|
this->impulseTorqueSum += Formula::ImpulseTorque( this->momentOfInertiaTensor, Formula::AngularImpulseAcceleration(worldA, worldOffset) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->impulseForceSum += Formula::ImpulseForce( this->mass, localImpulseLinearAcc );
|
this->impulseForceSum += Formula::ImpulseForce( this->mass, worldA );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::ApplyLinearImpulseAccelerationAt_World( const Float3 &worldImpulseLinearAcc, const Float3 &worldPos )
|
void RigidBody::ApplyImpulseTorque( const Float3 &worldT )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
Float4x4 view = this->GetView();
|
this->impulseTorqueSum += worldT;
|
||||||
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 )
|
void RigidBody::ApplyAngularImpulseAcceleration( const Float3 &worldA )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
this->impulseTorqueSum += t;
|
this->impulseTorqueSum += Formula::ImpulseTorque( this->momentOfInertiaTensor, worldA );
|
||||||
}
|
|
||||||
|
|
||||||
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()
|
Float3 & RigidBody::AccessBoundingReach()
|
||||||
|
@ -181,14 +159,14 @@ const Float & RigidBody::GetMass() const
|
||||||
return this->mass;
|
return this->mass;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Float4x4 & RigidBody::GetOrientation() const
|
const Float4x4 RigidBody::GetOrientation() const
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
return this->box.orientation;
|
return OrientationMatrix( this->box.rotation, this->box.center );
|
||||||
}
|
}
|
||||||
|
|
||||||
Float4x4 RigidBody::GetView() const
|
Float4x4 RigidBody::GetView() const
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
return InverseOrientationMatrix( this->box.orientation );
|
return InverseOrientationMatrix( this->GetOrientation() );
|
||||||
}
|
}
|
||||||
|
|
||||||
const Float3 & RigidBody::GetBoundingReach() const
|
const Float3 & RigidBody::GetBoundingReach() const
|
||||||
|
@ -246,106 +224,21 @@ Float3 RigidBody::GetLinearVelocity() const
|
||||||
return Formula::LinearVelocity( this->mass, this->linearMomentum );
|
return Formula::LinearVelocity( this->mass, this->linearMomentum );
|
||||||
}
|
}
|
||||||
|
|
||||||
Float3 RigidBody::GetTangentialImpulseForceAt_Local( const Float3 &localPos ) const
|
void RigidBody::GetMomentumAt( const Float3 &worldPos, const Float3 &surfaceNormal, Float3 &normalMomentum, Float3 &tangentialMomentum ) const
|
||||||
{ // by Dan Andersson
|
{
|
||||||
return Formula::TangentialImpulseForce( this->impulseTorqueSum, localPos );
|
Float3 worldOffset = worldPos - this->box.center;
|
||||||
|
Float3 momentum = Formula::TangentialLinearMomentum( this->angularMomentum, worldOffset );
|
||||||
|
momentum += this->linearMomentum;
|
||||||
|
|
||||||
|
normalMomentum = NormalProjection( momentum, surfaceNormal );
|
||||||
|
tangentialMomentum = momentum - normalMomentum;
|
||||||
}
|
}
|
||||||
|
|
||||||
Float3 RigidBody::GetTangentialImpulseForceAt_World( const Float3 &worldPos ) const
|
void RigidBody::SetMomentOfInertia( const Float4x4 &localI )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
return this->GetTangentialImpulseForceAt_Local( (this->GetView() * Float4(worldPos, 1.0f)).xyz ); // should not be any disform thus result.w = 1.0f
|
if( localI.GetDeterminant() != 0.0f ) // insanitycheck! momentOfInertiaTensor must be invertable
|
||||||
}
|
|
||||||
|
|
||||||
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 &localPos ) const
|
|
||||||
{ // by Dan Andersson
|
|
||||||
return this->impulseForceSum + Formula::TangentialImpulseForce( this->impulseForceSum, localPos );
|
|
||||||
}
|
|
||||||
|
|
||||||
Float3 RigidBody::GetImpulseForceAt_World( const Float3 &worldPos ) const
|
|
||||||
{ // by Dan Andersson
|
|
||||||
Float4 localForce = Float4( this->GetImpulseForceAt_Local((this->GetView() * Float4(worldPos, 1.0f)).xyz), 0.0f ); // should not be any disform thus result.w = 1.0f
|
|
||||||
return (this->box.orientation * localForce).xyz; // should not be any disform thus result.w = 0.0f
|
|
||||||
}
|
|
||||||
|
|
||||||
Float3 RigidBody::GetLinearMomentumAt_Local( const Float3 &localPos ) const
|
|
||||||
{ // by Dan Andersson
|
|
||||||
// Reminder! Momentum is a world value.
|
|
||||||
return Float3::null; // TODO:
|
|
||||||
}
|
|
||||||
|
|
||||||
Float3 RigidBody::GetLinearMomentumAt_World( const Float3 &worldPos ) const
|
|
||||||
{ // by Dan Andersson
|
|
||||||
// Reminder! Momentum is a world value.
|
|
||||||
Float4 localMomentum = Float4( this->GetLinearMomentumAt_Local((this->GetView() * Float4(worldPos, 1.0f)).xyz), 0.0f ); // should not be any disform thus result.w = 1.0f
|
|
||||||
return (this->box.orientation * localMomentum).xyz; // should not be any disform thus result.w = 0.0f
|
|
||||||
|
|
||||||
// TODO: angularMomentum is a local value!!
|
|
||||||
return this->linearMomentum + Formula::TangentialLinearMomentum( this->angularMomentum, worldPos );
|
|
||||||
}
|
|
||||||
|
|
||||||
Float3 RigidBody::GetImpulseAccelerationAt_Local( const Float3 &localPos ) const
|
|
||||||
{ // by Dan Andersson
|
|
||||||
// Reminder! Acceleration is a world value.
|
|
||||||
Float4 worldAccel = Float4( this->GetImpulseAccelerationAt_Local((this->box.orientation * Float4(localPos, 1.0f)).xyz), 0.0f ); // should not be any disform thus result.w = 1.0f
|
|
||||||
return (this->GetView() * worldAccel).xyz; // should not be any disform thus result.w = 0.0f
|
|
||||||
}
|
|
||||||
|
|
||||||
Float3 RigidBody::GetImpulseAccelerationAt_World( const Float3 &worldPos ) const
|
|
||||||
{ // by Dan Andersson
|
|
||||||
// Reminder! Acceleration is a world value.
|
|
||||||
return Formula::LinearImpulseAcceleration( this->mass, this->impulseForceSum )
|
|
||||||
+ Formula::TangentialImpulseAcceleration( this->momentOfInertiaTensor.GetInverse(), this->impulseTorqueSum, worldPos );
|
|
||||||
}
|
|
||||||
|
|
||||||
Float3 RigidBody::GetLinearVelocityAt_Local( const Float3 &localPos ) const
|
|
||||||
{ // by Dan Andersson
|
|
||||||
// Reminder! Velocity is a world value.
|
|
||||||
Float4 worldV = Float4( this->GetLinearVelocityAt_Local((this->box.orientation * Float4(localPos, 1.0f)).xyz), 0.0f ); // should not be any disform thus result.w = 1.0f
|
|
||||||
return (this->GetView() * worldV).xyz; // should not be any disform thus result.w = 0.0f
|
|
||||||
}
|
|
||||||
|
|
||||||
Float3 RigidBody::GetLinearVelocityAt_World( const Float3 &worldPos ) const
|
|
||||||
{ // by Dan Andersson
|
|
||||||
// Reminder! Velocity is a world value.
|
|
||||||
return Formula::LinearVelocity( this->mass, this->linearMomentum )
|
|
||||||
+ Formula::TangentialLinearVelocity( this->momentOfInertiaTensor.GetInverse(), this->angularMomentum, worldPos );
|
|
||||||
}
|
|
||||||
|
|
||||||
void RigidBody::SetMomentOfInertia( const Float4x4 &i )
|
|
||||||
{ // by Dan Andersson
|
|
||||||
if( i.GetDeterminant() != 0.0f ) // insanitycheck! momentOfInertiaTensor must be invertable
|
|
||||||
{
|
{
|
||||||
this->momentOfInertiaTensor = i;
|
this->momentOfInertiaTensor = localI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,7 +262,8 @@ void RigidBody::SetMass_KeepMomentum( const Float &m )
|
||||||
|
|
||||||
void RigidBody::SetOrientation( const Float4x4 &o )
|
void RigidBody::SetOrientation( const Float4x4 &o )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
this->box.orientation = o;
|
ExtractRotationMatrix( o, this->box.rotation );
|
||||||
|
this->box.center = o.v[3].xyz;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::SetSize( const Float3 &widthHeight )
|
void RigidBody::SetSize( const Float3 &widthHeight )
|
||||||
|
@ -377,98 +271,77 @@ void RigidBody::SetSize( const Float3 &widthHeight )
|
||||||
this->box.boundingOffset = 0.5f * widthHeight;
|
this->box.boundingOffset = 0.5f * widthHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::SetCenter( const Float3 &p )
|
void RigidBody::SetCenter( const Float3 &worldPos )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
this->box.center = p;
|
this->box.center = worldPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::SetImpulseTorque( const Float3 &t )
|
void RigidBody::SetImpulseTorque( const Float3 &worldT )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
this->impulseTorqueSum = t;
|
this->impulseTorqueSum = worldT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::SetAngularMomentum( const Float3 &h )
|
void RigidBody::SetAngularMomentum( const Float3 &worldH )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
this->angularMomentum = h;
|
this->angularMomentum = worldH;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::SetAngularImpulseAcceleration( const Float3 &a )
|
void RigidBody::SetAngularImpulseAcceleration( const Float3 &worldA )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
this->impulseTorqueSum = Formula::ImpulseTorque( this->momentOfInertiaTensor, a );
|
this->impulseTorqueSum = Formula::ImpulseTorque( this->momentOfInertiaTensor, worldA );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::SetAngularVelocity( const Float3 &w )
|
void RigidBody::SetAngularVelocity( const Float3 &worldW )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
this->angularMomentum = Formula::AngularMomentum( this->momentOfInertiaTensor, w );
|
this->angularMomentum = Formula::AngularMomentum( this->momentOfInertiaTensor, worldW );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::SetImpulseForce( const Float3 &f )
|
void RigidBody::SetImpulseForce( const Float3 &worldF )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
this->impulseForceSum = f;
|
this->impulseForceSum = worldF;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::SetLinearMomentum( const Float3 &g )
|
void RigidBody::SetLinearMomentum( const Float3 &worldG )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
this->linearMomentum = g;
|
this->linearMomentum = worldG;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::SetLinearImpulseAcceleration( const Float3 &a )
|
void RigidBody::SetLinearImpulseAcceleration( const Float3 &worldA )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
this->impulseForceSum = Formula::ImpulseForce( this->mass, a );
|
this->impulseForceSum = Formula::ImpulseForce( this->mass, worldA );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::SetLinearVelocity( const Float3 &v )
|
void RigidBody::SetLinearVelocity( const Float3 &worldV )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
this->linearMomentum = Formula::LinearMomentum( this->mass, v );
|
this->linearMomentum = Formula::LinearMomentum( this->mass, worldV );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::SetImpulseForceAt_Local( const Float3 &localForce, const Float3 &localPos )
|
void RigidBody::SetImpulseForceAt( const Float3 &worldForce, const Float3 &worldPos )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
// Reminder! Impulse force and torque is world values.
|
Float3 worldOffset = worldPos - this->box.center;
|
||||||
Float3 worldForce = ( this->box.orientation * Float4(localForce, 0.0f) ).xyz,
|
this->impulseForceSum = VectorProjection( worldForce, worldOffset );
|
||||||
worldPos = ( this->box.orientation * Float4(localPos, 1.0f) ).xyz;
|
this->impulseTorqueSum = Formula::ImpulseTorque( worldForce, worldOffset );
|
||||||
this->SetImpulseForceAt_World( worldForce, worldPos );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::SetImpulseForceAt_World( const Float3 &worldForce, const Float3 &worldPos )
|
void RigidBody::SetLinearMomentumAt( const Float3 &worldG, const Float3 &worldPos )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
// Reminder! Impulse force and torque is world values.
|
Float3 worldOffset = worldPos - this->box.center;
|
||||||
this->impulseForceSum = VectorProjection( worldForce, worldPos );
|
this->linearMomentum = VectorProjection( worldG, worldOffset );
|
||||||
this->impulseTorqueSum = Formula::ImpulseTorque( worldForce, worldPos );
|
this->angularMomentum = Formula::AngularMomentum( worldG, worldOffset );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::SetLinearMomentumAt_Local( const Float3 &localG, const Float3 &localPos )
|
void RigidBody::SetImpulseAccelerationAt( const Float3 &worldA, const Float3 &worldPos )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
// Reminder! Linear and angular momentum is world values.
|
Float3 worldOffset = worldPos - this->box.center;
|
||||||
Float3 worldG = ( this->box.orientation * Float4(localG, 0.0f) ).xyz,
|
this->impulseForceSum = Formula::ImpulseForce( this->mass, VectorProjection(worldA, worldOffset) );
|
||||||
worldPos = ( this->box.orientation * Float4(localPos, 1.0f) ).xyz;
|
this->impulseTorqueSum = Formula::ImpulseTorque( this->box.rotation * this->momentOfInertiaTensor,
|
||||||
this->SetLinearMomentumAt_World( worldG, worldPos );
|
Formula::AngularImpulseAcceleration(worldA, worldOffset) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::SetLinearMomentumAt_World( const Float3 &worldG, const Float3 &worldPos )
|
void RigidBody::SetLinearVelocityAt( const Float3 &worldV, const Float3 &worldPos )
|
||||||
{ // by Dan Andersson
|
{ // by Dan Andersson
|
||||||
// Reminder! Linear and angular momentum is world values.
|
Float3 worldOffset = worldPos - this->box.center;
|
||||||
this->linearMomentum = VectorProjection( worldG, worldPos );
|
this->linearMomentum = Formula::LinearMomentum( this->mass, VectorProjection(worldV, worldOffset) );
|
||||||
this->angularMomentum = Formula::AngularMomentum( worldG, worldPos );
|
this->angularMomentum = Formula::AngularMomentum( this->box.rotation * this->momentOfInertiaTensor,
|
||||||
}
|
Formula::AngularVelocity(worldV, worldOffset) );
|
||||||
|
|
||||||
void RigidBody::SetImpulseAccelerationAt_Local( const Float3 &a, const Float3 &pos )
|
|
||||||
{ // by Dan Andersson
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -14,30 +14,26 @@ namespace Oyster { namespace Physics3D
|
||||||
struct RigidBody
|
struct RigidBody
|
||||||
{ /// A struct of a simple rigid body.
|
{ /// A struct of a simple rigid body.
|
||||||
public:
|
public:
|
||||||
::Oyster::Collision3D::Box box; /// Contains data representing physical presence.
|
::Oyster::Collision3D::Box box; /** Contains data representing physical presence. (worldValue) */
|
||||||
::Oyster::Math::Float3 angularMomentum, /// The angular momentum H (Nm*s) around an parallell axis.
|
::Oyster::Math::Float3 angularMomentum, /** The angular momentum H (Nm*s) around an parallell axis. (worldValue) */
|
||||||
linearMomentum, /// The linear momentum G (kg*m/s).
|
linearMomentum, /** The linear momentum G (kg*m/s). (worldValue) */
|
||||||
impulseTorqueSum, /// The impulse torque T (Nm) that will be consumed each update.
|
impulseTorqueSum, /** The impulse torque T (Nm) that will be consumed each update. (worldValue) */
|
||||||
impulseForceSum; /// The impulse force F (N) that will be consumed each update.
|
impulseForceSum; /** The impulse force F (N) that will be consumed each update. (worldValue) */
|
||||||
|
|
||||||
RigidBody( const ::Oyster::Collision3D::Box &box = ::Oyster::Collision3D::Box(), ::Oyster::Math::Float mass = 1.0f );
|
RigidBody( const ::Oyster::Collision3D::Box &box = ::Oyster::Collision3D::Box(), ::Oyster::Math::Float mass = 1.0f );
|
||||||
|
|
||||||
RigidBody & operator = ( const RigidBody &body );
|
RigidBody & operator = ( const RigidBody &body );
|
||||||
|
|
||||||
void Update_LeapFrog( ::Oyster::Math::Float deltaTime );
|
void Update_LeapFrog( ::Oyster::Math::Float deltaTime );
|
||||||
void ApplyImpulseForce( const ::Oyster::Math::Float3 &f );
|
void ApplyImpulseForce( const ::Oyster::Math::Float3 &worldF );
|
||||||
void ApplyImpulseForceAt_Local( const ::Oyster::Math::Float3 &f, const ::Oyster::Math::Float3 &pos );
|
void ApplyImpulseForceAt( const ::Oyster::Math::Float3 &worldF, const ::Oyster::Math::Float3 &worldPos );
|
||||||
void ApplyImpulseForceAt_World( const ::Oyster::Math::Float3 &f, const ::Oyster::Math::Float3 &pos ); /// ApplyImpulseForce_LocalPos is preferred
|
void ApplyLinearImpulseAcceleration( const ::Oyster::Math::Float3 &worldA );
|
||||||
void ApplyLinearImpulseAcceleration( const ::Oyster::Math::Float3 &a );
|
void ApplyLinearImpulseAccelerationAt( const ::Oyster::Math::Float3 &worldA, const ::Oyster::Math::Float3 &worldPos );
|
||||||
void ApplyLinearImpulseAccelerationAt_Local( const ::Oyster::Math::Float3 &a, const ::Oyster::Math::Float3 &pos );
|
void ApplyImpulseTorque( const ::Oyster::Math::Float3 &worldT );
|
||||||
void ApplyLinearImpulseAccelerationAt_World( const ::Oyster::Math::Float3 &a, const ::Oyster::Math::Float3 &pos ); /// ApplyLinearImpulseAcceleration_LocalPos is preferred
|
void ApplyAngularImpulseAcceleration( const ::Oyster::Math::Float3 &worldA );
|
||||||
void ApplyImpulseTorque( const ::Oyster::Math::Float3 &t );
|
|
||||||
void ApplyAngularImpulseAcceleration( const ::Oyster::Math::Float3 &a );
|
|
||||||
|
|
||||||
// ACCESS METHODS /////////////////////////////
|
// ACCESS METHODS /////////////////////////////
|
||||||
|
|
||||||
::Oyster::Math::Float4x4 & AccessOrientation();
|
|
||||||
const ::Oyster::Math::Float4x4 & AccessOrientation() const;
|
|
||||||
::Oyster::Math::Float3 & AccessBoundingReach();
|
::Oyster::Math::Float3 & AccessBoundingReach();
|
||||||
const ::Oyster::Math::Float3 & AccessBoundingReach() const;
|
const ::Oyster::Math::Float3 & AccessBoundingReach() const;
|
||||||
::Oyster::Math::Float3 & AccessCenter();
|
::Oyster::Math::Float3 & AccessCenter();
|
||||||
|
@ -48,7 +44,7 @@ namespace Oyster { namespace Physics3D
|
||||||
const ::Oyster::Math::Float4x4 & GetMomentOfInertia() const;
|
const ::Oyster::Math::Float4x4 & GetMomentOfInertia() const;
|
||||||
const ::Oyster::Math::Float & GetMass() const;
|
const ::Oyster::Math::Float & GetMass() const;
|
||||||
|
|
||||||
const ::Oyster::Math::Float4x4 & GetOrientation() const;
|
const ::Oyster::Math::Float4x4 GetOrientation() const;
|
||||||
::Oyster::Math::Float4x4 GetView() const;
|
::Oyster::Math::Float4x4 GetView() const;
|
||||||
const ::Oyster::Math::Float4x4 & GetToWorldMatrix() const;
|
const ::Oyster::Math::Float4x4 & GetToWorldMatrix() const;
|
||||||
::Oyster::Math::Float4x4 GetToLocalMatrix() const;
|
::Oyster::Math::Float4x4 GetToLocalMatrix() const;
|
||||||
|
@ -68,56 +64,36 @@ namespace Oyster { namespace Physics3D
|
||||||
::Oyster::Math::Float3 GetLinearImpulseAcceleration() const;
|
::Oyster::Math::Float3 GetLinearImpulseAcceleration() const;
|
||||||
::Oyster::Math::Float3 GetLinearVelocity() const;
|
::Oyster::Math::Float3 GetLinearVelocity() const;
|
||||||
|
|
||||||
::Oyster::Math::Float3 GetTangentialImpulseForceAt_Local( const ::Oyster::Math::Float3 &pos ) const;
|
void GetMomentumAt( const ::Oyster::Math::Float3 &worldPos, const ::Oyster::Math::Float3 &surfaceNormal, ::Oyster::Math::Float3 &normalMomentum, ::Oyster::Math::Float3 &tangentialMomentum ) 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 ////////////////////////////////
|
// SET METHODS ////////////////////////////////
|
||||||
|
|
||||||
void SetMomentOfInertia( const ::Oyster::Math::Float4x4 &i );
|
void SetMomentOfInertia( const ::Oyster::Math::Float4x4 &localI );
|
||||||
void SetMass_KeepVelocity( const ::Oyster::Math::Float &m );
|
void SetMass_KeepVelocity( const ::Oyster::Math::Float &m );
|
||||||
void SetMass_KeepMomentum( const ::Oyster::Math::Float &m );
|
void SetMass_KeepMomentum( const ::Oyster::Math::Float &m );
|
||||||
|
|
||||||
void SetOrientation( const ::Oyster::Math::Float4x4 &o );
|
void SetOrientation( const ::Oyster::Math::Float4x4 &o );
|
||||||
void SetSize( const ::Oyster::Math::Float3 &widthHeight );
|
void SetSize( const ::Oyster::Math::Float3 &widthHeight );
|
||||||
void SetCenter( const ::Oyster::Math::Float3 &p );
|
void SetCenter( const ::Oyster::Math::Float3 &worldPos );
|
||||||
|
|
||||||
void SetImpulseTorque( const ::Oyster::Math::Float3 &t );
|
void SetImpulseTorque( const ::Oyster::Math::Float3 &worldT );
|
||||||
void SetAngularMomentum( const ::Oyster::Math::Float3 &h );
|
void SetAngularMomentum( const ::Oyster::Math::Float3 &worldH );
|
||||||
void SetAngularImpulseAcceleration( const ::Oyster::Math::Float3 &a );
|
void SetAngularImpulseAcceleration( const ::Oyster::Math::Float3 &worldA );
|
||||||
void SetAngularVelocity( const ::Oyster::Math::Float3 &w );
|
void SetAngularVelocity( const ::Oyster::Math::Float3 &worldW );
|
||||||
|
|
||||||
void SetImpulseForce( const ::Oyster::Math::Float3 &f );
|
void SetImpulseForce( const ::Oyster::Math::Float3 &worldF );
|
||||||
void SetLinearMomentum( const ::Oyster::Math::Float3 &g );
|
void SetLinearMomentum( const ::Oyster::Math::Float3 &worldG );
|
||||||
void SetLinearImpulseAcceleration( const ::Oyster::Math::Float3 &a );
|
void SetLinearImpulseAcceleration( const ::Oyster::Math::Float3 &worldA );
|
||||||
void SetLinearVelocity( const ::Oyster::Math::Float3 &v );
|
void SetLinearVelocity( const ::Oyster::Math::Float3 &worldV );
|
||||||
|
|
||||||
void SetImpulseForceAt_Local( const ::Oyster::Math::Float3 &f, const ::Oyster::Math::Float3 &pos );
|
void SetImpulseForceAt( const ::Oyster::Math::Float3 &worldF, const ::Oyster::Math::Float3 &worldPos );
|
||||||
void SetImpulseForceAt_World( const ::Oyster::Math::Float3 &f, const ::Oyster::Math::Float3 &pos );
|
void SetLinearMomentumAt( const ::Oyster::Math::Float3 &worldG, const ::Oyster::Math::Float3 &worldPos );
|
||||||
void SetLinearMomentumAt_Local( const ::Oyster::Math::Float3 &g, const ::Oyster::Math::Float3 &pos );
|
void SetImpulseAccelerationAt( const ::Oyster::Math::Float3 &worldA, const ::Oyster::Math::Float3 &worldPos );
|
||||||
void SetLinearMomentumAt_World( const ::Oyster::Math::Float3 &g, const ::Oyster::Math::Float3 &pos );
|
void SetLinearVelocityAt( const ::Oyster::Math::Float3 &worldV, const ::Oyster::Math::Float3 &worldPos );
|
||||||
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:
|
private:
|
||||||
::Oyster::Math::Float mass; /// m (kg)
|
::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 )
|
::Oyster::Math::Float4x4 momentOfInertiaTensor; /** I (Nm*s) Tensor matrix ( only need to be 3x3 matrix, but is 4x4 for future hardware acceleration ) (localValue) */
|
||||||
};
|
};
|
||||||
|
|
||||||
// INLINE IMPLEMENTATIONS ///////////////////////////////////////
|
// INLINE IMPLEMENTATIONS ///////////////////////////////////////
|
||||||
|
|
|
@ -7,14 +7,21 @@
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include "Engine.h"
|
#include "Core/Core.h"
|
||||||
|
#include "Render\Preparations\Preparations.h"
|
||||||
|
#include "Render\Resources\Resources.h"
|
||||||
|
#include "Render\Rendering\Render.h"
|
||||||
|
#include "FileLoader\ObjReader.h"
|
||||||
|
#include "Definitions\GraphicalDefinition.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// Global Variables
|
// Global Variables
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
HINSTANCE g_hInst = NULL;
|
HINSTANCE g_hInst = NULL;
|
||||||
HWND g_hWnd = NULL;
|
HWND g_hWnd = NULL;
|
||||||
|
Oyster::Graphics::Render::Model* m = new Oyster::Graphics::Render::Model();
|
||||||
|
Oyster::Math::Float4x4 V;
|
||||||
|
Oyster::Math::Float4x4 P;
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
@ -131,59 +138,56 @@ HRESULT InitDirect3D()
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;;
|
HRESULT hr = S_OK;;
|
||||||
|
|
||||||
Oyster::Engine::Init::Setup setup;
|
Oyster::Graphics::Core::resolution = Oyster::Math::Float2( 1024, 768 );
|
||||||
setup.Fullscreen = false;
|
|
||||||
setup.ForceDX11 = true;
|
|
||||||
setup.SingleThreaded = true;
|
|
||||||
setup.window = g_hWnd;
|
|
||||||
|
|
||||||
Oyster::Engine::Init::FullInit( setup );
|
if(Oyster::Graphics::Core::Init::FullInit(g_hWnd,false,false)==Oyster::Graphics::Core::Init::Fail)
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
std::wstring ShaderPath = L"..\\OysterGraphics\\Shader\\HLSL\\";
|
//Init shaders
|
||||||
std::wstring EffectPath = L"SimpleDebug\\";
|
Oyster::Graphics::Render::Resources::Init();
|
||||||
|
|
||||||
Oyster::Core::ShaderManager::Init(ShaderPath + EffectPath + L"DebugPixel.hlsl",Oyster::Core::ShaderManager::ShaderType::Pixel,L"Debug",false);
|
Oyster::Graphics::Render::Preparations::Basic::SetViewPort();
|
||||||
Oyster::Core::ShaderManager::Init(ShaderPath + EffectPath + L"DebugVertex.hlsl",Oyster::Core::ShaderManager::ShaderType::Vertex,L"Debug",false);
|
|
||||||
|
|
||||||
Oyster::Core::ShaderManager::Set::Vertex(Oyster::Core::ShaderManager::Get::Vertex(L"Debug"));
|
#pragma region Triangle
|
||||||
Oyster::Core::ShaderManager::Set::Pixel(Oyster::Core::ShaderManager::Get::Pixel(L"Debug"));
|
//Oyster::Graphics::Definitions::ObjVertex mesh[] =
|
||||||
|
//{
|
||||||
|
// {Oyster::Math::Vector3(-1,1,0),Oyster::Math::Vector2(0,0),Oyster::Math::Vector3(1,1,0)},
|
||||||
|
// {Oyster::Math::Vector3(1,-1,0),Oyster::Math::Vector2(0,0),Oyster::Math::Vector3(1,1,0)},
|
||||||
|
// {Oyster::Math::Vector3(1,1,0),Oyster::Math::Vector2(0,0),Oyster::Math::Vector3(1,1,0)},
|
||||||
|
//};
|
||||||
|
|
||||||
D3D11_INPUT_ELEMENT_DESC inputDesc[] =
|
//Oyster::Graphics::Buffer::BUFFER_INIT_DESC desc;
|
||||||
{
|
//desc.ElementSize= sizeof(Oyster::Graphics::Definitions::ObjVertex);
|
||||||
{ "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }
|
//desc.NumElements = 3;
|
||||||
};
|
//desc.InitData=mesh;
|
||||||
|
//desc.Type = Oyster::Graphics::Buffer::BUFFER_TYPE::VERTEX_BUFFER;
|
||||||
|
//desc.Usage = Oyster::Graphics::Buffer::BUFFER_USAGE::BUFFER_USAGE_IMMUTABLE;
|
||||||
|
|
||||||
ID3D11InputLayout* layout;
|
//Oyster::Graphics::Buffer *b = new Oyster::Graphics::Buffer();;
|
||||||
|
//b->Init(desc);
|
||||||
|
|
||||||
Oyster::Core::ShaderManager::CreateInputLayout( inputDesc, 1, Oyster::Core::ShaderManager::Get::Vertex(L"Debug"), layout);
|
////b.Apply(0);
|
||||||
|
//Oyster::Graphics::Render::ModelInfo* mi = new Oyster::Graphics::Render::ModelInfo();
|
||||||
|
//mi->Indexed = false;
|
||||||
|
//mi->VertexCount = 3;
|
||||||
|
//mi->Vertices = b;
|
||||||
|
|
||||||
Oyster::Core::DeviceContext->IASetInputLayout(layout);
|
//m->info = mi;
|
||||||
Oyster::Core::DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
#pragma endregion
|
||||||
|
|
||||||
Oyster::Engine::PrepareForRendering::BindBackBuffer();
|
#pragma region Obj
|
||||||
|
OBJReader or;
|
||||||
|
or.readOBJFile(L"bth.obj");
|
||||||
|
m->info = or.toModel();
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
struct float4
|
m->World = Oyster::Math::Matrix::identity;
|
||||||
{
|
|
||||||
float x,y,z,w;
|
|
||||||
};
|
|
||||||
|
|
||||||
float4 mesh[] =
|
P = Oyster::Math3D::ProjectionMatrix_Perspective(PI/2,16.0f/9.0f,.1f,100);
|
||||||
{
|
|
||||||
{-1.0f,1.0f,0.0f,1.0f},
|
|
||||||
{1.0f,1.0f,0.0f,1.0f},
|
|
||||||
{1.0f,-1.0f,0.0f,1.0f},
|
|
||||||
};
|
|
||||||
|
|
||||||
Oyster::Buffer::BUFFER_INIT_DESC desc;
|
V = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),Oyster::Math::Float3(0,-1.5f,10.4f));
|
||||||
desc.ElementSize= sizeof(float4);
|
V = Oyster::Math3D::InverseOrientationMatrix(V);
|
||||||
desc.NumElements = 3;
|
|
||||||
desc.InitData=mesh;
|
|
||||||
desc.Type = Oyster::Buffer::BUFFER_TYPE::VERTEX_BUFFER;
|
|
||||||
desc.Usage = Oyster::Buffer::BUFFER_USAGE::BUFFER_USAGE_IMMUTABLE;
|
|
||||||
|
|
||||||
Oyster::Buffer b;
|
|
||||||
b.Init(desc);
|
|
||||||
b.Apply(0);
|
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -195,11 +199,18 @@ HRESULT Update(float deltaTime)
|
||||||
|
|
||||||
HRESULT Render(float deltaTime)
|
HRESULT Render(float deltaTime)
|
||||||
{
|
{
|
||||||
Oyster::Engine::PrepareForRendering::ClearBackBuffer(Oyster::Math::Float4(0,0,1,1));
|
Oyster::Graphics::Render::Rendering::Basic::NewFrame(V,P);
|
||||||
|
//Oyster::Graphics::Render::Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(0,0,1,1));
|
||||||
|
|
||||||
Oyster::Core::DeviceContext->Draw(3,0);
|
//m->info->Vertices->Apply(0);
|
||||||
|
|
||||||
Oyster::Core::SwapChain->Present(0,0);
|
//Oyster::Graphics::Core::deviceContext->Draw(3,0);
|
||||||
|
|
||||||
|
//Oyster::Graphics::Core::swapChain->Present(0,0);
|
||||||
|
|
||||||
|
Oyster::Graphics::Render::Rendering::Basic::RenderScene(m,1);
|
||||||
|
|
||||||
|
Oyster::Graphics::Render::Rendering::Basic::EndFrame();
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,98 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{1B3BEA4C-CF75-438A-9693-60FB8444BBF3}</ProjectGuid>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<RootNamespace>Tester</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>..\OysterGraphics;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="MainTest.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Misc\Misc.vcxproj">
|
||||||
|
<Project>{2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\OysterGraphics\OysterGraphics.vcxproj">
|
||||||
|
<Project>{0ec83e64-230e-48ef-b08c-6ac9651b4f82}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\OysterMath\OysterMath.vcxproj">
|
||||||
|
<Project>{f10cbc03-9809-4cba-95d8-327c287b18ee}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue