APPENDIX C


SCENE SPECIFICATIONS

C.1	CAT Application Programmers Interface

///////////////////////////////////////////////////////////////////////////
#include    <stdio.h>
#include    <unistd.h>
#include    <iostream.h>
#include    <cave_ogl.h>
#include    "cat_track.h"
#include    "cat_prompt.h"
 
	void *CAT_malloc( size_t sz ); /* calls CAVEMalloc with err-msg */
/* environment variables */
/*  CAT_DATA_PATH = "./data"  */
	char *CAT_data_env( char *sub_path = 0 );	
/*  CAT_AUDIO_PATH = "/usr/CAVE/audio"  */
	char *CAT_audio_env( char *sub_path = 0 );
/* is vss listening? set only in loop */
	extern int VSS_aud_connected;

/* use any of these to set the current horizontal boundary size.
 * subsequently created apps inherit the values 
 */	void CAT_set_corners(   float x1, float z1, float x2, float z2 );
	void CAT_set_boundary(  float px, float pz, float dx, float dz );
	void CAT_set_placement( float px, float pz );
	void CAT_set_dimension( float dx, float dz );

#define APP_SUBJECT		0	/* does not clear screen */
#define APP_MASTER		1	/* specify a clearing domain */
#define APP_TYP_OBJECT	0	/* no APP_CTL_CONT service */
#define APP_TYP_STANDARD	1	/* full frame-update service */

#define APP_CTL_NULL	0   /* possible ppr and ffn flag values */
#define APP_CTL_INIT	1
#define APP_CTL_BGN	2
#define APP_CTL_CONT	3
#define APP_CTL_END	4
#define APP_CTL_EXIT	5

	void CAT_create_app( 
		void (*ppr)(int,void*)  = NULL, 
		void (*ffn)(int,void*)  = NULL, 
		void (*dsp)(void*)	= NULL, 
		long status		= APP_SUBJECT, 
		long type		= APP_TYP_STANDARD, 
		void *data		= NULL 
		);
	void CAT_loop(int, char**);	/* arguments passed to CAVEInit */
   
/* command-line input structure */
	extern command_t CAT_command;

/* for drawing in cave space */
	extern GLfloat CAT_non_CAVENav_matrix[16];
/* animation clock time */
	extern float CAT_time, CAT_dt;
/* actual event time */
	extern float REAL_time, REAL_dt, REAL_dt_smooth;

/* PPR only: CAVE display clipping planes */
	void CAT_set_clipping( float near, float far );
/* PPR only: set app callback data arg */
	void CAT_set_app_data( void * data );

/*  navigation data is always in global coordinates.
 *  a replacement routine need only load the CAVE matrix.
 *  this will result in updating CAT_nav_data.
 */	void CAT_nav_replace( void (*nav)(void) );
	void CAT_nav_restore( void );
	extern navigator_t CAT_nav_data;		/* current global navigation data */
	navigator_t CAT_dfl_navigate ( void );	/* generate default nav input */

#define APP_RADIUS_3D_SQRT  0
#define APP_RADIUS_2D_SQRT  1
#define APP_RADIUS_3D_FAST  2
#define APP_RADIUS_2D_FAST  3
/* hypotenuse of app-origin to head, for culling */
	float CAT_get_radius(int flag = APP_RADIUS_3D_SQRT);   
/* rendering hint: 0.0 -> 1.0 */
	float CAT_get_lod( float target_fps = 0.0 );	    

/* trackers are distinct from navigation data because they are 
 * in app-local coordinates. 
 */	tracker_t   CAT_get_cave(void);
	tracker_t   CAT_get_head(void);
	tracker_t   CAT_get_wand(void);

	int	CAT_get_button(int index);
	float	CAT_get_valuator(int index);
#define CATBUTTON1	CAT_get_button(1)
#define CATBUTTON2	CAT_get_button(2)
#define CATBUTTON3	CAT_get_button(3)
#define CAT_JOYSTICK_X  CAT_get_valuator(0)
#define CAT_JOYSTICK_Y  CAT_get_valuator(1)

/* joystick sensitivity utilities */
	float CAT_joy_deadzone( float in, float zone = 0.1 );
	float CAT_joy_curve( float in, float power );

	int CAT_master_ppr(void);	/* TRUE for 1 ppr per cave */
	int CAT_master_ffn(void);	/* TRUE for 1 ffn per node */
	int CAT_master_dsp(void);	/* TRUE for 1 view per node */
	int CAT_master_view(void);	/* TRUE for 1 view per pipe all nodes */

#define APP_FEED_STOP	0	/* hint: pause in time : CAT_dt == 0.0 */
#define APP_FEED_IDLE	1	/* hint: free running */
#define APP_FEED_RECORD	2	/* hint: preserve live data */
#define APP_FEED_REPLAY	3	/* hint: extract recorded data */
/* if you want to record something, this helps */
	extern int CAT_feed_mode;

