From 015aca2cfd986bc048282828e246e042506ce585 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Thu, 18 Apr 2024 02:28:48 +0300 Subject: [PATCH] Initial BGSM file parsing --- components/bgsm/file.cpp | 124 +++++++++++++++++++++++++++++++++++++++ components/bgsm/file.hpp | 6 +- 2 files changed, 127 insertions(+), 3 deletions(-) diff --git a/components/bgsm/file.cpp b/components/bgsm/file.cpp index 1ad1918ccf..bb627ae34e 100644 --- a/components/bgsm/file.cpp +++ b/components/bgsm/file.cpp @@ -45,6 +45,130 @@ namespace Bgsm void BGSMFile::read(BGSMStream& stream) { MaterialFile::read(stream); + + stream.read(mDiffuseMap); + stream.read(mNormalMap); + stream.read(mSmoothSpecMap); + stream.read(mGreyscaleMap); + if (mVersion >= 3) + { + stream.read(mGlowMap); + stream.read(mWrinkleMap); + stream.read(mSpecularMap); + stream.read(mLightingMap); + stream.read(mFlowMap); + if (mVersion >= 17) + { + stream.read(mDistanceFieldAlphaMap); + } + } + else + { + stream.read(mEnvMap); + stream.read(mGlowMap); + stream.read(mInnerLayerMap); + stream.read(mWrinkleMap); + stream.read(mDisplacementMap); + } + stream.read(mEnableEditorAlphaThreshold); + if (mVersion >= 8) + { + stream.read(mTranslucency); + stream.read(mTranslucencyThickObject); + stream.read(mTranslucencyMixAlbedoWithSubsurfaceColor); + stream.read(mTranslucencySubsurfaceColor); + stream.read(mTranslucencyTransmissiveScale); + stream.read(mTranslucencyTurbulence); + } + else + { + stream.read(mRimLighting); + stream.read(mRimPower); + stream.read(mBackLightPower); + stream.read(mSubsurfaceLighting); + stream.read(mSubsurfaceLightingRolloff); + } + stream.read(mSpecularEnabled); + stream.read(mSpecularColor); + stream.read(mSpecularMult); + stream.read(mSmoothness); + stream.read(mFresnelPower); + stream.read(mWetnessControlSpecScale); + stream.read(mWetnessControlSpecPowerScale); + stream.read(mWetnessControlSpecMinvar); + if (mVersion < 10) + { + stream.read(mWetnessControlEnvMapScale); + } + stream.read(mWetnessControlFresnelPower); + stream.read(mWetnessControlMetalness); + if (mVersion >= 3) + { + stream.read(mPBR); + if (mVersion >= 9) + { + stream.read(mCustomPorosity); + stream.read(mPorosityValue); + } + } + stream.read(mRootMaterialPath); + stream.read(mAnisoLighting); + stream.read(mEmitEnabled); + if (mEmitEnabled) + { + stream.read(mEmittanceColor); + } + stream.read(mEmittanceMult); + stream.read(mModelSpaceNormals); + stream.read(mExternalEmittance); + if (mVersion >= 12) + { + stream.read(mLumEmittance); + if (mVersion >= 13) + { + stream.read(mUseAdaptiveEmissive); + stream.read(mAdaptiveEmissiveExposureParams); + } + } + else if (mVersion < 8) + { + stream.read(mBackLighting); + } + stream.read(mReceiveShadows); + stream.read(mHideSecret); + stream.read(mCastShadows); + stream.read(mDissolveFade); + stream.read(mAssumeShadowmask); + stream.read(mHasGlowMap); + if (mVersion < 7) + { + stream.read(mEnvMapWindow); + stream.read(mEnvMapEye); + } + stream.read(mHair); + stream.read(mHairTintColor); + stream.read(mTree); + stream.read(mFacegen); + stream.read(mSkinTint); + stream.read(mTessellate); + if (mVersion < 3) + { + stream.read(mDisplacementMapParams); + stream.read(mTessellationParams); + } + stream.read(mGrayscaleToPaletteScale); + if (mVersion >= 1) + { + stream.read(mSkewSpecularAlpha); + stream.read(mTerrain); + if (mTerrain) + { + if (mVersion == 3) + stream.skip(4); // Unknown + + stream.read(mTerrainParams); + } + } } void BGEMFile::read(BGSMStream& stream) diff --git a/components/bgsm/file.hpp b/components/bgsm/file.hpp index db0059cd29..57b08f68dc 100644 --- a/components/bgsm/file.hpp +++ b/components/bgsm/file.hpp @@ -68,7 +68,7 @@ namespace Bgsm std::string mEnvMap; std::string mInnerLayerMap; std::string mDisplacementMap; - bool mEnableEditorAlphaRef; + bool mEnableEditorAlphaThreshold; bool mTranslucency; bool mTranslucencyThickObject; bool mTranslucencyMixAlbedoWithSubsurfaceColor; @@ -78,7 +78,7 @@ namespace Bgsm bool mRimLighting; float mRimPower; float mBackLightPower; - bool mSursurfaceLighting; + bool mSubsurfaceLighting; float mSubsurfaceLightingRolloff; bool mSpecularEnabled; osg::Vec4f mSpecularColor; @@ -120,7 +120,7 @@ namespace Bgsm bool mSkinTint; bool mTessellate; osg::Vec2f mDisplacementMapParams; - osg::Vec3f mTesselationParams; + osg::Vec3f mTessellationParams; float mGrayscaleToPaletteScale; bool mSkewSpecularAlpha; bool mTerrain;