/
Frogush
/
LabVR
Обзор
Документация
Войти
/
Frogush
/
LabVR
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
4/Unit2.pas
83 строки
3 KB
Frogush
upload files
08 дек 2025, 21:09
08 дек 2025, 21:09
f125003
Код
Авторство
О чём код?
unit Unit2; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Menus, GLS.Objects, GLS.SpaceText, GLS.Scene, GLS.GeomObjects, GLS.Coordinates, Vcl.ExtCtrls, GLS.Cadencer, GLS.SceneViewer, GLS.BaseClasses, Math; type TForm2 = class(TForm) GLScene1: TGLScene; GLSceneViewer1: TGLSceneViewer; GLCadencer1: TGLCadencer; Timer1: TTimer; OpenDialog1: TOpenDialog; MainMenu1: TMainMenu; GLCamera1: TGLCamera; GLLightSource1: TGLLightSource; GLTeapot1: TGLTeapot; GLSpaceText1: TGLSpaceText; GLSphere1: TGLSphere; N1: TMenuItem; N2: TMenuItem; procedure N2Click(Sender: TObject); procedure FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); private { Private declarations } public { Public declarations } end; var Form2: TForm2; implementation {$R *.dfm} procedure TForm2.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin // �������� �� ��� X (�����-������) if Key = 37 then GLTeapot1.Position.X := GLTeapot1.Position.X - 0.5; // Left if Key = 39 then GLTeapot1.Position.X := GLTeapot1.Position.X + 0.5; // Right // �������� �� ��� Y (�����-����) if Key = 38 then GLTeapot1.Position.Y := GLTeapot1.Position.Y + 0.5; // Up if Key = 40 then GLTeapot1.Position.Y := GLTeapot1.Position.Y - 0.5; // Down // �������� �� ��� Z (������) - PageUp / PageDown if Key = 33 then GLTeapot1.Position.Z := GLTeapot1.Position.Z + 0.5; // PgUp if Key = 34 then GLTeapot1.Position.Z := GLTeapot1.Position.Z - 0.5; // PgDn end; procedure TForm2.FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); begin // ������ ��������� ������ (���) // Power(1.1, ...) �������� 1.1 � ������� ��� ��������� GLCamera1.AdjustDistanceToTarget(Power(1.1, -WheelDelta / 120)); Handled := True; // ��������, ��� �� ���������� ��������� end; procedure TForm2.N2Click(Sender: TObject); begin if OpenDialog1.Execute then begin // ��������� �������� �� ������ GLTeapot1.Material.Texture.Image.LoadFromFile(OpenDialog1.FileName); // ��������� �� �� �������� �� ����� (���. ������) GLSphere1.Material.Texture.Image.LoadFromFile(OpenDialog1.FileName); // ����������� �������� ��������, ���� ��� ���� ��������� GLTeapot1.Material.Texture.Disabled := False; GLSphere1.Material.Texture.Disabled := False; end; end; end.