From b2fd2d88f3998cfe8c0ff8272f15bc3572dd4396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD=20=D0=93=D1=80=D0=B0=D1=87=D1=91?= =?UTF-8?q?=D0=B2?= Date: Sat, 30 Oct 2021 17:40:08 +0500 Subject: [PATCH 1/2] Adding bmw x5m e70 model --- koptilnya/data/models/bmw_x5m_e70.txt | 110 ++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 koptilnya/data/models/bmw_x5m_e70.txt diff --git a/koptilnya/data/models/bmw_x5m_e70.txt b/koptilnya/data/models/bmw_x5m_e70.txt new file mode 100644 index 0000000..fd8b960 --- /dev/null +++ b/koptilnya/data/models/bmw_x5m_e70.txt @@ -0,0 +1,110 @@ +-- @shared +-- @name BMW X5M E70 +-- @author DarkSupah +-- @include /koptilnya/mesh_loader/builder.txt +require("/koptilnya/mesh_loader/builder.txt") + +DEBUG_MODE = true + +local LINK = "https://drive.google.com/u/0/uc?id=181xY-amHmR_fmIeqIjsSboCy3gBx3iWA&export=download" +local SCALE = Vector(1) + +local Materials = +{ + Body = "models/debug/debugwhite", + Shadow = "models/debug/debugwhite", + Plastic = "models/debug/debugwhite", + Exhaust = "models/shiny", + Seatbelts = "models/debug/debugwhite", + Ceiling = "models/debug/debugwhite", + Interior = "models/debug/debugwhite", + Seats = "models/debug/debugwhite", + Dashboard = "models/debug/debugwhite", + Chrome = "models/shiny", + DoorMaps = "models/debug/debugwhite", + LightsChrome = "models/shiny", + RearLights = "models/debug/debugwhite", + LightsGlass = "models/debug/debugwhite" +} + +local Colors = +{ + Body = Color(220,220,220), + Shadow = Color(0,0,0), + Bumper = Color(30,30,30), + Grille = Color(20,20,20), + Plastic = Color(20,20,20), + Exhaust = Color(120,120,120), + Seatbelts = Color(20,20,20), + Ceiling = Color(45,45,45), + Interior = Color(40,40,40), + Seats = Color(40,40,40), + Dashboard = Color(35,35,35), + Chrome = Color(140,140,140), + DoorMaps = Color(40,40,40), + LightsChrome = Color(160,160,160), + RearLights = Color(180,50,50), + LightsGlass = Color(180,50,50) +} + +local builder = {} + +if SERVER then + builder = MeshBuilder:new(LINK) + + local this = chip() + + // Body group + builder:build("Body", Vector(0), Angle(0), SCALE, Colors.Body, Materials.Body, this, this) + builder:build("RearBumper", Vector(0), Angle(0), SCALE, Colors.Body, Materials.Body, this, this) + builder:build("FrontBumper", Vector(0), Angle(0), SCALE, Colors.Body, Materials.Body, this, this) + builder:build("Doors", Vector(0), Angle(0), SCALE, Colors.Body, Materials.Body, this, this) + builder:build("Trunk", Vector(0), Angle(0), SCALE, Colors.Body, Materials.Body, this, this) + builder:build("Hatch", Vector(0), Angle(0), SCALE, Colors.Body, Materials.Body, this, this) + builder:build("Bonnet", Vector(0), Angle(0), SCALE, Colors.Body, Materials.Body, this, this) + builder:build("Mirrors", Vector(0), Angle(0), SCALE, Colors.Body, Materials.Body, this, this) + + // Plastic stuff + builder:build("Bumper_Plastic", Vector(0), Angle(0), SCALE, Colors.Bumper, Materials.Plastic, this, this) + builder:build("Grille", Vector(0), Angle(0), SCALE, Colors.Grille, Materials.Plastic, this, this) + builder:build("Plastic", Vector(0), Angle(0), SCALE, Colors.Plastic, Materials.Plastic, this, this) + + // Misc group + builder:build("Shadow", Vector(0), Angle(0), SCALE, Colors.Shadow, Materials.Shadow, this, this) + + builder:build("Exhaust_Chrome", Vector(0), Angle(0), SCALE, Colors.Exhaust, Materials.Exhaust, this, this) + builder:build("Seatbelts", Vector(0), Angle(0), SCALE, Colors.Seatbelts, Materials.Seatbelts, this, this) + + // Interior + builder:build("Ceiling", Vector(0), Angle(0), SCALE, Colors.Ceiling, Materials.Ceiling, this, this) + builder:build("Interior", Vector(0), Angle(0), SCALE, Colors.Interior, Materials.Interior, this, this) + builder:build("Door_Maps", Vector(0), Angle(0), SCALE, Colors.DoorMaps, Materials.DoorMaps, this, this) + + builder:build("Seats", Vector(0), Angle(0), SCALE, Colors.Seats, Materials.Seats, this, this) + builder:build("Interior_2", Vector(0), Angle(0), SCALE, Colors.Interior, Materials.Interior, this, this) + builder:build("Dashboard", Vector(0), Angle(0), SCALE, Colors.Dashboard, Materials.Dashboard, this, this) + + builder:build("Chrome", Vector(0), Angle(0), SCALE, Colors.Chrome, Materials.Chrome, this, this) + builder:build("Lights_Chrome", Vector(0), Angle(0), SCALE, Colors.LightsChrome, Materials.Lights_Chrome, this, this) + + //builder:build("RearLights_Lights", Vector(0), Angle(0), SCALE, Colors.RearLights, Materials.RearLights, this, this) + builder:build("RearLights_Glass", Vector(0), Angle(0), SCALE, Colors.LightsGlass, Materials.LightsGlass, this, this) + + local result = builder:getResult() +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 +end From 99d967ced6b343708e944e91d2996ca49a4b8728 Mon Sep 17 00:00:00 2001 From: Ivan Date: Thu, 4 Nov 2021 02:46:33 +0500 Subject: [PATCH 2/2] Added extension methods for tables and entities, added inrange helper to libs --- koptilnya/libs/entity.txt | 7 +++++++ koptilnya/libs/math.txt | 3 +++ koptilnya/libs/table.txt | 31 ++++++++++++++++++++++++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 koptilnya/libs/entity.txt create mode 100644 koptilnya/libs/math.txt diff --git a/koptilnya/libs/entity.txt b/koptilnya/libs/entity.txt new file mode 100644 index 0000000..2db67fe --- /dev/null +++ b/koptilnya/libs/entity.txt @@ -0,0 +1,7 @@ +function getLocalVelocity(entity) + if not entity:isValid() then + return + end + + return entity:worldToLocal(entity:getVelocity() + entity:getPos()) +end diff --git a/koptilnya/libs/math.txt b/koptilnya/libs/math.txt new file mode 100644 index 0000000..e90f495 --- /dev/null +++ b/koptilnya/libs/math.txt @@ -0,0 +1,3 @@ +function inrange(value, min, max) + return value >= min and value <= max +end diff --git a/koptilnya/libs/table.txt b/koptilnya/libs/table.txt index 6e0e583..b34c250 100644 --- a/koptilnya/libs/table.txt +++ b/koptilnya/libs/table.txt @@ -1,5 +1,4 @@ -- @name koptilnya/libs/table - function table.chunk(tbl, size) size = size or 1 size = size > 0 and size or 1 @@ -64,3 +63,33 @@ function table.contains(tbl, ...) return result end end + +function table.map(tbl, action) + local res = {} + + for _, field in ipairs(tbl) do + table.insert(res, action(field)) + end + + return res +end + +function table.filter(tbl, predicate) + local res = {} + + for _, field in ipairs(tbl) do + if predicate(field) == true then + table.insert(res, field) + end + end + + return res +end + +function table.find(tbl, predicate) + for _, field in ipairs(tbl) do + if predicate(field) == true then + return field + end + end +end