﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

public class T2SkinnedMeshMono : MonoBehaviour
{
    [HideInInspector]
    public string loadPath;
    [HideInInspector]
    public string savePath;
    public T2SkinnedMesh sMesh;
}

[Serializable]
public class T2SkinnedMesh
{
    public int version; //always 3
    public Vector3 boundingBoxMin;
    public Vector3 boundingBoxMax;
    public sbyte headTrackStartNode;
    public sbyte headTrackEndNode;
    public sbyte headTrackTrackFactor;
    public T2SkinnedMeshNode[] nodes; //nodes are also referred as joints/bone
    public int hotPointGroupCount; // ignored/unused in kex
    public T2SkinnedMeshHotPoint[] hotPoints;
    public int layers; // ignored/unused in kex
    public T2SkinnedMeshSurface[] surfaces; //each surface is a draw call
    public T2SkinnedMeshVertex[] vertices;
}

[Serializable]
public class T2SkinnedMeshNode
{
    public Int16[] childNodes; //indices
    public Vector3 boundingBoxMin;
    public Vector3 boundingBoxMax;
    public sbyte impactType;
    public sbyte symbolFlags;
    public sbyte parentIndex; //node index
    public float damageScalar; //range between 0.0 and 1.0
    public int flags;
}

[Serializable]
public class T2SkinnedMeshHotPoint
{
    public Vector3 origin; //in local model space
    public int flags;
    public Int16 boneID; //which bone to associate this hotpoint to
    public Int16 particleEffectID1; //if value is -1 then it will deal damage
    public Int16 particleEffectID2; //if effect ID 1 is -1 then it will deal damage based on what's provided for this field
}

[Serializable]
public class T2SkinnedMeshSurface
{
    public string materialFile;
    public Int16[] triangleIndexes; //last triangle index should always be -1
}

[Serializable]
public class T2SkinnedMeshVertex
{
    public Vector3 xyz;
    public Vector2 uv; //when read in TurokEX, the y coordinate is always read as 1.0f - UV.y
    public Vector3 normals;
    public Int16 nodeIndex;
}
