SEGS  0.6.1-develop [d2cac982]
Super Entity Game Server
SceneGraph.h
Go to the documentation of this file.
1 /*
2  * SEGS - Super Entity Game Server
3  * http://www.segs.io/
4  * Copyright (c) 2006 - 2019 SEGS Team (see AUTHORS.md)
5  * This software is licensed under the terms of the 3-clause BSD License. See LICENSE.md for details.
6  */
7 
8 #pragma once
11 #include "Common/Runtime/Handle.h"
12 
13 #include "glm/vec3.hpp"
14 #include "glm/mat3x3.hpp"
15 #include "glm/common.hpp"
16 #include "glm/gtc/constants.hpp"
17 
18 #include <QString>
19 #include <QHash>
20 #include <vector>
21 #include <memory>
22 
23 namespace SEGS
24 {
25 struct LoadingContext;
26 struct Model;
28 {
29  struct SceneNode *node;
30  glm::mat3x3 m_matrix2;
31  glm::vec3 m_pyr;
32  glm::vec3 m_translation;
33 };
35 {
36  glm::vec4 color;
37  float range;
39 };
40 using HLightProperties = std::unique_ptr<LightProperties>;
41 
42 struct SceneNode
43 {
45  {
46  is_LOD_fade_node = 0;
47  }
48  struct GeoStoreDef * m_belongs_to_geoset = nullptr;
49  std::vector<SceneNodeChildTransform> m_children;
50  std::vector<GroupProperty_Data> *m_properties = nullptr;
51 
53  Model *m_model = nullptr;
54  struct GeoStoreDef *m_geoset_info = nullptr; // where is this node from ?
55  QString m_name;
56  QString m_dir;
58  int m_index_in_scenegraph=0;
59 
60  uint32_t m_fx_name_hash = 0;
61  glm::vec3 m_center;
62  float radius = 0;
63  float vis_dist = 0;
64  float lod_near = 0;
65  float lod_far = 0;
66  float lod_near_fade = 0;
67  float lod_far_fade = 0;
68  float lod_scale = 0;
69  float shadow_dist = 0;
71  bool lod_fromtrick = false;
72  // Start of bit flags
73  uint32_t is_LOD_fade_node : 1;
74  uint32_t shell : 1;
75  uint32_t tray : 1;
76  uint32_t region_marker : 1;
77  uint32_t volume_trigger : 1;
78  uint32_t water_volume : 1;
79  uint32_t lava_volume : 1;
80  uint32_t sewer_volume : 1;
81  uint32_t door_volume : 1;
82  uint32_t in_use : 2;
83  uint32_t parent_fade : 1;
84  uint32_t key_light : 1;
85  // end of bit flags
86 };
87 
88 struct RootNode
89 {
90  glm::mat4 mat;
91  SceneNode *node = nullptr;
92  uint32_t index_in_roots_array=0;
93 };
94 
95 struct SceneGraph
96 {
97  std::vector<SceneNode *> all_converted_defs;
98  std::vector<RootNode *> refs;
99 
100  QHash<QString,SceneNode *> name_to_node;
101 };
102 struct PrefabStore;
103 struct LoadingContext;
104 
105 bool loadSceneGraph(const QString &path, LoadingContext &ctx, PrefabStore &prefabs);
106 SceneGraph *loadWholeMap(const QString &filename);
107 void loadSubgraph(const QString &filename, LoadingContext &ctx,PrefabStore &prefabs);
108 SceneNode * getNodeByName(const SceneGraph &graph,const QString &name);
109 } // and of SEGS namespace
uint32_t shell
Definition: SceneGraph.h:74
Definition: Prefab.h:51
QString m_dir
Definition: SceneGraph.h:56
Definition: Model.h:88
QHash< QString, SceneNode * > name_to_node
Definition: SceneGraph.h:100
Definition: Handle.h:28
std::vector< RootNode * > refs
Definition: SceneGraph.h:98
QString m_name
Definition: SceneGraph.h:55
Definition: seq_definitions.h:37
void loadSubgraph(const QString &filename, LoadingContext &ctx, PrefabStore &prefabs)
Definition: SceneGraph.cpp:656
uint32_t region_marker
Definition: SceneGraph.h:76
uint32_t is_LOD_fade_node
Definition: SceneGraph.h:73
glm::vec4 color
Definition: SceneGraph.h:36
HandleT< 20, 12, struct SoundInfo > sound_info
Definition: SceneGraph.h:70
HLightProperties m_light
Definition: SceneGraph.h:52
uint32_t volume_trigger
Definition: SceneGraph.h:77
Definition: Prefab.h:33
uint32_t water_volume
Definition: SceneGraph.h:78
glm::vec3 m_center
Definition: SceneGraph.h:61
uint32_t tray
Definition: SceneGraph.h:75
uint32_t door_volume
Definition: SceneGraph.h:81
glm::vec3 m_pyr
Definition: SceneGraph.h:31
Definition: SceneGraph.h:27
glm::vec3 m_translation
Definition: SceneGraph.h:32
glm::mat4 mat
Definition: SceneGraph.h:90
struct SceneNode * node
Definition: SceneGraph.h:29
Definition: SceneGraph.h:42
float range
Definition: SceneGraph.h:37
uint32_t sewer_volume
Definition: SceneGraph.h:80
Definition: SceneGraph.h:34
SceneGraph * loadWholeMap(const QString &filename)
Definition: SceneGraph.cpp:630
uint32_t lava_volume
Definition: SceneGraph.h:79
std::unique_ptr< LightProperties > HLightProperties
Definition: SceneGraph.h:40
Definition: AxisAlignedBox.h:16
uint32_t in_use
Definition: SceneGraph.h:82
std::vector< SceneNode * > all_converted_defs
Definition: SceneGraph.h:97
std::vector< SceneNodeChildTransform > m_children
Definition: SceneGraph.h:49
SceneNode * getNodeByName(const SceneGraph &graph, const QString &name)
Definition: SceneGraph.cpp:105
glm::mat3x3 m_matrix2
Definition: SceneGraph.h:30
Definition: Prefab.h:44
Definition: SceneGraph.h:88
uint32_t parent_fade
Definition: SceneGraph.h:83
int is_negative
Definition: SceneGraph.h:38
SceneNode()
Definition: SceneGraph.h:44
AxisAlignedBoundingBox m_bbox
Definition: SceneGraph.h:57
uint32_t key_light
Definition: SceneGraph.h:84
Definition: SceneGraph.h:95
bool loadSceneGraph(const QString &path, LoadingContext &ctx, PrefabStore &prefabs)
Definition: SceneGraph.cpp:618