fArchipelagoC.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. // ---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <tchar.h>
  4. #pragma hdrstop
  5. #include "fArchipelagoC.h"
  6. // ---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma link "GLS.BaseClasses"
  9. #pragma link "GLS.BitmapFont"
  10. #pragma link "GLS.Cadencer"
  11. #pragma link "GLS.Coordinates"
  12. #pragma link "GLS.HeightData"
  13. #pragma link "GLS.HeightTileFileHDS"
  14. #pragma link "GLS.Material"
  15. #pragma link "GLS.Objects"
  16. #pragma link "GLS.Scene"
  17. #pragma link "GLS.SkyDome"
  18. #pragma link "GLS.TerrainRenderer"
  19. #pragma link "GLS.VectorFileObjects"
  20. #pragma link "GLS.SceneViewer"
  21. #pragma link "GLS.WindowsFont"
  22. #pragma link "GLS.HUDObjects"
  23. #pragma link "GLS.File3DS"
  24. #pragma resource "*.dfm"
  25. TForm1 *Form1;
  26. #define cWaterLevel -10000
  27. #define cWaterOpaqueDepth 2000
  28. #define cWaveAmplitude 120
  29. // ---------------------------------------------------------------------------
  30. __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) {
  31. }
  32. // ---------------------------------------------------------------------------
  33. void __fastcall TForm1::FormCreate(TObject *Sender) {
  34. int i, j;
  35. String name;
  36. TGLLibMaterial *libMat;
  37. String DataPath;
  38. DataPath = ExtractFilePath(ParamStr(0));
  39. DataPath += "Data\\";
  40. SetCurrentDir(DataPath);
  41. MaterialLibrary->TexturePaths = DataPath;
  42. GLCustomHDS1->MaxPoolSize = 8 * 1024 * 1024;
  43. GLCustomHDS1->DefaultHeight = cWaterLevel;
  44. // load texmaps
  45. for (i = 0; i <= 3; i++)
  46. for (j = 0; j <= 3; j++) {
  47. name = Format("Tex_%d_%d.bmp", ARRAYOFCONST((i, j)));
  48. if (!FileExists(name)) {
  49. ShowMessage("Texture file " + name + " not found...\r\
  50. Did you run " "splitter->exe"
  51. " as said in the readme->txt?");
  52. Application->Terminate();
  53. Abort();
  54. }
  55. libMat = MaterialLibrary->AddTextureMaterial(name, name, false);
  56. libMat->Material->Texture->TextureMode = tmReplace;
  57. libMat->Material->Texture->TextureWrap = twNone;
  58. // comment out to turn off texture compression
  59. libMat->Material->Texture->Compression = tcStandard;
  60. libMat->Material->Texture->FilteringQuality = tfAnisotropic;
  61. libMat->Texture2Name = "detail";
  62. }
  63. // Initial camera height offset (controled with pageUp/pageDown)
  64. CamHeight = 20;
  65. // Water plane active
  66. WaterPlane = true;
  67. // load the sailboat
  68. /* lost material for sailboat
  69. FFSailBoat->LoadFromFile("sailboat.glsm");
  70. MLSailBoat->LoadFromFile("sailboat.glml");
  71. */
  72. FFSailBoat->LoadFromFile("boat.3DS");
  73. FFSailBoat->Position->SetPoint(-125*TerrainRenderer->Scale->X, 0,
  74. -100*TerrainRenderer->Scale->Z);
  75. FFSailBoat->TurnAngle = -30;
  76. // boost ambient
  77. for (i = 0; i < MLSailBoat->Materials->Count; i++)
  78. MLSailBoat->Materials->Items[i]
  79. ->Material->FrontProperties->Ambient->Color =
  80. MLSailBoat->Materials->Items[i]
  81. ->Material->FrontProperties->Diffuse->Color;
  82. // Move camera starting point near the sailboat
  83. DCCamera->Position = FFSailBoat->Position;
  84. DCCamera->Translate(25, 0, -15);
  85. DCCamera->Turn(200);
  86. // Help text
  87. HTHelp->Text = "Archipelago Demo\r\
  88. * : Increase CLOD precision\r\
  89. / : decrease CLOD precision\r\
  90. W : wireframe on/off\r\
  91. S : sea surface on/off\r\
  92. B : sailboat visible on/off\r\
  93. Num4 & Num6 : steer the sailboat\r\
  94. F1: show this help";
  95. HTHelp->Position->SetPoint(Screen->Width / 2 - 100,
  96. Screen->Height / 2 - 150, 0);
  97. HelpOpacity = 4;
  98. GLSceneViewer->Cursor = crNone;
  99. }
  100. // ---------------------------------------------------------------------------
  101. void TForm1::ResetMousePos(void) {
  102. if (GLSceneViewer->Cursor == crNone)
  103. SetCursorPos(Screen->Width / 2, Screen->Height / 2);
  104. }
  105. // ---------------------------------------------------------------------------
  106. void __fastcall TForm1::GLCadencerProgress(TObject *Sender,
  107. const double deltaTime, const double newTime) {
  108. float Speed, Alpha, f;
  109. float TerrainHeight, SurfaceHeight;
  110. TGLVector Sbp;
  111. POINT NewMousePos;
  112. // Handle keypresses
  113. if (IsKeyDown(VK_SHIFT))
  114. Speed = 100 * deltaTime;
  115. else
  116. Speed = 20 * deltaTime;
  117. if (IsKeyDown(VK_UP))
  118. DCCamera->Position->AddScaledVector(Speed,
  119. GLCamera->AbsoluteVectorToTarget());
  120. if (IsKeyDown(VK_DOWN))
  121. DCCamera->Position->AddScaledVector(-Speed,
  122. GLCamera->AbsoluteVectorToTarget());
  123. if (IsKeyDown(VK_LEFT))
  124. DCCamera->Position->AddScaledVector(-Speed,
  125. GLCamera->AbsoluteRightVectorToTarget());
  126. if (IsKeyDown(VK_RIGHT))
  127. DCCamera->Position->AddScaledVector(Speed,
  128. GLCamera->AbsoluteRightVectorToTarget());
  129. if (IsKeyDown(VK_PRIOR))
  130. CamHeight = CamHeight + Speed;
  131. if (IsKeyDown(VK_NEXT))
  132. CamHeight = CamHeight - Speed;
  133. if (IsKeyDown(VK_ESCAPE))
  134. Close();
  135. if (IsKeyDown(VK_F1))
  136. HelpOpacity = ClampValue(HelpOpacity + deltaTime * 5, 3, 5);
  137. if (IsKeyDown(VK_NUMPAD4))
  138. FFSailBoat->Turn(-deltaTime*3);
  139. if (IsKeyDown(VK_NUMPAD6))
  140. FFSailBoat->Turn(deltaTime*3);
  141. // Mouse movements and actions
  142. if (IsKeyDown(VK_LBUTTON)) {
  143. Alpha = DCCamera->Position->Y;
  144. DCCamera->Position->AddScaledVector(Speed,
  145. GLCamera->AbsoluteVectorToTarget());
  146. CamHeight = CamHeight + DCCamera->Position->Y - Alpha;
  147. }
  148. if (IsKeyDown(VK_RBUTTON)) {
  149. Alpha = DCCamera->Position->Y;
  150. DCCamera->Position->AddScaledVector(-Speed,
  151. GLCamera->AbsoluteVectorToTarget());
  152. CamHeight = CamHeight + DCCamera->Position->Y - Alpha;
  153. }
  154. GetCursorPos(&NewMousePos);
  155. GLCamera->MoveAroundTarget((Screen->Height / 2 - NewMousePos.y)*0.25,
  156. (Screen->Width / 2 - NewMousePos.x)*0.25);
  157. ResetMousePos();
  158. // Don"t drop our target through terrain!
  159. TerrainHeight = TerrainRenderer->InterpolatedHeight
  160. (DCCamera->Position->AsVector);
  161. SurfaceHeight = TerrainRenderer->Scale->Z * cWaterLevel / 128;
  162. if (TerrainHeight < SurfaceHeight)
  163. TerrainHeight = SurfaceHeight;
  164. DCCamera->Position->Y = TerrainHeight + CamHeight;
  165. // Adjust fog distance/color for air/water
  166. if ((GLCamera->AbsolutePosition.Y > SurfaceHeight) || (!WaterPlane)) {
  167. if (!WasAboveWater) {
  168. SkyDome->Visible = true;
  169. GLSceneViewer->Buffer->FogEnvironment->FogColor->Color = clrWhite;
  170. GLSceneViewer->Buffer->FogEnvironment->FogEnd = 1000;
  171. GLSceneViewer->Buffer->FogEnvironment->FogStart = 500;
  172. GLSceneViewer->Buffer->BackgroundColor = clWhite;
  173. GLCamera->DepthOfView = 1000;
  174. WasAboveWater = true;
  175. }
  176. }
  177. else {
  178. if (WasAboveWater) {
  179. SkyDome->Visible = false;
  180. GLSceneViewer->Buffer->FogEnvironment->FogColor->AsWinColor =
  181. clNavy;
  182. GLSceneViewer->Buffer->FogEnvironment->FogEnd = 100;
  183. GLSceneViewer->Buffer->FogEnvironment->FogStart = 0;
  184. GLSceneViewer->Buffer->BackgroundColor = clNavy;
  185. GLCamera->DepthOfView = 100;
  186. WasAboveWater = false;
  187. }
  188. }
  189. // Visibility of Help
  190. if (HelpOpacity > 0) {
  191. HelpOpacity = HelpOpacity - deltaTime;
  192. Alpha = ClampValue(HelpOpacity, 0, 1);
  193. if (Alpha > 0) {
  194. HTHelp->Visible = true;
  195. HTHelp->ModulateColor->Alpha = Alpha;
  196. }
  197. else
  198. HTHelp->Visible = false;
  199. }
  200. // Rock the sailboat
  201. Sbp = TerrainRenderer->AbsoluteToLocal(FFSailBoat->AbsolutePosition);
  202. Alpha = WaterPhase(Sbp.X + TerrainRenderer->TileSize * 0.5,
  203. Sbp.Y + TerrainRenderer->TileSize * 0.5);
  204. FFSailBoat->Position->Y = (cWaterLevel + sin(Alpha) * cWaveAmplitude) *
  205. (TerrainRenderer->Scale->Z / 128) + 10;
  206. f = cWaveAmplitude * 0.01;
  207. FFSailBoat->Up->SetVector(cos(Alpha)*0.02*f, 1,
  208. (sin(Alpha)*0.02 - 0.005)*f);
  209. FFSailBoat->Move(deltaTime*2);
  210. }
  211. // ---------------------------------------------------------------------------
  212. void __fastcall TForm1::Timer1Timer(TObject *Sender) {
  213. HTFPS->Text = Format("%.1f FPS - %d - %d",
  214. ARRAYOFCONST((GLSceneViewer->FramesPerSecond(),
  215. TerrainRenderer->LastTriangleCount, WaterPolyCount)));
  216. GLSceneViewer->ResetPerformanceMonitor();
  217. }
  218. // ---------------------------------------------------------------------------
  219. void __fastcall TForm1::FormKeyPress(TObject *Sender, System::WideChar &Key) {
  220. int i;
  221. TGLPolygonMode pm;
  222. switch (Key) {
  223. case 'w':
  224. case 'W': {
  225. if (MaterialLibrary->Materials->Items[0]->Material->PolygonMode ==
  226. pmLines)
  227. pm = pmFill;
  228. else
  229. pm = pmLines;
  230. for (i = 0; i < MaterialLibrary->Materials->Count; i++)
  231. MaterialLibrary->Materials->Items[i]
  232. ->Material->PolygonMode = pm;
  233. for (i = 0; i < MLSailBoat->Materials->Count; i++)
  234. MLSailBoat->Materials->Items[i]->Material->PolygonMode = pm;
  235. FFSailBoat->StructureChanged();
  236. break;
  237. }
  238. case 's':
  239. case 'S':
  240. WaterPlane = !WaterPlane;
  241. break;
  242. case 'b':
  243. case 'B':
  244. FFSailBoat->Visible = !FFSailBoat->Visible;
  245. break;
  246. case '*':
  247. if (TerrainRenderer->CLODPrecision > 1)
  248. TerrainRenderer->CLODPrecision =
  249. (int)(TerrainRenderer->CLODPrecision * 0.8);
  250. break;
  251. case '/':
  252. if (TerrainRenderer->CLODPrecision < 1000)
  253. TerrainRenderer->CLODPrecision =
  254. (int)(TerrainRenderer->CLODPrecision * 1.2 + 1);
  255. break;
  256. }
  257. Key = 0x0;
  258. }
  259. // ---------------------------------------------------------------------------
  260. void __fastcall TForm1::GLCustomHDS1MarkDirtyEvent(const TRect &area) {
  261. GLHeightTileFileHDS1->MarkDirty(area);
  262. }
  263. // ---------------------------------------------------------------------------
  264. void __fastcall TForm1::GLCustomHDS1StartPreparingData(TGLHeightData *heightData)
  265. {
  266. TGLHeightData *htfHD;
  267. int i, j, n;
  268. TTexPoint offset;
  269. htfHD = GLHeightTileFileHDS1->GetData(heightData->XLeft, heightData->YTop,
  270. heightData->Size, heightData->DataType);
  271. if ((htfHD->DataState == hdsNone))
  272. // or (htfHD->HeightMax<=cWaterLevel-cWaterOpaqueDepth)
  273. heightData->DataState = hdsNone;
  274. else {
  275. i = (heightData->XLeft / 128);
  276. j = (heightData->YTop / 128);
  277. if ((Cardinal(i) < 4) & (Cardinal(j) < 4)) {
  278. heightData->MaterialName =
  279. Format("Tex_%d_%d.bmp", ARRAYOFCONST((i, j)));
  280. heightData->TextureCoordinatesMode = tcmLocal;
  281. n = ((heightData->XLeft / 32) & 3);
  282. offset.S = n * 0.25;
  283. n = ((heightData->YTop / 32) & 3);
  284. offset.T = -n * 0.25;
  285. heightData->TextureCoordinatesOffset = offset;
  286. heightData->TextureCoordinatesScale = TexPointMake(0.25, 0.25);
  287. heightData->DataType = hdtSmallInt;
  288. htfHD->DataType = hdtSmallInt;
  289. heightData->Allocate(hdtSmallInt);
  290. Move(htfHD->SmallIntData, heightData->SmallIntData,
  291. htfHD->DataSize);
  292. heightData->DataState = hdsReady;
  293. heightData->HeightMin = htfHD->HeightMin;
  294. heightData->HeightMax = htfHD->HeightMax;
  295. }
  296. else
  297. heightData->DataState = hdsNone;
  298. }
  299. GLHeightTileFileHDS1->Release(htfHD);
  300. }
  301. // ---------------------------------------------------------------------------
  302. void __fastcall TForm1::GLSceneViewerBeforeRender(TObject *Sender) {
  303. int i, n;
  304. PAProgress->Left = (Width - PAProgress->Width) / 2;
  305. PAProgress->Visible = true;
  306. n = MaterialLibrary->Materials->Count;
  307. ProgressBar->Max = n - 1;
  308. try {
  309. for (i = 0; i < n; i++) {
  310. ProgressBar->Position = i;
  311. MaterialLibrary->Materials->Items[i]->Material->Texture->Handle;
  312. PAProgress->Repaint();
  313. }
  314. }
  315. __finally {
  316. ResetMousePos();
  317. PAProgress->Visible = false;
  318. GLSceneViewer->BeforeRender = NULL;
  319. }
  320. }
  321. // ---------------------------------------------------------------------------
  322. float TForm1::WaterPhase(const float px, const float py) {
  323. return GLCadencer->CurrentTime * 1.0 + px * 0.16 + py * 0.09;
  324. }
  325. // ---------------------------------------------------------------------------
  326. float TForm1::WaterHeight(const float px, const float py) {
  327. float alpha;
  328. alpha = WaterPhase(px + TerrainRenderer->TileSize * 0.5,
  329. py + TerrainRenderer->TileSize * 0.5);
  330. return (cWaterLevel + sin(alpha) * cWaveAmplitude) *
  331. (TerrainRenderer->Scale->Z * (1.0 / 128));
  332. }
  333. // ---------------------------------------------------------------------------
  334. void TForm1::IssuePoint(TGLHeightData *hd, int x, int y, int s2, float t, int rx,
  335. int ry) {
  336. const float r = 0.75;
  337. const float g = 0.75;
  338. const float b = 1.0;
  339. float px, py;
  340. float alpha, colorRatio, ca, sa;
  341. px = x + rx + s2;
  342. py = y + ry + s2;
  343. // if (hd->DataState == hdsNone) {
  344. alpha = 1;
  345. /*
  346. }
  347. else {
  348. alpha = (cWaterLevel - hd->SmallIntHeight(rx, ry)) *
  349. (1 / cWaterOpaqueDepth);
  350. alpha = ClampValue(alpha, 0.5, 1.0);
  351. }
  352. */
  353. SinCos(WaterPhase(px, py), sa, ca);
  354. colorRatio = 1 - alpha * 0.1;
  355. glColor4f(r*colorRatio, g*colorRatio, b, alpha);
  356. glTexCoord2f(px*0.01 + 0.002*sa, py*0.01 + 0.0022*ca - t*0.002);
  357. glVertex3f(px, py, cWaterLevel + cWaveAmplitude*sa);
  358. }
  359. // ---------------------------------------------------------------------------
  360. void __fastcall TForm1::TerrainRendererHeightDataPostRender
  361. (TGLRenderContextInfo &rci, TList *&HeightDatas) {
  362. int i, x, y, s, s2;
  363. float t;
  364. TGLHeightData *hd;
  365. if (WaterPlane) {
  366. t = GLCadencer->CurrentTime;
  367. MaterialLibrary->ApplyMaterial("water", rci);
  368. do {
  369. if (!WasAboveWater)
  370. rci.GLStates->InvertFrontFace();
  371. glPushAttrib(GL_ENABLE_BIT);
  372. glDisable(GL_LIGHTING);
  373. glDisable(GL_NORMALIZE);
  374. glStencilFunc(GL_ALWAYS, 1, 255);
  375. glStencilMask(255);
  376. glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
  377. glEnable(GL_STENCIL_TEST);
  378. glNormal3f(0, 0, 1);
  379. for (i = 0; i < HeightDatas->Count; i++) {
  380. hd = (TGLHeightData*)(HeightDatas->List[i]);
  381. if ((hd->DataState == hdsReady) && (hd->HeightMin >
  382. cWaterLevel))
  383. continue;
  384. x = hd->XLeft;
  385. y = hd->YTop;
  386. s = hd->Size - 1;
  387. s2 = s / 2;
  388. glBegin(GL_TRIANGLE_FAN);
  389. IssuePoint(hd, x, y, s2, t, s2, s2);
  390. IssuePoint(hd, x, y, s2, t, 0, 0);
  391. IssuePoint(hd, x, y, s2, t, s2, 0);
  392. IssuePoint(hd, x, y, s2, t, s, 0);
  393. IssuePoint(hd, x, y, s2, t, s, s2);
  394. IssuePoint(hd, x, y, s2, t, s, s);
  395. IssuePoint(hd, x, y, s2, t, s2, s);
  396. IssuePoint(hd, x, y, s2, t, 0, s);
  397. IssuePoint(hd, x, y, s2, t, 0, s2);
  398. IssuePoint(hd, x, y, s2, t, 0, 0);
  399. glEnd();
  400. }
  401. glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
  402. glPopAttrib();
  403. if (!WasAboveWater)
  404. rci.GLStates->InvertFrontFace();
  405. WaterPolyCount = HeightDatas->Count * 8;
  406. }
  407. while (MaterialLibrary->UnApplyMaterial(rci));
  408. }
  409. }
  410. // ---------------------------------------------------------------------------
  411. void __fastcall TForm1::DOWakeProgress(TObject *Sender, const double deltaTime,
  412. const double newTime) {
  413. int i;
  414. TGLVector sbp, sbr;
  415. if (WakeVertices == NULL) {
  416. WakeVertices = new TGLAffineVectorList();
  417. WakeStretch = new TGLAffineVectorList();
  418. WakeTime = new TGLSingleList();
  419. }
  420. // enlarge current vertices
  421. i = 0;
  422. while (i < WakeVertices->Count) {
  423. WakeVertices->CombineItem(i, WakeStretch->Items[i >> 1],
  424. -0.45*deltaTime);
  425. WakeVertices->CombineItem(i + 1, WakeStretch->Items[i >> 1],
  426. 0.45*deltaTime);
  427. i += 2;
  428. }
  429. // Progress wake
  430. if (newTime > DOWake->TagFloat) {
  431. if (DOWake->TagFloat == 0) {
  432. DOWake->TagFloat = newTime + 0.2;
  433. }
  434. else {
  435. DOWake->TagFloat = newTime + 1;
  436. sbp = VectorCombine(FFSailBoat->AbsolutePosition,
  437. FFSailBoat->AbsoluteDirection, 1, 3);
  438. sbr = FFSailBoat->AbsoluteRight();
  439. // add new
  440. WakeVertices->Add(VectorCombine(sbp, sbr, 1, -2));
  441. WakeVertices->Add(VectorCombine(sbp, sbr, 1, 2));
  442. WakeStretch->Add(VectorScale(sbr, (0.95 + Random()*0.1)));
  443. WakeTime->Add(newTime*0.1);
  444. if (WakeVertices->Count >= 80) {
  445. WakeVertices->Delete(0);
  446. WakeVertices->Delete(0);
  447. WakeStretch->Delete(0);
  448. WakeTime->Delete(0);
  449. }
  450. }
  451. }
  452. }
  453. // ---------------------------------------------------------------------------
  454. void __fastcall TForm1::DOWakeRender(TObject *Sender, TGLRenderContextInfo &rci) {
  455. int i, n;
  456. Vectortypes::TVector3f p;
  457. TGLVector sbp;
  458. float c;
  459. if (!(WakeVertices) && (!((FFSailBoat->Visible) || (WaterPlane)))) {
  460. MaterialLibrary->ApplyMaterial("wake", rci);
  461. do {
  462. glPushAttrib(GL_ENABLE_BIT);
  463. glDisable(GL_LIGHTING);
  464. glDisable(GL_FOG);
  465. glEnable(GL_BLEND);
  466. glBlendFunc(GL_ONE, GL_ONE);
  467. glStencilFunc(GL_EQUAL, 1, 255);
  468. glStencilMask(255);
  469. glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
  470. glEnable(GL_STENCIL_TEST);
  471. glDisable(GL_DEPTH_TEST);
  472. if (!WasAboveWater)
  473. rci.GLStates->InvertFrontFace();
  474. glBegin(GL_TRIANGLE_STRIP);
  475. n = WakeVertices->Count;
  476. for (i = 0; i < n; i++) {
  477. p = WakeVertices->Items[i ^ 1];
  478. sbp = TerrainRenderer->AbsoluteToLocal(VectorMake(p, 0));
  479. if ((i & 1) == 0) {
  480. c = (i & 0xFFE) * 0.2 / n;
  481. glColor3f(c, c, c);
  482. glTexCoord2f(0, WakeTime->Items[i / 2]);
  483. }
  484. else
  485. glTexCoord2f(1, WakeTime->Items[i / 2]);
  486. glVertex3f(p.X, WaterHeight(sbp.X, sbp.Y), p.Z);
  487. }
  488. glEnd();
  489. if (!WasAboveWater)
  490. rci.GLStates->InvertFrontFace();
  491. glPopAttrib();
  492. glDisable(stStencilTest);
  493. }
  494. while (MaterialLibrary->UnApplyMaterial(rci));
  495. }
  496. }
  497. // ---------------------------------------------------------------------------