GL - physics merge 2

This commit is contained in:
lindaandersson 2014-02-10 15:54:38 +01:00
parent 1b5e8e11cb
commit b731c206f4
6 changed files with 23 additions and 27 deletions

View File

@ -311,9 +311,9 @@ void GameState::InitiatePlayer(int id, std::wstring modelName, Oyster::Math::Flo
C_Object* obj;
modelData.visible = true;
//modelData.world = world;
//modelData.position = ;
//modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(2,2,-2), 1);
//modelData.scale = Oyster::Math::Float3(2,2,2);
modelData.position = Oyster::Math::Float3(world[12], world[13], world[14]);
modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(2,2,-2), 1);
modelData.scale = Oyster::Math::Float3(2,2,2);
modelData.modelPath = modelName;
modelData.id = myId;
@ -612,15 +612,15 @@ void GameState::Protocol( ObjPos* pos )
Oyster::Math::Float3 newLook = up.Cross(right);
newLook.Normalize();*/
camera->setRight(right);
camera->setUp(up);
//camera->setRight(right);
//camera->setUp(up);
//camera->setLook(objForward);
up *= 1;
objForward *= -2;
Oyster::Math::Float3 cameraPos = pos + up + objForward;
camera->SetPosition(cameraPos);
camera->UpdateViewMatrix();
//camera->SetPosition(cameraPos);
//camera->UpdateViewMatrix();
}
}

View File

@ -81,8 +81,8 @@ Game::LevelData* Game::CreateLevel()
if(this->level) return this->level;
this->level = new LevelData();
//this->level->level->InitiateLevel(1000);
this->level->level->InitiateLevel("3bana.bias");
this->level->level->InitiateLevel(1000);
//this->level->level->InitiateLevel("3bana.bias");
return this->level;
}

View File

@ -15,16 +15,16 @@ Game::PlayerData::PlayerData()
//sbDesc.quaternion = Oyster::Math::Float3(0, Oyster::Math::pi, 0);
//create rigid body
Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass);
Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f );
//create player with this rigid body
this->player = new Player(rigidBody,Level::LevelCollisionBefore, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER);
this->player->GetRigidBody()->SetCustomTag(this);
Oyster::Physics::ICustomBody::State state;
this->player->GetRigidBody()->GetState(state);
//state.SetRotation(Oyster::Math::Float3(0, Oyster::Math::pi, 0));
this->player->GetRigidBody()->SetState(state);
//Oyster::Physics::ICustomBody::State state;
//this->player->GetRigidBody()->GetState(state);
////state.SetRotation(Oyster::Math::Float3(0, Oyster::Math::pi, 0));
//this->player->GetRigidBody()->SetState(state);
player->EndFrame();
}
Game::PlayerData::PlayerData(int playerID,int teamID)

View File

@ -230,12 +230,7 @@ void Level::InitiateLevel(float radius)
int idCount = 100;
// add level sphere
ICustomBody* rigidBody = API::Instance().AddCollisionSphere(599.2f, Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0);
ICustomBody::State state;
rigidBody->GetState(state);
state.restitutionCoeff = 0.2f;
rigidBody->SetState(state);
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);
levelObj = new StaticObject(rigidBody, LevelCollisionBefore, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD);
this->levelObj->objectID = idCount++;
rigidBody->SetCustomTag(levelObj);
@ -247,7 +242,7 @@ void Level::InitiateLevel(float radius)
int offset = 0;
for(int i =0; i< nrOfBoxex; i ++)
{
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 605 + i*5, 10), 5);
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 605 + i*5, 10), 5, 0.5f, 0.8f, 0.6f);
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
this->dynamicObjects[i]->objectID = idCount++;

View File

@ -16,7 +16,7 @@ const Game *Object::gameInstance = (Game*)(&Game::Instance());
Object::Object()
{
this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0);
this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
this->type = OBJECT_TYPE::OBJECT_TYPE_UNKNOWN;
this->objectID = GID();
@ -26,7 +26,7 @@ Object::Object()
Object::Object(OBJECT_TYPE type)
{
this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0);
this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
this->type = type;
this->objectID = GID();
this->currPhysicsState = this->rigidBody->GetState();
@ -44,7 +44,7 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type)
Object::Object(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
{
this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0);
this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
this->type = type;
this->objectID = GID();

View File

@ -109,6 +109,7 @@ void Player::MoveForward()
Oyster::Math::Float3 forward = currPhysicsState.GetOrientation().v[2];
//Oyster::Math::Float3 forward = lookDir;
//newPhysicsState.ApplyLinearImpulse(forward * (MOVE_FORCE * this->gameInstance->GetFrameTime()));
//rigidBody->SetLinearVelocity( 10 * this->gameInstance->GetFrameTime() );
}
void Player::MoveBackwards()
{
@ -120,10 +121,10 @@ void Player::MoveRight()
{
//Do cross product with forward vector and negative gravity vector
Oyster::Math::Float3 forward = currPhysicsState.GetOrientation().v[2];
//Oyster::Math::Float3 forward = lookDir;
//Oyster::Math::Float3 r = (-currPhysicsState.GetGravityNormal()).Cross(forward);
//newPhysicsState.ApplyLinearImpulse(-r * MOVE_FORCE * this->gameInstance->GetFrameTime());
Oyster::Math::Float3 r = (-currPhysicsState.centerPos.Normalize()).Cross(forward);
//rigidBody->SetLinearVelocity(-r * 10 * this->gameInstance->GetFrameTime() );
}
void Player::MoveLeft()
{