World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
BSPModel.h
См. документацию.
1 #pragma once
2 
3 #include <vector>
4 
5 #include "../VectorTypes.h"
6 #include "Engine/Strings.h"
7 
8 #define FACE_PORTAL 0x00000001 // portal/two-sided
9 #define FACE_CAN_SATURATE_COLOR 0x00000002 // guess at perception faces
10 #define FACE_FLOW_DIAGONAL 0x00000004 // Diagonal flow of the lava or water
11 #define FACE_UNKNOW5 0x00000006
12 #define FACE_UNKNOW6 0x00000008
13 #define FACE_FLUID 0x00000010 // wavy animated water or lava
14 #define FACE_FLOW_VERTICAL 0x00000020 // Vertical flow of the lava or water
15 #define FACE_DONT_CACHE_TEXTURE 0x00000040 // do not load face texture if it isn't loaded already
16 #define FACE_RENDERED 0x00000080 // face has been rendered - ie seen by party
17 #define FACE_XY_PLANE 0x00000100
18 #define FACE_XZ_PLANE 0x00000200
19 #define FACE_YZ_PLANE 0x00000400
20 #define FACE_FLOW_HORIZONTAL 0x00000800 // Horizontal flow of the lava or water
21 #define FACE_HAS_EVENT_HINT 0x00001000
22 #define FACE_INVISIBLE 0x00002000
23 #define FACE_TEXTURE_FRAME 0x00004000 // Texture ID is a frameset from TextureFrameTable, otherwise BitmapID
24 #define FACE_OUTLINED 0x00010000 // outline face edges
25 #define FACE_INDOOR_DOOR 0x00020000
26 #define FACE_TEXTURE_FLOW 0x00040000 // The texture moves slowly. For horizontal facets only.
27 #define FACE_HAS_EVENT 0x00100000
28 #define FACE_INDOOR_CARPET 0x00200000
29 #define FACE_INDOOR_SKY 0x00400000
30 #define FACE_UNKNOW3 0x00800000
31 #define FACE_UNKNOW4 0x01000000
32 #define FACE_CLICKABLE 0x02000000 // Event can be triggered by clicking on the facet.
33 #define FACE_PRESSURE_PLATE 0x04000000 // Event can be triggered by stepping on the facet.
34 #define FACE_INDICATE 0x06000000 // Event can be triggered by indicating on the facet.
35 #define FACE_UNKNOW1 0x08000000
36 #define FACE_UNKNOW2 0x10000000
37 #define FACE_ETHEREAL 0x20000000 // Untouchable. You can pass through it.
38 #define FACE_INDOOR_LAVA 0x40000000
39 #define FACE_PICKED 0x80000000
40 
41 #pragma pack(push, 1)
42 struct BSPNode {
47 };
48 #pragma pack(pop)
49 
50 #pragma pack(push, 1)
53  Vec3_int_ *pVertices;
54 };
55 #pragma pack(pop)
56 
57 #pragma pack(push, 1)
58 struct BSPModelData {
59  char pModelName[32];
60  char pModelName2[32];
73  Vec3_int_ vPosition;
86  Vec3_int_ vBoundingCenter;
88 };
89 #pragma pack(pop)
90 
91 class Texture;
92 
93 struct ODMFace {
94  bool HasEventHint();
95 
96  static bool IsBackfaceNotCulled(struct RenderVertexSoft *a2,
97  struct Polygon *polygon);
98 
99  inline bool Invisible() const {
100  return (uAttributes & FACE_INVISIBLE) != 0;
101  }
102  inline bool Visible() const { return !Invisible(); }
103  inline bool Portal() const { return (uAttributes & FACE_PORTAL) != 0; }
104  inline bool Fluid() const { return (uAttributes & FACE_FLUID) != 0; }
105  inline bool Indoor_sky() const {
106  return (uAttributes & FACE_INDOOR_SKY) != 0;
107  }
108  inline bool Clickable() const {
109  return (uAttributes & FACE_CLICKABLE) != 0;
110  }
111  inline bool Pressure_Plate() const {
112  return (uAttributes & FACE_PRESSURE_PLATE) != 0;
113  }
114  inline bool Ethereal() const { return (uAttributes & FACE_ETHEREAL) != 0; }
115 
116  inline bool IsTextureFrameTable() {
117  return this->uAttributes & FACE_TEXTURE_FRAME;
118  }
120  this->uAttributes = this->uAttributes & FACE_TEXTURE_FRAME
121  ? this->uAttributes & ~FACE_TEXTURE_FRAME
122  : this->uAttributes | FACE_TEXTURE_FRAME;
123  }
124 
125  void SetTexture(const String &filename);
126  Texture *GetTexture();
127 
128  bool Deserialize(struct ODMFace_MM7 *);
129 
130  unsigned int index;
132  int zCalc1;
133  int zCalc2;
134  int zCalc3;
142  void *resource; // __int16 uTextureID;
149  char field_128;
150  char field_129;
159  char field_132;
160  char field_133;
161 };
162 
163 class BSPModel {
164  public:
165  void Release();
166 
167  unsigned int index;
173  Vec3_int_ vPosition;
186  Vec3_int_ vBoundingCenter;
188 
190  std::vector<ODMFace> pFaces;
192  std::vector<BSPNode> pNodes;
193 };
194 
195 class BSPModelList : public std::vector<BSPModel> {
196  public:
198 };
uint16_t
unsigned __int16 uint16_t
Definition: SDL_config.h:37
BSPModel::sSomeOtherMinX
int32_t sSomeOtherMinX
Definition: BSPModel.h:180
BSPVertexBuffer::uNumVertices
uint32_t uNumVertices
Definition: BSPModel.h:52
ODMFace::uGradientVertex4
uint8_t uGradientVertex4
Definition: BSPModel.h:154
ODMFace::field_129
char field_129
Definition: BSPModel.h:150
BSPModel::pVertices
struct BSPVertexBuffer pVertices
Definition: BSPModel.h:189
BSPModelData::pModelName
char pModelName[32]
Definition: BSPModel.h:59
ODMFace::ToggleIsTextureFrameTable
void ToggleIsTextureFrameTable()
Definition: BSPModel.h:119
int16_t
signed __int16 int16_t
Definition: SDL_config.h:36
ODMFace::zCalc1
int zCalc1
Definition: BSPModel.h:132
ODMFace::pYInterceptDisplacements
int16_t pYInterceptDisplacements[20]
Definition: BSPModel.h:140
ODMFace::pTextureVIDs
int16_t pTextureVIDs[20]
Definition: BSPModel.h:138
BSPModel::sSomeOtherMinY
int32_t sSomeOtherMinY
Definition: BSPModel.h:181
BSPModelData::sMaxY
int32_t sMaxY
Definition: BSPModel.h:78
BSPModelData::sSomeOtherMinY
int32_t sSomeOtherMinY
Definition: BSPModel.h:81
BSPModel::vPosition
Vec3_int_ vPosition
Definition: BSPModel.h:173
Polygon
Definition: Polygon.h:14
BSPNode::uCoplanarOffset
int16_t uCoplanarOffset
Definition: BSPModel.h:45
BSPModel::index
unsigned int index
Definition: BSPModel.h:167
ODMFace::Portal
bool Portal() const
Definition: BSPModel.h:103
BSPModelData::sMinZ
int32_t sMinZ
Definition: BSPModel.h:76
BSPModelData::sSomeOtherMaxX
int32_t sSomeOtherMaxX
Definition: BSPModel.h:83
ODMFace::IsTextureFrameTable
bool IsTextureFrameTable()
Definition: BSPModel.h:116
BSPModelData
Definition: BSPModel.h:58
BSPModel::sMaxX
int32_t sMaxX
Definition: BSPModel.h:177
BSPModel::sCenterY
int32_t sCenterY
Definition: BSPModel.h:172
Texture
Definition: Texture.h:4
BBox_short_
Definition: VectorTypes.h:113
BSPVertexBuffer
Definition: BSPModel.h:51
BSPModel::sBoundingRadius
int32_t sBoundingRadius
Definition: BSPModel.h:187
ODMFace::zCalc3
int zCalc3
Definition: BSPModel.h:134
BSPModelData::uNumDecorations
uint32_t uNumDecorations
Definition: BSPModel.h:70
BSPModel::sCenterX
int32_t sCenterX
Definition: BSPModel.h:171
BSPModel::sSomeOtherMinZ
int32_t sSomeOtherMinZ
Definition: BSPModel.h:182
BSPNode::uBack
int16_t uBack
Definition: BSPModel.h:44
BSPModelData::sCenterX
int32_t sCenterX
Definition: BSPModel.h:71
ODMFace::sCogTriggeredID
int16_t sCogTriggeredID
Definition: BSPModel.h:147
BSPModelData::ppFacesOrdering
uint32_t ppFacesOrdering
Definition: BSPModel.h:67
ODMFace::uPolygonType
uint8_t uPolygonType
Definition: BSPModel.h:156
ODMFace_MM7
Definition: BSPModel.cpp:11
BSPModelList::Load
uint8_t * Load(uint8_t *data)
Definition: BSPModel.cpp:45
BSPNode
Definition: BSPModel.h:42
BSPModel::sMinZ
int32_t sMinZ
Definition: BSPModel.h:176
ODMFace::pTextureUIDs
int16_t pTextureUIDs[20]
Definition: BSPModel.h:137
ODMFace::Invisible
bool Invisible() const
Definition: BSPModel.h:99
ODMFace::sCogTriggerType
int16_t sCogTriggerType
Definition: BSPModel.h:148
ODMFace::pBoundingBox
struct BBox_short_ pBoundingBox
Definition: BSPModel.h:145
ODMFace::sTextureDeltaV
int16_t sTextureDeltaV
Definition: BSPModel.h:144
BSPModel::pFacesOrdering
uint16_t * pFacesOrdering
Definition: BSPModel.h:191
BSPModelData::ppFaces
uint32_t ppFaces
Definition: BSPModel.h:66
BSPModel::sMinY
int32_t sMinY
Definition: BSPModel.h:175
BSPModelData::sMinY
int32_t sMinY
Definition: BSPModel.h:75
ODMFace::pVertexIDs
uint16_t pVertexIDs[20]
Definition: BSPModel.h:136
BSPModelList
Definition: BSPModel.h:195
ODMFace::pXInterceptDisplacements
int16_t pXInterceptDisplacements[20]
Definition: BSPModel.h:139
BSPModel::pModelName
String pModelName
Definition: BSPModel.h:168
BSPModelData::pModelName2
char pModelName2[32]
Definition: BSPModel.h:60
BSPModel::pNodes
std::vector< BSPNode > pNodes
Definition: BSPModel.h:192
ODMFace::uGradientVertex2
uint8_t uGradientVertex2
Definition: BSPModel.h:152
BSPModelData::sMinX
int32_t sMinX
Definition: BSPModel.h:74
ODMFace::field_128
char field_128
Definition: BSPModel.h:149
BSPModelData::ppVertices
uint32_t ppVertices
Definition: BSPModel.h:63
ODMFace::uGradientVertex1
uint8_t uGradientVertex1
Definition: BSPModel.h:151
Plane_int_
Definition: VectorTypes.h:106
int32_t
signed __int32 int32_t
Definition: SDL_config.h:38
BSPModel::sMinX
int32_t sMinX
Definition: BSPModel.h:174
BSPModelData::field_40
int32_t field_40
Definition: BSPModel.h:61
ODMFace::uShadeType
uint8_t uShadeType
Definition: BSPModel.h:157
BSPModelData::sSomeOtherMaxY
int32_t sSomeOtherMaxY
Definition: BSPModel.h:84
ODMFace::resource
void * resource
Definition: BSPModel.h:142
BSPModelData::sSomeOtherMinX
int32_t sSomeOtherMinX
Definition: BSPModel.h:80
ODMFace::uNumVertices
uint8_t uNumVertices
Definition: BSPModel.h:155
ODMFace::uGradientVertex3
uint8_t uGradientVertex3
Definition: BSPModel.h:153
ODMFace::IsBackfaceNotCulled
static bool IsBackfaceNotCulled(struct RenderVertexSoft *a2, struct Polygon *polygon)
Definition: Outdoor.cpp:522
ODMFace::Indoor_sky
bool Indoor_sky() const
Definition: BSPModel.h:105
ODMFace::field_133
char field_133
Definition: BSPModel.h:160
ODMFace::SetTexture
void SetTexture(const String &filename)
Definition: BSPModel.cpp:155
BSPModelData::uNumFaces
uint32_t uNumFaces
Definition: BSPModel.h:64
BSPModelData::uNumConvexFaces
uint32_t uNumConvexFaces
Definition: BSPModel.h:65
ODMFace::sTextureDeltaU
int16_t sTextureDeltaU
Definition: BSPModel.h:143
BSPNode::uCoplanarSize
int16_t uCoplanarSize
Definition: BSPModel.h:46
ODMFace::index
unsigned int index
Definition: BSPModel.h:130
BSPModelData::uNumVertices
uint32_t uNumVertices
Definition: BSPModel.h:62
ODMFace::Pressure_Plate
bool Pressure_Plate() const
Definition: BSPModel.h:111
BSPModelData::ppNodes
uint32_t ppNodes
Definition: BSPModel.h:69
BSPModelData::sSomeOtherMinZ
int32_t sSomeOtherMinZ
Definition: BSPModel.h:82
BSPModelData::sMaxZ
int32_t sMaxZ
Definition: BSPModel.h:79
ODMFace::Deserialize
bool Deserialize(struct ODMFace_MM7 *)
Definition: BSPModel.cpp:168
BSPModel::sMaxY
int32_t sMaxY
Definition: BSPModel.h:178
uint8_t
unsigned __int8 uint8_t
Definition: SDL_config.h:35
ODMFace::Visible
bool Visible() const
Definition: BSPModel.h:102
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
ODMFace::HasEventHint
bool HasEventHint()
Definition: BSPModel.cpp:206
BSPModel::sSomeOtherMaxY
int32_t sSomeOtherMaxY
Definition: BSPModel.h:184
BSPModelData::uNumNodes
uint32_t uNumNodes
Definition: BSPModel.h:68
ODMFace::GetTexture
Texture * GetTexture()
Definition: BSPModel.cpp:146
BSPModelData::sMaxX
int32_t sMaxX
Definition: BSPModel.h:77
BSPModel::pModelName2
String pModelName2
Definition: BSPModel.h:169
ODMFace::field_132
char field_132
Definition: BSPModel.h:159
ODMFace::Clickable
bool Clickable() const
Definition: BSPModel.h:108
BSPModelData::vBoundingCenter
Vec3_int_ vBoundingCenter
Definition: BSPModel.h:86
BSPModel::pFaces
std::vector< ODMFace > pFaces
Definition: BSPModel.h:190
BSPModelData::sCenterY
int32_t sCenterY
Definition: BSPModel.h:72
ODMFace
Definition: BSPModel.h:93
BSPModel::vBoundingCenter
Vec3_int_ vBoundingCenter
Definition: BSPModel.h:186
BSPModel::sSomeOtherMaxX
int32_t sSomeOtherMaxX
Definition: BSPModel.h:183
ODMFace::uAttributes
uint32_t uAttributes
Definition: BSPModel.h:135
ODMFace::pFacePlane
struct Plane_int_ pFacePlane
Definition: BSPModel.h:131
BSPVertexBuffer::pVertices
Vec3_int_ * pVertices
Definition: BSPModel.h:53
BSPModelData::sSomeOtherMaxZ
int32_t sSomeOtherMaxZ
Definition: BSPModel.h:85
BSPModel::Release
void Release()
Definition: BSPModel.cpp:137
ODMFace::zCalc2
int zCalc2
Definition: BSPModel.h:133
BSPModel::field_40
int32_t field_40
Definition: BSPModel.h:170
ODMFace::Fluid
bool Fluid() const
Definition: BSPModel.h:104
BSPModelData::vPosition
Vec3_int_ vPosition
Definition: BSPModel.h:73
BSPNode::uFront
int16_t uFront
Definition: BSPModel.h:43
BSPModel
Definition: BSPModel.h:163
RenderVertexSoft
Definition: IRender.h:113
BSPModel::sSomeOtherMaxZ
int32_t sSomeOtherMaxZ
Definition: BSPModel.h:185
uint32_t
unsigned __int32 uint32_t
Definition: SDL_config.h:39
String
std::string String
Definition: Strings.h:10
BSPModelData::sBoundingRadius
int32_t sBoundingRadius
Definition: BSPModel.h:87
ODMFace::pZInterceptDisplacements
int16_t pZInterceptDisplacements[20]
Definition: BSPModel.h:141
ODMFace::Ethereal
bool Ethereal() const
Definition: BSPModel.h:114
BSPModel::sMaxZ
int32_t sMaxZ
Definition: BSPModel.h:179
ODMFace::bVisible
uint8_t bVisible
Definition: BSPModel.h:158
ODMFace::sCogNumber
int16_t sCogNumber
Definition: BSPModel.h:146
Strings.h