/
MikeLight
/
Lab
Обзор
Документация
Войти
/
MikeLight
/
Lab
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Lab13/fxVR.cpp
75 строк
2 KB
MikeLight
upload files
18 дек 2025, 14:45
18 дек 2025, 14:45
385fc10
Код
Авторство
О чём код?
//--------------------------------------------------------------------------- #include <fmx.h> #pragma hdrstop #include "fxVR.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "GBE.Cubemap" #pragma resource "*.fmx" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { Viewport3D1->Expand = 0.25; Viewport3D1->Stereo = true; } //--------------------------------------------------------------------------- void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key, System::WideChar &KeyChar, TShiftState Shift) { if (KeyChar == 'W' || KeyChar == 'w') { Dummy2->Position->Z = Dummy2->Position->Z - 0.5; } if (KeyChar == 'S' || KeyChar == 's') { Dummy2->Position->Z = Dummy2->Position->Z + 0.5; } if (KeyChar == 'D' || KeyChar == 'd') { Dummy2->Position->X = Dummy2->Position->X - 0.5; } if (KeyChar == 'A' || KeyChar == 'a') { Dummy2->Position->X = Dummy2->Position->X + 0.5; } if (KeyChar == ' ') { Grid3D1->ZWrite = !Grid3D1->ZWrite; } } //--------------------------------------------------------------------------- void __fastcall TForm1::Viewport3D1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, float X, float Y) { mx = X; my = Y; } //--------------------------------------------------------------------------- void __fastcall TForm1::Viewport3D1MouseMove(TObject *Sender, TShiftState Shift, float X, float Y) { if (Shift.Contains(ssLeft)) { Dummy2->RotationAngle->Y += mx - X; Dummy1->RotationAngle->X += -(my - Y); } mx = X; my = Y; } //--------------------------------------------------------------------------- void __fastcall TForm1::Viewport3D1MouseWheel(TObject *Sender, TShiftState Shift, int WheelDelta, bool &Handled) { Dummy2->Position->Y += -WheelDelta * 2.5 / 120; Dummy2->Position->Z += -WheelDelta * 2.5 / 120; } //---------------------------------------------------------------------------