1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-07 12:54:00 +00:00
OpenMW/components/nif/effect.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

83 lines
2.2 KiB
C++
Raw Normal View History

#include "effect.hpp"
#include "node.hpp"
2023-08-31 15:59:33 +00:00
#include "texture.hpp"
namespace Nif
{
2022-07-21 11:51:34 +00:00
void NiDynamicEffect::read(NIFStream* nif)
{
NiAVObject::read(nif);
2023-08-31 19:05:55 +00:00
if (nif->getVersion() > NIFFile::VER_MW && nif->getVersion() < nif->generateVersion(10, 1, 0, 0))
return;
if (nif->getBethVersion() >= NIFFile::BethVersion::BETHVER_FO4)
return;
if (nif->getVersion() >= nif->generateVersion(10, 1, 0, 106))
nif->read(mSwitchState);
size_t numAffectedNodes = nif->get<uint32_t>();
nif->skip(numAffectedNodes * 4);
2022-07-21 11:51:34 +00:00
}
2022-09-22 18:26:05 +00:00
2015-11-12 22:27:34 +00:00
void NiLight::read(NIFStream* nif)
{
2015-11-12 22:27:34 +00:00
NiDynamicEffect::read(nif);
2022-09-22 18:26:05 +00:00
nif->read(mDimmer);
nif->read(mAmbient);
nif->read(mDiffuse);
nif->read(mSpecular);
}
2022-09-22 18:26:05 +00:00
2023-08-31 19:05:55 +00:00
void NiPointLight::read(NIFStream* nif)
{
2023-08-31 19:05:55 +00:00
NiLight::read(nif);
2022-09-22 18:26:05 +00:00
nif->read(mConstantAttenuation);
nif->read(mLinearAttenuation);
nif->read(mQuadraticAttenuation);
2023-08-31 19:05:55 +00:00
}
2022-09-22 18:26:05 +00:00
2023-08-31 19:05:55 +00:00
void NiSpotLight::read(NIFStream* nif)
{
NiPointLight::read(nif);
2022-09-22 18:26:05 +00:00
nif->read(mOuterSpotAngle);
if (nif->getVersion() >= NIFStream::generateVersion(20, 2, 0, 5))
nif->read(mInnerSpotAngle);
nif->read(mExponent);
2023-08-31 19:05:55 +00:00
}
2022-09-22 18:26:05 +00:00
2023-08-31 19:05:55 +00:00
void NiTextureEffect::read(NIFStream* nif)
{
NiDynamicEffect::read(nif);
2022-09-22 18:26:05 +00:00
2023-08-31 19:05:55 +00:00
nif->read(mProjectionRotation);
nif->read(mProjectionPosition);
nif->read(mFilterMode);
if (nif->getVersion() >= NIFStream::generateVersion(20, 5, 0, 4))
nif->read(mMaxAnisotropy);
nif->read(mClampMode);
mTextureType = static_cast<TextureType>(nif->get<uint32_t>());
mCoordGenType = static_cast<CoordGenType>(nif->get<uint32_t>());
mTexture.read(nif);
nif->read(mEnableClipPlane);
mClipPlane = osg::Plane(nif->get<osg::Vec4f>());
if (nif->getVersion() <= NIFStream::generateVersion(10, 2, 0, 0))
nif->skip(4); // PS2-specific shorts
if (nif->getVersion() <= NIFStream::generateVersion(4, 1, 0, 12))
nif->skip(2); // Unknown short
}
2022-09-22 18:26:05 +00:00
void NiTextureEffect::post(Reader& nif)
{
2015-11-12 22:27:34 +00:00
NiDynamicEffect::post(nif);
2022-09-22 18:26:05 +00:00
2023-08-31 19:05:55 +00:00
mTexture.post(nif);
2015-11-12 22:45:12 +00:00
}
}