1 /*
2  * Compiz cube atlantis plugin
3  *
4  * atlantis.c
5  *
6  * This plugin renders a fish tank inside of the transparent cube,
7  * replete with fish, crabs, sand, bubbles, and coral.
8  *
9  * Copyright : (C) 2007-2008 by David Mikos
10  * Email     : infiniteloopcounter@gmail.com
11  *
12  * Copyright : (C) 2007 by Dennis Kasprzyk
13  * E-mail    : onestone@opencompositing.org
14  *
15  *
16  * This program is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU General Public License
18  * as published by the Free Software Foundation; either version 2
19  * of the License, or (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  *
26  */
27 
28 /*
29  * This file is part of an automatically generated output from
30  * executing objToC.java on a .obj 3D model. The output was
31  * split manually into this code and a header with model data.
32  */
33 
34 #include "atlantis-internal.h"
35 #include "fish2.h"
36 
37 void
AnimateFish2(float t)38 AnimateFish2(float t)
39 {
40     int   ti = (int) t;
41     float w = 2*PI*(t-ti);
42     Fish2Points[2+3*2] =8.472+27.614014*sinf(w-6.2797337);
43     Fish2Points[2+3*14] = Fish2Points[2+3*2];
44     Fish2Points[2+3*257] =8.228001+685.45593*sinf(w-6.197503);
45     Fish2Points[2+3*258] =-64.92+830.6361*sinf(w-6.1793556);
46     Fish2Points[2+3*259] =-64.467995+3308.5679*sinf(w-5.869614);
47     Fish2Points[2+3*260] =-9.048+743.78406*sinf(w-6.1902122);
48     Fish2Points[2+3*261] =-173.584+2643.146*sinf(w-5.952792);
49     Fish2Points[2+3*262] =-124.144005+1403.7742*sinf(w-6.1077137);
50     Fish2Points[2+3*263] =-17.488+2293.32*sinf(w-5.9965205);
51     Fish2Points[2+3*264] =-25.028+2843.0222*sinf(w-5.9278073);
52     Fish2Points[2+3*265] =-59.236+801.5239*sinf(w-6.182995);
53     Fish2Points[2+3*266] =18.132+742.0499*sinf(w-6.190429);
54     Fish2Points[2+3*267] =-81.304+2823.6082*sinf(w-5.9302344);
55     Fish2Points[2+3*268] =-49.635998+2374.306*sinf(w-5.9863973);
56     Fish2Points[2+3*269] =-23.664+686.854*sinf(w-6.1973286);
57     Fish2Points[2+3*270] =-3.3400002+3498.526*sinf(w-5.8458695);
58     Fish2Points[2+3*271] =-5.844+3508.1099*sinf(w-5.8446717);
59     Fish2Points[2+3*272] =-34.212+998.92993*sinf(w-6.158319);
60     Fish2Points[2+3*273] = Fish2Points[2+3*271];
61     Fish2Points[2+3*274] =62.584+3194.708*sinf(w-5.8838468);
62     Fish2Points[2+3*275] = Fish2Points[2+3*265];
63     Fish2Points[2+3*276] = Fish2Points[2+3*264];
64     Fish2Points[2+3*277] =-17.64+3378.4058*sinf(w-5.8608847);
65     Fish2Points[2+3*278] = Fish2Points[2+3*272];
66     Fish2Points[2+3*279] = Fish2Points[2+3*269];
67     Fish2Points[2+3*280] = Fish2Points[2+3*271];
68     Fish2Points[2+3*281] = Fish2Points[2+3*265];
69     Fish2Points[2+3*282] =0.724+1415.1799*sinf(w-6.106288);
70     Fish2Points[2+3*283] = Fish2Points[2+3*263];
71     Fish2Points[2+3*284] = Fish2Points[2+3*266];
72     Fish2Points[2+3*285] =6.0959997+1936.6799*sinf(w-6.0411005);
73     Fish2Points[2+3*286] =11.648+1321.4961*sinf(w-6.117998);
74     Fish2Points[2+3*287] =-52.8+3035.812*sinf(w-5.903709);
75     Fish2Points[2+3*288] =-133.184+1432.0901*sinf(w-6.104174);
76     Fish2Points[2+3*289] = Fish2Points[2+3*257];
77     Fish2Points[2+3*290] =-87.284+2772.508*sinf(w-5.9366217);
78     Fish2Points[2+3*291] =-124.035995+1555.332*sinf(w-6.088769);
79     Fish2Points[2+3*292] =-0.604+677.182*sinf(w-6.1985373);
80     Fish2Points[2+3*293] =-48.868+3261.3838*sinf(w-5.875512);
81     Fish2Points[2+3*294] = Fish2Points[2+3*266];
82     Fish2Points[2+3*295] =30.212+3307.566*sinf(w-5.8697395);
83     Fish2Points[2+3*296] = Fish2Points[2+3*263];
84     Fish2Points[2+3*297] = Fish2Points[2+3*282];
85     Fish2Points[2+3*298] =-12.172+1906.4141*sinf(w-6.0448837);
86     Fish2Points[2+3*299] = Fish2Points[2+3*258];
87     Fish2Points[2+3*300] =-41.54+3162.44*sinf(w-5.8878803);
88     Fish2Points[2+3*301] = Fish2Points[2+3*259];
89     Fish2Points[2+3*302] = Fish2Points[2+3*266];
90     Fish2Points[2+3*303] =-111.52+3457.7358*sinf(w-5.8509684);
91     Fish2Points[2+3*304] = Fish2Points[2+3*295];
92     Fish2Points[2+3*305] = Fish2Points[2+3*266];
93     Fish2Points[2+3*306] = Fish2Points[2+3*268];
94     Fish2Points[2+3*307] = Fish2Points[2+3*285];
95     Fish2Points[2+3*308] =38.868+1401.502*sinf(w-6.1079974);
96     Fish2Points[2+3*309] = Fish2Points[2+3*277];
97     Fish2Points[2+3*310] =48.524+3463.4404*sinf(w-5.8502555);
98     Fish2Points[2+3*311] = Fish2Points[2+3*259];
99     Fish2Points[2+3*312] = Fish2Points[2+3*287];
100     Fish2Points[2+3*313] = Fish2Points[2+3*257];
101     Fish2Points[2+3*314] = Fish2Points[2+3*260];
102     Fish2Points[2+3*315] =-56.904+2984.6318*sinf(w-5.910106);
103     Fish2Points[2+3*316] = Fish2Points[2+3*261];
104     Fish2Points[2+3*317] = Fish2Points[2+3*267];
105     Fish2Points[2+3*318] = Fish2Points[2+3*266];
106     Fish2Points[2+3*319] = Fish2Points[2+3*293];
107     Fish2Points[2+3*320] = Fish2Points[2+3*272];
108     Fish2Points[2+3*321] = Fish2Points[2+3*274];
109     Fish2Points[2+3*322] =116.548004+1603.0479*sinf(w-6.082804);
110     Fish2Points[2+3*323] = Fish2Points[2+3*269];
111     Fish2Points[2+3*324] =38.724003+3138.046*sinf(w-5.8909297);
112     Fish2Points[2+3*325] = Fish2Points[2+3*270];
113     Fish2Points[2+3*326] =-87.647995+928.5459*sinf(w-6.167117);
114     Fish2Points[2+3*327] = Fish2Points[2+3*303];
115     Fish2Points[2+3*328] = Fish2Points[2+3*266];
116     Fish2Points[2+3*329] = Fish2Points[2+3*315];
117     Fish2Points[2+3*330] = Fish2Points[2+3*260];
118     Fish2Points[2+3*331] =-26.915998+3044.708*sinf(w-5.902597);
119     Fish2Points[2+3*332] = Fish2Points[2+3*308];
120     Fish2Points[2+3*333] = Fish2Points[2+3*265];
121     Fish2Points[2+3*334] = Fish2Points[2+3*277];
122     Fish2Points[2+3*335] = Fish2Points[2+3*290];
123     Fish2Points[2+3*336] = Fish2Points[2+3*292];
124     Fish2Points[2+3*337] =-37.312+2777.5*sinf(w-5.935998);
125     Fish2Points[2+3*338] = Fish2Points[2+3*292];
126     Fish2Points[2+3*339] =-64.952+1454.354*sinf(w-6.101391);
127     Fish2Points[2+3*340] = Fish2Points[2+3*337];
128     Fish2Points[2+3*341] =-100.708+2697.448*sinf(w-5.9460044);
129     Fish2Points[2+3*342] = Fish2Points[2+3*337];
130     Fish2Points[2+3*343] = Fish2Points[2+3*339];
131     Fish2Points[2+3*344] = Fish2Points[2+3*260];
132     Fish2Points[2+3*345] =-40.440002+1561.1921*sinf(w-6.0880365);
133     Fish2Points[2+3*346] = Fish2Points[2+3*331];
134     Fish2Points[2+3*347] = Fish2Points[2+3*331];
135     Fish2Points[2+3*348] = Fish2Points[2+3*345];
136     Fish2Points[2+3*349] =-116.116005+2728.93*sinf(w-5.942069);
137     Fish2Points[2+3*368] =-39.843998+386.25*sinf(w-6.2349043);
138     Fish2Points[2+3*370] =182.37201+62.35205*sinf(w-6.275391);
139     Fish2Points[2+3*401] =-120.659996+1114.71*sinf(w-6.1438465);
140     Fish2Points[2+3*402] =-62.452+1218.2461*sinf(w-6.1309047);
141     Fish2Points[2+3*407] =128.42401+409.07202*sinf(w-6.2320514);
142     Fish2Points[2+3*429] =109.272+1242.75*sinf(w-6.1278415);
143     Fish2Points[2+3*430] =-37.024+1098.196*sinf(w-6.1459107);
144     Fish2Points[2+3*431] =-140.92401+391.776*sinf(w-6.2342134);
145 }
146 
147 
148 void
DrawAnimatedFish2()149 DrawAnimatedFish2()
150 {
151     glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_LIGHTING_BIT);
152     glEnableClientState(GL_NORMAL_ARRAY);
153     glEnableClientState(GL_VERTEX_ARRAY);
154     glVertexPointer (3, GL_FLOAT, 0, Fish2Points);
155     glNormalPointer (GL_FLOAT, 0, Fish2Normals);
156 
157     //TopFin
158     glDisable (GL_COLOR_MATERIAL);
159     glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
160     glLightModelf (GL_LIGHT_MODEL_TWO_SIDE, 1.0f);
161     glDisable(GL_CULL_FACE);
162     glMaterialfv (GL_FRONT_AND_BACK, GL_SHININESS, UserDefined_DS_85_shininess);
163     glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT, UserDefined_DS_85_ambient);
164     glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE, UserDefined_DS_85_diffuse);
165     glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, UserDefined_DS_85_specular);
166     glDrawElements(GL_TRIANGLES, 84, GL_UNSIGNED_INT, &(Fish2Indices[0]));
167 
168     //Eye
169     glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
170     glLightModelf (GL_LIGHT_MODEL_TWO_SIDE, 0.0f);
171     glEnable(GL_CULL_FACE);
172     glMaterialfv (GL_FRONT, GL_SHININESS, EyePupil_shininess);
173     glMaterialfv (GL_FRONT, GL_AMBIENT, EyePupil_ambient);
174     glMaterialfv (GL_FRONT, GL_DIFFUSE, EyePupil_diffuse);
175     glMaterialfv (GL_FRONT, GL_SPECULAR, EyePupil_specular);
176     glDrawElements(GL_TRIANGLES, 48, GL_UNSIGNED_INT, &(Fish2Indices[84]));
177 
178     glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
179     glMaterialfv (GL_FRONT, GL_SHININESS, EyeWhite_shininess);
180     glMaterialfv (GL_FRONT, GL_AMBIENT, EyeWhite_ambient);
181     glMaterialfv (GL_FRONT, GL_DIFFUSE, EyeWhite_diffuse);
182     glMaterialfv (GL_FRONT, GL_SPECULAR, EyeWhite_specular);
183     glDrawElements(GL_TRIANGLES, 408, GL_UNSIGNED_INT, &(Fish2Indices[132]));
184 
185     //BottomFin
186     glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
187     glLightModelf (GL_LIGHT_MODEL_TWO_SIDE, 1.0f);
188     glDisable(GL_CULL_FACE);
189     glMaterialfv (GL_FRONT_AND_BACK, GL_SHININESS, UserDefined_DS_85_shininess);
190     glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT, UserDefined_DS_85_ambient);
191     glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE, UserDefined_DS_85_diffuse);
192     glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, UserDefined_DS_85_specular);
193     glDrawElements(GL_TRIANGLES, 93, GL_UNSIGNED_INT, &(Fish2Indices[540]));
194 
195     //TailFin
196     glDrawElements(GL_TRIANGLES, 93, GL_UNSIGNED_INT, &(Fish2Indices[633]));
197 
198     //Body
199     glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
200     glLightModelf (GL_LIGHT_MODEL_TWO_SIDE, 0.0f);
201     glEnable(GL_CULL_FACE);
202     glMaterialfv (GL_FRONT, GL_SHININESS, UserDefined_shininess);
203     glMaterialfv (GL_FRONT, GL_AMBIENT, UserDefined_ambient);
204     glMaterialfv (GL_FRONT, GL_DIFFUSE, UserDefined_diffuse);
205     glMaterialfv (GL_FRONT, GL_SPECULAR, UserDefined_specular);
206     glDrawElements(GL_TRIANGLES, 468, GL_UNSIGNED_INT, &(Fish2Indices[726]));
207     glDisableClientState (GL_NORMAL_ARRAY);
208     glPopAttrib();
209 }
210 
211 void
initDrawFish2(float * color)212 initDrawFish2(float *color)
213 {
214     glRotatef(180.0, 0.0, 1.0, 0.0);
215     glRotatef(90.0, 0.0, 1.0, 0.0);
216     glEnable(GL_CULL_FACE);
217 
218     copyColor((float *)UserDefined_DS_85_ambient, color, 0.68);
219     copyColor((float *)UserDefined_DS_85_diffuse, color, 0.68);
220     copyColor((float *)UserDefined_DS_85_specular, color, 0.085);
221     copyColor((float *)UserDefined_ambient, color, 0.8);
222     copyColor((float *)UserDefined_diffuse, color, 0.8);
223     copyColor((float *)UserDefined_specular, color, 0.1);
224 }
225 
226 void
finDrawFish2()227 finDrawFish2()
228 {
229     glDisable(GL_CULL_FACE);
230 }
231