Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding experimental Basic DAE exporter to OpenKh.Tools.KhModels, and some things #983

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions OpenKh.ColladaUtils/AlsoExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OpenKh.ColladaUtils
{
/// <seealso cref="https://kotlinlang.org/docs/scope-functions.html"/>
internal static class AlsoExtension
{
/// <seealso cref="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/also.html"/>
public static T Also<T>(this T obj, Action<T> action)
{
action(obj);
return obj;
}
}
}
78,603 changes: 78,603 additions & 0 deletions OpenKh.ColladaUtils/COLLADASchema.cs

Large diffs are not rendered by default.

70 changes: 70 additions & 0 deletions OpenKh.ColladaUtils/DaeModels.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using COLLADASchema;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace OpenKh.ColladaUtils
{
public static class DaeModels
{
public record DaeModel(
IReadOnlyList<DaeBone> Bones,
IReadOnlyList<DaeMaterial> Materials,
IReadOnlyList<DaeMesh> Meshes,
IReadOnlyList<DaeSkinController> SkinControllers,
IReadOnlyList<DaeMesh> InstanceGeometries,
IReadOnlyList<DaeInstanceController> InstanceControllers,
float GeometryScaling);

public record DaeInstanceController(
DaeMesh Mesh,
DaeBone Skeleton);

public record DaeSkinController(
DaeMesh Mesh,
IReadOnlyList<DaeBone> Bones,
IReadOnlyList<Matrix4x4> InvBindMatrices,
IReadOnlyList<float> SkinWeights,
IReadOnlyList<IReadOnlyList<DaeVertexWeight>> VertexWeightSets);

public record DaeVertexWeight(
int JointIndex,
int WeightIndex);

/// <param name="TriangleStripSets">
/// From blender 3.2.0:
///
/// ```
/// ERROR: Primitive type TRIANGLE_STRIPS is not supported.
/// Ignoring mesh Mesh1109
/// ```
/// </param>
public record DaeMesh(
string Name,
DaeMaterial? Material,
IReadOnlyList<Vector3> Vertices,
IReadOnlyList<Vector2> TextureCoordinates,
IReadOnlyList<IReadOnlyList<DaeVertexPointer>> TriangleStripSets,
IReadOnlyList<IReadOnlyList<DaeVertexPointer>> TriangleSets);

public record DaeVertexPointer(
int VertexIndex,
int TextureCoordinateIndex);

/// <param name="ParentIndex">`-1` for root</param>
public record DaeBone(
string Name,
int ParentIndex,
Vector3 RelativeScale,
Vector3 RelativeRotation,
Vector3 RelativeTranslation
);

public record DaeMaterial(
string Name,
string PngFilePath);
}
}
15 changes: 15 additions & 0 deletions OpenKh.ColladaUtils/OpenKh.ColladaUtils.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<None Update="collada_schema_1_4_1.xsd">
<SubType>Designer</SubType>
</None>
</ItemGroup>

</Project>
Loading
Loading