MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / writeToGroupDef

Method writeToGroupDef

src/bzfs/CustomMesh.cpp:215–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213
214
215void CustomMesh::writeToGroupDef(GroupDefinition* groupdef) const {
216 // include the old style parameters
217 MeshTransform xform;
218 if ((size.x != 1.0f) || (size.y != 1.0f) || (size.z != 1.0f)) {
219 xform.addScale(size);
220 }
221 if (rotation != 0.0f) {
222 const fvec3 zAxis(0.0f, 0.0f, 1.0f);
223 xform.addSpin((float)(rotation * (180.0 / M_PI)), zAxis);
224 }
225 if ((pos.x != 0.0f) || (pos.y != 0.0f) || (pos.z != 0.0f)) {
226 xform.addShift(pos);
227 }
228 xform.append(transform);
229
230 // hack to invalidate decorative meshes on older clients
231 bool forcePassable = false;
232 if (drawInfo) {
233 fvec3 vert;
234 if (decorative) {
235 vert.x = vert.y = vert.z = (Obstacle::maxExtent * 2.0f);
236 if ((faces.size() > 0) && !(driveThrough && shootThrough)) {
237 debugf(0, "WARNING: mesh is supposed to be decorative, setting to passable\n");
238 forcePassable = true;
239 }
240 }
241 else {
242 vert.x = vert.y = vert.z = 0.0f;
243 }
244 ((std::vector<fvec3>*)&vertices)->push_back(vert);
245 }
246
247 MeshObstacle* mesh =
248 new MeshObstacle(xform, checkTypes, checkPoints,
249 vertices, normals, texcoords, faces.size(),
250 noclusters, smoothBounce,
251 driveThrough || forcePassable,
252 shootThrough || forcePassable,
253 ricochet);
254
255 mesh->setName(name);
256
257 // add the faces
258 std::vector<CustomMeshFace*>::const_iterator faceIt;
259 for (faceIt = faces.begin(); faceIt != faces.end(); faceIt++) {
260 const CustomMeshFace* customFace = *faceIt;
261 customFace->write(mesh);
262 }
263
264 // add the weapons
265 std::vector<std::vector<std::string>*>::const_iterator weaponIt;
266 for (weaponIt = weapons.begin(); weaponIt != weapons.end(); weaponIt++) {
267 mesh->addWeapon(**weaponIt);
268 }
269
270 mesh->finalize();
271
272 if (!mesh->isValid()) {

Callers

nothing calls this directly

Calls 15

debugfFunction · 0.85
addScaleMethod · 0.80
addSpinMethod · 0.80
addShiftMethod · 0.80
serverSetupMethod · 0.80
setDrawInfoMethod · 0.80
addObstacleMethod · 0.80
appendMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
setNameMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected