Merge remote-tracking branch 'origin/Graphics' into GameLogicBranch

Conflicts:
	Bin/DLL/GamePhysics_x86D.dll
	Bin/DLL/GamePhysics_x86D.exp
	Bin/DLL/GamePhysics_x86D.ilk
	Bin/DLL/GamePhysics_x86D.pdb
	Code/OysterGraphics/OysterGraphics.vcxproj
	Code/OysterGraphics/OysterGraphics.vcxproj.filters
	Code/OysterGraphics/OysterGraphics.vcxproj.filters.orig
This commit is contained in:
Erik Persson 2013-11-27 09:12:21 +01:00
commit 61777e23df
90 changed files with 35541 additions and 515 deletions

Binary file not shown.

BIN
Bin/DLL/DebugPixel.cso Normal file

Binary file not shown.

BIN
Bin/DLL/DebugVertex.cso Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Bin/DLL/PixelGatherData.cso Normal file

Binary file not shown.

Binary file not shown.

View File

@ -149,14 +149,17 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Implementation\Octree.h" />
<ClInclude Include="Implementation\PhysicsAPI_Impl.h" /> <ClInclude Include="Implementation\PhysicsAPI_Impl.h" />
<ClInclude Include="Implementation\SimpleRigidBody.h" /> <ClInclude Include="Implementation\SimpleRigidBody.h" />
<ClInclude Include="Implementation\SphericalRigidBody.h" />
<ClInclude Include="PhysicsAPI.h" /> <ClInclude Include="PhysicsAPI.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="Implementation\DLLMain.cpp" />
<ClCompile Include="Implementation\PhysicsAPI_Impl.cpp" /> <ClCompile Include="Implementation\PhysicsAPI_Impl.cpp" />
<ClCompile Include="Implementation\SimpleRigidBody.cpp" /> <ClCompile Include="Implementation\SimpleRigidBody.cpp" />
<ClCompile Include="DLLMain.cpp" /> <ClCompile Include="Implementation\SphericalRigidBody.cpp" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

View File

@ -30,6 +30,9 @@
<ClInclude Include="Implementation\SimpleRigidBody.h"> <ClInclude Include="Implementation\SimpleRigidBody.h">
<Filter>Header Files\Implementation</Filter> <Filter>Header Files\Implementation</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Implementation\SphericalRigidBody.h">
<Filter>Header Files\Implementation</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="Implementation\PhysicsAPI_Impl.cpp"> <ClCompile Include="Implementation\PhysicsAPI_Impl.cpp">
@ -38,7 +41,10 @@
<ClCompile Include="Implementation\SimpleRigidBody.cpp"> <ClCompile Include="Implementation\SimpleRigidBody.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="DLLMain.cpp"> <ClCompile Include="Implementation\DLLMain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Implementation\SphericalRigidBody.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>

View File

@ -0,0 +1,57 @@
#ifndef OCTREE_H
#define OCTREE_H
#include <vector>
#include <map>
#include "Sphere.h"
#include "BoxAxisAligned.h"
#include "Utilities.h"
#include "../PhysicsAPI.h"
namespace Oyster
{
namespace Physics
{
class Octree
{
public:
struct Data
{
Data* prev;
Data* next;
Collision3D::Sphere container;
Utility::DynamicMemory::UniquePointer< ICustomBody > customBodyRef;
unsigned int queueRef;
};
struct OctreeNode
{
};
Octree(unsigned int bufferSize, unsigned char numLayers, Math::Float3 worldSize);
virtual ~Octree();
void AddObject(Utility::DynamicMemory::UniquePointer< ICustomBody > customBodyRef);
void MoveToUpdateQueue(Utility::DynamicMemory::UniquePointer< ICustomBody > customBodyRef);
void Update();
void DestroyObject(Utility::DynamicMemory::UniquePointer< ICustomBody > customBodyRef);
void Sample(Collision3D::ICollideable& collideable);
private:
std::vector < Data > leafData;
std::map< ICustomBody*, unsigned int > mapReferences;
};
}
}
#endif

View File

@ -3,67 +3,80 @@
#include "OysterPhysics3D.h" #include "OysterPhysics3D.h"
using namespace ::Oyster::Physics; using namespace ::Oyster::Physics;
using namespace ::Oyster::Physics3D;
using namespace ::Oyster::Math; using namespace ::Oyster::Math;
using namespace ::Oyster::Collision3D; using namespace ::Oyster::Collision3D;
using namespace ::Utility::DynamicMemory; using namespace ::Utility::DynamicMemory;
API_Impl instance; API_Impl API_instance;
::Oyster::Math::Float4x4 & MomentOfInertia::CreateSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius) // default API::EventAction_Collision
void defaultCollisionAction( const ICustomBody *proto, const ICustomBody *deuter )
{ /* do nothing */ }
// default API::EventAction_Destruction
void defaultDestructionAction( UniquePointer<ICustomBody> proto )
{ /* do nothing besides proto auto deleting itself. */ }
Float4x4 & MomentOfInertia::CreateSphereMatrix( const Float mass, const Float radius)
{ {
return ::Oyster::Physics3D::Formula::MomentOfInertia::Sphere(mass, radius); return Formula::MomentOfInertia::Sphere(mass, radius);
} }
::Oyster::Math::Float4x4 & MomentOfInertia::CreateHollowSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius) Float4x4 & MomentOfInertia::CreateHollowSphereMatrix( const Float mass, const Float radius)
{ {
return ::Oyster::Physics3D::Formula::MomentOfInertia::HollowSphere(mass, radius); return Formula::MomentOfInertia::HollowSphere(mass, radius);
} }
::Oyster::Math::Float4x4 & MomentOfInertia::CreateCuboidMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float width, const ::Oyster::Math::Float depth ) Float4x4 & MomentOfInertia::CreateCuboidMatrix( const Float mass, const Float height, const Float width, const Float depth )
{ {
return ::Oyster::Physics3D::Formula::MomentOfInertia::Cuboid(mass, height, width, depth); return Formula::MomentOfInertia::Cuboid(mass, height, width, depth);
} }
::Oyster::Math::Float4x4 & MomentOfInertia::CreateCylinderMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float radius ) Float4x4 & MomentOfInertia::CreateCylinderMatrix( const Float mass, const Float height, const Float radius )
{ {
return ::Oyster::Physics3D::Formula::MomentOfInertia::Cylinder(mass, height, radius); return Formula::MomentOfInertia::Cylinder(mass, height, radius);
} }
::Oyster::Math::Float4x4 & MomentOfInertia::CreateRodMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float length ) Float4x4 & MomentOfInertia::CreateRodMatrix( const Float mass, const Float length )
{ {
return ::Oyster::Physics3D::Formula::MomentOfInertia::RodCenter(mass, length); return Formula::MomentOfInertia::RodCenter(mass, length);
} }
API & API::Instance() API & API::Instance()
{ {
return instance; return API_instance;
} }
API_Impl::API_Impl() API_Impl::API_Impl()
{ : gravityConstant( Constant::gravity_constant ),
/** @todo TODO: Fix this constructor.*/ updateFrameLength( 1.0f / 120.0f ),
} collisionAction( defaultCollisionAction ),
destructionAction( defaultDestructionAction )
{}
API_Impl::~API_Impl() API_Impl::~API_Impl() {}
void API_Impl::Init( unsigned int numObjects, unsigned int numGravityWells , const Float3 &worldSize )
{ {
/** @todo TODO: Fix this destructor.*/ //! @todo TODO: implement stub
} }
void API_Impl::SetDeltaTime( float deltaTime ) void API_Impl::SetDeltaTime( float deltaTime )
{ {
/** @todo TODO: Fix this function.*/ updateFrameLength = deltaTime;
} }
void API_Impl::SetGravityConstant( float g ) void API_Impl::SetGravityConstant( float g )
{ {
/** @todo TODO: Fix this function.*/ this->gravityConstant = g;
} }
void API_Impl::SetAction( EventAction_Collision functionPointer ) void API_Impl::SetAction( API::EventAction_Collision functionPointer )
{ {
/** @todo TODO: Fix this function.*/ this->collisionAction = functionPointer;
} }
void API_Impl::SetAction( EventAction_Destruction functionPointer ) void API_Impl::SetAction( API::EventAction_Destruction functionPointer )
{ {
/** @todo TODO: Fix this function.*/ this->destructionAction = functionPointer;
} }
void API_Impl::Update() void API_Impl::Update()
@ -147,6 +160,11 @@ void API_Impl::SetOrientation( const ICustomBody* objRef, const Float4x4 &orient
//! @todo TODO: implement stub //! @todo TODO: implement stub
} }
void API_Impl::SetSize( const ICustomBody* objRef, const Float3 &size )
{
//! @todo TODO: implement stub
}
UniquePointer<ICustomBody> API_Impl::CreateSimpleRigidBody() const UniquePointer<ICustomBody> API_Impl::CreateSimpleRigidBody() const
{ {
return new SimpleRigidBody(); return new SimpleRigidBody();

View File

@ -13,6 +13,8 @@ namespace Oyster
API_Impl(); API_Impl();
virtual ~API_Impl(); virtual ~API_Impl();
void Init( unsigned int numObjects, unsigned int numGravityWells , const ::Oyster::Math::Float3 &worldSize );
void SetDeltaTime( float deltaTime ); void SetDeltaTime( float deltaTime );
void SetGravityConstant( float g ); void SetGravityConstant( float g );
void SetAction( EventAction_Collision functionPointer ); void SetAction( EventAction_Collision functionPointer );
@ -38,10 +40,14 @@ namespace Oyster
void SetCenter( const ICustomBody* objRef, const ::Oyster::Math::Float3 &worldPos ); void SetCenter( const ICustomBody* objRef, const ::Oyster::Math::Float3 &worldPos );
void SetRotation( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &rotation ); void SetRotation( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &rotation );
void SetOrientation( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &orientation ); void SetOrientation( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &orientation );
void SetSize( const ICustomBody* objRef, const ::Oyster::Math::Float3 &size );
::Utility::DynamicMemory::UniquePointer<ICustomBody> CreateSimpleRigidBody() const; ::Utility::DynamicMemory::UniquePointer<ICustomBody> CreateSimpleRigidBody() const;
private:
::Oyster::Math::Float gravityConstant, updateFrameLength;
EventAction_Collision collisionAction;
EventAction_Destruction destructionAction;
}; };
} }
} }

View File

