Implement drawMode of NiStencilProperty (Feature #1057)

report
scrawl 10 years ago
parent 14ae6d28b0
commit b650338d69

@ -9,10 +9,11 @@ void Node::getProperties(const Nif::NiTexturingProperty *&texprop,
const Nif::NiVertexColorProperty *&vertprop,
const Nif::NiZBufferProperty *&zprop,
const Nif::NiSpecularProperty *&specprop,
const Nif::NiWireframeProperty *&wireprop) const
const Nif::NiWireframeProperty *&wireprop,
const Nif::NiStencilProperty *&stencilprop) const
{
if(parent)
parent->getProperties(texprop, matprop, alphaprop, vertprop, zprop, specprop, wireprop);
parent->getProperties(texprop, matprop, alphaprop, vertprop, zprop, specprop, wireprop, stencilprop);
for(size_t i = 0;i < props.length();i++)
{
@ -35,6 +36,8 @@ void Node::getProperties(const Nif::NiTexturingProperty *&texprop,
specprop = static_cast<const Nif::NiSpecularProperty*>(pr);
else if(pr->recType == Nif::RC_NiWireframeProperty)
wireprop = static_cast<const Nif::NiWireframeProperty*>(pr);
else if (pr->recType == Nif::RC_NiStencilProperty)
stencilprop = static_cast<const Nif::NiStencilProperty*>(pr);
else
std::cerr<< "Unhandled property type: "<<pr->recName <<std::endl;
}

@ -98,7 +98,8 @@ public:
const Nif::NiVertexColorProperty *&vertprop,
const Nif::NiZBufferProperty *&zprop,
const Nif::NiSpecularProperty *&specprop,
const Nif::NiWireframeProperty *&wireprop) const;
const Nif::NiWireframeProperty *&wireprop,
const Nif::NiStencilProperty *&stencilprop) const;
Ogre::Matrix4 getLocalTransform() const;
Ogre::Matrix4 getWorldTransform() const;

@ -85,6 +85,7 @@ Ogre::String NIFMaterialLoader::getMaterial(const Nif::ShapeData *shapedata,
const Nif::NiZBufferProperty *zprop,
const Nif::NiSpecularProperty *specprop,
const Nif::NiWireframeProperty *wireprop,
const Nif::NiStencilProperty *stencilprop,
bool &needTangents, bool particleMaterial)
{
Ogre::MaterialManager &matMgr = Ogre::MaterialManager::getSingleton();
@ -106,6 +107,7 @@ Ogre::String NIFMaterialLoader::getMaterial(const Nif::ShapeData *shapedata,
// Default should be 1, but Bloodmoon's models are broken
int specFlags = 0;
int wireFlags = 0;
int drawMode = 1;
Ogre::String texName[7];
bool vertexColour = (shapedata->colors.size() != 0);
@ -205,6 +207,20 @@ Ogre::String NIFMaterialLoader::getMaterial(const Nif::ShapeData *shapedata,
}
}
if(stencilprop)
{
drawMode = stencilprop->data.drawMode;
if (stencilprop->data.enabled)
warn("Unhandled stencil test in "+name);
Nif::ControllerPtr ctrls = stencilprop->controller;
while(!ctrls.empty())
{
warn("Unhandled stencil controller "+ctrls->recName+" in "+name);
ctrls = ctrls->next;
}
}
// Material
if(matprop)
{
@ -249,8 +265,13 @@ Ogre::String NIFMaterialLoader::getMaterial(const Nif::ShapeData *shapedata,
for(int i = 0;i < 7;i++)
{
if(!texName[i].empty())
{
boost::hash_combine(h, texName[i]);
boost::hash_combine(h, texprop->textures[i].clamp);
boost::hash_combine(h, texprop->textures[i].uvSet);
}
}
boost::hash_combine(h, drawMode);
boost::hash_combine(h, vertexColour);
boost::hash_combine(h, alphaFlags);
boost::hash_combine(h, alphaTest);
@ -308,6 +329,13 @@ Ogre::String NIFMaterialLoader::getMaterial(const Nif::ShapeData *shapedata,
instance->setProperty("polygon_mode", sh::makeProperty(new sh::StringValue("wireframe")));
}
if (drawMode == 1)
instance->setProperty("cullmode", sh::makeProperty(new sh::StringValue("clockwise")));
else if (drawMode == 2)
instance->setProperty("cullmode", sh::makeProperty(new sh::StringValue("anticlockwise")));
else if (drawMode == 3)
instance->setProperty("cullmode", sh::makeProperty(new sh::StringValue("none")));
instance->setProperty("diffuseMap", sh::makeProperty(texName[Nif::NiTexturingProperty::BaseTexture]));
instance->setProperty("normalMap", sh::makeProperty(texName[Nif::NiTexturingProperty::BumpTexture]));
instance->setProperty("detailMap", sh::makeProperty(texName[Nif::NiTexturingProperty::DetailTexture]));

@ -18,6 +18,7 @@ namespace Nif
class NiZBufferProperty;
class NiSpecularProperty;
class NiWireframeProperty;
class NiStencilProperty;
}
namespace NifOgre
@ -41,6 +42,7 @@ public:
const Nif::NiZBufferProperty *zprop,
const Nif::NiSpecularProperty *specprop,
const Nif::NiWireframeProperty *wireprop,
const Nif::NiStencilProperty *stencilprop,
bool &needTangents, bool particleMaterial=false);
};

