using System.Collections;
using LibMMD.Unity3D.Animation;
using UnityEngine;
namespace LibMMD.Unity3D
{
/// Consumer-facing contract for one runtime-loaded MMD model instance.
public interface IMmdModelInstance
{
GameObject RootObject { get; }
MmdModelOptions Options { get; }
string ModelPath { get; }
string MotionPath { get; }
double MotionLength { get; }
double MotionPos { get; set; }
bool IsPlaying { get; set; }
bool IsLooping { get; set; }
bool EnableVmdIk { get; set; }
bool EnableLogging { get; set; }
int SubMeshCount { get; }
bool HasVisibleSubMesh { get; }
MmdUnityConfig MaterialSettings { get; }
IEnumerator LoadModel(string path);
IEnumerator LoadModelAndMotion(string modelPath, string motionPath);
IEnumerator LoadMotion(string path);
IEnumerator LoadMotion(MmdMotionAsset motionAsset);
void LoadPose(string path);
void LoadBonePose(string path);
void ResetMotion();
void ResetPhysics();
void SetRenderersVisible(bool visible);
void UpdateMaterialSettings(MmdUnityConfig config);
string[] GetSubMeshNames();
bool IsSubMeshVisible(int subMeshIndex);
void SetSubMeshVisible(int subMeshIndex, bool visible);
int SetSubMeshVisible(string materialName, bool visible);
SkinnedMeshRenderer[] GetRenderers(bool visibleOnly = false);
bool TryGetVisibleWorldBounds(out Bounds bounds);
}
/// Creates runtime MMD model instances without exposing their component setup.
public static class MmdModelInstance
{
public static IMmdModelInstance Create(
MmdModelOptions options = null, string name = "MMDGameObject")
{
var root = MmdGameObject.Create(options ?? new MmdModelOptions(), name);
return root.GetComponent();
}
}
}