From 9f19c7d61844c9b754e0808b56e2e169080af0f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=9A=D1=80=D1=83?= =?UTF-8?q?=D0=B3=D0=BB=D0=B8=D1=86=D0=BA=D0=B8=D0=B9?= Date: Sat, 10 May 2025 19:21:51 +0600 Subject: [PATCH] update --- koptilnya/.idea/.gitignore | 5 - koptilnya/.idea/koptilnya.iml | 12 -- koptilnya/.idea/modules.xml | 8 -- koptilnya/.idea/vcs.xml | 6 - koptilnya/data/models/audi_a6.txt | 17 +-- koptilnya/data/models/bmw_850csi_96.txt | 24 ++-- koptilnya/data/models/bmw_m4_g82.txt | 17 +-- .../data/models/ford mustang gt 2015.txt | 65 ++-------- koptilnya/data/models/ford_f-150_raptor.txt | 17 +-- koptilnya/data/models/jdm_wheels.txt | 18 +-- .../data/models/porsche 911 turbo s 2017.txt | 93 +++++++++++--- koptilnya/data/models/toyota_altezza.txt | 44 ++----- .../engine_remastered/configs/new_sx240.txt | 46 ++++--- .../engine_remastered/configs/sx240_stock.txt | 8 +- .../powertrain/differential.txt | 38 +++++- .../engine_remastered/powertrain/wheel.txt | 50 ++++++-- koptilnya/engine_remastered/vehicle.txt | 2 +- koptilnya/engine_remastered/wheel/wheel.txt | 119 +++++++----------- koptilnya/mesh_loader/builder.txt | 9 +- koptilnya/mesh_loader/cl_builder.txt | 12 +- koptilnya/mesh_loader/obj_parser.txt | 6 +- koptilnya/mesh_loader/sv_builder.txt | 6 +- koptilnya/torque_editor.txt | 22 ++-- 23 files changed, 310 insertions(+), 334 deletions(-) delete mode 100644 koptilnya/.idea/.gitignore delete mode 100644 koptilnya/.idea/koptilnya.iml delete mode 100644 koptilnya/.idea/modules.xml delete mode 100644 koptilnya/.idea/vcs.xml diff --git a/koptilnya/.idea/.gitignore b/koptilnya/.idea/.gitignore deleted file mode 100644 index b58b603..0000000 --- a/koptilnya/.idea/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/koptilnya/.idea/koptilnya.iml b/koptilnya/.idea/koptilnya.iml deleted file mode 100644 index 0c8867d..0000000 --- a/koptilnya/.idea/koptilnya.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/koptilnya/.idea/modules.xml b/koptilnya/.idea/modules.xml deleted file mode 100644 index 22e25db..0000000 --- a/koptilnya/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/koptilnya/.idea/vcs.xml b/koptilnya/.idea/vcs.xml deleted file mode 100644 index 6c0b863..0000000 --- a/koptilnya/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/koptilnya/data/models/audi_a6.txt b/koptilnya/data/models/audi_a6.txt index a464c6e..d6bdaeb 100644 --- a/koptilnya/data/models/audi_a6.txt +++ b/koptilnya/data/models/audi_a6.txt @@ -1,8 +1,8 @@ --- @shared --- @name Audi A6 2012 --- @author Opti1337, DarkSupah --- @include /koptilnya/mesh_loader/builder.txt -require("/koptilnya/mesh_loader/builder.txt") +--@shared +--@name Audi A6 2012 +--@author Opti1337, DarkSupah +--@include /libs/meshbuilder.txt +local MeshBuilder = require("/libs/meshbuilder.txt") DEBUG_MODE = true @@ -193,10 +193,5 @@ if SERVER then builder:build("DashDials", Vector(0), Angle(0), SCALE, Colors.DashDials, Materials.DashDials, this, this) - local result = builder:getResult() -else - PERMA.onPermissionsGained = function() - builder = MeshBuilder:new(LINK) - end - PERMA.build() + builder:apply() end diff --git a/koptilnya/data/models/bmw_850csi_96.txt b/koptilnya/data/models/bmw_850csi_96.txt index 52044a9..274edd2 100644 --- a/koptilnya/data/models/bmw_850csi_96.txt +++ b/koptilnya/data/models/bmw_850csi_96.txt @@ -1,15 +1,16 @@ --- @shared --- @name BMW 850CSi 96 --- @author Opti1337, DarkSupah --- @include /koptilnya/mesh_loader/builder.txt +--@shared +--@name BMW 850CSi 96 +--@author Opti1337, DarkSupah +--@include /libs/meshbuilder.txt + --@include koptilnya/libs/flux.txt local flux = require("koptilnya/libs/flux.txt") -require("/koptilnya/mesh_loader/builder.txt") +local MeshBuilder = require("/libs/meshbuilder.txt") DEBUG_MODE = true -local LINK = "http://82.179.248.158/bmw_850csi_96.obj#baaz" +local LINK = "https://raw.githubusercontent.com/koptilnya/gmod-data/main/bmw_850csi_96.obj" local SCALE = Vector(1) local Materials = @@ -129,7 +130,7 @@ if SERVER then builder:build("headlightl_black_plastic", Vector(0), Angle(0), SCALE, Colors.BlackPlastic, Materials.BlackPlastic, headlightL, this) builder:build("headlightl_chrome", Vector(0), Angle(0), SCALE, Colors.Chrome, Materials.Chrome, headlightL, this) - local result = builder:getResult() + local result = builder:apply() local headlightl = { angle = 0 @@ -140,8 +141,8 @@ if SERVER then } function openHeadlights() - flux.to(headlightl, 1, { angle = 28 }):delay(0.3):ease("quartout") - flux.to(headlightr, 1, { angle = 28 }):ease("quartout") + flux.to(headlightl, 1, { angle = 2 }):delay(0.3):ease("quartout") + flux.to(headlightr, 1, { angle = -2 }):ease("quartout") end function closeHeadlights() @@ -165,9 +166,4 @@ if SERVER then closeHeadlights() end end) -else - PERMA.onPermissionsGained = function() - builder = MeshBuilder:new(LINK) - end - PERMA.build() end diff --git a/koptilnya/data/models/bmw_m4_g82.txt b/koptilnya/data/models/bmw_m4_g82.txt index 77834e1..8b62d10 100644 --- a/koptilnya/data/models/bmw_m4_g82.txt +++ b/koptilnya/data/models/bmw_m4_g82.txt @@ -1,8 +1,8 @@ --- @shared --- @name BMW M4 G82 Competition --- @author Koptilnya1337 --- @include /koptilnya/mesh_loader/builder.txt -require("/koptilnya/mesh_loader/builder.txt") +--@shared +--@name BMW M4 G82 Competition +--@author Koptilnya1337 +--@include /libs/meshbuilder.txt +local MeshBuilder = require("/libs/meshbuilder.txt") DEBUG_MODE = true @@ -36,10 +36,5 @@ if SERVER then builder:build("Trunk", Vector(0), Angle(0), SCALE, Colors.Body, Materials.Body, this, this) builder:build("Roof", Vector(0), Angle(0), SCALE, Colors.Carbon, Materials.Carbon, this, this) - local result = builder:getResult() -else - PERMA.onPermissionsGained = function() - builder = MeshBuilder:new(LINK) - end - PERMA.build() + builder:apply() end diff --git a/koptilnya/data/models/ford mustang gt 2015.txt b/koptilnya/data/models/ford mustang gt 2015.txt index 61e54f5..133d414 100644 --- a/koptilnya/data/models/ford mustang gt 2015.txt +++ b/koptilnya/data/models/ford mustang gt 2015.txt @@ -1,10 +1,8 @@ --- @shared --- @name Ford Mustang GT 2015 --- @author Opti1337, DarkSupah --- @include /koptilnya/mesh_loader/builder.txt --- @include /koptilnya/car_systems/lights_controller.txt -require("/koptilnya/mesh_loader/builder.txt") -require("/koptilnya/car_systems/lights_controller.txt") +--@shared +--@name Ford Mustang GT 2015 +--@author Opti1337, DarkSupah +--@include /libs/meshbuilder.txt +local MeshBuilder = require("/libs/meshbuilder.txt") DEBUG_MODE = true @@ -50,8 +48,10 @@ local COLORS = { local builder = {} local lightsController = {} +builder = MeshBuilder:new(LINK) + if SERVER then - builder = MeshBuilder:new(LINK) + builder.onObjectParsed = function(builder, objectsNames) printTable(objectsNames) end @@ -91,52 +91,5 @@ if SERVER then local HighBeamLights = builder:build("HighBeamLights_body1_model0.017", Vector(0), Angle(0), SCALE, COLORS.LightsBase, MATERIALS.LightsBase, chip(), chip()) local FogLights = builder:build("FogLights_body1_model0.018", Vector(0), Angle(0), SCALE, COLORS.LightsBase, MATERIALS.LightsBase, chip(), chip()) - local result = builder:getResult() - - local lights = { - StopLights = {Entities = {LeftStopLight1, LeftStopLight2, LeftStopLight3, RightStopLight1, RightStopLight2, RightStopLight3}, LerpSpeed = 0.2, Colors = {On = Color(250, 0, 0), Off = Color(30, 0, 0), Active = Color(90, 0, 0)}}, - ReverseLights = {Entities = {ReverseLights}, LerpSpeed = 0.1, Colors = {On = Color(255, 255, 255), Off = Color(20, 20, 20)}}, - LowBeamLights = {Entities = {LowBeamLights}, LerpSpeed = 0.1, Colors = {On = Color(255, 255, 255), Off = Color(20, 20, 20)}}, - HighBeamLights = {Entities = {HighBeamLights}, LerpSpeed = 0.1, Colors = {On = Color(255, 255, 255), Off = Color(20, 20, 20)}}, - FogLights = {Entities = {FogLights}, LerpSpeed = 0.1, Colors = {On = Color(255, 255, 255), Off = Color(20, 20, 20)}} - TurnLights = {LeftEntities = {LeftStopLight1, LeftStopLight2, LeftStopLight3}, RightEntities = {RightStopLight1, RightStopLight2, RightStopLight3}, LerpSpeed = 0.2, Colors = {On = Color(250, 120, 0), Off = Color(30, 0, 0)}} - } - - -- local lightsEntities = {StopLights = {StopLights}, ReverseLights = {ReverseLights}, LowBeamLights = {LowBeamLights}, HighBeamLights = {HighBeamLights}} - -- local lightColors = {StopLights = {On = Color(250, 0, 0), Off = Color(30, 0, 0), Active = Color(90, 0, 0)}, ReverseLights = {On = Color(255, 255, 255), Off = Color(20, 20, 20), Active = Color(20, 20, 20)}} - -- local lights = {Lights = lightsEntities, Colors = lightColors} - - lightsController = LightsController:new(lights) - - wire.adjustPorts({LightInputs = "table"}, {}) - - hook.add("think", "lights", function() - lightsController:useStopLights(wire.ports.LightInputs.Stop) - lightsController:useReverseLights(wire.ports.LightInputs.Reverse) - lightsController:useLowBeam(wire.ports.LightInputs.LowBeam) - lightsController:useHighBeam(wire.ports.LightInputs.HighBeam) - - lightsController:setActive(wire.ports.LightInputs.LowBeam == 1) - - lightsController:update() - end -) -else - function init() - builder = MeshBuilder:new(LINK) - end - - - if hasPermission("http.get") and hasPermission("mesh") and hasPermission("entities.setRenderProperty", chip()) then - init() - else - setupPermissionRequest({"http.get", "mesh", "entities.setRenderProperty"}, "", true) - - hook.add("permissionrequest", "_permissionrequest", function() - if permissionRequestSatisfied() then - init() - end - end -) - end + builder:apply() end diff --git a/koptilnya/data/models/ford_f-150_raptor.txt b/koptilnya/data/models/ford_f-150_raptor.txt index e4773ef..cccf8ce 100644 --- a/koptilnya/data/models/ford_f-150_raptor.txt +++ b/koptilnya/data/models/ford_f-150_raptor.txt @@ -1,8 +1,8 @@ --- @shared --- @name Ford F-150 Raptor --- @author Opti1337, .hemp --- @include /koptilnya/mesh_loader/builder.txt -require("/koptilnya/mesh_loader/builder.txt") +--@shared +--@name Ford F-150 Raptor +--@author Opti1337, .hemp +--@include /libs/meshbuilder.txt +local MeshBuilder = require("/libs/meshbuilder.txt") DEBUG_MODE = true @@ -50,10 +50,5 @@ if SERVER then builder:build("Railing", Vector(0), Angle(0), SCALE, Color(255, 255, 255), "sprops/trans/wheels/wheel_d_rim1", chip(), chip()) - local result = builder:getResult() -else - PERMA.onPermissionsGained = function() - builder = MeshBuilder:new(LINK) - end - PERMA.build() + builder:apply() end diff --git a/koptilnya/data/models/jdm_wheels.txt b/koptilnya/data/models/jdm_wheels.txt index e0dde4a..bc555cb 100644 --- a/koptilnya/data/models/jdm_wheels.txt +++ b/koptilnya/data/models/jdm_wheels.txt @@ -1,9 +1,8 @@ --- @shared --- @name JDM Wheels --- @author Opti1337, .hemp --- @include /koptilnya/mesh_loader/builder.txt - -require("/koptilnya/mesh_loader/builder.txt") +--@shared +--@name JDM Wheels +--@author Opti1337, .hemp +--@include /libs/meshbuilder.txt +local MeshBuilder = require("/libs/meshbuilder.txt") local LINK = "https://raw.githubusercontent.com/koptilnya/gmod-data/main/jdmwheel1.obj?d=1" local SCALE = Vector(0.6) @@ -63,12 +62,7 @@ if SERVER then }, wheel, wheel) end - builder:getResult() + builder:apply() end end) -else - PERMA.onPermissionsGained = function() - builder = MeshBuilder:new(LINK) - end - PERMA.build() end diff --git a/koptilnya/data/models/porsche 911 turbo s 2017.txt b/koptilnya/data/models/porsche 911 turbo s 2017.txt index 9ac976d..b88f6f9 100644 --- a/koptilnya/data/models/porsche 911 turbo s 2017.txt +++ b/koptilnya/data/models/porsche 911 turbo s 2017.txt @@ -1,8 +1,8 @@ --- @shared --- @name Porsche 911 Turbo S 2017 --- @author Opti1337, DarkSupah --- @include /koptilnya/mesh_loader/builder.txt -require("/koptilnya/mesh_loader/builder.txt") +--@shared +--@name Porsche 911 Turbo S 2017 +--@author Opti1337, DarkSupah +--@include /libs/meshbuilder.txt +local MeshBuilder = require("/libs/meshbuilder.txt") DEBUG_MODE = true @@ -11,21 +11,80 @@ local SCALE = Vector(0.9) local builder = {} +local objectNames = {"Gear_stick_handle", +"Locks", +"Left_door_panel", +"Seat_base", +"Torpedo", +"Front_bumper_details", +"Dashboard_interior", +"Right_door_body", +"Body", +"Seatbelts", +"Seatbelts_caps", +"Dials", +"Dashboard_panel", +"Lower_dashboard", +"Rear_mirror", +"Dials_base", +"Front_lights_glass", +"Rear_logo", +"Exhaust_pipes", +"Torpedo_panel", +"Seats", +"Dials_glass", +"Gear_stick_base", +"Bonnet", +"Rear_lights_base", +"Torpedo_buttons", +"Seat_controls", +"Carpets", +"Steering_wheel", +"Interior_base", +"Front_bumper", +"Front_lights_bulbs", +"Doors_rubbers", +"Bottom", +"Seatbelts_caps_plastic", +"Windows_lines", +"Exterior_plastic", +"Front_lights_strips", +"Gear_stick_details", +"Exhaust_collector", +"Left_door_mirror", +"Dashboard_vents", +"Dashboard_plastic", +"Seatbelts_locks", +"Right_door_panel", +"Left_door_body", +"Right_door_mirror", +"Rear_lights_glass", +"Stitches", +"Right_front_turn", +"Timer", +"Front_lights_borders", +"Front_indicators_glass", +"Door_frames", +"Front_lights_base", +"Left_front_turn", +"Rear_details", +"Rear_spoiler_glass", +"Clothes_hooks", +"Exhaust_bumper", +"Left_side_indicator", +"Dashboard", +"Door_plastic", +"Rear_bumper", +"Seats_plastic", +"Right_side_indicator", +"Steering_wheel_details"} + if SERVER then builder = MeshBuilder:new(LINK) - builder.onObjectParsed = function(builder, objectsNames) - timer.simple(3, function() - for k, v in pairs(objectsNames) do + for k, v in pairs(objectNames) do - builder:build(v, Vector(0), Angle(0), SCALE, Color(360 / #objectsNames * k, 1, 1):hsvToRGB(), "models/debug/debugwhite", chip(), chip()) + builder:build(v, Vector(0), Angle(0), SCALE, Color(360 / #objectNames * k, 1, 1):hsvToRGB(), "models/debug/debugwhite", chip(), chip()) end - local result = builder:getResult() - end) - end -else - PERMA.onPermissionsGained = function() - builder = MeshBuilder:new(LINK) - end - PERMA.build() + builder:apply() end diff --git a/koptilnya/data/models/toyota_altezza.txt b/koptilnya/data/models/toyota_altezza.txt index aef263d..1316a44 100644 --- a/koptilnya/data/models/toyota_altezza.txt +++ b/koptilnya/data/models/toyota_altezza.txt @@ -1,18 +1,18 @@ --- @shared --- @name Toyota Altezza --- @author Opti1337, .hemp --- @include /koptilnya/mesh_loader/builder.txt -require("/koptilnya/mesh_loader/builder.txt") +--@shared +--@name Toyota Altezza +--@author Opti1337, .hemp +--@include /libs/meshbuilder.txt +local MeshBuilder = require("/libs/meshbuilder.txt") DEBUG_MODE = true local LINK = "https://www.dropbox.com/s/0vnd3nir8cyolz5/is300_3.obj?dl=1" local SCALE = Vector(0.8, 0.79, 0.8) -local builder = {} +local builder = MeshBuilder:new(LINK) if SERVER then - builder = MeshBuilder:new(LINK) + builder:build("body_Mesh_0", Vector(0), Angle(0), SCALE, Color(40, 40, 40), "models/debug/debugwhite", chip(), chip()) builder:build("chrome_Mesh_1", Vector(0), Angle(0), SCALE, Color(255, 255, 255), "sprops/textures/sprops_chrome", chip(), chip()) @@ -24,33 +24,5 @@ if SERVER then builder:build("Reshetka_Mesh_7", Vector(0), Angle(0), SCALE, Color(225, 255, 255, 255), "models/props_interiors/metalfence007a", chip(), chip()) builder:build("w_plastic_Mesh_8", Vector(0), Angle(0), SCALE, Color(225, 255, 255, 255), "models/combine_scanner/scanner_eye", chip(), chip()) - builder:getResult() -else - function init() - builder = MeshBuilder:new(LINK) - builder.onHologramsReceived = function(builder, objects) - local mat = material.create("VertexLitGeneric") - mat:setTextureURL("$basetexture", "https://i.imgur.com/gw4kfYv.jpg", - function(m, url, w, h, layout) - layout(0, 0, 2048, 2048) - end, - function(m, url) - objects[1].holo:setMaterial("") - objects[1].holo:setMeshMaterial(m) - end - ) - end - end - - if hasPermission("http.get") and hasPermission("mesh") and hasPermission("entities.setRenderProperty", chip()) then - init() - else - setupPermissionRequest({"http.get", "mesh", "entities.setRenderProperty"}, "", true) - - hook.add("permissionrequest", "_permissionrequest", function() - if permissionRequestSatisfied() then - init() - end - end) - end + builder:apply() end diff --git a/koptilnya/engine_remastered/configs/new_sx240.txt b/koptilnya/engine_remastered/configs/new_sx240.txt index 8ccc60a..9772258 100644 --- a/koptilnya/engine_remastered/configs/new_sx240.txt +++ b/koptilnya/engine_remastered/configs/new_sx240.txt @@ -8,13 +8,12 @@ local Vehicle, POWERTRAIN_COMPONENT = unpack(require('/koptilnya/engine_remaster local Differential = require('/koptilnya/engine_remastered/powertrain/differential.txt') local WheelConfig = { - BrakePower = 800, - CustomWheel = {}, - Model = 'models/sprops/trans/wheel_d/t_wheel25.mdl', - RotationAxle = Angle(1, 0, 0) + BrakePower = 1200, + CustomWheel = { Mass = 80 }, + Model = 'models/sprops/trans/wheel_d/t_wheel25.mdl' } -local FrontWheelsConfig = table.merge(table.copy(WheelConfig), { SteerLock = 35 }) -local RearWheelsConfig = table.merge(table.copy(WheelConfig), { HandbrakePower = 2000 }) +local FrontWheelsConfig = table.merge(table.copy(WheelConfig), { SteerLock = 33, CustomWheel = { Mass = 80, CasterAngle = 7 } }) +local RearWheelsConfig = table.merge(table.copy(WheelConfig), { HandbrakePower = 2200 }) Vehicle:new({ { @@ -58,12 +57,31 @@ Vehicle:new({ Reverse = 3.437 } }, + { + Name = 'AxleFront', + Type = POWERTRAIN_COMPONENT.Differential, + Config = { + SteerLock = 50 + } + }, + { + Name = 'WheelFL', + Type = POWERTRAIN_COMPONENT.Wheel, + Input = 'AxleFront', + Config = table.merge(table.copy(FrontWheelsConfig), { Offset = 0 }) + }, + { + Name = 'WheelFR', + Type = POWERTRAIN_COMPONENT.Wheel, + Input = 'AxleFront', + Config = table.merge(table.copy(FrontWheelsConfig), { Offset = 180 }) + }, { Name = 'Axle1', Input = 'Gearbox', Type = POWERTRAIN_COMPONENT.Differential, Config = { - Type = Differential.TYPES.HLSD, + Type = Differential.TYPES.Open, FinalDrive = 3.392, Inertia = 0.01, BiasAB = 0.5, @@ -73,25 +91,15 @@ Vehicle:new({ SlipTorque = 1000 } }, - { - Name = 'WheelFL', - Input = 'Axle1', - Type = POWERTRAIN_COMPONENT.Wheel, - Config = table.merge(table.copy(FrontWheelsConfig), { Offset = 0 }) - }, - { - Name = 'WheelFR', - Input = 'Axle1', - Type = POWERTRAIN_COMPONENT.Wheel, - Config = table.merge(table.copy(FrontWheelsConfig), { Offset = 180 }) - }, { Name = 'WheelRL', + Input = 'Axle1', Type = POWERTRAIN_COMPONENT.Wheel, Config = table.merge(table.copy(RearWheelsConfig), { Offset = 0 }) }, { Name = 'WheelRR', + Input = 'Axle1', Type = POWERTRAIN_COMPONENT.Wheel, Config = table.merge(table.copy(RearWheelsConfig), { Offset = 180 }) } diff --git a/koptilnya/engine_remastered/configs/sx240_stock.txt b/koptilnya/engine_remastered/configs/sx240_stock.txt index e2ff6c2..1a30611 100644 --- a/koptilnya/engine_remastered/configs/sx240_stock.txt +++ b/koptilnya/engine_remastered/configs/sx240_stock.txt @@ -1,7 +1,7 @@ --- @name SX 240 --- @author Koptilnya1337 --- @server --- @include /koptilnya/engine_remastered/vehicle.txt +--@name SX 240 +--@author Koptilnya1337 +--@server +--@include /koptilnya/engine_remastered/vehicle.txt require('/koptilnya/engine_remastered/vehicle.txt') Vehicle:new({ diff --git a/koptilnya/engine_remastered/powertrain/differential.txt b/koptilnya/engine_remastered/powertrain/differential.txt index 0deb4db..78f51cd 100644 --- a/koptilnya/engine_remastered/powertrain/differential.txt +++ b/koptilnya/engine_remastered/powertrain/differential.txt @@ -1,7 +1,6 @@ --@include /koptilnya/libs/constants.txt --@include ./powertrain_component.txt - local PowertrainComponent = require('./powertrain_component.txt') local WheelComponent = require('./wheel.txt') @@ -29,6 +28,9 @@ function Differential:initialize(vehicle, name, config) self.stiffness = config.Stiffness or 0.1 self.slipTorque = config.SlipTorque or 1000 self.splitStrategy = Differential.getSplitStrategy(config.Type or Differential.TYPES.Open) + + self.steerLock = config.SteerLock or 0 + self.steerAngle = 0 end function Differential:linkComponent(component) @@ -107,6 +109,40 @@ function Differential:forwardStep(torque, inertia) tqA = self.outputA:forwardStep(tqA, inertia * 0.5 * math.pow(self.finalDrive, 2) + aI) / self.finalDrive tqB = self.outputB:forwardStep(tqB, inertia * 0.5 * math.pow(self.finalDrive, 2) + bI) / self.finalDrive + -- // REFACTOR + if self.steerLock ~= 0 then + local steerInertia = (aI + bI) / 2 + local inputForce = 228.0 + local maxSteerSpeed = math.rad(1337) + + local inputTorque = self.vehicle.steer * inputForce + + local avgSteerAngle = (self.outputA.customWheel.steerAngle + self.outputB.customWheel.steerAngle) / 2 + local mz = self.outputA.customWheel.mz + self.outputB.customWheel.mz + local avgMz = (self.outputA.customWheel.mz + self.outputB.customWheel.mz) / 2 + local maxMz = math.max(self.outputA.customWheel.mz + self.outputB.customWheel.mz) + local steerTorque = mz * -1 + inputTorque + + local steerAngularAccel = steerTorque / steerInertia + + self.steerAngle = math.clamp( + self.steerAngle + steerAngularAccel * TICK_INTERVAL, + -self.steerLock, + self.steerLock + ) + + -- Аккерман + local wheelbase = 2.05 + local trackWidth = 1.124 + local radius = wheelbase / math.tan(math.rad(self.steerAngle)) + + local innerAngle = math.deg(math.atan(wheelbase / (radius - (trackWidth / 2)))) + local outerAngle = math.deg(math.atan(wheelbase / (radius + (trackWidth / 2)))) + + self.outputA.customWheel.steerAngle = outerAngle + self.outputB.customWheel.steerAngle = innerAngle + end + return (tqA + tqB) / self.finalDrive end diff --git a/koptilnya/engine_remastered/powertrain/wheel.txt b/koptilnya/engine_remastered/powertrain/wheel.txt index 0acfcd9..e6d98f4 100644 --- a/koptilnya/engine_remastered/powertrain/wheel.txt +++ b/koptilnya/engine_remastered/powertrain/wheel.txt @@ -55,10 +55,24 @@ function Wheel:initialize(vehicle, name, config) end end) - local right = self.entity:getRight() + local right = self.entity:getRight():getRotated(Angle(0, 90, 0)) local offsetRight = self.entity:getRight():rotateAroundAxis(self.entity:getUp(), self.offset) self.dir = right:dot(offsetRight) + + self.debugHolo1 = holograms.create( + Vector(), + Angle(), + 'models/sprops/geometry/sphere_3.mdl' + ) + + self.debugHolo2 = holograms.create( + Vector(), + Angle(), + 'models/sprops/geometry/sphere_3.mdl' + ) + + self.steerVelocity = 0 end function Wheel:getEntityRadius() @@ -79,8 +93,10 @@ function Wheel:createHolo(entity) entity:getAngles() + Angle(0, self.offset, 0), self.CONFIG.Model or '' ) + holo:setParent(entity) + -- holo:setColor(Color(255,255,255,110)) entity:setColor(Color(0,0,0,0)) return holo @@ -105,7 +121,7 @@ function Wheel:forwardStep(torque, inertia) return 0 end - self.customWheel.steerAngle = self.vehicle.steer * self.steerLock + -- self.customWheel.steerAngle = self.vehicle.steer * self.steerLock --self.customWheel.inertia = inertia --self.customWheel:setInertia(inertia) self.customWheel.motorTorque = torque @@ -115,19 +131,39 @@ function Wheel:forwardStep(torque, inertia) self.angularVelocity = self.customWheel.angularVelocity + self.debugHolo1:setPos(self.entity:localToWorld(Vector(0, 0, -self.entity:getModelRadius()))) + if self.customWheel.hasHit and isValid(self.vehicle.basePhysObject) then local surfaceForceVector = self.customWheel.right * self.customWheel.sideFriction.force + self.customWheel.forward * self.customWheel.forwardFriction.force - self.vehicle.basePhysObject:applyForceOffset(surfaceForceVector, self.entity:getPos() - Vector(0, 0, self.customWheel.radius)) + self.vehicle.basePhysObject:applyForceOffset(surfaceForceVector, self.entity:localToWorld(Vector(0, 0, -self.entity:getModelRadius()))) end if isValid(self.holo) then - self.rot = self.rot + math.deg(self.angularVelocity) * TICK_INTERVAL * self.dir - local steerAngle = self.entity:localToWorldAngles(Angle(0, self.offset - self.customWheel.steerAngle, 0) + self.rotationAxle * self.rot) - local angle = steerAngle + local spinAxis = self.customWheel.up:cross(self.customWheel.forward):getNormalized() - self.holo:setAngles(angle) + self.debugHolo2:setPos(self.entity:localToWorld(self.customWheel.up * math.sin(timer.curtime()) * 20)) + + local rotatedForwardAngle = self.customWheel.forward:getAngle() + Angle(0, 90, 0) + + + -- self.holo:setAngles(rotatedForwardAngle) + + + -- local ang = up:getAngle() + -- self.holo:setAngles(self.customWheel.forward:getAngle()) + + -- self.holo:setAngles(self.holo:getAngles():rotateAroundAxis(self.customWheel.right, 0)) + -- self.holo:setAngles(self.holo:getAngles():rotateAroundAxis(self.customWheel.right, nil, self.angularVelocity * TICK_INTERVAL)) + + + self.holo:setAngles(self.holo:getAngles():rotateAroundAxis(self.customWheel.right, nil, self.angularVelocity * TICK_INTERVAL)) + + -- local steerAngle = self.entity:localToWorldAngles(Angle(0, self.offset - self.customWheel.steerAngle, 0) + self.rotationAxle * self.rot) + -- local angle = steerAngle + + -- self.holo:setAngles(angle) end return self.customWheel.counterTorque diff --git a/koptilnya/engine_remastered/vehicle.txt b/koptilnya/engine_remastered/vehicle.txt index 5b976ad..ec926c5 100644 --- a/koptilnya/engine_remastered/vehicle.txt +++ b/koptilnya/engine_remastered/vehicle.txt @@ -63,7 +63,7 @@ function Vehicle:linkComponents() for _, componentConfig in pairs(self.config) do local component = self:getComponentByName(componentConfig.Name) - if componentConfig.Type == POWERTRAIN_COMPONENT.Wheel and componentConfig.Input == nil then + if componentConfig.Input == nil && component ~= self:getRootComponent() then table.insert(self.independentComponents, component) else local inputComponent = self:getComponentByName(componentConfig.Input) diff --git a/koptilnya/engine_remastered/wheel/wheel.txt b/koptilnya/engine_remastered/wheel/wheel.txt index e854d4f..74436aa 100644 --- a/koptilnya/engine_remastered/wheel/wheel.txt +++ b/koptilnya/engine_remastered/wheel/wheel.txt @@ -14,9 +14,10 @@ function Wheel:initialize(config) self.mass = config.Mass or 20 self.radius = config.Radius or 0.27 - self.rollingResistance = config.RollingResistance or 40 + self.rollingResistance = config.RollingResistance or 20 self.squat = config.Squat or 0.1 self.slipCircleShape = config.SlipCircleShape or 1.05 + self.casterAngle = math.rad(config.CasterAngle or 0) self.forwardFriction = Friction:new(config.ForwardFriction) self.sideFriction = Friction:new(config.SideFriction) @@ -35,6 +36,7 @@ function Wheel:initialize(config) self.forward = Vector(0) self.right = Vector(0) + self.up = Vector(0) self.entity = NULL_ENTITY self.physObj = nil self.baseInertia = 0.5 * self.mass * math.pow(self.radius, 2) @@ -168,73 +170,26 @@ function Wheel:slipCircle(Sx, Sy, Fx, Fy, slipCircleShape) return Sx, Sy, Fx, Fy end -function Wheel:selfAligningTorque(Vx, Vy, Lc) - local VxAbs = math.abs(Vx) - local Sy = 0 - - if VxAbs > 0.3 then - Sy = math.deg(math.atan(Vy / VxAbs)) - else - Sy = Vy * (0.003 / TICK_INTERVAL) - end - - Sy = math.clamp(Sy, -90, 90) - --local phi = (1 - self.E) * Sy + (self.E / self.B) * math.atan(self.B * Sy) - --local Mz = -slipSign * self.satFrictionPreset:evaluate(math.abs(phi), self.B, C, self.D, 0) * Lc - - return self.satFrictionPreset:evaluate(math.abs(Sy)) * -math.sign(Sy) -end - -function Wheel:selfAligningTorque2(Vx, Vy, Fz) - - if Fz == 0 then +function Wheel:selfAligningTorque(Sy, load) + if math.abs(Sy) < 0.001 or load < 0.001 then return 0 end - local VxAbs = math.abs(Vx) - local Sy = 0 + local B = self.satFrictionPreset.B + local C = self.satFrictionPreset.C + local D = self.satFrictionPreset.D + local E = self.satFrictionPreset.E - if VxAbs > 0.3 then - Sy = math.deg(math.atan(Vy / VxAbs)) - else - Sy = Vy * (0.003 / TICK_INTERVAL) - end + local loadScale = load * 1000 + local mechanicalTrail = 0.15 + local casterEffect = math.tan(self.casterAngle) + local effectiveTrail = mechanicalTrail + casterEffect * self.radius + local D_scaled = D * loadScale * effectiveTrail - Sy = math.clamp(Sy, -1, 1) + local term = B * Sy - E * (B * Sy - math.atan(B * Sy)) + local Mz = D_scaled * math.sin(C * math.atan(term)) - local a = { - -2.72, - -2.28, - -1.86, - -2.73, - 0.110, - -0.070, - 0.643, - -4.04, - 0.015, - -0.066, - 0.945, - 0.030, - 0.070 - } - local FzSqr = math.pow(Fz, 2) - - local C = 2.4 - local D = a[1] * FzSqr + a[2] * Fz - local BCD = (a[3] * FzSqr + a[4] * Fz) / math.pow(math.exp(1), a[5] * Fz) - local B = BCD / (C * D) - local E = a[6] * FzSqr + a[7] * Fz + a[8] - - local phi = (1 - E) * Sy + (E / B) * math.atan(B * Sy) - self.phi = phi - - return D * math.sin(C * math.atan(B * phi)) -end - -function Wheel:selfAligningTorque3(Mx, My, Sx, Sy) - local M = Mx * math.cos(Sy) + My * math.cos(Sx) - - return self.radius * M + return Mz end function Wheel:update() @@ -251,10 +206,27 @@ function Wheel:update() self.longitudinalLoadCoefficient = self:getLongitudinalLoadCoefficient(self.load * 1000) self.lateralLoadCoefficient = self:getLateralLoadCoefficient(self.load * 1000) - --self.steerAngle = self.steerAngle + self.mz / self.inertia + local baseForward = self.entity:getForward() + local baseUp = self.entity:getUp() + local baseRight = self.entity:getRight() - self.forward = self.entity:getForward():rotateAroundAxis(self.entity:getUp(), -self.steerAngle) - self.right = self.entity:getRight():rotateAroundAxis(self.entity:getUp(), -self.steerAngle) + local steerRotatedForward = baseForward:rotateAroundAxis(baseUp, -self.steerAngle) + local finalForward = steerRotatedForward:rotateAroundAxis(baseRight, nil, self.casterAngle) + + self.forward = finalForward:getNormalized() + self.right = baseUp:cross(self.forward):getNormalized() + self.up = self.forward:cross(self.right):getNormalized() + + + -- local steerRotated = self.entity:getForward():rotateAroundAxis(self.entity:getUp(), -self.steerAngle) + -- self.forward = steerRotated:rotateAroundAxis(self.entity:getRight(), self.casterAngle) + + + -- local steerRotatedRight = self.entity:getRight():rotateAroundAxis(self.entity:getUp(), -self.steerAngle) + -- self.right = steerRotatedRight:rotateAroundAxis(self.entity:getRight(), self.casterAngle) + + -- self.forward = self.entity:getForward():rotateAroundAxis(self.entity:getUp(), -self.steerAngle) + -- self.right = self.entity:getRight():rotateAroundAxis(self.entity:getUp(), -self.steerAngle) local forwardSpeed = 0 local sideSpeed = 0 @@ -272,16 +244,16 @@ function Wheel:update() self.longitudinalLoadCoefficient, self.radius, self.inertia, - 0.95, -- Force coeff - 0.9 -- Slip coeff + 0.95, + 0.9 ) local Sy, Fy = self:stepLateral( forwardSpeed, sideSpeed, self.lateralLoadCoefficient, - 0.95, -- Force coeff - 0.9 -- Slip coeff + 0.95, + 0.9 ) @@ -290,15 +262,10 @@ function Wheel:update() Sy, Fx, Fy, - 1.05 -- Shape of the slip circle / ellipse. + 1.05 ) - --local Mx = Fy * (math.cos(Sx) - 1) + Fx * math.sin(Sx) - --local My = Fx * (math.cos(Sy) - 1) + Fy * math.sin(Sy) - --local Mz = self:selfAligningTorque3(Mx, My, Sx, Sy) - local Mz = self:selfAligningTorque2(forwardSpeed, sideSpeed, self.load) - - self.mz = Mz + self.mz = self:selfAligningTorque(Sy, self.load) self.angularVelocity = W self.counterTorque = CounterTq diff --git a/koptilnya/mesh_loader/builder.txt b/koptilnya/mesh_loader/builder.txt index 83872d8..da943f2 100644 --- a/koptilnya/mesh_loader/builder.txt +++ b/koptilnya/mesh_loader/builder.txt @@ -1,7 +1,8 @@ --- @name koptilnya/mesh_loader/builder --- @include sv_builder.txt --- @include cl_builder.txt --- @include /koptilnya/libs/perma.txt +--@name koptilnya/mesh_loader/builder +--@include sv_builder.txt +--@include cl_builder.txt +--@include /koptilnya/libs/perma.txt +--@shared require("/koptilnya/libs/perma.txt") diff --git a/koptilnya/mesh_loader/cl_builder.txt b/koptilnya/mesh_loader/cl_builder.txt index b4f51f2..aa725de 100644 --- a/koptilnya/mesh_loader/cl_builder.txt +++ b/koptilnya/mesh_loader/cl_builder.txt @@ -1,9 +1,9 @@ --- @name koptilnya/mesh_loader/cl_builder --- @client --- @include /koptilnya/libs/table.txt --- @include obj_parser.txt --- @include /koptilnya/libs/utils.txt --- @include /koptilnya/libs/constants.txt +--@name koptilnya/mesh_loader/cl_builder +--@client +--@include /koptilnya/libs/table.txt +--@include obj_parser.txt +--@include /koptilnya/libs/utils.txt +--@include /koptilnya/libs/constants.txt require("/koptilnya/libs/table.txt") require("obj_parser.txt") require("/koptilnya/libs/utils.txt") diff --git a/koptilnya/mesh_loader/obj_parser.txt b/koptilnya/mesh_loader/obj_parser.txt index 1f269aa..174313c 100644 --- a/koptilnya/mesh_loader/obj_parser.txt +++ b/koptilnya/mesh_loader/obj_parser.txt @@ -1,6 +1,6 @@ --- @name koptilnya/mesh_loader/obj_parser --- @client --- @include /koptilnya/libs/workers.txt +--@name koptilnya/mesh_loader/obj_parser +--@client +--@include /koptilnya/libs/workers.txt require("/koptilnya/libs/workers.txt") ObjParser = class("ObjParser") diff --git a/koptilnya/mesh_loader/sv_builder.txt b/koptilnya/mesh_loader/sv_builder.txt index 8551aa2..8736898 100644 --- a/koptilnya/mesh_loader/sv_builder.txt +++ b/koptilnya/mesh_loader/sv_builder.txt @@ -1,6 +1,6 @@ --- @name koptilnya/mesh_loader/sv_builder --- @server --- @include /koptilnya/libs/workers.txt +--@name koptilnya/mesh_loader/sv_builder +--@server +--@include /koptilnya/libs/workers.txt require("/koptilnya/libs/workers.txt") local TIMEOUT = 4 diff --git a/koptilnya/torque_editor.txt b/koptilnya/torque_editor.txt index 0e092ab..623407b 100644 --- a/koptilnya/torque_editor.txt +++ b/koptilnya/torque_editor.txt @@ -1,14 +1,14 @@ --- @name Torque editor --- @author Opti1337 --- @shared --- @include /koptilnya/libs/render.txt --- @include /koptilnya/gui/render_devices/hud.txt --- @include /koptilnya/gui/gui.txt --- @include /koptilnya/gui/elements/panel.txt --- @include /koptilnya/gui/elements/label.txt --- @include /koptilnya/gui/elements/shape.txt --- @include /koptilnya/gui/elements/button.txt --- @include /koptilnya/gui/segoe_mdl2_assets_icons.txt +--@name Torque editor +--@author Opti1337 +--@shared +--@include /koptilnya/libs/render.txt +--@include /koptilnya/gui/render_devices/hud.txt +--@include /koptilnya/gui/gui.txt +--@include /koptilnya/gui/elements/panel.txt +--@include /koptilnya/gui/elements/label.txt +--@include /koptilnya/gui/elements/shape.txt +--@include /koptilnya/gui/elements/button.txt +--@include /koptilnya/gui/segoe_mdl2_assets_icons.txt local points = { Vector(0, 0), Vector(100, 0)