Changeset 10485
- Timestamp:
- 07/16/09 13:42:08 (4 years ago)
- Location:
- OpenSceneGraph/branches/OpenSceneGraph-2.8/src/osgPlugins
- Files:
-
- 8 modified
-
bsp (modified) (1 prop)
-
bsp/VBSPEntity.cpp (modified) (9 diffs)
-
bsp/VBSPEntity.h (modified) (1 diff)
-
bsp/VBSPGeometry.cpp (modified) (2 diffs)
-
bsp/VBSPReader.cpp (modified) (6 diffs)
-
mdl (modified) (1 prop)
-
mdl/MDLReader.cpp (modified) (9 diffs)
-
mdl/MDL_README.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/branches/OpenSceneGraph-2.8/src/osgPlugins/bsp
- Property svn:mergeinfo set to /OpenSceneGraph/trunk/src/osgPlugins/bsp:10482-10484
-
OpenSceneGraph/branches/OpenSceneGraph-2.8/src/osgPlugins/bsp/VBSPEntity.cpp
r10413 r10485 316 316 317 317 // Get the class name and process the entity appropriately 318 std::string className = (*param).second;319 if (class Name.compare("worldspawn") == 0)318 class_name = (*param).second; 319 if (class_name.compare("worldspawn") == 0) 320 320 { 321 321 // This is the entity that represents the main geometry of the map … … 324 324 processWorldSpawn(); 325 325 } 326 else if (class Name.compare(0, 3, "env") == 0)326 else if (class_name.compare(0, 3, "env") == 0) 327 327 { 328 328 // This is an environmental effect (such as a fire or dust cloud) … … 330 330 processEnv(); 331 331 } 332 else if ((class Name.compare("func_brush") == 0) ||333 (class Name.compare("func_illusionary") == 0) ||334 (class Name.compare("func_wall_toggle") == 0) ||335 (class Name.compare("func_breakable") == 0))332 else if ((class_name.compare("func_brush") == 0) || 333 (class_name.compare("func_illusionary") == 0) || 334 (class_name.compare("func_wall_toggle") == 0) || 335 (class_name.compare("func_breakable") == 0)) 336 336 { 337 337 // This is secondary map geometry, created along with the main … … 340 340 processFuncBrush(); 341 341 } 342 else if (class Name.compare(0, 4, "prop") == 0)342 else if (class_name.compare(0, 4, "prop") == 0) 343 343 { 344 344 // This is a "prop", an external model placed somewhere in the … … 347 347 processProp(); 348 348 } 349 else if (class Name.compare("infodecal") == 0)349 else if (class_name.compare("infodecal") == 0) 350 350 { 351 351 // This is a decal, which applies a texture to some surface in the … … 354 354 processInfoDecal(); 355 355 } 356 else if (class Name.compare(0, 4, "item") == 0)356 else if (class_name.compare(0, 4, "item") == 0) 357 357 { 358 358 // This is an "item". Like a prop, these are external models … … 368 368 ref_ptr<Group> VBSPEntity::createBrushGeometry() 369 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; 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 std::stringstream groupName; 383 384 384 385 // Create a list of VBSPGeometry objects for each texdata entry in the … … 502 503 } 503 504 505 // Name the entity group 506 groupName << class_name << ":" << entity_model_index; 507 entityGroup->setName(groupName.str()); 508 504 509 // Return the group we created 505 510 return entityGroup; … … 550 555 // Add the model node to the group 551 556 entityGroup->addChild(modelNode.get()); 557 558 // Set the group's name 559 entityGroup->setName(class_name + std::string(":") + entity_model); 552 560 } 553 561 else -
OpenSceneGraph/branches/OpenSceneGraph-2.8/src/osgPlugins/bsp/VBSPEntity.h
r9425 r10485 33 33 34 34 EntityClass entity_class; 35 std::string class_name; 35 36 36 37 typedef std::pair<std::string, std::string> EntityParameter; -
OpenSceneGraph/branches/OpenSceneGraph-2.8/src/osgPlugins/bsp/VBSPGeometry.cpp
r9539 r10485 2 2 #include <stdlib.h> 3 3 #include <osg/Geode> 4 #include <osgUtil/TriStripVisitor> 4 5 5 6 #include "VBSPGeometry.h" … … 648 649 // Add the geometry to the geode 649 650 geode->addDrawable(geometry.get()); 651 652 // Now, stripify the geode to convert the POLYGON primitives to 653 // triangle strips 654 osgUtil::TriStripVisitor tsv; 655 geode->accept(tsv); 656 tsv.stripify(); 650 657 } 651 658 -
OpenSceneGraph/branches/OpenSceneGraph-2.8/src/osgPlugins/bsp/VBSPReader.cpp
r9586 r10485 746 746 ref_ptr<Texture> texture; 747 747 ref_ptr<Texture> texture2; 748 ref_ptr<Material> material; 748 749 ref_ptr<BlendFunc> blend; 749 750 bool translucent; 751 double alpha; 750 752 751 753 // Find the material file … … 818 820 // Assume no transparency unless the properties say otherwise 819 821 translucent = false; 822 823 // Assume fully opaque 824 alpha = 1.0; 820 825 821 826 // Read the material properties next … … 859 864 translucent = true; 860 865 } 866 else if (equalCaseInsensitive(token, "$alpha")) 867 { 868 // Get the translucency setting 869 token = getToken(line, " \t\n\r\"", start); 870 871 // Interpret the setting 872 if (!token.empty()) 873 { 874 alpha = atof(token.c_str()); 875 } 876 } 861 877 862 878 // Try the next token … … 874 890 // attribute. This is used for displaced terrain surfaces in HL2 maps. 875 891 stateSet = createBlendShader(texture.get(), texture2.get()); 892 893 // Add a material to the state set 894 material = new Material(); 895 material->setAmbient(Material::FRONT_AND_BACK, 896 Vec4(1.0, 1.0, 1.0, 1.0) ); 897 material->setDiffuse(Material::FRONT_AND_BACK, 898 Vec4(1.0, 1.0, 1.0, 1.0) ); 899 material->setSpecular(Material::FRONT_AND_BACK, 900 Vec4(0.0, 0.0, 0.0, 1.0) ); 901 material->setShininess(Material::FRONT_AND_BACK, 1.0); 902 material->setEmission(Material::FRONT_AND_BACK, 903 Vec4(0.0, 0.0, 0.0, 1.0) ); 904 material->setAlpha(Material::FRONT_AND_BACK, alpha); 905 stateSet->setAttributeAndModes(material.get(), StateAttribute::ON); 876 906 } 877 907 else if (equalCaseInsensitive(shaderName, "UnlitGeneric")) … … 916 946 // Create the StateSet 917 947 stateSet = new StateSet(); 948 949 // Add a material to the state set 950 material = new Material(); 951 material->setAmbient(Material::FRONT_AND_BACK, 952 Vec4(1.0, 1.0, 1.0, 1.0) ); 953 material->setDiffuse(Material::FRONT_AND_BACK, 954 Vec4(1.0, 1.0, 1.0, 1.0) ); 955 material->setSpecular(Material::FRONT_AND_BACK, 956 Vec4(0.0, 0.0, 0.0, 1.0) ); 957 material->setShininess(Material::FRONT_AND_BACK, 1.0); 958 material->setEmission(Material::FRONT_AND_BACK, 959 Vec4(0.0, 0.0, 0.0, 1.0) ); 960 material->setAlpha(Material::FRONT_AND_BACK, alpha); 961 stateSet->setAttributeAndModes(material.get(), StateAttribute::ON); 918 962 919 963 // Add the texture attribute (or disable texturing if no base texture) … … 1082 1126 if (propNode.valid()) 1083 1127 { 1128 // Add the model to the transform node, and attach the transform 1129 // to the scene 1084 1130 propXform->addChild(propNode.get()); 1085 1131 group->addChild(propXform.get()); 1132 1133 // Name the prop 1134 propXform->setName(std::string("prop_static:" + propModel)); 1086 1135 } 1087 1136 else -
OpenSceneGraph/branches/OpenSceneGraph-2.8/src/osgPlugins/mdl
- Property svn:mergeinfo changed from /OpenSceneGraph/trunk/src/osgPlugins/mdl:10093 to /OpenSceneGraph/trunk/src/osgPlugins/mdl:10093,10482-10483
-
OpenSceneGraph/branches/OpenSceneGraph-2.8/src/osgPlugins/mdl/MDLReader.cpp
r9527 r10485 192 192 ref_ptr<Texture> texture; 193 193 ref_ptr<Texture> texture2; 194 ref_ptr<Material> material; 194 195 ref_ptr<BlendFunc> blend; 195 196 bool translucent; 197 double alpha; 196 198 197 199 // Find the material file … … 299 301 translucent = false; 300 302 303 // Assume full opacity 304 alpha = 1.0; 305 301 306 // Read the material properties next 302 307 while (!mtlFile->eof()) … … 342 347 } 343 348 } 349 else if (equalCaseInsensitive(token, "$alpha")) 350 { 351 // Get the translucency setting 352 token = getToken(line, " \t\n\r\"", start); 353 354 // Interpret the setting 355 if (!token.empty()) 356 { 357 alpha = atof(token.c_str()); 358 } 359 } 344 360 345 361 // Try the next token … … 380 396 BlendFunc::ONE_MINUS_SRC_ALPHA); 381 397 stateSet->setAttributeAndModes(blend.get(), StateAttribute::ON); 398 stateSet->setMode(GL_BLEND, StateAttribute::ON); 382 399 383 400 // Set the rendering hint for this stateset to transparent … … 388 405 { 389 406 // All other shaders fall back to fixed function 390 // TODO: LightMappedGeneric shader391 407 392 408 // Create the StateSet 393 409 stateSet = new StateSet(); 394 410 411 // Add a material to the state set 412 material = new Material(); 413 material->setAmbient(Material::FRONT_AND_BACK, 414 Vec4(1.0, 1.0, 1.0, 1.0) ); 415 material->setDiffuse(Material::FRONT_AND_BACK, 416 Vec4(1.0, 1.0, 1.0, 1.0) ); 417 material->setSpecular(Material::FRONT_AND_BACK, 418 Vec4(0.0, 0.0, 0.0, 1.0) ); 419 material->setShininess(Material::FRONT_AND_BACK, 1.0); 420 material->setEmission(Material::FRONT_AND_BACK, 421 Vec4(0.0, 0.0, 0.0, 1.0) ); 422 material->setAlpha(Material::FRONT_AND_BACK, alpha); 423 stateSet->setAttributeAndModes(material.get(), StateAttribute::ON); 424 395 425 // Add the texture attribute (or disable texturing if no base texture) 396 426 if (texture != NULL) … … 400 430 401 431 // See if the material is translucent 402 if ( translucent)432 if ((translucent) || (alpha < 1.0)) 403 433 { 404 434 // Add the blending attribute as well … … 407 437 stateSet->setAttributeAndModes(blend.get(), 408 438 StateAttribute::ON); 439 stateSet->setMode(GL_BLEND, StateAttribute::ON); 409 440 410 441 // Set the rendering hint for this stateset to transparent … … 634 665 } 635 666 636 // Open the VVD file that goes with this model667 // Open the VVD (vertex data) file that goes with this model 637 668 vvdFile = findDataFile(getNameLessExtension(file) + ".vvd", 638 669 CASE_INSENSITIVE); … … 640 671 vvdReader->readFile(vvdFile); 641 672 642 // Open the VTX file that goes with this model (at this point, I don't 643 // see a reason not to always just use the DX9 version) 673 // Open the VTX file (index and primitive data) that goes with this model 674 // (at this point, I don't see a reason not to always just use the DX9 675 // version) 644 676 vtxFile = findDataFile(getNameLessExtension(file) + ".dx90.vtx", 645 677 CASE_INSENSITIVE); -
OpenSceneGraph/branches/OpenSceneGraph-2.8/src/osgPlugins/mdl/MDL_README.txt
r9425 r10485 9 9 engine (Half Life 2, etc) to be loaded by OSG. 10 10 11 I've tested this plugin with dozens of on several HL2 models, as well as some12 3rd partymodels.11 I've tested this plugin with dozens of HL2 models, as well as some 3rd party 12 models. 13 13 14 14
