init
This commit is contained in:
commit
12ffbdc45d
76 changed files with 79368 additions and 0 deletions
106
computer/4/structure
Normal file
106
computer/4/structure
Normal file
|
@ -0,0 +1,106 @@
|
|||
v = 0.55
|
||||
X = vector.new(0,-0.92836897,0.28899258)
|
||||
Y = vector.new(-0.94538565,0.06753674,0.21695717)
|
||||
Z = vector.new(0.23369713,0.28899258,0.92836897)
|
||||
r1 = 40
|
||||
r2 = 10
|
||||
a = {1,-2,3,1,0,-1,-1,2,0,0}
|
||||
b = {-1.2314479651658854,-1.5872747213793104,0.04683103835434217,1.9674748180974897,1.153043896136355,-0.10238369338887907,1.7042206782594087,-1.242120063575402,0.5603127510670854,2.66234724349466}
|
||||
c = {4.321312860949716,2.116116100402904,2.7194094703705165,3.0821962706516177,5.994638109825947,0.8990716738267982,0.06271719387139103,0.7355961093238955,2.1949825399445198,5.522266625688897}
|
||||
l = vector.new(0.57735027,0.57735027,0.57735027)
|
||||
function surface(uv)
|
||||
--print("surface")
|
||||
total = 0
|
||||
for i = 1,#a do
|
||||
total = total + math.sin(a[i]*uv.x+math.floor(.5+b[i])*uv.y+c[i])
|
||||
end
|
||||
return math.pow(math.mod(total,2)-1,2)
|
||||
end
|
||||
function map(xyz)
|
||||
--print("map")
|
||||
local u = math.atan2(
|
||||
xyz:dot(X),xyz:dot(Y)
|
||||
)
|
||||
local v = math.atan2(
|
||||
xyz:dot(Z:normalize()),
|
||||
math.sqrt(
|
||||
xyz:dot(X)^2+xyz:dot(X)^2
|
||||
)
|
||||
-r1
|
||||
)
|
||||
return vector.new(u,v)
|
||||
end
|
||||
function lerp(x,y,t)
|
||||
--print("lerp")
|
||||
return x - (x-y)*t
|
||||
end
|
||||
function project(x,y)
|
||||
--print("project x:",x," y:",y)
|
||||
return x-(
|
||||
y*(
|
||||
(
|
||||
x:dot(
|
||||
y
|
||||
)
|
||||
)/(
|
||||
y:dot(
|
||||
y
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
end
|
||||
function setmag(x,y)
|
||||
--print("setmag")
|
||||
return x:normalize()*y
|
||||
end
|
||||
function f(x,y,z)
|
||||
--print("f")
|
||||
xyz = vector.new(x,y,z)
|
||||
dist = (xyz-setmag(project(xyz,Z),r1)):length()-r2
|
||||
detail = lerp(5*surface(map(xyz)),r1,v)
|
||||
return dist-detail
|
||||
end
|
||||
function blockat(x,y,z)
|
||||
--print("blockat")
|
||||
if f(x,y,z) < 0 then
|
||||
flag = false
|
||||
for k,v in pairs({
|
||||
{1,0,0},
|
||||
{0,1,0},
|
||||
{0,0,1},
|
||||
{-1,0,0},
|
||||
{0,-1,0},
|
||||
{0,0,-1}
|
||||
})do
|
||||
flag = f(x+v[1],y+v[2],z+v[3])>0 or flag
|
||||
end
|
||||
if flag then
|
||||
dx = f(x+0.1,y,z)-f(x-0.1,y,z)
|
||||
dy = f(x,y+0.1,z)-f(x,y-0.1,z)
|
||||
dz = f(x,y,z+0.1)-f(x,y,z-0.1)
|
||||
normal = vector.new(dx,dy,dz):normalize()
|
||||
if normal:dot(vector.new(0,0,1)) > 0.5 then
|
||||
return true, "minecraft:moss_block"
|
||||
end
|
||||
dot = normal:dot(l)
|
||||
lighttable = {
|
||||
{-.7,"minecraft:cobbled_deepslate"},
|
||||
{-.5,"minecraft:andesite"},
|
||||
{-.3,"minecraft:tuff"},
|
||||
{0,"minecraft:cobblestone"},
|
||||
{.5,"minecraft:diorite"},
|
||||
{.7,"create:cut_limestone"},
|
||||
{2,"minecraft:calcite"}
|
||||
}
|
||||
for i,v in ipairs(lighttable) do
|
||||
if dot < v[1] then
|
||||
return true, v[2]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- print(x,y,z,"is not part of the set")
|
||||
return false
|
||||
end
|
||||
return {blockat = blockat}
|
Loading…
Add table
Add a link
Reference in a new issue