/
Pyatigor_Yaroslav
/
KMiVVR
Обзор
Документация
Войти
/
Pyatigor_Yaroslav
/
KMiVVR
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Lab4/fFxy.cpp
184 строки
6 KB
Пятигор2302
upload files
01 дек 2025, 12:44
01 дек 2025, 12:44
eb60597
Код
Авторство
О чём код?
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "fFxy.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "GLS.BaseClasses" #pragma link "GLS.Coordinates" #pragma link "GLS.Graph" #pragma link "GLS.Objects" #pragma link "GLS.Scene" #pragma link "GLS.SceneViewer" #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Formula0(const float x, const float y, float &z, TVector4f &color, TTexPoint &texPoint) { z = VectorNorm(x, y); z = x * y; VectorLerp(clrBlue, clrRed, (z + 1) / 2, color); } //--------------------------------------------------------------------------- void __fastcall TForm1::Formula1(const float x, const float y, float &z, TVector4f &color, TTexPoint &texPoint) { z = VectorNorm(x, y); z = x * y * z; VectorLerp(clrBlue, clrRed, (z + 1) / 2, color); } //--------------------------------------------------------------------------- void __fastcall TForm1::Formula2(const float x, const float y, float &z, TVector4f &color, TTexPoint &texPoint) { z = VectorNorm(x, y); z = sin(z * 12) / (2 * (z * 6.28 + 1)); VectorLerp(clrBlue, clrRed, (z + 1) / 2, color); } //--------------------------------------------------------------------------- void __fastcall TForm1::Formula3(const float x, const float y, float &z, TVector4f &color, TTexPoint &texPoint) { z = VectorNorm(x, y); z = (pow(x, 2) + pow(y, 2)) * sin(8 * atan2(x, y)); VectorLerp(clrBlue, clrRed, (z + 1) / 2, color); } //--------------------------------------------------------------------------- void __fastcall TForm1::Formula4(const float x, const float y, float &z, TVector4f &color, TTexPoint &texPoint) { z = VectorNorm(x, y); z = sin(x * 5) * cos(y * 5); VectorLerp(clrBlue, clrRed, (z + 1) / 2, color); } //--------------------------------------------------------------------------- void __fastcall TForm1::Formula5(const float x, const float y, float &z, TVector4f &color, TTexPoint &texPoint) { z = VectorNorm(x, y); z = exp(-z * 2) * sin(z * 20); VectorLerp(clrBlue, clrRed, (z + 1) / 2, color); } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { RadioGroup1Click(Sender); } //--------------------------------------------------------------------------- void __fastcall TForm1::RadioGroup1Click(TObject *Sender) { switch (RadioGroup1->ItemIndex) { case 0: GLHeightField1->OnGetHeight = Formula0; break; case 1: GLHeightField1->OnGetHeight = Formula1; break; case 2: GLHeightField1->OnGetHeight = Formula2; break; case 3: GLHeightField1->OnGetHeight = Formula3; break; case 4: GLHeightField1->OnGetHeight = Formula4; break; case 5: GLHeightField1->OnGetHeight = Formula5; break; default:; } } //--------------------------------------------------------------------------- void __fastcall TForm1::RadioGroup2Click(TObject *Sender) { switch (RadioGroup2->ItemIndex) { case 0: GLHeightField1->Material->PolygonMode = pmFill; break; case 1: GLHeightField1->Material->PolygonMode = pmLines; break; case 2: GLHeightField1->Material->PolygonMode = pmPoints; break; default:; } GLHeightField1->StructureChanged(); } //--------------------------------------------------------------------------- void __fastcall TForm1::CheckBox1Click(TObject *Sender) { if (CheckBox1->Checked) { GLXYZGrid1->ZSamplingScale->Origin = 0; GLXYZGrid2->YSamplingScale->Origin = 0; GLXYZGrid3->XSamplingScale->Origin = 0; } else { GLXYZGrid1->ZSamplingScale->Origin = -1; GLXYZGrid2->YSamplingScale->Origin = -1; GLXYZGrid3->XSamplingScale->Origin = -1; } } //--------------------------------------------------------------------------- void __fastcall TForm1::TrackBar1Change(TObject *Sender) { GLXYZGrid1->ZSamplingScale->Origin = -((float)TrackBar1->Position / 10); } //--------------------------------------------------------------------------- void __fastcall TForm1::TrackBar2Change(TObject *Sender) { GLXYZGrid2->YSamplingScale->Origin = -((float)TrackBar2->Position / 10); } //--------------------------------------------------------------------------- void __fastcall TForm1::TrackBar3Change(TObject *Sender) { GLXYZGrid3->XSamplingScale->Origin = -((float)TrackBar3->Position / 10); } //--------------------------------------------------------------------------- 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.0))); } //---------------------------------------------------------------------------