/
MikeLight
/
Lab
Обзор
Документация
Войти
/
MikeLight
/
Lab
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
lab8/fEffectsFLAG.cpp
267 строк
8 KB
MikeLight
upload files
25 ноя 2025, 12:59
25 ноя 2025, 12:59
7a75111
Код
Авторство
О чём код?
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "fEffectsFLAG.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "GLS.BaseClasses" #pragma link "GLS.Scene" #pragma link "GLS.SceneViewer" #pragma link "GLS.Cadencer" #pragma link "GLS.FireFX" #pragma link "GLS.Coordinates" #pragma link "GLS.Objects" #pragma link "GLS.Tree" #pragma link "GLS.Material" #pragma link "GLS.FileTGA" #pragma link "GLS.BitmapFont" #pragma link "GLS.HUDObjects" #pragma link "GLS.WindowsFont" #pragma link "GLS.ThorFX" #pragma link "GLS.Graph" #pragma link "GLS.SkyDome" #pragma link "GLS.LensFlare" #pragma link "GLS.Atmosphere" #pragma resource "*.dfm" TfrmMain *frmMain; //--------------------------------------------------------------------------- __fastcall TfrmMain::TfrmMain(TComponent* Owner) : TForm(Owner) { GLHeightField1->Material->Texture->Image->LoadFromFile("../../Assets/ground.jpg"); GLMaterialLibrary1->AddTextureMaterial("LeafFront", "../../Assets/leaf.png"); GLMaterialLibrary1->Materials->Items[0]->Material->BlendingMode = bmAlphaTest50; GLMaterialLibrary1->Materials->Items[0]->Material->Texture->TextureMode = tmModulate; GLMaterialLibrary1->Materials->Items[0]->Material->Texture->TextureFormat = tfRGBA; GLMaterialLibrary1->AddTextureMaterial("LeafBack", "../../Assets/leaf.png"); GLMaterialLibrary1->Materials->Items[1]->Material->BlendingMode = bmAlphaTest50; GLMaterialLibrary1->Materials->Items[1]->Material->Texture->TextureMode = tmModulate; GLMaterialLibrary1->Materials->Items[1]->Material->Texture->TextureFormat = tfRGBA; GLMaterialLibrary1->AddTextureMaterial("Branch", "../../Assets/zbark.jpg"); GLMaterialLibrary1->Materials->Items[2]->Material->Texture->TextureMode = tmModulate; GLTree1->LeafMaterialName = "LeafFront"; GLTree1->LeafBackMaterialName = "LeafBack"; GLTree1->BranchMaterialName = "Branch"; GLHeightField2->Material->Texture->Image->LoadFromFile("../../Assets/marbletiles.jpg"); GLSphere1->Material->Texture->Image->LoadFromFile("../../Assets/earth_4096.jpg"); GLSkyDome3->Bands->Clear(); GLSkyDome3->Stars->AddRandomStars(5000, ConvertColorVector(clrWhite)); GLAtmosphere1->TogleBlendingMode(); GLHUDText1->Text = " Press \"w\" - up, \"s\" - down, \"a, q\" - left, \"d, e\" - right."; i_f = 0; } //--------------------------------------------------------------------------- void __fastcall TfrmMain::GLSceneViewer1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { mx = X; my = Y; } //--------------------------------------------------------------------------- void __fastcall TfrmMain::GLSceneViewer1MouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { if (Shift.Contains(ssLeft)) { GLCamera1->MoveAroundTarget(my - Y, mx - X); } else if (Shift.Contains(ssRight)) { GLCamera1->RotateTarget(my - Y, mx - X, 0); } mx = X; my = Y; } //--------------------------------------------------------------------------- void __fastcall TfrmMain::GLSceneViewer1MouseWheel(TObject *Sender, TShiftState Shift, int WheelDelta, TPoint &MousePos, bool &Handled) { GLCamera1->AdjustDistanceToTarget(Power(1.1, -WheelDelta / 120)); } //--------------------------------------------------------------------------- void __fastcall TfrmMain::GLCadencer1Progress(TObject *Sender, const double DeltaTime, const double NewTime) { if (RadioButton3->Checked) { GLSphere1->Turn(DeltaTime * 20); } if (RadioButton1->Checked) { if(IsKeyDown(87)) { GLDummyCube4->Position->Y += DeltaTime; } if(IsKeyDown(83)) { GLDummyCube4->Position->Y -= DeltaTime; } if(IsKeyDown(65)) { GLDummyCube4->Position->X += DeltaTime; } if(IsKeyDown(68)) { GLDummyCube4->Position->X -= DeltaTime; } if(IsKeyDown(81)) { GLDummyCube4->Position->Z += DeltaTime; } if(IsKeyDown(69)) { GLDummyCube4->Position->Z -= DeltaTime; } } if(IsKeyDown(27)) { Close(); } } //--------------------------------------------------------------------------- void __fastcall TfrmMain::TrackBar1Change(TObject *Sender) { if (RadioButton1->Checked) { GLFireFXManager1->FireDir->X = TrackBar1->Position * 0.1; } if (RadioButton2->Checked) { GLThorFXManager1->GlowSize = (float)TrackBar1->Position / 50; } } //--------------------------------------------------------------------------- void __fastcall TfrmMain::Timer1Timer(TObject *Sender) { frmMain->Caption = "������������ ������ �8 " + GLSceneViewer1->FramesPerSecondText(); if (i_f < GLTree1->Count && RadioButton1->Checked) { GLTree1->Children[i_f]->Visible = true; i_f++; } } //--------------------------------------------------------------------------- void __fastcall TfrmMain::RadioButton1Click(TObject *Sender) { GLDummyCube1->Visible = false; GLDummyCube2->Visible = false; GLDummyCube3->Visible = false; Label2->Visible = false; Label3->Visible = false; Label4->Visible = false; Label5->Visible = false; TrackBar1->Visible = false; TrackBar2->Visible = false; TrackBar3->Visible = false; TrackBar4->Visible = false; CheckBox1->Visible = false; CheckBox2->Visible = false; CheckBox3->Visible = false; GLFireFXManager1->Disabled = true; GLThorFXManager1->Disabled = true; GLHUDText1->Visible = false; GLLightSource1->Position->X = 0; if (RadioButton1->Checked) { GLCamera1->TargetObject = GLDummyCube1; GLDummyCube1->Visible = true; Label2->Visible = true; Label2->Caption = "�����:"; TrackBar1->Visible = true; TrackBar1->Max = 20; TrackBar1->Min = -20; TrackBar1->Position = 0; GLFireFXManager1->Disabled = false; GLHUDText1->Visible = true; } if (RadioButton2->Checked) { GLCamera1->TargetObject = GLDummyCube2; GLDummyCube2->Visible = true; Label2->Visible = true; Label2->Caption = "������ ��������:"; TrackBar1->Visible = true; TrackBar1->Max = 50; TrackBar1->Min = 0; TrackBar1->Position = 10; Label2->Visible = true; Label3->Visible = true; Label4->Visible = true; Label5->Visible = true; TrackBar1->Visible = true; TrackBar2->Visible = true; TrackBar3->Visible = true; TrackBar4->Visible = true; CheckBox1->Visible = true; CheckBox2->Visible = true; CheckBox3->Visible = true; GLThorFXManager1->Disabled = false; CheckBox2Click(Sender); } if (RadioButton3->Checked) { GLLightSource1->Position->X = 30; GLCamera1->TargetObject = GLDummyCube3; GLDummyCube3->Visible = true; } } //--------------------------------------------------------------------------- void __fastcall TfrmMain::TrackBar2Change(TObject *Sender) { GLThorFXManager1->InnerColor->Alpha = (float)TrackBar2->Position / 50; } //--------------------------------------------------------------------------- void __fastcall TfrmMain::TrackBar3Change(TObject *Sender) { GLThorFXManager1->Wildness = (float)TrackBar3->Position / 5; } //--------------------------------------------------------------------------- void __fastcall TfrmMain::TrackBar4Change(TObject *Sender) { GLThorFXManager1->Vibrate = (float)TrackBar4->Position / 10; } //--------------------------------------------------------------------------- void __fastcall TfrmMain::CheckBox1Click(TObject *Sender) { GLThorFXManager1->Core = CheckBox1->Checked; } //--------------------------------------------------------------------------- void __fastcall TfrmMain::CheckBox2Click(TObject *Sender) { GLThorFXManager1->Disabled = CheckBox2->Checked; } //--------------------------------------------------------------------------- void __fastcall TfrmMain::GLThorFXManager1CalcPoint(TObject *Sender, int PointNo, float &x, float &y, float &z) { if (CheckBox3->Checked) { float Place = (float)PointNo / GLThorFXManager1->Maxpoints; float Spin = (Place * M_PI) * 10 + (GLCadencer1->CurrentTime * 20); float Scale = (float)Sin(Place * M_PI) / 2; y = y + Sin(Spin) * Scale; x = x + Cos(Spin) * Scale; } } //--------------------------------------------------------------------------- void __fastcall TfrmMain::GLHeightField2GetHeight(const float x, const float y, float &z, TGLColorVector &Color, TTexPoint &TexPoint) { z = 2; } //---------------------------------------------------------------------------