/*
======================================================================
sample.c

Ernie Wright  01 Jun 05

This version has been modified to fit your TV.
====================================================================== */

/*
 * sample.c - Simple file to make a scene with a few objects
 *
 * Author:  Alexander Enzmann
 *
 * Modified: 1 September 1993
 *           Eric Haines
 *           changed file name, made sure values were passed as doubles
 *           (the HPUX compiler sees "..., 5, ..." as an integer and merrily
 *           passes the integer representation down to the subroutine which
 *           wants a double).
 *
 * size_factor is ignored.
 *
 * size_factor # spheres   # squares
 *      x          xx           x
 */

#include <stdio.h>
#include "lwmod.h"
#include "def.h"
#include "lib.h"


static int size_factor;
static int output_format = 0;
static char *spdName = "Sample";

static COORD3 Red     = { 1.0, 0.0, 0.0 };
static COORD3 Cyan    = { 0.0, 1.0, 1.0 };
static COORD3 Yellow  = { 1.0, 0.0, 1.0 };
static COORD3 Magenta = { 1.0, 1.0, 0.0 };


void spdSample( int sf )
{
    COORD3 back_color;
    COORD4 from, at, up;
    COORD4 center, normal;
    COORD4 base, apex;


    size_factor = sf;

    /* output background color - Light Grey */
    /* NOTE: Do this BEFORE lib_output_viewpoint(), for display_init() */
    SET_COORD3( back_color, 0.8, 0.8, 0.8 ) ;
    lib_output_background_color( back_color ) ;

    SET_COORD3(from, 0, 5, -5);
    SET_COORD3(at, 0, 0, 0);
    SET_COORD3(up, 0, 1, 0);
    lib_output_viewpoint(from, at, up, 45.0, 1.0, 0.001, 512, 512);

    SET_COORD4(center, -10, 20, -20, 1.0);
    lib_output_light(center);

    lwMonitorBegin( spdName, "Creating sample geometry.", 4 );

    lib_output_color(spdName, 1, Cyan, 0.1, 0.7, 0.0, 0.7, 10.0, 0.0, 1.0);
    SET_COORD3(center,-1, 0, 0);
    SET_COORD3(normal, 1, 1,-0.5);
    lib_output_torus(center, normal, 2.0, 0.5, output_format);
    if ( lwMonitorStep( 1 ))
      return;

    lib_output_color(spdName, 2, Magenta, 0.1, 0.7, 0.0, 0.7, 10.0, 0.0, 1.0);
    SET_COORD3(center, 0, 0, 0);
    SET_COORD3(normal, 0, 1,-0.5);
    lib_output_torus(center, normal, 2.0, 0.5, output_format);
    if ( lwMonitorStep( 1 ))
      return;

    lib_output_color(spdName, 3, Yellow, 0.1, 0.7, 0.0, 0.7, 10.0, 0.0, 1.0);
    SET_COORD3(center, 1, 0, 0);
    SET_COORD3(normal,-1, 1,-0.5);
    lib_output_torus(center, normal, 2.0, 0.5, output_format);
    if ( lwMonitorStep( 1 ))
      return;

    lib_output_color(spdName, 4, Red, 0.1, 0.7, 0.0, 0.7, 10.0, 0.0, 1.0);
    SET_COORD4(base, 0, -2, 0, 2);
    SET_COORD4(apex, 0,  2, 0, 0.1);
    lib_output_cylcone(base, apex, output_format);
    if ( lwMonitorStep( 1 ))
      return;

    lib_set_polygonalization(4, 1);
    lib_output_color(spdName, 5, Red, 0.1, 0.7, 0.0, 0.7, 10.0, 0.0, 1.0);
    SET_COORD3(base, 0, -2, 0);
    SET_COORD3(apex, 0,  1, 0);
    lib_output_disc(base, apex, 0.0, 4.0, output_format);

    lwMonitorDone();
}