#define APP_DSP_NULL		0
#define APP_DSP_NORMAL	1 /* hint: regular cavewall display */
#define APP_DSP_VIDEO	2 /* hint: low detail for live video image */
#define APP_DSP_PHOTO	3 /* hint: high quality for still frame rendering */
	extern int CAT_dsp_mode;

/* world display functions: without navigation transform */
	void    CAT_dsp_execute(void);
	void    CAT_dsp_video_execute(void);
	void    CAT_dsp_photo_execute(void);

#define APP_DFL_LIGHT_UBIND		0   /* un-bind lighting */
#define APP_DFL_LIGHT_BIND		1   /* bind default lights */
#define APP_DFL_LIGHT_REBIND	2   /* re-bind lighting */
#define APP_DFL_LIGHT_DEFINE	3   /* refresh default settings for BGN */
	void    CAT_dfl_light( int flag );
/* calls clear(): */
	void    CAT_dfl_fog( ulong col, float visibility, int do_clear = 1 ); 
	void    CAT_dfl_sky( ulong col );
	void    CAT_dfl_ground( ulong col );

	void	CAT_set_linewidth(int lw);	 /* relative to image size */
	void	CAT_net_set_dsp( void (*net_dsp)(void) );
	void 	CAT_start_screen( void (*dsp)(void) );

/* Virtual Director command function */
	void	CAT_command_director( char *tok, char *v1=0, char *v2=0 );

///////////////////////////////////////////////////////////////////////////


C.2 Point Cloud Format #include "ogl_cloud.h" typedef struct { float x, y, z, option4; } point; non-default-path/somedata.bin [ dimensions: <32bits> 2 (number of dimensions to follow) length: <32bits> i (number of data frames) size: <32bits> j (number of points per frame) point data: <sizeof(point)*len*size> (raw binary data array) ] non-default-path/someconfig.cf [ # binarydata : non-default-path/<prefix>.bin binarydata somedata # rgbtexture : non-default-path/<prefix>.rgb rgbtexture gauss_64 # format : absolute|relative format absolute # range : first and last desired data frames (begin at 1) range 1 730 # rate : data frames per second rate 24.0 # option4 : ignore r g b a R # option4 : funpack R # option4 : radius r g b a # option4 : interpolate r g b a to r g b a and R # option4 : interpolateR r g b a R to r g b a R option4 funpack 0.002 # oldstylecolor : y|n ( funpack : irisGL uses ABGR ) oldstylecolor y # object : triangle|square|texture|pyramid object triangle ]
C.3 Wavefront Modelling API by Dave Pape wfObject *wfReadObject(char *fname); void wfInitObject(wfObject *obj); void wfDrawObject(wfObject *obj); void wfWriteObject(FILE *fp,wfObject *obj); void wfGetBoundingSphere(wfObject *obj,wfVertex center,float *radius); void wfGetBoundingBox(wfObject *obj,wfVertex corner0,wfVertex corner1); void wfSetMemoryAllocator(void * (*allocfn)(size_t),void (*freefn)(void *)); void wfSetNewIDFunction(int (*idfn)(void)); int wfNewID(void); void wfEnable(int); void wfDisable(int); int wfIsEnabled(int); void wfTranslateObject(wfObject *obj,float tx,float ty,float tz); void wfScaleObject(wfObject *obj,float sx,float sy,float sz); void wfRotateObject(wfObject *obj,float angle,float x,float y,float z); void wfDeformObject(wfObject *obj,void (*vF)(float *),void (*nF)(float *)); wfObject * wfCopyObjectGeometry(wfObject *obj); void wfComputeNormals(wfObject *obj,int smooth,int clockwise); wfFace *wfRayIntersection(wfObject *obj,float *ray0,float *delta,float *ret_t); int wfRayHits(wfObject *obj,float *ray0,float *raydelta);
C.4 Example Application #include <cat_ogl.h> extern void calculate(); extern void *swap(); extern void transform( void *vp ); extern void draw(); /* parent process routines */ void my_nav( void ) { /* assign CAVENav matrix */ } void my_ppr( int flag, void* ) { if( flag == APP_CTL_BGN ) CAT_nav_replace( my_nav ); calculate(); void *vp = swap(); CAT_set_app_data( vp ); } /* child process routines */ void my_ffn( int, void* ) { /* optional */ } void my_dsp( void *vp ) { glPushMatrix(); transform( vp ); draw(); glPopMatrix(); } main() { CAT_create_app( my_ppr, my_ffn, my_dsp ); CAT_command_director( "please" ); CAT_loop(); }


thiebaux@evl.uic.edu