/
daryadevx
/
KMiVVR
Обзор
Документация
Войти
/
daryadevx
/
KMiVVR
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Lab5/fBall.cpp
126 строк
4 KB
daryadevx
fix
24 дек 2024, 21:14
24 дек 2024, 21:14
5d0eeb2
Код
Авторство
О чём код?
//--------------------------------------------------------------------------- #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) { z = 1 / (1 + VectorNorm( GLSphere1->Position->X - x, GLSphere1->Position->Y - y)) * GLSphere1->Position->Z + 0.5; } //--------------------------------------------------------------------------- void __fastcall TForm1::GLCadencer1Progress( TObject* Sender, const double deltaTime, const double newTime) { GLHeightField1->Visible = true; } //---------------------------------------------------------------------------