GL - trying to make walking nice

This commit is contained in:
Erik Persson 2014-01-30 15:12:53 +01:00
parent 323b7322fa
commit ae6a570a12
7 changed files with 26 additions and 18 deletions

View File

@ -81,9 +81,10 @@ bool GameState::LoadModels(std::wstring mapFile)
C_Object* obj; C_Object* obj;
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(0,0,0)); translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(0,0,0));
Oyster::Math3D::Float4x4 scale = Oyster::Math3D::Float4x4::identity; Oyster::Math3D::Float4x4 scale = Oyster::Math3D::Float4x4::identity;
scale.v[0].x = 8; scale.v[0].x = 0.2;
scale.v[1].y = 8; scale.v[1].y = 0.2;
scale.v[2].z = 8; scale.v[2].z = 0.2;
scale.v[3].w = 1;
modelData.world = translate ;//modelData.world * translate modelData.world = translate ;//modelData.world * translate
modelData.modelPath = L"world_earth.dan"; modelData.modelPath = L"world_earth.dan";
modelData.id = 0; modelData.id = 0;
@ -94,7 +95,7 @@ bool GameState::LoadModels(std::wstring mapFile)
// add box model // add box model
modelData.world = Oyster::Math3D::Float4x4::identity; modelData.world = Oyster::Math3D::Float4x4::identity;
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-5,175,0)); translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-5,15,0));
modelData.world = modelData.world * translate; modelData.world = modelData.world * translate;
modelData.modelPath = L"box.dan"; modelData.modelPath = L"box.dan";
modelData.id = 1; modelData.id = 1;
@ -132,7 +133,7 @@ bool GameState::InitCamera(Oyster::Math::Float3 startPos)
camera->LookAt(pos, dir, up); camera->LookAt(pos, dir, up);
camera->SetLens(3.14f/2, 1024/768, 1, 1000); camera->SetLens(3.14f/2, 1024/768, 1, 1000);
privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000); privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1024.0f/768.0f,.1f,1000);
//privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000); //privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000);
Oyster::Graphics::API::SetProjection(privData->proj); Oyster::Graphics::API::SetProjection(privData->proj);
camera->UpdateViewMatrix(); camera->UpdateViewMatrix();

View File

@ -81,8 +81,11 @@ using namespace GameLogic;
void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj, void *args) void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj, void *args)
{ {
Oyster::Math::Float3 pushForce = Oyster::Math::Float4(1,0,0) * (1); Oyster::Math::Float3 pushForce = Oyster::Math::Float4(1,0,0) * (500);
Oyster::Physics::ICustomBody::State state; Oyster::Physics::ICustomBody::State state;
Object *realObj = (Object*)obj->GetCustomTag();
if(realObj->GetType() == OBJECT_TYPE_PLAYER || realObj->GetType() == OBJECT_TYPE_WORLD)
return;
state = obj->GetState(); state = obj->GetState();
state.ApplyLinearImpulse(pushForce); state.ApplyLinearImpulse(pushForce);
obj->SetState(state); obj->SetState(state);

View File

@ -7,9 +7,9 @@ Game::PlayerData::PlayerData()
{ {
//set some stats that are appropriate to a player //set some stats that are appropriate to a player
Oyster::Physics::API::SimpleBodyDescription sbDesc; Oyster::Physics::API::SimpleBodyDescription sbDesc;
sbDesc.centerPosition = Oyster::Math::Float3(0,165,0); sbDesc.centerPosition = Oyster::Math::Float3(0,350,0);
sbDesc.size = Oyster::Math::Float3(4,7,4); sbDesc.size = Oyster::Math::Float3(4,7,4);
sbDesc.mass = 10;
//create rigid body //create rigid body
Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release(); Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release();

View File

@ -25,7 +25,7 @@ void Level::InitiateLevel(float radius)
API::SphericalBodyDescription sbDesc; API::SphericalBodyDescription sbDesc;
sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,1); sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,1);
sbDesc.ignoreGravity = true; sbDesc.ignoreGravity = true;
sbDesc.radius = 150; sbDesc.radius = 300;
sbDesc.mass = 10e12f; sbDesc.mass = 10e12f;
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release(); ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
@ -59,7 +59,7 @@ void Level::InitiateLevel(float radius)
// add gravitation // add gravitation
API::Gravity gravityWell; API::Gravity gravityWell;
gravityWell.gravityType = API::Gravity::GravityType_Well; gravityWell.gravityType = API::Gravity::GravityType_Well;
gravityWell.well.mass = 10e16f; gravityWell.well.mass = 1e15f;
gravityWell.well.position = Oyster::Math::Float4(0,0,0,1); gravityWell.well.position = Oyster::Math::Float4(0,0,0,1);
API::Instance().AddGravity(gravityWell); API::Instance().AddGravity(gravityWell);
} }

