SEGS  0.6.1-develop [d2cac982]
Super Entity Game Server
MapStructure.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
9 #include <algorithm>
10 #include "CoXHash.h"
11 #include "DataStorage.h"
12 
13 struct TreeStore
14 {
15  virtual size_t num_children() const
16  {
17  return 0;
18  }
19  virtual TreeStore *nth_child(size_t )
20  {
21  return 0;
22  }
23  virtual size_t idx_of_child(TreeStore *) const
24  {
25  return ~0UL;
26  }
27  virtual std::string to_string() const
28  {
29  return "";
30  }
31 };
32 
33 
34 namespace MapStructs
35 {
36  struct Lod;
37  struct Fog;
38  struct Beacon;
39  struct Sound;
40  struct TexReplace;
41  struct Omni;
42  struct Ambient;
43  struct TintColor;
44  struct Property;
45  struct Group;
46  struct Def : public TreeStore
47  {
48  std::vector<Lod *> m_lods;
49  std::vector<Fog *> m_fogs;
50  std::vector<Beacon *> m_beacons;
51  std::vector<Sound *> m_sounds;
52  std::vector<TexReplace *> m_texture_replacements;
53  std::vector<Omni *> m_omni;
54  std::vector<Ambient *> m_ambients;
55  std::vector<TintColor *> m_tint_colors;
56  std::vector<Property *> m_properties;
57  std::vector<Group *> m_groups;
58 
59  std::string m_src_name;
60  std::string m_obj_name;
61  std::string m_type_name;
62  uint32_t m_flags;
63  static void build_schema();
64  virtual std::string to_string() const
65  {
66  return "Def["+m_src_name+"]";
67  }
68  virtual size_t num_children() const
69  {
70  return m_groups.size();
71  }
72  virtual TreeStore *nth_child(size_t idx)
73  {
74  return (TreeStore *)m_groups[idx];
75  }
76 
77  };
78  struct Ref : public TreeStore
79  {
80  std::string m_src_name;
83  static void build_schema();
84  virtual std::string to_string() const
85  {
86  return "Ref["+m_src_name+"]";
87  }
88  };
89 
90  struct TexReplace : public TreeStore
91  {
92  uint32_t m_src;
93  std::string m_name_tgt;
94  static void build_schema();
95  };
96  struct Ambient : public TreeStore
97  {
98  Color3ub m_color;
99  static void build_schema();
100  };
101  struct Omni : public TreeStore
102  {
103  float m_val;
104  uint32_t m_flags;
105  Color3ub m_color;
106  static void build_schema();
107  };
108 
109  struct Beacon : public TreeStore
110  {
111  DECL_READABLE(Beacon)
112  std::string m_name;
113  float m_val; //radius?
114  static void build_schema();
115  };
116  struct Sound : public TreeStore
117  {
118  DECL_READABLE(Sound)
119  std::string m_name;
120  float m_a;
121  float m_b;
122  float m_c;
123  uint32_t m_flags;
124  static void build_schema();
125  };
126  struct Fog : public TreeStore
127  {
128  float m_a;
129  float m_b;
130  float m_c;
131  Color3ub m_col1;
132  Color3ub m_col2;
133  static void build_schema();
134  };
135  struct TintColor : public TreeStore
136  {
137  Color3ub m_col1;
138  Color3ub m_col2;
139  static void build_schema();
140  };
141 
142  struct Lod : public TreeStore
143  {
144  float m_far;
145  float m_far_fade;
146  float m_near;
147  float m_near_fade;
148  float m_scale;
149  static void build_schema();
150  };
151  struct Property : public TreeStore
152  {
153  std::string m_txt1;
154  std::string m_txt2;
155  uint32_t m_val3;
156  static void build_schema();
157  };
158  struct Group : public TreeStore
159  {
160  std::string m_name; // this is reference to a model name or def name
163  static void build_schema();
164  };
165 }
166 struct SceneStorage : public TreeStore
167 {
168  typedef std::vector<MapStructs::Def *> vDef;
169  typedef std::vector<MapStructs::Ref *> vRef;
170  vDef m_defs;
171  vRef m_refs;
172  vDef m_root;
173  std::string m_scene_file;
174  uint32_t m_version;
175  static void build_schema();
176  size_t num_children() const
177  {
178  return m_defs.size()+m_refs.size()+m_root.size();
179  }
180  virtual TreeStore *nth_child(size_t idx)
181  {
182  if(idx<m_defs.size())
183  return m_defs[idx];
184  idx-=m_defs.size();
185  if(idx<m_refs.size())
186  return m_refs[idx];
187  idx-=m_refs.size();
188  if(idx<m_root.size())
189  return m_root[idx];
190  return 0;
191  }
192  virtual size_t idx_of_child(TreeStore *child) const
193  {
194  vDef::const_iterator itr=std::find(m_defs.begin(),m_defs.end(),child);
195  if(itr!=m_defs.end())
196  return itr-m_defs.begin();
197  return ~0UL;
198  }
199  virtual std::string to_string() const
200  {
201  return m_scene_file;
202  }
203 };
float m_near_fade
Definition: MapStructure.h:147
uint32_t m_flags
Definition: MapStructure.h:62
virtual size_t idx_of_child(TreeStore *) const
Definition: MapStructure.h:23
size_t num_children() const
Definition: MapStructure.h:176
Color3ub m_col1
Definition: MapStructure.h:137
Definition: MapStructure.h:126
float m_b
Definition: MapStructure.h:129
Color3ub m_color
Definition: MapStructure.h:98
std::vector< Omni * > m_omni
Definition: MapStructure.h:53
std::string m_txt1
Definition: MapStructure.h:153
float m_a
Definition: MapStructure.h:128
virtual std::string to_string() const
Definition: MapStructure.h:64
Definition: seq_definitions.h:23
virtual TreeStore * nth_child(size_t idx)
Definition: MapStructure.h:180
std::string m_txt2
Definition: MapStructure.h:154
Vec3 m_pos
Definition: MapStructure.h:161
Color3ub m_col2
Definition: MapStructure.h:132
virtual size_t num_children() const
Definition: MapStructure.h:68
vDef m_defs
Definition: MapStructure.h:170
std::vector< Sound * > m_sounds
Definition: MapStructure.h:51
vDef m_root
Definition: MapStructure.h:172
Definition: MapStructure.h:90
std::string m_name_tgt
Definition: MapStructure.h:93
std::vector< TintColor * > m_tint_colors
Definition: MapStructure.h:55
float m_near
Definition: MapStructure.h:146
Definition: MapStructure.h:96
float m_scale
Definition: MapStructure.h:148
virtual TreeStore * nth_child(size_t)
Definition: MapStructure.h:19
float m_val
Definition: MapStructure.h:103
Color3ub m_col2
Definition: MapStructure.h:138
Definition: MapStructure.h:101
std::vector< TexReplace * > m_texture_replacements
Definition: MapStructure.h:52
std::vector< Property * > m_properties
Definition: MapStructure.h:56
std::vector< Group * > m_groups
Definition: MapStructure.h:57
Definition: MapStructure.h:109
std::vector< Beacon * > m_beacons
Definition: MapStructure.h:50
std::vector< Lod * > m_lods
Definition: MapStructure.h:48
std::string m_name
Definition: MapStructure.h:160
std::string m_scene_file
Definition: MapStructure.h:173
glm::vec3 Vec3
Definition: DataStorage.h:19
std::string m_obj_name
Definition: MapStructure.h:60
uint32_t m_val3
Definition: MapStructure.h:155
virtual std::string to_string() const
Definition: MapStructure.h:27
uint32_t m_version
Definition: MapStructure.h:174
std::string m_src_name
Definition: MapStructure.h:80
Color3ub m_color
Definition: MapStructure.h:105
virtual std::string to_string() const
Definition: MapStructure.h:84
virtual size_t idx_of_child(TreeStore *child) const
Definition: MapStructure.h:192
virtual size_t num_children() const
Definition: MapStructure.h:15
Vec3 m_rot
Definition: MapStructure.h:162
Definition: MapStructure.h:78
float m_far_fade
Definition: MapStructure.h:145
std::vector< Fog * > m_fogs
Definition: MapStructure.h:49
Definition: MapStructure.h:46
Definition: MapStructure.h:166
Vec3 m_rot
Definition: MapStructure.h:82
float m_c
Definition: MapStructure.h:130
Definition: MapStructure.h:116
Definition: MapStructure.h:34
std::string m_src_name
Definition: MapStructure.h:59
vRef m_refs
Definition: MapStructure.h:171
Vec3 m_pos
Definition: MapStructure.h:81
virtual std::string to_string() const
Definition: MapStructure.h:199
std::vector< MapStructs::Ref * > vRef
Definition: MapStructure.h:169
virtual TreeStore * nth_child(size_t idx)
Definition: MapStructure.h:72
Definition: MapStructure.h:13
float m_far
Definition: MapStructure.h:144
uint32_t m_src
Definition: MapStructure.h:92
uint32_t m_flags
Definition: MapStructure.h:104
Definition: MapStructure.h:151
std::vector< Ambient * > m_ambients
Definition: MapStructure.h:54
Definition: MapStructure.h:135
Color3ub m_col1
Definition: MapStructure.h:131
Definition: MapStructure.h:158
Definition: MapStructure.h:142
std::vector< MapStructs::Def * > vDef
Definition: MapStructure.h:168
std::string m_type_name
Definition: MapStructure.h:61