From e8b0e75ed7773623e1fef3bbb0cbb305f0be101e Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Tue, 18 Feb 2014 15:07:40 +0100 Subject: [PATCH] Render rigid body from lvl format --- .../GameClient/GameClientState/C_Object.cpp | 8 +++++- .../GameClient/GameClientState/C_Object.h | 25 ++++++++++++------- .../GameClient/GameClientState/GameState.cpp | 12 ++++++--- .../GameClientState/NetLoadState.cpp | 6 +++++ Code/OysterGraphics/DllInterfaces/GFXAPI.cpp | 1 + 5 files changed, 38 insertions(+), 14 deletions(-) diff --git a/Code/Game/GameClient/GameClientState/C_Object.cpp b/Code/Game/GameClient/GameClientState/C_Object.cpp index dc22f34d..ccea9a86 100644 --- a/Code/Game/GameClient/GameClientState/C_Object.cpp +++ b/Code/Game/GameClient/GameClientState/C_Object.cpp @@ -9,6 +9,10 @@ C_Object::C_Object() id = 0; model = NULL; + + // RB DEBUG + type = RB_Type_None; + // !RB DEBUG } C_Object::~C_Object() { @@ -104,6 +108,7 @@ bool C_Object::InitRB(RBInitData RBInit) RBposition = RBInit.position; RBrotation = RBInit.rotation; RBscale = RBInit.scale; + type = RBInit.type; return true; } Oyster::Math::Float4x4 C_Object::getRBWorld() const @@ -142,4 +147,5 @@ Oyster::Math::Float3 C_Object::getRBScale() const RB_Type C_Object::getBRtype()const { return this->type; -} \ No newline at end of file +} +// !RB DEBUG \ No newline at end of file diff --git a/Code/Game/GameClient/GameClientState/C_Object.h b/Code/Game/GameClient/GameClientState/C_Object.h index d0b86a41..dcc2731c 100644 --- a/Code/Game/GameClient/GameClientState/C_Object.h +++ b/Code/Game/GameClient/GameClientState/C_Object.h @@ -5,11 +5,22 @@ namespace DanBias { namespace Client { + // RB DEBUG enum RB_Type { RB_Type_Cube, - RB_Type_Sphere + RB_Type_Sphere, + RB_Type_None, }; + struct RBInitData + { + Oyster::Math::Float3 position; + Oyster::Math::Quaternion rotation; + Oyster::Math::Float3 scale; + RB_Type type; + }; + // !RB DEBUG + struct ModelInitData { int id; @@ -19,13 +30,6 @@ namespace DanBias Oyster::Math::Float3 scale; bool visible; }; - struct RBInitData - { - Oyster::Math::Float3 position; - Oyster::Math::Quaternion rotation; - Oyster::Math::Float3 scale; - RB_Type type; - }; class C_Object { @@ -40,7 +44,8 @@ namespace DanBias Oyster::Math::Quaternion RBrotation; Oyster::Math::Float3 RBscale; RB_Type type; - + // !RB DEBUG + int id; protected: @@ -71,6 +76,8 @@ namespace DanBias void setRBScale(Oyster::Math::Float3 newScale); Oyster::Math::Float3 getRBScale() const; RB_Type getBRtype()const; + // !RB DEBUG + virtual void Render(); virtual void Release(); virtual int GetId() const; diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp index 1afba43d..ba333061 100644 --- a/Code/Game/GameClient/GameClientState/GameState.cpp +++ b/Code/Game/GameClient/GameClientState/GameState.cpp @@ -81,7 +81,7 @@ bool GameState::Init( SharedStateContent &shared ) Graphics::API::Option gfxOp = Graphics::API::GetOption(); Float aspectRatio = gfxOp.Resolution.x / gfxOp.Resolution.y; - this->privData->camera.SetPerspectiveProjection( Math::pi/8, aspectRatio, 0.1f, 1000.0f ); + this->privData->camera.SetPerspectiveProjection( Math::pi/2, aspectRatio, 0.1f, 1000.0f ); Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() ); //tell server ready @@ -109,6 +109,7 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa RBData.position = position; RBData.rotation = ArrayToQuaternion( rotation ); RBData.scale = Float3( 1 ); + // !RB DEBUG if( isMyPlayer ) { @@ -116,6 +117,7 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa { // RB DEBUG this->privData->player.InitRB( RBData ); + // !RB DEBUG this->privData->myId = id; this->privData->camera.SetPosition( this->privData->player.getPos() ); @@ -132,6 +134,7 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa { // RB DEBUG this->privData->player.InitRB( RBData ); + // !RB DEBUG (*this->privData->dynamicObjects)[id] = p; } @@ -168,14 +171,13 @@ bool GameState::Render() // RB DEBUG render wire frame Oyster::Graphics::API::StartRenderWireFrame(); - Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(Float3( 0,132, 20)); Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(Float3( 0.5f, 0.5f, 0.5f)); Oyster::Math3D::Float4x4 world = translation * scale; Oyster::Graphics::API::RenderDebugCube( world ); Oyster::Graphics::API::RenderDebugCube(this->privData->player.getRBWorld()); - + staticObject = this->privData->staticObjects->begin(); for( ; staticObject != this->privData->staticObjects->end(); ++staticObject ) { if( staticObject->second->getBRtype() == RB_Type_Cube) @@ -188,7 +190,7 @@ bool GameState::Render() } } - + dynamicObject = this->privData->dynamicObjects->begin(); for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject ) { if( dynamicObject->second->getBRtype() == RB_Type_Cube) @@ -200,6 +202,8 @@ bool GameState::Render() Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld()); } } + // !RB DEBUG + Oyster::Graphics::API::EndFrame(); return true; } diff --git a/Code/Game/GameClient/GameClientState/NetLoadState.cpp b/Code/Game/GameClient/GameClientState/NetLoadState.cpp index 706e0d53..2fe143d6 100644 --- a/Code/Game/GameClient/GameClientState/NetLoadState.cpp +++ b/Code/Game/GameClient/GameClientState/NetLoadState.cpp @@ -146,6 +146,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position; RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size; + RBData.type = RB_Type_Cube; staticObject->InitRB( RBData ); } @@ -154,8 +155,10 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position; RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius; + RBData.type = RB_Type_Sphere; staticObject->InitRB( RBData ); } + // !RB DEBUG (*this->privData->staticObjects)[objectID] = staticObject; } @@ -187,6 +190,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position; RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size; + RBData.type = RB_Type_Cube; dynamicObject->InitRB( RBData ); } @@ -195,8 +199,10 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position; RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius; + RBData.type = RB_Type_Sphere; dynamicObject->InitRB( RBData ); } + // !RB DEBUG (*this->privData->dynamicObjects)[objectID] = dynamicObject; } diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index bdfa0bde..96e2bbe2 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -197,6 +197,7 @@ namespace Oyster void API::StartRenderWireFrame() { Core::deviceContext->RSSetState(wire); + Core::deviceContext->OMSetRenderTargets(Render::Resources::Gather::Pass.RTV.size(),&Render::Resources::Gather::Pass.RTV[0],NULL); } void API::RenderDebugCube(Math::Matrix world)