Merge branch 'MiscBranch' of https://github.com/dean11/Danbias into Network
This commit is contained in:
commit
f02a67b9b1
|
@ -145,7 +145,11 @@
|
|||
</ProjectReference>
|
||||
</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>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
|
|
@ -16,16 +16,21 @@
|
|||
<Filter Include="Header Files\Implementation">
|
||||
<UniqueIdentifier>{f2cb55b8-47a0-45c7-8dce-5b93f945a57b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\Implementation">
|
||||
<UniqueIdentifier>{cac9a78f-f09b-4850-b1aa-ea87e8368678}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Include">
|
||||
<UniqueIdentifier>{792daa4b-b2f7-4664-9529-71a929365274}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Include\GamePhysics.h">
|
||||
<ClInclude Include="PhysicsAPI.h">
|
||||
<Filter>Header Files\Include</Filter>
|
||||
</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>
|
||||
</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
|
|
@ -69,21 +69,29 @@
|
|||
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||
</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>
|
||||
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
@ -138,10 +146,21 @@
|
|||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Resource\Loaders\ByteLoader.cpp" />
|
||||
<ClCompile Include="Resource\Loaders\CustomLoader.cpp" />
|
||||
<ClCompile Include="Resource\OResourceHandler.cpp" />
|
||||
<ClCompile Include="Resource\OResource.cpp" />
|
||||
<ClCompile Include="Thread\OysterMutex.cpp" />
|
||||
<ClCompile Include="Thread\OysterThread_Impl.cpp" />
|
||||
<ClCompile Include="Utilities.cpp" />
|
||||
<ClCompile Include="WinTimer.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Resource\OysterResource.h" />
|
||||
<ClInclude Include="Resource\OResource.h" />
|
||||
<ClInclude Include="Thread\IThreadObject.h" />
|
||||
<ClInclude Include="Thread\OysterMutex.h" />
|
||||
<ClInclude Include="Thread\OysterThread.h" />
|
||||
<ClInclude Include="Utilities-InlineImpl.h" />
|
||||
<ClInclude Include="Utilities.h" />
|
||||
<ClInclude Include="WinTimer.h" />
|
||||
|
|
|
@ -21,6 +21,24 @@
|
|||
<ClCompile Include="WinTimer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Resource\OResource.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Resource\OResourceHandler.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Resource\Loaders\ByteLoader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Resource\Loaders\CustomLoader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Thread\OysterMutex.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Thread\OysterThread_Impl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Utilities.h">
|
||||
|
@ -32,5 +50,20 @@
|
|||
<ClInclude Include="Utilities-InlineImpl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Resource\OysterResource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Resource\OResource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Thread\IThreadObject.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Thread\OysterMutex.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Thread\OysterThread.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,176 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "..\OResource.h"
|
||||
#include "..\..\Utilities.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
using namespace Oyster::Resource;
|
||||
bool readANSI = false;
|
||||
|
||||
|
||||
|
||||
bool ReadFromFile(const wchar_t fileName[], const wchar_t openFlag[], std::wstring& outData, size_t elemSize)
|
||||
{
|
||||
size_t bytesTotal = 0;
|
||||
size_t bytesRead = 0;
|
||||
FILE *stream;
|
||||
|
||||
if( _wfopen_s( &stream, fileName, openFlag ) == 0 )
|
||||
{
|
||||
//Get size of the file
|
||||
fseek(stream, 0L, SEEK_END);
|
||||
bytesTotal = ftell(stream);
|
||||
fseek(stream, 0L, SEEK_SET);
|
||||
|
||||
//Sanity check
|
||||
if(bytesTotal == 0) return false;
|
||||
|
||||
//Create the new byte buffer
|
||||
wchar_t *buff = new wchar_t[bytesTotal + 1];
|
||||
|
||||
//Read the bytes to the end
|
||||
bytesRead = fread_s( buff, bytesTotal, elemSize, bytesTotal ,stream );
|
||||
fclose( stream );
|
||||
|
||||
//Did we read enough bytes
|
||||
if(!readANSI && bytesRead != bytesTotal) return false;
|
||||
|
||||
//Add delimiter
|
||||
buff[bytesRead] = L'\0';
|
||||
|
||||
outData.resize(bytesTotal);
|
||||
outData = buff;
|
||||
|
||||
delete [] buff;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring msg = L"Failed to open file: \n";
|
||||
msg.append(fileName);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
bool ReadFromFile(const wchar_t fileName[], const char openFlag[], std::string& outData, size_t elemSize)
|
||||
{
|
||||
std::string sFilename;
|
||||
std::wstring wsFile = fileName;
|
||||
::Utility::String::WStringToString(wsFile, sFilename);
|
||||
size_t bytesTotal = 0;
|
||||
size_t bytesRead = 0;
|
||||
FILE *stream;
|
||||
|
||||
if( fopen_s( &stream, sFilename.c_str(), openFlag ) == 0 )
|
||||
{
|
||||
//Get size of the file
|
||||
fseek(stream, 0L, SEEK_END);
|
||||
bytesTotal = ftell(stream);
|
||||
fseek(stream, 0L, SEEK_SET);
|
||||
fflush(stream);
|
||||
|
||||
//Sanity check
|
||||
if(bytesTotal == 0) return false;
|
||||
|
||||
//Create the new byte buffer
|
||||
char *buff = new char[bytesTotal + 1];
|
||||
|
||||
//Read the bytes to the end
|
||||
bytesRead = fread_s( buff, bytesTotal, elemSize, bytesTotal ,stream );
|
||||
fclose( stream );
|
||||
|
||||
//Did we read enough bytes (Get the bytes if we read with ANSI since the hidden characters is ignored)
|
||||
if(!readANSI && bytesRead != bytesTotal) return false;
|
||||
|
||||
buff[bytesRead + 1];
|
||||
|
||||
outData.clear();
|
||||
outData.resize(bytesRead);
|
||||
memcpy(&outData[0], &buff[0], bytesRead);
|
||||
|
||||
delete [] buff;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string msg = "Failed to open file: \n";
|
||||
msg.append(sFilename.c_str());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
OResource* OResource::ByteLoader(const wchar_t filename[], ResourceType type, OResource* old)
|
||||
{
|
||||
OResource *resource = old;
|
||||
std::wstring wOut;
|
||||
std::string sOut;
|
||||
bool success = false;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case Oyster::Resource::ResourceType_Byte_Raw:
|
||||
success = ReadFromFile(filename, "rb", sOut, sizeof(char));
|
||||
break;
|
||||
|
||||
case Oyster::Resource::ResourceType_Byte_ANSI:
|
||||
readANSI = true;
|
||||
success = ReadFromFile(filename, "r", sOut, sizeof(char));
|
||||
readANSI = false;
|
||||
break;
|
||||
|
||||
case Oyster::Resource::ResourceType_Byte_UTF8:
|
||||
success = ReadFromFile(filename, "r, ccs=UTF-8", sOut, sizeof(char));
|
||||
break;
|
||||
|
||||
case Oyster::Resource::ResourceType_Byte_UNICODE:
|
||||
success = ReadFromFile(filename, "r, ccs=UNICODE", sOut, sizeof(char));
|
||||
break;
|
||||
|
||||
case Oyster::Resource::ResourceType_Byte_UTF16LE:
|
||||
success = ReadFromFile(filename, "r, ccs=UTF-16LE", sOut, sizeof(char));
|
||||
break;
|
||||
}
|
||||
|
||||
if(!success) return 0;
|
||||
if(wOut.size())
|
||||
{
|
||||
//const wchar_t *data = new wchar_t[wOut.size()];
|
||||
//resource = new OResource((void*)data, type, (sizeof(wchar_t) * wOut.size()), sizeof(wchar_t), filename);
|
||||
}
|
||||
else if(sOut.size())
|
||||
{
|
||||
char *data = new char[sOut.size()+1];
|
||||
data[sOut.size()] = '\0';
|
||||
memcpy(&data[0], &sOut[0], sOut.size());
|
||||
|
||||
if(!old)
|
||||
{
|
||||
resource = new OResource((OHRESOURCE)data, type, (sizeof(char) * sOut.size()), sizeof(char), filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
old->resourceData = (OHRESOURCE)data;
|
||||
}
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
|
||||
void OResource::ByteUnloader()
|
||||
{
|
||||
delete [] ((char*)this->resourceData);
|
||||
this->resourceData = 0;
|
||||
}
|
||||
|
||||
OResource* OResource::ByteReloader()
|
||||
{
|
||||
ByteUnloader();
|
||||
return ByteLoader(this->resourceFilename.c_str(), this->resourceType, this);
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "..\OResource.h"
|
||||
#include "..\..\Utilities.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
using namespace Oyster::Resource;
|
||||
|
||||
|
||||
OResource* OResource::CustomLoader(const wchar_t filename[], CustomLoadFunction fnc)
|
||||
{
|
||||
const CustomData &data = fnc(filename);
|
||||
|
||||
if(!data.loadedData) return 0;
|
||||
if(!data.resourceUnloadFnc) return 0;
|
||||
|
||||
OResource *resource = new OResource((OHRESOURCE)data.loadedData, ResourceType_UNKNOWN, 0, 0, filename);
|
||||
|
||||
resource->customData = new CustomResourceData();
|
||||
resource->customData->unloadingFunction = data.resourceUnloadFnc;
|
||||
resource->resourceData = (OHRESOURCE)data.loadedData;
|
||||
resource->customData->loadingFunction = fnc;
|
||||
|
||||
return resource;
|
||||
}
|
||||
void OResource::CustomUnloader()
|
||||
{
|
||||
this->customData->unloadingFunction((void*)this->resourceData);
|
||||
}
|
||||
OResource* OResource::CustomReloader()
|
||||
{
|
||||
CustomUnloader();
|
||||
|
||||
const CustomData &data = this->customData->loadingFunction(this->resourceFilename.c_str());
|
||||
this->resourceData = (OHRESOURCE)data.loadedData;
|
||||
|
||||
if(data.resourceUnloadFnc)
|
||||
this->customData->unloadingFunction = data.resourceUnloadFnc;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "OResource.h"
|
||||
|
||||
using namespace Oyster::Resource;
|
||||
|
||||
OResource::OResource(OHRESOURCE handle, ResourceType type, size_t resourceSize, size_t elementSize, ::std::wstring filename)
|
||||
: resourceData (handle)
|
||||
, resourceFilename (filename)
|
||||
, resourceSize (resourceSize)
|
||||
, resourceElementSize (elementSize)
|
||||
, resourceType (type)
|
||||
, customData (0)
|
||||
{
|
||||
|
||||
}
|
||||
OResource::~OResource()
|
||||
{}
|
||||
|
||||
|
||||
OResource* OResource::Load (const wchar_t filename[], ResourceType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case Oyster::Resource::ResourceType_Byte_Raw:
|
||||
case Oyster::Resource::ResourceType_Byte_ANSI:
|
||||
case Oyster::Resource::ResourceType_Byte_UTF8:
|
||||
case Oyster::Resource::ResourceType_Byte_UNICODE:
|
||||
case Oyster::Resource::ResourceType_Byte_UTF16LE:
|
||||
return OResource::ByteLoader(filename, type);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
OResource* OResource::Load (const wchar_t filename[], CustomLoadFunction loadFnc)
|
||||
{
|
||||
return OResource::CustomLoader(filename, loadFnc);
|
||||
}
|
||||
OResource* OResource::Reload (OResource* resource)
|
||||
{
|
||||
if(!resource) return 0;
|
||||
|
||||
switch (resource->resourceType)
|
||||
{
|
||||
case Oyster::Resource::ResourceType_Byte_Raw:
|
||||
case Oyster::Resource::ResourceType_Byte_ANSI:
|
||||
case Oyster::Resource::ResourceType_Byte_UTF8:
|
||||
case Oyster::Resource::ResourceType_Byte_UNICODE:
|
||||
case Oyster::Resource::ResourceType_Byte_UTF16LE:
|
||||
resource->ByteReloader();
|
||||
break;
|
||||
|
||||
case Oyster::Resource::ResourceType_UNKNOWN:
|
||||
resource->CustomReloader();
|
||||
break;
|
||||
}
|
||||
|
||||
return resource;
|
||||
}
|
||||
bool OResource::Release (OResource* resource)
|
||||
{
|
||||
if(resource->resourceRef.Decref() == 0)
|
||||
{
|
||||
switch (resource->resourceType)
|
||||
{
|
||||
case Oyster::Resource::ResourceType_Byte_Raw:
|
||||
case Oyster::Resource::ResourceType_Byte_ANSI:
|
||||
case Oyster::Resource::ResourceType_Byte_UTF8:
|
||||
case Oyster::Resource::ResourceType_Byte_UNICODE:
|
||||
case Oyster::Resource::ResourceType_Byte_UTF16LE:
|
||||
resource->ByteUnloader();
|
||||
break;
|
||||
|
||||
case Oyster::Resource::ResourceType_UNKNOWN:
|
||||
resource->CustomUnloader();
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef MISC_O_RESOURCE_H
|
||||
#define MISC_O_RESOURCE_H
|
||||
|
||||
#include "..\Utilities.h"
|
||||
#include "OysterResource.h"
|
||||
#include <string>
|
||||
|
||||
namespace Oyster
|
||||
{
|
||||
namespace Resource
|
||||
{
|
||||
class OResource
|
||||
{
|
||||
public:
|
||||
struct CustomResourceData
|
||||
{
|
||||
CustomLoadFunction loadingFunction;
|
||||
CustomUnloadFunction unloadingFunction;
|
||||
};
|
||||
|
||||
public:
|
||||
OResource(OHRESOURCE handle, ResourceType type, size_t size, size_t elementSize, ::std::wstring resourceFilename);
|
||||
virtual~ OResource();
|
||||
|
||||
inline ResourceType GetResourceType() const
|
||||
{ return this->resourceType; }
|
||||
inline const wchar_t* GetResourceFilename() const
|
||||
{ return this->resourceFilename.c_str(); }
|
||||
inline OHRESOURCE GetResourceHandle() const
|
||||
{ return this->resourceData; }
|
||||
inline unsigned long long GetResourceSize() const
|
||||
{ return this->resourceSize; }
|
||||
inline unsigned long long GetResourceElementSize() const
|
||||
{ return this->resourceElementSize; }
|
||||
inline unsigned int GetResourceID() const
|
||||
{ return this->resourceID; }
|
||||
inline void SetResourceID(unsigned int id)
|
||||
{ this->resourceID = id; }
|
||||
|
||||
public:
|
||||
static OResource* Load (const wchar_t filename[], ResourceType type);
|
||||
static OResource* Load (const wchar_t filename[], CustomLoadFunction loadFnc);
|
||||
static OResource* Reload (OResource* resource);
|
||||
static bool Release (OResource* resource);
|
||||
|
||||
Utility::DynamicMemory::ReferenceCount resourceRef;
|
||||
|
||||
private:
|
||||
static OResource* ByteLoader (const wchar_t filename[], ResourceType type, OResource* old = 0);
|
||||
void ByteUnloader ();
|
||||
OResource* ByteReloader ();
|
||||
|
||||
static OResource* CustomLoader (const wchar_t filename[], CustomLoadFunction loadFnc);
|
||||
void CustomUnloader ();
|
||||
OResource* CustomReloader ();
|
||||
|
||||
OHRESOURCE resourceData;
|
||||
ResourceType resourceType;
|
||||
size_t resourceSize;
|
||||
size_t resourceElementSize;
|
||||
::std::wstring resourceFilename;
|
||||
unsigned int resourceID;
|
||||
|
||||
CustomResourceData *customData;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,180 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "OysterResource.h"
|
||||
#include "OResource.h"
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
using namespace Oyster::Resource;
|
||||
|
||||
class ResourcePrivate
|
||||
{
|
||||
public:
|
||||
|
||||
std::map<std::wstring, OResource*> resources;
|
||||
|
||||
OResource* FindResource(const OHRESOURCE& h) const;
|
||||
OResource* FindResource(const wchar_t c[]) const;
|
||||
void SaveResource(OResource* r, bool addNew = true);
|
||||
|
||||
} resourcePrivate;
|
||||
|
||||
|
||||
OHRESOURCE OysterResource::LoadResource(const wchar_t* filename, ResourceType type)
|
||||
{
|
||||
if(!filename) return 0;
|
||||
|
||||
OResource *resourceData = resourcePrivate.FindResource(filename);
|
||||
if(resourceData)
|
||||
{
|
||||
//Add new reference
|
||||
resourcePrivate.SaveResource(resourceData, false);
|
||||
return resourceData->GetResourceHandle();
|
||||
}
|
||||
|
||||
resourceData = OResource::Load(filename, type);
|
||||
|
||||
if(!resourceData) return 0;
|
||||
|
||||
resourcePrivate.SaveResource(resourceData);
|
||||
|
||||
return resourceData->GetResourceHandle();
|
||||
}
|
||||
OHRESOURCE OysterResource::LoadResource(const wchar_t filename[], CustomLoadFunction loadFnc, unsigned int CustomId)
|
||||
{
|
||||
if(!filename) return 0;
|
||||
if(!loadFnc) return 0;
|
||||
|
||||
OResource *resourceData = resourcePrivate.FindResource(filename);
|
||||
if(resourceData)
|
||||
{
|
||||
//Add new reference
|
||||
resourcePrivate.SaveResource(resourceData, false);
|
||||
return resourceData->GetResourceHandle();
|
||||
}
|
||||
|
||||
resourceData = OResource::Load(filename, loadFnc);
|
||||
|
||||
if(!resourceData) return 0;
|
||||
|
||||
resourceData->SetResourceID(CustomId);
|
||||
|
||||
resourcePrivate.SaveResource(resourceData);
|
||||
|
||||
return (OHRESOURCE)resourceData->GetResourceHandle();
|
||||
}
|
||||
|
||||
OHRESOURCE ReloadResource(const wchar_t filename[])
|
||||
{
|
||||
OResource *resourceData = resourcePrivate.FindResource(filename);
|
||||
if(!resourceData) return 0; //The resource has not been loaded
|
||||
|
||||
return OResource::Reload(resourceData)->GetResourceHandle();
|
||||
}
|
||||
OHRESOURCE ReloadResource(OHRESOURCE resource)
|
||||
{
|
||||
OResource *resourceData = resourcePrivate.FindResource(resource);
|
||||
if(!resourceData) return 0; //The resource has not been loaded
|
||||
|
||||
return OResource::Reload(resourceData)->GetResourceHandle();
|
||||
}
|
||||
|
||||
void OysterResource::Clean()
|
||||
{
|
||||
auto i = resourcePrivate.resources.begin();
|
||||
auto last = resourcePrivate.resources.end();
|
||||
|
||||
for (i; i != last; i++)
|
||||
{
|
||||
if(OResource::Release(i->second))
|
||||
{
|
||||
const wchar_t* temp = i->second->GetResourceFilename();
|
||||
delete resourcePrivate.resources[temp];
|
||||
resourcePrivate.resources.erase(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
void OysterResource::ReleaseResource(const OHRESOURCE& resourceData)
|
||||
{
|
||||
OResource* t = resourcePrivate.FindResource(resourceData);
|
||||
if(t)
|
||||
{
|
||||
if(OResource::Release(t))
|
||||
{
|
||||
const wchar_t* temp = t->GetResourceFilename();
|
||||
delete resourcePrivate.resources[temp];
|
||||
resourcePrivate.resources.erase(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OysterResource::SetResourceId (const OHRESOURCE& resourceData, unsigned int id)
|
||||
{
|
||||
OResource* t = resourcePrivate.FindResource(resourceData);
|
||||
|
||||
if(t) t->SetResourceID(id);
|
||||
}
|
||||
ResourceType OysterResource::GetResourceType (const OHRESOURCE& resourceData)
|
||||
{
|
||||
OResource* t = resourcePrivate.FindResource(resourceData);
|
||||
|
||||
if(t) return t->GetResourceType();
|
||||
|
||||
return ResourceType_UNKNOWN;
|
||||
}
|
||||
const wchar_t* OysterResource::GetResourceFilename (const OHRESOURCE& resourceData)
|
||||
{
|
||||
OResource* t = resourcePrivate.FindResource(resourceData);
|
||||
|
||||
if(t) return t->GetResourceFilename();
|
||||
|
||||
return 0;
|
||||
}
|
||||
unsigned int OysterResource::GetResourceId (const OHRESOURCE& resourceData)
|
||||
{
|
||||
OResource* t = resourcePrivate.FindResource(resourceData);
|
||||
|
||||
if(t) return t->GetResourceID();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
OResource* ResourcePrivate::FindResource(const OHRESOURCE& h) const
|
||||
{
|
||||
for (auto i = this->resources.begin(); i != this->resources.end() ; i++)
|
||||
{
|
||||
if(i->second->GetResourceHandle() == h)
|
||||
{
|
||||
return i->second;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
OResource* ResourcePrivate::FindResource(const wchar_t c[]) const
|
||||
{
|
||||
std::wstring temp = c;
|
||||
auto t = this->resources.find(c);
|
||||
if(t == this->resources.end()) return 0;
|
||||
|
||||
return t->second;
|
||||
}
|
||||
void ResourcePrivate::SaveResource( OResource* r, bool addNew )
|
||||
{
|
||||
if(!r) return;
|
||||
|
||||
if(addNew)
|
||||
{
|
||||
this->resources[r->GetResourceFilename()] = r;
|
||||
}
|
||||
|
||||
r->resourceRef.Incref();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef MISC_OYSTER_RESOURCE_H
|
||||
#define MISC_OYSTER_RESOURCE_H
|
||||
|
||||
|
||||
namespace Oyster
|
||||
{
|
||||
namespace Resource
|
||||
{
|
||||
struct CustomData;
|
||||
/** A Resource handle representing various resources */
|
||||
typedef unsigned long OHRESOURCE;
|
||||
/** Typedef on a fuction required for custom unloading */
|
||||
typedef void(*CustomUnloadFunction)(void* loadedData);
|
||||
/** Typedef on a fuction required for custom loading */
|
||||
typedef const CustomData&(*CustomLoadFunction)(const wchar_t filename[]);
|
||||
|
||||
/** An enum class representing all avalible resources that is supported. */
|
||||
enum ResourceType
|
||||
{
|
||||
//Byte
|
||||
ResourceType_Byte_Raw, /**< Handle can be interpeted as char[] or char* */
|
||||
ResourceType_Byte_ANSI, /**< Handle can be interpeted as char[] or char* */
|
||||
ResourceType_Byte_UTF8, /**< Handle can be interpeted as char[] or char* */
|
||||
ResourceType_Byte_UNICODE, /**< Handle can be interpeted as char[] or char* */
|
||||
ResourceType_Byte_UTF16LE, /**< Handle can be interpeted as char[] or char* */
|
||||
|
||||
ResourceType_COUNT, /**< Not used. */
|
||||
|
||||
ResourceType_UNKNOWN = -1, /**< Handle can be interpeted as void* */
|
||||
};
|
||||
|
||||
/** A struct to return when doing a custom resource Load
|
||||
* By loading this way you are handing over the ownership to the resource loaded.
|
||||
*/
|
||||
struct CustomData
|
||||
{
|
||||
void* loadedData; ///<! The loaded resource interpeted as a void*.
|
||||
CustomUnloadFunction resourceUnloadFnc; ///<! The function that will be used to free the resource when needed.
|
||||
};
|
||||
|
||||
/** A resource handler interface to interact with when loading resources.
|
||||
* The resource handler uses the filename to make resources unuiqe.
|
||||
*/
|
||||
class OysterResource
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Load a resource given a type.
|
||||
* @param filename The path to the resource.
|
||||
* @param type The resource type to load.
|
||||
* @param force If set to true, the resource will be reloaded if it already exists. If it does not, nothing happens.
|
||||
* @return If function suceeds, a handle to the resource will be returned. If failed 0 is returned.
|
||||
*/
|
||||
static OHRESOURCE LoadResource(const wchar_t filename[], ResourceType type);
|
||||
|
||||
/**
|
||||
* Load a resource with a custom loading function
|
||||
* @param filename The path to the resource.
|
||||
* @param force If set to true, the resource will be reloaded even if exists.
|
||||
* @param loadFnc If set, this gives you the right to do custom resource loading if your recource type is not supported.
|
||||
* @return If function suceeds, a handle to the resource will be returned. If failed 0 is returned.
|
||||
*/
|
||||
static OHRESOURCE LoadResource(const wchar_t filename[], CustomLoadFunction loadFnc = 0, unsigned int CustomId = 0);
|
||||
|
||||
/**
|
||||
* Reload a resource
|
||||
* @param filename The path to the resource.
|
||||
* @return If function suceeds, a handle to the resource will be returned. If failed 0 is returned.
|
||||
*/
|
||||
static OHRESOURCE ReloadResource(const wchar_t filename[]);
|
||||
|
||||
/**
|
||||
* Reload a resource
|
||||
* @param filename The path to the resource.
|
||||
* @return If function suceeds, a handle to the resource will be returned. If failed 0 is returned.
|
||||
*/
|
||||
static OHRESOURCE ReloadResource(OHRESOURCE resource);
|
||||
|
||||
/**
|
||||
* Releases all resources loaded by the resource handler.
|
||||
* @return Nothing
|
||||
*/
|
||||
static void Clean();
|
||||
|
||||
/**
|
||||
* Release a reference to the resource handle
|
||||
* @param resource The handle to release.
|
||||
* @return Nothing
|
||||
*/
|
||||
static void ReleaseResource(const OHRESOURCE& resource);
|
||||
|
||||
/** Set a user defined ID
|
||||
* @param resource A handle to accociate the id with.
|
||||
* @param id A user defined identifier that the resource handler does not touch.
|
||||
*/
|
||||
static void SetResourceId(const OHRESOURCE& resource, unsigned int id);
|
||||
|
||||
/** Get a resource type given a OHRESOURCE handle
|
||||
* @param resource The handle to check
|
||||
* @return Returns the resource type of the handle
|
||||
*/
|
||||
static ResourceType GetResourceType(const OHRESOURCE& resource);
|
||||
|
||||
/** Get a resource filename given a OHRESOURCE handle
|
||||
* @param resource The handle to check
|
||||
* @return Returns the accociated filename
|
||||
*/
|
||||
static const wchar_t* GetResourceFilename(const OHRESOURCE& resource);
|
||||
|
||||
/** Get a user defined ID accociated with a handle
|
||||
* @param resource The handle to check
|
||||
* @return Returns the accociated ID
|
||||
*/
|
||||
static unsigned int GetResourceId(const OHRESOURCE& resource);
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,37 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef MISC_I_THREAD_OBJECT_H
|
||||
#define MISC_I_THREAD_OBJECT_H
|
||||
|
||||
|
||||
|
||||
namespace Oyster
|
||||
{
|
||||
namespace Thread
|
||||
{
|
||||
/**
|
||||
* Inherit this class to get threading compatibility.
|
||||
*/
|
||||
class IThreadObject
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Override this to get notified when the thread is started.
|
||||
*/
|
||||
virtual void ThreadEntry() { }
|
||||
/**
|
||||
* Override this to get notified when the thread is about to exit.
|
||||
*/
|
||||
virtual void ThreadExit() { }
|
||||
/**
|
||||
* This function is required to get threading working.
|
||||
*/
|
||||
virtual bool DoWork ( ) = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !MISC_I_THREAD_OBJECT_H
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "OysterMutex.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <future>
|
||||
|
||||
|
||||
|
||||
OysterMutex::OysterMutex()
|
||||
{}
|
||||
|
||||
OysterMutex::OysterMutex(bool initialOwnership)
|
||||
{
|
||||
if(initialOwnership)
|
||||
{
|
||||
this->mutex.lock();
|
||||
this->id = std::this_thread::get_id();
|
||||
}
|
||||
}
|
||||
OysterMutex::~OysterMutex()
|
||||
{
|
||||
}
|
||||
void OysterMutex::LockMutex()
|
||||
{
|
||||
if(std::this_thread::get_id() == this->id) return;
|
||||
|
||||
this->mutex.lock();
|
||||
|
||||
this->id = std::this_thread::get_id();
|
||||
}
|
||||
void OysterMutex::LockMutex(unsigned int msec)
|
||||
{
|
||||
if(std::this_thread::get_id() == this->id) return;
|
||||
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
auto end = start + std::chrono::milliseconds(msec);
|
||||
|
||||
do
|
||||
{
|
||||
if(this->mutex.try_lock())
|
||||
{
|
||||
this->mutex.lock();
|
||||
this->id = std::this_thread::get_id();
|
||||
return;
|
||||
}
|
||||
} while (std::chrono::high_resolution_clock::now() < end);
|
||||
|
||||
this->mutex.lock();
|
||||
}
|
||||
void OysterMutex::UnlockMutex()
|
||||
{
|
||||
//Let the owner unlock
|
||||
if(std::this_thread::get_id() != this->id) return;
|
||||
|
||||
this->mutex.unlock();
|
||||
this->id = std::thread::id();
|
||||
|
||||
}
|
||||
bool OysterMutex::IsTaken()
|
||||
{
|
||||
return !this->mutex.try_lock();
|
||||
}
|
||||
void OysterMutex::Reset()
|
||||
{
|
||||
if(!this->mutex.try_lock())
|
||||
this->mutex.unlock();
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef MISC_OYSTER_MUTEX_H
|
||||
#define MISC_OYSTER_MUTEX_H
|
||||
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
|
||||
class OysterMutex
|
||||
{
|
||||
public:
|
||||
OysterMutex();
|
||||
OysterMutex(bool initialOwnership);
|
||||
virtual~OysterMutex();
|
||||
void LockMutex();
|
||||
void LockMutex(unsigned int timeSpan);
|
||||
void UnlockMutex();
|
||||
/** Returns true if mutex is taken */
|
||||
bool IsTaken();
|
||||
/** This function resets resource locking */
|
||||
void Reset();
|
||||
|
||||
private:
|
||||
std::mutex mutex;
|
||||
std::thread::id id;
|
||||
|
||||
OysterMutex(const OysterMutex&);
|
||||
};
|
||||
|
||||
#endif // !MISC_OYSTER_MUTEX_H
|
|
@ -0,0 +1,49 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef MISC_OYSTER_THREAD_H
|
||||
#define MISC_OYSTER_THREAD_H
|
||||
|
||||
#include "IThreadObject.h"
|
||||
|
||||
namespace Oyster
|
||||
{
|
||||
namespace Thread
|
||||
{
|
||||
enum OYSTER_THREAD_ERROR
|
||||
{
|
||||
OYSTER_THREAD_ERROR_FAILED,
|
||||
OYSTER_THREAD_ERROR_SUCCESS,
|
||||
};
|
||||
|
||||
class OysterThread
|
||||
{
|
||||
private:
|
||||
struct PrivateData;
|
||||
PrivateData *privateData;
|
||||
|
||||
OysterThread(const OysterThread& original);
|
||||
const OysterThread& operator=(const OysterThread& original);
|
||||
|
||||
public:
|
||||
OysterThread();
|
||||
virtual~OysterThread();
|
||||
|
||||
OYSTER_THREAD_ERROR Create(IThreadObject* worker, bool start);
|
||||
OYSTER_THREAD_ERROR Start();
|
||||
void Stop();
|
||||
void Pause();
|
||||
void Pause(int mSec);
|
||||
void Resume();
|
||||
OYSTER_THREAD_ERROR Reset(IThreadObject* worker = 0);
|
||||
void Terminate();
|
||||
void Wait();
|
||||
void Wait(int mSec);
|
||||
OYSTER_THREAD_ERROR Swap(const OysterThread* other);
|
||||
bool IsActive();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !MISC_OYSTER_THREAD_H
|
|
@ -0,0 +1,253 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "OysterThread.h"
|
||||
#include "OysterMutex.h"
|
||||
#include "..\Utilities.h"
|
||||
#include <thread>
|
||||
#include <assert.h>
|
||||
|
||||
using namespace Oyster::Thread;
|
||||
using namespace Utility::DynamicMemory::SmartPointer;
|
||||
|
||||
|
||||
#pragma region Declerations
|
||||
|
||||
struct ThreadData;
|
||||
/** A typical Oyster thread function */
|
||||
typedef void (*ThreadFunction)(StdSmartPointer<ThreadData>&);
|
||||
|
||||
enum OYSTER_THREAD_STATE
|
||||
{
|
||||
OYSTER_THREAD_STATE_RESET,
|
||||
OYSTER_THREAD_STATE_RUNNING,
|
||||
OYSTER_THREAD_STATE_PAUSED,
|
||||
OYSTER_THREAD_STATE_STOPED,
|
||||
OYSTER_THREAD_STATE_TERMINATED,
|
||||
OYSTER_THREAD_STATE_DEAD,
|
||||
};
|
||||
|
||||
//TODO: Add a threadStartPackage struct that contains all the necasary data to fire of a thread
|
||||
struct ThreadData
|
||||
{
|
||||
OYSTER_THREAD_STATE state; //<! The current thread state.
|
||||
StdSmartPointer<std::thread> workerThread; //<! The worker thread.
|
||||
std::thread::id callingThread; //<! The owner thread.
|
||||
IThreadObject *owner; //<! The owner of the thread as IThread.
|
||||
int msec; //<! A timer in miliseconds.
|
||||
OysterMutex mutexLock; //<! The lock, locking the member variabls.
|
||||
|
||||
ThreadData() {}
|
||||
|
||||
private:
|
||||
ThreadData(const ThreadData&){};
|
||||
};
|
||||
struct OysterThread::PrivateData
|
||||
{
|
||||
StdSmartPointer<ThreadData> threadData;
|
||||
|
||||
PrivateData()
|
||||
:threadData(new ThreadData())
|
||||
{
|
||||
threadData->owner = 0;
|
||||
threadData->workerThread = 0;
|
||||
threadData->callingThread;
|
||||
threadData->state = OYSTER_THREAD_STATE_STOPED;
|
||||
}
|
||||
~PrivateData()
|
||||
{
|
||||
//@todo TODO: Make detatch avalible.
|
||||
//this->threadData->workerThread->detach();
|
||||
|
||||
this->threadData->owner = 0;
|
||||
|
||||
this->threadData->state = OYSTER_THREAD_STATE_DEAD;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
|
||||
static void ThreadingFunction(StdSmartPointer<ThreadData> &origin)
|
||||
{
|
||||
bool shouldContinue;
|
||||
StdSmartPointer<ThreadData> w = origin;
|
||||
|
||||
theBegining:
|
||||
|
||||
while(w->state == OYSTER_THREAD_STATE_STOPED);
|
||||
w->mutexLock.LockMutex();
|
||||
w->owner->ThreadEntry();
|
||||
w->mutexLock.UnlockMutex();
|
||||
|
||||
while (w->state != OYSTER_THREAD_STATE_STOPED && w->state != OYSTER_THREAD_STATE_DEAD)
|
||||
{
|
||||
|
||||
w->mutexLock.LockMutex();
|
||||
{
|
||||
shouldContinue = w->owner->DoWork();
|
||||
}
|
||||
w->mutexLock.UnlockMutex();
|
||||
|
||||
if(!shouldContinue)
|
||||
{
|
||||
goto theEnd;
|
||||
}
|
||||
if(w->state == OYSTER_THREAD_STATE_TERMINATED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if(w->state == OYSTER_THREAD_STATE_RESET)
|
||||
{
|
||||
goto theBegining;
|
||||
}
|
||||
else if(w->msec > 0)
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(w->msec));
|
||||
}
|
||||
|
||||
while (w->state == OYSTER_THREAD_STATE_PAUSED);
|
||||
}
|
||||
|
||||
if(w->state == OYSTER_THREAD_STATE_DEAD)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
theEnd:
|
||||
|
||||
w->mutexLock.LockMutex();
|
||||
w->owner->ThreadExit();
|
||||
w->mutexLock.UnlockMutex();
|
||||
|
||||
w->state = OYSTER_THREAD_STATE_DEAD;
|
||||
}
|
||||
|
||||
OysterThread::OysterThread()
|
||||
{
|
||||
this->privateData = new PrivateData();
|
||||
}
|
||||
OysterThread::~OysterThread()
|
||||
{
|
||||
delete this->privateData;
|
||||
this->privateData = 0;
|
||||
}
|
||||
|
||||
OYSTER_THREAD_ERROR OysterThread::Create(IThreadObject* worker, bool start)
|
||||
{
|
||||
if(!this->privateData) return OYSTER_THREAD_ERROR_FAILED;
|
||||
if(this->privateData->threadData->workerThread) return OYSTER_THREAD_ERROR_FAILED;
|
||||
|
||||
this->privateData->threadData->owner = worker;
|
||||
|
||||
ThreadFunction fnc = ThreadingFunction;
|
||||
|
||||
//Maby move this thread creation to a seperate Start() function because std::thread fires the thread when it is created. :(
|
||||
this->privateData->threadData->workerThread = new std::thread(fnc, this->privateData->threadData);
|
||||
|
||||
if(!this->privateData->threadData->workerThread)
|
||||
return OYSTER_THREAD_ERROR_FAILED;
|
||||
|
||||
if(start)
|
||||
{
|
||||
//@todo TODO: No need to lock since the other thread end is only reading this value. Worst case scenario is n lost cycles.
|
||||
this->privateData->threadData->state = OYSTER_THREAD_STATE_RUNNING;
|
||||
}
|
||||
return OYSTER_THREAD_ERROR_SUCCESS;
|
||||
}
|
||||
OYSTER_THREAD_ERROR OysterThread::Start()
|
||||
{
|
||||
if(!this->privateData->threadData->workerThread)
|
||||
return OYSTER_THREAD_ERROR_FAILED;
|
||||
|
||||
this->privateData->threadData->state = OYSTER_THREAD_STATE_RUNNING;
|
||||
return OYSTER_THREAD_ERROR_SUCCESS;
|
||||
}
|
||||
void OysterThread::Stop()
|
||||
{
|
||||
this->privateData->threadData->mutexLock.LockMutex();
|
||||
this->privateData->threadData->state = OYSTER_THREAD_STATE_STOPED;
|
||||
this->privateData->threadData->mutexLock.UnlockMutex();
|
||||
}
|
||||
void OysterThread::Pause()
|
||||
{
|
||||
this->privateData->threadData->mutexLock.LockMutex();
|
||||
this->privateData->threadData->state = OYSTER_THREAD_STATE_PAUSED;
|
||||
this->privateData->threadData->mutexLock.UnlockMutex();
|
||||
}
|
||||
void OysterThread::Pause(int msec)
|
||||
{
|
||||
|
||||
if(std::this_thread::get_id() == this->privateData->threadData->workerThread->get_id())
|
||||
{
|
||||
this->privateData->threadData->msec = msec;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->privateData->threadData->mutexLock.LockMutex();
|
||||
this->privateData->threadData->state = OYSTER_THREAD_STATE_PAUSED;
|
||||
this->privateData->threadData->msec = msec;
|
||||
this->privateData->threadData->mutexLock.UnlockMutex();
|
||||
}
|
||||
}
|
||||
void OysterThread::Resume()
|
||||
{
|
||||
this->privateData->threadData->mutexLock.LockMutex();
|
||||
this->privateData->threadData->state = OYSTER_THREAD_STATE_RUNNING;
|
||||
this->privateData->threadData->mutexLock.UnlockMutex();
|
||||
}
|
||||
OYSTER_THREAD_ERROR OysterThread::Reset(IThreadObject* worker)
|
||||
{
|
||||
this->privateData->threadData->mutexLock.LockMutex();
|
||||
if(worker)
|
||||
{
|
||||
this->privateData->threadData->owner = worker;
|
||||
}
|
||||
this->privateData->threadData->callingThread = std::this_thread::get_id();
|
||||
this->privateData->threadData->msec = 0;
|
||||
this->privateData->threadData->mutexLock.UnlockMutex();
|
||||
|
||||
return OYSTER_THREAD_ERROR_SUCCESS;
|
||||
}
|
||||
void OysterThread::Terminate()
|
||||
{
|
||||
delete this->privateData->threadData->workerThread;
|
||||
this->privateData->threadData->mutexLock.Reset();
|
||||
this->privateData->threadData->workerThread = 0;
|
||||
this->privateData->threadData->callingThread = std::thread::id();
|
||||
this->privateData->threadData->msec = 0;
|
||||
this->privateData->threadData->state = OYSTER_THREAD_STATE_STOPED;
|
||||
}
|
||||
void OysterThread::Wait()
|
||||
{
|
||||
if(this->privateData->threadData->state == OYSTER_THREAD_STATE_DEAD)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(this->privateData->threadData->workerThread->get_id() == std::this_thread::get_id()) return;
|
||||
|
||||
this->privateData->threadData->workerThread->join();
|
||||
}
|
||||
void OysterThread::Wait(int msec)
|
||||
{
|
||||
if(this->privateData->threadData->workerThread->get_id() == std::this_thread::get_id()) return;
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(msec));
|
||||
}
|
||||
OYSTER_THREAD_ERROR OysterThread::Swap(const OysterThread* other)
|
||||
{
|
||||
this->privateData->threadData->workerThread->swap(*other->privateData->threadData->workerThread);
|
||||
return OYSTER_THREAD_ERROR_SUCCESS;
|
||||
}
|
||||
bool OysterThread::IsActive()
|
||||
{
|
||||
if (this->privateData->threadData->state == OYSTER_THREAD_STATE_RUNNING)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
// Inline and template implementations for
|
||||
// the Utility Collection of Miscellanious Handy Functions
|
||||
// © Dan Andersson 2013
|
||||
// © Dennis Andersen 2013 TODO: Is this correct?
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef UTILITIES_INLINE_IMPL_H
|
||||
|
@ -149,8 +150,7 @@ namespace Utility
|
|||
return this->ownedArray != NULL;
|
||||
}
|
||||
|
||||
template<typename Type>
|
||||
Type* UniqueArray<Type>::Release()
|
||||
template<typename Type>Type* UniqueArray<Type>::Release()
|
||||
{
|
||||
Type *copy = this->ownedArray;
|
||||
this->ownedArray = NULL;
|
||||
|
@ -162,6 +162,113 @@ namespace Utility
|
|||
{
|
||||
return this->operator bool();
|
||||
}
|
||||
|
||||
namespace SmartPointer
|
||||
{
|
||||
template<typename T>
|
||||
void StdSmartPointer<T>::Destroy()
|
||||
{
|
||||
delete this->_rc;
|
||||
this->_rc = NULL;
|
||||
delete this->_ptr;
|
||||
this->_ptr = NULL;
|
||||
}
|
||||
template<typename T> StdSmartPointer<T>::StdSmartPointer()
|
||||
:_rc(0), _ptr(0)
|
||||
{ }
|
||||
template<typename T> StdSmartPointer<T>::StdSmartPointer(T* p)
|
||||
:_ptr(p)
|
||||
{
|
||||
this->_rc = new ReferenceCount();
|
||||
this->_rc->Incref();
|
||||
}
|
||||
template<typename T> StdSmartPointer<T>::StdSmartPointer(const StdSmartPointer& d)
|
||||
:_ptr(d._ptr), _rc(d._rc)
|
||||
{
|
||||
if(this->_rc)
|
||||
this->_rc->Incref();
|
||||
}
|
||||
template<typename T> StdSmartPointer<T>::~StdSmartPointer()
|
||||
{
|
||||
if (this->_rc && this->_rc->Decref() == 0)
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
}
|
||||
template<typename T> StdSmartPointer<T>& StdSmartPointer<T>::operator= (const StdSmartPointer<T>& p)
|
||||
{
|
||||
if (this != &p)
|
||||
{
|
||||
//Last to go?
|
||||
if(this->_rc && this->_rc->Release() == 0)
|
||||
{
|
||||
//Call child specific
|
||||
Destroy();
|
||||
}
|
||||
|
||||
this->_ptr = p._ptr;
|
||||
this->_rc = p._rc;
|
||||
this->_rc->Add();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
template<typename T> StdSmartPointer<T>& StdSmartPointer<T>::operator= (T* p)
|
||||
{
|
||||
if (this->_ptr != p)
|
||||
{
|
||||
//Last to go?
|
||||
if(this->_rc)
|
||||
{
|
||||
if(this->_rc->Decref() == 0)
|
||||
{
|
||||
//Call child specific
|
||||
Destroy();
|
||||
this->_rc = new ReferenceCount();
|
||||
}
|
||||
}
|
||||
else
|
||||
this->_rc = new ReferenceCount();
|
||||
|
||||
this->_ptr = p;
|
||||
this->_rc->Incref();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
template<typename T> inline bool StdSmartPointer<T>::operator== (const StdSmartPointer<T>& d)
|
||||
{
|
||||
return d._ptr == this->_ptr;
|
||||
}
|
||||
template<typename T> inline bool StdSmartPointer<T>::operator== (const T& p)
|
||||
{
|
||||
return &p == this->_ptr;
|
||||
}
|
||||
template<typename T> inline T& StdSmartPointer<T>::operator* ()
|
||||
{
|
||||
return *this->_ptr;
|
||||
}
|
||||
template<typename T> inline T* StdSmartPointer<T>::operator-> ()
|
||||
{
|
||||
return this->_ptr;
|
||||
}
|
||||
template<typename T> inline StdSmartPointer<T>::operator T* ()
|
||||
{
|
||||
return this->_ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the connected pointer */
|
||||
template<typename T> inline T* StdSmartPointer<T>::Get()
|
||||
{
|
||||
return this->_ptr;
|
||||
}
|
||||
|
||||
/** Checks if the pointer is valid (not NULL)
|
||||
Returns true for valid, else false. */
|
||||
template<typename T> inline bool StdSmartPointer<T>::IsValid()
|
||||
{
|
||||
return (this->_ptr != NULL) ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -281,6 +281,53 @@ namespace Utility
|
|||
return output;
|
||||
}
|
||||
|
||||
::std::wstring & wToLowerCase( ::std::wstring &output, const ::std::wstring &str )
|
||||
{
|
||||
int length = (int)str.length();
|
||||
output.resize( length );
|
||||
for( int i = 0; i < length; ++i )
|
||||
output[i] = ::std::tolower( str[i], ::std::locale() );
|
||||
return output;
|
||||
}
|
||||
|
||||
::std::wstring & wToLowerCase( ::std::wstring &str )
|
||||
{
|
||||
int length = (int)str.length();
|
||||
for( int i = 0; i < length; ++i )
|
||||
str[i] = ::std::tolower( str[i], ::std::locale() );
|
||||
return str;
|
||||
}
|
||||
|
||||
//To wstring
|
||||
|
||||
::std::wstring & StringToWString( const ::std::string &str, ::std::wstring &wstr )
|
||||
{
|
||||
const char *orig = str.c_str();
|
||||
|
||||
// Convert to a wchar_t*
|
||||
size_t origsize = strlen(orig) + 1;
|
||||
const size_t newsize = 255;
|
||||
size_t convertedChars = 0;
|
||||
wchar_t wcstring[newsize];
|
||||
mbstowcs_s(&convertedChars, wcstring, origsize, orig, _TRUNCATE);
|
||||
wstr = wcstring;
|
||||
//wcscat_s(wcstring, L" (wchar_t *)");
|
||||
return wstr;
|
||||
}
|
||||
|
||||
::std::string & WStringToString( const ::std::wstring &wstr, ::std::string &str )
|
||||
{
|
||||
const wchar_t* orig = wstr.c_str();
|
||||
// Convert to a char*
|
||||
size_t origsize = wcslen(orig) + 1;
|
||||
const size_t newsize = 255;
|
||||
size_t convertedChars = 0;
|
||||
char nstring[newsize];
|
||||
wcstombs_s(&convertedChars, nstring, origsize, orig, _TRUNCATE);
|
||||
str = nstring;
|
||||
//strcat_s(nstring, " (char *)");
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
// STREAM ////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Utility Collection of Miscellanious Handy Functions
|
||||
// © Dan Andersson 2013
|
||||
// © Dennis Andersen 2013
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef UTILITIES_H
|
||||
|
@ -105,6 +106,63 @@ namespace Utility
|
|||
private:
|
||||
mutable Type *ownedArray;
|
||||
};
|
||||
|
||||
struct ReferenceCount
|
||||
{
|
||||
private:
|
||||
int count;
|
||||
|
||||
public:
|
||||
ReferenceCount() :count(0) { }
|
||||
ReferenceCount(const ReferenceCount& o) { count = o.count; }
|
||||
inline const ReferenceCount& operator=(const ReferenceCount& o) { count = o.count; return *this;}
|
||||
inline void Incref() { this->count++; }
|
||||
inline void Incref(int c) { this->count += c; }
|
||||
inline int Decref() { return --this->count;}
|
||||
inline void Reset() { this->count = 0; }
|
||||
};
|
||||
|
||||
namespace SmartPointer
|
||||
{
|
||||
//! Smart pointer for a regular object.
|
||||
/**
|
||||
* Regular objects, objects that is deleted normaly (ie not COM objects, or array pointers)
|
||||
* can use this class to easy the use of dynamic memory
|
||||
*/
|
||||
template<typename T>
|
||||
struct StdSmartPointer
|
||||
{
|
||||
private:
|
||||
ReferenceCount *_rc;
|
||||
T *_ptr;
|
||||
|
||||
/** Destroys the pointer and returns the memory allocated. */
|
||||
void Destroy();
|
||||
|
||||
public:
|
||||
StdSmartPointer();
|
||||
StdSmartPointer(T* p);
|
||||
StdSmartPointer(const StdSmartPointer& d);
|
||||
virtual~StdSmartPointer();
|
||||
StdSmartPointer<T>& operator= (const StdSmartPointer<T>& p);
|
||||
StdSmartPointer<T>& operator= (T* p);
|
||||
bool operator== (const StdSmartPointer<T>& d);
|
||||
bool operator== (const T& p);
|
||||
T& operator* ();
|
||||
T* operator-> ();
|
||||
operator T* ();
|
||||
|
||||
/**
|
||||
* Returns the connected pointer */
|
||||
T* Get();
|
||||
|
||||
/** Checks if the pointer is valid (not NULL)
|
||||
Returns true for valid, else false. */
|
||||
bool IsValid();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
namespace String
|
||||
|
@ -128,6 +186,13 @@ namespace Utility
|
|||
::std::vector<::std::wstring> & Split( ::std::vector<::std::wstring> &output, const ::std::wstring &str, char delim, ::std::wstring::size_type offset = 0 );
|
||||
::std::vector<::std::wstring> & Split( ::std::vector<::std::wstring> &output, const ::std::wstring &str, const ::std::wstring &delim, ::std::wstring::size_type offset = 0 );
|
||||
::std::vector<::std::wstring> & Split( ::std::vector<::std::wstring> &output, const ::std::wstring &str, const ::std::vector<::std::wstring> &delim, ::std::wstring::size_type offset = 0 );
|
||||
::std::wstring & wToLowerCase( ::std::wstring &output, const ::std::wstring &str );
|
||||
::std::wstring & wToLowerCase( ::std::wstring &str );
|
||||
|
||||
//To wstring
|
||||
|
||||
::std::wstring & StringToWstring( const ::std::string &str, ::std::wstring &wstr );
|
||||
::std::string & WStringToString( const ::std::wstring &wstr, ::std::string &str );
|
||||
}
|
||||
|
||||
namespace Stream
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include "Buffer.h"
|
||||
#include "Core.h"
|
||||
|
||||
using namespace Oyster;
|
||||
using namespace Oyster::Graphics;
|
||||
|
||||
Oyster::Buffer::Buffer()
|
||||
Buffer::Buffer()
|
||||
{
|
||||
mBuffer = NULL;
|
||||
}
|
||||
|
@ -23,32 +23,32 @@ HRESULT Buffer::Apply(UINT32 misc) const
|
|||
{
|
||||
UINT32 vertexSize = mElementSize;
|
||||
UINT32 offset = 0;
|
||||
Oyster::Core::DeviceContext->IASetVertexBuffers(misc, 1, &mBuffer, &vertexSize, &offset );
|
||||
Core::deviceContext->IASetVertexBuffers(misc, 1, &mBuffer, &vertexSize, &offset );
|
||||
}
|
||||
break;
|
||||
case INDEX_BUFFER:
|
||||
{
|
||||
Oyster::Core::DeviceContext->IASetIndexBuffer(mBuffer, DXGI_FORMAT_R32_UINT, 0);
|
||||
Core::deviceContext->IASetIndexBuffer(mBuffer, DXGI_FORMAT_R32_UINT, 0);
|
||||
}
|
||||
break;
|
||||
case CONSTANT_BUFFER_VS:
|
||||
{
|
||||
Oyster::Core::DeviceContext->VSSetConstantBuffers(misc, 1, &mBuffer);
|
||||
Core::deviceContext->VSSetConstantBuffers(misc, 1, &mBuffer);
|
||||
}
|
||||
break;
|
||||
case CONSTANT_BUFFER_GS:
|
||||
{
|
||||
Oyster::Core::DeviceContext->GSSetConstantBuffers(misc, 1, &mBuffer);
|
||||
Core::deviceContext->GSSetConstantBuffers(misc, 1, &mBuffer);
|
||||
}
|
||||
break;
|
||||
case CONSTANT_BUFFER_PS:
|
||||
{
|
||||
Oyster::Core::DeviceContext->PSSetConstantBuffers(misc, 1, &mBuffer);
|
||||
Core::deviceContext->PSSetConstantBuffers(misc, 1, &mBuffer);
|
||||
}
|
||||
break;
|
||||
case CONSTANT_BUFFER_CS:
|
||||
{
|
||||
Oyster::Core::DeviceContext->CSSetConstantBuffers(misc,1,&mBuffer);
|
||||
Core::deviceContext->CSSetConstantBuffers(misc,1,&mBuffer);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -145,11 +145,11 @@ HRESULT Buffer::Init(const BUFFER_INIT_DESC& initDesc)
|
|||
data.pSysMem = initDesc.InitData;
|
||||
data.SysMemPitch=0;
|
||||
data.SysMemSlicePitch = 0;
|
||||
hr = Oyster::Core::Device->CreateBuffer(&bufferDesc, &data, &mBuffer);
|
||||
hr = Core::device->CreateBuffer(&bufferDesc, &data, &mBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
hr = Oyster::Core::Device->CreateBuffer(&bufferDesc, NULL, &mBuffer);
|
||||
hr = Core::device->CreateBuffer(&bufferDesc, NULL, &mBuffer);
|
||||
}
|
||||
|
||||
if(FAILED(hr))
|
||||
|
@ -173,7 +173,7 @@ void* Buffer::Map()
|
|||
else if(mUsage == BUFFER_CPU_WRITE_DISCARD) mapType = D3D11_MAP_WRITE_DISCARD;
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
if(FAILED(hr = Oyster::Core::DeviceContext->Map(
|
||||
if(FAILED(hr = Core::deviceContext->Map(
|
||||
mBuffer,
|
||||
0,
|
||||
(D3D11_MAP)mapType,
|
||||
|
@ -194,10 +194,10 @@ void* Buffer::Map()
|
|||
|
||||
void Buffer::Unmap()
|
||||
{
|
||||
Oyster::Core::DeviceContext->Unmap( mBuffer, 0 );
|
||||
Core::deviceContext->Unmap( mBuffer, 0 );
|
||||
}
|
||||
|
||||
Oyster::Buffer::operator ID3D11Buffer *()
|
||||
Buffer::operator ID3D11Buffer *()
|
||||
{
|
||||
return this->mBuffer;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
namespace Oyster
|
||||
{
|
||||
namespace Graphics
|
||||
{
|
||||
class Buffer
|
||||
{
|
||||
public:
|
||||
|
@ -71,7 +73,7 @@ namespace Oyster
|
|||
UINT32 GetVertexSize();
|
||||
UINT32 GetElementCount();
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,169 +1,25 @@
|
|||
#include "Core.h"
|
||||
|
||||
using namespace Oyster;
|
||||
using namespace Oyster::Graphics;
|
||||
using std::string;
|
||||
|
||||
//GPU
|
||||
ID3D11Device *Core::Device = NULL;
|
||||
ID3D11Device *Core::device = NULL;
|
||||
|
||||
//API
|
||||
ID3D11DeviceContext *Core::DeviceContext = NULL;
|
||||
ID3D11DeviceContext *Core::deviceContext = NULL;
|
||||
|
||||
//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)
|
||||
{
|
||||
UINT createDeviceFlags = 0;
|
||||
ID3D11UnorderedAccessView* Core::backBufferUAV = NULL;
|
||||
|
||||
if( SingleThreaded )
|
||||
createDeviceFlags = ::D3D11_CREATE_DEVICE_SINGLETHREADED;
|
||||
ID3D11DepthStencilView* Core::depthStencil = NULL;
|
||||
|
||||
::D3D_DRIVER_TYPE driverType = ::D3D_DRIVER_TYPE_HARDWARE;
|
||||
D3D11_VIEWPORT* Core::viewPort = NULL;
|
||||
|
||||
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,
|
||||
&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;
|
||||
}
|
||||
Oyster::Math::Float2 Core::resolution = Oyster::Math::Float2::null;
|
|
@ -7,23 +7,35 @@
|
|||
#include "CoreIncludes.h"
|
||||
#include <sstream>
|
||||
#include "Buffer.h"
|
||||
#include "OysterMath.h"
|
||||
|
||||
namespace Oyster
|
||||
{
|
||||
namespace Graphics
|
||||
{
|
||||
class Core
|
||||
{
|
||||
public:
|
||||
|
||||
static ID3D11Device* Device;
|
||||
static ID3D11Device* device;
|
||||
|
||||
static ID3D11DeviceContext* DeviceContext;
|
||||
static ID3D11DeviceContext* deviceContext;
|
||||
|
||||
static IDXGISwapChain* SwapChain;
|
||||
static IDXGISwapChain* swapChain;
|
||||
|
||||
static std::stringstream* AccesLog();
|
||||
static std::stringstream log;
|
||||
|
||||
static bool Init(bool SingleThreaded,bool Reference,bool ForceDX11);
|
||||
//BackBufferRTV
|
||||
static ID3D11RenderTargetView* backBufferRTV;
|
||||
//BackBufferUAV
|
||||
static ID3D11UnorderedAccessView* backBufferUAV;
|
||||
//DepthStencil
|
||||
static ID3D11DepthStencilView* depthStencil;
|
||||
//ViewPort
|
||||
static D3D11_VIEWPORT* viewPort;
|
||||
|
||||
static Oyster::Math::Float2 resolution;
|
||||
|
||||
static bool CreateSwapChain(HWND Window, int NrofBuffers,bool MSAA_Quality,bool Fullscreen);
|
||||
|
||||
class ShaderManager
|
||||
{
|
||||
|
@ -52,9 +64,9 @@ namespace Oyster
|
|||
|
||||
struct
|
||||
{
|
||||
std::vector<Oyster::Buffer*> Vertex;
|
||||
std::vector<Oyster::Buffer*> Geometry;
|
||||
std::vector<Oyster::Buffer*> Pixel;
|
||||
std::vector<Buffer*> Vertex;
|
||||
std::vector<Buffer*> Geometry;
|
||||
std::vector<Buffer*> Pixel;
|
||||
}CBuffers;
|
||||
|
||||
ShaderEffect()
|
||||
|
@ -108,7 +120,33 @@ namespace Oyster
|
|||
static void Domain(int Index);
|
||||
};
|
||||
};
|
||||
|
||||
//Set resulotion Before Calling Full Init
|
||||
class Init
|
||||
{
|
||||
public:
|
||||
enum State
|
||||
{
|
||||
Sucsess,
|
||||
Fail
|
||||
};
|
||||
|
||||
static State CreateDeviceAndDeviceContext(bool SingleThreaded = true, bool Reference = false, bool ForceDX11 = true);
|
||||
|
||||
static State CreateSwapChain(HWND Window, int NrofBuffers,bool MSAA_Quality,bool Fullscreen, Oyster::Math::Float2 Size);
|
||||
|
||||
static State CreateDepthStencil(bool MSAA_Quality, Oyster::Math::Float2 Size);
|
||||
|
||||
static State CreateBackBufferViews();
|
||||
|
||||
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
|
||||
#include <windows.h>
|
||||
#include <D3D11.h>
|
||||
#include <d3dCompiler.h>
|
||||
#include <d3dcompiler.h>
|
||||
|
||||
#pragma comment(lib, "d3d11.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,6 +5,8 @@ const char* ShaderFunction = "main";
|
|||
|
||||
namespace Oyster
|
||||
{
|
||||
namespace Graphics
|
||||
{
|
||||
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
|
||||
|
@ -28,7 +30,7 @@ namespace Oyster
|
|||
std::map<std::wstring,int> VSMap;
|
||||
}
|
||||
|
||||
#pragma region Init
|
||||
#pragma region Init
|
||||
bool Core::ShaderManager::Init(std::wstring filename, ShaderType type, std::wstring name, bool Precompiled)
|
||||
{
|
||||
if(Precompiled)
|
||||
|
@ -73,7 +75,7 @@ namespace Oyster
|
|||
if(VSMap.count(name))
|
||||
return false;
|
||||
|
||||
if(FAILED(Core::Device->CreateVertexShader(sd.data, sd.size, 0, &vertex)))
|
||||
if(FAILED(Core::device->CreateVertexShader(sd.data, sd.size, 0, &vertex)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -91,7 +93,7 @@ namespace Oyster
|
|||
|
||||
if(GSMap.count(name))
|
||||
return false;
|
||||
if(FAILED(Core::Device->CreateGeometryShader(sd.data, sd.size, 0, &geometry)))
|
||||
if(FAILED(Core::device->CreateGeometryShader(sd.data, sd.size, 0, &geometry)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -103,7 +105,7 @@ namespace Oyster
|
|||
|
||||
if(PSMap.count(name))
|
||||
return false;
|
||||
if(FAILED(Core::Device->CreatePixelShader(sd.data, sd.size, 0, &pixel)))
|
||||
if(FAILED(Core::device->CreatePixelShader(sd.data, sd.size, 0, &pixel)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -115,7 +117,7 @@ namespace Oyster
|
|||
|
||||
if(CSMap.count(name))
|
||||
return false;
|
||||
if(FAILED(Core::Device->CreateComputeShader(sd.data, sd.size, 0, &compute)))
|
||||
if(FAILED(Core::device->CreateComputeShader(sd.data, sd.size, 0, &compute)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -141,15 +143,14 @@ namespace Oyster
|
|||
|
||||
ID3D11PixelShader* pixel;
|
||||
|
||||
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"ps_5_0",0,0,&Shader,&Error)))
|
||||
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;
|
||||
}
|
||||
if(FAILED(Oyster::Core::Device->CreatePixelShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&pixel)))
|
||||
if(FAILED(Core::device->CreatePixelShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&pixel)))
|
||||
{
|
||||
Error->Release();
|
||||
Shader->Release();
|
||||
return false;
|
||||
}
|
||||
|
@ -169,15 +170,14 @@ namespace Oyster
|
|||
|
||||
ID3D11GeometryShader* geometry;
|
||||
|
||||
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"gs_5_0",0,0,&Shader,&Error)))
|
||||
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;
|
||||
}
|
||||
if(FAILED(Oyster::Core::Device->CreateGeometryShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&geometry)))
|
||||
if(FAILED(Core::device->CreateGeometryShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&geometry)))
|
||||
{
|
||||
Error->Release();
|
||||
Shader->Release();
|
||||
return false;
|
||||
}
|
||||
|
@ -197,15 +197,14 @@ namespace Oyster
|
|||
|
||||
ID3D11VertexShader* vertex;
|
||||
|
||||
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"vs_5_0",0,0,&Shader,&Error)))
|
||||
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;
|
||||
}
|
||||
if(FAILED(Oyster::Core::Device->CreateVertexShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&vertex)))
|
||||
if(FAILED(Core::device->CreateVertexShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&vertex)))
|
||||
{
|
||||
Error->Release();
|
||||
Shader->Release();
|
||||
return false;
|
||||
}
|
||||
|
@ -234,7 +233,7 @@ namespace Oyster
|
|||
}
|
||||
return true;
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma endregion
|
||||
|
||||
void Core::ShaderManager::CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout)
|
||||
{
|
||||
|
@ -243,10 +242,10 @@ namespace Oyster
|
|||
Layout=0;
|
||||
return;
|
||||
}
|
||||
Device->CreateInputLayout(desc,ElementCount,VData[VertexIndex].data,VData[VertexIndex].size,&Layout);
|
||||
Core::device->CreateInputLayout(desc,ElementCount,VData[VertexIndex].data,VData[VertexIndex].size,&Layout);
|
||||
}
|
||||
|
||||
#pragma region Get
|
||||
#pragma region Get
|
||||
int Core::ShaderManager::Get::Pixel(std::wstring Name)
|
||||
{
|
||||
if(PSMap.count(Name))
|
||||
|
@ -281,37 +280,37 @@ namespace Oyster
|
|||
{
|
||||
return -1;
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Set
|
||||
#pragma region Set
|
||||
/// \todo smart set
|
||||
void Core::ShaderManager::Set::Pixel(int Index)
|
||||
{
|
||||
if(Index==-1)
|
||||
DeviceContext->PSSetShader( NULL,NULL,0);
|
||||
Core::deviceContext->PSSetShader( NULL,NULL,0);
|
||||
else
|
||||
DeviceContext->PSSetShader( PS[Index],NULL,0);
|
||||
Core::deviceContext->PSSetShader( PS[Index],NULL,0);
|
||||
}
|
||||
void Core::ShaderManager::Set::Vertex(int Index)
|
||||
{
|
||||
if(Index==-1)
|
||||
DeviceContext->VSSetShader( NULL,NULL,0);
|
||||
Core::deviceContext->VSSetShader( NULL,NULL,0);
|
||||
else
|
||||
DeviceContext->VSSetShader( VS[Index],NULL,0);
|
||||
Core::deviceContext->VSSetShader( VS[Index],NULL,0);
|
||||
}
|
||||
void Core::ShaderManager::Set::Geometry(int Index)
|
||||
{
|
||||
if(Index==-1)
|
||||
DeviceContext->GSSetShader( NULL,NULL,0);
|
||||
Core::deviceContext->GSSetShader( NULL,NULL,0);
|
||||
else
|
||||
DeviceContext->GSSetShader( GS[Index],NULL,0);
|
||||
Core::deviceContext->GSSetShader( GS[Index],NULL,0);
|
||||
}
|
||||
void Core::ShaderManager::Set::Compute(int Index)
|
||||
{
|
||||
if(Index==-1)
|
||||
DeviceContext->CSSetShader( NULL,NULL,0);
|
||||
Core::deviceContext->CSSetShader( NULL,NULL,0);
|
||||
else
|
||||
DeviceContext->CSSetShader( CS[Index],NULL,0);
|
||||
Core::deviceContext->CSSetShader( CS[Index],NULL,0);
|
||||
}
|
||||
/// \todo set Hull
|
||||
void Core::ShaderManager::Set::Hull(int Index)
|
||||
|
@ -323,7 +322,7 @@ namespace Oyster
|
|||
{
|
||||
return;
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma endregion
|
||||
|
||||
/// \todo smart Set ie. not resetting the shader
|
||||
/// \todo research states
|
||||
|
@ -334,18 +333,18 @@ namespace Oyster
|
|||
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);
|
||||
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);
|
||||
Oyster::Core::DeviceContext->RSSetState(se.RenderStates.Rasterizer);
|
||||
Oyster::Core::DeviceContext->PSSetSamplers(0,se.RenderStates.SampleCount,se.RenderStates.SampleState);
|
||||
Core::deviceContext->RSSetState(se.RenderStates.Rasterizer);
|
||||
Core::deviceContext->PSSetSamplers(0,se.RenderStates.SampleCount,se.RenderStates.SampleState);
|
||||
float test[4] = {0};
|
||||
Oyster::Core::DeviceContext->OMSetBlendState(se.RenderStates.BlendState,test,-1);
|
||||
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,6 +9,8 @@
|
|||
|
||||
namespace Oyster
|
||||
{
|
||||
namespace Graphics
|
||||
{
|
||||
class Engine
|
||||
{
|
||||
private:
|
||||
|
@ -16,7 +18,7 @@ namespace Oyster
|
|||
~Engine();
|
||||
|
||||
public:
|
||||
class Init
|
||||
/*class Init
|
||||
{
|
||||
public:
|
||||
struct Setup
|
||||
|
@ -66,7 +68,7 @@ namespace Oyster
|
|||
private:
|
||||
Init();
|
||||
~Init();
|
||||
};
|
||||
};*/
|
||||
|
||||
class States
|
||||
{
|
||||
|
@ -94,7 +96,7 @@ namespace Oyster
|
|||
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 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::
|
||||
|
||||
|
@ -147,19 +149,20 @@ namespace Oyster
|
|||
{
|
||||
public:
|
||||
//Basic Setup
|
||||
static void NewFrame(const Float4& Color, const Matrix& View, const Matrix& Projection);
|
||||
//static void NewFrame(const Float4& Color, const Matrix& View, const Matrix& Projection);
|
||||
|
||||
//Geometry Pass
|
||||
static void BeginRenderGeometry();
|
||||
static void RenderGeometry(const Oyster::Render::Model* models,int count);
|
||||
//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 InputPointLights(Oyster::Resources::BufferDefinitions::PointLightDescription *p, int NrOfPointlights );
|
||||
static void RenderLightning();
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,9 +1,9 @@
|
|||
//Oyster
|
||||
|
||||
// Render
|
||||
#include "Render\Model.h"
|
||||
#include "Render\Camera.h"
|
||||
#include "Render\TextBox.h"
|
||||
//#include "Render\Model.h"
|
||||
//#include "Render\Camera.h"
|
||||
//#include "Render\TextBox.h"
|
||||
|
||||
// Core
|
||||
#include "Core\Core.h"
|
||||
|
@ -16,8 +16,8 @@
|
|||
#include "OysterMath.h"
|
||||
|
||||
// Resources
|
||||
#include "Resourses\ShaderEffects.h"
|
||||
#include "Resourses\Buffers.h"
|
||||
#include "Resourses\PipelineResources.h"
|
||||
#include "Resourses\GraphicsDefinitions.h"
|
||||
#include "Resourses\Manager.h"
|
||||
//#include "Resourses\ShaderEffects.h"
|
||||
//#include "Resourses\Buffers.h"
|
||||
//#include "Resourses\PipelineResources.h"
|
||||
//#include "Resourses\GraphicsDefinitions.h"
|
||||
//#include "Resourses\Manager.h"
|
|
@ -1,268 +1,149 @@
|
|||
#include "ObjReader.h"
|
||||
#include "Utilities.h"
|
||||
#include "..\Core\Core.h"
|
||||
#include "OBJReader.h"
|
||||
#include "..\Definitions\GraphicalDefinition.h"
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
|
||||
using namespace std;
|
||||
using namespace Oyster::FileLoaders;
|
||||
using namespace Oyster;
|
||||
using namespace Oyster::Math;
|
||||
|
||||
ObjReader *ObjReader::LoadFile(std::string fileName, Oyster::Math::Float4x4 transform)
|
||||
OBJReader::OBJReader()
|
||||
{
|
||||
static std::map<std::string, ObjReader *> cache;
|
||||
|
||||
ObjReader *reader = NULL;
|
||||
|
||||
if (cache.count(fileName))
|
||||
{
|
||||
reader = cache[fileName];
|
||||
}
|
||||
else
|
||||
{
|
||||
reader = new ObjReader();
|
||||
reader->ParseFile(fileName, transform);
|
||||
|
||||
cache[fileName] = reader;
|
||||
}
|
||||
|
||||
return reader;
|
||||
_mPos = 0;
|
||||
_mNormal = 0;
|
||||
_mTexel = 0;
|
||||
}
|
||||
|
||||
ObjReader::ObjReader(void)
|
||||
OBJReader::~OBJReader()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
ObjReader::~ObjReader(void)
|
||||
void OBJReader::readOBJFile( std::wstring fileName )
|
||||
{
|
||||
std::fstream inStream;
|
||||
std::string typeOfData = " ";
|
||||
float vertexData;
|
||||
std::string face1, face2, face3;
|
||||
|
||||
inStream.open( fileName, std::fstream::in );
|
||||
|
||||
if( inStream.is_open() )
|
||||
{
|
||||
while( !inStream.eof() )
|
||||
{
|
||||
inStream >> typeOfData;
|
||||
|
||||
if( typeOfData == "v" )
|
||||
{
|
||||
Oyster::Math::Float3 position;
|
||||
|
||||
inStream >> vertexData;
|
||||
position.x = vertexData;
|
||||
|
||||
inStream >> vertexData;
|
||||
position.y = vertexData;
|
||||
|
||||
inStream >> vertexData;
|
||||
position.z = vertexData;
|
||||
|
||||
_mVertexCoord.push_back( position );
|
||||
|
||||
}
|
||||
else if( typeOfData == "vt" )
|
||||
{
|
||||
Oyster::Math::Float2 texel;
|
||||
inStream >> vertexData;
|
||||
texel.x = vertexData;
|
||||
|
||||
inStream >> vertexData;
|
||||
texel.y = 1 - vertexData;
|
||||
|
||||
_mVertexTexture.push_back( texel );
|
||||
}
|
||||
else if( typeOfData == "vn" )
|
||||
{
|
||||
Oyster::Math::Float3 normal;
|
||||
inStream >> vertexData;
|
||||
normal.x = vertexData;
|
||||
|
||||
inStream >> vertexData;
|
||||
normal.y = vertexData;
|
||||
|
||||
inStream >> vertexData;
|
||||
normal.z = vertexData;
|
||||
|
||||
_mVertexNormal.push_back( normal );
|
||||
}
|
||||
else if( typeOfData == "f" )
|
||||
{
|
||||
inStream >> face1;
|
||||
stringSplit( face1 );
|
||||
|
||||
addToOBJarray();
|
||||
|
||||
inStream >> face2;
|
||||
stringSplit( face2 );
|
||||
|
||||
addToOBJarray();
|
||||
|
||||
inStream >> face3;
|
||||
stringSplit( face3 );
|
||||
|
||||
addToOBJarray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inStream.close();
|
||||
}
|
||||
|
||||
void ObjReader::ParseFile(std::string fileName, Float4x4 transform)
|
||||
Oyster::Graphics::Render::ModelInfo* OBJReader::toModel()
|
||||
{
|
||||
ifstream input;
|
||||
input.open(fileName.c_str());
|
||||
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();
|
||||
|
||||
if(!input.is_open())
|
||||
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))
|
||||
{
|
||||
return;
|
||||
//Something isn't okay here
|
||||
}
|
||||
modelInfo->Indexed = false;
|
||||
modelInfo->VertexCount = (int)desc.NumElements;
|
||||
modelInfo->Vertices = b;
|
||||
|
||||
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);
|
||||
|
||||
if(c=="v")
|
||||
{
|
||||
position = readVertex(offset,s);
|
||||
vList.push_back(position);
|
||||
}
|
||||
else if(c=="vt")
|
||||
{
|
||||
uv = readUV(offset,s);
|
||||
uvList.push_back(uv);
|
||||
}
|
||||
else if(c=="vn")
|
||||
{
|
||||
normal = readNormal(offset,s);
|
||||
nList.push_back(normal);
|
||||
}
|
||||
else if(c=="f")
|
||||
{
|
||||
readFace(offset, s, face);
|
||||
|
||||
vertex1.Position = vList[(int)face[0].x];
|
||||
vertex1.UV = uvList[(int)face[0].y];
|
||||
vertex1.Normal = nList[(int)face[0].z];
|
||||
|
||||
vertex2.Position = vList[(int)face[1].x];
|
||||
vertex2.UV = uvList[(int)face[1].y];
|
||||
vertex2.Normal = nList[(int)face[1].z];
|
||||
|
||||
vertex3.Position = vList[(int)face[2].x];
|
||||
vertex3.UV = uvList[(int)face[2].y];
|
||||
vertex3.Normal = nList[(int)face[2].z];
|
||||
|
||||
VertexList.push_back(vertex1);
|
||||
VertexList.push_back(vertex3);
|
||||
VertexList.push_back(vertex2);
|
||||
}
|
||||
else if(c=="mtllib")
|
||||
{
|
||||
this->materials = GetMaterials(path+s.substr(offset+1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
input.close();
|
||||
|
||||
this->numVertices = VertexList.size();
|
||||
this->vertices = new Vertex[this->numVertices];
|
||||
|
||||
for(size_t i=0;i<this->numVertices;++i)
|
||||
{
|
||||
vertices[i].Position=Math::transformVector(Math::Float4(VertexList[i].Position,1),transform);
|
||||
vertices[i].Normal=Math::transformVector(Math::Float4(VertexList[i].Normal,0),transform);
|
||||
vertices[i].UV = VertexList[i].UV;
|
||||
}
|
||||
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;
|
||||
(*vertex)=this->vertices;
|
||||
Textures = this->materials;
|
||||
char delim = '/';
|
||||
std::string vPos, vNormal, vTexel;
|
||||
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;
|
||||
int offset=(int)d.find('/');
|
||||
data.x=(float)atoi(d.substr(1,offset).c_str())-1;
|
||||
OBJFormat temp;
|
||||
|
||||
int newOffset = (int)d.find('/',offset+1);
|
||||
string d2=d.substr(offset+1,newOffset-offset-1);
|
||||
data.y=(float)atoi(d2.c_str())-1;
|
||||
offset=newOffset;
|
||||
temp._d3VertexCoord = _mVertexCoord.at( _mPos - 1 );
|
||||
temp._d3VertexNormal = _mVertexNormal.at( _mNormal - 1 );
|
||||
temp._d3VertexTexture = _mVertexTexture.at( _mTexel - 1 );
|
||||
|
||||
newOffset = (int)d.find('/',offset+1);
|
||||
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;
|
||||
_myOBJ.push_back( temp );
|
||||
}
|
|
@ -1,42 +1,55 @@
|
|||
#pragma once
|
||||
#include "..\Core\CoreIncludes.h"
|
||||
#include "..\Math\OysterMath.h"
|
||||
#ifndef OBJREADER_H
|
||||
#define OBJREADER_H
|
||||
#include "..\..\Misc\Utilities.h"
|
||||
#include "..\..\OysterMath\OysterMath.h"
|
||||
#include "..\Model\ModelInfo.h"
|
||||
|
||||
namespace Oyster
|
||||
//#include <fstream>
|
||||
|
||||
|
||||
|
||||
class OBJReader
|
||||
{
|
||||
namespace FileLoaders
|
||||
{
|
||||
class ObjReader
|
||||
{
|
||||
public:
|
||||
struct Vertex
|
||||
struct OBJFormat
|
||||
{
|
||||
Oyster::Math::Float3 Position;
|
||||
Oyster::Math::Float3 Normal;
|
||||
Oyster::Math::Float2 UV;
|
||||
Oyster::Math::Float3 _d3VertexCoord;
|
||||
Oyster::Math::Float2 _d3VertexTexture;
|
||||
Oyster::Math::Float3 _d3VertexNormal;
|
||||
};
|
||||
|
||||
static ObjReader *LoadFile(std::string fileName, Oyster::Math::Float4x4 transform = Oyster::Math::Float4x4::identity);
|
||||
struct OBJMaterialData
|
||||
{
|
||||
std::string _name;
|
||||
std::string _mapKd;
|
||||
float _kd[3];
|
||||
float _ka[3];
|
||||
float _tf[3];
|
||||
float _ni;
|
||||
|
||||
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);
|
||||
};
|
||||
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 "ModelInfo.h"
|
||||
|
||||
using namespace Oyster::Math;
|
||||
//using namespace Oyster::Math;
|
||||
|
||||
namespace Oyster
|
||||
{
|
||||
namespace Graphics
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
|
||||
struct Model
|
||||
{
|
||||
ModelInfo* info;
|
||||
Float4x4 *World;
|
||||
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>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<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>
|
||||
|
@ -140,31 +143,24 @@
|
|||
<ItemGroup>
|
||||
<ClCompile Include="Core\Buffer.cpp" />
|
||||
<ClCompile Include="Core\Core.cpp" />
|
||||
<ClCompile Include="Core\Init.cpp" />
|
||||
<ClCompile Include="Core\ShaderManager.cpp" />
|
||||
<ClCompile Include="Engine.cpp" />
|
||||
<ClCompile Include="Render\Model.cpp" />
|
||||
<ClCompile Include="Render\TextBox.cpp" />
|
||||
<ClCompile Include="Resourses\Buffers.cpp" />
|
||||
<ClCompile Include="Resourses\Manager.cpp" />
|
||||
<ClCompile Include="Resourses\PipelineResources.cpp" />
|
||||
<ClCompile Include="Resourses\ShaderEffects.cpp" />
|
||||
<ClCompile Include="FileLoader\ObjReader.cpp" />
|
||||
<ClCompile Include="Render\Preparations\BasicPreparations.cpp" />
|
||||
<ClCompile Include="Render\Rendering\BasicRender.cpp" />
|
||||
<ClCompile Include="Render\Resources\Resources.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Core\Buffer.h" />
|
||||
<ClInclude Include="Core\Core.h" />
|
||||
<ClInclude Include="Core\CoreIncludes.h" />
|
||||
<ClInclude Include="Engine.h" />
|
||||
<ClInclude Include="EngineIncludes.h" />
|
||||
<ClInclude Include="FileLoader\ObjReader.h" />
|
||||
<ClInclude Include="Render\Lights.h" />
|
||||
<ClInclude Include="Render\Model.h" />
|
||||
<ClInclude Include="Render\ModelInfo.h" />
|
||||
<ClInclude Include="Render\TextBox.h" />
|
||||
<ClInclude Include="Resourses\Buffers.h" />
|
||||
<ClInclude Include="Resourses\GraphicsDefinitions.h" />
|
||||
<ClInclude Include="Resourses\Manager.h" />
|
||||
<ClInclude Include="Resourses\PipelineResources.h" />
|
||||
<ClInclude Include="Resourses\ShaderEffects.h" />
|
||||
<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">
|
||||
|
@ -175,6 +171,17 @@
|
|||
</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>
|
||||
<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">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
|
||||
|
@ -192,6 +199,8 @@
|
|||
<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" />
|
||||
|
|
|
@ -21,30 +21,24 @@
|
|||
<ClCompile Include="Core\Core.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</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">
|
||||
<Filter>Source Files</Filter>
|
||||
</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>
|
||||
<ClInclude Include="Core\Buffer.h">
|
||||
|
@ -56,37 +50,22 @@
|
|||
<ClInclude Include="Core\CoreIncludes.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Render\Lights.h">
|
||||
<ClInclude Include="Render\Preparations\Preparations.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Render\Model.h">
|
||||
<ClInclude Include="Render\Rendering\Render.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Render\ModelInfo.h">
|
||||
<ClInclude Include="Model\ModelInfo.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Render\TextBox.h">
|
||||
<ClInclude Include="Model\Model.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Resourses\Buffers.h">
|
||||
<ClInclude Include="Render\Resources\Resources.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Resourses\GraphicsDefinitions.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">
|
||||
<ClInclude Include="Definitions\GraphicalDefinition.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FileLoader\ObjReader.h">
|
||||
|
@ -96,5 +75,6 @@
|
|||
<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,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);
|
||||
}
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
namespace Oyster
|
||||
{
|
||||
namespace Graphics
|
||||
{
|
||||
class Shader
|
||||
{
|
||||
public:
|
||||
|
@ -75,4 +77,5 @@ namespace Oyster
|
|||
|
||||
static std::stringstream* AccesLog();
|
||||
};
|
||||
}
|
||||
}
|
|
@ -161,6 +161,32 @@ namespace LinearAlgebra2D
|
|||
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>
|
||||
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),
|
||||
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
|
||||
|
@ -283,6 +315,33 @@ namespace LinearAlgebra3D
|
|||
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>
|
||||
::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 */
|
||||
|
@ -327,6 +386,23 @@ namespace LinearAlgebra3D
|
|||
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>
|
||||
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;
|
||||
}
|
||||
|
||||
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.
|
||||
width; of the projection sample volume.
|
||||
height; of the projection sample volume.
|
||||
|
@ -390,6 +472,10 @@ namespace LinearAlgebra3D
|
|||
template<typename ScalarType>
|
||||
inline ::LinearAlgebra::Vector3<ScalarType> VectorProjection( const ::LinearAlgebra::Vector3<ScalarType> &vector, const ::LinearAlgebra::Vector3<ScalarType> &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"
|
||||
|
|
|
@ -33,17 +33,50 @@ namespace Oyster { namespace Math2D
|
|||
Float3x3 & RotationMatrix( const Float &radian, Float3x3 &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 )
|
||||
{ return ::LinearAlgebra2D::OrientationMatrix( radian, position, targetMem ); }
|
||||
{
|
||||
return ::LinearAlgebra2D::OrientationMatrix( radian, position, 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 )
|
||||
{ return ::LinearAlgebra2D::OrientationMatrix( radian, position, localCenterOfRotation, targetMem ); }
|
||||
{
|
||||
return ::LinearAlgebra2D::OrientationMatrix( radian, position, localCenterOfRotation, 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
|
||||
|
@ -63,29 +96,83 @@ namespace Oyster { namespace Math3D
|
|||
Float4x4 & RotationMatrix( const Float &radian, const Float3 &normalizedAxis, Float4x4 &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 )
|
||||
{ return ::LinearAlgebra3D::OrientationMatrix( normalizedAxis, deltaRadian, sumTranslation, targetMem ); }
|
||||
{
|
||||
return ::LinearAlgebra3D::OrientationMatrix( normalizedAxis, deltaRadian, sumTranslation, 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 )
|
||||
{ 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 )
|
||||
{ return ::LinearAlgebra3D::InverseOrientationMatrix( orientationMatrix, targetMem ); }
|
||||
{
|
||||
return ::LinearAlgebra3D::InverseOrientationMatrix( orientationMatrix, targetMem );
|
||||
}
|
||||
|
||||
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 )
|
||||
{ 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 )
|
||||
{ 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 )
|
||||
{
|
||||
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
|
||||
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
|
||||
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.
|
||||
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
|
||||
|
@ -148,6 +163,18 @@ namespace Oyster { namespace Math3D /// Oyster's native math library specialized
|
|||
/// Please make sure normalizedAxis is normalized.
|
||||
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
|
||||
* @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() );
|
||||
|
||||
//! @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.
|
||||
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
|
||||
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.
|
||||
* @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
|
||||
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
|
||||
inline Float4x4 & ViewProjectionMatrix( const Float4x4 &view, const Float4x4 &projection, Float4x4 &targetMem = Float4x4() )
|
||||
{ return targetMem = projection * view; }
|
||||
|
||||
/// Helper inline function that sets and then returns targetMem = transformer * transformee
|
||||
inline Float4x4 & TransformMatrix( const Float4x4 &transformer, const Float4x4 &transformee, Float4x4 &targetMem = Float4x4() )
|
||||
/** Helper inline function that sets and then returns targetMem = transformer * transformee */
|
||||
inline Float4x4 & TransformMatrix( const Float4x4 &transformer, const Float4x4 &transformee, Float4x4 &targetMem )
|
||||
{ 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
|
||||
inline Float4 & TransformVector( const Float4x4 &transformer, const Float4 &transformee, Float4 &targetMem = Float4() )
|
||||
{ return targetMem = transformer * transformee; }
|
||||
|
|
|
@ -8,19 +8,28 @@
|
|||
using namespace ::Oyster::Collision3D;
|
||||
using namespace ::Oyster::Math3D;
|
||||
|
||||
Box::Box( ) : ICollideable(Type_box), orientation(Float4x4::identity), boundingOffset() {}
|
||||
Box::Box( const Float4x4 &o, const Float3 &s ) : ICollideable(Type_box), orientation(o), boundingOffset(s*0.5) {}
|
||||
Box::Box( )
|
||||
: 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::operator = ( const Box &box )
|
||||
{
|
||||
this->orientation = box.orientation;
|
||||
this->rotation = box.rotation;
|
||||
this->center = box.center;
|
||||
this->boundingOffset = box.boundingOffset;
|
||||
return *this;
|
||||
}
|
||||
|
||||
::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
|
||||
{
|
||||
|
@ -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_sphere: return Utility::Intersect( *this, *(Sphere*)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: return Utility::Intersect( *this, *(Box*)target );
|
||||
case Type_frustrum: return false; // TODO: :
|
||||
// case Type_frustrum: return false; // TODO: :
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
@ -44,11 +53,11 @@ bool Box::Contains( const ICollideable *target ) const
|
|||
switch( target->type )
|
||||
{
|
||||
case Type_point: return Utility::Intersect( *this, *(Point*)target );
|
||||
case Type_sphere: return false; // TODO:
|
||||
case Type_triangle: return false; // TODO:
|
||||
case Type_box_axis_aligned: return false; // TODO:
|
||||
case Type_box: return false; // TODO:
|
||||
case Type_frustrum: return false; // TODO:
|
||||
// case Type_sphere: return false; // TODO:
|
||||
// case Type_triangle: return false; // TODO:
|
||||
// case Type_box_axis_aligned: return false; // TODO:
|
||||
// case Type_box: return false; // TODO:
|
||||
// case Type_frustrum: return false; // TODO:
|
||||
default: return false;
|
||||
}
|
||||
}
|
|
@ -16,19 +16,18 @@ namespace Oyster { namespace Collision3D
|
|||
public:
|
||||
union
|
||||
{
|
||||
struct{ ::Oyster::Math::Float4x4 orientation; ::Oyster::Math::Float3 boundingOffset; };
|
||||
struct{ ::Oyster::Math::Float4x4 rotation; ::Oyster::Math::Float3 center, boundingOffset; };
|
||||
struct
|
||||
{
|
||||
::Oyster::Math::Float3 xAxis; ::Oyster::Math::Float paddingA;
|
||||
::Oyster::Math::Float3 yAxis; ::Oyster::Math::Float paddingB;
|
||||
::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( 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( );
|
||||
|
||||
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_sphere: return Utility::Intersect( *this, *(Sphere*)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: return false; // TODO:
|
||||
case Type_frustrum: return false; // TODO:
|
||||
// case Type_box: return false; // TODO:
|
||||
// case Type_frustrum: return false; // TODO:
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
@ -45,12 +45,12 @@ bool BoxAxisAligned::Contains( const ICollideable *target ) const
|
|||
{
|
||||
switch( target->type )
|
||||
{
|
||||
case Type_point: return false; // TODO:
|
||||
case Type_sphere: return false; // TODO:
|
||||
case Type_triangle: return false; // TODO:
|
||||
case Type_box_axis_aligned: return false; // TODO:
|
||||
case Type_box: return false; // TODO:
|
||||
case Type_frustrum: return false; // TODO:
|
||||
// case Type_point: return false; // TODO:
|
||||
// case Type_sphere: return false; // TODO:
|
||||
// case Type_triangle: return false; // TODO:
|
||||
// case Type_box_axis_aligned: return false; // TODO:
|
||||
// case Type_box: return false; // TODO:
|
||||
// case Type_frustrum: return false; // TODO:
|
||||
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_sphere: return Utility::Intersect( *this, *(Sphere*)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: return Utility::Intersect( *this, *(Box*)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;
|
||||
}
|
||||
}
|
||||
|
@ -214,14 +214,14 @@ bool Frustrum::Contains( const ICollideable *target ) const
|
|||
switch( target->type )
|
||||
{
|
||||
case Type_point: return Utility::Intersect( *this, *(Point*)target );
|
||||
case Type_ray: return false; // TODO:
|
||||
case Type_sphere: return false; // TODO:
|
||||
case Type_plane: return false; // TODO:
|
||||
case Type_triangle: return false; // TODO:
|
||||
case Type_box_axis_aligned: return false; // TODO:
|
||||
case Type_box: return false; // TODO:
|
||||
case Type_frustrum: return false; // TODO:
|
||||
case Type_line: return false; // TODO:
|
||||
// case Type_ray: return false; // TODO:
|
||||
// case Type_sphere: return false; // TODO:
|
||||
// case Type_plane: return false; // TODO:
|
||||
// case Type_triangle: return false; // TODO:
|
||||
// case Type_box_axis_aligned: return false; // TODO:
|
||||
// case Type_box: return false; // TODO:
|
||||
// case Type_frustrum: return false; // TODO:
|
||||
// case Type_line: return false; // TODO:
|
||||
default: return false;
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ namespace Oyster { namespace Collision3D /// Contains a collection of 3D shapes
|
|||
Type_ray,
|
||||
Type_sphere,
|
||||
Type_plane,
|
||||
Type_triangle,
|
||||
// Type_triangle,
|
||||
Type_box_axis_aligned,
|
||||
Type_box,
|
||||
Type_frustrum,
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
#include "Utilities.h"
|
||||
#include <limits>
|
||||
|
||||
using namespace Oyster::Math3D;
|
||||
using namespace ::Oyster::Math3D;
|
||||
using namespace ::Utility::Value;
|
||||
|
||||
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
|
||||
inline bool EqualsZero( const Float &value )
|
||||
{ // 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
|
||||
inline bool NotEqualsZero( const Float &value )
|
||||
{ // by Dan Andersson
|
||||
return ::Utility::Value::Abs( value ) > epsilon;
|
||||
return Abs( value ) > epsilon;
|
||||
}
|
||||
|
||||
// returns true if miss/reject
|
||||
|
@ -39,8 +40,8 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
|||
t2 = e - boundingOffset;
|
||||
t1 /= f; t2 /= f;
|
||||
if( t1 > t2 ) ::Utility::Element::Swap( t1, t2 );
|
||||
tMin = ::Utility::Value::Max( tMin, t1 );
|
||||
tMax = ::Utility::Value::Min( tMax, t2 );
|
||||
tMin = Max( tMin, t1 );
|
||||
tMax = Min( tMax, t2 );
|
||||
if( tMin > tMax ) return true;
|
||||
if( tMax < 0.0f ) return true;
|
||||
}
|
||||
|
@ -65,101 +66,140 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
|||
{ // by Dan Andersson
|
||||
Float3 c = (box.maxVertex + box.minVertex) * 0.5f, // box.Center
|
||||
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.y * ::Utility::Value::Abs(plane.normal.y);
|
||||
boxExtend += h.z * ::Utility::Value::Abs(plane.normal.z);
|
||||
boxExtend = h.x * Abs(plane.normal.x); // Box max extending towards plane
|
||||
boxExtend += h.y * Abs(plane.normal.y);
|
||||
boxExtend += h.z * Abs(plane.normal.z);
|
||||
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 )
|
||||
{ // 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.y * ::Utility::Value::Abs(plane.normal.Dot(box.orientation.v[1].xyz));
|
||||
boxExtend += box.boundingOffset.z * ::Utility::Value::Abs(plane.normal.Dot(box.orientation.v[2].xyz));
|
||||
boxExtend = box.boundingOffset.x * Abs(plane.normal.Dot(box.xAxis)); // Box max extending towards plane
|
||||
boxExtend += box.boundingOffset.y * Abs(plane.normal.Dot(box.yAxis));
|
||||
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
|
||||
Float4x4 absOrientationB;
|
||||
{
|
||||
Float4x4 tO = orientationB.GetTranspose();
|
||||
absOrientationB.v[0] = ::Utility::Value::Abs(tO.v[0]);
|
||||
if( absOrientationB.v[0].w > boundingOffsetA.x + boundingOffsetB.Dot(absOrientationB.v[0].xyz) ) return false;
|
||||
absOrientationB.v[1] = ::Utility::Value::Abs(tO.v[1]);
|
||||
if( absOrientationB.v[1].w > boundingOffsetA.y + boundingOffsetB.Dot(absOrientationB.v[1].xyz) ) return false;
|
||||
absOrientationB.v[2] = ::Utility::Value::Abs(tO.v[2]);
|
||||
if( absOrientationB.v[2].w > boundingOffsetA.z + boundingOffsetB.Dot(absOrientationB.v[2].xyz) ) return false;
|
||||
|
||||
/*****************************************************************
|
||||
* Uses the Seperating Axis Theorem
|
||||
* if( |t dot s| > hA dot |s * RA| + hB dot |s * RB| ) then not intersecting
|
||||
* |t dot s| > hA dot |s| + hB dot |s * RB| .. as RA = I
|
||||
*
|
||||
* t: objectB's offset from objectA [worldOffset]
|
||||
* s: current comparison axis
|
||||
* 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();
|
||||
if( ::Utility::Value::Abs(orientationB.v[3].Dot(orientationB.v[0])) > boundingOffsetB.x + boundingOffsetA.Dot(absOrientationB.v[0].xyz) ) return false;
|
||||
if( ::Utility::Value::Abs(orientationB.v[3].Dot(orientationB.v[1])) > boundingOffsetB.x + boundingOffsetA.Dot(absOrientationB.v[1].xyz) ) return false;
|
||||
if( ::Utility::Value::Abs(orientationB.v[3].Dot(orientationB.v[2])) > boundingOffsetB.x + boundingOffsetA.Dot(absOrientationB.v[2].xyz) ) return false;
|
||||
// s = { 0, 1, 0 } [ RA.v[1] ]
|
||||
if( absWorldOffset.y > boundingOffsetA.y + boundingOffsetB.Dot(Float3(absRotationB.v[0].y, absRotationB.v[1].y, absRotationB.v[2].y)) )
|
||||
{ // t.y > hA.y + hB dot |{RB.v[0].y, RB.v[1].y, RB.v[2].y}|
|
||||
return false;
|
||||
}
|
||||
|
||||
// ( 1,0,0 ) x orientationB.v[0].xyz:
|
||||
Float d = boundingOffsetA.y * absOrientationB.v[0].z;
|
||||
d += boundingOffsetA.z * absOrientationB.v[0].y;
|
||||
d += boundingOffsetB.y * absOrientationB.v[2].x;
|
||||
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;
|
||||
// s = { 0, 0, 1 } [ RA.v[2] ]
|
||||
if( absWorldOffset.z > boundingOffsetA.z + boundingOffsetB.Dot(Float3(absRotationB.v[0].z, absRotationB.v[1].z, absRotationB.v[2].z)) )
|
||||
{ // t.z > hA.z + hB dot |{RB.v[0].z, RB.v[1].z, RB.v[2].z}|
|
||||
return false;
|
||||
}
|
||||
|
||||
// ( 1,0,0 ) x orientationB.v[1].xyz:
|
||||
d = boundingOffsetA.y * absOrientationB.v[1].z;
|
||||
d += boundingOffsetA.z * absOrientationB.v[1].y;
|
||||
d += boundingOffsetB.x * absOrientationB.v[2].x;
|
||||
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;
|
||||
// s = RB.v[0].xyz
|
||||
if( Abs(worldOffset.Dot(rotationB.v[0].xyz)) > boundingOffsetA.Dot(absRotationB.v[0].xyz) + boundingOffsetB.x )
|
||||
{ // |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
|
||||
return false;
|
||||
}
|
||||
|
||||
// ( 1,0,0 ) x orientationB.v[2].xyz:
|
||||
d = boundingOffsetA.y * absOrientationB.v[2].z;
|
||||
d += boundingOffsetA.z * absOrientationB.v[2].y;
|
||||
d += boundingOffsetB.x * absOrientationB.v[1].x;
|
||||
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;
|
||||
// s = RB.v[1].xyz
|
||||
if( Abs(worldOffset.Dot(rotationB.v[1].xyz)) > boundingOffsetA.Dot(absRotationB.v[1].xyz) + boundingOffsetB.y )
|
||||
{ // |t dot s| > hA dot |s| + hB.y
|
||||
return false;
|
||||
}
|
||||
|
||||
// ( 0,1,0 ) x orientationB.v[0].xyz:
|
||||
d = boundingOffsetA.x * absOrientationB.v[0].z;
|
||||
d += boundingOffsetA.z * absOrientationB.v[0].x;
|
||||
d += boundingOffsetB.y * absOrientationB.v[2].y;
|
||||
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;
|
||||
// s = RB.v[2].xyz
|
||||
if( Abs(worldOffset.Dot(rotationB.v[2].xyz)) > boundingOffsetA.Dot(absRotationB.v[2].xyz) + boundingOffsetB.z )
|
||||
{ // |t dot s| > hA dot |s| + hB.z
|
||||
return false;
|
||||
}
|
||||
|
||||
// ( 0,1,0 ) x orientationB.v[1].xyz:
|
||||
d = boundingOffsetA.x * absOrientationB.v[1].z;
|
||||
d += boundingOffsetA.z * absOrientationB.v[1].x;
|
||||
d += boundingOffsetB.x * absOrientationB.v[2].y;
|
||||
d += boundingOffsetB.z * absOrientationB.v[0].y;
|
||||
if( ::Utility::Value::Abs(orientationB.v[3].x*orientationB.v[1].z - orientationB.v[3].z*orientationB.v[1].x) > d ) return false;
|
||||
// s = ( 1,0,0 ) x rotationB.v[0].xyz:
|
||||
Float d = boundingOffsetA.y * absRotationB.v[0].z;
|
||||
d += boundingOffsetA.z * absRotationB.v[0].y;
|
||||
d += boundingOffsetB.y * absRotationB.v[2].x;
|
||||
d += boundingOffsetB.z * absRotationB.v[1].x;
|
||||
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:
|
||||
d = boundingOffsetA.x * absOrientationB.v[2].z;
|
||||
d += boundingOffsetA.z * absOrientationB.v[2].x;
|
||||
d += boundingOffsetB.x * absOrientationB.v[1].y;
|
||||
d += boundingOffsetB.y * absOrientationB.v[0].y;
|
||||
if( ::Utility::Value::Abs(orientationB.v[3].x*orientationB.v[2].z - orientationB.v[3].z*orientationB.v[2].x) > d ) return false;
|
||||
// s = ( 1,0,0 ) x rotationB.v[1].xyz:
|
||||
d = boundingOffsetA.y * absRotationB.v[1].z;
|
||||
d += boundingOffsetA.z * absRotationB.v[1].y;
|
||||
d += boundingOffsetB.x * absRotationB.v[2].x;
|
||||
d += boundingOffsetB.z * absRotationB.v[0].x;
|
||||
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:
|
||||
d = boundingOffsetA.x * absOrientationB.v[0].y;
|
||||
d += boundingOffsetA.y * absOrientationB.v[0].x;
|
||||
d += boundingOffsetB.y * absOrientationB.v[2].z;
|
||||
d += boundingOffsetB.z * absOrientationB.v[1].z;
|
||||
if( ::Utility::Value::Abs(orientationB.v[3].y*orientationB.v[0].x - orientationB.v[3].x*orientationB.v[0].y) > d ) return false;
|
||||
// s = ( 1,0,0 ) x rotationB.v[2].xyz:
|
||||
d = boundingOffsetA.y * absRotationB.v[2].z;
|
||||
d += boundingOffsetA.z * absRotationB.v[2].y;
|
||||
d += boundingOffsetB.x * absRotationB.v[1].x;
|
||||
d += boundingOffsetB.y * absRotationB.v[0].x;
|
||||
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:
|
||||
d = boundingOffsetA.x * absOrientationB.v[1].y;
|
||||
d += boundingOffsetA.y * absOrientationB.v[1].x;
|
||||
d += boundingOffsetB.x * absOrientationB.v[2].z;
|
||||
d += boundingOffsetB.z * absOrientationB.v[0].z;
|
||||
if( ::Utility::Value::Abs(orientationB.v[3].y*orientationB.v[1].x - orientationB.v[3].x*orientationB.v[1].y) > d ) return false;
|
||||
// s = ( 0,1,0 ) x rotationB.v[0].xyz:
|
||||
d = boundingOffsetA.x * absRotationB.v[0].z;
|
||||
d += boundingOffsetA.z * absRotationB.v[0].x;
|
||||
d += boundingOffsetB.y * absRotationB.v[2].y;
|
||||
d += boundingOffsetB.z * absRotationB.v[1].y;
|
||||
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:
|
||||
d = boundingOffsetA.x * absOrientationB.v[2].y;
|
||||
d += boundingOffsetA.y * absOrientationB.v[2].x;
|
||||
d += boundingOffsetB.x * absOrientationB.v[1].z;
|
||||
d += boundingOffsetB.y * absOrientationB.v[0].z;
|
||||
if( ::Utility::Value::Abs(orientationB.v[3].y*orientationB.v[2].x - orientationB.v[3].x*orientationB.v[2].y) > d ) return false;
|
||||
// s = ( 0,1,0 ) x rotationB.v[1].xyz:
|
||||
d = boundingOffsetA.x * absRotationB.v[1].z;
|
||||
d += boundingOffsetA.z * absRotationB.v[1].x;
|
||||
d += boundingOffsetB.x * absRotationB.v[2].y;
|
||||
d += boundingOffsetB.z * absRotationB.v[0].y;
|
||||
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;
|
||||
}
|
||||
|
@ -353,8 +393,8 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
|||
|
||||
bool Intersect( const BoxAxisAligned &box, const Sphere &sphere )
|
||||
{ // by Dan Andersson
|
||||
Float3 e = ::Utility::Value::Max( box.minVertex - sphere.center, Float3::null );
|
||||
e += ::Utility::Value::Max( sphere.center - box.maxVertex, Float3::null );
|
||||
Float3 e = Max( box.minVertex - sphere.center, Float3::null );
|
||||
e += Max( sphere.center - box.maxVertex, Float3::null );
|
||||
|
||||
if( e.Dot(e) > (sphere.radius * sphere.radius) ) return false;
|
||||
return true;
|
||||
|
@ -385,17 +425,17 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
|||
|
||||
bool Intersect( const Box &box, const Point &point )
|
||||
{ // 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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
|
@ -419,11 +459,11 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
|||
|
||||
bool Intersect( const Box &box, const Sphere &sphere )
|
||||
{ // by Dan Andersson
|
||||
Float3 e = sphere.center - box.orientation.v[3].xyz,
|
||||
centerL = Float3( e.Dot(box.orientation.v[0].xyz), e.Dot(box.orientation.v[1].xyz), e.Dot(box.orientation.v[2].xyz) );
|
||||
Float3 e = sphere.center - box.center,
|
||||
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 += ::Utility::Value::Max( centerL - box.boundingOffset, Float3::null );
|
||||
e = Max( (box.boundingOffset + centerL)*=-1.0f, Float3::null );
|
||||
e += Max( centerL - box.boundingOffset, Float3::null );
|
||||
|
||||
if( e.Dot(e) > (sphere.radius * sphere.radius) ) return false;
|
||||
return true;
|
||||
|
@ -440,20 +480,20 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
|||
|
||||
bool Intersect( const Box &boxA, const BoxAxisAligned &boxB )
|
||||
{ // by Dan Andersson
|
||||
Float3 alignedOffsetBoundaries = boxB.maxVertex - boxB.minVertex;
|
||||
Float4x4 translated = boxA.orientation;
|
||||
translated.v[3].xyz -= boxB.minVertex;
|
||||
translated.v[3].xyz += alignedOffsetBoundaries * 0.5f;
|
||||
alignedOffsetBoundaries = ::Utility::Value::Abs(alignedOffsetBoundaries);
|
||||
return Private::FifteenAxisVsAlignedAxisOverlappingChecks( alignedOffsetBoundaries, boxA.boundingOffset, translated );
|
||||
Float3 alignedOffsetBoundaries = (boxB.maxVertex - boxB.minVertex) * 0.5f,
|
||||
offset = boxA.center - Average( boxB.minVertex, boxB.maxVertex );
|
||||
return Private::SeperatingAxisTest_AxisAlignedVsTransformedBox( alignedOffsetBoundaries, boxA.boundingOffset, boxA.rotation, offset );
|
||||
}
|
||||
|
||||
bool Intersect( const Box &boxA, const Box &boxB )
|
||||
{ // by Dan Andersson
|
||||
Float4x4 M;
|
||||
InverseOrientationMatrix( boxA.orientation, M );
|
||||
TransformMatrix( M, boxB.orientation, M ); /// TODO: not verified
|
||||
return Private::FifteenAxisVsAlignedAxisOverlappingChecks( boxA.boundingOffset, boxB.boundingOffset, M );
|
||||
Float4x4 orientationA = OrientationMatrix(boxA.rotation, boxA.center),
|
||||
orientationB = OrientationMatrix(boxB.rotation, boxB.center),
|
||||
invOrientationA = InverseOrientationMatrix( orientationA );
|
||||
|
||||
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 )
|
||||
|
@ -490,37 +530,37 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
|||
if( Intersect(frustrum.leftPlane, ray, distance) )
|
||||
{
|
||||
intersected = true;
|
||||
connectDistance = ::Utility::Value::Min( connectDistance, distance );
|
||||
connectDistance = Min( connectDistance, distance );
|
||||
}
|
||||
|
||||
if( Intersect(frustrum.rightPlane, ray, distance) )
|
||||
{
|
||||
intersected = true;
|
||||
connectDistance = ::Utility::Value::Min( connectDistance, distance );
|
||||
connectDistance = Min( connectDistance, distance );
|
||||
}
|
||||
|
||||
if( Intersect(frustrum.bottomPlane, ray, distance) )
|
||||
{
|
||||
intersected = true;
|
||||
connectDistance = ::Utility::Value::Min( connectDistance, distance );
|
||||
connectDistance = Min( connectDistance, distance );
|
||||
}
|
||||
|
||||
if( Intersect(frustrum.topPlane, ray, distance) )
|
||||
{
|
||||
intersected = true;
|
||||
connectDistance = ::Utility::Value::Min( connectDistance, distance );
|
||||
connectDistance = Min( connectDistance, distance );
|
||||
}
|
||||
|
||||
if( Intersect(frustrum.nearPlane, ray, distance) )
|
||||
{
|
||||
intersected = true;
|
||||
connectDistance = ::Utility::Value::Min( connectDistance, distance );
|
||||
connectDistance = Min( connectDistance, distance );
|
||||
}
|
||||
|
||||
if( Intersect(frustrum.farPlane, ray, distance) )
|
||||
{
|
||||
intersected = true;
|
||||
connectDistance = ::Utility::Value::Min( connectDistance, distance );
|
||||
connectDistance = Min( connectDistance, distance );
|
||||
}
|
||||
|
||||
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
|
||||
******************************************************************/
|
||||
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
|
||||
******************************************************************/
|
||||
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
|
||||
******************************************************************/
|
||||
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
|
||||
******************************************************************/
|
||||
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
|
||||
******************************************************************/
|
||||
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
|
||||
******************************************************************/
|
||||
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
|
||||
******************************************************************/
|
||||
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
|
||||
******************************************************************/
|
||||
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
|
||||
******************************************************************/
|
||||
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
|
||||
******************************************************************/
|
||||
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
|
||||
******************************************************************/
|
||||
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;
|
||||
}
|
||||
|
||||
inline ::Oyster::Math::Float3 Impulse( )
|
||||
{
|
||||
//! @todo TODO: implement calculation for impulse. Hijack Mattias Eriksson
|
||||
return ::Oyster::Math::Float3::null;
|
||||
}
|
||||
|
||||
namespace MomentOfInertia
|
||||
{ /// Library of Formulas to calculate moment of inerta for simple shapes
|
||||
/** @todo TODO: add MomentOfInertia tensor formulas */
|
||||
|
|
|
@ -39,20 +39,21 @@ RigidBody & RigidBody::operator = ( const RigidBody &body )
|
|||
void RigidBody::Update_LeapFrog( Float deltaTime )
|
||||
{ // 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
|
||||
// dv = dt * a = dt * F / m
|
||||
// ds = dt * avg_v
|
||||
Float3 deltaLinearVelocity = this->impulseForceSum;
|
||||
deltaLinearVelocity *= (deltaTime / this->mass);
|
||||
Float3 deltaPos = deltaTime * ::Utility::Value::AverageWithDelta( Formula::LinearVelocity(this->mass, this->linearMomentum), deltaLinearVelocity );
|
||||
// dG = F * dt
|
||||
// ds = dt * Formula::LinearVelocity( m, avg_G ) = dt * avg_G / m = (dt / m) * avg_G
|
||||
Float3 linearImpulse = this->impulseForceSum * deltaTime; // aka deltaLinearMomentum
|
||||
Float3 deltaPos = ( deltaTime / this->mass ) * ::Utility::Value::AverageWithDelta( this->linearMomentum, linearImpulse );
|
||||
|
||||
// updating the angular
|
||||
// dw = dt * a = dt * ( I^-1 * T )
|
||||
// rotation = dt * avg_w
|
||||
Float4x4 inversedMomentOfInertiaTensor = this->momentOfInertiaTensor.GetInverse();
|
||||
Float3 deltaAngularVelocity = Formula::AngularImpulseAcceleration( inversedMomentOfInertiaTensor, this->impulseTorqueSum ); // I^-1 * T
|
||||
deltaAngularVelocity *= deltaTime;
|
||||
Float3 rotationAxis = ::Utility::Value::AverageWithDelta( Formula::AngularVelocity(inversedMomentOfInertiaTensor,this->angularMomentum), deltaAngularVelocity );
|
||||
// dH = T * dt
|
||||
// dO = dt * Formula::AngularVelocity( (RI)^-1, avg_H ) = dt * (RI)^-1 * avg_H
|
||||
Float3 angularImpulse = this->impulseTorqueSum * deltaTime; // aka deltaAngularMomentum
|
||||
Float3 rotationAxis = Formula::AngularVelocity( wMomentOfInertiaTensor.GetInverse(),
|
||||
::Utility::Value::AverageWithDelta(this->angularMomentum, angularImpulse) );
|
||||
|
||||
Float deltaRadian = rotationAxis.Dot( rotationAxis );
|
||||
if( deltaRadian != 0.0f )
|
||||
|
@ -60,95 +61,72 @@ void RigidBody::Update_LeapFrog( Float deltaTime )
|
|||
deltaRadian = ::std::sqrt( deltaRadian );
|
||||
rotationAxis /= deltaRadian;
|
||||
|
||||
// using rotationAxis, deltaRadian and deltaPos to create a matrix to update the orientation matrix
|
||||
UpdateOrientationMatrix( deltaPos, RotationMatrix(deltaRadian, rotationAxis), this->box.orientation );
|
||||
|
||||
/** @todo TODO: ISSUE! how is momentOfInertiaTensor related to the orientation of the RigidBody? */
|
||||
// using rotationAxis, deltaRadian and deltaPos to create a matrix to update the box
|
||||
this->box.center += deltaPos;
|
||||
TransformMatrix( RotationMatrix(deltaRadian, rotationAxis), this->box.rotation, this->box.rotation );
|
||||
}
|
||||
else
|
||||
{ // no rotation, only use deltaPos to translate the RigidBody
|
||||
this->box.center += deltaPos;
|
||||
}
|
||||
|
||||
// update movements and clear impulses
|
||||
this->linearMomentum += Formula::LinearMomentum( this->mass, deltaLinearVelocity );
|
||||
// update momentums and clear impulseForceSum and impulseTorqueSum
|
||||
this->linearMomentum += linearImpulse;
|
||||
this->impulseForceSum = Float3::null;
|
||||
this->angularMomentum += Formula::AngularMomentum( this->momentOfInertiaTensor, deltaAngularVelocity );
|
||||
this->angularMomentum += angularImpulse;
|
||||
this->impulseTorqueSum = Float3::null;
|
||||
}
|
||||
|
||||
void RigidBody::ApplyImpulseForce( const Float3 &f )
|
||||
void RigidBody::ApplyImpulseForce( const Float3 &worldF )
|
||||
{ // 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
|
||||
if( localOffset != Float3::null )
|
||||
Float3 worldOffset = worldPos - this->box.center;
|
||||
if( worldOffset != Float3::null )
|
||||
{
|
||||
this->impulseForceSum += VectorProjection( localForce, localOffset );
|
||||
this->impulseTorqueSum += Formula::ImpulseTorque( localForce, localOffset );
|
||||
this->impulseForceSum += VectorProjection( worldF, worldOffset );
|
||||
this->impulseTorqueSum += Formula::ImpulseTorque( worldF, worldOffset );
|
||||
}
|
||||
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
|
||||
Float4x4 view = this->GetView();
|
||||
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
|
||||
this->impulseForceSum += Formula::ImpulseForce( this->mass, worldA );
|
||||
}
|
||||
|
||||
void RigidBody::ApplyLinearImpulseAcceleration( const Float3 &a )
|
||||
void RigidBody::ApplyLinearImpulseAccelerationAt( const Float3 &worldA, const Float3 &worldPos )
|
||||
{ // by Dan Andersson
|
||||
this->impulseForceSum += Formula::ImpulseForce( this->mass, a );
|
||||
}
|
||||
|
||||
void RigidBody::ApplyLinearImpulseAccelerationAt_Local( const Float3 &localImpulseLinearAcc, const Float3 &localOffset )
|
||||
{ // by Dan Andersson
|
||||
if( localOffset != Float3::null )
|
||||
Float3 worldOffset = worldPos - this->box.center;
|
||||
if( worldOffset != Float3::null )
|
||||
{
|
||||
this->impulseForceSum += Formula::ImpulseForce( this->mass, VectorProjection(localImpulseLinearAcc, localOffset) );
|
||||
this->impulseForceSum += Formula::ImpulseForce( this->mass, VectorProjection(worldA, worldOffset) );
|
||||
|
||||
// tanAcc = angularAcc x localPosition
|
||||
// angularAcc = localPosition x tanAcc = localPosition x linearAcc
|
||||
// T = I * angularAcc
|
||||
this->impulseTorqueSum += Formula::ImpulseTorque( this->momentOfInertiaTensor, Formula::AngularImpulseAcceleration(localImpulseLinearAcc, localOffset) );
|
||||
this->impulseTorqueSum += Formula::ImpulseTorque( this->momentOfInertiaTensor, Formula::AngularImpulseAcceleration(worldA, worldOffset) );
|
||||
}
|
||||
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
|
||||
Float4x4 view = this->GetView();
|
||||
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
|
||||
this->impulseTorqueSum += worldT;
|
||||
}
|
||||
|
||||
void RigidBody::ApplyImpulseTorque( const Float3 &t )
|
||||
void RigidBody::ApplyAngularImpulseAcceleration( const Float3 &worldA )
|
||||
{ // by Dan Andersson
|
||||
this->impulseTorqueSum += t;
|
||||
}
|
||||
|
||||
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;
|
||||
this->impulseTorqueSum += Formula::ImpulseTorque( this->momentOfInertiaTensor, worldA );
|
||||
}
|
||||
|
||||
Float3 & RigidBody::AccessBoundingReach()
|
||||
|
@ -181,14 +159,14 @@ const Float & RigidBody::GetMass() const
|
|||
return this->mass;
|
||||
}
|
||||
|
||||
const Float4x4 & RigidBody::GetOrientation() const
|
||||
const Float4x4 RigidBody::GetOrientation() const
|
||||
{ // by Dan Andersson
|
||||
return this->box.orientation;
|
||||
return OrientationMatrix( this->box.rotation, this->box.center );
|
||||
}
|
||||
|
||||
Float4x4 RigidBody::GetView() const
|
||||
{ // by Dan Andersson
|
||||
return InverseOrientationMatrix( this->box.orientation );
|
||||
return InverseOrientationMatrix( this->GetOrientation() );
|
||||
}
|
||||
|
||||
const Float3 & RigidBody::GetBoundingReach() const
|
||||
|
@ -246,106 +224,21 @@ Float3 RigidBody::GetLinearVelocity() const
|
|||
return Formula::LinearVelocity( this->mass, this->linearMomentum );
|
||||
}
|
||||
|
||||
Float3 RigidBody::GetTangentialImpulseForceAt_Local( const Float3 &localPos ) const
|
||||
{ // by Dan Andersson
|
||||
return Formula::TangentialImpulseForce( this->impulseTorqueSum, localPos );
|
||||
void RigidBody::GetMomentumAt( const Float3 &worldPos, const Float3 &surfaceNormal, Float3 &normalMomentum, Float3 &tangentialMomentum ) const
|
||||
{
|
||||
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
|
||||
return this->GetTangentialImpulseForceAt_Local( (this->GetView() * Float4(worldPos, 1.0f)).xyz ); // should not be any disform thus result.w = 1.0f
|
||||
}
|
||||
|
||||
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
|
||||
if( localI.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 )
|
||||
{ // 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 )
|
||||
|
@ -377,98 +271,77 @@ void RigidBody::SetSize( const Float3 &widthHeight )
|
|||
this->box.boundingOffset = 0.5f * widthHeight;
|
||||
}
|
||||
|
||||
void RigidBody::SetCenter( const Float3 &p )
|
||||
void RigidBody::SetCenter( const Float3 &worldPos )
|
||||
{ // 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
|
||||
this->impulseTorqueSum = t;
|
||||
this->impulseTorqueSum = worldT;
|
||||
}
|
||||
|
||||
void RigidBody::SetAngularMomentum( const Float3 &h )
|
||||
void RigidBody::SetAngularMomentum( const Float3 &worldH )
|
||||
{ // by Dan Andersson
|
||||
this->angularMomentum = h;
|
||||
this->angularMomentum = worldH;
|
||||
}
|
||||
|
||||
void RigidBody::SetAngularImpulseAcceleration( const Float3 &a )
|
||||
void RigidBody::SetAngularImpulseAcceleration( const Float3 &worldA )
|
||||
{ // 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
|
||||
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
|
||||
this->impulseForceSum = f;
|
||||
this->impulseForceSum = worldF;
|
||||
}
|
||||
|
||||
void RigidBody::SetLinearMomentum( const Float3 &g )
|
||||
void RigidBody::SetLinearMomentum( const Float3 &worldG )
|
||||
{ // by Dan Andersson
|
||||
this->linearMomentum = g;
|
||||
this->linearMomentum = worldG;
|
||||
}
|
||||
|
||||
void RigidBody::SetLinearImpulseAcceleration( const Float3 &a )
|
||||
void RigidBody::SetLinearImpulseAcceleration( const Float3 &worldA )
|
||||
{ // 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
|
||||
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
|
||||
// Reminder! Impulse force and torque is world values.
|
||||
Float3 worldForce = ( this->box.orientation * Float4(localForce, 0.0f) ).xyz,
|
||||
worldPos = ( this->box.orientation * Float4(localPos, 1.0f) ).xyz;
|
||||
this->SetImpulseForceAt_World( worldForce, worldPos );
|
||||
|
||||
Float3 worldOffset = worldPos - this->box.center;
|
||||
this->impulseForceSum = VectorProjection( worldForce, worldOffset );
|
||||
this->impulseTorqueSum = Formula::ImpulseTorque( worldForce, worldOffset );
|
||||
}
|
||||
|
||||
void RigidBody::SetImpulseForceAt_World( const Float3 &worldForce, const Float3 &worldPos )
|
||||
void RigidBody::SetLinearMomentumAt( const Float3 &worldG, const Float3 &worldPos )
|
||||
{ // by Dan Andersson
|
||||
// Reminder! Impulse force and torque is world values.
|
||||
this->impulseForceSum = VectorProjection( worldForce, worldPos );
|
||||
this->impulseTorqueSum = Formula::ImpulseTorque( worldForce, worldPos );
|
||||
Float3 worldOffset = worldPos - this->box.center;
|
||||
this->linearMomentum = VectorProjection( worldG, worldOffset );
|
||||
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
|
||||
// Reminder! Linear and angular momentum is world values.
|
||||
Float3 worldG = ( this->box.orientation * Float4(localG, 0.0f) ).xyz,
|
||||
worldPos = ( this->box.orientation * Float4(localPos, 1.0f) ).xyz;
|
||||
this->SetLinearMomentumAt_World( worldG, worldPos );
|
||||
Float3 worldOffset = worldPos - this->box.center;
|
||||
this->impulseForceSum = Formula::ImpulseForce( this->mass, VectorProjection(worldA, worldOffset) );
|
||||
this->impulseTorqueSum = Formula::ImpulseTorque( this->box.rotation * this->momentOfInertiaTensor,
|
||||
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
|
||||
// Reminder! Linear and angular momentum is world values.
|
||||
this->linearMomentum = VectorProjection( worldG, worldPos );
|
||||
this->angularMomentum = Formula::AngularMomentum( worldG, worldPos );
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
Float3 worldOffset = worldPos - this->box.center;
|
||||
this->linearMomentum = Formula::LinearMomentum( this->mass, VectorProjection(worldV, worldOffset) );
|
||||
this->angularMomentum = Formula::AngularMomentum( this->box.rotation * this->momentOfInertiaTensor,
|
||||
Formula::AngularVelocity(worldV, worldOffset) );
|
||||
}
|
|
@ -14,30 +14,26 @@ namespace Oyster { namespace Physics3D
|
|||
struct RigidBody
|
||||
{ /// A struct of a simple rigid body.
|
||||
public:
|
||||
::Oyster::Collision3D::Box box; /// Contains data representing physical presence.
|
||||
::Oyster::Math::Float3 angularMomentum, /// The angular momentum H (Nm*s) around an parallell axis.
|
||||
linearMomentum, /// The linear momentum G (kg*m/s).
|
||||
impulseTorqueSum, /// The impulse torque T (Nm) that will be consumed each update.
|
||||
impulseForceSum; /// The impulse force F (N) that will be consumed each update.
|
||||
::Oyster::Collision3D::Box box; /** Contains data representing physical presence. (worldValue) */
|
||||
::Oyster::Math::Float3 angularMomentum, /** The angular momentum H (Nm*s) around an parallell axis. (worldValue) */
|
||||
linearMomentum, /** The linear momentum G (kg*m/s). (worldValue) */
|
||||
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. (worldValue) */
|
||||
|
||||
RigidBody( const ::Oyster::Collision3D::Box &box = ::Oyster::Collision3D::Box(), ::Oyster::Math::Float mass = 1.0f );
|
||||
|
||||
RigidBody & operator = ( const RigidBody &body );
|
||||
|
||||
void Update_LeapFrog( ::Oyster::Math::Float deltaTime );
|
||||
void ApplyImpulseForce( const ::Oyster::Math::Float3 &f );
|
||||
void ApplyImpulseForceAt_Local( const ::Oyster::Math::Float3 &f, const ::Oyster::Math::Float3 &pos );
|
||||
void ApplyImpulseForceAt_World( const ::Oyster::Math::Float3 &f, const ::Oyster::Math::Float3 &pos ); /// ApplyImpulseForce_LocalPos is preferred
|
||||
void ApplyLinearImpulseAcceleration( const ::Oyster::Math::Float3 &a );
|
||||
void ApplyLinearImpulseAccelerationAt_Local( const ::Oyster::Math::Float3 &a, const ::Oyster::Math::Float3 &pos );
|
||||
void ApplyLinearImpulseAccelerationAt_World( const ::Oyster::Math::Float3 &a, const ::Oyster::Math::Float3 &pos ); /// ApplyLinearImpulseAcceleration_LocalPos is preferred
|
||||
void ApplyImpulseTorque( const ::Oyster::Math::Float3 &t );
|
||||
void ApplyAngularImpulseAcceleration( const ::Oyster::Math::Float3 &a );
|
||||
void ApplyImpulseForce( const ::Oyster::Math::Float3 &worldF );
|
||||
void ApplyImpulseForceAt( const ::Oyster::Math::Float3 &worldF, const ::Oyster::Math::Float3 &worldPos );
|
||||
void ApplyLinearImpulseAcceleration( const ::Oyster::Math::Float3 &worldA );
|
||||
void ApplyLinearImpulseAccelerationAt( const ::Oyster::Math::Float3 &worldA, const ::Oyster::Math::Float3 &worldPos );
|
||||
void ApplyImpulseTorque( const ::Oyster::Math::Float3 &worldT );
|
||||
void ApplyAngularImpulseAcceleration( const ::Oyster::Math::Float3 &worldA );
|
||||
|
||||
// ACCESS METHODS /////////////////////////////
|
||||
|
||||
::Oyster::Math::Float4x4 & AccessOrientation();
|
||||
const ::Oyster::Math::Float4x4 & AccessOrientation() const;
|
||||
::Oyster::Math::Float3 & AccessBoundingReach();
|
||||
const ::Oyster::Math::Float3 & AccessBoundingReach() const;
|
||||
::Oyster::Math::Float3 & AccessCenter();
|
||||
|
@ -48,7 +44,7 @@ namespace Oyster { namespace Physics3D
|
|||
const ::Oyster::Math::Float4x4 & GetMomentOfInertia() const;
|
||||
const ::Oyster::Math::Float & GetMass() const;
|
||||
|
||||
const ::Oyster::Math::Float4x4 & GetOrientation() const;
|
||||
const ::Oyster::Math::Float4x4 GetOrientation() const;
|
||||
::Oyster::Math::Float4x4 GetView() const;
|
||||
const ::Oyster::Math::Float4x4 & GetToWorldMatrix() const;
|
||||
::Oyster::Math::Float4x4 GetToLocalMatrix() const;
|
||||
|
@ -68,56 +64,36 @@ namespace Oyster { namespace Physics3D
|
|||
::Oyster::Math::Float3 GetLinearImpulseAcceleration() const;
|
||||
::Oyster::Math::Float3 GetLinearVelocity() const;
|
||||
|
||||
::Oyster::Math::Float3 GetTangentialImpulseForceAt_Local( const ::Oyster::Math::Float3 &pos ) 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;
|
||||
void GetMomentumAt( const ::Oyster::Math::Float3 &worldPos, const ::Oyster::Math::Float3 &surfaceNormal, ::Oyster::Math::Float3 &normalMomentum, ::Oyster::Math::Float3 &tangentialMomentum ) const;
|
||||
|
||||
// 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_KeepMomentum( const ::Oyster::Math::Float &m );
|
||||
|
||||
void SetOrientation( const ::Oyster::Math::Float4x4 &o );
|
||||
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 SetAngularMomentum( const ::Oyster::Math::Float3 &h );
|
||||
void SetAngularImpulseAcceleration( const ::Oyster::Math::Float3 &a );
|
||||
void SetAngularVelocity( const ::Oyster::Math::Float3 &w );
|
||||
void SetImpulseTorque( const ::Oyster::Math::Float3 &worldT );
|
||||
void SetAngularMomentum( const ::Oyster::Math::Float3 &worldH );
|
||||
void SetAngularImpulseAcceleration( const ::Oyster::Math::Float3 &worldA );
|
||||
void SetAngularVelocity( const ::Oyster::Math::Float3 &worldW );
|
||||
|
||||
void SetImpulseForce( const ::Oyster::Math::Float3 &f );
|
||||
void SetLinearMomentum( const ::Oyster::Math::Float3 &g );
|
||||
void SetLinearImpulseAcceleration( const ::Oyster::Math::Float3 &a );
|
||||
void SetLinearVelocity( const ::Oyster::Math::Float3 &v );
|
||||
void SetImpulseForce( const ::Oyster::Math::Float3 &worldF );
|
||||
void SetLinearMomentum( const ::Oyster::Math::Float3 &worldG );
|
||||
void SetLinearImpulseAcceleration( const ::Oyster::Math::Float3 &worldA );
|
||||
void SetLinearVelocity( const ::Oyster::Math::Float3 &worldV );
|
||||
|
||||
void SetImpulseForceAt_Local( const ::Oyster::Math::Float3 &f, const ::Oyster::Math::Float3 &pos );
|
||||
void SetImpulseForceAt_World( const ::Oyster::Math::Float3 &f, const ::Oyster::Math::Float3 &pos );
|
||||
void SetLinearMomentumAt_Local( const ::Oyster::Math::Float3 &g, const ::Oyster::Math::Float3 &pos );
|
||||
void SetLinearMomentumAt_World( const ::Oyster::Math::Float3 &g, const ::Oyster::Math::Float3 &pos );
|
||||
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 );
|
||||
void SetImpulseForceAt( const ::Oyster::Math::Float3 &worldF, const ::Oyster::Math::Float3 &worldPos );
|
||||
void SetLinearMomentumAt( const ::Oyster::Math::Float3 &worldG, const ::Oyster::Math::Float3 &worldPos );
|
||||
void SetImpulseAccelerationAt( const ::Oyster::Math::Float3 &worldA, const ::Oyster::Math::Float3 &worldPos );
|
||||
void SetLinearVelocityAt( const ::Oyster::Math::Float3 &worldV, const ::Oyster::Math::Float3 &worldPos );
|
||||
|
||||
private:
|
||||
::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::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 ) (localValue) */
|
||||
};
|
||||
|
||||
// INLINE IMPLEMENTATIONS ///////////////////////////////////////
|
||||
|
|
Binary file not shown.
|
@ -1,2 +0,0 @@
|
|||
#v4.0:v110:false
|
||||
Debug|Win32|C:\DanBias\Danbias\|
|
|
@ -1,13 +0,0 @@
|
|||
Build started 11/15/2013 11:04:26 AM.
|
||||
1>Project "C:\DanBias\Danbias\Tester\Tester.vcxproj" on node 3 (Build target(s)).
|
||||
1>Link:
|
||||
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"C:\DanBias\Danbias\Debug\Tester.exe" /INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:\DanBias\Danbias\Debug\Tester.pdb" /SUBSYSTEM:WINDOWS /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\DanBias\Danbias\Debug\Tester.lib" /MACHINE:X86 Debug\MainTest.obj
|
||||
C:\DanBias\External\Lib\Misc\Misc_x86D.lib
|
||||
C:\DanBias\External\Lib\OysterMath\OysterMath_x86D.lib
|
||||
C:\DanBias\External\Lib\OysterGraphics\OysterGraphics_x86D.lib
|
||||
Tester.vcxproj -> C:\DanBias\Danbias\Debug\Tester.exe
|
||||
1>Done Building Project "C:\DanBias\Danbias\Tester\Tester.vcxproj" (Build target(s)).
|
||||
|
||||
Build succeeded.
|
||||
|
||||
Time Elapsed 00:00:00.98
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -7,14 +7,21 @@
|
|||
//--------------------------------------------------------------------------------------
|
||||
#define NOMINMAX
|
||||
#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
|
||||
//--------------------------------------------------------------------------------------
|
||||
HINSTANCE g_hInst = 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;;
|
||||
|
||||
Oyster::Engine::Init::Setup setup;
|
||||
setup.Fullscreen = false;
|
||||
setup.ForceDX11 = true;
|
||||
setup.SingleThreaded = true;
|
||||
setup.window = g_hWnd;
|
||||
Oyster::Graphics::Core::resolution = Oyster::Math::Float2( 1024, 768 );
|
||||
|
||||
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\\";
|
||||
std::wstring EffectPath = L"SimpleDebug\\";
|
||||
//Init shaders
|
||||
Oyster::Graphics::Render::Resources::Init();
|
||||
|
||||
Oyster::Core::ShaderManager::Init(ShaderPath + EffectPath + L"DebugPixel.hlsl",Oyster::Core::ShaderManager::ShaderType::Pixel,L"Debug",false);
|
||||
Oyster::Core::ShaderManager::Init(ShaderPath + EffectPath + L"DebugVertex.hlsl",Oyster::Core::ShaderManager::ShaderType::Vertex,L"Debug",false);
|
||||
Oyster::Graphics::Render::Preparations::Basic::SetViewPort();
|
||||
|
||||
Oyster::Core::ShaderManager::Set::Vertex(Oyster::Core::ShaderManager::Get::Vertex(L"Debug"));
|
||||
Oyster::Core::ShaderManager::Set::Pixel(Oyster::Core::ShaderManager::Get::Pixel(L"Debug"));
|
||||
#pragma region Triangle
|
||||
//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[] =
|
||||
{
|
||||
{ "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }
|
||||
};
|
||||
//Oyster::Graphics::Buffer::BUFFER_INIT_DESC desc;
|
||||
//desc.ElementSize= sizeof(Oyster::Graphics::Definitions::ObjVertex);
|
||||
//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);
|
||||
Oyster::Core::DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
//m->info = mi;
|
||||
#pragma endregion
|
||||
|
||||
Oyster::Engine::PrepareForRendering::BindBackBuffer();
|
||||
#pragma region Obj
|
||||
OBJReader or;
|
||||
or.readOBJFile(L"bth.obj");
|
||||
m->info = or.toModel();
|
||||
#pragma endregion
|
||||
|
||||
struct float4
|
||||
{
|
||||
float x,y,z,w;
|
||||
};
|
||||
m->World = Oyster::Math::Matrix::identity;
|
||||
|
||||
float4 mesh[] =
|
||||
{
|
||||
{-1.0f,1.0f,0.0f,1.0f},
|
||||
{1.0f,1.0f,0.0f,1.0f},
|
||||
{1.0f,-1.0f,0.0f,1.0f},
|
||||
};
|
||||
P = Oyster::Math3D::ProjectionMatrix_Perspective(PI/2,16.0f/9.0f,.1f,100);
|
||||
|
||||
Oyster::Buffer::BUFFER_INIT_DESC desc;
|
||||
desc.ElementSize= sizeof(float4);
|
||||
desc.NumElements = 3;
|
||||
desc.InitData=mesh;
|
||||
desc.Type = Oyster::Buffer::BUFFER_TYPE::VERTEX_BUFFER;
|
||||
desc.Usage = Oyster::Buffer::BUFFER_USAGE::BUFFER_USAGE_IMMUTABLE;
|
||||
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));
|
||||
V = Oyster::Math3D::InverseOrientationMatrix(V);
|
||||
|
||||
Oyster::Buffer b;
|
||||
b.Init(desc);
|
||||
b.Apply(0);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -195,11 +199,18 @@ HRESULT Update(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;
|
||||
}
|
||||
|
|
|
@ -69,18 +69,26 @@
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)..\Bin\Executable\$(ProjectName)\</OutDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)..\Bin\Executable\$(ProjectName)\</OutDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)..\Bin\Executable\$(ProjectName)\</OutDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)..\Bin\Executable\$(ProjectName)\</OutDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
|
|
@ -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