From f507e17807d1b7e9f1546a99e10be10a4a18dd44 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Fri, 22 Sep 2023 00:18:35 +0300 Subject: [PATCH] Read BSWaterShaderProperty and BSSkyShaderProperty --- components/nif/niffile.cpp | 2 ++ components/nif/property.cpp | 17 +++++++++++- components/nif/property.hpp | 55 +++++++++++++++++++++++++++++-------- components/nif/record.hpp | 2 ++ 4 files changed, 64 insertions(+), 12 deletions(-) diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index 8f0925103a..8dbf65d070 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -393,6 +393,8 @@ namespace Nif { "BSDistantTreeShaderProperty", &construct }, { "BSLightingShaderProperty", &construct }, { "BSEffectShaderProperty", &construct }, + { "BSSkyShaderProperty", &construct }, + { "BSWaterShaderProperty", &construct }, { "DistantLODShaderProperty", &construct }, { "HairShaderProperty", &construct }, { "Lighting30ShaderProperty", &construct }, diff --git a/components/nif/property.cpp b/components/nif/property.cpp index fa6fa1b4cf..bcc70540c8 100644 --- a/components/nif/property.cpp +++ b/components/nif/property.cpp @@ -232,7 +232,7 @@ namespace Nif BSShaderLightingProperty::read(nif); mFilename = nif->getSizedString(); - mSkyObjectType = static_cast(nif->get()); + mSkyObjectType = static_cast(nif->get()); } void TallGrassShaderProperty::read(NIFStream* nif) @@ -455,6 +455,21 @@ namespace Nif } } + void BSSkyShaderProperty::read(NIFStream* nif) + { + BSShaderProperty::read(nif); + + mFilename = nif->getSizedString(); + mSkyObjectType = static_cast(nif->get()); + } + + void BSWaterShaderProperty::read(NIFStream* nif) + { + BSShaderProperty::read(nif); + + nif->read(mFlags); + } + void NiAlphaProperty::read(NIFStream* nif) { NiProperty::read(nif); diff --git a/components/nif/property.hpp b/components/nif/property.hpp index 37d17989b6..0d4a5b33c6 100644 --- a/components/nif/property.hpp +++ b/components/nif/property.hpp @@ -171,20 +171,20 @@ namespace Nif void read(NIFStream* nif) override; }; - struct SkyShaderProperty : BSShaderLightingProperty + enum class SkyObjectType : uint32_t { - enum class ObjectType : uint32_t - { - SkyTexture = 0, - SkySunglare = 1, - Sky = 2, - SkyClouds = 3, - SkyStars = 5, - SkyMoonStarsMask = 7, - }; + SkyTexture = 0, + SkySunglare = 1, + Sky = 2, + SkyClouds = 3, + SkyStars = 5, + SkyMoonStarsMask = 7, + }; + struct SkyShaderProperty : BSShaderLightingProperty + { std::string mFilename; - ObjectType mSkyObjectType; + SkyObjectType mSkyObjectType; void read(NIFStream* nif) override; }; @@ -358,6 +358,39 @@ namespace Nif bool treeAnim() const { return mShaderFlags2 & BSLSFlag2_TreeAnim; } }; + struct BSSkyShaderProperty : BSShaderProperty + { + std::string mFilename; + SkyObjectType mSkyObjectType; + + void read(NIFStream* nif) override; + }; + + struct BSWaterShaderProperty : BSShaderProperty + { + enum Flags + { + Flag_Displacement = 0x0001, + Flag_LOD = 0x0002, + Flag_Depth = 0x0004, + Flag_ActorInWater = 0x0008, + Flag_ActorInWaterIsMoving = 0x0010, + Flag_Underwater = 0x0020, + Flag_Reflections = 0x0040, + Flag_Refractions = 0x0080, + Flag_VertexUV = 0x0100, + Flag_VertexAlphaDepth = 0x0200, + Flag_Procedural = 0x0400, + Flag_Fog = 0x0800, + Flag_UpdateConstants = 0x1000, + Flag_CubeMap = 0x2000, + }; + + uint32_t mFlags; + + void read(NIFStream* nif) override; + }; + struct NiAlphaProperty : NiProperty { enum Flags diff --git a/components/nif/record.hpp b/components/nif/record.hpp index d399660432..fd780e52eb 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -100,8 +100,10 @@ namespace Nif RC_BSShaderPPLightingProperty, RC_BSShaderProperty, RC_BSShaderTextureSet, + RC_BSSkyShaderProperty, RC_BSTriShape, RC_BSWArray, + RC_BSWaterShaderProperty, RC_BSXFlags, RC_DistantLODShaderProperty, RC_HairShaderProperty,