diff options
author | chai <chaifix@163.com> | 2020-10-14 10:15:19 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2020-10-14 10:15:19 +0800 |
commit | 4056f06baea18d3c5ae23c4a022fc6ae6b135bb2 (patch) | |
tree | ec33414096256b2df270ef43452ee21be55179df | |
parent | 104ca96a6581bddf48b769abdcb84842459260c3 (diff) |
+dynamic bone
21 files changed, 2830 insertions, 0 deletions
diff --git a/Assets/ThirdParty/DynamicBone.meta b/Assets/ThirdParty/DynamicBone.meta new file mode 100644 index 00000000..8faf0435 --- /dev/null +++ b/Assets/ThirdParty/DynamicBone.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: e6ba56ede2604dd4082ed2d0b4f435dd +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/ThirdParty/DynamicBone/Demo.meta b/Assets/ThirdParty/DynamicBone/Demo.meta new file mode 100644 index 00000000..e10847fe --- /dev/null +++ b/Assets/ThirdParty/DynamicBone/Demo.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 21a42390d25252341a66bc19a8addaea +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/ThirdParty/DynamicBone/Demo/Demo1.unity b/Assets/ThirdParty/DynamicBone/Demo/Demo1.unity new file mode 100644 index 00000000..c583337f --- /dev/null +++ b/Assets/ThirdParty/DynamicBone/Demo/Demo1.unity @@ -0,0 +1,983 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} + m_AmbientEquatorColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} + m_AmbientGroundColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &4 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 10 + m_Resolution: 1 + m_BakeResolution: 50 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 0 + m_CompAOExponentDirect: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 0 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 + m_MixedBakeMode: 1 + m_BakeBackend: 0 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVRFilteringMode: 0 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ShowResolutionOverlay: 1 + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 0 +--- !u!196 &5 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666666 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!4 &90977926 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 400020, guid: 19015a5957bbaa745a61cba005220542, + type: 3} + m_PrefabInstance: {fileID: 1497342384} + m_PrefabAsset: {fileID: 0} +--- !u!1 &94102368 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 100072, guid: ba128457d0ea5e3439dbe4a53b9d1273, + type: 3} + m_PrefabInstance: {fileID: 560668931} + m_PrefabAsset: {fileID: 0} +--- !u!114 &94102370 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 94102368} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: baedd976e12657241bf7ff2d1c685342, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Direction: 1 + m_Center: {x: 0, y: -0.2, z: 0} + m_Bound: 0 + m_Radius: 0.1 + m_Height: 0.6 +--- !u!1 &143600401 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 100000, guid: 8a4fd2ea0aec44e449f6dc1271079085, + type: 3} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 143600402} + - component: {fileID: 143600404} + - component: {fileID: 143600405} + - component: {fileID: 143600406} + m_Layer: 0 + m_Name: Player + m_TagString: Player + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &143600402 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 400000, guid: 8a4fd2ea0aec44e449f6dc1271079085, + type: 3} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 143600401} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1237224165} + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &143600404 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 143600401} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f9ac8d30c6a0d9642a11e5be4c440740, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Root: {fileID: 1240282084} + m_UpdateRate: 60 + m_UpdateMode: 3 + m_Damping: 0.2 + m_DampingDistrib: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_Elasticity: 0.1 + m_ElasticityDistrib: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_Stiffness: 0.8 + m_StiffnessDistrib: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_Inert: 0.5 + m_InertDistrib: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_Friction: 0 + m_FrictionDistrib: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_Radius: 0 + m_RadiusDistrib: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_EndLength: 0 + m_EndOffset: {x: -0.1, y: -0.1, z: 0.3} + m_Gravity: {x: 0, y: 0, z: 0} + m_Force: {x: 0, y: 0, z: 0} + m_Colliders: [] + m_Exclusions: [] + m_FreezeAxis: 0 + m_DistantDisable: 0 + m_ReferenceObject: {fileID: 0} + m_DistanceToObject: 20 +--- !u!114 &143600405 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 143600401} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f9ac8d30c6a0d9642a11e5be4c440740, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Root: {fileID: 1610302986} + m_UpdateRate: 60 + m_UpdateMode: 3 + m_Damping: 0.2 + m_DampingDistrib: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_Elasticity: 0.1 + m_ElasticityDistrib: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_Stiffness: 0.8 + m_StiffnessDistrib: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_Inert: 0.5 + m_InertDistrib: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_Friction: 0 + m_FrictionDistrib: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_Radius: 0 + m_RadiusDistrib: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0.28642094 + value: 0.8996325 + inSlope: -0.9737102 + outSlope: -0.11496421 + tangentMode: 1 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_EndLength: 0 + m_EndOffset: {x: 0.1, y: -0.1, z: 0.3} + m_Gravity: {x: 0, y: 0, z: 0} + m_Force: {x: 0, y: 0, z: 0} + m_Colliders: [] + m_Exclusions: [] + m_FreezeAxis: 0 + m_DistantDisable: 0 + m_ReferenceObject: {fileID: 0} + m_DistanceToObject: 20 +--- !u!114 &143600406 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 143600401} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f9ac8d30c6a0d9642a11e5be4c440740, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Root: {fileID: 90977926} + m_UpdateRate: 60 + m_UpdateMode: 3 + m_Damping: 0.2 + m_DampingDistrib: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_Elasticity: 0.05 + m_ElasticityDistrib: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_Stiffness: 0.7 + m_StiffnessDistrib: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_Inert: 0.5 + m_InertDistrib: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_Friction: 0 + m_FrictionDistrib: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_Radius: 0.15 + m_RadiusDistrib: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0.004166667 + value: 1.0124999 + inSlope: -0.762605 + outSlope: -0.762605 + tangentMode: 34 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 0.99583334 + value: 0.25624996 + inSlope: -0.762605 + outSlope: -0.762605 + tangentMode: 34 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_EndLength: 0 + m_EndOffset: {x: 0, y: 0, z: 0} + m_Gravity: {x: 0, y: -0.002, z: 0} + m_Force: {x: 0, y: 0, z: 0} + m_Colliders: + - {fileID: 94102370} + - {fileID: 838898607} + m_Exclusions: [] + m_FreezeAxis: 0 + m_DistantDisable: 0 + m_ReferenceObject: {fileID: 0} + m_DistanceToObject: 20 +--- !u!1 &249192883 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 249192888} + - component: {fileID: 249192887} + - component: {fileID: 249192886} + - component: {fileID: 249192885} + - component: {fileID: 249192884} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &249192884 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 249192883} + m_Enabled: 1 +--- !u!124 &249192885 +Behaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 249192883} + m_Enabled: 1 +--- !u!92 &249192886 +Behaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 249192883} + m_Enabled: 1 +--- !u!20 &249192887 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 249192883} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0.019607844} + m_projectionMatrixMode: 1 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_GateFitMode: 2 + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 0 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &249192888 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 249192883} + m_LocalRotation: {x: 0, y: 0.94676715, z: 0, w: 0.32191932} + m_LocalPosition: {x: -1.0038998, y: 1, z: 2.1806068} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &560668931 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 143600402} + m_Modifications: + - target: {fileID: 400004, guid: ba128457d0ea5e3439dbe4a53b9d1273, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400004, guid: ba128457d0ea5e3439dbe4a53b9d1273, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400004, guid: ba128457d0ea5e3439dbe4a53b9d1273, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400004, guid: ba128457d0ea5e3439dbe4a53b9d1273, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400004, guid: ba128457d0ea5e3439dbe4a53b9d1273, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400004, guid: ba128457d0ea5e3439dbe4a53b9d1273, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400004, guid: ba128457d0ea5e3439dbe4a53b9d1273, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 11100000, guid: ba128457d0ea5e3439dbe4a53b9d1273, type: 3} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: ba128457d0ea5e3439dbe4a53b9d1273, type: 3} +--- !u!1 &838898605 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 100140, guid: ba128457d0ea5e3439dbe4a53b9d1273, + type: 3} + m_PrefabInstance: {fileID: 560668931} + m_PrefabAsset: {fileID: 0} +--- !u!114 &838898607 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 838898605} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: baedd976e12657241bf7ff2d1c685342, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Direction: 1 + m_Center: {x: 0, y: -0.2, z: 0} + m_Bound: 0 + m_Radius: 0.1 + m_Height: 0.6 +--- !u!4 &1237224165 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 400004, guid: ba128457d0ea5e3439dbe4a53b9d1273, + type: 3} + m_PrefabInstance: {fileID: 560668931} + m_PrefabAsset: {fileID: 0} +--- !u!4 &1240282084 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 400046, guid: ba128457d0ea5e3439dbe4a53b9d1273, + type: 3} + m_PrefabInstance: {fileID: 560668931} + m_PrefabAsset: {fileID: 0} +--- !u!1 &1273446005 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1273446007} + - component: {fileID: 1273446006} + m_Layer: 0 + m_Name: Directional light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &1273446006 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1273446005} + m_Enabled: 1 + serializedVersion: 8 + m_Type: 1 + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_Intensity: 0.6 + m_Range: 10 + m_SpotAngle: 30 + m_CookieSize: 10 + m_Shadows: + m_Type: 0 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_Lightmapping: 1 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &1273446007 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1273446005} + m_LocalRotation: {x: -0.1614625, y: -0.9591772, z: 0.16742207, w: -0.16086924} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &1497342384 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 2086915445} + m_Modifications: + - target: {fileID: 400000, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.x + value: 2.33569484e-08 + objectReference: {fileID: 0} + - target: {fileID: 400000, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.y + value: -2.33569484e-08 + objectReference: {fileID: 0} + - target: {fileID: 400000, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.z + value: -.707106829 + objectReference: {fileID: 0} + - target: {fileID: 400000, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.w + value: .707106829 + objectReference: {fileID: 0} + - target: {fileID: 400000, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.x + value: .000276203005 + objectReference: {fileID: 0} + - target: {fileID: 400000, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.y + value: -.00660187891 + objectReference: {fileID: 0} + - target: {fileID: 400000, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.z + value: -2.88577301e-10 + objectReference: {fileID: 0} + - target: {fileID: 400002, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.x + value: -3.65551231e-14 + objectReference: {fileID: 0} + - target: {fileID: 400002, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.y + value: 4.19035161e-15 + objectReference: {fileID: 0} + - target: {fileID: 400002, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.z + value: .104671292 + objectReference: {fileID: 0} + - target: {fileID: 400002, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.w + value: .994506896 + objectReference: {fileID: 0} + - target: {fileID: 400002, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.x + value: -.237109601 + objectReference: {fileID: 0} + - target: {fileID: 400002, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.y + value: -3.86498868e-08 + objectReference: {fileID: 0} + - target: {fileID: 400002, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.z + value: 1.03641966e-08 + objectReference: {fileID: 0} + - target: {fileID: 400004, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.x + value: -3.34032593e-14 + objectReference: {fileID: 0} + - target: {fileID: 400004, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.y + value: 1.07828522e-14 + objectReference: {fileID: 0} + - target: {fileID: 400004, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.z + value: .0872370228 + objectReference: {fileID: 0} + - target: {fileID: 400004, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.w + value: .996187627 + objectReference: {fileID: 0} + - target: {fileID: 400004, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.x + value: -.273902506 + objectReference: {fileID: 0} + - target: {fileID: 400004, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.y + value: -4.7683713e-08 + objectReference: {fileID: 0} + - target: {fileID: 400004, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.z + value: 1.19724319e-08 + objectReference: {fileID: 0} + - target: {fileID: 400006, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.x + value: -2.77442271e-14 + objectReference: {fileID: 0} + - target: {fileID: 400006, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.y + value: 1.74333594e-14 + objectReference: {fileID: 0} + - target: {fileID: 400006, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.z + value: .142351687 + objectReference: {fileID: 0} + - target: {fileID: 400006, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.w + value: .989816129 + objectReference: {fileID: 0} + - target: {fileID: 400006, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.x + value: -.233021542 + objectReference: {fileID: 0} + - target: {fileID: 400006, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.y + value: -3.81469718e-08 + objectReference: {fileID: 0} + - target: {fileID: 400006, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.z + value: 1.01855058e-08 + objectReference: {fileID: 0} + - target: {fileID: 400008, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.x + value: -2.33242567e-14 + objectReference: {fileID: 0} + - target: {fileID: 400008, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.y + value: 2.38246363e-14 + objectReference: {fileID: 0} + - target: {fileID: 400008, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.z + value: .0788995922 + objectReference: {fileID: 0} + - target: {fileID: 400008, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.w + value: .996882558 + objectReference: {fileID: 0} + - target: {fileID: 400008, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.x + value: -.163523868 + objectReference: {fileID: 0} + - target: {fileID: 400008, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400008, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.z + value: 7.1477233e-09 + objectReference: {fileID: 0} + - target: {fileID: 400010, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.x + value: -1.85772452e-14 + objectReference: {fileID: 0} + - target: {fileID: 400010, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.y + value: 2.47326353e-14 + objectReference: {fileID: 0} + - target: {fileID: 400010, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.z + value: .067116484 + objectReference: {fileID: 0} + - target: {fileID: 400010, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.w + value: .997745156 + objectReference: {fileID: 0} + - target: {fileID: 400010, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.x + value: -.269845426 + objectReference: {fileID: 0} + - target: {fileID: 400010, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400010, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.z + value: 1.20644108e-08 + objectReference: {fileID: 0} + - target: {fileID: 400012, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.x + value: -1.29496388e-14 + objectReference: {fileID: 0} + - target: {fileID: 400012, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.y + value: 2.88675842e-14 + objectReference: {fileID: 0} + - target: {fileID: 400012, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.z + value: .176200867 + objectReference: {fileID: 0} + - target: {fileID: 400012, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.w + value: .984354258 + objectReference: {fileID: 0} + - target: {fileID: 400012, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.x + value: -.183964223 + objectReference: {fileID: 0} + - target: {fileID: 400012, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.y + value: 3.81469718e-08 + objectReference: {fileID: 0} + - target: {fileID: 400012, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.z + value: 8.04060107e-09 + objectReference: {fileID: 0} + - target: {fileID: 400014, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.x + value: -7.54951487e-15 + objectReference: {fileID: 0} + - target: {fileID: 400014, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.y + value: 3.07254154e-14 + objectReference: {fileID: 0} + - target: {fileID: 400014, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.z + value: 7.45057882e-09 + objectReference: {fileID: 0} + - target: {fileID: 400014, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.x + value: -.159488067 + objectReference: {fileID: 0} + - target: {fileID: 400014, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400014, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.z + value: 6.6989605e-09 + objectReference: {fileID: 0} + - target: {fileID: 400016, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400016, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400016, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400016, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.x + value: 1.89660824e-07 + objectReference: {fileID: 0} + - target: {fileID: 400016, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.y + value: .707106829 + objectReference: {fileID: 0} + - target: {fileID: 400016, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.z + value: -.707106829 + objectReference: {fileID: 0} + - target: {fileID: 400016, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalRotation.w + value: 1.89660824e-07 + objectReference: {fileID: 0} + - target: {fileID: 400016, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalScale.x + value: .800000012 + objectReference: {fileID: 0} + - target: {fileID: 400016, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalScale.y + value: .800000012 + objectReference: {fileID: 0} + - target: {fileID: 400016, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_LocalScale.z + value: .800000012 + objectReference: {fileID: 0} + - target: {fileID: 400016, guid: 19015a5957bbaa745a61cba005220542, type: 3} + propertyPath: m_RootOrder + value: 2 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 19015a5957bbaa745a61cba005220542, type: 3} +--- !u!4 &1610302986 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 400114, guid: ba128457d0ea5e3439dbe4a53b9d1273, + type: 3} + m_PrefabInstance: {fileID: 560668931} + m_PrefabAsset: {fileID: 0} +--- !u!1 &1749629814 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1749629816} + - component: {fileID: 1749629815} + m_Layer: 0 + m_Name: Demo1 + m_TagString: GameController + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1749629815 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1749629814} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 178320cedf292cb4f8d6c0b737b35953, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Player: {fileID: 143600401} +--- !u!4 &1749629816 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1749629814} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0.4343313, y: -0.07096064, z: 0.36408234} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &2086915445 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 400014, guid: ba128457d0ea5e3439dbe4a53b9d1273, + type: 3} + m_PrefabInstance: {fileID: 560668931} + m_PrefabAsset: {fileID: 0} diff --git a/Assets/ThirdParty/DynamicBone/Demo/Demo1.unity.meta b/Assets/ThirdParty/DynamicBone/Demo/Demo1.unity.meta new file mode 100644 index 00000000..36e7b54a --- /dev/null +++ b/Assets/ThirdParty/DynamicBone/Demo/Demo1.unity.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 902c84bf971339c459ce4b757e333a55 +DefaultImporter: + userData: diff --git a/Assets/ThirdParty/DynamicBone/Demo/DynamicBoneDemo1.cs b/Assets/ThirdParty/DynamicBone/Demo/DynamicBoneDemo1.cs new file mode 100644 index 00000000..a7a0bf10 --- /dev/null +++ b/Assets/ThirdParty/DynamicBone/Demo/DynamicBoneDemo1.cs @@ -0,0 +1,54 @@ +using UnityEngine;
+using System.Collections;
+
+public class DynamicBoneDemo1 : MonoBehaviour
+{
+ public GameObject m_Player;
+ float m_weight = 1;
+ float m_sleepTime;
+
+ void Update()
+ {
+ m_Player.transform.Rotate(new Vector3(0, Input.GetAxis("Horizontal") * Time.deltaTime * 200, 0));
+ m_Player.transform.Translate(transform.forward * Input.GetAxis("Vertical") * Time.deltaTime * 4);
+ }
+
+ void OnGUI()
+ {
+ float x = 50;
+ float y = 50;
+ float w1 = 100;
+ float w2 = 200;
+ float h = 24;
+
+ GUI.Label(new Rect(x, y, w2, h), "Press arrow key to move");
+ Animation a = m_Player.GetComponentInChildren<Animation>();
+ y += h;
+ a.enabled = GUI.Toggle(new Rect(x, y, w2, h), a.enabled, "Play Animation");
+
+ y += h * 2;
+ DynamicBone[] dbs = m_Player.GetComponents<DynamicBone>();
+ GUI.Label(new Rect(x, y, w2, h), "Choose dynamic bone:");
+ y += h;
+ dbs[0].enabled = dbs[1].enabled = GUI.Toggle(new Rect(x, y, w1, h), dbs[0].enabled, "Breasts");
+ y += h;
+ dbs[2].enabled = GUI.Toggle(new Rect(x, y, w1, h), dbs[2].enabled, "Tail");
+
+ y += h;
+ GUI.Label(new Rect(x, y, w2, h), "Weight");
+ m_weight = GUI.HorizontalSlider(new Rect(x + 50, y, w1, h), m_weight, 0, 1);
+ foreach (var db in dbs)
+ db.SetWeight(m_weight);
+/*
+ y += h * 2;
+ GUI.Label(new Rect(x, y, w2, h), "Sleep");
+ m_sleepTime = GUI.HorizontalSlider(new Rect(x + 50, y, w1, h), m_sleepTime, 0, 1);
+ if (m_sleepTime > 0)
+ System.Threading.Thread.Sleep((int)(m_sleepTime * 100));
+
+ y += h;
+ GUI.Label(new Rect(x, y, w2, h), "Time Scale");
+ Time.timeScale = GUI.HorizontalSlider(new Rect(x + 80, y, w1, h), Time.timeScale, 0, 2);
+*/
+ }
+}
diff --git a/Assets/ThirdParty/DynamicBone/Demo/DynamicBoneDemo1.cs.meta b/Assets/ThirdParty/DynamicBone/Demo/DynamicBoneDemo1.cs.meta new file mode 100644 index 00000000..48612013 --- /dev/null +++ b/Assets/ThirdParty/DynamicBone/Demo/DynamicBoneDemo1.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 178320cedf292cb4f8d6c0b737b35953 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ThirdParty/DynamicBone/Demo/c1.fbx b/Assets/ThirdParty/DynamicBone/Demo/c1.fbx Binary files differnew file mode 100644 index 00000000..565c9155 --- /dev/null +++ b/Assets/ThirdParty/DynamicBone/Demo/c1.fbx diff --git a/Assets/ThirdParty/DynamicBone/Demo/c1.fbx.meta b/Assets/ThirdParty/DynamicBone/Demo/c1.fbx.meta new file mode 100644 index 00000000..443abe56 --- /dev/null +++ b/Assets/ThirdParty/DynamicBone/Demo/c1.fbx.meta @@ -0,0 +1,421 @@ +fileFormatVersion: 2 +guid: ba128457d0ea5e3439dbe4a53b9d1273 +ModelImporter: + serializedVersion: 16 + fileIDToRecycleName: + 100000: abdomen + 100002: abdomen2 + 100004: //RootNode + 100006: chest + 100008: Genesis2Female + 100010: Genesis2Female.Shape + 100012: head + 100014: hip + 100016: lBigToe + 100018: lCarpal1 + 100020: lCarpal2 + 100022: lCollar + 100024: lEye + 100026: lFoot + 100028: lForeArm + 100030: lHand + 100032: lIndex1 + 100034: lIndex2 + 100036: lIndex3 + 100038: lMid1 + 100040: lMid2 + 100042: lMid3 + 100044: lowerJaw + 100046: lPectoral + 100048: lPinky1 + 100050: lPinky2 + 100052: lPinky3 + 100054: lRing1 + 100056: lRing2 + 100058: lRing3 + 100060: lShin + 100062: lShldr + 100064: lSmallToe1 + 100066: lSmallToe2 + 100068: lSmallToe3 + 100070: lSmallToe4 + 100072: lThigh + 100074: lThumb1 + 100076: lThumb2 + 100078: lThumb3 + 100080: lToe + 100082: neck + 100084: pelvis + 100086: rBigToe + 100088: rCarpal1 + 100090: rCarpal2 + 100092: rCollar + 100094: rEye + 100096: rFoot + 100098: rForeArm + 100100: rHand + 100102: rIndex1 + 100104: rIndex2 + 100106: rIndex3 + 100108: rMid1 + 100110: rMid2 + 100112: rMid3 + 100114: rPectoral + 100116: rPinky1 + 100118: rPinky2 + 100120: rPinky3 + 100122: rRing1 + 100124: rRing2 + 100126: rRing3 + 100128: rShin + 100130: rShldr + 100132: rSmallToe1 + 100134: rSmallToe2 + 100136: rSmallToe3 + 100138: rSmallToe4 + 100140: rThigh + 100142: rThumb1 + 100144: rThumb2 + 100146: rThumb3 + 100148: rToe + 100150: tongue01 + 100152: tongue02 + 100154: tongue03 + 100156: tongue04 + 100158: tongue05 + 100160: tongueBase + 100162: tongueTip + 100164: upperJaw + 400000: abdomen + 400002: abdomen2 + 400004: //RootNode + 400006: chest + 400008: Genesis2Female + 400010: Genesis2Female.Shape + 400012: head + 400014: hip + 400016: lBigToe + 400018: lCarpal1 + 400020: lCarpal2 + 400022: lCollar + 400024: lEye + 400026: lFoot + 400028: lForeArm + 400030: lHand + 400032: lIndex1 + 400034: lIndex2 + 400036: lIndex3 + 400038: lMid1 + 400040: lMid2 + 400042: lMid3 + 400044: lowerJaw + 400046: lPectoral + 400048: lPinky1 + 400050: lPinky2 + 400052: lPinky3 + 400054: lRing1 + 400056: lRing2 + 400058: lRing3 + 400060: lShin + 400062: lShldr + 400064: lSmallToe1 + 400066: lSmallToe2 + 400068: lSmallToe3 + 400070: lSmallToe4 + 400072: lThigh + 400074: lThumb1 + 400076: lThumb2 + 400078: lThumb3 + 400080: lToe + 400082: neck + 400084: pelvis + 400086: rBigToe + 400088: rCarpal1 + 400090: rCarpal2 + 400092: rCollar + 400094: rEye + 400096: rFoot + 400098: rForeArm + 400100: rHand + 400102: rIndex1 + 400104: rIndex2 + 400106: rIndex3 + 400108: rMid1 + 400110: rMid2 + 400112: rMid3 + 400114: rPectoral + 400116: rPinky1 + 400118: rPinky2 + 400120: rPinky3 + 400122: rRing1 + 400124: rRing2 + 400126: rRing3 + 400128: rShin + 400130: rShldr + 400132: rSmallToe1 + 400134: rSmallToe2 + 400136: rSmallToe3 + 400138: rSmallToe4 + 400140: rThigh + 400142: rThumb1 + 400144: rThumb2 + 400146: rThumb3 + 400148: rToe + 400150: tongue01 + 400152: tongue02 + 400154: tongue03 + 400156: tongue04 + 400158: tongue05 + 400160: tongueBase + 400162: tongueTip + 400164: upperJaw + 4300000: Genesis2Female.Shape + 7400000: Animation + 9500000: //RootNode + 11100000: //RootNode + 13700000: Genesis2Female.Shape + materials: + importMaterials: 0 + materialName: 0 + materialSearch: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + optimizeGameObjects: 0 + animationCompression: 2 + animationRotationError: .5 + animationPositionError: .5 + animationScaleError: .5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + clipAnimations: + - serializedVersion: 16 + name: Animation + takeName: Animation + firstFrame: 0 + lastFrame: 206 + wrapMode: 2 + orientationOffsetY: 0 + level: 0 + cycleOffset: 0 + loop: 0 + loopTime: 0 + loopBlend: 0 + loopBlendOrientation: 0 + loopBlendPositionY: 0 + loopBlendPositionXZ: 0 + keepOriginalOrientation: 0 + keepOriginalPositionY: 1 + keepOriginalPositionXZ: 0 + heightFromFeet: 0 + mirror: 0 + bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000 + curves: [] + events: [] + transformMask: + - path: + weight: 1 + - path: Genesis2Female + weight: 1 + - path: Genesis2Female/Genesis2Female.Shape + weight: 1 + - path: Genesis2Female/hip + weight: 1 + - path: Genesis2Female/hip/abdomen + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal1 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal1/lIndex1 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal1/lIndex1/lIndex2 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal1/lIndex1/lIndex2/lIndex3 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal1/lMid1 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal1/lMid1/lMid2 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal1/lMid1/lMid2/lMid3 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal2 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal2/lPinky1 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal2/lPinky1/lPinky2 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal2/lPinky1/lPinky2/lPinky3 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal2/lRing1 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal2/lRing1/lRing2 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lCarpal2/lRing1/lRing2/lRing3 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lThumb1 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lThumb1/lThumb2 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lCollar/lShldr/lForeArm/lHand/lThumb1/lThumb2/lThumb3 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/lPectoral + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/neck + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/lEye + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/lowerJaw + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/lowerJaw/tongueBase + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/lowerJaw/tongueBase/tongue01 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/lowerJaw/tongueBase/tongue01/tongue02 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/lowerJaw/tongueBase/tongue01/tongue02/tongue03 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/lowerJaw/tongueBase/tongue01/tongue02/tongue03/tongue04 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/lowerJaw/tongueBase/tongue01/tongue02/tongue03/tongue04/tongue05 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/lowerJaw/tongueBase/tongue01/tongue02/tongue03/tongue04/tongue05/tongueTip + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/rEye + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/neck/head/upperJaw + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal1 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal1/rIndex1 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal1/rIndex1/rIndex2 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal1/rIndex1/rIndex2/rIndex3 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal1/rMid1 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal1/rMid1/rMid2 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal1/rMid1/rMid2/rMid3 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal2 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal2/rPinky1 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal2/rPinky1/rPinky2 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal2/rPinky1/rPinky2/rPinky3 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal2/rRing1 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal2/rRing1/rRing2 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rCarpal2/rRing1/rRing2/rRing3 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rThumb1 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rThumb1/rThumb2 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rCollar/rShldr/rForeArm/rHand/rThumb1/rThumb2/rThumb3 + weight: 1 + - path: Genesis2Female/hip/abdomen/abdomen2/chest/rPectoral + weight: 1 + - path: Genesis2Female/hip/pelvis + weight: 1 + - path: Genesis2Female/hip/pelvis/lThigh + weight: 1 + - path: Genesis2Female/hip/pelvis/lThigh/lShin + weight: 1 + - path: Genesis2Female/hip/pelvis/lThigh/lShin/lFoot + weight: 1 + - path: Genesis2Female/hip/pelvis/lThigh/lShin/lFoot/lToe + weight: 1 + - path: Genesis2Female/hip/pelvis/lThigh/lShin/lFoot/lToe/lBigToe + weight: 1 + - path: Genesis2Female/hip/pelvis/lThigh/lShin/lFoot/lToe/lSmallToe1 + weight: 1 + - path: Genesis2Female/hip/pelvis/lThigh/lShin/lFoot/lToe/lSmallToe2 + weight: 1 + - path: Genesis2Female/hip/pelvis/lThigh/lShin/lFoot/lToe/lSmallToe3 + weight: 1 + - path: Genesis2Female/hip/pelvis/lThigh/lShin/lFoot/lToe/lSmallToe4 + weight: 1 + - path: Genesis2Female/hip/pelvis/rThigh + weight: 1 + - path: Genesis2Female/hip/pelvis/rThigh/rShin + weight: 1 + - path: Genesis2Female/hip/pelvis/rThigh/rShin/rFoot + weight: 1 + - path: Genesis2Female/hip/pelvis/rThigh/rShin/rFoot/rToe + weight: 1 + - path: Genesis2Female/hip/pelvis/rThigh/rShin/rFoot/rToe/rBigToe + weight: 1 + - path: Genesis2Female/hip/pelvis/rThigh/rShin/rFoot/rToe/rSmallToe1 + weight: 1 + - path: Genesis2Female/hip/pelvis/rThigh/rShin/rFoot/rToe/rSmallToe2 + weight: 1 + - path: Genesis2Female/hip/pelvis/rThigh/rShin/rFoot/rToe/rSmallToe3 + weight: 1 + - path: Genesis2Female/hip/pelvis/rThigh/rShin/rFoot/rToe/rSmallToe4 + weight: 1 + maskType: 0 + maskSource: {instanceID: 0} + isReadable: 0 + meshes: + lODScreenPercentages: [] + globalScale: .00999999978 + meshCompression: 0 + addColliders: 0 + importBlendShapes: 0 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + optimizeMeshForGPU: 1 + weldVertices: 1 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVPackMargin: 4 + tangentSpace: + normalSmoothAngle: 60 + splitTangentsAcrossUV: 1 + normalImportMode: 0 + tangentImportMode: 2 + importAnimation: 1 + copyAvatar: 0 + humanDescription: + human: [] + skeleton: [] + armTwist: .5 + foreArmTwist: .5 + upperLegTwist: .5 + legTwist: .5 + armStretch: .0500000007 + legStretch: .0500000007 + feetSpacing: 0 + rootMotionBoneName: + lastHumanDescriptionAvatarSource: {instanceID: 0} + animationType: 1 + additionalBone: 0 + userData: diff --git a/Assets/ThirdParty/DynamicBone/Demo/tail.FBX b/Assets/ThirdParty/DynamicBone/Demo/tail.FBX Binary files differnew file mode 100644 index 00000000..a198e263 --- /dev/null +++ b/Assets/ThirdParty/DynamicBone/Demo/tail.FBX diff --git a/Assets/ThirdParty/DynamicBone/Demo/tail.FBX.meta b/Assets/ThirdParty/DynamicBone/Demo/tail.FBX.meta new file mode 100644 index 00000000..76ee0624 --- /dev/null +++ b/Assets/ThirdParty/DynamicBone/Demo/tail.FBX.meta @@ -0,0 +1,98 @@ +fileFormatVersion: 2 +guid: 19015a5957bbaa745a61cba005220542 +ModelImporter: + serializedVersion: 16 + fileIDToRecycleName: + 100000: Bone01 + 100002: Bone02 + 100004: Bone03 + 100006: Bone04 + 100008: Bone05 + 100010: Bone06 + 100012: Bone07 + 100014: Bone08 + 100016: //RootNode + 100018: tail + 100020: tail1 + 100022: tail2 + 100024: tail3 + 100026: tail4 + 100028: tail5 + 100030: tail6 + 100032: tail7 + 100034: tail8 + 400000: Bone01 + 400002: Bone02 + 400004: Bone03 + 400006: Bone04 + 400008: Bone05 + 400010: Bone06 + 400012: Bone07 + 400014: Bone08 + 400016: //RootNode + 400018: tail + 400020: tail1 + 400022: tail2 + 400024: tail3 + 400026: tail4 + 400028: tail5 + 400030: tail6 + 400032: tail7 + 400034: tail8 + 4300000: tail + 9500000: //RootNode + 11100000: //RootNode + 13700000: tail + materials: + importMaterials: 0 + materialName: 0 + materialSearch: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + optimizeGameObjects: 0 + animationCompression: 1 + animationRotationError: .5 + animationPositionError: .5 + animationScaleError: .5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + clipAnimations: [] + isReadable: 0 + meshes: + lODScreenPercentages: [] + globalScale: .00999999978 + meshCompression: 0 + addColliders: 0 + importBlendShapes: 0 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + optimizeMeshForGPU: 1 + weldVertices: 1 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVPackMargin: 4 + tangentSpace: + normalSmoothAngle: 60 + splitTangentsAcrossUV: 1 + normalImportMode: 0 + tangentImportMode: 2 + importAnimation: 0 + copyAvatar: 0 + humanDescription: + human: [] + skeleton: [] + armTwist: .5 + foreArmTwist: .5 + upperLegTwist: .5 + legTwist: .5 + armStretch: .0500000007 + legStretch: .0500000007 + feetSpacing: 0 + rootMotionBoneName: + lastHumanDescriptionAvatarSource: {instanceID: 0} + animationType: 1 + additionalBone: 0 + userData: diff --git a/Assets/ThirdParty/DynamicBone/ReadMe.txt b/Assets/ThirdParty/DynamicBone/ReadMe.txt new file mode 100644 index 00000000..add9da94 --- /dev/null +++ b/Assets/ThirdParty/DynamicBone/ReadMe.txt @@ -0,0 +1,143 @@ +Dynamic Bone apply physics to character's bones or joints.
+With simple setup, your character's hair, cloth, breasts or any part will move realistically.
+
+Open Assets/DynamicBone/Demo/Demo1 to see how it works.
+If you have any questions or suggestions, please contact willhongcom@gmail.com.
+
+
+-------------------------------------------------------------------------
+Basic setup:
+
+1. Prepare a properly setup character, both Mecanim and legacy rigs are supported.
+2. Select the game object you want to apply Dynamic Bone.
+3. In the component menu, select Dynamic Bone -> Dynamic Bone.
+4. In the inspector, select root object.
+5. Adjust dynamic bone parameters (see detail descriptions in the following section).
+
+
+You can add collider objects if required:
+
+1. Select game object the collider will attached.
+2. In the component menu, select Dynamic Bone -> Dynamic Bone Collider.
+3. Adjust position and size of the collider.
+4. In Dynamic Bone component, increase size of colliders and append corresponding object.
+
+
+-------------------------------------------------------------------------
+Dynamic Bone component description:
+
+- Root
+ The root of the transform hierarchy to apply physics.
+
+- Update Rate
+ Internal physics simulation rate, measures in frames per seconds.
+
+- Update Mode
+ Normal: Update physics in fixed timestamp as specified rate.
+ AnimatePhysics: Updates during the physic loop in order to synchronized with the physics engine.
+ UnscaledTime: Updates independently of Time.timeScale.
+ Default: Update physics every frame instead of specified rate, recommended.
+
+- Damping
+ How much the bones slowed down.
+
+- Elasticity
+ How much the force applied to return each bone to original orientation.
+
+- Stiffness
+ How much bone's original orientation are preserved.
+
+- Inert
+ How much character's position change is ignored in physics simulation.
+
+- Friction
+ How much the bones slowed down when collide.
+
+- Radius
+ Each bone can be a sphere to collide with colliders. Radius describe sphere's size.
+
+- Damping Distrib, Elasticity Distrib, Stiffness Distrib, Inert Distrib, Radius Distrib
+ How parameters change over hierarchy chain. Curve values are multiplied to corresponding parameters.
+
+- End Length
+ If End Length is not zero, an extra bone is generated at the end of transform hierarchy,
+ length is multiplied by last two bone's distance.
+
+- End Offset
+ If End Offset is not zero, an extra bone is generated at the end of transform hierarchy,
+ offset is in character's local space.
+
+- Gravity
+ The force apply to bones, in world space. Partial force apply to character's initial pose is cancelled out.
+
+- Force
+ The force apply to bones, in world space.
+
+- Colliders
+ Collider objects interact with the bones.
+
+- Exclusions
+ Bones exclude from physics simulation.
+
+- Freeze Axis
+ Constrain bones to move on specified plane.
+
+- Distant Disable, Reference Object, Distance To Object
+ Disable physics simulation automatically if character is far from camera or player.
+ If there is no reference object, default main camera is used.
+
+
+Dynamic Bone Collider component description:
+
+- Center
+ The center of the sphere or capsule, in the object's local space.
+
+- Radius
+ The radius of the sphere or capsule, will be scaled by the transform's scale.
+
+- Height
+ The height of the capsule, including two half-spheres, will be scaled by the transform's scale.
+
+- Direction
+ The axis of the capsule's height.
+
+- Bound
+ Constrain bones to outside bound or inside bound.
+
+-------------------------------------------------------------------------
+Dynamic Bone script reference:
+
+- public void SetWeight(float w);
+ Control how physics blend with existing animation.
+
+- public void UpdateParameters();
+ Update parameters at runtime, call this funtion after modifing parameters.
+
+-------------------------------------------------------------------------
+Version History
+
+1.0.1 Initial release.
+1.0.2 Improve inspector UI.
+1.0.3 Fix inert unstable when enabled / disabled.
+1.1.0 Use curve to setup parameters over hierarchy chain.
+ Collider can configured to constrain bones inside bound.
+1.1.1 Add exclusion setting.
+1.1.2 Deal with negative scale problem.
+1.1.3 Fix bug with bones contain scale.
+1.1.4 Add freeze axis.
+ Fix bug when added via script.
+1.1.5 Add distant disable.
+ Reduce GC alloc.
+1.1.6 Fix capsule collider bug.
+1.1.7 Unity 5 support.
+1.1.8 Fix problems caused by negative scale.
+1.1.9 Improve detecting negative scale.
+ Fix bug if collider is set as inside.
+ Add UpdateMode setting.
+1.1.10 Fix problems caused by negative scale after Unity 5.4.
+1.2.0 Add tool tips.
+ Add plane collider.
+ Add function to update parameters at runtime.
+1.2.1 Add friction parameter.
+ Update UNITY_5 to compatible with newer version.
+1.2.2 Add "Default" update mode, fix some jitter issue.
diff --git a/Assets/ThirdParty/DynamicBone/ReadMe.txt.meta b/Assets/ThirdParty/DynamicBone/ReadMe.txt.meta new file mode 100644 index 00000000..e2accdc8 --- /dev/null +++ b/Assets/ThirdParty/DynamicBone/ReadMe.txt.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: bdbe6feeda2a62b45ad9a4e311031478 +TextScriptImporter: + userData: diff --git a/Assets/ThirdParty/DynamicBone/Scripts.meta b/Assets/ThirdParty/DynamicBone/Scripts.meta new file mode 100644 index 00000000..29ce2ddf --- /dev/null +++ b/Assets/ThirdParty/DynamicBone/Scripts.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 993edbffbda2d3e4abd24f1bf074c5f2 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/ThirdParty/DynamicBone/Scripts/DynamicBone.cs b/Assets/ThirdParty/DynamicBone/Scripts/DynamicBone.cs new file mode 100644 index 00000000..3cdadee0 --- /dev/null +++ b/Assets/ThirdParty/DynamicBone/Scripts/DynamicBone.cs @@ -0,0 +1,714 @@ +using UnityEngine;
+using System.Collections.Generic;
+
+[AddComponentMenu("Dynamic Bone/Dynamic Bone")]
+public class DynamicBone : MonoBehaviour
+{
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("The root of the transform hierarchy to apply physics.")]
+#endif
+ public Transform m_Root = null;
+
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("Internal physics simulation rate.")]
+#endif
+ public float m_UpdateRate = 60.0f;
+
+ public enum UpdateMode
+ {
+ Normal,
+ AnimatePhysics,
+ UnscaledTime,
+ Default
+ }
+ public UpdateMode m_UpdateMode = UpdateMode.Default;
+
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("How much the bones slowed down.")]
+#endif
+ [Range(0, 1)]
+ public float m_Damping = 0.1f;
+ public AnimationCurve m_DampingDistrib = null;
+
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("How much the force applied to return each bone to original orientation.")]
+#endif
+ [Range(0, 1)]
+ public float m_Elasticity = 0.1f;
+ public AnimationCurve m_ElasticityDistrib = null;
+
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("How much bone's original orientation are preserved.")]
+#endif
+ [Range(0, 1)]
+ public float m_Stiffness = 0.1f;
+ public AnimationCurve m_StiffnessDistrib = null;
+
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("How much character's position change is ignored in physics simulation.")]
+#endif
+ [Range(0, 1)]
+ public float m_Inert = 0;
+ public AnimationCurve m_InertDistrib = null;
+
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("How much the bones slowed down when collide.")]
+#endif
+ public float m_Friction = 0;
+ public AnimationCurve m_FrictionDistrib = null;
+
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("Each bone can be a sphere to collide with colliders. Radius describe sphere's size.")]
+#endif
+ public float m_Radius = 0;
+ public AnimationCurve m_RadiusDistrib = null;
+
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("If End Length is not zero, an extra bone is generated at the end of transform hierarchy.")]
+#endif
+ public float m_EndLength = 0;
+
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("If End Offset is not zero, an extra bone is generated at the end of transform hierarchy.")]
+#endif
+ public Vector3 m_EndOffset = Vector3.zero;
+
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("The force apply to bones. Partial force apply to character's initial pose is cancelled out.")]
+#endif
+ public Vector3 m_Gravity = Vector3.zero;
+
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("The force apply to bones.")]
+#endif
+ public Vector3 m_Force = Vector3.zero;
+
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("Collider objects interact with the bones.")]
+#endif
+ public List<DynamicBoneColliderBase> m_Colliders = null;
+
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("Bones exclude from physics simulation.")]
+#endif
+ public List<Transform> m_Exclusions = null;
+
+
+ public enum FreezeAxis
+ {
+ None, X, Y, Z
+ }
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("Constrain bones to move on specified plane.")]
+#endif
+ public FreezeAxis m_FreezeAxis = FreezeAxis.None;
+
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("Disable physics simulation automatically if character is far from camera or player.")]
+#endif
+ public bool m_DistantDisable = false;
+ public Transform m_ReferenceObject = null;
+ public float m_DistanceToObject = 20;
+
+ Vector3 m_LocalGravity = Vector3.zero;
+ Vector3 m_ObjectMove = Vector3.zero;
+ Vector3 m_ObjectPrevPosition = Vector3.zero;
+ float m_BoneTotalLength = 0;
+ float m_ObjectScale = 1.0f;
+ float m_Time = 0;
+ float m_Weight = 1.0f;
+ bool m_DistantDisabled = false;
+
+ class Particle
+ {
+ public Transform m_Transform = null;
+ public int m_ParentIndex = -1;
+ public float m_Damping = 0;
+ public float m_Elasticity = 0;
+ public float m_Stiffness = 0;
+ public float m_Inert = 0;
+ public float m_Friction = 0;
+ public float m_Radius = 0;
+ public float m_BoneLength = 0;
+ public bool m_isCollide = false;
+
+ public Vector3 m_Position = Vector3.zero;
+ public Vector3 m_PrevPosition = Vector3.zero;
+ public Vector3 m_EndOffset = Vector3.zero;
+ public Vector3 m_InitLocalPosition = Vector3.zero;
+ public Quaternion m_InitLocalRotation = Quaternion.identity;
+ }
+
+ List<Particle> m_Particles = new List<Particle>();
+
+ void Start()
+ {
+ SetupParticles();
+ }
+
+ void FixedUpdate()
+ {
+ if (m_UpdateMode == UpdateMode.AnimatePhysics)
+ PreUpdate();
+ }
+
+ void Update()
+ {
+ if (m_UpdateMode != UpdateMode.AnimatePhysics)
+ PreUpdate();
+ }
+
+ void LateUpdate()
+ {
+ if (m_DistantDisable)
+ CheckDistance();
+
+ if (m_Weight > 0 && !(m_DistantDisable && m_DistantDisabled))
+ {
+#if UNITY_5_3_OR_NEWER
+ float dt = m_UpdateMode == UpdateMode.UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime;
+#else
+ float dt = Time.deltaTime;
+#endif
+ UpdateDynamicBones(dt);
+ }
+ }
+
+ void PreUpdate()
+ {
+ if (m_Weight > 0 && !(m_DistantDisable && m_DistantDisabled))
+ InitTransforms();
+ }
+
+ void CheckDistance()
+ {
+ Transform rt = m_ReferenceObject;
+ if (rt == null && Camera.main != null)
+ rt = Camera.main.transform;
+ if (rt != null)
+ {
+ float d = (rt.position - transform.position).sqrMagnitude;
+ bool disable = d > m_DistanceToObject * m_DistanceToObject;
+ if (disable != m_DistantDisabled)
+ {
+ if (!disable)
+ ResetParticlesPosition();
+ m_DistantDisabled = disable;
+ }
+ }
+ }
+
+ void OnEnable()
+ {
+ ResetParticlesPosition();
+ }
+
+ void OnDisable()
+ {
+ InitTransforms();
+ }
+
+ void OnValidate()
+ {
+ m_UpdateRate = Mathf.Max(m_UpdateRate, 0);
+ m_Damping = Mathf.Clamp01(m_Damping);
+ m_Elasticity = Mathf.Clamp01(m_Elasticity);
+ m_Stiffness = Mathf.Clamp01(m_Stiffness);
+ m_Inert = Mathf.Clamp01(m_Inert);
+ m_Friction = Mathf.Clamp01(m_Friction);
+ m_Radius = Mathf.Max(m_Radius, 0);
+
+ if (Application.isEditor && Application.isPlaying)
+ {
+ InitTransforms();
+ SetupParticles();
+ }
+ }
+
+ void OnDrawGizmosSelected()
+ {
+ if (!enabled || m_Root == null)
+ return;
+
+ if (Application.isEditor && !Application.isPlaying && transform.hasChanged)
+ {
+ InitTransforms();
+ SetupParticles();
+ }
+
+ Gizmos.color = Color.white;
+ for (int i = 0; i < m_Particles.Count; ++i)
+ {
+ Particle p = m_Particles[i];
+ if (p.m_ParentIndex >= 0)
+ {
+ Particle p0 = m_Particles[p.m_ParentIndex];
+ Gizmos.DrawLine(p.m_Position, p0.m_Position);
+ }
+ if (p.m_Radius > 0)
+ Gizmos.DrawWireSphere(p.m_Position, p.m_Radius * m_ObjectScale);
+ }
+ }
+
+ public void SetWeight(float w)
+ {
+ if (m_Weight != w)
+ {
+ if (w == 0)
+ InitTransforms();
+ else if (m_Weight == 0)
+ ResetParticlesPosition();
+ m_Weight = w;
+ }
+ }
+
+ public float GetWeight()
+ {
+ return m_Weight;
+ }
+
+ void UpdateDynamicBones(float t)
+ {
+ if (m_Root == null)
+ return;
+
+ m_ObjectScale = Mathf.Abs(transform.lossyScale.x);
+ m_ObjectMove = transform.position - m_ObjectPrevPosition;
+ m_ObjectPrevPosition = transform.position;
+
+ int loop = 1;
+ float timeVar = 1;
+
+ if (m_UpdateMode == UpdateMode.Default)
+ {
+ if (m_UpdateRate > 0)
+ {
+ timeVar = Time.deltaTime * m_UpdateRate;
+ }
+ else
+ {
+ timeVar = Time.deltaTime;
+ }
+ }
+ else
+ {
+ if (m_UpdateRate > 0)
+ {
+ float dt = 1.0f / m_UpdateRate;
+ m_Time += t;
+ loop = 0;
+
+ while (m_Time >= dt)
+ {
+ m_Time -= dt;
+ if (++loop >= 3)
+ {
+ m_Time = 0;
+ break;
+ }
+ }
+ }
+ }
+
+ if (loop > 0)
+ {
+ for (int i = 0; i < loop; ++i)
+ {
+ UpdateParticles1(timeVar);
+ UpdateParticles2(timeVar);
+ m_ObjectMove = Vector3.zero;
+ }
+ }
+ else
+ {
+ SkipUpdateParticles();
+ }
+
+ ApplyParticlesToTransforms();
+ }
+
+ public void SetupParticles()
+ {
+ m_Particles.Clear();
+ if (m_Root == null)
+ return;
+
+ m_LocalGravity = m_Root.InverseTransformDirection(m_Gravity);
+ m_ObjectScale = Mathf.Abs(transform.lossyScale.x);
+ m_ObjectPrevPosition = transform.position;
+ m_ObjectMove = Vector3.zero;
+ m_BoneTotalLength = 0;
+ AppendParticles(m_Root, -1, 0);
+ UpdateParameters();
+ }
+
+ void AppendParticles(Transform b, int parentIndex, float boneLength)
+ {
+ Particle p = new Particle();
+ p.m_Transform = b;
+ p.m_ParentIndex = parentIndex;
+ if (b != null)
+ {
+ p.m_Position = p.m_PrevPosition = b.position;
+ p.m_InitLocalPosition = b.localPosition;
+ p.m_InitLocalRotation = b.localRotation;
+ }
+ else // end bone
+ {
+ Transform pb = m_Particles[parentIndex].m_Transform;
+ if (m_EndLength > 0)
+ {
+ Transform ppb = pb.parent;
+ if (ppb != null)
+ p.m_EndOffset = pb.InverseTransformPoint((pb.position * 2 - ppb.position)) * m_EndLength;
+ else
+ p.m_EndOffset = new Vector3(m_EndLength, 0, 0);
+ }
+ else
+ {
+ p.m_EndOffset = pb.InverseTransformPoint(transform.TransformDirection(m_EndOffset) + pb.position);
+ }
+ p.m_Position = p.m_PrevPosition = pb.TransformPoint(p.m_EndOffset);
+ }
+
+ if (parentIndex >= 0)
+ {
+ boneLength += (m_Particles[parentIndex].m_Transform.position - p.m_Position).magnitude;
+ p.m_BoneLength = boneLength;
+ m_BoneTotalLength = Mathf.Max(m_BoneTotalLength, boneLength);
+ }
+
+ int index = m_Particles.Count;
+ m_Particles.Add(p);
+
+ if (b != null)
+ {
+ for (int i = 0; i < b.childCount; ++i)
+ {
+ Transform child = b.GetChild(i);
+ bool exclude = false;
+ if (m_Exclusions != null)
+ {
+ exclude = m_Exclusions.Contains(child);
+ }
+ if (!exclude)
+ AppendParticles(child, index, boneLength);
+ else if (m_EndLength > 0 || m_EndOffset != Vector3.zero)
+ AppendParticles(null, index, boneLength);
+ }
+
+ if (b.childCount == 0 && (m_EndLength > 0 || m_EndOffset != Vector3.zero))
+ AppendParticles(null, index, boneLength);
+ }
+ }
+
+ public void UpdateParameters()
+ {
+ if (m_Root == null)
+ return;
+
+ m_LocalGravity = m_Root.InverseTransformDirection(m_Gravity);
+
+ for (int i = 0; i < m_Particles.Count; ++i)
+ {
+ Particle p = m_Particles[i];
+ p.m_Damping = m_Damping;
+ p.m_Elasticity = m_Elasticity;
+ p.m_Stiffness = m_Stiffness;
+ p.m_Inert = m_Inert;
+ p.m_Friction = m_Friction;
+ p.m_Radius = m_Radius;
+
+ if (m_BoneTotalLength > 0)
+ {
+ float a = p.m_BoneLength / m_BoneTotalLength;
+ if (m_DampingDistrib != null && m_DampingDistrib.keys.Length > 0)
+ p.m_Damping *= m_DampingDistrib.Evaluate(a);
+ if (m_ElasticityDistrib != null && m_ElasticityDistrib.keys.Length > 0)
+ p.m_Elasticity *= m_ElasticityDistrib.Evaluate(a);
+ if (m_StiffnessDistrib != null && m_StiffnessDistrib.keys.Length > 0)
+ p.m_Stiffness *= m_StiffnessDistrib.Evaluate(a);
+ if (m_InertDistrib != null && m_InertDistrib.keys.Length > 0)
+ p.m_Inert *= m_InertDistrib.Evaluate(a);
+ if (m_FrictionDistrib != null && m_FrictionDistrib.keys.Length > 0)
+ p.m_Friction *= m_FrictionDistrib.Evaluate(a);
+ if (m_RadiusDistrib != null && m_RadiusDistrib.keys.Length > 0)
+ p.m_Radius *= m_RadiusDistrib.Evaluate(a);
+ }
+
+ p.m_Damping = Mathf.Clamp01(p.m_Damping);
+ p.m_Elasticity = Mathf.Clamp01(p.m_Elasticity);
+ p.m_Stiffness = Mathf.Clamp01(p.m_Stiffness);
+ p.m_Inert = Mathf.Clamp01(p.m_Inert);
+ p.m_Friction = Mathf.Clamp01(p.m_Friction);
+ p.m_Radius = Mathf.Max(p.m_Radius, 0);
+ }
+ }
+
+ void InitTransforms()
+ {
+ for (int i = 0; i < m_Particles.Count; ++i)
+ {
+ Particle p = m_Particles[i];
+ if (p.m_Transform != null)
+ {
+ p.m_Transform.localPosition = p.m_InitLocalPosition;
+ p.m_Transform.localRotation = p.m_InitLocalRotation;
+ }
+ }
+ }
+
+ void ResetParticlesPosition()
+ {
+ for (int i = 0; i < m_Particles.Count; ++i)
+ {
+ Particle p = m_Particles[i];
+ if (p.m_Transform != null)
+ {
+ p.m_Position = p.m_PrevPosition = p.m_Transform.position;
+ }
+ else // end bone
+ {
+ Transform pb = m_Particles[p.m_ParentIndex].m_Transform;
+ p.m_Position = p.m_PrevPosition = pb.TransformPoint(p.m_EndOffset);
+ }
+ p.m_isCollide = false;
+ }
+ m_ObjectPrevPosition = transform.position;
+ }
+
+ void UpdateParticles1(float timeVar)
+ {
+ Vector3 force = m_Gravity;
+ Vector3 fdir = m_Gravity.normalized;
+ Vector3 rf = m_Root.TransformDirection(m_LocalGravity);
+ Vector3 pf = fdir * Mathf.Max(Vector3.Dot(rf, fdir), 0); // project current gravity to rest gravity
+ force -= pf; // remove projected gravity
+ force = (force + m_Force) * (m_ObjectScale * timeVar);
+
+ for (int i = 0; i < m_Particles.Count; ++i)
+ {
+ Particle p = m_Particles[i];
+ if (p.m_ParentIndex >= 0)
+ {
+ // verlet integration
+ Vector3 v = p.m_Position - p.m_PrevPosition;
+ Vector3 rmove = m_ObjectMove * p.m_Inert;
+ p.m_PrevPosition = p.m_Position + rmove;
+ float damping = p.m_Damping;
+ if (p.m_isCollide)
+ {
+ damping += p.m_Friction;
+ if (damping > 1)
+ damping = 1;
+ p.m_isCollide = false;
+ }
+ p.m_Position += v * (1 - damping) + force + rmove;
+ }
+ else
+ {
+ p.m_PrevPosition = p.m_Position;
+ p.m_Position = p.m_Transform.position;
+ }
+ }
+ }
+
+ void UpdateParticles2(float timeVar)
+ {
+ Plane movePlane = new Plane();
+
+ for (int i = 1; i < m_Particles.Count; ++i)
+ {
+ Particle p = m_Particles[i];
+ Particle p0 = m_Particles[p.m_ParentIndex];
+
+ float restLen;
+ if (p.m_Transform != null)
+ restLen = (p0.m_Transform.position - p.m_Transform.position).magnitude;
+ else
+ restLen = p0.m_Transform.localToWorldMatrix.MultiplyVector(p.m_EndOffset).magnitude;
+
+ // keep shape
+ float stiffness = Mathf.Lerp(1.0f, p.m_Stiffness, m_Weight);
+ if (stiffness > 0 || p.m_Elasticity > 0)
+ {
+ Matrix4x4 m0 = p0.m_Transform.localToWorldMatrix;
+ m0.SetColumn(3, p0.m_Position);
+ Vector3 restPos;
+ if (p.m_Transform != null)
+ restPos = m0.MultiplyPoint3x4(p.m_Transform.localPosition);
+ else
+ restPos = m0.MultiplyPoint3x4(p.m_EndOffset);
+
+ Vector3 d = restPos - p.m_Position;
+ p.m_Position += d * (p.m_Elasticity * timeVar);
+
+ if (stiffness > 0)
+ {
+ d = restPos - p.m_Position;
+ float len = d.magnitude;
+ float maxlen = restLen * (1 - stiffness) * 2;
+ if (len > maxlen)
+ p.m_Position += d * ((len - maxlen) / len);
+ }
+ }
+
+ // collide
+ if (m_Colliders != null)
+ {
+ float particleRadius = p.m_Radius * m_ObjectScale;
+ for (int j = 0; j < m_Colliders.Count; ++j)
+ {
+ DynamicBoneColliderBase c = m_Colliders[j];
+ if (c != null && c.enabled)
+ p.m_isCollide |= c.Collide(ref p.m_Position, particleRadius);
+ }
+ }
+
+ // freeze axis, project to plane
+ if (m_FreezeAxis != FreezeAxis.None)
+ {
+ switch (m_FreezeAxis)
+ {
+ case FreezeAxis.X:
+ movePlane.SetNormalAndPosition(p0.m_Transform.right, p0.m_Position);
+ break;
+ case FreezeAxis.Y:
+ movePlane.SetNormalAndPosition(p0.m_Transform.up, p0.m_Position);
+ break;
+ case FreezeAxis.Z:
+ movePlane.SetNormalAndPosition(p0.m_Transform.forward, p0.m_Position);
+ break;
+ }
+ p.m_Position -= movePlane.normal * movePlane.GetDistanceToPoint(p.m_Position);
+ }
+
+ // keep length
+ Vector3 dd = p0.m_Position - p.m_Position;
+ float leng = dd.magnitude;
+ if (leng > 0)
+ p.m_Position += dd * ((leng - restLen) / leng);
+ }
+ }
+
+ // only update stiffness and keep bone length
+ void SkipUpdateParticles()
+ {
+ for (int i = 0; i < m_Particles.Count; ++i)
+ {
+ Particle p = m_Particles[i];
+ if (p.m_ParentIndex >= 0)
+ {
+ p.m_PrevPosition += m_ObjectMove;
+ p.m_Position += m_ObjectMove;
+
+ Particle p0 = m_Particles[p.m_ParentIndex];
+
+ float restLen;
+ if (p.m_Transform != null)
+ restLen = (p0.m_Transform.position - p.m_Transform.position).magnitude;
+ else
+ restLen = p0.m_Transform.localToWorldMatrix.MultiplyVector(p.m_EndOffset).magnitude;
+
+ // keep shape
+ float stiffness = Mathf.Lerp(1.0f, p.m_Stiffness, m_Weight);
+ if (stiffness > 0)
+ {
+ Matrix4x4 m0 = p0.m_Transform.localToWorldMatrix;
+ m0.SetColumn(3, p0.m_Position);
+ Vector3 restPos;
+ if (p.m_Transform != null)
+ restPos = m0.MultiplyPoint3x4(p.m_Transform.localPosition);
+ else
+ restPos = m0.MultiplyPoint3x4(p.m_EndOffset);
+
+ Vector3 d = restPos - p.m_Position;
+ float len = d.magnitude;
+ float maxlen = restLen * (1 - stiffness) * 2;
+ if (len > maxlen)
+ p.m_Position += d * ((len - maxlen) / len);
+ }
+
+ // keep length
+ Vector3 dd = p0.m_Position - p.m_Position;
+ float leng = dd.magnitude;
+ if (leng > 0)
+ p.m_Position += dd * ((leng - restLen) / leng);
+ }
+ else
+ {
+ p.m_PrevPosition = p.m_Position;
+ p.m_Position = p.m_Transform.position;
+ }
+ }
+ }
+
+ static Vector3 MirrorVector(Vector3 v, Vector3 axis)
+ {
+ return v - axis * (Vector3.Dot(v, axis) * 2);
+ }
+
+ void ApplyParticlesToTransforms()
+ {
+#if !UNITY_5_4_OR_NEWER
+ // detect negative scale
+ Vector3 ax = Vector3.right;
+ Vector3 ay = Vector3.up;
+ Vector3 az = Vector3.forward;
+ bool nx = false, ny = false, nz = false;
+
+ Vector3 loosyScale = transform.lossyScale;
+ if (loosyScale.x < 0 || loosyScale.y < 0 || loosyScale.z < 0)
+ {
+ Transform mirrorObject = transform;
+ do
+ {
+ Vector3 ls = mirrorObject.localScale;
+ nx = ls.x < 0;
+ if (nx)
+ ax = mirrorObject.right;
+ ny = ls.y < 0;
+ if (ny)
+ ay = mirrorObject.up;
+ nz = ls.z < 0;
+ if (nz)
+ az = mirrorObject.forward;
+ if (nx || ny || nz)
+ break;
+
+ mirrorObject = mirrorObject.parent;
+ }
+ while (mirrorObject != null);
+ }
+#endif
+
+ for (int i = 1; i < m_Particles.Count; ++i)
+ {
+ Particle p = m_Particles[i];
+ Particle p0 = m_Particles[p.m_ParentIndex];
+
+ if (p0.m_Transform.childCount <= 1) // do not modify bone orientation if has more then one child
+ {
+ Vector3 v;
+ if (p.m_Transform != null)
+ v = p.m_Transform.localPosition;
+ else
+ v = p.m_EndOffset;
+ Vector3 v2 = p.m_Position - p0.m_Position;
+#if !UNITY_5_4_OR_NEWER
+ if (nx)
+ v2 = MirrorVector(v2, ax);
+ if (ny)
+ v2 = MirrorVector(v2, ay);
+ if (nz)
+ v2 = MirrorVector(v2, az);
+#endif
+ Quaternion rot = Quaternion.FromToRotation(p0.m_Transform.TransformDirection(v), v2);
+ p0.m_Transform.rotation = rot * p0.m_Transform.rotation;
+ }
+
+ if (p.m_Transform != null)
+ p.m_Transform.position = p.m_Position;
+ }
+ }
+}
diff --git a/Assets/ThirdParty/DynamicBone/Scripts/DynamicBone.cs.meta b/Assets/ThirdParty/DynamicBone/Scripts/DynamicBone.cs.meta new file mode 100644 index 00000000..89a5ba7f --- /dev/null +++ b/Assets/ThirdParty/DynamicBone/Scripts/DynamicBone.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f9ac8d30c6a0d9642a11e5be4c440740 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ThirdParty/DynamicBone/Scripts/DynamicBoneCollider.cs b/Assets/ThirdParty/DynamicBone/Scripts/DynamicBoneCollider.cs new file mode 100644 index 00000000..d5df92b8 --- /dev/null +++ b/Assets/ThirdParty/DynamicBone/Scripts/DynamicBoneCollider.cs @@ -0,0 +1,235 @@ +using UnityEngine;
+
+[AddComponentMenu("Dynamic Bone/Dynamic Bone Collider")]
+public class DynamicBoneCollider : DynamicBoneColliderBase
+{
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("The radius of the sphere or capsule.")]
+#endif
+ public float m_Radius = 0.5f;
+
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("The height of the capsule.")]
+#endif
+ public float m_Height = 0;
+
+ void OnValidate()
+ {
+ m_Radius = Mathf.Max(m_Radius, 0);
+ m_Height = Mathf.Max(m_Height, 0);
+ }
+
+ public override bool Collide(ref Vector3 particlePosition, float particleRadius)
+ {
+ float radius = m_Radius * Mathf.Abs(transform.lossyScale.x);
+ float h = m_Height * 0.5f - m_Radius;
+ if (h <= 0)
+ {
+ if (m_Bound == Bound.Outside)
+ return OutsideSphere(ref particlePosition, particleRadius, transform.TransformPoint(m_Center), radius);
+ else
+ return InsideSphere(ref particlePosition, particleRadius, transform.TransformPoint(m_Center), radius);
+ }
+ else
+ {
+ Vector3 c0 = m_Center;
+ Vector3 c1 = m_Center;
+
+ switch (m_Direction)
+ {
+ case Direction.X:
+ c0.x -= h;
+ c1.x += h;
+ break;
+ case Direction.Y:
+ c0.y -= h;
+ c1.y += h;
+ break;
+ case Direction.Z:
+ c0.z -= h;
+ c1.z += h;
+ break;
+ }
+ if (m_Bound == Bound.Outside)
+ return OutsideCapsule(ref particlePosition, particleRadius, transform.TransformPoint(c0), transform.TransformPoint(c1), radius);
+ else
+ return InsideCapsule(ref particlePosition, particleRadius, transform.TransformPoint(c0), transform.TransformPoint(c1), radius);
+ }
+ }
+
+ static bool OutsideSphere(ref Vector3 particlePosition, float particleRadius, Vector3 sphereCenter, float sphereRadius)
+ {
+ float r = sphereRadius + particleRadius;
+ float r2 = r * r;
+ Vector3 d = particlePosition - sphereCenter;
+ float len2 = d.sqrMagnitude;
+
+ // if is inside sphere, project onto sphere surface
+ if (len2 > 0 && len2 < r2)
+ {
+ float len = Mathf.Sqrt(len2);
+ particlePosition = sphereCenter + d * (r / len);
+ return true;
+ }
+ return false;
+ }
+
+ static bool InsideSphere(ref Vector3 particlePosition, float particleRadius, Vector3 sphereCenter, float sphereRadius)
+ {
+ float r = sphereRadius - particleRadius;
+ float r2 = r * r;
+ Vector3 d = particlePosition - sphereCenter;
+ float len2 = d.sqrMagnitude;
+
+ // if is outside sphere, project onto sphere surface
+ if (len2 > r2)
+ {
+ float len = Mathf.Sqrt(len2);
+ particlePosition = sphereCenter + d * (r / len);
+ return true;
+ }
+ return false;
+ }
+
+ static bool OutsideCapsule(ref Vector3 particlePosition, float particleRadius, Vector3 capsuleP0, Vector3 capsuleP1, float capsuleRadius)
+ {
+ float r = capsuleRadius + particleRadius;
+ float r2 = r * r;
+ Vector3 dir = capsuleP1 - capsuleP0;
+ Vector3 d = particlePosition - capsuleP0;
+ float t = Vector3.Dot(d, dir);
+
+ if (t <= 0)
+ {
+ // check sphere1
+ float len2 = d.sqrMagnitude;
+ if (len2 > 0 && len2 < r2)
+ {
+ float len = Mathf.Sqrt(len2);
+ particlePosition = capsuleP0 + d * (r / len);
+ return true;
+ }
+ }
+ else
+ {
+ float dl = dir.sqrMagnitude;
+ if (t >= dl)
+ {
+ // check sphere2
+ d = particlePosition - capsuleP1;
+ float len2 = d.sqrMagnitude;
+ if (len2 > 0 && len2 < r2)
+ {
+ float len = Mathf.Sqrt(len2);
+ particlePosition = capsuleP1 + d * (r / len);
+ return true;
+ }
+ }
+ else if (dl > 0)
+ {
+ // check cylinder
+ t /= dl;
+ d -= dir * t;
+ float len2 = d.sqrMagnitude;
+ if (len2 > 0 && len2 < r2)
+ {
+ float len = Mathf.Sqrt(len2);
+ particlePosition += d * ((r - len) / len);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ static bool InsideCapsule(ref Vector3 particlePosition, float particleRadius, Vector3 capsuleP0, Vector3 capsuleP1, float capsuleRadius)
+ {
+ float r = capsuleRadius - particleRadius;
+ float r2 = r * r;
+ Vector3 dir = capsuleP1 - capsuleP0;
+ Vector3 d = particlePosition - capsuleP0;
+ float t = Vector3.Dot(d, dir);
+
+ if (t <= 0)
+ {
+ // check sphere1
+ float len2 = d.sqrMagnitude;
+ if (len2 > r2)
+ {
+ float len = Mathf.Sqrt(len2);
+ particlePosition = capsuleP0 + d * (r / len);
+ return true;
+ }
+ }
+ else
+ {
+ float dl = dir.sqrMagnitude;
+ if (t >= dl)
+ {
+ // check sphere2
+ d = particlePosition - capsuleP1;
+ float len2 = d.sqrMagnitude;
+ if (len2 > r2)
+ {
+ float len = Mathf.Sqrt(len2);
+ particlePosition = capsuleP1 + d * (r / len);
+ return true;
+ }
+ }
+ else if (dl > 0)
+ {
+ // check cylinder
+ t /= dl;
+ d -= dir * t;
+ float len2 = d.sqrMagnitude;
+ if (len2 > r2)
+ {
+ float len = Mathf.Sqrt(len2);
+ particlePosition += d * ((r - len) / len);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ void OnDrawGizmosSelected()
+ {
+ if (!enabled)
+ return;
+
+ if (m_Bound == Bound.Outside)
+ Gizmos.color = Color.yellow;
+ else
+ Gizmos.color = Color.magenta;
+ float radius = m_Radius * Mathf.Abs(transform.lossyScale.x);
+ float h = m_Height * 0.5f - m_Radius;
+ if (h <= 0)
+ {
+ Gizmos.DrawWireSphere(transform.TransformPoint(m_Center), radius);
+ }
+ else
+ {
+ Vector3 c0 = m_Center;
+ Vector3 c1 = m_Center;
+
+ switch (m_Direction)
+ {
+ case Direction.X:
+ c0.x -= h;
+ c1.x += h;
+ break;
+ case Direction.Y:
+ c0.y -= h;
+ c1.y += h;
+ break;
+ case Direction.Z:
+ c0.z -= h;
+ c1.z += h;
+ break;
+ }
+ Gizmos.DrawWireSphere(transform.TransformPoint(c0), radius);
+ Gizmos.DrawWireSphere(transform.TransformPoint(c1), radius);
+ }
+ }
+}
diff --git a/Assets/ThirdParty/DynamicBone/Scripts/DynamicBoneCollider.cs.meta b/Assets/ThirdParty/DynamicBone/Scripts/DynamicBoneCollider.cs.meta new file mode 100644 index 00000000..35fae1e7 --- /dev/null +++ b/Assets/ThirdParty/DynamicBone/Scripts/DynamicBoneCollider.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: baedd976e12657241bf7ff2d1c685342 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ThirdParty/DynamicBone/Scripts/DynamicBoneColliderBase.cs b/Assets/ThirdParty/DynamicBone/Scripts/DynamicBoneColliderBase.cs new file mode 100644 index 00000000..9e921457 --- /dev/null +++ b/Assets/ThirdParty/DynamicBone/Scripts/DynamicBoneColliderBase.cs @@ -0,0 +1,35 @@ +using UnityEngine;
+
+public class DynamicBoneColliderBase : MonoBehaviour
+{
+ public enum Direction
+ {
+ X, Y, Z
+ }
+
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("The axis of the capsule's height.")]
+#endif
+ public Direction m_Direction = Direction.Y;
+
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("The center of the sphere or capsule, in the object's local space.")]
+#endif
+ public Vector3 m_Center = Vector3.zero;
+
+ public enum Bound
+ {
+ Outside,
+ Inside
+ }
+
+#if UNITY_5_3_OR_NEWER
+ [Tooltip("Constrain bones to outside bound or inside bound.")]
+#endif
+ public Bound m_Bound = Bound.Outside;
+
+ public virtual bool Collide(ref Vector3 particlePosition, float particleRadius)
+ {
+ return false;
+ }
+}
diff --git a/Assets/ThirdParty/DynamicBone/Scripts/DynamicBoneColliderBase.cs.meta b/Assets/ThirdParty/DynamicBone/Scripts/DynamicBoneColliderBase.cs.meta new file mode 100644 index 00000000..edc8b9f6 --- /dev/null +++ b/Assets/ThirdParty/DynamicBone/Scripts/DynamicBoneColliderBase.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 04878769c08021a41bc2d2375e23ec0b +timeCreated: 1482666371 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThirdParty/DynamicBone/Scripts/DynamicBonePlaneCollider.cs b/Assets/ThirdParty/DynamicBone/Scripts/DynamicBonePlaneCollider.cs new file mode 100644 index 00000000..7265d26a --- /dev/null +++ b/Assets/ThirdParty/DynamicBone/Scripts/DynamicBonePlaneCollider.cs @@ -0,0 +1,76 @@ +using UnityEngine;
+
+[AddComponentMenu("Dynamic Bone/Dynamic Bone Plane Collider")]
+public class DynamicBonePlaneCollider : DynamicBoneColliderBase
+{
+ void OnValidate()
+ {
+ }
+
+ public override bool Collide(ref Vector3 particlePosition, float particleRadius)
+ {
+ Vector3 normal = Vector3.up;
+ switch (m_Direction)
+ {
+ case Direction.X:
+ normal = transform.right;
+ break;
+ case Direction.Y:
+ normal = transform.up;
+ break;
+ case Direction.Z:
+ normal = transform.forward;
+ break;
+ }
+
+ Vector3 p = transform.TransformPoint(m_Center);
+ Plane plane = new Plane(normal, p);
+ float d = plane.GetDistanceToPoint(particlePosition);
+
+ if (m_Bound == Bound.Outside)
+ {
+ if (d < 0)
+ {
+ particlePosition -= normal * d;
+ return true;
+ }
+ }
+ else
+ {
+ if (d > 0)
+ {
+ particlePosition -= normal * d;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ void OnDrawGizmosSelected()
+ {
+ if (!enabled)
+ return;
+
+ if (m_Bound == Bound.Outside)
+ Gizmos.color = Color.yellow;
+ else
+ Gizmos.color = Color.magenta;
+
+ Vector3 normal = Vector3.up;
+ switch (m_Direction)
+ {
+ case Direction.X:
+ normal = transform.right;
+ break;
+ case Direction.Y:
+ normal = transform.up;
+ break;
+ case Direction.Z:
+ normal = transform.forward;
+ break;
+ }
+
+ Vector3 p = transform.TransformPoint(m_Center);
+ Gizmos.DrawLine(p, p + normal);
+ }
+}
diff --git a/Assets/ThirdParty/DynamicBone/Scripts/DynamicBonePlaneCollider.cs.meta b/Assets/ThirdParty/DynamicBone/Scripts/DynamicBonePlaneCollider.cs.meta new file mode 100644 index 00000000..4978da8e --- /dev/null +++ b/Assets/ThirdParty/DynamicBone/Scripts/DynamicBonePlaneCollider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4e535bdf3689369408cc4d078260ef6a +timeCreated: 1482666461 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |