/
Pyatigor_Yaroslav
/
KMiVVR
Обзор
Документация
Войти
/
Pyatigor_Yaroslav
/
KMiVVR
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Lab8/fEffectsFLAG.cpp
284 строки
9 KB
Пятигор2302
upload files
15 дек 2025, 19:14
15 дек 2025, 19:14
8013f57
Код
Авторство
О чём код?
//--------------------------------------------------------------------------- #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" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(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; GLTree1->BranchNoise = 0.5; GLTree1->BranchRadius = 0.1; } //--------------------------------------------------------------------------- void __fastcall TForm1::GLSceneViewer1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { mx = X; my = Y; } //--------------------------------------------------------------------------- void __fastcall TForm1::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 TForm1::GLSceneViewer1MouseWheel(TObject *Sender, TShiftState Shift, int WheelDelta, TPoint &MousePos, bool &Handled) { GLCamera1->AdjustDistanceToTarget(Power(1.1, -WheelDelta / 120)); } //--------------------------------------------------------------------------- void __fastcall TForm1::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 TForm1::TrackBar1Change(TObject *Sender) { if (RadioButton1->Checked) { GLFireFXManager1->FireDir->X = TrackBar1->Position * 0.1; } if (RadioButton2->Checked) { GLThorFXManager1->GlowSize = (float)TrackBar1->Position / 50; } } //--------------------------------------------------------------------------- void __fastcall TForm1::Timer1Timer(TObject *Sender) { Form1->Caption = "Lab8 Fire, lightning and atmosphere glow effects Andrusenko - " + GLSceneViewer1->FramesPerSecondText(); if (i_f < GLTree1->Count && RadioButton1->Checked) { GLTree1->Children[i_f]->Visible = true; i_f++; } } //--------------------------------------------------------------------------- void __fastcall TForm1::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 = "Wind:"; TrackBar1->Visible = true; TrackBar1->Max = 20; TrackBar1->Min = -20; TrackBar1->Position = 0; GLFireFXManager1->Disabled = false; GLFireFXManager1->FireCrown = 0.5; GLFireFXManager1->FireDir->Y = 0.2; GLFireFXManager1->InitialDir->X = 0; GLFireFXManager1->InitialDir->Y = 1; GLFireFXManager1->InitialDir->Z = 0; GLHUDText1->Visible = true; } if (RadioButton2->Checked) { GLCamera1->TargetObject = GLDummyCube2; GLDummyCube2->Visible = true; Label2->Visible = true; Label2->Caption = "Glow Size:"; 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; GLThorFXManager1->OuterColor->Color = clrGreen; GLThorFXManager1->InnerColor->Color = clrWhite; CheckBox2Click(Sender); } if (RadioButton3->Checked) { GLLightSource1->Position->X = 30; GLCamera1->TargetObject = GLDummyCube3; GLDummyCube3->Visible = true; } } //--------------------------------------------------------------------------- void __fastcall TForm1::TrackBar2Change(TObject *Sender) { GLThorFXManager1->InnerColor->Alpha = (float)TrackBar2->Position / 50; } //--------------------------------------------------------------------------- void __fastcall TForm1::TrackBar3Change(TObject *Sender) { GLThorFXManager1->Wildness = (float)TrackBar3->Position / 5; } //--------------------------------------------------------------------------- void __fastcall TForm1::TrackBar4Change(TObject *Sender) { GLThorFXManager1->Vibrate = (float)TrackBar4->Position / 10; } //--------------------------------------------------------------------------- void __fastcall TForm1::CheckBox1Click(TObject *Sender) { GLThorFXManager1->Core = CheckBox1->Checked; } //--------------------------------------------------------------------------- void __fastcall TForm1::CheckBox2Click(TObject *Sender) { GLThorFXManager1->Disabled = CheckBox2->Checked; } //--------------------------------------------------------------------------- void __fastcall TForm1::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 * 12) + (GLCadencer1->CurrentTime * 25); float Radius = 0.2f; float Offset = 0.1f; // ��� ������������� ������� if (PointNo % 2 == 0) { x = x + Cos(Spin) * Radius + Offset; z = z + Sin(Spin) * Radius; } else { x = x + Cos(Spin + M_PI) * Radius - Offset; z = z + Sin(Spin + M_PI) * Radius; } } } //--------------------------------------------------------------------------- void __fastcall TForm1::GLHeightField2GetHeight(const float x, const float y, float &z, TGLColorVector &Color, TTexPoint &TexPoint) { z = 2; } //---------------------------------------------------------------------------