rev |
line source |
nuclear@0
|
1 #include <cassert>
|
nuclear@0
|
2 #include "hellpart.h"
|
nuclear@0
|
3
|
nuclear@0
|
4 HellPart::HellPart(GraphicsContext *gc) {
|
nuclear@0
|
5 this->gc = gc;
|
nuclear@0
|
6
|
nuclear@0
|
7 SceneLoader::SetNormalFileSaving(true);
|
nuclear@0
|
8 SceneLoader::SetDataPath("data/textures/");
|
nuclear@0
|
9 SceneLoader::LoadScene("data/geometry/hell.3ds", &scene);
|
nuclear@0
|
10
|
nuclear@0
|
11 CamPath = scene->GetCurve("CamPath");
|
nuclear@0
|
12 cam = const_cast<Camera*>(scene->GetActiveCamera());
|
nuclear@0
|
13 cam->SetCameraPath(CamPath, 0, 0, 30000);
|
nuclear@0
|
14 cam->SetClippingPlanes(1.0f, 100000.0f);
|
nuclear@0
|
15
|
nuclear@0
|
16 cam2 = scene->GetCamera("Camera02");
|
nuclear@0
|
17 cam3 = scene->GetCamera("Camera03");
|
nuclear@0
|
18 cam2->SetClippingPlanes(1.0f, 100000.0f);
|
nuclear@0
|
19 cam3->SetClippingPlanes(1.0f, 100000.0f);
|
nuclear@0
|
20
|
nuclear@0
|
21 Thunder = scene->GetLight("Omni01");
|
nuclear@0
|
22 Thunder->SetIntensity(0.0f);
|
nuclear@0
|
23
|
nuclear@0
|
24 ThundEnv[0] = scene->GetObject("b1");
|
nuclear@0
|
25 ThundEnv[1] = scene->GetObject("b2");
|
nuclear@0
|
26 ThundEnv[2] = scene->GetObject("b3");
|
nuclear@0
|
27 ThundEnv[3] = scene->GetObject("b4");
|
nuclear@0
|
28 ThundEnv[4] = scene->GetObject("b5");
|
nuclear@0
|
29 for(int i=0; i<5; i++) {
|
nuclear@0
|
30 scene->RemoveObject(ThundEnv[i]);
|
nuclear@0
|
31 }
|
nuclear@0
|
32
|
nuclear@0
|
33 Stones[0] = scene->GetObject("Box01");
|
nuclear@0
|
34 Stones[1] = scene->GetObject("Box02");
|
nuclear@0
|
35 Stones[2] = scene->GetObject("Box03");
|
nuclear@0
|
36 Stones[3] = scene->GetObject("Box04");
|
nuclear@0
|
37 Stones[4] = scene->GetObject("Box05");
|
nuclear@0
|
38 for(int i=0; i<5; i++) {
|
nuclear@0
|
39 scene->RemoveObject(Stones[i]);
|
nuclear@0
|
40 Stones[i]->SetShadingMode(FlatShading);
|
nuclear@0
|
41 }
|
nuclear@0
|
42
|
nuclear@0
|
43 Rings[0] = scene->GetObject("Tube01");
|
nuclear@0
|
44 Rings[1] = scene->GetObject("Tube02");
|
nuclear@0
|
45 Rings[2] = scene->GetObject("Tube03");
|
nuclear@0
|
46 Rings[3] = scene->GetObject("Tube04");
|
nuclear@0
|
47 Rings[4] = scene->GetObject("Tube05");
|
nuclear@0
|
48 for(int i=0; i<5; i++) {
|
nuclear@0
|
49 scene->RemoveObject(Rings[i]);
|
nuclear@0
|
50 }
|
nuclear@0
|
51
|
nuclear@0
|
52 // Load Credits
|
nuclear@0
|
53 dbgtex = gc->texman->AddTexture("data/textures/psys02.jpg");
|
nuclear@0
|
54 CredNuc[0] = gc->texman->AddTexture("data/textures/credits/nuc1.jpg");
|
nuclear@0
|
55 CredNuc[1] = gc->texman->AddTexture("data/textures/credits/nuc2.jpg");
|
nuclear@0
|
56 CredNuc[2] = gc->texman->AddTexture("data/textures/credits/nuc3.jpg");
|
nuclear@0
|
57 CredNuc[3] = gc->texman->AddTexture("data/textures/credits/nuc4.jpg");
|
nuclear@0
|
58 CredNuc[4] = gc->texman->AddTexture("data/textures/credits/nuc5.jpg");
|
nuclear@0
|
59 CredNuc[5] = gc->texman->AddTexture("data/textures/credits/nuc6.jpg");
|
nuclear@0
|
60 CredNuc[6] = gc->texman->AddTexture("data/textures/credits/nuc7.jpg");
|
nuclear@0
|
61
|
nuclear@0
|
62 CredRaw[0] = gc->texman->AddTexture("data/textures/credits/raw1.jpg");
|
nuclear@0
|
63 CredRaw[1] = gc->texman->AddTexture("data/textures/credits/raw2.jpg");
|
nuclear@0
|
64 CredRaw[2] = gc->texman->AddTexture("data/textures/credits/raw3.jpg");
|
nuclear@0
|
65 CredRaw[3] = gc->texman->AddTexture("data/textures/credits/raw4.jpg");
|
nuclear@0
|
66 CredRaw[4] = gc->texman->AddTexture("data/textures/credits/raw5.jpg");
|
nuclear@0
|
67 CredRaw[5] = gc->texman->AddTexture("data/textures/credits/raw6.jpg");
|
nuclear@0
|
68 CredRaw[6] = gc->texman->AddTexture("data/textures/credits/raw7.jpg");
|
nuclear@0
|
69
|
nuclear@0
|
70 CredAmi[0] = gc->texman->AddTexture("data/textures/credits/am1.jpg");
|
nuclear@0
|
71 CredAmi[1] = gc->texman->AddTexture("data/textures/credits/am2.jpg");
|
nuclear@0
|
72 CredAmi[2] = gc->texman->AddTexture("data/textures/credits/am3.jpg");
|
nuclear@0
|
73 CredAmi[3] = gc->texman->AddTexture("data/textures/credits/am4.jpg");
|
nuclear@0
|
74 CredAmi[4] = gc->texman->AddTexture("data/textures/credits/am5.jpg");
|
nuclear@0
|
75 CredAmi[5] = gc->texman->AddTexture("data/textures/credits/am6.jpg");
|
nuclear@0
|
76 CredAmi[6] = gc->texman->AddTexture("data/textures/credits/am7.jpg");
|
nuclear@0
|
77
|
nuclear@0
|
78 CredAmv[0] = gc->texman->AddTexture("data/textures/credits/amv1.jpg");
|
nuclear@0
|
79 CredAmv[1] = gc->texman->AddTexture("data/textures/credits/amv2.jpg");
|
nuclear@0
|
80 CredAmv[2] = gc->texman->AddTexture("data/textures/credits/amv3.jpg");
|
nuclear@0
|
81 CredAmv[3] = gc->texman->AddTexture("data/textures/credits/amv4.jpg");
|
nuclear@0
|
82 CredAmv[4] = gc->texman->AddTexture("data/textures/credits/amv5.jpg");
|
nuclear@0
|
83 CredAmv[5] = gc->texman->AddTexture("data/textures/credits/amv6.jpg");
|
nuclear@0
|
84 CredAmv[6] = gc->texman->AddTexture("data/textures/credits/amv7.jpg");
|
nuclear@0
|
85
|
nuclear@0
|
86 Credits = new Object(gc);
|
nuclear@0
|
87 Credits->CreatePlane(1.7f, 0);
|
nuclear@0
|
88 Credits->Scale(1.0f, 0.3f, 1.0f);
|
nuclear@0
|
89
|
nuclear@0
|
90 Blood = scene->GetObject("Blood");
|
nuclear@0
|
91 scene->RemoveObject(Blood);
|
nuclear@0
|
92 Grail = scene->GetObject("Object13");
|
nuclear@0
|
93 //scene->RemoveObject(Grail);
|
nuclear@0
|
94 }
|
nuclear@0
|
95
|
nuclear@0
|
96 HellPart::~HellPart() {
|
nuclear@0
|
97 delete scene;
|
nuclear@0
|
98 }
|
nuclear@0
|
99
|
nuclear@0
|
100 void HellPart::MainLoop() {
|
nuclear@0
|
101 dword msec = timer.GetMilliSec();
|
nuclear@0
|
102 float t = msec / 1000.0f;
|
nuclear@0
|
103
|
nuclear@0
|
104 // deform blood surface
|
nuclear@0
|
105 Vertex *BloodVerts = Blood->GetTriMesh()->GetModVertexArray();
|
nuclear@0
|
106 dword VertexCount = Blood->GetTriMesh()->GetVertexCount();
|
nuclear@0
|
107
|
nuclear@0
|
108 for(dword i=0; i<VertexCount; i++) {
|
nuclear@0
|
109 Vector2 pos2d(BloodVerts[i].pos.x, BloodVerts[i].pos.z);
|
nuclear@0
|
110 float dist = pos2d.Length();
|
nuclear@0
|
111 BloodVerts[i].pos.y = (1.5f * sinf(dist - t*3.0f)) * (dist > 0.0f ? (1.0f / (dist*1.5f)) : 1.0f);
|
nuclear@0
|
112 }
|
nuclear@0
|
113 Blood->GetTriMesh()->CalculateNormals();
|
nuclear@0
|
114
|
nuclear@0
|
115
|
nuclear@0
|
116 ////////////////////////
|
nuclear@0
|
117
|
nuclear@0
|
118 gc->Clear(0);
|
nuclear@0
|
119 gc->ClearZBufferStencil(1.0f, 0);
|
nuclear@0
|
120
|
nuclear@0
|
121 scene->SetActiveCamera(cam);
|
nuclear@0
|
122
|
nuclear@0
|
123 if(t >= 18.0f && t < 22.0f) {
|
nuclear@0
|
124 scene->SetActiveCamera(cam2);
|
nuclear@0
|
125 Credits->material.SetTexture(CredNuc[(int)(t * 20.0f) % 7], TextureMap);
|
nuclear@0
|
126 }
|
nuclear@0
|
127 if(t >= 24.0f && t < 28.0f) {
|
nuclear@0
|
128 scene->SetActiveCamera(cam3);
|
nuclear@0
|
129 Credits->material.SetTexture(CredRaw[(int)(t * 20.0f) % 7], TextureMap);
|
nuclear@0
|
130 }
|
nuclear@0
|
131 if(t >= 30.0f && t < 34.0f) {
|
nuclear@0
|
132 scene->SetActiveCamera(cam2);
|
nuclear@0
|
133 Credits->material.SetTexture(CredAmi[(int)(t * 20.0f) % 7], TextureMap);
|
nuclear@0
|
134 }
|
nuclear@0
|
135 if(t >= 36.0f && t < 40.0f) {
|
nuclear@0
|
136 scene->SetActiveCamera(cam3);
|
nuclear@0
|
137 Credits->material.SetTexture(CredAmv[(int)(t * 20.0f) % 7], TextureMap);
|
nuclear@0
|
138 }
|
nuclear@0
|
139
|
nuclear@0
|
140 cam->FollowPath(msec);
|
nuclear@0
|
141
|
nuclear@0
|
142 gc->SetAmbientLight(Color(0.5f));
|
nuclear@0
|
143
|
nuclear@0
|
144 scene->Render();
|
nuclear@0
|
145
|
nuclear@0
|
146 for(int i=0; i<5; i++) {
|
nuclear@0
|
147 Matrix4x4 tmat = Stones[i]->TransMat, rmat = Stones[i]->GRotMat;
|
nuclear@0
|
148 Stones[i]->Translate(0.0f, sinf(t) * 54.0f, 0.0f);
|
nuclear@0
|
149 Stones[i]->GlobalRotate(0.0f, t/4.0f, 0.0f);
|
nuclear@0
|
150
|
nuclear@0
|
151 Stones[i]->Render();
|
nuclear@0
|
152
|
nuclear@0
|
153 Stones[i]->TransMat = tmat;
|
nuclear@0
|
154 Stones[i]->GRotMat = rmat;
|
nuclear@0
|
155 }
|
nuclear@0
|
156
|
nuclear@0
|
157 float Rot = t / 2.0f;
|
nuclear@0
|
158
|
nuclear@0
|
159 for(int i=0; i<5; i++) {
|
nuclear@0
|
160 Rings[i]->ResetRotation();
|
nuclear@0
|
161 }
|
nuclear@0
|
162
|
nuclear@0
|
163 Rings[0]->Rotate(Rot, 0.0f, 0.0f);
|
nuclear@0
|
164
|
nuclear@0
|
165 Rings[1]->Rotate(0.0f, 0.0f, Rot);
|
nuclear@0
|
166
|
nuclear@0
|
167 Vector3 axis(1.0f, 0.0f, 0.0f);
|
nuclear@0
|
168 axis.Rotate(0.0f, 0.0f, QuarterPi);
|
nuclear@0
|
169 Rings[2]->Rotate(0.0f, 0.0f, QuarterPi);
|
nuclear@0
|
170 Rings[2]->Rotate(axis, Rot);
|
nuclear@0
|
171
|
nuclear@0
|
172 axis = Vector3(0.0f, 0.0f, 1.0f);
|
nuclear@0
|
173 axis.Rotate(QuarterPi, 0.0f, 0.0f);
|
nuclear@0
|
174 Rings[3]->Rotate(QuarterPi, 0.0f, 0.0f);
|
nuclear@0
|
175 Rings[3]->Rotate(axis, Rot);
|
nuclear@0
|
176
|
nuclear@0
|
177 Rings[4]->Rotate(Rot, 0.0f, Rot);
|
nuclear@0
|
178
|
nuclear@0
|
179 gc->SetZWrite(false);
|
nuclear@0
|
180 for(int i=0; i<5; i++) {
|
nuclear@0
|
181 Rings[i]->Render();
|
nuclear@0
|
182 }
|
nuclear@0
|
183 gc->SetZWrite(true);
|
nuclear@0
|
184
|
nuclear@0
|
185 Light *light = scene->GetLight("Spot01");
|
nuclear@0
|
186 light->SetRange(100000.0f);
|
nuclear@0
|
187 light->SetIntensity(0.5f);
|
nuclear@0
|
188 light->SetLight(0, gc);
|
nuclear@0
|
189 Blood->Render();
|
nuclear@0
|
190 light->SetRange(100.0f);
|
nuclear@0
|
191 light->SetLight(0, gc);
|
nuclear@0
|
192
|
nuclear@0
|
193 gc->SetAmbientLight(Color(0.0f));
|
nuclear@0
|
194
|
nuclear@0
|
195 if((t >= 18.0f && t < 22.0f) || (t >= 24.0f && t < 28.0f) || (t >= 30.0f && t < 34.0f) || (t >= 36.0f && t < 40.0f)) {
|
nuclear@0
|
196 gc->SetAlphaBlending(true);
|
nuclear@0
|
197 gc->SetLighting(false);
|
nuclear@0
|
198 gc->SetZBuffering(false);
|
nuclear@0
|
199 gc->SetBlendFunc(BLEND_ONE, BLEND_ONE);
|
nuclear@0
|
200 gc->SetMaterial(Material(1.0f, 1.0f, 1.0f));
|
nuclear@0
|
201 gc->SetTexture(0, Credits->material.Maps[TextureMap]);
|
nuclear@0
|
202 gc->SetTexture(1, 0);
|
nuclear@0
|
203 gc->SetTextureCoordIndex(0, 0);
|
nuclear@0
|
204
|
nuclear@0
|
205 gc->SetTextureStageColor(0, TexBlendSelectArg1, TexArgTexture, TexArgCurrent);
|
nuclear@0
|
206 gc->SetTextureStageAlpha(0, TexBlendSelectArg1, TexArgTexture, TexArgCurrent);
|
nuclear@0
|
207 Matrix4x4 WorldMat;
|
nuclear@0
|
208 WorldMat.Scale(1.0f, 0.3f, 1.0f);
|
nuclear@0
|
209 gc->SetWorldMatrix(WorldMat);
|
nuclear@0
|
210 Matrix4x4 ViewMat;
|
nuclear@0
|
211 ViewMat.Translate(0.0f, 0.0f, 2.0f);
|
nuclear@0
|
212 gc->SetViewMatrix(ViewMat);
|
nuclear@0
|
213 Matrix4x4 ProjMat, OldProj;
|
nuclear@0
|
214 OldProj = gc->GetProjectionMatrix();
|
nuclear@0
|
215 CreateProjectionMatrix(&ProjMat, QuarterPi, 1.333333f, 1.0f, 10.0f);
|
nuclear@0
|
216 gc->SetProjectionMatrix(ProjMat);
|
nuclear@0
|
217
|
nuclear@0
|
218 Credits->RenderBare();
|
nuclear@0
|
219
|
nuclear@0
|
220 gc->SetProjectionMatrix(OldProj);
|
nuclear@0
|
221 gc->SetLighting(true);
|
nuclear@0
|
222 gc->SetZBuffering(true);
|
nuclear@0
|
223 gc->SetAlphaBlending(false);
|
nuclear@0
|
224 }
|
nuclear@0
|
225 } |