using System.Numerics; using EvilEngine.Formats.Humanoids; namespace EvilEngine.Formats.Models; public sealed record Model( IReadOnlyList Nodes, IReadOnlyList Roots, IReadOnlyList Meshes, IReadOnlyList Skins, IReadOnlyList Materials, IReadOnlyList Textures, IReadOnlyList Images, IReadOnlyList Animations, IReadOnlyList Variants, ModelExtras Extras); public sealed record ModelNode( string? Name, IReadOnlyList Children, Vector3 Translation, Quaternion Rotation, Vector3 Scale, int? Mesh = null, int? Skin = null, IReadOnlyList? Weights = null, IReadOnlyList? Lods = null) { public static ModelNode Named(string? name, params int[] children) { return new ModelNode(name, children, Vector3.Zero, Quaternion.Identity, Vector3.One); } } public sealed record ModelLod(int Mesh, float Distance); public sealed record ModelMesh( string? Name, IReadOnlyList Primitives, IReadOnlyList MorphNames, IReadOnlyList MorphWeights); public sealed record ModelPrimitive( int? Material, uint[] Indices, ModelVertices Vertices, IReadOnlyList Targets, IReadOnlyList VariantMappings); public sealed record ModelVertices( Vector3[] Positions, Vector3[]? Normals = null, Vector4[]? Tangents = null, Vector2[]? Uv0 = null, Vector2[]? Uv1 = null, Vector4[]? Colors = null, IReadOnlyList? Joints = null, IReadOnlyList? Custom = null) { public IReadOnlyList JointSets => Joints ?? []; public IReadOnlyList CustomAttributes => Custom ?? []; } public sealed record ModelJointSet(ushort[] Joints, float[] Weights); public sealed record ModelAttribute(string Name, int Components, float[] Values); public sealed record ModelMorphTarget(Vector3[]? Positions, Vector3[]? Normals, Vector3[]? Tangents); public sealed record ModelVariantMapping(int Material, IReadOnlyList Variants); public sealed record ModelSkin(string? Name, IReadOnlyList Joints, Matrix4x4[] InverseBindMatrices, int? Skeleton); public sealed record ModelMaterial(string? Name, ContentId? Id, ModelPbr Pbr); public enum ModelAlphaMode { Opaque, Mask, Blend } public sealed record ModelPbr( Vector4 BaseColor, ModelTextureRef? BaseColorTexture, float Metallic, float Roughness, ModelTextureRef? MetallicRoughnessTexture, ModelTextureRef? NormalTexture, float NormalScale, ModelTextureRef? OcclusionTexture, float OcclusionStrength, Vector3 Emissive, ModelTextureRef? EmissiveTexture, ModelAlphaMode AlphaMode, float AlphaCutoff, bool DoubleSided) { public static readonly ModelPbr Default = new(Vector4.One, null, 1, 1, null, null, 1, null, 1, Vector3.Zero, null, ModelAlphaMode.Opaque, 0.5f, false); } public sealed record ModelTextureRef(int Texture, int TexCoord = 0); public sealed record ModelTexture(int? Image, ModelSampler Sampler); public sealed record ModelSampler( int? MagFilter = null, int? MinFilter = null, int WrapS = ModelSampler.Repeat, int WrapT = ModelSampler.Repeat) { public const int Repeat = 10497; public static readonly ModelSampler Default = new(); } public sealed record ModelImage(string? Name, string MimeType, byte[] Bytes); public enum ModelChannelPath { Translation, Rotation, Scale, Weights } public enum ModelInterpolation { Linear, Step, CubicSpline } public sealed record ModelAnimation(string? Name, IReadOnlyList Channels) { public ModelAnimationInfo? Info { get; init; } } public sealed record ModelAnimationInfo(ContentId? Model, float Rate, bool Loop) { public Vector3? Move { get; init; } public IReadOnlyList Parameters { get; init; } = []; public IReadOnlyList At { get; init; } = []; public Vector2? Fade { get; init; } public string? Blend { get; init; } public bool Delta { get; init; } public bool Realtime { get; init; } public IReadOnlyList? Weights { get; init; } public IReadOnlyList Layers { get; init; } = []; } public sealed record ModelAnimationLayer(ContentId Animation, bool Always); public sealed record ModelChannel( int Node, ModelChannelPath Path, ModelInterpolation Interpolation, float[] Times, float[] Values); public sealed record ModelExtras( IReadOnlyList BodyGroups, IReadOnlyList Attachments, IReadOnlyList Hitboxes, IReadOnlyDictionary Attributes, IReadOnlyDictionary Games) { public static readonly ModelExtras Empty = new([], [], [], new Dictionary(), new Dictionary()); public HumanoidBinding? Humanoid { get; init; } public IReadOnlyList Eyeballs { get; init; } = []; public IReadOnlyList Mouths { get; init; } = []; public IReadOnlyList Constraints { get; init; } = []; } public sealed record ModelBodyGroup(string Name, IReadOnlyList Choices); public sealed record ModelBodyChoice(string Name, IReadOnlyList Nodes); public sealed record ModelEyeball( int Node, Vector3 Origin, Vector3 Up, Vector3 Forward, float Radius, float Iris, float Turn, Vector3 Look, float Limit, IReadOnlyList Primitives); public sealed record ModelMouth(int Node, Vector3 Forward); public abstract record ModelConstraint(int Node); public sealed record ModelPoseInterp(int Node, int Driver, IReadOnlyList Triggers) : ModelConstraint(Node); public readonly record struct ModelInterpTrigger( float Tolerance, Quaternion Trigger, Vector3 Position, Quaternion Rotation); public readonly record struct ModelPrimitiveRef(int Mesh, int Primitive); public sealed record ModelHitbox(string? Name, int Group, int Node, Vector3 Min, Vector3 Max);