colored_sphere.lua


NAME
    colored_sphere

FUNCTION
    colored_sphere(R, iter, color)

NOTES
    Create a spherical object.

INPUTS
    R     - radius
    iter  - interations in creating the sphere (usually 4 to 5)
    color - color, e.g., {0, 1, 0, 1}

OUTPUTS
    a polygon object

SOURCE

require("register")

function colored_sphere(R, iter, color)
    assert(R > 0)
    assert(iter > 0 and iter < 8)
    assert(color)
    local shape, xyz, nor = zeGrf.new("polygon", "vertex", "vertex")
    shape:set{type = "triangles", vertex = xyz, vertex_normal = nor, color = color}
    local arr = zeUtl.new("double")
    zeMake.sphere(arr, R, iter)
    xyz:add(arr)
    arr:shift(3)
    nor:add(arr)
    return shape
end