@ -1,19 +1,19 @@
#include "SimpleRigidBody.h" #include "SimpleRigidBody.h"
#include "PhysicsAPI_Impl.h"
using namespace ::Oyster::Physics; using namespace ::Oyster::Physics;
using namespace ::Oyster::Math; using namespace ::Oyster::Math3D;
using namespace ::Oyster::Collision3D; using namespace ::Oyster::Collision3D;
using namespace ::Utility::DynamicMemory; using namespace ::Utility::DynamicMemory;
using namespace ::Utility::Value;
SimpleRigidBody::SimpleRigidBody() SimpleRigidBody::SimpleRigidBody()
{ : previous(), current(),
//! @todo TODO: implement stub gravityNormal(0.0f),
} subscribeCollision(true),
ignoreGravity(false) {}
SimpleRigidBody::~SimpleRigidBody() SimpleRigidBody::~SimpleRigidBody() {}
{
//! @todo TODO: implement stub
}
UniquePointer<ICustomBody> SimpleRigidBody::Clone() const UniquePointer<ICustomBody> SimpleRigidBody::Clone() const
{ {
@ -21,96 +21,132 @@ UniquePointer<ICustomBody> SimpleRigidBody::Clone() const
} }
bool SimpleRigidBody::IsSubscribingCollisions() const bool SimpleRigidBody::IsSubscribingCollisions() const
{ { // Assumption
//! @todo TODO: implement stub return this->subscribeCollision;
return false;
} }
bool SimpleRigidBody::Intersects( const ICustomBody &object, Float &deltaWhen, Float3 &worldPointOfContact ) const bool SimpleRigidBody::IsAffectedByGravity() const
{ {
//! @todo TODO: implement stub return !this->ignoreGravity;
}
bool SimpleRigidBody::Intersects( const ICustomBody &object, Float timeStepLength, Float &deltaWhen, Float3 &worldPointOfContact ) const
{
if( object.Intersects(this->current.box) )
{ //! @todo TODO: better implementation needed
deltaWhen = timeStepLength;
worldPointOfContact = Average( this->current.box.center, object.GetCenter() );
return true;
}
else
{
return false; return false;
}
} }
bool SimpleRigidBody::Intersects( const ICollideable &shape ) const bool SimpleRigidBody::Intersects( const ICollideable &shape ) const
{ {
//! @todo TODO: implement stub return this->current.box.Intersects( shape );
return false;
} }
Sphere & SimpleRigidBody::GetBoundingSphere( Sphere &targetMem ) const Sphere & SimpleRigidBody::GetBoundingSphere( Sphere &targetMem ) const
{ {
//! @todo TODO: implement stub return targetMem = Sphere( this->current.box.center, this->current.box.boundingOffset.GetMagnitude() );
return targetMem = Sphere( Float3::null, 0.0f );
} }
Float3 & SimpleRigidBody::GetNormalAt( const Float3 &worldPos, Float3 &targetMem ) const Float3 & SimpleRigidBody::GetNormalAt( const Float3 &worldPos, Float3 &targetMem ) const
{ {
//! @todo TODO: implement stub //! @todo TODO: better implementation needed
return targetMem = Float3::standard_unit_z; return targetMem = (worldPos - this->current.box.center).GetNormalized();
}
Float3 & SimpleRigidBody::GetGravityNormal( Float3 &targetMem ) const
{
return targetMem = this->gravityNormal;
} }
Float3 & SimpleRigidBody::GetCenter( Float3 &targetMem ) const Float3 & SimpleRigidBody::GetCenter( Float3 &targetMem ) const
{ {
//! @todo TODO: implement stub return targetMem = this->current.box.center;
return targetMem = Float3::null;
} }
Float4x4 & SimpleRigidBody::GetRotation( Float4x4 &targetMem ) const Float4x4 & SimpleRigidBody::GetRotation( Float4x4 &targetMem ) const
{ {
//! @todo TODO: implement stub return targetMem = this->current.box.rotation;
return targetMem = Float4x4::identity;
} }
Float4x4 & SimpleRigidBody::GetOrientation( Float4x4 &targetMem ) const Float4x4 & SimpleRigidBody::GetOrientation( Float4x4 &targetMem ) const
{ {
//! @todo TODO: implement stub return targetMem = this->current.GetOrientation();
return targetMem = Float4x4::identity;
} }
Float4x4 & SimpleRigidBody::GetView( Float4x4 &targetMem ) const Float4x4 & SimpleRigidBody::GetView( Float4x4 &targetMem ) const
{ {
//! @todo TODO: implement stub return targetMem = this->current.GetView();
return targetMem = Float4x4::identity;
} }
UpdateState SimpleRigidBody::Update( Float timeStepLength ) UpdateState SimpleRigidBody::Update( Float timeStepLength )
{ {
//! @todo TODO: implement stub this->previous = this->current; // memorizing the old state
return resting;
this->current.Update_LeapFrog( timeStepLength );
// compare previous and new state and return result
return this->current == this->previous ? resting : altered;
}
void SimpleRigidBody::SetGravity( bool ignore)
{
this->ignoreGravity = ignore;
this->gravityNormal = Float3::null;
}
void SimpleRigidBody::SetGravityNormal( const Float3 &normalizedVector )
{
this->gravityNormal = normalizedVector;
}
void SimpleRigidBody::SetSubscription( bool subscribeCollision )
{
this->subscribeCollision = subscribeCollision;
} }
void SimpleRigidBody::SetMomentOfInertiaTensor_KeepVelocity( const Float4x4 &localI ) void SimpleRigidBody::SetMomentOfInertiaTensor_KeepVelocity( const Float4x4 &localI )
{ {
//! @todo TODO: implement stub this->current.SetMomentOfInertia_KeepVelocity( localI );
} }
void SimpleRigidBody::SetMomentOfInertiaTensor_KeepMomentum( const Float4x4 &localI ) void SimpleRigidBody::SetMomentOfInertiaTensor_KeepMomentum( const Float4x4 &localI )
{ {
//! @todo TODO: implement stub this->current.SetMomentOfInertia_KeepMomentum( localI );
} }
void SimpleRigidBody::SetMass_KeepVelocity( Float m ) void SimpleRigidBody::SetMass_KeepVelocity( Float m )
{ {
//! @todo TODO: implement stub this->current.SetMass_KeepVelocity( m );
} }
void SimpleRigidBody::SetMass_KeepMomentum( Float m ) void SimpleRigidBody::SetMass_KeepMomentum( Float m )
{ {
//! @todo TODO: implement stub this->current.SetMass_KeepMomentum( m );
} }
void SimpleRigidBody::SetCenter( const Float3 &worldPos ) void SimpleRigidBody::SetCenter( const Float3 &worldPos )
{ {
//! @todo TODO: implement stub this->current.SetCenter( worldPos );
} }
void SimpleRigidBody::SetRotation( const Float4x4 &rotation ) void SimpleRigidBody::SetRotation( const Float4x4 &rotation )
{ {
//! @todo TODO: implement stub this->current.SetRotation( rotation );
} }
void SimpleRigidBody::SetOrientation( const Float4x4 &orientation ) void SimpleRigidBody::SetOrientation( const Float4x4 &orientation )
{ {
//! @todo TODO: implement stub this->current.SetOrientation( orientation );
}
void SimpleRigidBody::SetSize( const Float3 &size )
{
this->current.SetSize( size );
} }

View File

