1 /* atlantis --- Shows moving 3D sea animals */
4 static const char sccsid[] = "@(#)shark.c 1.2 98/06/16 xlockmore";
7 /* Copyright (c) E. Lassauge, 1998. */
10 * Permission to use, copy, modify, and distribute this software and its
11 * documentation for any purpose and without fee is hereby granted,
12 * provided that the above copyright notice appear in all copies and that
13 * both that copyright notice and this permission notice appear in
14 * supporting documentation.
16 * This file is provided AS IS with no warranties of any kind. The author
17 * shall have no liability with respect to the infringement of copyrights,
18 * trade secrets or any patents by this file or any part thereof. In no
19 * event will the author be liable for any lost revenue or profits or
20 * other special, indirect and consequential damages.
22 * The original code for this mode was written by Mark J. Kilgard
23 * as a demo for openGL programming.
25 * Porting it to xlock was possible by comparing the original Mesa's morph3d
26 * demo with it's ported version to xlock, so thanks for Marcelo F. Vianna
27 * (look at morph3d.c) for his indirect help.
29 * Thanks goes also to Brian Paul for making it possible and inexpensive
30 * to use OpenGL at home.
32 * My e-mail address is lassauge@users.sourceforge.net
34 * Eric Lassauge (May-13-1998)
39 * (c) Copyright 1993, 1994, Silicon Graphics, Inc.
41 * Permission to use, copy, modify, and distribute this software for
42 * any purpose and without fee is hereby granted, provided that the above
43 * copyright notice appear in all copies and that both the copyright notice
44 * and this permission notice appear in supporting documentation, and that
45 * the name of Silicon Graphics, Inc. not be used in advertising
46 * or publicity pertaining to distribution of the software without specific,
47 * written prior permission.
49 * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
50 * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
51 * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
52 * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
53 * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
54 * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
55 * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
56 * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
57 * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
58 * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
59 * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
60 * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
62 * US Government Users Restricted Rights
63 * Use, duplication, or disclosure by the Government is subject to
64 * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
65 * (c)(1)(ii) of the Rights in Technical Data and Computer Software
66 * clause at DFARS 252.227-7013 and/or in similar or successor
67 * clauses in the FAR or the DOD or NASA FAR Supplement.
68 * Unpublished-- rights reserved under the copyright laws of the
69 * United States. Contractor/manufacturer is Silicon Graphics,
70 * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
72 * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
81 static const float N001[3] = {0, 1, 0};
83 static const float N002[3] = {0.000077, -0.020611, 0.999788};
84 static const float N003[3] = {0.961425, 0.258729, -0.09339};
85 static const float N004[3] = {0.510811, -0.769633, -0.383063};
86 static const float N005[3] = {0.400123, 0.855734, -0.328055};
87 static const float N006[3] = {-0.770715, 0.610204, -0.18344};
88 static const float N007[3] = {-0.915597, -0.373345, -0.149316};
89 static const float N008[3] = {-0.972788, 0.208921, -0.100179};
90 static const float N009[3] = {-0.939713, -0.312268, -0.139383};
91 static const float N010[3] = {-0.624138, -0.741047, -0.247589};
92 static const float N011[3] = {0.591434, -0.768401, -0.244471};
93 static const float N012[3] = {0.935152, -0.328495, -0.132598};
94 static const float N013[3] = {0.997102, 0.074243, -0.016593};
95 static const float N014[3] = {0.969995, 0.241712, -0.026186};
96 static const float N015[3] = {0.844539, 0.502628, -0.184714};
97 static const float N016[3] = {-0.906608, 0.386308, -0.169787};
98 static const float N017[3] = {-0.970016, 0.241698, -0.025516};
99 static const float N018[3] = {-0.998652, 0.050493, -0.012045};
100 static const float N019[3] = {-0.942685, -0.333051, -0.020556};
101 static const float N020[3] = {-0.660944, -0.750276, 0.01548};
102 static const float N021[3] = {0.503549, -0.862908, -0.042749};
103 static const float N022[3] = {0.953202, -0.302092, -0.012089};
104 static const float N023[3] = {0.998738, 0.023574, 0.044344};
105 static const float N024[3] = {0.979297, 0.193272, 0.060202};
106 static const float N025[3] = {0.7983, 0.464885, 0.382883};
107 static const float N026[3] = {-0.75659, 0.452403, 0.472126};
108 static const float N027[3] = {-0.953855, 0.293003, 0.065651};
109 static const float N028[3] = {-0.998033, 0.040292, 0.048028};
110 static const float N029[3] = {-0.977079, -0.204288, 0.059858};
111 static const float N030[3] = {-0.729117, -0.675304, 0.11114};
112 static const float N031[3] = {0.598361, -0.792753, 0.116221};
113 static const float N032[3] = {0.965192, -0.252991, 0.066332};
114 static const float N033[3] = {0.998201, -0.00279, 0.059892};
115 static const float N034[3] = {0.978657, 0.193135, 0.070207};
116 static const float N035[3] = {0.718815, 0.680392, 0.142733};
117 static const float N036[3] = {-0.383096, 0.906212, 0.178936};
118 static const float N037[3] = {-0.952831, 0.29259, 0.080647};
119 static const float N038[3] = {-0.99768, 0.032417, 0.059861};
120 static const float N039[3] = {-0.982629, -0.169881, 0.0747};
121 static const float N040[3] = {-0.695424, -0.703466, 0.1467};
122 static const float N041[3] = {0.359323, -0.915531, 0.180805};
123 static const float N042[3] = {0.943356, -0.319387, 0.089842};
124 static const float N043[3] = {0.998272, -0.032435, 0.048993};
125 static const float N044[3] = {0.978997, 0.193205, 0.065084};
126 static const float N045[3] = {0.872144, 0.470094, -0.135565};
127 static const float N046[3] = {-0.664282, 0.737945, -0.119027};
128 static const float N047[3] = {-0.954508, 0.28857, 0.075107};
129 static const float N048[3] = {-0.998273, 0.032406, 0.048993};
130 static const float N049[3] = {-0.979908, -0.193579, 0.048038};
131 static const float N050[3] = {-0.858736, -0.507202, -0.072938};
132 static const float N051[3] = {0.643545, -0.763887, -0.048237};
133 static const float N052[3] = {0.95558, -0.288954, 0.058068};
135 static const float N053[3] = {0, 1, 0};
136 static const float N054[3] = {0, 1, 0};
137 static const float N055[3] = {0, 1, 0};
138 static const float N056[3] = {0, 1, 0};
139 static const float N057[3] = {0, 1, 0};
141 static const float N058[3] = {0.00005, 0.793007, -0.609213};
142 static const float N059[3] = {0.91351, 0.235418, -0.331779};
143 static const float N060[3] = {-0.80797, 0.495, -0.319625};
144 static const float N061[3] = {0, 0.784687, -0.619892};
145 static const float N062[3] = {0, -1, 0};
146 static const float N063[3] = {0, 1, 0};
147 static const float N064[3] = {0, 1, 0};
148 static const float N065[3] = {0, 1, 0};
149 static const float N066[3] = {-0.055784, 0.257059, 0.964784};
151 static const float N067[3] = {0, 1, 0};
152 static const float N068[3] = {0, 1, 0};
154 static const float N069[3] = {-0.000505, -0.929775, -0.368127};
155 static const float N070[3] = {0, 1, 0};
157 static const float N071[3] = {-0.987102, 0.131723, -0.090984};
158 static const float N072[3] = {-0.987102, 0.131723, -0.090984};
159 static const float N073[3] = {-0.987102, 0.131723, -0.090984};
160 static const float N074[3] = {0, 1, 0};
161 static const float N075[3] = {0, 1, 0};
162 static const float N076[3] = {0, 1, 0};
163 static const float N077[3] = {0.99521, 0.071962, -0.066168};
164 static const float N078[3] = {0.99521, 0.071962, -0.066168};
165 static const float N079[3] = {0.99521, 0.071962, -0.066168};
166 static const float N080[3] = {0, 1, 0};
167 static const float N081[3] = {0, 1, 0};
168 static const float N082[3] = {0, 1, 0};
169 static const float P001[3] = {0, 0, 0};
171 static float P002[3] = {0, -36.59, 5687.72};
172 static const float P003[3] = {90, 114.73, 724.38};
173 static float P004[3] = {58.24, -146.84, 262.35};
174 static const float P005[3] = {27.81, 231.52, 510.43};
175 static const float P006[3] = {-27.81, 230.43, 509.76};
176 static float P007[3] = {-46.09, -146.83, 265.84};
177 static const float P008[3] = {-90, 103.84, 718.53};
178 static const float P009[3] = {-131.1, -165.92, 834.85};
179 static float P010[3] = {-27.81, -285.31, 500};
180 static float P011[3] = {27.81, -285.32, 500};
181 static const float P012[3] = {147.96, -170.89, 845.5};
182 static const float P013[3] = {180, 0, 2000};
183 static const float P014[3] = {145.62, 352.67, 2000};
184 static const float P015[3] = {55.62, 570.63, 2000};
185 static const float P016[3] = {-55.62, 570.64, 2000};
186 static const float P017[3] = {-145.62, 352.68, 2000};
187 static const float P018[3] = {-180, 0.01, 2000};
188 static const float P019[3] = {-178.2, -352.66, 2001.61};
189 static const float P020[3] = {-55.63, -570.63, 2000};
190 static const float P021[3] = {55.62, -570.64, 2000};
191 static const float P022[3] = {179.91, -352.69, 1998.39};
192 static float P023[3] = {150, 0, 3000};
193 static float P024[3] = {121.35, 293.89, 3000};
194 static float P025[3] = {46.35, 502.93, 2883.09};
195 static float P026[3] = {-46.35, 497.45, 2877.24};
196 static float P027[3] = {-121.35, 293.9, 3000};
197 static float P028[3] = {-150, 0, 3000};
198 static float P029[3] = {-152.21, -304.84, 2858.68};
199 static float P030[3] = {-46.36, -475.52, 3000};
200 static float P031[3] = {46.35, -475.53, 3000};
201 static float P032[3] = {155.64, -304.87, 2863.5};
202 static float P033[3] = {90, 0, 4000};
203 static float P034[3] = {72.81, 176.33, 4000};
204 static float P035[3] = {27.81, 285.32, 4000};
205 static float P036[3] = {-27.81, 285.32, 4000};
206 static float P037[3] = {-72.81, 176.34, 4000};
207 static float P038[3] = {-90, 0, 4000};
208 static float P039[3] = {-72.81, -176.33, 4000};
209 static float P040[3] = {-27.81, -285.31, 4000};
210 static float P041[3] = {27.81, -285.32, 4000};
211 static float P042[3] = {72.81, -176.34, 4000};
212 static float P043[3] = {30, 0, 5000};
213 static float P044[3] = {24.27, 58.78, 5000};
214 static float P045[3] = {9.27, 95.11, 5000};
215 static float P046[3] = {-9.27, 95.11, 5000};
216 static float P047[3] = {-24.27, 58.78, 5000};
217 static float P048[3] = {-30, 0, 5000};
218 static float P049[3] = {-24.27, -58.78, 5000};
219 static float P050[3] = {-9.27, -95.1, 5000};
220 static float P051[3] = {9.27, -95.11, 5000};
221 static float P052[3] = {24.27, -58.78, 5000};
223 static const float P053[3] = {0, 0, 0};
224 static const float P054[3] = {0, 0, 0};
225 static const float P055[3] = {0, 0, 0};
226 static const float P056[3] = {0, 0, 0};
227 static const float P057[3] = {0, 0, 0};
229 static const float P058[3] = {0, 1212.72, 2703.08};
230 static const float P059[3] = {50.36, 0, 108.14};
231 static const float P060[3] = {-22.18, 0, 108.14};
232 static float P061[3] = {0, 1181.61, 6344.65};
233 static const float P062[3] = {516.45, -887.08, 2535.45};
234 static const float P063[3] = {-545.69, -879.31, 2555.63};
235 static const float P064[3] = {618.89, -1005.64, 2988.32};
236 static const float P065[3] = {-635.37, -1014.79, 2938.68};
237 static const float P066[3] = {0, 1374.43, 3064.18};
239 static const float P067[3] = {158.49, -11.89, 1401.56};
240 static const float P068[3] = {-132.08, -17.9, 1394.31};
242 static float P069[3] = {0, -418.25, 5765.04};
243 static float P070[3] = {0, 1266.91, 6629.6};
244 static const float P071[3] = {-139.12, -124.96, 997.98};
245 static const float P072[3] = {-139.24, -110.18, 1020.68};
246 static const float P073[3] = {-137.33, -94.52, 1022.63};
247 static const float P074[3] = {-137.03, -79.91, 996.89};
248 static const float P075[3] = {-135.21, -91.48, 969.14};
249 static const float P076[3] = {-135.39, -110.87, 968.76};
250 static const float P077[3] = {150.23, -78.44, 995.53};
251 static const float P078[3] = {152.79, -92.76, 1018.46};
252 static const float P079[3] = {154.19, -110.2, 1020.55};
253 static const float P080[3] = {151.33, -124.15, 993.77};
254 static const float P081[3] = {150.49, -111.19, 969.86};
255 static const float P082[3] = {150.79, -92.41, 969.7};
256 static const float iP002[3] = {0, -36.59, 5687.72};
257 static const float iP004[3] = {58.24, -146.84, 262.35};
258 static const float iP007[3] = {-46.09, -146.83, 265.84};
259 static const float iP010[3] = {-27.81, -285.31, 500};
260 static const float iP011[3] = {27.81, -285.32, 500};
261 static const float iP023[3] = {150, 0, 3000};
262 static const float iP024[3] = {121.35, 293.89, 3000};
263 static const float iP025[3] = {46.35, 502.93, 2883.09};
264 static const float iP026[3] = {-46.35, 497.45, 2877.24};
265 static const float iP027[3] = {-121.35, 293.9, 3000};
266 static const float iP028[3] = {-150, 0, 3000};
267 static const float iP029[3] = {-121.35, -304.84, 2853.86};
268 static const float iP030[3] = {-46.36, -475.52, 3000};
269 static const float iP031[3] = {46.35, -475.53, 3000};
270 static const float iP032[3] = {121.35, -304.87, 2853.86};
271 static const float iP033[3] = {90, 0, 4000};
272 static const float iP034[3] = {72.81, 176.33, 4000};
273 static const float iP035[3] = {27.81, 285.32, 4000};
274 static const float iP036[3] = {-27.81, 285.32, 4000};
275 static const float iP037[3] = {-72.81, 176.34, 4000};
276 static const float iP038[3] = {-90, 0, 4000};
277 static const float iP039[3] = {-72.81, -176.33, 4000};
278 static const float iP040[3] = {-27.81, -285.31, 4000};
279 static const float iP041[3] = {27.81, -285.32, 4000};
280 static const float iP042[3] = {72.81, -176.34, 4000};
281 static const float iP043[3] = {30, 0, 5000};
282 static const float iP044[3] = {24.27, 58.78, 5000};
283 static const float iP045[3] = {9.27, 95.11, 5000};
284 static const float iP046[3] = {-9.27, 95.11, 5000};
285 static const float iP047[3] = {-24.27, 58.78, 5000};
286 static const float iP048[3] = {-30, 0, 5000};
287 static const float iP049[3] = {-24.27, -58.78, 5000};
288 static const float iP050[3] = {-9.27, -95.1, 5000};
289 static const float iP051[3] = {9.27, -95.11, 5000};
290 static const float iP052[3] = {24.27, -58.78, 5000};
292 static const float iP053[3] = {0, 0, 0};
294 static const float iP061[3] = {0, 1181.61, 6344.65};
295 static const float iP069[3] = {0, -418.25, 5765.04};
296 static const float iP070[3] = {0, 1266.91, 6629.6};
1241 DrawShark(fishRec * fish, int wire)
1245 float seg1, seg2, seg3, seg4, segup;
1246 float thrash, chomp;
1249 fish->htail = (int) (fish->htail - (int) (5 * fish->v)) % 360;
1251 thrash = 50 * fish->v;
1253 seg1 = 0.6 * thrash * sin(fish->htail * RRAD);
1254 seg2 = 1.8 * thrash * sin((fish->htail + 45) * RRAD);
1255 seg3 = 3 * thrash * sin((fish->htail + 90) * RRAD);
1256 seg4 = 4 * thrash * sin((fish->htail + 110) * RRAD);
1260 chomp = -(fish->v - 2) * 200;
1262 P004[1] = iP004[1] + chomp;
1263 P007[1] = iP007[1] + chomp;
1264 P010[1] = iP010[1] + chomp;
1265 P011[1] = iP011[1] + chomp;
1267 P023[0] = iP023[0] + seg1;
1268 P024[0] = iP024[0] + seg1;
1269 P025[0] = iP025[0] + seg1;
1270 P026[0] = iP026[0] + seg1;
1271 P027[0] = iP027[0] + seg1;
1272 P028[0] = iP028[0] + seg1;
1273 P029[0] = iP029[0] + seg1;
1274 P030[0] = iP030[0] + seg1;
1275 P031[0] = iP031[0] + seg1;
1276 P032[0] = iP032[0] + seg1;
1277 P033[0] = iP033[0] + seg2;
1278 P034[0] = iP034[0] + seg2;
1279 P035[0] = iP035[0] + seg2;
1280 P036[0] = iP036[0] + seg2;
1281 P037[0] = iP037[0] + seg2;
1282 P038[0] = iP038[0] + seg2;
1283 P039[0] = iP039[0] + seg2;
1284 P040[0] = iP040[0] + seg2;
1285 P041[0] = iP041[0] + seg2;
1286 P042[0] = iP042[0] + seg2;
1287 P043[0] = iP043[0] + seg3;
1288 P044[0] = iP044[0] + seg3;
1289 P045[0] = iP045[0] + seg3;
1290 P046[0] = iP046[0] + seg3;
1291 P047[0] = iP047[0] + seg3;
1292 P048[0] = iP048[0] + seg3;
1293 P049[0] = iP049[0] + seg3;
1294 P050[0] = iP050[0] + seg3;
1295 P051[0] = iP051[0] + seg3;
1296 P052[0] = iP052[0] + seg3;
1297 P002[0] = iP002[0] + seg4;
1298 P061[0] = iP061[0] + seg4;
1299 P069[0] = iP069[0] + seg4;
1300 P070[0] = iP070[0] + seg4;
1302 fish->vtail += ((fish->dtheta - fish->vtail) * 0.1);
1304 if (fish->vtail > 0.5) {
1306 } else if (fish->vtail < -0.5) {
1309 segup = thrash * fish->vtail;
1311 P023[1] = iP023[1] + segup;
1312 P024[1] = iP024[1] + segup;
1313 P025[1] = iP025[1] + segup;
1314 P026[1] = iP026[1] + segup;
1315 P027[1] = iP027[1] + segup;
1316 P028[1] = iP028[1] + segup;
1317 P029[1] = iP029[1] + segup;
1318 P030[1] = iP030[1] + segup;
1319 P031[1] = iP031[1] + segup;
1320 P032[1] = iP032[1] + segup;
1321 P033[1] = iP033[1] + segup * 5;
1322 P034[1] = iP034[1] + segup * 5;
1323 P035[1] = iP035[1] + segup * 5;
1324 P036[1] = iP036[1] + segup * 5;
1325 P037[1] = iP037[1] + segup * 5;
1326 P038[1] = iP038[1] + segup * 5;
1327 P039[1] = iP039[1] + segup * 5;
1328 P040[1] = iP040[1] + segup * 5;
1329 P041[1] = iP041[1] + segup * 5;
1330 P042[1] = iP042[1] + segup * 5;
1331 P043[1] = iP043[1] + segup * 12;
1332 P044[1] = iP044[1] + segup * 12;
1333 P045[1] = iP045[1] + segup * 12;
1334 P046[1] = iP046[1] + segup * 12;
1335 P047[1] = iP047[1] + segup * 12;
1336 P048[1] = iP048[1] + segup * 12;
1337 P049[1] = iP049[1] + segup * 12;
1338 P050[1] = iP050[1] + segup * 12;
1339 P051[1] = iP051[1] + segup * 12;
1340 P052[1] = iP052[1] + segup * 12;
1341 P002[1] = iP002[1] + segup * 17;
1342 P061[1] = iP061[1] + segup * 17;
1343 P069[1] = iP069[1] + segup * 17;
1344 P070[1] = iP070[1] + segup * 17;
1348 glTranslatef(0, 0, -3000);
1350 glGetFloatv(GL_MODELVIEW_MATRIX, &mat[0][0]);
1352 if (mat[0][2] >= 0) {
1355 if (mat[1][2] >= 0) {
1358 if (mat[2][2] >= 0) {
1363 glEnable(GL_CULL_FACE);
1364 cap = wire ? GL_LINE_LOOP : GL_POLYGON;
1391 glDisable(GL_CULL_FACE);