|
|
@ -33,6 +33,8 @@
|
|
|
|
#include <OgreSubMesh.h>
|
|
|
|
#include <OgreSubMesh.h>
|
|
|
|
#include <OgreRoot.h>
|
|
|
|
#include <OgreRoot.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <boost/lexical_cast.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
#include <extern/shiny/Main/Factory.hpp>
|
|
|
|
#include <extern/shiny/Main/Factory.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
#include <components/settings/settings.hpp>
|
|
|
|
#include <components/settings/settings.hpp>
|
|
|
@ -260,8 +262,8 @@ void NIFLoader::createMaterial(const String &name,
|
|
|
|
NifOverrides::TransparencyResult result = NifOverrides::Overrides::getTransparencyOverride(texName);
|
|
|
|
NifOverrides::TransparencyResult result = NifOverrides::Overrides::getTransparencyOverride(texName);
|
|
|
|
if (result.first)
|
|
|
|
if (result.first)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
instance->setProperty("alpha_rejection_func", sh::makeProperty<sh::StringValue>(new sh::StringValue("greater_equal")));
|
|
|
|
instance->setProperty("alpha_rejection",
|
|
|
|
instance->setProperty("alpha_rejection_value", sh::makeProperty<sh::IntValue>(new sh::IntValue(result.second)));
|
|
|
|
sh::makeProperty<sh::StringValue>(new sh::StringValue("greater_equal " + boost::lexical_cast<std::string>(result.second))));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -272,81 +274,34 @@ void NIFLoader::createMaterial(const String &name,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
warn("Unhandled alpha setting for texture " + texName);
|
|
|
|
warn("Unhandled alpha setting for texture " + texName);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
// As of yet UNTESTED code from Chris:
|
|
|
|
if (!texName.empty())
|
|
|
|
/*pass->setTextureFiltering(Ogre::TFO_ANISOTROPIC);
|
|
|
|
{
|
|
|
|
pass->setDepthFunction(Ogre::CMPF_LESS_EQUAL);
|
|
|
|
Pass *pass = material->getTechnique(0)->getPass(0);
|
|
|
|
pass->setDepthCheckEnabled(true);
|
|
|
|
/*TextureUnitState *txt =*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
pass->createTextureUnitState(texName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pass->setVertexColourTracking(TVC_DIFFUSE);
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
// As of yet UNTESTED code from Chris:
|
|
|
|
|
|
|
|
/*pass->setTextureFiltering(Ogre::TFO_ANISOTROPIC);
|
|
|
|
|
|
|
|
pass->setDepthFunction(Ogre::CMPF_LESS_EQUAL);
|
|
|
|
|
|
|
|
pass->setDepthCheckEnabled(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add transparency if NiAlphaProperty was present
|
|
|
|
// Add transparency if NiAlphaProperty was present
|
|
|
|
if (alphaFlags != -1)
|
|
|
|
if (alphaFlags != -1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::cout << "Alpha flags set!" << endl;
|
|
|
|
|
|
|
|
if ((alphaFlags&1))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::cout << "Alpha flags set!" << endl;
|
|
|
|
pass->setDepthWriteEnabled(false);
|
|
|
|
if ((alphaFlags&1))
|
|
|
|
pass->setSceneBlending(getBlendFactor((alphaFlags>>1)&0xf),
|
|
|
|
{
|
|
|
|
getBlendFactor((alphaFlags>>5)&0xf));
|
|
|
|
pass->setDepthWriteEnabled(false);
|
|
|
|
|
|
|
|
pass->setSceneBlending(getBlendFactor((alphaFlags>>1)&0xf),
|
|
|
|
|
|
|
|
getBlendFactor((alphaFlags>>5)&0xf));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
pass->setDepthWriteEnabled(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((alphaFlags>>9)&1)
|
|
|
|
|
|
|
|
pass->setAlphaRejectSettings(getTestMode((alphaFlags>>10)&0x7),
|
|
|
|
|
|
|
|
alphaTest);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pass->setTransparentSortingEnabled(!((alphaFlags>>13)&1));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
pass->setDepthWriteEnabled(true); */
|
|
|
|
pass->setDepthWriteEnabled(true);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
if ((alphaFlags>>9)&1)
|
|
|
|
// Add transparency if NiAlphaProperty was present
|
|
|
|
pass->setAlphaRejectSettings(getTestMode((alphaFlags>>10)&0x7),
|
|
|
|
if (alphaFlags != -1)
|
|
|
|
alphaTest);
|
|
|
|
{
|
|
|
|
|
|
|
|
// The 237 alpha flags are by far the most common. Check
|
|
|
|
|
|
|
|
// NiAlphaProperty in nif/property.h if you need to decode
|
|
|
|
|
|
|
|
// other values. 237 basically means normal transparencly.
|
|
|
|
|
|
|
|
if (alphaFlags == 237)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NifOverrides::TransparencyResult result = NifOverrides::Overrides::getTransparencyOverride(texName);
|
|
|
|
|
|
|
|
if (result.first)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pass->setAlphaRejectFunction(CMPF_GREATER_EQUAL);
|
|
|
|
|
|
|
|
pass->setAlphaRejectValue(result.second);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Enable transparency
|
|
|
|
|
|
|
|
pass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//pass->setDepthCheckEnabled(false);
|
|
|
|
pass->setTransparentSortingEnabled(!((alphaFlags>>13)&1));
|
|
|
|
pass->setDepthWriteEnabled(false);
|
|
|
|
|
|
|
|
//std::cout << "alpha 237; material: " << name << " texName: " << texName << std::endl;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
warn("Unhandled alpha setting for texture " + texName);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
material->getTechnique(0)->setShadowCasterMaterial("depth_shadow_caster_noalpha");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
else
|
|
|
|
|
|
|
|
pass->setDepthWriteEnabled(true); */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Takes a name and adds a unique part to it. This is just used to
|
|
|
|
// Takes a name and adds a unique part to it. This is just used to
|
|
|
|