@ -2,6 +2,7 @@
#define OYSTER_PHYSICS_SIMPLE_RIGIDBODY_H #define OYSTER_PHYSICS_SIMPLE_RIGIDBODY_H
#include "..\PhysicsAPI.h" #include "..\PhysicsAPI.h"
#include "RigidBody.h"
namespace Oyster { namespace Physics namespace Oyster { namespace Physics
{ {
@ -14,11 +15,13 @@ namespace Oyster { namespace Physics
::Utility::DynamicMemory::UniquePointer<ICustomBody> Clone() const; ::Utility::DynamicMemory::UniquePointer<ICustomBody> Clone() const;
bool IsSubscribingCollisions() const; bool IsSubscribingCollisions() const;
bool Intersects( const ICustomBody &object, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const; bool IsAffectedByGravity() const;
bool Intersects( const ICustomBody &object, ::Oyster::Math::Float timeStepLength, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const;
bool Intersects( const ::Oyster::Collision3D::ICollideable &shape ) const; bool Intersects( const ::Oyster::Collision3D::ICollideable &shape ) const;
::Oyster::Collision3D::Sphere & GetBoundingSphere( ::Oyster::Collision3D::Sphere &targetMem = ::Oyster::Collision3D::Sphere() ) const; ::Oyster::Collision3D::Sphere & GetBoundingSphere( ::Oyster::Collision3D::Sphere &targetMem = ::Oyster::Collision3D::Sphere() ) const;
::Oyster::Math::Float3 & GetNormalAt( const ::Oyster::Math::Float3 &worldPos, ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const; ::Oyster::Math::Float3 & GetNormalAt( const ::Oyster::Math::Float3 &worldPos, ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const;
::Oyster::Math::Float3 & GetGravityNormal( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const;
::Oyster::Math::Float3 & GetCenter( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const; ::Oyster::Math::Float3 & GetCenter( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const;
::Oyster::Math::Float4x4 & GetRotation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const; ::Oyster::Math::Float4x4 & GetRotation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
::Oyster::Math::Float4x4 & GetOrientation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const; ::Oyster::Math::Float4x4 & GetOrientation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
@ -26,6 +29,9 @@ namespace Oyster { namespace Physics
UpdateState Update( ::Oyster::Math::Float timeStepLength ); UpdateState Update( ::Oyster::Math::Float timeStepLength );
void SetGravity( bool ignore);
void SetGravityNormal( const ::Oyster::Math::Float3 &normalizedVector );
void SetSubscription( bool subscribeCollision );
void SetMomentOfInertiaTensor_KeepVelocity( const ::Oyster::Math::Float4x4 &localI ); void SetMomentOfInertiaTensor_KeepVelocity( const ::Oyster::Math::Float4x4 &localI );
void SetMomentOfInertiaTensor_KeepMomentum( const ::Oyster::Math::Float4x4 &localI ); void SetMomentOfInertiaTensor_KeepMomentum( const ::Oyster::Math::Float4x4 &localI );
void SetMass_KeepVelocity( ::Oyster::Math::Float m ); void SetMass_KeepVelocity( ::Oyster::Math::Float m );
@ -33,8 +39,12 @@ namespace Oyster { namespace Physics
void SetCenter( const ::Oyster::Math::Float3 &worldPos ); void SetCenter( const ::Oyster::Math::Float3 &worldPos );
void SetRotation( const ::Oyster::Math::Float4x4 &rotation ); void SetRotation( const ::Oyster::Math::Float4x4 &rotation );
void SetOrientation( const ::Oyster::Math::Float4x4 &orientation ); void SetOrientation( const ::Oyster::Math::Float4x4 &orientation );
void SetSize( const ::Oyster::Math::Float3 &size );
private: private:
::Oyster::Physics3D::RigidBody previous, current;
::Oyster::Math::Float3 gravityNormal;
bool subscribeCollision, ignoreGravity;
}; };
} } } }

View File

@ -0,0 +1,157 @@
#include "SphericalRigidBody.h"
#include "PhysicsAPI_Impl.h"
using namespace ::Oyster::Physics;
using namespace ::Oyster::Math3D;
using namespace ::Oyster::Collision3D;
using namespace ::Utility::DynamicMemory;
using namespace ::Utility::Value;
SphericalRigidBody::SphericalRigidBody()
: previous(), current( Box(Float4x4::identity, Float3::null, Float3(1.0f)) ),
gravityNormal( 0.0f ),
subscribeCollision( true ),
ignoreGravity( false ),
body( Float3::null, 0.5f ) {}
SphericalRigidBody::~SphericalRigidBody() {}
UniquePointer<ICustomBody> SphericalRigidBody::Clone() const
{
return new SphericalRigidBody( *this );
}
bool SphericalRigidBody::IsSubscribingCollisions() const
{ // Assumption
return this->subscribeCollision;
}
bool SphericalRigidBody::IsAffectedByGravity() const
{
return !this->ignoreGravity;
}
bool SphericalRigidBody::Intersects( const ICustomBody &object, Float timeStepLength, Float &deltaWhen, Float3 &worldPointOfContact ) const
{
if( object.Intersects(this->body) )
{ //! @todo TODO: better implementation needed
deltaWhen = timeStepLength;
worldPointOfContact = Average( this->body.center, object.GetCenter() );
return true;
}
else
{
return false;
}
}
bool SphericalRigidBody::Intersects( const ICollideable &shape ) const
{
return this->current.box.Intersects( shape );
}
Sphere & SphericalRigidBody::GetBoundingSphere( Sphere &targetMem ) const
{
return targetMem = this->body;
}
Float3 & SphericalRigidBody::GetNormalAt( const Float3 &worldPos, Float3 &targetMem ) const
{
//! @todo TODO: better implementation needed
return targetMem = (worldPos - this->current.box.center).GetNormalized();
}
Float3 & SphericalRigidBody::GetGravityNormal( Float3 &targetMem ) const
{
return targetMem = this->gravityNormal;
}
Float3 & SphericalRigidBody::GetCenter( Float3 &targetMem ) const
{
return targetMem = this->current.box.center;
}
Float4x4 & SphericalRigidBody::GetRotation( Float4x4 &targetMem ) const
{
return targetMem = this->current.box.rotation;
}
Float4x4 & SphericalRigidBody::GetOrientation( Float4x4 &targetMem ) const
{
return targetMem = this->current.GetOrientation();
}
Float4x4 & SphericalRigidBody::GetView( Float4x4 &targetMem ) const
{
return targetMem = this->current.GetView();
}
UpdateState SphericalRigidBody::Update( Float timeStepLength )
{
this->previous = this->current; // memorizing the old state
this->current.Update_LeapFrog( timeStepLength );
this->body.center = this->current.GetCenter();
// compare previous and new state and return result
return this->current == this->previous ? resting : altered;
}
void SphericalRigidBody::SetGravity( bool ignore)
{
this->ignoreGravity = ignore;
this->gravityNormal = Float3::null;
}
void SphericalRigidBody::SetGravityNormal( const Float3 &normalizedVector )
{
this->gravityNormal = normalizedVector;
}
void SphericalRigidBody::SetSubscription( bool subscribeCollision )
{
this->subscribeCollision = subscribeCollision;
}
void SphericalRigidBody::SetMomentOfInertiaTensor_KeepVelocity( const Float4x4 &localI )
{
this->current.SetMomentOfInertia_KeepVelocity( localI );
}
void SphericalRigidBody::SetMomentOfInertiaTensor_KeepMomentum( const Float4x4 &localI )
{
this->current.SetMomentOfInertia_KeepMomentum( localI );
}
void SphericalRigidBody::SetMass_KeepVelocity( Float m )
{
this->current.SetMass_KeepVelocity( m );
}
void SphericalRigidBody::SetMass_KeepMomentum( Float m )
{
this->current.SetMass_KeepMomentum( m );
}
void SphericalRigidBody::SetCenter( const Float3 &worldPos )
{
this->current.SetCenter( worldPos );
this->body.center = worldPos;
}
void SphericalRigidBody::SetRotation( const Float4x4 &rotation )
{
this->current.SetRotation( rotation );
}
void SphericalRigidBody::SetOrientation( const Float4x4 &orientation )
{
this->current.SetOrientation( orientation );
this->body.center = orientation.v[3].xyz;
}
void SphericalRigidBody::SetSize( const Float3 &size )
{
this->current.SetSize( size );
this->body.radius = 0.5f * Min( Min( size.x, size.y ), size.z ); // inline Min( FloatN )?
}

View File

@ -0,0 +1,53 @@
#ifndef OYSTER_PHYSICS_SPHERICAL_RIGIDBODY_H
#define OYSTER_PHYSICS_SPHERICAL_RIGIDBODY_H
#include "..\PhysicsAPI.h"
#include "RigidBody.h"
#include "Sphere.h"
namespace Oyster { namespace Physics
{
class SphericalRigidBody : public ICustomBody
{
public:
SphericalRigidBody();
virtual ~SphericalRigidBody();
::Utility::DynamicMemory::UniquePointer<ICustomBody> Clone() const;
bool IsSubscribingCollisions() const;
bool IsAffectedByGravity() const;
bool Intersects( const ICustomBody &object, ::Oyster::Math::Float timeStepLength, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const;
bool Intersects( const ::Oyster::Collision3D::ICollideable &shape ) const;
::Oyster::Collision3D::Sphere & GetBoundingSphere( ::Oyster::Collision3D::Sphere &targetMem = ::Oyster::Collision3D::Sphere() ) const;
::Oyster::Math::Float3 & GetNormalAt( const ::Oyster::Math::Float3 &worldPos, ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const;
::Oyster::Math::Float3 & GetGravityNormal( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const;
::Oyster::Math::Float3 & GetCenter( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const;
::Oyster::Math::Float4x4 & GetRotation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
::Oyster::Math::Float4x4 & GetOrientation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
::Oyster::Math::Float4x4 & GetView( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
UpdateState Update( ::Oyster::Math::Float timeStepLength );
void SetGravity( bool ignore);
void SetGravityNormal( const ::Oyster::Math::Float3 &normalizedVector );
void SetSubscription( bool subscribeCollision );
void SetMomentOfInertiaTensor_KeepVelocity( const ::Oyster::Math::Float4x4 &localI );
void SetMomentOfInertiaTensor_KeepMomentum( const ::Oyster::Math::Float4x4 &localI );
void SetMass_KeepVelocity( ::Oyster::Math::Float m );
void SetMass_KeepMomentum( ::Oyster::Math::Float m );
void SetCenter( const ::Oyster::Math::Float3 &worldPos );
void SetRotation( const ::Oyster::Math::Float4x4 &rotation );
void SetOrientation( const ::Oyster::Math::Float4x4 &orientation );
void SetSize( const ::Oyster::Math::Float3 &size );
private:
::Oyster::Physics3D::RigidBody previous, current;
::Oyster::Math::Float3 gravityNormal;
bool subscribeCollision, ignoreGravity;
::Oyster::Collision3D::Sphere body;
};
} }
#endif

View File

@ -45,12 +45,20 @@ namespace Oyster
class PHYSICS_DLL_USAGE API class PHYSICS_DLL_USAGE API
{ {
public: public:
typedef void (*EventAction_Collision)( unsigned int, unsigned int ); typedef void (*EventAction_Collision)( const ICustomBody *proto, const ICustomBody *deuter );
typedef void (*EventAction_Destruction)( unsigned int, ::Utility::DynamicMemory::UniquePointer<ICustomBody> ); typedef void (*EventAction_Destruction)( ::Utility::DynamicMemory::UniquePointer<ICustomBody> proto );
/** Gets the Physics instance. */ /** Gets the Physics instance. */
static API & Instance(); static API & Instance();
/********************************************************
* Clears all content and reset Engine assetts such as buffers.
* @param numObjects: The predicted max number of active objects.
* @param numGravityWells: The predicted max number of active gravity wells.
* @param worldSize: The size of acceptable physics space.
********************************************************/
virtual void Init( unsigned int numObjects, unsigned int numGravityWells , const ::Oyster::Math::Float3 &worldSize ) = 0;
/******************************************************** /********************************************************
* Sets the time length of each physics update frame. * Sets the time length of each physics update frame.
********************************************************/ ********************************************************/
@ -196,6 +204,13 @@ namespace Oyster
********************************************************/ ********************************************************/
virtual void SetOrientation( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &orientation ) = 0; virtual void SetOrientation( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &orientation ) = 0;
/********************************************************
* Resizes the boundingBox.
* @param objRef: A pointer to the ICustomBody representing a physical object.
* @param size: New size of this [m]
********************************************************/
virtual void SetSize( const ICustomBody* objRef, const ::Oyster::Math::Float3 &size ) = 0;
/******************************************************** /********************************************************
* Creates a new dynamically allocated object that can be used as a component for more complex ICustomBodies. * Creates a new dynamically allocated object that can be used as a component for more complex ICustomBodies.
* @return A pointer along with the responsibility to delete. * @return A pointer along with the responsibility to delete.
@ -206,7 +221,7 @@ namespace Oyster
virtual ~API() {} virtual ~API() {}
}; };
//! documentation in progress //! The root interface for all physical representations processable by the engine.
class PHYSICS_DLL_USAGE ICustomBody class PHYSICS_DLL_USAGE ICustomBody
{ {
public: public:
@ -218,26 +233,148 @@ namespace Oyster
********************************************************/ ********************************************************/
virtual ::Utility::DynamicMemory::UniquePointer<ICustomBody> Clone() const = 0; virtual ::Utility::DynamicMemory::UniquePointer<ICustomBody> Clone() const = 0;
/********************************************************
* @return true if Engine should call the EventAction_Collision function.
********************************************************/
virtual bool IsSubscribingCollisions() const = 0; virtual bool IsSubscribingCollisions() const = 0;
virtual bool Intersects( const ICustomBody &object, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const = 0;
/********************************************************
* @return true if Engine should apply gravity on this object.
********************************************************/
virtual bool IsAffectedByGravity() const = 0;
/********************************************************
* Performs a detailed Intersect test and returns if, when and where.
* @param object: What this is intersect testing against.
* @param timeStepLength: The value set by API::SetDeltaTime(...)
* @param deltaWhen: Time in seconds since last update frame til timeOfContact. 0.0f <= deltaWhen <= timeStepLength
* @param worldPointOfContact: Where at timeOfContact, this and object touches eachother.
* @return true if this truly intersects with object.
********************************************************/
virtual bool Intersects( const ICustomBody &object, ::Oyster::Math::Float timeStepLength, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const = 0;
/********************************************************
* param shape: Any defined sample shape.
* @return true if this truly intersects with shape.
********************************************************/
virtual bool Intersects( const ::Oyster::Collision3D::ICollideable &shape ) const = 0; virtual bool Intersects( const ::Oyster::Collision3D::ICollideable &shape ) const = 0;
/********************************************************
* Required by Engine's Collision Search.
* @param targetMem: Provided memory that written into and then returned.
* @return a sphere shape that contains the ICustomBody.
********************************************************/
virtual ::Oyster::Collision3D::Sphere & GetBoundingSphere( ::Oyster::Collision3D::Sphere &targetMem = ::Oyster::Collision3D::Sphere() ) const = 0; virtual ::Oyster::Collision3D::Sphere & GetBoundingSphere( ::Oyster::Collision3D::Sphere &targetMem = ::Oyster::Collision3D::Sphere() ) const = 0;
/********************************************************
* Required by Engine's Collision Responsing.
* @param worldPos: Should be worldPointOfContact from Intersects( ... )
* @param targetMem: Provided memory that written into and then returned.
* @return a surface normal in worldSpace.
********************************************************/
virtual ::Oyster::Math::Float3 & GetNormalAt( const ::Oyster::Math::Float3 &worldPos, ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const = 0; virtual ::Oyster::Math::Float3 & GetNormalAt( const ::Oyster::Math::Float3 &worldPos, ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const = 0;
/********************************************************
* The gravity normal will have same direction as the total gravity force pulling on this and have the magnitude of 1.0f.
* @param targetMem: Provided memory that written into and then returned.
* @return a normalized vector in worldSpace. Exception: Null vector if no gravity been applied.
********************************************************/
virtual ::Oyster::Math::Float3 & GetGravityNormal( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const = 0;
/********************************************************
* The world position of this center of gravity.
* @param targetMem: Provided memory that written into and then returned.
* @return a position in worldSpace.
********************************************************/
virtual ::Oyster::Math::Float3 & GetCenter( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const = 0; virtual ::Oyster::Math::Float3 & GetCenter( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const = 0;
/********************************************************
* @param targetMem: Provided memory that written into and then returned.
* @return a copy of this's rotation matrix.
********************************************************/
virtual ::Oyster::Math::Float4x4 & GetRotation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const = 0; virtual ::Oyster::Math::Float4x4 & GetRotation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const = 0;
/********************************************************
* @param targetMem: Provided memory that written into and then returned.
* @return a copy of this's orientation matrix.
********************************************************/
virtual ::Oyster::Math::Float4x4 & GetOrientation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const = 0; virtual ::Oyster::Math::Float4x4 & GetOrientation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const = 0;
/********************************************************
* @param targetMem: Provided memory that written into and then returned.
* @return a copy of this's view matrix.
********************************************************/
virtual ::Oyster::Math::Float4x4 & GetView( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const = 0; virtual ::Oyster::Math::Float4x4 & GetView( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const = 0;
/********************************************************
* To not be called if is in Engine
* Is called during API::Update
********************************************************/
virtual UpdateState Update( ::Oyster::Math::Float timeStepLength ) = 0; virtual UpdateState Update( ::Oyster::Math::Float timeStepLength ) = 0;
/********************************************************
* @param ignore: True if Engine should not apply Gravity.
********************************************************/
virtual void SetGravity( bool ignore) = 0;
/********************************************************
* Used by Engine
* @param normalizedVector: Should have same direction as the pullinggravity.
********************************************************/
virtual void SetGravityNormal( const ::Oyster::Math::Float3 &normalizedVector ) = 0;
/********************************************************
* @param subscribeCollision: If is true, engine will call EventAction_Collision when this collides.
********************************************************/
virtual void SetSubscription( bool subscribeCollision ) = 0;
/********************************************************
* To not be called if is in Engine
* Use API::SetMomentOfInertiaTensor_KeepVelocity(...) instead
********************************************************/
virtual void SetMomentOfInertiaTensor_KeepVelocity( const ::Oyster::Math::Float4x4 &localI ) = 0; virtual void SetMomentOfInertiaTensor_KeepVelocity( const ::Oyster::Math::Float4x4 &localI ) = 0;
/********************************************************
* To not be called if is in Engine
* Use API::SetMomentOfInertiaTensor_KeepMomentum(...)
********************************************************/
virtual void SetMomentOfInertiaTensor_KeepMomentum( const ::Oyster::Math::Float4x4 &localI ) = 0; virtual void SetMomentOfInertiaTensor_KeepMomentum( const ::Oyster::Math::Float4x4 &localI ) = 0;
/********************************************************
* To not be called if is in Engine
* Use API::SetMass_KeepVelocity(...)
********************************************************/
virtual void SetMass_KeepVelocity( ::Oyster::Math::Float m ) = 0; virtual void SetMass_KeepVelocity( ::Oyster::Math::Float m ) = 0;
/********************************************************
* To not be called if is in Engine
* Use API::SetMass_KeepMomentum(...)
********************************************************/
virtual void SetMass_KeepMomentum( ::Oyster::Math::Float m ) = 0; virtual void SetMass_KeepMomentum( ::Oyster::Math::Float m ) = 0;
/********************************************************
* To not be called if is in Engine
* Use API::SetCenter(...)
********************************************************/
virtual void SetCenter( const ::Oyster::Math::Float3 &worldPos ) = 0; virtual void SetCenter( const ::Oyster::Math::Float3 &worldPos ) = 0;
/********************************************************
* To not be called if is in Engine
* Use API::SetRotation(...)
********************************************************/
virtual void SetRotation( const ::Oyster::Math::Float4x4 &rotation ) = 0; virtual void SetRotation( const ::Oyster::Math::Float4x4 &rotation ) = 0;
/********************************************************
* To not be called if is in Engine
* Use API::SetOrientation(...)
********************************************************/
virtual void SetOrientation( const ::Oyster::Math::Float4x4 &orientation ) = 0; virtual void SetOrientation( const ::Oyster::Math::Float4x4 &orientation ) = 0;
/********************************************************
* To not be called if is in Engine
* Use API::SetSize(...)
********************************************************/
virtual void SetSize( const ::Oyster::Math::Float3 &size ) = 0;
}; };
} }
} }

View File

@ -69,21 +69,29 @@
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir> <OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName> <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>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir> <OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName> <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>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir> <OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName> <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>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir> <OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName> <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> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
@ -138,10 +146,16 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <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="Utilities.cpp" /> <ClCompile Include="Utilities.cpp" />
<ClCompile Include="WinTimer.cpp" /> <ClCompile Include="WinTimer.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Resource\OysterResource.h" />
<ClInclude Include="Resource\OResource.h" />
<ClInclude Include="Utilities-InlineImpl.h" /> <ClInclude Include="Utilities-InlineImpl.h" />
<ClInclude Include="Utilities.h" /> <ClInclude Include="Utilities.h" />
<ClInclude Include="WinTimer.h" /> <ClInclude Include="WinTimer.h" />

View File

@ -21,6 +21,18 @@
<ClCompile Include="WinTimer.cpp"> <ClCompile Include="WinTimer.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </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>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Utilities.h"> <ClInclude Include="Utilities.h">
@ -32,5 +44,11 @@
<ClInclude Include="Utilities-InlineImpl.h"> <ClInclude Include="Utilities-InlineImpl.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Resource\OysterResource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Resource\OResource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,173 @@
#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);
}

View File

@ -0,0 +1,42 @@
#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();
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->resourceData = (OHRESOURCE)data.loadedData;
if(data.resourceUnloadFnc)
this->customData->unloadingFunction = data.resourceUnloadFnc;
return this;
}

View File

@ -0,0 +1,82 @@
#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;
}

View File

@ -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::RefCount 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

View File

@ -0,0 +1,179 @@
/////////////////////////////////////////////////////////////////////
// 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;
if(resourceData) 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();
}

View File

@ -0,0 +1,122 @@
/////////////////////////////////////////////////////////////////////
// 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 void(*CustomUnloadFunction)(void*);
typedef const CustomData&(*CustomLoadFunction)();
/** 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, /**< Handle can be interpeted as ? */
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

View File

@ -281,6 +281,53 @@ namespace Utility
return output; 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 //////////////////////////////////////////////////////////// // STREAM ////////////////////////////////////////////////////////////

View File

@ -113,6 +113,21 @@ namespace Utility
private: private:
mutable Type *ownedArray; mutable Type *ownedArray;
}; };
struct RefCount
{
private:
int count;
public:
RefCount() :count(0) { }
RefCount(const RefCount& o) { count = o.count; }
const RefCount& operator=(const RefCount& o) { count = o.count; return *this;}
void Incref() { this->count++; }
void Incref(int c) { this->count += c; }
int Decref() { return --this->count;}
void Reset() { this->count = 0; }
};
} }
namespace String namespace String
@ -136,6 +151,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, 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::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::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 namespace Stream

View File

@ -1,19 +1,18 @@
#include "Buffer.h"
#include "Core.h" #include "Core.h"
using namespace Oyster::Graphics; using namespace Oyster::Graphics;
Buffer::Buffer() Core::Buffer::Buffer()
{ {
mBuffer = NULL; mBuffer = NULL;
} }
Buffer::~Buffer() Core::Buffer::~Buffer()
{ {
SAFE_RELEASE(mBuffer); SAFE_RELEASE(mBuffer);
} }
HRESULT Buffer::Apply(UINT32 misc) const HRESULT Core::Buffer::Apply(UINT32 misc) const
{ {
HRESULT hr = S_OK; HRESULT hr = S_OK;
@ -59,7 +58,7 @@ HRESULT Buffer::Apply(UINT32 misc) const
return hr; return hr;
} }
HRESULT Buffer::Init(const BUFFER_INIT_DESC& initDesc) HRESULT Core::Buffer::Init(const BUFFER_INIT_DESC& initDesc)
{ {
D3D11_BUFFER_DESC bufferDesc; D3D11_BUFFER_DESC bufferDesc;
@ -154,13 +153,13 @@ HRESULT Buffer::Init(const BUFFER_INIT_DESC& initDesc)
if(FAILED(hr)) if(FAILED(hr))
{ {
MessageBox(NULL, "Unable to create buffer.", "Slenda Error", MB_ICONERROR | MB_OK); //MessageBox(NULL, L"Unable to create buffer.", L"Slenda Error", MB_ICONERROR | MB_OK);
} }
return hr; return hr;
} }
void* Buffer::Map() void* Core::Buffer::Map()
{ {
void* ret = NULL; void* ret = NULL;
if(mUsage == BUFFER_CPU_WRITE || mUsage == BUFFER_CPU_READ || mUsage == BUFFER_CPU_WRITE_DISCARD) if(mUsage == BUFFER_CPU_WRITE || mUsage == BUFFER_CPU_READ || mUsage == BUFFER_CPU_WRITE_DISCARD)
@ -192,17 +191,17 @@ void* Buffer::Map()
} }
void Buffer::Unmap() void Core::Buffer::Unmap()
{ {
Core::deviceContext->Unmap( mBuffer, 0 ); Core::deviceContext->Unmap( mBuffer, 0 );
} }
Buffer::operator ID3D11Buffer *() Core::Buffer::operator ID3D11Buffer *()
{ {
return this->mBuffer; return this->mBuffer;
} }
Buffer::operator const ID3D11Buffer *() const Core::Buffer::operator const ID3D11Buffer *() const
{ {
return this->mBuffer; return this->mBuffer;
} }

View File

@ -1,79 +0,0 @@
#pragma once
#ifndef CoreBuffer
#define CoreBuffer
#include "CoreIncludes.h"
namespace Oyster
{
namespace Graphics
{
class Buffer
{
public:
enum BUFFER_TYPE
{
VERTEX_BUFFER,
INDEX_BUFFER,
CONSTANT_BUFFER_VS,
CONSTANT_BUFFER_GS,
CONSTANT_BUFFER_PS,
CONSTANT_BUFFER_CS,
STRUCTURED_BUFFER,
BUFFER_TYPE_COUNT
};
enum BUFFER_USAGE
{
BUFFER_DEFAULT,
BUFFER_STREAM_OUT_TARGET,
BUFFER_CPU_WRITE,
BUFFER_CPU_WRITE_DISCARD,
BUFFER_CPU_READ,
BUFFER_USAGE_COUNT,
BUFFER_USAGE_IMMUTABLE
};
struct BUFFER_INIT_DESC
{
BUFFER_TYPE Type;
UINT32 NumElements;
UINT32 ElementSize;
BUFFER_USAGE Usage;
void* InitData;
BUFFER_INIT_DESC()
{
InitData = NULL;
Usage = BUFFER_DEFAULT;
}
};
protected:
ID3D11Buffer* mBuffer;
BUFFER_TYPE mType;
BUFFER_USAGE mUsage;
UINT32 mElementSize;
UINT32 mElementCount;
public:
Buffer();
virtual ~Buffer();
HRESULT Init(const BUFFER_INIT_DESC& initDesc);
void* Map();
void Unmap();
operator ID3D11Buffer*();
operator const ID3D11Buffer*() const;
HRESULT Apply(UINT32 misc = 0) const;
ID3D11Buffer* GetBufferPointer();
UINT32 GetVertexSize();
UINT32 GetElementCount();
};
}
}
#endif

View File

@ -4,9 +4,8 @@
#define Core_h #define Core_h
#include "CoreIncludes.h" #include "Dx11Includes.h"
#include <sstream> #include <sstream>
#include "Buffer.h"
#include "OysterMath.h" #include "OysterMath.h"
namespace Oyster namespace Oyster
@ -36,6 +35,72 @@ namespace Oyster
static Oyster::Math::Float2 resolution; static Oyster::Math::Float2 resolution;
class Buffer
{
public:
enum BUFFER_TYPE
{
VERTEX_BUFFER,
INDEX_BUFFER,
CONSTANT_BUFFER_VS,
CONSTANT_BUFFER_GS,
CONSTANT_BUFFER_PS,
CONSTANT_BUFFER_CS,
STRUCTURED_BUFFER,
BUFFER_TYPE_COUNT
};
enum BUFFER_USAGE
{
BUFFER_DEFAULT,
BUFFER_STREAM_OUT_TARGET,
BUFFER_CPU_WRITE,
BUFFER_CPU_WRITE_DISCARD,
BUFFER_CPU_READ,
BUFFER_USAGE_COUNT,
BUFFER_USAGE_IMMUTABLE
};
struct BUFFER_INIT_DESC
{
BUFFER_TYPE Type;
UINT32 NumElements;
UINT32 ElementSize;
BUFFER_USAGE Usage;
void* InitData;
BUFFER_INIT_DESC()
{
InitData = NULL;
Usage = BUFFER_DEFAULT;
}
};
protected:
ID3D11Buffer* mBuffer;
BUFFER_TYPE mType;
BUFFER_USAGE mUsage;
UINT32 mElementSize;
UINT32 mElementCount;
public:
Buffer();
virtual ~Buffer();
HRESULT Init(const BUFFER_INIT_DESC& initDesc);
void* Map();
void Unmap();
operator ID3D11Buffer*();
operator const ID3D11Buffer*() const;
HRESULT Apply(UINT32 misc = 0) const;
ID3D11Buffer* GetBufferPointer();
UINT32 GetVertexSize();
UINT32 GetElementCount();
};
class ShaderManager class ShaderManager
{ {

View File

@ -6,10 +6,14 @@
// http://lolengine.net/blog/2011/3/4/fuck-you-microsoft-near-far-macros // http://lolengine.net/blog/2011/3/4/fuck-you-microsoft-near-far-macros
#include <windows.h> #include <windows.h>
#include <D3D11.h> #include <D3D11.h>
#include <d3dcompiler.h>
#pragma comment(lib, "d3d11.lib") #pragma comment(lib, "d3d11.lib")
#ifdef _DEBUG
#include <d3dcompiler.h>
#pragma comment(lib, "d3dcompiler.lib") #pragma comment(lib, "d3dcompiler.lib")
#endif
#include <string> #include <string>

View File

@ -103,8 +103,8 @@ namespace Oyster
desc.BufferDesc.RefreshRate.Denominator=1; desc.BufferDesc.RefreshRate.Denominator=1;
desc.BufferDesc.RefreshRate.Numerator=60; desc.BufferDesc.RefreshRate.Numerator=60;
desc.BufferDesc.Height = Size.y; desc.BufferDesc.Height = (UINT)Size.y;
desc.BufferDesc.Width = Size.x; desc.BufferDesc.Width = (UINT)Size.x;
if(Core::swapChain) if(Core::swapChain)
{ {
@ -180,8 +180,8 @@ namespace Oyster
desc.BindFlags = D3D11_BIND_DEPTH_STENCIL; desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
desc.CPUAccessFlags=0; desc.CPUAccessFlags=0;
desc.MiscFlags=0; desc.MiscFlags=0;
desc.Height = Size.y; desc.Height = (UINT)Size.y;
desc.Width = Size.x; desc.Width = (UINT)Size.x;
if(Core::depthStencil) if(Core::depthStencil)
{ {

View File

@ -1,5 +1,6 @@
#include "Core.h" #include "Core.h"
#include <fstream> #include <fstream>
#include <map>
const char* ShaderFunction = "main"; const char* ShaderFunction = "main";
@ -143,7 +144,7 @@ namespace Oyster
ID3D11PixelShader* pixel; 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(); std::string fel = (char*)Error->GetBufferPointer();
Error->Release(); Error->Release();
@ -170,7 +171,7 @@ namespace Oyster
ID3D11GeometryShader* geometry; 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(); std::string fel = (char*)Error->GetBufferPointer();
Error->Release(); Error->Release();
@ -197,7 +198,7 @@ namespace Oyster
ID3D11VertexShader* vertex; 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(); std::string fel = (char*)Error->GetBufferPointer();
Error->Release(); Error->Release();

View File

@ -0,0 +1,36 @@
#include "..\OysterGraphics\Core\Dx11Includes.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;
};
struct FinalVertex
{
Oyster::Math::Float3 pos;
Oyster::Math::Float2 uv;
Oyster::Math::Float3 normal;
Oyster::Math::Float3 tangent;
Oyster::Math::Float3 biTangent;
Oyster::Math::Float4 boneIndex;
Oyster::Math::Float4 boneWeights;
};
}
}
}

View File

@ -0,0 +1,66 @@
#include "GFXAPI.h"
#include "../Core/Core.h"
#include "../Render/Resources/Resources.h"
#include "../Render/Rendering/Render.h"
#include "../FileLoader/ObjReader.h"
namespace Oyster
{
namespace Graphics
{
API::State API::Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Math::Float2 resulotion)
{
Core::resolution = resulotion;
if(Core::Init::FullInit(Window, MSAA_Quality, Fullscreen) == Core::Init::Fail)
{
return API::Fail;
}
if(Render::Resources::Init() == Core::Init::Fail)
{
return API::Fail;
}
Render::Preparations::Basic::SetViewPort();
return API::Sucsess;
}
void API::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection)
{
Render::Rendering::Basic::NewFrame(View, Projection);
}
void API::RenderScene(Model::Model* models, int count)
{
Render::Rendering::Basic::RenderScene(models,count);
}
void API::EndFrame()
{
Render::Rendering::Basic::EndFrame();
}
API::State API::SetOptions(API::Option option)
{
return API::Sucsess;
}
Model::Model* API::CreateModel(std::wstring filename)
{
Model::Model* m = new Model::Model();
m->WorldMatrix = Oyster::Math::Float4x4::identity;
m->Visible = true;
OBJReader or;
or.readOBJFile(filename);
m->info = or.toModel();
return m;
}
void API::DeleteModel(Model::Model* model)
{
delete model;
}
}
}

View File

@ -0,0 +1,42 @@
#pragma once
#include <string>
#include "..\Model\Model.h"
#include "OysterMath.h"
#include <Windows.h>
#if defined GFX_DLL_EXPORT
#define GFX_DLL_USAGE __declspec(dllexport)
#else
#define GFX_DLL_USAGE __declspec(dllimport)
#endif
namespace Oyster
{
namespace Graphics
{
class GFX_DLL_USAGE API
{
public:
enum State
{
Sucsess,
Fail
};
struct Option
{
};
static State Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Oyster::Math::Float2 StartResulotion);
//! @brief from Oyster::Math Float4x4, expects corect methods
static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection);
static void RenderScene(Oyster::Graphics::Model::Model* models, int count);
static void EndFrame();
static Oyster::Graphics::Model::Model* CreateModel(std::wstring filename);
static void DeleteModel(Oyster::Graphics::Model::Model* model);
static State SetOptions(Option);
};
}
}

View File

@ -1,6 +1,8 @@
#include "OBJReader.h" #include "OBJReader.h"
#include "..\Definitions\GraphicalDefinition.h"
#include <sstream> #include <sstream>
#include <fstream> #include <fstream>
#include "TextureLoader.h"
using namespace std; using namespace std;
OBJReader::OBJReader() OBJReader::OBJReader()
@ -15,14 +17,14 @@ OBJReader::~OBJReader()
} }
void OBJReader::readOBJFile( wstring fileName ) void OBJReader::readOBJFile( std::wstring fileName )
{ {
fstream inStream; std::fstream inStream;
string typeOfData = " "; std::string typeOfData = " ";
float vertexData; float vertexData;
string face1, face2, face3; std::string face1, face2, face3;
inStream.open( fileName, fstream::in ); inStream.open( fileName, std::fstream::in );
if( inStream.is_open() ) if( inStream.is_open() )
{ {
@ -94,12 +96,40 @@ void OBJReader::readOBJFile( wstring fileName )
inStream.close(); inStream.close();
} }
Oyster::Graphics::Model::ModelInfo* OBJReader::toModel()
{
Oyster::Graphics::Core::Buffer* b = new Oyster::Graphics::Core::Buffer();
Oyster::Graphics::Core::Buffer::BUFFER_INIT_DESC desc;
Oyster::Graphics::Model::ModelInfo* modelInfo = new Oyster::Graphics::Model::ModelInfo();
desc.ElementSize = 32;
desc.InitData = &this->_myOBJ[0];
desc.NumElements = this->_myOBJ.size();
desc.Type = Oyster::Graphics::Core::Buffer::BUFFER_TYPE::VERTEX_BUFFER;
desc.Usage = Oyster::Graphics::Core::Buffer::BUFFER_DEFAULT;
HRESULT hr = S_OK;
hr = b->Init(desc);
if(FAILED(hr))
{
//Something isn't okay here
}
modelInfo->Indexed = false;
modelInfo->VertexCount = (int)desc.NumElements;
modelInfo->Vertices = b;
//Oyster::Resource::OysterResource::LoadResource(L"Normal.png",(Oyster::Resource::CustomLoadFunction)Oyster::Graphics::Loading::LoadTexture);
return modelInfo;
}
//Private functions //Private functions
void OBJReader::stringSplit( string strToSplit ) void OBJReader::stringSplit( std::string strToSplit )
{ {
char delim = '/'; char delim = '/';
string vPos, vNormal, vTexel; std::string vPos, vNormal, vTexel;
stringstream aStream(strToSplit); std::stringstream aStream(strToSplit);
getline( aStream, vPos, delim ); getline( aStream, vPos, delim );
getline( aStream, vTexel, delim ); getline( aStream, vTexel, delim );
getline( aStream, vNormal ); getline( aStream, vNormal );

View File

@ -2,6 +2,7 @@
#define OBJREADER_H #define OBJREADER_H
#include "..\..\Misc\Utilities.h" #include "..\..\Misc\Utilities.h"
#include "..\..\OysterMath\OysterMath.h" #include "..\..\OysterMath\OysterMath.h"
#include "..\Model\ModelInfo.h"
//#include <fstream> //#include <fstream>
@ -19,8 +20,8 @@ class OBJReader
struct OBJMaterialData struct OBJMaterialData
{ {
string _name; std::string _name;
string _mapKd; std::string _mapKd;
float _kd[3]; float _kd[3];
float _ka[3]; float _ka[3];
float _tf[3]; float _tf[3];
@ -35,19 +36,20 @@ class OBJReader
std::vector<OBJFormat> _myOBJ; std::vector<OBJFormat> _myOBJ;
private: private:
vector<Oyster::Math::Float3> _mVertexCoord, _mVertexNormal; std::vector<Oyster::Math::Float3> _mVertexCoord, _mVertexNormal;
vector<Oyster::Math::Float2> _mVertexTexture; std::vector<Oyster::Math::Float2> _mVertexTexture;
int _mNrOfCoords, _mNrOfNormals, _mNrOfTexels, _mNrOfFaces; int _mNrOfCoords, _mNrOfNormals, _mNrOfTexels, _mNrOfFaces;
int _mPos, _mNormal, _mTexel; int _mPos, _mNormal, _mTexel;
void stringSplit( string strToSplit ); void stringSplit( std::string strToSplit );
void addToOBJarray(); void addToOBJarray();
public: public:
OBJReader(); OBJReader();
~OBJReader(); ~OBJReader();
void readOBJFile( wstring fileName); void readOBJFile( std::wstring fileName);
Oyster::Graphics::Model::ModelInfo* toModel();
}; };
#endif #endif

View File

@ -0,0 +1,7 @@
#include "TextureLoader.h"
#include "..\Core\Dx11Includes.h"
Oyster::Resource::CustomData* Oyster::Graphics::Loading::LoadTexture()
{
return NULL;
}

View File

@ -0,0 +1,13 @@
#pragma once
#include "..\..\Misc\Resource\OysterResource.h"
namespace Oyster
{
namespace Graphics
{
namespace Loading
{
void UnloadTexture();
Oyster::Resource::CustomData* LoadTexture();
}
}
}

View File

@ -1,28 +1,19 @@
#pragma once #pragma once
#ifndef Mesh_h #ifndef Mesh_h
#define Mesh_h #define Mesh_h
//#include "../Engine.h"
//#include "..\Core\CoreIncludes.h"
//#include "..\Core\Buffer.h"
#include "OysterMath.h" #include "OysterMath.h"
//#include "ICollideable.h"
#include "ModelInfo.h"
using namespace Oyster::Math;
namespace Oyster namespace Oyster
{ {
namespace Graphics namespace Graphics
{ {
namespace Render namespace Model
{ {
struct Model struct Model
{ {
ModelInfo* info; //! do not Edit, linked to render data
Float4x4 *World; void* info;
Oyster::Math::Float4x4 WorldMatrix;
bool Visible; bool Visible;
}; };
} }

View File

@ -2,26 +2,19 @@
#ifndef MODELINFO_h #ifndef MODELINFO_h
#define MODELINFO_h #define MODELINFO_h
//#include "../Engine.h"
#include "..\Core\Core.h"
#include "..\Core\CoreIncludes.h"
#include "..\Core\Buffer.h"
//#include "OysterMath.h"
//#include "ICollideable.h"
using namespace Oyster::Math;
namespace Oyster namespace Oyster
{ {
namespace Graphics namespace Graphics
{ {
namespace Render namespace Model
{ {
struct ModelInfo struct ModelInfo
{ {
std::vector<ID3D11ShaderResourceView*> Material; std::vector<ID3D11ShaderResourceView*> Material;
Buffer Vertices,Indecies; Core::Buffer *Vertices,*Indecies;
bool Indexed; bool Indexed;
int VertexCount; int VertexCount;
}; };

View File

@ -24,7 +24,7 @@
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset> <PlatformToolset>v110</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
@ -66,22 +66,22 @@
</ImportGroup> </ImportGroup>
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir> <OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName> <TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir> <OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName> <TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir> <OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName> <TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir> <OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName> <TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
</PropertyGroup> </PropertyGroup>
@ -91,6 +91,7 @@
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>GFX_DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
@ -105,6 +106,7 @@
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\OysterPhysic3D\Collision;..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\OysterPhysic3D\Collision;..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>GFX_DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
@ -118,6 +120,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>GFX_DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
@ -133,6 +136,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>GFX_DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
@ -145,20 +149,31 @@
<ClCompile Include="Core\Core.cpp" /> <ClCompile Include="Core\Core.cpp" />
<ClCompile Include="Core\Init.cpp" /> <ClCompile Include="Core\Init.cpp" />
<ClCompile Include="Core\ShaderManager.cpp" /> <ClCompile Include="Core\ShaderManager.cpp" />
<<<<<<< HEAD
<ClCompile Include="Render\Preparations\BasicPreparations.cpp" /> <ClCompile Include="Render\Preparations\BasicPreparations.cpp" />
<ClCompile Include="Render\Rendering\BasicRender.cpp" /> <ClCompile Include="Render\Rendering\BasicRender.cpp" />
<ClCompile Include="Resources\Resources.cpp" /> <ClCompile Include="Resources\Resources.cpp" />
=======
<ClCompile Include="DllInterfaces\GFXAPI.cpp" />
<ClCompile Include="FileLoader\ObjReader.cpp" />
<ClCompile Include="FileLoader\TextureLoader.cpp" />
<ClCompile Include="Render\Preparations\BasicPreparations.cpp" />
<ClCompile Include="Render\Rendering\BasicRender.cpp" />
<ClCompile Include="Render\Resources\Resources.cpp" />
>>>>>>> origin/Graphics
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Core\Buffer.h" />
<ClInclude Include="Core\Core.h" /> <ClInclude Include="Core\Core.h" />
<ClInclude Include="Core\CoreIncludes.h" /> <ClInclude Include="Core\Dx11Includes.h" />
<ClInclude Include="EngineIncludes.h" /> <ClInclude Include="DllInterfaces\GFXAPI.h" />
<ClInclude Include="FileLoader\ObjReader.h" />
<ClInclude Include="FileLoader\TextureLoader.h" />
<ClInclude Include="Model\Model.h" /> <ClInclude Include="Model\Model.h" />
<ClInclude Include="Model\ModelInfo.h" /> <ClInclude Include="Model\ModelInfo.h" />
<ClInclude Include="Render\Preparations\Preparations.h" /> <ClInclude Include="Render\Preparations\Preparations.h" />
<ClInclude Include="Render\Rendering\Render.h" /> <ClInclude Include="Render\Rendering\Render.h" />
<ClInclude Include="Resources\Resources.h" /> <ClInclude Include="Definitions\GraphicalDefinition.h" />
<ClInclude Include="Render\Resources\Resources.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Misc\Misc.vcxproj"> <ProjectReference Include="..\Misc\Misc.vcxproj">
@ -169,11 +184,30 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<FxCompile Include="Shader\HLSL\Deffered Shaders\GatherGBuffer\PixelGatherData.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>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
</FxCompile>
<FxCompile Include="Shader\HLSL\Deffered Shaders\GatherGBuffer\VertexGatherData.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>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
</FxCompile>
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugCameraVertex.hlsl"> <FxCompile Include="Shader\HLSL\SimpleDebug\DebugCameraVertex.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType> <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType> <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType> <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">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>
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl"> <FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType> <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
@ -196,6 +230,9 @@
</AssemblerOutput> </AssemblerOutput>
</FxCompile> </FxCompile>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="Shader\HLSL\Deffered Shaders\GatherGBuffer\GBufferHeader.hlsli" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>

View File

@ -27,29 +27,37 @@
<ClCompile Include="Core\Init.cpp"> <ClCompile Include="Core\Init.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<<<<<<< HEAD
<ClCompile Include="Resources\Resources.cpp"> <ClCompile Include="Resources\Resources.cpp">
=======
<ClCompile Include="Render\Rendering\BasicRender.cpp">
>>>>>>> origin/Graphics
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Render\Preparations\BasicPreparations.cpp"> <ClCompile Include="Render\Preparations\BasicPreparations.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<<<<<<< HEAD
<ClCompile Include="Render\Rendering\BasicRender.cpp"> <ClCompile Include="Render\Rendering\BasicRender.cpp">
=======
<ClCompile Include="Render\Resources\Resources.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="FileLoader\ObjReader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="FileLoader\TextureLoader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DllInterfaces\GFXAPI.cpp">
>>>>>>> origin/Graphics
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Core\Buffer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Core\Core.h"> <ClInclude Include="Core\Core.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Core\CoreIncludes.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="EngineIncludes.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Render\Preparations\Preparations.h"> <ClInclude Include="Render\Preparations\Preparations.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -62,7 +70,22 @@
<ClInclude Include="Model\Model.h"> <ClInclude Include="Model\Model.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Resources\Resources.h"> <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>
<ClInclude Include="FileLoader\TextureLoader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Core\Dx11Includes.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DllInterfaces\GFXAPI.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
@ -70,5 +93,10 @@
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugVertex.hlsl" /> <FxCompile Include="Shader\HLSL\SimpleDebug\DebugVertex.hlsl" />
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl" /> <FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl" />
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugCameraVertex.hlsl" /> <FxCompile Include="Shader\HLSL\SimpleDebug\DebugCameraVertex.hlsl" />
<FxCompile Include="Shader\HLSL\Deffered Shaders\GatherGBuffer\PixelGatherData.hlsl" />
<FxCompile Include="Shader\HLSL\Deffered Shaders\GatherGBuffer\VertexGatherData.hlsl" />
</ItemGroup>
<ItemGroup>
<None Include="Shader\HLSL\Deffered Shaders\GatherGBuffer\GBufferHeader.hlsli" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -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>

View File

@ -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>

View File

@ -1,4 +1,7 @@
#include "Render.h" #include "Render.h"
#include "../Resources/Resources.h"
#include "../../Definitions/GraphicalDefinition.h"
#include "../../Model/ModelInfo.h"
namespace Oyster namespace Oyster
{ {
@ -8,24 +11,55 @@ namespace Oyster
{ {
namespace Rendering namespace Rendering
{ {
Core::ShaderManager::ShaderEffect Basic::Resources::se = Core::ShaderManager::ShaderEffect();
void Basic::Resources::Init() void Basic::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection)
{
se.Shaders.Vertex = Core::ShaderManager::Get::Vertex(L"DebugCamera");
se.Shaders.Pixel = Core::ShaderManager::Get::Pixel(L"Debug");
}
void Basic::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4 Projection)
{ {
Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(0,0,0,1)); 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)
void Basic::RenderScene(Model::Model* models, int count)
{ {
for(int i = 0; i < count; ++i)
{
if(models[i].Visible)
{
void* data = Resources::ModelData.Map();
memcpy(data,&(models[i].WorldMatrix),sizeof(Math::Float4x4));
Resources::ModelData.Unmap();
//Set Materials :: NONE
Model
::ModelInfo* info = (Model::ModelInfo*)models[i].info;
info->Vertices->Apply();
if(info->Indexed)
{
info->Indecies->Apply();
Oyster::Graphics::Core::deviceContext->DrawIndexed(info->VertexCount,0,0);
}
else
{
Oyster::Graphics::Core::deviceContext->Draw(info->VertexCount,0);
}
}
}
} }
void Basic::EndFrame() void Basic::EndFrame()
{ {
Core::swapChain->Present(0,0);
} }
} }
} }

View File

@ -15,16 +15,9 @@ namespace Oyster
class Basic class Basic
{ {
public: public:
class Resources
{
static Core::ShaderManager::ShaderEffect se;
static void Init(); static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection);
}; static void RenderScene(Model::Model* models, int count);
static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4 Projection);
static void RenderScene(Model* models, int count);
static void EndFrame(); static void EndFrame();
}; };
} }

View File

@ -0,0 +1,108 @@
#include "Resources.h"
#include "..\OysterGraphics\Definitions\GraphicalDefinition.h"
// /Bin/Executable/Tester ->
// /Code/OysterGraphics/Shader/HLSL
const std::wstring PathFromExeToHlsl = L"..\\..\\..\\Code\\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;
typedef Oyster::Graphics::Core::Buffer Buffer;
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;
ModelData.Apply(1);
#pragma endregion
return Core::Init::Sucsess;
}
}
}
}

View File

@ -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 Core::Buffer ModelData;
static Core::Buffer VPData;
static Core::Init::State Init();
};
}
}
}
#endif

View File

@ -1,56 +0,0 @@
#include "Resources.h"
const std::wstring PathFromExeToHlsl = L"";
const std::wstring VertexTransformDebug = L"TransformDebugVertex";
const std::wstring VertexDebug = L"DebugVertex";
const std::wstring PixelRed = L"DebugPixel";
typedef Oyster::Graphics::Core::ShaderManager::ShaderType Shader;
namespace Oyster
{
namespace Graphics
{
namespace Render
{
Core::Init::State Resources::Init()
{
#pragma region LoadShaders
#ifdef _DEBUG
/** Load Vertex Shader for d3dcompile*/
Core::ShaderManager::Init(PathFromExeToHlsl + L"SimpleDebug\\" +L"DebugCameraVertex",Shader::Vertex, VertexTransformDebug, false);
Core::ShaderManager::Init(PathFromExeToHlsl + L"SimpleDebug\\" +L"DebugVertex",Shader::Vertex, VertexDebug, false);
/** Load Pixel Shader for d3dcompile */
Core::ShaderManager::Init(PathFromExeToHlsl + L"SimpleDebug\\" + L"DebugPixel", Shader::Pixel, PixelRed, false);
#else
/** Load Vertex Shader with Precompiled */
#endif
#pragma endregion
#pragma region CreateBuffers
/** @todo Create Buffers */
#pragma endregion
#pragma region Setup Render States
/** @todo Create DX States */
#pragma endregion
#pragma region Setup Views
/** @todo Create Views */
#pragma endregion
#pragma region Create Shader Effects
/** @todo Create ShaderEffects */
#pragma endregion
return Core::Init::Sucsess;
}
}
}
}

View File

@ -1,26 +0,0 @@
#pragma once
#ifndef Reources_h
#define Reources_h
#include <map>
#include "..\Core\Core.h"
namespace Oyster
{
namespace Graphics
{
namespace Render
{
class Resources
{
const Core::ShaderManager::ShaderEffect basic;
const Buffer ModelData;
Core::Init::State Init();
};
}
}
}
#endif

View File

@ -0,0 +1,41 @@
struct VertexIn
{
float3 pos : POSITION;
float2 UV : TEXCOORD;
float3 normal : NORMAL;
float3 tangent : TANGENT;
float3 biTangent : BITANGENT;
float4 boneIndex : BONEINDEX;
float4 boneWeight : BONEWEIGHT;
};
struct VertexOut
{
float4 pos : SV_POSITION;
float4 ViewPos : POSITION;
float2 UV : TEXCOORD;
float3 normal : NORMAL;
float3 tangent : TANGENT;
float3 biTangent : BITANGENT;
};
struct PixelOut
{
float4 DiffuseGlow : SV_TARGET0;
float4 NormalSpec : SV_TARGET1;
};
Texture2D Diffuse : register(t0);
Texture2D Specular : register(t1);
cbuffer PerFrame : register(b0)
{
matrix View;
float4x4 Projection;
matrix VP;
}
cbuffer PerModel : register(b1)
{
matrix World;
}

View File

@ -0,0 +1,9 @@
#include "GBufferHeader.hlsli"
PixelOut main(VertexOut input)
{
PixelOut output;
output.DiffuseGlow = float4(1.0f, 0.0f, 0.0f, 1.0f);
output.NormalSpec = float4(input.normal, 1.0f);
return output;
}

View File

@ -0,0 +1,12 @@
#include "GBufferHeader.hlsli"
VertexOut main( VertexIn input )
{
VertexOut output;
matrix WV = mul(View, World);
output.ViewPos = mul(WV, float4(input.pos,1));
output.pos = mul(Projection, output.ViewPos);
output.UV = input.UV;
output.normal = float4(input.normal, 0);
return output;
}

View File

@ -9,10 +9,20 @@ cbuffer PerModel : register(b1)
matrix World; matrix World;
} }
struct VertexIn
float4 main( float4 pos : POSITION ) : SV_POSITION
{ {
matrix VP = mul(View, Projection); float3 pos : POSITION;
matrix WVP = mul(World, VP); float2 UV : TEXCOORD;
return mul(WVP, pos); float3 normal : NORMAL;
};
float4 main( VertexIn input ) : SV_POSITION
{
float4 postTransform = mul( World, float4(input.pos,1) );
//float4 postTransform = float4(input.pos,1);
//return postTransform;
//return mul(View, float4(input.pos,1));
matrix VP = mul(Projection, View);
//matrix WVP = mul(World, VP);
return mul(VP, postTransform );
} }

View File

@ -1,4 +1,4 @@
float4 main() : SV_TARGET float4 main() : SV_TARGET0
{ {
return float4(1.0f, 0.0f, 0.0f, 1.0f); return float4(1.0f, 0.0f, 0.0f, 1.0f);
} }

View File

@ -31,28 +31,28 @@ Box & Box::operator = ( const Box &box )
return ::Utility::DynamicMemory::UniquePointer<ICollideable>( new Box(*this) ); return ::Utility::DynamicMemory::UniquePointer<ICollideable>( new Box(*this) );
} }
bool Box::Intersects( const ICollideable *target ) const bool Box::Intersects( const ICollideable &target ) const
{ {
switch( target->type ) switch( target.type )
{ {
case Type_universe: return true; case Type_universe: return true;
case Type_point: return Utility::Intersect( *this, *(Point*)target ); case Type_point: return Utility::Intersect( *this, *(Point*)&target );
case Type_ray: return Utility::Intersect( *this, *(Ray*)target, ((Ray*)target)->collisionDistance ); case Type_ray: return Utility::Intersect( *this, *(Ray*)&target, ((Ray*)&target)->collisionDistance );
case Type_sphere: return Utility::Intersect( *this, *(Sphere*)target ); case Type_sphere: return Utility::Intersect( *this, *(Sphere*)&target );
case Type_plane: return Utility::Intersect( *this, *(Plane*)target ); case Type_plane: return Utility::Intersect( *this, *(Plane*)&target );
// case Type_triangle: return false; // TODO: : // case Type_triangle: return false; // TODO: :
case Type_box_axis_aligned: return Utility::Intersect( *this, *(BoxAxisAligned*)target ); case Type_box_axis_aligned: return Utility::Intersect( *this, *(BoxAxisAligned*)&target );
case Type_box: return Utility::Intersect( *this, *(Box*)target ); case Type_box: return Utility::Intersect( *this, *(Box*)&target );
// case Type_frustrum: return false; // TODO: : // case Type_frustrum: return false; // TODO: :
default: return false; default: return false;
} }
} }
bool Box::Contains( const ICollideable *target ) const bool Box::Contains( const ICollideable &target ) const
{ {
switch( target->type ) switch( target.type )
{ {
case Type_point: return Utility::Intersect( *this, *(Point*)target ); case Type_point: return Utility::Intersect( *this, *(Point*)&target );
// case Type_sphere: return false; // TODO: // case Type_sphere: return false; // TODO:
// case Type_triangle: return false; // TODO: // case Type_triangle: return false; // TODO:
// case Type_box_axis_aligned: return false; // TODO: // case Type_box_axis_aligned: return false; // TODO:

View File

@ -33,8 +33,8 @@ namespace Oyster { namespace Collision3D
Box & operator = ( const Box &box ); Box & operator = ( const Box &box );
virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const; virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const;
bool Intersects( const ICollideable *target ) const; bool Intersects( const ICollideable &target ) const;
bool Contains( const ICollideable *target ) const; bool Contains( const ICollideable &target ) const;
}; };
} } } }

View File

@ -24,26 +24,26 @@ BoxAxisAligned & BoxAxisAligned::operator = ( const BoxAxisAligned &box )
::Utility::DynamicMemory::UniquePointer<ICollideable> BoxAxisAligned::Clone( ) const ::Utility::DynamicMemory::UniquePointer<ICollideable> BoxAxisAligned::Clone( ) const
{ return ::Utility::DynamicMemory::UniquePointer<ICollideable>( new BoxAxisAligned(*this) ); } { return ::Utility::DynamicMemory::UniquePointer<ICollideable>( new BoxAxisAligned(*this) ); }
bool BoxAxisAligned::Intersects( const ICollideable *target ) const bool BoxAxisAligned::Intersects( const ICollideable &target ) const
{ {
switch( target->type ) switch( target.type )
{ {
case Type_universe: return true; case Type_universe: return true;
case Type_point: return Utility::Intersect( *this, *(Point*)target ); case Type_point: return Utility::Intersect( *this, *(Point*)&target );
case Type_ray: return Utility::Intersect( *this, *(Ray*)target, ((Ray*)target)->collisionDistance ); case Type_ray: return Utility::Intersect( *this, *(Ray*)&target, ((Ray*)&target)->collisionDistance );
case Type_sphere: return Utility::Intersect( *this, *(Sphere*)target ); case Type_sphere: return Utility::Intersect( *this, *(Sphere*)&target );
case Type_plane: return Utility::Intersect( *this, *(Plane*)target ); case Type_plane: return Utility::Intersect( *this, *(Plane*)&target );
// case Type_triangle: return false; // TODO: // case Type_triangle: return false; // TODO:
case Type_box_axis_aligned: return Utility::Intersect( *this, *(BoxAxisAligned*)target ); case Type_box_axis_aligned: return Utility::Intersect( *this, *(BoxAxisAligned*)&target );
// case Type_box: return false; // TODO: // case Type_box: return false; // TODO:
// case Type_frustrum: return false; // TODO: // case Type_frustrum: return false; // TODO:
default: return false; default: return false;
} }
} }
bool BoxAxisAligned::Contains( const ICollideable *target ) const bool BoxAxisAligned::Contains( const ICollideable &target ) const
{ {
switch( target->type ) switch( target.type )
{ {
// case Type_point: return false; // TODO: // case Type_point: return false; // TODO:
// case Type_sphere: return false; // TODO: // case Type_sphere: return false; // TODO:

View File

@ -28,8 +28,8 @@ namespace Oyster { namespace Collision3D
BoxAxisAligned & operator = ( const BoxAxisAligned &box ); BoxAxisAligned & operator = ( const BoxAxisAligned &box );
virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const; virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const;
bool Intersects( const ICollideable *target ) const; bool Intersects( const ICollideable &target ) const;
bool Contains( const ICollideable *target ) const; bool Contains( const ICollideable &target ) const;
}; };
} } } }

View File

@ -191,29 +191,29 @@ void Frustrum::WriteToByte( unsigned int &nextIndex, unsigned char targetMem[] )
::Utility::DynamicMemory::UniquePointer<ICollideable> Frustrum::Clone( ) const ::Utility::DynamicMemory::UniquePointer<ICollideable> Frustrum::Clone( ) const
{ return ::Utility::DynamicMemory::UniquePointer<ICollideable>( new Frustrum(*this) ); } { return ::Utility::DynamicMemory::UniquePointer<ICollideable>( new Frustrum(*this) ); }
bool Frustrum::Intersects( const ICollideable *target ) const bool Frustrum::Intersects( const ICollideable &target ) const
{ {
switch( target->type ) switch( target.type )
{ {
case Type_universe: return true; case Type_universe: return true;
case Type_point: return Utility::Intersect( *this, *(Point*)target ); case Type_point: return Utility::Intersect( *this, *(Point*)&target );
case Type_ray: return Utility::Intersect( *this, *(Ray*)target, ((Ray*)target)->collisionDistance ); case Type_ray: return Utility::Intersect( *this, *(Ray*)&target, ((Ray*)&target)->collisionDistance );
case Type_sphere: return Utility::Intersect( *this, *(Sphere*)target ); case Type_sphere: return Utility::Intersect( *this, *(Sphere*)&target );
case Type_plane: return Utility::Intersect( *this, *(Plane*)target ); case Type_plane: return Utility::Intersect( *this, *(Plane*)&target );
// case Type_triangle: return false; // TODO: // case Type_triangle: return false; // TODO:
case Type_box_axis_aligned: return Utility::Intersect( *this, *(BoxAxisAligned*)target ); case Type_box_axis_aligned: return Utility::Intersect( *this, *(BoxAxisAligned*)&target );
case Type_box: return Utility::Intersect( *this, *(Box*)target ); case Type_box: return Utility::Intersect( *this, *(Box*)&target );
case Type_frustrum: return Utility::Intersect( *this, *(Frustrum*)target ); case Type_frustrum: return Utility::Intersect( *this, *(Frustrum*)&target );
// case Type_line: return false; // TODO: // case Type_line: return false; // TODO:
default: return false; default: return false;
} }
} }
bool Frustrum::Contains( const ICollideable *target ) const bool Frustrum::Contains( const ICollideable &target ) const
{ {
switch( target->type ) switch( target.type )
{ {
case Type_point: return Utility::Intersect( *this, *(Point*)target ); case Type_point: return Utility::Intersect( *this, *(Point*)&target );
// case Type_ray: return false; // TODO: // case Type_ray: return false; // TODO:
// case Type_sphere: return false; // TODO: // case Type_sphere: return false; // TODO:
// case Type_plane: return false; // TODO: // case Type_plane: return false; // TODO:

View File

@ -38,8 +38,8 @@ namespace Oyster { namespace Collision3D
void WriteToByte( unsigned char targetMem[], unsigned int &nextIndex ) const; /// DEPRECATED void WriteToByte( unsigned char targetMem[], unsigned int &nextIndex ) const; /// DEPRECATED
virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const; virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const;
bool Intersects( const ICollideable *target ) const; bool Intersects( const ICollideable &target ) const;
bool Contains( const ICollideable *target ) const; bool Contains( const ICollideable &target ) const;
}; };
// INLINE IMPLEMENTATIONS /////////////////////////////////////// // INLINE IMPLEMENTATIONS ///////////////////////////////////////

View File

@ -8,7 +8,7 @@
#include "Utilities.h" #include "Utilities.h"
namespace Oyster { namespace Collision3D /// Contains a collection of 3D shapes and intercollission algorithms. namespace Oyster { namespace Collision3D //! Contains a collection of 3D shapes and intercollission algorithms.
{ {
class ICollideable class ICollideable
{ {
@ -34,8 +34,8 @@ namespace Oyster { namespace Collision3D /// Contains a collection of 3D shapes
virtual ~ICollideable(); virtual ~ICollideable();
virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const = 0; virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const = 0;
virtual bool Intersects( const ICollideable *target ) const = 0; virtual bool Intersects( const ICollideable &target ) const = 0;
virtual bool Contains( const ICollideable *target ) const = 0; virtual bool Contains( const ICollideable &target ) const = 0;
}; };
} } } }
#endif #endif

View File

@ -23,9 +23,9 @@ Line & Line::operator = ( const Line &line )
::Utility::DynamicMemory::UniquePointer<ICollideable> Line::Clone( ) const ::Utility::DynamicMemory::UniquePointer<ICollideable> Line::Clone( ) const
{ return ::Utility::DynamicMemory::UniquePointer<ICollideable>( new Line(*this) ); } { return ::Utility::DynamicMemory::UniquePointer<ICollideable>( new Line(*this) ); }
bool Line::Intersects( const ICollideable *target ) const bool Line::Intersects( const ICollideable &target ) const
{ {
if( target->type == Type_universe ) if( target.type == Type_universe )
{ {
this->ray.collisionDistance = 0.0f; this->ray.collisionDistance = 0.0f;
return true; return true;
@ -38,5 +38,5 @@ bool Line::Intersects( const ICollideable *target ) const
return false; return false;
} }
bool Line::Contains( const ICollideable *target ) const bool Line::Contains( const ICollideable &target ) const
{ /* TODO: : */ return false; } { /* TODO: : */ return false; }

View File

@ -29,8 +29,8 @@ namespace Oyster { namespace Collision3D
Line & operator = ( const Line &line ); Line & operator = ( const Line &line );
virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const; virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const;
bool Intersects( const ICollideable *target ) const; bool Intersects( const ICollideable &target ) const;
bool Contains( const ICollideable *target ) const; bool Contains( const ICollideable &target ) const;
}; };
} } } }

View File

@ -22,31 +22,31 @@ Plane & Plane::operator = ( const Plane &plane )
::Utility::DynamicMemory::UniquePointer<ICollideable> Plane::Clone( ) const ::Utility::DynamicMemory::UniquePointer<ICollideable> Plane::Clone( ) const
{ return ::Utility::DynamicMemory::UniquePointer<ICollideable>( new Plane(*this) ); } { return ::Utility::DynamicMemory::UniquePointer<ICollideable>( new Plane(*this) ); }
bool Plane::Intersects( const ICollideable *target ) const bool Plane::Intersects( const ICollideable &target ) const
{ {
switch( target->type ) switch( target.type )
{ {
case Type_universe: return true; case Type_universe: return true;
case Type_point: return Utility::Intersect( *this, *(Point*)target ); case Type_point: return Utility::Intersect( *this, *(Point*)&target );
case Type_ray: return Utility::Intersect( *this, *(Ray*)target, ((Ray*)target)->collisionDistance ); case Type_ray: return Utility::Intersect( *this, *(Ray*)&target, ((Ray*)&target)->collisionDistance );
case Type_sphere: return Utility::Intersect( *this, *(Sphere*)target ); case Type_sphere: return Utility::Intersect( *this, *(Sphere*)&target );
case Type_plane: return Utility::Intersect( *this, *(Plane*)target ); case Type_plane: return Utility::Intersect( *this, *(Plane*)&target );
// case Type_triangle: return false; // TODO: // case Type_triangle: return false; // TODO:
case Type_box_axis_aligned: return Utility::Intersect( *(BoxAxisAligned*)target, *this ); case Type_box_axis_aligned: return Utility::Intersect( *(BoxAxisAligned*)&target, *this );
case Type_box: return Utility::Intersect( *(Box*)target, *this ); case Type_box: return Utility::Intersect( *(Box*)&target, *this );
case Type_frustrum: return false; // TODO: case Type_frustrum: return false; // TODO:
case Type_line: return false; // TODO: case Type_line: return false; // TODO:
default: return false; default: return false;
} }
} }
bool Plane::Contains( const ICollideable *target ) const bool Plane::Contains( const ICollideable &target ) const
{ {
switch( target->type ) switch( target.type )
{ {
case Type_point: return Utility::Intersect( *this, *(Point*)target ); case Type_point: return Utility::Intersect( *this, *(Point*)&target );
case Type_ray: return Utility::Contains( *this, *(Ray*)target ); case Type_ray: return Utility::Contains( *this, *(Ray*)&target );
case Type_plane: return Utility::Contains( *this, *(Plane*)target ); case Type_plane: return Utility::Contains( *this, *(Plane*)&target );
// case Type_triangle: return false; // TODO: // case Type_triangle: return false; // TODO:
default: return false; default: return false;
} }

View File

@ -28,8 +28,8 @@ namespace Oyster { namespace Collision3D
Plane & operator = ( const Plane &plane ); Plane & operator = ( const Plane &plane );
virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const; virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const;
bool Intersects( const ICollideable *target ) const; bool Intersects( const ICollideable &target ) const;
bool Contains( const ICollideable *target ) const; bool Contains( const ICollideable &target ) const;
}; };
} } } }

