Read NiPointLight (Fixes #3011)

openmw-38
scrawl 9 years ago
parent 8cd41f0ed4
commit ba211ad9ad

@ -5,29 +5,19 @@
namespace Nif
{
void NiLight::SLight::read(NIFStream *nif)
void NiLight::read(NIFStream *nif)
{
NiDynamicEffect::read(nif);
dimmer = nif->getFloat();
ambient = nif->getVector3();
diffuse = nif->getVector3();
specular = nif->getVector3();
}
void NiLight::read(NIFStream *nif)
{
Effect::read(nif);
nif->getInt(); // 1
nif->getInt(); // 1?
light.read(nif);
}
void NiTextureEffect::read(NIFStream *nif)
{
Effect::read(nif);
int tmp = nif->getInt();
if(tmp) nif->getInt(); // always 1?
NiDynamicEffect::read(nif);
/*
3 x Vector4 = [1,0,0,0]
@ -52,10 +42,17 @@ void NiTextureEffect::read(NIFStream *nif)
void NiTextureEffect::post(NIFFile *nif)
{
Effect::post(nif);
NiDynamicEffect::post(nif);
texture.post(nif);
}
void NiPointLight::read(NIFStream *nif)
{
NiLight::read(nif);
constantAttenuation = nif->getFloat();
linearAttenuation = nif->getFloat();
quadraticAttenuation = nif->getFloat();
}
}

@ -29,27 +29,38 @@
namespace Nif
{
typedef Node Effect;
// Used for NiAmbientLight and NiDirectionalLight. Might also work for
// NiPointLight and NiSpotLight?
struct NiLight : Effect
struct NiDynamicEffect : public Node
{
struct SLight
void read(NIFStream *nif)
{
float dimmer;
osg::Vec3f ambient;
osg::Vec3f diffuse;
osg::Vec3f specular;
Node::read(nif);
unsigned int numAffectedNodes = nif->getUInt();
for (unsigned int i=0; i<numAffectedNodes; ++i)
nif->getUInt(); // ref to another Node
}
};
// Used as base for NiAmbientLight, NiDirectionalLight, NiPointLight and NiSpotLight.
struct NiLight : NiDynamicEffect
{
float dimmer;
osg::Vec3f ambient;
osg::Vec3f diffuse;
osg::Vec3f specular;
void read(NIFStream *nif);
};
SLight light;
void read(NIFStream *nif);
};
struct NiPointLight : public NiLight
{
float constantAttenuation;
float linearAttenuation;
float quadraticAttenuation;
void read(NIFStream *nif);
};
struct NiTextureEffect : Effect
struct NiTextureEffect : NiDynamicEffect
{
NiSourceTexturePtr texture;

@ -82,6 +82,7 @@ static std::map<std::string,RecordFactoryEntry> makeFactory()
newFactory.insert(makeEntry("NiFlipController", &construct <NiFlipController> , RC_NiFlipController ));
newFactory.insert(makeEntry("NiAmbientLight", &construct <NiLight> , RC_NiLight ));
newFactory.insert(makeEntry("NiDirectionalLight", &construct <NiLight> , RC_NiLight ));
newFactory.insert(makeEntry("NiPointLight", &construct <NiPointLight> , RC_NiLight ));
newFactory.insert(makeEntry("NiTextureEffect", &construct <NiTextureEffect> , RC_NiTextureEffect ));
newFactory.insert(makeEntry("NiVertWeightsExtraData", &construct <NiVertWeightsExtraData> , RC_NiVertWeightsExtraData ));
newFactory.insert(makeEntry("NiTextKeyExtraData", &construct <NiTextKeyExtraData> , RC_NiTextKeyExtraData ));

Loading…
Cancel
Save