diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0672046a..0ac5fabc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,9 +20,9 @@ jobs: run: | md fbx cd fbx - Invoke-WebRequest "https://damassets.autodesk.net/content/dam/autodesk/www/adn/fbx/2020-2-1/fbx202021_fbxsdk_vs2019_win.exe" -OutFile "fbxsdk.exe" + Invoke-WebRequest "https://damassets.autodesk.net/content/dam/autodesk/www/adn/fbx/2020-3-2/fbx202032_fbxsdk_vs2019_win.exe" -OutFile "fbxsdk.exe" Start-Process -FilePath "fbxsdk.exe" /S -Wait - Invoke-WebRequest "https://damassets.autodesk.net/content/dam/autodesk/www/adn/fbx/2020-2-1/fbx202021_fbxsdk_vs2019_pdbs.exe" -OutFile "fbxpdb.exe" + Invoke-WebRequest "https://damassets.autodesk.net/content/dam/autodesk/www/adn/fbx/2020-3-2/fbx202032_fbxsdk_vs2019_pdbs.exe" -OutFile "fbxpdb.exe" Start-Process -FilePath "fbxpdb.exe" /S -Wait cd .. diff --git a/AssetStudio/Classes/AnimationClip.cs b/AssetStudio/Classes/AnimationClip.cs index 5769838d..abe7af4f 100644 --- a/AssetStudio/Classes/AnimationClip.cs +++ b/AssetStudio/Classes/AnimationClip.cs @@ -1019,7 +1019,7 @@ public AnimationClip(ObjectReader reader) : base(reader) } m_SampleRate = reader.ReadSingle(); - m_WrapMode = reader.ReadInt32(); + //m_WrapMode = reader.ReadInt32(); if (version[0] > 3 || (version[0] == 3 && version[1] >= 4)) //3.4 and up { m_Bounds = new AABB(reader); diff --git a/AssetStudio/Classes/AudioClip.cs b/AssetStudio/Classes/AudioClip.cs index 90a226c5..c4df54dd 100644 --- a/AssetStudio/Classes/AudioClip.cs +++ b/AssetStudio/Classes/AudioClip.cs @@ -35,10 +35,11 @@ public AudioClip(ObjectReader reader) : base(reader) { if (version[0] < 5) { - m_Format = reader.ReadInt32(); m_Type = (FMODSoundType)reader.ReadInt32(); - m_3D = reader.ReadBoolean(); - m_UseHardware = reader.ReadBoolean(); + m_Length = reader.ReadSingle(); + m_Frequency = reader.ReadInt32(); + m_Size = reader.ReadInt32(); + var m_DecompressOnLoad = reader.ReadBoolean(); reader.AlignStream(); if (version[0] >= 4 || (version[0] == 3 && version[1] >= 2)) //3.2.0 to 5 diff --git a/AssetStudio/Classes/Material.cs b/AssetStudio/Classes/Material.cs index dcc9f217..d58716f0 100644 --- a/AssetStudio/Classes/Material.cs +++ b/AssetStudio/Classes/Material.cs @@ -13,6 +13,8 @@ public UnityTexEnv(ObjectReader reader) m_Texture = new PPtr(reader); m_Scale = reader.ReadVector2(); m_Offset = reader.ReadVector2(); + var m_Pivot = reader.ReadVector2(); + var m_Rotation = reader.ReadSingle(); } } diff --git a/AssetStudio/Classes/Mesh.cs b/AssetStudio/Classes/Mesh.cs index e11c637c..5b0069ba 100644 --- a/AssetStudio/Classes/Mesh.cs +++ b/AssetStudio/Classes/Mesh.cs @@ -423,7 +423,7 @@ public SubMesh(ObjectReader reader) firstByte = reader.ReadUInt32(); indexCount = reader.ReadUInt32(); - topology = (GfxPrimitiveType)reader.ReadInt32(); + topology = reader.ReadUInt32() > 0 ? GfxPrimitiveType.TriangleStrip : GfxPrimitiveType.Triangles; if (version[0] < 4) //4.0 down { @@ -479,25 +479,6 @@ public Mesh(ObjectReader reader) : base(reader) m_Use16BitIndices = reader.ReadInt32() > 0; } - if (version[0] == 2 && version[1] <= 5) //2.5 and down - { - int m_IndexBuffer_size = reader.ReadInt32(); - - if (m_Use16BitIndices) - { - m_IndexBuffer = new uint[m_IndexBuffer_size / 2]; - for (int i = 0; i < m_IndexBuffer_size / 2; i++) - { - m_IndexBuffer[i] = reader.ReadUInt16(); - } - reader.AlignStream(); - } - else - { - m_IndexBuffer = reader.ReadUInt32Array(m_IndexBuffer_size / 4); - } - } - int m_SubMeshesSize = reader.ReadInt32(); m_SubMeshes = new SubMesh[m_SubMeshesSize]; for (int i = 0; i < m_SubMeshesSize; i++) @@ -517,56 +498,53 @@ public Mesh(ObjectReader reader) : base(reader) var m_RootBoneNameHash = reader.ReadUInt32(); } - if (version[0] > 2 || (version[0] == 2 && version[1] >= 6)) //2.6.0 and up + if (version[0] >= 2019) //2019 and up { - if (version[0] >= 2019) //2019 and up + var m_BonesAABBSize = reader.ReadInt32(); + var m_BonesAABB = new MinMaxAABB[m_BonesAABBSize]; + for (int i = 0; i < m_BonesAABBSize; i++) { - var m_BonesAABBSize = reader.ReadInt32(); - var m_BonesAABB = new MinMaxAABB[m_BonesAABBSize]; - for (int i = 0; i < m_BonesAABBSize; i++) - { - m_BonesAABB[i] = new MinMaxAABB(reader); - } - - var m_VariableBoneCountWeights = reader.ReadUInt32Array(); + m_BonesAABB[i] = new MinMaxAABB(reader); } - var m_MeshCompression = reader.ReadByte(); - if (version[0] >= 4) - { - if (version[0] < 5) - { - var m_StreamCompression = reader.ReadByte(); - } - var m_IsReadable = reader.ReadBoolean(); - var m_KeepVertices = reader.ReadBoolean(); - var m_KeepIndices = reader.ReadBoolean(); - } - reader.AlignStream(); + var m_VariableBoneCountWeights = reader.ReadUInt32Array(); + } - //Unity fixed it in 2017.3.1p1 and later versions - if ((version[0] > 2017 || (version[0] == 2017 && version[1] >= 4)) || //2017.4 - ((version[0] == 2017 && version[1] == 3 && version[2] == 1) && buildType.IsPatch) || //fixed after 2017.3.1px - ((version[0] == 2017 && version[1] == 3) && m_MeshCompression == 0))//2017.3.xfx with no compression + var m_MeshCompression = reader.ReadByte(); + if (version[0] >= 4) + { + if (version[0] < 5) { - var m_IndexFormat = reader.ReadInt32(); - m_Use16BitIndices = m_IndexFormat == 0; + var m_StreamCompression = reader.ReadByte(); } + var m_IsReadable = reader.ReadBoolean(); + var m_KeepVertices = reader.ReadBoolean(); + var m_KeepIndices = reader.ReadBoolean(); + } + reader.AlignStream(); - int m_IndexBuffer_size = reader.ReadInt32(); - if (m_Use16BitIndices) - { - m_IndexBuffer = new uint[m_IndexBuffer_size / 2]; - for (int i = 0; i < m_IndexBuffer_size / 2; i++) - { - m_IndexBuffer[i] = reader.ReadUInt16(); - } - reader.AlignStream(); - } - else + //Unity fixed it in 2017.3.1p1 and later versions + if ((version[0] > 2017 || (version[0] == 2017 && version[1] >= 4)) || //2017.4 + ((version[0] == 2017 && version[1] == 3 && version[2] == 1) && buildType.IsPatch) || //fixed after 2017.3.1px + ((version[0] == 2017 && version[1] == 3) && m_MeshCompression == 0))//2017.3.xfx with no compression + { + var m_IndexFormat = reader.ReadInt32(); + m_Use16BitIndices = m_IndexFormat == 0; + } + + int m_IndexBuffer_size = reader.ReadInt32(); + if (m_Use16BitIndices) + { + m_IndexBuffer = new uint[m_IndexBuffer_size / 2]; + for (int i = 0; i < m_IndexBuffer_size / 2; i++) { - m_IndexBuffer = reader.ReadUInt32Array(m_IndexBuffer_size / 4); + m_IndexBuffer[i] = reader.ReadUInt16(); } + reader.AlignStream(); + } + else + { + m_IndexBuffer = reader.ReadUInt32Array(m_IndexBuffer_size / 4); } if (version[0] < 3 || (version[0] == 3 && version[1] < 5)) //3.4.2 and earlier @@ -586,28 +564,9 @@ public Mesh(ObjectReader reader) : base(reader) m_UV1 = reader.ReadSingleArray(reader.ReadInt32() * 2); //Vector2 - if (version[0] == 2 && version[1] <= 5) //2.5 and down - { - int m_TangentSpace_size = reader.ReadInt32(); - m_Normals = new float[m_TangentSpace_size * 3]; - m_Tangents = new float[m_TangentSpace_size * 4]; - for (int v = 0; v < m_TangentSpace_size; v++) - { - m_Normals[v * 3] = reader.ReadSingle(); - m_Normals[v * 3 + 1] = reader.ReadSingle(); - m_Normals[v * 3 + 2] = reader.ReadSingle(); - m_Tangents[v * 3] = reader.ReadSingle(); - m_Tangents[v * 3 + 1] = reader.ReadSingle(); - m_Tangents[v * 3 + 2] = reader.ReadSingle(); - m_Tangents[v * 3 + 3] = reader.ReadSingle(); //handedness - } - } - else //2.6.0 and later - { - m_Tangents = reader.ReadSingleArray(reader.ReadInt32() * 4); //Vector4 + m_Tangents = reader.ReadSingleArray(reader.ReadInt32() * 4); //Vector4 - m_Normals = reader.ReadSingleArray(reader.ReadInt32() * 3); //Vector3 - } + m_Normals = reader.ReadSingleArray(reader.ReadInt32() * 3); //Vector3 } else { @@ -628,10 +587,7 @@ public Mesh(ObjectReader reader) : base(reader) m_VertexData = new VertexData(reader); } - if (version[0] > 2 || (version[0] == 2 && version[1] >= 6)) //2.6.0 and later - { - m_CompressedMesh = new CompressedMesh(reader); - } + m_CompressedMesh = new CompressedMesh(reader); reader.Position += 24; //AABB m_LocalAABB @@ -695,10 +651,7 @@ private void ProcessData() ReadVertexData(); } - if (version[0] > 2 || (version[0] == 2 && version[1] >= 6)) //2.6.0 and later - { - DecompressCompressedMesh(); - } + DecompressCompressedMesh(); GetTriangles(); } diff --git a/AssetStudio/Classes/PPtr.cs b/AssetStudio/Classes/PPtr.cs index a9ec6d63..983d92b9 100644 --- a/AssetStudio/Classes/PPtr.cs +++ b/AssetStudio/Classes/PPtr.cs @@ -1,4 +1,5 @@ using System; +using System.Buffers.Binary; namespace AssetStudio { @@ -12,8 +13,11 @@ public sealed class PPtr where T : Object public PPtr(ObjectReader reader) { - m_FileID = reader.ReadInt32(); - m_PathID = reader.m_Version < SerializedFileFormatVersion.Unknown_14 ? reader.ReadInt32() : reader.ReadInt64(); + var buffer = (new byte[8]); + reader.Read(buffer, 0, buffer.Length); + + m_FileID = BinaryPrimitives.ReadInt16LittleEndian(buffer); + m_PathID = ((long)BinaryPrimitives.ReadUInt16LittleEndian(buffer.AsSpan(2)) << 32) | BinaryPrimitives.ReadUInt32LittleEndian(buffer.AsSpan(4)); assetsFile = reader.assetsFile; } diff --git a/AssetStudio/Classes/SkinnedMeshRenderer.cs b/AssetStudio/Classes/SkinnedMeshRenderer.cs index d45f29e3..d6335623 100644 --- a/AssetStudio/Classes/SkinnedMeshRenderer.cs +++ b/AssetStudio/Classes/SkinnedMeshRenderer.cs @@ -18,11 +18,6 @@ public SkinnedMeshRenderer(ObjectReader reader) : base(reader) var m_SkinNormals = reader.ReadBoolean(); //3.1.0 and below reader.AlignStream(); - if (version[0] == 2 && version[1] < 6) //2.6 down - { - var m_DisableAnimationWhenOffscreen = new PPtr(reader); - } - m_Mesh = new PPtr(reader); m_Bones = new PPtr[reader.ReadInt32()]; diff --git a/AssetStudio/Classes/Texture2D.cs b/AssetStudio/Classes/Texture2D.cs index af90baf0..28fedf8f 100644 --- a/AssetStudio/Classes/Texture2D.cs +++ b/AssetStudio/Classes/Texture2D.cs @@ -125,6 +125,9 @@ public Texture2D(ObjectReader reader) : base(reader) var m_PlatformBlob = reader.ReadUInt8Array(); reader.AlignStream(); } + var m_Limit = reader.ReadInt32(); + var m_Touchable = reader.ReadBoolean(); + reader.AlignStream(); 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 { diff --git a/AssetStudio/SerializedFile.cs b/AssetStudio/SerializedFile.cs index 76174186..88aee399 100644 --- a/AssetStudio/SerializedFile.cs +++ b/AssetStudio/SerializedFile.cs @@ -72,7 +72,7 @@ public SerializedFile(FileReader reader, AssetsManager assetsManager) } if (header.m_Version >= SerializedFileFormatVersion.Unknown_7) { - unityVersion = reader.ReadStringToNull(); + unityVersion = "2.5.5b4"; SetVersion(unityVersion); } if (header.m_Version >= SerializedFileFormatVersion.Unknown_8) diff --git a/AssetStudioFBXNative/AssetStudioFBXNative.vcxproj b/AssetStudioFBXNative/AssetStudioFBXNative.vcxproj index b7c19024..0ffba44d 100644 --- a/AssetStudioFBXNative/AssetStudioFBXNative.vcxproj +++ b/AssetStudioFBXNative/AssetStudioFBXNative.vcxproj @@ -100,14 +100,14 @@ true _AS_DLL;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - C:\Program Files\Autodesk\FBX\FBX SDK\2020.2.1\include;%(AdditionalIncludeDirectories) + C:\Program Files\Autodesk\FBX\FBX SDK\2020.3.2\include;%(AdditionalIncludeDirectories) MultiThreadedDebug Console true libfbxsdk-mt.lib;libxml2-mt.lib;zlib-mt.lib;wininet.lib;%(AdditionalDependencies) - C:\Program Files\Autodesk\FBX\FBX SDK\2020.2.1\lib\vs2019\x86\debug;%(AdditionalLibraryDirectories) + C:\Program Files\Autodesk\FBX\FBX SDK\2020.3.2\lib\vs2019\x86\debug;%(AdditionalLibraryDirectories) LIBCMT;%(IgnoreSpecificDefaultLibraries) @@ -119,7 +119,7 @@ true _AS_DLL;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - C:\Program Files\Autodesk\FBX\FBX SDK\2020.2.1\include;%(AdditionalIncludeDirectories) + C:\Program Files\Autodesk\FBX\FBX SDK\2020.3.2\include;%(AdditionalIncludeDirectories) MultiThreaded @@ -128,7 +128,7 @@ true true libfbxsdk-mt.lib;libxml2-mt.lib;zlib-mt.lib;%(AdditionalDependencies) - C:\Program Files\Autodesk\FBX\FBX SDK\2020.2.1\lib\vs2019\x86\release;%(AdditionalLibraryDirectories) + C:\Program Files\Autodesk\FBX\FBX SDK\2020.3.2\lib\vs2019\x86\release;%(AdditionalLibraryDirectories) @@ -137,14 +137,14 @@ true _AS_DLL;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - C:\Program Files\Autodesk\FBX\FBX SDK\2020.2.1\include;%(AdditionalIncludeDirectories) + C:\Program Files\Autodesk\FBX\FBX SDK\2020.3.2\include;%(AdditionalIncludeDirectories) MultiThreadedDebug Console true libfbxsdk-mt.lib;libxml2-mt.lib;zlib-mt.lib;wininet.lib;%(AdditionalDependencies) - C:\Program Files\Autodesk\FBX\FBX SDK\2020.2.1\lib\vs2019\x64\debug;%(AdditionalLibraryDirectories) + C:\Program Files\Autodesk\FBX\FBX SDK\2020.3.2\lib\vs2019\x64\debug;%(AdditionalLibraryDirectories) LIBCMT;%(IgnoreSpecificDefaultLibraries) @@ -156,7 +156,7 @@ true _AS_DLL;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - C:\Program Files\Autodesk\FBX\FBX SDK\2020.2.1\include;%(AdditionalIncludeDirectories) + C:\Program Files\Autodesk\FBX\FBX SDK\2020.3.2\include;%(AdditionalIncludeDirectories) MultiThreaded @@ -165,7 +165,7 @@ true true libfbxsdk-mt.lib;libxml2-mt.lib;zlib-mt.lib;%(AdditionalDependencies) - C:\Program Files\Autodesk\FBX\FBX SDK\2020.2.1\lib\vs2019\x64\release;%(AdditionalLibraryDirectories) + C:\Program Files\Autodesk\FBX\FBX SDK\2020.3.2\lib\vs2019\x64\release;%(AdditionalLibraryDirectories) diff --git a/README.md b/README.md index 47425c48..3f8caec0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,13 @@ -# AssetStudio -[![Build status](https://ci.appveyor.com/api/projects/status/rnu7l90422pdewx4?svg=true)](https://ci.appveyor.com/project/Perfare/assetstudio/branch/master/artifacts) +# FFStudio + +Customized `AssetStudio` that works with FF. + +Special Thanks To: +- [OpenFusion](https://github.com/OpenFusionProject/OpenFusion). +- [Jade](https://github.com/JadeShrineMaiden). +- [bc15bekl](https://github.com/bc15bekl). + +_____________________________________________________________________________________________________________________________ **None of the repo, the tool, nor the repo owner is affiliated with, or sponsored or authorized by, Unity Technologies or its affiliates.**