diff --git a/koptilnya/engine_remastered/configs/new_sx240.txt b/koptilnya/engine_remastered/configs/new_sx240.txt new file mode 100644 index 0000000..fed1e6c --- /dev/null +++ b/koptilnya/engine_remastered/configs/new_sx240.txt @@ -0,0 +1,46 @@ +-- @name SX 240 +-- @author Koptilnya1337 +-- @server +-- @include /koptilnya/engine_remastered/vehicle.txt +require('/koptilnya/engine_remastered/vehicle.txt') + +Vehicle:new({ + Engine = { + IdleRPM = 900, + MaxRPM = 7500, + Inertia = 0.151, + StartFriction = -30, + FrictionCoeff = 0.02, + LimiterDuration = 0.08, + TorqueMap = { + 118.89918444138, 122.0751393736, 125.25109430583, 128.42704923806, 131.60300417029, 134.77895910251, 137.95491403474, 141.13086896697, 144.3068238992, 147.48277883143, 150.65873376365, 153.83468869588, 157.01064362811, 160.18659856034, 163.36255349256, + 166.53850842479, 169.71446335702, 172.89041828925, 176.06637322148, 179.2423281537, 182.41828308593, 185.59423801816, 188.77019295039, 191.94614788261, 195.12210281484, 198.29805774707, 201.4740126793, 204.64996761153, 207.82592254375, 211.00187747598, + 214.17783240821, 217.35378734044, 220.52974227266, 223.70569720489, 226.88165213712, 227.9621903219, 229.04272850669, 230.12326669147, 231.20380487625, 232.28434306104, 233.36488124582, 234.4454194306, 235.52595761538, 236.60649580017, 237.68703398495, + 238.76757216973, 239.84811035452, 240.9286485393, 242.00918672408, 243.08972490886, 244.17026309365, 245.25080127843, 246.33133946321, 247.411877648, 248.49241583278, 249.57295401756, 250.65349220234, 251.73403038713, 252.81456857191, 253.89510675669, 254.97564494148, + 256.05618312626, 257.13672131104, 258.21725949582, 259.29779768061, 260.37833586539, 261.29278066787, 262.20722547034, 263.12167027282, 264.0361150753, 264.95055987777, 265.86500468025, 266.77944948273, 267.6938942852, 268.60833908768, 269.52278389016, + 270.43722869263, 271.35167349511, 272.26611829758, 273.18056310006, 274.09500790254, 275.00945270501, 275.92389750749, 276.83834230997, 275.50329427594, 274.16824624192, 272.8331982079, 271.49815017388, 270.16310213985, 268.82805410583, 267.49300607181, + 266.15795803778, 264.82291000376, 263.48786196974, 262.15281393572, 260.81776590169, 259.48271786767, 250.23203287321, 240.98134787874, 231.73066288428, 222.47997788981 + } + }, + Clutch = { + Inertia = 0.002, + SlipTorque = 1000 + }, + Gearbox = { + Type = 'MANUAL', + Inertia = 0.01, + Ratios = { 3.626, 2.200, 1.541, 1.213, 1.000, 0.767 }, + Reverse = 3.437 + }, + Axles = { + { + FinalDrive = 3.392, + Inertia = 0.01, + BiasAB = 0.5, + CoastRamp = 0.5, + PowerRamp = 1, + Stiffness = 0.1, + SlipTorque = 1000 + } + } +}) diff --git a/koptilnya/engine_remastered/differential.txt b/koptilnya/engine_remastered/differential.txt index 48d1464..ba97feb 100644 --- a/koptilnya/engine_remastered/differential.txt +++ b/koptilnya/engine_remastered/differential.txt @@ -32,6 +32,9 @@ function Differential:initialize(config, order) self.outputA = Wheel:new(wheelConfig, prefix .. 'Left') self.outputB = Wheel:new(table.merge(wheelConfig, { Direction = -1 }), prefix .. 'Right') + self.outputA.input = self + self.outputB.input = self + table.merge(self.wireInputs, self.outputA.wireInputs) table.merge(self.wireInputs, self.outputB.wireInputs) table.merge(self.wireOutputs, self.outputA.wireOutputs) diff --git a/koptilnya/engine_remastered/wheel.txt b/koptilnya/engine_remastered/wheel.txt index ed92581..32c07eb 100644 --- a/koptilnya/engine_remastered/wheel.txt +++ b/koptilnya/engine_remastered/wheel.txt @@ -12,6 +12,7 @@ function Wheel:initialize(config, prefix) PowertrainComponent.initialize(self) self.prefix = prefix + self.rollingResistance = config.RollingResistance or -50 self.direction = config.Direction or 1 self.wireInputs = { @@ -33,7 +34,8 @@ function Wheel:initialize(config, prefix) end if config.CalculateInertia then - self.entity:setInertia(calculateWheelInertia(val)) + self.entity:setInertia(Vector(7.7)) + --self.entity:setInertia(calculateWheelInertia(val)) end self.inertia = self.entity:getInertia().y @@ -63,14 +65,33 @@ function Wheel:forwardStep(torque, inertia) return 0 end - local initialAngularVelocity = self.angularVelocity + local initAngularVelocity = self.angularVelocity - --self.entity:setInertia(self.entity:getInertia():setY(inertia)) + self.entity:setInertia(Vector(inertia)) self.torque = math.deg(torque) * 1.33 * -self.direction self.entity:applyTorque(self.torque * TICK_INTERVAL * self.entity:getRight()) self.angularVelocity = math.rad(self.entity:getAngleVelocity().y) * self.direction - local deltaOmegaTorque = (self.angularVelocity - initialAngularVelocity) * self.inertia / TICK_INTERVAL + local tq = (self.angularVelocity - initAngularVelocity) * inertia * TICK_INTERVAL - return torque + return self.rollingResistance - (tq - torque) end + +--local physObj = self.entity:getPhysicsObject() +--local load = physObj:getStress() +--local frictionSnapshot = physObj:getFrictionSnapshot() +--local forwardFrictionSpeed = 0 +--local contactVelocity = physObj:getVelocityAtPoint(self.entity:getPos() + Vector(0, 0, self.entity:getModelRadius())) / 39.37 +-- +--if #table.getKeys(frictionSnapshot) > 0 then +-- local data = frictionSnapshot[1] +-- local forwardDir = data['Normal']:cross(self.entity:getRight() * self.direction):getNormalized() +-- +-- forwardFrictionSpeed = contactVelocity:dot(forwardDir) +--end +-- +--local errorTorque = (self.angularVelocity - forwardFrictionSpeed / self:getRadius()) * inertia / TICK_INTERVAL +--local rollingResistance = -40 +--local deltaOmegaTorque = (self.angularVelocity - initialAngularVelocity) * self.inertia / TICK_INTERVAL +-- +--return rollingResistance - deltaOmegaTorque