/
Ivanoff
/
KMiVVR
Обзор
Документация
Войти
/
Ivanoff
/
KMiVVR
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
5/fFxy.cpp
156 строк
5 KB
ivanoff
lab
20 дек 2024, 10:14
20 дек 2024, 10:14
f5dd62a
Код
Авторство
О чём код?
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "fFxy.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" TFormFxy *FormFxy; //--------------------------------------------------------------------------- __fastcall TFormFxy::TFormFxy(TComponent * Owner):TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TFormFxy::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 TFormFxy::Formula1(const float x, const float y, float &z, TVector4f &color, TTexPoint &texPoint) { // 1st formula z = VectorNorm(x, y); z = x*y*z; // z = (x*x)*(y*y); VectorLerp(clrBlue, clrRed, (z+1)/2, color); } //--------------------------------------------------------------------------- void __fastcall TFormFxy::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 TFormFxy::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 TFormFxy::CheckBox1Click(TObject * Sender) { if(CheckBox1->Checked) { XZGrid->YSamplingScale->Origin = 0; YZGrid->XSamplingScale->Origin = 0; XYGrid->ZSamplingScale->Origin = 0; } else { XZGrid->YSamplingScale->Origin = -1; YZGrid->XSamplingScale->Origin = -1; XYGrid->ZSamplingScale->Origin = -1; } } //--------------------------------------------------------------------------- void __fastcall TFormFxy::TrackBar1Change(TObject * Sender) { XYGrid->ZSamplingScale->Origin = -((float)TrackBar1->Position / 10); } //--------------------------------------------------------------------------- void __fastcall TFormFxy::TrackBar2Change(TObject *Sender) { XZGrid->YSamplingScale->Origin = -((float)TrackBar2->Position / 10); } //--------------------------------------------------------------------------- void __fastcall TFormFxy::TrackBar3Change(TObject *Sender) { YZGrid->XSamplingScale->Origin = -((float)TrackBar3->Position / 10); } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- void __fastcall TFormFxy::GLSceneViewer1MouseDown(TObject * Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { mx = X; my = Y; } //--------------------------------------------------------------------------- void __fastcall TFormFxy::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 TFormFxy::FormMouseWheel(TObject *Sender, TShiftState Shift, int WheelDelta, TPoint &MousePos, bool &Handled) { GLCamera1-> AdjustDistanceToTarget(Power(1.1, (WheelDelta / 120.0))); } //--------------------------------------------------------------------------- void __fastcall TFormFxy::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; default: ; } } //--------------------------------------------------------------------------- void __fastcall TFormFxy::FormCreate(TObject *Sender) { RadioGroup1Click(Sender); } //---------------------------------------------------------------------------