This commit is contained in:
Nikita Kruglickiy 2021-11-08 21:12:02 +03:00
commit 3eaa9025af
4 changed files with 150 additions and 1 deletions

View File

@ -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

View File

@ -0,0 +1,7 @@
function getLocalVelocity(entity)
if not entity:isValid() then
return
end
return entity:worldToLocal(entity:getVelocity() + entity:getPos())
end

3
koptilnya/libs/math.txt Normal file
View File

@ -0,0 +1,3 @@
function inrange(value, min, max)
return value >= min and value <= max
end

View File

@ -1,5 +1,4 @@
-- @name koptilnya/libs/table -- @name koptilnya/libs/table
function table.chunk(tbl, size) function table.chunk(tbl, size)
size = size or 1 size = size or 1
size = size > 0 and size or 1 size = size > 0 and size or 1
@ -64,3 +63,33 @@ function table.contains(tbl, ...)
return result return result
end end
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