You've already forked UniversalViewer
Initial files
This commit is contained in:
68
Assets/Scripts/ModelViewerBase/Pose/PoseLoadOptions.cs
Normal file
68
Assets/Scripts/ModelViewerBase/Pose/PoseLoadOptions.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class PoseLoadOptions
|
||||
{
|
||||
//general
|
||||
public bool
|
||||
Root,
|
||||
Morphs;
|
||||
|
||||
//body parts
|
||||
public bool
|
||||
Body,
|
||||
Ears,
|
||||
//EarsAlt,
|
||||
Tail,
|
||||
//TailAlt,
|
||||
Other;
|
||||
|
||||
//all
|
||||
public bool
|
||||
Position,
|
||||
Rotation,
|
||||
Scale;
|
||||
|
||||
public PoseLoadOptions(bool value)
|
||||
{
|
||||
Root = value;
|
||||
Morphs = value;
|
||||
Body = value;
|
||||
Ears = value;
|
||||
//EarsAlt = value;
|
||||
Tail = value;
|
||||
//TailAlt = value;
|
||||
Other = value;
|
||||
Position = value;
|
||||
Rotation = value;
|
||||
Scale = value;
|
||||
}
|
||||
|
||||
public static PoseLoadOptions None()
|
||||
{
|
||||
return new PoseLoadOptions(false);
|
||||
}
|
||||
|
||||
public static PoseLoadOptions All()
|
||||
{
|
||||
return new PoseLoadOptions(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static class PoseLoadOptionsExtra
|
||||
{
|
||||
public static void ApplyTo(this SerializableTransform tsf, Transform t, PoseLoadOptions options)
|
||||
{
|
||||
if (tsf.Space == Space.World)
|
||||
{
|
||||
if (options.Position) t.position = tsf.Position;
|
||||
if (options.Rotation) t.eulerAngles = tsf.Rotation;
|
||||
if (options.Scale) t.localScale = tsf.Scale;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (options.Position) t.localPosition = tsf.Position;
|
||||
if (options.Rotation) t.localEulerAngles = tsf.Rotation;
|
||||
if (options.Scale) t.localScale = tsf.Scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ModelViewerBase/Pose/PoseLoadOptions.cs.meta
Normal file
11
Assets/Scripts/ModelViewerBase/Pose/PoseLoadOptions.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f825489d1d491e478e07e6e6334ca16
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
public class SerializablePoseParams
|
||||
{
|
||||
public bool Body,
|
||||
Root,
|
||||
Ears,
|
||||
EarsAlt,
|
||||
Tail,
|
||||
TailAlt,
|
||||
PhysicsBones,
|
||||
Morphs;
|
||||
|
||||
public SerializablePoseParams() { }
|
||||
|
||||
public SerializablePoseParams(bool value)
|
||||
{
|
||||
Body = Root = Ears = EarsAlt = Tail = TailAlt = PhysicsBones = Morphs = true;
|
||||
}
|
||||
|
||||
public SerializablePoseParams SetRoot(bool value)
|
||||
{
|
||||
Root = value;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: adae87bbf883dae4baa06f2c4303f5cc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/ModelViewerBase/Pose/Timeline.meta
Normal file
8
Assets/Scripts/ModelViewerBase/Pose/Timeline.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a69fe7c010475646b6b04eb27a854b1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,6 @@
|
||||
public interface IKeyframeSetter
|
||||
{
|
||||
public void SetKeyframe(int frameNum);
|
||||
public void EnableKeyframeSet();
|
||||
public void DisableKeyframeSet();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8fa2a5bc09d8ef04c8e7844a4c11ade4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
26
Assets/Scripts/ModelViewerBase/Pose/Timeline/KeyframeData.cs
Normal file
26
Assets/Scripts/ModelViewerBase/Pose/Timeline/KeyframeData.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
[System.Serializable]
|
||||
public class KeyframeData
|
||||
{
|
||||
public SerializableTransform Root;
|
||||
|
||||
public KeyframeData() { }
|
||||
|
||||
public KeyframeData(ObjectContainer container)
|
||||
{
|
||||
this.Root = new SerializableTransform(container.transform);
|
||||
}
|
||||
|
||||
public virtual KeyframeData Clone()
|
||||
{
|
||||
var keyframe = new KeyframeData();
|
||||
keyframe.Root = new SerializableTransform(this.Root);
|
||||
return keyframe;
|
||||
}
|
||||
|
||||
public virtual KeyframeData Lerp(KeyframeData target, float amount)
|
||||
{
|
||||
var copy = this.Clone();
|
||||
copy.Root = copy.Root.LerpWith(target.Root, amount);
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78f95c9a0a831be438b081224ae745eb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,72 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public class KeyframeDataCamera : KeyframeData
|
||||
{
|
||||
public SerializableTransform CamTransform;
|
||||
|
||||
public int CameraMode;
|
||||
public bool CameraLock;
|
||||
public float Fov = 45;
|
||||
public float CamDist = 5;
|
||||
public float CamHeight = 1;
|
||||
public float TargetHeigh = 1;
|
||||
public float CamAngle = 0;
|
||||
public float MovSpeed = 5;
|
||||
public float RotSpeed = 1;
|
||||
public float ZoomSpeed = 0.2f;
|
||||
|
||||
public KeyframeDataCamera() { }
|
||||
|
||||
public KeyframeDataCamera(CameraContainer camera)
|
||||
{
|
||||
Root = new SerializableTransform(camera.Camera.transform);
|
||||
CamTransform = new SerializableTransform(camera.Camera.Cam.transform);
|
||||
|
||||
var settings = camera.Settings;
|
||||
CameraMode = settings.CameraMode;
|
||||
CameraLock = settings.CameraLock;
|
||||
Fov = settings.Fov;
|
||||
CamDist = settings.CamDist;
|
||||
CamHeight = settings.CamHeight;
|
||||
TargetHeigh = settings.TargetHeight;
|
||||
CamAngle = settings.CamAngle;
|
||||
MovSpeed = settings.MovSpeed;
|
||||
RotSpeed = settings.RotSpeed;
|
||||
ZoomSpeed = settings.ZoomSpeed;
|
||||
}
|
||||
|
||||
public override KeyframeData Clone()
|
||||
{
|
||||
var keyframe = new KeyframeDataCamera();
|
||||
keyframe.Root = new SerializableTransform(this.Root);
|
||||
keyframe.CamTransform = new SerializableTransform(this.CamTransform);
|
||||
keyframe.CameraMode = this.CameraMode;
|
||||
keyframe.CameraLock = this.CameraLock;
|
||||
keyframe.Fov = this.Fov;
|
||||
keyframe.CamDist = this.CamDist;
|
||||
keyframe.CamHeight = this.CamHeight;
|
||||
keyframe.TargetHeigh = this.TargetHeigh;
|
||||
keyframe.CamAngle = this.CamAngle;
|
||||
keyframe.MovSpeed = this.MovSpeed;
|
||||
keyframe.RotSpeed = this.RotSpeed;
|
||||
keyframe.ZoomSpeed = this.ZoomSpeed;
|
||||
return keyframe;
|
||||
}
|
||||
|
||||
public override KeyframeData Lerp(KeyframeData target1, float amount)
|
||||
{
|
||||
var target = target1 as KeyframeDataCamera;
|
||||
var copy = this.Clone() as KeyframeDataCamera;
|
||||
copy.Root = copy.Root.LerpWith(target.Root, amount);
|
||||
copy.CamTransform = copy.CamTransform.LerpWith(target.CamTransform, amount);
|
||||
copy.Fov = Mathf.Lerp(copy.Fov, target.Fov, amount);
|
||||
copy.CamDist = Mathf.Lerp(copy.CamDist, target.CamDist, amount);
|
||||
copy.CamHeight = Mathf.Lerp(copy.CamHeight, target.CamHeight, amount);
|
||||
copy.TargetHeigh = Mathf.Lerp(copy.TargetHeigh, target.TargetHeigh, amount);
|
||||
copy.CamAngle = Mathf.Lerp(copy.CamAngle, target.CamAngle, amount);
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6436dcc628970074cb9f996d0953e8fe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
|
||||
public class KeyframeToggleContext : IDisposable
|
||||
{
|
||||
private IKeyframeSetter _keyframmable;
|
||||
private bool _enableKeyframes;
|
||||
|
||||
public KeyframeToggleContext(IKeyframeSetter keyframmable, bool enableKeyframes = false)
|
||||
{
|
||||
_keyframmable = keyframmable;
|
||||
_enableKeyframes = enableKeyframes;
|
||||
Toggle(true);
|
||||
}
|
||||
|
||||
public void ForceSetKeyframe(int frameNum = -1)
|
||||
{
|
||||
Toggle(false);
|
||||
_keyframmable.SetKeyframe(frameNum);
|
||||
Toggle(true);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Toggle(false);
|
||||
}
|
||||
|
||||
private void Toggle(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
if (_enableKeyframes) _keyframmable.EnableKeyframeSet();
|
||||
else _keyframmable.DisableKeyframeSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_enableKeyframes) _keyframmable.DisableKeyframeSet();
|
||||
else _keyframmable.EnableKeyframeSet();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 943743df82cb7ce41a28df2e9cda34dd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user