Contents
- 1 概要
- 2 実行時のパラメータ変更
- 3 Properties
- 3.1 clothType
- 3.2 sourceRenderers
- 3.3 meshWriteMode
- 3.4 paintMode
- 3.5 paintMaps
- 3.6 rootBones
- 3.7 connectionMode
- 3.8 rotationalInterpolation
- 3.9 rootRotation
- 3.10 updateMode
- 3.11 animationPoseRatio
- 3.12 reductionSetting
- 3.13 customSkinningSetting
- 3.14 cullingSettings
- 3.15 normalAlignmentSetting
- 3.16 normalAxis
- 3.17 gravity
- 3.18 gravityDirection
- 3.19 gravityFalloff
- 3.20 stablizationTimeAfterReset
- 3.21 blendWeight
- 3.22 damping
- 3.23 radius
- 3.24 inertiaConstraint
- 3.25 tetherConstraint
- 3.26 distanceConstraint
- 3.27 triangleBendingConstraint
- 3.28 angleRestorationConstraint
- 3.29 angleLimitConstraint
- 3.30 motionConstraint
- 3.31 colliderCollisionConstraint
- 3.32 selfCollisionConstraint
- 3.33 Wind
- 3.34 Spring
- 4 Methods
概要
ClothSerializeDataクラスはすべてのパラメータを内包しています。
スクリプトから布コンポーネントを構築する場合には、このクラスのメンバを操作します。
また、実行時にこのクラスを操作してパラメータを変更することも可能です。
ただし一部のパラメータは実行時には変更できません。
また、このクラスのメンバはJsonとしてエクスポートとインポートが可能です。
これらは通常プリセットの機能として利用されます。
実行時に変更が可能かどうか、またプリセットとしてエクスポート可能かどうかは次のようにコメントとして記載されています。
/// [OK] Runtime changes.
/// [NG] Export/Import with Presets
実行時のパラメータ変更
実行時のパラメータ変更はまずClothSerializeDataクラスの該当するメンバを操作します。
次にその変更をシステムに通知するために SetParameterChange() を呼び出します。
この操作はすべてのパラメータで共通です。
次の例は100フレームごとにコライダーを追加/削除します。
using MagicaCloth2;
using UnityEngine;
public class RuntimeColliderTest : MonoBehaviour
{
public MagicaCloth cloth;
public ColliderComponent col;
bool sw = false;
void Start()
{
}
void Update()
{
if (cloth == null || col == null)
return;
// Check if MagicaCloth is running
if (cloth.IsValid() == false)
return;
if (Time.frameCount % 100 == 0)
{
sw = !sw;
UpdateCollider();
}
}
/// <summary>
/// Add or Remove colliders
/// </summary>
void UpdateCollider()
{
// It manages all parameters that cloth.SerializeData can change at runtime.
if (sw)
{
// add collider.
cloth.SerializeData.colliderCollisionConstraint.colliderList.Add(col);
}
else
{
// remove collider
cloth.SerializeData.colliderCollisionConstraint.colliderList.Remove(col);
}
// change notification
cloth.SetParameterChange();
}
}
Properties
clothType
/// <summary>
/// simulation type.
/// [NG] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public ClothProcess.ClothType clothType = ClothProcess.ClothType.MeshCloth;
/// <summary>
/// Cloth Type
/// </summary>
public enum ClothType
{
MeshCloth = 0,
BoneCloth = 1,
BoneSpring = 10,
}
sourceRenderers
/// <summary>
/// Renderer list used in MeshCloth.
/// [NG] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public List<Renderer> sourceRenderers = new List<Renderer>();
meshWriteMode
/// <summary>
/// メッシュへの書き込み対象
/// Write target to mesh.
/// </summary>
public enum ClothMeshWriteMode
{
/// <summary>
/// 位置と法線
/// Position, Normal
/// </summary>
PositionAndNormal = 0,
/// <summary>
/// 位置と法線と接線
/// Position, Normal, Tangent
/// </summary>
PositionAndNormalTangent = 1,
}
/// <summary>
/// Write target to mesh in MeshCloth.
/// [OK] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public ClothMeshWriteMode meshWriteMode = ClothMeshWriteMode.PositionAndNormal;
paintMode
/// <summary>
/// vertex paint mode.
/// [NG] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public PaintMode paintMode = PaintMode.Manual;
public enum PaintMode
{
Manual = 0,
[InspectorName("Texture Fixed(RD) Move(GR) Ignore(BK)")]
Texture_Fixed_Move = 1,
[InspectorName("Texture Fixed(RD) Move(GR) Limit(BL) Ignore(BK)")]
Texture_Fixed_Move_Limit = 2,
}
paintMaps
/// <summary>
/// texture for painting.
/// Sync to sourceRenderers.
/// [NG] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public List<Texture2D> paintMaps = new List<Texture2D>();
rootBones
/// <summary>
/// Root bone list used in BoneCloth.
/// [NG] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public List<Transform> rootBones = new List<Transform>();
connectionMode
/// <summary>
/// BoneCloth connection method.
/// [NG] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public RenderSetupData.BoneConnectionMode connectionMode = RenderSetupData.BoneConnectionMode.Line;
public enum BoneConnectionMode
{
// line only.
// ラインのみ
Line = 0,
//Automatically mesh connection according to the interval of Transform.
// Transformの間隔に従い自動でメッシュ接続
AutomaticMesh = 1,
//Generate meshes in the order of Transforms registered in RootList and connect the beginning and end in a loop.
// RootListに登録されたTransformの順にメッシュを生成し、最初と最後をループ状に繋げる
SequentialLoopMesh = 2,
// Generate meshes in the order of Transforms registered in RootList, but do not connect the beginning and end.
// RootListに登録されたTransformの順にメッシュを生成するが最初と最後を繋げない
SequentialNonLoopMesh = 3,
}
rotationalInterpolation
/// <summary>
/// Transform rotation interpolation rate in BoneCloth.(0.0 ~ 1.0)
/// (0.0=parent-based, 0.5=middle, 1.0=child-based)
/// [OK] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float rotationalInterpolation = 0.5f;
rootRotation
/// <summary>
/// Rotation interpolation rate of Root Transform in BoneCloth.(0.0 ~ 1.0)
/// (0.0=does not rotate, 0.5=middle, 1.0=child-based)
/// [OK] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float rootRotation = 0.5f;
updateMode
/// <summary>
/// Set the update timing.
/// [OK] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public ClothUpdateMode updateMode = ClothUpdateMode.AnimatorLinkage;
/// <summary>
/// Simulation Update Mode
/// </summary>
public enum ClothUpdateMode
{
/// <summary>
/// This mode assumes that normal Update() will perform the move and animation.
/// </summary>
Normal = 0,
/// <summary>
/// This mode assumes that FixedUpdate() is used to perform movement and animation.
/// </summary>
UnityPhysics = 1,
/// <summary>
/// Updates are independent of Unity's Time.timeScale.
/// </summary>
Unscaled = 2,
/// <summary>
/// Automatically set from linked animator.
/// 連動アニメーターから自動設定する
/// - Animator.UpdateMode.Normal -> Normal
/// - Animator.UpdateMode.AnimatePhysics -> UnityPhysics
/// - Animator.UpdateMode.UnscaledTime -> Unscaled
/// </summary>
AnimatorLinkage = 10,
}
animationPoseRatio
/// <summary>
/// Blend ratio between initial pose and animation pose.
/// [OK] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float animationPoseRatio = 0.0f;
reductionSetting
/// <summary>
/// vertex reduction parameters.
/// </summary>
public ReductionSettings reductionSetting = new ReductionSettings();
/// <summary>
/// Configuration data for reduction.
/// リダクション用の設定データ
/// </summary>
[System.Serializable]
public class ReductionSettings : IDataValidate
{
/// <summary>
/// Simple distance reduction (% of AABB maximum distance) (0.0 ~ 1.0).
/// 単純な距離による削減(AABB最大距離の%)(0.0 ~ 1.0)
/// [NG] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
[Range(0.0f, 0.1f)]
public float simpleDistance = 0.0f;
/// <summary>
/// Reduction by distance considering geometry (% of AABB maximum distance) (0.0 ~ 1.0).
/// 形状を考慮した距離による削減(AABB最大距離の%)(0.0 ~ 1.0)
/// [NG] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
[Range(0.0f, 0.1f)]
public float shapeDistance = 0.0f;
}
customSkinningSetting
/// <summary>
/// custom skinning parameters.
/// </summary>
public CustomSkinningSettings customSkinningSetting = new CustomSkinningSettings();
[System.Serializable]
public class CustomSkinningSettings : IValid, IDataValidate
{
/// <summary>
/// valid state.
/// 有効状態
/// [NG] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public bool enable = false;
/// <summary>
/// Bones for custom skinning.
/// カスタムスキニング用ボーン
/// [NG] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public List<Transform> skinningBones = new List<Transform>();
}
cullingSettings
/// <summary>
/// culling settings.
/// </summary>
public CullingSettings cullingSettings = new CullingSettings();
[System.Serializable]
public class CullingSettings : IDataValidate
{
/// <summary>
/// Camera culling mode.
/// カメラカリングモード
/// </summary>
public enum CameraCullingMode
{
/// <summary>
/// No culling.
/// カリングは行わない
/// </summary>
Off = 0,
/// <summary>
/// Simulation resets when hidden from camera.
/// カメラから非表示になるとシミュレーションはリセットされる
/// </summary>
Reset = 10,
/// <summary>
/// Simulation pauses when hidden from camera.
/// カメラから非表示になるとシミュレーションは一時停止する
/// </summary>
Keep = 20,
/// <summary>
/// Automatically set from linked animator.
/// 連動アニメーターから自動設定する
/// - Animator.CullingMode.AlwaysAnimate -> Off
/// - Animator.CullingMode.CullUpdateTransforms -> Reset
/// - Animator.CullingMode.CullCompletely -> Keep
/// </summary>
AnimatorLinkage = 30,
}
/// <summary>
/// Camera culling method.
/// カリング方式
/// </summary>
public enum CameraCullingMethod
{
/// <summary>
/// Work with an animator.
/// アニメーターと連動する
/// </summary>
AutomaticRenderer = 0,
/// <summary>
/// Determine from user-specified renderer.
/// ユーザー指定のレンダラーから判定する
/// </summary>
ManualRenderer = 10,
}
/// <summary>
/// Camera culling mode.
/// カメラカリングモード
/// [OK] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public CameraCullingMode cameraCullingMode = CameraCullingMode.AnimatorLinkage;
/// <summary>
/// Camera culling judgment method.
/// カメラカリング判定方式
/// [OK] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public CameraCullingMethod cameraCullingMethod = CameraCullingMethod.AutomaticRenderer;
/// <summary>
/// User-specified camera culling judgment renderer.
/// ユーザー指定のカメラカリング判定用レンダラー
/// [OK] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public List<Renderer> cameraCullingRenderers = new List<Renderer>();
/// <summary>
/// 距離カリングの状態と距離
/// Distance Culling State and Distance.
/// [OK] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public CheckSliderSerializeData distanceCullingLength;
/// <summary>
/// 距離カリングのフェード割合(0.0 ~ 1.0)
/// Distance culling fade rate (0.0 to 1.0).
/// [OK] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float distanceCullingFadeRatio;
/// <summary>
/// 距離カリングの測定対象(None=メインカメラ)
/// Distance culling measurement target (None = main camera).
/// [OK] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public GameObject distanceCullingReferenceObject;
}
normalAlignmentSetting
/// <summary>
/// Normal definition.
/// </summary>
public NormalAlignmentSettings normalAlignmentSetting = new NormalAlignmentSettings();
/// <summary>
/// Normal adjustment settings.
/// 法線調整設定
/// </summary>
[System.Serializable]
public class NormalAlignmentSettings : IValid, IDataValidate
{
public enum AlignmentMode
{
None = 0,
/// <summary>
/// Radiation from center of AABB.
/// 中心から放射
/// </summary>
BoundingBoxCenter = 1,
/// <summary>
/// Emit from the specified transform.
/// 指定トランスフォームから放射
/// </summary>
Transform = 2,
}
/// <summary>
/// adjustment mode.
/// [NG] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public AlignmentMode alignmentMode = AlignmentMode.None;
/// <summary>
/// Transform at which the radiation is centered.
/// [NG] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public Transform adjustmentTransform;
}
normalAxis
/// <summary>
/// axis to use as normal.
/// [OK] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public ClothNormalAxis normalAxis = ClothNormalAxis.Up;
gravity
/// <summary>
/// Gravity.
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 10.0f)]
public float gravity = 5.0f;
gravityDirection
/// <summary>
/// Gravity world direction.
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public float3 gravityDirection = new float3(0, -1, 0);
gravityFalloff
/// <summary>
/// 初期姿勢での重力の減衰率(0.0 ~ 1.0)
/// 1.0にすることで初期姿勢では重力係数が0になる。
/// 0.0では常にどの姿勢でも重力が100%発生する。
///
/// Attenuation rate of gravity at initial pose (0.0 ~ 1.0)
/// By setting it to 1.0, the gravity coefficient becomes 0 in the initial posture.
/// At 0.0, gravity is always 100% in any pose.
///
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float gravityFalloff = 0.0f;
stablizationTimeAfterReset
/// <summary>
/// リセット後の速度安定化時間(s)
/// 急激な速度変化を抑えます。
///
/// Speed stabilization time after reset (s).
/// Avoid sudden speed changes.
///
/// [OK] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float stablizationTimeAfterReset = 0.1f;
blendWeight
/// <summary>
/// 元の姿勢とシミュレーション結果のブレンド割合(0.0 ~ 1.0)
///
/// Blend ratio of original posture and simulation result (0.0 ~ 1.0).
///
/// [OK] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
[System.NonSerialized]
public float blendWeight = 1.0f;
damping
/// <summary>
/// air resistance.
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public CurveSerializeData damping = new CurveSerializeData(0.05f);
radius
/// <summary>
/// Particle radius.
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public CurveSerializeData radius = new CurveSerializeData(0.02f);
inertiaConstraint
/// <summary>
/// Inertia.
/// </summary>
public InertiaConstraint.SerializeData inertiaConstraint = new InertiaConstraint.SerializeData();
/// <summary>
/// テレポートモード
/// Teleport processing mode.
/// </summary>
public enum TeleportMode
{
None = 0,
/// <summary>
/// シミュレーションをリセットします
/// Reset the simulation.
/// </summary>
Reset = 1,
/// <summary>
/// テレポート前の状態を継続します
/// Continue the state before the teleport.
/// </summary>
Keep = 2,
}
[System.Serializable]
public class SerializeData : IDataValidate
{
/// <summary>
/// Anchor that cancels inertia.
/// Anchor translation and rotation are excluded from simulation.
/// This is useful if your character rides a vehicle.
/// 慣性を打ち消すアンカー
/// アンカーの移動と回転はシミュレーションから除外されます
/// これはキャラクターが乗り物に乗る場合に便利です
/// [OK] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public Transform anchor;
/// <summary>
/// Anchor Influence (0.0 ~ 1.0)
/// アンカーの影響(0.0 ~ 1.0)
/// [OK] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float anchorInertia;
/// <summary>
/// World Influence (0.0 ~ 1.0).
/// ワールド移動影響(0.0 ~ 1.0)
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[FormerlySerializedAs("movementInertia")]
[Range(0.0f, 1.0f)]
public float worldInertia;
/// <summary>
/// World Influence Smoothing (0.0 ~ 1.0).
/// ワールド移動影響平滑化(0.0 ~ 1.0)
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float movementInertiaSmoothing;
/// <summary>
/// World movement speed limit (m/s).
/// ワールド移動速度制限(m/s)
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public CheckSliderSerializeData movementSpeedLimit;
/// <summary>
/// World rotation speed limit (deg/s).
/// ワールド回転速度制限(deg/s)
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public CheckSliderSerializeData rotationSpeedLimit;
/// <summary>
/// Local Influence (0.0 ~ 1.0).
/// ローカル慣性影響(0.0 ~ 1.0)
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float localInertia;
/// <summary>
/// Local movement speed limit (m/s).
/// ローカル移動速度制限(m/s)
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public CheckSliderSerializeData localMovementSpeedLimit;
/// <summary>
/// Local rotation speed limit (deg/s).
/// ローカル回転速度制限(deg/s)
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public CheckSliderSerializeData localRotationSpeedLimit;
/// <summary>
/// depth inertia (0.0 ~ 1.0).
/// Increasing the effect weakens the inertia near the root (makes it difficult to move).
/// 深度慣性(0.0 ~ 1.0)
/// 影響を大きくするとルート付近の慣性が弱くなる(動きにくくなる)
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float depthInertia;
/// <summary>
/// Centrifugal acceleration (0.0 ~ 1.0).
/// 遠心力加速(0.0 ~ 1.0)
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float centrifualAcceleration;
/// <summary>
/// Particle Velocity Limit (m/s).
/// パーティクル速度制限(m/s)
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public CheckSliderSerializeData particleSpeedLimit;
/// <summary>
/// Teleport determination method.
/// テレポート判定モード
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public TeleportMode teleportMode;
/// <summary>
/// Teleport detection distance.
/// テレポート判定距離
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public float teleportDistance;
/// <summary>
/// Teleport detection angle(deg).
/// テレポート判定回転角度(deg)
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public float teleportRotation;
}
tetherConstraint
/// <summary>
/// Tether.
/// </summary>
public TetherConstraint.SerializeData tetherConstraint = new TetherConstraint.SerializeData();
[System.Serializable]
public class SerializeData : IDataValidate
{
/// <summary>
/// Maximum shrink limit (0.0 ~ 1.0).
/// 0.0=do not shrink.
/// 最大縮小限界(0.0 ~ 1.0)
/// 0.0=縮小しない
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float distanceCompression;
}
distanceConstraint
/// <summary>
/// Distance restoration.
/// </summary>
public DistanceConstraint.SerializeData distanceConstraint = new DistanceConstraint.SerializeData();
[System.Serializable]
public class SerializeData : IDataValidate
{
/// <summary>
/// Overall connection stiffness (0.0 ~ 1.0).
/// 全体的な接続の剛性(0.0 ~ 1.0)
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public CurveSerializeData stiffness;
}
triangleBendingConstraint
/// <summary>
/// Triangle bending / volume.
/// </summary>
public TriangleBendingConstraint.SerializeData triangleBendingConstraint = new TriangleBendingConstraint.SerializeData();
[System.Serializable]
public class SerializeData : IDataValidate
{
/// <summary>
/// Restoring force (0.0 ~ 1.0)
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float stiffness;
}
angleRestorationConstraint
/// <summary>
/// Angle restoration.
/// </summary>
public AngleConstraint.RestorationSerializeData angleRestorationConstraint = new AngleConstraint.RestorationSerializeData();
/// <summary>
/// angle restoration.
/// 角度復元
/// </summary>
[System.Serializable]
public class RestorationSerializeData : IDataValidate
{
/// <summary>
/// Presence or absence of use.
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public bool useAngleRestoration;
/// <summary>
/// resilience.
/// 復元力
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public CurveSerializeData stiffness;
/// <summary>
/// Velocity decay during restoration.
/// 復元時の速度減衰
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float velocityAttenuation;
/// <summary>
/// Directional Attenuation of Gravity.
/// Note that this attenuation occurs even if the gravity is 0!
/// 復元の重力方向減衰
/// この減衰は重力が0でも発生するので注意!
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float gravityFalloff;
}
angleLimitConstraint
/// <summary>
/// Angle Limit.
/// </summary>
public AngleConstraint.LimitSerializeData angleLimitConstraint = new AngleConstraint.LimitSerializeData();
/// <summary>
/// angle limit.
/// 角度制限
/// </summary>
[System.Serializable]
public class LimitSerializeData : IDataValidate
{
/// <summary>
/// Presence or absence of use.
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public bool useAngleLimit;
/// <summary>
/// Limit angle (deg).
/// 制限角度(deg)
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public CurveSerializeData limitAngle;
/// <summary>
/// Standard stiffness.
/// 基準剛性
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float stiffness;
}
motionConstraint
/// <summary>
/// Max distance / Backstop
/// </summary>
public MotionConstraint.SerializeData motionConstraint = new MotionConstraint.SerializeData();
[System.Serializable]
public class SerializeData : IDataValidate
{
/// <summary>
/// Whether or not to use maximum travel range
/// 最大移動範囲
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public bool useMaxDistance;
/// <summary>
/// Maximum travel range.
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public CurveSerializeData maxDistance;
/// <summary>
/// Use of backstop.
/// バックストップ使用の有無
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public bool useBackstop;
/// <summary>
/// Backstop sphere radius.
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.1f, 10.0f)]
public float backstopRadius;
/// <summary>
/// Distance from vertex to backstop sphere.
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public CurveSerializeData backstopDistance;
/// <summary>
/// repulsive force(0.0 ~ 1.0)
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float stiffness;
}
colliderCollisionConstraint
/// <summary>
/// Collider collision.
/// </summary>
public ColliderCollisionConstraint.SerializeData colliderCollisionConstraint = new ColliderCollisionConstraint.SerializeData();
/// <summary>
/// Collision judgment mode.
/// 衝突判定モード
/// </summary>
public enum Mode
{
None = 0,
Point = 1,
Edge = 2,
}
[System.Serializable]
public class SerializeData : IDataValidate, ITransform
{
/// <summary>
/// Collision judgment mode.
/// 衝突判定モード
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public Mode mode;
/// <summary>
/// Friction (0.0 ~ 1.0).
/// Dynamic friction/stationary friction combined use.
/// 摩擦(0.0 ~ 1.0)
/// 動摩擦/静止摩擦兼用
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 0.5f)]
public float friction;
/// <summary>
/// Collider list.
/// コライダーリスト
/// [OK] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public List<ColliderComponent> colliderList = new List<ColliderComponent>();
/// <summary>
/// List of Transforms that perform collision detection with BoneSpring.
/// BoneSpringで衝突判定を行うTransformのリスト
/// [OK] Runtime changes.
/// [NG] Export/Import with Presets
/// </summary>
public List<Transform> collisionBones = new List<Transform>();
/// <summary>
/// The maximum distance from the origin that a vertex will be pushed by the collider. Currently used only with BoneSpring.
/// コライダーにより頂点が押し出される原点からの最大距離。現在はBoneSpringのみで利用。
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public CurveSerializeData limitDistance = new CurveSerializeData(0.05f);
}
selfCollisionConstraint
/// <summary>
/// Self collision
/// </summary>
public SelfCollisionConstraint.SerializeData selfCollisionConstraint = new SelfCollisionConstraint.SerializeData();
public enum SelfCollisionMode
{
None = 0,
/// <summary>
/// PointPoint
/// </summary>
//Point = 1, // omit!
/// <summary>
/// PointTriangle + EdgeEdge + Intersect
/// </summary>
FullMesh = 2,
}
[System.Serializable]
public class SerializeData : IDataValidate
{
/// <summary>
/// self-collision mode
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public SelfCollisionMode selfMode;
/// <summary>
/// primitive thickness.
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public CurveSerializeData surfaceThickness = new CurveSerializeData(0.005f, 0.5f, 1.0f, false);
/// <summary>
/// mutual collision mode.
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public SelfCollisionMode syncMode;
/// <summary>
/// Mutual Collision Opponent.
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public MagicaCloth syncPartner;
/// <summary>
/// cloth weight.
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float clothMass = 0.0f;
}
Wind
/// <summary>
/// Wind
/// </summary>
public WindSettings wind = new WindSettings();
/// <summary>
/// 風調整用シリアライズデータ
/// Serialized data for wind adjustment.
/// </summary>
[System.Serializable]
public class WindSettings : IValid, IDataValidate
{
/// <summary>
/// 全体の影響率(1.0=100%)
/// Overall impact rate (1.0=100%).
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 2.0f)]
public float influence = 1.0f;
/// <summary>
/// 揺れの周期(値を大きくすると周期が速くなる)
/// Period of shaking (the higher the value, the faster the period).
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 2.0f)]
public float frequency = 1.0f;
/// <summary>
/// 乱流率
/// turbulence rate.
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 2.0f)]
public float turbulence = 1.0f;
/// <summary>
/// Sin波とNoise波のブレンド率(0.0:sin ~ 1.0:noise)
/// Blend ratio of sine wave and noise wave (0.0:sin ~ 1.0:noise).
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float blend = 0.7f;
/// <summary>
/// ベースラインごとの同期率
/// Synchronization rate by baseline.
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float synchronization = 0.7f;
/// <summary>
/// 深さ影響率
/// Depth influence factor.
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float depthWeight = 0.0f;
/// <summary>
/// 移動時の風速
/// Wind speed when moving.
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 10.0f)]
public float movingWind = 0.0f;
Spring
/// <summary>
/// Spring
/// </summary>
public SpringConstraint.SerializeData springConstraint = new SpringConstraint.SerializeData();
[System.Serializable]
public class SerializeData : IDataValidate
{
/// <summary>
/// Use of springs
/// スプリングの利用
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
public bool useSpring;
/// <summary>
/// spring strength.(0.0 ~ 1.0)
/// スプリングの強さ(0.0 ~ 1.0)
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.001f, 0.2f)]
public float springPower;
/// <summary>
/// Distance that can be moved from the origin.
/// 原点から移動可能な距離
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 0.5f)]
public float limitDistance;
/// <summary>
/// Movement restriction in normal direction.(0.0 ~ 1.0)
/// 法線方向に対しての移動制限(0.0 ~ 1.0)
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float normalLimitRatio;
/// <summary>
/// De-synchronize each spring.(0.0 ~ 1.0)
/// 各スプリングの非同期化(0.0 ~ 1.0)
/// [OK] Runtime changes.
/// [OK] Export/Import with Presets
/// </summary>
[Range(0.0f, 1.0f)]
public float springNoise;
}
Methods
IsValid
/// <summary>
/// クロスを構築するための最低限の情報が揃っているかチェックする
/// Check if you have the minimum information to construct the cloth.
/// </summary>
/// <returns></returns>
public bool IsValid()
ExportJson
/// <summary>
/// パラメータをJsonへエクスポートする
/// Export parameters to Json.
/// </summary>
/// <returns></returns>
public string ExportJson()
ImportJson
/// <summary>
/// パラメータをJsonからインポートする
/// Parameterブロックの値型のみがインポートされる
/// Import parameters from Json.
/// Only value types of Parameter blocks are imported.
/// </summary>
/// <param name="json"></param>
/// <returns></returns>
public bool ImportJson(string json)
Import
/// <summary>
/// 別のシリアライズデータからインポートする
/// Import from another serialized data.
/// </summary>
/// <param name="sdata"></param>
/// <param name="deepCopy">true = Copy all, false = parameter only</param>
public void Import(ClothSerializeData sdata, bool deepCopy = false)