/*
======================================================================
lib.h

Ernie Wright  01 Jun 05

Header for the SPD geometry library.  This is a modified subset of the
original, for use with a LightWave Modeler plug-in.
====================================================================== */

#ifndef LIB_H
#define LIB_H

#include "def.h"
#include "libvec.h"

#if __cplusplus
extern "C" {
#endif


#define LIB_VERSION "3.13"        /* library version */
#define OUTPUT_RESOLUTION 3       /* default tesselation level */

/* the samples */

void spdGears( int sf );
void spdJacks( int sf );
void spdLattice( int sf );
void spdMountain( int sf );
void spdRings( int sf );
void spdSample( int sf );
void spdShells( int sf );
void spdSombrero( int sf );
void spdBalls( int sf );
void spdTeapot( int sf );
void spdTetra( int sf );
void spdTree( int sf );

/* libinf.c */

void lib_set_polygonalization( int u_steps, int v_steps );

/* libpr1.c */

void lib_output_comment( char *comment );
void lib_output_viewpoint( COORD3 from, COORD3 at, COORD3 up, double fov_angle,
        double aspect_ratio, double hither, int resx, int resy );
void lib_output_light( COORD4 center_pt );
void lib_output_background_color( COORD3 color );
char *lib_output_color( char *name, int index, COORD3 color, double ka,
        double kd, double ks, double ks_spec, double ang, double kt,
        double i_of_r );

/* libpr2.c */

void lib_output_cylcone( COORD4 base_pt, COORD4 apex_pt, int curve_format );
void lib_output_disc( COORD3 center, COORD3 normal, double iradius,
        double oradius, int curve_format );
void lib_output_sphere( COORD4 center_pt, int curve_format );
void lib_output_box( COORD3 point1, COORD3 point2 );
void lib_output_sq_sphere( COORD4 center_pt, double a1, double a2,
        double a3, double n, double e, int curve_format );

/* libpr3.c */

void lib_output_height( char *filename, float **data, int height, int width,
   double x0, double x1, double y0, double y1, double z0, double z1 );
void lib_output_torus( COORD3 center, COORD3 normal, double iradius,
        double oradius, int curve_format );

/* libini.c */

int  lib_open( int raytracer_format, char *filename );
void lib_close( void );
void lib_storage_initialize( void );
void lib_storage_shutdown( void );

/* libply.c */

#define VBUFFER_SIZE 1024
#define POLYEND_SIZE  512

extern int gU_resolution;
extern int gV_resolution;
extern unsigned int *gPoly_vbuffer;
extern int *gPoly_end;

void lib_output_polygon_cylcone( COORD4 base_pt, COORD4 apex_pt );
void lib_output_polygon_disc( COORD3 center, COORD3 normal, double iradius,
        double oradius );
void lib_output_polygon_sphere( COORD4 center_pt );
void lib_output_polygon_height( int height, int width, float **data,
        double x0, double x1, double y0, double y1, double z0, double z1 );
void lib_output_polygon_torus( COORD3 center, COORD3 normal, double iradius,
        double oradius );
void lib_output_polygon_box( COORD3 p1, COORD3 p2 );
void lib_output_polygon( int tot_vert, COORD3 vert[] );
void lib_output_polypatch( int tot_vert, COORD3 vert[], COORD3 norm[] );

/* libtx.c */

#define U_SCALEX   0
#define U_SCALEY   1
#define U_SCALEZ   2
#define U_SHEARXY  3
#define U_SHEARXZ  4
#define U_SHEARYZ  5
#define U_ROTATEX  6
#define U_ROTATEY  7
#define U_ROTATEZ  8
#define U_TRANSX   9
#define U_TRANSY  10
#define U_TRANSZ  11
#define U_PERSPX  12
#define U_PERSPY  13
#define U_PERSPZ  14
#define U_PERSPW  15

int  lib_tx_active( void );
void lib_get_current_tx( MATRIX );
void lib_set_current_tx( MATRIX );
void lib_tx_pop( void );
void lib_tx_push( void );
void lib_tx_rotate( int, double );
void lib_tx_scale( COORD3 );
void lib_tx_translate( COORD3 );
int  lib_tx_unwind( MATRIX, double * );

extern MATRIX IdentityTx;

#if __cplusplus
}
#endif

#endif /* LIB_H */
