| 1 | |
|---|
| 2 | #include "VBSPEntity.h" |
|---|
| 3 | #include "VBSPGeometry.h" |
|---|
| 4 | |
|---|
| 5 | #include <osg/MatrixTransform> |
|---|
| 6 | #include <osgDB/ReadFile> |
|---|
| 7 | #include <osgDB/FileUtils> |
|---|
| 8 | #include <osgDB/FileNameUtils> |
|---|
| 9 | #include <iostream> |
|---|
| 10 | #include <sstream> |
|---|
| 11 | #include <stdlib.h> |
|---|
| 12 | #include <string.h> |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | using namespace bsp; |
|---|
| 16 | using namespace osg; |
|---|
| 17 | using namespace osgDB; |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | #ifdef _MSC_VER |
|---|
| 22 | #define strcasecmp _stricmp |
|---|
| 23 | #endif |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | VBSPEntity::VBSPEntity(std::string & entityText, VBSPData * bspData) |
|---|
| 27 | { |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | bsp_data = bspData; |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | entity_visible = false; |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | entity_transformed = false; |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | entity_model_index = -1; |
|---|
| 40 | entity_model.clear(); |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | entity_class = ENTITY_OTHER; |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | parseParameters(entityText); |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | VBSPEntity::~VBSPEntity() |
|---|
| 51 | { |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | void VBSPEntity::processWorldSpawn() |
|---|
| 56 | { |
|---|
| 57 | |
|---|
| 58 | entity_visible = true; |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | entity_transformed = false; |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | entity_model_index = 0; |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | void VBSPEntity::processEnv() |
|---|
| 70 | { |
|---|
| 71 | |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | void VBSPEntity::processFuncBrush() |
|---|
| 76 | { |
|---|
| 77 | |
|---|
| 78 | entity_transformed = true; |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | EntityParameters::iterator param = entity_parameters.find("model"); |
|---|
| 82 | if (param != entity_parameters.end()) |
|---|
| 83 | { |
|---|
| 84 | |
|---|
| 85 | std::string value = (*param).second; |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | |
|---|
| 89 | if (value[0] == '*') |
|---|
| 90 | { |
|---|
| 91 | value = value.substr(1, std::string::npos); |
|---|
| 92 | entity_model_index = atoi(value.c_str()); |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | entity_visible = true; |
|---|
| 96 | } |
|---|
| 97 | else |
|---|
| 98 | { |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | entity_visible = false; |
|---|
| 102 | } |
|---|
| 103 | } |
|---|
| 104 | else |
|---|
| 105 | { |
|---|
| 106 | |
|---|
| 107 | entity_visible = false; |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | param = entity_parameters.find("origin"); |
|---|
| 112 | if (param != entity_parameters.end()) |
|---|
| 113 | { |
|---|
| 114 | |
|---|
| 115 | std::string value = (*param).second; |
|---|
| 116 | |
|---|
| 117 | |
|---|
| 118 | entity_origin = getVector(value); |
|---|
| 119 | } |
|---|
| 120 | param = entity_parameters.find("angles"); |
|---|
| 121 | if (param != entity_parameters.end()) |
|---|
| 122 | { |
|---|
| 123 | |
|---|
| 124 | std::string value = (*param).second; |
|---|
| 125 | |
|---|
| 126 | |
|---|
| 127 | entity_angles = getVector(value); |
|---|
| 128 | } |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | void VBSPEntity::processProp() |
|---|
| 133 | { |
|---|
| 134 | |
|---|
| 135 | entity_visible = true; |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | entity_transformed = true; |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | EntityParameters::iterator param = entity_parameters.find("model"); |
|---|
| 142 | if (param != entity_parameters.end()) |
|---|
| 143 | { |
|---|
| 144 | |
|---|
| 145 | entity_model = (*param).second; |
|---|
| 146 | } |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | param = entity_parameters.find("origin"); |
|---|
| 150 | if (param != entity_parameters.end()) |
|---|
| 151 | { |
|---|
| 152 | |
|---|
| 153 | std::string value = (*param).second; |
|---|
| 154 | |
|---|
| 155 | |
|---|
| 156 | entity_origin = getVector(value); |
|---|
| 157 | } |
|---|
| 158 | param = entity_parameters.find("angles"); |
|---|
| 159 | if (param != entity_parameters.end()) |
|---|
| 160 | { |
|---|
| 161 | |
|---|
| 162 | std::string value = (*param).second; |
|---|
| 163 | |
|---|
| 164 | |
|---|
| 165 | entity_angles = getVector(value); |
|---|
| 166 | } |
|---|
| 167 | } |
|---|
| 168 | |
|---|
| 169 | |
|---|
| 170 | void VBSPEntity::processInfoDecal() |
|---|
| 171 | { |
|---|
| 172 | |
|---|
| 173 | } |
|---|
| 174 | |
|---|
| 175 | |
|---|
| 176 | void VBSPEntity::processItem() |
|---|
| 177 | { |
|---|
| 178 | |
|---|
| 179 | } |
|---|
| 180 | |
|---|
| 181 | |
|---|
| 182 | Vec3f VBSPEntity::getVector(std::string str) |
|---|
| 183 | { |
|---|
| 184 | float x, y, z; |
|---|
| 185 | |
|---|
| 186 | |
|---|
| 187 | std::string::size_type start = str.find_first_not_of(" \t\r\n", 0); |
|---|
| 188 | |
|---|
| 189 | |
|---|
| 190 | std::string::size_type end = str.find_first_of(" \t\r\n", start); |
|---|
| 191 | |
|---|
| 192 | if ((end > start) && (start != std::string::npos)) |
|---|
| 193 | x = osg::asciiToFloat(str.substr(start, end-start).c_str()); |
|---|
| 194 | else |
|---|
| 195 | return Vec3f(); |
|---|
| 196 | |
|---|
| 197 | |
|---|
| 198 | start = str.find_first_not_of(" \t\r\n", end+1); |
|---|
| 199 | |
|---|
| 200 | |
|---|
| 201 | end = str.find_first_of(" \t\r\n", start); |
|---|
| 202 | |
|---|
| 203 | if ((end > start) && (start != std::string::npos)) |
|---|
| 204 | y = osg::asciiToFloat(str.substr(start, end-start).c_str()); |
|---|
| 205 | else |
|---|
| 206 | return Vec3f(); |
|---|
| 207 | |
|---|
| 208 | |
|---|
| 209 | start = str.find_first_not_of(" \t\r\n", end+1); |
|---|
| 210 | |
|---|
| 211 | |
|---|
| 212 | end = str.find_first_of(" \t\r\n", start); |
|---|
| 213 | if (end == std::string::npos) |
|---|
| 214 | end = str.length(); |
|---|
| 215 | |
|---|
| 216 | if ((end > start) && (start != std::string::npos)) |
|---|
| 217 | z = osg::asciiToFloat(str.substr(start, end-start).c_str()); |
|---|
| 218 | else |
|---|
| 219 | return Vec3f(); |
|---|
| 220 | |
|---|
| 221 | |
|---|
| 222 | return Vec3f(x, y, z); |
|---|
| 223 | } |
|---|
| 224 | |
|---|
| 225 | |
|---|
| 226 | std::string VBSPEntity::getToken(std::string str, size_t & index) |
|---|
| 227 | { |
|---|
| 228 | std::string::size_type end = std::string::npos; |
|---|
| 229 | std::string token; |
|---|
| 230 | |
|---|
| 231 | |
|---|
| 232 | std::string::size_type start = str.find_first_of("\"", index); |
|---|
| 233 | if (start != std::string::npos) |
|---|
| 234 | { |
|---|
| 235 | |
|---|
| 236 | start++; |
|---|
| 237 | end = str.find_first_of("\"", start); |
|---|
| 238 | if (end != std::string::npos) |
|---|
| 239 | { |
|---|
| 240 | |
|---|
| 241 | token = str.substr(start, end-start); |
|---|
| 242 | } |
|---|
| 243 | else |
|---|
| 244 | { |
|---|
| 245 | |
|---|
| 246 | |
|---|
| 247 | token = str.substr(start); |
|---|
| 248 | } |
|---|
| 249 | } |
|---|
| 250 | else |
|---|
| 251 | { |
|---|
| 252 | |
|---|
| 253 | token.clear(); |
|---|
| 254 | } |
|---|
| 255 | |
|---|
| 256 | |
|---|
| 257 | |
|---|
| 258 | if (end != std::string::npos) |
|---|
| 259 | index = end+1; |
|---|
| 260 | else |
|---|
| 261 | index = std::string::npos; |
|---|
| 262 | |
|---|
| 263 | |
|---|
| 264 | return token; |
|---|
| 265 | } |
|---|
| 266 | |
|---|
| 267 | |
|---|
| 268 | void VBSPEntity::parseParameters(std::string & entityText) |
|---|
| 269 | { |
|---|
| 270 | |
|---|
| 271 | std::istringstream str(entityText, std::istringstream::in); |
|---|
| 272 | |
|---|
| 273 | |
|---|
| 274 | while (!str.eof()) |
|---|
| 275 | { |
|---|
| 276 | |
|---|
| 277 | std::string line; |
|---|
| 278 | std::getline(str, line); |
|---|
| 279 | |
|---|
| 280 | |
|---|
| 281 | size_t start = 0; |
|---|
| 282 | std::string token = getToken(line, start); |
|---|
| 283 | |
|---|
| 284 | |
|---|
| 285 | |
|---|
| 286 | while (!token.empty()) |
|---|
| 287 | { |
|---|
| 288 | |
|---|
| 289 | std::string key = token; |
|---|
| 290 | |
|---|
| 291 | |
|---|
| 292 | start++; |
|---|
| 293 | token = getToken(line, start); |
|---|
| 294 | |
|---|
| 295 | |
|---|
| 296 | if (!token.empty()) |
|---|
| 297 | { |
|---|
| 298 | |
|---|
| 299 | |
|---|
| 300 | EntityParameter param(key, token); |
|---|
| 301 | entity_parameters.insert(param); |
|---|
| 302 | } |
|---|
| 303 | } |
|---|
| 304 | } |
|---|
| 305 | |
|---|
| 306 | |
|---|
| 307 | |
|---|
| 308 | EntityParameters::iterator param = entity_parameters.find("classname"); |
|---|
| 309 | |
|---|
| 310 | |
|---|
| 311 | if (param == entity_parameters.end()) |
|---|
| 312 | { |
|---|
| 313 | |
|---|
| 314 | return; |
|---|
| 315 | } |
|---|
| 316 | |
|---|
| 317 | |
|---|
| 318 | std::string className = (*param).second; |
|---|
| 319 | if (className.compare("worldspawn") == 0) |
|---|
| 320 | { |
|---|
| 321 | |
|---|
| 322 | |
|---|
| 323 | entity_class = ENTITY_WORLDSPAWN; |
|---|
| 324 | processWorldSpawn(); |
|---|
| 325 | } |
|---|
| 326 | else if (className.compare(0, 3, "env") == 0) |
|---|
| 327 | { |
|---|
| 328 | |
|---|
| 329 | entity_class = ENTITY_ENV; |
|---|
| 330 | processEnv(); |
|---|
| 331 | } |
|---|
| 332 | else if ((className.compare("func_brush") == 0) || |
|---|
| 333 | (className.compare("func_illusionary") == 0) || |
|---|
| 334 | (className.compare("func_wall_toggle") == 0) || |
|---|
| 335 | (className.compare("func_breakable") == 0)) |
|---|
| 336 | { |
|---|
| 337 | |
|---|
| 338 | |
|---|
| 339 | entity_class = ENTITY_FUNC_BRUSH; |
|---|
| 340 | processFuncBrush(); |
|---|
| 341 | } |
|---|
| 342 | else if (className.compare(0, 4, "prop") == 0) |
|---|
| 343 | { |
|---|
| 344 | |
|---|
| 345 | |
|---|
| 346 | entity_class = ENTITY_PROP; |
|---|
| 347 | processProp(); |
|---|
| 348 | } |
|---|
| 349 | else if (className.compare("infodecal") == 0) |
|---|
| 350 | { |
|---|
| 351 | |
|---|
| 352 | |
|---|
| 353 | entity_class = ENTITY_INFO_DECAL; |
|---|
| 354 | processInfoDecal(); |
|---|
| 355 | } |
|---|
| 356 | else if (className.compare(0, 4, "item") == 0) |
|---|
| 357 | { |
|---|
| 358 | |
|---|
| 359 | |
|---|
| 360 | |
|---|
| 361 | |
|---|
| 362 | entity_class = ENTITY_ITEM; |
|---|
| 363 | processItem(); |
|---|
| 364 | } |
|---|
| 365 | } |
|---|
| 366 | |
|---|
| 367 | |
|---|
| 368 | ref_ptr<Group> VBSPEntity::createBrushGeometry() |
|---|
| 369 | { |
|---|
| 370 | int i; |
|---|
| 371 | int numGeoms; |
|---|
| 372 | VBSPGeometry ** vbspGeomList; |
|---|
| 373 | Model currentModel; |
|---|
| 374 | Face currentFace; |
|---|
| 375 | TexInfo currentTexInfo; |
|---|
| 376 | TexData currentTexData; |
|---|
| 377 | const char * texName; |
|---|
| 378 | char currentTexName[256]; |
|---|
| 379 | int currentGeomIndex; |
|---|
| 380 | VBSPGeometry * currentGeom; |
|---|
| 381 | ref_ptr<Group> entityGroup; |
|---|
| 382 | ref_ptr<Group> geomGroup; |
|---|
| 383 | |
|---|
| 384 | |
|---|
| 385 | |
|---|
| 386 | |
|---|
| 387 | |
|---|
| 388 | numGeoms = bsp_data->getNumStateSets(); |
|---|
| 389 | vbspGeomList = new VBSPGeometry *[numGeoms]; |
|---|
| 390 | |
|---|
| 391 | |
|---|
| 392 | |
|---|
| 393 | memset(vbspGeomList, 0, sizeof(VBSPGeometry *) * numGeoms); |
|---|
| 394 | |
|---|
| 395 | |
|---|
| 396 | currentModel = bsp_data->getModel(entity_model_index); |
|---|
| 397 | |
|---|
| 398 | |
|---|
| 399 | |
|---|
| 400 | for (i = 0; i < currentModel.num_faces; i++) |
|---|
| 401 | { |
|---|
| 402 | |
|---|
| 403 | currentFace = bsp_data->getFace(currentModel.first_face + i); |
|---|
| 404 | |
|---|
| 405 | |
|---|
| 406 | currentTexInfo = bsp_data->getTexInfo(currentFace.texinfo_index); |
|---|
| 407 | currentTexData = bsp_data->getTexData(currentTexInfo.texdata_index); |
|---|
| 408 | |
|---|
| 409 | |
|---|
| 410 | texName = bsp_data-> |
|---|
| 411 | getTexDataString(currentTexData.name_string_table_id).c_str(); |
|---|
| 412 | strcpy(currentTexName, texName); |
|---|
| 413 | |
|---|
| 414 | |
|---|
| 415 | if ((strcasecmp(currentTexName, "tools/toolsareaportal") != 0) && |
|---|
| 416 | (strcasecmp(currentTexName, "tools/toolsblocklos") != 0) && |
|---|
| 417 | (strcasecmp(currentTexName, "tools/toolsblockbullets") != 0) && |
|---|
| 418 | (strcasecmp(currentTexName, "tools/toolsblocklight") != 0) && |
|---|
| 419 | (strcasecmp(currentTexName, "tools/toolsclip") != 0) && |
|---|
| 420 | (strcasecmp(currentTexName, "tools/toolscontrolclip") != 0) && |
|---|
| 421 | (strcasecmp(currentTexName, "tools/toolsdotted") != 0) && |
|---|
| 422 | (strcasecmp(currentTexName, "tools/toolshint") != 0) && |
|---|
| 423 | (strcasecmp(currentTexName, "tools/toolsinvisible") != 0) && |
|---|
| 424 | (strcasecmp(currentTexName, "tools/toolsinvisibleladder") != 0) && |
|---|
| 425 | (strcasecmp(currentTexName, "tools/toolsnodraw") != 0) && |
|---|
| 426 | (strcasecmp(currentTexName, "tools/toolsnpcclip") != 0) && |
|---|
| 427 | (strcasecmp(currentTexName, "tools/toolsoccluder") != 0) && |
|---|
| 428 | (strcasecmp(currentTexName, "tools/toolsorigin") != 0) && |
|---|
| 429 | (strcasecmp(currentTexName, "tools/toolsskip") != 0) && |
|---|
| 430 | (strcasecmp(currentTexName, "tools/toolsskybox") != 0) && |
|---|
| 431 | (strcasecmp(currentTexName, "tools/toolsskyfog") != 0) && |
|---|
| 432 | (strcasecmp(currentTexName, "tools/toolstrigger") != 0)) |
|---|
| 433 | { |
|---|
| 434 | |
|---|
| 435 | |
|---|
| 436 | currentGeomIndex = currentTexInfo.texdata_index; |
|---|
| 437 | currentGeom = vbspGeomList[currentGeomIndex]; |
|---|
| 438 | if (currentGeom == NULL) |
|---|
| 439 | { |
|---|
| 440 | |
|---|
| 441 | vbspGeomList[currentGeomIndex] = new VBSPGeometry(bsp_data); |
|---|
| 442 | currentGeom = vbspGeomList[currentGeomIndex]; |
|---|
| 443 | } |
|---|
| 444 | |
|---|
| 445 | |
|---|
| 446 | currentGeom->addFace(currentModel.first_face + i); |
|---|
| 447 | } |
|---|
| 448 | } |
|---|
| 449 | |
|---|
| 450 | |
|---|
| 451 | if (entity_transformed) |
|---|
| 452 | { |
|---|
| 453 | |
|---|
| 454 | MatrixTransform * entityXform = new MatrixTransform(); |
|---|
| 455 | |
|---|
| 456 | |
|---|
| 457 | |
|---|
| 458 | Matrixf transMat, rotMat; |
|---|
| 459 | Quat roll, yaw, pitch; |
|---|
| 460 | transMat.makeTranslate(entity_origin * 0.0254); |
|---|
| 461 | pitch.makeRotate(osg::DegreesToRadians(entity_angles.x()), |
|---|
| 462 | Vec3f(0.0, 1.0, 0.0)); |
|---|
| 463 | yaw.makeRotate(osg::DegreesToRadians(entity_angles.y()), |
|---|
| 464 | Vec3f(0.0, 0.0, 1.0)); |
|---|
| 465 | roll.makeRotate(osg::DegreesToRadians(entity_angles.z()), |
|---|
| 466 | Vec3f(1.0, 0.0, 0.0)); |
|---|
| 467 | rotMat.makeRotate(roll * pitch * yaw); |
|---|
| 468 | |
|---|
| 469 | |
|---|
| 470 | entityXform->setMatrix(rotMat * transMat); |
|---|
| 471 | |
|---|
| 472 | |
|---|
| 473 | entityGroup = entityXform; |
|---|
| 474 | } |
|---|
| 475 | else |
|---|
| 476 | { |
|---|
| 477 | |
|---|
| 478 | entityGroup = new Group(); |
|---|
| 479 | } |
|---|
| 480 | |
|---|
| 481 | |
|---|
| 482 | |
|---|
| 483 | for (i = 0; i < numGeoms; i++) |
|---|
| 484 | { |
|---|
| 485 | |
|---|
| 486 | currentGeom = vbspGeomList[i]; |
|---|
| 487 | if (currentGeom != NULL) |
|---|
| 488 | { |
|---|
| 489 | |
|---|
| 490 | geomGroup = currentGeom->createGeometry(); |
|---|
| 491 | |
|---|
| 492 | |
|---|
| 493 | if (geomGroup.valid()) |
|---|
| 494 | { |
|---|
| 495 | |
|---|
| 496 | geomGroup->setStateSet(bsp_data->getStateSet(i)); |
|---|
| 497 | |
|---|
| 498 | |
|---|
| 499 | entityGroup->addChild(geomGroup.get()); |
|---|
| 500 | } |
|---|
| 501 | } |
|---|
| 502 | } |
|---|
| 503 | |
|---|
| 504 | |
|---|
| 505 | return entityGroup; |
|---|
| 506 | } |
|---|
| 507 | |
|---|
| 508 | |
|---|
| 509 | ref_ptr<Group> VBSPEntity::createModelGeometry() |
|---|
| 510 | { |
|---|
| 511 | std::string modelFile; |
|---|
| 512 | ref_ptr<Node> modelNode; |
|---|
| 513 | ref_ptr<Group> entityGroup; |
|---|
| 514 | |
|---|
| 515 | |
|---|
| 516 | modelNode = osgDB::readNodeFile(entity_model); |
|---|
| 517 | if (modelNode.valid()) |
|---|
| 518 | { |
|---|
| 519 | |
|---|
| 520 | if (entity_transformed) |
|---|
| 521 | { |
|---|
| 522 | |
|---|
| 523 | MatrixTransform * entityXform = new MatrixTransform(); |
|---|
| 524 | |
|---|
| 525 | |
|---|
| 526 | |
|---|
| 527 | Matrixf transMat, rotMat; |
|---|
| 528 | Quat roll, yaw, pitch; |
|---|
| 529 | transMat.makeTranslate(entity_origin * 0.0254); |
|---|
| 530 | pitch.makeRotate(osg::DegreesToRadians(entity_angles.x()), |
|---|
| 531 | Vec3f(0.0, 1.0, 0.0)); |
|---|
| 532 | yaw.makeRotate(osg::DegreesToRadians(entity_angles.y()), |
|---|
| 533 | Vec3f(0.0, 0.0, 1.0)); |
|---|
| 534 | roll.makeRotate(osg::DegreesToRadians(entity_angles.z()), |
|---|
| 535 | Vec3f(1.0, 0.0, 0.0)); |
|---|
| 536 | rotMat.makeRotate(roll * pitch * yaw); |
|---|
| 537 | |
|---|
| 538 | |
|---|
| 539 | entityXform->setMatrix(rotMat * transMat); |
|---|
| 540 | |
|---|
| 541 | |
|---|
| 542 | entityGroup = entityXform; |
|---|
| 543 | } |
|---|
| 544 | else |
|---|
| 545 | { |
|---|
| 546 | |
|---|
| 547 | entityGroup = new Group(); |
|---|
| 548 | } |
|---|
| 549 | |
|---|
| 550 | |
|---|
| 551 | entityGroup->addChild(modelNode.get()); |
|---|
| 552 | } |
|---|
| 553 | else |
|---|
| 554 | { |
|---|
| 555 | notify(WARN) << "Couldn't find prop \"" << entity_model << "\"."; |
|---|
| 556 | notify(WARN) << std::endl; |
|---|
| 557 | |
|---|
| 558 | |
|---|
| 559 | entityGroup = NULL; |
|---|
| 560 | } |
|---|
| 561 | |
|---|
| 562 | return entityGroup; |
|---|
| 563 | } |
|---|
| 564 | |
|---|
| 565 | |
|---|
| 566 | EntityClass VBSPEntity::getClass() |
|---|
| 567 | { |
|---|
| 568 | return entity_class; |
|---|
| 569 | } |
|---|
| 570 | |
|---|
| 571 | |
|---|
| 572 | bool VBSPEntity::isVisible() |
|---|
| 573 | { |
|---|
| 574 | return entity_visible; |
|---|
| 575 | } |
|---|
| 576 | |
|---|
| 577 | |
|---|
| 578 | ref_ptr<Group> VBSPEntity::createGeometry() |
|---|
| 579 | { |
|---|
| 580 | |
|---|
| 581 | if (!entity_visible) |
|---|
| 582 | return NULL; |
|---|
| 583 | |
|---|
| 584 | |
|---|
| 585 | if ((entity_class == ENTITY_WORLDSPAWN) || |
|---|
| 586 | (entity_class == ENTITY_FUNC_BRUSH)) |
|---|
| 587 | { |
|---|
| 588 | return createBrushGeometry(); |
|---|
| 589 | } |
|---|
| 590 | else if (entity_class == ENTITY_PROP) |
|---|
| 591 | { |
|---|
| 592 | return createModelGeometry(); |
|---|
| 593 | } |
|---|
| 594 | |
|---|
| 595 | |
|---|
| 596 | return NULL; |
|---|
| 597 | } |
|---|