/
MikeLight
/
Lab
Обзор
Документация
Войти
/
MikeLight
/
Lab
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
lab3/L3_b/cL3_b.cpp
117 строк
4 KB
MikeLight
upload files
24 ноя 2025, 14:59
24 ноя 2025, 14:59
c6bafae
Код
Авторство
О чём код?
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "cL3_b.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 resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { FRotationActive = true; FRotationSpeedX = 0.0f; FRotationSpeedY = 0.0f; FRotationSpeedZ = 0.0f; FCurrentSpeed = 100.0f; CheckBoxY->Checked = true; TrackBarAlpha->Position = 1000; TrackBarSpeed->Position = 10; GLDummyCube1->Material->BlendingMode = bmTransparency; KeyPreview = true; if (CheckBoxY->Checked) FRotationSpeedY = FCurrentSpeed; } //--------------------------------------------------------------------------- void __fastcall TForm1::GLCadencer1Progress(TObject *Sender, const double DeltaTime, const double NewTime) { if (FRotationActive) { if (FRotationSpeedX != 0) GLDummyCube1->TurnAngle = GLDummyCube1->TurnAngle + FRotationSpeedX * DeltaTime; if (FRotationSpeedY != 0) GLDummyCube1->RollAngle = GLDummyCube1->RollAngle + FRotationSpeedY * DeltaTime; if (FRotationSpeedZ != 0) GLDummyCube1->PitchAngle = GLDummyCube1->PitchAngle + FRotationSpeedZ * DeltaTime; if (GLDummyCube1->TurnAngle > 360) GLDummyCube1->TurnAngle -= 360; if (GLDummyCube1->RollAngle > 360) GLDummyCube1->RollAngle -= 360; if (GLDummyCube1->PitchAngle > 360) GLDummyCube1->PitchAngle -= 360; } } //--------------------------------------------------------------------------- void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if (Key == VK_SPACE) { FRotationActive = !FRotationActive; } } //--------------------------------------------------------------------------- void __fastcall TForm1::TrackBarAlphaChange(TObject *Sender) { float alpha = (float)TrackBarAlpha->Position / 10.0f; GLPlane1->Material->FrontProperties->Diffuse->Alpha = alpha; GLPlane1->Material->BackProperties->Diffuse->Alpha = alpha; GLPlane2->Material->FrontProperties->Diffuse->Alpha = alpha; GLPlane2->Material->BackProperties->Diffuse->Alpha = alpha; GLPlane3->Material->FrontProperties->Diffuse->Alpha = alpha; GLPlane3->Material->BackProperties->Diffuse->Alpha = alpha; GLPlane4->Material->FrontProperties->Diffuse->Alpha = alpha; GLPlane4->Material->BackProperties->Diffuse->Alpha = alpha; GLPlane5->Material->FrontProperties->Diffuse->Alpha = alpha; GLPlane5->Material->BackProperties->Diffuse->Alpha = alpha; GLPlane6->Material->FrontProperties->Diffuse->Alpha = alpha; GLPlane6->Material->BackProperties->Diffuse->Alpha = alpha; } //--------------------------------------------------------------------------- void __fastcall TForm1::TrackBarSpeedChange(TObject *Sender) { FCurrentSpeed = (float)TrackBarSpeed->Position; if (CheckBoxX->Checked) FRotationSpeedX = FCurrentSpeed; if (CheckBoxY->Checked) FRotationSpeedY = FCurrentSpeed; if (CheckBoxZ->Checked) FRotationSpeedZ = FCurrentSpeed; } //--------------------------------------------------------------------------- void __fastcall TForm1::CheckBoxXClick(TObject *Sender) { FRotationSpeedX = CheckBoxX->Checked ? FCurrentSpeed : 0.0f; } //--------------------------------------------------------------------------- void __fastcall TForm1::CheckBoxYClick(TObject *Sender) { FRotationSpeedY = CheckBoxY->Checked ? FCurrentSpeed : 0.0f; } //--------------------------------------------------------------------------- void __fastcall TForm1::CheckBoxZClick(TObject *Sender) { FRotationSpeedZ = CheckBoxZ->Checked ? FCurrentSpeed : 0.0f; } //---------------------------------------------------------------------------