Skip to content
This repository was archived by the owner on May 11, 2024. It is now read-only.

Commit a56b958

Browse files
committed
- [GUI] Improve ExportOptions.
- [GUI] Update Library. - [GUI] Fix bug in `AssetBrowser`.
1 parent 445460d commit a56b958

27 files changed

+512
-477
lines changed

AssetStudio.CLI/Exporter.cs

+4-6
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ public static bool ExportAnimator(AssetItem item, string exportPath, List<AssetI
336336
}
337337
var m_Animator = (Animator)item.Asset;
338338
var convert = animationList != null
339-
? new ModelConverter(m_Animator, Properties.Settings.Default.convertType, Studio.Game, Properties.Settings.Default.collectAnimations, animationList.Select(x => (AnimationClip)x.Asset).ToArray())
340-
: new ModelConverter(m_Animator, Properties.Settings.Default.convertType, Studio.Game, Properties.Settings.Default.collectAnimations);
339+
? new ModelConverter(m_Animator, Properties.Settings.Default.convertType, Properties.Settings.Default.texs, Properties.Settings.Default.uvs, Studio.Game, Properties.Settings.Default.collectAnimations, animationList.Select(x => (AnimationClip)x.Asset).ToArray())
340+
: new ModelConverter(m_Animator, Properties.Settings.Default.convertType, Properties.Settings.Default.texs, Properties.Settings.Default.uvs, Studio.Game, Properties.Settings.Default.collectAnimations);
341341
ExportFbx(convert, exportFullPath);
342342
return true;
343343
}
@@ -352,8 +352,8 @@ public static bool ExportGameObject(AssetItem item, string exportPath, List <Ass
352352
public static bool ExportGameObject(GameObject gameObject, string exportPath, List<AssetItem> animationList = null)
353353
{
354354
var convert = animationList != null
355-
? new ModelConverter(gameObject, Properties.Settings.Default.convertType, Studio.Game, Properties.Settings.Default.collectAnimations, animationList.Select(x => (AnimationClip)x.Asset).ToArray())
356-
: new ModelConverter(gameObject, Properties.Settings.Default.convertType, Studio.Game, Properties.Settings.Default.collectAnimations);
355+
? new ModelConverter(gameObject, Properties.Settings.Default.convertType, Properties.Settings.Default.texs, Properties.Settings.Default.uvs, Studio.Game, Properties.Settings.Default.collectAnimations, animationList.Select(x => (AnimationClip)x.Asset).ToArray())
356+
: new ModelConverter(gameObject, Properties.Settings.Default.convertType, Properties.Settings.Default.texs, Properties.Settings.Default.uvs, Studio.Game, Properties.Settings.Default.collectAnimations);
357357

358358
if (convert.MeshList.Count == 0)
359359
{
@@ -377,8 +377,6 @@ private static void ExportFbx(IImported convert, string exportPath)
377377
exportBlendShape = Properties.Settings.Default.exportBlendShape,
378378
castToBone = Properties.Settings.Default.castToBone,
379379
boneSize = (int)Properties.Settings.Default.boneSize,
380-
exportAllUvsAsDiffuseMaps = Properties.Settings.Default.exportAllUvsAsDiffuseMaps,
381-
exportUV0UV1 = Properties.Settings.Default.exportUV0UV1,
382380
scaleFactor = (float)Properties.Settings.Default.scaleFactor,
383381
fbxVersion = Properties.Settings.Default.fbxVersion,
384382
fbxFormat = Properties.Settings.Default.fbxFormat

AssetStudio.CLI/Program.cs

-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ public static void Run(Options o)
4343
Logger.Default = new ConsoleLogger();
4444
Logger.FileLogging = Settings.Default.enableFileLogging;
4545
AssetsHelper.Minimal = Settings.Default.minimalAssetMap;
46-
Shader.Parsable = !Settings.Default.disableShader;
47-
Renderer.Parsable = !Settings.Default.disableRenderer;
48-
AnimationClip.Parsable = !Settings.Default.disableAnimationClip;
4946
AssetsHelper.SetUnityVersion(o.UnityVersion);
5047

5148
assetsManager.Silent = o.Silent;

AssetStudio.CLI/Settings.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,17 @@ public class Settings
5757
public bool exportBlendShape => AppSettings.Get("exportBlendShape", true);
5858
public bool castToBone => AppSettings.Get("castToBone", false);
5959
public bool restoreExtensionName => AppSettings.Get("restoreExtensionName", true);
60-
public bool exportAllUvsAsDiffuseMaps => AppSettings.Get("exportAllUvsAsDiffuseMaps", false);
61-
public bool exportUV0UV1 => AppSettings.Get("exportUV0UV1", false);
6260
public bool encrypted => AppSettings.Get("encrypted", true);
6361
public byte key => AppSettings.Get("key", (byte)0x93);
6462
public int selectedGame => AppSettings.Get("selectedGame", 0);
6563
public bool enableResolveDependencies => AppSettings.Get("enableResolveDependencies", true);
6664
public int selectedCNUnityKey => AppSettings.Get("selectedCNUnityKey", 0);
6765
public int selectedAssetMapType => AppSettings.Get("selectedAssetMapType", 0);
6866
public bool exportMiHoYoBinData => AppSettings.Get("exportMiHoYoBinData", true);
69-
public bool disableShader => AppSettings.Get("disableShader", false);
70-
public bool disableRenderer => AppSettings.Get("disableRenderer", false);
71-
public bool disableAnimationClip => AppSettings.Get("disableAnimationClip", false);
7267
public bool enableFileLogging => AppSettings.Get("enableFileLogging", false);
7368
public bool minimalAssetMap => AppSettings.Get("minimalAssetMap", true);
69+
public string texs => AppSettings.Get("texs", string.Empty);
70+
public string uvs => AppSettings.Get("uvs", string.Empty);
7471

7572
}
7673
}

AssetStudio.CLI/Studio.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,13 @@ public static void ProcessAssetData(Object asset, ClassIDType[] typeFilters, Reg
332332
break;
333333
case Mesh _:
334334
case TextAsset _:
335-
case AnimationClip _ when AnimationClip.Parsable:
335+
case AnimationClip _:
336336
case Font _:
337337
case MovieTexture _:
338338
case Sprite _:
339339
case Material _:
340340
case MiHoYoBinData _:
341-
case Shader _ when Shader.Parsable:
341+
case Shader _:
342342
case Animator _:
343343
exportable = !ModelOnly;
344344
break;

AssetStudio.FBXNative/api.cpp

+43-12
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,18 @@ AS_API(void) AsFbxLinkTexture(int32_t dest, FbxFileTexture* pTexture, FbxSurface
370370
case 3:
371371
pProp = &pMaterial->Bump;
372372
break;
373+
case 4:
374+
pProp = &pMaterial->Ambient;
375+
break;
376+
case 5:
377+
pProp = &pMaterial->Emissive;
378+
break;
379+
case 6:
380+
pProp = &pMaterial->Reflection;
381+
break;
382+
case 7:
383+
pProp = &pMaterial->DisplacementColor;
384+
break;
373385
default:
374386
pProp = nullptr;
375387
break;
@@ -462,26 +474,45 @@ AS_API(void) AsFbxMeshCreateElementNormal(FbxMesh* pMesh)
462474
pNormal->SetReferenceMode(FbxGeometryElement::eDirect);
463475
}
464476

465-
AS_API(void) AsFbxMeshCreateDiffuseUV(FbxMesh* pMesh, int32_t uv)
477+
AS_API(void) AsFbxMeshCreateUV(FbxMesh* pMesh, int32_t uv, int32_t uvType)
466478
{
467479
if (pMesh == nullptr)
468480
{
469481
return;
470482
}
471483

472-
auto pUV = pMesh->CreateElementUV(FbxString("UV") + FbxString(uv), FbxLayerElement::eTextureDiffuse);
473-
pUV->SetMappingMode(FbxGeometryElement::eByControlPoint);
474-
pUV->SetReferenceMode(FbxGeometryElement::eDirect);
475-
}
476-
477-
AS_API(void) AsFbxMeshCreateNormalMapUV(FbxMesh* pMesh, int32_t uv)
478-
{
479-
if (pMesh == nullptr)
480-
{
481-
return;
484+
FbxLayerElement::EType type;
485+
switch (uvType) {
486+
case 0:
487+
type = FbxLayerElement::eTextureDiffuse;
488+
break;
489+
case 1:
490+
type = FbxLayerElement::eTextureNormalMap;
491+
break;
492+
case 2:
493+
type = FbxLayerElement::eTextureSpecular;
494+
break;
495+
case 3:
496+
type = FbxLayerElement::eTextureBump;
497+
break;
498+
case 4:
499+
type = FbxLayerElement::eTextureAmbient;
500+
break;
501+
case 5:
502+
type = FbxLayerElement::eTextureEmissive;
503+
break;
504+
case 6:
505+
type = FbxLayerElement::eTextureReflection;
506+
break;
507+
case 7:
508+
type = FbxLayerElement::eTextureDisplacement;
509+
break;
510+
default:
511+
type = FbxLayerElement::eTextureDiffuse;
512+
break;
482513
}
483514

484-
auto pUV = pMesh->CreateElementUV(FbxString("UV") + FbxString(uv), FbxLayerElement::eTextureNormalMap);
515+
auto pUV = pMesh->CreateElementUV(FbxString("UV") + FbxString(uv), type);
485516
pUV->SetMappingMode(FbxGeometryElement::eByControlPoint);
486517
pUV->SetReferenceMode(FbxGeometryElement::eDirect);
487518
}

AssetStudio.FBXWrapper/Fbx.cs

-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ public record ExportOptions
6262
public bool exportBlendShape;
6363
public bool castToBone;
6464
public int boneSize;
65-
public bool exportAllUvsAsDiffuseMaps;
66-
public bool exportUV0UV1;
6765
public float scaleFactor;
6866
public int fbxVersion;
6967
public int fbxFormat;

AssetStudio.FBXWrapper/FbxExporterContext.PInvoke.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ private static IntPtr AsFbxExportSingleFrame(IntPtr context, IntPtr parentNode,
7676
private static extern void AsFbxMeshCreateElementNormal(IntPtr mesh);
7777

7878
[DllImport(FbxDll.DllName)]
79-
private static extern void AsFbxMeshCreateDiffuseUV(IntPtr mesh, int uv);
80-
81-
[DllImport(FbxDll.DllName)]
82-
private static extern void AsFbxMeshCreateNormalMapUV(IntPtr mesh, int uv);
79+
private static extern void AsFbxMeshCreateUV(IntPtr mesh, int uv, int uvType);
8380

8481
[DllImport(FbxDll.DllName)]
8582
private static extern void AsFbxMeshCreateElementTangent(IntPtr mesh);

AssetStudio.FBXWrapper/FbxExporterContext.cs

+5-32
Original file line numberDiff line numberDiff line change
@@ -256,39 +256,12 @@ private void ExportMesh(ImportedFrame rootFrame, List<ImportedMaterial> material
256256
AsFbxMeshCreateElementNormal(mesh);
257257
}
258258

259-
if (_exportOptions.exportUV0UV1)
259+
for (int i = 0; i < importedMesh.hasUV.Length; i++)
260260
{
261-
if (importedMesh.hasUV[0])
262-
{
263-
AsFbxMeshCreateDiffuseUV(mesh, 0);
264-
}
265-
if (importedMesh.hasUV[1])
266-
{
267-
if (_exportOptions.exportAllUvsAsDiffuseMaps)
268-
{
269-
AsFbxMeshCreateDiffuseUV(mesh, 1);
270-
}
271-
else
272-
{
273-
AsFbxMeshCreateNormalMapUV(mesh, 1);
274-
}
275-
}
276-
}
277-
else
278-
{
279-
for (int i = 0; i < importedMesh.hasUV.Length; i++)
280-
{
281-
if (!importedMesh.hasUV[i]) { continue; }
261+
if (!importedMesh.hasUV[i]) { continue; }
282262

283-
if (i == 1 && !_exportOptions.exportAllUvsAsDiffuseMaps)
284-
{
285-
AsFbxMeshCreateNormalMapUV(mesh, 1);
286-
}
287-
else
288-
{
289-
AsFbxMeshCreateDiffuseUV(mesh, i);
290-
}
291-
}
263+
var type = importedMesh.uvType[i];
264+
AsFbxMeshCreateUV(mesh, i, type);
292265
}
293266

294267
if (importedMesh.hasTangent)
@@ -391,7 +364,7 @@ private void ExportMesh(ImportedFrame rootFrame, List<ImportedMaterial> material
391364
AsFbxMeshElementNormalAdd(mesh, 0, normal.X, normal.Y, normal.Z);
392365
}
393366

394-
var uvSize = _exportOptions.exportUV0UV1 ? 2 : importedMesh.hasUV.Length;
367+
var uvSize = importedMesh.hasUV.Length;
395368
for (var uvIndex = 0; uvIndex < uvSize; uvIndex += 1)
396369
{
397370
if (importedMesh.hasUV[uvIndex])

AssetStudio.GUI/App.config

+6-15
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@
6464
<setting name="restoreExtensionName" serializeAs="String">
6565
<value>True</value>
6666
</setting>
67-
<setting name="exportAllUvsAsDiffuseMaps" serializeAs="String">
68-
<value>False</value>
69-
</setting>
7067
<setting name="key" serializeAs="String">
7168
<value>147</value>
7269
</setting>
@@ -91,15 +88,6 @@
9188
<setting name="skipContainer" serializeAs="String">
9289
<value>False</value>
9390
</setting>
94-
<setting name="exportUV0UV1" serializeAs="String">
95-
<value>False</value>
96-
</setting>
97-
<setting name="disableShader" serializeAs="String">
98-
<value>False</value>
99-
</setting>
100-
<setting name="disableRenderer" serializeAs="String">
101-
<value>False</value>
102-
</setting>
10391
<setting name="minimalAssetMap" serializeAs="String">
10492
<value>True</value>
10593
</setting>
@@ -115,15 +103,18 @@
115103
<setting name="selectedCABMapName" serializeAs="String">
116104
<value />
117105
</setting>
118-
<setting name="disableAnimationClip" serializeAs="String">
119-
<value>False</value>
120-
</setting>
121106
<setting name="enableFileLogging" serializeAs="String">
122107
<value>True</value>
123108
</setting>
124109
<setting name="enableVerbose" serializeAs="String">
125110
<value>False</value>
126111
</setting>
112+
<setting name="uvs" serializeAs="String">
113+
<value>{"UV0":{"Item1":true,"Item2":0},"UV1":{"Item1":false,"Item2":1},"UV2":{"Item1":true,"Item2":0},"UV3":{"Item1":false,"Item2":0},"UV4":{"Item1":false,"Item2":0},"UV5":{"Item1":false,"Item2":0},"UV6":{"Item1":true,"Item2":0},"UV7":{"Item1":true,"Item2":0}}</value>
114+
</setting>
115+
<setting name="texs" serializeAs="String">
116+
<value>{}</value>
117+
</setting>
127118
</AssetStudio.GUI.Properties.Settings>
128119
</userSettings>
129120
</configuration>

AssetStudio.GUI/AssetBrowser.cs

+11-5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public AssetBrowser(MainForm form)
2323
{
2424
InitializeComponent();
2525
_parent = form;
26+
_assetEntries = new List<AssetEntry>();
27+
_columnNames = new List<string>();
2628
}
2729

2830
private async void loadAssetMap_Click(object sender, EventArgs e)
@@ -37,8 +39,11 @@ private async void loadAssetMap_Click(object sender, EventArgs e)
3739
await Task.Run(() => ResourceMap.FromFile(path));
3840

3941
_sortedColumn = null;
40-
_columnNames = typeof(AssetEntry).GetProperties().Select(x => x.Name).ToList();
41-
_assetEntries = ResourceMap.GetEntries();
42+
_columnNames.Clear();
43+
_columnNames.AddRange(typeof(AssetEntry).GetProperties().Select(x => x.Name).ToList());
44+
45+
_assetEntries.Clear();
46+
_assetEntries.AddRange(ResourceMap.GetEntries());
4247

4348
assetDataGridView.Columns.Clear();
4449
assetDataGridView.Columns.AddRange(_columnNames.Select(x => new DataGridViewTextBoxColumn() { Name = x, HeaderText = x, SortMode = DataGridViewColumnSortMode.Programmatic }).ToArray());
@@ -96,9 +101,9 @@ private void searchTextBox_KeyPress(object sender, KeyPressEventArgs e)
96101
filters[name] = new Regex(regex, RegexOptions.IgnoreCase);
97102
}
98103

99-
_assetEntries = ResourceMap.GetEntries().FindAll(x => x.Matches(filters));
104+
_assetEntries.Clear();
105+
_assetEntries.AddRange(ResourceMap.GetEntries().FindAll(x => x.Matches(filters)));
100106

101-
assetDataGridView.CurrentCell = assetDataGridView[0, 0];
102107
assetDataGridView.Rows.Clear();
103108
assetDataGridView.RowCount = _assetEntries.Count;
104109
assetDataGridView.Refresh();
@@ -158,7 +163,8 @@ private void AssetListView_ColumnHeaderMouseClick(object sender, DataGridViewCel
158163
_ => x => ""
159164
};
160165

161-
_assetEntries = direction == ListSortDirection.Ascending ? _assetEntries.OrderBy(keySelector).ToList() : _assetEntries.OrderByDescending(keySelector).ToList();
166+
_assetEntries.Clear();
167+
_assetEntries.AddRange(direction == ListSortDirection.Ascending ? _assetEntries.OrderBy(keySelector).ToList() : _assetEntries.OrderByDescending(keySelector).ToList());
162168

163169
assetDataGridView.CurrentCell = assetDataGridView[0, 0];
164170
assetDataGridView.Rows.Clear();

0 commit comments

Comments
 (0)