/
Reznik
/
VRLabs
Обзор
Документация
Войти
/
Reznik
/
VRLabs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
Lab4/fcGlobus.cpp
170 строк
6 KB
Reznik
Мои лабы
10 май 2026, 18:49
10 май 2026, 18:49
c5dfe83
Код
Авторство
О чём код?
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "fcGlobus.h" #include <Vcl.Imaging.jpeg.hpp> #include "GLS.Material.hpp" #include "GLS.Color.hpp" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "GLS.BaseClasses" #pragma link "GLS.Coordinates" #pragma link "GLS.Objects" #pragma link "GLS.Scene" #pragma link "GLS.SceneViewer" #pragma link "GLS.SimpleNavigation" #pragma link "GLS.GeomObjects" #pragma link "GLS.Material" #pragma link "GLS.Cadencer" #pragma resource "*.dfm" TFormGlobe *FormGlobe; //--------------------------------------------------------------------------- __fastcall TFormGlobe::TFormGlobe(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TFormGlobe::FormCreate(TObject *Sender) { // Земля sfPlanet->Material->Texture->Enabled = true; sfPlanet->Material->Texture->Image->LoadFromFile("assets\\maps\\topography.jpg"); // Сетка sfGrid->Material->Texture->Enabled = true; sfGrid->Material->Texture->Image->LoadFromFile("assets\\maps\\celestial_grid.jpg"); // Облака sfClouds->Material->Texture->Enabled = true; sfClouds->Material->Texture->Image->LoadFromFile("assets\\maps\\clouds.jpg"); sfClouds->Material->BlendingMode = bmTransparency; sfClouds->Visible = false; // **СОЛНЦЕ С ТЕКСТУРОЙ ☀️** Sun->Material->Texture->Enabled = true; Sun->Material->Texture->Image->LoadFromFile("assets\\maps\\sun.jpg"); Sun->Material->FrontProperties->Emission->Color = clrYellow; // свечение Sun->Scale->X = 4; Sun->Scale->Y = 4; Sun->Scale->Z = 4; Sun->Visible = true; // Луна Moon->Material->Texture->Enabled = true; Moon->Material->Texture->Image->LoadFromFile("assets\\maps\\moon.jpg"); Moon->Material->FrontProperties->Diffuse->Color = clrWhite; Moon->Scale->X = 0.4f; Moon->Scale->Y = 0.4f; Moon->Scale->Z = 0.4f; // ===== ПЕРЕНОСИМ ЯДРО ПОД ЗЕМЛЮ ===== // если sfCore/diskCore сейчас не под sfPlanet – перепривяжем sfCore->Parent = sfPlanet; diskCore->Parent = sfPlanet; // ставим ядро в центр Земли sfCore->Position->SetPoint(0, 0, 0); diskCore->Position->SetPoint(0, 0, 0); // чтобы не торчало снаружи sfCore->Scale->SetVector(0.6f, 0.6f, 0.6f); diskCore->OuterRadius = 0.65f; diskCore->InnerRadius = 0.65f; sfCore->Visible = false; diskCore->Visible = false; // Свет внутри Земли (для ядра) GLLightSource1->Position->SetPoint(0, 0, 1); // В центре Земли GLLightSource1->SpotCutOff = 180; // Полное освещение GLLightSource1->Diffuse->Color = clrWhite; // Свет для солнца GLLightSource2->Position->SetPoint(0, 0, 0); // в центре Солнца GLLightSource2->ConstAttenuation = 1; GLLightSource2->LinearAttenuation = 0; GLLightSource2->QuadraticAttenuation = 0.01; // небольшое затухание EarthOrbit->Position->X = 12.0f; // Земля на орбите GLCamera1->Position->Z = 35; } //--------------------------------------------------------------------------- void __fastcall TFormGlobe::TreeView1Change(TObject *Sender, TTreeNode *Node) { if (Node == nullptr) return; sfClouds->Visible = false; // СБРАСЫВАЕМ ВСЕ ОБЪЕКТЫ sfPlanet->Scale->SetVector(1,1,1); sfPlanet->Start = 0; sfPlanet->Stop = 360; sfCore->Visible = false; diskCore->Visible = false; if (Node->Text == "Топография") { sfPlanet->Material->Texture->Image->LoadFromFile("assets\\maps\\topography.jpg"); } else if (Node->Text == "Температура") { sfPlanet->Material->Texture->Image->LoadFromFile("assets\\maps\\temperature.jpg"); } else if (Node->Text == "Океанида") { sfPlanet->Material->Texture->Image->LoadFromFile("assets\\maps\\exoaqua.jpg"); } else if (Node->Text == "Ядро") { sfPlanet->Start = 0; sfPlanet->Stop = 180; sfPlanet->Material->Texture->Image->LoadFromFile("assets\\maps\\earth_east.jpg"); // ===== БОЛЬШОЕ ЯДРО БЕЗ ПРОСВЕТОВ ===== sfCore->Visible = true; sfCore->Scale->SetVector(0.6f, 0.6f, 0.6f); sfCore->Position->SetPoint(0, 0, 0); diskCore->Visible = true; diskCore->OuterRadius = 0.55f; diskCore->InnerRadius = 0.25f; diskCore->Position->SetPoint(0, 0, 0); // Светящееся ядро sfCore->Material->Texture->Enabled = false; sfCore->Material->FrontProperties->Diffuse->SetColor(1.0f, 0.3f, 0.1f, 1.0f); sfCore->Material->FrontProperties->Emission->SetColor(0.8f, 0.2f, 0.0f, 1.0f); diskCore->Material->Texture->Enabled = false; diskCore->Material->FrontProperties->Diffuse->SetColor(1.0f, 0.5f, 0.2f, 1.0f); diskCore->Material->FrontProperties->Emission->SetColor(0.6f, 0.3f, 0.0f, 1.0f); } else if (Node->Text == "Облака") { sfClouds->Visible = true; } } //--------------------------------------------------------------------------- void __fastcall TFormGlobe::GLCadencer1Progress(TObject *Sender, const double DeltaTime, const double NewTime) { // Солнце Sun->RollAngle = DegToRad(NewTime * 100); // Земля орбита float earthAngle = DegToRad(NewTime * 0.5); EarthOrbit->Position->X = 12 * cos(earthAngle); EarthOrbit->Position->Z = 12 * sin(earthAngle); // Земля вращение sfPlanet->RollAngle = DegToRad(NewTime * 200); sfClouds->RollAngle = DegToRad(NewTime * 150); // Луна орбита (вокруг Земли) float moonAngle = DegToRad(NewTime * 2); Moon->Position->X = 2.5f * cos(moonAngle); Moon->Position->Z = 2.5f * sin(moonAngle); Moon->RollAngle = DegToRad(NewTime * 300); if (sfCore->Visible) { sfCore->RollAngle = DegToRad(NewTime * 200); diskCore->RollAngle = DegToRad(NewTime * 200); } }