/
ArtemSls
/
O3DM
Обзор
Документация
Войти
/
ArtemSls
/
O3DM
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
patch
fBrownianMotion.cpp
143 строки
3 KB
ArtemSls
Lab5
24 янв 2025, 01:52
24 янв 2025, 01:52
60fb638
Код
Авторство
О чём код?
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "fBrownianMotion.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "GLS.BaseClasses" #pragma link "GLS.Cadencer" #pragma link "GLS.Scene" #pragma link "GLS.SceneViewer" #pragma link "GLS.Coordinates" #pragma link "GLS.Graph" #pragma link "GLS.Objects" #pragma link "GLS.SimpleNavigation" #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __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 = (double)TrackBar1->Position / 10; 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.445) { dx = m * rand() / RAND_MAX / d; dx = dx * (-1.0); } if(GLSphere1->Position->X < -0.445) { dx = m * rand() / RAND_MAX / d; } if(GLSphere1->Position->Y > 0.445) { dy = m * rand() / RAND_MAX / d; dy = dy * (-1.0); } if(GLSphere1->Position->Y < -0.445) { dy = m * rand() / RAND_MAX / d; } if(GLSphere1->Position->Z > 0.445) { dz = m * rand() / RAND_MAX / d; dz = dz * (-1.0); } if (GLSphere1->Position->Z < -0.445) { 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 = (double)TrackBar1->Position / 10; 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, TGLColorVector &Color, TTexPoint &TexPoint) { z = 1 / (1 + VectorNorm(GLSphere1->Position->X - x, GLSphere1->Position->Y - y)) * GLSphere1->Position->Z + 0.5; } //--------------------------------------------------------------------------- void __fastcall TForm1::CheckBox1Click(TObject *Sender) { GLHeightField1->Visible = CheckBox1->Checked; } //---------------------------------------------------------------------------