mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-07-22 03:54:16 -04:00
2018.3.0b support
Refactor mesh read Fixed bug
This commit is contained in:
@ -632,7 +632,10 @@ namespace AssetStudio
|
||||
{
|
||||
m_ConstantClip = new ConstantClip(reader);
|
||||
}
|
||||
m_Binding = new ValueArrayConstant(reader);
|
||||
if (version[0] < 2018 || (version[0] == 2018 && version[1] < 3)) //2018.3 down
|
||||
{
|
||||
m_Binding = new ValueArrayConstant(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -947,6 +950,8 @@ namespace AssetStudio
|
||||
{
|
||||
m_ClipBindingConstant = new AnimationClipBindingConstant(reader);
|
||||
}
|
||||
//m_HasGenericRootTransform 2018.3
|
||||
//m_HasMotionFloatCurves 2018.3
|
||||
/*int numEvents = reader.ReadInt32();
|
||||
m_Events = new List<AnimationEvent>(numEvents);
|
||||
for (int i = 0; i < numEvents; i++)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -62,6 +62,11 @@ namespace AssetStudio
|
||||
var m_RenderingLayerMask = reader.ReadUInt32();
|
||||
}
|
||||
|
||||
if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 3)) //2018.3 and up
|
||||
{
|
||||
var m_RendererPriority = reader.ReadInt32();
|
||||
}
|
||||
|
||||
var m_LightmapIndex = reader.ReadUInt16();
|
||||
var m_LightmapIndexDynamic = reader.ReadUInt16();
|
||||
}
|
||||
|
@ -58,154 +58,6 @@ namespace AssetStudio
|
||||
}
|
||||
}
|
||||
|
||||
public class BoneWeights4
|
||||
{
|
||||
public float[] weight;
|
||||
public int[] boneIndex;
|
||||
|
||||
public BoneWeights4(ObjectReader reader)
|
||||
{
|
||||
weight = reader.ReadSingleArray(4);
|
||||
boneIndex = reader.ReadInt32Array(4);
|
||||
}
|
||||
}
|
||||
|
||||
public class StreamInfo
|
||||
{
|
||||
public uint channelMask;
|
||||
public uint offset;
|
||||
public uint stride;
|
||||
public uint align;
|
||||
public byte dividerOp;
|
||||
public ushort frequency;
|
||||
|
||||
public StreamInfo() { }
|
||||
|
||||
public StreamInfo(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
|
||||
channelMask = reader.ReadUInt32();
|
||||
offset = reader.ReadUInt32();
|
||||
|
||||
if (version[0] < 4)
|
||||
{
|
||||
stride = reader.ReadUInt32();
|
||||
align = reader.ReadUInt32();
|
||||
}
|
||||
else
|
||||
{
|
||||
stride = reader.ReadByte();
|
||||
dividerOp = reader.ReadByte();
|
||||
frequency = reader.ReadUInt16();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ChannelInfo
|
||||
{
|
||||
public byte stream;
|
||||
public byte offset;
|
||||
public byte format;
|
||||
public byte dimension;
|
||||
|
||||
public ChannelInfo(ObjectReader reader)
|
||||
{
|
||||
stream = reader.ReadByte();
|
||||
offset = reader.ReadByte();
|
||||
format = reader.ReadByte();
|
||||
dimension = reader.ReadByte();
|
||||
}
|
||||
}
|
||||
|
||||
public class VertexData
|
||||
{
|
||||
public uint m_CurrentChannels;
|
||||
public uint m_VertexCount;
|
||||
public ChannelInfo[] m_Channels;
|
||||
public StreamInfo[] m_Streams;
|
||||
public byte[] m_DataSize;
|
||||
|
||||
public VertexData(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
|
||||
if (version[0] < 2018)//2018 down
|
||||
{
|
||||
m_CurrentChannels = reader.ReadUInt32();
|
||||
}
|
||||
m_VertexCount = reader.ReadUInt32();
|
||||
|
||||
if (version[0] >= 4)
|
||||
{
|
||||
var m_ChannelsSize = reader.ReadInt32();
|
||||
m_Channels = new ChannelInfo[m_ChannelsSize];
|
||||
for (int i = 0; i < m_ChannelsSize; i++)
|
||||
{
|
||||
m_Channels[i] = new ChannelInfo(reader);
|
||||
}
|
||||
}
|
||||
|
||||
if (version[0] < 5) //5.0 down
|
||||
{
|
||||
if (version[0] < 4)
|
||||
{
|
||||
m_Streams = new StreamInfo[4];
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Streams = new StreamInfo[reader.ReadInt32()];
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_Streams.Length; i++)
|
||||
{
|
||||
m_Streams[i] = new StreamInfo(reader);
|
||||
}
|
||||
}
|
||||
|
||||
m_DataSize = reader.ReadBytes(reader.ReadInt32());
|
||||
reader.AlignStream();
|
||||
}
|
||||
}
|
||||
|
||||
public class SubMesh
|
||||
{
|
||||
public uint firstByte;
|
||||
public uint indexCount;
|
||||
public int topology;
|
||||
public uint triangleCount;
|
||||
public uint baseVertex;
|
||||
public uint firstVertex;
|
||||
public uint vertexCount;
|
||||
public AABB localAABB;
|
||||
|
||||
public SubMesh(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
|
||||
firstByte = reader.ReadUInt32();
|
||||
indexCount = reader.ReadUInt32();
|
||||
topology = reader.ReadInt32();
|
||||
|
||||
if (version[0] < 4) //4.0 down
|
||||
{
|
||||
triangleCount = reader.ReadUInt32();
|
||||
}
|
||||
|
||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 3)) //2017.3 and up
|
||||
{
|
||||
baseVertex = reader.ReadUInt32();
|
||||
}
|
||||
|
||||
if (version[0] >= 3) //3.0 and up
|
||||
{
|
||||
firstVertex = reader.ReadUInt32();
|
||||
vertexCount = reader.ReadUInt32();
|
||||
localAABB = new AABB(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SpriteRenderData
|
||||
{
|
||||
public PPtr<Texture2D> texture;
|
||||
|
@ -7,74 +7,37 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public sealed class Texture2D : Texture
|
||||
public class StreamingInfo
|
||||
{
|
||||
public int m_Width;
|
||||
public int m_Height;
|
||||
public int m_CompleteImageSize;
|
||||
public TextureFormat m_TextureFormat;
|
||||
public bool m_MipMap;
|
||||
public int m_MipCount;
|
||||
public bool m_IsReadable;
|
||||
public bool m_ReadAllowed;
|
||||
public int m_ImageCount;
|
||||
public int m_TextureDimension;
|
||||
//m_TextureSettings
|
||||
public int m_FilterMode;
|
||||
public int m_Aniso;
|
||||
public float m_MipBias;
|
||||
public int m_WrapMode;
|
||||
public int m_LightmapFormat;
|
||||
public int m_ColorSpace;
|
||||
//image dataa
|
||||
public int image_data_size;
|
||||
public Lazy<byte[]> image_data;
|
||||
//m_StreamData
|
||||
public uint offset;
|
||||
public uint size;
|
||||
public string path;
|
||||
|
||||
public Texture2D(ObjectReader reader) : base(reader)
|
||||
public StreamingInfo(ObjectReader reader)
|
||||
{
|
||||
m_Width = reader.ReadInt32();
|
||||
m_Height = reader.ReadInt32();
|
||||
m_CompleteImageSize = reader.ReadInt32();
|
||||
m_TextureFormat = (TextureFormat)reader.ReadInt32();
|
||||
offset = reader.ReadUInt32();
|
||||
size = reader.ReadUInt32();
|
||||
path = reader.ReadAlignedString();
|
||||
}
|
||||
}
|
||||
|
||||
if (version[0] < 5 || (version[0] == 5 && version[1] < 2))
|
||||
{
|
||||
m_MipMap = reader.ReadBoolean();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_MipCount = reader.ReadInt32();
|
||||
}
|
||||
public class GLTextureSettings
|
||||
{
|
||||
public int m_FilterMode;
|
||||
public int m_Aniso;
|
||||
public float m_MipBias;
|
||||
public int m_WrapMode;
|
||||
|
||||
public GLTextureSettings(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
|
||||
m_IsReadable = reader.ReadBoolean(); //2.6.0 and up
|
||||
m_ReadAllowed = reader.ReadBoolean(); //3.0.0 - 5.4
|
||||
//m_StreamingMipmaps 2018.2 and up
|
||||
reader.AlignStream();
|
||||
if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 2)) //2018.2 and up
|
||||
{
|
||||
var m_StreamingMipmapsPriority = reader.ReadInt32();
|
||||
}
|
||||
else if (HasStructMember("m_StreamingMipmapsPriority")) //will fix in some patch version bundle
|
||||
{
|
||||
var m_StreamingMipmapsPriority = reader.ReadInt32();
|
||||
}
|
||||
if (HasStructMember("m_StreamingGroupID")) //What the hell is this?
|
||||
{
|
||||
var m_StreamingGroupID = reader.ReadUInt32();
|
||||
}
|
||||
m_ImageCount = reader.ReadInt32();
|
||||
m_TextureDimension = reader.ReadInt32();
|
||||
//m_TextureSettings
|
||||
m_FilterMode = reader.ReadInt32();
|
||||
m_Aniso = reader.ReadInt32();
|
||||
m_MipBias = reader.ReadSingle();
|
||||
if (version[0] >= 2017)//2017.x and up
|
||||
{
|
||||
int m_WrapU = reader.ReadInt32();
|
||||
m_WrapMode = reader.ReadInt32(); //m_WrapU
|
||||
int m_WrapV = reader.ReadInt32();
|
||||
int m_WrapW = reader.ReadInt32();
|
||||
}
|
||||
@ -82,29 +45,63 @@ namespace AssetStudio
|
||||
{
|
||||
m_WrapMode = reader.ReadInt32();
|
||||
}
|
||||
if (version[0] >= 3)
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class Texture2D : Texture
|
||||
{
|
||||
public int m_Width;
|
||||
public int m_Height;
|
||||
public TextureFormat m_TextureFormat;
|
||||
public bool m_MipMap;
|
||||
public int m_MipCount;
|
||||
public GLTextureSettings m_TextureSettings;
|
||||
public Lazy<byte[]> image_data;
|
||||
public StreamingInfo m_StreamData;
|
||||
|
||||
public Texture2D(ObjectReader reader) : base(reader)
|
||||
{
|
||||
m_Width = reader.ReadInt32();
|
||||
m_Height = reader.ReadInt32();
|
||||
var m_CompleteImageSize = reader.ReadInt32();
|
||||
m_TextureFormat = (TextureFormat)reader.ReadInt32();
|
||||
if (version[0] < 5 || (version[0] == 5 && version[1] < 2)) //5.2 down
|
||||
{
|
||||
m_LightmapFormat = reader.ReadInt32();
|
||||
if (version[0] >= 4 || version[1] >= 5)//3.5.0 and up
|
||||
{
|
||||
m_ColorSpace = reader.ReadInt32();
|
||||
}
|
||||
m_MipMap = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
image_data_size = reader.ReadInt32();
|
||||
|
||||
else
|
||||
{
|
||||
m_MipCount = reader.ReadInt32();
|
||||
}
|
||||
var m_IsReadable = reader.ReadBoolean(); //2.6.0 and up
|
||||
var m_ReadAllowed = reader.ReadBoolean(); //3.0.0 - 5.4
|
||||
//bool m_StreamingMipmaps 2018.2 and up
|
||||
reader.AlignStream();
|
||||
if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 2)) //2018.2 and up
|
||||
{
|
||||
var m_StreamingMipmapsPriority = reader.ReadInt32();
|
||||
}
|
||||
var m_ImageCount = reader.ReadInt32();
|
||||
var m_TextureDimension = reader.ReadInt32();
|
||||
m_TextureSettings = new GLTextureSettings(reader);
|
||||
if (version[0] >= 3) //3.0 and up
|
||||
{
|
||||
var m_LightmapFormat = reader.ReadInt32();
|
||||
}
|
||||
if (version[0] > 3 || (version[0] == 3 && version[1] >= 5)) //3.5.0 and up
|
||||
{
|
||||
var m_ColorSpace = reader.ReadInt32();
|
||||
}
|
||||
var image_data_size = reader.ReadInt32();
|
||||
if (image_data_size == 0 && ((version[0] == 5 && version[1] >= 3) || version[0] > 5))//5.3.0 and up
|
||||
{
|
||||
offset = reader.ReadUInt32();
|
||||
size = reader.ReadUInt32();
|
||||
image_data_size = (int)size;
|
||||
path = reader.ReadAlignedString();
|
||||
m_StreamData = new StreamingInfo(reader);
|
||||
}
|
||||
|
||||
ResourceReader resourceReader;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
if (!string.IsNullOrEmpty(m_StreamData?.path))
|
||||
{
|
||||
resourceReader = new ResourceReader(path, assetsFile, offset, image_data_size);
|
||||
resourceReader = new ResourceReader(m_StreamData.path, assetsFile, m_StreamData.offset, (int)m_StreamData.size);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ namespace AssetStudio
|
||||
{
|
||||
public Vector3 Position { get; set; }
|
||||
public float[] Weights { get; set; }
|
||||
public byte[] BoneIndices { get; set; }
|
||||
public int[] BoneIndices { get; set; }
|
||||
public Vector3 Normal { get; set; }
|
||||
public float[] UV { get; set; }
|
||||
public Vector4 Tangent { get; set; }
|
||||
|
Reference in New Issue
Block a user