In this lesson, we introduce a many line (or "polyline") function that will draw
many lines and connect each of them together. You just have to supply the
sequential endpoints through which to draw the lines. This allows you to draw 3D "spaghetti"
like graphics. The function is called line3dx and accepts an array of 3D coordinates.
Move the mouse over a dotted box for more information.
You can find a list of color codes here.
The 3D drawing area will appear under your code-editor. You might have to scroll down to see it.
Now you try. Mess around with the code a bit and see what you can come up with.
Type your code here:
See your results here:
When using this function to draw, Lua has an interesting construct called a
"table," which is an array of arrays, which is what the {{x1,y1,z1},{x2,y2,z2}...} actually is.
The point? If you define an empty array, like p={}, then you can "push" (x,y,z) points
into it, one by one like this: table.insert(p,{x,y,z}). See the example.
Share your code
Show a friend, family member, or teacher what you've done!