feat: item models generation simple & remove core:item_models
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
local item_models = require "core:item_models"
|
||||
|
||||
local tsf = entity.transform
|
||||
local body = entity.rigidbody
|
||||
local rig = entity.skeleton
|
||||
@@ -27,7 +25,7 @@ end
|
||||
|
||||
do -- setup visuals
|
||||
local matrix = mat4.idt()
|
||||
scale = item_models.setup(dropitem.id, rig, 0)
|
||||
rig:set_model(0, item.name(dropitem.id)..".model")
|
||||
local bodysize = math.min(scale[1], scale[2], scale[3]) * DROP_SCALE
|
||||
body:set_size({scale[1] * DROP_SCALE, bodysize, scale[3] * DROP_SCALE})
|
||||
mat4.mul(matrix, rotation, matrix)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
local item_models = require "core:item_models"
|
||||
|
||||
local tsf = entity.transform
|
||||
local body = entity.rigidbody
|
||||
local rig = entity.skeleton
|
||||
@@ -9,12 +7,7 @@ local itemIndex = rig:index("item")
|
||||
|
||||
local function refresh_model(id)
|
||||
itemid = id
|
||||
if id == 0 then
|
||||
rig:set_model(itemIndex, "")
|
||||
else
|
||||
local scale = item_models.setup(itemid, rig, itemIndex)
|
||||
rig:set_matrix(itemIndex, mat4.scale(scale))
|
||||
end
|
||||
rig:set_model(itemIndex, item.name(itemid)..".model")
|
||||
end
|
||||
|
||||
function on_render()
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
local function setup(id, rig, index)
|
||||
rig:set_model(index, "drop-block")
|
||||
local icon = item.icon(id)
|
||||
local size = {1.0, 1.0, 1.0}
|
||||
if icon:find("^block%-previews%:") then
|
||||
local bid = block.index(icon:sub(16))
|
||||
model = block.get_model(bid)
|
||||
if model == "X" then
|
||||
size = {1.0, 0.3, 1.0}
|
||||
rig:set_model(index, "drop-item")
|
||||
rig:set_texture("$0", icon)
|
||||
else
|
||||
if model == "aabb" then
|
||||
local rot = block.get_rotation_profile(bid) == "pipe" and 4 or 0
|
||||
size = block.get_hitbox(bid, rot)[2]
|
||||
vec3.mul(size, 2.0, size)
|
||||
end
|
||||
local textures = block.get_textures(bid)
|
||||
for i,t in ipairs(textures) do
|
||||
rig:set_texture("$"..tostring(i-1), "blocks:"..textures[i])
|
||||
end
|
||||
end
|
||||
else
|
||||
size = {1.0, 0.3, 1.0}
|
||||
rig:set_model(index, "drop-item")
|
||||
rig:set_texture("$0", icon)
|
||||
end
|
||||
return size
|
||||
end
|
||||
|
||||
return {
|
||||
setup=setup,
|
||||
}
|
||||
Reference in New Issue
Block a user