/
Frogush
/
LabVR
Обзор
Документация
Войти
/
Frogush
/
LabVR
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
lab_5/fBall.cpp
133 строки
4 KB
Frogush
upload files
08 дек 2025, 21:10
08 дек 2025, 21:10
8263c46
Код
Авторство
О чём код?
//--------------------------------------------------------------------------- #include <vcl.h> #include <stdlib.h> #include <math.h> #pragma hdrstop #include "fBall.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "GLS.Scene" #pragma link "GLS.WaterPlane" #pragma link "GLS.BaseClasses" #pragma link "GLS.Cadencer" #pragma link "GLS.Coordinates" #pragma link "GLS.Graph" #pragma link "GLS.Objects" #pragma link "GLS.SceneViewer" #pragma resource "*.dfm" TForm1* Form1; int xst, yst, zst, xdl, ydl, zdl, xx, yy, zz; double dx, dy, dz, m, d; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) {} //--------------------------------------------------------------------------- void __fastcall TForm1::GLDummyCube1Progress( TObject* Sender, const double deltaTime, const double newTime) { xst++; yst++; zst++; if (xst > xdl) { xx = rand() % 2; xdl = rand() % 1000 + 100; xst = 0; } if (yst > ydl) { yy = rand() % 2; ydl = rand() % 1000 + 100; yst = 0; } if (zst > zdl) { zz = rand() % 2; zdl = rand() % 1000 + 100; zst = 0; } if (xx == 0) { GLSphere1->TurnAngle = GLSphere1->TurnAngle + deltaTime * 50; } else { GLSphere1->TurnAngle = GLSphere1->TurnAngle - deltaTime * 50; } if (yy == 0) { GLSphere1->RollAngle = GLSphere1->RollAngle + deltaTime * 50; } else { GLSphere1->RollAngle = GLSphere1->RollAngle - deltaTime * 50; } if (zz == 0) { GLSphere1->PitchAngle = GLSphere1->PitchAngle + deltaTime * 50; } else { GLSphere1->PitchAngle = GLSphere1->PitchAngle - deltaTime * 50; } d = 100; GLSphere1->Position->X = GLSphere1->Position->X + dx; GLSphere1->Position->Y = GLSphere1->Position->Y + dy; GLSphere1->Position->Z = GLSphere1->Position->Z + dz; if (GLSphere1->Position->X > 0.5) { dx = m * rand() / RAND_MAX / d; dx = dx * (-1.0); } if (GLSphere1->Position->X < -0.5) { dx = m * rand() / RAND_MAX / d; } if (GLSphere1->Position->Y > 0.5) { dy = m * rand() / RAND_MAX / d; dy = dy * (-1.0); } if (GLSphere1->Position->Y < -0.5) { dy = m * rand() / RAND_MAX / d; } if (GLSphere1->Position->Z > 0.5) { dz = m * rand() / RAND_MAX / d; dz = dz * (-1.0); } if (GLSphere1->Position->Z < -0.5) { dz = m * rand() / RAND_MAX / d; } GLHeightField1->StructureChanged(); } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject* Sender) { xst = 0; yst = 0; zst = 0; xdl = rand() % 1000 + 100; ydl = rand() % 1000 + 100; zdl = rand() % 1000 + 100; xx = rand() % 2; yy = rand() % 2; zz = rand() % 2; m = 1.0; d = 100; dx = m * rand() / RAND_MAX / d; dy = m * rand() / RAND_MAX / d; dz = m * rand() / RAND_MAX / d; } //--------------------------------------------------------------------------- void __fastcall TForm1::GLHeightField1GetHeight(const float x, const float y, float &z, TVector4f &color, TTexPoint &texPoint) { // 1. ������� ���������� (��� � ���������) float dist = VectorNorm(GLSphere1->Position->X - x, GLSphere1->Position->Y - y); // 2. ������� ����� (sin), �� ������ � "����������" // (dist * 10.0) -> ������� ����� // (GLSphere1->Position->X * 20.0) -> ���������� ����� ������ ���������� (������) float wave = sin(dist * 10.0 + GLSphere1->Position->X * 20.0); // 3. ��������� ������ ���������: // �������� ����� �� ������ ������ (Position->Z). ����� ����� -> ����� �������. // ����� �� (1 + dist), ����� ����� �������� � ����� (��� ���� � ���������). z = (wave * GLSphere1->Position->Z) / (1.0 + dist) + 0.5; } //--------------------------------------------------------------------------- void __fastcall TForm1::GLCadencer1Progress( TObject* Sender, const double deltaTime, const double newTime) { GLHeightField1->Visible = true; } //---------------------------------------------------------------------------