mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-26 04:12:41 +01:00
boat driving force
This commit is contained in:
parent
d437e9697e
commit
bec157c598
@ -183,6 +183,17 @@ void VehicleObject::tick(float dt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( vehicle->type == VehicleData::BOAT ) {
|
||||||
|
if( isInWater() ) {
|
||||||
|
btVector3 localSteer = btVector3(info->handling.dimensions.x * steerAngle, 0.f, 0.f)
|
||||||
|
.rotate(physBody->getOrientation().getAxis(), physBody->getOrientation().getAngle());
|
||||||
|
physBody->applyForce(
|
||||||
|
physVehicle->getForwardVector() * engineForce * 100.f,
|
||||||
|
localSteer);
|
||||||
|
}
|
||||||
|
physBody->setDamping(0.2f, 0.6f);
|
||||||
|
}
|
||||||
|
|
||||||
auto ws = getPosition();
|
auto ws = getPosition();
|
||||||
auto wX = (int) ((ws.x + WATER_WORLD_SIZE/2.f) / (WATER_WORLD_SIZE/WATER_HQ_DATA_SIZE));
|
auto wX = (int) ((ws.x + WATER_WORLD_SIZE/2.f) / (WATER_WORLD_SIZE/WATER_HQ_DATA_SIZE));
|
||||||
auto wY = (int) ((ws.y + WATER_WORLD_SIZE/2.f) / (WATER_WORLD_SIZE/WATER_HQ_DATA_SIZE));
|
auto wY = (int) ((ws.y + WATER_WORLD_SIZE/2.f) / (WATER_WORLD_SIZE/WATER_HQ_DATA_SIZE));
|
||||||
@ -221,13 +232,13 @@ void VehicleObject::tick(float dt)
|
|||||||
if( vehicle->type != VehicleData::BOAT ) {
|
if( vehicle->type != VehicleData::BOAT ) {
|
||||||
// dimensions.z doesn't quite fite, so divide by 120 instead of 100.
|
// dimensions.z doesn't quite fite, so divide by 120 instead of 100.
|
||||||
oZ = (info->handling.dimensions.z / 2.f) - (info->handling.dimensions.z * (info->handling.percentSubmerged/120.f));
|
oZ = (info->handling.dimensions.z / 2.f) - (info->handling.dimensions.z * (info->handling.percentSubmerged/120.f));
|
||||||
|
|
||||||
|
// Damper motion
|
||||||
|
physBody->setDamping(0.95f, 0.9f);
|
||||||
}
|
}
|
||||||
auto vFwd = getRotation() * glm::vec3(0.f, info->handling.dimensions.y/2.f, 0.f);
|
auto vFwd = getRotation() * glm::vec3(0.f, info->handling.dimensions.y/2.f, 0.f);
|
||||||
auto vRt = getRotation() * glm::vec3(info->handling.dimensions.x/2.f, 0.f, 0.f);
|
auto vRt = getRotation() * glm::vec3(info->handling.dimensions.x/2.f, 0.f, 0.f);
|
||||||
|
|
||||||
// Damper motion
|
|
||||||
physBody->setDamping(0.95f, 0.9f);
|
|
||||||
|
|
||||||
applyWaterFloat( vFwd, oZ);
|
applyWaterFloat( vFwd, oZ);
|
||||||
applyWaterFloat(-vFwd, oZ);
|
applyWaterFloat(-vFwd, oZ);
|
||||||
applyWaterFloat( vRt, oZ);
|
applyWaterFloat( vRt, oZ);
|
||||||
|
@ -18,7 +18,7 @@ IngameState::IngameState()
|
|||||||
auto spawnPos = glm::vec3( -1000.f, -1000.f, 14.f );
|
auto spawnPos = glm::vec3( -1000.f, -1000.f, 14.f );
|
||||||
for( auto& vi : getWorld()->vehicleTypes ) {
|
for( auto& vi : getWorld()->vehicleTypes ) {
|
||||||
auto sp = spawnPos;
|
auto sp = spawnPos;
|
||||||
if(vi.first == 120) sp = { -1000.f, -1050.f, 5.f };
|
if(vi.first == 120) sp = { -1000.f, -1040.f, 5.f };
|
||||||
auto v = getWorld()->createVehicle(vi.first, sp, glm::quat());
|
auto v = getWorld()->createVehicle(vi.first, sp, glm::quat());
|
||||||
spawnPos -= glm::vec3( 2.f + v->info->handling.dimensions.x, 0.f, 0.f);
|
spawnPos -= glm::vec3( 2.f + v->info->handling.dimensions.x, 0.f, 0.f);
|
||||||
if( ++j > 33 ) break;
|
if( ++j > 33 ) break;
|
||||||
|
Loading…
Reference in New Issue
Block a user