View File

@ -21,28 +21,28 @@ Point & Point::operator = ( const Point &point )
::Utility::DynamicMemory::UniquePointer<ICollideable> Point::Clone( ) const ::Utility::DynamicMemory::UniquePointer<ICollideable> Point::Clone( ) const
{ return ::Utility::DynamicMemory::UniquePointer<ICollideable>( new Point(*this) ); } { return ::Utility::DynamicMemory::UniquePointer<ICollideable>( new Point(*this) ); }
bool Point::Intersects( const ICollideable *target ) const bool Point::Intersects( const ICollideable &target ) const
{ {
switch( target->type ) switch( target.type )
{ {
case Type_universe: return true; case Type_universe: return true;
case Type_point: return Utility::Intersect( *this, *(Point*)target ); case Type_point: return Utility::Intersect( *this, *(Point*)&target );
case Type_ray: return Utility::Intersect( *(Ray*)target, *this, ((Ray*)target)->collisionDistance ); case Type_ray: return Utility::Intersect( *(Ray*)&target, *this, ((Ray*)&target)->collisionDistance );
case Type_sphere: Utility::Intersect( *(Sphere*)target, *this ); case Type_sphere: Utility::Intersect( *(Sphere*)&target, *this );
case Type_plane: return Utility::Intersect( *(Plane*)target, *this ); case Type_plane: return Utility::Intersect( *(Plane*)&target, *this );
//case Type_triangle: return false; // TODO: //case Type_triangle: return false; // TODO:
case Type_box_axis_aligned: return Utility::Intersect( *(BoxAxisAligned*)target, *this ); case Type_box_axis_aligned: return Utility::Intersect( *(BoxAxisAligned*)&target, *this );
case Type_box: return Utility::Intersect( *(Box*)target, *this ); case Type_box: return Utility::Intersect( *(Box*)&target, *this );
case Type_frustrum: return false; // TODO: case Type_frustrum: return false; // TODO:
default: return false; default: return false;
} }
} }
bool Point::Contains( const ICollideable *target ) const bool Point::Contains( const ICollideable &target ) const
{ {
switch( target->type ) switch( target.type )
{ {
case Type_point: return Utility::Intersect( *this, *(Point*)target ); case Type_point: return Utility::Intersect( *this, *(Point*)&target );
default: return false; default: return false;
} }
} }

View File

@ -27,8 +27,8 @@ namespace Oyster { namespace Collision3D
Point & operator = ( const Point &point ); Point & operator = ( const Point &point );
virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const; virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const;
bool Intersects( const ICollideable *target ) const; bool Intersects( const ICollideable &target ) const;
bool Contains( const ICollideable *target ) const; bool Contains( const ICollideable &target ) const;
}; };
} } } }

View File

@ -22,31 +22,31 @@ Ray & Ray::operator = ( const Ray &ray )
::Utility::DynamicMemory::UniquePointer<ICollideable> Ray::Clone( ) const ::Utility::DynamicMemory::UniquePointer<ICollideable> Ray::Clone( ) const
{ return ::Utility::DynamicMemory::UniquePointer<ICollideable>( new Ray(*this) ); } { return ::Utility::DynamicMemory::UniquePointer<ICollideable>( new Ray(*this) ); }
bool Ray::Intersects( const ICollideable *target ) const bool Ray::Intersects( const ICollideable &target ) const
{ {
switch( target->type ) switch( target.type )
{ {
case Type_universe: case Type_universe:
this->collisionDistance = 0.0f; this->collisionDistance = 0.0f;
return true; return true;
case Type_point: return Utility::Intersect( *this, *(Point*)target, this->collisionDistance ); case Type_point: return Utility::Intersect( *this, *(Point*)&target, this->collisionDistance );
case Type_ray: return Utility::Intersect( *this, *(Ray*)target, this->collisionDistance, ((Ray*)target)->collisionDistance ); case Type_ray: return Utility::Intersect( *this, *(Ray*)&target, this->collisionDistance, ((Ray*)&target)->collisionDistance );
case Type_sphere: return Utility::Intersect( *(Sphere*)target, *this, this->collisionDistance ); case Type_sphere: return Utility::Intersect( *(Sphere*)&target, *this, this->collisionDistance );
case Type_plane: return Utility::Intersect( *(Plane*)target, *this, this->collisionDistance ); case Type_plane: return Utility::Intersect( *(Plane*)&target, *this, this->collisionDistance );
// case Type_triangle: return false; // TODO: // case Type_triangle: return false; // TODO:
case Type_box_axis_aligned: return Utility::Intersect( *(BoxAxisAligned*)target, *this, this->collisionDistance ); case Type_box_axis_aligned: return Utility::Intersect( *(BoxAxisAligned*)&target, *this, this->collisionDistance );
case Type_box: return Utility::Intersect( *(Box*)target, *this, this->collisionDistance ); case Type_box: return Utility::Intersect( *(Box*)&target, *this, this->collisionDistance );
case Type_frustrum: return false; // TODO: case Type_frustrum: return false; // TODO:
default: return false; default: return false;
} }
} }
bool Ray::Contains( const ICollideable *target ) const bool Ray::Contains( const ICollideable &target ) const
{ {
switch( target->type ) switch( target.type )
{ {
case Type_point: return Utility::Intersect( *this, *(Point*)target, this->collisionDistance ); case Type_point: return Utility::Intersect( *this, *(Point*)&target, this->collisionDistance );
case Type_ray: Utility::Contains( *this, *(Ray*)target ); case Type_ray: Utility::Contains( *this, *(Ray*)&target );
default: return false; default: return false;
} }
} }

