Rewrite NiVertexColorProperty

7220-lua-add-a-general-purpose-lexical-parser
Alexei Kotov 2 years ago
parent d39127cc3d
commit 99aa90f90c

@ -227,10 +227,20 @@ namespace Nif
emissiveMult = nif->getFloat();
}
void S_VertexColorProperty::read(NIFStream* nif)
void NiVertexColorProperty::read(NIFStream* nif)
{
vertmode = nif->getInt();
lightmode = nif->getInt();
Property::read(nif);
mFlags = nif->getUShort();
if (nif->getVersion() <= NIFFile::NIFVersion::VER_OB)
{
mVertexMode = static_cast<VertexMode>(nif->getUInt());
mLightingMode = static_cast<LightMode>(nif->getUInt());
}
else
{
mVertexMode = static_cast<VertexMode>((mFlags >> 4) & 0x3);
mLightingMode = static_cast<LightMode>((mFlags >> 3) & 0x1);
}
}
void S_AlphaProperty::read(NIFStream* nif)

@ -293,22 +293,6 @@ namespace Nif
void read(NIFStream* nif);
};
struct S_VertexColorProperty
{
/* Vertex mode:
0 - source ignore
1 - source emmisive
2 - source amb diff
Lighting mode
0 - lighting emmisive
1 - lighting emmisive ambient/diffuse
*/
int vertmode, lightmode;
void read(NIFStream* nif);
};
struct S_AlphaProperty
{
/*
@ -402,9 +386,28 @@ namespace Nif
int alphaTestMode() const { return (flags >> 10) & 0x7; }
};
struct NiVertexColorProperty : public StructPropT<S_VertexColorProperty>
struct NiVertexColorProperty : public Property
{
enum class VertexMode : unsigned int
{
VertMode_SrcIgnore = 0,
VertMode_SrcEmissive = 1,
VertMode_SrcAmbDif = 2
};
enum class LightMode : unsigned int
{
LightMode_Emissive = 0,
LightMode_EmiAmbDif = 1
};
unsigned short mFlags;
VertexMode mVertexMode;
LightMode mLightingMode;
void read(NIFStream* nif) override;
};
struct NiStencilProperty : public Property
{
S_StencilProperty data;

@ -2300,23 +2300,39 @@ namespace NifOsg
{
const Nif::NiVertexColorProperty* vertprop
= static_cast<const Nif::NiVertexColorProperty*>(property);
lightmode = vertprop->data.lightmode;
switch (vertprop->data.vertmode)
switch (vertprop->mVertexMode)
{
case 0:
case Nif::NiVertexColorProperty::VertexMode::VertMode_SrcIgnore:
{
mat->setColorMode(osg::Material::OFF);
break;
case 1:
}
case Nif::NiVertexColorProperty::VertexMode::VertMode_SrcEmissive:
{
mat->setColorMode(osg::Material::EMISSION);
break;
case 2:
if (lightmode != 0)
mat->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
else
mat->setColorMode(osg::Material::OFF);
}
case Nif::NiVertexColorProperty::VertexMode::VertMode_SrcAmbDif:
{
switch (vertprop->mLightingMode)
{
case Nif::NiVertexColorProperty::LightMode::LightMode_Emissive:
{
mat->setColorMode(osg::Material::OFF);
break;
}
case Nif::NiVertexColorProperty::LightMode::LightMode_EmiAmbDif:
default:
{
mat->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
break;
}
}
break;
}
}
break;
}
case Nif::RC_NiAlphaProperty:

Loading…
Cancel
Save