2018.3.0b support
Refactor mesh read Fixed bug
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user