View File

@ -36,8 +36,8 @@ namespace Oyster { namespace Collision3D
Ray & operator = ( const Ray &ray ); Ray & operator = ( const Ray &ray );
virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const; virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const;
bool Intersects( const ICollideable *target ) const; bool Intersects( const ICollideable &target ) const;
bool Contains( const ICollideable *target ) const; bool Contains( const ICollideable &target ) const;
}; };
} } } }

View File

@ -36,6 +36,51 @@ RigidBody & RigidBody::operator = ( const RigidBody &body )
return *this; return *this;
} }
bool RigidBody::operator == ( const RigidBody &body )
{
if( this->box.center != body.box.center )
{
return false;
}
if( this->box.rotation != body.box.rotation )
{
return false;
}
if( this->box.boundingOffset != body.box.boundingOffset )
{
return false;
}
if( this->angularMomentum != body.angularMomentum )
{
return false;
}
if( this->linearMomentum != body.linearMomentum )
{
return false;
}
if( this->impulseTorqueSum != body.impulseTorqueSum )
{
return false;
}
if( this->impulseForceSum != body.impulseForceSum )
{
return false;
}
return true;
}
bool RigidBody::operator != ( const RigidBody &body )
{
return !this->operator==( body );
}
void RigidBody::Update_LeapFrog( Float deltaTime ) void RigidBody::Update_LeapFrog( Float deltaTime )
{ // by Dan Andersson: Euler leap frog update when Runga Kutta is not needed { // by Dan Andersson: Euler leap frog update when Runga Kutta is not needed
@ -287,6 +332,11 @@ void RigidBody::SetCenter( const Float3 &worldPos )
this->box.center = worldPos; this->box.center = worldPos;
} }
void RigidBody::SetRotation( const Float4x4 &r )
{ // by Dan Andersson
this->box.rotation = r;
}
void RigidBody::SetImpulseTorque( const Float3 &worldT ) void RigidBody::SetImpulseTorque( const Float3 &worldT )
{ // by Dan Andersson { // by Dan Andersson
this->impulseTorqueSum = worldT; this->impulseTorqueSum = worldT;

View File

@ -24,6 +24,9 @@ namespace Oyster { namespace Physics3D
RigidBody & operator = ( const RigidBody &body ); RigidBody & operator = ( const RigidBody &body );
bool operator == ( const RigidBody &body );
bool operator != ( const RigidBody &body );
void Update_LeapFrog( ::Oyster::Math::Float deltaTime ); void Update_LeapFrog( ::Oyster::Math::Float deltaTime );
void ApplyImpulseForce( const ::Oyster::Math::Float3 &worldF ); void ApplyImpulseForce( const ::Oyster::Math::Float3 &worldF );
void ApplyImpulseForceAt( const ::Oyster::Math::Float3 &worldF, const ::Oyster::Math::Float3 &worldPos ); void ApplyImpulseForceAt( const ::Oyster::Math::Float3 &worldF, const ::Oyster::Math::Float3 &worldPos );
@ -76,6 +79,7 @@ namespace Oyster { namespace Physics3D
void SetOrientation( const ::Oyster::Math::Float4x4 &o ); void SetOrientation( const ::Oyster::Math::Float4x4 &o );
void SetSize( const ::Oyster::Math::Float3 &widthHeight ); void SetSize( const ::Oyster::Math::Float3 &widthHeight );
void SetCenter( const ::Oyster::Math::Float3 &worldPos ); void SetCenter( const ::Oyster::Math::Float3 &worldPos );
void SetRotation( const ::Oyster::Math::Float4x4 &r );
void SetImpulseTorque( const ::Oyster::Math::Float3 &worldT ); void SetImpulseTorque( const ::Oyster::Math::Float3 &worldT );
void SetAngularMomentum( const ::Oyster::Math::Float3 &worldH ); void SetAngularMomentum( const ::Oyster::Math::Float3 &worldH );

View File

@ -18,29 +18,29 @@ Sphere & Sphere::operator = ( const Sphere &sphere )
::Utility::DynamicMemory::UniquePointer<ICollideable> Sphere::Clone( ) const ::Utility::DynamicMemory::UniquePointer<ICollideable> Sphere::Clone( ) const
{ return ::Utility::DynamicMemory::UniquePointer<ICollideable>( new Sphere(*this) ); } { return ::Utility::DynamicMemory::UniquePointer<ICollideable>( new Sphere(*this) ); }
bool Sphere::Intersects( const ICollideable *target ) const bool Sphere::Intersects( const ICollideable &target ) const
{ {
switch( target->type ) switch( target.type )
{ {
case Type_universe: return true; case Type_universe: return true;
case Type_point: return Utility::Intersect( *this, *(Point*)target ); case Type_point: return Utility::Intersect( *this, *(Point*)&target );
case Type_ray: return Utility::Intersect( *this, *(Ray*)target, ((Ray*)target)->collisionDistance ); case Type_ray: return Utility::Intersect( *this, *(Ray*)&target, ((Ray*)&target)->collisionDistance );
case Type_sphere: Utility::Intersect( *this, *(Sphere*)target ); case Type_sphere: Utility::Intersect( *this, *(Sphere*)&target );
case Type_plane: return Utility::Intersect( *(Plane*)target, *this ); case Type_plane: return Utility::Intersect( *(Plane*)&target, *this );
// case Type_triangle: return false; // TODO: // case Type_triangle: return false; // TODO:
case Type_box_axis_aligned: return Utility::Intersect( *(BoxAxisAligned*)target, *this ); case Type_box_axis_aligned: return Utility::Intersect( *(BoxAxisAligned*)&target, *this );
case Type_box: return Utility::Intersect( *(Box*)target, *this ); case Type_box: return Utility::Intersect( *(Box*)&target, *this );
case Type_frustrum: return false; // TODO: case Type_frustrum: return false; // TODO:
default: return false; default: return false;
} }
} }
bool Sphere::Contains( const ICollideable *target ) const bool Sphere::Contains( const ICollideable &target ) const
{ {
switch( target->type ) switch( target.type )
{ {
case Type_point: return Utility::Intersect( *this, *(Point*)target ); case Type_point: return Utility::Intersect( *this, *(Point*)&target );
case Type_sphere: return Utility::Contains( *this, *(Sphere*)target ); case Type_sphere: return Utility::Contains( *this, *(Sphere*)&target );
// case Type_triangle: return false; // TODO: // case Type_triangle: return false; // TODO:
case Type_box_axis_aligned: return false; // TODO: case Type_box_axis_aligned: return false; // TODO:
case Type_box: return false; // TODO: case Type_box: return false; // TODO:

View File

@ -27,8 +27,8 @@ namespace Oyster { namespace Collision3D
Sphere & operator = ( const Sphere &sphere ); Sphere & operator = ( const Sphere &sphere );
virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const; virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const;
bool Intersects( const ICollideable *target ) const; bool Intersects( const ICollideable &target ) const;
bool Contains( const ICollideable *target ) const; bool Contains( const ICollideable &target ) const;
}; };
} } } }

View File

@ -13,15 +13,15 @@ Universe & Universe::operator = ( const Universe &universe )
UniquePointer<ICollideable> Universe::Clone( ) const UniquePointer<ICollideable> Universe::Clone( ) const
{ return UniquePointer<ICollideable>( new Universe(*this) ); } { return UniquePointer<ICollideable>( new Universe(*this) ); }
bool Universe::Intersects( const ICollideable *target ) const bool Universe::Intersects( const ICollideable &target ) const
{ // universe touches everything { // universe touches everything
switch( target->type ) switch( target.type )
{ {
case Type_ray: case Type_ray:
((Ray*)target)->collisionDistance = 0.0f; ((Ray*)&target)->collisionDistance = 0.0f;
break; break;
case Type_line: case Type_line:
((Line*)target)->ray.collisionDistance = 0.0f; ((Line*)&target)->ray.collisionDistance = 0.0f;
break; break;
default: break; default: break;
} }
@ -29,6 +29,6 @@ bool Universe::Intersects( const ICollideable *target ) const
return true; return true;
} }
bool Universe::Contains( const ICollideable *target ) const bool Universe::Contains( const ICollideable &target ) const
{ return true; } // universe contains everything { return true; } // universe contains everything

View File

@ -19,8 +19,8 @@ namespace Oyster { namespace Collision3D
Universe & operator = ( const Universe &universe ); Universe & operator = ( const Universe &universe );
virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const; virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const;
bool Intersects( const ICollideable *target ) const; bool Intersects( const ICollideable &target ) const;
bool Contains( const ICollideable *target ) const; bool Contains( const ICollideable &target ) const;
}; };
} } } }

