GL - fixed graphics, collision with house, locked to 30 fps on client, jump added

This commit is contained in:
lindaandersson 2014-02-12 09:32:13 +01:00
parent 4c9d62b163
commit bdc5b5e736
4 changed files with 30 additions and 31 deletions

View File

@ -93,12 +93,12 @@ namespace DanBias
m_data->recieverObj->Update(); m_data->recieverObj->Update();
capFrame += dt; capFrame += dt;
//if(capFrame > 0.03) if(capFrame > 0.03)
{ {
Oyster::Graphics::API::Update(dt); Oyster::Graphics::API::Update(capFrame);
if(Update(dt) != S_OK) if(Update(capFrame) != S_OK)
return DanBiasClientReturn_Error; return DanBiasClientReturn_Error;
if(Render(dt) != S_OK) if(Render(capFrame) != S_OK)
return DanBiasClientReturn_Error; return DanBiasClientReturn_Error;
capFrame = 0; capFrame = 0;
} }

View File

@ -50,11 +50,11 @@ bool GameState::Init(Oyster::Network::NetworkClient* nwClient)
GameState::gameStateState GameState::LoadGame() GameState::gameStateState GameState::LoadGame()
{ {
Oyster::Graphics::Definitions::Pointlight plight; Oyster::Graphics::Definitions::Pointlight plight;
plight.Pos = Float3(315, 0 ,5); plight.Pos = Float3(615, 0 ,5);
plight.Color = Float3(0.9f,0.7f,0.2f); plight.Color = Float3(0.9f,0.7f,0.2f);
plight.Radius = 10; plight.Radius = 100;
plight.Bright = 0.5f; plight.Bright = 0.5f;
//Oyster::Graphics::API::AddLight(plight); Oyster::Graphics::API::AddLight(plight);
plight.Pos = Float3(10,800,5); plight.Pos = Float3(10,800,5);
plight.Color = Float3(0.9f,0.7f,0.3f); plight.Color = Float3(0.9f,0.7f,0.3f);
plight.Radius = 300; plight.Radius = 300;
@ -122,9 +122,8 @@ bool GameState::LoadModels()
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);
} }
/*
// add crystal model // add crystal model
modelData.position = Oyster::Math::Float3(10, 301, 0); modelData.position = Oyster::Math::Float3(10, 601, 0);
modelData.modelPath = L"crystalformation_b.dan"; modelData.modelPath = L"crystalformation_b.dan";
modelData.id = id++; modelData.id = id++;
// load models // load models
@ -132,19 +131,19 @@ bool GameState::LoadModels()
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);
// add house model // add house model
modelData.position = Oyster::Math::Float3(-50, 290, 0); modelData.position = Oyster::Math::Float3(-50, 590, 0);
//Oyster::Math3D::Float4x4 rot = Oyster::Math3D::RotationMatrix(Oyster::Math::Float3(0 ,Utility::Value::Radian(90.0f), 0)); //Oyster::Math3D::Float4x4 rot = Oyster::Math3D::RotationMatrix(Oyster::Math::Float3(0 ,Utility::Value::Radian(90.0f), 0));
modelData.visible = true; modelData.visible = true;
modelData.modelPath = L"building_corporation.dan"; modelData.modelPath = L"building_corporation.dan";
modelData.id = id++; modelData.id = id++;
// load models // load models
this->dynamicObjects.Push(new C_DynamicObj()); this->staticObjects.Push(new C_StaticObj());
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData);
// add player model // add player model
modelData.position = Oyster::Math::Float3(0, 320, 0); modelData.position = Oyster::Math::Float3(0, 602, 0);
modelData.modelPath = L"char_still_sizeref.dan"; modelData.modelPath = L"char_still_sizeref.dan";
modelData.id = id++; modelData.id = id++;
// load models // load models
@ -152,7 +151,7 @@ bool GameState::LoadModels()
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);
// add player model 2 // add player model 2
modelData.position = Oyster::Math::Float3(50, 320, 0); modelData.position = Oyster::Math::Float3(50, 602, 0);
modelData.modelPath = L"char_still_sizeref.dan"; modelData.modelPath = L"char_still_sizeref.dan";
modelData.id = id++; modelData.id = id++;
// load models // load models
@ -160,7 +159,7 @@ bool GameState::LoadModels()
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);
// add jumppad // add jumppad
modelData.position = Oyster::Math::Float3(4, 300.3, 0); modelData.position = Oyster::Math::Float3(4, 600.3, 0);
modelData.modelPath = L"jumppad_round.dan"; modelData.modelPath = L"jumppad_round.dan";
modelData.id = id++; modelData.id = id++;
// load models // load models
@ -174,7 +173,7 @@ bool GameState::LoadModels()
modelData.id = id++; modelData.id = id++;
// load models // load models
this->dynamicObjects.Push(new C_DynamicObj()); this->dynamicObjects.Push(new C_DynamicObj());
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);*/ this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);
return true; return true;
} }
bool GameState::LoadModels(std::string mapFile) bool GameState::LoadModels(std::string mapFile)
@ -374,7 +373,7 @@ bool GameState::Render(float dt)
std::wstring fps; std::wstring fps;
float f = 1/dt; float f = 1/dt;
fps = std::to_wstring(f); fps = std::to_wstring(f);
Oyster::Graphics::API::RenderText(fps,Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.05f,0.08f)); Oyster::Graphics::API::RenderText(fps,Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.2f,0.05f));
Oyster::Graphics::API::EndFrame(); Oyster::Graphics::API::EndFrame();
return true; return true;

View File

@ -113,7 +113,7 @@ void Level::InitiateLevel(std::string levelPath)
void Level::InitiateLevel(float radius) void Level::InitiateLevel(float radius)
{ {
API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0)); API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0));
API::Instance().SetGravity(50); API::Instance().SetGravity(100);
int idCount = 100; int idCount = 100;
// add level sphere // add level sphere
ICustomBody* rigidBody = API::Instance().AddCollisionSphere(599.2f, Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f); ICustomBody* rigidBody = API::Instance().AddCollisionSphere(599.2f, Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
@ -165,20 +165,20 @@ void Level::InitiateLevel(float radius)
//// add crystal // add crystal
ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 605, 0), 5, 0.5f, 0.8f, 0.6f);
//ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 605, 0), 5); this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
rigidBody_Crystal->SetCustomTag(this->dynamicObjects[nrOfBoxex]);
//this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); this->dynamicObjects[nrOfBoxex]->objectID = idCount++;
//rigidBody_Crystal->SetCustomTag(this->dynamicObjects[nrOfBoxex]);
//
//// add house
//ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 905, 0), 0); // add house
//this->staticObjects.Push(new StaticObject(rigidBody_House,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_GENERIC)); ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(20, 20, 20), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(-50, 590, 0), 0, 0.5f, 0.8f, 0.6f);
//rigidBody_House->SetCustomTag(this->staticObjects[0]); this->staticObjects.Push(new StaticObject(rigidBody_House,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_GENERIC));
rigidBody_House->SetCustomTag(this->staticObjects[0]);
this->staticObjects[0]->objectID = idCount++;
} }
void Level::AddPlayerToTeam(Player *player, int teamID) void Level::AddPlayerToTeam(Player *player, int teamID)

View File

@ -156,8 +156,8 @@ void Player::Rotate(const Oyster::Math3D::Float4 lookDir)
void Player::Jump() void Player::Jump()
{ {
Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1]; Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1].GetNormalized();
//this->rigidBody->GetState().SetLinearVelocity(up *10); this->rigidBody->ApplyImpulse(up *2000);
} }
bool Player::IsWalking() bool Player::IsWalking()