-
Notifications
You must be signed in to change notification settings - Fork 2
/
urho3dwidget.h
56 lines (46 loc) · 1.31 KB
/
urho3dwidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef URHO3DWIDGET_H
#define URHO3DWIDGET_H
#include <Urho3D/Container/Ptr.h>
#include <Urho3D/Core/Object.h>
#include <Urho3D/Engine/Engine.h>
#include <Urho3D/Graphics/Camera.h>
#include <Urho3D/Scene/Scene.h>
#include <Urho3d/Core/Context.h>
#include <QWidget>
#include <Urho3D/Container/HashMap.h>
#include <Urho3D/Math/StringHash.h>
class Urho3dWidget : public QWidget, public Urho3D::Object {
Q_OBJECT
URHO3D_OBJECT(Urho3dWidget, Urho3D::Object)
public:
explicit Urho3dWidget(Urho3D::Context* context, QWidget* parent = nullptr);
~Urho3dWidget();
void Start();
void Stop();
void Setup();
Q_SIGNALS:
public Q_SLOTS:
protected:
void closeEvent(QCloseEvent* e);
void timerEvent(QTimerEvent* e);
void resizeEvent(QResizeEvent* e);
void keyPressEvent(QKeyEvent* e);
private:
void HandleUpdate(Urho3D::StringHash eventType,
Urho3D::VariantMap& eventData);
void createScene();
void setupViewport();
void MoveCamera();
Urho3D::SharedPtr<Urho3D::Engine> engine_;
Urho3D::SharedPtr<Urho3D::Scene> scene_;
Urho3D::SharedPtr<Urho3D::Node> cameraNode_;
/// Camera yaw angle.
float yaw_;
/// Camera pitch angle.
float pitch_;
int timerId;
float timeStep = 1;
// Movement speed as world units per second
const float MOVE_SPEED = 40.0f;
};
#endif // URHO3DWIDGET_H