add spaghetti
This commit is contained in:
30
MareSynchronos/Interop/Material.cs
Normal file
30
MareSynchronos/Interop/Material.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using FFXIVClientStructs.FFXIV.Client.Graphics.Render;
|
||||
|
||||
namespace Penumbra.Interop.Structs;
|
||||
|
||||
[StructLayout( LayoutKind.Explicit )]
|
||||
public unsafe struct Material
|
||||
{
|
||||
[FieldOffset( 0x10 )]
|
||||
public ResourceHandle* ResourceHandle;
|
||||
|
||||
[FieldOffset( 0x28 )]
|
||||
public MaterialData* MaterialData;
|
||||
|
||||
[FieldOffset( 0x48 )]
|
||||
public Texture* Tex1;
|
||||
|
||||
[FieldOffset( 0x60 )]
|
||||
public Texture* Tex2;
|
||||
|
||||
[FieldOffset( 0x78 )]
|
||||
public Texture* Tex3;
|
||||
}
|
||||
|
||||
[StructLayout( LayoutKind.Explicit )]
|
||||
public unsafe struct MaterialData
|
||||
{
|
||||
[FieldOffset( 0x0 )]
|
||||
public byte* Data;
|
||||
}
|
||||
28
MareSynchronos/Interop/MtrlResource.cs
Normal file
28
MareSynchronos/Interop/MtrlResource.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Penumbra.Interop.Structs;
|
||||
|
||||
[StructLayout( LayoutKind.Explicit )]
|
||||
public unsafe struct MtrlResource
|
||||
{
|
||||
[FieldOffset( 0x00 )]
|
||||
public ResourceHandle Handle;
|
||||
|
||||
[FieldOffset( 0xD0 )]
|
||||
public ushort* TexSpace; // Contains the offsets for the tex files inside the string list.
|
||||
|
||||
[FieldOffset( 0xE0 )]
|
||||
public byte* StringList;
|
||||
|
||||
[FieldOffset( 0xF8 )]
|
||||
public ushort ShpkOffset;
|
||||
|
||||
[FieldOffset( 0xFA )]
|
||||
public byte NumTex;
|
||||
|
||||
public byte* ShpkString
|
||||
=> StringList + ShpkOffset;
|
||||
|
||||
public byte* TexString( int idx )
|
||||
=> StringList + *( TexSpace + 4 + idx * 8 );
|
||||
}
|
||||
41
MareSynchronos/Interop/RenderModel.cs
Normal file
41
MareSynchronos/Interop/RenderModel.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using FFXIVClientStructs.FFXIV.Client.Graphics.Render;
|
||||
|
||||
namespace Penumbra.Interop.Structs;
|
||||
|
||||
[StructLayout( LayoutKind.Explicit )]
|
||||
public unsafe struct RenderModel
|
||||
{
|
||||
[FieldOffset( 0x18 )]
|
||||
public RenderModel* PreviousModel;
|
||||
|
||||
[FieldOffset( 0x20 )]
|
||||
public RenderModel* NextModel;
|
||||
|
||||
[FieldOffset( 0x30 )]
|
||||
public ResourceHandle* ResourceHandle;
|
||||
|
||||
[FieldOffset( 0x40 )]
|
||||
public Skeleton* Skeleton;
|
||||
|
||||
[FieldOffset( 0x58 )]
|
||||
public void** BoneList;
|
||||
|
||||
[FieldOffset( 0x60 )]
|
||||
public int BoneListCount;
|
||||
|
||||
[FieldOffset( 0x68 )]
|
||||
private void* UnkDXBuffer1;
|
||||
|
||||
[FieldOffset( 0x70 )]
|
||||
private void* UnkDXBuffer2;
|
||||
|
||||
[FieldOffset( 0x78 )]
|
||||
private void* UnkDXBuffer3;
|
||||
|
||||
[FieldOffset( 0x90 )]
|
||||
public void** Materials;
|
||||
|
||||
[FieldOffset( 0x98 )]
|
||||
public int MaterialCount;
|
||||
}
|
||||
96
MareSynchronos/Interop/ResourceHandle.cs
Normal file
96
MareSynchronos/Interop/ResourceHandle.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using FFXIVClientStructs.FFXIV.Client.System.Resource;
|
||||
using Penumbra.GameData.Enums;
|
||||
|
||||
namespace Penumbra.Interop.Structs;
|
||||
|
||||
[StructLayout( LayoutKind.Explicit )]
|
||||
public unsafe struct ResourceHandle
|
||||
{
|
||||
[StructLayout( LayoutKind.Explicit )]
|
||||
public struct DataIndirection
|
||||
{
|
||||
[FieldOffset( 0x00 )]
|
||||
public void** VTable;
|
||||
|
||||
[FieldOffset( 0x10 )]
|
||||
public byte* DataPtr;
|
||||
|
||||
[FieldOffset( 0x28 )]
|
||||
public ulong DataLength;
|
||||
}
|
||||
|
||||
public const int SsoSize = 15;
|
||||
|
||||
public byte* FileName()
|
||||
{
|
||||
if( FileNameLength > SsoSize )
|
||||
{
|
||||
return FileNameData;
|
||||
}
|
||||
|
||||
fixed( byte** name = &FileNameData )
|
||||
{
|
||||
return ( byte* )name;
|
||||
}
|
||||
}
|
||||
|
||||
public ReadOnlySpan< byte > FileNameSpan()
|
||||
=> new(FileName(), FileNameLength);
|
||||
|
||||
[FieldOffset( 0x00 )]
|
||||
public void** VTable;
|
||||
|
||||
[FieldOffset( 0x08 )]
|
||||
public ResourceCategory Category;
|
||||
|
||||
[FieldOffset( 0x0C )]
|
||||
public ResourceType FileType;
|
||||
|
||||
[FieldOffset( 0x10 )]
|
||||
public uint Id;
|
||||
|
||||
[FieldOffset( 0x48 )]
|
||||
public byte* FileNameData;
|
||||
|
||||
[FieldOffset( 0x58 )]
|
||||
public int FileNameLength;
|
||||
|
||||
[FieldOffset( 0xAC )]
|
||||
public uint RefCount;
|
||||
|
||||
// May return null.
|
||||
public static byte* GetData( ResourceHandle* handle )
|
||||
=> ( ( delegate* unmanaged< ResourceHandle*, byte* > )handle->VTable[ 23 ] )( handle );
|
||||
|
||||
public static ulong GetLength( ResourceHandle* handle )
|
||||
=> ( ( delegate* unmanaged< ResourceHandle*, ulong > )handle->VTable[ 17 ] )( handle );
|
||||
|
||||
|
||||
// Only use these if you know what you are doing.
|
||||
// Those are actually only sure to be accessible for DefaultResourceHandles.
|
||||
[FieldOffset( 0xB0 )]
|
||||
public DataIndirection* Data;
|
||||
|
||||
[FieldOffset( 0xB8 )]
|
||||
public uint DataLength;
|
||||
|
||||
public (IntPtr Data, int Length) GetData()
|
||||
=> Data != null
|
||||
? ( ( IntPtr )Data->DataPtr, ( int )Data->DataLength )
|
||||
: ( IntPtr.Zero, 0 );
|
||||
|
||||
public bool SetData( IntPtr data, int length )
|
||||
{
|
||||
if( Data == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Data->DataPtr = length != 0 ? ( byte* )data : null;
|
||||
Data->DataLength = ( ulong )length;
|
||||
DataLength = ( uint )length;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user