GL - gravity working
This commit is contained in:
parent
c7b3c1ec30
commit
561418c427
|
@ -47,13 +47,23 @@ bool GameState::Init(Oyster::Network::NetworkClient* nwClient)
|
|||
GameState::gameStateState GameState::LoadGame()
|
||||
{
|
||||
Oyster::Graphics::Definitions::Pointlight plight;
|
||||
plight.Pos = Oyster::Math::Float3(0,3,0);
|
||||
plight.Pos = Oyster::Math::Float3(0,15,5);
|
||||
plight.Color = Oyster::Math::Float3(0,1,0);
|
||||
plight.Radius = 5;
|
||||
plight.Radius = 50;
|
||||
plight.Bright = 2;
|
||||
Oyster::Graphics::API::AddLight(plight);
|
||||
plight.Pos = Oyster::Math::Float3(10,15,5);
|
||||
plight.Color = Oyster::Math::Float3(1,0,0);
|
||||
plight.Radius = 50;
|
||||
plight.Bright = 2;
|
||||
Oyster::Graphics::API::AddLight(plight);
|
||||
plight.Pos = Oyster::Math::Float3(10,-15,5);
|
||||
plight.Color = Oyster::Math::Float3(0,0,1);
|
||||
plight.Radius = 50;
|
||||
plight.Bright = 2;
|
||||
Oyster::Graphics::API::AddLight(plight);
|
||||
LoadModels(L"map");
|
||||
InitCamera(Oyster::Math::Float3(0,0,5.4f));
|
||||
InitCamera(Oyster::Math::Float3(0,0,20.0f));
|
||||
return gameStateState_playing;
|
||||
}
|
||||
bool GameState::LoadModels(std::wstring mapFile)
|
||||
|
@ -89,6 +99,15 @@ bool GameState::LoadModels(std::wstring mapFile)
|
|||
modelData.world = modelData.world * translate;
|
||||
modelData.modelPath = L"..\\Content\\Models\\char_white.dan";
|
||||
modelData.id ++;
|
||||
|
||||
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(0,0,0));
|
||||
Oyster::Math3D::Float4x4 scale = Oyster::Math3D::Float4x4::identity;
|
||||
scale.v[0].x = 8;
|
||||
scale.v[1].y = 8;
|
||||
scale.v[2].z = 8;
|
||||
modelData.world = scale; //modelData.world * translate
|
||||
modelData.modelPath = L"ball.dan";
|
||||
modelData.id ++;
|
||||
|
||||
obj = new C_DynamicObj();
|
||||
privData->object.push_back(obj);
|
||||
|
|
|
@ -100,6 +100,30 @@ bool Game::NewFrame()
|
|||
|
||||
API::Instance().Update();
|
||||
|
||||
for (unsigned int i = 0; i < this->players.Size(); i++)
|
||||
{
|
||||
if(this->players[i]->player) this->players[i]->player->EndFrame();
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < this->players.Size(); i++)
|
||||
{
|
||||
if(this->players[i]->player) this->players[i]->player->BeginFrame();
|
||||
}
|
||||
|
||||
API::Instance().Update();
|
||||
|
||||
for (unsigned int i = 0; i < this->players.Size(); i++)
|
||||
{
|
||||
if(this->players[i]->player) this->players[i]->player->EndFrame();
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < this->players.Size(); i++)
|
||||
{
|
||||
if(this->players[i]->player) this->players[i]->player->BeginFrame();
|
||||
}
|
||||
|
||||
API::Instance().Update();
|
||||
|
||||
for (unsigned int i = 0; i < this->players.Size(); i++)
|
||||
{
|
||||
if(this->players[i]->player) this->players[i]->player->EndFrame();
|
||||
|
|
|
@ -19,24 +19,28 @@ void Level::InitiateLevel(std::string levelPath)
|
|||
}
|
||||
void Level::InitiateLevel(float radius)
|
||||
{
|
||||
//API::SphericalBodyDescription sbDesc;
|
||||
//sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,1);
|
||||
//sbDesc.ignoreGravity = true;
|
||||
//sbDesc.radius = radius;
|
||||
//sbDesc.mass = 1e16f; //10^16
|
||||
API::SphericalBodyDescription sbDesc;
|
||||
sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,1);
|
||||
sbDesc.ignoreGravity = true;
|
||||
sbDesc.radius = 8; //radius;
|
||||
sbDesc.mass = 10e12f;
|
||||
//sbDesc.mass = 0; //10^16
|
||||
//sbDesc.subscription_onCollision = CollisionManager::LevelCollision;
|
||||
//
|
||||
//ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
|
||||
//API::Instance().AddObject(rigidBody);
|
||||
|
||||
//API::Gravity gravityWell;
|
||||
//
|
||||
//gravityWell.gravityType = API::Gravity::GravityType_Well;
|
||||
//gravityWell.well.mass = 1e16f;
|
||||
//gravityWell.well.position = Oyster::Math::Float4(0,0,0,1);
|
||||
//
|
||||
//API::Instance().AddGravity(gravityWell);
|
||||
sbDesc.subscription_onCollision = CollisionManager::LevelCollision;
|
||||
|
||||
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
|
||||
API::Instance().AddObject(rigidBody);
|
||||
ICustomBody::State state;
|
||||
rigidBody->GetState(state);
|
||||
state.SetRestitutionCoeff(0.1);
|
||||
rigidBody->SetState(state);
|
||||
|
||||
API::Gravity gravityWell;
|
||||
|
||||
gravityWell.gravityType = API::Gravity::GravityType_Well;
|
||||
gravityWell.well.mass = 10e12f;
|
||||
gravityWell.well.position = Oyster::Math::Float4(0,0,0,1);
|
||||
|
||||
API::Instance().AddGravity(gravityWell);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ Object::Object()
|
|||
Object::Object(void* collisionFunc, OBJECT_TYPE type)
|
||||
{
|
||||
API::SimpleBodyDescription sbDesc;
|
||||
//sbDesc.centerPosition =
|
||||
|
||||
//poi
|
||||
this->rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
|
||||
|
|
|
@ -16,6 +16,10 @@ Player::Player()
|
|||
teamID = -1;
|
||||
playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
||||
lookDir = Oyster::Math::Float4(0,0,-1,0);
|
||||
setState.SetCenterPosition(Oyster::Math::Float4(0,15,0,1));
|
||||
setState.SetReach(Oyster::Math::Float4(2,3.5,2,0));
|
||||
|
||||
|
||||
}
|
||||
|
||||
Player::~Player(void)
|
||||
|
@ -53,18 +57,18 @@ void Player::Move(const PLAYER_MOVEMENT &movement)
|
|||
|
||||
void Player::MoveForward()
|
||||
{
|
||||
setState.ApplyLinearImpulse(this->lookDir * (100 * this->gameInstance->GetFrameTime()));
|
||||
setState.ApplyLinearImpulse(this->lookDir * (20 * this->gameInstance->GetFrameTime()));
|
||||
}
|
||||
void Player::MoveBackwards()
|
||||
{
|
||||
setState.ApplyLinearImpulse(-this->lookDir * 100 * this->gameInstance->GetFrameTime());
|
||||
setState.ApplyLinearImpulse(-this->lookDir * 20 * this->gameInstance->GetFrameTime());
|
||||
}
|
||||
void Player::MoveRight()
|
||||
{
|
||||
//Do cross product with forward vector and negative gravity vector
|
||||
Oyster::Math::Float4 r = Oyster::Math::Float4(1, 0, 0, 0 );
|
||||
//Oyster::Math::Float4 r = (-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir);
|
||||
setState.ApplyLinearImpulse(r * 100 * this->gameInstance->GetFrameTime());
|
||||
setState.ApplyLinearImpulse(r * 20 * this->gameInstance->GetFrameTime());
|
||||
|
||||
}
|
||||
void Player::MoveLeft()
|
||||
|
@ -72,7 +76,7 @@ void Player::MoveLeft()
|
|||
//Do cross product with forward vector and negative gravity vector
|
||||
Oyster::Math::Float4 r = Oyster::Math::Float4(1, 0, 0, 0 );
|
||||
//Oyster::Math::Float4 r1 = -(-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir); //Still get zero
|
||||
setState.ApplyLinearImpulse(-r * 100 * this->gameInstance->GetFrameTime());
|
||||
setState.ApplyLinearImpulse(-r * 20 * this->gameInstance->GetFrameTime());
|
||||
}
|
||||
|
||||
void Player::UseWeapon(const WEAPON_FIRE &usage)
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace
|
|||
|
||||
// calc from perspective of deuter
|
||||
Float4 normal; deuter->GetNormalAt( worldPointOfContact, normal );
|
||||
Float protoG_Magnitude = protoG.Dot( normal ),
|
||||
Float protoG_Magnitude = protoG.Dot( normal ),
|
||||
deuterG_Magnitude = deuterG.Dot( normal );
|
||||
|
||||
// if they are not relatively moving towards eachother, there is no collision
|
||||
|
|
Loading…
Reference in New Issue