fTilesC.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <tchar.h>
  4. #pragma hdrstop
  5. #include "fTilesC.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma link "GLS.BaseClasses"
  9. #pragma link "GLS.Cadencer"
  10. #pragma link "GLS.Coordinates"
  11. #pragma link "GLS.Graph"
  12. #pragma link "GLS.Material"
  13. #pragma link "GLS.Objects"
  14. #pragma link "GLS.Scene"
  15. #pragma link "GLS.TilePlane"
  16. #pragma link "GLS.SceneViewer"
  17. #pragma resource "*.dfm"
  18. TForm1* Form1;
  19. //---------------------------------------------------------------------------
  20. __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) {}
  21. //---------------------------------------------------------------------------
  22. void __fastcall TForm1::FormCreate(TObject* Sender)
  23. {
  24. int i, j;
  25. TFileName Path = GetCurrentAssetPath();
  26. SetCurrentDir(Path + "\\texture");
  27. GLMaterialLibrary->TexturePaths = GetCurrentDir();
  28. GLMaterialLibrary->LibMaterialByName("beigemarble")
  29. ->Material->Texture->Image->LoadFromFile("beigemarble.jpg");
  30. GLMaterialLibrary->LibMaterialByName("marbletiles")
  31. ->Material->Texture->Image->LoadFromFile("marbletiles.jpg");
  32. GLMaterialLibrary->LibMaterialByName("walkway")
  33. ->Material->Texture->Image->LoadFromFile("walkway.jpg");
  34. // fill the tiled area with random tiles
  35. RandSeed = 0;
  36. TilePlane = new TGLTilePlane (this);
  37. for (int i = -20; i < 20; i++)
  38. for (int j = -20; j < 20; j++)
  39. ///? TilePlane->Tiles[i][j] = Random(GLMaterialLibrary->Materials->Count - 1) + 1;
  40. // set all tile materials to anisotropic add them to the material selection combo
  41. for (i = 0; GLMaterialLibrary->Materials->Count - 1; i++) {
  42. GLMaterialLibrary->Materials->Items[i]
  43. ->Material->Texture->FilteringQuality = tfAnisotropic;
  44. CBMaterial->Items->Add(GLMaterialLibrary->Materials->Items[i]->Name);
  45. }
  46. CBMaterial->ItemIndex = 0;
  47. TilePlane->Free();
  48. }
  49. //---------------------------------------------------------------------------
  50. void __fastcall TForm1::FormMouseWheel(TObject *Sender, TShiftState Shift, int WheelDelta,
  51. TPoint &MousePos, bool &Handled)
  52. {
  53. Camera->AdjustDistanceToTarget(Power(1.1, WheelDelta / 120));
  54. }
  55. //---------------------------------------------------------------------------
  56. void __fastcall TForm1::DirectOpenGLRender(TObject *Sender, TGLRenderContextInfo &rci)
  57. {
  58. // we clear the depth buffer, so that the grid is always in front of the
  59. // tile plane and won't Z-Fight with it
  60. glClear(GL_DEPTH_BUFFER_BIT);
  61. }
  62. //---------------------------------------------------------------------------