View File

@ -86,24 +86,24 @@ void Player::Move(const PLAYER_MOVEMENT &movement)
void Player::MoveForward() void Player::MoveForward()
{ {
setState.ApplyLinearImpulse(this->lookDir * (20 * this->gameInstance->GetFrameTime())); setState.ApplyLinearImpulse(this->lookDir * (2000 * this->gameInstance->GetFrameTime()));
} }
void Player::MoveBackwards() void Player::MoveBackwards()
{ {
setState.ApplyLinearImpulse(-this->lookDir * 20 * this->gameInstance->GetFrameTime()); setState.ApplyLinearImpulse(-this->lookDir * 2000 * this->gameInstance->GetFrameTime());
} }
void Player::MoveRight() 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 r = (-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir); Oyster::Math::Float3 r = (-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir);
setState.ApplyLinearImpulse(r * 20 * this->gameInstance->GetFrameTime()); setState.ApplyLinearImpulse(r * 2000 * this->gameInstance->GetFrameTime());
} }
void Player::MoveLeft() void Player::MoveLeft()
{ {
//Do cross product with forward vector and negative gravity vector //Do cross product with forward vector and negative gravity vector
Oyster::Math::Float3 r = -(-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir); //Still get zero Oyster::Math::Float3 r = -(-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir); //Still get zero
setState.ApplyLinearImpulse(-r * 20 * this->gameInstance->GetFrameTime()); setState.ApplyLinearImpulse(-r * 2000 * this->gameInstance->GetFrameTime());
} }
void Player::UseWeapon(const WEAPON_FIRE &usage) void Player::UseWeapon(const WEAPON_FIRE &usage)
@ -123,7 +123,7 @@ void Player::Rotate(const Oyster::Math3D::Float3 lookDir)
{ {
this->lookDir = lookDir; this->lookDir = lookDir;
Oyster::Math::Float4 up(0,1,0,0);//-setState.GetGravityNormal(); Oyster::Math::Float4 up = -setState.GetGravityNormal();
Oyster::Math::Float4 pos = setState.GetCenterPosition(); Oyster::Math::Float4 pos = setState.GetCenterPosition();
Oyster::Math::Float4x4 world = Oyster::Math3D::OrientationMatrix_LookAtDirection(lookDir, up.xyz, pos.xyz); Oyster::Math::Float4x4 world = Oyster::Math3D::OrientationMatrix_LookAtDirection(lookDir, up.xyz, pos.xyz);
// cant set rotation // cant set rotation

View File

@ -27,7 +27,9 @@ void main( uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID )
Shaded.Specular += light.Specular; Shaded.Specular += light.Specular;
} }
Diffuse[DTid.xy] = float4(Shaded.Diffuse * DiffuseGlow[DTid.xy].xyz,1); //Diffuse[DTid.xy] = float4(Shaded.Diffuse * DiffuseGlow[DTid.xy].xyz,1);
Diffuse[DTid.xy] = float4(DiffuseGlow[DTid.xy].xyz,1);
Specular[DTid.xy] = float4(Shaded.Specular, 1); Specular[DTid.xy] = float4(Shaded.Specular, 1);

View File

@ -8,5 +8,7 @@ RWTexture2D<float4> Output;
void main( uint3 DTid : SV_DispatchThreadID ) void main( uint3 DTid : SV_DispatchThreadID )
{ {
Output[DTid.xy] = Diffuse[DTid.xy] + Specular[DTid.xy] + Diffuse[DTid.xy] * Ambient[DTid.xy/4].w;// + float4(Ambient[DTid.xy/4].xyz,1); GLOW Output[DTid.xy] = Diffuse[DTid.xy] + Specular[DTid.xy] + Diffuse[DTid.xy] * Ambient[DTid.xy/4].w;// + float4(Ambient[DTid.xy/4].xyz,1); GLOW
//Output[DTid.xy] = Diffuse[DTid.xy] + Diffuse[DTid.xy] * Ambient[DTid.xy/4].w;// + float4(Ambient[DTid.xy/4].xyz,1); GLOW
//Output[DTid.xy] = Diffuse[DTid.xy]; //Output[DTid.xy] = Diffuse[DTid.xy];
} }