forked from mirror/openmw-tes3mp
Read NiPointLight (Fixes #3011)
This commit is contained in:
parent
8cd41f0ed4
commit
ba211ad9ad
3 changed files with 38 additions and 29 deletions
|
@ -5,29 +5,19 @@
|
||||||
namespace Nif
|
namespace Nif
|
||||||
{
|
{
|
||||||
|
|
||||||
void NiLight::SLight::read(NIFStream *nif)
|
void NiLight::read(NIFStream *nif)
|
||||||
{
|
{
|
||||||
|
NiDynamicEffect::read(nif);
|
||||||
|
|
||||||
dimmer = nif->getFloat();
|
dimmer = nif->getFloat();
|
||||||
ambient = nif->getVector3();
|
ambient = nif->getVector3();
|
||||||
diffuse = nif->getVector3();
|
diffuse = nif->getVector3();
|
||||||
specular = 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)
|
void NiTextureEffect::read(NIFStream *nif)
|
||||||
{
|
{
|
||||||
Effect::read(nif);
|
NiDynamicEffect::read(nif);
|
||||||
|
|
||||||
int tmp = nif->getInt();
|
|
||||||
if(tmp) nif->getInt(); // always 1?
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
3 x Vector4 = [1,0,0,0]
|
3 x Vector4 = [1,0,0,0]
|
||||||
|
@ -52,10 +42,17 @@ void NiTextureEffect::read(NIFStream *nif)
|
||||||
|
|
||||||
void NiTextureEffect::post(NIFFile *nif)
|
void NiTextureEffect::post(NIFFile *nif)
|
||||||
{
|
{
|
||||||
Effect::post(nif);
|
NiDynamicEffect::post(nif);
|
||||||
texture.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
|
namespace Nif
|
||||||
{
|
{
|
||||||
|
|
||||||
typedef Node Effect;
|
struct NiDynamicEffect : public Node
|
||||||
|
|
||||||
// Used for NiAmbientLight and NiDirectionalLight. Might also work for
|
|
||||||
// NiPointLight and NiSpotLight?
|
|
||||||
struct NiLight : Effect
|
|
||||||
{
|
{
|
||||||
struct SLight
|
void read(NIFStream *nif)
|
||||||
{
|
{
|
||||||
float dimmer;
|
Node::read(nif);
|
||||||
osg::Vec3f ambient;
|
unsigned int numAffectedNodes = nif->getUInt();
|
||||||
osg::Vec3f diffuse;
|
for (unsigned int i=0; i<numAffectedNodes; ++i)
|
||||||
osg::Vec3f specular;
|
nif->getUInt(); // ref to another Node
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void read(NIFStream *nif);
|
// Used as base for NiAmbientLight, NiDirectionalLight, NiPointLight and NiSpotLight.
|
||||||
};
|
struct NiLight : NiDynamicEffect
|
||||||
SLight light;
|
{
|
||||||
|
float dimmer;
|
||||||
|
osg::Vec3f ambient;
|
||||||
|
osg::Vec3f diffuse;
|
||||||
|
osg::Vec3f specular;
|
||||||
|
|
||||||
void read(NIFStream *nif);
|
void read(NIFStream *nif);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NiTextureEffect : Effect
|
struct NiPointLight : public NiLight
|
||||||
|
{
|
||||||
|
float constantAttenuation;
|
||||||
|
float linearAttenuation;
|
||||||
|
float quadraticAttenuation;
|
||||||
|
|
||||||
|
void read(NIFStream *nif);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct NiTextureEffect : NiDynamicEffect
|
||||||
{
|
{
|
||||||
NiSourceTexturePtr texture;
|
NiSourceTexturePtr texture;
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ static std::map<std::string,RecordFactoryEntry> makeFactory()
|
||||||
newFactory.insert(makeEntry("NiFlipController", &construct <NiFlipController> , RC_NiFlipController ));
|
newFactory.insert(makeEntry("NiFlipController", &construct <NiFlipController> , RC_NiFlipController ));
|
||||||
newFactory.insert(makeEntry("NiAmbientLight", &construct <NiLight> , RC_NiLight ));
|
newFactory.insert(makeEntry("NiAmbientLight", &construct <NiLight> , RC_NiLight ));
|
||||||
newFactory.insert(makeEntry("NiDirectionalLight", &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("NiTextureEffect", &construct <NiTextureEffect> , RC_NiTextureEffect ));
|
||||||
newFactory.insert(makeEntry("NiVertWeightsExtraData", &construct <NiVertWeightsExtraData> , RC_NiVertWeightsExtraData ));
|
newFactory.insert(makeEntry("NiVertWeightsExtraData", &construct <NiVertWeightsExtraData> , RC_NiVertWeightsExtraData ));
|
||||||
newFactory.insert(makeEntry("NiTextKeyExtraData", &construct <NiTextKeyExtraData> , RC_NiTextKeyExtraData ));
|
newFactory.insert(makeEntry("NiTextKeyExtraData", &construct <NiTextKeyExtraData> , RC_NiTextKeyExtraData ));
|
||||||
|
|
Loading…
Reference in a new issue