Наши проекты:
Журнал · Discuz!ML · Wiki · DRKB · Помощь проекту |
||
ПРАВИЛА | FAQ | Помощь | Поиск | Участники | Календарь | Избранное | RSS |
[18.117.196.217] |
|
Сообщ.
#1
,
|
|
|
Добрый день! Подскажите, как в C++ заставить камеру двигаться и переключаться от одного объекта к другому по нажатии клавиш в C++ Builder? Библиотека GLKeyboard подключена в обоих файлах, проект собрался, но почему-то клавиатуру "не видит". Работаю в RAD Studio 10.3 и GLScene 1.8.
CPP-файл: #include <vcl.h> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "GLBaseClasses" #pragma link "GLCoordinates" #pragma link "GLCrossPlatform" #pragma link "GLObjects" #pragma link "GLScene" #pragma link "GLWin32Viewer" #pragma link "GLCadencer" #pragma link "GLKeyboard" #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::GoToTheCube1Click(TObject *Sender) { GLSceneViewer1->Camera=GLCamera1; } //--------------------------------------------------------------------------- void __fastcall TForm1::GoToTheSphere1Click(TObject *Sender) { GLSceneViewer1->Camera=GLCamera2; } //--------------------------------------------------------------------------- void __fastcall TForm1::NotFocus1Click(TObject *Sender) { GLSceneViewer1->Camera=NULL; } //--------------------------------------------------------------------------- void __fastcall TForm1::NotFocus2Click(TObject *Sender) { GLSceneViewer1->Camera=NULL; } //--------------------------------------------------------------------------- void __fastcall TForm1::GLCadencer1Progress(TObject *Sender, const double deltaTime, const double newTime) { GLCube1->Turn(deltaTime*10); GLSphere1->Turn(deltaTime*10); //Движение вперед по клавишам ‘ц’ и’ w’ if (IsKeyDown('ц') || IsKeyDown('w')) GLSceneViewer1->Camera->Move(2* deltaTime); //Движение назад по клавишам ‘ы’ и ‘s’ if (IsKeyDown('ы') || IsKeyDown('s')) GLSceneViewer1->Camera->Move(-2* deltaTime); //Поворот влево по клавишам ‘ф’ и’ a’ if (IsKeyDown('ф') || IsKeyDown('a')) GLSceneViewer1->Camera->Slide(-2* deltaTime); //Поворот вправо по клавишам ‘в’ и ‘d’ if (IsKeyDown('в') || IsKeyDown('d')) GLSceneViewer1->Camera->Slide(2* deltaTime); //Движение вверх по клавишам ‘u’ и ‘г’ if (IsKeyDown('u') || IsKeyDown('г')) GLSceneViewer1->Camera->Lift(0.01); //Движение вниз по клавишам ‘n’ и ‘т’ if (IsKeyDown('n') || IsKeyDown('т')) GLSceneViewer1->Camera->Lift(-0.01); if (IsKeyDown('c') || IsKeyDown('с')) GLSceneViewer1->Camera=GLCamera1; if (IsKeyDown('v') || IsKeyDown('м')) GLSceneViewer1->Camera=GLCamera2; if (IsKeyDown('b') || IsKeyDown('и')) GLSceneViewer1->Camera=NULL; } H-файл: #ifndef Unit1H #define Unit1H //--------------------------------------------------------------------------- #include <System.Classes.hpp> #include <Vcl.Controls.hpp> #include <Vcl.StdCtrls.hpp> #include <Vcl.Forms.hpp> #include "GLBaseClasses.hpp" #include "GLCoordinates.hpp" #include "GLCrossPlatform.hpp" #include "GLObjects.hpp" #include "GLScene.hpp" #include "GLWin32Viewer.hpp" #include "GLKeyboard.hpp" #include "Math.hpp" #include <Vcl.Menus.hpp> #include "GLCadencer.hpp" //--------------------------------------------------------------------------- class TForm1 : public TForm { __published: // IDE-managed Components TGLScene *GLScene1; TGLSceneViewer *GLSceneViewer1; TGLCamera *GLCamera1; TGLCube *GLCube1; TGLSphere *GLSphere1; TGLCamera *GLCamera2; TGLLightSource *GLLightSource1; TGLLightSource *GLLightSource2; TMainMenu *MainMenu1; TMenuItem *Cube1; TMenuItem *Sphere1; TMenuItem *GoToTheCube1; TMenuItem *NotFocus1; TMenuItem *GoToTheSphere1; TMenuItem *NotFocus2; TGLCadencer *GLCadencer1; void __fastcall GoToTheCube1Click(TObject *Sender); void __fastcall GoToTheSphere1Click(TObject *Sender); void __fastcall NotFocus1Click(TObject *Sender); void __fastcall NotFocus2Click(TObject *Sender); void __fastcall GLCadencer1Progress(TObject *Sender, const double deltaTime, const double newTime); private: // User declarations public: // User declarations __fastcall TForm1(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE TForm1 *Form1; //--------------------------------------------------------------------------- #endif |