Merge branch 'GameClientGraphics' of https://github.com/dean11/Danbias into GameClientGraphics

This commit is contained in:
lanariel 2014-02-18 15:21:01 +01:00
commit a068ce7ddb
5 changed files with 38 additions and 14 deletions

View File

@ -9,6 +9,10 @@ C_Object::C_Object()
id = 0; id = 0;
model = NULL; model = NULL;
// RB DEBUG
type = RB_Type_None;
// !RB DEBUG
} }
C_Object::~C_Object() C_Object::~C_Object()
{ {
@ -104,6 +108,7 @@ bool C_Object::InitRB(RBInitData RBInit)
RBposition = RBInit.position; RBposition = RBInit.position;
RBrotation = RBInit.rotation; RBrotation = RBInit.rotation;
RBscale = RBInit.scale; RBscale = RBInit.scale;
type = RBInit.type;
return true; return true;
} }
Oyster::Math::Float4x4 C_Object::getRBWorld() const Oyster::Math::Float4x4 C_Object::getRBWorld() const
@ -143,3 +148,4 @@ RB_Type C_Object::getBRtype()const
{ {
return this->type; return this->type;
} }
// !RB DEBUG

View File

@ -5,11 +5,22 @@ namespace DanBias
{ {
namespace Client namespace Client
{ {
// RB DEBUG
enum RB_Type enum RB_Type
{ {
RB_Type_Cube, 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 struct ModelInitData
{ {
int id; int id;
@ -19,13 +30,6 @@ namespace DanBias
Oyster::Math::Float3 scale; Oyster::Math::Float3 scale;
bool visible; bool visible;
}; };
struct RBInitData
{
Oyster::Math::Float3 position;
Oyster::Math::Quaternion rotation;
Oyster::Math::Float3 scale;
RB_Type type;
};
class C_Object class C_Object
{ {
@ -40,6 +44,7 @@ namespace DanBias
Oyster::Math::Quaternion RBrotation; Oyster::Math::Quaternion RBrotation;
Oyster::Math::Float3 RBscale; Oyster::Math::Float3 RBscale;
RB_Type type; RB_Type type;
// !RB DEBUG
int id; int id;
@ -71,6 +76,8 @@ namespace DanBias
void setRBScale(Oyster::Math::Float3 newScale); void setRBScale(Oyster::Math::Float3 newScale);
Oyster::Math::Float3 getRBScale() const; Oyster::Math::Float3 getRBScale() const;
RB_Type getBRtype()const; RB_Type getBRtype()const;
// !RB DEBUG
virtual void Render(); virtual void Render();
virtual void Release(); virtual void Release();
virtual int GetId() const; virtual int GetId() const;

View File

@ -81,7 +81,7 @@ bool GameState::Init( SharedStateContent &shared )
Graphics::API::Option gfxOp = Graphics::API::GetOption(); Graphics::API::Option gfxOp = Graphics::API::GetOption();
Float aspectRatio = gfxOp.Resolution.x / gfxOp.Resolution.y; 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() ); Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() );
//tell server ready //tell server ready
@ -109,6 +109,7 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
RBData.position = position; RBData.position = position;
RBData.rotation = ArrayToQuaternion( rotation ); RBData.rotation = ArrayToQuaternion( rotation );
RBData.scale = Float3( 1 ); RBData.scale = Float3( 1 );
// !RB DEBUG
if( isMyPlayer ) if( isMyPlayer )
{ {
@ -116,6 +117,7 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
{ {
// RB DEBUG // RB DEBUG
this->privData->player.InitRB( RBData ); this->privData->player.InitRB( RBData );
// !RB DEBUG
this->privData->myId = id; this->privData->myId = id;
this->privData->camera.SetPosition( this->privData->player.getPos() ); 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 // RB DEBUG
this->privData->player.InitRB( RBData ); this->privData->player.InitRB( RBData );
// !RB DEBUG
(*this->privData->dynamicObjects)[id] = p; (*this->privData->dynamicObjects)[id] = p;
} }
@ -168,14 +171,13 @@ bool GameState::Render()
// RB DEBUG render wire frame // RB DEBUG render wire frame
Oyster::Graphics::API::StartRenderWireFrame(); Oyster::Graphics::API::StartRenderWireFrame();
Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(Float3( 0,132, 20)); 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 scale = Oyster::Math3D::ScalingMatrix(Float3( 0.5f, 0.5f, 0.5f));
Oyster::Math3D::Float4x4 world = translation * scale; Oyster::Math3D::Float4x4 world = translation * scale;
Oyster::Graphics::API::RenderDebugCube( world ); Oyster::Graphics::API::RenderDebugCube( world );
Oyster::Graphics::API::RenderDebugCube(this->privData->player.getRBWorld()); Oyster::Graphics::API::RenderDebugCube(this->privData->player.getRBWorld());
staticObject = this->privData->staticObjects->begin();
for( ; staticObject != this->privData->staticObjects->end(); ++staticObject ) for( ; staticObject != this->privData->staticObjects->end(); ++staticObject )
{ {
if( staticObject->second->getBRtype() == RB_Type_Cube) 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 ) for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject )
{ {
if( dynamicObject->second->getBRtype() == RB_Type_Cube) if( dynamicObject->second->getBRtype() == RB_Type_Cube)
@ -200,6 +202,8 @@ bool GameState::Render()
Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld()); Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld());
} }
} }
// !RB DEBUG
Oyster::Graphics::API::EndFrame(); Oyster::Graphics::API::EndFrame();
return true; return true;
} }

View File

@ -146,6 +146,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position; RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position;
RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation
RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size; RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size;
RBData.type = RB_Type_Cube;
staticObject->InitRB( RBData ); 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.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position;
RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation
RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius; RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius;
RBData.type = RB_Type_Sphere;
staticObject->InitRB( RBData ); staticObject->InitRB( RBData );
} }
// !RB DEBUG
(*this->privData->staticObjects)[objectID] = staticObject; (*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.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position;
RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation
RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size; RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size;
RBData.type = RB_Type_Cube;
dynamicObject->InitRB( RBData ); 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.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position;
RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation
RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius; RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius;
RBData.type = RB_Type_Sphere;
dynamicObject->InitRB( RBData ); dynamicObject->InitRB( RBData );
} }
// !RB DEBUG
(*this->privData->dynamicObjects)[objectID] = dynamicObject; (*this->privData->dynamicObjects)[objectID] = dynamicObject;
} }

View File

@ -206,6 +206,7 @@ namespace Oyster
{ {
Core::deviceContext->OMSetRenderTargets(Render::Resources::Gather::Pass.RTV.size(),&Render::Resources::Gather::Pass.RTV[0],NULL); Core::deviceContext->OMSetRenderTargets(Render::Resources::Gather::Pass.RTV.size(),&Render::Resources::Gather::Pass.RTV[0],NULL);
Core::deviceContext->RSSetState(wire); 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) void API::RenderDebugCube(Math::Matrix world)