More cool stuff
This commit is contained in:
parent
f372d3e05b
commit
b225c53611
|
@ -55,7 +55,7 @@ bool LobbyState::LoadModels(std::wstring file)
|
|||
|
||||
modelData.world = Oyster::Math3D::Float4x4::identity;
|
||||
modelData.visible = true;
|
||||
modelData.modelPath = L"..\\Content\\Models\\box_2.dan";
|
||||
modelData.modelPath = L"crate_colonists.dan";
|
||||
// load models
|
||||
privData->object[0] = new C_StaticObj();
|
||||
privData->object[0]->Init(modelData);
|
||||
|
|
|
@ -72,11 +72,11 @@ void Level::InitiateLevel(float radius)
|
|||
//this->dynamicObjects = new DynamicArray< DynamicObject>;
|
||||
// add box
|
||||
API::SimpleBodyDescription sbDesc_TestBox;
|
||||
sbDesc_TestBox.centerPosition = Oyster::Math::Float4(10,320,0,0);
|
||||
sbDesc_TestBox.centerPosition = Oyster::Math::Float4(10,320,0,1);
|
||||
sbDesc_TestBox.ignoreGravity = false;
|
||||
|
||||
sbDesc_TestBox.mass = 20;
|
||||
sbDesc_TestBox.size = Oyster::Math::Float4(2,2,2,0);
|
||||
sbDesc_TestBox.size = Oyster::Math::Float4(1,1,1,0);
|
||||
|
||||
|
||||
ICustomBody* rigidBody_TestBox;
|
||||
|
@ -132,7 +132,7 @@ void Level::InitiateLevel(float radius)
|
|||
sbDesc_Crystal.centerPosition = Oyster::Math::Float4(10, 305, 0, 1);
|
||||
sbDesc_Crystal.ignoreGravity = false;
|
||||
sbDesc_Crystal.mass = 80;
|
||||
sbDesc_Crystal.size = Oyster::Math::Float3(2,3,2);
|
||||
sbDesc_Crystal.size = Oyster::Math::Float3(1,2,1);
|
||||
|
||||
ICustomBody* rigidBody_Crystal = API::Instance().CreateRigidBody(sbDesc_Crystal).Release();
|
||||
rigidBody_Crystal->SetSubscription(Level::PhysicsOnMoveLevel);
|
||||
|
|
|
@ -158,10 +158,10 @@ void Object::EndFrame()
|
|||
}
|
||||
|
||||
|
||||
if(currPhysicsState.GetGravityNormal()!= Float3::null)
|
||||
//if(currPhysicsState.GetGravityNormal()!= Float3::null)
|
||||
{
|
||||
Oyster::Math::Float4 axis;
|
||||
Oyster::Math3D::SnapAngularAxis(Oyster::Math::Float4(currPhysicsState.GetAngularAxis(), 0), Oyster::Math::Float4::standard_unit_y, -Oyster::Math::Float4(currPhysicsState.GetGravityNormal()), axis);
|
||||
Oyster::Math3D::SnapAngularAxis(Oyster::Math::Float4(currPhysicsState.GetAngularAxis(), 0), Oyster::Math::Float4::standard_unit_y, Oyster::Math::Float4(currPhysicsState.GetCenterPosition().GetNormalized(), 0), axis);
|
||||
if(axis !=axis)
|
||||
{
|
||||
//error
|
||||
|
@ -170,17 +170,17 @@ void Object::EndFrame()
|
|||
axis.Normalize();
|
||||
currPhysicsState.SetRotation(axis.xyz);
|
||||
currPhysicsState.SetAngularMomentum(Float3::null);
|
||||
Oyster::Math::Float3 debug = ::LinearAlgebra3D::WorldAxisOf(::LinearAlgebra3D::Rotation(axis.xyz), Oyster::Math::Float3::standard_unit_y);
|
||||
debug += currPhysicsState.GetGravityNormal();
|
||||
//Oyster::Math::Float3 debug = ::LinearAlgebra3D::WorldAxisOf(::LinearAlgebra3D::Rotation(axis.xyz), Oyster::Math::Float3::standard_unit_y);
|
||||
//debug += currPhysicsState.GetGravityNormal();
|
||||
}
|
||||
Oyster::Math::Float3 pos = currPhysicsState.GetCenterPosition();
|
||||
Oyster::Math::Float3 up = -currPhysicsState.GetGravityNormal();
|
||||
//Oyster::Math::Float3 pos = currPhysicsState.GetCenterPosition();
|
||||
//Oyster::Math::Float3 up = -currPhysicsState.GetGravityNormal();
|
||||
//300, 0,0,
|
||||
//1,0,0
|
||||
|
||||
/*if( pos.GetLength() < 303.5f)
|
||||
/*if( pos.GetLength() < 301.5f)
|
||||
{
|
||||
Oyster::Math::Float moveUp = 303.5 - pos.GetLength();
|
||||
Oyster::Math::Float moveUp = 301.5 - pos.GetLength();
|
||||
up *= moveUp;
|
||||
|
||||
currPhysicsState.SetCenterPosition(pos + up);
|
||||
|
|
|
@ -178,9 +178,7 @@ namespace
|
|||
ICustomBody::State protoState; proto->GetState( protoState );
|
||||
ICustomBody::State deuterState; deuter->GetState( deuterState );
|
||||
|
||||
// calc from perspective of deuter.
|
||||
// calc from perspective of deuter.
|
||||
Float4 normal = (worldPointOfContact - Float4(deuterState.GetCenterPosition(), 1.0f )).GetNormalized(); // Init value is only borrowed
|
||||
Float4 normal = (worldPointOfContact - Float4(deuterState.GetCenterPosition(), 1.0f )); // Init value is only borrowed
|
||||
if( normal.Dot(normal) > 0.0f )
|
||||
{
|
||||
deuter->GetNormalAt( worldPointOfContact, normal );
|
||||
|
@ -208,7 +206,7 @@ namespace
|
|||
Float protoG_Magnitude = protoG.Dot( normal ),
|
||||
deuterG_Magnitude = deuterG.Dot( normal );
|
||||
|
||||
if(protoState.GetMass() == 70)
|
||||
if(protoState.GetMass() == 20)
|
||||
{
|
||||
const char *breakpoint = "STOP";
|
||||
}
|
||||
|
@ -234,7 +232,11 @@ namespace
|
|||
return;
|
||||
}
|
||||
|
||||
// calc from perspective of proto
|
||||
// bounce
|
||||
Float4 bounceD = normal * -Formula::CollisionResponse::Bounce( deuterState.GetRestitutionCoeff(),
|
||||
deuterState.GetMass(), deuterG_Magnitude,
|
||||
protoState.GetMass(), protoG_Magnitude );
|
||||
|
||||
normal = (worldPointOfContact - Float4(protoState.GetCenterPosition(), 1.0f )).GetNormalized();
|
||||
if( normal.Dot(normal) > 0.0f )
|
||||
{
|
||||
|
@ -260,10 +262,7 @@ namespace
|
|||
Float4(protoState.GetLinearMomentum(), 0), protoState.GetFrictionCoeff_Static(), protoState.GetFrictionCoeff_Kinetic(), protoState.GetMass(),
|
||||
Float4(deuterState.GetLinearMomentum(), 0), deuterState.GetFrictionCoeff_Static(), deuterState.GetFrictionCoeff_Kinetic(), deuterState.GetMass());
|
||||
|
||||
if(protoState.GetMass() == 70)
|
||||
{
|
||||
const char *breakpoint = "STOP";
|
||||
}
|
||||
|
||||
|
||||
protoState.ApplyFriction( -friction.xyz );
|
||||
|
||||
|
@ -279,21 +278,7 @@ namespace
|
|||
}
|
||||
|
||||
|
||||
if(protoState.GetMass() == 50)
|
||||
{
|
||||
const char* breakPoint = "Break";
|
||||
}
|
||||
|
||||
// bounce
|
||||
Float4 bounceD = normal * -Formula::CollisionResponse::Bounce( deuterState.GetRestitutionCoeff(),
|
||||
deuterState.GetMass(), deuterG_Magnitude,
|
||||
protoState.GetMass(), protoG_Magnitude );
|
||||
|
||||
// calc from perspective of proto
|
||||
proto->GetNormalAt( worldPointOfContact, normal );
|
||||
normal.Normalize();
|
||||
protoG_Magnitude = protoG.Dot( normal );
|
||||
deuterG_Magnitude = deuterG.Dot( normal );
|
||||
|
||||
// bounce
|
||||
Float4 bounceP = normal * Formula::CollisionResponse::Bounce( protoState.GetRestitutionCoeff(),
|
||||
|
@ -411,7 +396,7 @@ void API_Impl::Update()
|
|||
{
|
||||
const char *breakpoint = "STOP";
|
||||
}
|
||||
Float force = Physics3D::Formula::ForceField( this->gravityConstant, state.GetMass(), this->gravity[i].well.mass, rSquared );
|
||||
Float force = 9.82*10;
|
||||
gravityImpulse += ((this->updateFrameLength * force)) * d.GetNormalized();
|
||||
}
|
||||
break;
|
||||
|
@ -430,7 +415,7 @@ void API_Impl::Update()
|
|||
if( gravityImpulse != gravityImpulse ) // debug: trap
|
||||
const char *breakpoint = "This should never happen";
|
||||
Float posLength = state.GetCenterPosition().GetLength();
|
||||
if( gravityImpulse != Float4::null && posLength - 300 > 3.5 )
|
||||
if( gravityImpulse != Float4::null && posLength - 300 > state.GetReach().y )
|
||||
{
|
||||
state.ApplyLinearImpulse( gravityImpulse.xyz );
|
||||
state.SetGravityNormal( gravityImpulse.GetNormalized().xyz );
|
||||
|
@ -453,7 +438,7 @@ void API_Impl::Update()
|
|||
//LinearAlgebra3D::InterpolateAxisYToNormal_UsingNlerp(state.SetOrientation(, Float4(state.GetGravityNormal(), 0.0f), 1.0f);
|
||||
|
||||
|
||||
/*if( abs(lM.x) < this->epsilon )
|
||||
if( abs(lM.x) < this->epsilon )
|
||||
{
|
||||
state.linearMomentum.x = 0;
|
||||
}
|
||||
|
@ -464,7 +449,7 @@ void API_Impl::Update()
|
|||
if( abs(lM.z) < this->epsilon )
|
||||
{
|
||||
state.linearMomentum.z = 0;
|
||||
}*/
|
||||
}
|
||||
|
||||
(*proto)->SetState( state );
|
||||
|
||||
|
|
|
@ -66,14 +66,14 @@ void RigidBody::Update_LeapFrog( Float updateFrameLength )
|
|||
|
||||
// updating the angular
|
||||
// dO = dt * Formula::AngularVelocity( (RI)^-1, avg_H ) = dt * (RI)^-1 * avg_H
|
||||
this->axis += updateFrameLength * this->momentOfInertiaTensor.CalculateAngularVelocity( this->rotation, AverageWithDelta(this->momentum_Angular, this->impulse_Angular) );
|
||||
this->rotation = Rotation( this->axis );
|
||||
//this->axis += updateFrameLength * this->momentOfInertiaTensor.CalculateAngularVelocity( this->rotation, AverageWithDelta(this->momentum_Angular, this->impulse_Angular) );
|
||||
//this->rotation = Rotation( this->axis );
|
||||
|
||||
// update momentums and clear impulse_Linear and impulse_Angular
|
||||
this->momentum_Linear += this->impulse_Linear;
|
||||
this->impulse_Linear = Float4::null;
|
||||
|
||||
this->momentum_Angular += this->impulse_Angular; //! HACK: @todo Rotation temporary disabled
|
||||
//this->momentum_Angular += this->impulse_Angular; //! HACK: @todo Rotation temporary disabled
|
||||
this->impulse_Angular = Float4::null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue