/
Pyatigor_Yaroslav
/
KMiVVR
Обзор
Документация
Войти
/
Pyatigor_Yaroslav
/
KMiVVR
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Lab2/fLab2.cpp
181 строка
5 KB
Пятигор2302
upload files
18 ноя 2025, 14:20
18 ноя 2025, 14:20
4981a3d
Код
Авторство
О чём код?
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "fLab2.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "GLS.BaseClasses" #pragma link "GLS.Cadencer" #pragma link "GLS.Coordinates" #pragma link "GLS.Objects" #pragma link "GLS.Scene" #pragma link "GLS.SceneViewer" #pragma link "GLS.Collision" #pragma link "GLS.GeomObjects" #pragma link "GLS.ParticleFX" #pragma link "GLS.ParticleFX" #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { for (int i = 0; i < N; i++) { mas_time[i] = 7.0 / 180 * pow(i, N - 1) - 17.0 / 24 * pow(i, N - 2) + 44.0 / 9 * pow(i, N - 3) - 383.0 / 24 * pow(i, N - 4) + 4603.0 / 180 * pow(i, N - 5) - 143.0 / 6 * i + 30; } } //--------------------------------------------------------------------------- void __fastcall TForm1::initial_time() { for (int i = 0; i < N; i++) { cur_time[i] = 0; mas_flag[i] = true; } } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { GLCadencer1->Enabled = false; int i = 0; while (i < 1000) { int m_color[] = {255, 0, 0, 255, 100, 0, 255, 255, 0, 0, 128, 0, 0, 255, 255, 0, 0, 255, 128, 0, 128}; TGLPoints *P = new TGLPoints(GLCylinder1); int col = rand() % N; P->Tag = col; P->Colors->Add(m_color[col * 3], m_color[col * 3 + 1], m_color[col * 3 + 2], 0.5); P->Size = 5; P->Position->X = 1.0 * rand() / RAND_MAX - 0.5; P->Position->Y = 1.0 * rand() / RAND_MAX - 0.5; P->Position->Z = 1.0 * rand() / RAND_MAX - 0.5; P->Style = psSmooth; double radius_xy = sqrt(pow(P->Position->X, 2) + pow(P->Position->Y, 2)); double abs_z = abs(P->Position->Z); if (radius_xy > 0.3 || abs_z > 0.25) { i++; } else { delete P; } } initial_time(); update_points(); if (CheckBox2->Checked) { GLCadencer1->Enabled = true; } } //--------------------------------------------------------------------------- void __fastcall TForm1::update_points() { for (int i = 0; i < GLCylinder1->ComponentCount; i++) { GLCylinder1->Children[i]->Visible = true; } } //--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) { GLCadencer1->Enabled = false; GLCylinder1->DeleteChildren(); GLCylinder1->Visible = !GLCylinder1->Visible; GLCylinder1->Visible = !GLCylinder1->Visible; } //--------------------------------------------------------------------------- void __fastcall TForm1::CheckBox1Click(TObject *Sender) { if (CheckBox1->Checked) { GLCylinder1->Material->FrontProperties->Diffuse->Alpha = 1000; } else { GLCylinder1->Material->FrontProperties->Diffuse->Alpha = 0; } } //--------------------------------------------------------------------------- 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) { for (int i = 0; i < N; i++) { cur_time[i]++; } for (int i = 0; i < GLCylinder1->ComponentCount; i++) { int j = GLCylinder1->Children[i]->Tag; if((cur_time[j] == mas_time[j] && mas_flag[j]) || (cur_time[j] == dead_time && !mas_flag[j])) { GLCylinder1->Children[i]->Visible = !GLCylinder1->Children[i]->Visible; } } for (int i = 0; i < N; i++) { if ((cur_time[i] == mas_time[i] && mas_flag[i]) || (cur_time[i] == dead_time && !mas_flag[i])) { cur_time[i] = 0; mas_flag[i] = !mas_flag[i]; } } } //--------------------------------------------------------------------------- void __fastcall TForm1::CheckBox2Click(TObject *Sender) { if (CheckBox2->Checked) { GLCadencer1->Enabled = true; } else { GLCadencer1->Enabled = false; } } //---------------------------------------------------------------------------