2019-04-30 23:07:25 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Collada141;
|
2019-05-01 21:38:14 +02:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Xml;
|
|
|
|
|
using ColladaHelper;
|
2019-06-13 23:31:35 +02:00
|
|
|
|
using OpenTK;
|
2019-07-16 23:35:21 +02:00
|
|
|
|
using Toolbox.Library.Rendering;
|
2019-04-30 23:07:25 +02:00
|
|
|
|
|
2019-07-16 23:35:21 +02:00
|
|
|
|
namespace Toolbox.Library
|
2019-04-30 23:07:25 +02:00
|
|
|
|
{
|
2019-05-01 21:38:14 +02:00
|
|
|
|
public class DAE : DAEHelper
|
2019-04-30 23:07:25 +02:00
|
|
|
|
{
|
2019-05-01 21:38:14 +02:00
|
|
|
|
public List<STGenericObject> objects = new List<STGenericObject>();
|
|
|
|
|
public List<STGenericMaterial> materials = new List<STGenericMaterial>();
|
|
|
|
|
public STSkeleton skeleton;
|
|
|
|
|
public List<string> BoneNames = new List<string>();
|
|
|
|
|
|
2019-04-30 23:07:25 +02:00
|
|
|
|
public bool UseTransformMatrix = true;
|
|
|
|
|
|
2019-06-13 23:31:35 +02:00
|
|
|
|
Dictionary<string, Vertex> VertexSkinSources = new Dictionary<string, Vertex>();
|
|
|
|
|
Dictionary<string, Matrix4> MatrixSkinSources = new Dictionary<string, Matrix4>();
|
|
|
|
|
|
|
|
|
|
public bool LoadFile(string FileName)
|
2019-04-30 23:07:25 +02:00
|
|
|
|
{
|
|
|
|
|
COLLADA collada = COLLADA.Load(FileName);
|
|
|
|
|
|
|
|
|
|
foreach (var item in collada.Items)
|
|
|
|
|
{
|
|
|
|
|
if (item is library_geometries)
|
|
|
|
|
{
|
2019-05-01 21:38:14 +02:00
|
|
|
|
LoadGeometry((library_geometries)item);
|
2019-04-30 23:07:25 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-06-13 23:31:35 +02:00
|
|
|
|
|
|
|
|
|
return true;
|
2019-04-30 23:07:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-01 21:38:14 +02:00
|
|
|
|
private void SetControllers(COLLADA collada)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-13 23:31:35 +02:00
|
|
|
|
|
2019-05-01 21:38:14 +02:00
|
|
|
|
private void LoadGeometry(library_geometries Geometries)
|
2019-04-30 23:07:25 +02:00
|
|
|
|
{
|
2019-05-01 21:38:14 +02:00
|
|
|
|
foreach (var geom in Geometries.geometry)
|
|
|
|
|
{
|
|
|
|
|
var mesh = geom.Item as mesh;
|
|
|
|
|
if (mesh == null)
|
|
|
|
|
continue;
|
|
|
|
|
|
2019-06-13 23:31:35 +02:00
|
|
|
|
Console.WriteLine(geom.name);
|
|
|
|
|
|
2019-05-01 21:38:14 +02:00
|
|
|
|
foreach (var source in mesh.source)
|
|
|
|
|
{
|
|
|
|
|
var float_array = source.Item as float_array;
|
|
|
|
|
if (float_array == null)
|
|
|
|
|
continue;
|
2019-04-30 23:07:25 +02:00
|
|
|
|
|
2019-05-01 21:38:14 +02:00
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-30 23:07:25 +02:00
|
|
|
|
}
|
2019-06-13 23:31:35 +02:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2019-04-30 23:07:25 +02:00
|
|
|
|
}
|
|
|
|
|
}
|