191
192
std::string tex2Name;
192
193
ref_ptr<Texture> texture;
193
194
ref_ptr<Texture> texture2;
195
ref_ptr<Material> material;
194
196
ref_ptr<BlendFunc> blend;
195
197
bool translucent;
197
200
// Find the material file
198
201
mtlFileName = std::string(materialName) + ".vmt";
341
347
translucent = true;
350
else if (equalCaseInsensitive(token, "$alpha"))
352
// Get the translucency setting
353
token = getToken(line, " \t\n\r\"", start);
355
// Interpret the setting
358
alpha = osg::asciiToDouble(token.c_str());
345
362
// Try the next token
346
363
token = getToken(line, " \t\n\r\"", start);
379
396
blend = new BlendFunc(BlendFunc::SRC_ALPHA,
380
397
BlendFunc::ONE_MINUS_SRC_ALPHA);
381
398
stateSet->setAttributeAndModes(blend.get(), StateAttribute::ON);
399
stateSet->setMode(GL_BLEND, StateAttribute::ON);
383
401
// Set the rendering hint for this stateset to transparent
384
402
stateSet->setRenderingHint(StateSet::TRANSPARENT_BIN);
389
407
// All other shaders fall back to fixed function
390
// TODO: LightMappedGeneric shader
392
409
// Create the StateSet
393
410
stateSet = new StateSet();
412
// Add a material to the state set
413
material = new Material();
414
material->setAmbient(Material::FRONT_AND_BACK,
415
Vec4(1.0, 1.0, 1.0, 1.0) );
416
material->setDiffuse(Material::FRONT_AND_BACK,
417
Vec4(1.0, 1.0, 1.0, 1.0) );
418
material->setSpecular(Material::FRONT_AND_BACK,
419
Vec4(0.0, 0.0, 0.0, 1.0) );
420
material->setShininess(Material::FRONT_AND_BACK, 1.0);
421
material->setEmission(Material::FRONT_AND_BACK,
422
Vec4(0.0, 0.0, 0.0, 1.0) );
423
material->setAlpha(Material::FRONT_AND_BACK, alpha);
424
stateSet->setAttributeAndModes(material.get(), StateAttribute::ON);
395
426
// Add the texture attribute (or disable texturing if no base texture)
396
427
if (texture != NULL)
399
430
StateAttribute::ON);
401
432
// See if the material is translucent
433
if ((translucent) || (alpha < 1.0))
404
435
// Add the blending attribute as well
405
436
blend = new BlendFunc(BlendFunc::SRC_ALPHA,
406
437
BlendFunc::ONE_MINUS_SRC_ALPHA);
407
438
stateSet->setAttributeAndModes(blend.get(),
408
439
StateAttribute::ON);
440
stateSet->setMode(GL_BLEND, StateAttribute::ON);
410
442
// Set the rendering hint for this stateset to transparent
411
443
stateSet->setRenderingHint(StateSet::TRANSPARENT_BIN);
633
665
mdlRoot->addBodyPart(partNode);
636
// Open the VVD file that goes with this model
668
// Open the VVD (vertex data) file that goes with this model
637
669
vvdFile = findDataFile(getNameLessExtension(file) + ".vvd",
638
670
CASE_INSENSITIVE);
639
671
vvdReader = new VVDReader();
640
672
vvdReader->readFile(vvdFile);
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)
674
// Open the VTX file (index and primitive data) that goes with this model
675
// (at this point, I don't see a reason not to always just use the DX9
644
677
vtxFile = findDataFile(getNameLessExtension(file) + ".dx90.vtx",
645
678
CASE_INSENSITIVE);
646
679
vtxReader = new VTXReader(vvdReader, mdlRoot);