Of course , as a computer science and engineering major currently graduating in visualization and algorithms this is the most interesting update yet, after lurking here from one of the earliest updates i really like the design/architecture simplicity that Josh always talks about. Hence I am going to study each and every piece of LTSL.thesilverspanch wrote:Has anyone gone into the dev update video yet and screen captured the code he used to generate the ships/icons?
That said, the plate-mesh algorithm for generating ships is on the top of my list, if I get it correct the ships are defined implicitly by taking the union of multiple plate-mesh type distance functions, these are themselves boxes with a certain bezel (curvature), as in http://www.iquilezles.org/www/articles/ ... ctions.htm. If i can squeeze in the time between my graduation project maybe ill attempt to write a LTSL parser and try to generate those implicit function definitions (ships), which then could be visualized with something like marching cubes iso-surface extraction. Or is sombody else already attempting this ?
Ship generator:
Code: Select all
function (ShipType_Generate (float scale)(int seed))
local kBevel 0.25
local kPlates 8
function (GetAxis (RNG rng))
local side (Int rng 6)
switch
case (== side 0) (Vec3 -1 0 0)
case (== side 1) (Vec3 1 0 0)
case (== side 2) (Vec3 0 -1 0)
case (== side 3) (Vec3 0 1 0)
case (== side 4) (Vec3 0 0 -1)
default (Vec3 0 0 1)
local self PlateMesh
local rng (RNG_MTG (+ seed 27))
local s (Vec3 1.0 1.0 (* 1.0 (^ scale 0.1)))
switch
case false
+= self (Plate 0 s 0 0.25)
+= self (Plate 0 (Vec3 4 1 2) 0 0.5)
+= self (Plate 0 (Vec3 4 1.5 2) 0 0.5)
+= self (Plate (Vec3 4 0 0) (Vec3 0.5 0.5 8) 0 0.5)
+= self (Plate (Vec3 -4 0 0) (Vec3 0.5 0.5 8) 0 0.5)
case true
local centers (List (Vec3 0 1 0))
local sizes (List s)
local centersc (List (Vec3 0 1 0))
Append centers (Vec3 0 1 0)
Append centers (Vec3 0 1 0)
Append sizes (* s (Vec3 2 1 0.5))
Append sizes (* s (Vec3 0.5 0.5 2))
for i 0 (< i kPlates) (++ i)
local index (Int rng (Size centers))
local center (Vec3 (Get centers i))
local size (Vec3 (Get sizes i))
local dir (GetAxis rng)
local newSize (* size (RNG_Vec3 rng 0.5 1.0))
local newCenter (+ center (* dir (+ size newSize))
local reps (RNG_Int rng 3 3)
for j 0 (< j reps)(++ j)
Append centers newCenter;
Append sizes newSize;
Append centersc newCenter;
Append sizesc (* newSize (Vec3 0.5 0.5 4.0))
set newCenter (+ newCenter (* (Vec3 0 0 4.0) newSize))
set newSize (* newSize 0.9)
for i 0 (< i (Size centersc))(++ i)
Append centers (Vec3 (Get centersc i))
Append sizes (Vec3 (Get sizesc i))
for i 0 (< i (Size centers))(++ i)
local b (RNG_float rng 0.1 0.6)
local p (Vec3 (Get centers i))
local s (Vec3 (Get sizes i))
+= self (Plate (* (Vec3 1.0 1.0 1.0) p)(* (Vec3 1 1.0 1) s) 0 b)
+= self (Plate (* (Vec3 -1.0 1.0 1.0) p)(* (Vec3 1 1.0 1) s) 0 b)
self
Code: Select all
function Main
function (ProceduralIcon (RNG rng))
local kGlyphs 4
local icon Icon
for i 0 (< i kGlyphs)(++ i)
local a (Vec2 (RNG_Float rng) (RNG_Float rng))
local b (Vec2 (RNG_Float rng) (RNG_Float rng))
local ar (* a (Vec2 -1 1))
local br (* a (Vec2 -1 1))
local r (RNG_Float rng)
Add icon
Glyph_Line a b 1 0.2
Add icon
Glyph_Line ar br 1 0.2
Add icon (Glyph_Circle a r 1 1)
Add icon (Glyph_Circle b r 1 1)
Add icon (Glyph_Circle ar r 1 1)
Add icon (Glyph_Circle br r 1 1)
icon
local kNodes 16
local children (List (Node_Label "Check these out!"))
local rng (RNG_MTG 12)
for i 0 (< i kNodes)(++ i)
Append children
Node_Custom
+ "Icon" i
RNG_Vec3 rng 0 1
ProceduralIcon rng
List (Node_Label "blah")
Node_Custom
"My Custom. Scripted Node"
Vec3 1 0 0.1
Icon
children
# We did not see more than this ......