- [Core] Fix bug with assets parsing.
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
@@ -43,10 +40,64 @@ namespace AssetStudio
|
||||
Logger.Verbose($"Initialized reader for {type} object with {m_PathID} in file {assetsFile.fileName} !!");
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int index, int count)
|
||||
{
|
||||
var pos = Position - byteStart;
|
||||
if (pos + count > byteSize)
|
||||
{
|
||||
throw new EndOfStreamException("Unable to read beyond the end of the stream.");
|
||||
}
|
||||
return base.Read(buffer, index, count);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
Logger.Verbose($"Resetting reader position to object offset 0x{byteStart:X8}...");
|
||||
Position = byteStart;
|
||||
}
|
||||
|
||||
public Vector3 ReadVector3()
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))
|
||||
{
|
||||
return new Vector3(ReadSingle(), ReadSingle(), ReadSingle());
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Vector4(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle());
|
||||
}
|
||||
}
|
||||
|
||||
public XForm ReadXForm()
|
||||
{
|
||||
var t = ReadVector3();
|
||||
var q = ReadQuaternion();
|
||||
var s = ReadVector3();
|
||||
|
||||
return new XForm(t, q, s);
|
||||
}
|
||||
|
||||
public XForm ReadXForm4()
|
||||
{
|
||||
var t = ReadVector4();
|
||||
var q = ReadQuaternion();
|
||||
var s = ReadVector4();
|
||||
|
||||
return new XForm(t, q, s);
|
||||
}
|
||||
|
||||
public Vector3[] ReadVector3Array(int length = 0)
|
||||
{
|
||||
if (length == 0)
|
||||
{
|
||||
length = ReadInt32();
|
||||
}
|
||||
return ReadArray(ReadVector3, length);
|
||||
}
|
||||
|
||||
public XForm[] ReadXFormArray()
|
||||
{
|
||||
return ReadArray(ReadXForm, ReadInt32());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user