GL - physics merge 2
This commit is contained in:
parent
1b5e8e11cb
commit
b731c206f4
|
@ -311,9 +311,9 @@ void GameState::InitiatePlayer(int id, std::wstring modelName, Oyster::Math::Flo
|
||||||
C_Object* obj;
|
C_Object* obj;
|
||||||
modelData.visible = true;
|
modelData.visible = true;
|
||||||
//modelData.world = world;
|
//modelData.world = world;
|
||||||
//modelData.position = ;
|
modelData.position = Oyster::Math::Float3(world[12], world[13], world[14]);
|
||||||
//modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(2,2,-2), 1);
|
modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(2,2,-2), 1);
|
||||||
//modelData.scale = Oyster::Math::Float3(2,2,2);
|
modelData.scale = Oyster::Math::Float3(2,2,2);
|
||||||
modelData.modelPath = modelName;
|
modelData.modelPath = modelName;
|
||||||
modelData.id = myId;
|
modelData.id = myId;
|
||||||
|
|
||||||
|
@ -612,15 +612,15 @@ void GameState::Protocol( ObjPos* pos )
|
||||||
Oyster::Math::Float3 newLook = up.Cross(right);
|
Oyster::Math::Float3 newLook = up.Cross(right);
|
||||||
newLook.Normalize();*/
|
newLook.Normalize();*/
|
||||||
|
|
||||||
camera->setRight(right);
|
//camera->setRight(right);
|
||||||
camera->setUp(up);
|
//camera->setUp(up);
|
||||||
//camera->setLook(objForward);
|
//camera->setLook(objForward);
|
||||||
|
|
||||||
up *= 1;
|
up *= 1;
|
||||||
objForward *= -2;
|
objForward *= -2;
|
||||||
Oyster::Math::Float3 cameraPos = pos + up + objForward;
|
Oyster::Math::Float3 cameraPos = pos + up + objForward;
|
||||||
camera->SetPosition(cameraPos);
|
//camera->SetPosition(cameraPos);
|
||||||
camera->UpdateViewMatrix();
|
//camera->UpdateViewMatrix();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,8 +81,8 @@ Game::LevelData* Game::CreateLevel()
|
||||||
if(this->level) return this->level;
|
if(this->level) return this->level;
|
||||||
|
|
||||||
this->level = new LevelData();
|
this->level = new LevelData();
|
||||||
//this->level->level->InitiateLevel(1000);
|
this->level->level->InitiateLevel(1000);
|
||||||
this->level->level->InitiateLevel("3bana.bias");
|
//this->level->level->InitiateLevel("3bana.bias");
|
||||||
|
|
||||||
return this->level;
|
return this->level;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,16 +15,16 @@ Game::PlayerData::PlayerData()
|
||||||
//sbDesc.quaternion = Oyster::Math::Float3(0, Oyster::Math::pi, 0);
|
//sbDesc.quaternion = Oyster::Math::Float3(0, Oyster::Math::pi, 0);
|
||||||
|
|
||||||
//create rigid body
|
//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
|
//create player with this rigid body
|
||||||
this->player = new Player(rigidBody,Level::LevelCollisionBefore, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER);
|
this->player = new Player(rigidBody,Level::LevelCollisionBefore, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER);
|
||||||
this->player->GetRigidBody()->SetCustomTag(this);
|
this->player->GetRigidBody()->SetCustomTag(this);
|
||||||
|
|
||||||
Oyster::Physics::ICustomBody::State state;
|
//Oyster::Physics::ICustomBody::State state;
|
||||||
this->player->GetRigidBody()->GetState(state);
|
//this->player->GetRigidBody()->GetState(state);
|
||||||
//state.SetRotation(Oyster::Math::Float3(0, Oyster::Math::pi, 0));
|
////state.SetRotation(Oyster::Math::Float3(0, Oyster::Math::pi, 0));
|
||||||
this->player->GetRigidBody()->SetState(state);
|
//this->player->GetRigidBody()->SetState(state);
|
||||||
player->EndFrame();
|
player->EndFrame();
|
||||||
}
|
}
|
||||||
Game::PlayerData::PlayerData(int playerID,int teamID)
|
Game::PlayerData::PlayerData(int playerID,int teamID)
|
||||||
|
|
|
@ -230,12 +230,7 @@ void Level::InitiateLevel(float radius)
|
||||||
|
|
||||||
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);
|
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::State state;
|
|
||||||
rigidBody->GetState(state);
|
|
||||||
state.restitutionCoeff = 0.2f;
|
|
||||||
rigidBody->SetState(state);
|
|
||||||
levelObj = new StaticObject(rigidBody, LevelCollisionBefore, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD);
|
levelObj = new StaticObject(rigidBody, LevelCollisionBefore, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD);
|
||||||
this->levelObj->objectID = idCount++;
|
this->levelObj->objectID = idCount++;
|
||||||
rigidBody->SetCustomTag(levelObj);
|
rigidBody->SetCustomTag(levelObj);
|
||||||
|
@ -247,7 +242,7 @@ void Level::InitiateLevel(float radius)
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
for(int i =0; i< nrOfBoxex; i ++)
|
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.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||||
this->dynamicObjects[i]->objectID = idCount++;
|
this->dynamicObjects[i]->objectID = idCount++;
|
||||||
|
|
|
@ -16,7 +16,7 @@ const Game *Object::gameInstance = (Game*)(&Game::Instance());
|
||||||
Object::Object()
|
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->type = OBJECT_TYPE::OBJECT_TYPE_UNKNOWN;
|
||||||
this->objectID = GID();
|
this->objectID = GID();
|
||||||
|
@ -26,7 +26,7 @@ Object::Object()
|
||||||
|
|
||||||
Object::Object(OBJECT_TYPE type)
|
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->type = type;
|
||||||
this->objectID = GID();
|
this->objectID = GID();
|
||||||
this->currPhysicsState = this->rigidBody->GetState();
|
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)
|
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->type = type;
|
||||||
this->objectID = GID();
|
this->objectID = GID();
|
||||||
|
|
|
@ -109,6 +109,7 @@ void Player::MoveForward()
|
||||||
Oyster::Math::Float3 forward = currPhysicsState.GetOrientation().v[2];
|
Oyster::Math::Float3 forward = currPhysicsState.GetOrientation().v[2];
|
||||||
//Oyster::Math::Float3 forward = lookDir;
|
//Oyster::Math::Float3 forward = lookDir;
|
||||||
//newPhysicsState.ApplyLinearImpulse(forward * (MOVE_FORCE * this->gameInstance->GetFrameTime()));
|
//newPhysicsState.ApplyLinearImpulse(forward * (MOVE_FORCE * this->gameInstance->GetFrameTime()));
|
||||||
|
//rigidBody->SetLinearVelocity( 10 * this->gameInstance->GetFrameTime() );
|
||||||
}
|
}
|
||||||
void Player::MoveBackwards()
|
void Player::MoveBackwards()
|
||||||
{
|
{
|
||||||
|
@ -120,10 +121,10 @@ void Player::MoveRight()
|
||||||
{
|
{
|
||||||
//Do cross product with forward vector and negative gravity vector
|
//Do cross product with forward vector and negative gravity vector
|
||||||
Oyster::Math::Float3 forward = currPhysicsState.GetOrientation().v[2];
|
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 forward = lookDir;
|
||||||
|
Oyster::Math::Float3 r = (-currPhysicsState.centerPos.Normalize()).Cross(forward);
|
||||||
|
//rigidBody->SetLinearVelocity(-r * 10 * this->gameInstance->GetFrameTime() );
|
||||||
}
|
}
|
||||||
void Player::MoveLeft()
|
void Player::MoveLeft()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue