spin.c
4.35 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/**************************************************************************
* *
* Copyright (C) 1995, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
*************************************************************************/
/*
* File: spin.c
*
* Routines for creating display list for Spin application
* Create Matrices
* Set Attributes
* Select Model
*
*/
#include <ultra64.h>
#include <gu.h>
#include <os.h>
#include <em.h>
#include "spin.h"
#include "texture.h"
extern Spin_mode;
/**************************************************************************
* List of model display lists, main loop cycles through these.
**************************************************************************/
Gfx *modelList[] = {
&(square_dl[0]),
&(square2_dl[0]),
&(box_dl[0]),
&(rect_box_dl[0]),
&(cone_dl[0]),
&(cylinder_dl[0]),
&(frustrum_dl[0]),
&(bumble_dl[0]),
&(icosa_dl[0]),
&(torii_dl[0]),
&(ground_dl[0]),
&(u64_dl[0]),
&(cross_dl[0]),
&(sphere_dl[0]),
&(pipe_dl[0]),
&(twist_dl[0]),
&(twist1_dl[0]),
&(sector_dl[0]),
&(frac_island_dl[0]),
&(triangle_dl[0]),
&(runway_dl[0]),
&(hexagonOpaInter_dl[0]),
&(big_tex_dl[0]),
&(bigger_tex_dl[0]),
&(gorge_dl[0]),
&(airport_dl[0]),
&(xluramp_q_dl[0]),
&(tex_fill_rect_dl[0]),
(Gfx *) NULL, /* last one, to count them... */
};
/**************************************************************************
* Build display list
**************************************************************************/
void BuildDisplayList(Dynamic *dynamicp, int caseno, int fov, float aspect, int near, int far)
{
unsigned char red, grn, blu; /* mode icon color */
u16 perspNorm;
Mtx rot;
/*
* Build Matrices
*/
guPerspective(&dynamicp->projection,&perspNorm,
(float)fov, aspect, (float)near, (float)far, 1.0);
guLookAt(&dynamicp->viewing,
0, 0, 3000,
0, 0, 0,
0, 1, 0);
gSPMatrix(glistp++, osVirtualToPhysical(&(dynamicp->projection)),
G_MTX_PROJECTION|G_MTX_LOAD|G_MTX_NOPUSH);
/****************** special transform for immobile background **************/
/*****************************************************************************/
gSPMatrix(glistp++, osVirtualToPhysical(&(dynamicp->viewing)),
G_MTX_MODELVIEW|G_MTX_LOAD|G_MTX_NOPUSH);
gSPMatrix(glistp++, osVirtualToPhysical(&(dynamicp->eye)),
G_MTX_MODELVIEW|G_MTX_MUL|G_MTX_NOPUSH);
gSPMatrix(glistp++, osVirtualToPhysical(&(dynamicp->modeling)),
G_MTX_MODELVIEW|G_MTX_MUL|G_MTX_NOPUSH);
gSPPerspNormalize(glistp++, perspNorm);
/*
* select model
*/
/* ### What is caseno 21??? */
if (caseno == 21)
{
/*
* opaque non-inter polys
*/
gSPDisplayList(glistp++, box1Opa_dl);
gSPDisplayList(glistp++, opaDecal_dl);
/* set up static viewpoint to draw transparent parts of hexagon */
guLookAt(&(dynamicp->view),
0, 0, 3000,
0, 0, 0,
0, 1, 0);
gSPMatrix(glistp++, osVirtualToPhysical(&(dynamicp->view)),
G_MTX_MODELVIEW|G_MTX_LOAD|G_MTX_PUSH);
/*
* opaque inter polys
*/
gSPDisplayList(glistp++, hexagonOpaInter_dl);
gSPDisplayList(glistp++, opaHexDecal_dl);
gSPPopMatrix(glistp++, G_MTX_MODELVIEW);
/*
* transparent non-inter polys
*/
gSPDisplayList(glistp++, box1Trans_dl);
gSPDisplayList(glistp++, transDecal_dl);
gSPMatrix(glistp++, osVirtualToPhysical(&(dynamicp->view)),
G_MTX_MODELVIEW|G_MTX_LOAD|G_MTX_PUSH);
/*
* cloud surface
gSPDisplayList(glistp++, square1_dl);
*/
/*
* transparent inter polys
*/
gSPDisplayList(glistp++, hexagonTransInter_dl);
gSPPopMatrix(glistp++, G_MTX_MODELVIEW);
}
else
{
gSPDisplayList(glistp++, modelList[caseno]);
}
gDPFullSync(glistp++);
}