separate code into library

misc
This commit is contained in:
Perfare
2018-11-19 06:48:06 +08:00
parent b93866d196
commit 8ea998b81f
89 changed files with 2492 additions and 2273 deletions

View File

@ -1,49 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<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)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9131C403-7FE8-444D-9AF5-5FE5DF76FF24}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AssetStudioUtility</RootNamespace>
<AssemblyName>AssetStudioUtility</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="SharpDX.Mathematics">
<HintPath>..\AssetStudio\Libraries\SharpDX.Mathematics.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Imported.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -1,285 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using SharpDX;
namespace AssetStudio
{
public interface IImported
{
List<ImportedFrame> FrameList { get; }
List<ImportedMesh> MeshList { get; }
List<ImportedMaterial> MaterialList { get; }
List<ImportedTexture> TextureList { get; }
List<ImportedKeyframedAnimation> AnimationList { get; }
List<ImportedMorph> MorphList { get; }
}
public class ImportedFrame : IEnumerable<ImportedFrame>
{
public string Name { get; set; }
public float[] LocalRotation { get; set; }
public float[] LocalPosition { get; set; }
public float[] 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 void InitChildren(int count)
{
children = new List<ImportedFrame>(count);
}
public void AddChild(ImportedFrame obj)
{
children.Add(obj);
obj.Parent = this;
}
public void ClearChild()
{
children.Clear();
}
public IEnumerator<ImportedFrame> GetEnumerator()
{
return children.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
public class ImportedMesh
{
public string Name { get; set; }
public List<ImportedSubmesh> SubmeshList { get; set; }
public List<ImportedBone> BoneList { 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 Position { get; set; }
public float[] Weights { get; set; }
public byte[] BoneIndices { get; set; }
public Vector3 Normal { get; set; }
public float[] UV { get; set; }
public Vector4 Tangent { get; set; }
}
public class ImportedVertexWithColour : ImportedVertex
{
public Color4 Colour { get; set; }
}
public class ImportedFace
{
public int[] VertexIndices { get; set; }
}
public class ImportedBone
{
public string Name { get; set; }
public float[,] Matrix { get; set; }
}
public class ImportedMaterial
{
public string Name { get; set; }
public Color4 Diffuse { get; set; }
public Color4 Ambient { get; set; }
public Color4 Specular { get; set; }
public Color4 Emissive { get; set; }
public float Power { get; set; }
public string[] Textures { get; set; }
public Vector2[] TexOffsets { get; set; }
public Vector2[] TexScales { 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 List<ImportedAnimationKeyframedTrack> TrackList { get; set; }
public ImportedAnimationKeyframedTrack FindTrack(string name)
{
var track = TrackList.Find(x => x.Name == name);
if (track == null)
{
track = new ImportedAnimationKeyframedTrack { Name = name };
TrackList.Add(track);
}
return track;
}
}
public class ImportedAnimationKeyframedTrack
{
public string Name { 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 List<ImportedKeyframe<float>> Curve = new List<ImportedKeyframe<float>>();
}
public class ImportedKeyframe<T>
{
public float time { get; set; }
public T value { get; set; }
public T inSlope { get; set; }
public T outSlope { get; set; }
public ImportedKeyframe(float time, T value)
{
this.time = time;
this.value = value;
}
}
public class ImportedMorph
{
public string Name { get; set; }
public string ClipName { get; set; }
public List<Tuple<float, int, int>> Channels { get; set; }
public List<ImportedMorphKeyframe> KeyframeList { get; set; }
public List<ushort> MorphedVertexIndices { get; set; }
}
public class ImportedMorphKeyframe
{
public string Name { get; set; }
public List<ImportedVertex> VertexList { get; set; }
public List<ushort> MorphedVertexIndices { get; set; }
public float Weight { get; set; }
}
public static class ImportedHelpers
{
public static ImportedFrame FindFrame(string name, ImportedFrame root)
{
if (root.Name == name)
{
return root;
}
foreach (var child in root)
{
var frame = FindFrame(name, child);
if (frame != null)
{
return frame;
}
}
return null;
}
public static ImportedFrame FindChildOrRoot(string name, ImportedFrame root)
{
foreach (var child in root)
{
var frame = FindFrame(name, child);
if (frame != null)
{
return frame;
}
}
if (root.Name == name)
{
return root;
}
return null;
}
public static ImportedMesh FindMesh(string frameName, List<ImportedMesh> importedMeshList)
{
foreach (ImportedMesh mesh in importedMeshList)
{
if (mesh.Name == frameName)
{
return mesh;
}
}
return null;
}
public static ImportedMesh FindMesh(ImportedFrame frame, List<ImportedMesh> importedMeshList)
{
string framePath = frame.Name;
ImportedFrame root = frame;
while (root.Parent != null)
{
root = root.Parent;
framePath = root.Name + "/" + framePath;
}
foreach (ImportedMesh mesh in importedMeshList)
{
if (mesh.Name == framePath)
{
return mesh;
}
}
return null;
}
public static ImportedMaterial FindMaterial(string name, List<ImportedMaterial> importedMats)
{
foreach (ImportedMaterial 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 (ImportedTexture tex in importedTextureList)
{
if (tex.Name == name)
{
return tex;
}
}
return null;
}
}
}

View File

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("AssetStudioUtility")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AssetStudioUtility")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("9131c403-7fe8-444d-9af5-5fe5df76ff24")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]