diff --git a/pkg/base/lib_va.lua b/pkg/base/lib_va.lua index a82b2ba..62c6772 100644 --- a/pkg/base/lib_va.lua +++ b/pkg/base/lib_va.lua @@ -264,6 +264,17 @@ function model_loaders.pmf(isfile, pkt, extra) end) end +function model_loaders.lua(isfile, pkt, extra) + extra = extra or {} + --print(pkt) + if isfile then pkt = loadfile(pkt) end + if not pkt then return nil end + + print(pkt) + + return pkt +end + --[[ function loadkv6(fname, name, ptsize, ptspacing) return parsekv6(common.bin_load(fname), name, ptsize, ptspacing) diff --git a/pkg/base/preconf.lua b/pkg/base/preconf.lua index 2f4e229..7f842ce 100644 --- a/pkg/base/preconf.lua +++ b/pkg/base/preconf.lua @@ -70,7 +70,7 @@ function model_load(mdict, prio, sdir) end for i=1,#prio do - local mdl = SKIN_ENABLE[prio[i]] and model_loaders[prio[i]]( + local mdl = model_loaders[prio[i]]( true, mdict[prio[i]].bdir.."/"..mdict[prio[i]].name, mdict[prio[i]]) if mdl then return mdl end end diff --git a/pkg/iceball/rugby/main.lua b/pkg/iceball/rugby/main.lua new file mode 100644 index 0000000..f39de24 --- /dev/null +++ b/pkg/iceball/rugby/main.lua @@ -0,0 +1,18 @@ + +do + local s_model_load = model_load + function model_load(mdict, ...) + print(mdict) + if mdict.kv6 and mdict.kv6.name == "bomb.kv6" then + return s_model_load ({ + lua = { + bdir = "pkg/iceball/rugby", + name = "mdl_ball.lua", + }, + }, {"lua"}) + else + return s_model_load(mdict, ...) + end + end +end + diff --git a/pkg/iceball/rugby/mdl_ball.lua b/pkg/iceball/rugby/mdl_ball.lua new file mode 100644 index 0000000..14534eb --- /dev/null +++ b/pkg/iceball/rugby/mdl_ball.lua @@ -0,0 +1,67 @@ + +do + local settings = ... + + local this = {} + + this.tex = skin_load("png", "mdl_ball.png", "pkg/iceball/rugby") + + do + local ucount = 16 + local vcount = 10 + local scale = 0.4 + function uvmap(u, v) + local amp = math.sin(v) + amp = amp*0.4*scale + local rs = math.sin(u) + local rc = math.cos(u) + + return rs*amp, (math.cos(v)-1)*0.7*scale, rc*amp + end + + local l = {} + local iu, iv + local u0 = 0 + local v0 = 0 + local u1 = 2/ucount + local v1 = 1/vcount + local au0 = 0 + local av0 = 0 + local au1 = 2*math.pi/ucount + local av1 = math.pi/vcount + for iu=0,ucount-1 do + for iv=0,vcount-1 do + local u = 2*iu*math.pi/ucount + local v = iv*math.pi/vcount + local x00, y00, z00 = uvmap(u+au0, v+av0) + local x01, y01, z01 = uvmap(u+au0, v+av1) + local x10, y10, z10 = uvmap(u+au1, v+av0) + local x11, y11, z11 = uvmap(u+au1, v+av1) + + u = (iu*2/ucount)%1 + v = (iv/vcount)%1 + + l[1+#l] = {x00, y00, z00, v+v0, u+u0} + l[1+#l] = {x10, y10, z10, v+v0, u+u1} + l[1+#l] = {x01, y01, z01, v+v1, u+u0} + l[1+#l] = {x01, y01, z01, v+v1, u+u0} + l[1+#l] = {x10, y10, z10, v+v0, u+u1} + l[1+#l] = {x11, y11, z11, v+v1, u+u1} + end + end + + this.va = common.va_make(l, nil, "3v,2t") + end + + function this.render_global(x, y, z, r1, r2, r3, s) + client.va_render_global(this.va, x, y, z, r1, r2, r3, s, this.tex) + end + + function this.render_local(x, y, z, r1, r2, r3, s) + client.va_render_local(this.va, x, y, z, r1, r2, r3, s, this.tex) + end + + return this + +end + diff --git a/pkg/iceball/rugby/mdl_ball.png b/pkg/iceball/rugby/mdl_ball.png new file mode 100644 index 0000000..6cb1297 Binary files /dev/null and b/pkg/iceball/rugby/mdl_ball.png differ diff --git a/pkg/iceball/rugby/mod.json b/pkg/iceball/rugby/mod.json new file mode 100644 index 0000000..96c1115 --- /dev/null +++ b/pkg/iceball/rugby/mod.json @@ -0,0 +1,3 @@ +{ + "preload": ["main.lua"] +}