summaryrefslogtreecommitdiff
path: root/include/PR/uportals.h
blob: 28a1466f981e565b130eab5f8386a5465a67285f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*====================================================================
 * uportals.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.
 *====================================================================*/

/**************************************************************************
 *
 *  uportals.h - header file for the ultraportals library
 *
 *  $Revision: 1.12 $
 *  $Date: 1997/02/11 08:40:49 $
 *  $Source: /disk6/Master/cvsmdev2/PR/include/uportals.h,v $
 *
 **************************************************************************/



#ifndef __ULTRAPORTALS_H__
#define __ULTRAPORTALS_H__

#include <ultra64.h>
#include "matrix.h"
#include "vector.h"

#ifdef __cplusplus
extern "C" {
#endif

#ifndef ENABLEPORTALS
#define ENABLEPORTALS
#endif

#define UP_MAXPVERTS 	16		/* max number of portal verts	*/
#define UP_MAXCELLS	50		/* max number of cells		*/
#define UP_CELLNL	32		/* max length of cell names 	*/
#define UP_OBNL		32		/* max length of obejct names 	*/
    
typedef struct
{
    vec3	min, max;		/* min and max pts of the box	*/
} upBox;

typedef struct _upPortalData * _portalptr;
typedef struct _upCellData * _cellptr;
typedef struct _upObjectData * _objectptr;

typedef struct _upPortalData
{
    int 	numverts;		/* number of verts in the portal*/
    _cellptr	attached_cell;		/* cell on the 'other side'	*/
    vec3	verts[UP_MAXPVERTS];	/* the actual vertices		*/
#ifdef MVTVIEW
    int         mvt_id;                 /* if has mvt, this is the id   */
#endif
} upPortalData;

typedef struct _upCellData
{
    int 	numportals;		/* number of portals		*/
    int 	numobjects;		/* number of objects		*/
    int 	rendered;		/* last frame number rendered	*/
    _portalptr	*portals;		/* array for the actual portals	*/
    _objectptr  *objects;		/* array for 'detail' objects	*/
    upBox	bbox;			/* bounding box of the cell	*/
    Gfx		*dlist;			/* associated display list	*/
    char	name[UP_CELLNL];	/* name of the cell		*/
    float 	eyeheight;		/* height to constrain eyept to */
    int		zone;			/* current zone number		*/
} upCellData;

typedef struct _upObjectData
{
    int 	rendered;		/* last frame number rendered   */
    upBox	bbox;			/* bounding box for the object 	*/
    Gfx		*dlist;			/* associated display list	*/
    char	name[UP_OBNL];		/* name of the object		*/
} upObjectData;

typedef struct
{
    int 	numcells;		/* how many cells are there?	*/
    upCellData	cells[UP_MAXCELLS];   	/* the actual cells		*/
    Gfx		*rootdlist;		/* display list for all cells	*/
    vec2	portalmin, portalmax;	/* XY bbox used by upCheckCells */
    float	near, far;		/* near, far clipping planes	*/
    FMatrix	viewmat;		/* viewing matrix (world->eye)	*/
    FMatrix	projmat;		/* proj matrix (eye->screen)	*/
    FMatrix 	compmat;		/* view * proj (world->screen)	*/
    int		portaldepth;		/* depth of the portal stack	*/
    int		framecount;		/* current frame number		*/
} upLocateData;

/*
 * Functions:
 */
extern void upInit();		/* generated automatically by flt2walk	*/
extern Gfx *upAddVisibleCells(Gfx * glistp, vec3 eyept);
extern void upTogglePortalBounds();
extern void upToggleScissorBox();

/*
 * Globals:
 */
extern upLocateData 	upLocator;	/* also extern by test_portals.h */

/*
 * Macros:
 */
#define UP_HUGEVAL  3.40282347e+37
#define PT_IN_BOX(p,box) ((p)[0] > (box).min[0] && (p)[0] < (box).max[0] &&\
			  (p)[1] > (box).min[1] && (p)[1] < (box).max[1] &&\
			  (p)[2] > (box).min[2] && (p)[2] < (box).max[2])


#ifdef __Cplusplus
}
#endif

#endif