improve drop visuals
This commit is contained in:
parent
4b084dffad
commit
e6c3775286
@ -16,14 +16,17 @@ do -- setup visuals
|
|||||||
local icon = item.icon(dropitem.id)
|
local icon = item.icon(dropitem.id)
|
||||||
if icon:find("^block%-previews%:") then
|
if icon:find("^block%-previews%:") then
|
||||||
local bid = block.index(icon:sub(16))
|
local bid = block.index(icon:sub(16))
|
||||||
local model = block.get_model(bid)
|
model = block.get_model(bid)
|
||||||
if model == "X" then
|
if model == "X" then
|
||||||
entity:set_rig("drop-item")
|
entity:set_rig("drop-item")
|
||||||
body:set_size(vec3.mul(body:get_size(), {1.0, 0.3, 1.0}))
|
body:set_size(vec3.mul(body:get_size(), {1.0, 0.3, 1.0}))
|
||||||
rig:set_texture("$0", icon)
|
rig:set_texture("$0", icon)
|
||||||
else
|
else
|
||||||
if model == "aabb" then
|
if model == "aabb" then
|
||||||
scale = block.get_hitbox(bid, 0)[2]
|
local rot = block.get_rotation_profile(bid) == "pipe" and 4 or 0
|
||||||
|
scale = block.get_hitbox(bid, rot)[2]
|
||||||
|
body:set_size(vec3.mul(body:get_size(), {1.0, 0.7, 1.0}))
|
||||||
|
vec3.mul(scale, 1.5, scale)
|
||||||
end
|
end
|
||||||
local textures = block.get_textures(bid)
|
local textures = block.get_textures(bid)
|
||||||
for i,t in ipairs(textures) do
|
for i,t in ipairs(textures) do
|
||||||
@ -41,7 +44,11 @@ do -- setup visuals
|
|||||||
end
|
end
|
||||||
|
|
||||||
function on_grounded(force)
|
function on_grounded(force)
|
||||||
local matrix = mat4.rotate({0, 1, 0}, math.random()*360)
|
local matrix = mat4.idt()
|
||||||
|
mat4.rotate(matrix, {0, 1, 0}, math.random()*360, matrix)
|
||||||
|
if model == "aabb" then
|
||||||
|
mat4.rotate(matrix, {1, 0, 0}, 90, matrix)
|
||||||
|
end
|
||||||
mat4.scale(matrix, scale, matrix)
|
mat4.scale(matrix, scale, matrix)
|
||||||
rig:set_matrix(0, matrix)
|
rig:set_matrix(0, matrix)
|
||||||
inair = false
|
inair = false
|
||||||
@ -66,7 +73,7 @@ function on_update()
|
|||||||
|
|
||||||
mat4.rotate(rotation, {0, 1, 0}, 240*dt, rotation)
|
mat4.rotate(rotation, {0, 1, 0}, 240*dt, rotation)
|
||||||
mat4.rotate(rotation, {0, 0, 1}, 240*dt, rotation)
|
mat4.rotate(rotation, {0, 0, 1}, 240*dt, rotation)
|
||||||
|
|
||||||
local matrix = mat4.idt()
|
local matrix = mat4.idt()
|
||||||
mat4.mul(matrix, rotation, matrix)
|
mat4.mul(matrix, rotation, matrix)
|
||||||
mat4.scale(matrix, scale, matrix)
|
mat4.scale(matrix, scale, matrix)
|
||||||
|
|||||||
@ -286,7 +286,7 @@ static int l_get_model(lua::State* L) {
|
|||||||
|
|
||||||
static int l_get_hitbox(lua::State* L) {
|
static int l_get_hitbox(lua::State* L) {
|
||||||
if (auto def = require_block(L)) {
|
if (auto def = require_block(L)) {
|
||||||
auto& hitbox = def->rt.hitboxes[0].at(lua::tointeger(L, 2));
|
auto& hitbox = def->rt.hitboxes[lua::tointeger(L, 2)].at(0);
|
||||||
lua::createtable(L, 2, 0);
|
lua::createtable(L, 2, 0);
|
||||||
|
|
||||||
lua::pushvec3_arr(L, hitbox.min());
|
lua::pushvec3_arr(L, hitbox.min());
|
||||||
@ -299,6 +299,13 @@ static int l_get_hitbox(lua::State* L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_get_rotation_profile(lua::State* L) {
|
||||||
|
if (auto def = require_block(L)) {
|
||||||
|
return lua::pushstring(L, def->rotations.name);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const luaL_Reg blocklib [] = {
|
const luaL_Reg blocklib [] = {
|
||||||
{"index", lua::wrap<l_index>},
|
{"index", lua::wrap<l_index>},
|
||||||
{"name", lua::wrap<l_name>},
|
{"name", lua::wrap<l_name>},
|
||||||
@ -325,5 +332,6 @@ const luaL_Reg blocklib [] = {
|
|||||||
{"get_textures", lua::wrap<l_get_textures>},
|
{"get_textures", lua::wrap<l_get_textures>},
|
||||||
{"get_model", lua::wrap<l_get_model>},
|
{"get_model", lua::wrap<l_get_model>},
|
||||||
{"get_hitbox", lua::wrap<l_get_hitbox>},
|
{"get_hitbox", lua::wrap<l_get_hitbox>},
|
||||||
|
{"get_rotation_profile", lua::wrap<l_get_rotation_profile>},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user