Add some start for Evp Data.

This commit is contained in:
Ottermandias 2022-09-02 18:36:34 +02:00
parent 8aec63d0be
commit 2010e02034
4 changed files with 128 additions and 60 deletions

View file

@ -1,4 +1,3 @@
using System;
using System.IO;
using System.Linq;
using System.Text;

View file

@ -23,8 +23,8 @@ public enum EqpEntry : ulong
BodyShowNecklace = 0x08_00ul,
BodyShowBracelet = 0x10_00ul,
BodyShowTail = 0x20_00ul,
DisableBreastPhysics = 0x40_00ul,
_15 = 0x80_00ul,
BodyDisableBreastPhysics = 0x40_00ul,
BodyHasVfxObject = 0x80_00ul,
BodyMask = 0xFF_FFul,
LegsEnabled = 0x01ul << 16,
@ -75,7 +75,7 @@ public enum EqpEntry : ulong
_55 = 0x00_80_00ul << 40,
HeadShowHrothgarHat = 0x01_00_00ul << 40,
HeadShowVieraHat = 0x02_00_00ul << 40,
_58 = 0x04_00_00ul << 40,
HeadHasVfxObject = 0x04_00_00ul << 40,
_59 = 0x08_00_00ul << 40,
_60 = 0x10_00_00ul << 40,
_61 = 0x20_00_00ul << 40,
@ -150,8 +150,8 @@ public static class Eqp
EqpEntry.BodyShowNecklace => EquipSlot.Body,
EqpEntry.BodyShowBracelet => EquipSlot.Body,
EqpEntry.BodyShowTail => EquipSlot.Body,
EqpEntry.DisableBreastPhysics => EquipSlot.Body,
EqpEntry._15 => EquipSlot.Body,
EqpEntry.BodyDisableBreastPhysics => EquipSlot.Body,
EqpEntry.BodyHasVfxObject => EquipSlot.Body,
EqpEntry.LegsEnabled => EquipSlot.Legs,
EqpEntry.LegsHideKneePads => EquipSlot.Legs,
@ -198,9 +198,9 @@ public static class Eqp
EqpEntry._55 => EquipSlot.Head,
EqpEntry.HeadShowHrothgarHat => EquipSlot.Head,
EqpEntry.HeadShowVieraHat => EquipSlot.Head,
EqpEntry.HeadHasVfxObject => EquipSlot.Head,
// Currently unused.
EqpEntry._58 => EquipSlot.Unknown,
// currently unused
EqpEntry._59 => EquipSlot.Unknown,
EqpEntry._60 => EquipSlot.Unknown,
EqpEntry._61 => EquipSlot.Unknown,
@ -229,8 +229,8 @@ public static class Eqp
EqpEntry.BodyShowNecklace => "Show Necklace",
EqpEntry.BodyShowBracelet => "Show Bracelet",
EqpEntry.BodyShowTail => "Show Tail",
EqpEntry.DisableBreastPhysics => "Disable Breast Physics",
EqpEntry._15 => "Unknown 15",
EqpEntry.BodyDisableBreastPhysics => "Disable Breast Physics",
EqpEntry.BodyHasVfxObject => "Has Special Effects",
EqpEntry.LegsEnabled => "Enabled",
EqpEntry.LegsHideKneePads => "Hide Knee Pads",
@ -277,7 +277,8 @@ public static class Eqp
EqpEntry._55 => "Unknown 55",
EqpEntry.HeadShowHrothgarHat => "Show on Hrothgar",
EqpEntry.HeadShowVieraHat => "Show on Viera",
EqpEntry._58 => "Unknown 58",
EqpEntry.HeadHasVfxObject => "Has Special Effects",
EqpEntry._59 => "Unknown 59",
EqpEntry._60 => "Unknown 60",
EqpEntry._61 => "Unknown 61",

View file

@ -0,0 +1,68 @@
using System;
namespace Penumbra.Meta.Files;
// EVP file structure:
// [Identifier:3 bytes, EVP]
// [NumModels:ushort]
// NumModels x [ModelId:ushort]
// Containing the relevant model IDs. Seems to be sorted.
// NumModels x [DataArray]:512 Byte]
// Containing Flags in each byte, 0x01 set for Body, 0x02 set for Helmet. Unsure where the index into this array comes from.
public unsafe class EvpFile : MetaBaseFile
{
public const int FlagArraySize = 512;
[Flags]
public enum EvpFlag : byte
{
None = 0x00,
Body = 0x01,
Head = 0x02,
Both = Body | Head,
}
public int NumModels
=> Data[ 3 ];
public ReadOnlySpan< ushort > ModelSetIds
=> new(Data + 4, NumModels);
public ushort ModelSetId( int idx )
=> idx >= 0 && idx < NumModels ? ( ( ushort* )( Data + 4 ) )[ idx ] : ushort.MaxValue;
public ReadOnlySpan< EvpFlag > Flags( int idx )
=> new(Data + 4 + idx * FlagArraySize, FlagArraySize);
public EvpFlag Flag( ushort modelSet, int arrayIndex )
{
if( arrayIndex is >= FlagArraySize or < 0 )
{
return EvpFlag.None;
}
var ids = ModelSetIds;
for( var i = 0; i < ids.Length; ++i )
{
var model = ids[ i ];
if( model < modelSet )
{
continue;
}
if( model > modelSet )
{
break;
}
return Flags( i )[ arrayIndex ];
}
return EvpFlag.None;
}
public EvpFile()
: base( ( Interop.Structs.CharacterUtility.Index )1 ) // TODO: Name
{ }
}