@ -320,13 +320,14 @@ void NIFMeshLoader::createSubMesh(Ogre::Mesh *mesh, const Nif::NiTriShape *shape
const Nif::NiZBufferProperty *zprop = NULL;
const Nif::NiSpecularProperty *specprop = NULL;
const Nif::NiWireframeProperty *wireprop = NULL;
const Nif::NiStencilProperty *stencilprop = NULL;
bool needTangents = false;
shape->getProperties(texprop, matprop, alphaprop, vertprop, zprop, specprop, wireprop);
shape->getProperties(texprop, matprop, alphaprop, vertprop, zprop, specprop, wireprop, stencilprop);
std::string matname = NIFMaterialLoader::getMaterial(data, mesh->getName(), mGroup,
texprop, matprop, alphaprop,
vertprop, zprop, specprop,
wireprop, needTangents);
wireprop, stencilprop, needTangents);
if(matname.length() > 0)
sub->setMaterialName(matname);

@ -732,7 +732,8 @@ class NIFObjectLoader
const Nif::NiZBufferProperty *zprop = NULL;
const Nif::NiSpecularProperty *specprop = NULL;
const Nif::NiWireframeProperty *wireprop = NULL;
node->getProperties(texprop, matprop, alphaprop, vertprop, zprop, specprop, wireprop);
const Nif::NiStencilProperty *stencilprop = NULL;
node->getProperties(texprop, matprop, alphaprop, vertprop, zprop, specprop, wireprop, stencilprop);
Ogre::ControllerValueRealPtr srcval((animflags&Nif::NiNode::AnimFlag_AutoPlay) ?
Ogre::ControllerManager::getSingleton().getFrameTimeSource() :
@ -889,13 +890,14 @@ class NIFObjectLoader
const Nif::NiZBufferProperty *zprop = NULL;
const Nif::NiSpecularProperty *specprop = NULL;
const Nif::NiWireframeProperty *wireprop = NULL;
const Nif::NiStencilProperty *stencilprop = NULL;
bool needTangents = false;
partnode->getProperties(texprop, matprop, alphaprop, vertprop, zprop, specprop, wireprop);
partnode->getProperties(texprop, matprop, alphaprop, vertprop, zprop, specprop, wireprop, stencilprop);
partsys->setMaterialName(NIFMaterialLoader::getMaterial(particledata, fullname, group,
texprop, matprop, alphaprop,
vertprop, zprop, specprop,
wireprop, needTangents,
wireprop, stencilprop, needTangents,
// MW doesn't light particles, but the MaterialProperty
// used still has lighting, so that must be ignored.
true));

@ -67,6 +67,7 @@ material openmw_objects_base
depth_check $depth_check
transparent_sorting $transparent_sorting
polygon_mode $polygon_mode
cull_hardware $cullmode
texture_unit diffuseMap
{

Loading…
Cancel
Save