World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
Класс BSPModelList

#include <BSPModel.h>

+ Граф наследования:BSPModelList:
+ Граф связей класса BSPModelList:

Открытые члены

uint8_tLoad (uint8_t *data)
 

Подробное описание

См. определение в файле BSPModel.h строка 195

Методы

◆ Load()

uint8_t * BSPModelList::Load ( uint8_t data)

См. определение в файле BSPModel.cpp строка 45

45  {
46  static_assert(sizeof(BSPModelData) == 188, "Wrong type size");
47  static_assert(sizeof(BSPNode) == 8, "Wrong type size");
48  static_assert(sizeof(Vec3_int_) == 12, "Wrong type size");
49 
50  uint32_t uNumBModels;
51  memcpy(&uNumBModels, data, 4); // количество BModel'ей
52  data += 4;
53 
54  std::vector<BSPModelData> models;
55  for (unsigned int i = 0; i < uNumBModels; ++i) {
56  BSPModelData model;
57  memcpy(&model, data, sizeof(BSPModelData));
58  data += sizeof(BSPModelData);
59  models.push_back(model);
60  }
61 
62  unsigned int model_index = 0;
63  for (BSPModelData &model : models) {
64  this->emplace_back();
65  BSPModel &new_model = this->back();
66 
67  new_model.index = model_index;
68  new_model.pModelName = model.pModelName;
69  new_model.pModelName2 = model.pModelName2;
70  new_model.field_40 = model.field_40;
71  new_model.sCenterX = model.sCenterX;
72  new_model.sCenterY = model.sCenterY;
73  new_model.vPosition = model.vPosition;
74  new_model.sMinX = model.sMinX;
75  new_model.sMinY = model.sMinY;
76  new_model.sMinZ = model.sMinZ;
77  new_model.sMaxX = model.sMaxX;
78  new_model.sMaxY = model.sMaxY;
79  new_model.sMaxZ = model.sMaxZ;
80  new_model.sSomeOtherMinX = model.sSomeOtherMinX;
81  new_model.sSomeOtherMinY = model.sSomeOtherMinY;
82  new_model.sSomeOtherMinZ = model.sSomeOtherMinZ;
83  new_model.sSomeOtherMaxX = model.sSomeOtherMaxX;
84  new_model.sSomeOtherMaxY = model.sSomeOtherMaxY;
85  new_model.sSomeOtherMaxZ = model.sSomeOtherMaxZ;
86  new_model.vBoundingCenter = model.vBoundingCenter;
87  new_model.sBoundingRadius = model.sBoundingRadius;
88 
89  unsigned int verticesSize = model.uNumVertices * sizeof(Vec3_int_);
90  new_model.pVertices.pVertices = (Vec3_int_ *)malloc(verticesSize);
91  memcpy(new_model.pVertices.pVertices, data, verticesSize);
92  data += verticesSize;
93 
94  for (size_t i = 0; i < model.uNumFaces; i++) {
95  new_model.pFaces.emplace_back();
96  ODMFace &face = new_model.pFaces.back();
97  face.index = i;
98  face.Deserialize((ODMFace_MM7 *)data);
99  data += sizeof(ODMFace_MM7);
100  }
101 
102  unsigned int facesOrderingSize = model.uNumFaces * sizeof(short);
103  new_model.pFacesOrdering = (uint16_t *)malloc(facesOrderingSize);
104  memcpy(new_model.pFacesOrdering, data, facesOrderingSize);
105  data += facesOrderingSize;
106 
107  for (size_t i = 0; i < model.uNumNodes; i++) {
108  BSPNode node;
109  memcpy(&node, data, sizeof(BSPNode));
110  new_model.pNodes.push_back(node);
111  data += sizeof(BSPNode);
112  }
113 
114  const char *textureFilenames =
115  (const char *)malloc(10 * model.uNumFaces);
116  memcpy((char *)textureFilenames, data, 10 * model.uNumFaces);
117  data += 10 * model.uNumFaces;
118  for (unsigned int j = 0; j < model.uNumFaces; ++j) {
119  const char *texFilename = &textureFilenames[j * 10];
120  new_model.pFaces[j].SetTexture(texFilename);
121  if (new_model.pFaces[j].sCogTriggeredID) {
122  if (new_model.pFaces[j].HasEventHint())
123  new_model.pFaces[j].uAttributes |= FACE_HAS_EVENT;
124  else
125  new_model.pFaces[j].uAttributes &= ~FACE_HAS_EVENT;
126  }
127  }
128 
129  free((void *)textureFilenames);
130 
131  model_index++;
132  }
133 
134  return data;
135 }

