0c126e4155
Rewrote the compression handling from scatch. It's way easier and cleaner to add new formats code wise as it's handled like file formats. Added wip TVOL support (Touhou Azure Reflections) Added XCI support. Note I plan to improve NSP, XCI, NCA, etc later for exefs exporting. The compression rework now compresses via streams, so files get decompressed properly within archives as streams. Added hyrule warriors bin.gz compression along with archive rebuilding. Note i do not have texture rebuilding done just yet.
160 lines
4.8 KiB
C#
160 lines
4.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Collada141;
|
|
using System.Runtime.InteropServices;
|
|
using System.Diagnostics;
|
|
using System.Globalization;
|
|
using System.Xml;
|
|
using ColladaHelper;
|
|
using OpenTK;
|
|
using Toolbox.Library.Rendering;
|
|
|
|
namespace Toolbox.Library
|
|
{
|
|
public class DAE : DAEHelper
|
|
{
|
|
public List<STGenericObject> objects = new List<STGenericObject>();
|
|
public List<STGenericMaterial> materials = new List<STGenericMaterial>();
|
|
public STSkeleton skeleton;
|
|
public List<string> BoneNames = new List<string>();
|
|
|
|
public bool UseTransformMatrix = true;
|
|
|
|
Dictionary<string, Vertex> VertexSkinSources = new Dictionary<string, Vertex>();
|
|
Dictionary<string, Matrix4> MatrixSkinSources = new Dictionary<string, Matrix4>();
|
|
|
|
private Matrix4 GlobalTransform = Matrix4.Identity;
|
|
public bool LoadFile(string FileName)
|
|
{
|
|
GlobalTransform = Matrix4.Identity;
|
|
|
|
COLLADA collada = COLLADA.Load(FileName);
|
|
|
|
//Check axis up
|
|
if (collada.asset != null)
|
|
{
|
|
switch (collada.asset.up_axis)
|
|
{
|
|
case UpAxisType.X_UP:
|
|
GlobalTransform = Matrix4.CreateRotationX(90);
|
|
break;
|
|
case UpAxisType.Y_UP:
|
|
GlobalTransform = Matrix4.CreateRotationY(90);
|
|
break;
|
|
case UpAxisType.Z_UP:
|
|
GlobalTransform = Matrix4.CreateRotationZ(90);
|
|
break;
|
|
}
|
|
|
|
if (collada.asset.unit != null)
|
|
{
|
|
var amount = collada.asset.unit.meter;
|
|
var type = collada.asset.unit.name;
|
|
if (type == "meter")
|
|
{
|
|
|
|
}
|
|
else if (type == "centimeter")
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach (var item in collada.Items)
|
|
{
|
|
if (item is library_geometries)
|
|
LoadGeometry((library_geometries)item);
|
|
if (item is library_images)
|
|
LoadImages((library_images)item);
|
|
if (item is library_controllers)
|
|
LoadControllers((library_controllers)item);
|
|
if (item is library_nodes)
|
|
LoadNodes((library_nodes)item);
|
|
if (item is library_visual_scenes)
|
|
LoadVisualScenes((library_visual_scenes)item);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
private void LoadVisualScenes(library_visual_scenes nodes)
|
|
{
|
|
|
|
}
|
|
|
|
private void LoadNodes(library_nodes nodes)
|
|
{
|
|
|
|
}
|
|
|
|
private void LoadControllers(library_controllers controllers)
|
|
{
|
|
|
|
}
|
|
|
|
private void LoadMaterials(library_materials materials)
|
|
{
|
|
|
|
}
|
|
|
|
private void LoadImages(library_images images)
|
|
{
|
|
|
|
}
|
|
|
|
private void LoadGeometry(library_geometries geometries)
|
|
{
|
|
foreach (var geom in geometries.geometry)
|
|
{
|
|
var mesh = geom.Item as mesh;
|
|
if (mesh == null)
|
|
continue;
|
|
|
|
foreach (var source in mesh.source)
|
|
{
|
|
var float_array = source.Item as float_array;
|
|
if (float_array == null)
|
|
continue;
|
|
|
|
Console.Write("Geometry {0} source {1} : ", geom.id, source.id);
|
|
foreach (var mesh_source_value in float_array.Values)
|
|
Console.Write("{0} ", mesh_source_value);
|
|
Console.WriteLine();
|
|
}
|
|
}
|
|
}
|
|
|
|
public bool ExportFile(string FileName, List<STGenericObject> meshes, STSkeleton skeleton = null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
private List<STGenericObject> CreateGenericObjects(string Name, library_geometries Geometries)
|
|
{
|
|
List<STGenericObject> objects = new List<STGenericObject>();
|
|
foreach (var geom in Geometries.geometry)
|
|
{
|
|
var daeMesh = geom.Item as mesh;
|
|
if (daeMesh == null)
|
|
continue;
|
|
|
|
STGenericObject mesh = new STGenericObject();
|
|
mesh.ObjectName = Name;
|
|
|
|
foreach (var source in daeMesh.source)
|
|
{
|
|
var float_array = source.Item as float_array;
|
|
if (float_array == null)
|
|
continue;
|
|
}
|
|
objects.Add(mesh);
|
|
}
|
|
return objects;
|
|
}
|
|
}
|
|
}
|