/
Fuv
/
KMiVVR
Обзор
Документация
Войти
/
Fuv
/
KMiVVR
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
L2/Unit1.cpp
81 строка
3 KB
Fuv
upload files
24 дек 2025, 18:08
24 дек 2025, 18:08
23d3544
Код
Авторство
О чём код?
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "GLS.BaseClasses" #pragma link "GLS.Coordinates" #pragma link "GLS.Objects" #pragma link "GLS.Scene" #pragma link "GLS.SceneViewer" #pragma link "GLS.GeomObjects" #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { GLCone1->Material->PolygonMode = pmLines; TGLPoints* P[1000]; for (int i = 0; i < 1000; i++) { P[i] = new TGLPoints(GLCube1); P[i]->Colors->Add(((float)(rand() % 256)) / 256.0, ((float)(rand() % 256)) / 256.0, ((float)(rand() % 256)) / 256.0, 0.5); P[i]->Size = 3; P[i]->Position->X = 1.0 * rand() / RAND_MAX - 0.5; P[i]->Position->Y = 1.0 * rand() / RAND_MAX - 0.5; P[i]->Position->Z = 1.0 * rand() / RAND_MAX - 0.5; } TGLPoints* R[1000]; for (int i = 0; i < 1000; i++) { R[i] = new TGLPoints(GLCone1); R[i]->Colors->Add(((float)(rand() % 256)) / 256.0, ((float)(rand() % 256)) / 256.0, ((float)(rand() % 256)) / 256.0, 0.5); R[i]->Size = 3; R[i]->Position->Y = 1.0 * rand() / RAND_MAX; float max_radius = 0.5 * (1.0 - R[i]->Position->Y); float angle = 2.0 * M_PI * rand() / RAND_MAX; float random_val = (float)rand() / RAND_MAX; float radius = max_radius * sqrt(random_val); R[i]->Position->X = radius * cos(angle); R[i]->Position->Z = radius * sin(angle); R[i]->Position->Y = R[i]->Position->Y - 0.5; } } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { GLSceneViewer1->Camera = GLCamera1; } //--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) { GLSceneViewer1->Camera = GLCamera2; } //--------------------------------------------------------------------------- void __fastcall TForm1::Button3Click(TObject *Sender) { GLSceneViewer1->Camera = GLCamera3; } //--------------------------------------------------------------------------- void __fastcall TForm1::GLSceneViewer1MouseWheel(TObject *Sender, TShiftState Shift, int WheelDelta, TPoint &MousePos, bool &Handled) { if (GLSceneViewer1->MouseInControl == true) { if (GLSceneViewer1->Camera == GLCamera1) GLCamera1->AdjustDistanceToTarget(Power(1.1, -WheelDelta / 120)); else if (GLSceneViewer1->Camera == GLCamera2) GLCamera2->AdjustDistanceToTarget(Power(1.1, -WheelDelta / 120)); else if (GLSceneViewer1->Camera == GLCamera3) GLCamera3->AdjustDistanceToTarget(Power(1.1, -WheelDelta / 120)); } } //---------------------------------------------------------------------------