Compare commits
271 Commits
v0.10.0
...
v0.14.38-m
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eab789939d | ||
|
|
04266251aa | ||
|
|
c5f7ef6e91 | ||
|
|
4a81c461e8 | ||
|
|
b10d03d50d | ||
|
|
da98a0c5b8 | ||
|
|
76d17bacf5 | ||
|
|
6678ce082b | ||
|
|
07074b3deb | ||
|
|
df5d9f90d4 | ||
|
|
4f2d30552a | ||
|
|
d259c7a5cd | ||
|
|
c71ceb7ea6 | ||
|
|
85cf134a49 | ||
|
|
687b1d3a0d | ||
|
|
a30a0d0bc5 | ||
|
|
e1dc54d6d7 | ||
|
|
c4270e186d | ||
|
|
182a42ace2 | ||
|
|
06fbe69a97 | ||
|
|
a0bf4f9acd | ||
|
|
12568ba044 | ||
|
|
de95b02285 | ||
|
|
286edfe72c | ||
|
|
d717b223b7 | ||
|
|
9e195832ef | ||
|
|
c8d08b2793 | ||
|
|
2bcd9662be | ||
|
|
ea461ee3d2 | ||
|
|
fda821b441 | ||
|
|
5c193c761a | ||
|
|
14f47c6d30 | ||
|
|
e53eacef78 | ||
|
|
ada26db659 | ||
|
|
48ca96807f | ||
|
|
2018028853 | ||
|
|
6f138dcc05 | ||
|
|
69bcd2be67 | ||
|
|
45ad53b19a | ||
|
|
6230240ee3 | ||
|
|
73ec9f4bee | ||
|
|
f3a0bf505e | ||
|
|
290708876d | ||
|
|
5b96a29cca | ||
|
|
948e2c4d92 | ||
|
|
76da1c33ae | ||
|
|
72b84ee24d | ||
|
|
7b33d41172 | ||
|
|
c7043c1a83 | ||
|
|
d0baf26c61 | ||
|
|
60ac10b043 | ||
|
|
80dc24b487 | ||
|
|
9d32a9dd6a | ||
|
|
d96cc3c762 | ||
|
|
509df42730 | ||
|
|
4efa5b0507 | ||
|
|
cffe96b409 | ||
|
|
16dddc01e3 | ||
|
|
b5d2c2cadb | ||
|
|
1d2c0ab6cb | ||
|
|
c6b7e04c47 | ||
|
|
5704813b28 | ||
|
|
465c989e75 | ||
|
|
d335aaef9e | ||
|
|
495b48c783 | ||
|
|
05b55722fb | ||
|
|
de54257eef | ||
|
|
e62b6c3d77 | ||
|
|
dc05e5b5eb | ||
|
|
f377381e26 | ||
|
|
20f9fe493f | ||
|
|
0b462754a5 | ||
|
|
b1ea8dd346 | ||
|
|
4a46f897bd | ||
|
|
6a5ec80de7 | ||
|
|
4f2046d412 | ||
|
|
1cf59e8d67 | ||
|
|
e9e8390bbc | ||
|
|
738b084440 | ||
|
|
32cce894ac | ||
|
|
a6264b39d1 | ||
|
|
eb4981808b | ||
|
|
50c17c2ec4 | ||
|
|
e001dff3de | ||
|
|
3a0100ed37 | ||
|
|
58ab3116db | ||
|
|
6b93df41f2 | ||
|
|
b9cf7d5874 | ||
|
|
da4eb15d6b | ||
|
|
378840bc1b | ||
|
|
3441135b2f | ||
|
|
afcbba8182 | ||
|
|
cefdf08873 | ||
|
|
59be547a82 | ||
|
|
a2be5ebdac | ||
|
|
f76d3d8fcd | ||
|
|
edb6256fc9 | ||
|
|
8946a4fba5 | ||
|
|
87e1739208 | ||
|
|
10f4aaa39f | ||
|
|
957073b041 | ||
|
|
e1bb9a6cf0 | ||
|
|
558adb0b66 | ||
|
|
6a4979f999 | ||
|
|
9e76d94eea | ||
|
|
fa91820016 | ||
|
|
be091ecebb | ||
|
|
903be743ac | ||
|
|
c3c4697562 | ||
|
|
e6ed312de2 | ||
|
|
33461e068f | ||
|
|
7f13c90189 | ||
|
|
54ed3971a2 | ||
|
|
e602a5cf3b | ||
|
|
dec0a22ffe | ||
|
|
911272167a | ||
|
|
54d78d55a0 | ||
|
|
ff550b457f | ||
|
|
f449d7a8ab | ||
|
|
761579ab1a | ||
|
|
5cd4cf67cf | ||
|
|
fabfc77a52 | ||
|
|
f8ffaa0400 | ||
|
|
d156b5d947 | ||
|
|
d7551bdeb2 | ||
|
|
7d5e06bce4 | ||
|
|
0bc17f0ff5 | ||
|
|
9edc268cd4 | ||
|
|
356d5fa8a4 | ||
|
|
eb170d4f34 | ||
|
|
324c5ec7a2 | ||
|
|
ae155ca603 | ||
|
|
eb13585174 | ||
|
|
98c9eea58a | ||
|
|
067517740f | ||
|
|
3addb0e894 | ||
|
|
7452d4275e | ||
|
|
96ea522e83 | ||
|
|
ab24f049cf | ||
|
|
ec9184ba93 | ||
|
|
0a5b866a03 | ||
|
|
58d5a3fc37 | ||
|
|
19534ebb4d | ||
|
|
0a764c74d6 | ||
|
|
ab5f5fbd9d | ||
|
|
7dbc2ff95d | ||
|
|
bfaa207853 | ||
|
|
8c749e21e1 | ||
|
|
8ea998b81f | ||
|
|
b93866d196 | ||
|
|
c0a5a7a5dd | ||
|
|
6d68f2bde5 | ||
|
|
a89fd049f1 | ||
|
|
e7c5976f7c | ||
|
|
798a63e33c | ||
|
|
e13b4489c3 | ||
|
|
c6484ba77e | ||
|
|
a98fd52831 | ||
|
|
9d3cae8b28 | ||
|
|
f5aef9486f | ||
|
|
c2ae9e63e0 | ||
|
|
b04cdbf12b | ||
|
|
1f897cf431 | ||
|
|
d380c38710 | ||
|
|
3cd6126ed9 | ||
|
|
22b2d472bc | ||
|
|
2c58fae804 | ||
|
|
1e9b8037ab | ||
|
|
0dbd5b52f0 | ||
|
|
21a8d7ef49 | ||
|
|
17bd7a210a | ||
|
|
40b191f039 | ||
|
|
3442b39784 | ||
|
|
f15ee038b4 | ||
|
|
ec8b41155a | ||
|
|
d54bfbdfe7 | ||
|
|
a1f491af25 | ||
|
|
f2b041741b | ||
|
|
97169ff6dd | ||
|
|
11019a8473 | ||
|
|
767e4d0bf6 | ||
|
|
250856598b | ||
|
|
61751eeb1b | ||
|
|
99651a5d77 | ||
|
|
b31614641d | ||
|
|
310c165824 | ||
|
|
a233af5b8f | ||
|
|
2d0278db87 | ||
|
|
18af0a8856 | ||
|
|
d7d56b4ad8 | ||
|
|
3034dbc392 | ||
|
|
0b508509af | ||
|
|
14ad9431b9 | ||
|
|
c9a98d7163 | ||
|
|
afae830ece | ||
|
|
ec8c3e71d6 | ||
|
|
a7c5330042 | ||
|
|
10f02af70b | ||
|
|
2fd2b71148 | ||
|
|
d1bec6a672 | ||
|
|
9336613755 | ||
|
|
9f482b7cf9 | ||
|
|
0c8fcb07b1 | ||
|
|
eb302be569 | ||
|
|
cb3cf2a5ea | ||
|
|
9e5a06c107 | ||
|
|
b49d5bdeb4 | ||
|
|
0c23548817 | ||
|
|
cdaeb36e06 | ||
|
|
114073f359 | ||
|
|
959a1a65b9 | ||
|
|
3e59a78376 | ||
|
|
2bd4729fe7 | ||
|
|
84054428a8 | ||
|
|
9ad063bd0a | ||
|
|
9d1fd2f945 | ||
|
|
35edb9d391 | ||
|
|
d523862fac | ||
|
|
21ff88c890 | ||
|
|
e034ac5c1e | ||
|
|
adf39dde27 | ||
|
|
9b1e3435d6 | ||
|
|
66a2dbe730 | ||
|
|
28a3b6cb23 | ||
|
|
2adda81b28 | ||
|
|
380afbf295 | ||
|
|
d39e24246e | ||
|
|
a3e430d98d | ||
|
|
e0dcd6ac10 | ||
|
|
02f8d46620 | ||
|
|
dc6b9748a3 | ||
|
|
54c2bdc728 | ||
|
|
18275557df | ||
|
|
453f6b6e36 | ||
|
|
7236136cf1 | ||
|
|
ac6bd5236e | ||
|
|
b2acf9a2a7 | ||
|
|
7a8ac79ec4 | ||
|
|
70c9d0edb3 | ||
|
|
18e934dd7e | ||
|
|
3457d4d22c | ||
|
|
f65514b320 | ||
|
|
0a0b172a09 | ||
|
|
3e2d0935b8 | ||
|
|
71c633b506 | ||
|
|
79af119cf4 | ||
|
|
9385b4da76 | ||
|
|
75985c8bf0 | ||
|
|
9c8601a665 | ||
|
|
8218662548 | ||
|
|
52ba354dc5 | ||
|
|
87d6a26232 | ||
|
|
546fe52ff0 | ||
|
|
674c634c2c | ||
|
|
a3c92ddb8f | ||
|
|
4bcc16245c | ||
|
|
bd5eb3be5d | ||
|
|
ffda15a1a5 | ||
|
|
5354506315 | ||
|
|
ed569bfaf8 | ||
|
|
592bfb64e7 | ||
|
|
17b986f5df | ||
|
|
de464dfe10 | ||
|
|
906149a58a | ||
|
|
e3a0ab4e4a | ||
|
|
500f7788d4 | ||
|
|
af80b270cf | ||
|
|
8031d1a03f | ||
|
|
bc2469e11a | ||
|
|
9e4be3e082 | ||
|
|
7410511c40 |
172
.gitignore
vendored
172
.gitignore
vendored
@@ -1,7 +1,10 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
@@ -15,13 +18,22 @@
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
build/
|
||||
x64/
|
||||
x86/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
# Visual Studio 2015 cache/options directory
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
@@ -36,18 +48,28 @@ TestResult.xml
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# DNX
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
@@ -57,6 +79,7 @@ artifacts/
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
@@ -72,14 +95,21 @@ _Chutzpah*
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
@@ -101,9 +131,18 @@ _TeamCity*
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
@@ -131,47 +170,68 @@ publish/
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
## TODO: Comment the next line if you want to checkin your
|
||||
## web deploy settings but do note that will include unencrypted
|
||||
## passwords
|
||||
#*.pubxml
|
||||
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/packages/*
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/packages/build/
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/packages/repositories.config
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Windows Azure Build Output
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Windows Store app package directory
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
[Ss]tyle[Cc]op.*
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
node_modules/
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
@@ -182,21 +242,30 @@ _UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- Backup*.rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
@@ -204,7 +273,68 @@ FakesAssemblies/
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# LightSwitch generated files
|
||||
GeneratedArtifacts/
|
||||
_Pvt_Extensions/
|
||||
ModelManifest.xml
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
@@ -1,49 +1,71 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27130.2024
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29920.165
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssetStudio", "AssetStudio\AssetStudio.csproj", "{24551E2D-E9B6-4CD6-8F2A-D9F4A13E7853}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssetStudio", "AssetStudio\AssetStudio.csproj", "{7662F8C2-7BFD-442E-A948-A43B4F7EB06E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssetStudio-x86", "AssetStudio\AssetStudio-x86.csproj", "{F5E07FB2-95E4-417F-943F-D439D9A03BBA}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssetStudioFBX", "AssetStudioFBX\AssetStudioFBX.vcxproj", "{B82DD1BA-4EEC-4F29-A686-03D7F0DF39B8}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssetStudioFBX", "AssetStudioFBX\AssetStudioFBX.vcxproj", "{4F8EF5EF-732B-49CF-9EB3-B23E19AE6267}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Texture2DDecoder", "Texture2DDecoder\Texture2DDecoder.vcxproj", "{BEC7B5E6-0A7B-4824-97A7-EEA04D9EBA29}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssetStudioUtility", "AssetStudioUtility\AssetStudioUtility.csproj", "{9131C403-7FE8-444D-9AF5-5FE5DF76FF24}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssetStudioUtility", "AssetStudioUtility\AssetStudioUtility.csproj", "{80AEC261-21EE-4E4F-A93B-7A744DC84888}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssetStudioFBX-x86", "AssetStudioFBX\AssetStudioFBX-x86.vcxproj", "{276DE52E-3FFE-4C3D-9076-62BCB7A5B991}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssetStudioGUI", "AssetStudioGUI\AssetStudioGUI.csproj", "{52B196FB-4C8A-499B-B877-1A0EB4F33EC0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{24551E2D-E9B6-4CD6-8F2A-D9F4A13E7853}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{24551E2D-E9B6-4CD6-8F2A-D9F4A13E7853}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{24551E2D-E9B6-4CD6-8F2A-D9F4A13E7853}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{24551E2D-E9B6-4CD6-8F2A-D9F4A13E7853}.Release|Any CPU.Build.0 = Release|x64
|
||||
{F5E07FB2-95E4-417F-943F-D439D9A03BBA}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{F5E07FB2-95E4-417F-943F-D439D9A03BBA}.Debug|Any CPU.Build.0 = Debug|x86
|
||||
{F5E07FB2-95E4-417F-943F-D439D9A03BBA}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{F5E07FB2-95E4-417F-943F-D439D9A03BBA}.Release|Any CPU.Build.0 = Release|x86
|
||||
{4F8EF5EF-732B-49CF-9EB3-B23E19AE6267}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{4F8EF5EF-732B-49CF-9EB3-B23E19AE6267}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{4F8EF5EF-732B-49CF-9EB3-B23E19AE6267}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{4F8EF5EF-732B-49CF-9EB3-B23E19AE6267}.Release|Any CPU.Build.0 = Release|x64
|
||||
{9131C403-7FE8-444D-9AF5-5FE5DF76FF24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9131C403-7FE8-444D-9AF5-5FE5DF76FF24}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9131C403-7FE8-444D-9AF5-5FE5DF76FF24}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9131C403-7FE8-444D-9AF5-5FE5DF76FF24}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{276DE52E-3FFE-4C3D-9076-62BCB7A5B991}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||
{276DE52E-3FFE-4C3D-9076-62BCB7A5B991}.Debug|Any CPU.Build.0 = Debug|Win32
|
||||
{276DE52E-3FFE-4C3D-9076-62BCB7A5B991}.Release|Any CPU.ActiveCfg = Release|Win32
|
||||
{276DE52E-3FFE-4C3D-9076-62BCB7A5B991}.Release|Any CPU.Build.0 = Release|Win32
|
||||
{7662F8C2-7BFD-442E-A948-A43B4F7EB06E}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{7662F8C2-7BFD-442E-A948-A43B4F7EB06E}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{7662F8C2-7BFD-442E-A948-A43B4F7EB06E}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{7662F8C2-7BFD-442E-A948-A43B4F7EB06E}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{7662F8C2-7BFD-442E-A948-A43B4F7EB06E}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{7662F8C2-7BFD-442E-A948-A43B4F7EB06E}.Release|x64.Build.0 = Release|Any CPU
|
||||
{7662F8C2-7BFD-442E-A948-A43B4F7EB06E}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{7662F8C2-7BFD-442E-A948-A43B4F7EB06E}.Release|x86.Build.0 = Release|Any CPU
|
||||
{B82DD1BA-4EEC-4F29-A686-03D7F0DF39B8}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{B82DD1BA-4EEC-4F29-A686-03D7F0DF39B8}.Debug|x64.Build.0 = Debug|x64
|
||||
{B82DD1BA-4EEC-4F29-A686-03D7F0DF39B8}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{B82DD1BA-4EEC-4F29-A686-03D7F0DF39B8}.Debug|x86.Build.0 = Debug|Win32
|
||||
{B82DD1BA-4EEC-4F29-A686-03D7F0DF39B8}.Release|x64.ActiveCfg = Release|x64
|
||||
{B82DD1BA-4EEC-4F29-A686-03D7F0DF39B8}.Release|x64.Build.0 = Release|x64
|
||||
{B82DD1BA-4EEC-4F29-A686-03D7F0DF39B8}.Release|x86.ActiveCfg = Release|Win32
|
||||
{B82DD1BA-4EEC-4F29-A686-03D7F0DF39B8}.Release|x86.Build.0 = Release|Win32
|
||||
{BEC7B5E6-0A7B-4824-97A7-EEA04D9EBA29}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{BEC7B5E6-0A7B-4824-97A7-EEA04D9EBA29}.Debug|x64.Build.0 = Debug|x64
|
||||
{BEC7B5E6-0A7B-4824-97A7-EEA04D9EBA29}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{BEC7B5E6-0A7B-4824-97A7-EEA04D9EBA29}.Debug|x86.Build.0 = Debug|Win32
|
||||
{BEC7B5E6-0A7B-4824-97A7-EEA04D9EBA29}.Release|x64.ActiveCfg = Release|x64
|
||||
{BEC7B5E6-0A7B-4824-97A7-EEA04D9EBA29}.Release|x64.Build.0 = Release|x64
|
||||
{BEC7B5E6-0A7B-4824-97A7-EEA04D9EBA29}.Release|x86.ActiveCfg = Release|Win32
|
||||
{BEC7B5E6-0A7B-4824-97A7-EEA04D9EBA29}.Release|x86.Build.0 = Release|Win32
|
||||
{80AEC261-21EE-4E4F-A93B-7A744DC84888}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{80AEC261-21EE-4E4F-A93B-7A744DC84888}.Debug|x64.Build.0 = Debug|x64
|
||||
{80AEC261-21EE-4E4F-A93B-7A744DC84888}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{80AEC261-21EE-4E4F-A93B-7A744DC84888}.Debug|x86.Build.0 = Debug|x86
|
||||
{80AEC261-21EE-4E4F-A93B-7A744DC84888}.Release|x64.ActiveCfg = Release|x64
|
||||
{80AEC261-21EE-4E4F-A93B-7A744DC84888}.Release|x64.Build.0 = Release|x64
|
||||
{80AEC261-21EE-4E4F-A93B-7A744DC84888}.Release|x86.ActiveCfg = Release|x86
|
||||
{80AEC261-21EE-4E4F-A93B-7A744DC84888}.Release|x86.Build.0 = Release|x86
|
||||
{52B196FB-4C8A-499B-B877-1A0EB4F33EC0}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{52B196FB-4C8A-499B-B877-1A0EB4F33EC0}.Debug|x64.Build.0 = Debug|x64
|
||||
{52B196FB-4C8A-499B-B877-1A0EB4F33EC0}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{52B196FB-4C8A-499B-B877-1A0EB4F33EC0}.Debug|x86.Build.0 = Debug|x86
|
||||
{52B196FB-4C8A-499B-B877-1A0EB4F33EC0}.Release|x64.ActiveCfg = Release|x64
|
||||
{52B196FB-4C8A-499B-B877-1A0EB4F33EC0}.Release|x64.Build.0 = Release|x64
|
||||
{52B196FB-4C8A-499B-B877-1A0EB4F33EC0}.Release|x86.ActiveCfg = Release|x86
|
||||
{52B196FB-4C8A-499B-B877-1A0EB4F33EC0}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {F5C476A6-2B3B-416F-8BD5-6FE454FF3972}
|
||||
SolutionGuid = {F8734F96-97B6-40CA-B791-6D5467F2F713}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace SevenZip
|
||||
{
|
||||
class CRC
|
||||
public class CRC
|
||||
{
|
||||
public static readonly uint[] Table;
|
||||
|
||||
|
||||
@@ -1,144 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace SevenZip.Compression.LZMA
|
||||
{
|
||||
public static class SevenZipHelper
|
||||
{
|
||||
|
||||
static int dictionary = 1 << 23;
|
||||
|
||||
// static Int32 posStateBits = 2;
|
||||
// static Int32 litContextBits = 3; // for normal files
|
||||
// UInt32 litContextBits = 0; // for 32-bit data
|
||||
// static Int32 litPosBits = 0;
|
||||
// UInt32 litPosBits = 2; // for 32-bit data
|
||||
// static Int32 algorithm = 2;
|
||||
// static Int32 numFastBytes = 128;
|
||||
|
||||
static bool eos = false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static CoderPropID[] propIDs =
|
||||
{
|
||||
CoderPropID.DictionarySize,
|
||||
CoderPropID.PosStateBits,
|
||||
CoderPropID.LitContextBits,
|
||||
CoderPropID.LitPosBits,
|
||||
CoderPropID.Algorithm,
|
||||
CoderPropID.NumFastBytes,
|
||||
CoderPropID.MatchFinder,
|
||||
CoderPropID.EndMarker
|
||||
};
|
||||
|
||||
// these are the default properties, keeping it simple for now:
|
||||
static object[] properties =
|
||||
{
|
||||
(Int32)(dictionary),
|
||||
(Int32)(2),
|
||||
(Int32)(3),
|
||||
(Int32)(0),
|
||||
(Int32)(2),
|
||||
(Int32)(128),
|
||||
"bt4",
|
||||
eos
|
||||
};
|
||||
|
||||
|
||||
public static byte[] Compress(byte[] inputBytes)
|
||||
{
|
||||
|
||||
MemoryStream inStream = new MemoryStream(inputBytes);
|
||||
MemoryStream outStream = new MemoryStream();
|
||||
Encoder encoder = new Encoder();
|
||||
encoder.SetCoderProperties(propIDs, properties);
|
||||
encoder.WriteCoderProperties(outStream);
|
||||
long fileSize = inStream.Length;
|
||||
for (int i = 0; i < 8; i++)
|
||||
outStream.WriteByte((Byte)(fileSize >> (8 * i)));
|
||||
encoder.Code(inStream, outStream, -1, -1, null);
|
||||
return outStream.ToArray();
|
||||
}
|
||||
|
||||
public static byte[] Decompress(byte[] inputBytes)
|
||||
{
|
||||
MemoryStream newInStream = new MemoryStream(inputBytes);
|
||||
|
||||
Decoder decoder = new Decoder();
|
||||
|
||||
newInStream.Seek(0, 0);
|
||||
MemoryStream newOutStream = new MemoryStream();
|
||||
|
||||
byte[] properties2 = new byte[5];
|
||||
if (newInStream.Read(properties2, 0, 5) != 5)
|
||||
throw (new Exception("input .lzma is too short"));
|
||||
long outSize = 0;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
int v = newInStream.ReadByte();
|
||||
if (v < 0)
|
||||
throw (new Exception("Can't Read 1"));
|
||||
outSize |= ((long)(byte)v) << (8 * i);
|
||||
}
|
||||
decoder.SetDecoderProperties(properties2);
|
||||
|
||||
long compressedSize = newInStream.Length - newInStream.Position;
|
||||
decoder.Code(newInStream, newOutStream, compressedSize, outSize, null);
|
||||
|
||||
byte[] b = newOutStream.ToArray();
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
public static MemoryStream StreamDecompress(MemoryStream newInStream)
|
||||
{
|
||||
Decoder decoder = new Decoder();
|
||||
|
||||
newInStream.Seek(0, 0);
|
||||
MemoryStream newOutStream = new MemoryStream();
|
||||
|
||||
byte[] properties2 = new byte[5];
|
||||
if (newInStream.Read(properties2, 0, 5) != 5)
|
||||
throw (new Exception("input .lzma is too short"));
|
||||
long outSize = 0;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
int v = newInStream.ReadByte();
|
||||
if (v < 0)
|
||||
throw (new Exception("Can't Read 1"));
|
||||
outSize |= ((long)(byte)v) << (8 * i);
|
||||
}
|
||||
decoder.SetDecoderProperties(properties2);
|
||||
|
||||
long compressedSize = newInStream.Length - newInStream.Position;
|
||||
decoder.Code(newInStream, newOutStream, compressedSize, outSize, null);
|
||||
|
||||
newOutStream.Position = 0;
|
||||
return newOutStream;
|
||||
}
|
||||
|
||||
public static MemoryStream StreamDecompress(MemoryStream newInStream, long outSize)
|
||||
{
|
||||
Decoder decoder = new Decoder();
|
||||
|
||||
newInStream.Seek(0, 0);
|
||||
MemoryStream newOutStream = new MemoryStream();
|
||||
|
||||
byte[] properties2 = new byte[5];
|
||||
if (newInStream.Read(properties2, 0, 5) != 5)
|
||||
throw (new Exception("input .lzma is too short"));
|
||||
decoder.SetDecoderProperties(properties2);
|
||||
|
||||
long compressedSize = newInStream.Length - newInStream.Position;
|
||||
decoder.Code(newInStream, newOutStream, compressedSize, outSize, null);
|
||||
|
||||
newOutStream.Position = 0;
|
||||
return newOutStream;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,290 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{F5E07FB2-95E4-417F-943F-D439D9A03BBA}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>AssetStudio</RootNamespace>
|
||||
<AssemblyName>AssetStudio</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>
|
||||
</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="BrotliSharpLib, Version=0.2.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>Library\BrotliSharpLib.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>Library\OpenTK.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK.GLControl, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>Library\OpenTK.GLControl.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="SharpDX.Mathematics">
|
||||
<HintPath>Library\SharpDX.Mathematics.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Half, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>Library\System.Half.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="7zip\Common\CommandLineParser.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Common\CRC.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Common\InBuffer.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Common\OutBuffer.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Compress\LZMA\LzmaBase.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Compress\LZMA\LzmaDecoder.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Compress\LZMA\LzmaEncoder.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Compress\LZ\IMatchFinder.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Compress\LZ\LzBinTree.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Compress\LZ\LzInWindow.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Compress\LZ\LzOutWindow.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Compress\RangeCoder\RangeCoder.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Compress\RangeCoder\RangeCoderBit.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Compress\RangeCoder\RangeCoderBitTree.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\ICoder.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\SevenZipHelper.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="AssetStudioForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="AssetStudioForm.Designer.cs">
|
||||
<DependentUpon>AssetStudioForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Classes\Animation.cs" />
|
||||
<Compile Include="Classes\AnimationClip.cs" />
|
||||
<Compile Include="Classes\Animator.cs" />
|
||||
<Compile Include="Classes\AnimatorController.cs" />
|
||||
<Compile Include="Classes\AnimatorOverrideController.cs" />
|
||||
<Compile Include="Classes\Avatar.cs" />
|
||||
<Compile Include="OpenFolderDialog.cs" />
|
||||
<Compile Include="Classes\AssetBundle.cs" />
|
||||
<Compile Include="Classes\MovieTexture.cs" />
|
||||
<Compile Include="Classes\Sprite.cs" />
|
||||
<Compile Include="Classes\SpriteAtlas.cs" />
|
||||
<Compile Include="Classes\VideoClip.cs" />
|
||||
<Compile Include="StudioClasses\AssetPreloadData.cs" />
|
||||
<Compile Include="Classes\AudioClip.cs" />
|
||||
<Compile Include="Classes\BuildSettings.cs" />
|
||||
<Compile Include="StudioClasses\BinaryReaderExtensions.cs" />
|
||||
<Compile Include="StudioClasses\BinaryWriterExtensions.cs" />
|
||||
<Compile Include="StudioClasses\BundleFile.cs" />
|
||||
<Compile Include="StudioClasses\ClassStruct.cs" />
|
||||
<Compile Include="StudioClasses\FBXExporter.cs" />
|
||||
<Compile Include="StudioClasses\BuildTarget.cs" />
|
||||
<Compile Include="StudioClasses\ModelConverter.cs" />
|
||||
<Compile Include="StudioClasses\ShaderResource.Designer.cs">
|
||||
<DependentUpon>ShaderResource.resx</DependentUpon>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<Compile Include="StudioClasses\SpriteHelper.cs" />
|
||||
<Compile Include="StudioClasses\StringExtensions.cs" />
|
||||
<Compile Include="StudioClasses\EndianBinaryReader.cs" />
|
||||
<Compile Include="Classes\Texture2D.Converter.cs" />
|
||||
<Compile Include="StudioClasses\Exporter.cs" />
|
||||
<Compile Include="StudioClasses\Importer.cs" />
|
||||
<Compile Include="StudioClasses\Studio.cs" />
|
||||
<Compile Include="StudioClasses\ClassIDReference.cs" />
|
||||
<Compile Include="ExportOptions.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ExportOptions.Designer.cs">
|
||||
<DependentUpon>ExportOptions.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="FMOD Studio API\fmod.cs" />
|
||||
<Compile Include="FMOD Studio API\fmod_dsp.cs" />
|
||||
<Compile Include="FMOD Studio API\fmod_errors.cs" />
|
||||
<Compile Include="Classes\Font.cs" />
|
||||
<Compile Include="GOHierarchy.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Lz4DecoderStream.cs" />
|
||||
<Compile Include="Classes\Material.cs" />
|
||||
<Compile Include="Classes\Mesh.cs" />
|
||||
<Compile Include="Classes\GameObject.cs" />
|
||||
<Compile Include="StudioClasses\PPtrHelpers.cs" />
|
||||
<Compile Include="Classes\MonoBehaviour.cs" />
|
||||
<Compile Include="Classes\PlayerSettings.cs" />
|
||||
<Compile Include="Classes\RectTransform.cs" />
|
||||
<Compile Include="Classes\MeshRenderer.cs" />
|
||||
<Compile Include="Classes\Shader.cs" />
|
||||
<Compile Include="Classes\SkinnedMeshRenderer.cs" />
|
||||
<Compile Include="Classes\MeshFilter.cs" />
|
||||
<Compile Include="Classes\TextAsset.cs" />
|
||||
<Compile Include="Classes\Texture2D.cs" />
|
||||
<Compile Include="Classes\Transform.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="StudioClasses\AssetsFile.cs" />
|
||||
<Compile Include="StudioClasses\WebFile.cs" />
|
||||
<EmbeddedResource Include="AssetStudioForm.resx">
|
||||
<DependentUpon>AssetStudioForm.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ExportOptions.resx">
|
||||
<DependentUpon>ExportOptions.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="StudioClasses\ShaderResource.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>ShaderResource.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="app.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Microsoft .NET Framework 4 Client Profile %28x86 and x64%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.4.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 4.5</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\preview.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AssetStudioFBX\AssetStudioFBX-x86.vcxproj">
|
||||
<Project>{276de52e-3ffe-4c3d-9076-62bcb7a5b991}</Project>
|
||||
<Name>AssetStudioFBX-x86</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\AssetStudioUtility\AssetStudioUtility.csproj">
|
||||
<Project>{9131c403-7fe8-444d-9af5-5fe5df76ff24}</Project>
|
||||
<Name>AssetStudioUtility</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>xcopy /y "$(ProjectDir)Library" "$(TargetDir)"
|
||||
xcopy /y "$(ProjectDir)Library\$(PlatformName)" "$(TargetDir)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -1,290 +1,154 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{24551E2D-E9B6-4CD6-8F2A-D9F4A13E7853}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{7662F8C2-7BFD-442E-A948-A43B4F7EB06E}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>AssetStudio</RootNamespace>
|
||||
<AssemblyName>AssetStudio</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>
|
||||
</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="BrotliSharpLib, Version=0.2.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>Library\BrotliSharpLib.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>Library\OpenTK.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK.GLControl, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>Library\OpenTK.GLControl.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="SharpDX.Mathematics">
|
||||
<HintPath>Library\SharpDX.Mathematics.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Half, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>Library\System.Half.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="7zip\Common\CommandLineParser.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Common\CRC.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Common\InBuffer.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Common\OutBuffer.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Compress\LZMA\LzmaBase.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Compress\LZMA\LzmaDecoder.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Compress\LZMA\LzmaEncoder.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Compress\LZ\IMatchFinder.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Compress\LZ\LzBinTree.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Compress\LZ\LzInWindow.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Compress\LZ\LzOutWindow.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Compress\RangeCoder\RangeCoder.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Compress\RangeCoder\RangeCoderBit.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Compress\RangeCoder\RangeCoderBitTree.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\ICoder.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\SevenZipHelper.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="7zip\Common\CommandLineParser.cs" />
|
||||
<Compile Include="7zip\Common\CRC.cs" />
|
||||
<Compile Include="7zip\Common\InBuffer.cs" />
|
||||
<Compile Include="7zip\Common\OutBuffer.cs" />
|
||||
<Compile Include="7zip\Compress\LZMA\LzmaBase.cs" />
|
||||
<Compile Include="7zip\Compress\LZMA\LzmaDecoder.cs" />
|
||||
<Compile Include="7zip\Compress\LZMA\LzmaEncoder.cs" />
|
||||
<Compile Include="7zip\Compress\LZ\IMatchFinder.cs" />
|
||||
<Compile Include="7zip\Compress\LZ\LzBinTree.cs" />
|
||||
<Compile Include="7zip\Compress\LZ\LzInWindow.cs" />
|
||||
<Compile Include="7zip\Compress\LZ\LzOutWindow.cs" />
|
||||
<Compile Include="7zip\Compress\RangeCoder\RangeCoder.cs" />
|
||||
<Compile Include="7zip\Compress\RangeCoder\RangeCoderBit.cs" />
|
||||
<Compile Include="7zip\Compress\RangeCoder\RangeCoderBitTree.cs" />
|
||||
<Compile Include="7zip\ICoder.cs" />
|
||||
<Compile Include="AssetsManager.cs" />
|
||||
<Compile Include="Brotli\BitReader.cs" />
|
||||
<Compile Include="Brotli\BrotliInputStream.cs" />
|
||||
<Compile Include="Brotli\BrotliRuntimeException.cs" />
|
||||
<Compile Include="Brotli\Context.cs" />
|
||||
<Compile Include="Brotli\Decode.cs" />
|
||||
<Compile Include="Brotli\Dictionary.cs" />
|
||||
<Compile Include="Brotli\Huffman.cs" />
|
||||
<Compile Include="Brotli\HuffmanTreeGroup.cs" />
|
||||
<Compile Include="Brotli\IntReader.cs" />
|
||||
<Compile Include="Brotli\Prefix.cs" />
|
||||
<Compile Include="Brotli\RunningState.cs" />
|
||||
<Compile Include="Brotli\State.cs" />
|
||||
<Compile Include="Brotli\Transform.cs" />
|
||||
<Compile Include="Brotli\Utils.cs" />
|
||||
<Compile Include="Brotli\WordTransformType.cs" />
|
||||
<Compile Include="BuildTarget.cs" />
|
||||
<Compile Include="BuildType.cs" />
|
||||
<Compile Include="BundleFile.cs" />
|
||||
<Compile Include="Classes\Animation.cs" />
|
||||
<Compile Include="Classes\AnimationClip.cs" />
|
||||
<Compile Include="Classes\Animator.cs" />
|
||||
<Compile Include="Classes\AnimatorController.cs" />
|
||||
<Compile Include="Classes\AnimatorOverrideController.cs" />
|
||||
<Compile Include="Classes\Avatar.cs" />
|
||||
<Compile Include="OpenFolderDialog.cs" />
|
||||
<Compile Include="StudioClasses\BinaryReaderExtensions.cs" />
|
||||
<Compile Include="StudioClasses\BinaryWriterExtensions.cs" />
|
||||
<Compile Include="StudioClasses\BuildTarget.cs" />
|
||||
<Compile Include="StudioClasses\ClassIDReference.cs" />
|
||||
<Compile Include="StudioClasses\ShaderResource.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>ShaderResource.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Classes\AssetBundle.cs" />
|
||||
<Compile Include="Classes\MovieTexture.cs" />
|
||||
<Compile Include="Classes\Sprite.cs" />
|
||||
<Compile Include="Classes\SpriteAtlas.cs" />
|
||||
<Compile Include="Classes\VideoClip.cs" />
|
||||
<Compile Include="StudioClasses\AssetPreloadData.cs" />
|
||||
<Compile Include="Classes\AudioClip.cs" />
|
||||
<Compile Include="Classes\Avatar.cs" />
|
||||
<Compile Include="Classes\Behaviour.cs" />
|
||||
<Compile Include="Classes\BuildSettings.cs" />
|
||||
<Compile Include="StudioClasses\BundleFile.cs" />
|
||||
<Compile Include="StudioClasses\ClassStruct.cs" />
|
||||
<Compile Include="StudioClasses\FBXExporter.cs" />
|
||||
<Compile Include="StudioClasses\SpriteHelper.cs" />
|
||||
<Compile Include="StudioClasses\StringExtensions.cs" />
|
||||
<Compile Include="Classes\Texture2D.Converter.cs" />
|
||||
<Compile Include="StudioClasses\Exporter.cs" />
|
||||
<Compile Include="StudioClasses\Importer.cs" />
|
||||
<Compile Include="StudioClasses\Studio.cs" />
|
||||
<Compile Include="StudioClasses\EndianBinaryReader.cs" />
|
||||
<Compile Include="ExportOptions.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ExportOptions.Designer.cs">
|
||||
<DependentUpon>ExportOptions.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="FMOD Studio API\fmod.cs" />
|
||||
<Compile Include="FMOD Studio API\fmod_dsp.cs" />
|
||||
<Compile Include="FMOD Studio API\fmod_errors.cs" />
|
||||
<Compile Include="Classes\Component.cs" />
|
||||
<Compile Include="Classes\EditorExtension.cs" />
|
||||
<Compile Include="Classes\Font.cs" />
|
||||
<Compile Include="GOHierarchy.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Lz4DecoderStream.cs" />
|
||||
<Compile Include="Classes\GameObject.cs" />
|
||||
<Compile Include="Classes\Material.cs" />
|
||||
<Compile Include="Classes\Mesh.cs" />
|
||||
<Compile Include="Classes\GameObject.cs" />
|
||||
<Compile Include="StudioClasses\PPtrHelpers.cs" />
|
||||
<Compile Include="Classes\MonoBehaviour.cs" />
|
||||
<Compile Include="Classes\PlayerSettings.cs" />
|
||||
<Compile Include="Classes\RectTransform.cs" />
|
||||
<Compile Include="Classes\MeshFilter.cs" />
|
||||
<Compile Include="Classes\MeshRenderer.cs" />
|
||||
<Compile Include="Classes\MonoBehaviour.cs" />
|
||||
<Compile Include="Classes\MonoScript.cs" />
|
||||
<Compile Include="Classes\MovieTexture.cs" />
|
||||
<Compile Include="Classes\NamedObject.cs" />
|
||||
<Compile Include="Classes\Object.cs" />
|
||||
<Compile Include="Classes\PlayerSettings.cs" />
|
||||
<Compile Include="Classes\PPtr.cs" />
|
||||
<Compile Include="Classes\RectTransform.cs" />
|
||||
<Compile Include="Classes\Renderer.cs" />
|
||||
<Compile Include="Classes\RuntimeAnimatorController.cs" />
|
||||
<Compile Include="Classes\Shader.cs" />
|
||||
<Compile Include="Classes\SkinnedMeshRenderer.cs" />
|
||||
<Compile Include="Classes\MeshFilter.cs" />
|
||||
<Compile Include="Classes\Sprite.cs" />
|
||||
<Compile Include="Classes\SpriteAtlas.cs" />
|
||||
<Compile Include="Classes\TextAsset.cs" />
|
||||
<Compile Include="Classes\Texture.cs" />
|
||||
<Compile Include="Classes\Texture2D.cs" />
|
||||
<Compile Include="Classes\Transform.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Classes\VideoClip.cs" />
|
||||
<Compile Include="ClassIDType.cs" />
|
||||
<Compile Include="CommonString.cs" />
|
||||
<Compile Include="EndianBinaryReader.cs" />
|
||||
<Compile Include="Extensions\BinaryReaderExtensions.cs" />
|
||||
<Compile Include="Extensions\BinaryWriterExtensions.cs" />
|
||||
<Compile Include="Extensions\StreamExtensions.cs" />
|
||||
<Compile Include="FileIdentifier.cs" />
|
||||
<Compile Include="IImported.cs" />
|
||||
<Compile Include="ILogger.cs" />
|
||||
<Compile Include="ImportHelper.cs" />
|
||||
<Compile Include="IProgress.cs" />
|
||||
<Compile Include="LocalSerializedObjectIdentifier.cs" />
|
||||
<Compile Include="Logger.cs" />
|
||||
<Compile Include="Lz4DecoderStream.cs" />
|
||||
<Compile Include="Math\Color.cs" />
|
||||
<Compile Include="Math\Half.cs" />
|
||||
<Compile Include="Math\HalfHelper.cs" />
|
||||
<Compile Include="Math\Matrix4x4.cs" />
|
||||
<Compile Include="Math\Quaternion.cs" />
|
||||
<Compile Include="Math\Vector2.cs" />
|
||||
<Compile Include="Math\Vector3.cs" />
|
||||
<Compile Include="Math\Vector4.cs" />
|
||||
<Compile Include="ObjectInfo.cs" />
|
||||
<Compile Include="ObjectReader.cs" />
|
||||
<Compile Include="Progress.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="StudioClasses\AssetsFile.cs" />
|
||||
<Compile Include="StudioClasses\ModelConverter.cs" />
|
||||
<Compile Include="StudioClasses\WebFile.cs" />
|
||||
<Compile Include="AssetStudioForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="AssetStudioForm.Designer.cs">
|
||||
<DependentUpon>AssetStudioForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="ExportOptions.resx">
|
||||
<DependentUpon>ExportOptions.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="StudioClasses\ShaderResource.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>ShaderResource.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="AssetStudioForm.resx">
|
||||
<DependentUpon>AssetStudioForm.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<None Include="app.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Microsoft .NET Framework 4 Client Profile %28x86 and x64%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.4.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 4.5</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\preview.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AssetStudioFBX\AssetStudioFBX.vcxproj">
|
||||
<Project>{4f8ef5ef-732b-49cf-9eb3-b23e19ae6267}</Project>
|
||||
<Name>AssetStudioFBX</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\AssetStudioUtility\AssetStudioUtility.csproj">
|
||||
<Project>{9131c403-7fe8-444d-9af5-5fe5df76ff24}</Project>
|
||||
<Name>AssetStudioUtility</Name>
|
||||
</ProjectReference>
|
||||
<Compile Include="ResourceReader.cs" />
|
||||
<Compile Include="SerializedFile.cs" />
|
||||
<Compile Include="SerializedFileHeader.cs" />
|
||||
<Compile Include="SerializedType.cs" />
|
||||
<Compile Include="SevenZipHelper.cs" />
|
||||
<Compile Include="StreamFile.cs" />
|
||||
<Compile Include="TypeTreeHelper.cs" />
|
||||
<Compile Include="TypeTreeNode.cs" />
|
||||
<Compile Include="UType.cs" />
|
||||
<Compile Include="WebFile.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>xcopy /y "$(ProjectDir)Library" "$(TargetDir)"
|
||||
xcopy /y "$(ProjectDir)Library\$(PlatformName)" "$(TargetDir)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
File diff suppressed because it is too large
Load Diff
413
AssetStudio/AssetsManager.cs
Normal file
413
AssetStudio/AssetsManager.cs
Normal file
@@ -0,0 +1,413 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using static AssetStudio.ImportHelper;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class AssetsManager
|
||||
{
|
||||
public List<SerializedFile> assetsFileList = new List<SerializedFile>();
|
||||
internal Dictionary<string, int> assetsFileIndexCache = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||
internal Dictionary<string, BinaryReader> resourceFileReaders = new Dictionary<string, BinaryReader>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
private List<string> importFiles = new List<string>();
|
||||
private HashSet<string> importFilesHash = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
private HashSet<string> assetsFileListHash = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public void LoadFiles(params string[] files)
|
||||
{
|
||||
var path = Path.GetDirectoryName(files[0]);
|
||||
MergeSplitAssets(path);
|
||||
var toReadFile = ProcessingSplitFiles(files.ToList());
|
||||
Load(toReadFile);
|
||||
}
|
||||
|
||||
public void LoadFolder(string path)
|
||||
{
|
||||
MergeSplitAssets(path, true);
|
||||
var files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).ToList();
|
||||
var toReadFile = ProcessingSplitFiles(files);
|
||||
Load(toReadFile);
|
||||
}
|
||||
|
||||
private void Load(string[] files)
|
||||
{
|
||||
foreach (var file in files)
|
||||
{
|
||||
importFiles.Add(file);
|
||||
importFilesHash.Add(Path.GetFileName(file));
|
||||
}
|
||||
|
||||
Progress.Reset();
|
||||
//use a for loop because list size can change
|
||||
for (var i = 0; i < importFiles.Count; i++)
|
||||
{
|
||||
LoadFile(importFiles[i]);
|
||||
Progress.Report(i + 1, importFiles.Count);
|
||||
}
|
||||
|
||||
importFiles.Clear();
|
||||
importFilesHash.Clear();
|
||||
assetsFileListHash.Clear();
|
||||
|
||||
ReadAssets();
|
||||
ProcessAssets();
|
||||
}
|
||||
|
||||
private void LoadFile(string fullName)
|
||||
{
|
||||
switch (CheckFileType(fullName, out var reader))
|
||||
{
|
||||
case FileType.AssetsFile:
|
||||
LoadAssetsFile(fullName, reader);
|
||||
break;
|
||||
case FileType.BundleFile:
|
||||
LoadBundleFile(fullName, reader);
|
||||
break;
|
||||
case FileType.WebFile:
|
||||
LoadWebFile(fullName, reader);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadAssetsFile(string fullName, EndianBinaryReader reader)
|
||||
{
|
||||
var fileName = Path.GetFileName(fullName);
|
||||
if (!assetsFileListHash.Contains(fileName))
|
||||
{
|
||||
Logger.Info($"Loading {fileName}");
|
||||
try
|
||||
{
|
||||
var assetsFile = new SerializedFile(this, fullName, reader);
|
||||
assetsFileList.Add(assetsFile);
|
||||
assetsFileListHash.Add(assetsFile.fileName);
|
||||
|
||||
foreach (var sharedFile in assetsFile.m_Externals)
|
||||
{
|
||||
var sharedFilePath = Path.GetDirectoryName(fullName) + "\\" + sharedFile.fileName;
|
||||
var sharedFileName = sharedFile.fileName;
|
||||
|
||||
if (!importFilesHash.Contains(sharedFileName))
|
||||
{
|
||||
if (!File.Exists(sharedFilePath))
|
||||
{
|
||||
var findFiles = Directory.GetFiles(Path.GetDirectoryName(fullName), sharedFileName, SearchOption.AllDirectories);
|
||||
if (findFiles.Length > 0)
|
||||
{
|
||||
sharedFilePath = findFiles[0];
|
||||
}
|
||||
}
|
||||
|
||||
if (File.Exists(sharedFilePath))
|
||||
{
|
||||
importFiles.Add(sharedFilePath);
|
||||
importFilesHash.Add(sharedFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
reader.Dispose();
|
||||
//Logger.Warning($"Unable to load assets file {fileName}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
reader.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadAssetsFromMemory(string fullName, EndianBinaryReader reader, string originalPath, string unityVersion = null)
|
||||
{
|
||||
var fileName = Path.GetFileName(fullName);
|
||||
if (!assetsFileListHash.Contains(fileName))
|
||||
{
|
||||
try
|
||||
{
|
||||
var assetsFile = new SerializedFile(this, fullName, reader);
|
||||
assetsFile.originalPath = originalPath;
|
||||
if (assetsFile.header.m_Version < 7)
|
||||
{
|
||||
assetsFile.SetVersion(unityVersion);
|
||||
}
|
||||
assetsFileList.Add(assetsFile);
|
||||
assetsFileListHash.Add(assetsFile.fileName);
|
||||
}
|
||||
catch
|
||||
{
|
||||
//Logger.Error($"Unable to load assets file {fileName} from {Path.GetFileName(originalPath)}");
|
||||
resourceFileReaders.Add(fileName, reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadBundleFile(string fullName, EndianBinaryReader reader, string parentPath = null)
|
||||
{
|
||||
var fileName = Path.GetFileName(fullName);
|
||||
Logger.Info("Loading " + fileName);
|
||||
try
|
||||
{
|
||||
var bundleFile = new BundleFile(reader, fullName);
|
||||
foreach (var file in bundleFile.fileList)
|
||||
{
|
||||
var subReader = new EndianBinaryReader(file.stream);
|
||||
if (SerializedFile.IsSerializedFile(subReader))
|
||||
{
|
||||
var dummyPath = Path.GetDirectoryName(fullName) + Path.DirectorySeparatorChar + file.fileName;
|
||||
LoadAssetsFromMemory(dummyPath, subReader, parentPath ?? fullName, bundleFile.m_Header.unityRevision);
|
||||
}
|
||||
else
|
||||
{
|
||||
resourceFileReaders.Add(file.fileName, subReader);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
/*var str = $"Unable to load bundle file {fileName}";
|
||||
if (parentPath != null)
|
||||
{
|
||||
str += $" from {Path.GetFileName(parentPath)}";
|
||||
}
|
||||
Logger.Error(str);*/
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadWebFile(string fullName, EndianBinaryReader reader)
|
||||
{
|
||||
var fileName = Path.GetFileName(fullName);
|
||||
Logger.Info("Loading " + fileName);
|
||||
try
|
||||
{
|
||||
var webFile = new WebFile(reader);
|
||||
foreach (var file in webFile.fileList)
|
||||
{
|
||||
var dummyPath = Path.GetDirectoryName(fullName) + "\\" + file.fileName;
|
||||
switch (CheckFileType(file.stream, out var fileReader))
|
||||
{
|
||||
case FileType.AssetsFile:
|
||||
LoadAssetsFromMemory(dummyPath, fileReader, fullName);
|
||||
break;
|
||||
case FileType.BundleFile:
|
||||
LoadBundleFile(dummyPath, fileReader, fullName);
|
||||
break;
|
||||
case FileType.WebFile:
|
||||
LoadWebFile(dummyPath, fileReader);
|
||||
break;
|
||||
case FileType.ResourceFile:
|
||||
resourceFileReaders.Add(file.fileName, fileReader);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
//Logger.Error($"Unable to load web file {fileName}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
foreach (var assetsFile in assetsFileList)
|
||||
{
|
||||
assetsFile.Objects.Clear();
|
||||
assetsFile.reader.Close();
|
||||
}
|
||||
assetsFileList.Clear();
|
||||
|
||||
foreach (var resourceFileReader in resourceFileReaders)
|
||||
{
|
||||
resourceFileReader.Value.Close();
|
||||
}
|
||||
resourceFileReaders.Clear();
|
||||
|
||||
assetsFileIndexCache.Clear();
|
||||
}
|
||||
|
||||
private void ReadAssets()
|
||||
{
|
||||
Logger.Info("Read assets...");
|
||||
|
||||
var progressCount = assetsFileList.Sum(x => x.m_Objects.Count);
|
||||
int i = 0;
|
||||
Progress.Reset();
|
||||
foreach (var assetsFile in assetsFileList)
|
||||
{
|
||||
foreach (var objectInfo in assetsFile.m_Objects)
|
||||
{
|
||||
var objectReader = new ObjectReader(assetsFile.reader, assetsFile, objectInfo);
|
||||
try
|
||||
{
|
||||
Object obj;
|
||||
switch (objectReader.type)
|
||||
{
|
||||
case ClassIDType.Animation:
|
||||
obj = new Animation(objectReader);
|
||||
break;
|
||||
case ClassIDType.AnimationClip:
|
||||
obj = new AnimationClip(objectReader);
|
||||
break;
|
||||
case ClassIDType.Animator:
|
||||
obj = new Animator(objectReader);
|
||||
break;
|
||||
case ClassIDType.AnimatorController:
|
||||
obj = new AnimatorController(objectReader);
|
||||
break;
|
||||
case ClassIDType.AnimatorOverrideController:
|
||||
obj = new AnimatorOverrideController(objectReader);
|
||||
break;
|
||||
case ClassIDType.AssetBundle:
|
||||
obj = new AssetBundle(objectReader);
|
||||
break;
|
||||
case ClassIDType.AudioClip:
|
||||
obj = new AudioClip(objectReader);
|
||||
break;
|
||||
case ClassIDType.Avatar:
|
||||
obj = new Avatar(objectReader);
|
||||
break;
|
||||
case ClassIDType.Font:
|
||||
obj = new Font(objectReader);
|
||||
break;
|
||||
case ClassIDType.GameObject:
|
||||
obj = new GameObject(objectReader);
|
||||
break;
|
||||
case ClassIDType.Material:
|
||||
obj = new Material(objectReader);
|
||||
break;
|
||||
case ClassIDType.Mesh:
|
||||
obj = new Mesh(objectReader);
|
||||
break;
|
||||
case ClassIDType.MeshFilter:
|
||||
obj = new MeshFilter(objectReader);
|
||||
break;
|
||||
case ClassIDType.MeshRenderer:
|
||||
obj = new MeshRenderer(objectReader);
|
||||
break;
|
||||
case ClassIDType.MonoBehaviour:
|
||||
obj = new MonoBehaviour(objectReader);
|
||||
break;
|
||||
case ClassIDType.MonoScript:
|
||||
obj = new MonoScript(objectReader);
|
||||
break;
|
||||
case ClassIDType.MovieTexture:
|
||||
obj = new MovieTexture(objectReader);
|
||||
break;
|
||||
case ClassIDType.PlayerSettings:
|
||||
obj = new PlayerSettings(objectReader);
|
||||
break;
|
||||
case ClassIDType.RectTransform:
|
||||
obj = new RectTransform(objectReader);
|
||||
break;
|
||||
case ClassIDType.Shader:
|
||||
obj = new Shader(objectReader);
|
||||
break;
|
||||
case ClassIDType.SkinnedMeshRenderer:
|
||||
obj = new SkinnedMeshRenderer(objectReader);
|
||||
break;
|
||||
case ClassIDType.Sprite:
|
||||
obj = new Sprite(objectReader);
|
||||
break;
|
||||
case ClassIDType.SpriteAtlas:
|
||||
obj = new SpriteAtlas(objectReader);
|
||||
break;
|
||||
case ClassIDType.TextAsset:
|
||||
obj = new TextAsset(objectReader);
|
||||
break;
|
||||
case ClassIDType.Texture2D:
|
||||
obj = new Texture2D(objectReader);
|
||||
break;
|
||||
case ClassIDType.Transform:
|
||||
obj = new Transform(objectReader);
|
||||
break;
|
||||
case ClassIDType.VideoClip:
|
||||
obj = new VideoClip(objectReader);
|
||||
break;
|
||||
default:
|
||||
obj = new Object(objectReader);
|
||||
break;
|
||||
}
|
||||
assetsFile.AddObject(obj);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
/*var sb = new StringBuilder();
|
||||
sb.AppendLine("Unable to load object")
|
||||
.AppendLine($"Assets {assetsFile.fileName}")
|
||||
.AppendLine($"Type {objectReader.type}")
|
||||
.AppendLine($"PathID {objectInfo.m_PathID}")
|
||||
.Append(e);
|
||||
Logger.Error(sb.ToString());*/
|
||||
}
|
||||
|
||||
Progress.Report(++i, progressCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessAssets()
|
||||
{
|
||||
Logger.Info("Process Assets...");
|
||||
|
||||
foreach (var assetsFile in assetsFileList)
|
||||
{
|
||||
foreach (var obj in assetsFile.Objects)
|
||||
{
|
||||
if (obj is GameObject m_GameObject)
|
||||
{
|
||||
foreach (var pptr in m_GameObject.m_Components)
|
||||
{
|
||||
if (pptr.TryGet(out var m_Component))
|
||||
{
|
||||
switch (m_Component)
|
||||
{
|
||||
case Transform m_Transform:
|
||||
m_GameObject.m_Transform = m_Transform;
|
||||
break;
|
||||
case MeshRenderer m_MeshRenderer:
|
||||
m_GameObject.m_MeshRenderer = m_MeshRenderer;
|
||||
break;
|
||||
case MeshFilter m_MeshFilter:
|
||||
m_GameObject.m_MeshFilter = m_MeshFilter;
|
||||
break;
|
||||
case SkinnedMeshRenderer m_SkinnedMeshRenderer:
|
||||
m_GameObject.m_SkinnedMeshRenderer = m_SkinnedMeshRenderer;
|
||||
break;
|
||||
case Animator m_Animator:
|
||||
m_GameObject.m_Animator = m_Animator;
|
||||
break;
|
||||
case Animation m_Animation:
|
||||
m_GameObject.m_Animation = m_Animation;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (obj is SpriteAtlas m_SpriteAtlas)
|
||||
{
|
||||
foreach (var m_PackedSprite in m_SpriteAtlas.m_PackedSprites)
|
||||
{
|
||||
if (m_PackedSprite.TryGet(out var m_Sprite))
|
||||
{
|
||||
if (m_Sprite.m_SpriteAtlas.IsNull)
|
||||
{
|
||||
m_Sprite.m_SpriteAtlas.Set(m_SpriteAtlas);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
271
AssetStudio/Brotli/BitReader.cs
Normal file
271
AssetStudio/Brotli/BitReader.cs
Normal file
@@ -0,0 +1,271 @@
|
||||
/* Copyright 2015 Google Inc. All Rights Reserved.
|
||||
|
||||
Distributed under MIT license.
|
||||
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
*/
|
||||
namespace Org.Brotli.Dec
|
||||
{
|
||||
/// <summary>Bit reading helpers.</summary>
|
||||
internal sealed class BitReader
|
||||
{
|
||||
/// <summary>
|
||||
/// Input byte buffer, consist of a ring-buffer and a "slack" region where bytes from the start of
|
||||
/// the ring-buffer are copied.
|
||||
/// </summary>
|
||||
private const int Capacity = 1024;
|
||||
|
||||
private const int Slack = 16;
|
||||
|
||||
private const int IntBufferSize = Capacity + Slack;
|
||||
|
||||
private const int ByteReadSize = Capacity << 2;
|
||||
|
||||
private const int ByteBufferSize = IntBufferSize << 2;
|
||||
|
||||
private readonly byte[] byteBuffer = new byte[ByteBufferSize];
|
||||
|
||||
private readonly int[] intBuffer = new int[IntBufferSize];
|
||||
|
||||
private readonly Org.Brotli.Dec.IntReader intReader = new Org.Brotli.Dec.IntReader();
|
||||
|
||||
private System.IO.Stream input;
|
||||
|
||||
/// <summary>Input stream is finished.</summary>
|
||||
private bool endOfStreamReached;
|
||||
|
||||
/// <summary>Pre-fetched bits.</summary>
|
||||
internal long accumulator;
|
||||
|
||||
/// <summary>Current bit-reading position in accumulator.</summary>
|
||||
internal int bitOffset;
|
||||
|
||||
/// <summary>Offset of next item in intBuffer.</summary>
|
||||
private int intOffset;
|
||||
|
||||
private int tailBytes = 0;
|
||||
|
||||
/* Number of bytes in unfinished "int" item. */
|
||||
/// <summary>Fills up the input buffer.</summary>
|
||||
/// <remarks>
|
||||
/// Fills up the input buffer.
|
||||
/// <p> No-op if there are at least 36 bytes present after current position.
|
||||
/// <p> After encountering the end of the input stream, 64 additional zero bytes are copied to the
|
||||
/// buffer.
|
||||
/// </remarks>
|
||||
internal static void ReadMoreInput(Org.Brotli.Dec.BitReader br)
|
||||
{
|
||||
// TODO: Split to check and read; move read outside of decoding loop.
|
||||
if (br.intOffset <= Capacity - 9)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (br.endOfStreamReached)
|
||||
{
|
||||
if (IntAvailable(br) >= -2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("No more input");
|
||||
}
|
||||
int readOffset = br.intOffset << 2;
|
||||
int bytesRead = ByteReadSize - readOffset;
|
||||
System.Array.Copy(br.byteBuffer, readOffset, br.byteBuffer, 0, bytesRead);
|
||||
br.intOffset = 0;
|
||||
try
|
||||
{
|
||||
while (bytesRead < ByteReadSize)
|
||||
{
|
||||
int len = br.input.Read(br.byteBuffer, bytesRead, ByteReadSize - bytesRead);
|
||||
// EOF is -1 in Java, but 0 in C#.
|
||||
if (len <= 0)
|
||||
{
|
||||
br.endOfStreamReached = true;
|
||||
br.tailBytes = bytesRead;
|
||||
bytesRead += 3;
|
||||
break;
|
||||
}
|
||||
bytesRead += len;
|
||||
}
|
||||
}
|
||||
catch (System.IO.IOException e)
|
||||
{
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Failed to read input", e);
|
||||
}
|
||||
Org.Brotli.Dec.IntReader.Convert(br.intReader, bytesRead >> 2);
|
||||
}
|
||||
|
||||
internal static void CheckHealth(Org.Brotli.Dec.BitReader br, bool endOfStream)
|
||||
{
|
||||
if (!br.endOfStreamReached)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int byteOffset = (br.intOffset << 2) + ((br.bitOffset + 7) >> 3) - 8;
|
||||
if (byteOffset > br.tailBytes)
|
||||
{
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Read after end");
|
||||
}
|
||||
if (endOfStream && (byteOffset != br.tailBytes))
|
||||
{
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Unused bytes after end");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Advances the Read buffer by 5 bytes to make room for reading next 24 bits.</summary>
|
||||
internal static void FillBitWindow(Org.Brotli.Dec.BitReader br)
|
||||
{
|
||||
if (br.bitOffset >= 32)
|
||||
{
|
||||
br.accumulator = ((long)br.intBuffer[br.intOffset++] << 32) | ((long)(((ulong)br.accumulator) >> 32));
|
||||
br.bitOffset -= 32;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Reads the specified number of bits from Read Buffer.</summary>
|
||||
internal static int ReadBits(Org.Brotli.Dec.BitReader br, int n)
|
||||
{
|
||||
FillBitWindow(br);
|
||||
int val = (int)((long)(((ulong)br.accumulator) >> br.bitOffset)) & ((1 << n) - 1);
|
||||
br.bitOffset += n;
|
||||
return val;
|
||||
}
|
||||
|
||||
/// <summary>Initialize bit reader.</summary>
|
||||
/// <remarks>
|
||||
/// Initialize bit reader.
|
||||
/// <p> Initialisation turns bit reader to a ready state. Also a number of bytes is prefetched to
|
||||
/// accumulator. Because of that this method may block until enough data could be read from input.
|
||||
/// </remarks>
|
||||
/// <param name="br">BitReader POJO</param>
|
||||
/// <param name="input">data source</param>
|
||||
internal static void Init(Org.Brotli.Dec.BitReader br, System.IO.Stream input)
|
||||
{
|
||||
if (br.input != null)
|
||||
{
|
||||
throw new System.InvalidOperationException("Bit reader already has associated input stream");
|
||||
}
|
||||
Org.Brotli.Dec.IntReader.Init(br.intReader, br.byteBuffer, br.intBuffer);
|
||||
br.input = input;
|
||||
br.accumulator = 0;
|
||||
br.bitOffset = 64;
|
||||
br.intOffset = Capacity;
|
||||
br.endOfStreamReached = false;
|
||||
Prepare(br);
|
||||
}
|
||||
|
||||
private static void Prepare(Org.Brotli.Dec.BitReader br)
|
||||
{
|
||||
ReadMoreInput(br);
|
||||
CheckHealth(br, false);
|
||||
FillBitWindow(br);
|
||||
FillBitWindow(br);
|
||||
}
|
||||
|
||||
internal static void Reload(Org.Brotli.Dec.BitReader br)
|
||||
{
|
||||
if (br.bitOffset == 64)
|
||||
{
|
||||
Prepare(br);
|
||||
}
|
||||
}
|
||||
|
||||
/// <exception cref="System.IO.IOException"/>
|
||||
internal static void Close(Org.Brotli.Dec.BitReader br)
|
||||
{
|
||||
System.IO.Stream @is = br.input;
|
||||
br.input = null;
|
||||
if (@is != null)
|
||||
{
|
||||
@is.Close();
|
||||
}
|
||||
}
|
||||
|
||||
internal static void JumpToByteBoundary(Org.Brotli.Dec.BitReader br)
|
||||
{
|
||||
int padding = (64 - br.bitOffset) & 7;
|
||||
if (padding != 0)
|
||||
{
|
||||
int paddingBits = Org.Brotli.Dec.BitReader.ReadBits(br, padding);
|
||||
if (paddingBits != 0)
|
||||
{
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Corrupted padding bits");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static int IntAvailable(Org.Brotli.Dec.BitReader br)
|
||||
{
|
||||
int limit = Capacity;
|
||||
if (br.endOfStreamReached)
|
||||
{
|
||||
limit = (br.tailBytes + 3) >> 2;
|
||||
}
|
||||
return limit - br.intOffset;
|
||||
}
|
||||
|
||||
internal static void CopyBytes(Org.Brotli.Dec.BitReader br, byte[] data, int offset, int length)
|
||||
{
|
||||
if ((br.bitOffset & 7) != 0)
|
||||
{
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Unaligned copyBytes");
|
||||
}
|
||||
// Drain accumulator.
|
||||
while ((br.bitOffset != 64) && (length != 0))
|
||||
{
|
||||
data[offset++] = unchecked((byte)((long)(((ulong)br.accumulator) >> br.bitOffset)));
|
||||
br.bitOffset += 8;
|
||||
length--;
|
||||
}
|
||||
if (length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Get data from shadow buffer with "sizeof(int)" granularity.
|
||||
int copyInts = System.Math.Min(IntAvailable(br), length >> 2);
|
||||
if (copyInts > 0)
|
||||
{
|
||||
int readOffset = br.intOffset << 2;
|
||||
System.Array.Copy(br.byteBuffer, readOffset, data, offset, copyInts << 2);
|
||||
offset += copyInts << 2;
|
||||
length -= copyInts << 2;
|
||||
br.intOffset += copyInts;
|
||||
}
|
||||
if (length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Read tail bytes.
|
||||
if (IntAvailable(br) > 0)
|
||||
{
|
||||
// length = 1..3
|
||||
FillBitWindow(br);
|
||||
while (length != 0)
|
||||
{
|
||||
data[offset++] = unchecked((byte)((long)(((ulong)br.accumulator) >> br.bitOffset)));
|
||||
br.bitOffset += 8;
|
||||
length--;
|
||||
}
|
||||
CheckHealth(br, false);
|
||||
return;
|
||||
}
|
||||
// Now it is possible to copy bytes directly.
|
||||
try
|
||||
{
|
||||
while (length > 0)
|
||||
{
|
||||
int len = br.input.Read(data, offset, length);
|
||||
if (len == -1)
|
||||
{
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Unexpected end of input");
|
||||
}
|
||||
offset += len;
|
||||
length -= len;
|
||||
}
|
||||
}
|
||||
catch (System.IO.IOException e)
|
||||
{
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Failed to read input", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
223
AssetStudio/Brotli/BrotliInputStream.cs
Normal file
223
AssetStudio/Brotli/BrotliInputStream.cs
Normal file
@@ -0,0 +1,223 @@
|
||||
/* Copyright 2015 Google Inc. All Rights Reserved.
|
||||
|
||||
Distributed under MIT license.
|
||||
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
*/
|
||||
namespace Org.Brotli.Dec
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="System.IO.Stream"/>
|
||||
/// decorator that decompresses brotli data.
|
||||
/// <p> Not thread-safe.
|
||||
/// </summary>
|
||||
public class BrotliInputStream : System.IO.Stream
|
||||
{
|
||||
public const int DefaultInternalBufferSize = 16384;
|
||||
|
||||
/// <summary>Internal buffer used for efficient byte-by-byte reading.</summary>
|
||||
private byte[] buffer;
|
||||
|
||||
/// <summary>Number of decoded but still unused bytes in internal buffer.</summary>
|
||||
private int remainingBufferBytes;
|
||||
|
||||
/// <summary>Next unused byte offset.</summary>
|
||||
private int bufferOffset;
|
||||
|
||||
/// <summary>Decoder state.</summary>
|
||||
private readonly Org.Brotli.Dec.State state = new Org.Brotli.Dec.State();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a
|
||||
/// <see cref="System.IO.Stream"/>
|
||||
/// wrapper that decompresses brotli data.
|
||||
/// <p> For byte-by-byte reading (
|
||||
/// <see cref="ReadByte()"/>
|
||||
/// ) internal buffer with
|
||||
/// <see cref="DefaultInternalBufferSize"/>
|
||||
/// size is allocated and used.
|
||||
/// <p> Will block the thread until first kilobyte of data of source is available.
|
||||
/// </summary>
|
||||
/// <param name="source">underlying data source</param>
|
||||
/// <exception cref="System.IO.IOException">in case of corrupted data or source stream problems</exception>
|
||||
public BrotliInputStream(System.IO.Stream source)
|
||||
: this(source, DefaultInternalBufferSize, null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a
|
||||
/// <see cref="System.IO.Stream"/>
|
||||
/// wrapper that decompresses brotli data.
|
||||
/// <p> For byte-by-byte reading (
|
||||
/// <see cref="ReadByte()"/>
|
||||
/// ) internal buffer of specified size is
|
||||
/// allocated and used.
|
||||
/// <p> Will block the thread until first kilobyte of data of source is available.
|
||||
/// </summary>
|
||||
/// <param name="source">compressed data source</param>
|
||||
/// <param name="byteReadBufferSize">
|
||||
/// size of internal buffer used in case of
|
||||
/// byte-by-byte reading
|
||||
/// </param>
|
||||
/// <exception cref="System.IO.IOException">in case of corrupted data or source stream problems</exception>
|
||||
public BrotliInputStream(System.IO.Stream source, int byteReadBufferSize)
|
||||
: this(source, byteReadBufferSize, null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a
|
||||
/// <see cref="System.IO.Stream"/>
|
||||
/// wrapper that decompresses brotli data.
|
||||
/// <p> For byte-by-byte reading (
|
||||
/// <see cref="ReadByte()"/>
|
||||
/// ) internal buffer of specified size is
|
||||
/// allocated and used.
|
||||
/// <p> Will block the thread until first kilobyte of data of source is available.
|
||||
/// </summary>
|
||||
/// <param name="source">compressed data source</param>
|
||||
/// <param name="byteReadBufferSize">
|
||||
/// size of internal buffer used in case of
|
||||
/// byte-by-byte reading
|
||||
/// </param>
|
||||
/// <param name="customDictionary">
|
||||
/// custom dictionary data;
|
||||
/// <see langword="null"/>
|
||||
/// if not used
|
||||
/// </param>
|
||||
/// <exception cref="System.IO.IOException">in case of corrupted data or source stream problems</exception>
|
||||
public BrotliInputStream(System.IO.Stream source, int byteReadBufferSize, byte[] customDictionary)
|
||||
{
|
||||
if (byteReadBufferSize <= 0)
|
||||
{
|
||||
throw new System.ArgumentException("Bad buffer size:" + byteReadBufferSize);
|
||||
}
|
||||
else if (source == null)
|
||||
{
|
||||
throw new System.ArgumentException("source is null");
|
||||
}
|
||||
this.buffer = new byte[byteReadBufferSize];
|
||||
this.remainingBufferBytes = 0;
|
||||
this.bufferOffset = 0;
|
||||
try
|
||||
{
|
||||
Org.Brotli.Dec.State.SetInput(state, source);
|
||||
}
|
||||
catch (Org.Brotli.Dec.BrotliRuntimeException ex)
|
||||
{
|
||||
throw new System.IO.IOException("Brotli decoder initialization failed", ex);
|
||||
}
|
||||
if (customDictionary != null)
|
||||
{
|
||||
Org.Brotli.Dec.Decode.SetCustomDictionary(state, customDictionary);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary><inheritDoc/></summary>
|
||||
/// <exception cref="System.IO.IOException"/>
|
||||
public override void Close()
|
||||
{
|
||||
Org.Brotli.Dec.State.Close(state);
|
||||
}
|
||||
|
||||
/// <summary><inheritDoc/></summary>
|
||||
/// <exception cref="System.IO.IOException"/>
|
||||
public override int ReadByte()
|
||||
{
|
||||
if (bufferOffset >= remainingBufferBytes)
|
||||
{
|
||||
remainingBufferBytes = Read(buffer, 0, buffer.Length);
|
||||
bufferOffset = 0;
|
||||
if (remainingBufferBytes == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return buffer[bufferOffset++] & unchecked((int)(0xFF));
|
||||
}
|
||||
|
||||
/// <summary><inheritDoc/></summary>
|
||||
/// <exception cref="System.IO.IOException"/>
|
||||
public override int Read(byte[] destBuffer, int destOffset, int destLen)
|
||||
{
|
||||
if (destOffset < 0)
|
||||
{
|
||||
throw new System.ArgumentException("Bad offset: " + destOffset);
|
||||
}
|
||||
else if (destLen < 0)
|
||||
{
|
||||
throw new System.ArgumentException("Bad length: " + destLen);
|
||||
}
|
||||
else if (destOffset + destLen > destBuffer.Length)
|
||||
{
|
||||
throw new System.ArgumentException("Buffer overflow: " + (destOffset + destLen) + " > " + destBuffer.Length);
|
||||
}
|
||||
else if (destLen == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int copyLen = System.Math.Max(remainingBufferBytes - bufferOffset, 0);
|
||||
if (copyLen != 0)
|
||||
{
|
||||
copyLen = System.Math.Min(copyLen, destLen);
|
||||
System.Array.Copy(buffer, bufferOffset, destBuffer, destOffset, copyLen);
|
||||
bufferOffset += copyLen;
|
||||
destOffset += copyLen;
|
||||
destLen -= copyLen;
|
||||
if (destLen == 0)
|
||||
{
|
||||
return copyLen;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
state.output = destBuffer;
|
||||
state.outputOffset = destOffset;
|
||||
state.outputLength = destLen;
|
||||
state.outputUsed = 0;
|
||||
Org.Brotli.Dec.Decode.Decompress(state);
|
||||
if (state.outputUsed == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return state.outputUsed + copyLen;
|
||||
}
|
||||
catch (Org.Brotli.Dec.BrotliRuntimeException ex)
|
||||
{
|
||||
throw new System.IO.IOException("Brotli stream decoding failed", ex);
|
||||
}
|
||||
}
|
||||
// <{[INJECTED CODE]}>
|
||||
public override bool CanRead {
|
||||
get {return true;}
|
||||
}
|
||||
|
||||
public override bool CanSeek {
|
||||
get {return false;}
|
||||
}
|
||||
public override long Length {
|
||||
get {throw new System.NotSupportedException();}
|
||||
}
|
||||
public override long Position {
|
||||
get {throw new System.NotSupportedException();}
|
||||
set {throw new System.NotSupportedException();}
|
||||
}
|
||||
public override long Seek(long offset, System.IO.SeekOrigin origin) {
|
||||
throw new System.NotSupportedException();
|
||||
}
|
||||
public override void SetLength(long value){
|
||||
throw new System.NotSupportedException();
|
||||
}
|
||||
|
||||
public override bool CanWrite{get{return false;}}
|
||||
public override System.IAsyncResult BeginWrite(byte[] buffer, int offset,
|
||||
int count, System.AsyncCallback callback, object state) {
|
||||
throw new System.NotSupportedException();
|
||||
}
|
||||
public override void Write(byte[] buffer, int offset, int count) {
|
||||
throw new System.NotSupportedException();
|
||||
}
|
||||
|
||||
public override void Flush() {}
|
||||
}
|
||||
}
|
||||
22
AssetStudio/Brotli/BrotliRuntimeException.cs
Normal file
22
AssetStudio/Brotli/BrotliRuntimeException.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
/* Copyright 2015 Google Inc. All Rights Reserved.
|
||||
|
||||
Distributed under MIT license.
|
||||
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
*/
|
||||
namespace Org.Brotli.Dec
|
||||
{
|
||||
/// <summary>Unchecked exception used internally.</summary>
|
||||
[System.Serializable]
|
||||
internal class BrotliRuntimeException : System.Exception
|
||||
{
|
||||
internal BrotliRuntimeException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
internal BrotliRuntimeException(string message, System.Exception cause)
|
||||
: base(message, cause)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
57
AssetStudio/Brotli/Context.cs
Normal file
57
AssetStudio/Brotli/Context.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
/* Copyright 2015 Google Inc. All Rights Reserved.
|
||||
|
||||
Distributed under MIT license.
|
||||
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
*/
|
||||
namespace Org.Brotli.Dec
|
||||
{
|
||||
/// <summary>Common context lookup table for all context modes.</summary>
|
||||
internal sealed class Context
|
||||
{
|
||||
internal static readonly int[] Lookup = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 12, 16, 12, 12, 20, 12, 16, 24, 28, 12, 12, 32, 12, 36, 12, 44, 44, 44, 44, 44, 44, 44, 44
|
||||
, 44, 44, 32, 32, 24, 40, 28, 12, 12, 48, 52, 52, 52, 48, 52, 52, 52, 48, 52, 52, 52, 52, 52, 48, 52, 52, 52, 52, 52, 48, 52, 52, 52, 52, 52, 24, 12, 28, 12, 12, 12, 56, 60, 60, 60, 56, 60, 60, 60, 56, 60, 60, 60, 60, 60, 56, 60, 60, 60, 60
|
||||
, 60, 56, 60, 60, 60, 60, 60, 24, 12, 28, 12, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
|
||||
2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1,
|
||||
1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
|
||||
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
|
||||
40, 40, 40, 40, 40, 40, 40, 40, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 56, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38
|
||||
, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
|
||||
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35
|
||||
, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
|
||||
34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9,
|
||||
10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24,
|
||||
25, 25, 25, 25, 26, 26, 26, 26, 27, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 30, 31, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 35, 35, 35, 35, 36, 36, 36, 36, 37, 37, 37, 37, 38, 38, 38, 38, 39, 39, 39, 39,
|
||||
40, 40, 40, 40, 41, 41, 41, 41, 42, 42, 42, 42, 43, 43, 43, 43, 44, 44, 44, 44, 45, 45, 45, 45, 46, 46, 46, 46, 47, 47, 47, 47, 48, 48, 48, 48, 49, 49, 49, 49, 50, 50, 50, 50, 51, 51, 51, 51, 52, 52, 52, 52, 53, 53, 53, 53, 54, 54, 54, 54,
|
||||
55, 55, 55, 55, 56, 56, 56, 56, 57, 57, 57, 57, 58, 58, 58, 58, 59, 59, 59, 59, 60, 60, 60, 60, 61, 61, 61, 61, 62, 62, 62, 62, 63, 63, 63, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
internal static readonly int[] LookupOffsets = new int[] { 1024, 1536, 1280, 1536, 0, 256, 768, 512 };
|
||||
// CONTEXT_UTF8, last byte.
|
||||
// ASCII range.
|
||||
// UTF8 continuation byte range.
|
||||
// UTF8 lead byte range.
|
||||
// CONTEXT_UTF8 second last byte.
|
||||
// ASCII range.
|
||||
// UTF8 continuation byte range.
|
||||
// UTF8 lead byte range.
|
||||
// CONTEXT_SIGNED, second last byte.
|
||||
// CONTEXT_SIGNED, last byte, same as the above values shifted by 3 bits.
|
||||
// CONTEXT_LSB6, last byte.
|
||||
// CONTEXT_MSB6, last byte.
|
||||
// CONTEXT_{M,L}SB6, second last byte,
|
||||
// CONTEXT_LSB6
|
||||
// CONTEXT_MSB6
|
||||
// CONTEXT_UTF8
|
||||
// CONTEXT_SIGNED
|
||||
}
|
||||
}
|
||||
992
AssetStudio/Brotli/Decode.cs
Normal file
992
AssetStudio/Brotli/Decode.cs
Normal file
@@ -0,0 +1,992 @@
|
||||
/* Copyright 2015 Google Inc. All Rights Reserved.
|
||||
|
||||
Distributed under MIT license.
|
||||
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
*/
|
||||
namespace Org.Brotli.Dec
|
||||
{
|
||||
/// <summary>API for Brotli decompression.</summary>
|
||||
internal sealed class Decode
|
||||
{
|
||||
private const int DefaultCodeLength = 8;
|
||||
|
||||
private const int CodeLengthRepeatCode = 16;
|
||||
|
||||
private const int NumLiteralCodes = 256;
|
||||
|
||||
private const int NumInsertAndCopyCodes = 704;
|
||||
|
||||
private const int NumBlockLengthCodes = 26;
|
||||
|
||||
private const int LiteralContextBits = 6;
|
||||
|
||||
private const int DistanceContextBits = 2;
|
||||
|
||||
private const int HuffmanTableBits = 8;
|
||||
|
||||
private const int HuffmanTableMask = unchecked((int)(0xFF));
|
||||
|
||||
private const int CodeLengthCodes = 18;
|
||||
|
||||
private static readonly int[] CodeLengthCodeOrder = new int[] { 1, 2, 3, 4, 0, 5, 17, 6, 16, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
|
||||
|
||||
private const int NumDistanceShortCodes = 16;
|
||||
|
||||
private static readonly int[] DistanceShortCodeIndexOffset = new int[] { 3, 2, 1, 0, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2 };
|
||||
|
||||
private static readonly int[] DistanceShortCodeValueOffset = new int[] { 0, 0, 0, 0, -1, 1, -2, 2, -3, 3, -1, 1, -2, 2, -3, 3 };
|
||||
|
||||
/// <summary>Static Huffman code for the code length code lengths.</summary>
|
||||
private static readonly int[] FixedTable = new int[] { unchecked((int)(0x020000)), unchecked((int)(0x020004)), unchecked((int)(0x020003)), unchecked((int)(0x030002)), unchecked((int)(0x020000)), unchecked((int)(0x020004)), unchecked((int)(0x020003
|
||||
)), unchecked((int)(0x040001)), unchecked((int)(0x020000)), unchecked((int)(0x020004)), unchecked((int)(0x020003)), unchecked((int)(0x030002)), unchecked((int)(0x020000)), unchecked((int)(0x020004)), unchecked((int)(0x020003)), unchecked((int
|
||||
)(0x040005)) };
|
||||
|
||||
/// <summary>Decodes a number in the range [0..255], by reading 1 - 11 bits.</summary>
|
||||
private static int DecodeVarLenUnsignedByte(Org.Brotli.Dec.BitReader br)
|
||||
{
|
||||
if (Org.Brotli.Dec.BitReader.ReadBits(br, 1) != 0)
|
||||
{
|
||||
int n = Org.Brotli.Dec.BitReader.ReadBits(br, 3);
|
||||
if (n == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Org.Brotli.Dec.BitReader.ReadBits(br, n) + (1 << n);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static void DecodeMetaBlockLength(Org.Brotli.Dec.BitReader br, Org.Brotli.Dec.State state)
|
||||
{
|
||||
state.inputEnd = Org.Brotli.Dec.BitReader.ReadBits(br, 1) == 1;
|
||||
state.metaBlockLength = 0;
|
||||
state.isUncompressed = false;
|
||||
state.isMetadata = false;
|
||||
if (state.inputEnd && Org.Brotli.Dec.BitReader.ReadBits(br, 1) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int sizeNibbles = Org.Brotli.Dec.BitReader.ReadBits(br, 2) + 4;
|
||||
if (sizeNibbles == 7)
|
||||
{
|
||||
state.isMetadata = true;
|
||||
if (Org.Brotli.Dec.BitReader.ReadBits(br, 1) != 0)
|
||||
{
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Corrupted reserved bit");
|
||||
}
|
||||
int sizeBytes = Org.Brotli.Dec.BitReader.ReadBits(br, 2);
|
||||
if (sizeBytes == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < sizeBytes; i++)
|
||||
{
|
||||
int bits = Org.Brotli.Dec.BitReader.ReadBits(br, 8);
|
||||
if (bits == 0 && i + 1 == sizeBytes && sizeBytes > 1)
|
||||
{
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Exuberant nibble");
|
||||
}
|
||||
state.metaBlockLength |= bits << (i * 8);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < sizeNibbles; i++)
|
||||
{
|
||||
int bits = Org.Brotli.Dec.BitReader.ReadBits(br, 4);
|
||||
if (bits == 0 && i + 1 == sizeNibbles && sizeNibbles > 4)
|
||||
{
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Exuberant nibble");
|
||||
}
|
||||
state.metaBlockLength |= bits << (i * 4);
|
||||
}
|
||||
}
|
||||
state.metaBlockLength++;
|
||||
if (!state.inputEnd)
|
||||
{
|
||||
state.isUncompressed = Org.Brotli.Dec.BitReader.ReadBits(br, 1) == 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Decodes the next Huffman code from bit-stream.</summary>
|
||||
private static int ReadSymbol(int[] table, int offset, Org.Brotli.Dec.BitReader br)
|
||||
{
|
||||
int val = (int)((long)(((ulong)br.accumulator) >> br.bitOffset));
|
||||
offset += val & HuffmanTableMask;
|
||||
int bits = table[offset] >> 16;
|
||||
int sym = table[offset] & unchecked((int)(0xFFFF));
|
||||
if (bits <= HuffmanTableBits)
|
||||
{
|
||||
br.bitOffset += bits;
|
||||
return sym;
|
||||
}
|
||||
offset += sym;
|
||||
int mask = (1 << bits) - 1;
|
||||
offset += (int)(((uint)(val & mask)) >> HuffmanTableBits);
|
||||
br.bitOffset += ((table[offset] >> 16) + HuffmanTableBits);
|
||||
return table[offset] & unchecked((int)(0xFFFF));
|
||||
}
|
||||
|
||||
private static int ReadBlockLength(int[] table, int offset, Org.Brotli.Dec.BitReader br)
|
||||
{
|
||||
Org.Brotli.Dec.BitReader.FillBitWindow(br);
|
||||
int code = ReadSymbol(table, offset, br);
|
||||
int n = Org.Brotli.Dec.Prefix.BlockLengthNBits[code];
|
||||
return Org.Brotli.Dec.Prefix.BlockLengthOffset[code] + Org.Brotli.Dec.BitReader.ReadBits(br, n);
|
||||
}
|
||||
|
||||
private static int TranslateShortCodes(int code, int[] ringBuffer, int index)
|
||||
{
|
||||
if (code < NumDistanceShortCodes)
|
||||
{
|
||||
index += DistanceShortCodeIndexOffset[code];
|
||||
index &= 3;
|
||||
return ringBuffer[index] + DistanceShortCodeValueOffset[code];
|
||||
}
|
||||
return code - NumDistanceShortCodes + 1;
|
||||
}
|
||||
|
||||
private static void MoveToFront(int[] v, int index)
|
||||
{
|
||||
int value = v[index];
|
||||
for (; index > 0; index--)
|
||||
{
|
||||
v[index] = v[index - 1];
|
||||
}
|
||||
v[0] = value;
|
||||
}
|
||||
|
||||
private static void InverseMoveToFrontTransform(byte[] v, int vLen)
|
||||
{
|
||||
int[] mtf = new int[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
mtf[i] = i;
|
||||
}
|
||||
for (int i = 0; i < vLen; i++)
|
||||
{
|
||||
int index = v[i] & unchecked((int)(0xFF));
|
||||
v[i] = unchecked((byte)mtf[index]);
|
||||
if (index != 0)
|
||||
{
|
||||
MoveToFront(mtf, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ReadHuffmanCodeLengths(int[] codeLengthCodeLengths, int numSymbols, int[] codeLengths, Org.Brotli.Dec.BitReader br)
|
||||
{
|
||||
int symbol = 0;
|
||||
int prevCodeLen = DefaultCodeLength;
|
||||
int repeat = 0;
|
||||
int repeatCodeLen = 0;
|
||||
int space = 32768;
|
||||
int[] table = new int[32];
|
||||
Org.Brotli.Dec.Huffman.BuildHuffmanTable(table, 0, 5, codeLengthCodeLengths, CodeLengthCodes);
|
||||
while (symbol < numSymbols && space > 0)
|
||||
{
|
||||
Org.Brotli.Dec.BitReader.ReadMoreInput(br);
|
||||
Org.Brotli.Dec.BitReader.FillBitWindow(br);
|
||||
int p = (int)(((long)(((ulong)br.accumulator) >> br.bitOffset))) & 31;
|
||||
br.bitOffset += table[p] >> 16;
|
||||
int codeLen = table[p] & unchecked((int)(0xFFFF));
|
||||
if (codeLen < CodeLengthRepeatCode)
|
||||
{
|
||||
repeat = 0;
|
||||
codeLengths[symbol++] = codeLen;
|
||||
if (codeLen != 0)
|
||||
{
|
||||
prevCodeLen = codeLen;
|
||||
space -= 32768 >> codeLen;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int extraBits = codeLen - 14;
|
||||
int newLen = 0;
|
||||
if (codeLen == CodeLengthRepeatCode)
|
||||
{
|
||||
newLen = prevCodeLen;
|
||||
}
|
||||
if (repeatCodeLen != newLen)
|
||||
{
|
||||
repeat = 0;
|
||||
repeatCodeLen = newLen;
|
||||
}
|
||||
int oldRepeat = repeat;
|
||||
if (repeat > 0)
|
||||
{
|
||||
repeat -= 2;
|
||||
repeat <<= extraBits;
|
||||
}
|
||||
repeat += Org.Brotli.Dec.BitReader.ReadBits(br, extraBits) + 3;
|
||||
int repeatDelta = repeat - oldRepeat;
|
||||
if (symbol + repeatDelta > numSymbols)
|
||||
{
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("symbol + repeatDelta > numSymbols");
|
||||
}
|
||||
// COV_NF_LINE
|
||||
for (int i = 0; i < repeatDelta; i++)
|
||||
{
|
||||
codeLengths[symbol++] = repeatCodeLen;
|
||||
}
|
||||
if (repeatCodeLen != 0)
|
||||
{
|
||||
space -= repeatDelta << (15 - repeatCodeLen);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (space != 0)
|
||||
{
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Unused space");
|
||||
}
|
||||
// COV_NF_LINE
|
||||
// TODO: Pass max_symbol to Huffman table builder instead?
|
||||
Org.Brotli.Dec.Utils.FillWithZeroes(codeLengths, symbol, numSymbols - symbol);
|
||||
}
|
||||
|
||||
// TODO: Use specialized versions for smaller tables.
|
||||
internal static void ReadHuffmanCode(int alphabetSize, int[] table, int offset, Org.Brotli.Dec.BitReader br)
|
||||
{
|
||||
bool ok = true;
|
||||
int simpleCodeOrSkip;
|
||||
Org.Brotli.Dec.BitReader.ReadMoreInput(br);
|
||||
// TODO: Avoid allocation.
|
||||
int[] codeLengths = new int[alphabetSize];
|
||||
simpleCodeOrSkip = Org.Brotli.Dec.BitReader.ReadBits(br, 2);
|
||||
if (simpleCodeOrSkip == 1)
|
||||
{
|
||||
// Read symbols, codes & code lengths directly.
|
||||
int maxBitsCounter = alphabetSize - 1;
|
||||
int maxBits = 0;
|
||||
int[] symbols = new int[4];
|
||||
int numSymbols = Org.Brotli.Dec.BitReader.ReadBits(br, 2) + 1;
|
||||
while (maxBitsCounter != 0)
|
||||
{
|
||||
maxBitsCounter >>= 1;
|
||||
maxBits++;
|
||||
}
|
||||
// TODO: uncomment when codeLengths is reused.
|
||||
// Utils.fillWithZeroes(codeLengths, 0, alphabetSize);
|
||||
for (int i = 0; i < numSymbols; i++)
|
||||
{
|
||||
symbols[i] = Org.Brotli.Dec.BitReader.ReadBits(br, maxBits) % alphabetSize;
|
||||
codeLengths[symbols[i]] = 2;
|
||||
}
|
||||
codeLengths[symbols[0]] = 1;
|
||||
switch (numSymbols)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
ok = symbols[0] != symbols[1];
|
||||
codeLengths[symbols[1]] = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case 3:
|
||||
{
|
||||
ok = symbols[0] != symbols[1] && symbols[0] != symbols[2] && symbols[1] != symbols[2];
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
default:
|
||||
{
|
||||
ok = symbols[0] != symbols[1] && symbols[0] != symbols[2] && symbols[0] != symbols[3] && symbols[1] != symbols[2] && symbols[1] != symbols[3] && symbols[2] != symbols[3];
|
||||
if (Org.Brotli.Dec.BitReader.ReadBits(br, 1) == 1)
|
||||
{
|
||||
codeLengths[symbols[2]] = 3;
|
||||
codeLengths[symbols[3]] = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
codeLengths[symbols[0]] = 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Decode Huffman-coded code lengths.
|
||||
int[] codeLengthCodeLengths = new int[CodeLengthCodes];
|
||||
int space = 32;
|
||||
int numCodes = 0;
|
||||
for (int i = simpleCodeOrSkip; i < CodeLengthCodes && space > 0; i++)
|
||||
{
|
||||
int codeLenIdx = CodeLengthCodeOrder[i];
|
||||
Org.Brotli.Dec.BitReader.FillBitWindow(br);
|
||||
int p = (int)((long)(((ulong)br.accumulator) >> br.bitOffset)) & 15;
|
||||
// TODO: Demultiplex FIXED_TABLE.
|
||||
br.bitOffset += FixedTable[p] >> 16;
|
||||
int v = FixedTable[p] & unchecked((int)(0xFFFF));
|
||||
codeLengthCodeLengths[codeLenIdx] = v;
|
||||
if (v != 0)
|
||||
{
|
||||
space -= (32 >> v);
|
||||
numCodes++;
|
||||
}
|
||||
}
|
||||
ok = (numCodes == 1 || space == 0);
|
||||
ReadHuffmanCodeLengths(codeLengthCodeLengths, alphabetSize, codeLengths, br);
|
||||
}
|
||||
if (!ok)
|
||||
{
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Can't readHuffmanCode");
|
||||
}
|
||||
// COV_NF_LINE
|
||||
Org.Brotli.Dec.Huffman.BuildHuffmanTable(table, offset, HuffmanTableBits, codeLengths, alphabetSize);
|
||||
}
|
||||
|
||||
private static int DecodeContextMap(int contextMapSize, byte[] contextMap, Org.Brotli.Dec.BitReader br)
|
||||
{
|
||||
Org.Brotli.Dec.BitReader.ReadMoreInput(br);
|
||||
int numTrees = DecodeVarLenUnsignedByte(br) + 1;
|
||||
if (numTrees == 1)
|
||||
{
|
||||
Org.Brotli.Dec.Utils.FillWithZeroes(contextMap, 0, contextMapSize);
|
||||
return numTrees;
|
||||
}
|
||||
bool useRleForZeros = Org.Brotli.Dec.BitReader.ReadBits(br, 1) == 1;
|
||||
int maxRunLengthPrefix = 0;
|
||||
if (useRleForZeros)
|
||||
{
|
||||
maxRunLengthPrefix = Org.Brotli.Dec.BitReader.ReadBits(br, 4) + 1;
|
||||
}
|
||||
int[] table = new int[Org.Brotli.Dec.Huffman.HuffmanMaxTableSize];
|
||||
ReadHuffmanCode(numTrees + maxRunLengthPrefix, table, 0, br);
|
||||
for (int i = 0; i < contextMapSize; )
|
||||
{
|
||||
Org.Brotli.Dec.BitReader.ReadMoreInput(br);
|
||||
Org.Brotli.Dec.BitReader.FillBitWindow(br);
|
||||
int code = ReadSymbol(table, 0, br);
|
||||
if (code == 0)
|
||||
{
|
||||
contextMap[i] = 0;
|
||||
i++;
|
||||
}
|
||||
else if (code <= maxRunLengthPrefix)
|
||||
{
|
||||
int reps = (1 << code) + Org.Brotli.Dec.BitReader.ReadBits(br, code);
|
||||
while (reps != 0)
|
||||
{
|
||||
if (i >= contextMapSize)
|
||||
{
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Corrupted context map");
|
||||
}
|
||||
// COV_NF_LINE
|
||||
contextMap[i] = 0;
|
||||
i++;
|
||||
reps--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
contextMap[i] = unchecked((byte)(code - maxRunLengthPrefix));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (Org.Brotli.Dec.BitReader.ReadBits(br, 1) == 1)
|
||||
{
|
||||
InverseMoveToFrontTransform(contextMap, contextMapSize);
|
||||
}
|
||||
return numTrees;
|
||||
}
|
||||
|
||||
private static void DecodeBlockTypeAndLength(Org.Brotli.Dec.State state, int treeType)
|
||||
{
|
||||
Org.Brotli.Dec.BitReader br = state.br;
|
||||
int[] ringBuffers = state.blockTypeRb;
|
||||
int offset = treeType * 2;
|
||||
Org.Brotli.Dec.BitReader.FillBitWindow(br);
|
||||
int blockType = ReadSymbol(state.blockTypeTrees, treeType * Org.Brotli.Dec.Huffman.HuffmanMaxTableSize, br);
|
||||
state.blockLength[treeType] = ReadBlockLength(state.blockLenTrees, treeType * Org.Brotli.Dec.Huffman.HuffmanMaxTableSize, br);
|
||||
if (blockType == 1)
|
||||
{
|
||||
blockType = ringBuffers[offset + 1] + 1;
|
||||
}
|
||||
else if (blockType == 0)
|
||||
{
|
||||
blockType = ringBuffers[offset];
|
||||
}
|
||||
else
|
||||
{
|
||||
blockType -= 2;
|
||||
}
|
||||
if (blockType >= state.numBlockTypes[treeType])
|
||||
{
|
||||
blockType -= state.numBlockTypes[treeType];
|
||||
}
|
||||
ringBuffers[offset] = ringBuffers[offset + 1];
|
||||
ringBuffers[offset + 1] = blockType;
|
||||
}
|
||||
|
||||
private static void DecodeLiteralBlockSwitch(Org.Brotli.Dec.State state)
|
||||
{
|
||||
DecodeBlockTypeAndLength(state, 0);
|
||||
int literalBlockType = state.blockTypeRb[1];
|
||||
state.contextMapSlice = literalBlockType << LiteralContextBits;
|
||||
state.literalTreeIndex = state.contextMap[state.contextMapSlice] & unchecked((int)(0xFF));
|
||||
state.literalTree = state.hGroup0.trees[state.literalTreeIndex];
|
||||
int contextMode = state.contextModes[literalBlockType];
|
||||
state.contextLookupOffset1 = Org.Brotli.Dec.Context.LookupOffsets[contextMode];
|
||||
state.contextLookupOffset2 = Org.Brotli.Dec.Context.LookupOffsets[contextMode + 1];
|
||||
}
|
||||
|
||||
private static void DecodeCommandBlockSwitch(Org.Brotli.Dec.State state)
|
||||
{
|
||||
DecodeBlockTypeAndLength(state, 1);
|
||||
state.treeCommandOffset = state.hGroup1.trees[state.blockTypeRb[3]];
|
||||
}
|
||||
|
||||
private static void DecodeDistanceBlockSwitch(Org.Brotli.Dec.State state)
|
||||
{
|
||||
DecodeBlockTypeAndLength(state, 2);
|
||||
state.distContextMapSlice = state.blockTypeRb[5] << DistanceContextBits;
|
||||
}
|
||||
|
||||
private static void MaybeReallocateRingBuffer(Org.Brotli.Dec.State state)
|
||||
{
|
||||
int newSize = state.maxRingBufferSize;
|
||||
if ((long)newSize > state.expectedTotalSize)
|
||||
{
|
||||
/* TODO: Handle 2GB+ cases more gracefully. */
|
||||
int minimalNewSize = (int)state.expectedTotalSize + state.customDictionary.Length;
|
||||
while ((newSize >> 1) > minimalNewSize)
|
||||
{
|
||||
newSize >>= 1;
|
||||
}
|
||||
if (!state.inputEnd && newSize < 16384 && state.maxRingBufferSize >= 16384)
|
||||
{
|
||||
newSize = 16384;
|
||||
}
|
||||
}
|
||||
if (newSize <= state.ringBufferSize)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int ringBufferSizeWithSlack = newSize + Org.Brotli.Dec.Dictionary.MaxTransformedWordLength;
|
||||
byte[] newBuffer = new byte[ringBufferSizeWithSlack];
|
||||
if (state.ringBuffer != null)
|
||||
{
|
||||
System.Array.Copy(state.ringBuffer, 0, newBuffer, 0, state.ringBufferSize);
|
||||
}
|
||||
else if (state.customDictionary.Length != 0)
|
||||
{
|
||||
/* Prepend custom dictionary, if any. */
|
||||
int length = state.customDictionary.Length;
|
||||
int offset = 0;
|
||||
if (length > state.maxBackwardDistance)
|
||||
{
|
||||
offset = length - state.maxBackwardDistance;
|
||||
length = state.maxBackwardDistance;
|
||||
}
|
||||
System.Array.Copy(state.customDictionary, offset, newBuffer, 0, length);
|
||||
state.pos = length;
|
||||
state.bytesToIgnore = length;
|
||||
}
|
||||
state.ringBuffer = newBuffer;
|
||||
state.ringBufferSize = newSize;
|
||||
}
|
||||
|
||||
/// <summary>Reads next metablock header.</summary>
|
||||
/// <param name="state">decoding state</param>
|
||||
private static void ReadMetablockInfo(Org.Brotli.Dec.State state)
|
||||
{
|
||||
Org.Brotli.Dec.BitReader br = state.br;
|
||||
if (state.inputEnd)
|
||||
{
|
||||
state.nextRunningState = Org.Brotli.Dec.RunningState.Finished;
|
||||
state.bytesToWrite = state.pos;
|
||||
state.bytesWritten = 0;
|
||||
state.runningState = Org.Brotli.Dec.RunningState.Write;
|
||||
return;
|
||||
}
|
||||
// TODO: Reset? Do we need this?
|
||||
state.hGroup0.codes = null;
|
||||
state.hGroup0.trees = null;
|
||||
state.hGroup1.codes = null;
|
||||
state.hGroup1.trees = null;
|
||||
state.hGroup2.codes = null;
|
||||
state.hGroup2.trees = null;
|
||||
Org.Brotli.Dec.BitReader.ReadMoreInput(br);
|
||||
DecodeMetaBlockLength(br, state);
|
||||
if (state.metaBlockLength == 0 && !state.isMetadata)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (state.isUncompressed || state.isMetadata)
|
||||
{
|
||||
Org.Brotli.Dec.BitReader.JumpToByteBoundary(br);
|
||||
state.runningState = state.isMetadata ? Org.Brotli.Dec.RunningState.ReadMetadata : Org.Brotli.Dec.RunningState.CopyUncompressed;
|
||||
}
|
||||
else
|
||||
{
|
||||
state.runningState = Org.Brotli.Dec.RunningState.CompressedBlockStart;
|
||||
}
|
||||
if (state.isMetadata)
|
||||
{
|
||||
return;
|
||||
}
|
||||
state.expectedTotalSize += state.metaBlockLength;
|
||||
if (state.ringBufferSize < state.maxRingBufferSize)
|
||||
{
|
||||
MaybeReallocateRingBuffer(state);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ReadMetablockHuffmanCodesAndContextMaps(Org.Brotli.Dec.State state)
|
||||
{
|
||||
Org.Brotli.Dec.BitReader br = state.br;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
state.numBlockTypes[i] = DecodeVarLenUnsignedByte(br) + 1;
|
||||
state.blockLength[i] = 1 << 28;
|
||||
if (state.numBlockTypes[i] > 1)
|
||||
{
|
||||
ReadHuffmanCode(state.numBlockTypes[i] + 2, state.blockTypeTrees, i * Org.Brotli.Dec.Huffman.HuffmanMaxTableSize, br);
|
||||
ReadHuffmanCode(NumBlockLengthCodes, state.blockLenTrees, i * Org.Brotli.Dec.Huffman.HuffmanMaxTableSize, br);
|
||||
state.blockLength[i] = ReadBlockLength(state.blockLenTrees, i * Org.Brotli.Dec.Huffman.HuffmanMaxTableSize, br);
|
||||
}
|
||||
}
|
||||
Org.Brotli.Dec.BitReader.ReadMoreInput(br);
|
||||
state.distancePostfixBits = Org.Brotli.Dec.BitReader.ReadBits(br, 2);
|
||||
state.numDirectDistanceCodes = NumDistanceShortCodes + (Org.Brotli.Dec.BitReader.ReadBits(br, 4) << state.distancePostfixBits);
|
||||
state.distancePostfixMask = (1 << state.distancePostfixBits) - 1;
|
||||
int numDistanceCodes = state.numDirectDistanceCodes + (48 << state.distancePostfixBits);
|
||||
// TODO: Reuse?
|
||||
state.contextModes = new byte[state.numBlockTypes[0]];
|
||||
for (int i = 0; i < state.numBlockTypes[0]; )
|
||||
{
|
||||
/* Ensure that less than 256 bits read between readMoreInput. */
|
||||
int limit = System.Math.Min(i + 96, state.numBlockTypes[0]);
|
||||
for (; i < limit; ++i)
|
||||
{
|
||||
state.contextModes[i] = unchecked((byte)(Org.Brotli.Dec.BitReader.ReadBits(br, 2) << 1));
|
||||
}
|
||||
Org.Brotli.Dec.BitReader.ReadMoreInput(br);
|
||||
}
|
||||
// TODO: Reuse?
|
||||
state.contextMap = new byte[state.numBlockTypes[0] << LiteralContextBits];
|
||||
int numLiteralTrees = DecodeContextMap(state.numBlockTypes[0] << LiteralContextBits, state.contextMap, br);
|
||||
state.trivialLiteralContext = true;
|
||||
for (int j = 0; j < state.numBlockTypes[0] << LiteralContextBits; j++)
|
||||
{
|
||||
if (state.contextMap[j] != j >> LiteralContextBits)
|
||||
{
|
||||
state.trivialLiteralContext = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// TODO: Reuse?
|
||||
state.distContextMap = new byte[state.numBlockTypes[2] << DistanceContextBits];
|
||||
int numDistTrees = DecodeContextMap(state.numBlockTypes[2] << DistanceContextBits, state.distContextMap, br);
|
||||
Org.Brotli.Dec.HuffmanTreeGroup.Init(state.hGroup0, NumLiteralCodes, numLiteralTrees);
|
||||
Org.Brotli.Dec.HuffmanTreeGroup.Init(state.hGroup1, NumInsertAndCopyCodes, state.numBlockTypes[1]);
|
||||
Org.Brotli.Dec.HuffmanTreeGroup.Init(state.hGroup2, numDistanceCodes, numDistTrees);
|
||||
Org.Brotli.Dec.HuffmanTreeGroup.Decode(state.hGroup0, br);
|
||||
Org.Brotli.Dec.HuffmanTreeGroup.Decode(state.hGroup1, br);
|
||||
Org.Brotli.Dec.HuffmanTreeGroup.Decode(state.hGroup2, br);
|
||||
state.contextMapSlice = 0;
|
||||
state.distContextMapSlice = 0;
|
||||
state.contextLookupOffset1 = Org.Brotli.Dec.Context.LookupOffsets[state.contextModes[0]];
|
||||
state.contextLookupOffset2 = Org.Brotli.Dec.Context.LookupOffsets[state.contextModes[0] + 1];
|
||||
state.literalTreeIndex = 0;
|
||||
state.literalTree = state.hGroup0.trees[0];
|
||||
state.treeCommandOffset = state.hGroup1.trees[0];
|
||||
// TODO: == 0?
|
||||
state.blockTypeRb[0] = state.blockTypeRb[2] = state.blockTypeRb[4] = 1;
|
||||
state.blockTypeRb[1] = state.blockTypeRb[3] = state.blockTypeRb[5] = 0;
|
||||
}
|
||||
|
||||
private static void CopyUncompressedData(Org.Brotli.Dec.State state)
|
||||
{
|
||||
Org.Brotli.Dec.BitReader br = state.br;
|
||||
byte[] ringBuffer = state.ringBuffer;
|
||||
// Could happen if block ends at ring buffer end.
|
||||
if (state.metaBlockLength <= 0)
|
||||
{
|
||||
Org.Brotli.Dec.BitReader.Reload(br);
|
||||
state.runningState = Org.Brotli.Dec.RunningState.BlockStart;
|
||||
return;
|
||||
}
|
||||
int chunkLength = System.Math.Min(state.ringBufferSize - state.pos, state.metaBlockLength);
|
||||
Org.Brotli.Dec.BitReader.CopyBytes(br, ringBuffer, state.pos, chunkLength);
|
||||
state.metaBlockLength -= chunkLength;
|
||||
state.pos += chunkLength;
|
||||
if (state.pos == state.ringBufferSize)
|
||||
{
|
||||
state.nextRunningState = Org.Brotli.Dec.RunningState.CopyUncompressed;
|
||||
state.bytesToWrite = state.ringBufferSize;
|
||||
state.bytesWritten = 0;
|
||||
state.runningState = Org.Brotli.Dec.RunningState.Write;
|
||||
return;
|
||||
}
|
||||
Org.Brotli.Dec.BitReader.Reload(br);
|
||||
state.runningState = Org.Brotli.Dec.RunningState.BlockStart;
|
||||
}
|
||||
|
||||
private static bool WriteRingBuffer(Org.Brotli.Dec.State state)
|
||||
{
|
||||
/* Ignore custom dictionary bytes. */
|
||||
if (state.bytesToIgnore != 0)
|
||||
{
|
||||
state.bytesWritten += state.bytesToIgnore;
|
||||
state.bytesToIgnore = 0;
|
||||
}
|
||||
int toWrite = System.Math.Min(state.outputLength - state.outputUsed, state.bytesToWrite - state.bytesWritten);
|
||||
if (toWrite != 0)
|
||||
{
|
||||
System.Array.Copy(state.ringBuffer, state.bytesWritten, state.output, state.outputOffset + state.outputUsed, toWrite);
|
||||
state.outputUsed += toWrite;
|
||||
state.bytesWritten += toWrite;
|
||||
}
|
||||
return state.outputUsed < state.outputLength;
|
||||
}
|
||||
|
||||
internal static void SetCustomDictionary(Org.Brotli.Dec.State state, byte[] data)
|
||||
{
|
||||
state.customDictionary = (data == null) ? new byte[0] : data;
|
||||
}
|
||||
|
||||
/// <summary>Actual decompress implementation.</summary>
|
||||
internal static void Decompress(Org.Brotli.Dec.State state)
|
||||
{
|
||||
if (state.runningState == Org.Brotli.Dec.RunningState.Uninitialized)
|
||||
{
|
||||
throw new System.InvalidOperationException("Can't decompress until initialized");
|
||||
}
|
||||
if (state.runningState == Org.Brotli.Dec.RunningState.Closed)
|
||||
{
|
||||
throw new System.InvalidOperationException("Can't decompress after close");
|
||||
}
|
||||
Org.Brotli.Dec.BitReader br = state.br;
|
||||
int ringBufferMask = state.ringBufferSize - 1;
|
||||
byte[] ringBuffer = state.ringBuffer;
|
||||
while (state.runningState != Org.Brotli.Dec.RunningState.Finished)
|
||||
{
|
||||
switch (state.runningState)
|
||||
{
|
||||
case Org.Brotli.Dec.RunningState.BlockStart:
|
||||
{
|
||||
// TODO: extract cases to methods for the better readability.
|
||||
if (state.metaBlockLength < 0)
|
||||
{
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Invalid metablock length");
|
||||
}
|
||||
ReadMetablockInfo(state);
|
||||
/* Ring-buffer would be reallocated here. */
|
||||
ringBufferMask = state.ringBufferSize - 1;
|
||||
ringBuffer = state.ringBuffer;
|
||||
continue;
|
||||
}
|
||||
|
||||
case Org.Brotli.Dec.RunningState.CompressedBlockStart:
|
||||
{
|
||||
ReadMetablockHuffmanCodesAndContextMaps(state);
|
||||
state.runningState = Org.Brotli.Dec.RunningState.MainLoop;
|
||||
goto case Org.Brotli.Dec.RunningState.MainLoop;
|
||||
}
|
||||
|
||||
case Org.Brotli.Dec.RunningState.MainLoop:
|
||||
{
|
||||
// Fall through
|
||||
if (state.metaBlockLength <= 0)
|
||||
{
|
||||
state.runningState = Org.Brotli.Dec.RunningState.BlockStart;
|
||||
continue;
|
||||
}
|
||||
Org.Brotli.Dec.BitReader.ReadMoreInput(br);
|
||||
if (state.blockLength[1] == 0)
|
||||
{
|
||||
DecodeCommandBlockSwitch(state);
|
||||
}
|
||||
state.blockLength[1]--;
|
||||
Org.Brotli.Dec.BitReader.FillBitWindow(br);
|
||||
int cmdCode = ReadSymbol(state.hGroup1.codes, state.treeCommandOffset, br);
|
||||
int rangeIdx = (int)(((uint)cmdCode) >> 6);
|
||||
state.distanceCode = 0;
|
||||
if (rangeIdx >= 2)
|
||||
{
|
||||
rangeIdx -= 2;
|
||||
state.distanceCode = -1;
|
||||
}
|
||||
int insertCode = Org.Brotli.Dec.Prefix.InsertRangeLut[rangeIdx] + (((int)(((uint)cmdCode) >> 3)) & 7);
|
||||
int copyCode = Org.Brotli.Dec.Prefix.CopyRangeLut[rangeIdx] + (cmdCode & 7);
|
||||
state.insertLength = Org.Brotli.Dec.Prefix.InsertLengthOffset[insertCode] + Org.Brotli.Dec.BitReader.ReadBits(br, Org.Brotli.Dec.Prefix.InsertLengthNBits[insertCode]);
|
||||
state.copyLength = Org.Brotli.Dec.Prefix.CopyLengthOffset[copyCode] + Org.Brotli.Dec.BitReader.ReadBits(br, Org.Brotli.Dec.Prefix.CopyLengthNBits[copyCode]);
|
||||
state.j = 0;
|
||||
state.runningState = Org.Brotli.Dec.RunningState.InsertLoop;
|
||||
goto case Org.Brotli.Dec.RunningState.InsertLoop;
|
||||
}
|
||||
|
||||
case Org.Brotli.Dec.RunningState.InsertLoop:
|
||||
{
|
||||
// Fall through
|
||||
if (state.trivialLiteralContext)
|
||||
{
|
||||
while (state.j < state.insertLength)
|
||||
{
|
||||
Org.Brotli.Dec.BitReader.ReadMoreInput(br);
|
||||
if (state.blockLength[0] == 0)
|
||||
{
|
||||
DecodeLiteralBlockSwitch(state);
|
||||
}
|
||||
state.blockLength[0]--;
|
||||
Org.Brotli.Dec.BitReader.FillBitWindow(br);
|
||||
ringBuffer[state.pos] = unchecked((byte)ReadSymbol(state.hGroup0.codes, state.literalTree, br));
|
||||
state.j++;
|
||||
if (state.pos++ == ringBufferMask)
|
||||
{
|
||||
state.nextRunningState = Org.Brotli.Dec.RunningState.InsertLoop;
|
||||
state.bytesToWrite = state.ringBufferSize;
|
||||
state.bytesWritten = 0;
|
||||
state.runningState = Org.Brotli.Dec.RunningState.Write;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int prevByte1 = ringBuffer[(state.pos - 1) & ringBufferMask] & unchecked((int)(0xFF));
|
||||
int prevByte2 = ringBuffer[(state.pos - 2) & ringBufferMask] & unchecked((int)(0xFF));
|
||||
while (state.j < state.insertLength)
|
||||
{
|
||||
Org.Brotli.Dec.BitReader.ReadMoreInput(br);
|
||||
if (state.blockLength[0] == 0)
|
||||
{
|
||||
DecodeLiteralBlockSwitch(state);
|
||||
}
|
||||
int literalTreeIndex = state.contextMap[state.contextMapSlice + (Org.Brotli.Dec.Context.Lookup[state.contextLookupOffset1 + prevByte1] | Org.Brotli.Dec.Context.Lookup[state.contextLookupOffset2 + prevByte2])] & unchecked((int)(0xFF));
|
||||
state.blockLength[0]--;
|
||||
prevByte2 = prevByte1;
|
||||
Org.Brotli.Dec.BitReader.FillBitWindow(br);
|
||||
prevByte1 = ReadSymbol(state.hGroup0.codes, state.hGroup0.trees[literalTreeIndex], br);
|
||||
ringBuffer[state.pos] = unchecked((byte)prevByte1);
|
||||
state.j++;
|
||||
if (state.pos++ == ringBufferMask)
|
||||
{
|
||||
state.nextRunningState = Org.Brotli.Dec.RunningState.InsertLoop;
|
||||
state.bytesToWrite = state.ringBufferSize;
|
||||
state.bytesWritten = 0;
|
||||
state.runningState = Org.Brotli.Dec.RunningState.Write;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (state.runningState != Org.Brotli.Dec.RunningState.InsertLoop)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
state.metaBlockLength -= state.insertLength;
|
||||
if (state.metaBlockLength <= 0)
|
||||
{
|
||||
state.runningState = Org.Brotli.Dec.RunningState.MainLoop;
|
||||
continue;
|
||||
}
|
||||
if (state.distanceCode < 0)
|
||||
{
|
||||
Org.Brotli.Dec.BitReader.ReadMoreInput(br);
|
||||
if (state.blockLength[2] == 0)
|
||||
{
|
||||
DecodeDistanceBlockSwitch(state);
|
||||
}
|
||||
state.blockLength[2]--;
|
||||
Org.Brotli.Dec.BitReader.FillBitWindow(br);
|
||||
state.distanceCode = ReadSymbol(state.hGroup2.codes, state.hGroup2.trees[state.distContextMap[state.distContextMapSlice + (state.copyLength > 4 ? 3 : state.copyLength - 2)] & unchecked((int)(0xFF))], br);
|
||||
if (state.distanceCode >= state.numDirectDistanceCodes)
|
||||
{
|
||||
state.distanceCode -= state.numDirectDistanceCodes;
|
||||
int postfix = state.distanceCode & state.distancePostfixMask;
|
||||
state.distanceCode = (int)(((uint)state.distanceCode) >> state.distancePostfixBits);
|
||||
int n = ((int)(((uint)state.distanceCode) >> 1)) + 1;
|
||||
int offset = ((2 + (state.distanceCode & 1)) << n) - 4;
|
||||
state.distanceCode = state.numDirectDistanceCodes + postfix + ((offset + Org.Brotli.Dec.BitReader.ReadBits(br, n)) << state.distancePostfixBits);
|
||||
}
|
||||
}
|
||||
// Convert the distance code to the actual distance by possibly looking up past distances
|
||||
// from the ringBuffer.
|
||||
state.distance = TranslateShortCodes(state.distanceCode, state.distRb, state.distRbIdx);
|
||||
if (state.distance < 0)
|
||||
{
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Negative distance");
|
||||
}
|
||||
// COV_NF_LINE
|
||||
if (state.maxDistance != state.maxBackwardDistance && state.pos < state.maxBackwardDistance)
|
||||
{
|
||||
state.maxDistance = state.pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
state.maxDistance = state.maxBackwardDistance;
|
||||
}
|
||||
state.copyDst = state.pos;
|
||||
if (state.distance > state.maxDistance)
|
||||
{
|
||||
state.runningState = Org.Brotli.Dec.RunningState.Transform;
|
||||
continue;
|
||||
}
|
||||
if (state.distanceCode > 0)
|
||||
{
|
||||
state.distRb[state.distRbIdx & 3] = state.distance;
|
||||
state.distRbIdx++;
|
||||
}
|
||||
if (state.copyLength > state.metaBlockLength)
|
||||
{
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Invalid backward reference");
|
||||
}
|
||||
// COV_NF_LINE
|
||||
state.j = 0;
|
||||
state.runningState = Org.Brotli.Dec.RunningState.CopyLoop;
|
||||
goto case Org.Brotli.Dec.RunningState.CopyLoop;
|
||||
}
|
||||
|
||||
case Org.Brotli.Dec.RunningState.CopyLoop:
|
||||
{
|
||||
// fall through
|
||||
int src = (state.pos - state.distance) & ringBufferMask;
|
||||
int dst = state.pos;
|
||||
int copyLength = state.copyLength - state.j;
|
||||
if ((src + copyLength < ringBufferMask) && (dst + copyLength < ringBufferMask))
|
||||
{
|
||||
for (int k = 0; k < copyLength; ++k)
|
||||
{
|
||||
ringBuffer[dst++] = ringBuffer[src++];
|
||||
}
|
||||
state.j += copyLength;
|
||||
state.metaBlockLength -= copyLength;
|
||||
state.pos += copyLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (; state.j < state.copyLength; )
|
||||
{
|
||||
ringBuffer[state.pos] = ringBuffer[(state.pos - state.distance) & ringBufferMask];
|
||||
state.metaBlockLength--;
|
||||
state.j++;
|
||||
if (state.pos++ == ringBufferMask)
|
||||
{
|
||||
state.nextRunningState = Org.Brotli.Dec.RunningState.CopyLoop;
|
||||
state.bytesToWrite = state.ringBufferSize;
|
||||
state.bytesWritten = 0;
|
||||
state.runningState = Org.Brotli.Dec.RunningState.Write;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (state.runningState == Org.Brotli.Dec.RunningState.CopyLoop)
|
||||
{
|
||||
state.runningState = Org.Brotli.Dec.RunningState.MainLoop;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
case Org.Brotli.Dec.RunningState.Transform:
|
||||
{
|
||||
if (state.copyLength >= Org.Brotli.Dec.Dictionary.MinWordLength && state.copyLength <= Org.Brotli.Dec.Dictionary.MaxWordLength)
|
||||
{
|
||||
int offset = Org.Brotli.Dec.Dictionary.OffsetsByLength[state.copyLength];
|
||||
int wordId = state.distance - state.maxDistance - 1;
|
||||
int shift = Org.Brotli.Dec.Dictionary.SizeBitsByLength[state.copyLength];
|
||||
int mask = (1 << shift) - 1;
|
||||
int wordIdx = wordId & mask;
|
||||
int transformIdx = (int)(((uint)wordId) >> shift);
|
||||
offset += wordIdx * state.copyLength;
|
||||
if (transformIdx < Org.Brotli.Dec.Transform.Transforms.Length)
|
||||
{
|
||||
int len = Org.Brotli.Dec.Transform.TransformDictionaryWord(ringBuffer, state.copyDst, Org.Brotli.Dec.Dictionary.GetData(), offset, state.copyLength, Org.Brotli.Dec.Transform.Transforms[transformIdx]);
|
||||
state.copyDst += len;
|
||||
state.pos += len;
|
||||
state.metaBlockLength -= len;
|
||||
if (state.copyDst >= state.ringBufferSize)
|
||||
{
|
||||
state.nextRunningState = Org.Brotli.Dec.RunningState.CopyWrapBuffer;
|
||||
state.bytesToWrite = state.ringBufferSize;
|
||||
state.bytesWritten = 0;
|
||||
state.runningState = Org.Brotli.Dec.RunningState.Write;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Invalid backward reference");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// COV_NF_LINE
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Invalid backward reference");
|
||||
}
|
||||
// COV_NF_LINE
|
||||
state.runningState = Org.Brotli.Dec.RunningState.MainLoop;
|
||||
continue;
|
||||
}
|
||||
|
||||
case Org.Brotli.Dec.RunningState.CopyWrapBuffer:
|
||||
{
|
||||
System.Array.Copy(ringBuffer, state.ringBufferSize, ringBuffer, 0, state.copyDst - state.ringBufferSize);
|
||||
state.runningState = Org.Brotli.Dec.RunningState.MainLoop;
|
||||
continue;
|
||||
}
|
||||
|
||||
case Org.Brotli.Dec.RunningState.ReadMetadata:
|
||||
{
|
||||
while (state.metaBlockLength > 0)
|
||||
{
|
||||
Org.Brotli.Dec.BitReader.ReadMoreInput(br);
|
||||
// Optimize
|
||||
Org.Brotli.Dec.BitReader.ReadBits(br, 8);
|
||||
state.metaBlockLength--;
|
||||
}
|
||||
state.runningState = Org.Brotli.Dec.RunningState.BlockStart;
|
||||
continue;
|
||||
}
|
||||
|
||||
case Org.Brotli.Dec.RunningState.CopyUncompressed:
|
||||
{
|
||||
CopyUncompressedData(state);
|
||||
continue;
|
||||
}
|
||||
|
||||
case Org.Brotli.Dec.RunningState.Write:
|
||||
{
|
||||
if (!WriteRingBuffer(state))
|
||||
{
|
||||
// Output buffer is full.
|
||||
return;
|
||||
}
|
||||
if (state.pos >= state.maxBackwardDistance)
|
||||
{
|
||||
state.maxDistance = state.maxBackwardDistance;
|
||||
}
|
||||
state.pos &= ringBufferMask;
|
||||
state.runningState = state.nextRunningState;
|
||||
continue;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Unexpected state " + state.runningState);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (state.runningState == Org.Brotli.Dec.RunningState.Finished)
|
||||
{
|
||||
if (state.metaBlockLength < 0)
|
||||
{
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Invalid metablock length");
|
||||
}
|
||||
Org.Brotli.Dec.BitReader.JumpToByteBoundary(br);
|
||||
Org.Brotli.Dec.BitReader.CheckHealth(state.br, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
97
AssetStudio/Brotli/Dictionary.cs
Normal file
97
AssetStudio/Brotli/Dictionary.cs
Normal file
File diff suppressed because one or more lines are too long
149
AssetStudio/Brotli/Huffman.cs
Normal file
149
AssetStudio/Brotli/Huffman.cs
Normal file
@@ -0,0 +1,149 @@
|
||||
/* Copyright 2015 Google Inc. All Rights Reserved.
|
||||
|
||||
Distributed under MIT license.
|
||||
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
*/
|
||||
namespace Org.Brotli.Dec
|
||||
{
|
||||
/// <summary>Utilities for building Huffman decoding tables.</summary>
|
||||
internal sealed class Huffman
|
||||
{
|
||||
/// <summary>
|
||||
/// Maximum possible Huffman table size for an alphabet size of 704, max code length 15 and root
|
||||
/// table bits 8.
|
||||
/// </summary>
|
||||
internal const int HuffmanMaxTableSize = 1080;
|
||||
|
||||
private const int MaxLength = 15;
|
||||
|
||||
/// <summary>Returns reverse(reverse(key, len) + 1, len).</summary>
|
||||
/// <remarks>
|
||||
/// Returns reverse(reverse(key, len) + 1, len).
|
||||
/// <p> reverse(key, len) is the bit-wise reversal of the len least significant bits of key.
|
||||
/// </remarks>
|
||||
private static int GetNextKey(int key, int len)
|
||||
{
|
||||
int step = 1 << (len - 1);
|
||||
while ((key & step) != 0)
|
||||
{
|
||||
step >>= 1;
|
||||
}
|
||||
return (key & (step - 1)) + step;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores
|
||||
/// <paramref name="item"/>
|
||||
/// in
|
||||
/// <c>table[0], table[step], table[2 * step] .., table[end]</c>
|
||||
/// .
|
||||
/// <p> Assumes that end is an integer multiple of step.
|
||||
/// </summary>
|
||||
private static void ReplicateValue(int[] table, int offset, int step, int end, int item)
|
||||
{
|
||||
do
|
||||
{
|
||||
end -= step;
|
||||
table[offset + end] = item;
|
||||
}
|
||||
while (end > 0);
|
||||
}
|
||||
|
||||
/// <param name="count">histogram of bit lengths for the remaining symbols,</param>
|
||||
/// <param name="len">code length of the next processed symbol.</param>
|
||||
/// <returns>table width of the next 2nd level table.</returns>
|
||||
private static int NextTableBitSize(int[] count, int len, int rootBits)
|
||||
{
|
||||
int left = 1 << (len - rootBits);
|
||||
while (len < MaxLength)
|
||||
{
|
||||
left -= count[len];
|
||||
if (left <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
len++;
|
||||
left <<= 1;
|
||||
}
|
||||
return len - rootBits;
|
||||
}
|
||||
|
||||
/// <summary>Builds Huffman lookup table assuming code lengths are in symbol order.</summary>
|
||||
internal static void BuildHuffmanTable(int[] rootTable, int tableOffset, int rootBits, int[] codeLengths, int codeLengthsSize)
|
||||
{
|
||||
int key;
|
||||
// Reversed prefix code.
|
||||
int[] sorted = new int[codeLengthsSize];
|
||||
// Symbols sorted by code length.
|
||||
// TODO: fill with zeroes?
|
||||
int[] count = new int[MaxLength + 1];
|
||||
// Number of codes of each length.
|
||||
int[] offset = new int[MaxLength + 1];
|
||||
// Offsets in sorted table for each length.
|
||||
int symbol;
|
||||
// Build histogram of code lengths.
|
||||
for (symbol = 0; symbol < codeLengthsSize; symbol++)
|
||||
{
|
||||
count[codeLengths[symbol]]++;
|
||||
}
|
||||
// Generate offsets into sorted symbol table by code length.
|
||||
offset[1] = 0;
|
||||
for (int len = 1; len < MaxLength; len++)
|
||||
{
|
||||
offset[len + 1] = offset[len] + count[len];
|
||||
}
|
||||
// Sort symbols by length, by symbol order within each length.
|
||||
for (symbol = 0; symbol < codeLengthsSize; symbol++)
|
||||
{
|
||||
if (codeLengths[symbol] != 0)
|
||||
{
|
||||
sorted[offset[codeLengths[symbol]]++] = symbol;
|
||||
}
|
||||
}
|
||||
int tableBits = rootBits;
|
||||
int tableSize = 1 << tableBits;
|
||||
int totalSize = tableSize;
|
||||
// Special case code with only one value.
|
||||
if (offset[MaxLength] == 1)
|
||||
{
|
||||
for (key = 0; key < totalSize; key++)
|
||||
{
|
||||
rootTable[tableOffset + key] = sorted[0];
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Fill in root table.
|
||||
key = 0;
|
||||
symbol = 0;
|
||||
for (int len = 1, step = 2; len <= rootBits; len++, step <<= 1)
|
||||
{
|
||||
for (; count[len] > 0; count[len]--)
|
||||
{
|
||||
ReplicateValue(rootTable, tableOffset + key, step, tableSize, len << 16 | sorted[symbol++]);
|
||||
key = GetNextKey(key, len);
|
||||
}
|
||||
}
|
||||
// Fill in 2nd level tables and add pointers to root table.
|
||||
int mask = totalSize - 1;
|
||||
int low = -1;
|
||||
int currentOffset = tableOffset;
|
||||
for (int len = rootBits + 1, step = 2; len <= MaxLength; len++, step <<= 1)
|
||||
{
|
||||
for (; count[len] > 0; count[len]--)
|
||||
{
|
||||
if ((key & mask) != low)
|
||||
{
|
||||
currentOffset += tableSize;
|
||||
tableBits = NextTableBitSize(count, len, rootBits);
|
||||
tableSize = 1 << tableBits;
|
||||
totalSize += tableSize;
|
||||
low = key & mask;
|
||||
rootTable[tableOffset + low] = (tableBits + rootBits) << 16 | (currentOffset - tableOffset - low);
|
||||
}
|
||||
ReplicateValue(rootTable, currentOffset + (key >> rootBits), step, tableSize, (len - rootBits) << 16 | sorted[symbol++]);
|
||||
key = GetNextKey(key, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
50
AssetStudio/Brotli/HuffmanTreeGroup.cs
Normal file
50
AssetStudio/Brotli/HuffmanTreeGroup.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
/* Copyright 2015 Google Inc. All Rights Reserved.
|
||||
|
||||
Distributed under MIT license.
|
||||
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
*/
|
||||
namespace Org.Brotli.Dec
|
||||
{
|
||||
/// <summary>Contains a collection of huffman trees with the same alphabet size.</summary>
|
||||
internal sealed class HuffmanTreeGroup
|
||||
{
|
||||
/// <summary>The maximal alphabet size in this group.</summary>
|
||||
private int alphabetSize;
|
||||
|
||||
/// <summary>Storage for Huffman lookup tables.</summary>
|
||||
internal int[] codes;
|
||||
|
||||
/// <summary>
|
||||
/// Offsets of distinct lookup tables in
|
||||
/// <see cref="codes"/>
|
||||
/// storage.
|
||||
/// </summary>
|
||||
internal int[] trees;
|
||||
|
||||
/// <summary>Initializes the Huffman tree group.</summary>
|
||||
/// <param name="group">POJO to be initialised</param>
|
||||
/// <param name="alphabetSize">the maximal alphabet size in this group</param>
|
||||
/// <param name="n">number of Huffman codes</param>
|
||||
internal static void Init(Org.Brotli.Dec.HuffmanTreeGroup group, int alphabetSize, int n)
|
||||
{
|
||||
group.alphabetSize = alphabetSize;
|
||||
group.codes = new int[n * Org.Brotli.Dec.Huffman.HuffmanMaxTableSize];
|
||||
group.trees = new int[n];
|
||||
}
|
||||
|
||||
/// <summary>Decodes Huffman trees from input stream and constructs lookup tables.</summary>
|
||||
/// <param name="group">target POJO</param>
|
||||
/// <param name="br">data source</param>
|
||||
internal static void Decode(Org.Brotli.Dec.HuffmanTreeGroup group, Org.Brotli.Dec.BitReader br)
|
||||
{
|
||||
int next = 0;
|
||||
int n = group.trees.Length;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
group.trees[i] = next;
|
||||
Org.Brotli.Dec.Decode.ReadHuffmanCode(group.alphabetSize, group.codes, next, br);
|
||||
next += Org.Brotli.Dec.Huffman.HuffmanMaxTableSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
AssetStudio/Brotli/IntReader.cs
Normal file
36
AssetStudio/Brotli/IntReader.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
/* Copyright 2017 Google Inc. All Rights Reserved.
|
||||
|
||||
Distributed under MIT license.
|
||||
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
*/
|
||||
namespace Org.Brotli.Dec
|
||||
{
|
||||
/// <summary>Byte-to-int conversion magic.</summary>
|
||||
internal sealed class IntReader
|
||||
{
|
||||
private byte[] byteBuffer;
|
||||
|
||||
private int[] intBuffer;
|
||||
|
||||
internal static void Init(Org.Brotli.Dec.IntReader ir, byte[] byteBuffer, int[] intBuffer)
|
||||
{
|
||||
ir.byteBuffer = byteBuffer;
|
||||
ir.intBuffer = intBuffer;
|
||||
}
|
||||
|
||||
/// <summary>Translates bytes to ints.</summary>
|
||||
/// <remarks>
|
||||
/// Translates bytes to ints.
|
||||
/// NB: intLen == 4 * byteSize!
|
||||
/// NB: intLen should be less or equal to intBuffer length.
|
||||
/// </remarks>
|
||||
internal static void Convert(Org.Brotli.Dec.IntReader ir, int intLen)
|
||||
{
|
||||
for (int i = 0; i < intLen; ++i)
|
||||
{
|
||||
ir.intBuffer[i] = ((ir.byteBuffer[i * 4] & unchecked((int)(0xFF)))) | ((ir.byteBuffer[(i * 4) + 1] & unchecked((int)(0xFF))) << 8) | ((ir.byteBuffer[(i * 4) + 2] & unchecked((int)(0xFF))) << 16) | ((ir.byteBuffer[(i * 4) + 3] & unchecked((int
|
||||
)(0xFF))) << 24);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
AssetStudio/Brotli/Prefix.cs
Normal file
33
AssetStudio/Brotli/Prefix.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Copyright 2015 Google Inc. All Rights Reserved.
|
||||
|
||||
Distributed under MIT license.
|
||||
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
*/
|
||||
namespace Org.Brotli.Dec
|
||||
{
|
||||
/// <summary>Lookup tables to map prefix codes to value ranges.</summary>
|
||||
/// <remarks>
|
||||
/// Lookup tables to map prefix codes to value ranges.
|
||||
/// <p> This is used during decoding of the block lengths, literal insertion lengths and copy
|
||||
/// lengths.
|
||||
/// <p> Range represents values: [offset, offset + 2 ^ n_bits)
|
||||
/// </remarks>
|
||||
internal sealed class Prefix
|
||||
{
|
||||
internal static readonly int[] BlockLengthOffset = new int[] { 1, 5, 9, 13, 17, 25, 33, 41, 49, 65, 81, 97, 113, 145, 177, 209, 241, 305, 369, 497, 753, 1265, 2289, 4337, 8433, 16625 };
|
||||
|
||||
internal static readonly int[] BlockLengthNBits = new int[] { 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 24 };
|
||||
|
||||
internal static readonly int[] InsertLengthOffset = new int[] { 0, 1, 2, 3, 4, 5, 6, 8, 10, 14, 18, 26, 34, 50, 66, 98, 130, 194, 322, 578, 1090, 2114, 6210, 22594 };
|
||||
|
||||
internal static readonly int[] InsertLengthNBits = new int[] { 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 12, 14, 24 };
|
||||
|
||||
internal static readonly int[] CopyLengthOffset = new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 18, 22, 30, 38, 54, 70, 102, 134, 198, 326, 582, 1094, 2118 };
|
||||
|
||||
internal static readonly int[] CopyLengthNBits = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 24 };
|
||||
|
||||
internal static readonly int[] InsertRangeLut = new int[] { 0, 0, 8, 8, 0, 16, 8, 16, 16 };
|
||||
|
||||
internal static readonly int[] CopyRangeLut = new int[] { 0, 8, 0, 8, 16, 0, 16, 8, 16 };
|
||||
}
|
||||
}
|
||||
37
AssetStudio/Brotli/RunningState.cs
Normal file
37
AssetStudio/Brotli/RunningState.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
/* Copyright 2015 Google Inc. All Rights Reserved.
|
||||
|
||||
Distributed under MIT license.
|
||||
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
*/
|
||||
namespace Org.Brotli.Dec
|
||||
{
|
||||
/// <summary>Enumeration of decoding state-machine.</summary>
|
||||
internal sealed class RunningState
|
||||
{
|
||||
internal const int Uninitialized = 0;
|
||||
|
||||
internal const int BlockStart = 1;
|
||||
|
||||
internal const int CompressedBlockStart = 2;
|
||||
|
||||
internal const int MainLoop = 3;
|
||||
|
||||
internal const int ReadMetadata = 4;
|
||||
|
||||
internal const int CopyUncompressed = 5;
|
||||
|
||||
internal const int InsertLoop = 6;
|
||||
|
||||
internal const int CopyLoop = 7;
|
||||
|
||||
internal const int CopyWrapBuffer = 8;
|
||||
|
||||
internal const int Transform = 9;
|
||||
|
||||
internal const int Finished = 10;
|
||||
|
||||
internal const int Closed = 11;
|
||||
|
||||
internal const int Write = 12;
|
||||
}
|
||||
}
|
||||
171
AssetStudio/Brotli/State.cs
Normal file
171
AssetStudio/Brotli/State.cs
Normal file
@@ -0,0 +1,171 @@
|
||||
/* Copyright 2015 Google Inc. All Rights Reserved.
|
||||
|
||||
Distributed under MIT license.
|
||||
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
*/
|
||||
namespace Org.Brotli.Dec
|
||||
{
|
||||
internal sealed class State
|
||||
{
|
||||
internal int runningState = Org.Brotli.Dec.RunningState.Uninitialized;
|
||||
|
||||
internal int nextRunningState;
|
||||
|
||||
internal readonly Org.Brotli.Dec.BitReader br = new Org.Brotli.Dec.BitReader();
|
||||
|
||||
internal byte[] ringBuffer;
|
||||
|
||||
internal readonly int[] blockTypeTrees = new int[3 * Org.Brotli.Dec.Huffman.HuffmanMaxTableSize];
|
||||
|
||||
internal readonly int[] blockLenTrees = new int[3 * Org.Brotli.Dec.Huffman.HuffmanMaxTableSize];
|
||||
|
||||
internal int metaBlockLength;
|
||||
|
||||
internal bool inputEnd;
|
||||
|
||||
internal bool isUncompressed;
|
||||
|
||||
internal bool isMetadata;
|
||||
|
||||
internal readonly Org.Brotli.Dec.HuffmanTreeGroup hGroup0 = new Org.Brotli.Dec.HuffmanTreeGroup();
|
||||
|
||||
internal readonly Org.Brotli.Dec.HuffmanTreeGroup hGroup1 = new Org.Brotli.Dec.HuffmanTreeGroup();
|
||||
|
||||
internal readonly Org.Brotli.Dec.HuffmanTreeGroup hGroup2 = new Org.Brotli.Dec.HuffmanTreeGroup();
|
||||
|
||||
internal readonly int[] blockLength = new int[3];
|
||||
|
||||
internal readonly int[] numBlockTypes = new int[3];
|
||||
|
||||
internal readonly int[] blockTypeRb = new int[6];
|
||||
|
||||
internal readonly int[] distRb = new int[] { 16, 15, 11, 4 };
|
||||
|
||||
internal int pos = 0;
|
||||
|
||||
internal int maxDistance = 0;
|
||||
|
||||
internal int distRbIdx = 0;
|
||||
|
||||
internal bool trivialLiteralContext = false;
|
||||
|
||||
internal int literalTreeIndex = 0;
|
||||
|
||||
internal int literalTree;
|
||||
|
||||
internal int j;
|
||||
|
||||
internal int insertLength;
|
||||
|
||||
internal byte[] contextModes;
|
||||
|
||||
internal byte[] contextMap;
|
||||
|
||||
internal int contextMapSlice;
|
||||
|
||||
internal int distContextMapSlice;
|
||||
|
||||
internal int contextLookupOffset1;
|
||||
|
||||
internal int contextLookupOffset2;
|
||||
|
||||
internal int treeCommandOffset;
|
||||
|
||||
internal int distanceCode;
|
||||
|
||||
internal byte[] distContextMap;
|
||||
|
||||
internal int numDirectDistanceCodes;
|
||||
|
||||
internal int distancePostfixMask;
|
||||
|
||||
internal int distancePostfixBits;
|
||||
|
||||
internal int distance;
|
||||
|
||||
internal int copyLength;
|
||||
|
||||
internal int copyDst;
|
||||
|
||||
internal int maxBackwardDistance;
|
||||
|
||||
internal int maxRingBufferSize;
|
||||
|
||||
internal int ringBufferSize = 0;
|
||||
|
||||
internal long expectedTotalSize = 0;
|
||||
|
||||
internal byte[] customDictionary = new byte[0];
|
||||
|
||||
internal int bytesToIgnore = 0;
|
||||
|
||||
internal int outputOffset;
|
||||
|
||||
internal int outputLength;
|
||||
|
||||
internal int outputUsed;
|
||||
|
||||
internal int bytesWritten;
|
||||
|
||||
internal int bytesToWrite;
|
||||
|
||||
internal byte[] output;
|
||||
|
||||
// Current meta-block header information.
|
||||
// TODO: Update to current spec.
|
||||
private static int DecodeWindowBits(Org.Brotli.Dec.BitReader br)
|
||||
{
|
||||
if (Org.Brotli.Dec.BitReader.ReadBits(br, 1) == 0)
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
int n = Org.Brotli.Dec.BitReader.ReadBits(br, 3);
|
||||
if (n != 0)
|
||||
{
|
||||
return 17 + n;
|
||||
}
|
||||
n = Org.Brotli.Dec.BitReader.ReadBits(br, 3);
|
||||
if (n != 0)
|
||||
{
|
||||
return 8 + n;
|
||||
}
|
||||
return 17;
|
||||
}
|
||||
|
||||
/// <summary>Associate input with decoder state.</summary>
|
||||
/// <param name="state">uninitialized state without associated input</param>
|
||||
/// <param name="input">compressed data source</param>
|
||||
internal static void SetInput(Org.Brotli.Dec.State state, System.IO.Stream input)
|
||||
{
|
||||
if (state.runningState != Org.Brotli.Dec.RunningState.Uninitialized)
|
||||
{
|
||||
throw new System.InvalidOperationException("State MUST be uninitialized");
|
||||
}
|
||||
Org.Brotli.Dec.BitReader.Init(state.br, input);
|
||||
int windowBits = DecodeWindowBits(state.br);
|
||||
if (windowBits == 9)
|
||||
{
|
||||
/* Reserved case for future expansion. */
|
||||
throw new Org.Brotli.Dec.BrotliRuntimeException("Invalid 'windowBits' code");
|
||||
}
|
||||
state.maxRingBufferSize = 1 << windowBits;
|
||||
state.maxBackwardDistance = state.maxRingBufferSize - 16;
|
||||
state.runningState = Org.Brotli.Dec.RunningState.BlockStart;
|
||||
}
|
||||
|
||||
/// <exception cref="System.IO.IOException"/>
|
||||
internal static void Close(Org.Brotli.Dec.State state)
|
||||
{
|
||||
if (state.runningState == Org.Brotli.Dec.RunningState.Uninitialized)
|
||||
{
|
||||
throw new System.InvalidOperationException("State MUST be initialized");
|
||||
}
|
||||
if (state.runningState == Org.Brotli.Dec.RunningState.Closed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
state.runningState = Org.Brotli.Dec.RunningState.Closed;
|
||||
Org.Brotli.Dec.BitReader.Close(state.br);
|
||||
}
|
||||
}
|
||||
}
|
||||
154
AssetStudio/Brotli/Transform.cs
Normal file
154
AssetStudio/Brotli/Transform.cs
Normal file
@@ -0,0 +1,154 @@
|
||||
/* Copyright 2015 Google Inc. All Rights Reserved.
|
||||
|
||||
Distributed under MIT license.
|
||||
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
*/
|
||||
namespace Org.Brotli.Dec
|
||||
{
|
||||
/// <summary>Transformations on dictionary words.</summary>
|
||||
internal sealed class Transform
|
||||
{
|
||||
private readonly byte[] prefix;
|
||||
|
||||
private readonly int type;
|
||||
|
||||
private readonly byte[] suffix;
|
||||
|
||||
internal Transform(string prefix, int type, string suffix)
|
||||
{
|
||||
this.prefix = ReadUniBytes(prefix);
|
||||
this.type = type;
|
||||
this.suffix = ReadUniBytes(suffix);
|
||||
}
|
||||
|
||||
internal static byte[] ReadUniBytes(string uniBytes)
|
||||
{
|
||||
byte[] result = new byte[uniBytes.Length];
|
||||
for (int i = 0; i < result.Length; ++i)
|
||||
{
|
||||
result[i] = unchecked((byte)uniBytes[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static readonly Org.Brotli.Dec.Transform[] Transforms = new Org.Brotli.Dec.Transform[] { new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, string.Empty), new Org.Brotli.Dec.Transform(string.Empty,
|
||||
Org.Brotli.Dec.WordTransformType.Identity, " "), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType.Identity, " "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.OmitFirst1, string.Empty), new Org.Brotli.Dec.Transform
|
||||
(string.Empty, Org.Brotli.Dec.WordTransformType.UppercaseFirst, " "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, " the "), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType.Identity
|
||||
, string.Empty), new Org.Brotli.Dec.Transform("s ", Org.Brotli.Dec.WordTransformType.Identity, " "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, " of "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType
|
||||
.UppercaseFirst, string.Empty), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, " and "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.OmitFirst2, string.Empty), new Org.Brotli.Dec.Transform
|
||||
(string.Empty, Org.Brotli.Dec.WordTransformType.OmitLast1, string.Empty), new Org.Brotli.Dec.Transform(", ", Org.Brotli.Dec.WordTransformType.Identity, " "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity
|
||||
, ", "), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType.UppercaseFirst, " "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, " in "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType
|
||||
.Identity, " to "), new Org.Brotli.Dec.Transform("e ", Org.Brotli.Dec.WordTransformType.Identity, " "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, "\""), new Org.Brotli.Dec.Transform(string.Empty,
|
||||
Org.Brotli.Dec.WordTransformType.Identity, "."), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, "\">"), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, "\n"), new
|
||||
Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.OmitLast3, string.Empty), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, "]"), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType
|
||||
.Identity, " for "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.OmitFirst3, string.Empty), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.OmitLast2, string.Empty), new Org.Brotli.Dec.Transform
|
||||
(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, " a "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, " that "), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType.UppercaseFirst
|
||||
, string.Empty), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, ". "), new Org.Brotli.Dec.Transform(".", Org.Brotli.Dec.WordTransformType.Identity, string.Empty), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType
|
||||
.Identity, ", "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.OmitFirst4, string.Empty), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, " with "), new Org.Brotli.Dec.Transform
|
||||
(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, "'"), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, " from "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity
|
||||
, " by "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.OmitFirst5, string.Empty), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.OmitFirst6, string.Empty), new Org.Brotli.Dec.Transform
|
||||
(" the ", Org.Brotli.Dec.WordTransformType.Identity, string.Empty), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.OmitLast4, string.Empty), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType
|
||||
.Identity, ". The "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.UppercaseAll, string.Empty), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, " on "), new Org.Brotli.Dec.Transform
|
||||
(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, " as "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, " is "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.OmitLast7
|
||||
, string.Empty), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.OmitLast1, "ing "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, "\n\t"), new Org.Brotli.Dec.Transform(string.Empty
|
||||
, Org.Brotli.Dec.WordTransformType.Identity, ":"), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType.Identity, ". "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, "ed "), new Org.Brotli.Dec.Transform
|
||||
(string.Empty, Org.Brotli.Dec.WordTransformType.OmitFirst9, string.Empty), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.OmitFirst7, string.Empty), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType
|
||||
.OmitLast6, string.Empty), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, "("), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.UppercaseFirst, ", "), new Org.Brotli.Dec.Transform
|
||||
(string.Empty, Org.Brotli.Dec.WordTransformType.OmitLast8, string.Empty), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, " at "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType
|
||||
.Identity, "ly "), new Org.Brotli.Dec.Transform(" the ", Org.Brotli.Dec.WordTransformType.Identity, " of "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.OmitLast5, string.Empty), new Org.Brotli.Dec.Transform(
|
||||
string.Empty, Org.Brotli.Dec.WordTransformType.OmitLast9, string.Empty), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType.UppercaseFirst, ", "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.UppercaseFirst
|
||||
, "\""), new Org.Brotli.Dec.Transform(".", Org.Brotli.Dec.WordTransformType.Identity, "("), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.UppercaseAll, " "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType
|
||||
.UppercaseFirst, "\">"), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, "=\""), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType.Identity, "."), new Org.Brotli.Dec.Transform(".com/",
|
||||
Org.Brotli.Dec.WordTransformType.Identity, string.Empty), new Org.Brotli.Dec.Transform(" the ", Org.Brotli.Dec.WordTransformType.Identity, " of the "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.UppercaseFirst
|
||||
, "'"), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, ". This "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, ","), new Org.Brotli.Dec.Transform(".", Org.Brotli.Dec.WordTransformType
|
||||
.Identity, " "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.UppercaseFirst, "("), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.UppercaseFirst, "."), new Org.Brotli.Dec.Transform
|
||||
(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, " not "), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType.Identity, "=\""), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, "er "
|
||||
), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType.UppercaseAll, " "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, "al "), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType
|
||||
.UppercaseAll, string.Empty), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, "='"), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.UppercaseAll, "\""), new Org.Brotli.Dec.Transform
|
||||
(string.Empty, Org.Brotli.Dec.WordTransformType.UppercaseFirst, ". "), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType.Identity, "("), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity,
|
||||
"ful "), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType.UppercaseFirst, ". "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, "ive "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType
|
||||
.Identity, "less "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.UppercaseAll, "'"), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, "est "), new Org.Brotli.Dec.Transform
|
||||
(" ", Org.Brotli.Dec.WordTransformType.UppercaseFirst, "."), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.UppercaseAll, "\">"), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType.Identity, "='"
|
||||
), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.UppercaseFirst, ","), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity, "ize "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType
|
||||
.UppercaseAll, "."), new Org.Brotli.Dec.Transform("\u00c2\u00a0", Org.Brotli.Dec.WordTransformType.Identity, string.Empty), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType.Identity, ","), new Org.Brotli.Dec.Transform(string.Empty
|
||||
, Org.Brotli.Dec.WordTransformType.UppercaseFirst, "=\""), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.UppercaseAll, "=\""), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.Identity
|
||||
, "ous "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.UppercaseAll, ", "), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.UppercaseFirst, "='"), new Org.Brotli.Dec.Transform(" ",
|
||||
Org.Brotli.Dec.WordTransformType.UppercaseFirst, ","), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType.UppercaseAll, "=\""), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType.UppercaseAll, ", "), new Org.Brotli.Dec.Transform
|
||||
(string.Empty, Org.Brotli.Dec.WordTransformType.UppercaseAll, ","), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.UppercaseAll, "("), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.
|
||||
UppercaseAll, ". "), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType.UppercaseAll, "."), new Org.Brotli.Dec.Transform(string.Empty, Org.Brotli.Dec.WordTransformType.UppercaseAll, "='"), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType
|
||||
.UppercaseAll, ". "), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType.UppercaseFirst, "=\""), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType.UppercaseAll, "='"), new Org.Brotli.Dec.Transform(" ", Org.Brotli.Dec.WordTransformType
|
||||
.UppercaseFirst, "='") };
|
||||
|
||||
internal static int TransformDictionaryWord(byte[] dst, int dstOffset, byte[] word, int wordOffset, int len, Org.Brotli.Dec.Transform transform)
|
||||
{
|
||||
int offset = dstOffset;
|
||||
// Copy prefix.
|
||||
byte[] @string = transform.prefix;
|
||||
int tmp = @string.Length;
|
||||
int i = 0;
|
||||
// In most cases tmp < 10 -> no benefits from System.arrayCopy
|
||||
while (i < tmp)
|
||||
{
|
||||
dst[offset++] = @string[i++];
|
||||
}
|
||||
// Copy trimmed word.
|
||||
int op = transform.type;
|
||||
tmp = Org.Brotli.Dec.WordTransformType.GetOmitFirst(op);
|
||||
if (tmp > len)
|
||||
{
|
||||
tmp = len;
|
||||
}
|
||||
wordOffset += tmp;
|
||||
len -= tmp;
|
||||
len -= Org.Brotli.Dec.WordTransformType.GetOmitLast(op);
|
||||
i = len;
|
||||
while (i > 0)
|
||||
{
|
||||
dst[offset++] = word[wordOffset++];
|
||||
i--;
|
||||
}
|
||||
if (op == Org.Brotli.Dec.WordTransformType.UppercaseAll || op == Org.Brotli.Dec.WordTransformType.UppercaseFirst)
|
||||
{
|
||||
int uppercaseOffset = offset - len;
|
||||
if (op == Org.Brotli.Dec.WordTransformType.UppercaseFirst)
|
||||
{
|
||||
len = 1;
|
||||
}
|
||||
while (len > 0)
|
||||
{
|
||||
tmp = dst[uppercaseOffset] & unchecked((int)(0xFF));
|
||||
if (tmp < unchecked((int)(0xc0)))
|
||||
{
|
||||
if (tmp >= 'a' && tmp <= 'z')
|
||||
{
|
||||
dst[uppercaseOffset] ^= unchecked((byte)32);
|
||||
}
|
||||
uppercaseOffset += 1;
|
||||
len -= 1;
|
||||
}
|
||||
else if (tmp < unchecked((int)(0xe0)))
|
||||
{
|
||||
dst[uppercaseOffset + 1] ^= unchecked((byte)32);
|
||||
uppercaseOffset += 2;
|
||||
len -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
dst[uppercaseOffset + 2] ^= unchecked((byte)5);
|
||||
uppercaseOffset += 3;
|
||||
len -= 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Copy suffix.
|
||||
@string = transform.suffix;
|
||||
tmp = @string.Length;
|
||||
i = 0;
|
||||
while (i < tmp)
|
||||
{
|
||||
dst[offset++] = @string[i++];
|
||||
}
|
||||
return offset - dstOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
59
AssetStudio/Brotli/Utils.cs
Normal file
59
AssetStudio/Brotli/Utils.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
/* Copyright 2015 Google Inc. All Rights Reserved.
|
||||
|
||||
Distributed under MIT license.
|
||||
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
*/
|
||||
namespace Org.Brotli.Dec
|
||||
{
|
||||
/// <summary>A set of utility methods.</summary>
|
||||
internal sealed class Utils
|
||||
{
|
||||
private static readonly byte[] ByteZeroes = new byte[1024];
|
||||
|
||||
private static readonly int[] IntZeroes = new int[1024];
|
||||
|
||||
/// <summary>Fills byte array with zeroes.</summary>
|
||||
/// <remarks>
|
||||
/// Fills byte array with zeroes.
|
||||
/// <p> Current implementation uses
|
||||
/// <see cref="System.Array.Copy(object, int, object, int, int)"/>
|
||||
/// , so it should be used for length not
|
||||
/// less than 16.
|
||||
/// </remarks>
|
||||
/// <param name="dest">array to fill with zeroes</param>
|
||||
/// <param name="offset">the first byte to fill</param>
|
||||
/// <param name="length">number of bytes to change</param>
|
||||
internal static void FillWithZeroes(byte[] dest, int offset, int length)
|
||||
{
|
||||
int cursor = 0;
|
||||
while (cursor < length)
|
||||
{
|
||||
int step = System.Math.Min(cursor + 1024, length) - cursor;
|
||||
System.Array.Copy(ByteZeroes, 0, dest, offset + cursor, step);
|
||||
cursor += step;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Fills int array with zeroes.</summary>
|
||||
/// <remarks>
|
||||
/// Fills int array with zeroes.
|
||||
/// <p> Current implementation uses
|
||||
/// <see cref="System.Array.Copy(object, int, object, int, int)"/>
|
||||
/// , so it should be used for length not
|
||||
/// less than 16.
|
||||
/// </remarks>
|
||||
/// <param name="dest">array to fill with zeroes</param>
|
||||
/// <param name="offset">the first item to fill</param>
|
||||
/// <param name="length">number of item to change</param>
|
||||
internal static void FillWithZeroes(int[] dest, int offset, int length)
|
||||
{
|
||||
int cursor = 0;
|
||||
while (cursor < length)
|
||||
{
|
||||
int step = System.Math.Min(cursor + 1024, length) - cursor;
|
||||
System.Array.Copy(IntZeroes, 0, dest, offset + cursor, step);
|
||||
cursor += step;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
68
AssetStudio/Brotli/WordTransformType.cs
Normal file
68
AssetStudio/Brotli/WordTransformType.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
/* Copyright 2015 Google Inc. All Rights Reserved.
|
||||
|
||||
Distributed under MIT license.
|
||||
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
*/
|
||||
namespace Org.Brotli.Dec
|
||||
{
|
||||
/// <summary>Enumeration of all possible word transformations.</summary>
|
||||
/// <remarks>
|
||||
/// Enumeration of all possible word transformations.
|
||||
/// <p>There are two simple types of transforms: omit X first/last symbols, two character-case
|
||||
/// transforms and the identity transform.
|
||||
/// </remarks>
|
||||
internal sealed class WordTransformType
|
||||
{
|
||||
internal const int Identity = 0;
|
||||
|
||||
internal const int OmitLast1 = 1;
|
||||
|
||||
internal const int OmitLast2 = 2;
|
||||
|
||||
internal const int OmitLast3 = 3;
|
||||
|
||||
internal const int OmitLast4 = 4;
|
||||
|
||||
internal const int OmitLast5 = 5;
|
||||
|
||||
internal const int OmitLast6 = 6;
|
||||
|
||||
internal const int OmitLast7 = 7;
|
||||
|
||||
internal const int OmitLast8 = 8;
|
||||
|
||||
internal const int OmitLast9 = 9;
|
||||
|
||||
internal const int UppercaseFirst = 10;
|
||||
|
||||
internal const int UppercaseAll = 11;
|
||||
|
||||
internal const int OmitFirst1 = 12;
|
||||
|
||||
internal const int OmitFirst2 = 13;
|
||||
|
||||
internal const int OmitFirst3 = 14;
|
||||
|
||||
internal const int OmitFirst4 = 15;
|
||||
|
||||
internal const int OmitFirst5 = 16;
|
||||
|
||||
internal const int OmitFirst6 = 17;
|
||||
|
||||
internal const int OmitFirst7 = 18;
|
||||
|
||||
internal const int OmitFirst8 = 19;
|
||||
|
||||
internal const int OmitFirst9 = 20;
|
||||
|
||||
internal static int GetOmitFirst(int type)
|
||||
{
|
||||
return type >= OmitFirst1 ? (type - OmitFirst1 + 1) : 0;
|
||||
}
|
||||
|
||||
internal static int GetOmitLast(int type)
|
||||
{
|
||||
return type <= OmitLast9 ? (type - OmitLast1 + 1) : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ namespace AssetStudio
|
||||
{
|
||||
public enum BuildTarget
|
||||
{
|
||||
UnknownPlatform = 3716,
|
||||
DashboardWidget = 1,
|
||||
StandaloneOSX = 2,
|
||||
StandaloneOSXPPC = 3,
|
||||
20
AssetStudio/BuildType.cs
Normal file
20
AssetStudio/BuildType.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class BuildType
|
||||
{
|
||||
private string buildType;
|
||||
|
||||
public BuildType(string type)
|
||||
{
|
||||
buildType = type;
|
||||
}
|
||||
|
||||
public bool IsAlpha => buildType == "a";
|
||||
public bool IsPatch => buildType == "p";
|
||||
}
|
||||
}
|
||||
306
AssetStudio/BundleFile.cs
Normal file
306
AssetStudio/BundleFile.cs
Normal file
@@ -0,0 +1,306 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Lz4;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class BundleFile
|
||||
{
|
||||
public class Header
|
||||
{
|
||||
public string signature;
|
||||
public uint version;
|
||||
public string unityVersion;
|
||||
public string unityRevision;
|
||||
public long size;
|
||||
public uint compressedBlocksInfoSize;
|
||||
public uint uncompressedBlocksInfoSize;
|
||||
public uint flags;
|
||||
}
|
||||
|
||||
public class StorageBlock
|
||||
{
|
||||
public uint compressedSize;
|
||||
public uint uncompressedSize;
|
||||
public ushort flags;
|
||||
}
|
||||
|
||||
public class Node
|
||||
{
|
||||
public long offset;
|
||||
public long size;
|
||||
public uint flags;
|
||||
public string path;
|
||||
}
|
||||
|
||||
public Header m_Header;
|
||||
private StorageBlock[] m_BlocksInfo;
|
||||
private Node[] m_DirectoryInfo;
|
||||
|
||||
public StreamFile[] fileList;
|
||||
|
||||
public BundleFile(EndianBinaryReader reader, string path)
|
||||
{
|
||||
m_Header = new Header();
|
||||
m_Header.signature = reader.ReadStringToNull();
|
||||
switch (m_Header.signature)
|
||||
{
|
||||
case "UnityArchive":
|
||||
break; //TODO
|
||||
case "UnityWeb":
|
||||
case "UnityRaw":
|
||||
ReadHeaderAndBlocksInfo(reader);
|
||||
using (var blocksStream = CreateBlocksStream(path))
|
||||
{
|
||||
ReadBlocksAndDirectory(reader, blocksStream);
|
||||
ReadFiles(blocksStream, path);
|
||||
}
|
||||
break;
|
||||
case "UnityFS":
|
||||
ReadHeader(reader);
|
||||
ReadBlocksInfoAndDirectory(reader);
|
||||
using (var blocksStream = CreateBlocksStream(path))
|
||||
{
|
||||
ReadBlocks(reader, blocksStream);
|
||||
ReadFiles(blocksStream, path);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadHeaderAndBlocksInfo(EndianBinaryReader reader)
|
||||
{
|
||||
var isCompressed = m_Header.signature == "UnityWeb";
|
||||
m_Header.version = reader.ReadUInt32();
|
||||
m_Header.unityVersion = reader.ReadStringToNull();
|
||||
m_Header.unityRevision = reader.ReadStringToNull();
|
||||
if (m_Header.version >= 4)
|
||||
{
|
||||
var hash = reader.ReadBytes(16);
|
||||
var crc = reader.ReadUInt32();
|
||||
}
|
||||
var minimumStreamedBytes = reader.ReadUInt32();
|
||||
var headerSize = reader.ReadUInt32();
|
||||
var numberOfLevelsToDownloadBeforeStreaming = reader.ReadUInt32();
|
||||
var levelCount = reader.ReadInt32();
|
||||
m_BlocksInfo = new StorageBlock[1];
|
||||
for (int i = 0; i < levelCount; i++)
|
||||
{
|
||||
var storageBlock = new StorageBlock()
|
||||
{
|
||||
compressedSize = reader.ReadUInt32(),
|
||||
uncompressedSize = reader.ReadUInt32(),
|
||||
flags = (ushort)(isCompressed ? 1 : 0)
|
||||
};
|
||||
if (i == levelCount - 1)
|
||||
{
|
||||
m_BlocksInfo[0] = storageBlock;
|
||||
}
|
||||
}
|
||||
if (m_Header.version >= 2)
|
||||
{
|
||||
var completeFileSize = reader.ReadUInt32();
|
||||
}
|
||||
if (m_Header.version >= 3)
|
||||
{
|
||||
var fileInfoHeaderSize = reader.ReadUInt32();
|
||||
}
|
||||
reader.Position = headerSize;
|
||||
}
|
||||
|
||||
private Stream CreateBlocksStream(string path)
|
||||
{
|
||||
Stream blocksStream;
|
||||
var uncompressedSizeSum = m_BlocksInfo.Sum(x => x.uncompressedSize);
|
||||
if (uncompressedSizeSum >= int.MaxValue)
|
||||
{
|
||||
/*var memoryMappedFile = MemoryMappedFile.CreateNew(Path.GetFileName(path), uncompressedSizeSum);
|
||||
assetsDataStream = memoryMappedFile.CreateViewStream();*/
|
||||
blocksStream = new FileStream(path + ".temp", FileMode.Create, FileAccess.ReadWrite, FileShare.None, 4096, FileOptions.DeleteOnClose);
|
||||
}
|
||||
else
|
||||
{
|
||||
blocksStream = new MemoryStream((int)uncompressedSizeSum);
|
||||
}
|
||||
return blocksStream;
|
||||
}
|
||||
|
||||
private void ReadBlocksAndDirectory(EndianBinaryReader reader, Stream blocksStream)
|
||||
{
|
||||
foreach (var blockInfo in m_BlocksInfo)
|
||||
{
|
||||
var uncompressedBytes = reader.ReadBytes((int)blockInfo.compressedSize);
|
||||
if (blockInfo.flags == 1)
|
||||
{
|
||||
using (var memoryStream = new MemoryStream(uncompressedBytes))
|
||||
{
|
||||
using (var decompressStream = SevenZipHelper.StreamDecompress(memoryStream))
|
||||
{
|
||||
uncompressedBytes = decompressStream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
blocksStream.Write(uncompressedBytes, 0, uncompressedBytes.Length);
|
||||
}
|
||||
blocksStream.Position = 0;
|
||||
var blocksReader = new EndianBinaryReader(blocksStream);
|
||||
var nodesCount = blocksReader.ReadInt32();
|
||||
m_DirectoryInfo = new Node[nodesCount];
|
||||
for (int i = 0; i < nodesCount; i++)
|
||||
{
|
||||
m_DirectoryInfo[i] = new Node
|
||||
{
|
||||
path = blocksReader.ReadStringToNull(),
|
||||
offset = blocksReader.ReadUInt32(),
|
||||
size = blocksReader.ReadUInt32()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public void ReadFiles(Stream blocksStream, string path)
|
||||
{
|
||||
fileList = new StreamFile[m_DirectoryInfo.Length];
|
||||
for (int i = 0; i < m_DirectoryInfo.Length; i++)
|
||||
{
|
||||
var node = m_DirectoryInfo[i];
|
||||
var file = new StreamFile();
|
||||
fileList[i] = file;
|
||||
file.fileName = Path.GetFileName(node.path);
|
||||
if (node.size >= int.MaxValue)
|
||||
{
|
||||
/*var memoryMappedFile = MemoryMappedFile.CreateNew(file.fileName, entryinfo_size);
|
||||
file.stream = memoryMappedFile.CreateViewStream();*/
|
||||
var extractPath = path + "_unpacked" + Path.DirectorySeparatorChar;
|
||||
Directory.CreateDirectory(extractPath);
|
||||
file.stream = File.Create(extractPath + file.fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
file.stream = new MemoryStream((int)node.size);
|
||||
}
|
||||
blocksStream.Position = node.offset;
|
||||
blocksStream.CopyTo(file.stream, node.size);
|
||||
file.stream.Position = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadHeader(EndianBinaryReader reader)
|
||||
{
|
||||
m_Header.version = reader.ReadUInt32();
|
||||
m_Header.unityVersion = reader.ReadStringToNull();
|
||||
m_Header.unityRevision = reader.ReadStringToNull();
|
||||
m_Header.size = reader.ReadInt64();
|
||||
m_Header.compressedBlocksInfoSize = reader.ReadUInt32();
|
||||
m_Header.uncompressedBlocksInfoSize = reader.ReadUInt32();
|
||||
m_Header.flags = reader.ReadUInt32();
|
||||
}
|
||||
|
||||
private void ReadBlocksInfoAndDirectory(EndianBinaryReader reader)
|
||||
{
|
||||
byte[] blocksInfoBytes;
|
||||
if ((m_Header.flags & 0x80) != 0) //kArchiveBlocksInfoAtTheEnd
|
||||
{
|
||||
var position = reader.Position;
|
||||
reader.Position = reader.BaseStream.Length - m_Header.compressedBlocksInfoSize;
|
||||
blocksInfoBytes = reader.ReadBytes((int)m_Header.compressedBlocksInfoSize);
|
||||
reader.Position = position;
|
||||
}
|
||||
else //0x40 kArchiveBlocksAndDirectoryInfoCombined
|
||||
{
|
||||
if (m_Header.version >= 7)
|
||||
{
|
||||
reader.AlignStream(16);
|
||||
}
|
||||
blocksInfoBytes = reader.ReadBytes((int)m_Header.compressedBlocksInfoSize);
|
||||
}
|
||||
var blocksInfoCompressedStream = new MemoryStream(blocksInfoBytes);
|
||||
MemoryStream blocksInfoUncompresseddStream;
|
||||
switch (m_Header.flags & 0x3F) //kArchiveCompressionTypeMask
|
||||
{
|
||||
default: //None
|
||||
{
|
||||
blocksInfoUncompresseddStream = blocksInfoCompressedStream;
|
||||
break;
|
||||
}
|
||||
case 1: //LZMA
|
||||
{
|
||||
blocksInfoUncompresseddStream = SevenZipHelper.StreamDecompress(blocksInfoCompressedStream);
|
||||
blocksInfoCompressedStream.Close();
|
||||
break;
|
||||
}
|
||||
case 2: //LZ4
|
||||
case 3: //LZ4HC
|
||||
{
|
||||
var uncompressedBytes = new byte[m_Header.uncompressedBlocksInfoSize];
|
||||
using (var decoder = new Lz4DecoderStream(blocksInfoCompressedStream))
|
||||
{
|
||||
decoder.Read(uncompressedBytes, 0, uncompressedBytes.Length);
|
||||
}
|
||||
blocksInfoUncompresseddStream = new MemoryStream(uncompressedBytes);
|
||||
break;
|
||||
}
|
||||
}
|
||||
using (var blocksInfoReader = new EndianBinaryReader(blocksInfoUncompresseddStream))
|
||||
{
|
||||
var uncompressedDataHash = blocksInfoReader.ReadBytes(16);
|
||||
var blocksInfoCount = blocksInfoReader.ReadInt32();
|
||||
m_BlocksInfo = new StorageBlock[blocksInfoCount];
|
||||
for (int i = 0; i < blocksInfoCount; i++)
|
||||
{
|
||||
m_BlocksInfo[i] = new StorageBlock
|
||||
{
|
||||
uncompressedSize = blocksInfoReader.ReadUInt32(),
|
||||
compressedSize = blocksInfoReader.ReadUInt32(),
|
||||
flags = blocksInfoReader.ReadUInt16()
|
||||
};
|
||||
}
|
||||
|
||||
var nodesCount = blocksInfoReader.ReadInt32();
|
||||
m_DirectoryInfo = new Node[nodesCount];
|
||||
for (int i = 0; i < nodesCount; i++)
|
||||
{
|
||||
m_DirectoryInfo[i] = new Node
|
||||
{
|
||||
offset = blocksInfoReader.ReadInt64(),
|
||||
size = blocksInfoReader.ReadInt64(),
|
||||
flags = blocksInfoReader.ReadUInt32(),
|
||||
path = blocksInfoReader.ReadStringToNull(),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadBlocks(EndianBinaryReader reader, Stream blocksStream)
|
||||
{
|
||||
foreach (var blockInfo in m_BlocksInfo)
|
||||
{
|
||||
switch (blockInfo.flags & 0x3F) //kStorageBlockCompressionTypeMask
|
||||
{
|
||||
default: //None
|
||||
{
|
||||
reader.BaseStream.CopyTo(blocksStream, blockInfo.compressedSize);
|
||||
break;
|
||||
}
|
||||
case 1: //LZMA
|
||||
{
|
||||
SevenZipHelper.StreamDecompress(reader.BaseStream, blocksStream, blockInfo.compressedSize, blockInfo.uncompressedSize);
|
||||
break;
|
||||
}
|
||||
case 2: //LZ4
|
||||
case 3: //LZ4HC
|
||||
{
|
||||
var compressedStream = new MemoryStream(reader.ReadBytes((int)blockInfo.compressedSize));
|
||||
using (var lz4Stream = new Lz4DecoderStream(compressedStream))
|
||||
{
|
||||
lz4Stream.CopyTo(blocksStream, blockInfo.uncompressedSize);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
blocksStream.Position = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
namespace AssetStudio
|
||||
{
|
||||
public enum ClassIDReference
|
||||
public enum ClassIDType
|
||||
{
|
||||
UnknownType = -1,
|
||||
Object = 0,
|
||||
GameObject = 1,
|
||||
Component = 2,
|
||||
LevelGameManager = 3,
|
||||
@@ -218,6 +219,8 @@
|
||||
VideoPlayer = 328,
|
||||
VideoClip = 329,
|
||||
OcclusionCullingData = 363,
|
||||
//kLargestRuntimeClassID = 364
|
||||
SmallestEditorClassID = 1000,
|
||||
Prefab = 1001,
|
||||
EditorExtensionImpl = 1002,
|
||||
AssetImporter = 1003,
|
||||
@@ -251,6 +254,7 @@
|
||||
PVRImporter = 1052,
|
||||
ASTCImporter = 1053,
|
||||
KTXImporter = 1054,
|
||||
IHVImageFormatImporter = 1055,
|
||||
AnimatorStateTransition = 1101,
|
||||
AnimatorState = 1102,
|
||||
HumanTemplate = 1105,
|
||||
@@ -262,6 +266,16 @@
|
||||
SubstanceImporter = 1112,
|
||||
LightmapParameters = 1113,
|
||||
LightmapSnapshot = 1120,
|
||||
GISRaster = 1121,
|
||||
GISRasterImporter = 1122,
|
||||
CadImporter = 1123,
|
||||
SketchUpImporter = 1124,
|
||||
BuildReport = 1125,
|
||||
PackedAssets = 1126,
|
||||
VideoClipImporter = 1127,
|
||||
ActivationLogComponent = 2000,
|
||||
//kLargestEditorClassID = 2001
|
||||
//kClassIdOutOfHierarchy = 100000
|
||||
SubDerived = 367388927,
|
||||
SiblingDerived = 334799969,
|
||||
SpriteAtlas = 687078895,
|
||||
@@ -5,26 +5,18 @@ using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class Animation
|
||||
public sealed class Animation : Behaviour
|
||||
{
|
||||
public PPtr m_GameObject;
|
||||
public List<PPtr> m_Animations;
|
||||
public PPtr<AnimationClip>[] m_Animations;
|
||||
|
||||
public Animation(AssetPreloadData preloadData)
|
||||
public Animation(ObjectReader reader) : base(reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
reader.Position = preloadData.Offset;
|
||||
|
||||
m_GameObject = sourceFile.ReadPPtr();
|
||||
var m_Enabled = reader.ReadByte();
|
||||
reader.AlignStream(4);
|
||||
var m_Animation = sourceFile.ReadPPtr();
|
||||
var m_Animation = new PPtr<AnimationClip>(reader);
|
||||
int numAnimations = reader.ReadInt32();
|
||||
m_Animations = new List<PPtr>(numAnimations);
|
||||
m_Animations = new PPtr<AnimationClip>[numAnimations];
|
||||
for (int i = 0; i < numAnimations; i++)
|
||||
{
|
||||
m_Animations.Add(sourceFile.ReadPPtr());
|
||||
m_Animations[i] = new PPtr<AnimationClip>(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,23 +5,59 @@ using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class Animator
|
||||
public sealed class Animator : Behaviour
|
||||
{
|
||||
public PPtr m_GameObject;
|
||||
public PPtr m_Avatar;
|
||||
public PPtr m_Controller;
|
||||
public PPtr<Avatar> m_Avatar;
|
||||
public PPtr<RuntimeAnimatorController> m_Controller;
|
||||
public bool m_HasTransformHierarchy = true;
|
||||
|
||||
public Animator(AssetPreloadData preloadData)
|
||||
public Animator(ObjectReader reader) : base(reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
reader.Position = preloadData.Offset;
|
||||
m_Avatar = new PPtr<Avatar>(reader);
|
||||
m_Controller = new PPtr<RuntimeAnimatorController>(reader);
|
||||
var m_CullingMode = reader.ReadInt32();
|
||||
|
||||
m_GameObject = sourceFile.ReadPPtr();
|
||||
var m_Enabled = reader.ReadByte();
|
||||
reader.AlignStream(4);
|
||||
m_Avatar = sourceFile.ReadPPtr();
|
||||
m_Controller = sourceFile.ReadPPtr();
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 5)) //4.5 and up
|
||||
{
|
||||
var m_UpdateMode = reader.ReadInt32();
|
||||
}
|
||||
|
||||
var m_ApplyRootMotion = reader.ReadBoolean();
|
||||
if (version[0] == 4 && version[1] >= 5) //4.5 and up - 5.0 down
|
||||
{
|
||||
reader.AlignStream();
|
||||
}
|
||||
|
||||
if (version[0] >= 5) //5.0 and up
|
||||
{
|
||||
var m_LinearVelocityBlending = reader.ReadBoolean();
|
||||
reader.AlignStream();
|
||||
}
|
||||
|
||||
if (version[0] < 4 || (version[0] == 4 && version[1] < 5)) //4.5 down
|
||||
{
|
||||
var m_AnimatePhysics = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3 and up
|
||||
{
|
||||
m_HasTransformHierarchy = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 5)) //4.5 and up
|
||||
{
|
||||
var m_AllowConstantClipSamplingOptimization = reader.ReadBoolean();
|
||||
}
|
||||
if (version[0] >= 5 && version[0] < 2018) //5.0 and up - 2018 down
|
||||
{
|
||||
reader.AlignStream();
|
||||
}
|
||||
|
||||
if (version[0] >= 2018) //2018 and up
|
||||
{
|
||||
var m_KeepAnimatorControllerStateOnDisable = reader.ReadBoolean();
|
||||
reader.AlignStream();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,21 +2,22 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using SharpDX;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class HumanPoseMask
|
||||
{
|
||||
public uint word0 { get; set; }
|
||||
public uint word1 { get; set; }
|
||||
public uint word2 { get; set; }
|
||||
public uint word0;
|
||||
public uint word1;
|
||||
public uint word2;
|
||||
|
||||
public HumanPoseMask(EndianBinaryReader reader, int[] version)
|
||||
public HumanPoseMask(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
|
||||
word0 = reader.ReadUInt32();
|
||||
word1 = reader.ReadUInt32();
|
||||
if (version[0] >= 5) //5.0 and up
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 2)) //5.2 and up
|
||||
{
|
||||
word2 = reader.ReadUInt32();
|
||||
}
|
||||
@@ -25,10 +26,10 @@ namespace AssetStudio
|
||||
|
||||
public class SkeletonMaskElement
|
||||
{
|
||||
public uint m_PathHash { get; set; }
|
||||
public float m_Weight { get; set; }
|
||||
public uint m_PathHash;
|
||||
public float m_Weight;
|
||||
|
||||
public SkeletonMaskElement(EndianBinaryReader reader)
|
||||
public SkeletonMaskElement(ObjectReader reader)
|
||||
{
|
||||
m_PathHash = reader.ReadUInt32();
|
||||
m_Weight = reader.ReadSingle();
|
||||
@@ -37,9 +38,9 @@ namespace AssetStudio
|
||||
|
||||
public class SkeletonMask
|
||||
{
|
||||
public SkeletonMaskElement[] m_Data { get; set; }
|
||||
public SkeletonMaskElement[] m_Data;
|
||||
|
||||
public SkeletonMask(EndianBinaryReader reader)
|
||||
public SkeletonMask(ObjectReader reader)
|
||||
{
|
||||
int numElements = reader.ReadInt32();
|
||||
m_Data = new SkeletonMaskElement[numElements];
|
||||
@@ -52,39 +53,47 @@ namespace AssetStudio
|
||||
|
||||
public class LayerConstant
|
||||
{
|
||||
public uint m_StateMachineIndex { get; set; }
|
||||
public uint m_StateMachineMotionSetIndex { get; set; }
|
||||
public HumanPoseMask m_BodyMask { get; set; }
|
||||
public SkeletonMask m_SkeletonMask { get; set; }
|
||||
public uint m_Binding { get; set; }
|
||||
public int m_LayerBlendingMode { get; set; }
|
||||
public float m_DefaultWeight { get; set; }
|
||||
public bool m_IKPass { get; set; }
|
||||
public bool m_SyncedLayerAffectsTiming { get; set; }
|
||||
public uint m_StateMachineIndex;
|
||||
public uint m_StateMachineMotionSetIndex;
|
||||
public HumanPoseMask m_BodyMask;
|
||||
public SkeletonMask m_SkeletonMask;
|
||||
public uint m_Binding;
|
||||
public int m_LayerBlendingMode;
|
||||
public float m_DefaultWeight;
|
||||
public bool m_IKPass;
|
||||
public bool m_SyncedLayerAffectsTiming;
|
||||
|
||||
public LayerConstant(EndianBinaryReader reader, int[] version)
|
||||
public LayerConstant(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
|
||||
m_StateMachineIndex = reader.ReadUInt32();
|
||||
m_StateMachineMotionSetIndex = reader.ReadUInt32();
|
||||
m_BodyMask = new HumanPoseMask(reader, version);
|
||||
m_BodyMask = new HumanPoseMask(reader);
|
||||
m_SkeletonMask = new SkeletonMask(reader);
|
||||
m_Binding = reader.ReadUInt32();
|
||||
m_LayerBlendingMode = reader.ReadInt32();
|
||||
m_DefaultWeight = reader.ReadSingle();
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 2)) //4.2 and up
|
||||
{
|
||||
m_DefaultWeight = reader.ReadSingle();
|
||||
}
|
||||
m_IKPass = reader.ReadBoolean();
|
||||
m_SyncedLayerAffectsTiming = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 2)) //4.2 and up
|
||||
{
|
||||
m_SyncedLayerAffectsTiming = reader.ReadBoolean();
|
||||
}
|
||||
reader.AlignStream();
|
||||
}
|
||||
}
|
||||
|
||||
public class ConditionConstant
|
||||
{
|
||||
public uint m_ConditionMode { get; set; }
|
||||
public uint m_EventID { get; set; }
|
||||
public float m_EventThreshold { get; set; }
|
||||
public float m_ExitTime { get; set; }
|
||||
public uint m_ConditionMode;
|
||||
public uint m_EventID;
|
||||
public float m_EventThreshold;
|
||||
public float m_ExitTime;
|
||||
|
||||
public ConditionConstant(EndianBinaryReader reader)
|
||||
public ConditionConstant(ObjectReader reader)
|
||||
{
|
||||
m_ConditionMode = reader.ReadUInt32();
|
||||
m_EventID = reader.ReadUInt32();
|
||||
@@ -95,23 +104,25 @@ namespace AssetStudio
|
||||
|
||||
public class TransitionConstant
|
||||
{
|
||||
public ConditionConstant[] m_ConditionConstantArray { get; set; }
|
||||
public uint m_DestinationState { get; set; }
|
||||
public uint m_FullPathID { get; set; }
|
||||
public uint m_ID { get; set; }
|
||||
public uint m_UserID { get; set; }
|
||||
public float m_TransitionDuration { get; set; }
|
||||
public float m_TransitionOffset { get; set; }
|
||||
public float m_ExitTime { get; set; }
|
||||
public bool m_HasExitTime { get; set; }
|
||||
public bool m_HasFixedDuration { get; set; }
|
||||
public int m_InterruptionSource { get; set; }
|
||||
public bool m_OrderedInterruption { get; set; }
|
||||
public bool m_Atomic { get; set; }
|
||||
public bool m_CanTransitionToSelf { get; set; }
|
||||
public ConditionConstant[] m_ConditionConstantArray;
|
||||
public uint m_DestinationState;
|
||||
public uint m_FullPathID;
|
||||
public uint m_ID;
|
||||
public uint m_UserID;
|
||||
public float m_TransitionDuration;
|
||||
public float m_TransitionOffset;
|
||||
public float m_ExitTime;
|
||||
public bool m_HasExitTime;
|
||||
public bool m_HasFixedDuration;
|
||||
public int m_InterruptionSource;
|
||||
public bool m_OrderedInterruption;
|
||||
public bool m_Atomic;
|
||||
public bool m_CanTransitionToSelf;
|
||||
|
||||
public TransitionConstant(EndianBinaryReader reader, int[] version)
|
||||
public TransitionConstant(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
|
||||
int numConditions = reader.ReadInt32();
|
||||
m_ConditionConstantArray = new ConditionConstant[numConditions];
|
||||
for (int i = 0; i < numConditions; i++)
|
||||
@@ -134,7 +145,7 @@ namespace AssetStudio
|
||||
m_ExitTime = reader.ReadSingle();
|
||||
m_HasExitTime = reader.ReadBoolean();
|
||||
m_HasFixedDuration = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
reader.AlignStream();
|
||||
m_InterruptionSource = reader.ReadInt32();
|
||||
m_OrderedInterruption = reader.ReadBoolean();
|
||||
}
|
||||
@@ -143,47 +154,51 @@ namespace AssetStudio
|
||||
m_Atomic = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
m_CanTransitionToSelf = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 5)) //4.5 and up
|
||||
{
|
||||
m_CanTransitionToSelf = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
reader.AlignStream();
|
||||
}
|
||||
}
|
||||
|
||||
public class LeafInfoConstant
|
||||
{
|
||||
public uint[] m_IDArray { get; set; }
|
||||
public uint m_IndexOffset { get; set; }
|
||||
public uint[] m_IDArray;
|
||||
public uint m_IndexOffset;
|
||||
|
||||
public LeafInfoConstant(EndianBinaryReader reader)
|
||||
public LeafInfoConstant(ObjectReader reader)
|
||||
{
|
||||
m_IDArray = reader.ReadUInt32Array(reader.ReadInt32());
|
||||
m_IDArray = reader.ReadUInt32Array();
|
||||
m_IndexOffset = reader.ReadUInt32();
|
||||
}
|
||||
}
|
||||
|
||||
public class MotionNeighborList
|
||||
{
|
||||
public uint[] m_NeighborArray { get; set; }
|
||||
public uint[] m_NeighborArray;
|
||||
|
||||
public MotionNeighborList(EndianBinaryReader reader)
|
||||
public MotionNeighborList(ObjectReader reader)
|
||||
{
|
||||
m_NeighborArray = reader.ReadUInt32Array(reader.ReadInt32());
|
||||
m_NeighborArray = reader.ReadUInt32Array();
|
||||
}
|
||||
}
|
||||
|
||||
public class Blend2dDataConstant
|
||||
{
|
||||
public Vector2[] m_ChildPositionArray { get; set; }
|
||||
public float[] m_ChildMagnitudeArray { get; set; }
|
||||
public Vector2[] m_ChildPairVectorArray { get; set; }
|
||||
public float[] m_ChildPairAvgMagInvArray { get; set; }
|
||||
public MotionNeighborList[] m_ChildNeighborListArray { get; set; }
|
||||
public Vector2[] m_ChildPositionArray;
|
||||
public float[] m_ChildMagnitudeArray;
|
||||
public Vector2[] m_ChildPairVectorArray;
|
||||
public float[] m_ChildPairAvgMagInvArray;
|
||||
public MotionNeighborList[] m_ChildNeighborListArray;
|
||||
|
||||
public Blend2dDataConstant(EndianBinaryReader reader)
|
||||
public Blend2dDataConstant(ObjectReader reader)
|
||||
{
|
||||
m_ChildPositionArray = reader.ReadVector2Array(reader.ReadInt32());
|
||||
m_ChildMagnitudeArray = reader.ReadSingleArray(reader.ReadInt32());
|
||||
m_ChildPairVectorArray = reader.ReadVector2Array(reader.ReadInt32());
|
||||
m_ChildPairAvgMagInvArray = reader.ReadSingleArray(reader.ReadInt32());
|
||||
m_ChildPositionArray = reader.ReadVector2Array();
|
||||
m_ChildMagnitudeArray = reader.ReadSingleArray();
|
||||
m_ChildPairVectorArray = reader.ReadVector2Array();
|
||||
m_ChildPairAvgMagInvArray = reader.ReadSingleArray();
|
||||
|
||||
int numNeighbours = reader.ReadInt32();
|
||||
m_ChildNeighborListArray = new MotionNeighborList[numNeighbours];
|
||||
@@ -196,79 +211,111 @@ namespace AssetStudio
|
||||
|
||||
public class Blend1dDataConstant // wrong labeled
|
||||
{
|
||||
public float[] m_ChildThresholdArray { get; set; }
|
||||
public float[] m_ChildThresholdArray;
|
||||
|
||||
public Blend1dDataConstant(EndianBinaryReader reader)
|
||||
public Blend1dDataConstant(ObjectReader reader)
|
||||
{
|
||||
m_ChildThresholdArray = reader.ReadSingleArray(reader.ReadInt32());
|
||||
m_ChildThresholdArray = reader.ReadSingleArray();
|
||||
}
|
||||
}
|
||||
|
||||
public class BlendDirectDataConstant
|
||||
{
|
||||
public uint[] m_ChildBlendEventIDArray { get; set; }
|
||||
public bool m_NormalizedBlendValues { get; set; }
|
||||
public uint[] m_ChildBlendEventIDArray;
|
||||
public bool m_NormalizedBlendValues;
|
||||
|
||||
public BlendDirectDataConstant(EndianBinaryReader reader)
|
||||
public BlendDirectDataConstant(ObjectReader reader)
|
||||
{
|
||||
m_ChildBlendEventIDArray = reader.ReadUInt32Array(reader.ReadInt32());
|
||||
m_ChildBlendEventIDArray = reader.ReadUInt32Array();
|
||||
m_NormalizedBlendValues = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
reader.AlignStream();
|
||||
}
|
||||
}
|
||||
|
||||
public class BlendTreeNodeConstant
|
||||
{
|
||||
public uint m_BlendType { get; set; }
|
||||
public uint m_BlendEventID { get; set; }
|
||||
public uint m_BlendEventYID { get; set; }
|
||||
public uint[] m_ChildIndices { get; set; }
|
||||
public Blend1dDataConstant m_Blend1dData { get; set; }
|
||||
public Blend2dDataConstant m_Blend2dData { get; set; }
|
||||
public BlendDirectDataConstant m_BlendDirectData { get; set; }
|
||||
public uint m_ClipID { get; set; }
|
||||
public uint m_ClipIndex { get; set; }
|
||||
public float m_Duration { get; set; }
|
||||
public float m_CycleOffset { get; set; }
|
||||
public bool m_Mirror { get; set; }
|
||||
public uint m_BlendType;
|
||||
public uint m_BlendEventID;
|
||||
public uint m_BlendEventYID;
|
||||
public uint[] m_ChildIndices;
|
||||
public float[] m_ChildThresholdArray;
|
||||
public Blend1dDataConstant m_Blend1dData;
|
||||
public Blend2dDataConstant m_Blend2dData;
|
||||
public BlendDirectDataConstant m_BlendDirectData;
|
||||
public uint m_ClipID;
|
||||
public uint m_ClipIndex;
|
||||
public float m_Duration;
|
||||
public float m_CycleOffset;
|
||||
public bool m_Mirror;
|
||||
|
||||
public BlendTreeNodeConstant(EndianBinaryReader reader, int[] version)
|
||||
public BlendTreeNodeConstant(ObjectReader reader)
|
||||
{
|
||||
m_BlendType = reader.ReadUInt32();
|
||||
var version = reader.version;
|
||||
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 1)) //4.1 and up
|
||||
{
|
||||
m_BlendType = reader.ReadUInt32();
|
||||
}
|
||||
m_BlendEventID = reader.ReadUInt32();
|
||||
m_BlendEventYID = reader.ReadUInt32();
|
||||
m_ChildIndices = reader.ReadUInt32Array(reader.ReadInt32());
|
||||
m_Blend1dData = new Blend1dDataConstant(reader);
|
||||
m_Blend2dData = new Blend2dDataConstant(reader);
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 1)) //4.1 and up
|
||||
{
|
||||
m_BlendEventYID = reader.ReadUInt32();
|
||||
}
|
||||
m_ChildIndices = reader.ReadUInt32Array();
|
||||
if (version[0] < 4 || (version[0] == 4 && version[1] < 1)) //4.1 down
|
||||
{
|
||||
m_ChildThresholdArray = reader.ReadSingleArray();
|
||||
}
|
||||
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 1)) //4.1 and up
|
||||
{
|
||||
m_Blend1dData = new Blend1dDataConstant(reader);
|
||||
m_Blend2dData = new Blend2dDataConstant(reader);
|
||||
}
|
||||
|
||||
if (version[0] >= 5) //5.0 and up
|
||||
{
|
||||
m_BlendDirectData = new BlendDirectDataConstant(reader);
|
||||
}
|
||||
|
||||
m_ClipID = reader.ReadUInt32();
|
||||
if (version[0] < 5) //5.0 down
|
||||
if (version[0] == 4 && version[1] >= 5) //4.5 - 5.0
|
||||
{
|
||||
m_ClipIndex = reader.ReadUInt32();
|
||||
}
|
||||
|
||||
m_Duration = reader.ReadSingle();
|
||||
m_CycleOffset = reader.ReadSingle();
|
||||
m_Mirror = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
|
||||
if (version[0] > 4
|
||||
|| (version[0] == 4 && version[1] > 1)
|
||||
|| (version[0] == 4 && version[1] == 1 && version[2] >= 3)) //4.1.3 and up
|
||||
{
|
||||
m_CycleOffset = reader.ReadSingle();
|
||||
m_Mirror = reader.ReadBoolean();
|
||||
reader.AlignStream();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class BlendTreeConstant
|
||||
{
|
||||
public BlendTreeNodeConstant[] m_NodeArray { get; set; }
|
||||
public BlendTreeNodeConstant[] m_NodeArray;
|
||||
public ValueArrayConstant m_BlendEventArrayConstant;
|
||||
|
||||
public BlendTreeConstant(EndianBinaryReader reader, int[] version)
|
||||
public BlendTreeConstant(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
|
||||
int numNodes = reader.ReadInt32();
|
||||
m_NodeArray = new BlendTreeNodeConstant[numNodes];
|
||||
for (int i = 0; i < numNodes; i++)
|
||||
{
|
||||
m_NodeArray[i] = new BlendTreeNodeConstant(reader, version);
|
||||
m_NodeArray[i] = new BlendTreeNodeConstant(reader);
|
||||
}
|
||||
|
||||
if (version[0] < 4 || (version[0] == 4 && version[1] < 5)) //4.5 down
|
||||
{
|
||||
m_BlendEventArrayConstant = new ValueArrayConstant(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -276,41 +323,38 @@ namespace AssetStudio
|
||||
|
||||
public class StateConstant
|
||||
{
|
||||
public TransitionConstant[] m_TransitionConstantArray { get; set; }
|
||||
public int[] m_BlendTreeConstantIndexArray { get; set; }
|
||||
public LeafInfoConstant[] m_LeafInfoArray { get; set; }
|
||||
public BlendTreeConstant[] m_BlendTreeConstantArray { get; set; }
|
||||
public uint m_NameID { get; set; }
|
||||
public uint m_PathID { get; set; }
|
||||
public uint m_FullPathID { get; set; }
|
||||
public uint m_TagID { get; set; }
|
||||
public uint m_SpeedParamID { get; set; }
|
||||
public uint m_MirrorParamID { get; set; }
|
||||
public uint m_CycleOffsetParamID { get; set; }
|
||||
public float m_Speed { get; set; }
|
||||
public float m_CycleOffset { get; set; }
|
||||
public bool m_IKOnFeet { get; set; }
|
||||
public bool m_WriteDefaultValues { get; set; }
|
||||
public bool m_Loop { get; set; }
|
||||
public bool m_Mirror { get; set; }
|
||||
public TransitionConstant[] m_TransitionConstantArray;
|
||||
public int[] m_BlendTreeConstantIndexArray;
|
||||
public LeafInfoConstant[] m_LeafInfoArray;
|
||||
public BlendTreeConstant[] m_BlendTreeConstantArray;
|
||||
public uint m_NameID;
|
||||
public uint m_PathID;
|
||||
public uint m_FullPathID;
|
||||
public uint m_TagID;
|
||||
public uint m_SpeedParamID;
|
||||
public uint m_MirrorParamID;
|
||||
public uint m_CycleOffsetParamID;
|
||||
public float m_Speed;
|
||||
public float m_CycleOffset;
|
||||
public bool m_IKOnFeet;
|
||||
public bool m_WriteDefaultValues;
|
||||
public bool m_Loop;
|
||||
public bool m_Mirror;
|
||||
|
||||
public StateConstant(EndianBinaryReader reader, int[] version)
|
||||
public StateConstant(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
|
||||
int numTransistions = reader.ReadInt32();
|
||||
m_TransitionConstantArray = new TransitionConstant[numTransistions];
|
||||
for (int i = 0; i < numTransistions; i++)
|
||||
{
|
||||
m_TransitionConstantArray[i] = new TransitionConstant(reader, version);
|
||||
m_TransitionConstantArray[i] = new TransitionConstant(reader);
|
||||
}
|
||||
|
||||
int numBlendIndices = reader.ReadInt32();
|
||||
m_BlendTreeConstantIndexArray = new int[numBlendIndices];
|
||||
for (int i = 0; i < numBlendIndices; i++)
|
||||
{
|
||||
m_BlendTreeConstantIndexArray[i] = reader.ReadInt32();
|
||||
}
|
||||
m_BlendTreeConstantIndexArray = reader.ReadInt32Array();
|
||||
|
||||
if (version[0] < 5) //5.0 down
|
||||
if (version[0] < 5 || (version[0] == 5 && version[1] < 2)) //5.2 down
|
||||
{
|
||||
int numInfos = reader.ReadInt32();
|
||||
m_LeafInfoArray = new LeafInfoConstant[numInfos];
|
||||
@@ -324,18 +368,21 @@ namespace AssetStudio
|
||||
m_BlendTreeConstantArray = new BlendTreeConstant[numBlends];
|
||||
for (int i = 0; i < numBlends; i++)
|
||||
{
|
||||
m_BlendTreeConstantArray[i] = new BlendTreeConstant(reader, version);
|
||||
m_BlendTreeConstantArray[i] = new BlendTreeConstant(reader);
|
||||
}
|
||||
|
||||
m_NameID = reader.ReadUInt32();
|
||||
m_PathID = reader.ReadUInt32();
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3 and up
|
||||
{
|
||||
m_PathID = reader.ReadUInt32();
|
||||
}
|
||||
if (version[0] >= 5) //5.0 and up
|
||||
{
|
||||
m_FullPathID = reader.ReadUInt32();
|
||||
}
|
||||
|
||||
m_TagID = reader.ReadUInt32();
|
||||
if (version[0] >= 5) //5.0 and up
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 1)) //5.1 and up
|
||||
{
|
||||
m_SpeedParamID = reader.ReadUInt32();
|
||||
m_MirrorParamID = reader.ReadUInt32();
|
||||
@@ -348,7 +395,10 @@ namespace AssetStudio
|
||||
}
|
||||
|
||||
m_Speed = reader.ReadSingle();
|
||||
m_CycleOffset = reader.ReadSingle();
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 1)) //4.1 and up
|
||||
{
|
||||
m_CycleOffset = reader.ReadSingle();
|
||||
}
|
||||
m_IKOnFeet = reader.ReadBoolean();
|
||||
if (version[0] >= 5) //5.0 and up
|
||||
{
|
||||
@@ -356,17 +406,21 @@ namespace AssetStudio
|
||||
}
|
||||
|
||||
m_Loop = reader.ReadBoolean();
|
||||
m_Mirror = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 1)) //4.1 and up
|
||||
{
|
||||
m_Mirror = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
reader.AlignStream();
|
||||
}
|
||||
}
|
||||
|
||||
public class SelectorTransitionConstant
|
||||
{
|
||||
public uint m_Destination { get; set; }
|
||||
public ConditionConstant[] m_ConditionConstantArray { get; set; }
|
||||
public uint m_Destination;
|
||||
public ConditionConstant[] m_ConditionConstantArray;
|
||||
|
||||
public SelectorTransitionConstant(EndianBinaryReader reader)
|
||||
public SelectorTransitionConstant(ObjectReader reader)
|
||||
{
|
||||
m_Destination = reader.ReadUInt32();
|
||||
|
||||
@@ -381,11 +435,11 @@ namespace AssetStudio
|
||||
|
||||
public class SelectorStateConstant
|
||||
{
|
||||
public SelectorTransitionConstant[] m_TransitionConstantArray { get; set; }
|
||||
public uint m_FullPathID { get; set; }
|
||||
public bool m_isEntry { get; set; }
|
||||
public SelectorTransitionConstant[] m_TransitionConstantArray;
|
||||
public uint m_FullPathID;
|
||||
public bool m_isEntry;
|
||||
|
||||
public SelectorStateConstant(EndianBinaryReader reader)
|
||||
public SelectorStateConstant(ObjectReader reader)
|
||||
{
|
||||
int numTransitions = reader.ReadInt32();
|
||||
m_TransitionConstantArray = new SelectorTransitionConstant[numTransitions];
|
||||
@@ -396,32 +450,34 @@ namespace AssetStudio
|
||||
|
||||
m_FullPathID = reader.ReadUInt32();
|
||||
m_isEntry = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
reader.AlignStream();
|
||||
}
|
||||
}
|
||||
|
||||
public class StateMachineConstant
|
||||
{
|
||||
public StateConstant[] m_StateConstantArray { get; set; }
|
||||
public TransitionConstant[] m_AnyStateTransitionConstantArray { get; set; }
|
||||
public SelectorStateConstant[] m_SelectorStateConstantArray { get; set; }
|
||||
public uint m_DefaultState { get; set; }
|
||||
public uint m_MotionSetCount { get; set; }
|
||||
public StateConstant[] m_StateConstantArray;
|
||||
public TransitionConstant[] m_AnyStateTransitionConstantArray;
|
||||
public SelectorStateConstant[] m_SelectorStateConstantArray;
|
||||
public uint m_DefaultState;
|
||||
public uint m_MotionSetCount;
|
||||
|
||||
public StateMachineConstant(EndianBinaryReader reader, int[] version)
|
||||
public StateMachineConstant(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
|
||||
int numStates = reader.ReadInt32();
|
||||
m_StateConstantArray = new StateConstant[numStates];
|
||||
for (int i = 0; i < numStates; i++)
|
||||
{
|
||||
m_StateConstantArray[i] = new StateConstant(reader, version);
|
||||
m_StateConstantArray[i] = new StateConstant(reader);
|
||||
}
|
||||
|
||||
int numAnyStates = reader.ReadInt32();
|
||||
m_AnyStateTransitionConstantArray = new TransitionConstant[numAnyStates];
|
||||
for (int i = 0; i < numAnyStates; i++)
|
||||
{
|
||||
m_AnyStateTransitionConstantArray[i] = new TransitionConstant(reader, version);
|
||||
m_AnyStateTransitionConstantArray[i] = new TransitionConstant(reader);
|
||||
}
|
||||
|
||||
if (version[0] >= 5) //5.0 and up
|
||||
@@ -441,119 +497,108 @@ namespace AssetStudio
|
||||
|
||||
public class ValueArray
|
||||
{
|
||||
public bool[] m_BoolValues { get; set; }
|
||||
public int[] m_IntValues { get; set; }
|
||||
public float[] m_FloatValues { get; set; }
|
||||
public object[] m_PositionValues { get; set; }
|
||||
public Vector4[] m_QuaternionValues { get; set; }
|
||||
public object[] m_ScaleValues { get; set; }
|
||||
public bool[] m_BoolValues;
|
||||
public int[] m_IntValues;
|
||||
public float[] m_FloatValues;
|
||||
public Vector4[] m_VectorValues;
|
||||
public Vector3[] m_PositionValues;
|
||||
public Vector4[] m_QuaternionValues;
|
||||
public Vector3[] m_ScaleValues;
|
||||
|
||||
public ValueArray(EndianBinaryReader reader, int[] version)
|
||||
public ValueArray(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
|
||||
if (version[0] < 5 || (version[0] == 5 && version[1] < 5)) //5.5 down
|
||||
{
|
||||
int numBools = reader.ReadInt32();
|
||||
m_BoolValues = new bool[numBools];
|
||||
for (int i = 0; i < numBools; i++)
|
||||
m_BoolValues = reader.ReadBooleanArray();
|
||||
reader.AlignStream();
|
||||
m_IntValues = reader.ReadInt32Array();
|
||||
m_FloatValues = reader.ReadSingleArray();
|
||||
}
|
||||
|
||||
if (version[0] < 4 || (version[0] == 4 && version[1] < 3)) //4.3 down
|
||||
{
|
||||
m_VectorValues = reader.ReadVector4Array();
|
||||
}
|
||||
else
|
||||
{
|
||||
int numPosValues = reader.ReadInt32();
|
||||
m_PositionValues = new Vector3[numPosValues];
|
||||
for (int i = 0; i < numPosValues; i++)
|
||||
{
|
||||
m_BoolValues[i] = reader.ReadBoolean();
|
||||
m_PositionValues[i] = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? reader.ReadVector3() : (Vector3)reader.ReadVector4(); //5.4 and up
|
||||
}
|
||||
|
||||
reader.AlignStream(4);
|
||||
m_QuaternionValues = reader.ReadVector4Array();
|
||||
|
||||
m_IntValues = reader.ReadInt32Array(reader.ReadInt32());
|
||||
m_FloatValues = reader.ReadSingleArray(reader.ReadInt32());
|
||||
}
|
||||
|
||||
int numPosValues = reader.ReadInt32();
|
||||
m_PositionValues = new object[numPosValues];
|
||||
for (int i = 0; i < numPosValues; i++)
|
||||
{
|
||||
m_PositionValues[i] = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? (object)reader.ReadVector3() : (object)reader.ReadVector4(); //5.4 and up
|
||||
}
|
||||
|
||||
m_QuaternionValues = reader.ReadVector4Array(reader.ReadInt32());
|
||||
|
||||
int numScaleValues = reader.ReadInt32();
|
||||
m_ScaleValues = new object[numScaleValues];
|
||||
for (int i = 0; i < numScaleValues; i++)
|
||||
{
|
||||
m_ScaleValues[i] = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? (object)reader.ReadVector3() : (object)reader.ReadVector4(); //5.4 adn up
|
||||
}
|
||||
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 5)) //5.5 and up
|
||||
{
|
||||
m_FloatValues = reader.ReadSingleArray(reader.ReadInt32());
|
||||
m_IntValues = reader.ReadInt32Array(reader.ReadInt32());
|
||||
|
||||
int numBools = reader.ReadInt32();
|
||||
m_BoolValues = new bool[numBools];
|
||||
for (int i = 0; i < numBools; i++)
|
||||
int numScaleValues = reader.ReadInt32();
|
||||
m_ScaleValues = new Vector3[numScaleValues];
|
||||
for (int i = 0; i < numScaleValues; i++)
|
||||
{
|
||||
m_BoolValues[i] = reader.ReadBoolean();
|
||||
m_ScaleValues[i] = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? reader.ReadVector3() : (Vector3)reader.ReadVector4(); //5.4 and up
|
||||
}
|
||||
|
||||
reader.AlignStream(4);
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 5)) //5.5 and up
|
||||
{
|
||||
m_FloatValues = reader.ReadSingleArray();
|
||||
m_IntValues = reader.ReadInt32Array();
|
||||
m_BoolValues = reader.ReadBooleanArray();
|
||||
reader.AlignStream();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ControllerConstant
|
||||
{
|
||||
public LayerConstant[] m_LayerArray { get; set; }
|
||||
public StateMachineConstant[] m_StateMachineArray { get; set; }
|
||||
public ValueArrayConstant m_Values { get; set; }
|
||||
public ValueArray m_DefaultValues { get; set; }
|
||||
public LayerConstant[] m_LayerArray;
|
||||
public StateMachineConstant[] m_StateMachineArray;
|
||||
public ValueArrayConstant m_Values;
|
||||
public ValueArray m_DefaultValues;
|
||||
|
||||
public ControllerConstant(EndianBinaryReader reader, int[] version)
|
||||
public ControllerConstant(ObjectReader reader)
|
||||
{
|
||||
int numLayers = reader.ReadInt32();
|
||||
m_LayerArray = new LayerConstant[numLayers];
|
||||
for (int i = 0; i < numLayers; i++)
|
||||
{
|
||||
m_LayerArray[i] = new LayerConstant(reader, version);
|
||||
m_LayerArray[i] = new LayerConstant(reader);
|
||||
}
|
||||
|
||||
int numStates = reader.ReadInt32();
|
||||
m_StateMachineArray = new StateMachineConstant[numStates];
|
||||
for (int i = 0; i < numStates; i++)
|
||||
{
|
||||
m_StateMachineArray[i] = new StateMachineConstant(reader, version);
|
||||
m_StateMachineArray[i] = new StateMachineConstant(reader);
|
||||
}
|
||||
|
||||
m_Values = new ValueArrayConstant(reader, version);
|
||||
m_DefaultValues = new ValueArray(reader, version);
|
||||
m_Values = new ValueArrayConstant(reader);
|
||||
m_DefaultValues = new ValueArray(reader);
|
||||
}
|
||||
}
|
||||
|
||||
public class AnimatorController
|
||||
public sealed class AnimatorController : RuntimeAnimatorController
|
||||
{
|
||||
public string m_Name;
|
||||
public PPtr[] m_AnimationClips;
|
||||
public PPtr<AnimationClip>[] m_AnimationClips;
|
||||
|
||||
public AnimatorController(AssetPreloadData preloadData)
|
||||
public AnimatorController(ObjectReader reader) : base(reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var version = preloadData.sourceFile.version;
|
||||
var reader = preloadData.InitReader();
|
||||
reader.Position = preloadData.Offset;
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
var m_ControllerSize = reader.ReadUInt32();
|
||||
var m_Controller = new ControllerConstant(reader, version);
|
||||
var m_Controller = new ControllerConstant(reader);
|
||||
|
||||
int tosSize = reader.ReadInt32();
|
||||
var m_TOS = new List<KeyValuePair<uint, string>>(tosSize);
|
||||
var m_TOS = new KeyValuePair<uint, string>[tosSize];
|
||||
for (int i = 0; i < tosSize; i++)
|
||||
{
|
||||
m_TOS.Add(new KeyValuePair<uint, string>(reader.ReadUInt32(), reader.ReadAlignedString()));
|
||||
m_TOS[i] = new KeyValuePair<uint, string>(reader.ReadUInt32(), reader.ReadAlignedString());
|
||||
}
|
||||
|
||||
int numClips = reader.ReadInt32();
|
||||
m_AnimationClips = new PPtr[numClips];
|
||||
m_AnimationClips = new PPtr<AnimationClip>[numClips];
|
||||
for (int i = 0; i < numClips; i++)
|
||||
{
|
||||
m_AnimationClips[i] = sourceFile.ReadPPtr();
|
||||
m_AnimationClips[i] = new PPtr<AnimationClip>(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,28 +5,32 @@ using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class AnimatorOverrideController
|
||||
public class AnimationClipOverride
|
||||
{
|
||||
public string m_Name;
|
||||
public PPtr m_Controller;
|
||||
public PPtr[][] m_Clips;
|
||||
public PPtr<AnimationClip> m_OriginalClip;
|
||||
public PPtr<AnimationClip> m_OverrideClip;
|
||||
|
||||
public AnimatorOverrideController(AssetPreloadData preloadData)
|
||||
public AnimationClipOverride(ObjectReader reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
reader.Position = preloadData.Offset;
|
||||
m_OriginalClip = new PPtr<AnimationClip>(reader);
|
||||
m_OverrideClip = new PPtr<AnimationClip>(reader);
|
||||
}
|
||||
}
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
m_Controller = sourceFile.ReadPPtr();
|
||||
public sealed class AnimatorOverrideController : RuntimeAnimatorController
|
||||
{
|
||||
public PPtr<RuntimeAnimatorController> m_Controller;
|
||||
public AnimationClipOverride[] m_Clips;
|
||||
|
||||
public AnimatorOverrideController(ObjectReader reader) : base(reader)
|
||||
{
|
||||
m_Controller = new PPtr<RuntimeAnimatorController>(reader);
|
||||
|
||||
int numOverrides = reader.ReadInt32();
|
||||
m_Clips = new PPtr[numOverrides][];
|
||||
m_Clips = new AnimationClipOverride[numOverrides];
|
||||
for (int i = 0; i < numOverrides; i++)
|
||||
{
|
||||
m_Clips[i] = new PPtr[2];
|
||||
m_Clips[i][0] = sourceFile.ReadPPtr();
|
||||
m_Clips[i][1] = sourceFile.ReadPPtr();
|
||||
m_Clips[i] = new AnimationClipOverride(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,46 +5,39 @@ using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
|
||||
class AssetBundle
|
||||
public class AssetInfo
|
||||
{
|
||||
public class AssetInfo
|
||||
public int preloadIndex;
|
||||
public int preloadSize;
|
||||
public PPtr<Object> asset;
|
||||
|
||||
public AssetInfo(ObjectReader reader)
|
||||
{
|
||||
public int preloadIndex;
|
||||
public int preloadSize;
|
||||
public PPtr asset;
|
||||
preloadIndex = reader.ReadInt32();
|
||||
preloadSize = reader.ReadInt32();
|
||||
asset = new PPtr<Object>(reader);
|
||||
}
|
||||
}
|
||||
|
||||
public class ContainerData
|
||||
public sealed class AssetBundle : NamedObject
|
||||
{
|
||||
public PPtr<Object>[] m_PreloadTable;
|
||||
public KeyValuePair<string, AssetInfo>[] m_Container;
|
||||
|
||||
public AssetBundle(ObjectReader reader) : base(reader)
|
||||
{
|
||||
public string first;
|
||||
public AssetInfo second;
|
||||
}
|
||||
|
||||
|
||||
public List<ContainerData> m_Container = new List<ContainerData>();
|
||||
|
||||
public AssetBundle(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
var m_Name = reader.ReadAlignedString();
|
||||
var size = reader.ReadInt32();
|
||||
for (int i = 0; i < size; i++)
|
||||
var m_PreloadTableSize = reader.ReadInt32();
|
||||
m_PreloadTable = new PPtr<Object>[m_PreloadTableSize];
|
||||
for (int i = 0; i < m_PreloadTableSize; i++)
|
||||
{
|
||||
sourceFile.ReadPPtr();
|
||||
m_PreloadTable[i] = new PPtr<Object>(reader);
|
||||
}
|
||||
size = reader.ReadInt32();
|
||||
for (int i = 0; i < size; i++)
|
||||
|
||||
var m_ContainerSize = reader.ReadInt32();
|
||||
m_Container = new KeyValuePair<string, AssetInfo>[m_ContainerSize];
|
||||
for (int i = 0; i < m_ContainerSize; i++)
|
||||
{
|
||||
var temp = new ContainerData();
|
||||
temp.first = reader.ReadAlignedString();
|
||||
temp.second = new AssetInfo();
|
||||
temp.second.preloadIndex = reader.ReadInt32();
|
||||
temp.second.preloadSize = reader.ReadInt32();
|
||||
temp.second.asset = sourceFile.ReadPPtr();
|
||||
m_Container.Add(temp);
|
||||
m_Container[i] = new KeyValuePair<string, AssetInfo>(reader.ReadAlignedString(), new AssetInfo(reader));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,11 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class AudioClip
|
||||
public sealed class AudioClip : NamedObject
|
||||
{
|
||||
public string m_Name;
|
||||
public int m_Format;
|
||||
public AudioType m_Type;
|
||||
public bool m_3D;
|
||||
@@ -31,43 +29,27 @@ namespace AssetStudio
|
||||
public string m_Source;
|
||||
public long m_Offset;
|
||||
public long m_Size;
|
||||
public byte[] m_AudioData;
|
||||
public ResourceReader m_AudioData;
|
||||
|
||||
public bool version5;
|
||||
|
||||
public AudioClip(AssetPreloadData preloadData, bool readSwitch)
|
||||
public AudioClip(ObjectReader reader) : base(reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
if (version[0] < 5)
|
||||
{
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
version5 = sourceFile.version[0] >= 5;
|
||||
if (sourceFile.version[0] < 5)
|
||||
{
|
||||
|
||||
m_Format = reader.ReadInt32(); //channels?
|
||||
m_Format = reader.ReadInt32();
|
||||
m_Type = (AudioType)reader.ReadInt32();
|
||||
m_3D = reader.ReadBoolean();
|
||||
m_UseHardware = reader.ReadBoolean();
|
||||
reader.Position += 2; //4 byte alignment
|
||||
reader.AlignStream();
|
||||
|
||||
if (sourceFile.version[0] >= 4 || (sourceFile.version[0] == 3 && sourceFile.version[1] >= 2)) //3.2.0 to 5
|
||||
if (version[0] >= 4 || (version[0] == 3 && version[1] >= 2)) //3.2.0 to 5
|
||||
{
|
||||
int m_Stream = reader.ReadInt32();
|
||||
m_Size = reader.ReadInt32();
|
||||
var tsize = m_Size % 4 != 0 ? m_Size + 4 - m_Size % 4 : m_Size;
|
||||
//TODO: Need more test
|
||||
if (preloadData.Size + preloadData.Offset - reader.Position != tsize)
|
||||
if (reader.byteSize + reader.byteStart - reader.Position != tsize)
|
||||
{
|
||||
m_Offset = reader.ReadInt32();
|
||||
m_Source = sourceFile.filePath + ".resS";
|
||||
m_Source = assetsFile.fullName + ".resS";
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -77,19 +59,18 @@ namespace AssetStudio
|
||||
}
|
||||
else
|
||||
{
|
||||
m_LoadType = reader.ReadInt32(); //Decompress on load, Compressed in memory, Streaming
|
||||
m_LoadType = reader.ReadInt32();
|
||||
m_Channels = reader.ReadInt32();
|
||||
m_Frequency = reader.ReadInt32();
|
||||
m_BitsPerSample = reader.ReadInt32();
|
||||
m_Length = reader.ReadSingle();
|
||||
m_IsTrackerFormat = reader.ReadBoolean();
|
||||
reader.Position += 3;
|
||||
reader.AlignStream();
|
||||
m_SubsoundIndex = reader.ReadInt32();
|
||||
m_PreloadAudioData = reader.ReadBoolean();
|
||||
m_LoadInBackground = reader.ReadBoolean();
|
||||
m_Legacy3D = reader.ReadBoolean();
|
||||
reader.Position += 1;
|
||||
m_3D = m_Legacy3D;
|
||||
reader.AlignStream();
|
||||
|
||||
m_Source = reader.ReadAlignedString();
|
||||
m_Offset = reader.ReadInt64();
|
||||
@@ -97,207 +78,16 @@ namespace AssetStudio
|
||||
m_CompressionFormat = (AudioCompressionFormat)reader.ReadInt32();
|
||||
}
|
||||
|
||||
if (readSwitch)
|
||||
ResourceReader resourceReader;
|
||||
if (!string.IsNullOrEmpty(m_Source))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(m_Source))
|
||||
{
|
||||
var resourceFileName = Path.GetFileName(m_Source);
|
||||
var resourceFilePath = Path.GetDirectoryName(sourceFile.filePath) + "\\" + resourceFileName;
|
||||
if (!File.Exists(resourceFilePath))
|
||||
{
|
||||
var findFiles = Directory.GetFiles(Path.GetDirectoryName(sourceFile.filePath), resourceFileName, SearchOption.AllDirectories);
|
||||
if (findFiles.Length > 0)
|
||||
{
|
||||
resourceFilePath = findFiles[0];
|
||||
}
|
||||
}
|
||||
if (File.Exists(resourceFilePath))
|
||||
{
|
||||
using (var resourceReader = new BinaryReader(File.OpenRead(resourceFilePath)))
|
||||
{
|
||||
resourceReader.BaseStream.Position = m_Offset;
|
||||
m_AudioData = resourceReader.ReadBytes((int)m_Size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Studio.resourceFileReaders.TryGetValue(resourceFileName.ToUpper(), out var resourceReader))
|
||||
{
|
||||
resourceReader.Position = m_Offset;
|
||||
m_AudioData = resourceReader.ReadBytes((int)m_Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"can't find the resource file {resourceFileName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Size > 0)
|
||||
m_AudioData = reader.ReadBytes((int)m_Size);
|
||||
}
|
||||
resourceReader = new ResourceReader(m_Source, assetsFile, m_Offset, (int)m_Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
preloadData.InfoText = "Compression format: ";
|
||||
|
||||
if (sourceFile.version[0] < 5)
|
||||
{
|
||||
switch (m_Type)
|
||||
{
|
||||
case AudioType.ACC:
|
||||
preloadData.extension = ".m4a";
|
||||
preloadData.InfoText += "Acc";
|
||||
break;
|
||||
case AudioType.AIFF:
|
||||
preloadData.extension = ".aif";
|
||||
preloadData.InfoText += "AIFF";
|
||||
break;
|
||||
case AudioType.IT:
|
||||
preloadData.extension = ".it";
|
||||
preloadData.InfoText += "Impulse tracker";
|
||||
break;
|
||||
case AudioType.MOD:
|
||||
preloadData.extension = ".mod";
|
||||
preloadData.InfoText += "Protracker / Fasttracker MOD";
|
||||
break;
|
||||
case AudioType.MPEG:
|
||||
preloadData.extension = ".mp3";
|
||||
preloadData.InfoText += "MP2/MP3 MPEG";
|
||||
break;
|
||||
case AudioType.OGGVORBIS:
|
||||
preloadData.extension = ".ogg";
|
||||
preloadData.InfoText += "Ogg vorbis";
|
||||
break;
|
||||
case AudioType.S3M:
|
||||
preloadData.extension = ".s3m";
|
||||
preloadData.InfoText += "ScreamTracker 3";
|
||||
break;
|
||||
case AudioType.WAV:
|
||||
preloadData.extension = ".wav";
|
||||
preloadData.InfoText += "Microsoft WAV";
|
||||
break;
|
||||
case AudioType.XM:
|
||||
preloadData.extension = ".xm";
|
||||
preloadData.InfoText += "FastTracker 2 XM";
|
||||
break;
|
||||
case AudioType.XMA:
|
||||
preloadData.extension = ".wav";
|
||||
preloadData.InfoText += "Xbox360 XMA";
|
||||
break;
|
||||
case AudioType.VAG:
|
||||
preloadData.extension = ".vag";
|
||||
preloadData.InfoText += "PlayStation Portable ADPCM";
|
||||
break;
|
||||
case AudioType.AUDIOQUEUE:
|
||||
preloadData.extension = ".fsb";
|
||||
preloadData.InfoText += "iPhone";
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (m_CompressionFormat)
|
||||
{
|
||||
case AudioCompressionFormat.PCM:
|
||||
preloadData.extension = ".fsb";
|
||||
preloadData.InfoText += "PCM";
|
||||
break;
|
||||
case AudioCompressionFormat.Vorbis:
|
||||
preloadData.extension = ".fsb";
|
||||
preloadData.InfoText += "Vorbis";
|
||||
break;
|
||||
case AudioCompressionFormat.ADPCM:
|
||||
preloadData.extension = ".fsb";
|
||||
preloadData.InfoText += "ADPCM";
|
||||
break;
|
||||
case AudioCompressionFormat.MP3:
|
||||
preloadData.extension = ".fsb";
|
||||
preloadData.InfoText += "MP3";
|
||||
break;
|
||||
case AudioCompressionFormat.VAG:
|
||||
preloadData.extension = ".vag";
|
||||
preloadData.InfoText += "PlayStation Portable ADPCM";
|
||||
break;
|
||||
case AudioCompressionFormat.HEVAG:
|
||||
preloadData.extension = ".vag";
|
||||
preloadData.InfoText += "PSVita ADPCM";
|
||||
break;
|
||||
case AudioCompressionFormat.XMA:
|
||||
preloadData.extension = ".wav";
|
||||
preloadData.InfoText += "Xbox360 XMA";
|
||||
break;
|
||||
case AudioCompressionFormat.AAC:
|
||||
preloadData.extension = ".m4a";
|
||||
preloadData.InfoText += "AAC";
|
||||
break;
|
||||
case AudioCompressionFormat.GCADPCM:
|
||||
preloadData.extension = ".fsb";
|
||||
preloadData.InfoText += "Nintendo 3DS/Wii DSP";
|
||||
break;
|
||||
case AudioCompressionFormat.ATRAC9:
|
||||
preloadData.extension = ".at9";
|
||||
preloadData.InfoText += "PSVita ATRAC9";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (preloadData.extension == null)
|
||||
{
|
||||
preloadData.extension = ".AudioClip";
|
||||
preloadData.InfoText += "Unknown";
|
||||
}
|
||||
|
||||
preloadData.InfoText += "\n3D: " + m_3D;
|
||||
|
||||
preloadData.Text = m_Name;
|
||||
if (m_Source != null)
|
||||
preloadData.fullSize = preloadData.Size + (int)m_Size;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsFMODSupport
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!version5)
|
||||
{
|
||||
switch (m_Type)
|
||||
{
|
||||
case AudioType.AIFF:
|
||||
case AudioType.IT:
|
||||
case AudioType.MOD:
|
||||
case AudioType.S3M:
|
||||
case AudioType.XM:
|
||||
case AudioType.XMA:
|
||||
case AudioType.VAG:
|
||||
case AudioType.AUDIOQUEUE:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (m_CompressionFormat)
|
||||
{
|
||||
case AudioCompressionFormat.PCM:
|
||||
case AudioCompressionFormat.Vorbis:
|
||||
case AudioCompressionFormat.ADPCM:
|
||||
case AudioCompressionFormat.MP3:
|
||||
case AudioCompressionFormat.VAG:
|
||||
case AudioCompressionFormat.HEVAG:
|
||||
case AudioCompressionFormat.XMA:
|
||||
case AudioCompressionFormat.GCADPCM:
|
||||
case AudioCompressionFormat.ATRAC9:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
resourceReader = new ResourceReader(reader, reader.BaseStream.Position, (int)m_Size);
|
||||
}
|
||||
m_AudioData = resourceReader;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,251 +1,312 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class Avatar
|
||||
public class Node
|
||||
{
|
||||
public string m_Name;
|
||||
private List<KeyValuePair<uint, string>> m_TOS;
|
||||
public int m_ParentId;
|
||||
public int m_AxesId;
|
||||
|
||||
public Avatar(AssetPreloadData preloadData)
|
||||
public Node(ObjectReader reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var version = sourceFile.version;
|
||||
var reader = preloadData.InitReader();
|
||||
reader.Position = preloadData.Offset;
|
||||
m_ParentId = reader.ReadInt32();
|
||||
m_AxesId = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
var m_AvatarSize = reader.ReadUInt32();
|
||||
//AvatarConstant m_Avatar
|
||||
//- OffsetPtr m_AvatarSkeleton
|
||||
//-- Skeleton data
|
||||
//--- vector m_Node
|
||||
var numNodes = reader.ReadInt32();
|
||||
for (int i = 0; i < numNodes; i++)
|
||||
{
|
||||
reader.Position += 8;
|
||||
}
|
||||
//--- vector m_ID
|
||||
int numIDs = reader.ReadInt32();
|
||||
for (int i = 0; i < numIDs; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
//--- vector m_AxesArray
|
||||
int numAxes = reader.ReadInt32();
|
||||
for (int i = 0; i < numAxes; i++)
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 76;
|
||||
else
|
||||
reader.Position += 88;
|
||||
}
|
||||
//- OffsetPtr m_AvatarSkeletonPose
|
||||
//-- SkeletonPose data
|
||||
int numXforms = reader.ReadInt32();
|
||||
for (int i = 0; i < numXforms; i++)
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 40;
|
||||
else
|
||||
reader.Position += 48;
|
||||
}
|
||||
//- OffsetPtr m_DefaultPose
|
||||
//-- SkeletonPose data
|
||||
numXforms = reader.ReadInt32();
|
||||
for (int i = 0; i < numXforms; i++)
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 40;
|
||||
else
|
||||
reader.Position += 48;
|
||||
}
|
||||
//- vector m_SkeletonNameIDArray
|
||||
numIDs = reader.ReadInt32();
|
||||
for (int i = 0; i < numIDs; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
//- OffsetPtr m_Human
|
||||
//-- Human data
|
||||
//--- xform m_RootX
|
||||
public class Limit
|
||||
{
|
||||
public object m_Min;
|
||||
public object m_Max;
|
||||
|
||||
public Limit(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 40;
|
||||
{
|
||||
m_Min = reader.ReadVector3();
|
||||
m_Max = reader.ReadVector3();
|
||||
}
|
||||
else
|
||||
reader.Position += 48;
|
||||
//--- OffsetPtr m_Skeleton
|
||||
//---- Skeleton data
|
||||
numNodes = reader.ReadInt32();
|
||||
for (int i = 0; i < numNodes; i++)
|
||||
{
|
||||
reader.Position += 8;
|
||||
}
|
||||
//--- vector m_ID
|
||||
numIDs = reader.ReadInt32();
|
||||
for (int i = 0; i < numIDs; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
//--- vector m_AxesArray
|
||||
numAxes = reader.ReadInt32();
|
||||
for (int i = 0; i < numAxes; i++)
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 76;
|
||||
else
|
||||
reader.Position += 88;
|
||||
}
|
||||
//--- OffsetPtr m_SkeletonPose
|
||||
//---- SkeletonPose data
|
||||
numXforms = reader.ReadInt32();
|
||||
for (int i = 0; i < numXforms; i++)
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 40;
|
||||
else
|
||||
reader.Position += 48;
|
||||
}
|
||||
//--- OffsetPtr m_LeftHand
|
||||
//---- Hand data
|
||||
//----- staticvector m_HandBoneIndex
|
||||
int numIndexes = reader.ReadInt32();
|
||||
for (int i = 0; i < numIndexes; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
//--- OffsetPtr m_RightHand
|
||||
numIndexes = reader.ReadInt32();
|
||||
for (int i = 0; i < numIndexes; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
//--- vector m_Handles
|
||||
int numHandles = reader.ReadInt32();
|
||||
for (int i = 0; i < numHandles; i++)
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 48;
|
||||
else
|
||||
reader.Position += 56;
|
||||
}
|
||||
//--- vector m_ColliderArray
|
||||
int numColliders = reader.ReadInt32();
|
||||
for (int i = 0; i < numColliders; i++)
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 72;
|
||||
else
|
||||
reader.Position += 80;
|
||||
}
|
||||
//--- staticvector m_HumanBoneIndex
|
||||
numIndexes = reader.ReadInt32();
|
||||
for (int i = 0; i < numIndexes; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
//--- staticvector m_HumanBoneMass
|
||||
int numMasses = reader.ReadInt32();
|
||||
for (int i = 0; i < numMasses; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
//--- staticvector m_ColliderIndex
|
||||
int numColliderIndexes = reader.ReadInt32();
|
||||
for (int i = 0; i < numColliderIndexes; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
var m_Scale = reader.ReadSingle();
|
||||
var m_ArmTwist = reader.ReadSingle();
|
||||
var m_ForeArmTwist = reader.ReadSingle();
|
||||
var m_UpperLegTwist = reader.ReadSingle();
|
||||
var m_LegTwist = reader.ReadSingle();
|
||||
var m_ArmStretch = reader.ReadSingle();
|
||||
var m_LegStretch = reader.ReadSingle();
|
||||
var m_FeetSpacing = reader.ReadSingle();
|
||||
var m_HasLeftHand = reader.ReadBoolean();
|
||||
var m_HasRightHand = reader.ReadBoolean();
|
||||
var m_HasTDoF = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
//- vector m_HumanSkeletonIndexArray
|
||||
numIndexes = reader.ReadInt32();
|
||||
for (int i = 0; i < numIndexes; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
//- vector m_HumanSkeletonReverseIndexArray
|
||||
int numReverseIndexes = reader.ReadInt32();
|
||||
for (int i = 0; i < numReverseIndexes; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
var m_RootMotionBoneIndex = reader.ReadInt32();
|
||||
//- xform m_RootMotionBoneX
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 40;
|
||||
else
|
||||
reader.Position += 48;
|
||||
//- OffsetPtr m_RootMotionSkeleton
|
||||
//-- Skeleton data
|
||||
//--- vector m_Node
|
||||
numNodes = reader.ReadInt32();
|
||||
for (int i = 0; i < numNodes; i++)
|
||||
{
|
||||
reader.Position += 8;
|
||||
}
|
||||
//--- vector m_ID
|
||||
numIDs = reader.ReadInt32();
|
||||
for (int i = 0; i < numIDs; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
//--- vector m_AxesArray
|
||||
numAxes = reader.ReadInt32();
|
||||
for (int i = 0; i < numAxes; i++)
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 76;
|
||||
else
|
||||
reader.Position += 88;
|
||||
}
|
||||
//- OffsetPtr m_RootMotionSkeletonPose
|
||||
//-- SkeletonPose data
|
||||
numXforms = reader.ReadInt32();
|
||||
for (int i = 0; i < numXforms; i++)
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4))//5.4 and up
|
||||
reader.Position += 40;
|
||||
else
|
||||
reader.Position += 48;
|
||||
}
|
||||
//- vector m_RootMotionSkeletonIndexArray
|
||||
int numMotionIndexes = reader.ReadInt32();
|
||||
for (int i = 0; i < numMotionIndexes; i++)
|
||||
{
|
||||
reader.Position += 4;
|
||||
}
|
||||
//map m_TOS
|
||||
int numTOS = reader.ReadInt32();
|
||||
m_TOS = new List<KeyValuePair<uint, string>>(numTOS);
|
||||
for (int i = 0; i < numTOS; i++)
|
||||
{
|
||||
m_TOS.Add(new KeyValuePair<uint, string>(reader.ReadUInt32(), reader.ReadAlignedString()));
|
||||
m_Min = reader.ReadVector4();
|
||||
m_Max = reader.ReadVector4();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string FindBoneName(uint hash)
|
||||
public class Axes
|
||||
{
|
||||
public Vector4 m_PreQ;
|
||||
public Vector4 m_PostQ;
|
||||
public object m_Sgn;
|
||||
public Limit m_Limit;
|
||||
public float m_Length;
|
||||
public uint m_Type;
|
||||
|
||||
public Axes(ObjectReader reader)
|
||||
{
|
||||
foreach (var pair in m_TOS)
|
||||
var version = reader.version;
|
||||
m_PreQ = reader.ReadVector4();
|
||||
m_PostQ = reader.ReadVector4();
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4)) //5.4 and up
|
||||
{
|
||||
if (pair.Key == hash)
|
||||
m_Sgn = reader.ReadVector3();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Sgn = reader.ReadVector4();
|
||||
}
|
||||
m_Limit = new Limit(reader);
|
||||
m_Length = reader.ReadSingle();
|
||||
m_Type = reader.ReadUInt32();
|
||||
}
|
||||
}
|
||||
|
||||
public class Skeleton
|
||||
{
|
||||
public Node[] m_Node;
|
||||
public uint[] m_ID;
|
||||
public Axes[] m_AxesArray;
|
||||
|
||||
|
||||
public Skeleton(ObjectReader reader)
|
||||
{
|
||||
int numNodes = reader.ReadInt32();
|
||||
m_Node = new Node[numNodes];
|
||||
for (int i = 0; i < numNodes; i++)
|
||||
{
|
||||
m_Node[i] = new Node(reader);
|
||||
}
|
||||
|
||||
m_ID = reader.ReadUInt32Array();
|
||||
|
||||
int numAxes = reader.ReadInt32();
|
||||
m_AxesArray = new Axes[numAxes];
|
||||
for (int i = 0; i < numAxes; i++)
|
||||
{
|
||||
m_AxesArray[i] = new Axes(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SkeletonPose
|
||||
{
|
||||
public xform[] m_X;
|
||||
|
||||
public SkeletonPose(ObjectReader reader)
|
||||
{
|
||||
int numXforms = reader.ReadInt32();
|
||||
m_X = new xform[numXforms];
|
||||
for (int i = 0; i < numXforms; i++)
|
||||
{
|
||||
m_X[i] = new xform(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Hand
|
||||
{
|
||||
public int[] m_HandBoneIndex;
|
||||
|
||||
public Hand(ObjectReader reader)
|
||||
{
|
||||
m_HandBoneIndex = reader.ReadInt32Array();
|
||||
}
|
||||
}
|
||||
|
||||
public class Handle
|
||||
{
|
||||
public xform m_X;
|
||||
public uint m_ParentHumanIndex;
|
||||
public uint m_ID;
|
||||
|
||||
public Handle(ObjectReader reader)
|
||||
{
|
||||
m_X = new xform(reader);
|
||||
m_ParentHumanIndex = reader.ReadUInt32();
|
||||
m_ID = reader.ReadUInt32();
|
||||
}
|
||||
}
|
||||
|
||||
public class Collider
|
||||
{
|
||||
public xform m_X;
|
||||
public uint m_Type;
|
||||
public uint m_XMotionType;
|
||||
public uint m_YMotionType;
|
||||
public uint m_ZMotionType;
|
||||
public float m_MinLimitX;
|
||||
public float m_MaxLimitX;
|
||||
public float m_MaxLimitY;
|
||||
public float m_MaxLimitZ;
|
||||
|
||||
public Collider(ObjectReader reader)
|
||||
{
|
||||
m_X = new xform(reader);
|
||||
m_Type = reader.ReadUInt32();
|
||||
m_XMotionType = reader.ReadUInt32();
|
||||
m_YMotionType = reader.ReadUInt32();
|
||||
m_ZMotionType = reader.ReadUInt32();
|
||||
m_MinLimitX = reader.ReadSingle();
|
||||
m_MaxLimitX = reader.ReadSingle();
|
||||
m_MaxLimitY = reader.ReadSingle();
|
||||
m_MaxLimitZ = reader.ReadSingle();
|
||||
}
|
||||
}
|
||||
|
||||
public class Human
|
||||
{
|
||||
public xform m_RootX;
|
||||
public Skeleton m_Skeleton;
|
||||
public SkeletonPose m_SkeletonPose;
|
||||
public Hand m_LeftHand;
|
||||
public Hand m_RightHand;
|
||||
public Handle[] m_Handles;
|
||||
public Collider[] m_ColliderArray;
|
||||
public int[] m_HumanBoneIndex;
|
||||
public float[] m_HumanBoneMass;
|
||||
public int[] m_ColliderIndex;
|
||||
public float m_Scale;
|
||||
public float m_ArmTwist;
|
||||
public float m_ForeArmTwist;
|
||||
public float m_UpperLegTwist;
|
||||
public float m_LegTwist;
|
||||
public float m_ArmStretch;
|
||||
public float m_LegStretch;
|
||||
public float m_FeetSpacing;
|
||||
public bool m_HasLeftHand;
|
||||
public bool m_HasRightHand;
|
||||
public bool m_HasTDoF;
|
||||
|
||||
public Human(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
m_RootX = new xform(reader);
|
||||
m_Skeleton = new Skeleton(reader);
|
||||
m_SkeletonPose = new SkeletonPose(reader);
|
||||
m_LeftHand = new Hand(reader);
|
||||
m_RightHand = new Hand(reader);
|
||||
|
||||
if (version[0] < 2018 || (version[0] == 2018 && version[1] < 2)) //2018.2 down
|
||||
{
|
||||
int numHandles = reader.ReadInt32();
|
||||
m_Handles = new Handle[numHandles];
|
||||
for (int i = 0; i < numHandles; i++)
|
||||
{
|
||||
return pair.Value.Substring(pair.Value.LastIndexOf('/') + 1);
|
||||
m_Handles[i] = new Handle(reader);
|
||||
}
|
||||
|
||||
int numColliders = reader.ReadInt32();
|
||||
m_ColliderArray = new Collider[numColliders];
|
||||
for (int i = 0; i < numColliders; i++)
|
||||
{
|
||||
m_ColliderArray[i] = new Collider(reader);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
m_HumanBoneIndex = reader.ReadInt32Array();
|
||||
|
||||
m_HumanBoneMass = reader.ReadSingleArray();
|
||||
|
||||
if (version[0] < 2018 || (version[0] == 2018 && version[1] < 2)) //2018.2 down
|
||||
{
|
||||
m_ColliderIndex = reader.ReadInt32Array();
|
||||
}
|
||||
|
||||
m_Scale = reader.ReadSingle();
|
||||
m_ArmTwist = reader.ReadSingle();
|
||||
m_ForeArmTwist = reader.ReadSingle();
|
||||
m_UpperLegTwist = reader.ReadSingle();
|
||||
m_LegTwist = reader.ReadSingle();
|
||||
m_ArmStretch = reader.ReadSingle();
|
||||
m_LegStretch = reader.ReadSingle();
|
||||
m_FeetSpacing = reader.ReadSingle();
|
||||
m_HasLeftHand = reader.ReadBoolean();
|
||||
m_HasRightHand = reader.ReadBoolean();
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 2)) //5.2 and up
|
||||
{
|
||||
m_HasTDoF = reader.ReadBoolean();
|
||||
}
|
||||
reader.AlignStream();
|
||||
}
|
||||
}
|
||||
|
||||
public class AvatarConstant
|
||||
{
|
||||
public Skeleton m_AvatarSkeleton;
|
||||
public SkeletonPose m_AvatarSkeletonPose;
|
||||
public SkeletonPose m_DefaultPose;
|
||||
public uint[] m_SkeletonNameIDArray;
|
||||
public Human m_Human;
|
||||
public int[] m_HumanSkeletonIndexArray;
|
||||
public int[] m_HumanSkeletonReverseIndexArray;
|
||||
public int m_RootMotionBoneIndex;
|
||||
public xform m_RootMotionBoneX;
|
||||
public Skeleton m_RootMotionSkeleton;
|
||||
public SkeletonPose m_RootMotionSkeletonPose;
|
||||
public int[] m_RootMotionSkeletonIndexArray;
|
||||
|
||||
public AvatarConstant(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
m_AvatarSkeleton = new Skeleton(reader);
|
||||
m_AvatarSkeletonPose = new SkeletonPose(reader);
|
||||
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3 and up
|
||||
{
|
||||
m_DefaultPose = new SkeletonPose(reader);
|
||||
|
||||
m_SkeletonNameIDArray = reader.ReadUInt32Array();
|
||||
}
|
||||
|
||||
m_Human = new Human(reader);
|
||||
|
||||
m_HumanSkeletonIndexArray = reader.ReadInt32Array();
|
||||
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3 and up
|
||||
{
|
||||
m_HumanSkeletonReverseIndexArray = reader.ReadInt32Array();
|
||||
}
|
||||
|
||||
m_RootMotionBoneIndex = reader.ReadInt32();
|
||||
m_RootMotionBoneX = new xform(reader);
|
||||
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3 and up
|
||||
{
|
||||
m_RootMotionSkeleton = new Skeleton(reader);
|
||||
m_RootMotionSkeletonPose = new SkeletonPose(reader);
|
||||
|
||||
m_RootMotionSkeletonIndexArray = reader.ReadInt32Array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class Avatar : NamedObject
|
||||
{
|
||||
public uint m_AvatarSize;
|
||||
public AvatarConstant m_Avatar;
|
||||
public KeyValuePair<uint, string>[] m_TOS;
|
||||
|
||||
public Avatar(ObjectReader reader) : base(reader)
|
||||
{
|
||||
m_AvatarSize = reader.ReadUInt32();
|
||||
m_Avatar = new AvatarConstant(reader);
|
||||
|
||||
int numTOS = reader.ReadInt32();
|
||||
m_TOS = new KeyValuePair<uint, string>[numTOS];
|
||||
for (int i = 0; i < numTOS; i++)
|
||||
{
|
||||
m_TOS[i] = new KeyValuePair<uint, string>(reader.ReadUInt32(), reader.ReadAlignedString());
|
||||
}
|
||||
|
||||
//HumanDescription m_HumanDescription 2019 and up
|
||||
}
|
||||
|
||||
public string FindBonePath(uint hash)
|
||||
{
|
||||
return m_TOS.FirstOrDefault(pair => pair.Key == hash).Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
18
AssetStudio/Classes/Behaviour.cs
Normal file
18
AssetStudio/Classes/Behaviour.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public abstract class Behaviour : Component
|
||||
{
|
||||
public byte m_Enabled;
|
||||
|
||||
protected Behaviour(ObjectReader reader) : base(reader)
|
||||
{
|
||||
m_Enabled = reader.ReadByte();
|
||||
reader.AlignStream();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,31 +5,18 @@ using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class BuildSettings
|
||||
public sealed class BuildSettings : Object
|
||||
{
|
||||
public string m_Version;
|
||||
|
||||
public BuildSettings(AssetPreloadData preloadData)
|
||||
public BuildSettings(ObjectReader reader) : base(reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
var levels = reader.ReadStringArray();
|
||||
|
||||
int levels = reader.ReadInt32();
|
||||
for (int l = 0; l < levels; l++) { string level = reader.ReadAlignedString(); }
|
||||
|
||||
if (sourceFile.version[0] == 5)
|
||||
{
|
||||
int preloadedPlugins = reader.ReadInt32();
|
||||
for (int l = 0; l < preloadedPlugins; l++) { string preloadedPlugin = reader.ReadAlignedString(); }
|
||||
}
|
||||
|
||||
reader.Position += 4; //bool flags
|
||||
if (sourceFile.fileGen >= 8) { reader.Position += 4; } //bool flags
|
||||
if (sourceFile.fileGen >= 9) { reader.Position += 4; } //bool flags
|
||||
if (sourceFile.version[0] == 5 ||
|
||||
(sourceFile.version[0] == 4 && (sourceFile.version[1] >= 3 ||
|
||||
(sourceFile.version[1] == 2 && sourceFile.buildType[0] != "a"))))
|
||||
{ reader.Position += 4; } //bool flags
|
||||
var hasRenderTexture = reader.ReadBoolean();
|
||||
var hasPROVersion = reader.ReadBoolean();
|
||||
var hasPublishingRights = reader.ReadBoolean();
|
||||
var hasShadows = reader.ReadBoolean();
|
||||
|
||||
m_Version = reader.ReadAlignedString();
|
||||
}
|
||||
|
||||
17
AssetStudio/Classes/Component.cs
Normal file
17
AssetStudio/Classes/Component.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public abstract class Component : EditorExtension
|
||||
{
|
||||
public PPtr<GameObject> m_GameObject;
|
||||
|
||||
protected Component(ObjectReader reader) : base(reader)
|
||||
{
|
||||
m_GameObject = new PPtr<GameObject>(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
AssetStudio/Classes/EditorExtension.cs
Normal file
19
AssetStudio/Classes/EditorExtension.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public abstract class EditorExtension : Object
|
||||
{
|
||||
protected EditorExtension(ObjectReader reader) : base(reader)
|
||||
{
|
||||
if (platform == BuildTarget.NoTarget)
|
||||
{
|
||||
var m_PrefabParentObject = new PPtr<EditorExtension>(reader);
|
||||
var m_PrefabInternal = new PPtr<Object>(reader); //PPtr<Prefab>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,185 +5,116 @@ using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class UFont
|
||||
public sealed class Font : NamedObject
|
||||
{
|
||||
public string m_Name;
|
||||
public byte[] m_FontData;
|
||||
|
||||
public UFont(AssetPreloadData preloadData, bool readSwitch)
|
||||
public Font(ObjectReader reader) : base(reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
if ((version[0] == 5 && version[1] >= 5) || version[0] > 5)//5.5 and up
|
||||
{
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
|
||||
if (readSwitch)
|
||||
{
|
||||
if ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 5) || sourceFile.version[0] > 5)
|
||||
var m_LineSpacing = reader.ReadSingle();
|
||||
var m_DefaultMaterial = new PPtr<Material>(reader);
|
||||
var m_FontSize = reader.ReadSingle();
|
||||
var m_Texture = new PPtr<Texture>(reader);
|
||||
int m_AsciiStartOffset = reader.ReadInt32();
|
||||
var m_Tracking = reader.ReadSingle();
|
||||
var m_CharacterSpacing = reader.ReadInt32();
|
||||
var m_CharacterPadding = reader.ReadInt32();
|
||||
var m_ConvertCase = reader.ReadInt32();
|
||||
int m_CharacterRects_size = reader.ReadInt32();
|
||||
for (int i = 0; i < m_CharacterRects_size; i++)
|
||||
{
|
||||
var m_LineSpacing = reader.ReadSingle();
|
||||
var m_DefaultMaterial = sourceFile.ReadPPtr();
|
||||
var m_FontSize = reader.ReadSingle();
|
||||
var m_Texture = sourceFile.ReadPPtr();
|
||||
int m_AsciiStartOffset = reader.ReadInt32();
|
||||
var m_Tracking = reader.ReadSingle();
|
||||
var m_CharacterSpacing = reader.ReadInt32();
|
||||
var m_CharacterPadding = reader.ReadInt32();
|
||||
var m_ConvertCase = reader.ReadInt32();
|
||||
int m_CharacterRects_size = reader.ReadInt32();
|
||||
for (int i = 0; i < m_CharacterRects_size; i++)
|
||||
{
|
||||
int index = reader.ReadInt32();
|
||||
//Rectf uv
|
||||
float uvx = reader.ReadSingle();
|
||||
float uvy = reader.ReadSingle();
|
||||
float uvwidth = reader.ReadSingle();
|
||||
float uvheight = reader.ReadSingle();
|
||||
//Rectf vert
|
||||
float vertx = reader.ReadSingle();
|
||||
float verty = reader.ReadSingle();
|
||||
float vertwidth = reader.ReadSingle();
|
||||
float vertheight = reader.ReadSingle();
|
||||
float width = reader.ReadSingle();
|
||||
|
||||
if (sourceFile.version[0] >= 4)
|
||||
{
|
||||
bool flipped = reader.ReadBoolean();
|
||||
reader.Position += 3;
|
||||
}
|
||||
}
|
||||
int m_KerningValues_size = reader.ReadInt32();
|
||||
for (int i = 0; i < m_KerningValues_size; i++)
|
||||
{
|
||||
int pairfirst = reader.ReadInt16();
|
||||
int pairsecond = reader.ReadInt16();
|
||||
float second = reader.ReadSingle();
|
||||
}
|
||||
var m_PixelScale = reader.ReadSingle();
|
||||
int m_FontData_size = reader.ReadInt32();
|
||||
if (m_FontData_size > 0)
|
||||
{
|
||||
m_FontData = reader.ReadBytes(m_FontData_size);
|
||||
|
||||
if (m_FontData[0] == 79 && m_FontData[1] == 84 && m_FontData[2] == 84 && m_FontData[3] == 79)
|
||||
{ preloadData.extension = ".otf"; }
|
||||
else { preloadData.extension = ".ttf"; }
|
||||
}
|
||||
reader.Position += 44;//CharacterInfo data 41
|
||||
}
|
||||
else
|
||||
int m_KerningValues_size = reader.ReadInt32();
|
||||
for (int i = 0; i < m_KerningValues_size; i++)
|
||||
{
|
||||
int m_AsciiStartOffset = reader.ReadInt32();
|
||||
|
||||
if (sourceFile.version[0] <= 3)
|
||||
{
|
||||
int m_FontCountX = reader.ReadInt32();
|
||||
int m_FontCountY = reader.ReadInt32();
|
||||
}
|
||||
|
||||
float m_Kerning = reader.ReadSingle();
|
||||
float m_LineSpacing = reader.ReadSingle();
|
||||
|
||||
if (sourceFile.version[0] <= 3)
|
||||
{
|
||||
int m_PerCharacterKerning_size = reader.ReadInt32();
|
||||
for (int i = 0; i < m_PerCharacterKerning_size; i++)
|
||||
{
|
||||
int first = reader.ReadInt32();
|
||||
float second = reader.ReadSingle();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int m_CharacterSpacing = reader.ReadInt32();
|
||||
int m_CharacterPadding = reader.ReadInt32();
|
||||
}
|
||||
|
||||
int m_ConvertCase = reader.ReadInt32();
|
||||
PPtr m_DefaultMaterial = sourceFile.ReadPPtr();
|
||||
|
||||
int m_CharacterRects_size = reader.ReadInt32();
|
||||
for (int i = 0; i < m_CharacterRects_size; i++)
|
||||
{
|
||||
int index = reader.ReadInt32();
|
||||
//Rectf uv
|
||||
float uvx = reader.ReadSingle();
|
||||
float uvy = reader.ReadSingle();
|
||||
float uvwidth = reader.ReadSingle();
|
||||
float uvheight = reader.ReadSingle();
|
||||
//Rectf vert
|
||||
float vertx = reader.ReadSingle();
|
||||
float verty = reader.ReadSingle();
|
||||
float vertwidth = reader.ReadSingle();
|
||||
float vertheight = reader.ReadSingle();
|
||||
float width = reader.ReadSingle();
|
||||
|
||||
if (sourceFile.version[0] >= 4)
|
||||
{
|
||||
bool flipped = reader.ReadBoolean();
|
||||
reader.Position += 3;
|
||||
}
|
||||
}
|
||||
|
||||
PPtr m_Texture = sourceFile.ReadPPtr();
|
||||
|
||||
int m_KerningValues_size = reader.ReadInt32();
|
||||
for (int i = 0; i < m_KerningValues_size; i++)
|
||||
{
|
||||
int pairfirst = reader.ReadInt16();
|
||||
int pairsecond = reader.ReadInt16();
|
||||
float second = reader.ReadSingle();
|
||||
}
|
||||
|
||||
if (sourceFile.version[0] <= 3)
|
||||
{
|
||||
bool m_GridFont = reader.ReadBoolean();
|
||||
reader.Position += 3; //4 byte alignment
|
||||
}
|
||||
else { float m_PixelScale = reader.ReadSingle(); }
|
||||
|
||||
int m_FontData_size = reader.ReadInt32();
|
||||
if (m_FontData_size > 0)
|
||||
{
|
||||
m_FontData = reader.ReadBytes(m_FontData_size);
|
||||
|
||||
if (m_FontData[0] == 79 && m_FontData[1] == 84 && m_FontData[2] == 84 && m_FontData[3] == 79)
|
||||
{ preloadData.extension = ".otf"; }
|
||||
else { preloadData.extension = ".ttf"; }
|
||||
|
||||
}
|
||||
|
||||
float m_FontSize = reader.ReadSingle();//problem here in minifootball
|
||||
float m_Ascent = reader.ReadSingle();
|
||||
uint m_DefaultStyle = reader.ReadUInt32();
|
||||
|
||||
int m_FontNames = reader.ReadInt32();
|
||||
for (int i = 0; i < m_FontNames; i++)
|
||||
{
|
||||
string m_FontName = reader.ReadAlignedString();
|
||||
}
|
||||
|
||||
if (sourceFile.version[0] >= 4)
|
||||
{
|
||||
int m_FallbackFonts = reader.ReadInt32();
|
||||
for (int i = 0; i < m_FallbackFonts; i++)
|
||||
{
|
||||
PPtr m_FallbackFont = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
int m_FontRenderingMode = reader.ReadInt32();
|
||||
}
|
||||
reader.Position += 8;
|
||||
}
|
||||
var m_PixelScale = reader.ReadSingle();
|
||||
int m_FontData_size = reader.ReadInt32();
|
||||
if (m_FontData_size > 0)
|
||||
{
|
||||
m_FontData = reader.ReadBytes(m_FontData_size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
preloadData.Text = m_Name;
|
||||
int m_AsciiStartOffset = reader.ReadInt32();
|
||||
|
||||
if (version[0] <= 3)
|
||||
{
|
||||
int m_FontCountX = reader.ReadInt32();
|
||||
int m_FontCountY = reader.ReadInt32();
|
||||
}
|
||||
|
||||
float m_Kerning = reader.ReadSingle();
|
||||
float m_LineSpacing = reader.ReadSingle();
|
||||
|
||||
if (version[0] <= 3)
|
||||
{
|
||||
int m_PerCharacterKerning_size = reader.ReadInt32();
|
||||
for (int i = 0; i < m_PerCharacterKerning_size; i++)
|
||||
{
|
||||
int first = reader.ReadInt32();
|
||||
float second = reader.ReadSingle();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int m_CharacterSpacing = reader.ReadInt32();
|
||||
int m_CharacterPadding = reader.ReadInt32();
|
||||
}
|
||||
|
||||
int m_ConvertCase = reader.ReadInt32();
|
||||
var m_DefaultMaterial = new PPtr<Material>(reader);
|
||||
|
||||
int m_CharacterRects_size = reader.ReadInt32();
|
||||
for (int i = 0; i < m_CharacterRects_size; i++)
|
||||
{
|
||||
int index = reader.ReadInt32();
|
||||
//Rectf uv
|
||||
float uvx = reader.ReadSingle();
|
||||
float uvy = reader.ReadSingle();
|
||||
float uvwidth = reader.ReadSingle();
|
||||
float uvheight = reader.ReadSingle();
|
||||
//Rectf vert
|
||||
float vertx = reader.ReadSingle();
|
||||
float verty = reader.ReadSingle();
|
||||
float vertwidth = reader.ReadSingle();
|
||||
float vertheight = reader.ReadSingle();
|
||||
float width = reader.ReadSingle();
|
||||
|
||||
if (version[0] >= 4)
|
||||
{
|
||||
var flipped = reader.ReadBoolean();
|
||||
reader.AlignStream();
|
||||
}
|
||||
}
|
||||
|
||||
var m_Texture = new PPtr<Texture>(reader);
|
||||
|
||||
int m_KerningValues_size = reader.ReadInt32();
|
||||
for (int i = 0; i < m_KerningValues_size; i++)
|
||||
{
|
||||
int pairfirst = reader.ReadInt16();
|
||||
int pairsecond = reader.ReadInt16();
|
||||
float second = reader.ReadSingle();
|
||||
}
|
||||
|
||||
if (version[0] <= 3)
|
||||
{
|
||||
var m_GridFont = reader.ReadBoolean();
|
||||
reader.AlignStream();
|
||||
}
|
||||
else { float m_PixelScale = reader.ReadSingle(); }
|
||||
|
||||
int m_FontData_size = reader.ReadInt32();
|
||||
if (m_FontData_size > 0)
|
||||
{
|
||||
m_FontData = reader.ReadBytes(m_FontData_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,67 +2,36 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class GameObject : TreeNode
|
||||
public sealed class GameObject : EditorExtension
|
||||
{
|
||||
public AssetPreloadData asset;
|
||||
public List<PPtr> m_Components = new List<PPtr>();
|
||||
public PPtr m_Transform;
|
||||
public PPtr m_MeshRenderer;
|
||||
public PPtr m_MeshFilter;
|
||||
public PPtr m_SkinnedMeshRenderer;
|
||||
public int m_Layer;
|
||||
public PPtr<Component>[] m_Components;
|
||||
public string m_Name;
|
||||
public ushort m_Tag;
|
||||
public bool m_IsActive;
|
||||
|
||||
public string uniqueID = "0";//this way file and folder TreeNodes will be treated as FBX scene
|
||||
public Transform m_Transform;
|
||||
public MeshRenderer m_MeshRenderer;
|
||||
public MeshFilter m_MeshFilter;
|
||||
public SkinnedMeshRenderer m_SkinnedMeshRenderer;
|
||||
public Animator m_Animator;
|
||||
public Animation m_Animation;
|
||||
|
||||
public GameObject(AssetPreloadData preloadData)
|
||||
public GameObject(ObjectReader reader) : base(reader)
|
||||
{
|
||||
if (preloadData != null)
|
||||
int m_Component_size = reader.ReadInt32();
|
||||
m_Components = new PPtr<Component>[m_Component_size];
|
||||
for (int i = 0; i < m_Component_size; i++)
|
||||
{
|
||||
asset = preloadData;
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
uniqueID = preloadData.uniqueID;
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
if ((version[0] == 5 && version[1] < 5) || version[0] < 5) //5.5 down
|
||||
{
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
int first = reader.ReadInt32();
|
||||
}
|
||||
|
||||
int m_Component_size = reader.ReadInt32();
|
||||
for (int j = 0; j < m_Component_size; j++)
|
||||
{
|
||||
if ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 5) || sourceFile.version[0] > 5)//5.5.0 and up
|
||||
{
|
||||
m_Components.Add(sourceFile.ReadPPtr());
|
||||
}
|
||||
else
|
||||
{
|
||||
int first = reader.ReadInt32();
|
||||
m_Components.Add(sourceFile.ReadPPtr());
|
||||
}
|
||||
}
|
||||
|
||||
m_Layer = reader.ReadInt32();
|
||||
m_Name = reader.ReadAlignedString();
|
||||
if (m_Name == "") { m_Name = "GameObject #" + uniqueID; }
|
||||
m_Tag = reader.ReadUInt16();
|
||||
m_IsActive = reader.ReadBoolean();
|
||||
|
||||
Text = m_Name;
|
||||
preloadData.Text = m_Name;
|
||||
//name should be unique
|
||||
Name = uniqueID;
|
||||
m_Components[i] = new PPtr<Component>(reader);
|
||||
}
|
||||
|
||||
var m_Layer = reader.ReadInt32();
|
||||
m_Name = reader.ReadAlignedString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,129 +1,100 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class TexEnv
|
||||
public class UnityTexEnv
|
||||
{
|
||||
public string name;
|
||||
public PPtr m_Texture;
|
||||
public float[] m_Scale;
|
||||
public float[] m_Offset;
|
||||
}
|
||||
public PPtr<Texture> m_Texture;
|
||||
public Vector2 m_Scale;
|
||||
public Vector2 m_Offset;
|
||||
|
||||
class strFloatPair
|
||||
{
|
||||
public string first;
|
||||
public float second;
|
||||
}
|
||||
|
||||
class strColorPair
|
||||
{
|
||||
public string first;
|
||||
public float[] second;
|
||||
}
|
||||
|
||||
class Material
|
||||
{
|
||||
public string m_Name;
|
||||
public PPtr m_Shader;
|
||||
public string[] m_ShaderKeywords;
|
||||
public int m_CustomRenderQueue;
|
||||
public TexEnv[] m_TexEnvs;
|
||||
public strFloatPair[] m_Floats;
|
||||
public strColorPair[] m_Colors;
|
||||
|
||||
public Material(AssetPreloadData preloadData)
|
||||
public UnityTexEnv(ObjectReader reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
m_Texture = new PPtr<Texture>(reader);
|
||||
m_Scale = reader.ReadVector2();
|
||||
m_Offset = reader.ReadVector2();
|
||||
}
|
||||
}
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
public class UnityPropertySheet
|
||||
{
|
||||
public KeyValuePair<string, UnityTexEnv>[] m_TexEnvs;
|
||||
public KeyValuePair<string, float>[] m_Floats;
|
||||
public KeyValuePair<string, Color>[] m_Colors;
|
||||
|
||||
public UnityPropertySheet(ObjectReader reader)
|
||||
{
|
||||
int m_TexEnvsSize = reader.ReadInt32();
|
||||
m_TexEnvs = new KeyValuePair<string, UnityTexEnv>[m_TexEnvsSize];
|
||||
for (int i = 0; i < m_TexEnvsSize; i++)
|
||||
{
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
m_TexEnvs[i] = new KeyValuePair<string, UnityTexEnv>(reader.ReadAlignedString(), new UnityTexEnv(reader));
|
||||
}
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
m_Shader = sourceFile.ReadPPtr();
|
||||
|
||||
if (sourceFile.version[0] == 4 && (sourceFile.version[1] >= 2 || (sourceFile.version[1] == 1 && sourceFile.buildType[0] != "a")))
|
||||
int m_FloatsSize = reader.ReadInt32();
|
||||
m_Floats = new KeyValuePair<string, float>[m_FloatsSize];
|
||||
for (int i = 0; i < m_FloatsSize; i++)
|
||||
{
|
||||
m_ShaderKeywords = new string[reader.ReadInt32()];
|
||||
for (int i = 0; i < m_ShaderKeywords.Length; i++)
|
||||
{
|
||||
m_ShaderKeywords[i] = reader.ReadAlignedString();
|
||||
}
|
||||
}
|
||||
else if (sourceFile.version[0] >= 5)//5.0 and up
|
||||
{
|
||||
m_ShaderKeywords = new[] { reader.ReadAlignedString() };
|
||||
uint m_LightmapFlags = reader.ReadUInt32();
|
||||
if (sourceFile.version[0] == 5 && sourceFile.version[1] >= 6 || sourceFile.version[0] > 5)//5.6.0 and up
|
||||
{
|
||||
var m_EnableInstancingVariants = reader.ReadBoolean();
|
||||
//var m_DoubleSidedGI = a_Stream.ReadBoolean();//2017.x
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
m_Floats[i] = new KeyValuePair<string, float>(reader.ReadAlignedString(), reader.ReadSingle());
|
||||
}
|
||||
|
||||
if (sourceFile.version[0] > 4 || sourceFile.version[0] == 4 && sourceFile.version[1] >= 3) { m_CustomRenderQueue = reader.ReadInt32(); }
|
||||
|
||||
if (sourceFile.version[0] == 5 && sourceFile.version[1] >= 1 || sourceFile.version[0] > 5)//5.1 and up
|
||||
int m_ColorsSize = reader.ReadInt32();
|
||||
m_Colors = new KeyValuePair<string, Color>[m_ColorsSize];
|
||||
for (int i = 0; i < m_ColorsSize; i++)
|
||||
{
|
||||
string[][] stringTagMap = new string[reader.ReadInt32()][];
|
||||
for (int i = 0; i < stringTagMap.Length; i++)
|
||||
{
|
||||
stringTagMap[i] = new[] { reader.ReadAlignedString(), reader.ReadAlignedString() };
|
||||
}
|
||||
}
|
||||
//disabledShaderPasses
|
||||
if ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 6) || sourceFile.version[0] > 5)//5.6.0 and up
|
||||
{
|
||||
var size = reader.ReadInt32();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
reader.ReadAlignedString();
|
||||
}
|
||||
}
|
||||
//m_SavedProperties
|
||||
m_TexEnvs = new TexEnv[reader.ReadInt32()];
|
||||
for (int i = 0; i < m_TexEnvs.Length; i++)
|
||||
{
|
||||
TexEnv m_TexEnv = new TexEnv()
|
||||
{
|
||||
name = reader.ReadAlignedString(),
|
||||
m_Texture = sourceFile.ReadPPtr(),
|
||||
m_Scale = new[] { reader.ReadSingle(), reader.ReadSingle() },
|
||||
m_Offset = new[] { reader.ReadSingle(), reader.ReadSingle() }
|
||||
};
|
||||
m_TexEnvs[i] = m_TexEnv;
|
||||
}
|
||||
|
||||
m_Floats = new strFloatPair[reader.ReadInt32()];
|
||||
for (int i = 0; i < m_Floats.Length; i++)
|
||||
{
|
||||
strFloatPair m_Float = new strFloatPair()
|
||||
{
|
||||
first = reader.ReadAlignedString(),
|
||||
second = reader.ReadSingle()
|
||||
};
|
||||
m_Floats[i] = m_Float;
|
||||
}
|
||||
|
||||
m_Colors = new strColorPair[reader.ReadInt32()];
|
||||
for (int i = 0; i < m_Colors.Length; i++)
|
||||
{
|
||||
strColorPair m_Color = new strColorPair()
|
||||
{
|
||||
first = reader.ReadAlignedString(),
|
||||
second = new[] { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() }
|
||||
};
|
||||
m_Colors[i] = m_Color;
|
||||
m_Colors[i] = new KeyValuePair<string, Color>(reader.ReadAlignedString(), reader.ReadColor4());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class Material : NamedObject
|
||||
{
|
||||
public PPtr<Shader> m_Shader;
|
||||
public UnityPropertySheet m_SavedProperties;
|
||||
|
||||
public Material(ObjectReader reader) : base(reader)
|
||||
{
|
||||
m_Shader = new PPtr<Shader>(reader);
|
||||
|
||||
if (version[0] == 4 && version[1] >= 1) //4.x
|
||||
{
|
||||
var m_ShaderKeywords = reader.ReadStringArray();
|
||||
}
|
||||
|
||||
if (version[0] >= 5) //5.0 and up
|
||||
{
|
||||
var m_ShaderKeywords = reader.ReadAlignedString();
|
||||
var m_LightmapFlags = reader.ReadUInt32();
|
||||
}
|
||||
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 6)) //5.6 and up
|
||||
{
|
||||
var m_EnableInstancingVariants = reader.ReadBoolean();
|
||||
//var m_DoubleSidedGI = a_Stream.ReadBoolean(); //2017 and up
|
||||
reader.AlignStream();
|
||||
}
|
||||
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3 and up
|
||||
{
|
||||
var m_CustomRenderQueue = reader.ReadInt32();
|
||||
}
|
||||
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 1)) //5.1 and up
|
||||
{
|
||||
var stringTagMapSize = reader.ReadInt32();
|
||||
for (int i = 0; i < stringTagMapSize; i++)
|
||||
{
|
||||
var first = reader.ReadAlignedString();
|
||||
var second = reader.ReadAlignedString();
|
||||
}
|
||||
}
|
||||
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 6)) //5.6 and up
|
||||
{
|
||||
var disabledShaderPasses = reader.ReadStringArray();
|
||||
}
|
||||
|
||||
m_SavedProperties = new UnityPropertySheet(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,26 +5,13 @@ using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class MeshFilter
|
||||
public sealed class MeshFilter : Component
|
||||
{
|
||||
public long preloadIndex;
|
||||
public PPtr m_GameObject = new PPtr();
|
||||
public PPtr m_Mesh = new PPtr();
|
||||
public PPtr<Mesh> m_Mesh;
|
||||
|
||||
public MeshFilter(AssetPreloadData preloadData)
|
||||
public MeshFilter(ObjectReader reader) : base(reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_GameObject = sourceFile.ReadPPtr();
|
||||
m_Mesh = sourceFile.ReadPPtr();
|
||||
m_Mesh = new PPtr<Mesh>(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,59 +5,10 @@ using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class MeshRenderer
|
||||
public sealed class MeshRenderer : Renderer
|
||||
{
|
||||
public PPtr m_GameObject;
|
||||
public bool m_Enabled;
|
||||
public byte m_CastShadows; //bool prior to version 5
|
||||
public bool m_ReceiveShadows;
|
||||
public ushort m_LightmapIndex;
|
||||
public ushort m_LightmapIndexDynamic;
|
||||
public PPtr[] m_Materials;
|
||||
|
||||
protected MeshRenderer() { }
|
||||
|
||||
public MeshRenderer(AssetPreloadData preloadData)
|
||||
public MeshRenderer(ObjectReader reader) : base(reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_GameObject = sourceFile.ReadPPtr();
|
||||
|
||||
if (sourceFile.version[0] < 5)
|
||||
{
|
||||
m_Enabled = reader.ReadBoolean();
|
||||
m_CastShadows = reader.ReadByte();
|
||||
m_ReceiveShadows = reader.ReadBoolean();
|
||||
m_LightmapIndex = reader.ReadByte();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Enabled = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
m_CastShadows = reader.ReadByte();
|
||||
m_ReceiveShadows = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
|
||||
m_LightmapIndex = reader.ReadUInt16();
|
||||
m_LightmapIndexDynamic = reader.ReadUInt16();
|
||||
}
|
||||
|
||||
if (sourceFile.version[0] >= 3) { reader.Position += 16; } //Vector4f m_LightmapTilingOffset
|
||||
if (sourceFile.version[0] >= 5) { reader.Position += 16; } //Vector4f m_LightmapTilingOffsetDynamic
|
||||
|
||||
m_Materials = new PPtr[reader.ReadInt32()];
|
||||
for (int m = 0; m < m_Materials.Length; m++)
|
||||
{
|
||||
m_Materials[m] = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,40 +5,15 @@ using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class MonoBehaviour
|
||||
public sealed class MonoBehaviour : Behaviour
|
||||
{
|
||||
public string serializedText;
|
||||
public PPtr<MonoScript> m_Script;
|
||||
public string m_Name;
|
||||
|
||||
public MonoBehaviour(AssetPreloadData preloadData, bool readSwitch)
|
||||
public MonoBehaviour(ObjectReader reader) : base(reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
var m_GameObject = sourceFile.ReadPPtr();
|
||||
var m_Enabled = reader.ReadByte();
|
||||
reader.AlignStream(4);
|
||||
var m_Script = sourceFile.ReadPPtr();
|
||||
var m_Name = reader.ReadAlignedString();
|
||||
if (readSwitch)
|
||||
{
|
||||
if ((serializedText = preloadData.ViewStruct()) == null)
|
||||
{
|
||||
var str = "PPtr<GameObject> m_GameObject\r\n";
|
||||
str += "\tint m_FileID = " + m_GameObject.m_FileID + "\r\n";
|
||||
str += "\tint64 m_PathID = " + m_GameObject.m_PathID + "\r\n";
|
||||
str += "UInt8 m_Enabled = " + m_Enabled + "\r\n";
|
||||
str += "PPtr<MonoScript> m_Script\r\n";
|
||||
str += "\tint m_FileID = " + m_Script.m_FileID + "\r\n";
|
||||
str += "\tint64 m_PathID = " + m_Script.m_PathID + "\r\n";
|
||||
str += "string m_Name = \"" + m_Name + "\"\r\n";
|
||||
serializedText = str;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
preloadData.extension = ".txt";
|
||||
preloadData.Text = m_Name;
|
||||
}
|
||||
m_Script = new PPtr<MonoScript>(reader);
|
||||
m_Name = reader.ReadAlignedString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
44
AssetStudio/Classes/MonoScript.cs
Normal file
44
AssetStudio/Classes/MonoScript.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public sealed class MonoScript : NamedObject
|
||||
{
|
||||
public string m_ClassName;
|
||||
public string m_Namespace = string.Empty;
|
||||
public string m_AssemblyName;
|
||||
|
||||
public MonoScript(ObjectReader reader) : base(reader)
|
||||
{
|
||||
if (version[0] > 3 || (version[0] == 3 && version[1] >= 4)) //3.4 and up
|
||||
{
|
||||
var m_ExecutionOrder = reader.ReadInt32();
|
||||
}
|
||||
if (version[0] < 5) //5.0 down
|
||||
{
|
||||
var m_PropertiesHash = reader.ReadUInt32();
|
||||
}
|
||||
else
|
||||
{
|
||||
var m_PropertiesHash = reader.ReadBytes(16);
|
||||
}
|
||||
if (version[0] < 3) //3.0 down
|
||||
{
|
||||
var m_PathName = reader.ReadAlignedString();
|
||||
}
|
||||
m_ClassName = reader.ReadAlignedString();
|
||||
if (version[0] >= 3) //3.0 and up
|
||||
{
|
||||
m_Namespace = reader.ReadAlignedString();
|
||||
}
|
||||
m_AssemblyName = reader.ReadAlignedString();
|
||||
if (version[0] < 2018 || (version[0] == 2018 && version[1] < 2)) //2018.2 down
|
||||
{
|
||||
var m_IsEditorScript = reader.ReadBoolean();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,32 +5,17 @@ using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class MovieTexture
|
||||
public sealed class MovieTexture : Texture
|
||||
{
|
||||
public string m_Name;
|
||||
public byte[] m_MovieData;
|
||||
public PPtr<AudioClip> m_AudioClip;
|
||||
|
||||
public MovieTexture(AssetPreloadData preloadData, bool readSwitch)
|
||||
public MovieTexture(ObjectReader reader) : base(reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
if (readSwitch)
|
||||
{
|
||||
var m_Loop = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
//PPtr<AudioClip>
|
||||
sourceFile.ReadPPtr();
|
||||
var size = reader.ReadInt32();
|
||||
m_MovieData = reader.ReadBytes(size);
|
||||
var m_ColorSpace = reader.ReadInt32();
|
||||
}
|
||||
else
|
||||
{
|
||||
preloadData.extension = ".ogv";
|
||||
preloadData.Text = m_Name;
|
||||
}
|
||||
var m_Loop = reader.ReadBoolean();
|
||||
reader.AlignStream();
|
||||
m_AudioClip = new PPtr<AudioClip>(reader);
|
||||
m_MovieData = reader.ReadBytes(reader.ReadInt32());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17
AssetStudio/Classes/NamedObject.cs
Normal file
17
AssetStudio/Classes/NamedObject.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class NamedObject : EditorExtension
|
||||
{
|
||||
public string m_Name;
|
||||
|
||||
protected NamedObject(ObjectReader reader) : base(reader)
|
||||
{
|
||||
m_Name = reader.ReadAlignedString();
|
||||
}
|
||||
}
|
||||
}
|
||||
62
AssetStudio/Classes/Object.cs
Normal file
62
AssetStudio/Classes/Object.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class Object
|
||||
{
|
||||
public SerializedFile assetsFile;
|
||||
public ObjectReader reader;
|
||||
public long m_PathID;
|
||||
public int[] version;
|
||||
protected BuildType buildType;
|
||||
public BuildTarget platform;
|
||||
public ClassIDType type;
|
||||
public SerializedType serializedType;
|
||||
public uint byteSize;
|
||||
|
||||
public Object(ObjectReader reader)
|
||||
{
|
||||
this.reader = reader;
|
||||
reader.Reset();
|
||||
assetsFile = reader.assetsFile;
|
||||
type = reader.type;
|
||||
m_PathID = reader.m_PathID;
|
||||
version = reader.version;
|
||||
buildType = reader.buildType;
|
||||
platform = reader.platform;
|
||||
serializedType = reader.serializedType;
|
||||
byteSize = reader.byteSize;
|
||||
|
||||
if (platform == BuildTarget.NoTarget)
|
||||
{
|
||||
var m_ObjectHideFlags = reader.ReadUInt32();
|
||||
}
|
||||
}
|
||||
|
||||
protected bool HasStructMember(string name)
|
||||
{
|
||||
return serializedType?.m_Nodes != null && serializedType.m_Nodes.Any(x => x.m_Name == name);
|
||||
}
|
||||
|
||||
public string Dump()
|
||||
{
|
||||
reader.Reset();
|
||||
if (serializedType?.m_Nodes != null)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
TypeTreeHelper.ReadTypeString(sb, serializedType.m_Nodes, reader);
|
||||
return sb.ToString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public byte[] GetRawData()
|
||||
{
|
||||
reader.Reset();
|
||||
return reader.ReadBytes((int)byteSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
131
AssetStudio/Classes/PPtr.cs
Normal file
131
AssetStudio/Classes/PPtr.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
using System;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public sealed class PPtr<T> where T : Object
|
||||
{
|
||||
public int m_FileID;
|
||||
public long m_PathID;
|
||||
|
||||
private SerializedFile assetsFile;
|
||||
private int index = -2; //-2 - Prepare, -1 - Missing
|
||||
|
||||
public PPtr(ObjectReader reader)
|
||||
{
|
||||
m_FileID = reader.ReadInt32();
|
||||
m_PathID = reader.m_Version < 14 ? reader.ReadInt32() : reader.ReadInt64();
|
||||
assetsFile = reader.assetsFile;
|
||||
}
|
||||
|
||||
private bool TryGetAssetsFile(out SerializedFile result)
|
||||
{
|
||||
result = null;
|
||||
if (m_FileID == 0)
|
||||
{
|
||||
result = assetsFile;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_FileID > 0 && m_FileID - 1 < assetsFile.m_Externals.Count)
|
||||
{
|
||||
var assetsManager = assetsFile.assetsManager;
|
||||
var assetsFileList = assetsManager.assetsFileList;
|
||||
var assetsFileIndexCache = assetsManager.assetsFileIndexCache;
|
||||
|
||||
if (index == -2)
|
||||
{
|
||||
var m_External = assetsFile.m_Externals[m_FileID - 1];
|
||||
var name = m_External.fileName;
|
||||
if (!assetsFileIndexCache.TryGetValue(name, out index))
|
||||
{
|
||||
index = assetsFileList.FindIndex(x => x.fileName.Equals(name, StringComparison.OrdinalIgnoreCase));
|
||||
assetsFileIndexCache.Add(name, index);
|
||||
}
|
||||
}
|
||||
|
||||
if (index >= 0)
|
||||
{
|
||||
result = assetsFileList[index];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGet(out T result)
|
||||
{
|
||||
if (TryGetAssetsFile(out var sourceFile))
|
||||
{
|
||||
if (sourceFile.ObjectsDic.TryGetValue(m_PathID, out var obj))
|
||||
{
|
||||
if (obj is T variable)
|
||||
{
|
||||
result = variable;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGet<T2>(out T2 result) where T2 : Object
|
||||
{
|
||||
if (TryGetAssetsFile(out var sourceFile))
|
||||
{
|
||||
if (sourceFile.ObjectsDic.TryGetValue(m_PathID, out var obj))
|
||||
{
|
||||
if (obj is T2 variable)
|
||||
{
|
||||
result = variable;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Set(T m_Object)
|
||||
{
|
||||
var name = m_Object.assetsFile.fileName;
|
||||
if (string.Equals(assetsFile.fileName, name, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
m_FileID = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_FileID = assetsFile.m_Externals.FindIndex(x => string.Equals(x.fileName, name, StringComparison.OrdinalIgnoreCase));
|
||||
if (m_FileID == -1)
|
||||
{
|
||||
assetsFile.m_Externals.Add(new FileIdentifier
|
||||
{
|
||||
fileName = m_Object.assetsFile.fileName
|
||||
});
|
||||
m_FileID = assetsFile.m_Externals.Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_FileID += 1;
|
||||
}
|
||||
}
|
||||
|
||||
var assetsManager = assetsFile.assetsManager;
|
||||
var assetsFileList = assetsManager.assetsFileList;
|
||||
var assetsFileIndexCache = assetsManager.assetsFileIndexCache;
|
||||
|
||||
if (!assetsFileIndexCache.TryGetValue(name, out index))
|
||||
{
|
||||
index = assetsFileList.FindIndex(x => x.fileName.Equals(name, StringComparison.OrdinalIgnoreCase));
|
||||
assetsFileIndexCache.Add(name, index);
|
||||
}
|
||||
|
||||
m_PathID = m_Object.m_PathID;
|
||||
}
|
||||
|
||||
public bool IsNull => m_PathID == 0 || m_FileID < 0;
|
||||
}
|
||||
}
|
||||
@@ -5,50 +5,45 @@ using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class PlayerSettings
|
||||
public sealed class PlayerSettings : Object
|
||||
{
|
||||
public string companyName;
|
||||
public string productName;
|
||||
|
||||
public PlayerSettings(AssetPreloadData preloadData)
|
||||
public PlayerSettings(ObjectReader reader) : base(reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
|
||||
if ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 4) || sourceFile.version[0] > 5)//5.4.0 nad up
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4)) //5.4.0 nad up
|
||||
{
|
||||
//productGUID
|
||||
reader.ReadInt32();
|
||||
reader.ReadInt32();
|
||||
reader.ReadInt32();
|
||||
reader.ReadInt32();
|
||||
var productGUID = reader.ReadBytes(16);
|
||||
}
|
||||
if (sourceFile.version[0] >= 3)
|
||||
|
||||
var AndroidProfiler = reader.ReadBoolean();
|
||||
//bool AndroidFilterTouchesWhenObscured 2017.2 and up
|
||||
//bool AndroidEnableSustainedPerformanceMode 2018 and up
|
||||
reader.AlignStream();
|
||||
int defaultScreenOrientation = reader.ReadInt32();
|
||||
int targetDevice = reader.ReadInt32();
|
||||
if (version[0] < 5 || (version[0] == 5 && version[1] < 3)) //5.3 down
|
||||
{
|
||||
if (sourceFile.version[0] == 3 && sourceFile.version[1] < 2) { string AndroidLicensePublicKey = reader.ReadAlignedString(); }
|
||||
else { bool AndroidProfiler = reader.ReadBoolean(); reader.AlignStream(4); }
|
||||
|
||||
int defaultScreenOrientation = reader.ReadInt32();
|
||||
int targetDevice = reader.ReadInt32();
|
||||
|
||||
if (sourceFile.version[0] < 5 || (sourceFile.version[0] == 5 && sourceFile.version[1] < 1))
|
||||
{ int targetGlesGraphics = reader.ReadInt32(); }
|
||||
|
||||
if ((sourceFile.version[0] == 5 && sourceFile.version[1] < 1) || (sourceFile.version[0] == 4 && sourceFile.version[1] == 6 && sourceFile.version[2] >= 3))
|
||||
{ int targetIOSGraphics = reader.ReadInt32(); }
|
||||
|
||||
if (sourceFile.version[0] >= 5 || sourceFile.version[0] == 5 && (sourceFile.version[1] > 2 || (sourceFile.version[1] == 2 && sourceFile.version[2] >= 1)))
|
||||
{ bool useOnDemandResources = reader.ReadBoolean(); reader.AlignStream(4); }
|
||||
|
||||
if (sourceFile.version[0] < 5 || (sourceFile.version[0] == 5 && sourceFile.version[1] < 3))
|
||||
{ int targetResolution = reader.ReadInt32(); }
|
||||
|
||||
if (sourceFile.version[0] == 3 && sourceFile.version[1] <= 1) { bool OverrideIPodMusic = reader.ReadBoolean(); reader.AlignStream(4); }
|
||||
else if (sourceFile.version[0] == 3 && sourceFile.version[1] <= 4) { }
|
||||
else { int accelerometerFrequency = reader.ReadInt32(); }//3.5.0 and up
|
||||
if (version[0] < 5) //5.0 down
|
||||
{
|
||||
int targetPlatform = reader.ReadInt32(); //4.0 and up targetGlesGraphics
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 6)) //4.6 and up
|
||||
{
|
||||
var targetIOSGraphics = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
int targetResolution = reader.ReadInt32();
|
||||
}
|
||||
else
|
||||
{
|
||||
var useOnDemandResources = reader.ReadBoolean();
|
||||
reader.AlignStream();
|
||||
}
|
||||
if (version[0] > 3 || (version[0] == 3 && version[1] >= 5)) //3.5 and up
|
||||
{
|
||||
var accelerometerFrequency = reader.ReadInt32();
|
||||
}
|
||||
//fail in version 5 beta
|
||||
companyName = reader.ReadAlignedString();
|
||||
productName = reader.ReadAlignedString();
|
||||
}
|
||||
|
||||
@@ -5,26 +5,10 @@ using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class RectTransform
|
||||
public sealed class RectTransform : Transform
|
||||
{
|
||||
public Transform m_Transform;
|
||||
|
||||
public RectTransform(AssetPreloadData preloadData)
|
||||
public RectTransform(ObjectReader reader) : base(reader)
|
||||
{
|
||||
m_Transform = new Transform(preloadData);
|
||||
|
||||
//var sourceFile = preloadData.sourceFile;
|
||||
//var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
|
||||
/*
|
||||
float[2] AnchorsMin
|
||||
float[2] AnchorsMax
|
||||
float[2] Pivod
|
||||
float Width
|
||||
float Height
|
||||
float[2] ?
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
148
AssetStudio/Classes/Renderer.cs
Normal file
148
AssetStudio/Classes/Renderer.cs
Normal file
@@ -0,0 +1,148 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class StaticBatchInfo
|
||||
{
|
||||
public ushort firstSubMesh;
|
||||
public ushort subMeshCount;
|
||||
|
||||
public StaticBatchInfo(ObjectReader reader)
|
||||
{
|
||||
firstSubMesh = reader.ReadUInt16();
|
||||
subMeshCount = reader.ReadUInt16();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class Renderer : Component
|
||||
{
|
||||
public PPtr<Material>[] m_Materials;
|
||||
public StaticBatchInfo m_StaticBatchInfo;
|
||||
public uint[] m_SubsetIndices;
|
||||
|
||||
protected Renderer(ObjectReader reader) : base(reader)
|
||||
{
|
||||
if (version[0] < 5) //5.0 down
|
||||
{
|
||||
var m_Enabled = reader.ReadBoolean();
|
||||
var m_CastShadows = reader.ReadBoolean();
|
||||
var m_ReceiveShadows = reader.ReadBoolean();
|
||||
var m_LightmapIndex = reader.ReadByte();
|
||||
}
|
||||
else //5.0 and up
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4)) //5.4 and up
|
||||
{
|
||||
var m_Enabled = reader.ReadBoolean();
|
||||
var m_CastShadows = reader.ReadByte();
|
||||
var m_ReceiveShadows = reader.ReadByte();
|
||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 2)) //2017.2 and up
|
||||
{
|
||||
var m_DynamicOccludee = reader.ReadByte();
|
||||
}
|
||||
var m_MotionVectors = reader.ReadByte();
|
||||
var m_LightProbeUsage = reader.ReadByte();
|
||||
var m_ReflectionProbeUsage = reader.ReadByte();
|
||||
if (version[0] > 2019 || (version[0] == 2019 && version[1] >= 3)) //2019.3 and up
|
||||
{
|
||||
var m_RayTracingMode = reader.ReadByte();
|
||||
}
|
||||
reader.AlignStream();
|
||||
}
|
||||
else
|
||||
{
|
||||
var m_Enabled = reader.ReadBoolean();
|
||||
reader.AlignStream();
|
||||
var m_CastShadows = reader.ReadByte();
|
||||
var m_ReceiveShadows = reader.ReadBoolean();
|
||||
reader.AlignStream();
|
||||
}
|
||||
|
||||
if (version[0] >= 2018) //2018 and up
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
if (version[0] >= 3) //3.0 and up
|
||||
{
|
||||
var m_LightmapTilingOffset = reader.ReadVector4();
|
||||
}
|
||||
|
||||
if (version[0] >= 5) //5.0 and up
|
||||
{
|
||||
var m_LightmapTilingOffsetDynamic = reader.ReadVector4();
|
||||
}
|
||||
|
||||
var m_MaterialsSize = reader.ReadInt32();
|
||||
m_Materials = new PPtr<Material>[m_MaterialsSize];
|
||||
for (int i = 0; i < m_MaterialsSize; i++)
|
||||
{
|
||||
m_Materials[i] = new PPtr<Material>(reader);
|
||||
}
|
||||
|
||||
if (version[0] < 3) //3.0 down
|
||||
{
|
||||
var m_LightmapTilingOffset = reader.ReadVector4();
|
||||
}
|
||||
else //3.0 and up
|
||||
{
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 5)) //5.5 and up
|
||||
{
|
||||
m_StaticBatchInfo = new StaticBatchInfo(reader);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_SubsetIndices = reader.ReadUInt32Array();
|
||||
}
|
||||
|
||||
var m_StaticBatchRoot = new PPtr<Transform>(reader);
|
||||
}
|
||||
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 4)) //5.4 and up
|
||||
{
|
||||
var m_ProbeAnchor = new PPtr<Transform>(reader);
|
||||
var m_LightProbeVolumeOverride = new PPtr<GameObject>(reader);
|
||||
}
|
||||
else if (version[0] > 3 || (version[0] == 3 && version[1] >= 5)) //3.5 - 5.3
|
||||
{
|
||||
var m_UseLightProbes = reader.ReadBoolean();
|
||||
reader.AlignStream();
|
||||
|
||||
if (version[0] >= 5)//5.0 and up
|
||||
{
|
||||
var m_ReflectionProbeUsage = reader.ReadInt32();
|
||||
}
|
||||
|
||||
var m_LightProbeAnchor = new PPtr<Transform>(reader); //5.0 and up m_ProbeAnchor
|
||||
}
|
||||
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3 and up
|
||||
{
|
||||
if (version[0] == 4 && version[1] == 3) //4.3
|
||||
{
|
||||
var m_SortingLayer = reader.ReadInt16();
|
||||
}
|
||||
else
|
||||
{
|
||||
var m_SortingLayerID = reader.ReadUInt32();
|
||||
}
|
||||
|
||||
//SInt16 m_SortingLayer 5.6 and up
|
||||
var m_SortingOrder = reader.ReadInt16();
|
||||
reader.AlignStream();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
15
AssetStudio/Classes/RuntimeAnimatorController.cs
Normal file
15
AssetStudio/Classes/RuntimeAnimatorController.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public abstract class RuntimeAnimatorController : NamedObject
|
||||
{
|
||||
protected RuntimeAnimatorController(ObjectReader reader) : base(reader)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,200 +2,793 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web.Script.Serialization;
|
||||
using Lz4;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class Shader
|
||||
public class StructParameter
|
||||
{
|
||||
public string m_Name;
|
||||
public byte[] m_Script;
|
||||
public MatrixParameter[] m_MatrixParams;
|
||||
public VectorParameter[] m_VectorParams;
|
||||
|
||||
public Shader(AssetPreloadData preloadData, bool readSwitch)
|
||||
public StructParameter(BinaryReader reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
var m_NameIndex = reader.ReadInt32();
|
||||
var m_Index = reader.ReadInt32();
|
||||
var m_ArraySize = reader.ReadInt32();
|
||||
var m_StructSize = reader.ReadInt32();
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
int numVectorParams = reader.ReadInt32();
|
||||
m_VectorParams = new VectorParameter[numVectorParams];
|
||||
for (int i = 0; i < numVectorParams; i++)
|
||||
{
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
m_VectorParams[i] = new VectorParameter(reader);
|
||||
}
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
|
||||
if (readSwitch)
|
||||
int numMatrixParams = reader.ReadInt32();
|
||||
m_MatrixParams = new MatrixParameter[numMatrixParams];
|
||||
for (int i = 0; i < numMatrixParams; i++)
|
||||
{
|
||||
if (sourceFile.version[0] == 5 && sourceFile.version[1] >= 5 || sourceFile.version[0] > 5)//5.5.0 and up
|
||||
m_MatrixParams[i] = new MatrixParameter(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SamplerParameter
|
||||
{
|
||||
public uint sampler;
|
||||
public int bindPoint;
|
||||
|
||||
public SamplerParameter(BinaryReader reader)
|
||||
{
|
||||
sampler = reader.ReadUInt32();
|
||||
bindPoint = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
public enum TextureDimension
|
||||
{
|
||||
kTexDimUnknown = -1,
|
||||
kTexDimNone = 0,
|
||||
kTexDimAny = 1,
|
||||
kTexDim2D = 2,
|
||||
kTexDim3D = 3,
|
||||
kTexDimCUBE = 4,
|
||||
kTexDim2DArray = 5,
|
||||
kTexDimCubeArray = 6,
|
||||
kTexDimForce32Bit = 2147483647
|
||||
};
|
||||
|
||||
public class SerializedTextureProperty
|
||||
{
|
||||
public string m_DefaultName;
|
||||
public TextureDimension m_TexDim;
|
||||
|
||||
public SerializedTextureProperty(BinaryReader reader)
|
||||
{
|
||||
m_DefaultName = reader.ReadAlignedString();
|
||||
m_TexDim = (TextureDimension)reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
|
||||
public enum SerializedPropertyType
|
||||
{
|
||||
kColor = 0,
|
||||
kVector = 1,
|
||||
kFloat = 2,
|
||||
kRange = 3,
|
||||
kTexture = 4
|
||||
};
|
||||
|
||||
public class SerializedProperty
|
||||
{
|
||||
public string m_Name;
|
||||
public string m_Description;
|
||||
public string[] m_Attributes;
|
||||
public SerializedPropertyType m_Type;
|
||||
public uint m_Flags;
|
||||
public float[] m_DefValue;
|
||||
public SerializedTextureProperty m_DefTexture;
|
||||
|
||||
public SerializedProperty(BinaryReader reader)
|
||||
{
|
||||
m_Name = reader.ReadAlignedString();
|
||||
m_Description = reader.ReadAlignedString();
|
||||
m_Attributes = reader.ReadStringArray();
|
||||
m_Type = (SerializedPropertyType)reader.ReadInt32();
|
||||
m_Flags = reader.ReadUInt32();
|
||||
m_DefValue = reader.ReadSingleArray(4);
|
||||
m_DefTexture = new SerializedTextureProperty(reader);
|
||||
}
|
||||
}
|
||||
|
||||
public class SerializedProperties
|
||||
{
|
||||
public SerializedProperty[] m_Props;
|
||||
|
||||
public SerializedProperties(BinaryReader reader)
|
||||
{
|
||||
int numProps = reader.ReadInt32();
|
||||
m_Props = new SerializedProperty[numProps];
|
||||
for (int i = 0; i < numProps; i++)
|
||||
{
|
||||
m_Props[i] = new SerializedProperty(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SerializedShaderFloatValue
|
||||
{
|
||||
public float val;
|
||||
public string name;
|
||||
|
||||
public SerializedShaderFloatValue(BinaryReader reader)
|
||||
{
|
||||
val = reader.ReadSingle();
|
||||
name = reader.ReadAlignedString();
|
||||
}
|
||||
}
|
||||
|
||||
public class SerializedShaderRTBlendState
|
||||
{
|
||||
public SerializedShaderFloatValue srcBlend;
|
||||
public SerializedShaderFloatValue destBlend;
|
||||
public SerializedShaderFloatValue srcBlendAlpha;
|
||||
public SerializedShaderFloatValue destBlendAlpha;
|
||||
public SerializedShaderFloatValue blendOp;
|
||||
public SerializedShaderFloatValue blendOpAlpha;
|
||||
public SerializedShaderFloatValue colMask;
|
||||
|
||||
public SerializedShaderRTBlendState(BinaryReader reader)
|
||||
{
|
||||
srcBlend = new SerializedShaderFloatValue(reader);
|
||||
destBlend = new SerializedShaderFloatValue(reader);
|
||||
srcBlendAlpha = new SerializedShaderFloatValue(reader);
|
||||
destBlendAlpha = new SerializedShaderFloatValue(reader);
|
||||
blendOp = new SerializedShaderFloatValue(reader);
|
||||
blendOpAlpha = new SerializedShaderFloatValue(reader);
|
||||
colMask = new SerializedShaderFloatValue(reader);
|
||||
}
|
||||
}
|
||||
|
||||
public class SerializedStencilOp
|
||||
{
|
||||
public SerializedShaderFloatValue pass;
|
||||
public SerializedShaderFloatValue fail;
|
||||
public SerializedShaderFloatValue zFail;
|
||||
public SerializedShaderFloatValue comp;
|
||||
|
||||
public SerializedStencilOp(BinaryReader reader)
|
||||
{
|
||||
pass = new SerializedShaderFloatValue(reader);
|
||||
fail = new SerializedShaderFloatValue(reader);
|
||||
zFail = new SerializedShaderFloatValue(reader);
|
||||
comp = new SerializedShaderFloatValue(reader);
|
||||
}
|
||||
}
|
||||
|
||||
public class SerializedShaderVectorValue
|
||||
{
|
||||
public SerializedShaderFloatValue x;
|
||||
public SerializedShaderFloatValue y;
|
||||
public SerializedShaderFloatValue z;
|
||||
public SerializedShaderFloatValue w;
|
||||
public string name;
|
||||
|
||||
public SerializedShaderVectorValue(BinaryReader reader)
|
||||
{
|
||||
x = new SerializedShaderFloatValue(reader);
|
||||
y = new SerializedShaderFloatValue(reader);
|
||||
z = new SerializedShaderFloatValue(reader);
|
||||
w = new SerializedShaderFloatValue(reader);
|
||||
name = reader.ReadAlignedString();
|
||||
}
|
||||
}
|
||||
|
||||
public enum FogMode
|
||||
{
|
||||
kFogUnknown = -1,
|
||||
kFogDisabled = 0,
|
||||
kFogLinear = 1,
|
||||
kFogExp = 2,
|
||||
kFogExp2 = 3
|
||||
};
|
||||
|
||||
public class SerializedShaderState
|
||||
{
|
||||
public string m_Name;
|
||||
public SerializedShaderRTBlendState[] rtBlend;
|
||||
public bool rtSeparateBlend;
|
||||
public SerializedShaderFloatValue zClip;
|
||||
public SerializedShaderFloatValue zTest;
|
||||
public SerializedShaderFloatValue zWrite;
|
||||
public SerializedShaderFloatValue culling;
|
||||
public SerializedShaderFloatValue offsetFactor;
|
||||
public SerializedShaderFloatValue offsetUnits;
|
||||
public SerializedShaderFloatValue alphaToMask;
|
||||
public SerializedStencilOp stencilOp;
|
||||
public SerializedStencilOp stencilOpFront;
|
||||
public SerializedStencilOp stencilOpBack;
|
||||
public SerializedShaderFloatValue stencilReadMask;
|
||||
public SerializedShaderFloatValue stencilWriteMask;
|
||||
public SerializedShaderFloatValue stencilRef;
|
||||
public SerializedShaderFloatValue fogStart;
|
||||
public SerializedShaderFloatValue fogEnd;
|
||||
public SerializedShaderFloatValue fogDensity;
|
||||
public SerializedShaderVectorValue fogColor;
|
||||
public FogMode fogMode;
|
||||
public int gpuProgramID;
|
||||
public SerializedTagMap m_Tags;
|
||||
public int m_LOD;
|
||||
public bool lighting;
|
||||
|
||||
public SerializedShaderState(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
rtBlend = new SerializedShaderRTBlendState[8];
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
rtBlend[i] = new SerializedShaderRTBlendState(reader);
|
||||
}
|
||||
rtSeparateBlend = reader.ReadBoolean();
|
||||
reader.AlignStream();
|
||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 2)) //2017.2 and up
|
||||
{
|
||||
zClip = new SerializedShaderFloatValue(reader);
|
||||
}
|
||||
zTest = new SerializedShaderFloatValue(reader);
|
||||
zWrite = new SerializedShaderFloatValue(reader);
|
||||
culling = new SerializedShaderFloatValue(reader);
|
||||
offsetFactor = new SerializedShaderFloatValue(reader);
|
||||
offsetUnits = new SerializedShaderFloatValue(reader);
|
||||
alphaToMask = new SerializedShaderFloatValue(reader);
|
||||
stencilOp = new SerializedStencilOp(reader);
|
||||
stencilOpFront = new SerializedStencilOp(reader);
|
||||
stencilOpBack = new SerializedStencilOp(reader);
|
||||
stencilReadMask = new SerializedShaderFloatValue(reader);
|
||||
stencilWriteMask = new SerializedShaderFloatValue(reader);
|
||||
stencilRef = new SerializedShaderFloatValue(reader);
|
||||
fogStart = new SerializedShaderFloatValue(reader);
|
||||
fogEnd = new SerializedShaderFloatValue(reader);
|
||||
fogDensity = new SerializedShaderFloatValue(reader);
|
||||
fogColor = new SerializedShaderVectorValue(reader);
|
||||
fogMode = (FogMode)reader.ReadInt32();
|
||||
gpuProgramID = reader.ReadInt32();
|
||||
m_Tags = new SerializedTagMap(reader);
|
||||
m_LOD = reader.ReadInt32();
|
||||
lighting = reader.ReadBoolean();
|
||||
reader.AlignStream();
|
||||
}
|
||||
}
|
||||
|
||||
public class ShaderBindChannel
|
||||
{
|
||||
public sbyte source;
|
||||
public sbyte target;
|
||||
|
||||
public ShaderBindChannel(BinaryReader reader)
|
||||
{
|
||||
source = reader.ReadSByte();
|
||||
target = reader.ReadSByte();
|
||||
}
|
||||
}
|
||||
|
||||
public class ParserBindChannels
|
||||
{
|
||||
public ShaderBindChannel[] m_Channels;
|
||||
public uint m_SourceMap;
|
||||
|
||||
public ParserBindChannels(BinaryReader reader)
|
||||
{
|
||||
int numChannels = reader.ReadInt32();
|
||||
m_Channels = new ShaderBindChannel[numChannels];
|
||||
for (int i = 0; i < numChannels; i++)
|
||||
{
|
||||
m_Channels[i] = new ShaderBindChannel(reader);
|
||||
}
|
||||
reader.AlignStream();
|
||||
|
||||
m_SourceMap = reader.ReadUInt32();
|
||||
}
|
||||
}
|
||||
|
||||
public class VectorParameter
|
||||
{
|
||||
public int m_NameIndex;
|
||||
public int m_Index;
|
||||
public int m_ArraySize;
|
||||
public sbyte m_Type;
|
||||
public sbyte m_Dim;
|
||||
|
||||
public VectorParameter(BinaryReader reader)
|
||||
{
|
||||
m_NameIndex = reader.ReadInt32();
|
||||
m_Index = reader.ReadInt32();
|
||||
m_ArraySize = reader.ReadInt32();
|
||||
m_Type = reader.ReadSByte();
|
||||
m_Dim = reader.ReadSByte();
|
||||
reader.AlignStream();
|
||||
}
|
||||
}
|
||||
|
||||
public class MatrixParameter
|
||||
{
|
||||
public int m_NameIndex;
|
||||
public int m_Index;
|
||||
public int m_ArraySize;
|
||||
public sbyte m_Type;
|
||||
public sbyte m_RowCount;
|
||||
|
||||
public MatrixParameter(BinaryReader reader)
|
||||
{
|
||||
m_NameIndex = reader.ReadInt32();
|
||||
m_Index = reader.ReadInt32();
|
||||
m_ArraySize = reader.ReadInt32();
|
||||
m_Type = reader.ReadSByte();
|
||||
m_RowCount = reader.ReadSByte();
|
||||
reader.AlignStream();
|
||||
}
|
||||
}
|
||||
|
||||
public class TextureParameter
|
||||
{
|
||||
public int m_NameIndex;
|
||||
public int m_Index;
|
||||
public int m_SamplerIndex;
|
||||
public sbyte m_Dim;
|
||||
|
||||
public TextureParameter(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
|
||||
m_NameIndex = reader.ReadInt32();
|
||||
m_Index = reader.ReadInt32();
|
||||
m_SamplerIndex = reader.ReadInt32();
|
||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 3)) //2017.3 and up
|
||||
{
|
||||
var m_MultiSampled = reader.ReadBoolean();
|
||||
}
|
||||
m_Dim = reader.ReadSByte();
|
||||
reader.AlignStream();
|
||||
}
|
||||
}
|
||||
|
||||
public class BufferBinding
|
||||
{
|
||||
public int m_NameIndex;
|
||||
public int m_Index;
|
||||
|
||||
public BufferBinding(BinaryReader reader)
|
||||
{
|
||||
m_NameIndex = reader.ReadInt32();
|
||||
m_Index = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
|
||||
public class ConstantBuffer
|
||||
{
|
||||
public int m_NameIndex;
|
||||
public MatrixParameter[] m_MatrixParams;
|
||||
public VectorParameter[] m_VectorParams;
|
||||
public StructParameter[] m_StructParams;
|
||||
public int m_Size;
|
||||
|
||||
public ConstantBuffer(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
|
||||
m_NameIndex = reader.ReadInt32();
|
||||
|
||||
int numMatrixParams = reader.ReadInt32();
|
||||
m_MatrixParams = new MatrixParameter[numMatrixParams];
|
||||
for (int i = 0; i < numMatrixParams; i++)
|
||||
{
|
||||
m_MatrixParams[i] = new MatrixParameter(reader);
|
||||
}
|
||||
|
||||
int numVectorParams = reader.ReadInt32();
|
||||
m_VectorParams = new VectorParameter[numVectorParams];
|
||||
for (int i = 0; i < numVectorParams; i++)
|
||||
{
|
||||
m_VectorParams[i] = new VectorParameter(reader);
|
||||
}
|
||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 3)) //2017.3 and up
|
||||
{
|
||||
int numStructParams = reader.ReadInt32();
|
||||
m_StructParams = new StructParameter[numStructParams];
|
||||
for (int i = 0; i < numStructParams; i++)
|
||||
{
|
||||
var str = (string)ShaderResource.ResourceManager.GetObject($"Shader{sourceFile.version[0]}{sourceFile.version[1]}");
|
||||
if (str == null)
|
||||
{
|
||||
str = preloadData.ViewStruct();
|
||||
if (str == null)
|
||||
m_Script = Encoding.UTF8.GetBytes("Serialized Shader can't be read");
|
||||
else
|
||||
m_Script = Encoding.UTF8.GetBytes(str);
|
||||
}
|
||||
else
|
||||
{
|
||||
reader.Position = preloadData.Offset;
|
||||
var sb = new StringBuilder();
|
||||
var members = new JavaScriptSerializer().Deserialize<List<ClassMember>>(str);
|
||||
ClassStructHelper.ReadClassStruct(sb, members, reader);
|
||||
m_Script = Encoding.UTF8.GetBytes(sb.ToString());
|
||||
//m_Script = ReadSerializedShader(members, a_Stream);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Script = reader.ReadBytes(reader.ReadInt32());
|
||||
if (sourceFile.version[0] == 5 && sourceFile.version[1] >= 3) //5.3 - 5.4
|
||||
{
|
||||
reader.AlignStream(4);
|
||||
reader.ReadAlignedString();//m_PathName
|
||||
var decompressedSize = reader.ReadUInt32();
|
||||
var m_SubProgramBlob = reader.ReadBytes(reader.ReadInt32());
|
||||
var decompressedBytes = new byte[decompressedSize];
|
||||
using (var decoder = new Lz4DecoderStream(new MemoryStream(m_SubProgramBlob)))
|
||||
{
|
||||
decoder.Read(decompressedBytes, 0, (int)decompressedSize);
|
||||
}
|
||||
m_Script = m_Script.Concat(decompressedBytes.ToArray()).ToArray();
|
||||
}
|
||||
m_StructParams[i] = new StructParameter(reader);
|
||||
}
|
||||
}
|
||||
m_Size = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
|
||||
public class UAVParameter
|
||||
{
|
||||
public int m_NameIndex;
|
||||
public int m_Index;
|
||||
public int m_OriginalIndex;
|
||||
|
||||
public UAVParameter(BinaryReader reader)
|
||||
{
|
||||
m_NameIndex = reader.ReadInt32();
|
||||
m_Index = reader.ReadInt32();
|
||||
m_OriginalIndex = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
|
||||
public enum ShaderGpuProgramType
|
||||
{
|
||||
kShaderGpuProgramUnknown = 0,
|
||||
kShaderGpuProgramGLLegacy = 1,
|
||||
kShaderGpuProgramGLES31AEP = 2,
|
||||
kShaderGpuProgramGLES31 = 3,
|
||||
kShaderGpuProgramGLES3 = 4,
|
||||
kShaderGpuProgramGLES = 5,
|
||||
kShaderGpuProgramGLCore32 = 6,
|
||||
kShaderGpuProgramGLCore41 = 7,
|
||||
kShaderGpuProgramGLCore43 = 8,
|
||||
kShaderGpuProgramDX9VertexSM20 = 9,
|
||||
kShaderGpuProgramDX9VertexSM30 = 10,
|
||||
kShaderGpuProgramDX9PixelSM20 = 11,
|
||||
kShaderGpuProgramDX9PixelSM30 = 12,
|
||||
kShaderGpuProgramDX10Level9Vertex = 13,
|
||||
kShaderGpuProgramDX10Level9Pixel = 14,
|
||||
kShaderGpuProgramDX11VertexSM40 = 15,
|
||||
kShaderGpuProgramDX11VertexSM50 = 16,
|
||||
kShaderGpuProgramDX11PixelSM40 = 17,
|
||||
kShaderGpuProgramDX11PixelSM50 = 18,
|
||||
kShaderGpuProgramDX11GeometrySM40 = 19,
|
||||
kShaderGpuProgramDX11GeometrySM50 = 20,
|
||||
kShaderGpuProgramDX11HullSM50 = 21,
|
||||
kShaderGpuProgramDX11DomainSM50 = 22,
|
||||
kShaderGpuProgramMetalVS = 23,
|
||||
kShaderGpuProgramMetalFS = 24,
|
||||
kShaderGpuProgramSPIRV = 25,
|
||||
kShaderGpuProgramConsole = 26
|
||||
};
|
||||
|
||||
public class SerializedSubProgram
|
||||
{
|
||||
public uint m_BlobIndex;
|
||||
public ParserBindChannels m_Channels;
|
||||
public ushort[] m_KeywordIndices;
|
||||
public sbyte m_ShaderHardwareTier;
|
||||
public ShaderGpuProgramType m_GpuProgramType;
|
||||
public VectorParameter[] m_VectorParams;
|
||||
public MatrixParameter[] m_MatrixParams;
|
||||
public TextureParameter[] m_TextureParams;
|
||||
public BufferBinding[] m_BufferParams;
|
||||
public ConstantBuffer[] m_ConstantBuffers;
|
||||
public BufferBinding[] m_ConstantBufferBindings;
|
||||
public UAVParameter[] m_UAVParams;
|
||||
public SamplerParameter[] m_Samplers;
|
||||
|
||||
public SerializedSubProgram(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
|
||||
m_BlobIndex = reader.ReadUInt32();
|
||||
m_Channels = new ParserBindChannels(reader);
|
||||
|
||||
if (version[0] >= 2019) //2019 and up
|
||||
{
|
||||
var m_GlobalKeywordIndices = reader.ReadUInt16Array();
|
||||
reader.AlignStream();
|
||||
var m_LocalKeywordIndices = reader.ReadUInt16Array();
|
||||
reader.AlignStream();
|
||||
}
|
||||
else
|
||||
{
|
||||
preloadData.extension = ".txt";
|
||||
preloadData.Text = m_Name;
|
||||
m_KeywordIndices = reader.ReadUInt16Array();
|
||||
if (version[0] >= 2017) //2017 and up
|
||||
{
|
||||
reader.AlignStream();
|
||||
}
|
||||
}
|
||||
|
||||
m_ShaderHardwareTier = reader.ReadSByte();
|
||||
m_GpuProgramType = (ShaderGpuProgramType)reader.ReadSByte();
|
||||
reader.AlignStream();
|
||||
|
||||
int numVectorParams = reader.ReadInt32();
|
||||
m_VectorParams = new VectorParameter[numVectorParams];
|
||||
for (int i = 0; i < numVectorParams; i++)
|
||||
{
|
||||
m_VectorParams[i] = new VectorParameter(reader);
|
||||
}
|
||||
|
||||
int numMatrixParams = reader.ReadInt32();
|
||||
m_MatrixParams = new MatrixParameter[numMatrixParams];
|
||||
for (int i = 0; i < numMatrixParams; i++)
|
||||
{
|
||||
m_MatrixParams[i] = new MatrixParameter(reader);
|
||||
}
|
||||
|
||||
int numTextureParams = reader.ReadInt32();
|
||||
m_TextureParams = new TextureParameter[numTextureParams];
|
||||
for (int i = 0; i < numTextureParams; i++)
|
||||
{
|
||||
m_TextureParams[i] = new TextureParameter(reader);
|
||||
}
|
||||
|
||||
int numBufferParams = reader.ReadInt32();
|
||||
m_BufferParams = new BufferBinding[numBufferParams];
|
||||
for (int i = 0; i < numBufferParams; i++)
|
||||
{
|
||||
m_BufferParams[i] = new BufferBinding(reader);
|
||||
}
|
||||
|
||||
int numConstantBuffers = reader.ReadInt32();
|
||||
m_ConstantBuffers = new ConstantBuffer[numConstantBuffers];
|
||||
for (int i = 0; i < numConstantBuffers; i++)
|
||||
{
|
||||
m_ConstantBuffers[i] = new ConstantBuffer(reader);
|
||||
}
|
||||
|
||||
int numConstantBufferBindings = reader.ReadInt32();
|
||||
m_ConstantBufferBindings = new BufferBinding[numConstantBufferBindings];
|
||||
for (int i = 0; i < numConstantBufferBindings; i++)
|
||||
{
|
||||
m_ConstantBufferBindings[i] = new BufferBinding(reader);
|
||||
}
|
||||
|
||||
int numUAVParams = reader.ReadInt32();
|
||||
m_UAVParams = new UAVParameter[numUAVParams];
|
||||
for (int i = 0; i < numUAVParams; i++)
|
||||
{
|
||||
m_UAVParams[i] = new UAVParameter(reader);
|
||||
}
|
||||
|
||||
if (version[0] >= 2017) //2017 and up
|
||||
{
|
||||
int numSamplers = reader.ReadInt32();
|
||||
m_Samplers = new SamplerParameter[numSamplers];
|
||||
for (int i = 0; i < numSamplers; i++)
|
||||
{
|
||||
m_Samplers[i] = new SamplerParameter(reader);
|
||||
}
|
||||
}
|
||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 2)) //2017.2 and up
|
||||
{
|
||||
var m_ShaderRequirements = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*private static byte[] ReadSerializedShader(List<ClassMember> members, EndianBinaryReader a_Stream)
|
||||
public class SerializedProgram
|
||||
{
|
||||
public SerializedSubProgram[] m_SubPrograms;
|
||||
|
||||
public SerializedProgram(ObjectReader reader)
|
||||
{
|
||||
var offsets = new List<uint>();
|
||||
var compressedLengths = new List<uint>();
|
||||
var decompressedLengths = new List<uint>();
|
||||
for (int i = 0; i < members.Count; i++)
|
||||
int numSubPrograms = reader.ReadInt32();
|
||||
m_SubPrograms = new SerializedSubProgram[numSubPrograms];
|
||||
for (int i = 0; i < numSubPrograms; i++)
|
||||
{
|
||||
var member = members[i];
|
||||
var level = member.Level;
|
||||
var varTypeStr = member.Type;
|
||||
if (member.Name == "offsets")
|
||||
m_SubPrograms[i] = new SerializedSubProgram(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum PassType
|
||||
{
|
||||
kPassTypeNormal = 0,
|
||||
kPassTypeUse = 1,
|
||||
kPassTypeGrab = 2
|
||||
};
|
||||
|
||||
public class SerializedPass
|
||||
{
|
||||
public KeyValuePair<string, int>[] m_NameIndices;
|
||||
public PassType m_Type;
|
||||
public SerializedShaderState m_State;
|
||||
public uint m_ProgramMask;
|
||||
public SerializedProgram progVertex;
|
||||
public SerializedProgram progFragment;
|
||||
public SerializedProgram progGeometry;
|
||||
public SerializedProgram progHull;
|
||||
public SerializedProgram progDomain;
|
||||
public SerializedProgram progRayTracing;
|
||||
public bool m_HasInstancingVariant;
|
||||
public string m_UseName;
|
||||
public string m_Name;
|
||||
public string m_TextureName;
|
||||
public SerializedTagMap m_Tags;
|
||||
|
||||
public SerializedPass(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
|
||||
int numIndices = reader.ReadInt32();
|
||||
m_NameIndices = new KeyValuePair<string, int>[numIndices];
|
||||
for (int i = 0; i < numIndices; i++)
|
||||
{
|
||||
m_NameIndices[i] = new KeyValuePair<string, int>(reader.ReadAlignedString(), reader.ReadInt32());
|
||||
}
|
||||
|
||||
m_Type = (PassType)reader.ReadInt32();
|
||||
m_State = new SerializedShaderState(reader);
|
||||
m_ProgramMask = reader.ReadUInt32();
|
||||
progVertex = new SerializedProgram(reader);
|
||||
progFragment = new SerializedProgram(reader);
|
||||
progGeometry = new SerializedProgram(reader);
|
||||
progHull = new SerializedProgram(reader);
|
||||
progDomain = new SerializedProgram(reader);
|
||||
if (version[0] > 2019 || (version[0] == 2019 && version[1] >= 3)) //2019.3 and up
|
||||
{
|
||||
progRayTracing = new SerializedProgram(reader);
|
||||
}
|
||||
m_HasInstancingVariant = reader.ReadBoolean();
|
||||
if (version[0] >= 2018) //2018 and up
|
||||
{
|
||||
var m_HasProceduralInstancingVariant = reader.ReadBoolean();
|
||||
}
|
||||
reader.AlignStream();
|
||||
m_UseName = reader.ReadAlignedString();
|
||||
m_Name = reader.ReadAlignedString();
|
||||
m_TextureName = reader.ReadAlignedString();
|
||||
m_Tags = new SerializedTagMap(reader);
|
||||
}
|
||||
}
|
||||
|
||||
public class SerializedTagMap
|
||||
{
|
||||
public KeyValuePair<string, string>[] tags;
|
||||
|
||||
public SerializedTagMap(BinaryReader reader)
|
||||
{
|
||||
int numTags = reader.ReadInt32();
|
||||
tags = new KeyValuePair<string, string>[numTags];
|
||||
for (int i = 0; i < numTags; i++)
|
||||
{
|
||||
tags[i] = new KeyValuePair<string, string>(reader.ReadAlignedString(), reader.ReadAlignedString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SerializedSubShader
|
||||
{
|
||||
public SerializedPass[] m_Passes;
|
||||
public SerializedTagMap m_Tags;
|
||||
public int m_LOD;
|
||||
|
||||
public SerializedSubShader(ObjectReader reader)
|
||||
{
|
||||
int numPasses = reader.ReadInt32();
|
||||
m_Passes = new SerializedPass[numPasses];
|
||||
for (int i = 0; i < numPasses; i++)
|
||||
{
|
||||
m_Passes[i] = new SerializedPass(reader);
|
||||
}
|
||||
|
||||
m_Tags = new SerializedTagMap(reader);
|
||||
m_LOD = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
|
||||
public class SerializedShaderDependency
|
||||
{
|
||||
public string from;
|
||||
public string to;
|
||||
|
||||
public SerializedShaderDependency(BinaryReader reader)
|
||||
{
|
||||
from = reader.ReadAlignedString();
|
||||
to = reader.ReadAlignedString();
|
||||
}
|
||||
}
|
||||
|
||||
public class SerializedShader
|
||||
{
|
||||
public SerializedProperties m_PropInfo;
|
||||
public SerializedSubShader[] m_SubShaders;
|
||||
public string m_Name;
|
||||
public string m_CustomEditorName;
|
||||
public string m_FallbackName;
|
||||
public SerializedShaderDependency[] m_Dependencies;
|
||||
public bool m_DisableNoSubshadersMessage;
|
||||
|
||||
public SerializedShader(ObjectReader reader)
|
||||
{
|
||||
m_PropInfo = new SerializedProperties(reader);
|
||||
|
||||
int numSubShaders = reader.ReadInt32();
|
||||
m_SubShaders = new SerializedSubShader[numSubShaders];
|
||||
for (int i = 0; i < numSubShaders; i++)
|
||||
{
|
||||
m_SubShaders[i] = new SerializedSubShader(reader);
|
||||
}
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
m_CustomEditorName = reader.ReadAlignedString();
|
||||
m_FallbackName = reader.ReadAlignedString();
|
||||
|
||||
int numDependencies = reader.ReadInt32();
|
||||
m_Dependencies = new SerializedShaderDependency[numDependencies];
|
||||
for (int i = 0; i < numDependencies; i++)
|
||||
{
|
||||
m_Dependencies[i] = new SerializedShaderDependency(reader);
|
||||
}
|
||||
|
||||
m_DisableNoSubshadersMessage = reader.ReadBoolean();
|
||||
reader.AlignStream();
|
||||
}
|
||||
}
|
||||
|
||||
public enum ShaderCompilerPlatform
|
||||
{
|
||||
kShaderCompPlatformNone = -1,
|
||||
kShaderCompPlatformGL = 0,
|
||||
kShaderCompPlatformD3D9 = 1,
|
||||
kShaderCompPlatformXbox360 = 2,
|
||||
kShaderCompPlatformPS3 = 3,
|
||||
kShaderCompPlatformD3D11 = 4,
|
||||
kShaderCompPlatformGLES20 = 5,
|
||||
kShaderCompPlatformNaCl = 6,
|
||||
kShaderCompPlatformFlash = 7,
|
||||
kShaderCompPlatformD3D11_9x = 8,
|
||||
kShaderCompPlatformGLES3Plus = 9,
|
||||
kShaderCompPlatformPSP2 = 10,
|
||||
kShaderCompPlatformPS4 = 11,
|
||||
kShaderCompPlatformXboxOne = 12,
|
||||
kShaderCompPlatformPSM = 13,
|
||||
kShaderCompPlatformMetal = 14,
|
||||
kShaderCompPlatformOpenGLCore = 15,
|
||||
kShaderCompPlatformN3DS = 16,
|
||||
kShaderCompPlatformWiiU = 17,
|
||||
kShaderCompPlatformVulkan = 18,
|
||||
kShaderCompPlatformSwitch = 19,
|
||||
kShaderCompPlatformXboxOneD3D12 = 20
|
||||
};
|
||||
|
||||
public class Shader : NamedObject
|
||||
{
|
||||
public byte[] m_Script;
|
||||
//5.3 - 5.4
|
||||
public uint decompressedSize;
|
||||
public byte[] m_SubProgramBlob;
|
||||
//5.5 and up
|
||||
public SerializedShader m_ParsedForm;
|
||||
public ShaderCompilerPlatform[] platforms;
|
||||
public uint[] offsets;
|
||||
public uint[] compressedLengths;
|
||||
public uint[] decompressedLengths;
|
||||
public byte[] compressedBlob;
|
||||
|
||||
public Shader(ObjectReader reader) : base(reader)
|
||||
{
|
||||
if (version[0] == 5 && version[1] >= 5 || version[0] > 5) //5.5 and up
|
||||
{
|
||||
m_ParsedForm = new SerializedShader(reader);
|
||||
platforms = reader.ReadUInt32Array().Select(x => (ShaderCompilerPlatform)x).ToArray();
|
||||
if (version[0] > 2019 || (version[0] == 2019 && version[1] >= 3)) //2019.3 and up
|
||||
{
|
||||
var offsets_size = a_Stream.ReadInt32();
|
||||
for (int j = 0; j < offsets_size; j++)
|
||||
{
|
||||
offsets.Add(a_Stream.ReadUInt32());
|
||||
}
|
||||
var compressedLengths_size = a_Stream.ReadInt32();
|
||||
for (int j = 0; j < compressedLengths_size; j++)
|
||||
{
|
||||
compressedLengths.Add(a_Stream.ReadUInt32());
|
||||
}
|
||||
var decompressedLengths_size = a_Stream.ReadInt32();
|
||||
for (int j = 0; j < decompressedLengths_size; j++)
|
||||
{
|
||||
decompressedLengths.Add(a_Stream.ReadUInt32());
|
||||
}
|
||||
var compressedBlob = a_Stream.ReadBytes(a_Stream.ReadInt32());
|
||||
var decompressedStream = new MemoryStream();
|
||||
for (int j = 0; j < offsets.Count; j++)
|
||||
{
|
||||
var compressedBytes = new byte[compressedLengths[j]];
|
||||
Array.Copy(compressedBlob, offsets[j], compressedBytes, 0, compressedLengths[j]);
|
||||
var decompressedBytes = new byte[decompressedLengths[j]];
|
||||
using (var mstream = new MemoryStream(compressedBytes))
|
||||
{
|
||||
var decoder = new Lz4DecoderStream(mstream);
|
||||
decoder.Read(decompressedBytes, 0, (int)decompressedLengths[j]);
|
||||
decoder.Dispose();
|
||||
}
|
||||
decompressedStream.Write(decompressedBytes, 0, decompressedBytes.Length);
|
||||
}
|
||||
var decompressedBlob = decompressedStream.ToArray();
|
||||
return decompressedBlob;
|
||||
}
|
||||
var align = (member.Flag & 0x4000) != 0;
|
||||
if (member.alignBefore)
|
||||
a_Stream.AlignStream(4);
|
||||
if (varTypeStr == "SInt8")//sbyte
|
||||
{
|
||||
a_Stream.ReadSByte();
|
||||
}
|
||||
else if (varTypeStr == "UInt8")//byte
|
||||
{
|
||||
a_Stream.ReadByte();
|
||||
}
|
||||
else if (varTypeStr == "short" || varTypeStr == "SInt16")//Int16
|
||||
{
|
||||
a_Stream.ReadInt16();
|
||||
}
|
||||
else if (varTypeStr == "UInt16" || varTypeStr == "unsigned short")//UInt16
|
||||
{
|
||||
a_Stream.ReadUInt16();
|
||||
}
|
||||
else if (varTypeStr == "int" || varTypeStr == "SInt32")//Int32
|
||||
{
|
||||
a_Stream.ReadInt32();
|
||||
}
|
||||
else if (varTypeStr == "UInt32" || varTypeStr == "unsigned int" || varTypeStr == "Type*")//UInt32
|
||||
{
|
||||
a_Stream.ReadUInt32();
|
||||
}
|
||||
else if (varTypeStr == "long long" || varTypeStr == "SInt64")//Int64
|
||||
{
|
||||
a_Stream.ReadInt64();
|
||||
}
|
||||
else if (varTypeStr == "UInt64" || varTypeStr == "unsigned long long")//UInt64
|
||||
{
|
||||
a_Stream.ReadUInt64();
|
||||
}
|
||||
else if (varTypeStr == "float")//float
|
||||
{
|
||||
a_Stream.ReadSingle();
|
||||
}
|
||||
else if (varTypeStr == "double")//double
|
||||
{
|
||||
a_Stream.ReadDouble();
|
||||
}
|
||||
else if (varTypeStr == "bool")//bool
|
||||
{
|
||||
a_Stream.ReadBoolean();
|
||||
}
|
||||
else if (varTypeStr == "string")//string
|
||||
{
|
||||
a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
i += 3;//skip
|
||||
}
|
||||
else if (varTypeStr == "Array")//Array
|
||||
{
|
||||
if ((members[i - 1].Flag & 0x4000) != 0)
|
||||
align = true;
|
||||
var size = a_Stream.ReadInt32();
|
||||
var array = ClassStructHelper.ReadArray(members, level, i);
|
||||
for (int j = 0; j < size; j++)
|
||||
{
|
||||
ReadSerializedShader(array, a_Stream);
|
||||
}
|
||||
i += array.Count + 1;//skip
|
||||
offsets = reader.ReadUInt32ArrayArray().Select(x => x[0]).ToArray();
|
||||
compressedLengths = reader.ReadUInt32ArrayArray().Select(x => x[0]).ToArray();
|
||||
decompressedLengths = reader.ReadUInt32ArrayArray().Select(x => x[0]).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (align)
|
||||
{
|
||||
align = false;
|
||||
ClassStructHelper.SetAlignBefore(members, level, i + 1);
|
||||
}
|
||||
offsets = reader.ReadUInt32Array();
|
||||
compressedLengths = reader.ReadUInt32Array();
|
||||
decompressedLengths = reader.ReadUInt32Array();
|
||||
}
|
||||
if (align)
|
||||
a_Stream.AlignStream(4);
|
||||
compressedBlob = reader.ReadBytes(reader.ReadInt32());
|
||||
}
|
||||
return null;
|
||||
}*/
|
||||
else
|
||||
{
|
||||
m_Script = reader.ReadBytes(reader.ReadInt32());
|
||||
reader.AlignStream();
|
||||
var m_PathName = reader.ReadAlignedString();
|
||||
if (version[0] == 5 && version[1] >= 3) //5.3 - 5.4
|
||||
{
|
||||
decompressedSize = reader.ReadUInt32();
|
||||
m_SubProgramBlob = reader.ReadBytes(reader.ReadInt32());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,143 +5,35 @@ using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class SkinnedMeshRenderer : MeshRenderer
|
||||
public sealed class SkinnedMeshRenderer : Renderer
|
||||
{
|
||||
public PPtr m_Mesh;
|
||||
public PPtr[] m_Bones;
|
||||
public List<float> m_BlendShapeWeights;
|
||||
public PPtr<Mesh> m_Mesh;
|
||||
public PPtr<Transform>[] m_Bones;
|
||||
public float[] m_BlendShapeWeights;
|
||||
|
||||
public SkinnedMeshRenderer(AssetPreloadData preloadData)
|
||||
public SkinnedMeshRenderer(ObjectReader reader) : base(reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var version = preloadData.sourceFile.version;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_GameObject = sourceFile.ReadPPtr();
|
||||
if (sourceFile.version[0] < 5)
|
||||
{
|
||||
m_Enabled = reader.ReadBoolean();
|
||||
m_CastShadows = reader.ReadByte();//bool
|
||||
m_ReceiveShadows = reader.ReadBoolean();
|
||||
m_LightmapIndex = reader.ReadByte();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Enabled = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
m_CastShadows = reader.ReadByte();
|
||||
m_ReceiveShadows = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
|
||||
m_LightmapIndex = reader.ReadUInt16();
|
||||
m_LightmapIndexDynamic = reader.ReadUInt16();
|
||||
}
|
||||
|
||||
if (version[0] >= 3) { reader.Position += 16; } //m_LightmapTilingOffset vector4d
|
||||
if (sourceFile.version[0] >= 5) { reader.Position += 16; } //Vector4f m_LightmapTilingOffsetDynamic
|
||||
|
||||
m_Materials = new PPtr[reader.ReadInt32()];
|
||||
for (int m = 0; m < m_Materials.Length; m++)
|
||||
{
|
||||
m_Materials[m] = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
if (version[0] < 3)
|
||||
{
|
||||
reader.Position += 16;//m_LightmapTilingOffset vector4d
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 5) || sourceFile.version[0] > 5)//5.5.0 and up
|
||||
{
|
||||
reader.Position += 4;//m_StaticBatchInfo
|
||||
}
|
||||
else
|
||||
{
|
||||
int m_SubsetIndices_size = reader.ReadInt32();
|
||||
reader.Position += m_SubsetIndices_size * 4;
|
||||
}
|
||||
PPtr m_StaticBatchRoot = sourceFile.ReadPPtr();
|
||||
|
||||
if ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 4) || sourceFile.version[0] > 5)//5.4.0 and up
|
||||
{
|
||||
PPtr m_ProbeAnchor = sourceFile.ReadPPtr();
|
||||
PPtr m_LightProbeVolumeOverride = sourceFile.ReadPPtr();
|
||||
}
|
||||
else if (version[0] >= 4 || (version[0] == 3 && version[1] >= 5))
|
||||
{
|
||||
bool m_UseLightProbes = reader.ReadBoolean();
|
||||
reader.Position += 3; //alignment
|
||||
if (version[0] == 5) { int m_ReflectionProbeUsage = reader.ReadInt32(); }
|
||||
//did I ever check if the anchor is conditioned by the bool?
|
||||
PPtr m_LightProbeAnchor = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
if (version[0] >= 5 || (version[0] == 4 && version[1] >= 3))
|
||||
{
|
||||
if (version[0] == 4 && version[1] <= 3) { int m_SortingLayer = reader.ReadInt16(); }
|
||||
else { int m_SortingLayer = reader.ReadInt32(); }
|
||||
|
||||
int m_SortingOrder = reader.ReadInt16();
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
}
|
||||
|
||||
int m_Quality = reader.ReadInt32();
|
||||
bool m_UpdateWhenOffscreen = reader.ReadBoolean();
|
||||
bool m_SkinNormals = reader.ReadBoolean(); //3.1.0 and below
|
||||
reader.Position += 2;
|
||||
var m_UpdateWhenOffscreen = reader.ReadBoolean();
|
||||
var m_SkinNormals = reader.ReadBoolean(); //3.1.0 and below
|
||||
reader.AlignStream();
|
||||
|
||||
if (version[0] == 2 && version[1] < 6)
|
||||
if (version[0] == 2 && version[1] < 6) //2.6 down
|
||||
{
|
||||
//this would be the only error if mainVersion is not read in time for a version 2.x game
|
||||
PPtr m_DisableAnimationWhenOffscreen = sourceFile.ReadPPtr();
|
||||
var m_DisableAnimationWhenOffscreen = new PPtr<Animation>(reader);
|
||||
}
|
||||
|
||||
m_Mesh = sourceFile.ReadPPtr();
|
||||
m_Mesh = new PPtr<Mesh>(reader);
|
||||
|
||||
m_Bones = new PPtr[reader.ReadInt32()];
|
||||
m_Bones = new PPtr<Transform>[reader.ReadInt32()];
|
||||
for (int b = 0; b < m_Bones.Length; b++)
|
||||
{
|
||||
m_Bones[b] = sourceFile.ReadPPtr();
|
||||
m_Bones[b] = new PPtr<Transform>(reader);
|
||||
}
|
||||
|
||||
if (version[0] < 3)
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3 and up
|
||||
{
|
||||
int m_BindPose = reader.ReadInt32();
|
||||
reader.Position += m_BindPose * 16 * 4;//Matrix4x4f
|
||||
}
|
||||
else
|
||||
{
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 3))//4.3 and up
|
||||
{
|
||||
int numBSWeights = reader.ReadInt32();
|
||||
m_BlendShapeWeights = new List<float>(numBSWeights);
|
||||
for (int i = 0; i < numBSWeights; i++)
|
||||
{
|
||||
m_BlendShapeWeights.Add(reader.ReadSingle());
|
||||
}
|
||||
}
|
||||
|
||||
/*if (version[0] > 4 || (version[0] >= 3 && version[1] >= 5))
|
||||
{
|
||||
PPtr m_RootBone = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
if (version[0] > 4 || (version[0] == 3 && version[1] >= 4))
|
||||
{
|
||||
//AABB
|
||||
float[] m_Center = { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() };
|
||||
float[] m_Extent = { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() };
|
||||
bool m_DirtyAABB = reader.ReadBoolean();
|
||||
}*/
|
||||
m_BlendShapeWeights = reader.ReadSingleArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,169 +1,245 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class Sprite
|
||||
public class SecondarySpriteTexture
|
||||
{
|
||||
public string m_Name;
|
||||
public RectangleF m_Rect;
|
||||
public float m_PixelsToUnits;
|
||||
public PointF m_Pivot;
|
||||
public Guid first;
|
||||
public PPtr texture;
|
||||
public PPtr m_SpriteAtlas;
|
||||
public RectangleF textureRect;
|
||||
public PointF[][] m_PhysicsShape;
|
||||
public PPtr<Texture2D> texture;
|
||||
public string name;
|
||||
|
||||
public Sprite(AssetPreloadData preloadData, bool readSwitch)
|
||||
public SecondarySpriteTexture(ObjectReader reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
var version = sourceFile.version;
|
||||
texture = new PPtr<Texture2D>(reader);
|
||||
name = reader.ReadStringToNull();
|
||||
}
|
||||
}
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
if (readSwitch)
|
||||
public enum SpritePackingRotation
|
||||
{
|
||||
kSPRNone = 0,
|
||||
kSPRFlipHorizontal = 1,
|
||||
kSPRFlipVertical = 2,
|
||||
kSPRRotate180 = 3,
|
||||
kSPRRotate90 = 4
|
||||
};
|
||||
|
||||
public enum SpritePackingMode
|
||||
{
|
||||
kSPMTight = 0,
|
||||
kSPMRectangle
|
||||
};
|
||||
|
||||
public enum SpriteMeshType
|
||||
{
|
||||
kSpriteMeshTypeFullRect,
|
||||
kSpriteMeshTypeTight
|
||||
};
|
||||
|
||||
public class SpriteSettings
|
||||
{
|
||||
public uint settingsRaw;
|
||||
|
||||
public uint packed;
|
||||
public SpritePackingMode packingMode;
|
||||
public SpritePackingRotation packingRotation;
|
||||
public SpriteMeshType meshType;
|
||||
|
||||
public SpriteSettings(BinaryReader reader)
|
||||
{
|
||||
settingsRaw = reader.ReadUInt32();
|
||||
|
||||
packed = settingsRaw & 1; //1
|
||||
packingMode = (SpritePackingMode)((settingsRaw >> 1) & 1); //1
|
||||
packingRotation = (SpritePackingRotation)((settingsRaw >> 2) & 0xf); //4
|
||||
meshType = (SpriteMeshType)((settingsRaw >> 6) & 1); //1
|
||||
//reserved
|
||||
}
|
||||
}
|
||||
|
||||
public class SpriteVertex
|
||||
{
|
||||
public Vector3 pos;
|
||||
public Vector2 uv;
|
||||
|
||||
public SpriteVertex(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
|
||||
pos = reader.ReadVector3();
|
||||
if (version[0] < 4 || (version[0] == 4 && version[1] <= 3)) //4.3 and down
|
||||
{
|
||||
//Rectf m_Rect
|
||||
m_Rect = new RectangleF(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
|
||||
//Vector2f m_Offset
|
||||
reader.Position += 8;
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 5)) //4.5 and up
|
||||
{
|
||||
//Vector4f m_Border
|
||||
reader.Position += 16;
|
||||
}
|
||||
|
||||
m_PixelsToUnits = reader.ReadSingle();
|
||||
if (version[0] > 5
|
||||
|| (version[0] == 5 && version[1] > 4)
|
||||
|| (version[0] == 5 && version[1] == 4 && version[2] >= 2)) //5.4.2 and up
|
||||
{
|
||||
//Vector2f m_Pivot
|
||||
m_Pivot = new PointF(reader.ReadSingle(), reader.ReadSingle());
|
||||
}
|
||||
|
||||
var m_Extrude = reader.ReadUInt32();
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 3)) //5.3 and up TODO need more test
|
||||
{
|
||||
var m_IsPolygon = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
|
||||
if (version[0] >= 2017) //2017 and up
|
||||
{
|
||||
//pair m_RenderDataKey
|
||||
first = new Guid(reader.ReadBytes(16));
|
||||
var second = reader.ReadInt64();
|
||||
//vector m_AtlasTags
|
||||
var size = reader.ReadInt32();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
var data = reader.ReadAlignedString();
|
||||
}
|
||||
|
||||
//PPtr<SpriteAtlas> m_SpriteAtlas
|
||||
m_SpriteAtlas = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
//SpriteRenderData m_RD
|
||||
// PPtr<Texture2D> texture
|
||||
texture = sourceFile.ReadPPtr();
|
||||
// PPtr<Texture2D> alphaTexture
|
||||
if (version[0] >= 5) //5.0 and up
|
||||
{
|
||||
var alphaTexture = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 6)) //5.6 and up
|
||||
{
|
||||
// vector m_SubMeshes
|
||||
var size = reader.ReadInt32();
|
||||
// SubMesh data
|
||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 3)) //2017.3 and up
|
||||
{
|
||||
reader.Position += 48 * size;
|
||||
}
|
||||
else
|
||||
{
|
||||
reader.Position += 44 * size;
|
||||
}
|
||||
|
||||
// vector m_IndexBuffer
|
||||
size = reader.ReadInt32();
|
||||
reader.Position += size; //UInt8 data
|
||||
reader.AlignStream(4);
|
||||
// VertexData m_VertexData
|
||||
var m_CurrentChannels = reader.ReadInt32();
|
||||
var m_VertexCount = reader.ReadUInt32();
|
||||
// vector m_Channels
|
||||
size = reader.ReadInt32();
|
||||
reader.Position += size * 4; //ChannelInfo data
|
||||
// TypelessData m_DataSize
|
||||
size = reader.ReadInt32();
|
||||
reader.Position += size; //UInt8 data
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
else
|
||||
{
|
||||
// vector vertices
|
||||
var size = reader.ReadInt32();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
//SpriteVertex data
|
||||
reader.Position += 12; //Vector3f pos
|
||||
if (version[0] < 4 || (version[0] == 4 && version[1] <= 3)) //4.3 and down
|
||||
reader.Position += 8; //Vector2f uv
|
||||
}
|
||||
|
||||
// vector indices
|
||||
size = reader.ReadInt32();
|
||||
reader.Position += 2 * size; //UInt16 data
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
|
||||
// Rectf textureRect
|
||||
textureRect = new RectangleF(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
|
||||
// Vector2f textureRectOffset
|
||||
reader.Position += 8;
|
||||
// Vector2f atlasRectOffset - 5.6 and up
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 6)) //5.6 and up
|
||||
{
|
||||
reader.Position += 8;
|
||||
}
|
||||
// unsigned int settingsRaw
|
||||
reader.Position += 4;
|
||||
// Vector4f uvTransform - 4.5 and up
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 5)) //4.5 and up
|
||||
{
|
||||
reader.Position += 16;
|
||||
}
|
||||
if (version[0] >= 2017) //2017 and up
|
||||
{
|
||||
// float downscaleMultiplier - 2017 and up
|
||||
reader.Position += 4;
|
||||
//vector m_PhysicsShape - 2017 and up
|
||||
var m_PhysicsShape_size = reader.ReadInt32();
|
||||
m_PhysicsShape = new PointF[m_PhysicsShape_size][];
|
||||
for (int i = 0; i < m_PhysicsShape_size; i++)
|
||||
{
|
||||
var data_size = reader.ReadInt32();
|
||||
//Vector2f
|
||||
m_PhysicsShape[i] = new PointF[data_size];
|
||||
for (int j = 0; j < data_size; j++)
|
||||
{
|
||||
m_PhysicsShape[i][j] = new PointF(reader.ReadSingle(), reader.ReadSingle());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
preloadData.Text = m_Name;
|
||||
uv = reader.ReadVector2();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SpriteRenderData
|
||||
{
|
||||
public PPtr<Texture2D> texture;
|
||||
public PPtr<Texture2D> alphaTexture;
|
||||
public SecondarySpriteTexture[] secondaryTextures;
|
||||
public SubMesh[] m_SubMeshes;
|
||||
public byte[] m_IndexBuffer;
|
||||
public VertexData m_VertexData;
|
||||
public SpriteVertex[] vertices;
|
||||
public ushort[] indices;
|
||||
public Matrix4x4[] m_Bindpose;
|
||||
public BoneWeights4[] m_SourceSkin;
|
||||
public RectangleF textureRect;
|
||||
public Vector2 textureRectOffset;
|
||||
public Vector2 atlasRectOffset;
|
||||
public SpriteSettings settingsRaw;
|
||||
public Vector4 uvTransform;
|
||||
public float downscaleMultiplier;
|
||||
|
||||
public SpriteRenderData(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
|
||||
texture = new PPtr<Texture2D>(reader);
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 2)) //5.2 and up
|
||||
{
|
||||
alphaTexture = new PPtr<Texture2D>(reader);
|
||||
}
|
||||
|
||||
if (version[0] >= 2019) //2019 and up
|
||||
{
|
||||
var secondaryTexturesSize = reader.ReadInt32();
|
||||
secondaryTextures = new SecondarySpriteTexture[secondaryTexturesSize];
|
||||
for (int i = 0; i < secondaryTexturesSize; i++)
|
||||
{
|
||||
secondaryTextures[i] = new SecondarySpriteTexture(reader);
|
||||
}
|
||||
}
|
||||
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 6)) //5.6 and up
|
||||
{
|
||||
var m_SubMeshesSize = reader.ReadInt32();
|
||||
m_SubMeshes = new SubMesh[m_SubMeshesSize];
|
||||
for (int i = 0; i < m_SubMeshesSize; i++)
|
||||
{
|
||||
m_SubMeshes[i] = new SubMesh(reader);
|
||||
}
|
||||
|
||||
m_IndexBuffer = reader.ReadBytes(reader.ReadInt32());
|
||||
reader.AlignStream();
|
||||
|
||||
m_VertexData = new VertexData(reader);
|
||||
}
|
||||
else
|
||||
{
|
||||
var verticesSize = reader.ReadInt32();
|
||||
vertices = new SpriteVertex[verticesSize];
|
||||
for (int i = 0; i < verticesSize; i++)
|
||||
{
|
||||
vertices[i] = new SpriteVertex(reader);
|
||||
}
|
||||
|
||||
indices = reader.ReadUInt16Array();
|
||||
reader.AlignStream();
|
||||
}
|
||||
|
||||
if (version[0] >= 2018) //2018 and up
|
||||
{
|
||||
m_Bindpose = reader.ReadMatrixArray();
|
||||
|
||||
if (version[0] == 2018 && version[1] < 2) //2018.2 down
|
||||
{
|
||||
var m_SourceSkinSize = reader.ReadInt32();
|
||||
for (int i = 0; i < m_SourceSkinSize; i++)
|
||||
{
|
||||
m_SourceSkin[i] = new BoneWeights4(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
textureRect = reader.ReadRectangleF();
|
||||
textureRectOffset = reader.ReadVector2();
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 6)) //5.6 and up
|
||||
{
|
||||
atlasRectOffset = reader.ReadVector2();
|
||||
}
|
||||
|
||||
settingsRaw = new SpriteSettings(reader);
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 5)) //4.5 and up
|
||||
{
|
||||
uvTransform = reader.ReadVector4();
|
||||
}
|
||||
|
||||
if (version[0] >= 2017) //2017 and up
|
||||
{
|
||||
downscaleMultiplier = reader.ReadSingle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class Sprite : NamedObject
|
||||
{
|
||||
public RectangleF m_Rect;
|
||||
public Vector2 m_Offset;
|
||||
public Vector4 m_Border;
|
||||
public float m_PixelsToUnits;
|
||||
public Vector2 m_Pivot;
|
||||
public uint m_Extrude;
|
||||
public bool m_IsPolygon;
|
||||
public KeyValuePair<Guid, long> m_RenderDataKey;
|
||||
public string[] m_AtlasTags;
|
||||
public PPtr<SpriteAtlas> m_SpriteAtlas;
|
||||
public SpriteRenderData m_RD;
|
||||
public Vector2[][] m_PhysicsShape;
|
||||
|
||||
public Sprite(ObjectReader reader) : base(reader)
|
||||
{
|
||||
m_Rect = reader.ReadRectangleF();
|
||||
m_Offset = reader.ReadVector2();
|
||||
if (version[0] > 4 || (version[0] == 4 && version[1] >= 5)) //4.5 and up
|
||||
{
|
||||
m_Border = reader.ReadVector4();
|
||||
}
|
||||
|
||||
m_PixelsToUnits = reader.ReadSingle();
|
||||
if (version[0] > 5
|
||||
|| (version[0] == 5 && version[1] > 4)
|
||||
|| (version[0] == 5 && version[1] == 4 && version[2] >= 2)
|
||||
|| (version[0] == 5 && version[1] == 4 && version[2] == 1 && buildType.IsPatch && version[3] >= 3)) //5.4.1p3 and up
|
||||
{
|
||||
m_Pivot = reader.ReadVector2();
|
||||
}
|
||||
|
||||
m_Extrude = reader.ReadUInt32();
|
||||
if (version[0] > 5 || (version[0] == 5 && version[1] >= 3)) //5.3 and up
|
||||
{
|
||||
m_IsPolygon = reader.ReadBoolean();
|
||||
reader.AlignStream();
|
||||
}
|
||||
|
||||
if (version[0] >= 2017) //2017 and up
|
||||
{
|
||||
var first = new Guid(reader.ReadBytes(16));
|
||||
var second = reader.ReadInt64();
|
||||
m_RenderDataKey = new KeyValuePair<Guid, long>(first, second);
|
||||
|
||||
m_AtlasTags = reader.ReadStringArray();
|
||||
|
||||
m_SpriteAtlas = new PPtr<SpriteAtlas>(reader);
|
||||
}
|
||||
|
||||
m_RD = new SpriteRenderData(reader);
|
||||
|
||||
if (version[0] >= 2017) //2017 and up
|
||||
{
|
||||
var m_PhysicsShapeSize = reader.ReadInt32();
|
||||
m_PhysicsShape = new Vector2[m_PhysicsShapeSize][];
|
||||
for (int i = 0; i < m_PhysicsShapeSize; i++)
|
||||
{
|
||||
m_PhysicsShape[i] = reader.ReadVector2Array();
|
||||
}
|
||||
}
|
||||
|
||||
//vector m_Bones 2018 and up
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,62 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class SpriteAtlas
|
||||
public class SpriteAtlasData
|
||||
{
|
||||
public List<PPtr> textures = new List<PPtr>();
|
||||
public List<RectangleF> textureRects = new List<RectangleF>();
|
||||
public List<Guid> guids = new List<Guid>();
|
||||
public PPtr<Texture2D> texture;
|
||||
public PPtr<Texture2D> alphaTexture;
|
||||
public System.Drawing.RectangleF textureRect;
|
||||
public Vector2 textureRectOffset;
|
||||
public Vector2 atlasRectOffset;
|
||||
public Vector4 uvTransform;
|
||||
public float downscaleMultiplier;
|
||||
public SpriteSettings settingsRaw;
|
||||
|
||||
|
||||
public SpriteAtlas(AssetPreloadData preloadData)
|
||||
public SpriteAtlasData(ObjectReader reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
var version = reader.version;
|
||||
texture = new PPtr<Texture2D>(reader);
|
||||
alphaTexture = new PPtr<Texture2D>(reader);
|
||||
textureRect = reader.ReadRectangleF();
|
||||
textureRectOffset = reader.ReadVector2();
|
||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 2)) //2017.2 and up
|
||||
{
|
||||
atlasRectOffset = reader.ReadVector2();
|
||||
}
|
||||
uvTransform = reader.ReadVector4();
|
||||
downscaleMultiplier = reader.ReadSingle();
|
||||
settingsRaw = new SpriteSettings(reader);
|
||||
}
|
||||
}
|
||||
|
||||
var m_Name = reader.ReadAlignedString();
|
||||
//vector m_PackedSprites
|
||||
var size = reader.ReadInt32();
|
||||
for (int i = 0; i < size; i++)
|
||||
public sealed class SpriteAtlas : NamedObject
|
||||
{
|
||||
public PPtr<Sprite>[] m_PackedSprites;
|
||||
public Dictionary<KeyValuePair<Guid, long>, SpriteAtlasData> m_RenderDataMap;
|
||||
|
||||
public SpriteAtlas(ObjectReader reader) : base(reader)
|
||||
{
|
||||
var m_PackedSpritesSize = reader.ReadInt32();
|
||||
m_PackedSprites = new PPtr<Sprite>[m_PackedSpritesSize];
|
||||
for (int i = 0; i < m_PackedSpritesSize; i++)
|
||||
{
|
||||
//PPtr<Sprite> data
|
||||
sourceFile.ReadPPtr();
|
||||
m_PackedSprites[i] = new PPtr<Sprite>(reader);
|
||||
}
|
||||
//vector m_PackedSpriteNamesToIndex
|
||||
size = reader.ReadInt32();
|
||||
for (int i = 0; i < size; i++)
|
||||
|
||||
var m_PackedSpriteNamesToIndex = reader.ReadStringArray();
|
||||
|
||||
var m_RenderDataMapSize = reader.ReadInt32();
|
||||
m_RenderDataMap = new Dictionary<KeyValuePair<Guid, long>, SpriteAtlasData>(m_RenderDataMapSize);
|
||||
for (int i = 0; i < m_RenderDataMapSize; i++)
|
||||
{
|
||||
var data = reader.ReadAlignedString();
|
||||
}
|
||||
//map m_RenderDataMap
|
||||
size = reader.ReadInt32();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
//pair first
|
||||
guids.Add(new Guid(reader.ReadBytes(16)));
|
||||
var first = new Guid(reader.ReadBytes(16));
|
||||
var second = reader.ReadInt64();
|
||||
//SpriteAtlasData second
|
||||
// PPtr<Texture2D> texture
|
||||
textures.Add(sourceFile.ReadPPtr());
|
||||
// PPtr<Texture2D> alphaTexture
|
||||
var alphaTexture = sourceFile.ReadPPtr();
|
||||
// Rectf textureRect
|
||||
textureRects.Add(new RectangleF(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()));
|
||||
// Vector2f textureRectOffset
|
||||
reader.Position += 8;
|
||||
if (sourceFile.version[0] > 2017 || (sourceFile.version[0] == 2017 && sourceFile.version[1] >= 2))//2017.2 and up
|
||||
{
|
||||
// Vector2f atlasRectOffset
|
||||
reader.Position += 8;
|
||||
}
|
||||
// Vector4f uvTransform
|
||||
// float downscaleMultiplier
|
||||
// unsigned int settingsRaw
|
||||
reader.Position += 24;
|
||||
var value = new SpriteAtlasData(reader);
|
||||
m_RenderDataMap.Add(new KeyValuePair<Guid, long>(first, second), value);
|
||||
}
|
||||
//string m_Tag
|
||||
//bool m_IsVariant
|
||||
|
||||
@@ -6,34 +6,13 @@ using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class TextAsset
|
||||
public sealed class TextAsset : NamedObject
|
||||
{
|
||||
public string m_Name;
|
||||
public byte[] m_Script;
|
||||
|
||||
public TextAsset(AssetPreloadData preloadData, bool readSwitch)
|
||||
public TextAsset(ObjectReader reader) : base(reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
|
||||
if (readSwitch)
|
||||
{
|
||||
m_Script = reader.ReadBytes(reader.ReadInt32());
|
||||
}
|
||||
else
|
||||
{
|
||||
preloadData.extension = ".txt";
|
||||
preloadData.Text = m_Name;
|
||||
}
|
||||
m_Script = reader.ReadBytes(reader.ReadInt32());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
20
AssetStudio/Classes/Texture.cs
Normal file
20
AssetStudio/Classes/Texture.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public abstract class Texture : NamedObject
|
||||
{
|
||||
protected Texture(ObjectReader reader) : base(reader)
|
||||
{
|
||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 3)) //2017.3 and up
|
||||
{
|
||||
var m_ForcedFallbackFormat = reader.ReadInt32();
|
||||
var m_DownscaleFallback = reader.ReadBoolean();
|
||||
reader.AlignStream();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,540 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
partial class Texture2D
|
||||
{
|
||||
[DllImport("PVRTexLibWrapper.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern bool DecompressPVR(byte[] buffer, IntPtr bmp, int len);
|
||||
|
||||
[DllImport("TextureConverterWrapper.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern bool Ponvert(byte[] buffer, IntPtr bmp, int nWidth, int nHeight, int len, int type, int bmpsize, bool fixAlpha);
|
||||
|
||||
[DllImport("crunch.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern bool DecompressCRN(byte[] pSrc_file_data, int src_file_size, out IntPtr uncompressedData, out int uncompressedSize);
|
||||
|
||||
[DllImport("crunchunity.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern bool DecompressUnityCRN(byte[] pSrc_file_data, int src_file_size, out IntPtr uncompressedData, out int uncompressedSize);
|
||||
|
||||
[DllImport("texgenpack.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern void texgenpackdecode(int texturetype, byte[] texturedata, int width, int height, IntPtr bmp, bool fixAlpha);
|
||||
|
||||
|
||||
public byte[] ConvertToContainer()
|
||||
{
|
||||
if (image_data == null || image_data.Length == 0)
|
||||
return null;
|
||||
switch (m_TextureFormat)
|
||||
{
|
||||
case TextureFormat.Alpha8:
|
||||
case TextureFormat.ARGB4444:
|
||||
case TextureFormat.RGB24:
|
||||
case TextureFormat.RGBA32:
|
||||
case TextureFormat.ARGB32:
|
||||
case TextureFormat.RGB565:
|
||||
case TextureFormat.R16:
|
||||
case TextureFormat.DXT1:
|
||||
case TextureFormat.DXT5:
|
||||
case TextureFormat.RGBA4444:
|
||||
case TextureFormat.BGRA32:
|
||||
case TextureFormat.RG16:
|
||||
case TextureFormat.R8:
|
||||
return ConvertToDDS();
|
||||
case TextureFormat.YUY2:
|
||||
case TextureFormat.PVRTC_RGB2:
|
||||
case TextureFormat.PVRTC_RGBA2:
|
||||
case TextureFormat.PVRTC_RGB4:
|
||||
case TextureFormat.PVRTC_RGBA4:
|
||||
case TextureFormat.ETC_RGB4:
|
||||
case TextureFormat.ETC2_RGB:
|
||||
case TextureFormat.ETC2_RGBA1:
|
||||
case TextureFormat.ETC2_RGBA8:
|
||||
case TextureFormat.ASTC_RGB_4x4:
|
||||
case TextureFormat.ASTC_RGB_5x5:
|
||||
case TextureFormat.ASTC_RGB_6x6:
|
||||
case TextureFormat.ASTC_RGB_8x8:
|
||||
case TextureFormat.ASTC_RGB_10x10:
|
||||
case TextureFormat.ASTC_RGB_12x12:
|
||||
case TextureFormat.ASTC_RGBA_4x4:
|
||||
case TextureFormat.ASTC_RGBA_5x5:
|
||||
case TextureFormat.ASTC_RGBA_6x6:
|
||||
case TextureFormat.ASTC_RGBA_8x8:
|
||||
case TextureFormat.ASTC_RGBA_10x10:
|
||||
case TextureFormat.ASTC_RGBA_12x12:
|
||||
case TextureFormat.ETC_RGB4_3DS:
|
||||
case TextureFormat.ETC_RGBA8_3DS:
|
||||
return ConvertToPVR();
|
||||
case TextureFormat.RHalf:
|
||||
case TextureFormat.RGHalf:
|
||||
case TextureFormat.RGBAHalf:
|
||||
case TextureFormat.RFloat:
|
||||
case TextureFormat.RGFloat:
|
||||
case TextureFormat.RGBAFloat:
|
||||
case TextureFormat.BC4:
|
||||
case TextureFormat.BC5:
|
||||
case TextureFormat.BC6H:
|
||||
case TextureFormat.BC7:
|
||||
case TextureFormat.ATC_RGB4:
|
||||
case TextureFormat.ATC_RGBA8:
|
||||
case TextureFormat.EAC_R:
|
||||
case TextureFormat.EAC_R_SIGNED:
|
||||
case TextureFormat.EAC_RG:
|
||||
case TextureFormat.EAC_RG_SIGNED:
|
||||
return ConvertToKTX();
|
||||
default:
|
||||
return image_data;
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] ConvertToDDS()
|
||||
{
|
||||
var imageBuffer = new byte[128 + image_data_size];
|
||||
dwMagic.CopyTo(imageBuffer, 0);
|
||||
BitConverter.GetBytes(dwFlags).CopyTo(imageBuffer, 8);
|
||||
BitConverter.GetBytes(m_Height).CopyTo(imageBuffer, 12);
|
||||
BitConverter.GetBytes(m_Width).CopyTo(imageBuffer, 16);
|
||||
BitConverter.GetBytes(dwPitchOrLinearSize).CopyTo(imageBuffer, 20);
|
||||
BitConverter.GetBytes(dwMipMapCount).CopyTo(imageBuffer, 28);
|
||||
BitConverter.GetBytes(dwSize).CopyTo(imageBuffer, 76);
|
||||
BitConverter.GetBytes(dwFlags2).CopyTo(imageBuffer, 80);
|
||||
BitConverter.GetBytes(dwFourCC).CopyTo(imageBuffer, 84);
|
||||
BitConverter.GetBytes(dwRGBBitCount).CopyTo(imageBuffer, 88);
|
||||
BitConverter.GetBytes(dwRBitMask).CopyTo(imageBuffer, 92);
|
||||
BitConverter.GetBytes(dwGBitMask).CopyTo(imageBuffer, 96);
|
||||
BitConverter.GetBytes(dwBBitMask).CopyTo(imageBuffer, 100);
|
||||
BitConverter.GetBytes(dwABitMask).CopyTo(imageBuffer, 104);
|
||||
BitConverter.GetBytes(dwCaps).CopyTo(imageBuffer, 108);
|
||||
BitConverter.GetBytes(dwCaps2).CopyTo(imageBuffer, 112);
|
||||
image_data.CopyTo(imageBuffer, 128);
|
||||
return imageBuffer;
|
||||
}
|
||||
|
||||
private byte[] ConvertToPVR()
|
||||
{
|
||||
var mstream = new MemoryStream();
|
||||
using (var writer = new BinaryWriter(mstream))
|
||||
{
|
||||
writer.Write(pvrVersion);
|
||||
writer.Write(pvrFlags);
|
||||
writer.Write(pvrPixelFormat);
|
||||
writer.Write(pvrColourSpace);
|
||||
writer.Write(pvrChannelType);
|
||||
writer.Write(m_Height);
|
||||
writer.Write(m_Width);
|
||||
writer.Write(pvrDepth);
|
||||
writer.Write(pvrNumSurfaces);
|
||||
writer.Write(pvrNumFaces);
|
||||
writer.Write(dwMipMapCount);
|
||||
writer.Write(pvrMetaDataSize);
|
||||
writer.Write(image_data);
|
||||
return mstream.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] ConvertToKTX()
|
||||
{
|
||||
var mstream = new MemoryStream();
|
||||
using (var writer = new BinaryWriter(mstream))
|
||||
{
|
||||
writer.Write(KTXHeader.IDENTIFIER);
|
||||
writer.Write(KTXHeader.ENDIANESS_LE);
|
||||
writer.Write(glType);
|
||||
writer.Write(glTypeSize);
|
||||
writer.Write(glFormat);
|
||||
writer.Write(glInternalFormat);
|
||||
writer.Write(glBaseInternalFormat);
|
||||
writer.Write(m_Width);
|
||||
writer.Write(m_Height);
|
||||
writer.Write(pixelDepth);
|
||||
writer.Write(numberOfArrayElements);
|
||||
writer.Write(numberOfFaces);
|
||||
writer.Write(numberOfMipmapLevels);
|
||||
writer.Write(bytesOfKeyValueData);
|
||||
writer.Write(image_data_size);
|
||||
writer.Write(image_data);
|
||||
return mstream.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public Bitmap ConvertToBitmap(bool flip)
|
||||
{
|
||||
if (image_data == null || image_data.Length == 0)
|
||||
return null;
|
||||
Bitmap bitmap;
|
||||
switch (m_TextureFormat)
|
||||
{
|
||||
case TextureFormat.Alpha8:
|
||||
case TextureFormat.ARGB4444:
|
||||
case TextureFormat.RGB24:
|
||||
case TextureFormat.RGBA32:
|
||||
case TextureFormat.ARGB32:
|
||||
case TextureFormat.R16:
|
||||
case TextureFormat.RGBA4444:
|
||||
case TextureFormat.BGRA32:
|
||||
case TextureFormat.RG16:
|
||||
case TextureFormat.R8:
|
||||
bitmap = BGRA32ToBitmap();
|
||||
break;
|
||||
case TextureFormat.RGB565:
|
||||
bitmap = RGB565ToBitmap();
|
||||
break;
|
||||
case TextureFormat.YUY2:
|
||||
case TextureFormat.PVRTC_RGB2:
|
||||
case TextureFormat.PVRTC_RGBA2:
|
||||
case TextureFormat.PVRTC_RGB4:
|
||||
case TextureFormat.PVRTC_RGBA4:
|
||||
case TextureFormat.ETC_RGB4:
|
||||
case TextureFormat.ETC2_RGB:
|
||||
case TextureFormat.ETC2_RGBA1:
|
||||
case TextureFormat.ETC2_RGBA8:
|
||||
case TextureFormat.ASTC_RGB_4x4:
|
||||
case TextureFormat.ASTC_RGB_5x5:
|
||||
case TextureFormat.ASTC_RGB_6x6:
|
||||
case TextureFormat.ASTC_RGB_8x8:
|
||||
case TextureFormat.ASTC_RGB_10x10:
|
||||
case TextureFormat.ASTC_RGB_12x12:
|
||||
case TextureFormat.ASTC_RGBA_4x4:
|
||||
case TextureFormat.ASTC_RGBA_5x5:
|
||||
case TextureFormat.ASTC_RGBA_6x6:
|
||||
case TextureFormat.ASTC_RGBA_8x8:
|
||||
case TextureFormat.ASTC_RGBA_10x10:
|
||||
case TextureFormat.ASTC_RGBA_12x12:
|
||||
case TextureFormat.ETC_RGB4_3DS:
|
||||
case TextureFormat.ETC_RGBA8_3DS:
|
||||
bitmap = PVRToBitmap(ConvertToPVR());
|
||||
break;
|
||||
case TextureFormat.DXT1:
|
||||
case TextureFormat.DXT5:
|
||||
case TextureFormat.RHalf:
|
||||
case TextureFormat.RGHalf:
|
||||
case TextureFormat.RGBAHalf:
|
||||
case TextureFormat.RFloat:
|
||||
case TextureFormat.RGFloat:
|
||||
case TextureFormat.RGBAFloat:
|
||||
case TextureFormat.RGB9e5Float:
|
||||
case TextureFormat.ATC_RGB4:
|
||||
case TextureFormat.ATC_RGBA8:
|
||||
case TextureFormat.EAC_R:
|
||||
case TextureFormat.EAC_R_SIGNED:
|
||||
case TextureFormat.EAC_RG:
|
||||
case TextureFormat.EAC_RG_SIGNED:
|
||||
bitmap = TextureConverter();
|
||||
break;
|
||||
case TextureFormat.BC4:
|
||||
case TextureFormat.BC5:
|
||||
case TextureFormat.BC6H:
|
||||
case TextureFormat.BC7:
|
||||
bitmap = Texgenpack();
|
||||
break;
|
||||
case TextureFormat.DXT1Crunched:
|
||||
case TextureFormat.DXT5Crunched:
|
||||
DecompressCRN();
|
||||
bitmap = TextureConverter();
|
||||
break;
|
||||
case TextureFormat.ETC_RGB4Crunched:
|
||||
case TextureFormat.ETC2_RGBA8Crunched:
|
||||
DecompressCRN();
|
||||
bitmap = PVRToBitmap(ConvertToPVR());
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
if (bitmap != null && flip)
|
||||
bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private Bitmap BGRA32ToBitmap()
|
||||
{
|
||||
var hObject = GCHandle.Alloc(image_data, GCHandleType.Pinned);
|
||||
var pObject = hObject.AddrOfPinnedObject();
|
||||
var bitmap = new Bitmap(m_Width, m_Height, m_Width * 4, PixelFormat.Format32bppArgb, pObject);
|
||||
hObject.Free();
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private Bitmap RGB565ToBitmap()
|
||||
{
|
||||
//stride = m_Width * 2 + m_Width * 2 % 4
|
||||
//所以m_Width * 2不为4的倍数时,需要在每行补上相应的像素
|
||||
byte[] buff;
|
||||
var padding = m_Width * 2 % 4;
|
||||
var stride = m_Width * 2 + padding;
|
||||
if (padding != 0)
|
||||
{
|
||||
buff = new byte[stride * m_Height];
|
||||
for (int i = 0; i < m_Height; i++)
|
||||
{
|
||||
Array.Copy(image_data, i * m_Width * 2, buff, i * stride, m_Width * 2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buff = image_data;
|
||||
}
|
||||
var hObject = GCHandle.Alloc(buff, GCHandleType.Pinned);
|
||||
var pObject = hObject.AddrOfPinnedObject();
|
||||
var bitmap = new Bitmap(m_Width, m_Height, stride, PixelFormat.Format16bppRgb565, pObject);
|
||||
hObject.Free();
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private Bitmap PVRToBitmap(byte[] pvrdata)
|
||||
{
|
||||
var bitmap = new Bitmap(m_Width, m_Height);
|
||||
var rect = new Rectangle(0, 0, m_Width, m_Height);
|
||||
var bmd = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
var len = Math.Abs(bmd.Stride) * bmd.Height;
|
||||
if (!DecompressPVR(pvrdata, bmd.Scan0, len))
|
||||
{
|
||||
bitmap.UnlockBits(bmd);
|
||||
bitmap.Dispose();
|
||||
return null;
|
||||
}
|
||||
bitmap.UnlockBits(bmd);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private Bitmap TextureConverter()
|
||||
{
|
||||
var bitmap = new Bitmap(m_Width, m_Height);
|
||||
var rect = new Rectangle(0, 0, m_Width, m_Height);
|
||||
var bmd = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
var len = Math.Abs(bmd.Stride) * bmd.Height;
|
||||
var fixAlpha = glBaseInternalFormat == KTXHeader.GL_RED || glBaseInternalFormat == KTXHeader.GL_RG;
|
||||
if (!Ponvert(image_data, bmd.Scan0, m_Width, m_Height, image_data_size, (int)q_format, len, fixAlpha))
|
||||
{
|
||||
bitmap.UnlockBits(bmd);
|
||||
bitmap.Dispose();
|
||||
return null;
|
||||
}
|
||||
bitmap.UnlockBits(bmd);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private void DecompressCRN()
|
||||
{
|
||||
IntPtr uncompressedData;
|
||||
int uncompressedSize;
|
||||
bool result;
|
||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 3)) //2017.3 and up
|
||||
{
|
||||
result = DecompressUnityCRN(image_data, image_data_size, out uncompressedData, out uncompressedSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = DecompressCRN(image_data, image_data_size, out uncompressedData, out uncompressedSize);
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
var uncompressedBytes = new byte[uncompressedSize];
|
||||
Marshal.Copy(uncompressedData, uncompressedBytes, 0, uncompressedSize);
|
||||
Marshal.FreeHGlobal(uncompressedData);
|
||||
image_data = uncompressedBytes;
|
||||
image_data_size = uncompressedSize;
|
||||
}
|
||||
}
|
||||
|
||||
private Bitmap Texgenpack()
|
||||
{
|
||||
var bitmap = new Bitmap(m_Width, m_Height);
|
||||
var rect = new Rectangle(0, 0, m_Width, m_Height);
|
||||
var bmd = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
var fixAlpha = glBaseInternalFormat == KTXHeader.GL_RED || glBaseInternalFormat == KTXHeader.GL_RG;
|
||||
texgenpackdecode((int)texturetype, image_data, m_Width, m_Height, bmd.Scan0, fixAlpha);
|
||||
bitmap.UnlockBits(bmd);
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
|
||||
public static class KTXHeader
|
||||
{
|
||||
public static byte[] IDENTIFIER = { 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A };
|
||||
public static byte[] ENDIANESS_LE = { 1, 2, 3, 4 };
|
||||
public static byte[] ENDIANESS_BE = { 4, 3, 2, 1 };
|
||||
|
||||
// constants for glInternalFormat
|
||||
public static int GL_ETC1_RGB8_OES = 0x8D64;
|
||||
|
||||
public static int GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00;
|
||||
public static int GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01;
|
||||
public static int GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02;
|
||||
public static int GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03;
|
||||
|
||||
public static int GL_ATC_RGB_AMD = 0x8C92;
|
||||
public static int GL_ATC_RGBA_EXPLICIT_ALPHA_AMD = 0x8C93;
|
||||
public static int GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD = 0x87EE;
|
||||
|
||||
public static int GL_COMPRESSED_RGB8_ETC2 = 0x9274;
|
||||
public static int GL_COMPRESSED_SRGB8_ETC2 = 0x9275;
|
||||
public static int GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276;
|
||||
public static int GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277;
|
||||
public static int GL_COMPRESSED_RGBA8_ETC2_EAC = 0x9278;
|
||||
public static int GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279;
|
||||
public static int GL_COMPRESSED_R11_EAC = 0x9270;
|
||||
public static int GL_COMPRESSED_SIGNED_R11_EAC = 0x9271;
|
||||
public static int GL_COMPRESSED_RG11_EAC = 0x9272;
|
||||
public static int GL_COMPRESSED_SIGNED_RG11_EAC = 0x9273;
|
||||
|
||||
public static int GL_COMPRESSED_RED_RGTC1 = 0x8DBB;
|
||||
public static int GL_COMPRESSED_RG_RGTC2 = 0x8DBD;
|
||||
public static int GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT = 0x8E8F;
|
||||
public static int GL_COMPRESSED_RGBA_BPTC_UNORM = 0x8E8C;
|
||||
|
||||
public static int GL_R16F = 0x822D;
|
||||
public static int GL_RG16F = 0x822F;
|
||||
public static int GL_RGBA16F = 0x881A;
|
||||
public static int GL_R32F = 0x822E;
|
||||
public static int GL_RG32F = 0x8230;
|
||||
public static int GL_RGBA32F = 0x8814;
|
||||
|
||||
// constants for glBaseInternalFormat
|
||||
public static int GL_RED = 0x1903;
|
||||
public static int GL_GREEN = 0x1904;
|
||||
public static int GL_BLUE = 0x1905;
|
||||
public static int GL_ALPHA = 0x1906;
|
||||
public static int GL_RGB = 0x1907;
|
||||
public static int GL_RGBA = 0x1908;
|
||||
public static int GL_RG = 0x8227;
|
||||
}
|
||||
|
||||
//from TextureConverter.h
|
||||
public enum QFORMAT
|
||||
{
|
||||
// General formats
|
||||
Q_FORMAT_RGBA_8UI = 1,
|
||||
Q_FORMAT_RGBA_8I,
|
||||
Q_FORMAT_RGB5_A1UI,
|
||||
Q_FORMAT_RGBA_4444,
|
||||
Q_FORMAT_RGBA_16UI,
|
||||
Q_FORMAT_RGBA_16I,
|
||||
Q_FORMAT_RGBA_32UI,
|
||||
Q_FORMAT_RGBA_32I,
|
||||
|
||||
Q_FORMAT_PALETTE_8_RGBA_8888,
|
||||
Q_FORMAT_PALETTE_8_RGBA_5551,
|
||||
Q_FORMAT_PALETTE_8_RGBA_4444,
|
||||
Q_FORMAT_PALETTE_4_RGBA_8888,
|
||||
Q_FORMAT_PALETTE_4_RGBA_5551,
|
||||
Q_FORMAT_PALETTE_4_RGBA_4444,
|
||||
Q_FORMAT_PALETTE_1_RGBA_8888,
|
||||
Q_FORMAT_PALETTE_8_RGB_888,
|
||||
Q_FORMAT_PALETTE_8_RGB_565,
|
||||
Q_FORMAT_PALETTE_4_RGB_888,
|
||||
Q_FORMAT_PALETTE_4_RGB_565,
|
||||
|
||||
Q_FORMAT_R2_GBA10UI,
|
||||
Q_FORMAT_RGB10_A2UI,
|
||||
Q_FORMAT_RGB10_A2I,
|
||||
Q_FORMAT_RGBA_F,
|
||||
Q_FORMAT_RGBA_HF,
|
||||
|
||||
Q_FORMAT_RGB9_E5, // Last five bits are exponent bits (Read following section in GLES3 spec: "3.8.17 Shared Exponent Texture Color Conversion")
|
||||
Q_FORMAT_RGB_8UI,
|
||||
Q_FORMAT_RGB_8I,
|
||||
Q_FORMAT_RGB_565,
|
||||
Q_FORMAT_RGB_16UI,
|
||||
Q_FORMAT_RGB_16I,
|
||||
Q_FORMAT_RGB_32UI,
|
||||
Q_FORMAT_RGB_32I,
|
||||
|
||||
Q_FORMAT_RGB_F,
|
||||
Q_FORMAT_RGB_HF,
|
||||
Q_FORMAT_RGB_11_11_10_F,
|
||||
|
||||
Q_FORMAT_RG_F,
|
||||
Q_FORMAT_RG_HF,
|
||||
Q_FORMAT_RG_32UI,
|
||||
Q_FORMAT_RG_32I,
|
||||
Q_FORMAT_RG_16I,
|
||||
Q_FORMAT_RG_16UI,
|
||||
Q_FORMAT_RG_8I,
|
||||
Q_FORMAT_RG_8UI,
|
||||
Q_FORMAT_RG_S88,
|
||||
|
||||
Q_FORMAT_R_32UI,
|
||||
Q_FORMAT_R_32I,
|
||||
Q_FORMAT_R_F,
|
||||
Q_FORMAT_R_16F,
|
||||
Q_FORMAT_R_16I,
|
||||
Q_FORMAT_R_16UI,
|
||||
Q_FORMAT_R_8I,
|
||||
Q_FORMAT_R_8UI,
|
||||
|
||||
Q_FORMAT_LUMINANCE_ALPHA_88,
|
||||
Q_FORMAT_LUMINANCE_8,
|
||||
Q_FORMAT_ALPHA_8,
|
||||
|
||||
Q_FORMAT_LUMINANCE_ALPHA_F,
|
||||
Q_FORMAT_LUMINANCE_F,
|
||||
Q_FORMAT_ALPHA_F,
|
||||
Q_FORMAT_LUMINANCE_ALPHA_HF,
|
||||
Q_FORMAT_LUMINANCE_HF,
|
||||
Q_FORMAT_ALPHA_HF,
|
||||
Q_FORMAT_DEPTH_16,
|
||||
Q_FORMAT_DEPTH_24,
|
||||
Q_FORMAT_DEPTH_24_STENCIL_8,
|
||||
Q_FORMAT_DEPTH_32,
|
||||
|
||||
Q_FORMAT_BGR_565,
|
||||
Q_FORMAT_BGRA_8888,
|
||||
Q_FORMAT_BGRA_5551,
|
||||
Q_FORMAT_BGRX_8888,
|
||||
Q_FORMAT_BGRA_4444,
|
||||
// Compressed formats
|
||||
Q_FORMAT_ATITC_RGBA,
|
||||
Q_FORMAT_ATC_RGBA_EXPLICIT_ALPHA = Q_FORMAT_ATITC_RGBA,
|
||||
Q_FORMAT_ATITC_RGB,
|
||||
Q_FORMAT_ATC_RGB = Q_FORMAT_ATITC_RGB,
|
||||
Q_FORMAT_ATC_RGBA_INTERPOLATED_ALPHA,
|
||||
Q_FORMAT_ETC1_RGB8,
|
||||
Q_FORMAT_3DC_X,
|
||||
Q_FORMAT_3DC_XY,
|
||||
|
||||
Q_FORMAT_ETC2_RGB8,
|
||||
Q_FORMAT_ETC2_RGBA8,
|
||||
Q_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1,
|
||||
Q_FORMAT_ETC2_SRGB8,
|
||||
Q_FORMAT_ETC2_SRGB8_ALPHA8,
|
||||
Q_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1,
|
||||
Q_FORMAT_EAC_R_SIGNED,
|
||||
Q_FORMAT_EAC_R_UNSIGNED,
|
||||
Q_FORMAT_EAC_RG_SIGNED,
|
||||
Q_FORMAT_EAC_RG_UNSIGNED,
|
||||
|
||||
Q_FORMAT_S3TC_DXT1_RGB,
|
||||
Q_FORMAT_S3TC_DXT1_RGBA,
|
||||
Q_FORMAT_S3TC_DXT3_RGBA,
|
||||
Q_FORMAT_S3TC_DXT5_RGBA,
|
||||
|
||||
// YUV formats
|
||||
Q_FORMAT_AYUV_32,
|
||||
Q_FORMAT_I444_24,
|
||||
Q_FORMAT_YUYV_16,
|
||||
Q_FORMAT_UYVY_16,
|
||||
Q_FORMAT_I420_12,
|
||||
Q_FORMAT_YV12_12,
|
||||
Q_FORMAT_NV21_12,
|
||||
Q_FORMAT_NV12_12,
|
||||
|
||||
// ASTC Format
|
||||
Q_FORMAT_ASTC_8,
|
||||
Q_FORMAT_ASTC_16,
|
||||
};
|
||||
|
||||
public enum texgenpack_texturetype
|
||||
{
|
||||
RGTC1,
|
||||
RGTC2,
|
||||
BPTC_FLOAT,
|
||||
BPTC
|
||||
}
|
||||
}
|
||||
@@ -1,778 +1,108 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
partial class Texture2D
|
||||
public class StreamingInfo
|
||||
{
|
||||
public string m_Name;
|
||||
public int m_Width;
|
||||
public int m_Height;
|
||||
public int m_CompleteImageSize;
|
||||
public TextureFormat m_TextureFormat;
|
||||
public bool m_MipMap;
|
||||
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 byte[] image_data;
|
||||
//m_StreamData
|
||||
public uint offset;
|
||||
public uint size;
|
||||
public string path;
|
||||
|
||||
//DDS Start
|
||||
private byte[] dwMagic = { 0x44, 0x44, 0x53, 0x20, 0x7c };
|
||||
private int dwFlags = 0x1 + 0x2 + 0x4 + 0x1000;
|
||||
//public int dwHeight; m_Height
|
||||
//public int dwWidth; m_Width
|
||||
private int dwPitchOrLinearSize;
|
||||
private int dwMipMapCount = 0x1;
|
||||
private int dwSize = 0x20;
|
||||
private int dwFlags2;
|
||||
private int dwFourCC;
|
||||
private int dwRGBBitCount;
|
||||
private int dwRBitMask;
|
||||
private int dwGBitMask;
|
||||
private int dwBBitMask;
|
||||
private int dwABitMask;
|
||||
private int dwCaps = 0x1000;
|
||||
private int dwCaps2 = 0x0;
|
||||
//DDS End
|
||||
//PVR Start
|
||||
private int pvrVersion = 0x03525650;
|
||||
private int pvrFlags = 0x0;
|
||||
private long pvrPixelFormat;
|
||||
private int pvrColourSpace = 0x0;
|
||||
private int pvrChannelType = 0x0;
|
||||
//public int pvrHeight; m_Height
|
||||
//public int pvrWidth; m_Width
|
||||
private int pvrDepth = 0x1;
|
||||
private int pvrNumSurfaces = 0x1; //For texture arrays
|
||||
private int pvrNumFaces = 0x1; //For cube maps
|
||||
//public int pvrMIPMapCount; dwMipMapCount
|
||||
private int pvrMetaDataSize = 0x0;
|
||||
//PVR End
|
||||
//KTX Start
|
||||
private int glType = 0;
|
||||
private int glTypeSize = 1;
|
||||
private int glFormat = 0;
|
||||
private int glInternalFormat;
|
||||
private int glBaseInternalFormat;
|
||||
//public int pixelWidth; m_Width
|
||||
//public int pixelHeight; m_Height
|
||||
private int pixelDepth = 0;
|
||||
private int numberOfArrayElements = 0;
|
||||
private int numberOfFaces = 1;
|
||||
private int numberOfMipmapLevels = 1;
|
||||
private int bytesOfKeyValueData = 0;
|
||||
//KTX End
|
||||
//TextureConverter
|
||||
private QFORMAT q_format;
|
||||
//texgenpack
|
||||
private texgenpack_texturetype texturetype;
|
||||
|
||||
private int[] version;
|
||||
|
||||
public Texture2D(AssetPreloadData preloadData, bool readSwitch)
|
||||
public StreamingInfo(ObjectReader reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
version = sourceFile.version;
|
||||
offset = reader.ReadUInt32();
|
||||
size = reader.ReadUInt32();
|
||||
path = reader.ReadAlignedString();
|
||||
}
|
||||
}
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
public class GLTextureSettings
|
||||
{
|
||||
public int m_FilterMode;
|
||||
public int m_Aniso;
|
||||
public float m_MipBias;
|
||||
public int m_WrapMode;
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 3))//2017.3 and up
|
||||
{
|
||||
var m_ForcedFallbackFormat = reader.ReadInt32();
|
||||
var m_DownscaleFallback = reader.ReadBoolean();
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
m_Width = reader.ReadInt32();
|
||||
m_Height = reader.ReadInt32();
|
||||
m_CompleteImageSize = reader.ReadInt32();
|
||||
m_TextureFormat = (TextureFormat)reader.ReadInt32();
|
||||
public GLTextureSettings(ObjectReader reader)
|
||||
{
|
||||
var version = reader.version;
|
||||
|
||||
if (version[0] < 5 || (version[0] == 5 && version[1] < 2))
|
||||
{ m_MipMap = reader.ReadBoolean(); }
|
||||
else
|
||||
{
|
||||
dwFlags += 0x20000;
|
||||
dwMipMapCount = reader.ReadInt32();//is this with or without main image?
|
||||
dwCaps += 0x400008;
|
||||
}
|
||||
|
||||
m_IsReadable = reader.ReadBoolean(); //2.6.0 and up
|
||||
m_ReadAllowed = reader.ReadBoolean(); //3.0.0 - 5.4
|
||||
reader.AlignStream(4);
|
||||
|
||||
m_ImageCount = reader.ReadInt32();
|
||||
m_TextureDimension = reader.ReadInt32();
|
||||
//m_TextureSettings
|
||||
m_FilterMode = reader.ReadInt32();
|
||||
m_Aniso = reader.ReadInt32();
|
||||
m_MipBias = reader.ReadSingle();
|
||||
m_WrapMode = reader.ReadInt32();
|
||||
if (version[0] >= 2017)//2017.x and up
|
||||
{
|
||||
m_WrapMode = reader.ReadInt32(); //m_WrapU
|
||||
int m_WrapV = reader.ReadInt32();
|
||||
int m_WrapW = reader.ReadInt32();
|
||||
}
|
||||
if (version[0] >= 3)
|
||||
else
|
||||
{
|
||||
m_LightmapFormat = reader.ReadInt32();
|
||||
if (version[0] >= 4 || version[1] >= 5) { m_ColorSpace = reader.ReadInt32(); } //3.5.0 and up
|
||||
m_WrapMode = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
image_data_size = reader.ReadInt32();
|
||||
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 ResourceReader image_data;
|
||||
public StreamingInfo m_StreamData;
|
||||
|
||||
if (m_MipMap)
|
||||
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
|
||||
{
|
||||
dwFlags += 0x20000;
|
||||
dwMipMapCount = Convert.ToInt32(Math.Log(Math.Max(m_Width, m_Height)) / Math.Log(2));
|
||||
dwCaps += 0x400008;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
if (readSwitch)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
var resourceFileName = Path.GetFileName(path);
|
||||
var resourceFilePath = Path.GetDirectoryName(sourceFile.filePath) + "\\" + resourceFileName;
|
||||
if (!File.Exists(resourceFilePath))
|
||||
{
|
||||
var findFiles = Directory.GetFiles(Path.GetDirectoryName(sourceFile.filePath), resourceFileName, SearchOption.AllDirectories);
|
||||
if (findFiles.Length > 0)
|
||||
{
|
||||
resourceFilePath = findFiles[0];
|
||||
}
|
||||
}
|
||||
if (File.Exists(resourceFilePath))
|
||||
{
|
||||
using (var resourceReader = new BinaryReader(File.OpenRead(resourceFilePath)))
|
||||
{
|
||||
resourceReader.BaseStream.Position = offset;
|
||||
image_data = resourceReader.ReadBytes(image_data_size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Studio.resourceFileReaders.TryGetValue(resourceFileName.ToUpper(), out var resourceReader))
|
||||
{
|
||||
resourceReader.Position = offset;
|
||||
image_data = resourceReader.ReadBytes(image_data_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"can't find the resource file {resourceFileName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
image_data = reader.ReadBytes(image_data_size);
|
||||
}
|
||||
|
||||
switch (m_TextureFormat)
|
||||
{
|
||||
//TODO 导出到DDS容器时应该用原像素还是转换以后的像素?
|
||||
case TextureFormat.Alpha8: //test pass
|
||||
{
|
||||
/*dwFlags2 = 0x2;
|
||||
dwRGBBitCount = 0x8;
|
||||
dwRBitMask = 0x0;
|
||||
dwGBitMask = 0x0;
|
||||
dwBBitMask = 0x0;
|
||||
dwABitMask = 0xFF; */
|
||||
|
||||
//转BGRA32
|
||||
var BGRA32 = Enumerable.Repeat<byte>(0xFF, image_data_size * 4).ToArray();
|
||||
for (var i = 0; i < image_data_size; i++)
|
||||
{
|
||||
BGRA32[i * 4 + 3] = image_data[i];
|
||||
}
|
||||
SetBGRA32Info(BGRA32);
|
||||
break;
|
||||
}
|
||||
case TextureFormat.ARGB4444: //test pass
|
||||
{
|
||||
SwapBytesForXbox(sourceFile.platform);
|
||||
|
||||
/*dwFlags2 = 0x41;
|
||||
dwRGBBitCount = 0x10;
|
||||
dwRBitMask = 0xF00;
|
||||
dwGBitMask = 0xF0;
|
||||
dwBBitMask = 0xF;
|
||||
dwABitMask = 0xF000;*/
|
||||
|
||||
//转BGRA32
|
||||
var BGRA32 = new byte[image_data_size * 2];
|
||||
for (var i = 0; i < image_data_size / 2; i++)
|
||||
{
|
||||
var pixelNew = new byte[4];
|
||||
var pixelOldShort = BitConverter.ToUInt16(image_data, i * 2);
|
||||
pixelNew[0] = (byte)(pixelOldShort & 0x000f);
|
||||
pixelNew[1] = (byte)((pixelOldShort & 0x00f0) >> 4);
|
||||
pixelNew[2] = (byte)((pixelOldShort & 0x0f00) >> 8);
|
||||
pixelNew[3] = (byte)((pixelOldShort & 0xf000) >> 12);
|
||||
// convert range
|
||||
for (var j = 0; j < 4; j++)
|
||||
pixelNew[j] = (byte)((pixelNew[j] << 4) | pixelNew[j]);
|
||||
pixelNew.CopyTo(BGRA32, i * 4);
|
||||
}
|
||||
SetBGRA32Info(BGRA32);
|
||||
break;
|
||||
}
|
||||
case TextureFormat.RGB24: //test pass
|
||||
{
|
||||
/*dwFlags2 = 0x40;
|
||||
dwRGBBitCount = 0x18;
|
||||
dwRBitMask = 0xFF;
|
||||
dwGBitMask = 0xFF00;
|
||||
dwBBitMask = 0xFF0000;
|
||||
dwABitMask = 0x0;*/
|
||||
|
||||
//转BGRA32
|
||||
var BGRA32 = new byte[image_data_size / 3 * 4];
|
||||
for (var i = 0; i < image_data_size / 3; i++)
|
||||
{
|
||||
BGRA32[i * 4] = image_data[i * 3 + 2];
|
||||
BGRA32[i * 4 + 1] = image_data[i * 3 + 1];
|
||||
BGRA32[i * 4 + 2] = image_data[i * 3 + 0];
|
||||
BGRA32[i * 4 + 3] = 255;
|
||||
}
|
||||
SetBGRA32Info(BGRA32);
|
||||
break;
|
||||
}
|
||||
case TextureFormat.RGBA32: //test pass
|
||||
{
|
||||
/*dwFlags2 = 0x41;
|
||||
dwRGBBitCount = 0x20;
|
||||
dwRBitMask = 0xFF;
|
||||
dwGBitMask = 0xFF00;
|
||||
dwBBitMask = 0xFF0000;
|
||||
dwABitMask = -16777216;*/
|
||||
|
||||
//转BGRA32
|
||||
var BGRA32 = new byte[image_data_size];
|
||||
for (var i = 0; i < image_data_size; i += 4)
|
||||
{
|
||||
BGRA32[i] = image_data[i + 2];
|
||||
BGRA32[i + 1] = image_data[i + 1];
|
||||
BGRA32[i + 2] = image_data[i + 0];
|
||||
BGRA32[i + 3] = image_data[i + 3];
|
||||
}
|
||||
SetBGRA32Info(BGRA32);
|
||||
break;
|
||||
}
|
||||
case TextureFormat.ARGB32://test pass
|
||||
{
|
||||
/*dwFlags2 = 0x41;
|
||||
dwRGBBitCount = 0x20;
|
||||
dwRBitMask = 0xFF00;
|
||||
dwGBitMask = 0xFF0000;
|
||||
dwBBitMask = -16777216;
|
||||
dwABitMask = 0xFF;*/
|
||||
|
||||
//转BGRA32
|
||||
var BGRA32 = new byte[image_data_size];
|
||||
for (var i = 0; i < image_data_size; i += 4)
|
||||
{
|
||||
BGRA32[i] = image_data[i + 3];
|
||||
BGRA32[i + 1] = image_data[i + 2];
|
||||
BGRA32[i + 2] = image_data[i + 1];
|
||||
BGRA32[i + 3] = image_data[i + 0];
|
||||
}
|
||||
SetBGRA32Info(BGRA32);
|
||||
break;
|
||||
}
|
||||
case TextureFormat.RGB565: //test pass
|
||||
{
|
||||
SwapBytesForXbox(sourceFile.platform);
|
||||
|
||||
dwFlags2 = 0x40;
|
||||
dwRGBBitCount = 0x10;
|
||||
dwRBitMask = 0xF800;
|
||||
dwGBitMask = 0x7E0;
|
||||
dwBBitMask = 0x1F;
|
||||
dwABitMask = 0x0;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.R16: //test pass
|
||||
{
|
||||
//转BGRA32
|
||||
var BGRA32 = new byte[image_data_size * 2];
|
||||
for (var i = 0; i < image_data_size; i += 2)
|
||||
{
|
||||
float f = Half.ToHalf(image_data, i);
|
||||
BGRA32[i * 2 + 2] = (byte)Math.Ceiling(f * 255);//R
|
||||
BGRA32[i * 2 + 3] = 255;//A
|
||||
}
|
||||
SetBGRA32Info(BGRA32);
|
||||
break;
|
||||
}
|
||||
case TextureFormat.DXT1: //test pass
|
||||
case TextureFormat.DXT1Crunched: //test pass
|
||||
{
|
||||
SwapBytesForXbox(sourceFile.platform);
|
||||
|
||||
if (m_MipMap) { dwPitchOrLinearSize = m_Height * m_Width / 2; }
|
||||
dwFlags2 = 0x4;
|
||||
dwFourCC = 0x31545844;
|
||||
dwRGBBitCount = 0x0;
|
||||
dwRBitMask = 0x0;
|
||||
dwGBitMask = 0x0;
|
||||
dwBBitMask = 0x0;
|
||||
dwABitMask = 0x0;
|
||||
|
||||
q_format = QFORMAT.Q_FORMAT_S3TC_DXT1_RGB;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.DXT5: //test pass
|
||||
case TextureFormat.DXT5Crunched: //test pass
|
||||
{
|
||||
SwapBytesForXbox(sourceFile.platform);
|
||||
|
||||
if (m_MipMap) { dwPitchOrLinearSize = m_Height * m_Width / 2; }
|
||||
dwFlags2 = 0x4;
|
||||
dwFourCC = 0x35545844;
|
||||
dwRGBBitCount = 0x0;
|
||||
dwRBitMask = 0x0;
|
||||
dwGBitMask = 0x0;
|
||||
dwBBitMask = 0x0;
|
||||
dwABitMask = 0x0;
|
||||
|
||||
q_format = QFORMAT.Q_FORMAT_S3TC_DXT5_RGBA;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.RGBA4444: //test pass
|
||||
{
|
||||
/*dwFlags2 = 0x41;
|
||||
dwRGBBitCount = 0x10;
|
||||
dwRBitMask = 0xF000;
|
||||
dwGBitMask = 0xF00;
|
||||
dwBBitMask = 0xF0;
|
||||
dwABitMask = 0xF;*/
|
||||
|
||||
//转BGRA32
|
||||
var BGRA32 = new byte[image_data_size * 2];
|
||||
for (var i = 0; i < image_data_size / 2; i++)
|
||||
{
|
||||
var pixelNew = new byte[4];
|
||||
var pixelOldShort = BitConverter.ToUInt16(image_data, i * 2);
|
||||
pixelNew[0] = (byte)((pixelOldShort & 0x00f0) >> 4);
|
||||
pixelNew[1] = (byte)((pixelOldShort & 0x0f00) >> 8);
|
||||
pixelNew[2] = (byte)((pixelOldShort & 0xf000) >> 12);
|
||||
pixelNew[3] = (byte)(pixelOldShort & 0x000f);
|
||||
// convert range
|
||||
for (var j = 0; j < 4; j++)
|
||||
pixelNew[j] = (byte)((pixelNew[j] << 4) | pixelNew[j]);
|
||||
pixelNew.CopyTo(BGRA32, i * 4);
|
||||
}
|
||||
SetBGRA32Info(BGRA32);
|
||||
break;
|
||||
}
|
||||
case TextureFormat.BGRA32: //test pass
|
||||
{
|
||||
dwFlags2 = 0x41;
|
||||
dwRGBBitCount = 0x20;
|
||||
dwRBitMask = 0xFF0000;
|
||||
dwGBitMask = 0xFF00;
|
||||
dwBBitMask = 0xFF;
|
||||
dwABitMask = -16777216;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.RHalf: //test pass
|
||||
{
|
||||
q_format = QFORMAT.Q_FORMAT_R_16F;
|
||||
glInternalFormat = KTXHeader.GL_R16F;
|
||||
glBaseInternalFormat = KTXHeader.GL_RED;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.RGHalf: //test pass
|
||||
{
|
||||
q_format = QFORMAT.Q_FORMAT_RG_HF;
|
||||
glInternalFormat = KTXHeader.GL_RG16F;
|
||||
glBaseInternalFormat = KTXHeader.GL_RG;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.RGBAHalf: //test pass
|
||||
{
|
||||
q_format = QFORMAT.Q_FORMAT_RGBA_HF;
|
||||
glInternalFormat = KTXHeader.GL_RGBA16F;
|
||||
glBaseInternalFormat = KTXHeader.GL_RGBA;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.RFloat: //test pass
|
||||
{
|
||||
q_format = QFORMAT.Q_FORMAT_R_F;
|
||||
glInternalFormat = KTXHeader.GL_R32F;
|
||||
glBaseInternalFormat = KTXHeader.GL_RED;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.RGFloat: //test pass
|
||||
{
|
||||
q_format = QFORMAT.Q_FORMAT_RG_F;
|
||||
glInternalFormat = KTXHeader.GL_RG32F;
|
||||
glBaseInternalFormat = KTXHeader.GL_RG;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.RGBAFloat: //test pass
|
||||
{
|
||||
q_format = QFORMAT.Q_FORMAT_RGBA_F;
|
||||
glInternalFormat = KTXHeader.GL_RGBA32F;
|
||||
glBaseInternalFormat = KTXHeader.GL_RGBA;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.YUY2: //test pass
|
||||
{
|
||||
pvrPixelFormat = 17;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.RGB9e5Float:
|
||||
{
|
||||
q_format = QFORMAT.Q_FORMAT_RGB9_E5;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.BC4: //test pass
|
||||
{
|
||||
texturetype = texgenpack_texturetype.RGTC1;
|
||||
glInternalFormat = KTXHeader.GL_COMPRESSED_RED_RGTC1;
|
||||
glBaseInternalFormat = KTXHeader.GL_RED;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.BC5: //test pass
|
||||
{
|
||||
texturetype = texgenpack_texturetype.RGTC2;
|
||||
glInternalFormat = KTXHeader.GL_COMPRESSED_RG_RGTC2;
|
||||
glBaseInternalFormat = KTXHeader.GL_RG;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.BC6H: //test pass
|
||||
{
|
||||
texturetype = texgenpack_texturetype.BPTC_FLOAT;
|
||||
glInternalFormat = KTXHeader.GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT;
|
||||
glBaseInternalFormat = KTXHeader.GL_RGB;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.BC7: //test pass
|
||||
{
|
||||
texturetype = texgenpack_texturetype.BPTC;
|
||||
glInternalFormat = KTXHeader.GL_COMPRESSED_RGBA_BPTC_UNORM;
|
||||
glBaseInternalFormat = KTXHeader.GL_RGBA;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.PVRTC_RGB2: //test pass
|
||||
{
|
||||
pvrPixelFormat = 0;
|
||||
glInternalFormat = KTXHeader.GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
|
||||
glBaseInternalFormat = KTXHeader.GL_RGB;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.PVRTC_RGBA2: //test pass
|
||||
{
|
||||
pvrPixelFormat = 1;
|
||||
glInternalFormat = KTXHeader.GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
|
||||
glBaseInternalFormat = KTXHeader.GL_RGBA;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.PVRTC_RGB4: //test pass
|
||||
{
|
||||
pvrPixelFormat = 2;
|
||||
glInternalFormat = KTXHeader.GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
|
||||
glBaseInternalFormat = KTXHeader.GL_RGB;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.PVRTC_RGBA4: //test pass
|
||||
{
|
||||
pvrPixelFormat = 3;
|
||||
glInternalFormat = KTXHeader.GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
|
||||
glBaseInternalFormat = KTXHeader.GL_RGBA;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.ETC_RGB4Crunched:
|
||||
case TextureFormat.ETC_RGB4_3DS: //test pass
|
||||
case TextureFormat.ETC_RGB4: //test pass
|
||||
{
|
||||
pvrPixelFormat = 6;
|
||||
glInternalFormat = KTXHeader.GL_ETC1_RGB8_OES;
|
||||
glBaseInternalFormat = KTXHeader.GL_RGB;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.ATC_RGB4: //test pass
|
||||
{
|
||||
q_format = QFORMAT.Q_FORMAT_ATITC_RGB;
|
||||
glInternalFormat = KTXHeader.GL_ATC_RGB_AMD;
|
||||
glBaseInternalFormat = KTXHeader.GL_RGB;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.ATC_RGBA8: //test pass
|
||||
{
|
||||
q_format = QFORMAT.Q_FORMAT_ATC_RGBA_INTERPOLATED_ALPHA;
|
||||
glInternalFormat = KTXHeader.GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD;
|
||||
glBaseInternalFormat = KTXHeader.GL_RGBA;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.EAC_R: //test pass
|
||||
{
|
||||
q_format = QFORMAT.Q_FORMAT_EAC_R_UNSIGNED;
|
||||
glInternalFormat = KTXHeader.GL_COMPRESSED_R11_EAC;
|
||||
glBaseInternalFormat = KTXHeader.GL_RED;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.EAC_R_SIGNED: //test pass
|
||||
{
|
||||
q_format = QFORMAT.Q_FORMAT_EAC_R_SIGNED;
|
||||
glInternalFormat = KTXHeader.GL_COMPRESSED_SIGNED_R11_EAC;
|
||||
glBaseInternalFormat = KTXHeader.GL_RED;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.EAC_RG: //test pass
|
||||
{
|
||||
q_format = QFORMAT.Q_FORMAT_EAC_RG_UNSIGNED;
|
||||
glInternalFormat = KTXHeader.GL_COMPRESSED_RG11_EAC;
|
||||
glBaseInternalFormat = KTXHeader.GL_RG;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.EAC_RG_SIGNED: //test pass
|
||||
{
|
||||
q_format = QFORMAT.Q_FORMAT_EAC_RG_SIGNED;
|
||||
glInternalFormat = KTXHeader.GL_COMPRESSED_SIGNED_RG11_EAC;
|
||||
glBaseInternalFormat = KTXHeader.GL_RG;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.ETC2_RGB: //test pass
|
||||
{
|
||||
pvrPixelFormat = 22;
|
||||
glInternalFormat = KTXHeader.GL_COMPRESSED_RGB8_ETC2;
|
||||
glBaseInternalFormat = KTXHeader.GL_RGB;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.ETC2_RGBA1: //test pass
|
||||
{
|
||||
pvrPixelFormat = 24;
|
||||
glInternalFormat = KTXHeader.GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;
|
||||
glBaseInternalFormat = KTXHeader.GL_RGBA;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.ETC2_RGBA8Crunched:
|
||||
case TextureFormat.ETC_RGBA8_3DS: //test pass
|
||||
case TextureFormat.ETC2_RGBA8: //test pass
|
||||
{
|
||||
pvrPixelFormat = 23;
|
||||
glInternalFormat = KTXHeader.GL_COMPRESSED_RGBA8_ETC2_EAC;
|
||||
glBaseInternalFormat = KTXHeader.GL_RGBA;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.ASTC_RGB_4x4: //test pass
|
||||
case TextureFormat.ASTC_RGBA_4x4: //test pass
|
||||
{
|
||||
pvrPixelFormat = 27;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.ASTC_RGB_5x5: //test pass
|
||||
case TextureFormat.ASTC_RGBA_5x5: //test pass
|
||||
{
|
||||
pvrPixelFormat = 29;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.ASTC_RGB_6x6: //test pass
|
||||
case TextureFormat.ASTC_RGBA_6x6: //test pass
|
||||
{
|
||||
pvrPixelFormat = 31;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.ASTC_RGB_8x8: //test pass
|
||||
case TextureFormat.ASTC_RGBA_8x8: //test pass
|
||||
{
|
||||
pvrPixelFormat = 34;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.ASTC_RGB_10x10: //test pass
|
||||
case TextureFormat.ASTC_RGBA_10x10: //test pass
|
||||
{
|
||||
pvrPixelFormat = 38;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.ASTC_RGB_12x12: //test pass
|
||||
case TextureFormat.ASTC_RGBA_12x12: //test pass
|
||||
{
|
||||
pvrPixelFormat = 40;
|
||||
break;
|
||||
}
|
||||
case TextureFormat.RG16: //test pass
|
||||
{
|
||||
//转BGRA32
|
||||
var BGRA32 = new byte[image_data_size * 2];
|
||||
for (var i = 0; i < image_data_size; i += 2)
|
||||
{
|
||||
BGRA32[i * 2 + 1] = image_data[i + 1];//G
|
||||
BGRA32[i * 2 + 2] = image_data[i];//R
|
||||
BGRA32[i * 2 + 3] = 255;//A
|
||||
}
|
||||
SetBGRA32Info(BGRA32);
|
||||
break;
|
||||
}
|
||||
case TextureFormat.R8: //test pass
|
||||
{
|
||||
//转BGRA32
|
||||
var BGRA32 = new byte[image_data_size * 4];
|
||||
for (var i = 0; i < image_data_size; i++)
|
||||
{
|
||||
BGRA32[i * 4 + 2] = image_data[i];//R
|
||||
BGRA32[i * 4 + 3] = 255;//A
|
||||
}
|
||||
SetBGRA32Info(BGRA32);
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_MipMap = reader.ReadBoolean();
|
||||
}
|
||||
else
|
||||
{
|
||||
preloadData.InfoText = $"Width: {m_Width}\nHeight: {m_Height}\nFormat: ";
|
||||
|
||||
string type = m_TextureFormat.ToString();
|
||||
preloadData.InfoText += type;
|
||||
|
||||
switch (m_TextureFormat)
|
||||
{
|
||||
case TextureFormat.Alpha8:
|
||||
case TextureFormat.ARGB4444:
|
||||
case TextureFormat.RGB24:
|
||||
case TextureFormat.RGBA32:
|
||||
case TextureFormat.ARGB32:
|
||||
case TextureFormat.RGB565:
|
||||
case TextureFormat.R16:
|
||||
case TextureFormat.DXT1:
|
||||
case TextureFormat.DXT5:
|
||||
case TextureFormat.RGBA4444:
|
||||
case TextureFormat.BGRA32:
|
||||
case TextureFormat.RG16:
|
||||
case TextureFormat.R8:
|
||||
preloadData.extension = ".dds"; break;
|
||||
case TextureFormat.DXT1Crunched:
|
||||
case TextureFormat.DXT5Crunched:
|
||||
case TextureFormat.ETC_RGB4Crunched:
|
||||
case TextureFormat.ETC2_RGBA8Crunched:
|
||||
preloadData.extension = ".crn"; break;
|
||||
case TextureFormat.YUY2:
|
||||
case TextureFormat.PVRTC_RGB2:
|
||||
case TextureFormat.PVRTC_RGBA2:
|
||||
case TextureFormat.PVRTC_RGB4:
|
||||
case TextureFormat.PVRTC_RGBA4:
|
||||
case TextureFormat.ETC_RGB4:
|
||||
case TextureFormat.ETC2_RGB:
|
||||
case TextureFormat.ETC2_RGBA1:
|
||||
case TextureFormat.ETC2_RGBA8:
|
||||
case TextureFormat.ASTC_RGB_4x4:
|
||||
case TextureFormat.ASTC_RGB_5x5:
|
||||
case TextureFormat.ASTC_RGB_6x6:
|
||||
case TextureFormat.ASTC_RGB_8x8:
|
||||
case TextureFormat.ASTC_RGB_10x10:
|
||||
case TextureFormat.ASTC_RGB_12x12:
|
||||
case TextureFormat.ASTC_RGBA_4x4:
|
||||
case TextureFormat.ASTC_RGBA_5x5:
|
||||
case TextureFormat.ASTC_RGBA_6x6:
|
||||
case TextureFormat.ASTC_RGBA_8x8:
|
||||
case TextureFormat.ASTC_RGBA_10x10:
|
||||
case TextureFormat.ASTC_RGBA_12x12:
|
||||
case TextureFormat.ETC_RGB4_3DS:
|
||||
case TextureFormat.ETC_RGBA8_3DS:
|
||||
preloadData.extension = ".pvr"; break;
|
||||
case TextureFormat.RHalf:
|
||||
case TextureFormat.RGHalf:
|
||||
case TextureFormat.RGBAHalf:
|
||||
case TextureFormat.RFloat:
|
||||
case TextureFormat.RGFloat:
|
||||
case TextureFormat.RGBAFloat:
|
||||
case TextureFormat.BC4:
|
||||
case TextureFormat.BC5:
|
||||
case TextureFormat.BC6H:
|
||||
case TextureFormat.BC7:
|
||||
case TextureFormat.ATC_RGB4:
|
||||
case TextureFormat.ATC_RGBA8:
|
||||
case TextureFormat.EAC_R:
|
||||
case TextureFormat.EAC_R_SIGNED:
|
||||
case TextureFormat.EAC_RG:
|
||||
case TextureFormat.EAC_RG_SIGNED:
|
||||
preloadData.extension = ".ktx"; break;
|
||||
default:
|
||||
preloadData.extension = ".tex"; break;
|
||||
}
|
||||
|
||||
switch (m_FilterMode)
|
||||
{
|
||||
case 0: preloadData.InfoText += "\nFilter Mode: Point "; break;
|
||||
case 1: preloadData.InfoText += "\nFilter Mode: Bilinear "; break;
|
||||
case 2: preloadData.InfoText += "\nFilter Mode: Trilinear "; break;
|
||||
|
||||
}
|
||||
|
||||
preloadData.InfoText += $"\nAnisotropic level: {m_Aniso}\nMip map bias: {m_MipBias}";
|
||||
|
||||
switch (m_WrapMode)
|
||||
{
|
||||
case 0: preloadData.InfoText += "\nWrap mode: Repeat"; break;
|
||||
case 1: preloadData.InfoText += "\nWrap mode: Clamp"; break;
|
||||
}
|
||||
|
||||
preloadData.Text = m_Name;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
preloadData.fullSize = preloadData.Size + (int)size;
|
||||
m_MipCount = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
|
||||
private void SwapBytesForXbox(int platform)
|
||||
{
|
||||
if (platform == 11) //swap bytes for Xbox confirmed, PS3 not encountered
|
||||
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
|
||||
{
|
||||
for (var i = 0; i < image_data_size / 2; i++)
|
||||
{
|
||||
var b0 = image_data[i * 2];
|
||||
image_data[i * 2] = image_data[i * 2 + 1];
|
||||
image_data[i * 2 + 1] = b0;
|
||||
}
|
||||
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
|
||||
{
|
||||
m_StreamData = new StreamingInfo(reader);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetBGRA32Info(byte[] BGRA32)
|
||||
{
|
||||
image_data = BGRA32;
|
||||
image_data_size = BGRA32.Length;
|
||||
dwFlags2 = 0x41;
|
||||
dwRGBBitCount = 0x20;
|
||||
dwRBitMask = 0xFF0000;
|
||||
dwGBitMask = 0xFF00;
|
||||
dwBBitMask = 0xFF;
|
||||
dwABitMask = -16777216;
|
||||
ResourceReader resourceReader;
|
||||
if (!string.IsNullOrEmpty(m_StreamData?.path))
|
||||
{
|
||||
resourceReader = new ResourceReader(m_StreamData.path, assetsFile, m_StreamData.offset, (int)m_StreamData.size);
|
||||
}
|
||||
else
|
||||
{
|
||||
resourceReader = new ResourceReader(reader, reader.BaseStream.Position, image_data_size);
|
||||
}
|
||||
image_data = resourceReader;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -835,5 +165,11 @@ namespace AssetStudio
|
||||
R8,
|
||||
ETC_RGB4Crunched,
|
||||
ETC2_RGBA8Crunched,
|
||||
ASTC_HDR_4x4,
|
||||
ASTC_HDR_5x5,
|
||||
ASTC_HDR_6x6,
|
||||
ASTC_HDR_8x8,
|
||||
ASTC_HDR_10x10,
|
||||
ASTC_HDR_12x12,
|
||||
}
|
||||
}
|
||||
@@ -5,37 +5,27 @@ using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class Transform
|
||||
public class Transform : Component
|
||||
{
|
||||
public PPtr m_GameObject = new PPtr();
|
||||
public float[] m_LocalRotation;
|
||||
public float[] m_LocalPosition;
|
||||
public float[] m_LocalScale;
|
||||
public List<PPtr> m_Children = new List<PPtr>();
|
||||
public PPtr m_Father = new PPtr();//can be transform or type 224 (as seen in Minions)
|
||||
public Quaternion m_LocalRotation;
|
||||
public Vector3 m_LocalPosition;
|
||||
public Vector3 m_LocalScale;
|
||||
public PPtr<Transform>[] m_Children;
|
||||
public PPtr<Transform> m_Father;
|
||||
|
||||
public Transform(AssetPreloadData preloadData)
|
||||
public Transform(ObjectReader reader) : base(reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
m_LocalRotation = reader.ReadQuaternion();
|
||||
m_LocalPosition = reader.ReadVector3();
|
||||
m_LocalScale = reader.ReadVector3();
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = reader.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_GameObject = sourceFile.ReadPPtr();
|
||||
m_LocalRotation = new[] { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() };
|
||||
m_LocalPosition = new[] { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() };
|
||||
m_LocalScale = new[] { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() };
|
||||
int m_ChildrenCount = reader.ReadInt32();
|
||||
for (int j = 0; j < m_ChildrenCount; j++)
|
||||
m_Children = new PPtr<Transform>[m_ChildrenCount];
|
||||
for (int i = 0; i < m_ChildrenCount; i++)
|
||||
{
|
||||
m_Children.Add(sourceFile.ReadPPtr());
|
||||
m_Children[i] = new PPtr<Transform>(reader);
|
||||
}
|
||||
m_Father = sourceFile.ReadPPtr();
|
||||
m_Father = new PPtr<Transform>(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,27 +3,24 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
class VideoClip
|
||||
public sealed class VideoClip : NamedObject
|
||||
{
|
||||
public string m_Name;
|
||||
public byte[] m_VideoData;
|
||||
public ResourceReader m_VideoData;
|
||||
public string m_OriginalPath;
|
||||
public string m_Source;
|
||||
public ulong m_Size;
|
||||
|
||||
public VideoClip(AssetPreloadData preloadData, bool readSwitch)
|
||||
public VideoClip(ObjectReader reader) : base(reader)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var reader = preloadData.InitReader();
|
||||
|
||||
m_Name = reader.ReadAlignedString();
|
||||
var m_OriginalPath = reader.ReadAlignedString();
|
||||
m_OriginalPath = reader.ReadAlignedString();
|
||||
var m_ProxyWidth = reader.ReadUInt32();
|
||||
var m_ProxyHeight = reader.ReadUInt32();
|
||||
var Width = reader.ReadUInt32();
|
||||
var Height = reader.ReadUInt32();
|
||||
if (sourceFile.version[0] >= 2017)//2017.x and up
|
||||
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 2)) //2017.2 and up
|
||||
{
|
||||
var m_PixelAspecRatioNum = reader.ReadUInt32();
|
||||
var m_PixelAspecRatioDen = reader.ReadUInt32();
|
||||
@@ -31,72 +28,26 @@ namespace AssetStudio
|
||||
var m_FrameRate = reader.ReadDouble();
|
||||
var m_FrameCount = reader.ReadUInt64();
|
||||
var m_Format = reader.ReadInt32();
|
||||
//m_AudioChannelCount
|
||||
var size = reader.ReadInt32();
|
||||
reader.Position += size * 2;
|
||||
reader.AlignStream(4);
|
||||
//m_AudioSampleRate
|
||||
size = reader.ReadInt32();
|
||||
reader.Position += size * 4;
|
||||
//m_AudioLanguage
|
||||
size = reader.ReadInt32();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
reader.ReadAlignedString();
|
||||
}
|
||||
var m_AudioChannelCount = reader.ReadUInt16Array();
|
||||
reader.AlignStream();
|
||||
var m_AudioSampleRate = reader.ReadUInt32Array();
|
||||
var m_AudioLanguage = reader.ReadStringArray();
|
||||
//StreamedResource m_ExternalResources
|
||||
var m_Source = reader.ReadAlignedString();
|
||||
m_Source = reader.ReadAlignedString();
|
||||
var m_Offset = reader.ReadUInt64();
|
||||
var m_Size = reader.ReadUInt64();
|
||||
m_Size = reader.ReadUInt64();
|
||||
var m_HasSplitAlpha = reader.ReadBoolean();
|
||||
|
||||
if (readSwitch)
|
||||
ResourceReader resourceReader;
|
||||
if (!string.IsNullOrEmpty(m_Source))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(m_Source))
|
||||
{
|
||||
var resourceFileName = Path.GetFileName(m_Source);
|
||||
var resourceFilePath = Path.GetDirectoryName(sourceFile.filePath) + "\\" + resourceFileName;
|
||||
if (!File.Exists(resourceFilePath))
|
||||
{
|
||||
var findFiles = Directory.GetFiles(Path.GetDirectoryName(sourceFile.filePath), resourceFileName, SearchOption.AllDirectories);
|
||||
if (findFiles.Length > 0)
|
||||
{
|
||||
resourceFilePath = findFiles[0];
|
||||
}
|
||||
}
|
||||
if (File.Exists(resourceFilePath))
|
||||
{
|
||||
using (var resourceReader = new BinaryReader(File.OpenRead(resourceFilePath)))
|
||||
{
|
||||
resourceReader.BaseStream.Position = (long)m_Offset;
|
||||
m_VideoData = resourceReader.ReadBytes((int)m_Size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Studio.resourceFileReaders.TryGetValue(resourceFileName.ToUpper(), out var resourceReader))
|
||||
{
|
||||
resourceReader.Position = (long)m_Offset;
|
||||
m_VideoData = resourceReader.ReadBytes((int)m_Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"can't find the resource file {resourceFileName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Size > 0)
|
||||
m_VideoData = reader.ReadBytes((int)m_Size);
|
||||
}
|
||||
resourceReader = new ResourceReader(m_Source, assetsFile, (long)m_Offset, (int)m_Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
preloadData.extension = Path.GetExtension(m_OriginalPath);
|
||||
preloadData.Text = m_Name;
|
||||
preloadData.fullSize = preloadData.Size + (int)m_Size;
|
||||
resourceReader = new ResourceReader(reader, reader.BaseStream.Position, (int)m_Size);
|
||||
}
|
||||
m_VideoData = resourceReader;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
119
AssetStudio/CommonString.cs
Normal file
119
AssetStudio/CommonString.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public static class CommonString
|
||||
{
|
||||
public static readonly Dictionary<uint, string> StringBuffer = new Dictionary<uint, string>
|
||||
{
|
||||
{0, "AABB"},
|
||||
{5, "AnimationClip"},
|
||||
{19, "AnimationCurve"},
|
||||
{34, "AnimationState"},
|
||||
{49, "Array"},
|
||||
{55, "Base"},
|
||||
{60, "BitField"},
|
||||
{69, "bitset"},
|
||||
{76, "bool"},
|
||||
{81, "char"},
|
||||
{86, "ColorRGBA"},
|
||||
{96, "Component"},
|
||||
{106, "data"},
|
||||
{111, "deque"},
|
||||
{117, "double"},
|
||||
{124, "dynamic_array"},
|
||||
{138, "FastPropertyName"},
|
||||
{155, "first"},
|
||||
{161, "float"},
|
||||
{167, "Font"},
|
||||
{172, "GameObject"},
|
||||
{183, "Generic Mono"},
|
||||
{196, "GradientNEW"},
|
||||
{208, "GUID"},
|
||||
{213, "GUIStyle"},
|
||||
{222, "int"},
|
||||
{226, "list"},
|
||||
{231, "long long"},
|
||||
{241, "map"},
|
||||
{245, "Matrix4x4f"},
|
||||
{256, "MdFour"},
|
||||
{263, "MonoBehaviour"},
|
||||
{277, "MonoScript"},
|
||||
{288, "m_ByteSize"},
|
||||
{299, "m_Curve"},
|
||||
{307, "m_EditorClassIdentifier"},
|
||||
{331, "m_EditorHideFlags"},
|
||||
{349, "m_Enabled"},
|
||||
{359, "m_ExtensionPtr"},
|
||||
{374, "m_GameObject"},
|
||||
{387, "m_Index"},
|
||||
{395, "m_IsArray"},
|
||||
{405, "m_IsStatic"},
|
||||
{416, "m_MetaFlag"},
|
||||
{427, "m_Name"},
|
||||
{434, "m_ObjectHideFlags"},
|
||||
{452, "m_PrefabInternal"},
|
||||
{469, "m_PrefabParentObject"},
|
||||
{490, "m_Script"},
|
||||
{499, "m_StaticEditorFlags"},
|
||||
{519, "m_Type"},
|
||||
{526, "m_Version"},
|
||||
{536, "Object"},
|
||||
{543, "pair"},
|
||||
{548, "PPtr<Component>"},
|
||||
{564, "PPtr<GameObject>"},
|
||||
{581, "PPtr<Material>"},
|
||||
{596, "PPtr<MonoBehaviour>"},
|
||||
{616, "PPtr<MonoScript>"},
|
||||
{633, "PPtr<Object>"},
|
||||
{646, "PPtr<Prefab>"},
|
||||
{659, "PPtr<Sprite>"},
|
||||
{672, "PPtr<TextAsset>"},
|
||||
{688, "PPtr<Texture>"},
|
||||
{702, "PPtr<Texture2D>"},
|
||||
{718, "PPtr<Transform>"},
|
||||
{734, "Prefab"},
|
||||
{741, "Quaternionf"},
|
||||
{753, "Rectf"},
|
||||
{759, "RectInt"},
|
||||
{767, "RectOffset"},
|
||||
{778, "second"},
|
||||
{785, "set"},
|
||||
{789, "short"},
|
||||
{795, "size"},
|
||||
{800, "SInt16"},
|
||||
{807, "SInt32"},
|
||||
{814, "SInt64"},
|
||||
{821, "SInt8"},
|
||||
{827, "staticvector"},
|
||||
{840, "string"},
|
||||
{847, "TextAsset"},
|
||||
{857, "TextMesh"},
|
||||
{866, "Texture"},
|
||||
{874, "Texture2D"},
|
||||
{884, "Transform"},
|
||||
{894, "TypelessData"},
|
||||
{907, "UInt16"},
|
||||
{914, "UInt32"},
|
||||
{921, "UInt64"},
|
||||
{928, "UInt8"},
|
||||
{934, "unsigned int"},
|
||||
{947, "unsigned long long"},
|
||||
{966, "unsigned short"},
|
||||
{981, "vector"},
|
||||
{988, "Vector2f"},
|
||||
{997, "Vector3f"},
|
||||
{1006, "Vector4f"},
|
||||
{1015, "m_ScriptingClassIdentifier"},
|
||||
{1042, "Gradient"},
|
||||
{1051, "Type*"},
|
||||
{1057, "int2_storage"},
|
||||
{1070, "int3_storage"},
|
||||
{1083, "BoundsInt"},
|
||||
{1093, "m_CorrespondingSourceObject"},
|
||||
{1121, "m_PrefabInstance"},
|
||||
{1138, "m_PrefabAsset"},
|
||||
{1152, "FileSize"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -7,20 +7,18 @@ namespace AssetStudio
|
||||
{
|
||||
public enum EndianType
|
||||
{
|
||||
BigEndian,
|
||||
LittleEndian
|
||||
LittleEndian,
|
||||
BigEndian
|
||||
}
|
||||
|
||||
public class EndianBinaryReader : BinaryReader
|
||||
{
|
||||
public EndianType endian;
|
||||
private byte[] a16 = new byte[2];
|
||||
private byte[] a32 = new byte[4];
|
||||
private byte[] a64 = new byte[8];
|
||||
|
||||
public EndianBinaryReader(Stream stream, EndianType endian = EndianType.BigEndian)
|
||||
: base(stream)
|
||||
{ this.endian = endian; }
|
||||
public EndianBinaryReader(Stream stream, EndianType endian = EndianType.BigEndian) : base(stream)
|
||||
{
|
||||
this.endian = endian;
|
||||
}
|
||||
|
||||
public long Position
|
||||
{
|
||||
@@ -32,9 +30,9 @@ namespace AssetStudio
|
||||
{
|
||||
if (endian == EndianType.BigEndian)
|
||||
{
|
||||
a16 = ReadBytes(2);
|
||||
Array.Reverse(a16);
|
||||
return BitConverter.ToInt16(a16, 0);
|
||||
var buff = ReadBytes(2);
|
||||
Array.Reverse(buff);
|
||||
return BitConverter.ToInt16(buff, 0);
|
||||
}
|
||||
return base.ReadInt16();
|
||||
}
|
||||
@@ -43,9 +41,9 @@ namespace AssetStudio
|
||||
{
|
||||
if (endian == EndianType.BigEndian)
|
||||
{
|
||||
a32 = ReadBytes(4);
|
||||
Array.Reverse(a32);
|
||||
return BitConverter.ToInt32(a32, 0);
|
||||
var buff = ReadBytes(4);
|
||||
Array.Reverse(buff);
|
||||
return BitConverter.ToInt32(buff, 0);
|
||||
}
|
||||
return base.ReadInt32();
|
||||
}
|
||||
@@ -54,9 +52,9 @@ namespace AssetStudio
|
||||
{
|
||||
if (endian == EndianType.BigEndian)
|
||||
{
|
||||
a64 = ReadBytes(8);
|
||||
Array.Reverse(a64);
|
||||
return BitConverter.ToInt64(a64, 0);
|
||||
var buff = ReadBytes(8);
|
||||
Array.Reverse(buff);
|
||||
return BitConverter.ToInt64(buff, 0);
|
||||
}
|
||||
return base.ReadInt64();
|
||||
}
|
||||
@@ -65,9 +63,9 @@ namespace AssetStudio
|
||||
{
|
||||
if (endian == EndianType.BigEndian)
|
||||
{
|
||||
a16 = ReadBytes(2);
|
||||
Array.Reverse(a16);
|
||||
return BitConverter.ToUInt16(a16, 0);
|
||||
var buff = ReadBytes(2);
|
||||
Array.Reverse(buff);
|
||||
return BitConverter.ToUInt16(buff, 0);
|
||||
}
|
||||
return base.ReadUInt16();
|
||||
}
|
||||
@@ -76,9 +74,9 @@ namespace AssetStudio
|
||||
{
|
||||
if (endian == EndianType.BigEndian)
|
||||
{
|
||||
a32 = ReadBytes(4);
|
||||
Array.Reverse(a32);
|
||||
return BitConverter.ToUInt32(a32, 0);
|
||||
var buff = ReadBytes(4);
|
||||
Array.Reverse(buff);
|
||||
return BitConverter.ToUInt32(buff, 0);
|
||||
}
|
||||
return base.ReadUInt32();
|
||||
}
|
||||
@@ -87,9 +85,9 @@ namespace AssetStudio
|
||||
{
|
||||
if (endian == EndianType.BigEndian)
|
||||
{
|
||||
a64 = ReadBytes(8);
|
||||
Array.Reverse(a64);
|
||||
return BitConverter.ToUInt64(a64, 0);
|
||||
var buff = ReadBytes(8);
|
||||
Array.Reverse(buff);
|
||||
return BitConverter.ToUInt64(buff, 0);
|
||||
}
|
||||
return base.ReadUInt64();
|
||||
}
|
||||
@@ -98,9 +96,9 @@ namespace AssetStudio
|
||||
{
|
||||
if (endian == EndianType.BigEndian)
|
||||
{
|
||||
a32 = ReadBytes(4);
|
||||
Array.Reverse(a32);
|
||||
return BitConverter.ToSingle(a32, 0);
|
||||
var buff = ReadBytes(4);
|
||||
Array.Reverse(buff);
|
||||
return BitConverter.ToSingle(buff, 0);
|
||||
}
|
||||
return base.ReadSingle();
|
||||
}
|
||||
@@ -109,9 +107,9 @@ namespace AssetStudio
|
||||
{
|
||||
if (endian == EndianType.BigEndian)
|
||||
{
|
||||
a64 = ReadBytes(8);
|
||||
Array.Reverse(a64);
|
||||
return BitConverter.ToUInt64(a64, 0);
|
||||
var buff = ReadBytes(8);
|
||||
Array.Reverse(buff);
|
||||
return BitConverter.ToUInt64(buff, 0);
|
||||
}
|
||||
return base.ReadDouble();
|
||||
}
|
||||
597
AssetStudio/ExportOptions.Designer.cs
generated
597
AssetStudio/ExportOptions.Designer.cs
generated
@@ -1,597 +0,0 @@
|
||||
namespace AssetStudio
|
||||
{
|
||||
partial class ExportOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.includeBox = new System.Windows.Forms.GroupBox();
|
||||
this.convertDummies = new System.Windows.Forms.CheckBox();
|
||||
this.embedBox = new System.Windows.Forms.CheckBox();
|
||||
this.lightsBox = new System.Windows.Forms.CheckBox();
|
||||
this.camerasBox = new System.Windows.Forms.CheckBox();
|
||||
this.exportDeformers = new System.Windows.Forms.CheckBox();
|
||||
this.geometryBox = new System.Windows.Forms.GroupBox();
|
||||
this.exportColors = new System.Windows.Forms.CheckBox();
|
||||
this.exportUVs = new System.Windows.Forms.CheckBox();
|
||||
this.exportTangents = new System.Windows.Forms.CheckBox();
|
||||
this.exportNormals = new System.Windows.Forms.CheckBox();
|
||||
this.advancedBox = new System.Windows.Forms.GroupBox();
|
||||
this.axisLabel = new System.Windows.Forms.Label();
|
||||
this.upAxis = new System.Windows.Forms.ComboBox();
|
||||
this.scaleFactor = new System.Windows.Forms.NumericUpDown();
|
||||
this.scaleLabel = new System.Windows.Forms.Label();
|
||||
this.fbxOKbutton = new System.Windows.Forms.Button();
|
||||
this.fbxCancel = new System.Windows.Forms.Button();
|
||||
this.showExpOpt = new System.Windows.Forms.CheckBox();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.convertAudio = new System.Windows.Forms.CheckBox();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.tojpg = new System.Windows.Forms.RadioButton();
|
||||
this.topng = new System.Windows.Forms.RadioButton();
|
||||
this.tobmp = new System.Windows.Forms.RadioButton();
|
||||
this.converttexture = new System.Windows.Forms.CheckBox();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.compatibility = new System.Windows.Forms.CheckBox();
|
||||
this.flatInbetween = new System.Windows.Forms.CheckBox();
|
||||
this.boneSize = new System.Windows.Forms.NumericUpDown();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.skins = new System.Windows.Forms.CheckBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.filterPrecision = new System.Windows.Forms.NumericUpDown();
|
||||
this.allBones = new System.Windows.Forms.CheckBox();
|
||||
this.allFrames = new System.Windows.Forms.CheckBox();
|
||||
this.EulerFilter = new System.Windows.Forms.CheckBox();
|
||||
this.includeBox.SuspendLayout();
|
||||
this.geometryBox.SuspendLayout();
|
||||
this.advancedBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.scaleFactor)).BeginInit();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.panel1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.boneSize)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.filterPrecision)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// includeBox
|
||||
//
|
||||
this.includeBox.AutoSize = true;
|
||||
this.includeBox.Controls.Add(this.convertDummies);
|
||||
this.includeBox.Controls.Add(this.embedBox);
|
||||
this.includeBox.Controls.Add(this.lightsBox);
|
||||
this.includeBox.Controls.Add(this.camerasBox);
|
||||
this.includeBox.Controls.Add(this.exportDeformers);
|
||||
this.includeBox.Controls.Add(this.geometryBox);
|
||||
this.includeBox.Location = new System.Drawing.Point(12, 12);
|
||||
this.includeBox.Name = "includeBox";
|
||||
this.includeBox.Size = new System.Drawing.Size(249, 267);
|
||||
this.includeBox.TabIndex = 0;
|
||||
this.includeBox.TabStop = false;
|
||||
this.includeBox.Text = "Include";
|
||||
//
|
||||
// convertDummies
|
||||
//
|
||||
this.convertDummies.AutoSize = true;
|
||||
this.convertDummies.Location = new System.Drawing.Point(14, 164);
|
||||
this.convertDummies.Name = "convertDummies";
|
||||
this.convertDummies.Size = new System.Drawing.Size(228, 16);
|
||||
this.convertDummies.TabIndex = 5;
|
||||
this.convertDummies.Text = "Convert Deforming Dummies to Bones";
|
||||
this.convertDummies.UseVisualStyleBackColor = true;
|
||||
this.convertDummies.CheckedChanged += new System.EventHandler(this.exportOpnions_CheckedChanged);
|
||||
//
|
||||
// embedBox
|
||||
//
|
||||
this.embedBox.AutoSize = true;
|
||||
this.embedBox.Enabled = false;
|
||||
this.embedBox.Location = new System.Drawing.Point(14, 230);
|
||||
this.embedBox.Name = "embedBox";
|
||||
this.embedBox.Size = new System.Drawing.Size(90, 16);
|
||||
this.embedBox.TabIndex = 4;
|
||||
this.embedBox.Text = "Embed Media";
|
||||
this.embedBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// lightsBox
|
||||
//
|
||||
this.lightsBox.AutoSize = true;
|
||||
this.lightsBox.Enabled = false;
|
||||
this.lightsBox.Location = new System.Drawing.Point(14, 208);
|
||||
this.lightsBox.Name = "lightsBox";
|
||||
this.lightsBox.Size = new System.Drawing.Size(60, 16);
|
||||
this.lightsBox.TabIndex = 3;
|
||||
this.lightsBox.Text = "Lights";
|
||||
this.lightsBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// camerasBox
|
||||
//
|
||||
this.camerasBox.AutoSize = true;
|
||||
this.camerasBox.Enabled = false;
|
||||
this.camerasBox.Location = new System.Drawing.Point(14, 186);
|
||||
this.camerasBox.Name = "camerasBox";
|
||||
this.camerasBox.Size = new System.Drawing.Size(66, 16);
|
||||
this.camerasBox.TabIndex = 2;
|
||||
this.camerasBox.Text = "Cameras";
|
||||
this.camerasBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// exportDeformers
|
||||
//
|
||||
this.exportDeformers.AutoSize = true;
|
||||
this.exportDeformers.Location = new System.Drawing.Point(14, 142);
|
||||
this.exportDeformers.Name = "exportDeformers";
|
||||
this.exportDeformers.Size = new System.Drawing.Size(108, 16);
|
||||
this.exportDeformers.TabIndex = 1;
|
||||
this.exportDeformers.Text = "Skin Deformers";
|
||||
this.exportDeformers.UseVisualStyleBackColor = true;
|
||||
this.exportDeformers.CheckedChanged += new System.EventHandler(this.exportDeformers_CheckedChanged);
|
||||
//
|
||||
// geometryBox
|
||||
//
|
||||
this.geometryBox.AutoSize = true;
|
||||
this.geometryBox.Controls.Add(this.exportColors);
|
||||
this.geometryBox.Controls.Add(this.exportUVs);
|
||||
this.geometryBox.Controls.Add(this.exportTangents);
|
||||
this.geometryBox.Controls.Add(this.exportNormals);
|
||||
this.geometryBox.Location = new System.Drawing.Point(7, 18);
|
||||
this.geometryBox.Name = "geometryBox";
|
||||
this.geometryBox.Size = new System.Drawing.Size(235, 122);
|
||||
this.geometryBox.TabIndex = 0;
|
||||
this.geometryBox.TabStop = false;
|
||||
this.geometryBox.Text = "Geometry";
|
||||
//
|
||||
// exportColors
|
||||
//
|
||||
this.exportColors.AutoSize = true;
|
||||
this.exportColors.Checked = true;
|
||||
this.exportColors.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.exportColors.Location = new System.Drawing.Point(7, 85);
|
||||
this.exportColors.Name = "exportColors";
|
||||
this.exportColors.Size = new System.Drawing.Size(102, 16);
|
||||
this.exportColors.TabIndex = 3;
|
||||
this.exportColors.Text = "Vertex Colors";
|
||||
this.exportColors.UseVisualStyleBackColor = true;
|
||||
this.exportColors.CheckedChanged += new System.EventHandler(this.exportOpnions_CheckedChanged);
|
||||
//
|
||||
// exportUVs
|
||||
//
|
||||
this.exportUVs.AutoSize = true;
|
||||
this.exportUVs.Checked = true;
|
||||
this.exportUVs.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.exportUVs.Location = new System.Drawing.Point(7, 63);
|
||||
this.exportUVs.Name = "exportUVs";
|
||||
this.exportUVs.Size = new System.Drawing.Size(108, 16);
|
||||
this.exportUVs.TabIndex = 2;
|
||||
this.exportUVs.Text = "UV Coordinates";
|
||||
this.exportUVs.UseVisualStyleBackColor = true;
|
||||
this.exportUVs.CheckedChanged += new System.EventHandler(this.exportOpnions_CheckedChanged);
|
||||
//
|
||||
// exportTangents
|
||||
//
|
||||
this.exportTangents.AutoSize = true;
|
||||
this.exportTangents.Location = new System.Drawing.Point(7, 41);
|
||||
this.exportTangents.Name = "exportTangents";
|
||||
this.exportTangents.Size = new System.Drawing.Size(72, 16);
|
||||
this.exportTangents.TabIndex = 1;
|
||||
this.exportTangents.Text = "Tangents";
|
||||
this.exportTangents.UseVisualStyleBackColor = true;
|
||||
this.exportTangents.CheckedChanged += new System.EventHandler(this.exportOpnions_CheckedChanged);
|
||||
//
|
||||
// exportNormals
|
||||
//
|
||||
this.exportNormals.AutoSize = true;
|
||||
this.exportNormals.Checked = true;
|
||||
this.exportNormals.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.exportNormals.Location = new System.Drawing.Point(7, 18);
|
||||
this.exportNormals.Name = "exportNormals";
|
||||
this.exportNormals.Size = new System.Drawing.Size(66, 16);
|
||||
this.exportNormals.TabIndex = 0;
|
||||
this.exportNormals.Text = "Normals";
|
||||
this.exportNormals.UseVisualStyleBackColor = true;
|
||||
this.exportNormals.CheckedChanged += new System.EventHandler(this.exportOpnions_CheckedChanged);
|
||||
//
|
||||
// advancedBox
|
||||
//
|
||||
this.advancedBox.AutoSize = true;
|
||||
this.advancedBox.Controls.Add(this.axisLabel);
|
||||
this.advancedBox.Controls.Add(this.upAxis);
|
||||
this.advancedBox.Controls.Add(this.scaleFactor);
|
||||
this.advancedBox.Controls.Add(this.scaleLabel);
|
||||
this.advancedBox.Location = new System.Drawing.Point(12, 285);
|
||||
this.advancedBox.Name = "advancedBox";
|
||||
this.advancedBox.Size = new System.Drawing.Size(249, 78);
|
||||
this.advancedBox.TabIndex = 5;
|
||||
this.advancedBox.TabStop = false;
|
||||
this.advancedBox.Text = "Advanced Options";
|
||||
//
|
||||
// axisLabel
|
||||
//
|
||||
this.axisLabel.AutoSize = true;
|
||||
this.axisLabel.Location = new System.Drawing.Point(6, 40);
|
||||
this.axisLabel.Name = "axisLabel";
|
||||
this.axisLabel.Size = new System.Drawing.Size(53, 12);
|
||||
this.axisLabel.TabIndex = 3;
|
||||
this.axisLabel.Text = "Up Axis:";
|
||||
//
|
||||
// upAxis
|
||||
//
|
||||
this.upAxis.FormattingEnabled = true;
|
||||
this.upAxis.Items.AddRange(new object[] {
|
||||
"Y-up"});
|
||||
this.upAxis.Location = new System.Drawing.Point(66, 38);
|
||||
this.upAxis.MaxDropDownItems = 2;
|
||||
this.upAxis.Name = "upAxis";
|
||||
this.upAxis.Size = new System.Drawing.Size(70, 20);
|
||||
this.upAxis.TabIndex = 2;
|
||||
//
|
||||
// scaleFactor
|
||||
//
|
||||
this.scaleFactor.DecimalPlaces = 2;
|
||||
this.scaleFactor.Increment = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
131072});
|
||||
this.scaleFactor.Location = new System.Drawing.Point(96, 14);
|
||||
this.scaleFactor.Name = "scaleFactor";
|
||||
this.scaleFactor.Size = new System.Drawing.Size(46, 21);
|
||||
this.scaleFactor.TabIndex = 1;
|
||||
this.scaleFactor.Value = new decimal(new int[] {
|
||||
254,
|
||||
0,
|
||||
0,
|
||||
131072});
|
||||
//
|
||||
// scaleLabel
|
||||
//
|
||||
this.scaleLabel.AutoSize = true;
|
||||
this.scaleLabel.Location = new System.Drawing.Point(6, 15);
|
||||
this.scaleLabel.Name = "scaleLabel";
|
||||
this.scaleLabel.Size = new System.Drawing.Size(83, 12);
|
||||
this.scaleLabel.TabIndex = 0;
|
||||
this.scaleLabel.Text = "Scale Factor:";
|
||||
//
|
||||
// fbxOKbutton
|
||||
//
|
||||
this.fbxOKbutton.Location = new System.Drawing.Point(339, 369);
|
||||
this.fbxOKbutton.Name = "fbxOKbutton";
|
||||
this.fbxOKbutton.Size = new System.Drawing.Size(75, 21);
|
||||
this.fbxOKbutton.TabIndex = 6;
|
||||
this.fbxOKbutton.Text = "OK";
|
||||
this.fbxOKbutton.UseVisualStyleBackColor = true;
|
||||
this.fbxOKbutton.Click += new System.EventHandler(this.fbxOKbutton_Click);
|
||||
//
|
||||
// fbxCancel
|
||||
//
|
||||
this.fbxCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.fbxCancel.Location = new System.Drawing.Point(420, 369);
|
||||
this.fbxCancel.Name = "fbxCancel";
|
||||
this.fbxCancel.Size = new System.Drawing.Size(75, 21);
|
||||
this.fbxCancel.TabIndex = 7;
|
||||
this.fbxCancel.Text = "Cancel";
|
||||
this.fbxCancel.UseVisualStyleBackColor = true;
|
||||
this.fbxCancel.Click += new System.EventHandler(this.fbxCancel_Click);
|
||||
//
|
||||
// showExpOpt
|
||||
//
|
||||
this.showExpOpt.AutoSize = true;
|
||||
this.showExpOpt.Location = new System.Drawing.Point(12, 372);
|
||||
this.showExpOpt.Name = "showExpOpt";
|
||||
this.showExpOpt.Size = new System.Drawing.Size(222, 16);
|
||||
this.showExpOpt.TabIndex = 8;
|
||||
this.showExpOpt.Text = "Show this dialog for every export";
|
||||
this.showExpOpt.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.convertAudio);
|
||||
this.groupBox1.Controls.Add(this.panel1);
|
||||
this.groupBox1.Controls.Add(this.converttexture);
|
||||
this.groupBox1.Location = new System.Drawing.Point(267, 12);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(228, 140);
|
||||
this.groupBox1.TabIndex = 9;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Convert";
|
||||
//
|
||||
// convertAudio
|
||||
//
|
||||
this.convertAudio.AutoSize = true;
|
||||
this.convertAudio.Checked = true;
|
||||
this.convertAudio.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.convertAudio.Location = new System.Drawing.Point(6, 78);
|
||||
this.convertAudio.Name = "convertAudio";
|
||||
this.convertAudio.Size = new System.Drawing.Size(198, 28);
|
||||
this.convertAudio.TabIndex = 6;
|
||||
this.convertAudio.Text = "Convert AudioClip to WAV(PCM)\r\n(If support)";
|
||||
this.convertAudio.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Controls.Add(this.tojpg);
|
||||
this.panel1.Controls.Add(this.topng);
|
||||
this.panel1.Controls.Add(this.tobmp);
|
||||
this.panel1.Location = new System.Drawing.Point(30, 42);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(146, 30);
|
||||
this.panel1.TabIndex = 5;
|
||||
//
|
||||
// tojpg
|
||||
//
|
||||
this.tojpg.AutoSize = true;
|
||||
this.tojpg.Location = new System.Drawing.Point(97, 6);
|
||||
this.tojpg.Name = "tojpg";
|
||||
this.tojpg.Size = new System.Drawing.Size(47, 16);
|
||||
this.tojpg.TabIndex = 4;
|
||||
this.tojpg.Text = "JPEG";
|
||||
this.tojpg.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// topng
|
||||
//
|
||||
this.topng.AutoSize = true;
|
||||
this.topng.Checked = true;
|
||||
this.topng.Location = new System.Drawing.Point(50, 6);
|
||||
this.topng.Name = "topng";
|
||||
this.topng.Size = new System.Drawing.Size(41, 16);
|
||||
this.topng.TabIndex = 3;
|
||||
this.topng.TabStop = true;
|
||||
this.topng.Text = "PNG";
|
||||
this.topng.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tobmp
|
||||
//
|
||||
this.tobmp.AutoSize = true;
|
||||
this.tobmp.Location = new System.Drawing.Point(3, 6);
|
||||
this.tobmp.Name = "tobmp";
|
||||
this.tobmp.Size = new System.Drawing.Size(41, 16);
|
||||
this.tobmp.TabIndex = 2;
|
||||
this.tobmp.Text = "BMP";
|
||||
this.tobmp.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// converttexture
|
||||
//
|
||||
this.converttexture.AutoSize = true;
|
||||
this.converttexture.Checked = true;
|
||||
this.converttexture.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.converttexture.Location = new System.Drawing.Point(6, 20);
|
||||
this.converttexture.Name = "converttexture";
|
||||
this.converttexture.Size = new System.Drawing.Size(192, 16);
|
||||
this.converttexture.TabIndex = 1;
|
||||
this.converttexture.Text = "Convert Texture (If support)";
|
||||
this.converttexture.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.compatibility);
|
||||
this.groupBox2.Controls.Add(this.flatInbetween);
|
||||
this.groupBox2.Controls.Add(this.boneSize);
|
||||
this.groupBox2.Controls.Add(this.label2);
|
||||
this.groupBox2.Controls.Add(this.skins);
|
||||
this.groupBox2.Controls.Add(this.label1);
|
||||
this.groupBox2.Controls.Add(this.filterPrecision);
|
||||
this.groupBox2.Controls.Add(this.allBones);
|
||||
this.groupBox2.Controls.Add(this.allFrames);
|
||||
this.groupBox2.Controls.Add(this.EulerFilter);
|
||||
this.groupBox2.Location = new System.Drawing.Point(267, 158);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(228, 205);
|
||||
this.groupBox2.TabIndex = 11;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Animator";
|
||||
//
|
||||
// compatibility
|
||||
//
|
||||
this.compatibility.AutoSize = true;
|
||||
this.compatibility.Location = new System.Drawing.Point(6, 177);
|
||||
this.compatibility.Name = "compatibility";
|
||||
this.compatibility.Size = new System.Drawing.Size(102, 16);
|
||||
this.compatibility.TabIndex = 13;
|
||||
this.compatibility.Text = "compatibility";
|
||||
this.compatibility.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// flatInbetween
|
||||
//
|
||||
this.flatInbetween.AutoSize = true;
|
||||
this.flatInbetween.Location = new System.Drawing.Point(6, 155);
|
||||
this.flatInbetween.Name = "flatInbetween";
|
||||
this.flatInbetween.Size = new System.Drawing.Size(102, 16);
|
||||
this.flatInbetween.TabIndex = 12;
|
||||
this.flatInbetween.Text = "flatInbetween";
|
||||
this.flatInbetween.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// boneSize
|
||||
//
|
||||
this.boneSize.Location = new System.Drawing.Point(65, 128);
|
||||
this.boneSize.Name = "boneSize";
|
||||
this.boneSize.Size = new System.Drawing.Size(46, 21);
|
||||
this.boneSize.TabIndex = 11;
|
||||
this.boneSize.Value = new decimal(new int[] {
|
||||
10,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(6, 130);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(53, 12);
|
||||
this.label2.TabIndex = 10;
|
||||
this.label2.Text = "boneSize";
|
||||
//
|
||||
// skins
|
||||
//
|
||||
this.skins.AutoSize = true;
|
||||
this.skins.Checked = true;
|
||||
this.skins.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.skins.Location = new System.Drawing.Point(6, 105);
|
||||
this.skins.Name = "skins";
|
||||
this.skins.Size = new System.Drawing.Size(54, 16);
|
||||
this.skins.TabIndex = 8;
|
||||
this.skins.Text = "skins";
|
||||
this.skins.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(26, 39);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(95, 12);
|
||||
this.label1.TabIndex = 7;
|
||||
this.label1.Text = "filterPrecision";
|
||||
//
|
||||
// filterPrecision
|
||||
//
|
||||
this.filterPrecision.DecimalPlaces = 2;
|
||||
this.filterPrecision.Increment = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
131072});
|
||||
this.filterPrecision.Location = new System.Drawing.Point(127, 37);
|
||||
this.filterPrecision.Name = "filterPrecision";
|
||||
this.filterPrecision.Size = new System.Drawing.Size(51, 21);
|
||||
this.filterPrecision.TabIndex = 6;
|
||||
this.filterPrecision.Value = new decimal(new int[] {
|
||||
25,
|
||||
0,
|
||||
0,
|
||||
131072});
|
||||
//
|
||||
// allBones
|
||||
//
|
||||
this.allBones.AutoSize = true;
|
||||
this.allBones.Checked = true;
|
||||
this.allBones.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.allBones.Location = new System.Drawing.Point(6, 83);
|
||||
this.allBones.Name = "allBones";
|
||||
this.allBones.Size = new System.Drawing.Size(72, 16);
|
||||
this.allBones.TabIndex = 5;
|
||||
this.allBones.Text = "allBones";
|
||||
this.allBones.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// allFrames
|
||||
//
|
||||
this.allFrames.AutoSize = true;
|
||||
this.allFrames.Location = new System.Drawing.Point(6, 61);
|
||||
this.allFrames.Name = "allFrames";
|
||||
this.allFrames.Size = new System.Drawing.Size(78, 16);
|
||||
this.allFrames.TabIndex = 4;
|
||||
this.allFrames.Text = "allFrames";
|
||||
this.allFrames.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// EulerFilter
|
||||
//
|
||||
this.EulerFilter.AutoSize = true;
|
||||
this.EulerFilter.Location = new System.Drawing.Point(6, 20);
|
||||
this.EulerFilter.Name = "EulerFilter";
|
||||
this.EulerFilter.Size = new System.Drawing.Size(90, 16);
|
||||
this.EulerFilter.TabIndex = 3;
|
||||
this.EulerFilter.Text = "EulerFilter";
|
||||
this.EulerFilter.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ExportOptions
|
||||
//
|
||||
this.AcceptButton = this.fbxOKbutton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.fbxCancel;
|
||||
this.ClientSize = new System.Drawing.Size(508, 398);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.showExpOpt);
|
||||
this.Controls.Add(this.fbxCancel);
|
||||
this.Controls.Add(this.fbxOKbutton);
|
||||
this.Controls.Add(this.advancedBox);
|
||||
this.Controls.Add(this.includeBox);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "ExportOptions";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Export options";
|
||||
this.TopMost = true;
|
||||
this.includeBox.ResumeLayout(false);
|
||||
this.includeBox.PerformLayout();
|
||||
this.geometryBox.ResumeLayout(false);
|
||||
this.geometryBox.PerformLayout();
|
||||
this.advancedBox.ResumeLayout(false);
|
||||
this.advancedBox.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.scaleFactor)).EndInit();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel1.PerformLayout();
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.boneSize)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.filterPrecision)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox includeBox;
|
||||
private System.Windows.Forms.GroupBox advancedBox;
|
||||
private System.Windows.Forms.NumericUpDown scaleFactor;
|
||||
private System.Windows.Forms.Label scaleLabel;
|
||||
private System.Windows.Forms.CheckBox embedBox;
|
||||
private System.Windows.Forms.CheckBox lightsBox;
|
||||
private System.Windows.Forms.CheckBox camerasBox;
|
||||
private System.Windows.Forms.CheckBox exportDeformers;
|
||||
private System.Windows.Forms.GroupBox geometryBox;
|
||||
private System.Windows.Forms.CheckBox exportColors;
|
||||
private System.Windows.Forms.CheckBox exportUVs;
|
||||
private System.Windows.Forms.CheckBox exportTangents;
|
||||
private System.Windows.Forms.CheckBox exportNormals;
|
||||
private System.Windows.Forms.Label axisLabel;
|
||||
private System.Windows.Forms.ComboBox upAxis;
|
||||
private System.Windows.Forms.Button fbxOKbutton;
|
||||
private System.Windows.Forms.Button fbxCancel;
|
||||
private System.Windows.Forms.CheckBox showExpOpt;
|
||||
private System.Windows.Forms.CheckBox convertDummies;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.CheckBox converttexture;
|
||||
private System.Windows.Forms.RadioButton tojpg;
|
||||
private System.Windows.Forms.RadioButton topng;
|
||||
private System.Windows.Forms.RadioButton tobmp;
|
||||
private System.Windows.Forms.CheckBox convertAudio;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.CheckBox compatibility;
|
||||
private System.Windows.Forms.CheckBox flatInbetween;
|
||||
private System.Windows.Forms.NumericUpDown boneSize;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.CheckBox skins;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.NumericUpDown filterPrecision;
|
||||
private System.Windows.Forms.CheckBox allBones;
|
||||
private System.Windows.Forms.CheckBox allFrames;
|
||||
private System.Windows.Forms.CheckBox EulerFilter;
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public partial class ExportOptions : Form
|
||||
{
|
||||
public ExportOptions()
|
||||
{
|
||||
InitializeComponent();
|
||||
exportNormals.Checked = (bool)Properties.Settings.Default["exportNormals"];
|
||||
exportTangents.Checked = (bool)Properties.Settings.Default["exportTangents"];
|
||||
exportUVs.Checked = (bool)Properties.Settings.Default["exportUVs"];
|
||||
exportColors.Checked = (bool)Properties.Settings.Default["exportColors"];
|
||||
exportDeformers.Checked = (bool)Properties.Settings.Default["exportDeformers"];
|
||||
convertDummies.Checked = (bool)Properties.Settings.Default["convertDummies"];
|
||||
convertDummies.Enabled = (bool)Properties.Settings.Default["exportDeformers"];
|
||||
scaleFactor.Value = (decimal)Properties.Settings.Default["scaleFactor"];
|
||||
upAxis.SelectedIndex = (int)Properties.Settings.Default["upAxis"];
|
||||
showExpOpt.Checked = (bool)Properties.Settings.Default["showExpOpt"];
|
||||
converttexture.Checked = (bool)Properties.Settings.Default["convertTexture"];
|
||||
convertAudio.Checked = (bool)Properties.Settings.Default["convertAudio"];
|
||||
var str = (string)Properties.Settings.Default["convertType"];
|
||||
foreach (Control c in panel1.Controls)
|
||||
{
|
||||
if (c.Text == str)
|
||||
{
|
||||
((RadioButton)c).Checked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
EulerFilter.Checked = (bool)Properties.Settings.Default["EulerFilter"];
|
||||
filterPrecision.Value = (decimal)Properties.Settings.Default["filterPrecision"];
|
||||
allFrames.Checked = (bool)Properties.Settings.Default["allFrames"];
|
||||
allBones.Checked = (bool)Properties.Settings.Default["allBones"];
|
||||
skins.Checked = (bool)Properties.Settings.Default["skins"];
|
||||
boneSize.Value = (decimal)Properties.Settings.Default["boneSize"];
|
||||
flatInbetween.Checked = (bool)Properties.Settings.Default["flatInbetween"];
|
||||
compatibility.Checked = (bool)Properties.Settings.Default["compatibility"];
|
||||
}
|
||||
|
||||
private void exportOpnions_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
Properties.Settings.Default[((CheckBox)sender).Name] = ((CheckBox)sender).Checked;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
|
||||
private void fbxOKbutton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Properties.Settings.Default["exportNormals"] = exportNormals.Checked;
|
||||
Properties.Settings.Default["exportTangents"] = exportTangents.Checked;
|
||||
Properties.Settings.Default["exportUVs"] = exportUVs.Checked;
|
||||
Properties.Settings.Default["exportColors"] = exportColors.Checked;
|
||||
Properties.Settings.Default["exportDeformers"] = exportDeformers.Checked;
|
||||
Properties.Settings.Default["scaleFactor"] = scaleFactor.Value;
|
||||
Properties.Settings.Default["upAxis"] = upAxis.SelectedIndex;
|
||||
Properties.Settings.Default["convertTexture"] = converttexture.Checked;
|
||||
Properties.Settings.Default["convertAudio"] = convertAudio.Checked;
|
||||
foreach (Control c in panel1.Controls)
|
||||
{
|
||||
if (((RadioButton)c).Checked)
|
||||
{
|
||||
Properties.Settings.Default["convertType"] = c.Text;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Properties.Settings.Default["EulerFilter"] = EulerFilter.Checked;
|
||||
Properties.Settings.Default["filterPrecision"] = filterPrecision.Value;
|
||||
Properties.Settings.Default["allFrames"] = allFrames.Checked;
|
||||
Properties.Settings.Default["allBones"] = allBones.Checked;
|
||||
Properties.Settings.Default["skins"] = skins.Checked;
|
||||
Properties.Settings.Default["boneSize"] = boneSize.Value;
|
||||
Properties.Settings.Default["flatInbetween"] = flatInbetween.Checked;
|
||||
Properties.Settings.Default["compatibility"] = compatibility.Checked;
|
||||
Properties.Settings.Default.Save();
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void fbxCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void exportDeformers_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
exportOpnions_CheckedChanged(sender, e);
|
||||
convertDummies.Enabled = exportDeformers.Checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
165
AssetStudio/Extensions/BinaryReaderExtensions.cs
Normal file
165
AssetStudio/Extensions/BinaryReaderExtensions.cs
Normal file
@@ -0,0 +1,165 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public static class BinaryReaderExtensions
|
||||
{
|
||||
public static void AlignStream(this BinaryReader reader)
|
||||
{
|
||||
reader.AlignStream(4);
|
||||
}
|
||||
|
||||
public static void AlignStream(this BinaryReader reader, int alignment)
|
||||
{
|
||||
var pos = reader.BaseStream.Position;
|
||||
var mod = pos % alignment;
|
||||
if (mod != 0)
|
||||
{
|
||||
reader.BaseStream.Position += alignment - mod;
|
||||
}
|
||||
}
|
||||
|
||||
public static string ReadAlignedString(this BinaryReader reader)
|
||||
{
|
||||
var length = reader.ReadInt32();
|
||||
if (length > 0 && length <= reader.BaseStream.Length - reader.BaseStream.Position)
|
||||
{
|
||||
var stringData = reader.ReadBytes(length);
|
||||
var result = Encoding.UTF8.GetString(stringData);
|
||||
reader.AlignStream(4);
|
||||
return result;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static string ReadStringToNull(this BinaryReader reader, int maxLength = 32767)
|
||||
{
|
||||
var bytes = new List<byte>();
|
||||
int count = 0;
|
||||
while (reader.BaseStream.Position != reader.BaseStream.Length && count < maxLength)
|
||||
{
|
||||
var b = reader.ReadByte();
|
||||
if (b == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
bytes.Add(b);
|
||||
count++;
|
||||
}
|
||||
return Encoding.UTF8.GetString(bytes.ToArray());
|
||||
}
|
||||
|
||||
public static Quaternion ReadQuaternion(this BinaryReader reader)
|
||||
{
|
||||
return new Quaternion(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
|
||||
}
|
||||
|
||||
public static Vector2 ReadVector2(this BinaryReader reader)
|
||||
{
|
||||
return new Vector2(reader.ReadSingle(), reader.ReadSingle());
|
||||
}
|
||||
|
||||
public static Vector3 ReadVector3(this BinaryReader reader)
|
||||
{
|
||||
return new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
|
||||
}
|
||||
|
||||
public static Vector4 ReadVector4(this BinaryReader reader)
|
||||
{
|
||||
return new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
|
||||
}
|
||||
|
||||
public static System.Drawing.RectangleF ReadRectangleF(this BinaryReader reader)
|
||||
{
|
||||
return new System.Drawing.RectangleF(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
|
||||
}
|
||||
|
||||
public static Color ReadColor4(this BinaryReader reader)
|
||||
{
|
||||
return new Color(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
|
||||
}
|
||||
|
||||
public static Matrix4x4 ReadMatrix(this BinaryReader reader)
|
||||
{
|
||||
return new Matrix4x4(reader.ReadSingleArray(16));
|
||||
}
|
||||
|
||||
private static T[] ReadArray<T>(Func<T> del, int length)
|
||||
{
|
||||
var array = new T[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
array[i] = del();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public static bool[] ReadBooleanArray(this BinaryReader reader)
|
||||
{
|
||||
return ReadArray(reader.ReadBoolean, reader.ReadInt32());
|
||||
}
|
||||
|
||||
public static ushort[] ReadUInt16Array(this BinaryReader reader)
|
||||
{
|
||||
return ReadArray(reader.ReadUInt16, reader.ReadInt32());
|
||||
}
|
||||
|
||||
public static int[] ReadInt32Array(this BinaryReader reader)
|
||||
{
|
||||
return ReadArray(reader.ReadInt32, reader.ReadInt32());
|
||||
}
|
||||
|
||||
public static int[] ReadInt32Array(this BinaryReader reader, int length)
|
||||
{
|
||||
return ReadArray(reader.ReadInt32, length);
|
||||
}
|
||||
|
||||
public static uint[] ReadUInt32Array(this BinaryReader reader)
|
||||
{
|
||||
return ReadArray(reader.ReadUInt32, reader.ReadInt32());
|
||||
}
|
||||
|
||||
public static uint[][] ReadUInt32ArrayArray(this BinaryReader reader)
|
||||
{
|
||||
return ReadArray(reader.ReadUInt32Array, reader.ReadInt32());
|
||||
}
|
||||
|
||||
public static uint[] ReadUInt32Array(this BinaryReader reader, int length)
|
||||
{
|
||||
return ReadArray(reader.ReadUInt32, length);
|
||||
}
|
||||
|
||||
public static float[] ReadSingleArray(this BinaryReader reader)
|
||||
{
|
||||
return ReadArray(reader.ReadSingle, reader.ReadInt32());
|
||||
}
|
||||
|
||||
public static float[] ReadSingleArray(this BinaryReader reader, int length)
|
||||
{
|
||||
return ReadArray(reader.ReadSingle, length);
|
||||
}
|
||||
|
||||
public static string[] ReadStringArray(this BinaryReader reader)
|
||||
{
|
||||
return ReadArray(reader.ReadAlignedString, reader.ReadInt32());
|
||||
}
|
||||
|
||||
public static Vector2[] ReadVector2Array(this BinaryReader reader)
|
||||
{
|
||||
return ReadArray(reader.ReadVector2, reader.ReadInt32());
|
||||
}
|
||||
|
||||
public static Vector4[] ReadVector4Array(this BinaryReader reader)
|
||||
{
|
||||
return ReadArray(reader.ReadVector4, reader.ReadInt32());
|
||||
}
|
||||
|
||||
public static Matrix4x4[] ReadMatrixArray(this BinaryReader reader)
|
||||
{
|
||||
return ReadArray(reader.ReadMatrix, reader.ReadInt32());
|
||||
}
|
||||
}
|
||||
}
|
||||
27
AssetStudio/Extensions/BinaryWriterExtensions.cs
Normal file
27
AssetStudio/Extensions/BinaryWriterExtensions.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public static class BinaryWriterExtensions
|
||||
{
|
||||
public static void AlignStream(this BinaryWriter writer, int alignment)
|
||||
{
|
||||
var pos = writer.BaseStream.Position;
|
||||
var mod = pos % alignment;
|
||||
if (mod != 0)
|
||||
{
|
||||
writer.Write(new byte[alignment - mod]);
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteAlignedString(this BinaryWriter writer, string str)
|
||||
{
|
||||
var bytes = Encoding.UTF8.GetBytes(str);
|
||||
writer.Write(bytes.Length);
|
||||
writer.Write(bytes);
|
||||
writer.AlignStream(4);
|
||||
}
|
||||
}
|
||||
}
|
||||
24
AssetStudio/Extensions/StreamExtensions.cs
Normal file
24
AssetStudio/Extensions/StreamExtensions.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.IO;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public static class StreamExtensions
|
||||
{
|
||||
private const int BufferSize = 81920;
|
||||
|
||||
public static void CopyTo(this Stream source, Stream destination, long size)
|
||||
{
|
||||
var buffer = new byte[BufferSize];
|
||||
for (var left = size; left > 0; left -= BufferSize)
|
||||
{
|
||||
int toRead = BufferSize < left ? BufferSize : (int)left;
|
||||
int read = source.Read(buffer, 0, toRead);
|
||||
destination.Write(buffer, 0, read);
|
||||
if (read != toRead)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
17
AssetStudio/FileIdentifier.cs
Normal file
17
AssetStudio/FileIdentifier.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class FileIdentifier
|
||||
{
|
||||
public Guid guid;
|
||||
public int type; //enum { kNonAssetType = 0, kDeprecatedCachedAssetType = 1, kSerializedAssetType = 2, kMetaAssetType = 3 };
|
||||
public string pathName;
|
||||
|
||||
//custom
|
||||
public string fileName;
|
||||
}
|
||||
}
|
||||
323
AssetStudio/IImported.cs
Normal file
323
AssetStudio/IImported.cs
Normal file
@@ -0,0 +1,323 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public interface IImported
|
||||
{
|
||||
ImportedFrame RootFrame { get; }
|
||||
List<ImportedMesh> MeshList { get; }
|
||||
List<ImportedMaterial> MaterialList { get; }
|
||||
List<ImportedTexture> TextureList { get; }
|
||||
List<ImportedKeyframedAnimation> AnimationList { get; }
|
||||
List<ImportedMorph> MorphList { get; }
|
||||
}
|
||||
|
||||
public class ImportedFrame
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public Vector3 LocalRotation { get; set; }
|
||||
public Vector3 LocalPosition { get; set; }
|
||||
public Vector3 LocalScale { get; set; }
|
||||
public ImportedFrame Parent { get; set; }
|
||||
|
||||
private List<ImportedFrame> children;
|
||||
|
||||
public ImportedFrame this[int i] => children[i];
|
||||
|
||||
public int Count => children.Count;
|
||||
|
||||
public string Path
|
||||
{
|
||||
get
|
||||
{
|
||||
var frame = this;
|
||||
var path = frame.Name;
|
||||
while (frame.Parent != null)
|
||||
{
|
||||
frame = frame.Parent;
|
||||
path = frame.Name + "/" + path;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
public ImportedFrame(int childrenCount = 0)
|
||||
{
|
||||
children = new List<ImportedFrame>(childrenCount);
|
||||
}
|
||||
|
||||
public void AddChild(ImportedFrame obj)
|
||||
{
|
||||
children.Add(obj);
|
||||
obj.Parent?.Remove(obj);
|
||||
obj.Parent = this;
|
||||
}
|
||||
|
||||
public void Remove(ImportedFrame frame)
|
||||
{
|
||||
children.Remove(frame);
|
||||
}
|
||||
|
||||
public ImportedFrame FindFrameByPath(string path)
|
||||
{
|
||||
var name = path.Substring(path.LastIndexOf('/') + 1);
|
||||
foreach (var frame in FindChilds(name))
|
||||
{
|
||||
if (frame.Path.EndsWith(path, StringComparison.Ordinal))
|
||||
{
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ImportedFrame FindFrame(string name)
|
||||
{
|
||||
if (Name == name)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
foreach (var child in children)
|
||||
{
|
||||
var frame = child.FindFrame(name);
|
||||
if (frame != null)
|
||||
{
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ImportedFrame FindChild(string name, bool recursive = true)
|
||||
{
|
||||
foreach (var child in children)
|
||||
{
|
||||
if (recursive)
|
||||
{
|
||||
var frame = child.FindFrame(name);
|
||||
if (frame != null)
|
||||
{
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (child.Name == name)
|
||||
{
|
||||
return child;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IEnumerable<ImportedFrame> FindChilds(string name)
|
||||
{
|
||||
if (Name == name)
|
||||
{
|
||||
yield return this;
|
||||
}
|
||||
foreach (var child in children)
|
||||
{
|
||||
foreach (var item in child.FindChilds(name))
|
||||
{
|
||||
yield return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ImportedMesh
|
||||
{
|
||||
public string Path { get; set; }
|
||||
public List<ImportedSubmesh> SubmeshList { get; set; }
|
||||
public List<ImportedBone> BoneList { get; set; }
|
||||
public bool hasNormal { get; set; }
|
||||
public bool[] hasUV { get; set; }
|
||||
public bool hasTangent { get; set; }
|
||||
public bool hasColor { get; set; }
|
||||
}
|
||||
|
||||
public class ImportedSubmesh
|
||||
{
|
||||
public List<ImportedVertex> VertexList { get; set; }
|
||||
public List<ImportedFace> FaceList { get; set; }
|
||||
public string Material { get; set; }
|
||||
}
|
||||
|
||||
public class ImportedVertex
|
||||
{
|
||||
public Vector3 Vertex { get; set; }
|
||||
public Vector3 Normal { get; set; }
|
||||
public float[][] UV { get; set; }
|
||||
public Vector4 Tangent { get; set; }
|
||||
public Color Color { get; set; }
|
||||
public float[] Weights { get; set; }
|
||||
public int[] BoneIndices { get; set; }
|
||||
}
|
||||
|
||||
public class ImportedFace
|
||||
{
|
||||
public int[] VertexIndices { get; set; }
|
||||
}
|
||||
|
||||
public class ImportedBone
|
||||
{
|
||||
public string Path { get; set; }
|
||||
public Matrix4x4 Matrix { get; set; }
|
||||
}
|
||||
|
||||
public class ImportedMaterial
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public Color Diffuse { get; set; }
|
||||
public Color Ambient { get; set; }
|
||||
public Color Specular { get; set; }
|
||||
public Color Emissive { get; set; }
|
||||
public Color Reflection { get; set; }
|
||||
public float Shininess { get; set; }
|
||||
public float Transparency { get; set; }
|
||||
public List<ImportedMaterialTexture> Textures { get; set; }
|
||||
}
|
||||
|
||||
public class ImportedMaterialTexture
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int Dest { get; set; }
|
||||
public Vector2 Offset { get; set; }
|
||||
public Vector2 Scale { get; set; }
|
||||
}
|
||||
|
||||
public class ImportedTexture
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public byte[] Data { get; set; }
|
||||
|
||||
public ImportedTexture(MemoryStream stream, string name)
|
||||
{
|
||||
Name = name;
|
||||
Data = stream.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public class ImportedKeyframedAnimation
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public float SampleRate { get; set; }
|
||||
public List<ImportedAnimationKeyframedTrack> TrackList { get; set; }
|
||||
|
||||
public ImportedAnimationKeyframedTrack FindTrack(string path)
|
||||
{
|
||||
var track = TrackList.Find(x => x.Path == path);
|
||||
if (track == null)
|
||||
{
|
||||
track = new ImportedAnimationKeyframedTrack { Path = path };
|
||||
TrackList.Add(track);
|
||||
}
|
||||
|
||||
return track;
|
||||
}
|
||||
}
|
||||
|
||||
public class ImportedAnimationKeyframedTrack
|
||||
{
|
||||
public string Path { get; set; }
|
||||
public List<ImportedKeyframe<Vector3>> Scalings = new List<ImportedKeyframe<Vector3>>();
|
||||
public List<ImportedKeyframe<Vector3>> Rotations = new List<ImportedKeyframe<Vector3>>();
|
||||
public List<ImportedKeyframe<Vector3>> Translations = new List<ImportedKeyframe<Vector3>>();
|
||||
public ImportedBlendShape BlendShape;
|
||||
}
|
||||
|
||||
public class ImportedKeyframe<T>
|
||||
{
|
||||
public float time { get; set; }
|
||||
public T value { get; set; }
|
||||
|
||||
public ImportedKeyframe(float time, T value)
|
||||
{
|
||||
this.time = time;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public class ImportedBlendShape
|
||||
{
|
||||
public string ChannelName;
|
||||
public List<ImportedKeyframe<float>> Keyframes = new List<ImportedKeyframe<float>>();
|
||||
}
|
||||
|
||||
public class ImportedMorph
|
||||
{
|
||||
public string Path { get; set; }
|
||||
public List<ImportedMorphChannel> Channels { get; set; }
|
||||
}
|
||||
|
||||
public class ImportedMorphChannel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public List<ImportedMorphKeyframe> KeyframeList { get; set; }
|
||||
}
|
||||
|
||||
public class ImportedMorphKeyframe
|
||||
{
|
||||
public bool hasNormals { get; set; }
|
||||
public bool hasTangents { get; set; }
|
||||
public float Weight { get; set; }
|
||||
public List<ImportedMorphVertex> VertexList { get; set; }
|
||||
}
|
||||
|
||||
public class ImportedMorphVertex
|
||||
{
|
||||
public uint Index { get; set; }
|
||||
public ImportedVertex Vertex { get; set; }
|
||||
}
|
||||
|
||||
public static class ImportedHelpers
|
||||
{
|
||||
public static ImportedMesh FindMesh(string path, List<ImportedMesh> importedMeshList)
|
||||
{
|
||||
foreach (var mesh in importedMeshList)
|
||||
{
|
||||
if (mesh.Path == path)
|
||||
{
|
||||
return mesh;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ImportedMaterial FindMaterial(string name, List<ImportedMaterial> importedMats)
|
||||
{
|
||||
foreach (var mat in importedMats)
|
||||
{
|
||||
if (mat.Name == name)
|
||||
{
|
||||
return mat;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ImportedTexture FindTexture(string name, List<ImportedTexture> importedTextureList)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var tex in importedTextureList)
|
||||
{
|
||||
if (tex.Name == name)
|
||||
{
|
||||
return tex;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
AssetStudio/ILogger.cs
Normal file
26
AssetStudio/ILogger.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public enum LoggerEvent
|
||||
{
|
||||
Verbose,
|
||||
Debug,
|
||||
Info,
|
||||
Warning,
|
||||
Error,
|
||||
}
|
||||
|
||||
public interface ILogger
|
||||
{
|
||||
void Log(LoggerEvent loggerEvent, string message);
|
||||
}
|
||||
|
||||
public sealed class DummyLogger : ILogger
|
||||
{
|
||||
public void Log(LoggerEvent loggerEvent, string message) { }
|
||||
}
|
||||
}
|
||||
17
AssetStudio/IProgress.cs
Normal file
17
AssetStudio/IProgress.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public interface IProgress
|
||||
{
|
||||
void Report(int value);
|
||||
}
|
||||
|
||||
public sealed class DummyProgress : IProgress
|
||||
{
|
||||
public void Report(int value) { }
|
||||
}
|
||||
}
|
||||
112
AssetStudio/ImportHelper.cs
Normal file
112
AssetStudio/ImportHelper.cs
Normal file
@@ -0,0 +1,112 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public enum FileType
|
||||
{
|
||||
AssetsFile,
|
||||
BundleFile,
|
||||
WebFile,
|
||||
ResourceFile
|
||||
}
|
||||
|
||||
public static class ImportHelper
|
||||
{
|
||||
public static void MergeSplitAssets(string path, bool allDirectories = false)
|
||||
{
|
||||
var splitFiles = Directory.GetFiles(path, "*.split0", allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
|
||||
foreach (var splitFile in splitFiles)
|
||||
{
|
||||
var destFile = Path.GetFileNameWithoutExtension(splitFile);
|
||||
var destPath = Path.GetDirectoryName(splitFile) + "\\";
|
||||
var destFull = destPath + destFile;
|
||||
if (!File.Exists(destFull))
|
||||
{
|
||||
var splitParts = Directory.GetFiles(destPath, destFile + ".split*");
|
||||
using (var destStream = File.Create(destFull))
|
||||
{
|
||||
for (int i = 0; i < splitParts.Length; i++)
|
||||
{
|
||||
var splitPart = destFull + ".split" + i;
|
||||
using (var sourceStream = File.OpenRead(splitPart))
|
||||
{
|
||||
sourceStream.CopyTo(destStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string[] ProcessingSplitFiles(List<string> selectFile)
|
||||
{
|
||||
var splitFiles = selectFile.Where(x => x.Contains(".split"))
|
||||
.Select(x => Path.GetDirectoryName(x) + "\\" + Path.GetFileNameWithoutExtension(x))
|
||||
.Distinct()
|
||||
.ToList();
|
||||
selectFile.RemoveAll(x => x.Contains(".split"));
|
||||
foreach (var file in splitFiles)
|
||||
{
|
||||
if (File.Exists(file))
|
||||
{
|
||||
selectFile.Add(file);
|
||||
}
|
||||
}
|
||||
return selectFile.Distinct().ToArray();
|
||||
}
|
||||
|
||||
public static FileType CheckFileType(Stream stream, out EndianBinaryReader reader)
|
||||
{
|
||||
reader = new EndianBinaryReader(stream);
|
||||
return CheckFileType(reader);
|
||||
}
|
||||
|
||||
public static FileType CheckFileType(string fileName, out EndianBinaryReader reader)
|
||||
{
|
||||
reader = new EndianBinaryReader(File.OpenRead(fileName));
|
||||
return CheckFileType(reader);
|
||||
}
|
||||
|
||||
private static FileType CheckFileType(EndianBinaryReader reader)
|
||||
{
|
||||
var signature = reader.ReadStringToNull(20);
|
||||
reader.Position = 0;
|
||||
switch (signature)
|
||||
{
|
||||
case "UnityWeb":
|
||||
case "UnityRaw":
|
||||
case "UnityArchive":
|
||||
case "UnityFS":
|
||||
return FileType.BundleFile;
|
||||
case "UnityWebData1.0":
|
||||
return FileType.WebFile;
|
||||
default:
|
||||
{
|
||||
var magic = reader.ReadBytes(2);
|
||||
reader.Position = 0;
|
||||
if (WebFile.gzipMagic.SequenceEqual(magic))
|
||||
{
|
||||
return FileType.WebFile;
|
||||
}
|
||||
reader.Position = 0x20;
|
||||
magic = reader.ReadBytes(6);
|
||||
reader.Position = 0;
|
||||
if (WebFile.brotliMagic.SequenceEqual(magic))
|
||||
{
|
||||
return FileType.WebFile;
|
||||
}
|
||||
if (SerializedFile.IsSerializedFile(reader))
|
||||
{
|
||||
return FileType.AssetsFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FileType.ResourceFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,151 +0,0 @@
|
||||
FMOD, FMOD Ex, FMOD Designer and FMOD Studio are
|
||||
Copyright <20> 2005-2016 Firelight Technologies Pty, Ltd.
|
||||
|
||||
GRANT OF LICENSE
|
||||
----------------
|
||||
THIS END USER LICENSE AGREEMENT GRANTS THE USER, THE RIGHT TO USE FMOD,
|
||||
IN ITS LIBRARY AND TOOL FORM, IN THEIR OWN PRODUCTS, BE THEY FOR PERSONAL,
|
||||
EDUCATIONAL OR COMMERCIAL USE.
|
||||
THE USER MUST ADHERE TO THE LICENSING MODEL PROVIDED BY FIRELIGHT
|
||||
TECHNOLOGIES, AND MUST APPLY FOR A LICENSE IF NECESSARY. THE FOLLOWING
|
||||
LICENSES ARE AVAILABLE.
|
||||
|
||||
FMOD NON-COMMERCIAL LICENSE
|
||||
------------------------------------
|
||||
IF YOUR PRODUCT IS NOT INTENDED FOR COMMERCIAL GAIN AND DOES NOT
|
||||
INCLUDE THE FMOD LIBRARY FOR RESALE, LICENSE OR OTHER COMMERCIAL
|
||||
DISTRIBUTION, THEN USE OF FMOD IS FREE OF CHARGE. THERE ARE NO
|
||||
LICENSE FEES FOR NON-COMMERCIAL APPLICATIONS.
|
||||
THE USER MAY USE THIS EULA AS EVIDENCE OF THEIR LICENSE WITHOUT
|
||||
CONTACTING FIRELIGHT TECHNOLOGIES.
|
||||
|
||||
CONDITIONS/LIMITATIONS:
|
||||
- WHEN USING THIS LICENSE, THE FMOD LIBRARY CANNOT BE USED FOR
|
||||
RESALE OR OTHER COMMERCIAL DISTRIBUTION
|
||||
- THIS LICENSE CANNOT BE USED FOR PRODUCTS WHICH DO NOT MAKE
|
||||
PROFIT BUT ARE STILL COMMERCIALLY RELEASED
|
||||
- THIS LICENSE CANNOT BE USED FOR COMMERCIAL SERVICES, WHERE THE
|
||||
EXECUTABLE CONTAINING FMOD IS NOT SOLD, BUT THE DATA IS.
|
||||
- WHEN USING FMOD, A CREDIT LINE IS REQUIRED IN EITHER DOCUMENTATION,
|
||||
OR 'ON SCREEN' FORMAT (IF POSSIBLE). IT SHOULD CONTAIN AT LEAST
|
||||
THE WORDS "FMOD" (OR "FMOD STUDIO" IF APPLICABLE) AND
|
||||
"FIRELIGHT TECHNOLOGIES."
|
||||
LOGOS ARE AVAILABLE FOR BOX OR MANUAL ART, BUT ARE NOT MANDATORY.
|
||||
AN EXAMPLE CREDIT COULD BE:
|
||||
|
||||
FMOD Sound System, copyright <20> Firelight Technologies Pty, Ltd., 1994-2016.
|
||||
OR
|
||||
FMOD Studio, copyright <20> Firelight Technologies Pty, Ltd., 1994-2016.
|
||||
OR
|
||||
Audio Engine supplied by FMOD by Firelight Technologies.
|
||||
|
||||
NOTE THIS IN ADVANCE, AS IT MUST BE DONE BEFORE SHIPPING YOUR
|
||||
PRODUCT WITH FMOD.
|
||||
|
||||
FMOD FREE FOR INDIES LICENSE (FMOD STUDIO ONLY)
|
||||
------------------------------------------------
|
||||
INDIE DEVELOPERS ARE CONSIDERED BY OUR LICENSING MODEL, DEVELOPERS THAT DEVELOP
|
||||
A TITLE FOR UNDER $100K USD (TYPICALLY CONSIDERED AN 'INDIE' TITLE) TOTAL
|
||||
BUDGET, MEANING YOUR TOTAL COSTS ARE LESS THAN $100K USD AT TIME OF SHIPPING,
|
||||
YOU CAN USE FMOD FOR FREE.
|
||||
|
||||
CONDITIONS/LIMITATIONS
|
||||
- PLEASE WRITE TO SALES@FMOD.COM WITH THE NAME OF YOUR TITLE, RELEASE DATE
|
||||
AND PLATFORMS SO WE CAN REGISTER YOU IN OUR SYSTEM.
|
||||
- THERE IS NO RESTRICTION ON PLATFORM, ANY PLATFORM COMBINATION MAY BE USED.
|
||||
- INCOME IS NOT RELEVANT TO THE BUDGET LEVEL, IT MUST BE EXPENSE RELATED.
|
||||
- WHEN USING FMOD, A CREDIT LINE IS REQUIRED IN EITHER DOCUMENTATION,
|
||||
OR 'ON SCREEN' FORMAT (IF POSSIBLE). IT SHOULD CONTAIN AT LEAST
|
||||
THE WORDS FMOD STUDIO AND FIRELIGHT TECHNOLOGIES.
|
||||
LOGOS ARE AVAILABLE FOR BOX OR MANUAL ART, BUT ARE NOT MANDATORY.
|
||||
AN EXAMPLE CREDIT COULD BE:
|
||||
|
||||
FMOD STUDIO, COPYRIGHT <20> FIRELIGHT TECHNOLOGIES PTY, LTD., 1994-2016.
|
||||
|
||||
COMMERCIAL USAGE (FMOD EX AND FMOD STUDIO)
|
||||
------------------------------------------
|
||||
IF THE PRODUCT THAT USES FMOD IS INTENDED TO GENERATE INCOME, VIA DIRECT SALES
|
||||
OR INDIRECT REVENUE (SUCH AS ADVERTISING, DONATIONS, CONTRACT FEE) THEN THE
|
||||
DEVELOPER MUST APPLY TO FIRELIGHT TECHNOLOGIES FOR A COMMERCIAL LICENSE (UNLESS
|
||||
THE USER QUALIFIES FOR AN FMOD STUDIO 'INDIE LICENSE').
|
||||
TO APPLY FOR THIS LICENSE WRITE TO SALES@FMOD.COM WITH THE RELEVANT DETAILS.
|
||||
|
||||
REDISTRIBUTION LICENSE (FMOD EX AND FMOD STUDIO)
|
||||
------------------------------------------------
|
||||
IF THE USER WISHES TO REDISTRIBUTE FMOD AS PART OF AN ENGINE OR TOOL SOLUTION,
|
||||
THE USER MUST APPLY TO FIRELIGHT TECHNOLOGIES TO BE GRANTED A 'REDISTRIBUTION
|
||||
LICENSE'.
|
||||
TO APPLY FOR THIS LICENSE WRITE TO SALES@FMOD.COM WITH THE RELEVANT DETAILS.
|
||||
|
||||
WARRANTY AND LIMITATION OF LIABILITY
|
||||
------------------------------------
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION
|
||||
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
FMOD Uses Ogg Vorbis codec. BSD license.
|
||||
-----------------------------------------
|
||||
Copyright (c) 2002, Xiph.org Foundation
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION
|
||||
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
For Android platform code.
|
||||
--------------------------
|
||||
Copyright (C) 2010 The Android Open Source Project
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
@@ -1,52 +0,0 @@
|
||||
The Open Toolkit library license
|
||||
|
||||
Copyright (c) 2006 - 2014 Stefanos Apostolopoulos <stapostol@gmail.com> for the Open Toolkit library.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
|
||||
|
||||
Third parties
|
||||
|
||||
|
||||
OpenTK.Platform.Windows and OpenTK.Platform.X11 include portions of the Mono class library. These portions are covered by the following license:
|
||||
|
||||
Copyright (c) 2004 Novell, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
|
||||
OpenTK.Compatibility includes portions of the Tao Framework library (Tao.OpenGl, Tao.OpenAl and Tao.Platform.Windows.SimpleOpenGlControl). These portions are covered by the following license:
|
||||
|
||||
Copyright <20>2003-2007 Tao Framework Team
|
||||
http://www.taoframework.com
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
|
||||
OpenTK.Half offers Half-to-Single and Single-to-Half conversions based on OpenEXR source code, which is covered by the following license:
|
||||
|
||||
Copyright (c) 2002, Industrial Light & Magic, a division of Lucas Digital Ltd. LLC. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Industrial Light & Magic nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,22 +0,0 @@
|
||||
crunch/crnlib uses the ZLIB license:
|
||||
http://opensource.org/licenses/Zlib
|
||||
|
||||
Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
@@ -1,13 +0,0 @@
|
||||
Copyright (c) 2015 Harm Hanemaaijer <fgenfb@yahoo.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user