textured_sphere.lua


NAME
    textured_sphere

FUNCTION
    textured_sphere(R, iter, fname)

NOTES
    Create a spherical object with a image wrapped on it.

INPUTS
    R     - radius
    iter  - interations in creating the sphere (usually 4 to 5)
    fname - image file name

OUTPUTS
    a node object

SOURCE

require("register")

function textured_sphere(R, iter, fname)
    local node, texture, sphere, xyz, nor, st
        = zeGrf.new("node", "texture", "polygon", "vertex", "vertex", "texcoord")
        
    node:add(texture, sphere)
    node:set{open = false}
    texture:set{image = fname}
    sphere:set{type = "triangles", vertex = xyz, vertex_normal = nor, texture_coord = st, color = {1, 1, 1, 1}}
    
    local arr = zeUtl.new("double")
    zeMake.sphere2(arr, R, iter)
    xyz:add(arr)
    arr:shift(3)
    nor:add(arr)
    arr:shift(3)
    st:add(arr)

    return node    
end