Перекрестные ссылки BSPModel::field_40, BSPModel::index, BSPModel::pFaces, BSPModel::pFacesOrdering, BSPModel::pModelName, BSPModel::pModelName2, BSPModel::pNodes, BSPVertexBuffer::pVertices, BSPModel::pVertices, BSPModel::sBoundingRadius, BSPModel::sCenterX, BSPModel::sCenterY, BSPModel::sMaxX, BSPModel::sMaxY, BSPModel::sMaxZ, BSPModel::sMinX, BSPModel::sMinY, BSPModel::sMinZ, BSPModel::sSomeOtherMaxX, BSPModel::sSomeOtherMaxY, BSPModel::sSomeOtherMaxZ, BSPModel::sSomeOtherMinX, BSPModel::sSomeOtherMinY, BSPModel::sSomeOtherMinZ, BSPModel::vBoundingCenter и BSPModel::vPosition.

Используется в OutdoorLocation::Load().

+ Граф вызова функции:

Объявления и описания членов классов находятся в файлах:
uint16_t
unsigned __int16 uint16_t
Definition: SDL_config.h:37
BSPModel::sSomeOtherMinX
int32_t sSomeOtherMinX
Definition: BSPModel.h:180
BSPModel::pVertices
struct BSPVertexBuffer pVertices
Definition: BSPModel.h:189
face
GLenum GLuint GLint GLenum face
Definition: SDL_opengl_glext.h:3022
BSPModelData::pModelName
char pModelName[32]
Definition: BSPModel.h:59
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
BSPModel::index
unsigned int index
Definition: BSPModel.h:167
BSPModelData::sMinZ
int32_t sMinZ
Definition: BSPModel.h:76
BSPModelData::sSomeOtherMaxX
int32_t sSomeOtherMaxX
Definition: BSPModel.h:83
BSPModelData
Definition: BSPModel.h:58
BSPModel::sMaxX
int32_t sMaxX
Definition: BSPModel.h:177
BSPModel::sCenterY
int32_t sCenterY
Definition: BSPModel.h:172
BSPModel::sBoundingRadius
int32_t sBoundingRadius
Definition: BSPModel.h:187
BSPModel::sCenterX
int32_t sCenterX
Definition: BSPModel.h:171
BSPModel::sSomeOtherMinZ
int32_t sSomeOtherMinZ
Definition: BSPModel.h:182
BSPModelData::sCenterX
int32_t sCenterX
Definition: BSPModel.h:71
ODMFace_MM7
Definition: BSPModel.cpp:11
BSPNode
Definition: BSPModel.h:42
BSPModel::sMinZ
int32_t sMinZ
Definition: BSPModel.h:176
BSPModel::pFacesOrdering
uint16_t * pFacesOrdering
Definition: BSPModel.h:191
BSPModel::sMinY
int32_t sMinY
Definition: BSPModel.h:175
BSPModelData::sMinY
int32_t sMinY
Definition: BSPModel.h:75
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
BSPModelData::sMinX
int32_t sMinX
Definition: BSPModel.h:74
BSPModel::sMinX
int32_t sMinX
Definition: BSPModel.h:174
BSPModelData::field_40
int32_t field_40
Definition: BSPModel.h:61
BSPModelData::sSomeOtherMaxY
int32_t sSomeOtherMaxY
Definition: BSPModel.h:84
BSPModelData::sSomeOtherMinX
int32_t sSomeOtherMinX
Definition: BSPModel.h:80
BSPModelData::uNumFaces
uint32_t uNumFaces
Definition: BSPModel.h:64
BSPModelData::uNumVertices
uint32_t uNumVertices
Definition: BSPModel.h:62
BSPModelData::sSomeOtherMinZ
int32_t sSomeOtherMinZ
Definition: BSPModel.h:82
BSPModelData::sMaxZ
int32_t sMaxZ
Definition: BSPModel.h:79
BSPModel::sMaxY
int32_t sMaxY
Definition: BSPModel.h:178
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
BSPModel::sSomeOtherMaxY
int32_t sSomeOtherMaxY
Definition: BSPModel.h:184
BSPModelData::uNumNodes
uint32_t uNumNodes
Definition: BSPModel.h:68
BSPModelData::sMaxX
int32_t sMaxX
Definition: BSPModel.h:77
BSPModel::pModelName2
String pModelName2
Definition: BSPModel.h:169
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
BSPVertexBuffer::pVertices
Vec3_int_ * pVertices
Definition: BSPModel.h:53
BSPModelData::sSomeOtherMaxZ
int32_t sSomeOtherMaxZ
Definition: BSPModel.h:85
BSPModel::field_40
int32_t field_40
Definition: BSPModel.h:170
BSPModelData::vPosition
Vec3_int_ vPosition
Definition: BSPModel.h:73
BSPModel
Definition: BSPModel.h:163
BSPModel::sSomeOtherMaxZ
int32_t sSomeOtherMaxZ
Definition: BSPModel.h:185
uint32_t
unsigned __int32 uint32_t
Definition: SDL_config.h:39
BSPModelData::sBoundingRadius
int32_t sBoundingRadius
Definition: BSPModel.h:87
BSPModel::sMaxZ
int32_t sMaxZ
Definition: BSPModel.h:179