/
ArtemSls
/
O3DM
Обзор
Документация
Войти
/
ArtemSls
/
O3DM
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
FormUnit_L4.cpp
158 строк
5 KB
ArtemSls
Lab4
24 янв 2025, 01:51
24 янв 2025, 01:51
7c68f0c
Код
Авторство
О чём код?
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "FormUnit_L4.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "GLS.Graph" #pragma link "GLS.Objects" #pragma link "GLS.Scene" #pragma link "GLS.SceneViewer" #pragma link "GLS.BaseClasses" #pragma link "GLS.Coordinates" #pragma resource "*.dfm" TForm_L4* Form_L4; //--------------------------------------------------------------------------- __fastcall TForm_L4::TForm_L4(TComponent* Owner) : TForm(Owner) {} //--------------------------------------------------------------------------- void __fastcall TForm_L4::Formula0(const float x, const float y, float &z, TVector4f &color, TTexPoint &texPoint) { // 0ro formula z = VectorNorm(x, y); z = x * y; VectorLerp(clrBlue, clrRed, (z + 1) / 2, color); } //--------------------------------------------------------------------------- void __fastcall TForm_L4::Formula1(const float x, const float y, float &z, TVector4f &color, TTexPoint &texPoint) { // 1st formula z = VectorNorm(x, y); z = x * y * z; VectorLerp(clrBlue, clrRed, (z + 1) / 2, color); } //--------------------------------------------------------------------------- void __fastcall TForm_L4::Formula2(const float x, const float y, float &z, TVector4f &color, TTexPoint &texPoint) { // 2nd formula z = VectorNorm(x, y); z = sin(z * 12) / (2 * (z * 6.28 + 1)); VectorLerp(clrBlue, clrRed, (z + 1) / 2, color); } //--------------------------------------------------------------------------- void __fastcall TForm_L4::Formula3(const float x, const float y, float &z, TVector4f &color, TTexPoint &texPoint) { // 3rd formula 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 TForm_L4::FormCreate(TObject* Sender) { rgFormulaClick(Sender); } //--------------------------------------------------------------------------- void __fastcall TForm_L4::TrackBarYChange(TObject* Sender) { XYGrid->ZSamplingScale->Origin = -((float)TrackBarY->Position / 10); } //--------------------------------------------------------------------------- void __fastcall TForm_L4::TrackBarXChange(TObject* Sender) { XZGrid->YSamplingScale->Origin = -((float)TrackBarX->Position / 10); } //--------------------------------------------------------------------------- void __fastcall TForm_L4::TrackBarZChange(TObject* Sender) { YZGrid->XSamplingScale->Origin = -((float)TrackBarZ->Position / 10); } //--------------------------------------------------------------------------- void __fastcall TForm_L4::ViewerMouseDown( TObject* Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { mx = X; my = Y; } //--------------------------------------------------------------------------- void __fastcall TForm_L4::ViewerMouseMove( TObject* Sender, TShiftState Shift, int X, int Y) { if (Shift.Contains(ssLeft)) Camera->MoveAroundTarget(my - Y, mx - X); else if (Shift.Contains(ssRight)) Camera->RotateTarget(my - Y, mx - X, 0); mx = X; my = Y; } //--------------------------------------------------------------------------- void __fastcall TForm_L4::FormMouseWheel(TObject* Sender, TShiftState Shift, int WheelDelta, TPoint &MousePos, bool &Handled) { Camera->AdjustDistanceToTarget(Power(1.1, (WheelDelta / 120.0))); } //--------------------------------------------------------------------------- void __fastcall TForm_L4::rgFormulaClick(TObject *Sender) { switch (rgFormula->ItemIndex) { case 0: HeightField->OnGetHeight = Formula0; break; case 1: HeightField->OnGetHeight = Formula1; break; case 2: HeightField->OnGetHeight = Formula2; break; case 3: HeightField->OnGetHeight = Formula3; break; default:; } } //--------------------------------------------------------------------------- void __fastcall TForm_L4::rgPolygonModeClick(TObject* Sender) { switch (rgPolygonMode->ItemIndex) { case 0: HeightField->Material->PolygonMode = pmFill; break; case 1: HeightField->Material->PolygonMode = pmLines; break; case 2: HeightField->Material->PolygonMode = pmPoints; break; default:; } HeightField->StructureChanged(); } //---------------------------------------------------------------------------