mvtview.h 4.42 KB
#ifndef __mvtview__
#define __mvtview__

/*====================================================================
 * mvtview.h
 *
 * Copyright 1995, Silicon Graphics, Inc.
 * All Rights Reserved.
 *
 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
 * Inc.; the contents of this file may not be disclosed to third
 * parties, copied or duplicated in any form, in whole or in part,
 * without the prior written permission of Silicon Graphics, Inc.
 *
 * RESTRICTED RIGHTS LEGEND:
 * Use, duplication or disclosure by the Government is subject to
 * restrictions as set forth in subdivision (c)(1)(ii) of the Rights
 * in Technical Data and Computer Software clause at DFARS
 * 252.227-7013, and/or in similar or successor clauses in the FAR,
 * DOD or NASA FAR Supplement. Unpublished - rights reserved under the
 * Copyright Laws of the United States.
 *====================================================================*/


#include "mvtdefs.h"


/*
 * Define a template, made to look like a function call, but actually need
 * to do CPP stuff to allow easy usage of #define's
 */
#define MVTinit_template(ID,NAME,BIGNAME)				\
	if (1) {							\
	   int _n,_x,_y;						\
   	   _x = BIGNAME##_WIDTH  / 32;					\
   	   _y = BIGNAME##_HEIGHT / 32;					\
   	   if ((_x*32) < BIGNAME##_WIDTH)  _x++;			\
   	   if ((_y*32) < BIGNAME##_HEIGHT) _y++;			\
           mvt_template[ID].data = NAME##_mvt_data;			\
           mvt_template[ID].width = BIGNAME##_WIDTH;			\
           mvt_template[ID].height = BIGNAME##_HEIGHT;			\
           mvt_template[ID].num_xtiles = _x;				\
           mvt_template[ID].num_ytiles = _y;				\
           mvt_template[ID].num_tiles = _x*_y;				\
	   for (_n=0; _n<mvt_template[ID].num_tiles; _n++)		\
              mvt_template[ID].mvt_vtx[_n]  = &(NAME##_mvt_vtx[_n][0]);	\
           mvt_template[ID].geometry_dl = NAME##;			\
           mvt_num_templates++;						\
 	} else



/*
 * Structure defining an MVT template object. This contains ONE copy
 * of the mvt data structure.
 */
typedef struct {
   MVTDataType *data;				/* mvt data */
   Vtx         *mvt_vtx[MVT_MAX_TILES];		/* mvt geometry vertices */
   Gfx         *geometry_dl;			/* geometry version */
   u8           width,height;			/* dimensions of mvt */
   u8  		num_tiles,num_xtiles,num_ytiles;/* tiles of mvt */
} MVTTemplate;


/*
 * Defines an instance of an object. Instances of objects come from the 
 * same group. A group comes from a single template. Thus updating the
 * entire set of objects for a group is very cheap.
 */
typedef struct {
   u8    group_id;		/* group id */
   u8    transition_count;	/* transition count for combined display */
   u8    xluback;		/* whether a XLU billboard mvt */
   u8    interpolate;		/* interpolate between mvt samples */
   u8    translates;		/* translate geo and mvt according to pos */
   float xpos,ypos,zpos;	/* position of mvt and geometry, see above */
   float rotation;		/* initial rotation */
   float angle_offset;		/* offset of mvt from screen plane, if any */
   float scale;			/* mvt/geo scale factor */
   float t2texture;		/* transition to texture distance, sqr'ed */
   float t2geometry;		/* transition to geometry distance, sqr'ed */
} MVTObject;


/*
 * Defines an a group of objects all using the same decompressed MVT
 */
typedef struct {
   u8  template_id;		/* originating template */
   s16 last_angle1,last_angle2;	/* last angle decompressed */
   u8  indep_rot;		/* whether to indep rotate each object plane */
   u8  object_id[MVT_MAX_OBJECTS_PER_GROUP]; /* objects in the group */
   u8  num_objects;		/* num of objects in the group */
} MVTGroup;
#define MVT_NO_INDEP_ROT	0
#define MVT_INDEP_ROT		1


/* externs */

extern Gfx         mvt_common_texture_dl[];
extern Gfx         mvt_common_geometry_dl[];

extern MVTTemplate mvt_template[MVT_MAX_TEMPLATES];
extern int         mvt_num_templates;

extern void MVTdraw(Dynamic *dynamicp, float eyept[3]);
extern int  MVTcreate_group(int id, int indep_rot);
extern void MVTset_position(int id, float pos[3], float rot);
extern int  MVTinstance_object(int gid, 
                               float xpos, float ypos, float zpos, float rot,
                               float angle_offset,
                               int   translates,
                               int   xluback,
                               int   interpolate,
                               float scale,
                               float transition_delta,
                               float tdist);

#endif