SEGS  0.4.2
Super Entity Game Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CoHModelLoader.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 #pragma once
9 #include "CohTextureConverter.h"
10 #include <glm/vec3.hpp>
11 #include <QStringList>
12 #include <memory>
13 #include <vector>
14 
15 namespace Urho3D
16 {
17  class StaticModel;
18 }
19 
20 struct CoHNode;
21 struct ConvertedGeoSet;
22 struct GeometryModifiers;
23 struct ModelModifiers;
24 
26 {
27  QString geopath;
28  QStringList entries;
29  bool loaded;
30 };
31 
33 {
34  std::vector<glm::vec3> pos;
35  std::vector<glm::vec3> norm;
36  std::vector<glm::vec2> uv1;
37  std::vector<glm::vec2> uv2;
38  std::vector<glm::ivec3> triangles;
39  std::vector<TextureWrapper> assigned_textures;
40  bool needs_tangents=false;
41 };
42 
43 enum class CoHBlendMode : uint8_t;
44 
45 #pragma pack(push, 1)
46 struct DeltaPack
47 {
48  int compressed_size=0;
49  uint32_t uncomp_size=0;
50  int buffer_offset=0;
51  uint8_t *compressed_data=nullptr;
52 };
53 
55 {
56  uint16_t tex_idx;
57  uint16_t tri_count;
58 };
59 
60 #pragma pack(pop)
61 struct PackBlock
62 {
70  DeltaPack &operator[](uint8_t idx) { return (&tris)[idx]; }
71 };
72 
73 enum ModelFlags : uint32_t
74 {
79  OBJ_LOD = 0x80,
80  OBJ_TREE = 0x100,
82  OBJ_FORCEOPAQUE = 0x400,
83  OBJ_BUMPMAP = 0x800,
84  OBJ_WORLDFX = 0x1000,
85  OBJ_CUBEMAP = 0x2000,
86  OBJ_DRAW_AS_ENT = 0x4000,
87  OBJ_STATICFX = 0x8000,
88  OBJ_HIDE = 0x10000,
89 };
90 
91 struct CoHModel
92 {
93  QString name;
94  int flags;
96  uint32_t num_textures;
98  uint32_t vertex_count;
99  uint32_t model_tri_count;
100  glm::vec3 scale;
101  glm::vec3 m_min;
102  glm::vec3 m_max;
103  ptrdiff_t boneinfo_offset = 0;
106  std::vector<TextureBind> texture_bind_info;
108  Urho3D::StaticModel * converted_model = nullptr;
109 };
110 std::unique_ptr<VBOPointers> getVBO(CoHModel &m);
111 
113 {
114  QString geopath;
115  QString name;
117  std::vector<CoHModel *> subs;
118  std::vector<QString> tex_names;
119  std::vector<char> m_geo_data;
120  uint32_t geo_data_size;
121  bool data_loaded = false;
122 };
123 void initLoadedModel(std::function<TextureWrapper(const QString &)> funcloader, CoHModel *model,
124  const std::vector<TextureWrapper> &textures);
125 
126 CoHModel * groupModelFind(const QString &a1);
127 bool prepareGeoLookupArray();
128 GeometryModifiers *findGeomModifier(const QString &modelname, const QString &trick_path);
129 GeoStoreDef * groupGetFileEntryPtr(const QString &a1);
130 ConvertedGeoSet * geosetLoad(const QString &m);
131 float *combineBuffers(VBOPointers &meshdata,CoHModel *mdl);
132 void geosetLoadData(class QFile &fp, ConvertedGeoSet *geoset);
Definition: CoHModelLoader.h:54
Definition: CoHModelLoader.h:83
float * combineBuffers(VBOPointers &meshdata, CoHModel *mdl)
Definition: CoHModelLoader.cpp:690
DeltaPack tris
Definition: CoHModelLoader.h:63
ConvertedGeoSet * geosetLoad(const QString &m)
load the given geoset, used when loading scene-subgraph and nodes
Definition: CoHModelLoader.cpp:675
GeometryModifiers * findGeomModifier(const QString &modelname, const QString &trick_path)
Definition: CoHModelLoader.cpp:653
ModelFlags
Definition: CoHModelLoader.h:73
DeltaPack norms
Definition: CoHModelLoader.h:65
Definition: CoHModelLoader.h:46
Definition: CoHModelLoader.h:91
float visibility_radius
Definition: CoHModelLoader.h:95
std::vector< glm::vec2 > uv2
Definition: CoHModelLoader.h:37
int flags
Definition: CoHModelLoader.h:94
Definition: CoHModelLoader.h:82
Definition: CoHSceneConverter.h:52
Definition: CoHModelLoader.h:85
glm::vec3 m_max
Definition: CoHModelLoader.h:102
Definition: CoHModelLoader.h:75
Definition: CoHModelLoader.h:112
std::vector< CoHModel * > subs
Definition: CoHModelLoader.h:117
Definition: CohTextureConverter.h:28
QString geopath
a path to a .geo file
Definition: CoHModelLoader.h:27
Definition: trick_definitions.h:114
DeltaPack grid
Definition: CoHModelLoader.h:69
CoHBlendMode blend_mode
Definition: CoHModelLoader.h:97
std::vector< TextureBind > texture_bind_info
Definition: CoHModelLoader.h:106
Definition: CoHModelLoader.h:80
void geosetLoadData(QFile &fp, ConvertedGeoSet *geoset)
Definition: CoHModelLoader.cpp:588
bool prepareGeoLookupArray()
Definition: CoHModelLoader.cpp:622
QString geopath
Definition: CoHModelLoader.h:114
std::vector< glm::vec3 > pos
Definition: CoHModelLoader.h:34
uint32_t vertex_count
Definition: CoHModelLoader.h:98
ModelModifiers * trck_node
Definition: CoHModelLoader.h:107
Definition: CoHModelLoader.h:32
std::vector< char > m_geo_data
Definition: CoHModelLoader.h:119
bool loaded
Definition: CoHModelLoader.h:29
void initLoadedModel(std::function< TextureWrapper(const QString &)> funcloader, CoHModel *model, const std::vector< TextureWrapper > &textures)
Definition: CoHModelLoader.cpp:754
ConvertedGeoSet * geoset
Definition: CoHModelLoader.h:104
uint16_t tex_idx
Definition: CoHModelLoader.h:56
Definition: trick_definitions.h:78
std::vector< glm::vec3 > norm
Definition: CoHModelLoader.h:35
QStringList entries
the names of models contained in a geoset
Definition: CoHModelLoader.h:28
bool needs_tangents
Definition: CoHModelLoader.h:40
std::vector< glm::vec2 > uv1
Definition: CoHModelLoader.h:36
DeltaPack verts
Definition: CoHModelLoader.h:64
CoHBlendMode
Definition: CoHSceneConverter.h:32
Definition: CoHModelLoader.h:79
uint32_t model_tri_count
Definition: CoHModelLoader.h:99
DeltaPack & operator[](uint8_t idx)
Definition: CoHModelLoader.h:70
glm::vec3 m_min
Definition: CoHModelLoader.h:101
uint32_t num_textures
Definition: CoHModelLoader.h:96
Definition: CoHModelLoader.h:86
std::vector< TextureWrapper > assigned_textures
Definition: CoHModelLoader.h:39
ConvertedGeoSet * parent_geoset
Definition: CoHModelLoader.h:116
uint16_t tri_count
Definition: CoHModelLoader.h:57
Definition: CoHModelLoader.h:76
Urho3D::StaticModel * converted_model
Definition: CoHModelLoader.h:108
uint32_t geo_data_size
Definition: CoHModelLoader.h:120
std::unique_ptr< VBOPointers > getVBO(CoHModel &model)
Definition: CoHModelLoader.cpp:683
DeltaPack sts
Definition: CoHModelLoader.h:66
GeoStoreDef * groupGetFileEntryPtr(const QString &a1)
Definition: CoHModelLoader.cpp:667
Definition: CoHModelLoader.h:88
ptrdiff_t boneinfo_offset
Definition: CoHModelLoader.h:103
Definition: CoHModelLoader.h:61
std::vector< QString > tex_names
Definition: CoHModelLoader.h:118
DeltaPack weights
Definition: CoHModelLoader.h:67
Definition: CoHModelLoader.h:25
Definition: CoHModelLoader.h:87
CoHModel * groupModelFind(const QString &a1)
Definition: CoHModelLoader.cpp:615
QString name
Definition: CoHModelLoader.h:115
DeltaPack matidxs
Definition: CoHModelLoader.h:68
glm::vec3 scale
Definition: CoHModelLoader.h:100
Definition: CoHModelLoader.h:81
PackBlock packed_data
Definition: CoHModelLoader.h:105
bool data_loaded
Definition: CoHModelLoader.h:121
QString name
Definition: CoHModelLoader.h:93
Definition: CoHModelLoader.h:77
Definition: CoHModelLoader.h:78
Definition: CoHModelLoader.h:84
std::vector< glm::ivec3 > triangles
Definition: CoHModelLoader.h:38