SEGS  0.4.2
Super Entity Game Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MapViewerApp.h
Go to the documentation of this file.
1 /*
2  * SEGS - Super Entity Game Server
3  * http://www.segs.io/
4  * Copyright (c) 2006 - 2018 SEGS Team (see Authors.txt)
5  * This software is licensed! (See License.txt for details)
6  */
7 
8 #ifndef MAPVIEWERAPP_H
9 #define MAPVIEWERAPP_H
10 #include "Lutefisk3D/Engine/Application.h"
11 #include <unordered_map>
12 #include <memory>
13 #include <QObject>
14 
15 class SideWindow; // Qt side window
16 
17 namespace Urho3D
18 {
19  class Node;
20  class Scene;
21  class StaticModel;
22  class Vector3;
23  class Drawable;
24 }
25 
26 struct CoHSceneGraph;
27 struct CoHNode;
28 struct CoHModel;
29 
30 class MapViewerApp : public QObject, public Urho3D::Application
31 {
32  Q_OBJECT
33 public:
34  MapViewerApp(Urho3D::Context *ctx);
35  ~MapViewerApp() override;
36  // Application interface
37 public:
38  void Setup() override;
39  void Start() override;
40 public slots:
41  void loadSelectedSceneGraph(const QString &path);
42  void onDisplayNode(CoHNode *n, bool rootnode);
43  void onNodeSelected(CoHNode *n);
44 signals:
45  void cameraLocationChanged(float x,float y,float z);
46  void nodeSelected(CoHNode *def,Urho3D::Node *n);
47  void modelSelected(CoHNode *def,CoHModel *model,Urho3D::Drawable*m);
48  void scenegraphLoaded(const CoHSceneGraph &);
49 private:
50  void CreateBaseScene();
51  void SetupViewport();
52  void CreateConsoleAndDebugHud();
53  void prepareSideWindow();
54  void prepareCursor();
55  bool Raycast(float maxDistance);
56  void HandlePostRenderUpdate(float ts);
57  void HandleKeyUp(int key, int scancode, unsigned buttons, int qualifiers);
58  void HandleKeyDown(int key, int scancode, unsigned buttons, int qualifiers, bool repeat);
59  void HandleUpdate(float ts);
60 
61  Urho3D::SharedPtr<Urho3D::Node> m_camera_node;
62  Urho3D::SharedPtr<Urho3D::Node> m_currently_shown_node;
63  CoHNode *m_current_selected_node=nullptr;
64  Urho3D::SharedPtr<Urho3D::Scene> m_scene;
65  // Camera params
66  float yaw_=0;
67  float pitch_=0;
68  // conversion results
69  std::unique_ptr<CoHSceneGraph> m_coh_scene;
70  std::unordered_map<void *,Urho3D::Node *> m_converted_nodes;
71  // UI helper variables
72  SideWindow *m_sidewindow=nullptr;
73  Urho3D::Drawable *m_selected_drawable=nullptr;
74 };
75 
76 #endif // MAPVIEWERAPP_H
void loadSelectedSceneGraph(const QString &path)
Definition: MapViewerApp.cpp:194
void nodeSelected(CoHNode *def, Urho3D::Node *n)
void scenegraphLoaded(const CoHSceneGraph &)
Definition: CoHModelLoader.h:91
Definition: CoHSceneConverter.h:52
void Setup() override
Definition: MapViewerApp.cpp:62
void Start() override
Definition: MapViewerApp.cpp:167
~MapViewerApp() override
Definition: MapViewerApp.cpp:58
void cameraLocationChanged(float x, float y, float z)
Definition: MapViewerApp.h:30
Definition: SideWindow.h:35
MapViewerApp(Urho3D::Context *ctx)
Definition: MapViewerApp.cpp:54
void onNodeSelected(CoHNode *n)
Definition: MapViewerApp.cpp:207
void onDisplayNode(CoHNode *n, bool rootnode)
Definition: MapViewerApp.cpp:216
void modelSelected(CoHNode *def, CoHModel *model, Urho3D::Drawable *m)
Definition: CoHSceneConverter.h:85