Binary file not shown.

View File

@ -1,2 +0,0 @@
#v4.0:v110:false
Debug|Win32|C:\DanBias\Danbias\|

View File

@ -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.

View File

@ -7,15 +7,18 @@
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
#define NOMINMAX #define NOMINMAX
#include <Windows.h> #include <Windows.h>
#include "Core/Core.h" #include "DllInterfaces\GFXAPI.h"
#include "Render\Preparations\Preparations.h"
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Global Variables // Global Variables
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
HINSTANCE g_hInst = NULL; HINSTANCE g_hInst = NULL;
HWND g_hWnd = NULL; HWND g_hWnd = NULL;
Oyster::Graphics::Model::Model* m = new Oyster::Graphics::Model::Model();
Oyster::Math::Float4x4 V;
Oyster::Math::Float4x4 P;
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -36,6 +39,22 @@ HRESULT InitDirect3D();
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow ) int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow )
{ {
BOOL b = SetDllDirectoryW(L"..\\..\\DLL");
typedef struct tagLOADPARMS32
{
LPSTR lpEnvAddress; // address of environment strings
LPSTR lpCmdLine; // address of command line
LPSTR lpCmdShow; // how to show new program
DWORD dwReserved; // must be zero
} LOADPARMS32;
LOADPARMS32 params;
params.dwReserved=NULL;
params.lpCmdLine="";
params.lpCmdShow="";
params.lpEnvAddress="";
LoadModule("OysterGraphics_x86D.dll",&params);
if( FAILED( InitWindow( hInstance, nCmdShow ) ) ) if( FAILED( InitWindow( hInstance, nCmdShow ) ) )
return 0; return 0;
@ -132,60 +151,50 @@ HRESULT InitDirect3D()
{ {
HRESULT hr = S_OK;; HRESULT hr = S_OK;;
Oyster::Graphics::Core::resolution = Oyster::Math::Float2( 1024, 768 ); if(Oyster::Graphics::API::Init(g_hWnd,false,false, Oyster::Math::Float2( 1024, 768 )) == Oyster::Graphics::API::Fail)
{
if(Oyster::Graphics::Core::Init::FullInit(g_hWnd,false,false)==Oyster::Graphics::Core::Init::Fail)
return E_FAIL; return E_FAIL;
}
#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)},
//};
//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;
//Oyster::Graphics::Buffer *b = new Oyster::Graphics::Buffer();;
//b->Init(desc);
////b.Apply(0);
//Oyster::Graphics::Render::ModelInfo* mi = new Oyster::Graphics::Render::ModelInfo();
//mi->Indexed = false;
//mi->VertexCount = 3;
//mi->Vertices = b;
//m->info = mi;
#pragma endregion
#pragma region Obj
m = Oyster::Graphics::API::CreateModel(L"bth.obj");
m->WorldMatrix *= 0.1f;
m->WorldMatrix.m44 = 1;
#pragma endregion
P = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,100);
std::wstring ShaderPath = L"..\\OysterGraphics\\Shader\\HLSL\\"; 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));
std::wstring EffectPath = L"SimpleDebug\\"; V = Oyster::Math3D::InverseOrientationMatrix(V);
Oyster::Graphics::Core::ShaderManager::Init(ShaderPath + EffectPath + L"DebugPixel.hlsl",Oyster::Graphics::Core::ShaderManager::ShaderType::Pixel,L"Debug",false);
Oyster::Graphics::Core::ShaderManager::Init(ShaderPath + EffectPath + L"DebugVertex.hlsl",Oyster::Graphics::Core::ShaderManager::ShaderType::Vertex,L"PassThroughFloat4",false);
Oyster::Graphics::Core::ShaderManager::Set::Vertex(Oyster::Graphics::Core::ShaderManager::Get::Vertex(L"PassThroughFloat4"));
Oyster::Graphics::Core::ShaderManager::Set::Pixel(Oyster::Graphics::Core::ShaderManager::Get::Pixel(L"Debug"));
D3D11_INPUT_ELEMENT_DESC inputDesc[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }
};
ID3D11InputLayout* layout;
Oyster::Graphics::Core::ShaderManager::CreateInputLayout( inputDesc, 1, Oyster::Graphics::Core::ShaderManager::Get::Vertex(L"PassThroughFloat4"), layout);
Oyster::Graphics::Core::deviceContext->IASetInputLayout(layout);
Oyster::Graphics::Core::deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
Oyster::Graphics::Render::Preparations::Basic::BindBackBufferRTV();
Oyster::Graphics::Render::Preparations::Basic::SetViewPort();
struct float4
{
float x,y,z,w;
};
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},
};
Oyster::Graphics::Buffer::BUFFER_INIT_DESC desc;
desc.ElementSize= sizeof(float4);
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;
Oyster::Graphics::Buffer b;
b.Init(desc);
b.Apply(0);
return S_OK; return S_OK;
} }
@ -197,11 +206,11 @@ HRESULT Update(float deltaTime)
HRESULT Render(float deltaTime) HRESULT Render(float deltaTime)
{ {
Oyster::Graphics::Render::Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(0,0,1,1)); Oyster::Graphics::API::NewFrame(V,P);
Oyster::Graphics::Core::deviceContext->Draw(3,0); Oyster::Graphics::API::RenderScene(m,1);
Oyster::Graphics::Core::swapChain->Present(0,0); Oyster::Graphics::API::EndFrame();
return S_OK; return S_OK;
} }

