/
Alexandr_mamonov
/
lab
Обзор
Документация
Войти
/
Alexandr_mamonov
/
lab
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Lab4_SolarSys_FMX/fcSolarsys.cpp
86 строк
3 KB
Александр Мамонов
Add visualization lab projects
11 май 2026, 20:15
11 май 2026, 20:15
e92b10e
Код
Авторство
О чём код?
#include <fmx.h> #include <System.IOUtils.hpp> #pragma hdrstop #include "fcSolarsys.h" #pragma package(smart_init) #pragma resource "*.fmx" TFormSolarsys *FormSolarsys; //----------------------------------------------------------------------------- void __fastcall TFormSolarsys::FormCreate(TObject *Sender) { Caption = "��������� ������� - ������ � �����"; OpenDialog1->Filter = "�����������|*.jpg;*.jpeg;*.png;*.bmp"; String defaultEarthTexture = "earth_texture.jpg"; if (FileExists(defaultEarthTexture)) { TextureMaterialEarth->Texture->LoadFromFile(defaultEarthTexture); } String defaultSunTexture = "sun_texture.jpg"; if (FileExists(defaultSunTexture)) { TextureMaterialSource1->Texture->LoadFromFile(defaultSunTexture); } } //----------------------------------------------------------------------------- __fastcall TFormSolarsys::TFormSolarsys(TComponent* Owner) : TForm(Owner) { AnimationsRunning = true; } void __fastcall TFormSolarsys::LoadEarthTextureClick(TObject *Sender) { if (OpenDialog1->Execute()) { try { TextureMaterialEarth->Texture->LoadFromFile(OpenDialog1->FileName); } catch (Exception &e) { ShowMessage("������ �������� ��������: " + e.Message); } } } //----------------------------------------------------------------------------- void __fastcall TFormSolarsys::LoadSunTextureClick(TObject *Sender) { if (OpenDialog1->Execute()) { try { TTextureMaterialSource *tempMaterial = new TTextureMaterialSource(this); tempMaterial->Texture->LoadFromFile(OpenDialog1->FileName); SphereSun->MaterialSource = tempMaterial; } catch (Exception &e) { ShowMessage("������ �������� ��������: " + e.Message); } } } //----------------------------------------------------------------------------- void __fastcall TFormSolarsys::ToggleAnimationClick(TObject *Sender) { AnimationsRunning = !AnimationsRunning; FloatAnimationSun->Enabled = AnimationsRunning; FloatAnimationEarth->Enabled = AnimationsRunning; FloatAnimationOrbit->Enabled = AnimationsRunning; if (AnimationsRunning) { ToggleAnimation->Text = "���������� ��������"; } else { ToggleAnimation->Text = "��������� ��������"; } } //----------------------------------------------------------------------------- void __fastcall TFormSolarsys::Viewport3D1MouseWheel(TObject *Sender, TShiftState Shift, int WheelDelta, bool &Handled) { float scale = 1.0f + (WheelDelta / 1200.0f); Camera1->Position->Z = Camera1->Position->Z * scale; Handled = true; } //---------------------------------------------------------------------------