View File

@ -69,18 +69,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)..\Bin\Executable\$(ProjectName)\</OutDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)..\Bin\Executable\$(ProjectName)\</OutDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)..\Bin\Executable\$(ProjectName)\</OutDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)..\Bin\Executable\$(ProjectName)\</OutDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
@ -95,7 +103,14 @@
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>OysterGraphics_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)..\Bin\DLL;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<DelayLoadDLLs>OysterGraphics_x86D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link> </Link>
<ProjectReference>
<LinkLibraryDependencies>
</LinkLibraryDependencies>
</ProjectReference>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile> <ClCompile>
@ -110,6 +125,9 @@
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>OysterGraphics_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)..\Bin\DLL;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<PreventDllBinding>true</PreventDllBinding>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -129,6 +147,9 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>OysterGraphics_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)..\Bin\DLL;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<PreventDllBinding>true</PreventDllBinding>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -148,6 +169,9 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>OysterGraphics_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)..\Bin\DLL;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<PreventDllBinding>true</PreventDllBinding>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
@ -159,6 +183,11 @@
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\OysterGraphics\OysterGraphics.vcxproj"> <ProjectReference Include="..\OysterGraphics\OysterGraphics.vcxproj">
<Project>{0ec83e64-230e-48ef-b08c-6ac9651b4f82}</Project> <Project>{0ec83e64-230e-48ef-b08c-6ac9651b4f82}</Project>
<Private>false</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>false</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\OysterMath\OysterMath.vcxproj"> <ProjectReference Include="..\OysterMath\OysterMath.vcxproj">
<Project>{f10cbc03-9809-4cba-95d8-327c287b18ee}</Project> <Project>{f10cbc03-9809-4cba-95d8-327c287b18ee}</Project>

33004
Tester/bth.obj Normal file

File diff suppressed because it is too large Load Diff