├── .gitignore ├── Assets ├── Packages.meta ├── Packages │ ├── MeshSmoothing.meta │ ├── MeshSmoothing │ │ ├── Demo.meta │ │ ├── Demo │ │ │ ├── Demo.cs │ │ │ ├── Demo.cs.meta │ │ │ ├── Demo.unity │ │ │ ├── Demo.unity.meta │ │ │ ├── Materials.meta │ │ │ ├── Materials │ │ │ │ ├── defaultMat.mat │ │ │ │ └── defaultMat.mat.meta │ │ │ ├── sphere.obj │ │ │ └── sphere.obj.meta │ │ ├── Scripts.meta │ │ └── Scripts │ │ │ ├── MeshSmoothing.cs │ │ │ ├── MeshSmoothing.cs.meta │ │ │ ├── VertexConnection.cs │ │ │ └── VertexConnection.cs.meta │ ├── Triangulation2D.meta │ └── Triangulation2D │ │ ├── Demo.meta │ │ ├── Demo │ │ ├── Demo.cs │ │ ├── Demo.cs.meta │ │ ├── Demo.unity │ │ ├── Demo.unity.meta │ │ ├── Materials.meta │ │ ├── Materials │ │ │ ├── CanvasLine.mat │ │ │ ├── CanvasLine.mat.meta │ │ │ ├── DemoMesh.mat │ │ │ ├── DemoMesh.mat.meta │ │ │ ├── DemoMeshLine.mat │ │ │ └── DemoMeshLine.mat.meta │ │ ├── Prefabs.meta │ │ ├── Prefabs │ │ │ ├── DemoMesh.prefab │ │ │ └── DemoMesh.prefab.meta │ │ ├── Scenes.meta │ │ ├── Scenes │ │ │ ├── Demo.unity │ │ │ └── Demo.unity.meta │ │ ├── Scripts.meta │ │ ├── Scripts │ │ │ ├── DemoMesh.cs │ │ │ ├── DemoMesh.cs.meta │ │ │ ├── LocalStorage.cs │ │ │ └── LocalStorage.cs.meta │ │ ├── Shaders.meta │ │ └── Shaders │ │ │ ├── DemoLine.shader │ │ │ ├── DemoLine.shader.meta │ │ │ ├── DemoMesh.shader │ │ │ ├── DemoMesh.shader.meta │ │ │ ├── SimplexNoise3D.cginc │ │ │ └── SimplexNoise3D.cginc.meta │ │ ├── Scripts.meta │ │ └── Scripts │ │ ├── Circle2D.cs │ │ ├── Circle2D.cs.meta │ │ ├── HalfEdge2D.cs │ │ ├── HalfEdge2D.cs.meta │ │ ├── Polygon2D.cs │ │ ├── Polygon2D.cs.meta │ │ ├── Segment2D.cs │ │ ├── Segment2D.cs.meta │ │ ├── Triangle2D.cs │ │ ├── Triangle2D.cs.meta │ │ ├── Triangulation2D.cs │ │ ├── Triangulation2D.cs.meta │ │ ├── Utils2D.cs │ │ ├── Utils2D.cs.meta │ │ ├── Vertex2D.cs │ │ └── Vertex2D.cs.meta ├── StreamingAssets.meta ├── StreamingAssets │ ├── duck.json │ ├── duck.json.meta │ ├── human.json │ ├── human.json.meta │ ├── points.json │ ├── points.json.meta │ ├── tako.json │ └── tako.json.meta ├── Teddy.meta └── Teddy │ ├── JSON.meta │ ├── JSON │ ├── duck.json │ └── duck.json.meta │ ├── Materials.meta │ ├── Materials │ ├── DebugChordLine.mat │ ├── DebugChordLine.mat.meta │ ├── DebugNormal.mat │ ├── DebugNormal.mat.meta │ ├── Puppet.mat │ ├── Puppet.mat.meta │ ├── Teddy.mat │ ├── Teddy.mat.meta │ ├── TeddyDebug.mat │ └── TeddyDebug.mat.meta │ ├── Prefabs.meta │ ├── Prefabs │ ├── Puppet.prefab │ └── Puppet.prefab.meta │ ├── Scenes.meta │ ├── Scenes │ ├── Demo.unity │ ├── Demo.unity.meta │ ├── Drawer.unity │ └── Drawer.unity.meta │ ├── Scripts.meta │ ├── Scripts │ ├── Demo.cs │ ├── Demo.cs.meta │ ├── Drawer.cs │ ├── Drawer.cs.meta │ ├── Editor.meta │ ├── Editor │ │ ├── DrawerEditor.cs │ │ └── DrawerEditor.cs.meta │ ├── Puppet.cs │ ├── Puppet.cs.meta │ ├── Teddy.meta │ └── Teddy │ │ ├── Chord2D.cs │ │ ├── Chord2D.cs.meta │ │ ├── Connection2D.cs │ │ ├── Connection2D.cs.meta │ │ ├── Face2D.cs │ │ ├── Face2D.cs.meta │ │ ├── Teddy.cs │ │ ├── Teddy.cs.meta │ │ ├── VertexNetwork2D.cs │ │ └── VertexNetwork2D.cs.meta │ ├── Shaders.meta │ ├── Shaders │ ├── Common.meta │ ├── Common │ │ ├── SimplexNoise3D.cginc │ │ └── SimplexNoise3D.cginc.meta │ ├── DebugChordLine.shader │ ├── DebugChordLine.shader.meta │ ├── DebugNormal.shader │ ├── DebugNormal.shader.meta │ ├── Puppet.shader │ ├── Puppet.shader.meta │ ├── Teddy.shader │ ├── Teddy.shader.meta │ ├── TeddyDebug.shader │ └── TeddyDebug.shader.meta │ ├── Textures.meta │ └── Textures │ ├── toon.png │ └── toon.png.meta ├── Captures ├── Demo.gif └── Demo.png ├── LICENSE ├── Packages └── manifest.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | [Pp]rojectSettings/ 6 | Papers/ 7 | .vs/ 8 | 9 | # Autogenerated VS/MD solution and project files 10 | *.csproj 11 | *.unityproj 12 | *.sln 13 | *.suo 14 | *.user 15 | *.userprefs 16 | *.pidb 17 | *.booproj 18 | 19 | # Unity3D Generated File On Crash Reports 20 | sysinfo.txt -------------------------------------------------------------------------------- /Assets/Packages.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 95a092943260541dbb5e61ee961f7dac 3 | folderAsset: yes 4 | timeCreated: 1465912480 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/MeshSmoothing.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ba88ea9ce22d45c7bf1b79d4a06616b 3 | folderAsset: yes 4 | timeCreated: 1468326009 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/MeshSmoothing/Demo.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 93b34bb29459b4d09baf524882707dff 3 | folderAsset: yes 4 | timeCreated: 1468230381 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/MeshSmoothing/Demo/Demo.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace mattatz.MeshSmoothingSystem.Demo { 5 | 6 | [RequireComponent (typeof(MeshRenderer))] 7 | [RequireComponent (typeof(MeshFilter))] 8 | public class Demo : MonoBehaviour { 9 | 10 | [System.Serializable] 11 | enum FilterType { 12 | Laplacian, HC 13 | }; 14 | 15 | MeshFilter filter { 16 | get { 17 | if(_filter == null) { 18 | _filter = GetComponent(); 19 | } 20 | return _filter; 21 | } 22 | } 23 | 24 | MeshFilter _filter; 25 | 26 | [SerializeField, Range(0f, 1f)] float intensity = 0.5f; 27 | [SerializeField] FilterType type; 28 | [SerializeField, Range(0, 20)] int times = 3; 29 | [SerializeField, Range(0f, 1f)] float hcAlpha = 0.5f; 30 | [SerializeField, Range(0f, 1f)] float hcBeta = 0.5f; 31 | 32 | void Start () { 33 | var mesh = filter.mesh; 34 | filter.mesh = ApplyNormalNoise(mesh); 35 | 36 | switch(type) { 37 | case FilterType.Laplacian: 38 | filter.mesh = MeshSmoothing.LaplacianFilter(filter.mesh, times); 39 | break; 40 | case FilterType.HC: 41 | filter.mesh = MeshSmoothing.HCFilter(filter.mesh, times, hcAlpha, hcBeta); 42 | break; 43 | } 44 | } 45 | 46 | // void Update () {} 47 | 48 | Mesh ApplyNormalNoise (Mesh mesh) { 49 | 50 | var vertices = mesh.vertices; 51 | var normals = mesh.normals; 52 | for(int i = 0, n = mesh.vertexCount; i < n; i++) { 53 | vertices[i] = vertices[i] + normals[i] * Random.value * intensity; 54 | } 55 | mesh.vertices = vertices; 56 | 57 | return mesh; 58 | } 59 | 60 | } 61 | 62 | } 63 | 64 | -------------------------------------------------------------------------------- /Assets/Packages/MeshSmoothing/Demo/Demo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 67cb55801a0d044f98b0d6053d71696c 3 | timeCreated: 1468230458 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/MeshSmoothing/Demo/Demo.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 9 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &3 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 11 47 | m_GIWorkflowMode: 0 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_TemporalCoherenceThreshold: 1 54 | m_EnvironmentLightingMode: 0 55 | m_EnableBakedLightmaps: 1 56 | m_EnableRealtimeLightmaps: 1 57 | m_LightmapEditorSettings: 58 | serializedVersion: 10 59 | m_Resolution: 2 60 | m_BakeResolution: 40 61 | m_AtlasSize: 1024 62 | m_AO: 0 63 | m_AOMaxDistance: 1 64 | m_CompAOExponent: 0 65 | m_CompAOExponentDirect: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 1024 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 1 75 | m_BakeBackend: 0 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 500 79 | m_PVRBounces: 2 80 | m_PVRFilterTypeDirect: 0 81 | m_PVRFilterTypeIndirect: 0 82 | m_PVRFilterTypeAO: 0 83 | m_PVRFilteringMode: 0 84 | m_PVRCulling: 1 85 | m_PVRFilteringGaussRadiusDirect: 1 86 | m_PVRFilteringGaussRadiusIndirect: 5 87 | m_PVRFilteringGaussRadiusAO: 2 88 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 89 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 90 | m_PVRFilteringAtrousPositionSigmaAO: 1 91 | m_ShowResolutionOverlay: 1 92 | m_LightingDataAsset: {fileID: 0} 93 | m_UseShadowmask: 0 94 | --- !u!196 &4 95 | NavMeshSettings: 96 | serializedVersion: 2 97 | m_ObjectHideFlags: 0 98 | m_BuildSettings: 99 | serializedVersion: 2 100 | agentTypeID: 0 101 | agentRadius: 0.5 102 | agentHeight: 2 103 | agentSlope: 45 104 | agentClimb: 0.4 105 | ledgeDropHeight: 0 106 | maxJumpAcrossDistance: 0 107 | minRegionArea: 2 108 | manualCellSize: 0 109 | cellSize: 0.16666667 110 | manualTileSize: 0 111 | tileSize: 256 112 | accuratePlacement: 0 113 | debug: 114 | m_Flags: 0 115 | m_NavMeshData: {fileID: 0} 116 | --- !u!1 &11316679 117 | GameObject: 118 | m_ObjectHideFlags: 0 119 | m_CorrespondingSourceObject: {fileID: 0} 120 | m_PrefabInternal: {fileID: 0} 121 | serializedVersion: 6 122 | m_Component: 123 | - component: {fileID: 11316681} 124 | - component: {fileID: 11316680} 125 | m_Layer: 0 126 | m_Name: Directional Light 127 | m_TagString: Untagged 128 | m_Icon: {fileID: 0} 129 | m_NavMeshLayer: 0 130 | m_StaticEditorFlags: 0 131 | m_IsActive: 1 132 | --- !u!108 &11316680 133 | Light: 134 | m_ObjectHideFlags: 0 135 | m_CorrespondingSourceObject: {fileID: 0} 136 | m_PrefabInternal: {fileID: 0} 137 | m_GameObject: {fileID: 11316679} 138 | m_Enabled: 1 139 | serializedVersion: 8 140 | m_Type: 1 141 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} 142 | m_Intensity: 1 143 | m_Range: 10 144 | m_SpotAngle: 30 145 | m_CookieSize: 10 146 | m_Shadows: 147 | m_Type: 2 148 | m_Resolution: -1 149 | m_CustomResolution: -1 150 | m_Strength: 1 151 | m_Bias: 0.05 152 | m_NormalBias: 0.4 153 | m_NearPlane: 0.2 154 | m_Cookie: {fileID: 0} 155 | m_DrawHalo: 0 156 | m_Flare: {fileID: 0} 157 | m_RenderMode: 0 158 | m_CullingMask: 159 | serializedVersion: 2 160 | m_Bits: 4294967295 161 | m_Lightmapping: 4 162 | m_LightShadowCasterMode: 0 163 | m_AreaSize: {x: 1, y: 1} 164 | m_BounceIntensity: 1 165 | m_ColorTemperature: 6570 166 | m_UseColorTemperature: 0 167 | m_ShadowRadius: 0 168 | m_ShadowAngle: 0 169 | --- !u!4 &11316681 170 | Transform: 171 | m_ObjectHideFlags: 0 172 | m_CorrespondingSourceObject: {fileID: 0} 173 | m_PrefabInternal: {fileID: 0} 174 | m_GameObject: {fileID: 11316679} 175 | m_LocalRotation: {x: 0.40821794, y: -0.23456973, z: 0.109381676, w: 0.87542605} 176 | m_LocalPosition: {x: 0, y: 3, z: 0} 177 | m_LocalScale: {x: 1, y: 1, z: 1} 178 | m_Children: [] 179 | m_Father: {fileID: 0} 180 | m_RootOrder: 1 181 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} 182 | --- !u!1 &17921022 183 | GameObject: 184 | m_ObjectHideFlags: 0 185 | m_CorrespondingSourceObject: {fileID: 100000, guid: b764289b0e7ce42ae84632dcad5d680c, 186 | type: 3} 187 | m_PrefabInternal: {fileID: 0} 188 | serializedVersion: 6 189 | m_Component: 190 | - component: {fileID: 17921026} 191 | - component: {fileID: 17921025} 192 | - component: {fileID: 17921024} 193 | - component: {fileID: 17921023} 194 | m_Layer: 0 195 | m_Name: HCFilter 196 | m_TagString: Untagged 197 | m_Icon: {fileID: 0} 198 | m_NavMeshLayer: 0 199 | m_StaticEditorFlags: 0 200 | m_IsActive: 1 201 | --- !u!114 &17921023 202 | MonoBehaviour: 203 | m_ObjectHideFlags: 0 204 | m_CorrespondingSourceObject: {fileID: 0} 205 | m_PrefabInternal: {fileID: 0} 206 | m_GameObject: {fileID: 17921022} 207 | m_Enabled: 1 208 | m_EditorHideFlags: 0 209 | m_Script: {fileID: 11500000, guid: 67cb55801a0d044f98b0d6053d71696c, type: 3} 210 | m_Name: 211 | m_EditorClassIdentifier: 212 | intensity: 0.25 213 | type: 1 214 | times: 10 215 | hcAlpha: 0.7 216 | hcBeta: 0.16 217 | --- !u!23 &17921024 218 | MeshRenderer: 219 | m_ObjectHideFlags: 0 220 | m_CorrespondingSourceObject: {fileID: 2300000, guid: b764289b0e7ce42ae84632dcad5d680c, 221 | type: 3} 222 | m_PrefabInternal: {fileID: 0} 223 | m_GameObject: {fileID: 17921022} 224 | m_Enabled: 1 225 | m_CastShadows: 1 226 | m_ReceiveShadows: 1 227 | m_DynamicOccludee: 1 228 | m_MotionVectors: 1 229 | m_LightProbeUsage: 1 230 | m_ReflectionProbeUsage: 1 231 | m_RenderingLayerMask: 4294967295 232 | m_Materials: 233 | - {fileID: 2100000, guid: 166b1183aadfd41f393aa308ab2dd2d1, type: 2} 234 | m_StaticBatchInfo: 235 | firstSubMesh: 0 236 | subMeshCount: 0 237 | m_StaticBatchRoot: {fileID: 0} 238 | m_ProbeAnchor: {fileID: 0} 239 | m_LightProbeVolumeOverride: {fileID: 0} 240 | m_ScaleInLightmap: 1 241 | m_PreserveUVs: 0 242 | m_IgnoreNormalsForChartDetection: 0 243 | m_ImportantGI: 0 244 | m_StitchLightmapSeams: 0 245 | m_SelectedEditorRenderState: 3 246 | m_MinimumChartSize: 4 247 | m_AutoUVMaxDistance: 0.5 248 | m_AutoUVMaxAngle: 89 249 | m_LightmapParameters: {fileID: 0} 250 | m_SortingLayerID: 0 251 | m_SortingLayer: 0 252 | m_SortingOrder: 0 253 | --- !u!33 &17921025 254 | MeshFilter: 255 | m_ObjectHideFlags: 0 256 | m_CorrespondingSourceObject: {fileID: 3300000, guid: b764289b0e7ce42ae84632dcad5d680c, 257 | type: 3} 258 | m_PrefabInternal: {fileID: 0} 259 | m_GameObject: {fileID: 17921022} 260 | m_Mesh: {fileID: 4300000, guid: b764289b0e7ce42ae84632dcad5d680c, type: 3} 261 | --- !u!4 &17921026 262 | Transform: 263 | m_ObjectHideFlags: 0 264 | m_CorrespondingSourceObject: {fileID: 400000, guid: b764289b0e7ce42ae84632dcad5d680c, 265 | type: 3} 266 | m_PrefabInternal: {fileID: 0} 267 | m_GameObject: {fileID: 17921022} 268 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 269 | m_LocalPosition: {x: 5, y: 0, z: 0} 270 | m_LocalScale: {x: 1.5, y: 1.5, z: 1.5} 271 | m_Children: [] 272 | m_Father: {fileID: 0} 273 | m_RootOrder: 4 274 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 275 | --- !u!1 &1119960215 276 | GameObject: 277 | m_ObjectHideFlags: 0 278 | m_CorrespondingSourceObject: {fileID: 0} 279 | m_PrefabInternal: {fileID: 0} 280 | serializedVersion: 6 281 | m_Component: 282 | - component: {fileID: 1119960220} 283 | - component: {fileID: 1119960219} 284 | - component: {fileID: 1119960218} 285 | - component: {fileID: 1119960217} 286 | - component: {fileID: 1119960216} 287 | m_Layer: 0 288 | m_Name: Main Camera 289 | m_TagString: MainCamera 290 | m_Icon: {fileID: 0} 291 | m_NavMeshLayer: 0 292 | m_StaticEditorFlags: 0 293 | m_IsActive: 1 294 | --- !u!81 &1119960216 295 | AudioListener: 296 | m_ObjectHideFlags: 0 297 | m_CorrespondingSourceObject: {fileID: 0} 298 | m_PrefabInternal: {fileID: 0} 299 | m_GameObject: {fileID: 1119960215} 300 | m_Enabled: 1 301 | --- !u!124 &1119960217 302 | Behaviour: 303 | m_ObjectHideFlags: 0 304 | m_CorrespondingSourceObject: {fileID: 0} 305 | m_PrefabInternal: {fileID: 0} 306 | m_GameObject: {fileID: 1119960215} 307 | m_Enabled: 1 308 | --- !u!92 &1119960218 309 | Behaviour: 310 | m_ObjectHideFlags: 0 311 | m_CorrespondingSourceObject: {fileID: 0} 312 | m_PrefabInternal: {fileID: 0} 313 | m_GameObject: {fileID: 1119960215} 314 | m_Enabled: 1 315 | --- !u!20 &1119960219 316 | Camera: 317 | m_ObjectHideFlags: 0 318 | m_CorrespondingSourceObject: {fileID: 0} 319 | m_PrefabInternal: {fileID: 0} 320 | m_GameObject: {fileID: 1119960215} 321 | m_Enabled: 1 322 | serializedVersion: 2 323 | m_ClearFlags: 1 324 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0.019607844} 325 | m_projectionMatrixMode: 1 326 | m_SensorSize: {x: 36, y: 24} 327 | m_LensShift: {x: 0, y: 0} 328 | m_FocalLength: 50 329 | m_NormalizedViewPortRect: 330 | serializedVersion: 2 331 | x: 0 332 | y: 0 333 | width: 1 334 | height: 1 335 | near clip plane: 0.3 336 | far clip plane: 1000 337 | field of view: 60 338 | orthographic: 1 339 | orthographic size: 5 340 | m_Depth: -1 341 | m_CullingMask: 342 | serializedVersion: 2 343 | m_Bits: 4294967295 344 | m_RenderingPath: -1 345 | m_TargetTexture: {fileID: 0} 346 | m_TargetDisplay: 0 347 | m_TargetEye: 3 348 | m_HDR: 0 349 | m_AllowMSAA: 1 350 | m_AllowDynamicResolution: 0 351 | m_ForceIntoRT: 0 352 | m_OcclusionCulling: 1 353 | m_StereoConvergence: 10 354 | m_StereoSeparation: 0.022 355 | --- !u!4 &1119960220 356 | Transform: 357 | m_ObjectHideFlags: 0 358 | m_CorrespondingSourceObject: {fileID: 0} 359 | m_PrefabInternal: {fileID: 0} 360 | m_GameObject: {fileID: 1119960215} 361 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 362 | m_LocalPosition: {x: 0, y: 0, z: -10} 363 | m_LocalScale: {x: 1, y: 1, z: 1} 364 | m_Children: [] 365 | m_Father: {fileID: 0} 366 | m_RootOrder: 0 367 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 368 | --- !u!1 &1460711494 369 | GameObject: 370 | m_ObjectHideFlags: 0 371 | m_CorrespondingSourceObject: {fileID: 100000, guid: b764289b0e7ce42ae84632dcad5d680c, 372 | type: 3} 373 | m_PrefabInternal: {fileID: 0} 374 | serializedVersion: 6 375 | m_Component: 376 | - component: {fileID: 1460711498} 377 | - component: {fileID: 1460711497} 378 | - component: {fileID: 1460711496} 379 | - component: {fileID: 1460711495} 380 | m_Layer: 0 381 | m_Name: Origin 382 | m_TagString: Untagged 383 | m_Icon: {fileID: 0} 384 | m_NavMeshLayer: 0 385 | m_StaticEditorFlags: 0 386 | m_IsActive: 1 387 | --- !u!114 &1460711495 388 | MonoBehaviour: 389 | m_ObjectHideFlags: 0 390 | m_CorrespondingSourceObject: {fileID: 0} 391 | m_PrefabInternal: {fileID: 0} 392 | m_GameObject: {fileID: 1460711494} 393 | m_Enabled: 1 394 | m_EditorHideFlags: 0 395 | m_Script: {fileID: 11500000, guid: 67cb55801a0d044f98b0d6053d71696c, type: 3} 396 | m_Name: 397 | m_EditorClassIdentifier: 398 | intensity: 0.25 399 | type: 0 400 | times: 0 401 | hcAlpha: 0.5 402 | hcBeta: 0.5 403 | --- !u!23 &1460711496 404 | MeshRenderer: 405 | m_ObjectHideFlags: 0 406 | m_CorrespondingSourceObject: {fileID: 2300000, guid: b764289b0e7ce42ae84632dcad5d680c, 407 | type: 3} 408 | m_PrefabInternal: {fileID: 0} 409 | m_GameObject: {fileID: 1460711494} 410 | m_Enabled: 1 411 | m_CastShadows: 1 412 | m_ReceiveShadows: 1 413 | m_DynamicOccludee: 1 414 | m_MotionVectors: 1 415 | m_LightProbeUsage: 1 416 | m_ReflectionProbeUsage: 1 417 | m_RenderingLayerMask: 4294967295 418 | m_Materials: 419 | - {fileID: 2100000, guid: 166b1183aadfd41f393aa308ab2dd2d1, type: 2} 420 | m_StaticBatchInfo: 421 | firstSubMesh: 0 422 | subMeshCount: 0 423 | m_StaticBatchRoot: {fileID: 0} 424 | m_ProbeAnchor: {fileID: 0} 425 | m_LightProbeVolumeOverride: {fileID: 0} 426 | m_ScaleInLightmap: 1 427 | m_PreserveUVs: 0 428 | m_IgnoreNormalsForChartDetection: 0 429 | m_ImportantGI: 0 430 | m_StitchLightmapSeams: 0 431 | m_SelectedEditorRenderState: 3 432 | m_MinimumChartSize: 4 433 | m_AutoUVMaxDistance: 0.5 434 | m_AutoUVMaxAngle: 89 435 | m_LightmapParameters: {fileID: 0} 436 | m_SortingLayerID: 0 437 | m_SortingLayer: 0 438 | m_SortingOrder: 0 439 | --- !u!33 &1460711497 440 | MeshFilter: 441 | m_ObjectHideFlags: 0 442 | m_CorrespondingSourceObject: {fileID: 3300000, guid: b764289b0e7ce42ae84632dcad5d680c, 443 | type: 3} 444 | m_PrefabInternal: {fileID: 0} 445 | m_GameObject: {fileID: 1460711494} 446 | m_Mesh: {fileID: 4300000, guid: b764289b0e7ce42ae84632dcad5d680c, type: 3} 447 | --- !u!4 &1460711498 448 | Transform: 449 | m_ObjectHideFlags: 0 450 | m_CorrespondingSourceObject: {fileID: 400000, guid: b764289b0e7ce42ae84632dcad5d680c, 451 | type: 3} 452 | m_PrefabInternal: {fileID: 0} 453 | m_GameObject: {fileID: 1460711494} 454 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 455 | m_LocalPosition: {x: -5, y: 0, z: 0} 456 | m_LocalScale: {x: 1.5, y: 1.5, z: 1.5} 457 | m_Children: [] 458 | m_Father: {fileID: 0} 459 | m_RootOrder: 2 460 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 461 | --- !u!1 &2063555839 462 | GameObject: 463 | m_ObjectHideFlags: 0 464 | m_CorrespondingSourceObject: {fileID: 100000, guid: b764289b0e7ce42ae84632dcad5d680c, 465 | type: 3} 466 | m_PrefabInternal: {fileID: 0} 467 | serializedVersion: 6 468 | m_Component: 469 | - component: {fileID: 2063555840} 470 | - component: {fileID: 2063555842} 471 | - component: {fileID: 2063555841} 472 | - component: {fileID: 2063555843} 473 | m_Layer: 0 474 | m_Name: LaplacianFilter 475 | m_TagString: Untagged 476 | m_Icon: {fileID: 0} 477 | m_NavMeshLayer: 0 478 | m_StaticEditorFlags: 0 479 | m_IsActive: 1 480 | --- !u!4 &2063555840 481 | Transform: 482 | m_ObjectHideFlags: 0 483 | m_CorrespondingSourceObject: {fileID: 400000, guid: b764289b0e7ce42ae84632dcad5d680c, 484 | type: 3} 485 | m_PrefabInternal: {fileID: 0} 486 | m_GameObject: {fileID: 2063555839} 487 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 488 | m_LocalPosition: {x: 0, y: 0, z: 0} 489 | m_LocalScale: {x: 1.5, y: 1.5, z: 1.5} 490 | m_Children: [] 491 | m_Father: {fileID: 0} 492 | m_RootOrder: 3 493 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 494 | --- !u!23 &2063555841 495 | MeshRenderer: 496 | m_ObjectHideFlags: 0 497 | m_CorrespondingSourceObject: {fileID: 2300000, guid: b764289b0e7ce42ae84632dcad5d680c, 498 | type: 3} 499 | m_PrefabInternal: {fileID: 0} 500 | m_GameObject: {fileID: 2063555839} 501 | m_Enabled: 1 502 | m_CastShadows: 1 503 | m_ReceiveShadows: 1 504 | m_DynamicOccludee: 1 505 | m_MotionVectors: 1 506 | m_LightProbeUsage: 1 507 | m_ReflectionProbeUsage: 1 508 | m_RenderingLayerMask: 4294967295 509 | m_Materials: 510 | - {fileID: 2100000, guid: 166b1183aadfd41f393aa308ab2dd2d1, type: 2} 511 | m_StaticBatchInfo: 512 | firstSubMesh: 0 513 | subMeshCount: 0 514 | m_StaticBatchRoot: {fileID: 0} 515 | m_ProbeAnchor: {fileID: 0} 516 | m_LightProbeVolumeOverride: {fileID: 0} 517 | m_ScaleInLightmap: 1 518 | m_PreserveUVs: 0 519 | m_IgnoreNormalsForChartDetection: 0 520 | m_ImportantGI: 0 521 | m_StitchLightmapSeams: 0 522 | m_SelectedEditorRenderState: 3 523 | m_MinimumChartSize: 4 524 | m_AutoUVMaxDistance: 0.5 525 | m_AutoUVMaxAngle: 89 526 | m_LightmapParameters: {fileID: 0} 527 | m_SortingLayerID: 0 528 | m_SortingLayer: 0 529 | m_SortingOrder: 0 530 | --- !u!33 &2063555842 531 | MeshFilter: 532 | m_ObjectHideFlags: 0 533 | m_CorrespondingSourceObject: {fileID: 3300000, guid: b764289b0e7ce42ae84632dcad5d680c, 534 | type: 3} 535 | m_PrefabInternal: {fileID: 0} 536 | m_GameObject: {fileID: 2063555839} 537 | m_Mesh: {fileID: 4300000, guid: b764289b0e7ce42ae84632dcad5d680c, type: 3} 538 | --- !u!114 &2063555843 539 | MonoBehaviour: 540 | m_ObjectHideFlags: 0 541 | m_CorrespondingSourceObject: {fileID: 0} 542 | m_PrefabInternal: {fileID: 0} 543 | m_GameObject: {fileID: 2063555839} 544 | m_Enabled: 1 545 | m_EditorHideFlags: 0 546 | m_Script: {fileID: 11500000, guid: 67cb55801a0d044f98b0d6053d71696c, type: 3} 547 | m_Name: 548 | m_EditorClassIdentifier: 549 | intensity: 0.25 550 | type: 0 551 | times: 10 552 | hcAlpha: 0.5 553 | hcBeta: 0.5 554 | -------------------------------------------------------------------------------- /Assets/Packages/MeshSmoothing/Demo/Demo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 61cf55a91cbcb4a5aa09dc3cec8b6d2d 3 | timeCreated: 1468230434 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/MeshSmoothing/Demo/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ed3c0d1b6d0ad44db8f491dd8e622af2 3 | folderAsset: yes 4 | timeCreated: 1468241176 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/MeshSmoothing/Demo/Materials/defaultMat.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: defaultMat 10 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 5 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _Glossiness: 0.5 63 | - _Metallic: 0 64 | - _Mode: 0 65 | - _OcclusionStrength: 1 66 | - _Parallax: 0.02 67 | - _SrcBlend: 1 68 | - _UVSec: 0 69 | - _ZWrite: 1 70 | m_Colors: 71 | - _Color: {r: 0.8, g: 0.8, b: 0.8, a: 1} 72 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 73 | -------------------------------------------------------------------------------- /Assets/Packages/MeshSmoothing/Demo/Materials/defaultMat.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 166b1183aadfd41f393aa308ab2dd2d1 3 | timeCreated: 1468241176 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/MeshSmoothing/Demo/sphere.obj.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b764289b0e7ce42ae84632dcad5d680c 3 | ModelImporter: 4 | serializedVersion: 23 5 | fileIDToRecycleName: 6 | 100000: default 7 | 100002: //RootNode 8 | 400000: default 9 | 400002: //RootNode 10 | 2300000: default 11 | 3300000: default 12 | 4300000: default 13 | 2186277476908879412: ImportLogs 14 | externalObjects: 15 | - first: 16 | type: UnityEngine:Material 17 | assembly: UnityEngine.CoreModule 18 | name: defaultMat 19 | second: {fileID: 2100000, guid: 166b1183aadfd41f393aa308ab2dd2d1, type: 2} 20 | materials: 21 | importMaterials: 1 22 | materialName: 0 23 | materialSearch: 1 24 | materialLocation: 0 25 | animations: 26 | legacyGenerateAnimations: 4 27 | bakeSimulation: 0 28 | resampleCurves: 1 29 | optimizeGameObjects: 0 30 | motionNodeName: 31 | rigImportErrors: 32 | rigImportWarnings: 33 | animationImportErrors: 34 | animationImportWarnings: 35 | animationRetargetingWarnings: 36 | animationDoRetargetingWarnings: 0 37 | importAnimatedCustomProperties: 0 38 | importConstraints: 0 39 | animationCompression: 1 40 | animationRotationError: 0.5 41 | animationPositionError: 0.5 42 | animationScaleError: 0.5 43 | animationWrapMode: 0 44 | extraExposedTransformPaths: [] 45 | extraUserProperties: [] 46 | clipAnimations: [] 47 | isReadable: 1 48 | meshes: 49 | lODScreenPercentages: [] 50 | globalScale: 1 51 | meshCompression: 0 52 | addColliders: 0 53 | importVisibility: 0 54 | importBlendShapes: 1 55 | importCameras: 0 56 | importLights: 0 57 | swapUVChannels: 0 58 | generateSecondaryUV: 0 59 | useFileUnits: 1 60 | optimizeMeshForGPU: 1 61 | keepQuads: 0 62 | weldVertices: 1 63 | preserveHierarchy: 0 64 | indexFormat: 1 65 | secondaryUVAngleDistortion: 8 66 | secondaryUVAreaDistortion: 15.000001 67 | secondaryUVHardAngle: 88 68 | secondaryUVPackMargin: 4 69 | useFileScale: 1 70 | previousCalculatedGlobalScale: 1 71 | hasPreviousCalculatedGlobalScale: 0 72 | tangentSpace: 73 | normalSmoothAngle: 60 74 | normalImportMode: 0 75 | tangentImportMode: 3 76 | normalCalculationMode: 0 77 | importAnimation: 1 78 | copyAvatar: 0 79 | humanDescription: 80 | serializedVersion: 2 81 | human: [] 82 | skeleton: [] 83 | armTwist: 0.5 84 | foreArmTwist: 0.5 85 | upperLegTwist: 0.5 86 | legTwist: 0.5 87 | armStretch: 0.05 88 | legStretch: 0.05 89 | feetSpacing: 0 90 | rootMotionBoneName: 91 | rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} 92 | hasTranslationDoF: 0 93 | hasExtraRoot: 0 94 | skeletonHasParents: 0 95 | lastHumanDescriptionAvatarSource: {instanceID: 0} 96 | animationType: 0 97 | humanoidOversampling: 1 98 | additionalBone: 0 99 | userData: 100 | assetBundleName: 101 | assetBundleVariant: 102 | -------------------------------------------------------------------------------- /Assets/Packages/MeshSmoothing/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f171e8ec7e984114b0e98e87175bcfd 3 | folderAsset: yes 4 | timeCreated: 1468230377 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/MeshSmoothing/Scripts/MeshSmoothing.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * @author mattatz / http://mattatz.github.io 3 | 4 | * https://www.researchgate.net/publication/220507688_Improved_Laplacian_Smoothing_of_Noisy_Surface_Meshes 5 | * http://graphics.stanford.edu/courses/cs468-12-spring/LectureSlides/06_smoothing.pdf 6 | * http://wiki.unity3d.com/index.php?title=MeshSmoother 7 | */ 8 | 9 | using UnityEngine; 10 | 11 | using System; 12 | using System.Collections; 13 | using System.Collections.Generic; 14 | 15 | namespace mattatz.MeshSmoothingSystem { 16 | 17 | public class MeshSmoothing { 18 | 19 | public static Mesh LaplacianFilter (Mesh mesh, int times = 1) { 20 | mesh.vertices = LaplacianFilter(mesh.vertices, mesh.triangles, times); 21 | mesh.RecalculateNormals(); 22 | mesh.RecalculateBounds(); 23 | return mesh; 24 | } 25 | 26 | public static Vector3[] LaplacianFilter(Vector3[] vertices, int[] triangles, int times) { 27 | var network = VertexConnection.BuildNetwork(triangles); 28 | for(int i = 0; i < times; i++) { 29 | vertices = LaplacianFilter(network, vertices, triangles); 30 | } 31 | return vertices; 32 | } 33 | 34 | static Vector3[] LaplacianFilter(Dictionary network, Vector3[] origin, int[] triangles) { 35 | Vector3[] vertices = new Vector3[origin.Length]; 36 | for(int i = 0, n = origin.Length; i < n; i++) { 37 | if(network.ContainsKey(i)) { 38 | var connection = network[i].Connection; 39 | var v = Vector3.zero; 40 | foreach(int adj in connection) { 41 | v += origin[adj]; 42 | } 43 | vertices[i] = v / connection.Count; 44 | } else { 45 | vertices[i] = origin[i]; 46 | } 47 | } 48 | return vertices; 49 | } 50 | 51 | /* 52 | * HC (Humphrey’s Classes) Smooth Algorithm - Reduces Shrinkage of Laplacian Smoother 53 | * alpha 0.0 ~ 1.0 54 | * beta 0.0 ~ 1.0 55 | */ 56 | public static Mesh HCFilter (Mesh mesh, int times = 5, float alpha = 0.5f, float beta = 0.75f) { 57 | mesh.vertices = HCFilter(mesh.vertices, mesh.triangles, times, alpha, beta); 58 | mesh.RecalculateNormals(); 59 | mesh.RecalculateBounds(); 60 | return mesh; 61 | } 62 | 63 | static Vector3[] HCFilter(Vector3[] vertices, int[] triangles, int times, float alpha, float beta) { 64 | alpha = Mathf.Clamp01(alpha); 65 | beta = Mathf.Clamp01(beta); 66 | 67 | var network = VertexConnection.BuildNetwork(triangles); 68 | 69 | Vector3[] origin = new Vector3[vertices.Length]; 70 | Array.Copy(vertices, origin, vertices.Length); 71 | for(int i = 0; i < times; i++) { 72 | vertices = HCFilter(network, origin, vertices, triangles, alpha, beta); 73 | } 74 | return vertices; 75 | } 76 | 77 | public static Vector3[] HCFilter(Dictionary network, Vector3[] o, Vector3[] q, int[] triangles, float alpha, float beta) { 78 | Vector3[] p = LaplacianFilter(network, q, triangles); 79 | Vector3[] b = new Vector3[o.Length]; 80 | 81 | for(int i = 0; i < p.Length; i++) { 82 | b[i] = p[i] - (alpha * o[i] + (1f - alpha) * q[i]); 83 | } 84 | 85 | for(int i = 0; i < p.Length; i++) { 86 | if(network.ContainsKey(i)) { 87 | var adjacents = network[i].Connection; 88 | var bs = Vector3.zero; 89 | foreach(int adj in adjacents) { 90 | bs += b[adj]; 91 | } 92 | p[i] = p[i] - (beta * b[i] + (1 - beta) / adjacents.Count * bs); 93 | } else { 94 | p[i] = b[i]; 95 | } 96 | } 97 | 98 | return p; 99 | } 100 | 101 | } 102 | 103 | } 104 | 105 | -------------------------------------------------------------------------------- /Assets/Packages/MeshSmoothing/Scripts/MeshSmoothing.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 541ea36a587c640fdbe3f149e3c8b62f 3 | timeCreated: 1468230387 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/MeshSmoothing/Scripts/VertexConnection.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | namespace mattatz.MeshSmoothingSystem { 7 | 8 | public class VertexConnection { 9 | 10 | public HashSet Connection { get { return connection; } } 11 | 12 | HashSet connection; 13 | 14 | public VertexConnection() { 15 | this.connection = new HashSet(); 16 | } 17 | 18 | public void Connect (int to) { 19 | connection.Add(to); 20 | } 21 | 22 | public static Dictionary BuildNetwork (int[] triangles) { 23 | var table = new Dictionary(); 24 | 25 | for(int i = 0, n = triangles.Length; i < n; i += 3) { 26 | int a = triangles[i], b = triangles[i + 1], c = triangles[i + 2]; 27 | if(!table.ContainsKey(a)) { 28 | table.Add(a, new VertexConnection()); 29 | } 30 | if(!table.ContainsKey(b)) { 31 | table.Add(b, new VertexConnection()); 32 | } 33 | if(!table.ContainsKey(c)) { 34 | table.Add(c, new VertexConnection()); 35 | } 36 | table[a].Connect(b); table[a].Connect(c); 37 | table[b].Connect(a); table[b].Connect(c); 38 | table[c].Connect(a); table[c].Connect(b); 39 | } 40 | 41 | return table; 42 | } 43 | 44 | } 45 | 46 | } 47 | 48 | -------------------------------------------------------------------------------- /Assets/Packages/MeshSmoothing/Scripts/VertexConnection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a3f5c282d8f4f4f5b8855c41b9331635 3 | timeCreated: 1468230939 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 701d6dbf589ea4376b6b9f97ec9764d2 3 | folderAsset: yes 4 | timeCreated: 1465912489 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6d5eeb6844b10497092a5fac3e2ab776 3 | folderAsset: yes 4 | timeCreated: 1465912651 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Demo.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | #if UNITY_EDITOR 4 | using UnityEditor; 5 | #endif 6 | 7 | using System; 8 | using System.IO; 9 | using System.Linq; 10 | using System.Collections; 11 | using System.Collections.Generic; 12 | 13 | using mattatz.Utils; 14 | 15 | namespace mattatz.Triangulation2DSystem.Example { 16 | 17 | public class Demo : MonoBehaviour { 18 | 19 | [SerializeField, Range(10f, 30f)] float angle = 20f; 20 | [SerializeField, Range(0.2f, 2f)] float threshold = 1.5f; 21 | [SerializeField] GameObject prefab; 22 | [SerializeField] Material lineMat; 23 | [SerializeField] bool debug; 24 | 25 | List points; 26 | 27 | Camera cam; 28 | float depth = 0f; 29 | bool dragging; 30 | 31 | void Start () { 32 | cam = Camera.main; 33 | depth = Mathf.Abs(cam.transform.position.z - transform.position.z); 34 | points = new List(); 35 | 36 | if(debug) { 37 | points = LocalStorage.LoadList("points.json"); 38 | Build(); 39 | } 40 | } 41 | 42 | void Update () { 43 | if(Input.GetMouseButtonDown(0)) { 44 | dragging = true; 45 | Clear(); 46 | } else if(Input.GetMouseButtonUp(0)) { 47 | // LocalStorage.SaveList(points, "points.json"); 48 | 49 | dragging = false; 50 | Build(); 51 | } 52 | 53 | if(dragging) { 54 | var screen = Input.mousePosition; 55 | screen.z = depth; 56 | var p = cam.ScreenToWorldPoint(screen); 57 | var p2D = new Vector2(p.x, p.y); 58 | if(points.Count <= 0 || Vector2.Distance(p2D, points.Last()) > threshold) { 59 | points.Add(p2D); 60 | } 61 | } 62 | } 63 | 64 | void Build () { 65 | points = Utils2D.Constrain(points, threshold); 66 | var polygon = Polygon2D.Contour(points.ToArray()); 67 | 68 | var vertices = polygon.Vertices; 69 | if(vertices.Length < 3) return; // error 70 | 71 | var triangulation = new Triangulation2D(polygon, angle); 72 | var go = Instantiate(prefab); 73 | go.transform.SetParent(transform, false); 74 | go.GetComponent().SetTriangulation(triangulation); 75 | 76 | Clear(); 77 | } 78 | 79 | void Clear () { 80 | points.Clear(); 81 | } 82 | 83 | void OnRenderObject () { 84 | if(points != null) { 85 | GL.PushMatrix(); 86 | GL.MultMatrix (transform.localToWorldMatrix); 87 | lineMat.SetColor("_Color", Color.white); 88 | lineMat.SetPass(0); 89 | GL.Begin(GL.LINES); 90 | for(int i = 0, n = points.Count - 1; i < n; i++) { 91 | GL.Vertex(points[i]); GL.Vertex(points[i + 1]); 92 | } 93 | GL.End(); 94 | GL.PopMatrix(); 95 | } 96 | } 97 | 98 | void OnDrawGizmos () { 99 | } 100 | 101 | } 102 | 103 | } 104 | 105 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Demo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 77e8e35d5f324406abb67b63ec25336b 3 | timeCreated: 1466757756 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Demo.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 9 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &4 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 11 47 | m_GIWorkflowMode: 0 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_TemporalCoherenceThreshold: 1 54 | m_EnvironmentLightingMode: 0 55 | m_EnableBakedLightmaps: 1 56 | m_EnableRealtimeLightmaps: 1 57 | m_LightmapEditorSettings: 58 | serializedVersion: 10 59 | m_Resolution: 2 60 | m_BakeResolution: 40 61 | m_AtlasSize: 1024 62 | m_AO: 0 63 | m_AOMaxDistance: 1 64 | m_CompAOExponent: 0 65 | m_CompAOExponentDirect: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 1024 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 1 75 | m_BakeBackend: 0 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 500 79 | m_PVRBounces: 2 80 | m_PVRFilterTypeDirect: 0 81 | m_PVRFilterTypeIndirect: 0 82 | m_PVRFilterTypeAO: 0 83 | m_PVRFilteringMode: 0 84 | m_PVRCulling: 1 85 | m_PVRFilteringGaussRadiusDirect: 1 86 | m_PVRFilteringGaussRadiusIndirect: 5 87 | m_PVRFilteringGaussRadiusAO: 2 88 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 89 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 90 | m_PVRFilteringAtrousPositionSigmaAO: 1 91 | m_ShowResolutionOverlay: 1 92 | m_LightingDataAsset: {fileID: 0} 93 | m_UseShadowmask: 0 94 | --- !u!196 &5 95 | NavMeshSettings: 96 | serializedVersion: 2 97 | m_ObjectHideFlags: 0 98 | m_BuildSettings: 99 | serializedVersion: 2 100 | agentTypeID: 0 101 | agentRadius: 0.5 102 | agentHeight: 2 103 | agentSlope: 45 104 | agentClimb: 0.4 105 | ledgeDropHeight: 0 106 | maxJumpAcrossDistance: 0 107 | minRegionArea: 2 108 | manualCellSize: 0 109 | cellSize: 0.16666667 110 | manualTileSize: 0 111 | tileSize: 256 112 | accuratePlacement: 0 113 | debug: 114 | m_Flags: 0 115 | m_NavMeshData: {fileID: 0} 116 | --- !u!1 &814989680 117 | GameObject: 118 | m_ObjectHideFlags: 0 119 | m_CorrespondingSourceObject: {fileID: 0} 120 | m_PrefabInternal: {fileID: 0} 121 | serializedVersion: 6 122 | m_Component: 123 | - component: {fileID: 814989685} 124 | - component: {fileID: 814989684} 125 | - component: {fileID: 814989683} 126 | - component: {fileID: 814989682} 127 | - component: {fileID: 814989681} 128 | m_Layer: 0 129 | m_Name: Main Camera 130 | m_TagString: MainCamera 131 | m_Icon: {fileID: 0} 132 | m_NavMeshLayer: 0 133 | m_StaticEditorFlags: 0 134 | m_IsActive: 1 135 | --- !u!81 &814989681 136 | AudioListener: 137 | m_ObjectHideFlags: 0 138 | m_CorrespondingSourceObject: {fileID: 0} 139 | m_PrefabInternal: {fileID: 0} 140 | m_GameObject: {fileID: 814989680} 141 | m_Enabled: 1 142 | --- !u!124 &814989682 143 | Behaviour: 144 | m_ObjectHideFlags: 0 145 | m_CorrespondingSourceObject: {fileID: 0} 146 | m_PrefabInternal: {fileID: 0} 147 | m_GameObject: {fileID: 814989680} 148 | m_Enabled: 1 149 | --- !u!92 &814989683 150 | Behaviour: 151 | m_ObjectHideFlags: 0 152 | m_CorrespondingSourceObject: {fileID: 0} 153 | m_PrefabInternal: {fileID: 0} 154 | m_GameObject: {fileID: 814989680} 155 | m_Enabled: 1 156 | --- !u!20 &814989684 157 | Camera: 158 | m_ObjectHideFlags: 0 159 | m_CorrespondingSourceObject: {fileID: 0} 160 | m_PrefabInternal: {fileID: 0} 161 | m_GameObject: {fileID: 814989680} 162 | m_Enabled: 1 163 | serializedVersion: 2 164 | m_ClearFlags: 1 165 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0.019607844} 166 | m_projectionMatrixMode: 1 167 | m_SensorSize: {x: 36, y: 24} 168 | m_LensShift: {x: 0, y: 0} 169 | m_FocalLength: 50 170 | m_NormalizedViewPortRect: 171 | serializedVersion: 2 172 | x: 0 173 | y: 0 174 | width: 1 175 | height: 1 176 | near clip plane: 0.3 177 | far clip plane: 1000 178 | field of view: 60 179 | orthographic: 0 180 | orthographic size: 5 181 | m_Depth: -1 182 | m_CullingMask: 183 | serializedVersion: 2 184 | m_Bits: 4294967295 185 | m_RenderingPath: -1 186 | m_TargetTexture: {fileID: 0} 187 | m_TargetDisplay: 0 188 | m_TargetEye: 3 189 | m_HDR: 0 190 | m_AllowMSAA: 1 191 | m_AllowDynamicResolution: 0 192 | m_ForceIntoRT: 0 193 | m_OcclusionCulling: 1 194 | m_StereoConvergence: 10 195 | m_StereoSeparation: 0.022 196 | --- !u!4 &814989685 197 | Transform: 198 | m_ObjectHideFlags: 0 199 | m_CorrespondingSourceObject: {fileID: 0} 200 | m_PrefabInternal: {fileID: 0} 201 | m_GameObject: {fileID: 814989680} 202 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 203 | m_LocalPosition: {x: 0, y: 1, z: -10} 204 | m_LocalScale: {x: 1, y: 1, z: 1} 205 | m_Children: [] 206 | m_Father: {fileID: 0} 207 | m_RootOrder: 0 208 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 209 | --- !u!1 &1702360279 210 | GameObject: 211 | m_ObjectHideFlags: 0 212 | m_CorrespondingSourceObject: {fileID: 0} 213 | m_PrefabInternal: {fileID: 0} 214 | serializedVersion: 6 215 | m_Component: 216 | - component: {fileID: 1702360281} 217 | - component: {fileID: 1702360280} 218 | m_Layer: 0 219 | m_Name: Directional Light 220 | m_TagString: Untagged 221 | m_Icon: {fileID: 0} 222 | m_NavMeshLayer: 0 223 | m_StaticEditorFlags: 0 224 | m_IsActive: 1 225 | --- !u!108 &1702360280 226 | Light: 227 | m_ObjectHideFlags: 0 228 | m_CorrespondingSourceObject: {fileID: 0} 229 | m_PrefabInternal: {fileID: 0} 230 | m_GameObject: {fileID: 1702360279} 231 | m_Enabled: 1 232 | serializedVersion: 8 233 | m_Type: 1 234 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} 235 | m_Intensity: 1 236 | m_Range: 10 237 | m_SpotAngle: 30 238 | m_CookieSize: 10 239 | m_Shadows: 240 | m_Type: 2 241 | m_Resolution: -1 242 | m_CustomResolution: -1 243 | m_Strength: 1 244 | m_Bias: 0.05 245 | m_NormalBias: 0.4 246 | m_NearPlane: 0.2 247 | m_Cookie: {fileID: 0} 248 | m_DrawHalo: 0 249 | m_Flare: {fileID: 0} 250 | m_RenderMode: 0 251 | m_CullingMask: 252 | serializedVersion: 2 253 | m_Bits: 4294967295 254 | m_Lightmapping: 4 255 | m_LightShadowCasterMode: 0 256 | m_AreaSize: {x: 1, y: 1} 257 | m_BounceIntensity: 1 258 | m_ColorTemperature: 6570 259 | m_UseColorTemperature: 0 260 | m_ShadowRadius: 0 261 | m_ShadowAngle: 0 262 | --- !u!4 &1702360281 263 | Transform: 264 | m_ObjectHideFlags: 0 265 | m_CorrespondingSourceObject: {fileID: 0} 266 | m_PrefabInternal: {fileID: 0} 267 | m_GameObject: {fileID: 1702360279} 268 | m_LocalRotation: {x: 0.40821794, y: -0.23456973, z: 0.109381676, w: 0.87542605} 269 | m_LocalPosition: {x: 0, y: 3, z: 0} 270 | m_LocalScale: {x: 1, y: 1, z: 1} 271 | m_Children: [] 272 | m_Father: {fileID: 0} 273 | m_RootOrder: 1 274 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 275 | --- !u!1 &1941270117 276 | GameObject: 277 | m_ObjectHideFlags: 0 278 | m_CorrespondingSourceObject: {fileID: 0} 279 | m_PrefabInternal: {fileID: 0} 280 | serializedVersion: 6 281 | m_Component: 282 | - component: {fileID: 1941270118} 283 | - component: {fileID: 1941270119} 284 | m_Layer: 0 285 | m_Name: Demo 286 | m_TagString: Untagged 287 | m_Icon: {fileID: 0} 288 | m_NavMeshLayer: 0 289 | m_StaticEditorFlags: 0 290 | m_IsActive: 1 291 | --- !u!4 &1941270118 292 | Transform: 293 | m_ObjectHideFlags: 0 294 | m_CorrespondingSourceObject: {fileID: 0} 295 | m_PrefabInternal: {fileID: 0} 296 | m_GameObject: {fileID: 1941270117} 297 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 298 | m_LocalPosition: {x: 0, y: 0, z: 0} 299 | m_LocalScale: {x: 1, y: 1, z: 1} 300 | m_Children: [] 301 | m_Father: {fileID: 0} 302 | m_RootOrder: 2 303 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 304 | --- !u!114 &1941270119 305 | MonoBehaviour: 306 | m_ObjectHideFlags: 0 307 | m_CorrespondingSourceObject: {fileID: 0} 308 | m_PrefabInternal: {fileID: 0} 309 | m_GameObject: {fileID: 1941270117} 310 | m_Enabled: 1 311 | m_EditorHideFlags: 0 312 | m_Script: {fileID: 11500000, guid: 77e8e35d5f324406abb67b63ec25336b, type: 3} 313 | m_Name: 314 | m_EditorClassIdentifier: 315 | count: 10 316 | size: 10 317 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Demo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 133386f84ad1444888f31f45aab51659 3 | timeCreated: 1465912656 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7ee545cc6c30e4a3181546264346d7ab 3 | folderAsset: yes 4 | timeCreated: 1466692483 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Materials/CanvasLine.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: CanvasLine 10 | m_Shader: {fileID: 4800000, guid: 21e9e5ce29c1c4bf18deb2895e31bd70, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 5 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: 2000 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _Glossiness: 0.5 63 | - _Metallic: 0 64 | - _Mode: 0 65 | - _OcclusionStrength: 1 66 | - _Parallax: 0.02 67 | - _SrcBlend: 1 68 | - _UVSec: 0 69 | - _ZWrite: 1 70 | m_Colors: 71 | - _Color: {r: 1, g: 1, b: 1, a: 1} 72 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 73 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Materials/CanvasLine.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3cdb56c432dc643c99684f1e7daff9b8 3 | timeCreated: 1466516387 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Materials/DemoMesh.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: DemoMesh 10 | m_Shader: {fileID: 4800000, guid: 5ea78bc862e0b4acc886e363496717b6, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 5 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: 2000 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _Glossiness: 0.5 63 | - _Metallic: 0 64 | - _Mode: 0 65 | - _OcclusionStrength: 1 66 | - _Parallax: 0.02 67 | - _SrcBlend: 1 68 | - _UVSec: 0 69 | - _ZWrite: 1 70 | m_Colors: 71 | - _Color: {r: 1, g: 1, b: 1, a: 1} 72 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 73 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Materials/DemoMesh.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ad59dae05c2214026b6e4097e9fe27d2 3 | timeCreated: 1466515189 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Materials/DemoMeshLine.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: DemoMeshLine 10 | m_Shader: {fileID: 4800000, guid: 21e9e5ce29c1c4bf18deb2895e31bd70, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 5 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: 2000 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _Glossiness: 0.5 63 | - _Metallic: 0 64 | - _Mode: 0 65 | - _OcclusionStrength: 1 66 | - _Parallax: 0.02 67 | - _SrcBlend: 1 68 | - _UVSec: 0 69 | - _ZWrite: 1 70 | m_Colors: 71 | - _Color: {r: 0, g: 0, b: 0, a: 1} 72 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 73 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Materials/DemoMeshLine.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f0eacebf3e8c64a399242fae6d8dcbc8 3 | timeCreated: 1466694534 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02f1bde77e07549fe8c002581af4bf39 3 | folderAsset: yes 4 | timeCreated: 1466692500 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Prefabs/DemoMesh.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &111580 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 6 9 | m_Component: 10 | - component: {fileID: 496996} 11 | - component: {fileID: 3356526} 12 | - component: {fileID: 2397546} 13 | - component: {fileID: 5423564} 14 | - component: {fileID: 11429206} 15 | m_Layer: 0 16 | m_Name: DemoMesh 17 | m_TagString: Untagged 18 | m_Icon: {fileID: 0} 19 | m_NavMeshLayer: 0 20 | m_StaticEditorFlags: 0 21 | m_IsActive: 1 22 | --- !u!4 &496996 23 | Transform: 24 | m_ObjectHideFlags: 1 25 | m_CorrespondingSourceObject: {fileID: 0} 26 | m_PrefabInternal: {fileID: 100100000} 27 | m_GameObject: {fileID: 111580} 28 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 29 | m_LocalPosition: {x: 0, y: 0, z: 0} 30 | m_LocalScale: {x: 1, y: 1, z: 1} 31 | m_Children: [] 32 | m_Father: {fileID: 0} 33 | m_RootOrder: 0 34 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 35 | --- !u!23 &2397546 36 | MeshRenderer: 37 | m_ObjectHideFlags: 1 38 | m_CorrespondingSourceObject: {fileID: 0} 39 | m_PrefabInternal: {fileID: 100100000} 40 | m_GameObject: {fileID: 111580} 41 | m_Enabled: 1 42 | m_CastShadows: 1 43 | m_ReceiveShadows: 1 44 | m_DynamicOccludee: 1 45 | m_MotionVectors: 1 46 | m_LightProbeUsage: 1 47 | m_ReflectionProbeUsage: 1 48 | m_RenderingLayerMask: 4294967295 49 | m_Materials: 50 | - {fileID: 2100000, guid: ad59dae05c2214026b6e4097e9fe27d2, type: 2} 51 | m_StaticBatchInfo: 52 | firstSubMesh: 0 53 | subMeshCount: 0 54 | m_StaticBatchRoot: {fileID: 0} 55 | m_ProbeAnchor: {fileID: 0} 56 | m_LightProbeVolumeOverride: {fileID: 0} 57 | m_ScaleInLightmap: 1 58 | m_PreserveUVs: 0 59 | m_IgnoreNormalsForChartDetection: 0 60 | m_ImportantGI: 0 61 | m_StitchLightmapSeams: 0 62 | m_SelectedEditorRenderState: 3 63 | m_MinimumChartSize: 4 64 | m_AutoUVMaxDistance: 0.5 65 | m_AutoUVMaxAngle: 89 66 | m_LightmapParameters: {fileID: 0} 67 | m_SortingLayerID: 0 68 | m_SortingLayer: 0 69 | m_SortingOrder: 0 70 | --- !u!33 &3356526 71 | MeshFilter: 72 | m_ObjectHideFlags: 1 73 | m_CorrespondingSourceObject: {fileID: 0} 74 | m_PrefabInternal: {fileID: 100100000} 75 | m_GameObject: {fileID: 111580} 76 | m_Mesh: {fileID: 0} 77 | --- !u!54 &5423564 78 | Rigidbody: 79 | m_ObjectHideFlags: 1 80 | m_CorrespondingSourceObject: {fileID: 0} 81 | m_PrefabInternal: {fileID: 100100000} 82 | m_GameObject: {fileID: 111580} 83 | serializedVersion: 2 84 | m_Mass: 1 85 | m_Drag: 0 86 | m_AngularDrag: 0.05 87 | m_UseGravity: 0 88 | m_IsKinematic: 0 89 | m_Interpolate: 0 90 | m_Constraints: 0 91 | m_CollisionDetection: 0 92 | --- !u!114 &11429206 93 | MonoBehaviour: 94 | m_ObjectHideFlags: 1 95 | m_CorrespondingSourceObject: {fileID: 0} 96 | m_PrefabInternal: {fileID: 100100000} 97 | m_GameObject: {fileID: 111580} 98 | m_Enabled: 1 99 | m_EditorHideFlags: 0 100 | m_Script: {fileID: 11500000, guid: bcb5140256a2f492abf35ca80af1c53a, type: 3} 101 | m_Name: 102 | m_EditorClassIdentifier: 103 | lineMat: {fileID: 2100000, guid: f0eacebf3e8c64a399242fae6d8dcbc8, type: 2} 104 | --- !u!1001 &100100000 105 | Prefab: 106 | m_ObjectHideFlags: 1 107 | serializedVersion: 2 108 | m_Modification: 109 | m_TransformParent: {fileID: 0} 110 | m_Modifications: [] 111 | m_RemovedComponents: [] 112 | m_SourcePrefab: {fileID: 0} 113 | m_RootGameObject: {fileID: 111580} 114 | m_IsPrefabAsset: 1 115 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Prefabs/DemoMesh.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 01293f85e33724cffb1f6673f3588572 3 | timeCreated: 1466694480 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 57b5bb180f19c43439bb92113c0685ec 3 | folderAsset: yes 4 | timeCreated: 1466692452 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Scenes/Demo.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 9 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &4 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 11 47 | m_GIWorkflowMode: 0 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_TemporalCoherenceThreshold: 1 54 | m_EnvironmentLightingMode: 0 55 | m_EnableBakedLightmaps: 1 56 | m_EnableRealtimeLightmaps: 1 57 | m_LightmapEditorSettings: 58 | serializedVersion: 10 59 | m_Resolution: 2 60 | m_BakeResolution: 40 61 | m_AtlasSize: 1024 62 | m_AO: 0 63 | m_AOMaxDistance: 1 64 | m_CompAOExponent: 0 65 | m_CompAOExponentDirect: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 1024 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 1 75 | m_BakeBackend: 0 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 500 79 | m_PVRBounces: 2 80 | m_PVRFilterTypeDirect: 0 81 | m_PVRFilterTypeIndirect: 0 82 | m_PVRFilterTypeAO: 0 83 | m_PVRFilteringMode: 0 84 | m_PVRCulling: 1 85 | m_PVRFilteringGaussRadiusDirect: 1 86 | m_PVRFilteringGaussRadiusIndirect: 5 87 | m_PVRFilteringGaussRadiusAO: 2 88 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 89 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 90 | m_PVRFilteringAtrousPositionSigmaAO: 1 91 | m_ShowResolutionOverlay: 1 92 | m_LightingDataAsset: {fileID: 0} 93 | m_UseShadowmask: 0 94 | --- !u!196 &5 95 | NavMeshSettings: 96 | serializedVersion: 2 97 | m_ObjectHideFlags: 0 98 | m_BuildSettings: 99 | serializedVersion: 2 100 | agentTypeID: 0 101 | agentRadius: 0.5 102 | agentHeight: 2 103 | agentSlope: 45 104 | agentClimb: 0.4 105 | ledgeDropHeight: 0 106 | maxJumpAcrossDistance: 0 107 | minRegionArea: 2 108 | manualCellSize: 0 109 | cellSize: 0.16666667 110 | manualTileSize: 0 111 | tileSize: 256 112 | accuratePlacement: 0 113 | debug: 114 | m_Flags: 0 115 | m_NavMeshData: {fileID: 0} 116 | --- !u!1 &814989680 117 | GameObject: 118 | m_ObjectHideFlags: 0 119 | m_CorrespondingSourceObject: {fileID: 0} 120 | m_PrefabInternal: {fileID: 0} 121 | serializedVersion: 6 122 | m_Component: 123 | - component: {fileID: 814989685} 124 | - component: {fileID: 814989684} 125 | - component: {fileID: 814989683} 126 | - component: {fileID: 814989682} 127 | - component: {fileID: 814989681} 128 | m_Layer: 0 129 | m_Name: Main Camera 130 | m_TagString: MainCamera 131 | m_Icon: {fileID: 0} 132 | m_NavMeshLayer: 0 133 | m_StaticEditorFlags: 0 134 | m_IsActive: 1 135 | --- !u!81 &814989681 136 | AudioListener: 137 | m_ObjectHideFlags: 0 138 | m_CorrespondingSourceObject: {fileID: 0} 139 | m_PrefabInternal: {fileID: 0} 140 | m_GameObject: {fileID: 814989680} 141 | m_Enabled: 1 142 | --- !u!124 &814989682 143 | Behaviour: 144 | m_ObjectHideFlags: 0 145 | m_CorrespondingSourceObject: {fileID: 0} 146 | m_PrefabInternal: {fileID: 0} 147 | m_GameObject: {fileID: 814989680} 148 | m_Enabled: 1 149 | --- !u!92 &814989683 150 | Behaviour: 151 | m_ObjectHideFlags: 0 152 | m_CorrespondingSourceObject: {fileID: 0} 153 | m_PrefabInternal: {fileID: 0} 154 | m_GameObject: {fileID: 814989680} 155 | m_Enabled: 1 156 | --- !u!20 &814989684 157 | Camera: 158 | m_ObjectHideFlags: 0 159 | m_CorrespondingSourceObject: {fileID: 0} 160 | m_PrefabInternal: {fileID: 0} 161 | m_GameObject: {fileID: 814989680} 162 | m_Enabled: 1 163 | serializedVersion: 2 164 | m_ClearFlags: 2 165 | m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0.019607844} 166 | m_projectionMatrixMode: 1 167 | m_SensorSize: {x: 36, y: 24} 168 | m_LensShift: {x: 0, y: 0} 169 | m_FocalLength: 50 170 | m_NormalizedViewPortRect: 171 | serializedVersion: 2 172 | x: 0 173 | y: 0 174 | width: 1 175 | height: 1 176 | near clip plane: 0.3 177 | far clip plane: 1000 178 | field of view: 70 179 | orthographic: 0 180 | orthographic size: 5 181 | m_Depth: -1 182 | m_CullingMask: 183 | serializedVersion: 2 184 | m_Bits: 4294967295 185 | m_RenderingPath: -1 186 | m_TargetTexture: {fileID: 0} 187 | m_TargetDisplay: 0 188 | m_TargetEye: 3 189 | m_HDR: 0 190 | m_AllowMSAA: 1 191 | m_AllowDynamicResolution: 0 192 | m_ForceIntoRT: 0 193 | m_OcclusionCulling: 1 194 | m_StereoConvergence: 10 195 | m_StereoSeparation: 0.022 196 | --- !u!4 &814989685 197 | Transform: 198 | m_ObjectHideFlags: 0 199 | m_CorrespondingSourceObject: {fileID: 0} 200 | m_PrefabInternal: {fileID: 0} 201 | m_GameObject: {fileID: 814989680} 202 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 203 | m_LocalPosition: {x: 0, y: 0, z: -20} 204 | m_LocalScale: {x: 1, y: 1, z: 1} 205 | m_Children: [] 206 | m_Father: {fileID: 0} 207 | m_RootOrder: 0 208 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 209 | --- !u!1 &1941270117 210 | GameObject: 211 | m_ObjectHideFlags: 0 212 | m_CorrespondingSourceObject: {fileID: 0} 213 | m_PrefabInternal: {fileID: 0} 214 | serializedVersion: 6 215 | m_Component: 216 | - component: {fileID: 1941270118} 217 | - component: {fileID: 1941270119} 218 | m_Layer: 0 219 | m_Name: Demo 220 | m_TagString: Untagged 221 | m_Icon: {fileID: 0} 222 | m_NavMeshLayer: 0 223 | m_StaticEditorFlags: 0 224 | m_IsActive: 1 225 | --- !u!4 &1941270118 226 | Transform: 227 | m_ObjectHideFlags: 0 228 | m_CorrespondingSourceObject: {fileID: 0} 229 | m_PrefabInternal: {fileID: 0} 230 | m_GameObject: {fileID: 1941270117} 231 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 232 | m_LocalPosition: {x: 0, y: 0, z: 0} 233 | m_LocalScale: {x: 1, y: 1, z: 1} 234 | m_Children: [] 235 | m_Father: {fileID: 0} 236 | m_RootOrder: 1 237 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 238 | --- !u!114 &1941270119 239 | MonoBehaviour: 240 | m_ObjectHideFlags: 0 241 | m_CorrespondingSourceObject: {fileID: 0} 242 | m_PrefabInternal: {fileID: 0} 243 | m_GameObject: {fileID: 1941270117} 244 | m_Enabled: 1 245 | m_EditorHideFlags: 0 246 | m_Script: {fileID: 11500000, guid: 77e8e35d5f324406abb67b63ec25336b, type: 3} 247 | m_Name: 248 | m_EditorClassIdentifier: 249 | angle: 22.5 250 | threshold: 0.483 251 | prefab: {fileID: 111580, guid: 01293f85e33724cffb1f6673f3588572, type: 2} 252 | lineMat: {fileID: 2100000, guid: 3cdb56c432dc643c99684f1e7daff9b8, type: 2} 253 | debug: 1 254 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Scenes/Demo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99428221878334a8683529a91c6d2b53 3 | timeCreated: 1466517357 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22ae8b0dfc64b479894a635234365124 3 | folderAsset: yes 4 | timeCreated: 1466692462 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Scripts/DemoMesh.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using Random = UnityEngine.Random; 3 | 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | 7 | namespace mattatz.Triangulation2DSystem.Example { 8 | 9 | [RequireComponent (typeof(MeshFilter))] 10 | [RequireComponent (typeof(Rigidbody))] 11 | public class DemoMesh : MonoBehaviour { 12 | 13 | [SerializeField] Material lineMat; 14 | 15 | Triangle2D[] triangles; 16 | 17 | void Start () { 18 | var body = GetComponent(); 19 | body.AddForce(Vector3.forward * Random.Range(150f, 160f)); 20 | body.AddTorque(Random.insideUnitSphere * Random.Range(10f, 20f)); 21 | } 22 | 23 | void Update () {} 24 | 25 | public void SetTriangulation (Triangulation2D triangulation) { 26 | var mesh = triangulation.Build(); 27 | GetComponent().sharedMesh = mesh; 28 | this.triangles = triangulation.Triangles; 29 | } 30 | 31 | void OnRenderObject () { 32 | if(triangles == null) return; 33 | 34 | GL.PushMatrix(); 35 | GL.MultMatrix (transform.localToWorldMatrix); 36 | 37 | lineMat.SetColor("_Color", Color.black); 38 | lineMat.SetPass(0); 39 | GL.Begin(GL.LINES); 40 | for(int i = 0, n = triangles.Length; i < n; i++) { 41 | var t = triangles[i]; 42 | GL.Vertex(t.s0.a.Coordinate); GL.Vertex(t.s0.b.Coordinate); 43 | GL.Vertex(t.s1.a.Coordinate); GL.Vertex(t.s1.b.Coordinate); 44 | GL.Vertex(t.s2.a.Coordinate); GL.Vertex(t.s2.b.Coordinate); 45 | } 46 | GL.End(); 47 | GL.PopMatrix(); 48 | } 49 | 50 | } 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Scripts/DemoMesh.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bcb5140256a2f492abf35ca80af1c53a 3 | timeCreated: 1466693882 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Scripts/LocalStorage.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | using System; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Collections; 7 | using System.Collections.Generic; 8 | 9 | namespace mattatz.Utils { 10 | 11 | [Serializable] 12 | public class JsonSerialization { 13 | [SerializeField] List target; 14 | public List ToList() { return target; } 15 | public JsonSerialization(List target) { 16 | this.target = target; 17 | } 18 | } 19 | 20 | public class LocalStorage { 21 | 22 | public static void SaveList (List target, string fileName) { 23 | var text = JsonUtility.ToJson(new JsonSerialization(target)); 24 | Save(text, fileName); 25 | } 26 | 27 | public static List LoadList (string fileName) { 28 | string json = Load(fileName); 29 | return JsonUtility.FromJson>(json).ToList(); 30 | } 31 | 32 | public static void Save (string text, string fileName) { 33 | string path = System.IO.Path.Combine(Application.streamingAssetsPath, fileName); 34 | FileInfo fi = new FileInfo(path); 35 | StreamWriter sw = fi.CreateText(); 36 | sw.WriteLine(text); 37 | sw.Flush(); 38 | sw.Close(); 39 | } 40 | 41 | public static string Load (string fileName) { 42 | string path = System.IO.Path.Combine(Application.streamingAssetsPath, fileName); 43 | return System.IO.File.ReadAllText(path); 44 | } 45 | 46 | } 47 | 48 | } 49 | 50 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Scripts/LocalStorage.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 179a565d3dde349a8ba57b9d77f383ae 3 | timeCreated: 1466755694 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4548c7205de644ae984fba97a98543a6 3 | folderAsset: yes 4 | timeCreated: 1466692475 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Shaders/DemoLine.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | Shader "Triangulation2D/Demo/Line" { 4 | 5 | Properties { 6 | _Color ("Color", Color) = (0, 0, 1, 1) 7 | } 8 | 9 | SubShader { 10 | Tags { "RenderType"="Opaque" } 11 | LOD 100 12 | 13 | CGINCLUDE 14 | 15 | #include "UnityCG.cginc" 16 | 17 | #pragma target 3.0 18 | 19 | fixed4 _Color; 20 | 21 | struct appdata { 22 | float4 vertex : POSITION; 23 | float3 normal : NORMAL; 24 | float2 uv : TEXCOORD0; 25 | }; 26 | 27 | struct v2f { 28 | float4 vertex : SV_POSITION; 29 | float3 normal : NORMAL; 30 | float2 uv : TEXCOORD0; 31 | }; 32 | 33 | v2f vert (appdata v) { 34 | v2f o; 35 | o.vertex = UnityObjectToClipPos(v.vertex); 36 | o.normal = v.normal; 37 | o.uv = v.uv; 38 | return o; 39 | } 40 | 41 | ENDCG 42 | 43 | Pass { 44 | CGPROGRAM 45 | #pragma vertex vert 46 | #pragma fragment frag 47 | fixed4 frag (v2f i) : SV_Target { 48 | return _Color; 49 | } 50 | ENDCG 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Shaders/DemoLine.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21e9e5ce29c1c4bf18deb2895e31bd70 3 | timeCreated: 1466516398 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Shaders/DemoMesh.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | Shader "Triangulation2D/Demo/Mesh" { 4 | 5 | Properties { 6 | } 7 | 8 | SubShader { 9 | Tags { "RenderType"="Opaque" } 10 | LOD 100 11 | 12 | CGINCLUDE 13 | 14 | #include "UnityCG.cginc" 15 | 16 | #pragma target 3.0 17 | 18 | struct appdata { 19 | float4 vertex : POSITION; 20 | float3 normal : NORMAL; 21 | float2 uv : TEXCOORD0; 22 | }; 23 | 24 | struct v2f { 25 | float4 vertex : SV_POSITION; 26 | float3 normal : NORMAL; 27 | float2 uv : TEXCOORD0; 28 | }; 29 | 30 | v2f vert (appdata v) { 31 | v2f o; 32 | o.vertex = UnityObjectToClipPos(v.vertex); 33 | o.normal = mul(unity_ObjectToWorld, float4(v.normal, 0)).xyz; 34 | o.uv = v.uv; 35 | return o; 36 | } 37 | 38 | fixed3 normal_color (fixed3 norm) { 39 | return (normalize(norm) + 1.0) * 0.5; 40 | } 41 | 42 | ENDCG 43 | 44 | Pass { 45 | Cull Front 46 | CGPROGRAM 47 | #pragma vertex vert 48 | #pragma fragment frag 49 | fixed4 frag (v2f i) : SV_Target { 50 | fixed4 col = fixed4(normal_color(i.normal), 1); 51 | return col; 52 | } 53 | ENDCG 54 | } 55 | 56 | Pass { 57 | Cull Back 58 | CGPROGRAM 59 | #pragma vertex vert 60 | #pragma fragment frag 61 | fixed4 frag (v2f i) : SV_Target { 62 | fixed4 col = fixed4(normal_color(-i.normal), 1); 63 | return col; 64 | } 65 | ENDCG 66 | } 67 | 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Shaders/DemoMesh.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ea78bc862e0b4acc886e363496717b6 3 | timeCreated: 1466515194 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Shaders/SimplexNoise3D.cginc: -------------------------------------------------------------------------------- 1 | // 2 | // Noise Shader Library for Unity - https://github.com/keijiro/NoiseShader 3 | // 4 | // Original work (webgl-noise) Copyright (C) 2011 Ashima Arts. 5 | // Translation and modification was made by Keijiro Takahashi. 6 | // 7 | // This shader is based on the webgl-noise GLSL shader. For further details 8 | // of the original shader, please see the following description from the 9 | // original source code. 10 | // 11 | 12 | // 13 | // Description : Array and textureless GLSL 2D/3D/4D simplex 14 | // noise functions. 15 | // Author : Ian McEwan, Ashima Arts. 16 | // Maintainer : ijm 17 | // Lastmod : 20110822 (ijm) 18 | // License : Copyright (C) 2011 Ashima Arts. All rights reserved. 19 | // Distributed under the MIT License. See LICENSE file. 20 | // https://github.com/ashima/webgl-noise 21 | // 22 | 23 | float3 mod289(float3 x) 24 | { 25 | return x - floor(x / 289.0) * 289.0; 26 | } 27 | 28 | float4 mod289(float4 x) 29 | { 30 | return x - floor(x / 289.0) * 289.0; 31 | } 32 | 33 | float4 permute(float4 x) 34 | { 35 | return mod289((x * 34.0 + 1.0) * x); 36 | } 37 | 38 | float4 taylorInvSqrt(float4 r) 39 | { 40 | return 1.79284291400159 - r * 0.85373472095314; 41 | } 42 | 43 | float snoise(float3 v) 44 | { 45 | const float2 C = float2(1.0 / 6.0, 1.0 / 3.0); 46 | 47 | // First corner 48 | float3 i = floor(v + dot(v, C.yyy)); 49 | float3 x0 = v - i + dot(i, C.xxx); 50 | 51 | // Other corners 52 | float3 g = step(x0.yzx, x0.xyz); 53 | float3 l = 1.0 - g; 54 | float3 i1 = min(g.xyz, l.zxy); 55 | float3 i2 = max(g.xyz, l.zxy); 56 | 57 | // x1 = x0 - i1 + 1.0 * C.xxx; 58 | // x2 = x0 - i2 + 2.0 * C.xxx; 59 | // x3 = x0 - 1.0 + 3.0 * C.xxx; 60 | float3 x1 = x0 - i1 + C.xxx; 61 | float3 x2 = x0 - i2 + C.yyy; 62 | float3 x3 = x0 - 0.5; 63 | 64 | // Permutations 65 | i = mod289(i); // Avoid truncation effects in permutation 66 | float4 p = 67 | permute(permute(permute(i.z + float4(0.0, i1.z, i2.z, 1.0)) 68 | + i.y + float4(0.0, i1.y, i2.y, 1.0)) 69 | + i.x + float4(0.0, i1.x, i2.x, 1.0)); 70 | 71 | // Gradients: 7x7 points over a square, mapped onto an octahedron. 72 | // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) 73 | float4 j = p - 49.0 * floor(p / 49.0); // mod(p,7*7) 74 | 75 | float4 x_ = floor(j / 7.0); 76 | float4 y_ = floor(j - 7.0 * x_); // mod(j,N) 77 | 78 | float4 x = (x_ * 2.0 + 0.5) / 7.0 - 1.0; 79 | float4 y = (y_ * 2.0 + 0.5) / 7.0 - 1.0; 80 | 81 | float4 h = 1.0 - abs(x) - abs(y); 82 | 83 | float4 b0 = float4(x.xy, y.xy); 84 | float4 b1 = float4(x.zw, y.zw); 85 | 86 | //float4 s0 = float4(lessThan(b0, 0.0)) * 2.0 - 1.0; 87 | //float4 s1 = float4(lessThan(b1, 0.0)) * 2.0 - 1.0; 88 | float4 s0 = floor(b0) * 2.0 + 1.0; 89 | float4 s1 = floor(b1) * 2.0 + 1.0; 90 | float4 sh = -step(h, 0.0); 91 | 92 | float4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; 93 | float4 a1 = b1.xzyw + s1.xzyw * sh.zzww; 94 | 95 | float3 g0 = float3(a0.xy, h.x); 96 | float3 g1 = float3(a0.zw, h.y); 97 | float3 g2 = float3(a1.xy, h.z); 98 | float3 g3 = float3(a1.zw, h.w); 99 | 100 | // Normalise gradients 101 | float4 norm = taylorInvSqrt(float4(dot(g0, g0), dot(g1, g1), dot(g2, g2), dot(g3, g3))); 102 | g0 *= norm.x; 103 | g1 *= norm.y; 104 | g2 *= norm.z; 105 | g3 *= norm.w; 106 | 107 | // Mix final noise value 108 | float4 m = max(0.6 - float4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0); 109 | m = m * m; 110 | m = m * m; 111 | 112 | float4 px = float4(dot(x0, g0), dot(x1, g1), dot(x2, g2), dot(x3, g3)); 113 | return 42.0 * dot(m, px); 114 | } 115 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Demo/Shaders/SimplexNoise3D.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 27095d50a08104a8b8c1bd0cc39ee427 3 | timeCreated: 1466758276 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3207a8a0bde6547718c98ca16d9b64ba 3 | folderAsset: yes 4 | timeCreated: 1466754477 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Scripts/Circle2D.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | using System; 4 | using System.Linq; 5 | using System.Collections; 6 | using System.Collections.Generic; 7 | 8 | namespace mattatz.Triangulation2DSystem { 9 | 10 | public class Circle2D { 11 | public Vector2 center; 12 | public float radius; 13 | 14 | public Circle2D (Vector2 c, float r) { 15 | this.center = c; 16 | this.radius = r; 17 | } 18 | 19 | public bool Contains (Vector2 p) { 20 | return (p - center).magnitude < radius; 21 | } 22 | 23 | public static Circle2D GetCircumscribedCircle(Triangle2D triangle) { 24 | var x1 = triangle.a.Coordinate.x; 25 | var y1 = triangle.a.Coordinate.y; 26 | var x2 = triangle.b.Coordinate.x; 27 | var y2 = triangle.b.Coordinate.y; 28 | var x3 = triangle.c.Coordinate.x; 29 | var y3 = triangle.c.Coordinate.y; 30 | 31 | float x1_2 = x1 * x1; 32 | float x2_2 = x2 * x2; 33 | float x3_2 = x3 * x3; 34 | float y1_2 = y1 * y1; 35 | float y2_2 = y2 * y2; 36 | float y3_2 = y3 * y3; 37 | 38 | // 外接円の中心座標を計算 39 | float c = 2f * ((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)); 40 | float x = ((y3 - y1) * (x2_2 - x1_2 + y2_2 - y1_2) + (y1 - y2) * (x3_2 - x1_2 + y3_2 - y1_2)) / c; 41 | float y = ((x1 - x3) * (x2_2 - x1_2 + y2_2 - y1_2) + (x2 - x1) * (x3_2 - x1_2 + y3_2 - y1_2)) / c; 42 | float _x = (x1 - x); 43 | float _y = (y1 - y); 44 | 45 | float r = Mathf.Sqrt((_x * _x) + (_y * _y)); 46 | return new Circle2D(new Vector2(x, y), r); 47 | } 48 | 49 | public void DrawGizmos (float step = 0.02f) { 50 | 51 | var points = new List(); 52 | for(float t = 0f; t <= 1f; t += step) { 53 | var r = t * Mathf.PI * 2f; 54 | float x = Mathf.Cos(r) * radius; 55 | float y = Mathf.Sin(r) * radius; 56 | points.Add(center + new Vector2(x, y)); 57 | } 58 | 59 | for(int i = 0, n = points.Count; i < n; i++) { 60 | var p0 = points[i]; 61 | var p1 = points[(i + 1) % n]; 62 | Gizmos.DrawLine(p0, p1); 63 | } 64 | 65 | } 66 | 67 | } 68 | 69 | 70 | } 71 | 72 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Scripts/Circle2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f4a27231bfb4241f59d009b3ef7a7f55 3 | timeCreated: 1466752903 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Scripts/HalfEdge2D.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | using System; 4 | using System.Linq; 5 | using System.Collections; 6 | using System.Collections.Generic; 7 | 8 | namespace mattatz.Triangulation2DSystem { 9 | 10 | public class HalfEdge2D { 11 | public Vector2 p; 12 | public HalfEdge2D from, to; 13 | public HalfEdge2D(Vector2 p) { 14 | this.p = p; 15 | } 16 | public void Invert () { 17 | var tmp = from; from = to; to = tmp; 18 | } 19 | public HalfEdge2D Split () { 20 | var m = (to.p + p) * 0.5f; 21 | var e = new HalfEdge2D(m); 22 | to.from = e; e.to = to; 23 | this.to = e; e.from = this; 24 | return e; 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Scripts/HalfEdge2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bd14051ec1efb42118dd17e727f7b467 3 | timeCreated: 1466753012 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Scripts/Polygon2D.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | using System; 4 | using System.Linq; 5 | using System.Collections; 6 | using System.Collections.Generic; 7 | 8 | namespace mattatz.Triangulation2DSystem { 9 | 10 | public class Polygon2D { 11 | 12 | public Vertex2D[] Vertices { get { return vertices.ToArray(); } } 13 | public Segment2D[] Segments { get { return segments.ToArray(); } } 14 | 15 | List vertices; 16 | List segments; 17 | 18 | /* 19 | * slow incremental approach 20 | * O(n * log(n)) 21 | */ 22 | public static Polygon2D ConvexHull (Vector2[] points) { 23 | var ordered = points.ToList().OrderBy(p => p.x).ToList(); 24 | 25 | var upper = new List(); 26 | upper.Add(ordered[0]); 27 | upper.Add(ordered[1]); 28 | for(int i = 2, n = ordered.Count; i < n; i++) { 29 | upper.Add(ordered[i]); 30 | int l = upper.Count; 31 | if(l > 2) { 32 | var p = upper[l - 3]; 33 | var r = upper[l - 2]; 34 | var q = upper[l - 1]; 35 | if(Utils2D.LeftSide(p, q, r)) { // r is left side of pq 36 | upper.RemoveAt(l - 2); 37 | } 38 | } 39 | } 40 | 41 | var lower = new List(); 42 | lower.Add(ordered[ordered.Count - 1]); 43 | lower.Add(ordered[ordered.Count - 2]); 44 | for(int i = ordered.Count - 3; i >= 0; i--) { 45 | lower.Add(ordered[i]); 46 | int l = lower.Count; 47 | if(l > 2) { 48 | var p = lower[l - 3]; 49 | var r = lower[l - 2]; 50 | var q = lower[l - 1]; 51 | if(Utils2D.LeftSide(p, q, r)) { // r is left side of pq 52 | lower.RemoveAt(l - 2); 53 | } 54 | } 55 | } 56 | 57 | lower.RemoveAt(lower.Count - 1); 58 | lower.RemoveAt(0); 59 | 60 | upper.AddRange (lower); 61 | 62 | return new Polygon2D(upper.ToArray()); 63 | } 64 | 65 | public static Polygon2D Contour (Vector2[] points) { 66 | var n = points.Length; 67 | var edges = new List(); 68 | for(int i = 0; i < n; i++) { 69 | edges.Add(new HalfEdge2D(points[i])); 70 | } 71 | for(int i = 0; i < n; i++) { 72 | var e = edges[i]; 73 | e.from = edges[(i == 0) ? (n - 1) : (i - 1)]; 74 | e.to = edges[(i + 1) % n]; 75 | } 76 | edges = Polygon2D.SplitEdges(edges); 77 | 78 | var result = new List(); 79 | 80 | HalfEdge2D start = edges[0]; 81 | result.Add(start.p); 82 | 83 | HalfEdge2D current = start; 84 | 85 | while(true) { 86 | HalfEdge2D from = current, to = current.to; 87 | HalfEdge2D from2 = to.to, to2 = from2.to; 88 | 89 | bool flag = false; 90 | 91 | while(from2 != start && to2 != from) { 92 | if(flag = Utils2D.Intersect(from.p, to.p, from2.p, to2.p)) { 93 | break; 94 | } 95 | from2 = to2; 96 | to2 = to2.to; 97 | } 98 | 99 | if(!flag) { 100 | result.Add(to.p); 101 | current = to; // step to next 102 | } else { 103 | result.Add(from2.p); 104 | 105 | // reconnect 106 | from.to = from2; 107 | from2.to = from; // invert this edge later 108 | 109 | to.from = to2; 110 | to.Invert(); 111 | to2.from = to; 112 | 113 | HalfEdge2D e = from2; 114 | while(e != to) { 115 | e.Invert(); 116 | e = e.to; 117 | } 118 | 119 | current = from2; 120 | } 121 | 122 | if(current == start) break; 123 | } 124 | 125 | result.RemoveAt(result.Count - 1); // remove last 126 | 127 | return new Polygon2D(result.ToArray()); 128 | } 129 | 130 | // Disable to intersect more than two edges 131 | static List SplitEdges (List edges) { 132 | HalfEdge2D start = edges[0]; 133 | HalfEdge2D cur = start; 134 | 135 | while(true) { 136 | HalfEdge2D from = cur, to = from.to; 137 | HalfEdge2D from2 = to.to, to2 = from2.to; 138 | 139 | int intersections = 0; 140 | 141 | while(to2 != from.from) { 142 | if(Utils2D.Intersect(from.p, to.p, from2.p, to2.p)) { 143 | intersections++; 144 | if(intersections >= 2) { 145 | break; 146 | } 147 | } 148 | // next 149 | from2 = from2.to; 150 | to2 = to2.to; 151 | } 152 | 153 | if(intersections >= 2) { 154 | edges.Add(cur.Split()); 155 | } else { 156 | // next 157 | cur = cur.to; 158 | if(cur == start) break; 159 | } 160 | } 161 | 162 | return edges; 163 | } 164 | 165 | // contour must be inversed clockwise order. 166 | public Polygon2D (Vector2[] contour) { 167 | vertices = contour.Select(p => new Vertex2D(p)).ToList(); 168 | segments = new List(); 169 | for(int i = 0, n = vertices.Count; i < n; i++) { 170 | var v0 = vertices[i]; 171 | var v1 = vertices[(i + 1) % n]; 172 | segments.Add(new Segment2D(v0, v1)); 173 | } 174 | } 175 | 176 | public bool Contains (Vector2 p) { 177 | return Utils2D.Contains(p, vertices); 178 | } 179 | 180 | public void DrawGizmos () { 181 | segments.ForEach(s => s.DrawGizmos()); 182 | } 183 | 184 | } 185 | 186 | } 187 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Scripts/Polygon2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4073f796194c44e5b175af9d4b35f40 3 | timeCreated: 1466753084 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Scripts/Segment2D.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | using System; 4 | using System.Linq; 5 | using System.Collections; 6 | using System.Collections.Generic; 7 | 8 | namespace mattatz.Triangulation2DSystem { 9 | 10 | public class Segment2D { 11 | 12 | public int ReferenceCount { get { return reference; } } 13 | public Vertex2D a, b; 14 | 15 | int reference; 16 | float length; 17 | 18 | public Segment2D (Vertex2D a, Vertex2D b) { 19 | this.a = a; 20 | this.b = b; 21 | } 22 | 23 | public Vector2 Midpoint () { 24 | return (a.Coordinate + b.Coordinate) * 0.5f; 25 | } 26 | 27 | public float Length () { 28 | if(length <= 0f) { 29 | length = (a.Coordinate - b.Coordinate).magnitude; 30 | } 31 | return length; 32 | } 33 | 34 | /* 35 | * check a given point "p" lies within diametral circle of segment(a, b) 36 | */ 37 | public bool EncroachedUpon (Vector2 p) { 38 | if(p == a.Coordinate || p == b.Coordinate) return false; 39 | var radius = (a.Coordinate - b.Coordinate).magnitude * 0.5f; 40 | return (Midpoint() - p).magnitude < radius; 41 | } 42 | 43 | const float epsilon = 0.0001f; 44 | public bool On (Vector2 p) { 45 | if(HasPoint(p)) return true; 46 | if(Distance(p) > epsilon) return false; 47 | 48 | Vector2 p0 = a.Coordinate, p1 = b.Coordinate; 49 | bool bx = (p0.x < p1.x) ? (p0.x <= p.x && p.x <= p1.x) : (p1.x <= p.x && p.x <= p0.x); 50 | bool by = (p0.y < p1.y) ? (p0.y <= p.y && p.y <= p1.y) : (p1.y <= p.y && p.y <= p0.y); 51 | return bx && by; 52 | } 53 | 54 | public bool On (Vertex2D v) { 55 | return On(v.Coordinate); 56 | } 57 | 58 | // https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line 59 | public float Distance (Vector2 p) { 60 | Vector2 p0 = a.Coordinate, p1 = b.Coordinate; 61 | float dx = (p1.x - p0.x), dy = (p1.y - p0.y); 62 | return Mathf.Abs((dy * p.x) - (dx * p.y) + (p1.x * p0.y) - (p1.y * p0.x)) / Mathf.Sqrt(dy * dy + dx * dx); 63 | } 64 | 65 | public float Distance (Vertex2D v) { 66 | return Distance(v.Coordinate); 67 | } 68 | 69 | public bool HasPoint (Vertex2D v) { 70 | return (a == v) || (b == v); 71 | } 72 | 73 | public bool HasPoint (Vector2 p) { 74 | return (a.Coordinate == p) || (b.Coordinate == p); 75 | } 76 | 77 | public int Increment () { 78 | a.Increment(); 79 | b.Increment(); 80 | return ++reference; 81 | } 82 | 83 | public int Decrement () { 84 | a.Decrement(); 85 | b.Decrement(); 86 | return --reference; 87 | } 88 | 89 | public void DrawGizmos () { 90 | Gizmos.DrawLine(a.Coordinate, b.Coordinate); 91 | } 92 | } 93 | 94 | } 95 | 96 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Scripts/Segment2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1f518ac0328164dc79a8882211b12ece 3 | timeCreated: 1466753053 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Scripts/Triangle2D.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | using System; 4 | using System.Linq; 5 | using System.Collections; 6 | using System.Collections.Generic; 7 | 8 | namespace mattatz.Triangulation2DSystem { 9 | 10 | public class Triangle2D { 11 | 12 | public Vertex2D a, b, c; 13 | public Segment2D s0, s1, s2; 14 | private Circle2D circum; 15 | 16 | public Triangle2D (Segment2D s0, Segment2D s1, Segment2D s2) { 17 | this.s0 = s0; 18 | this.s1 = s1; 19 | this.s2 = s2; 20 | this.a = s0.a; 21 | this.b = s0.b; 22 | this.c = (s2.b == this.a || s2.b == this.b) ? s2.a : s2.b; 23 | } 24 | 25 | public bool HasPoint (Vertex2D p) { 26 | return (a == p) || (b == p) || (c == p); 27 | } 28 | 29 | public bool HasCommonPoint (Triangle2D t) { 30 | return HasPoint(t.a) || HasPoint(t.b) || HasPoint(t.c); 31 | } 32 | 33 | public bool HasSegment (Segment2D s) { 34 | return (s0 == s) || (s1 == s) || (s2 == s); 35 | } 36 | 37 | public bool HasSegment (Vector2 a, Vector2 b) { 38 | return (s0.HasPoint(a) && s0.HasPoint(b)) || (s1.HasPoint(a) && s1.HasPoint(b)) || (s2.HasPoint(a) && s2.HasPoint(b)); 39 | } 40 | 41 | public Vertex2D ExcludePoint (Segment2D s) { 42 | if(!s.HasPoint(a)) return a; 43 | else if(!s.HasPoint(b)) return b; 44 | return c; 45 | } 46 | 47 | public Vertex2D ExcludePoint (Vector2 p0, Vector2 p1) { 48 | if(p0 != a.Coordinate && p1 != a.Coordinate) return a; 49 | else if(p0 != b.Coordinate && p1 != b.Coordinate) return b; 50 | return c; 51 | } 52 | 53 | public Vertex2D[] ExcludePoint (Vector2 p) { 54 | if(p == a.Coordinate) return new Vertex2D[] { b, c }; 55 | else if(p == b.Coordinate) return new Vertex2D[] { a, c }; 56 | return new Vertex2D[] { a, b }; 57 | } 58 | 59 | public Segment2D[] ExcludeSegment (Segment2D s) { 60 | if(s0.Equals(s)) { 61 | return new Segment2D[] { s1, s2 }; 62 | } else if(s1.Equals(s)) { 63 | return new Segment2D[] { s0, s2 }; 64 | } 65 | return new Segment2D[] { s0, s1 }; 66 | } 67 | 68 | public Segment2D CommonSegment (Vertex2D v0, Vertex2D v1) { 69 | if(s0.HasPoint(v0) && s0.HasPoint(v1)) { 70 | return s0; 71 | } else if(s1.HasPoint(v0) && s1.HasPoint(v1)) { 72 | return s1; 73 | } 74 | return s2; 75 | } 76 | 77 | public Segment2D[] CommonSegments (Vertex2D v) { 78 | if(s0.HasPoint(v) && s1.HasPoint(v)) { 79 | return new [] {s0, s1}; 80 | } else if(s1.HasPoint(v) && s2.HasPoint(v)) { 81 | return new [] {s1, s2}; 82 | } 83 | return new [] {s0, s2}; 84 | } 85 | 86 | public Vector2 Circumcenter () { 87 | if(circum == null) { 88 | circum = Circle2D.GetCircumscribedCircle(this); 89 | } 90 | return circum.center; 91 | } 92 | 93 | public bool ContainsInExternalCircle (Vertex2D v) { 94 | if(circum == null) { 95 | circum = Circle2D.GetCircumscribedCircle(this); 96 | } 97 | return circum.Contains(v.Coordinate); 98 | } 99 | 100 | float Angle (Vector2 from, Vector2 to0, Vector2 to1) { 101 | var v0 = (to0 - from); 102 | var v1 = (to1 - from); 103 | 104 | // 0 ~ PI 105 | float acos = Mathf.Acos(Vector2.Dot(v0, v1) / Mathf.Sqrt(v0.sqrMagnitude * v1.sqrMagnitude)); 106 | return acos; 107 | } 108 | 109 | // angle must to RADIAN 110 | public bool Skinny (float angle, float threshold) { 111 | if(s0.Length() <= threshold && s1.Length() <= threshold && s2.Length() <= threshold) return false; 112 | 113 | if(Angle(a.Coordinate, b.Coordinate, c.Coordinate) < angle) return true; // angle bac 114 | else if(Angle(b.Coordinate, a.Coordinate, c.Coordinate) < angle) return true; // angle abc 115 | else if(Angle(c.Coordinate, a.Coordinate, b.Coordinate) < angle) return true; // angle acb 116 | return false; 117 | } 118 | 119 | public bool Equals (Triangle2D t) { 120 | return HasPoint(t.a) && HasPoint(t.b) && HasPoint(t.c); 121 | } 122 | 123 | public void DrawGizmos () { 124 | s0.DrawGizmos(); 125 | s1.DrawGizmos(); 126 | s2.DrawGizmos(); 127 | } 128 | 129 | } 130 | 131 | } 132 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Scripts/Triangle2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d9f67eb9a35bd43fbafca4352a90655d 3 | timeCreated: 1466753132 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Scripts/Triangulation2D.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mattatz / http://mattatz.github.io 3 | * 4 | * Ruppert's Delaunay Refinement Algorithm 5 | * Jim Ruppert. A Delaunay Refinement Algorithm for Quality 2-Dimensional Mesh Generation / http://www.cis.upenn.edu/~cis610/ruppert.pdf 6 | * The Quake Group at Carnegie Mellon University / https://www.cs.cmu.edu/~quake/tripaper/triangle3.html 7 | * Wikipedia / https://en.wikipedia.org/wiki/Ruppert%27s_algorithm 8 | * ETH zurich CG13 Chapter 7 / http://www.ti.inf.ethz.ch/ew/Lehre/CG13/lecture/Chapter%207.pdf 9 | */ 10 | 11 | using UnityEngine; 12 | 13 | using System; 14 | using System.Linq; 15 | using System.Collections; 16 | using System.Collections.Generic; 17 | 18 | namespace mattatz.Triangulation2DSystem { 19 | 20 | public class Triangulation2D { 21 | 22 | const float kAngleMax = 30f; 23 | 24 | public Polygon2D Polygon { get { return PSLG; } } 25 | public Triangle2D[] Triangles { get { return T.ToArray(); } } 26 | public List Edges { get { return E; } } 27 | public List Points { get { return P; } } 28 | 29 | List V = new List(); // vertices in PSLG 30 | List S = new List(); // segments in PSLG 31 | 32 | List P = new List(); // vertices in DT 33 | List E = new List(); // segments in DT 34 | 35 | Polygon2D PSLG; 36 | List T = new List(); 37 | 38 | public Triangulation2D (Polygon2D polygon, float angle = 20f, float threshold = 0.1f) { 39 | angle = Mathf.Min(angle, kAngleMax) * Mathf.Deg2Rad; 40 | 41 | PSLG = polygon; 42 | V = PSLG.Vertices.ToList(); 43 | S = PSLG.Segments.ToList(); 44 | Triangulate (polygon.Vertices.Select(v => v.Coordinate).ToArray(), angle, threshold); 45 | } 46 | 47 | public Mesh Build () { 48 | return Build((Vertex2D v) => { 49 | var xy = v.Coordinate; 50 | return new Vector3(xy.x, xy.y, 0f); 51 | }); 52 | } 53 | 54 | public Mesh Build (Func coord) { 55 | var mesh = new Mesh(); 56 | 57 | var vertices = P.Select(p => { 58 | return coord(p); 59 | }).ToArray(); 60 | 61 | var triangles = new List(); 62 | for(int i = 0, n = T.Count; i < n; i++) { 63 | var t = T[i]; 64 | int a = P.IndexOf(t.a), b = P.IndexOf(t.b), c = P.IndexOf(t.c); 65 | if(a < 0 || b < 0 || c < 0) { 66 | // Debug.Log(a + " : " + b + " : " + c); 67 | continue; 68 | } 69 | if(Utils2D.LeftSide(t.a.Coordinate, t.b.Coordinate, t.c.Coordinate)) { 70 | triangles.Add(a); triangles.Add(c); triangles.Add(b); 71 | } else { 72 | triangles.Add(a); triangles.Add(b); triangles.Add(c); 73 | } 74 | } 75 | 76 | mesh.vertices = vertices; 77 | mesh.SetTriangles(triangles.ToArray(), 0); 78 | mesh.RecalculateNormals(); 79 | 80 | return mesh; 81 | } 82 | 83 | int FindVertex (Vector2 p, List Vertices) { 84 | return Vertices.FindIndex (v => { 85 | return v.Coordinate == p; 86 | // return Mathf.Approximately(v.Coordinate.x, p.x) && Mathf.Approximately(v.Coordinate.y, p.y); 87 | }); 88 | } 89 | 90 | int FindSegment (Vertex2D a, Vertex2D b, List Segments) { 91 | return Segments.FindIndex (s => (s.a == a && s.b == b) || (s.a == b && s.b == a)); 92 | } 93 | 94 | public Vertex2D CheckAndAddVertex (Vector2 coord) { 95 | var idx = FindVertex(coord, P); 96 | if(idx < 0) { 97 | var v = new Vertex2D(coord); 98 | P.Add(v); 99 | return v; 100 | } 101 | return P[idx]; 102 | } 103 | 104 | public Segment2D CheckAndAddSegment (Vertex2D a, Vertex2D b) { 105 | var idx = FindSegment(a, b, E); 106 | Segment2D s; 107 | if(idx < 0) { 108 | s = new Segment2D(a, b); 109 | E.Add(s); 110 | } else { 111 | s = E[idx]; 112 | } 113 | s.Increment(); 114 | return s; 115 | } 116 | 117 | public Triangle2D AddTriangle (Vertex2D a, Vertex2D b, Vertex2D c) { 118 | var s0 = CheckAndAddSegment(a, b); 119 | var s1 = CheckAndAddSegment(b, c); 120 | var s2 = CheckAndAddSegment(c, a); 121 | var t = new Triangle2D(s0, s1, s2); 122 | T.Add(t); 123 | return t; 124 | } 125 | 126 | public void RemoveTriangle (Triangle2D t) { 127 | var idx = T.IndexOf(t); 128 | if(idx < 0) return; 129 | 130 | T.RemoveAt(idx); 131 | if(t.s0.Decrement() <= 0) RemoveSegment (t.s0); 132 | if(t.s1.Decrement() <= 0) RemoveSegment (t.s1); 133 | if(t.s2.Decrement() <= 0) RemoveSegment (t.s2); 134 | } 135 | 136 | public void RemoveTriangle (Segment2D s) { 137 | T.FindAll(t => t.HasSegment(s)).ForEach(t => RemoveTriangle(t)); 138 | } 139 | 140 | public void RemoveSegment (Segment2D s) { 141 | E.Remove(s); 142 | if(s.a.ReferenceCount <= 0) P.Remove(s.a); 143 | if(s.b.ReferenceCount <= 0) P.Remove(s.b); 144 | } 145 | 146 | void Bound (Vector2[] points, out Vector2 min, out Vector2 max) { 147 | min = Vector2.one * float.MaxValue; 148 | max = Vector2.one * float.MinValue; 149 | for(int i = 0, n = points.Length; i < n; i++) { 150 | var p = points[i]; 151 | min.x = Mathf.Min (min.x, p.x); 152 | min.y = Mathf.Min (min.y, p.y); 153 | max.x = Mathf.Max (max.x, p.x); 154 | max.y = Mathf.Max (max.y, p.y); 155 | } 156 | } 157 | 158 | public Triangle2D AddExternalTriangle (Vector2 min, Vector2 max) { 159 | var center = (max + min) * 0.5f; 160 | var diagonal = (max - min).magnitude; 161 | var dh = diagonal * 0.5f; 162 | var rdh = Mathf.Sqrt(3f) * dh; 163 | return AddTriangle( 164 | CheckAndAddVertex(center + new Vector2(-rdh, -dh) * 3f), 165 | CheckAndAddVertex(center + new Vector2(rdh, -dh) * 3f), 166 | CheckAndAddVertex(center + new Vector2(0f, diagonal) * 3f) 167 | ); 168 | } 169 | 170 | void Triangulate (Vector2[] points, float angle, float threshold) { 171 | Vector2 min, max; 172 | Bound(points, out min, out max); 173 | 174 | AddExternalTriangle(min, max); 175 | 176 | for(int i = 0, n = points.Length; i < n; i++) { 177 | var v = points[i]; 178 | UpdateTriangulation (v); 179 | } 180 | 181 | Refine (angle, threshold); 182 | RemoveExternalPSLG (); 183 | } 184 | 185 | void RemoveCommonTriangles (Triangle2D target) { 186 | for(int i = 0, n = T.Count; i < n; i++) { 187 | var t = T[i]; 188 | if(t.HasCommonPoint(target)) { 189 | RemoveTriangle (t); 190 | i--; 191 | n--; 192 | } 193 | } 194 | } 195 | 196 | void RemoveExternalPSLG () { 197 | for(int i = 0, n = T.Count; i < n; i++) { 198 | var t = T[i]; 199 | if(ExternalPSLG(t) || HasOuterSegments(t)) { 200 | // if(ExternalPSLG(t)) { 201 | RemoveTriangle (t); 202 | i--; 203 | n--; 204 | } 205 | } 206 | } 207 | 208 | bool ContainsSegments (Segment2D s, List segments) { 209 | return segments.FindIndex (s2 => 210 | (s2.a.Coordinate == s.a.Coordinate && s2.b.Coordinate == s.b.Coordinate) || 211 | (s2.a.Coordinate == s.b.Coordinate && s2.b.Coordinate == s.a.Coordinate) 212 | ) >= 0; 213 | } 214 | 215 | bool HasOuterSegments (Triangle2D t) { 216 | if(!ContainsSegments(t.s0, S)) { 217 | return ExternalPSLG(t.s0); 218 | } 219 | if(!ContainsSegments(t.s1, S)) { 220 | return ExternalPSLG(t.s1); 221 | } 222 | if(!ContainsSegments(t.s2, S)) { 223 | return ExternalPSLG(t.s2); 224 | } 225 | return false; 226 | } 227 | 228 | void UpdateTriangulation (Vector2 p) { 229 | var tmpT = new List(); 230 | var tmpS = new List(); 231 | 232 | var v = CheckAndAddVertex(p); 233 | tmpT = T.FindAll(t => t.ContainsInExternalCircle(v)); 234 | tmpT.ForEach(t => { 235 | tmpS.Add(t.s0); 236 | tmpS.Add(t.s1); 237 | tmpS.Add(t.s2); 238 | 239 | AddTriangle(t.a, t.b, v); 240 | AddTriangle(t.b, t.c, v); 241 | AddTriangle(t.c, t.a, v); 242 | RemoveTriangle (t); 243 | }); 244 | 245 | while(tmpS.Count != 0) { 246 | var s = tmpS.Last(); 247 | tmpS.RemoveAt(tmpS.Count - 1); 248 | 249 | var commonT = T.FindAll(t => t.HasSegment(s)); 250 | if(commonT.Count <= 1) continue; 251 | 252 | var abc = commonT[0]; 253 | var abd = commonT[1]; 254 | 255 | if(abc.Equals(abd)) { 256 | RemoveTriangle (abc); 257 | RemoveTriangle (abd); 258 | continue; 259 | } 260 | 261 | var a = s.a; 262 | var b = s.b; 263 | var c = abc.ExcludePoint(s); 264 | var d = abd.ExcludePoint(s); 265 | 266 | var ec = Circle2D.GetCircumscribedCircle(abc); 267 | if(ec.Contains(d.Coordinate)) { 268 | RemoveTriangle (abc); 269 | RemoveTriangle (abd); 270 | 271 | AddTriangle(a, c, d); // add acd 272 | AddTriangle(b, c, d); // add bcd 273 | 274 | var segments0 = abc.ExcludeSegment(s); 275 | tmpS.Add(segments0[0]); 276 | tmpS.Add(segments0[1]); 277 | 278 | var segments1 = abd.ExcludeSegment(s); 279 | tmpS.Add(segments1[0]); 280 | tmpS.Add(segments1[1]); 281 | } 282 | } 283 | 284 | } 285 | 286 | bool FindAndSplit (float threshold) { 287 | for(int i = 0, n = S.Count; i < n; i++) { 288 | var s = S[i]; 289 | if(s.Length() < threshold) continue; 290 | 291 | for(int j = 0, m = P.Count; j < m; j++) { 292 | if(s.EncroachedUpon(P[j].Coordinate)) { 293 | SplitSegment(s); 294 | return true; 295 | } 296 | } 297 | } 298 | return false; 299 | } 300 | 301 | bool ExternalPSLG (Vector2 p) { 302 | return !Utils2D.Contains(p, V); 303 | } 304 | 305 | bool ExternalPSLG (Segment2D s) { 306 | return ExternalPSLG(s.Midpoint()); 307 | } 308 | 309 | bool ExternalPSLG (Triangle2D t) { 310 | // return ExternalPSLG(t.s0) && ExternalPSLG(t.s1) && ExternalPSLG(t.s2); 311 | return 312 | ExternalPSLG(t.a.Coordinate) || 313 | ExternalPSLG(t.b.Coordinate) || 314 | ExternalPSLG(t.c.Coordinate) 315 | ; 316 | } 317 | 318 | void Refine (float angle, float threshold) { 319 | while(T.Any(t => !ExternalPSLG(t) && t.Skinny(angle, threshold))) { 320 | RefineSubRoutine(angle, threshold); 321 | } 322 | } 323 | 324 | void RefineSubRoutine (float angle, float threshold) { 325 | 326 | while(true) { 327 | if(!FindAndSplit(threshold)) break; 328 | } 329 | 330 | var skinny = T.Find (t => !ExternalPSLG(t) && t.Skinny(angle, threshold)); 331 | var p = skinny.Circumcenter(); 332 | 333 | var segments = S.FindAll(s => s.EncroachedUpon(p)); 334 | if(segments.Count > 0) { 335 | segments.ForEach(s => SplitSegment(s)); 336 | } else { 337 | SplitTriangle(skinny); 338 | } 339 | } 340 | 341 | void SplitTriangle (Triangle2D t) { 342 | var c = t.Circumcenter(); 343 | UpdateTriangulation(c); 344 | } 345 | 346 | void SplitSegment (Segment2D s) { 347 | Vertex2D a = s.a, b = s.b; 348 | var mv = new Vertex2D(s.Midpoint()); 349 | 350 | // add mv to V 351 | // the index is between a and b. 352 | var idxA = V.IndexOf(a); 353 | var idxB = V.IndexOf(b); 354 | if(Mathf.Abs(idxA - idxB) == 1) { 355 | var idx = (idxA > idxB) ? idxA : idxB; 356 | V.Insert(idx, mv); 357 | } else { 358 | V.Add(mv); 359 | } 360 | 361 | UpdateTriangulation(mv.Coordinate); 362 | 363 | // Add two halves to S 364 | var sidx = S.IndexOf(s); 365 | S.RemoveAt(sidx); 366 | 367 | S.Add(new Segment2D(s.a, mv)); 368 | S.Add(new Segment2D(mv, s.b)); 369 | } 370 | 371 | bool CheckUnique () { 372 | var flag = false; 373 | 374 | for(int i = 0, n = P.Count; i < n; i++) { 375 | var v0 = P[i]; 376 | for(int j = i + 1; j < n; j++) { 377 | var v1 = P[j]; 378 | if(Utils2D.CheckEqual(v0, v1)) { 379 | Debug.LogWarning("vertex " + i + " equals " + j); 380 | flag = true; 381 | } 382 | } 383 | } 384 | 385 | for(int i = 0, n = E.Count; i < n; i++) { 386 | var s0 = E[i]; 387 | for(int j = i + 1; j < n; j++) { 388 | var s1 = E[j]; 389 | if(Utils2D.CheckEqual(s0, s1)) { 390 | Debug.LogWarning("segment " + i + " equals " + j); 391 | flag = true; 392 | } 393 | } 394 | } 395 | 396 | for(int i = 0, n = T.Count; i < n; i++) { 397 | var t0 = T[i]; 398 | for(int j = i + 1; j < n; j++) { 399 | var t1 = T[j]; 400 | if(Utils2D.CheckEqual(t0, t1)) { 401 | Debug.LogWarning("triangle " + i + " equals " + j); 402 | flag = true; 403 | } 404 | } 405 | } 406 | 407 | for(int i = 0, n = T.Count; i < n; i++) { 408 | var t = T[i]; 409 | if(Utils2D.CheckEqual(t.s0, t.s1) || Utils2D.CheckEqual(t.s0, t.s2) || Utils2D.CheckEqual(t.s1, t.s2)) { 410 | Debug.LogWarning("triangle " + i + " has duplicated segments"); 411 | flag = true; 412 | } 413 | } 414 | 415 | return flag; 416 | } 417 | 418 | public void DrawGizmos () { 419 | T.ForEach(t => t.DrawGizmos()); 420 | } 421 | 422 | } 423 | 424 | } 425 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Scripts/Triangulation2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a78fb95b758004930bc6358a8f554b36 3 | timeCreated: 1465912497 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Scripts/Utils2D.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | using System; 4 | using System.Linq; 5 | using System.Collections; 6 | using System.Collections.Generic; 7 | 8 | namespace mattatz.Triangulation2DSystem { 9 | 10 | public class Utils2D { 11 | 12 | // constrain a distance between two points to "threshold" length 13 | public static List Constrain (List points, float threshold = 1f) { 14 | var result = new List(); 15 | 16 | var n = points.Count; 17 | for(int i = 0, j = 1; i < n && j < n; j++) { 18 | var from = points[i]; 19 | var to = points[j]; 20 | if(Vector2.Distance(from, to) > threshold) { 21 | result.Add(from); 22 | i = j; 23 | } 24 | } 25 | 26 | var p0 = result.Last(); 27 | var p1 = result.First(); 28 | if(Vector2.Distance(p0, p1) > threshold) { 29 | result.Add((p0 + p1) * 0.5f); 30 | } 31 | 32 | return result; 33 | } 34 | 35 | // http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect 36 | // check intersection segment (p0, p1) to segment (p2, p3) 37 | public static bool Intersect (Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3) { 38 | var s1 = p1 - p0; 39 | var s2 = p3 - p2; 40 | var s = (-s1.y * (p0.x - p2.x) + s1.x * (p0.y - p2.y)) / (-s2.x * s1.y + s1.x * s2.y); 41 | var t = ( s2.x * (p0.y - p2.y) - s2.y * (p0.x - p2.x)) / (-s2.x * s1.y + s1.x * s2.y); 42 | return (s >= 0 && s <= 1 && t >= 0 && t <= 1); 43 | } 44 | 45 | // http://stackoverflow.com/questions/217578/how-can-i-determine-whether-a-2d-point-is-within-a-polygon 46 | public static bool Contains (Vector2 p, List vertices) { 47 | var n = vertices.Count; 48 | bool c = false; 49 | for(int i = 0, j = n - 1; i < n; j = i++) { 50 | if(vertices[i].Coordinate == p) return true; 51 | if ( 52 | ((vertices[i].Coordinate.y > p.y) != (vertices[j].Coordinate.y > p.y)) && 53 | (p.x < (vertices[j].Coordinate.x - vertices[i].Coordinate.x) * (p.y - vertices[i].Coordinate.y) / (vertices[j].Coordinate.y - vertices[i].Coordinate.y) + vertices[i].Coordinate.x) 54 | ) { 55 | c = !c; 56 | } 57 | } 58 | // c == true means odd, c == false means even 59 | return c; 60 | } 61 | 62 | // check p is left side of segment (from, to) 63 | public static bool LeftSide (Vector2 from, Vector2 to, Vector2 p) { 64 | float cross = ((to.x - from.x) * (p.y - from.y) - (to.y - from.y) * (p.x - from.x)); 65 | return (cross > 0f); 66 | } 67 | 68 | public static bool CheckEqual (Vertex2D v0, Vertex2D v1) { 69 | return (v0.Coordinate == v1.Coordinate); 70 | } 71 | 72 | public static bool CheckEqual (Segment2D s0, Segment2D s1) { 73 | return 74 | (CheckEqual(s0.a, s1.a) && CheckEqual(s0.b, s1.b)) || 75 | (CheckEqual(s0.a, s1.b) && CheckEqual(s0.b, s1.a)); 76 | } 77 | 78 | public static bool CheckEqual (Triangle2D t0, Triangle2D t1) { 79 | // 0,1,2 == 0,1,2 80 | // 0,1,2 == 0,2,1 81 | // 0,1,2 == 1,0,2 82 | // 0,1,2 == 1,2,0 83 | // 0,1,2 == 2,0,1 84 | // 0,1,2 == 2,1,0 85 | return 86 | (CheckEqual(t0.s0, t1.s0) && CheckEqual(t0.s1, t1.s1) && CheckEqual(t0.s2, t1.s2)) || 87 | (CheckEqual(t0.s0, t1.s0) && CheckEqual(t0.s1, t1.s2) && CheckEqual(t0.s2, t1.s1)) || 88 | 89 | (CheckEqual(t0.s0, t1.s1) && CheckEqual(t0.s1, t1.s0) && CheckEqual(t0.s2, t1.s2)) || 90 | (CheckEqual(t0.s0, t1.s1) && CheckEqual(t0.s1, t1.s2) && CheckEqual(t0.s2, t1.s0)) || 91 | 92 | (CheckEqual(t0.s0, t1.s2) && CheckEqual(t0.s1, t1.s0) && CheckEqual(t0.s2, t1.s1)) || 93 | (CheckEqual(t0.s0, t1.s2) && CheckEqual(t0.s1, t1.s1) && CheckEqual(t0.s2, t1.s0)); 94 | } 95 | 96 | } 97 | 98 | } 99 | 100 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Scripts/Utils2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 55e48844b4a884e5286a8968e1dcb026 3 | timeCreated: 1466753182 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Scripts/Vertex2D.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | using System; 4 | using System.Linq; 5 | using System.Collections; 6 | using System.Collections.Generic; 7 | 8 | namespace mattatz.Triangulation2DSystem { 9 | 10 | public class Vertex2D { 11 | public int ReferenceCount { get { return reference; } } 12 | public Vector2 Coordinate { get { return coordinate; } } 13 | 14 | Vector2 coordinate; 15 | int reference; 16 | 17 | public Vertex2D (Vector2 coord) { 18 | coordinate = coord; 19 | } 20 | 21 | public int Increment () { 22 | return ++reference; 23 | } 24 | 25 | public int Decrement () { 26 | return --reference; 27 | } 28 | } 29 | 30 | } 31 | 32 | -------------------------------------------------------------------------------- /Assets/Packages/Triangulation2D/Scripts/Vertex2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e02b555c78fb545a09fcf73891eb2d3e 3 | timeCreated: 1466752955 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/StreamingAssets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3794a60a90fe742a299a611aed5cb770 3 | folderAsset: yes 4 | timeCreated: 1467041615 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/StreamingAssets/duck.json: -------------------------------------------------------------------------------- 1 | {"target":[{"x":-4.8453850746154789,"y":1.3892998695373536},{"x":-5.2785868644714359,"y":0.9979575276374817},{"x":-5.869033336639404,"y":0.6435996890068054},{"x":-6.459702014923096,"y":0.48613253235816958},{"x":-6.991237163543701,"y":0.48613253235816958},{"x":-7.050149917602539,"y":1.0176684856414796},{"x":-6.754924774169922,"y":1.4900699853897095},{"x":-6.164478778839111,"y":1.824715256690979},{"x":-5.5540995597839359,"y":1.9821840524673463},{"x":-5.80525016784668,"y":2.4869205951690676},{"x":-5.962717056274414,"y":3.0184550285339357},{"x":-6.021850109100342,"y":3.5894126892089845},{"x":-5.687204360961914,"y":4.042103290557861},{"x":-5.293425559997559,"y":4.416172027587891},{"x":-4.702756881713867,"y":4.790239334106445},{"x":-4.112310409545898,"y":4.969852924346924},{"x":-3.5610642433166506,"y":5.0878987312316898},{"x":-3.009817123413086,"y":5.0878987312316898},{"x":-2.4388606548309328,"y":4.927995204925537},{"x":-2.0255916118621828,"y":4.475305080413818},{"x":-1.927035927772522,"y":3.8060126304626467},{"x":-1.927035927772522,"y":3.077587842941284},{"x":-2.0453033447265627,"y":2.3097424507141115},{"x":-2.0453033447265627,"y":1.7192943096160889},{"x":-2.0453033447265627,"y":1.0694924592971802},{"x":-2.0453033447265627,"y":0.4987567365169525},{"x":-1.631812572479248,"y":-0.03277838975191116},{"x":-1.0805667638778687,"y":-0.1707558035850525},{"x":-0.4898983836174011,"y":-0.22966744005680085},{"x":0.45490604639053347,"y":-0.22966744005680085},{"x":1.6165307760238648,"y":-0.22966744005680085},{"x":2.6204683780670168,"y":0.12468960136175156},{"x":3.8607177734375,"y":0.7151363492012024},{"x":4.333118915557861,"y":0.9908708333969116},{"x":5.278143405914307,"y":1.758495569229126},{"x":6.045991897583008,"y":2.467209815979004},{"x":6.931883811950684,"y":3.175922155380249},{"x":7.364863395690918,"y":3.5499908924102785},{"x":7.837484836578369,"y":3.8454349040985109},{"x":8.526488304138184,"y":3.96347975730896},{"x":9.116934776306153,"y":3.786301612854004},{"x":8.998888969421387,"y":3.0995140075683595},{"x":8.841421127319336,"y":2.4696452617645265},{"x":8.782289505004883,"y":1.839776635169983},{"x":9.077733993530274,"y":1.3082408905029297},{"x":9.176068305969239,"y":0.48126113414764407},{"x":9.176068305969239,"y":-0.22745294868946076},{"x":9.176068305969239,"y":-0.7786989808082581},{"x":9.116934776306153,"y":-1.4282792806625367},{"x":8.723376274108887,"y":-1.8417692184448243},{"x":8.250755310058594,"y":-2.314171552658081},{"x":7.778351306915283,"y":-2.7865731716156008},{"x":6.951592922210693,"y":-3.554419755935669},{"x":5.691634178161621,"y":-4.440311908721924},{"x":4.451385021209717,"y":-5.149024963378906},{"x":3.624405860900879,"y":-5.503382682800293},{"x":2.206977367401123,"y":-6.015206813812256},{"x":1.3802188634872437,"y":-6.192384719848633},{"x":0.6123729944229126,"y":-6.310429573059082},{"x":-0.15525254607200623,"y":-6.310429573059082},{"x":-1.139699935913086,"y":-6.310429573059082},{"x":-1.9073253870010377,"y":-5.956072807312012},{"x":-2.4979937076568605,"y":-5.601716041564941},{"x":-2.8523502349853517,"y":-5.188447952270508},{"x":-3.2855517864227297,"y":-4.518934726715088},{"x":-3.580775022506714,"y":-4.007110595703125},{"x":-3.757953643798828,"y":-3.4755754470825197},{"x":-3.994044065475464,"y":-2.7079505920410158},{"x":-4.033466815948486,"y":-2.0189473628997804},{"x":-4.033466815948486,"y":-1.0147895812988282},{"x":-3.738241672515869,"y":-0.30607548356056216},{"x":-3.8957102298736574,"y":0.26488152146339419}]} 2 | -------------------------------------------------------------------------------- /Assets/StreamingAssets/duck.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f74f130b181b74ab8995e97cdefd7a09 3 | timeCreated: 1468330058 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/StreamingAssets/human.json: -------------------------------------------------------------------------------- 1 | {"target":[{"x":-1.6334539651870728,"y":4.719587802886963},{"x":-2.4290318489074709,"y":6.219128131866455},{"x":-2.0078125,"y":7.716914653778076},{"x":0.05142351984977722,"y":8.372086524963379},{"x":1.5646544694900513,"y":7.576507568359375},{"x":1.7675410509109498,"y":5.782464981079102},{"x":2.4365782737731935,"y":4.37647008895874},{"x":3.450489044189453,"y":3.2375969886779787},{"x":4.433333873748779,"y":1.927078127861023},{"x":5.150987148284912,"y":0.5386336445808411},{"x":5.806158542633057,"y":-1.6610084772109986},{"x":6.102590084075928,"y":-3.455052137374878},{"x":6.149451732635498,"y":-5.093244552612305},{"x":4.448955059051514,"y":-5.327197074890137},{"x":3.450489044189453,"y":-3.7046244144439699},{"x":3.31008243560791,"y":-1.785794973373413},{"x":3.31008243560791,"y":-0.19446271657943726},{"x":2.625601053237915,"y":-2.035367012023926},{"x":2.4539544582366945,"y":-3.9854369163513185},{"x":2.3604087829589845,"y":-5.529909133911133},{"x":1.7206817865371705,"y":-7.292886257171631},{"x":0.5038829445838928,"y":-8.509684562683106},{"x":-0.43210121989250185,"y":-6.310041427612305},{"x":-0.3854159116744995,"y":-2.940286636352539},{"x":-1.0249671936035157,"y":-4.311180591583252},{"x":-1.9765723943710328,"y":-6.214565277099609},{"x":-3.006277561187744,"y":-7.4782233238220219},{"x":-4.597609996795654,"y":-8.414207458496094},{"x":-5.127994537353516,"y":-5.528153896331787},{"x":-4.425962448120117,"y":-4.170773506164551},{"x":-3.349395751953125,"y":-2.1115376949310304},{"x":-2.5069570541381838,"y":-0.6139275431632996},{"x":-1.6645184755325318,"y":0.8682382702827454},{"x":-2.9750373363494875,"y":-0.3468041718006134},{"x":-4.893867015838623,"y":-1.750868558883667},{"x":-6.407273769378662,"y":-2.4685213565826418},{"x":-6.859557628631592,"y":-0.7211626768112183},{"x":-6.438338279724121,"y":1.0572609901428223},{"x":-5.252780914306641,"y":2.508185625076294},{"x":-3.8330962657928469,"y":3.178978204727173},{"x":-2.4290318489074709,"y":3.8810107707977297}]} 2 | -------------------------------------------------------------------------------- /Assets/StreamingAssets/human.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9d748984ad3714fe98bcc2836c641d2e 3 | timeCreated: 1468390233 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/StreamingAssets/points.json: -------------------------------------------------------------------------------- 1 | {"target":[{"x":-1.6334539651870728,"y":4.719587802886963},{"x":-2.4290318489074709,"y":6.219128131866455},{"x":-2.0078125,"y":7.716914653778076},{"x":0.05142351984977722,"y":8.372086524963379},{"x":1.5646544694900513,"y":7.576507568359375},{"x":1.7675410509109498,"y":5.782464981079102},{"x":2.4365782737731935,"y":4.37647008895874},{"x":3.450489044189453,"y":3.2375969886779787},{"x":4.433333873748779,"y":1.927078127861023},{"x":5.150987148284912,"y":0.5386336445808411},{"x":5.806158542633057,"y":-1.6610084772109986},{"x":6.102590084075928,"y":-3.455052137374878},{"x":6.149451732635498,"y":-5.093244552612305},{"x":4.448955059051514,"y":-5.327197074890137},{"x":3.450489044189453,"y":-3.7046244144439699},{"x":3.31008243560791,"y":-1.785794973373413},{"x":3.31008243560791,"y":-0.19446271657943726},{"x":2.625601053237915,"y":-2.035367012023926},{"x":2.4539544582366945,"y":-3.9854369163513185},{"x":2.3604087829589845,"y":-5.529909133911133},{"x":1.7206817865371705,"y":-7.292886257171631},{"x":0.5038829445838928,"y":-8.509684562683106},{"x":-0.43210121989250185,"y":-6.310041427612305},{"x":-0.3854159116744995,"y":-2.940286636352539},{"x":-1.0249671936035157,"y":-4.311180591583252},{"x":-1.9765723943710328,"y":-6.214565277099609},{"x":-3.006277561187744,"y":-7.4782233238220219},{"x":-4.597609996795654,"y":-8.414207458496094},{"x":-5.127994537353516,"y":-5.528153896331787},{"x":-4.425962448120117,"y":-4.170773506164551},{"x":-3.349395751953125,"y":-2.1115376949310304},{"x":-2.5069570541381838,"y":-0.6139275431632996},{"x":-1.6645184755325318,"y":0.8682382702827454},{"x":-2.9750373363494875,"y":-0.3468041718006134},{"x":-4.893867015838623,"y":-1.750868558883667},{"x":-6.407273769378662,"y":-2.4685213565826418},{"x":-6.859557628631592,"y":-0.7211626768112183},{"x":-6.438338279724121,"y":1.0572609901428223},{"x":-5.252780914306641,"y":2.508185625076294},{"x":-3.8330962657928469,"y":3.178978204727173},{"x":-2.4290318489074709,"y":3.8810107707977297}]} 2 | -------------------------------------------------------------------------------- /Assets/StreamingAssets/points.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c0d7513ae5d6e46ec961e98e3ce97f6d 3 | timeCreated: 1467041628 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/StreamingAssets/tako.json: -------------------------------------------------------------------------------- 1 | {"target":[{"x":9.919037818908692,"y":-7.466579437255859},{"x":6.764720439910889,"y":-7.988295555114746},{"x":3.486116647720337,"y":-7.988295555114746},{"x":0.7786656618118286,"y":-7.41686487197876},{"x":-0.3390601873397827,"y":-6.001136779785156},{"x":-1.5310757160186768,"y":-4.734549522399902},{"x":-3.220231294631958,"y":-4.510837078094482},{"x":-4.8593926429748539,"y":-4.585407733917236},{"x":-6.1014018058776859,"y":-5.7279887199401859},{"x":-7.293419361114502,"y":-6.696571350097656},{"x":-9.156292915344239,"y":-7.367150783538818},{"x":-10.845168113708496,"y":-7.516292095184326},{"x":-12.112034797668457,"y":-6.1005635261535648},{"x":-12.956611633300782,"y":-4.510837078094482},{"x":-12.36032485961914,"y":-2.349958658218384},{"x":-11.019166946411133,"y":-1.6048089265823365},{"x":-8.883145332336426,"y":-1.3813754320144654},{"x":-7.243704795837402,"y":-0.7107968926429749},{"x":-6.722266674041748,"y":0.8292168378829956},{"x":-7.541988372802734,"y":2.9155232906341554},{"x":-8.957716941833496,"y":3.809814453125},{"x":-9.702866554260254,"y":5.896122455596924},{"x":-9.479153633117676,"y":7.833288669586182},{"x":-7.988853931427002,"y":9.273874282836914},{"x":-5.9025468826293949,"y":9.125011444091797},{"x":-4.611103057861328,"y":8.18100643157959},{"x":-3.7913818359375,"y":6.467273712158203},{"x":-4.039672374725342,"y":4.654112815856934},{"x":-4.039672374725342,"y":3.08952260017395},{"x":-2.5990865230560304,"y":1.84751296043396},{"x":-0.9599250555038452,"y":1.7729417085647584},{"x":0.9775198698043823,"y":2.816096305847168},{"x":1.8218177556991578,"y":4.107818603515625},{"x":4.2561235427856449,"y":3.7352449893951418},{"x":5.2992777824401859,"y":1.8723701238632203},{"x":5.199850082397461,"y":0.1834946870803833},{"x":3.336975574493408,"y":-1.455946683883667},{"x":3.2375473976135256,"y":-3.1945362091064455},{"x":4.727846145629883,"y":-4.585407733917236},{"x":6.51615047454834,"y":-4.883411407470703},{"x":8.081019401550293,"y":-4.808840751647949},{"x":9.198745727539063,"y":-3.1696791648864748},{"x":9.645890235900879,"y":-1.2322337627410889},{"x":9.720183372497559,"y":1.1520780324935914},{"x":11.086477279663086,"y":2.41866397857666},{"x":12.725637435913086,"y":1.375510811805725},{"x":13.470788955688477,"y":-0.38793572783470156},{"x":13.619929313659668,"y":-1.952526330947876},{"x":13.520501136779786,"y":-3.7656872272491457},{"x":12.477349281311036,"y":-5.032553195953369}]} 2 | -------------------------------------------------------------------------------- /Assets/StreamingAssets/tako.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e30bb79a3fc64b47be249c340bde335 3 | timeCreated: 1468375690 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Teddy.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9293f25c9092d4de09413fa6edf9785c 3 | folderAsset: yes 4 | timeCreated: 1465912475 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Teddy/JSON.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c99f5161102634d6190e010a6bc9063e 3 | folderAsset: yes 4 | timeCreated: 1473470217 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Teddy/JSON/duck.json: -------------------------------------------------------------------------------- 1 | {"target":[{"x":-4.8453850746154789,"y":1.3892998695373536},{"x":-5.2785868644714359,"y":0.9979575276374817},{"x":-5.869033336639404,"y":0.6435996890068054},{"x":-6.459702014923096,"y":0.48613253235816958},{"x":-6.991237163543701,"y":0.48613253235816958},{"x":-7.050149917602539,"y":1.0176684856414796},{"x":-6.754924774169922,"y":1.4900699853897095},{"x":-6.164478778839111,"y":1.824715256690979},{"x":-5.5540995597839359,"y":1.9821840524673463},{"x":-5.80525016784668,"y":2.4869205951690676},{"x":-5.962717056274414,"y":3.0184550285339357},{"x":-6.021850109100342,"y":3.5894126892089845},{"x":-5.687204360961914,"y":4.042103290557861},{"x":-5.293425559997559,"y":4.416172027587891},{"x":-4.702756881713867,"y":4.790239334106445},{"x":-4.112310409545898,"y":4.969852924346924},{"x":-3.5610642433166506,"y":5.0878987312316898},{"x":-3.009817123413086,"y":5.0878987312316898},{"x":-2.4388606548309328,"y":4.927995204925537},{"x":-2.0255916118621828,"y":4.475305080413818},{"x":-1.927035927772522,"y":3.8060126304626467},{"x":-1.927035927772522,"y":3.077587842941284},{"x":-2.0453033447265627,"y":2.3097424507141115},{"x":-2.0453033447265627,"y":1.7192943096160889},{"x":-2.0453033447265627,"y":1.0694924592971802},{"x":-2.0453033447265627,"y":0.4987567365169525},{"x":-1.631812572479248,"y":-0.03277838975191116},{"x":-1.0805667638778687,"y":-0.1707558035850525},{"x":-0.4898983836174011,"y":-0.22966744005680085},{"x":0.45490604639053347,"y":-0.22966744005680085},{"x":1.6165307760238648,"y":-0.22966744005680085},{"x":2.6204683780670168,"y":0.12468960136175156},{"x":3.8607177734375,"y":0.7151363492012024},{"x":4.333118915557861,"y":0.9908708333969116},{"x":5.278143405914307,"y":1.758495569229126},{"x":6.045991897583008,"y":2.467209815979004},{"x":6.931883811950684,"y":3.175922155380249},{"x":7.364863395690918,"y":3.5499908924102785},{"x":7.837484836578369,"y":3.8454349040985109},{"x":8.526488304138184,"y":3.96347975730896},{"x":9.116934776306153,"y":3.786301612854004},{"x":8.998888969421387,"y":3.0995140075683595},{"x":8.841421127319336,"y":2.4696452617645265},{"x":8.782289505004883,"y":1.839776635169983},{"x":9.077733993530274,"y":1.3082408905029297},{"x":9.176068305969239,"y":0.48126113414764407},{"x":9.176068305969239,"y":-0.22745294868946076},{"x":9.176068305969239,"y":-0.7786989808082581},{"x":9.116934776306153,"y":-1.4282792806625367},{"x":8.723376274108887,"y":-1.8417692184448243},{"x":8.250755310058594,"y":-2.314171552658081},{"x":7.778351306915283,"y":-2.7865731716156008},{"x":6.951592922210693,"y":-3.554419755935669},{"x":5.691634178161621,"y":-4.440311908721924},{"x":4.451385021209717,"y":-5.149024963378906},{"x":3.624405860900879,"y":-5.503382682800293},{"x":2.206977367401123,"y":-6.015206813812256},{"x":1.3802188634872437,"y":-6.192384719848633},{"x":0.6123729944229126,"y":-6.310429573059082},{"x":-0.15525254607200623,"y":-6.310429573059082},{"x":-1.139699935913086,"y":-6.310429573059082},{"x":-1.9073253870010377,"y":-5.956072807312012},{"x":-2.4979937076568605,"y":-5.601716041564941},{"x":-2.8523502349853517,"y":-5.188447952270508},{"x":-3.2855517864227297,"y":-4.518934726715088},{"x":-3.580775022506714,"y":-4.007110595703125},{"x":-3.757953643798828,"y":-3.4755754470825197},{"x":-3.994044065475464,"y":-2.7079505920410158},{"x":-4.033466815948486,"y":-2.0189473628997804},{"x":-4.033466815948486,"y":-1.0147895812988282},{"x":-3.738241672515869,"y":-0.30607548356056216},{"x":-3.8957102298736574,"y":0.26488152146339419}]} 2 | -------------------------------------------------------------------------------- /Assets/Teddy/JSON/duck.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 72f9004f4ed974c2f9937c6255a4f921 3 | timeCreated: 1473470228 4 | licenseType: Free 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Teddy/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3d059b773c63f40789428e243c339be7 3 | folderAsset: yes 4 | timeCreated: 1467041638 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Teddy/Materials/DebugChordLine.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: DebugChordLine 10 | m_Shader: {fileID: 4800000, guid: 021159c8f4a784b01be31b14171759ce, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 5 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: 2000 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _Glossiness: 0.5 63 | - _Metallic: 0 64 | - _Mode: 0 65 | - _OcclusionStrength: 1 66 | - _Parallax: 0.02 67 | - _SrcBlend: 1 68 | - _UVSec: 0 69 | - _ZWrite: 1 70 | m_Colors: 71 | - _Color: {r: 1, g: 0, b: 0, a: 1} 72 | - _Color0: {r: 0, g: 0, b: 1, a: 1} 73 | - _Color1: {r: 1, g: 0, b: 0, a: 1} 74 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 75 | -------------------------------------------------------------------------------- /Assets/Teddy/Materials/DebugChordLine.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 883e2b18d203147fbada1558849a276a 3 | timeCreated: 1467426554 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Teddy/Materials/DebugNormal.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: DebugNormal 10 | m_Shader: {fileID: 4800000, guid: 5d55d943652bf4080a3ce8c50255a814, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 5 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: 2000 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _Glossiness: 0.5 63 | - _Metallic: 0 64 | - _Mode: 0 65 | - _OcclusionStrength: 1 66 | - _Parallax: 0.02 67 | - _SrcBlend: 1 68 | - _UVSec: 0 69 | - _ZWrite: 1 70 | m_Colors: 71 | - _Color: {r: 1, g: 0, b: 0, a: 1} 72 | - _Color0: {r: 0, g: 0, b: 1, a: 1} 73 | - _Color1: {r: 1, g: 0, b: 0, a: 1} 74 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 75 | -------------------------------------------------------------------------------- /Assets/Teddy/Materials/DebugNormal.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c018b24602b9a4c19aafcb56eec3a757 3 | timeCreated: 1467646486 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Teddy/Materials/Puppet.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: Puppet 10 | m_Shader: {fileID: 4800000, guid: ca4b91d62092947848c78a75ffc52a5c, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 5 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | - _Ramp: 58 | m_Texture: {fileID: 2800000, guid: 42159495a12894c9c817fa639498ac80, type: 3} 59 | m_Scale: {x: 1, y: 1} 60 | m_Offset: {x: 0, y: 0} 61 | m_Floats: 62 | - _BumpScale: 1 63 | - _Cutoff: 0.5 64 | - _DetailNormalMapScale: 1 65 | - _DstBlend: 0 66 | - _EdgeLength: 1 67 | - _Glossiness: 0.5 68 | - _Metallic: 0 69 | - _Mode: 0 70 | - _OcclusionStrength: 1 71 | - _Parallax: 0.02 72 | - _Phong: 1 73 | - _SrcBlend: 1 74 | - _UVSec: 0 75 | - _ZWrite: 1 76 | m_Colors: 77 | - _Color: {r: 1, g: 1, b: 1, a: 1} 78 | - _Displacement: {r: 0.15, g: 0.75, b: 1, a: -1} 79 | - _DisplacementParams: {r: 0.32, g: 0.72, b: 0.2, a: -1} 80 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 81 | - _Params: {r: 0.47, g: 0.32, b: 1.44, a: -1} 82 | - _ToonParams: {r: 0.47, g: 0.32, b: 1.44, a: -1} 83 | -------------------------------------------------------------------------------- /Assets/Teddy/Materials/Puppet.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a6213c5183b6b40369cd890fb08448af 3 | timeCreated: 1468396622 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Teddy/Materials/Teddy.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: Teddy 10 | m_Shader: {fileID: 4800000, guid: 9cf4168ef735b469d8dedd819be76a97, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 5 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: 2000 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _EdgeLength: 1 63 | - _Glossiness: 0.5 64 | - _Metallic: 0 65 | - _Mode: 0 66 | - _OcclusionStrength: 1 67 | - _Parallax: 0.02 68 | - _Phong: 1 69 | - _SrcBlend: 1 70 | - _UVSec: 0 71 | - _ZWrite: 1 72 | m_Colors: 73 | - _Color: {r: 1, g: 1, b: 1, a: 1} 74 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 75 | -------------------------------------------------------------------------------- /Assets/Teddy/Materials/Teddy.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b52b0d7b6c4314502aa9a51b347b2c1e 3 | timeCreated: 1467718979 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Teddy/Materials/TeddyDebug.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: TeddyDebug 10 | m_Shader: {fileID: 4800000, guid: d3941bee5d42e4f5387e22269e04f6b5, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 5 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: 2000 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _EdgeLength: 1 63 | - _Glossiness: 0.5 64 | - _Metallic: 0 65 | - _Mode: 0 66 | - _OcclusionStrength: 1 67 | - _Parallax: 0.02 68 | - _Phong: 1 69 | - _SrcBlend: 1 70 | - _UVSec: 0 71 | - _ZWrite: 1 72 | m_Colors: 73 | - _Color: {r: 1, g: 1, b: 1, a: 1} 74 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 75 | -------------------------------------------------------------------------------- /Assets/Teddy/Materials/TeddyDebug.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 828fc864d081c4f618f5086c3aae6fb7 3 | timeCreated: 1468331826 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Teddy/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 97ed8592fffa5483cbcf5a4d5dc71230 3 | folderAsset: yes 4 | timeCreated: 1467041642 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Teddy/Prefabs/Puppet.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &141416 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 6 9 | m_Component: 10 | - component: {fileID: 400728} 11 | - component: {fileID: 3339914} 12 | - component: {fileID: 2392808} 13 | - component: {fileID: 6417168} 14 | - component: {fileID: 5445668} 15 | - component: {fileID: 11453512} 16 | m_Layer: 0 17 | m_Name: Puppet 18 | m_TagString: Untagged 19 | m_Icon: {fileID: 0} 20 | m_NavMeshLayer: 0 21 | m_StaticEditorFlags: 0 22 | m_IsActive: 1 23 | --- !u!4 &400728 24 | Transform: 25 | m_ObjectHideFlags: 1 26 | m_CorrespondingSourceObject: {fileID: 0} 27 | m_PrefabInternal: {fileID: 100100000} 28 | m_GameObject: {fileID: 141416} 29 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 30 | m_LocalPosition: {x: 0, y: 0, z: 0} 31 | m_LocalScale: {x: 1, y: 1, z: 1} 32 | m_Children: [] 33 | m_Father: {fileID: 0} 34 | m_RootOrder: 0 35 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 36 | --- !u!23 &2392808 37 | MeshRenderer: 38 | m_ObjectHideFlags: 1 39 | m_CorrespondingSourceObject: {fileID: 0} 40 | m_PrefabInternal: {fileID: 100100000} 41 | m_GameObject: {fileID: 141416} 42 | m_Enabled: 1 43 | m_CastShadows: 1 44 | m_ReceiveShadows: 1 45 | m_DynamicOccludee: 1 46 | m_MotionVectors: 1 47 | m_LightProbeUsage: 1 48 | m_ReflectionProbeUsage: 1 49 | m_RenderingLayerMask: 4294967295 50 | m_Materials: 51 | - {fileID: 2100000, guid: a6213c5183b6b40369cd890fb08448af, type: 2} 52 | m_StaticBatchInfo: 53 | firstSubMesh: 0 54 | subMeshCount: 0 55 | m_StaticBatchRoot: {fileID: 0} 56 | m_ProbeAnchor: {fileID: 0} 57 | m_LightProbeVolumeOverride: {fileID: 0} 58 | m_ScaleInLightmap: 1 59 | m_PreserveUVs: 0 60 | m_IgnoreNormalsForChartDetection: 0 61 | m_ImportantGI: 0 62 | m_StitchLightmapSeams: 0 63 | m_SelectedEditorRenderState: 3 64 | m_MinimumChartSize: 4 65 | m_AutoUVMaxDistance: 0.5 66 | m_AutoUVMaxAngle: 89 67 | m_LightmapParameters: {fileID: 0} 68 | m_SortingLayerID: 0 69 | m_SortingLayer: 0 70 | m_SortingOrder: 0 71 | --- !u!33 &3339914 72 | MeshFilter: 73 | m_ObjectHideFlags: 1 74 | m_CorrespondingSourceObject: {fileID: 0} 75 | m_PrefabInternal: {fileID: 100100000} 76 | m_GameObject: {fileID: 141416} 77 | m_Mesh: {fileID: 0} 78 | --- !u!54 &5445668 79 | Rigidbody: 80 | m_ObjectHideFlags: 1 81 | m_CorrespondingSourceObject: {fileID: 0} 82 | m_PrefabInternal: {fileID: 100100000} 83 | m_GameObject: {fileID: 141416} 84 | serializedVersion: 2 85 | m_Mass: 1 86 | m_Drag: 0 87 | m_AngularDrag: 0.05 88 | m_UseGravity: 1 89 | m_IsKinematic: 0 90 | m_Interpolate: 0 91 | m_Constraints: 0 92 | m_CollisionDetection: 0 93 | --- !u!64 &6417168 94 | MeshCollider: 95 | m_ObjectHideFlags: 1 96 | m_CorrespondingSourceObject: {fileID: 0} 97 | m_PrefabInternal: {fileID: 100100000} 98 | m_GameObject: {fileID: 141416} 99 | m_Material: {fileID: 0} 100 | m_IsTrigger: 0 101 | m_Enabled: 1 102 | serializedVersion: 3 103 | m_Convex: 1 104 | m_CookingOptions: 14 105 | m_SkinWidth: 0.01 106 | m_Mesh: {fileID: 0} 107 | --- !u!114 &11453512 108 | MonoBehaviour: 109 | m_ObjectHideFlags: 1 110 | m_CorrespondingSourceObject: {fileID: 0} 111 | m_PrefabInternal: {fileID: 100100000} 112 | m_GameObject: {fileID: 141416} 113 | m_Enabled: 1 114 | m_EditorHideFlags: 0 115 | m_Script: {fileID: 11500000, guid: 5817590b6aa7e4011a3f1845657530b5, type: 3} 116 | m_Name: 117 | m_EditorClassIdentifier: 118 | colors: 119 | - r: 1 120 | g: 0.49264705 121 | b: 0.49264705 122 | a: 1 123 | - r: 0.63235295 124 | g: 0.75659233 125 | b: 1 126 | a: 1 127 | - r: 0.66176474 128 | g: 1 129 | b: 0.81805277 130 | a: 1 131 | - r: 0.9723124 132 | g: 1 133 | b: 0.71323526 134 | a: 1 135 | - r: 0.9219067 136 | g: 0.74264705 137 | b: 1 138 | a: 1 139 | - r: 0.74264705 140 | g: 1 141 | b: 0.98935086 142 | a: 1 143 | - r: 1 144 | g: 0.85882354 145 | b: 0.64705884 146 | a: 1 147 | --- !u!1001 &100100000 148 | Prefab: 149 | m_ObjectHideFlags: 1 150 | serializedVersion: 2 151 | m_Modification: 152 | m_TransformParent: {fileID: 0} 153 | m_Modifications: [] 154 | m_RemovedComponents: [] 155 | m_SourcePrefab: {fileID: 0} 156 | m_RootGameObject: {fileID: 141416} 157 | m_IsPrefabAsset: 1 158 | -------------------------------------------------------------------------------- /Assets/Teddy/Prefabs/Puppet.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0df663ac47d80449490f30c901572dba 3 | timeCreated: 1468394377 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Teddy/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 154e458631f6c4c6882b01d3f13a0c0b 3 | folderAsset: yes 4 | timeCreated: 1467041636 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Teddy/Scenes/Demo.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 9 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &3 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 11 47 | m_GIWorkflowMode: 0 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_TemporalCoherenceThreshold: 1 54 | m_EnvironmentLightingMode: 0 55 | m_EnableBakedLightmaps: 1 56 | m_EnableRealtimeLightmaps: 1 57 | m_LightmapEditorSettings: 58 | serializedVersion: 10 59 | m_Resolution: 2 60 | m_BakeResolution: 40 61 | m_AtlasSize: 1024 62 | m_AO: 0 63 | m_AOMaxDistance: 1 64 | m_CompAOExponent: 0 65 | m_CompAOExponentDirect: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 1024 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 1 75 | m_BakeBackend: 0 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 500 79 | m_PVRBounces: 2 80 | m_PVRFilterTypeDirect: 0 81 | m_PVRFilterTypeIndirect: 0 82 | m_PVRFilterTypeAO: 0 83 | m_PVRFilteringMode: 0 84 | m_PVRCulling: 1 85 | m_PVRFilteringGaussRadiusDirect: 1 86 | m_PVRFilteringGaussRadiusIndirect: 5 87 | m_PVRFilteringGaussRadiusAO: 2 88 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 89 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 90 | m_PVRFilteringAtrousPositionSigmaAO: 1 91 | m_ShowResolutionOverlay: 1 92 | m_LightingDataAsset: {fileID: 0} 93 | m_UseShadowmask: 0 94 | --- !u!196 &4 95 | NavMeshSettings: 96 | serializedVersion: 2 97 | m_ObjectHideFlags: 0 98 | m_BuildSettings: 99 | serializedVersion: 2 100 | agentTypeID: 0 101 | agentRadius: 0.5 102 | agentHeight: 2 103 | agentSlope: 45 104 | agentClimb: 0.4 105 | ledgeDropHeight: 0 106 | maxJumpAcrossDistance: 0 107 | minRegionArea: 2 108 | manualCellSize: 0 109 | cellSize: 0.16666667 110 | manualTileSize: 0 111 | tileSize: 256 112 | accuratePlacement: 0 113 | debug: 114 | m_Flags: 0 115 | m_NavMeshData: {fileID: 0} 116 | --- !u!1 &776161038 117 | GameObject: 118 | m_ObjectHideFlags: 0 119 | m_CorrespondingSourceObject: {fileID: 0} 120 | m_PrefabInternal: {fileID: 0} 121 | serializedVersion: 6 122 | m_Component: 123 | - component: {fileID: 776161043} 124 | - component: {fileID: 776161042} 125 | - component: {fileID: 776161041} 126 | - component: {fileID: 776161040} 127 | - component: {fileID: 776161039} 128 | m_Layer: 0 129 | m_Name: Main Camera 130 | m_TagString: MainCamera 131 | m_Icon: {fileID: 0} 132 | m_NavMeshLayer: 0 133 | m_StaticEditorFlags: 0 134 | m_IsActive: 1 135 | --- !u!81 &776161039 136 | AudioListener: 137 | m_ObjectHideFlags: 0 138 | m_CorrespondingSourceObject: {fileID: 0} 139 | m_PrefabInternal: {fileID: 0} 140 | m_GameObject: {fileID: 776161038} 141 | m_Enabled: 1 142 | --- !u!124 &776161040 143 | Behaviour: 144 | m_ObjectHideFlags: 0 145 | m_CorrespondingSourceObject: {fileID: 0} 146 | m_PrefabInternal: {fileID: 0} 147 | m_GameObject: {fileID: 776161038} 148 | m_Enabled: 1 149 | --- !u!92 &776161041 150 | Behaviour: 151 | m_ObjectHideFlags: 0 152 | m_CorrespondingSourceObject: {fileID: 0} 153 | m_PrefabInternal: {fileID: 0} 154 | m_GameObject: {fileID: 776161038} 155 | m_Enabled: 1 156 | --- !u!20 &776161042 157 | Camera: 158 | m_ObjectHideFlags: 0 159 | m_CorrespondingSourceObject: {fileID: 0} 160 | m_PrefabInternal: {fileID: 0} 161 | m_GameObject: {fileID: 776161038} 162 | m_Enabled: 1 163 | serializedVersion: 2 164 | m_ClearFlags: 2 165 | m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0.019607844} 166 | m_projectionMatrixMode: 1 167 | m_SensorSize: {x: 36, y: 24} 168 | m_LensShift: {x: 0, y: 0} 169 | m_FocalLength: 50 170 | m_NormalizedViewPortRect: 171 | serializedVersion: 2 172 | x: 0 173 | y: 0 174 | width: 1 175 | height: 1 176 | near clip plane: 0.3 177 | far clip plane: 1000 178 | field of view: 60 179 | orthographic: 0 180 | orthographic size: 5 181 | m_Depth: -1 182 | m_CullingMask: 183 | serializedVersion: 2 184 | m_Bits: 4294967295 185 | m_RenderingPath: -1 186 | m_TargetTexture: {fileID: 0} 187 | m_TargetDisplay: 0 188 | m_TargetEye: 3 189 | m_HDR: 0 190 | m_AllowMSAA: 1 191 | m_AllowDynamicResolution: 0 192 | m_ForceIntoRT: 0 193 | m_OcclusionCulling: 1 194 | m_StereoConvergence: 10 195 | m_StereoSeparation: 0.022 196 | --- !u!4 &776161043 197 | Transform: 198 | m_ObjectHideFlags: 0 199 | m_CorrespondingSourceObject: {fileID: 0} 200 | m_PrefabInternal: {fileID: 0} 201 | m_GameObject: {fileID: 776161038} 202 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 203 | m_LocalPosition: {x: 0, y: 0, z: -20} 204 | m_LocalScale: {x: 1, y: 1, z: 1} 205 | m_Children: [] 206 | m_Father: {fileID: 0} 207 | m_RootOrder: 0 208 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 209 | --- !u!1 &1234193948 210 | GameObject: 211 | m_ObjectHideFlags: 0 212 | m_CorrespondingSourceObject: {fileID: 0} 213 | m_PrefabInternal: {fileID: 0} 214 | serializedVersion: 6 215 | m_Component: 216 | - component: {fileID: 1234193949} 217 | - component: {fileID: 1234193950} 218 | - component: {fileID: 1234193951} 219 | - component: {fileID: 1234193952} 220 | m_Layer: 0 221 | m_Name: Demo 222 | m_TagString: Untagged 223 | m_Icon: {fileID: 0} 224 | m_NavMeshLayer: 0 225 | m_StaticEditorFlags: 0 226 | m_IsActive: 1 227 | --- !u!4 &1234193949 228 | Transform: 229 | m_ObjectHideFlags: 0 230 | m_CorrespondingSourceObject: {fileID: 0} 231 | m_PrefabInternal: {fileID: 0} 232 | m_GameObject: {fileID: 1234193948} 233 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 234 | m_LocalPosition: {x: 0, y: 0, z: 0} 235 | m_LocalScale: {x: 1, y: 1, z: 1} 236 | m_Children: [] 237 | m_Father: {fileID: 0} 238 | m_RootOrder: 2 239 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 240 | --- !u!114 &1234193950 241 | MonoBehaviour: 242 | m_ObjectHideFlags: 0 243 | m_CorrespondingSourceObject: {fileID: 0} 244 | m_PrefabInternal: {fileID: 0} 245 | m_GameObject: {fileID: 1234193948} 246 | m_Enabled: 1 247 | m_EditorHideFlags: 0 248 | m_Script: {fileID: 11500000, guid: 7679bc500f3fb4c5baaa57933714ba60, type: 3} 249 | m_Name: 250 | m_EditorClassIdentifier: 251 | fileName: tako 252 | debug: 1 253 | lineMat: {fileID: 2100000, guid: f0eacebf3e8c64a399242fae6d8dcbc8, type: 2} 254 | smoothingTimes: 3 255 | smoothingAlpha: 0.25 256 | smoothingBeta: 0.5 257 | --- !u!33 &1234193951 258 | MeshFilter: 259 | m_ObjectHideFlags: 0 260 | m_CorrespondingSourceObject: {fileID: 0} 261 | m_PrefabInternal: {fileID: 0} 262 | m_GameObject: {fileID: 1234193948} 263 | m_Mesh: {fileID: 0} 264 | --- !u!23 &1234193952 265 | MeshRenderer: 266 | m_ObjectHideFlags: 0 267 | m_CorrespondingSourceObject: {fileID: 0} 268 | m_PrefabInternal: {fileID: 0} 269 | m_GameObject: {fileID: 1234193948} 270 | m_Enabled: 1 271 | m_CastShadows: 0 272 | m_ReceiveShadows: 0 273 | m_DynamicOccludee: 1 274 | m_MotionVectors: 1 275 | m_LightProbeUsage: 0 276 | m_ReflectionProbeUsage: 1 277 | m_RenderingLayerMask: 4294967295 278 | m_Materials: 279 | - {fileID: 2100000, guid: 828fc864d081c4f618f5086c3aae6fb7, type: 2} 280 | m_StaticBatchInfo: 281 | firstSubMesh: 0 282 | subMeshCount: 0 283 | m_StaticBatchRoot: {fileID: 0} 284 | m_ProbeAnchor: {fileID: 0} 285 | m_LightProbeVolumeOverride: {fileID: 0} 286 | m_ScaleInLightmap: 1 287 | m_PreserveUVs: 0 288 | m_IgnoreNormalsForChartDetection: 0 289 | m_ImportantGI: 0 290 | m_StitchLightmapSeams: 0 291 | m_SelectedEditorRenderState: 3 292 | m_MinimumChartSize: 4 293 | m_AutoUVMaxDistance: 0.5 294 | m_AutoUVMaxAngle: 89 295 | m_LightmapParameters: {fileID: 0} 296 | m_SortingLayerID: 0 297 | m_SortingLayer: 0 298 | m_SortingOrder: 0 299 | --- !u!1 &1804214272 300 | GameObject: 301 | m_ObjectHideFlags: 0 302 | m_CorrespondingSourceObject: {fileID: 0} 303 | m_PrefabInternal: {fileID: 0} 304 | serializedVersion: 6 305 | m_Component: 306 | - component: {fileID: 1804214274} 307 | - component: {fileID: 1804214273} 308 | m_Layer: 0 309 | m_Name: Directional light 310 | m_TagString: Untagged 311 | m_Icon: {fileID: 0} 312 | m_NavMeshLayer: 0 313 | m_StaticEditorFlags: 0 314 | m_IsActive: 1 315 | --- !u!108 &1804214273 316 | Light: 317 | m_ObjectHideFlags: 0 318 | m_CorrespondingSourceObject: {fileID: 0} 319 | m_PrefabInternal: {fileID: 0} 320 | m_GameObject: {fileID: 1804214272} 321 | m_Enabled: 1 322 | serializedVersion: 8 323 | m_Type: 1 324 | m_Color: {r: 1, g: 1, b: 1, a: 1} 325 | m_Intensity: 1 326 | m_Range: 10 327 | m_SpotAngle: 30 328 | m_CookieSize: 10 329 | m_Shadows: 330 | m_Type: 0 331 | m_Resolution: -1 332 | m_CustomResolution: -1 333 | m_Strength: 1 334 | m_Bias: 0.05 335 | m_NormalBias: 0.4 336 | m_NearPlane: 0.2 337 | m_Cookie: {fileID: 0} 338 | m_DrawHalo: 0 339 | m_Flare: {fileID: 0} 340 | m_RenderMode: 0 341 | m_CullingMask: 342 | serializedVersion: 2 343 | m_Bits: 4294967295 344 | m_Lightmapping: 4 345 | m_LightShadowCasterMode: 0 346 | m_AreaSize: {x: 1, y: 1} 347 | m_BounceIntensity: 1 348 | m_ColorTemperature: 6570 349 | m_UseColorTemperature: 0 350 | m_ShadowRadius: 0 351 | m_ShadowAngle: 0 352 | --- !u!4 &1804214274 353 | Transform: 354 | m_ObjectHideFlags: 0 355 | m_CorrespondingSourceObject: {fileID: 0} 356 | m_PrefabInternal: {fileID: 0} 357 | m_GameObject: {fileID: 1804214272} 358 | m_LocalRotation: {x: 0.40821794, y: -0.23456973, z: 0.109381676, w: 0.87542605} 359 | m_LocalPosition: {x: 19.28, y: 0.4871986, z: -0.82681346} 360 | m_LocalScale: {x: 1, y: 1, z: 1} 361 | m_Children: [] 362 | m_Father: {fileID: 0} 363 | m_RootOrder: 1 364 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} 365 | -------------------------------------------------------------------------------- /Assets/Teddy/Scenes/Demo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bd973af03d39247b3b4477dfd6f1d113 3 | timeCreated: 1467041649 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Teddy/Scenes/Drawer.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b12308b66fba14939a27adf3325666ca 3 | timeCreated: 1468372696 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Teddy/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df8e67297ddee42b58b2415e951809a7 3 | folderAsset: yes 4 | timeCreated: 1467041635 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Teddy/Scripts/Demo.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | #if UNITY_EDITOR 4 | using UnityEditor; 5 | #endif 6 | 7 | using System; 8 | using System.IO; 9 | using System.Linq; 10 | using System.Collections; 11 | using System.Collections.Generic; 12 | 13 | using mattatz.Utils; 14 | using mattatz.Triangulation2DSystem; 15 | using mattatz.MeshSmoothingSystem; 16 | 17 | namespace mattatz.TeddySystem.Example { 18 | 19 | public class Demo : MonoBehaviour { 20 | 21 | [SerializeField] string fileName = "duck"; 22 | [SerializeField] bool debug = false; 23 | [SerializeField] Material lineMat = null; 24 | 25 | [SerializeField] int smoothingTimes = 5; 26 | [SerializeField, Range(0f, 1f)] float smoothingAlpha = 0.25f, smoothingBeta = 0.5f; 27 | 28 | Teddy teddy; 29 | List contour; 30 | 31 | void Start () { 32 | if(debug) { 33 | var points = LocalStorage.LoadList(fileName + ".json"); 34 | teddy = new Teddy(points); 35 | contour = BuildContourSegments(teddy.triangulation); 36 | GetComponent().sharedMesh = teddy.Build(MeshSmoothingMethod.HC, smoothingTimes, smoothingAlpha, smoothingBeta); 37 | } 38 | } 39 | 40 | List BuildContourSegments (Triangulation2D triangulation) { 41 | var triangles = teddy.triangulation.Triangles; 42 | 43 | var contour = new List(); 44 | 45 | var table = new Dictionary>(); 46 | for(int i = 0, n = triangles.Length; i < n; i++) { 47 | var t = triangles[i]; 48 | if(!table.ContainsKey(t.s0)) table.Add(t.s0, new HashSet()); 49 | if(!table.ContainsKey(t.s1)) table.Add(t.s1, new HashSet()); 50 | if(!table.ContainsKey(t.s2)) table.Add(t.s2, new HashSet()); 51 | 52 | table[t.s0].Add(t); 53 | table[t.s1].Add(t); 54 | table[t.s2].Add(t); 55 | } 56 | 57 | contour = table.Keys.ToList().FindAll(s => { 58 | return table[s].Count == 1; 59 | }).ToList(); 60 | 61 | return contour; 62 | } 63 | 64 | void OnDrawGizmos () { 65 | if(contour != null) { 66 | Gizmos.color = Color.yellow; 67 | contour.ForEach(s => { 68 | Gizmos.DrawLine(s.a.Coordinate, s.b.Coordinate); 69 | }); 70 | } 71 | } 72 | 73 | void OnRenderObject () { 74 | if(teddy == null) return; 75 | 76 | if(teddy.triangulation != null) { 77 | lineMat.SetColor("_Color", Color.black); 78 | DrawTriangles(teddy.triangulation.Triangles); 79 | } 80 | } 81 | 82 | void DrawTriangles (Triangle2D[] triangles) { 83 | GL.PushMatrix(); 84 | GL.MultMatrix (transform.localToWorldMatrix); 85 | 86 | lineMat.SetPass(0); 87 | 88 | GL.Begin(GL.LINES); 89 | 90 | for(int i = 0, n = triangles.Length; i < n; i++) { 91 | var t = triangles[i]; 92 | GL.Vertex(t.s0.a.Coordinate); GL.Vertex(t.s0.b.Coordinate); 93 | GL.Vertex(t.s1.a.Coordinate); GL.Vertex(t.s1.b.Coordinate); 94 | GL.Vertex(t.s2.a.Coordinate); GL.Vertex(t.s2.b.Coordinate); 95 | } 96 | 97 | GL.End(); 98 | GL.PopMatrix(); 99 | } 100 | 101 | } 102 | 103 | } 104 | 105 | -------------------------------------------------------------------------------- /Assets/Teddy/Scripts/Demo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7679bc500f3fb4c5baaa57933714ba60 3 | timeCreated: 1468330397 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Teddy/Scripts/Drawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | using System; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Collections; 7 | using System.Collections.Generic; 8 | 9 | using mattatz.Utils; 10 | using mattatz.Triangulation2DSystem; 11 | 12 | namespace mattatz.TeddySystem.Example { 13 | 14 | public enum OperationMode { 15 | Default, 16 | Draw, 17 | Move 18 | }; 19 | 20 | public class Drawer : MonoBehaviour { 21 | 22 | [SerializeField, Range(0.2f, 1.5f)] float threshold = 1.0f; 23 | [SerializeField] GameObject prefab; 24 | [SerializeField] GameObject floor; 25 | [SerializeField] Material lineMat; 26 | [SerializeField] TextAsset json; 27 | 28 | OperationMode mode; 29 | 30 | Teddy teddy; 31 | List points; 32 | List puppets = new List(); 33 | 34 | Camera cam; 35 | float screenZ = 0f; 36 | 37 | Puppet selected; 38 | Vector3 origin; 39 | Vector3 startPoint; 40 | 41 | void Start () { 42 | cam = Camera.main; 43 | screenZ = Mathf.Abs(cam.transform.position.z - transform.position.z); 44 | 45 | points = new List(); 46 | points = JsonUtility.FromJson>(json.text).ToList(); 47 | Build(); 48 | } 49 | 50 | void Update () { 51 | var bottom = cam.ViewportToWorldPoint(new Vector3(0.5f, 0f, screenZ)); 52 | floor.transform.position = bottom; 53 | 54 | var screen = Input.mousePosition; 55 | screen.z = screenZ; 56 | 57 | switch(mode) { 58 | 59 | case OperationMode.Default: 60 | 61 | if(Input.GetMouseButtonDown(0)) { 62 | Clear(); 63 | 64 | var ray = cam.ScreenPointToRay(screen); 65 | RaycastHit hit; 66 | if(Physics.Raycast(ray.origin, ray.direction, out hit, float.MaxValue)) { 67 | startPoint = cam.ScreenToWorldPoint(screen);; 68 | 69 | selected = hit.collider.GetComponent(); 70 | selected.Select(); 71 | startPoint = hit.point; 72 | origin = selected.transform.position; 73 | 74 | mode = OperationMode.Move; 75 | } else { 76 | mode = OperationMode.Draw; 77 | } 78 | } 79 | 80 | break; 81 | 82 | case OperationMode.Draw: 83 | if(Input.GetMouseButtonUp(0)) { 84 | Build(); 85 | mode = OperationMode.Default; 86 | } else { 87 | var p = cam.ScreenToWorldPoint(screen); 88 | var p2D = new Vector2(p.x, p.y); 89 | if(points.Count <= 0 || Vector2.Distance(p2D, points.Last()) > threshold) { 90 | points.Add(p2D); 91 | } 92 | } 93 | break; 94 | 95 | case OperationMode.Move: 96 | 97 | if(Input.GetMouseButtonUp(0)) { 98 | selected.Unselect(); 99 | selected = null; 100 | 101 | mode = OperationMode.Default; 102 | } else { 103 | var currentPoint = cam.ScreenToWorldPoint(screen); 104 | var offset = currentPoint - startPoint; 105 | selected.transform.position = origin + offset; 106 | } 107 | 108 | break; 109 | 110 | } 111 | 112 | } 113 | 114 | void Build () { 115 | if(points.Count < 3) return; 116 | 117 | points = Utils2D.Constrain(points, threshold); 118 | if(points.Count < 3) return; 119 | 120 | teddy = new Teddy(points); 121 | var mesh = teddy.Build(MeshSmoothingMethod.HC, 2, 0.2f, 0.75f); 122 | var go = Instantiate(prefab); 123 | go.transform.parent = transform; 124 | 125 | var puppet = go.GetComponent(); 126 | puppet.SetMesh(mesh); 127 | puppets.Add(puppet); 128 | } 129 | 130 | void Clear () { 131 | points.Clear(); 132 | } 133 | 134 | public void Save () { 135 | LocalStorage.SaveList(points, "points.json"); 136 | } 137 | 138 | public void Reset () { 139 | puppets.ForEach(puppet => { 140 | puppet.Ignore(); 141 | Destroy(puppet.gameObject, 10f); 142 | }); 143 | puppets.Clear(); 144 | } 145 | 146 | void OnDrawGizmos () { 147 | if(points != null) { 148 | Gizmos.color = Color.white; 149 | points.ForEach(p => { 150 | Gizmos.DrawSphere(p, 0.02f); 151 | }); 152 | } 153 | } 154 | 155 | void OnRenderObject () { 156 | 157 | if(points != null) { 158 | GL.PushMatrix(); 159 | GL.MultMatrix (transform.localToWorldMatrix); 160 | lineMat.SetColor("_Color", Color.white); 161 | lineMat.SetPass(0); 162 | GL.Begin(GL.LINES); 163 | for(int i = 0, n = points.Count - 1; i < n; i++) { 164 | GL.Vertex(points[i]); GL.Vertex(points[i + 1]); 165 | } 166 | GL.End(); 167 | GL.PopMatrix(); 168 | } 169 | 170 | } 171 | 172 | } 173 | 174 | } 175 | 176 | -------------------------------------------------------------------------------- /Assets/Teddy/Scripts/Drawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35da94b020fc249cbad33ac35b2a876f 3 | timeCreated: 1468330112 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Teddy/Scripts/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fdc9a38965335430eb391b92aa5635af 3 | folderAsset: yes 4 | timeCreated: 1468393771 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Teddy/Scripts/Editor/DrawerEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | using System.Collections; 5 | 6 | namespace mattatz.TeddySystem.Example { 7 | 8 | [CustomEditor (typeof(Drawer))] 9 | public class DrawerEditor : Editor { 10 | 11 | public override void OnInspectorGUI () { 12 | base.OnInspectorGUI(); 13 | if(GUILayout.Button("Save")) { 14 | (target as Drawer).Save(); 15 | } 16 | } 17 | 18 | } 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /Assets/Teddy/Scripts/Editor/DrawerEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7aeb0f2e772864f4b9d416c169e471fc 3 | timeCreated: 1468393778 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Teddy/Scripts/Puppet.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using Random = UnityEngine.Random; 3 | 4 | using System; 5 | using System.Linq; 6 | using System.Collections; 7 | using System.Collections.Generic; 8 | 9 | namespace mattatz.TeddySystem.Example { 10 | 11 | [RequireComponent (typeof(Rigidbody), typeof(MeshFilter), typeof(MeshRenderer)) ] 12 | [RequireComponent (typeof(MeshCollider)) ] 13 | public class Puppet : MonoBehaviour { 14 | 15 | Rigidbody body { 16 | get { 17 | if(_body == null) { 18 | _body = GetComponent(); 19 | } 20 | return _body; 21 | } 22 | } 23 | 24 | MeshFilter filter { 25 | get { 26 | if(_filter == null) { 27 | _filter = GetComponent(); 28 | } 29 | return _filter; 30 | } 31 | } 32 | 33 | MeshCollider col { 34 | get { 35 | if(_collider == null) { 36 | _collider = GetComponent(); 37 | } 38 | return _collider; 39 | } 40 | } 41 | 42 | [SerializeField] List colors; 43 | 44 | Rigidbody _body; 45 | MeshFilter _filter; 46 | MeshCollider _collider; 47 | 48 | void Start () { 49 | var rnd = GetComponent(); 50 | MaterialPropertyBlock block = new MaterialPropertyBlock(); 51 | rnd.GetPropertyBlock(block); 52 | block.SetColor("_Color", colors[Random.Range(0, colors.Count)]); 53 | 54 | rnd.SetPropertyBlock(block); 55 | } 56 | 57 | void Update () {} 58 | 59 | public void Ignore () { 60 | col.enabled = false; 61 | } 62 | 63 | public void Select () { 64 | body.isKinematic = true; 65 | } 66 | 67 | public void Unselect () { 68 | body.isKinematic = false; 69 | } 70 | 71 | public void SetMesh (Mesh mesh) { 72 | body.mass = mesh.bounds.size.magnitude; 73 | filter.sharedMesh = mesh; 74 | 75 | if(mesh.triangles.Length > 255 * 3) { 76 | var oVertices = mesh.vertices.ToList(); 77 | var oTriangles = mesh.triangles.ToList(); 78 | int count = oTriangles.Count / 3; 79 | 80 | var vertices = new List(); 81 | var triangles = new List(); 82 | 83 | for(int i = 0; i < 85; i++) { 84 | int idx = Random.Range(0, count) * 3; 85 | int a = oTriangles[idx], b = oTriangles[idx + 1], c = oTriangles[idx + 2]; 86 | int vCount = vertices.Count; 87 | vertices.Add(oVertices[a]); vertices.Add(oVertices[b]); vertices.Add(oVertices[c]); 88 | triangles.Add(vCount); triangles.Add(vCount + 1); triangles.Add(vCount + 2); 89 | 90 | oTriangles.RemoveAt(idx + 2); 91 | oTriangles.RemoveAt(idx + 1); 92 | oTriangles.RemoveAt(idx); 93 | count -= 3; 94 | } 95 | 96 | var colliderMesh = new Mesh(); 97 | colliderMesh.vertices = vertices.ToArray(); 98 | colliderMesh.SetTriangles(triangles.ToArray(), 0); 99 | col.sharedMesh = colliderMesh; 100 | } else { 101 | col.sharedMesh = mesh; 102 | } 103 | } 104 | 105 | } 106 | 107 | } 108 | 109 | -------------------------------------------------------------------------------- /Assets/Teddy/Scripts/Puppet.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5817590b6aa7e4011a3f1845657530b5 3 | timeCreated: 1468394204 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Teddy/Scripts/Teddy.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c77b78afc99b40cd8b5f9243d0e5510 3 | folderAsset: yes 4 | timeCreated: 1468330084 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Teddy/Scripts/Teddy/Chord2D.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | using mattatz.Triangulation2DSystem; 7 | 8 | namespace mattatz.TeddySystem { 9 | 10 | public class Chord2D { 11 | public Face2D Face { get { return face; } } 12 | 13 | public Vertex2D Src { get { return src; } } 14 | public Vertex2D Dst { get { return dst; } } 15 | public Segment2D SrcEdge { get { return srcEdge; } } 16 | public Segment2D DstEdge { get { return dstEdge; } } 17 | 18 | public List Connection { get { return connection; } } 19 | public bool Pruned { get { return pruned; } } 20 | 21 | Face2D face; 22 | Vertex2D src, dst; 23 | Segment2D srcEdge, dstEdge; 24 | 25 | List connection; 26 | 27 | bool pruned; 28 | 29 | public Chord2D (Vertex2D src, Vertex2D dst, Face2D face) { 30 | this.src = src; 31 | this.dst = dst; 32 | this.face = face; 33 | this.connection = new List(); 34 | } 35 | 36 | public void Connect (Chord2D c) { 37 | this.connection.Add(c); 38 | c.connection.Add(this); 39 | } 40 | 41 | public void Disconnect (Chord2D c) { 42 | this.connection.Remove(c); 43 | c.connection.Remove(this); 44 | } 45 | 46 | public void DisconnectAll () { 47 | for(int i = 0, n = this.connection.Count; i < n; i++) { 48 | var c = this.connection[i]; 49 | c.connection.Remove(this); 50 | } 51 | this.connection.Clear(); 52 | } 53 | 54 | /* 55 | public void SetSrc (Vertex2D v) { 56 | src = v; 57 | } 58 | 59 | public void SetDst (Vertex2D v) { 60 | dst = v; 61 | } 62 | */ 63 | 64 | public void SetSrcEdge (Segment2D s) { 65 | srcEdge = s; 66 | } 67 | 68 | public void SetDstEdge (Segment2D s) { 69 | dstEdge = s; 70 | } 71 | 72 | public void Prune () { 73 | pruned = true; 74 | } 75 | 76 | } 77 | 78 | } 79 | 80 | -------------------------------------------------------------------------------- /Assets/Teddy/Scripts/Teddy/Chord2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 04dac7383d1544a6bbafba807adff698 3 | timeCreated: 1467122437 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Teddy/Scripts/Teddy/Connection2D.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | using System; 4 | using System.Linq; 5 | using System.Collections; 6 | using System.Collections.Generic; 7 | 8 | using mattatz.Triangulation2DSystem; 9 | 10 | namespace mattatz.TeddySystem { 11 | 12 | public class Neighbor2D { 13 | public Face2D face; 14 | public Segment2D joint; 15 | public Neighbor2D (Face2D f, Segment2D s) { 16 | face = f; 17 | joint = s; 18 | } 19 | } 20 | 21 | public class Connection2D { 22 | 23 | Dictionary> connections; 24 | 25 | public Connection2D(List faces) { 26 | connections = new Dictionary>(); 27 | faces.ForEach(face => { 28 | Add(face); 29 | }); 30 | } 31 | 32 | public void Add (Face2D f) { 33 | CheckAndAdd(f.Triangle.s0, f); 34 | CheckAndAdd(f.Triangle.s1, f); 35 | CheckAndAdd(f.Triangle.s2, f); 36 | } 37 | 38 | void CheckAndAdd(Segment2D s, Face2D f) { 39 | if(!connections.ContainsKey(s)) connections.Add(s, new List()); 40 | connections[s].Add(f); 41 | } 42 | 43 | public void Remove(Face2D f) { 44 | connections[f.Triangle.s0].Remove(f); 45 | connections[f.Triangle.s1].Remove(f); 46 | connections[f.Triangle.s2].Remove(f); 47 | } 48 | 49 | public List GetNeighbors (Face2D f) { 50 | var neighbors0 = connections[f.Triangle.s0].FindAll(f2 => f2 != f).Select(f2 => new Neighbor2D(f2, f.Triangle.s0)); 51 | var neighbors1 = connections[f.Triangle.s1].FindAll(f2 => f2 != f).Select(f2 => new Neighbor2D(f2, f.Triangle.s1)); 52 | var neighbors2 = connections[f.Triangle.s2].FindAll(f2 => f2 != f).Select(f2 => new Neighbor2D(f2, f.Triangle.s2)); 53 | 54 | var neighbors = new List(); 55 | neighbors.AddRange(neighbors0); 56 | neighbors.AddRange(neighbors1); 57 | neighbors.AddRange(neighbors2); 58 | return neighbors; 59 | } 60 | 61 | } 62 | 63 | } 64 | 65 | -------------------------------------------------------------------------------- /Assets/Teddy/Scripts/Teddy/Connection2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c5e155d28c94f4a6c8f4fb79a23dda12 3 | timeCreated: 1467123458 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Teddy/Scripts/Teddy/Face2D.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | using mattatz.Triangulation2DSystem; 6 | 7 | namespace mattatz.TeddySystem { 8 | 9 | public enum Face2DType { 10 | Junction, Sleeve, Terminal 11 | }; 12 | 13 | public class Face2D { 14 | public Face2DType Type { get { return type; } } 15 | public Triangle2D Triangle { get { return triangle; } } 16 | 17 | public bool Pruned { get { return divides != null; } } 18 | public List Divides { get { return divides; } } 19 | 20 | Face2DType type; 21 | Triangle2D triangle; 22 | List divides; 23 | 24 | public Face2D (Face2DType tp, Triangle2D tri) { 25 | type = tp; 26 | triangle = tri; 27 | } 28 | 29 | public Vector2 Centroid () { 30 | return (triangle.a.Coordinate + triangle.b.Coordinate + triangle.c.Coordinate) / 3f; 31 | } 32 | 33 | public Vertex2D GetUncommonPoint (Face2D face) { 34 | var t0 = triangle; 35 | var t1 = face.Triangle; 36 | if(!t1.HasPoint(t0.a)) { 37 | return t0.a; 38 | } else if(!t1.HasPoint(t0.b)) { 39 | return t0.b; 40 | } 41 | return t0.c; 42 | } 43 | 44 | public Vertex2D GetUncommonPoint (Segment2D s) { 45 | var t = triangle; 46 | if(!s.HasPoint(t.a.Coordinate)) return t.a; 47 | else if(!s.HasPoint(t.b.Coordinate)) return t.b; 48 | return t.c; 49 | } 50 | 51 | public Segment2D[] GetUncommonSegments (Face2D face) { 52 | var t0 = triangle; 53 | var t1 = face.Triangle; 54 | if(t1.HasSegment(t0.s0)) { 55 | return new Segment2D[] { t0.s1, t0.s2 }; 56 | } else if(t1.HasSegment(t0.s1)) { 57 | return new Segment2D[] { t0.s0, t0.s2 }; 58 | } 59 | return new Segment2D[] { t0.s0, t0.s1 }; 60 | } 61 | 62 | public void SetDivides (List divides) { 63 | this.divides = divides; 64 | } 65 | 66 | } 67 | 68 | } 69 | 70 | -------------------------------------------------------------------------------- /Assets/Teddy/Scripts/Teddy/Face2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 23666285f29584c8a860aa2d21340b28 3 | timeCreated: 1467042052 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Teddy/Scripts/Teddy/Teddy.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6af34e18f31f2469891e089c9dd80aa3 3 | timeCreated: 1467041665 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Teddy/Scripts/Teddy/VertexNetwork2D.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | using mattatz.Triangulation2DSystem; 6 | 7 | namespace mattatz.TeddySystem { 8 | 9 | public class VertexNetwork2D { 10 | 11 | public Vertex2D Vertex { get { return vertex; } } 12 | public float Height { get { return height; } } 13 | public bool Contour { get { return contour; } } 14 | public HashSet Connection { get { return connection; } } 15 | public bool Elevated { get { return elevated; } } 16 | 17 | Vertex2D vertex; 18 | float height; 19 | 20 | HashSet connection; 21 | bool contour; 22 | bool elevated; 23 | 24 | public VertexNetwork2D (Vertex2D vertex, bool contour) { 25 | this.vertex = vertex; 26 | this.height = 0f; 27 | this.contour = this.elevated = contour; 28 | this.connection = new HashSet(); 29 | } 30 | 31 | public void Connect (VertexNetwork2D to) { 32 | this.connection.Add(to); 33 | } 34 | 35 | public bool Elevate () { 36 | if(elevated) return true; 37 | 38 | foreach(VertexNetwork2D vn in connection) { 39 | elevated = elevated || vn.Elevated; 40 | } 41 | 42 | if(elevated) { 43 | height = 0f; 44 | int count = 0; 45 | foreach(VertexNetwork2D vn in connection) { 46 | if(vn.Contour) { 47 | height += Vector2.Distance(vn.Vertex.Coordinate, Vertex.Coordinate); 48 | count++; 49 | } else if(vn.elevated) { 50 | height += vn.Height; 51 | count++; 52 | } 53 | } 54 | height /= count; 55 | } 56 | 57 | return elevated; 58 | } 59 | 60 | } 61 | 62 | } 63 | 64 | -------------------------------------------------------------------------------- /Assets/Teddy/Scripts/Teddy/VertexNetwork2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e36b4149b5534f8e8fddb64dbb12e46 3 | timeCreated: 1467439451 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Teddy/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1ac144dd3699843d59d36812eb34b92c 3 | folderAsset: yes 4 | timeCreated: 1467041640 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Teddy/Shaders/Common.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a624b37bbd2c44e47ad8a2f27370b0ad 3 | folderAsset: yes 4 | timeCreated: 1473470460 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Teddy/Shaders/Common/SimplexNoise3D.cginc: -------------------------------------------------------------------------------- 1 | // 2 | // Noise Shader Library for Unity - https://github.com/keijiro/NoiseShader 3 | // 4 | // Original work (webgl-noise) Copyright (C) 2011 Ashima Arts. 5 | // Translation and modification was made by Keijiro Takahashi. 6 | // 7 | // This shader is based on the webgl-noise GLSL shader. For further details 8 | // of the original shader, please see the following description from the 9 | // original source code. 10 | // 11 | 12 | // 13 | // Description : Array and textureless GLSL 2D/3D/4D simplex 14 | // noise functions. 15 | // Author : Ian McEwan, Ashima Arts. 16 | // Maintainer : ijm 17 | // Lastmod : 20110822 (ijm) 18 | // License : Copyright (C) 2011 Ashima Arts. All rights reserved. 19 | // Distributed under the MIT License. See LICENSE file. 20 | // https://github.com/ashima/webgl-noise 21 | // 22 | 23 | float3 mod289(float3 x) 24 | { 25 | return x - floor(x / 289.0) * 289.0; 26 | } 27 | 28 | float4 mod289(float4 x) 29 | { 30 | return x - floor(x / 289.0) * 289.0; 31 | } 32 | 33 | float4 permute(float4 x) 34 | { 35 | return mod289((x * 34.0 + 1.0) * x); 36 | } 37 | 38 | float4 taylorInvSqrt(float4 r) 39 | { 40 | return 1.79284291400159 - r * 0.85373472095314; 41 | } 42 | 43 | float snoise(float3 v) 44 | { 45 | const float2 C = float2(1.0 / 6.0, 1.0 / 3.0); 46 | 47 | // First corner 48 | float3 i = floor(v + dot(v, C.yyy)); 49 | float3 x0 = v - i + dot(i, C.xxx); 50 | 51 | // Other corners 52 | float3 g = step(x0.yzx, x0.xyz); 53 | float3 l = 1.0 - g; 54 | float3 i1 = min(g.xyz, l.zxy); 55 | float3 i2 = max(g.xyz, l.zxy); 56 | 57 | // x1 = x0 - i1 + 1.0 * C.xxx; 58 | // x2 = x0 - i2 + 2.0 * C.xxx; 59 | // x3 = x0 - 1.0 + 3.0 * C.xxx; 60 | float3 x1 = x0 - i1 + C.xxx; 61 | float3 x2 = x0 - i2 + C.yyy; 62 | float3 x3 = x0 - 0.5; 63 | 64 | // Permutations 65 | i = mod289(i); // Avoid truncation effects in permutation 66 | float4 p = 67 | permute(permute(permute(i.z + float4(0.0, i1.z, i2.z, 1.0)) 68 | + i.y + float4(0.0, i1.y, i2.y, 1.0)) 69 | + i.x + float4(0.0, i1.x, i2.x, 1.0)); 70 | 71 | // Gradients: 7x7 points over a square, mapped onto an octahedron. 72 | // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) 73 | float4 j = p - 49.0 * floor(p / 49.0); // mod(p,7*7) 74 | 75 | float4 x_ = floor(j / 7.0); 76 | float4 y_ = floor(j - 7.0 * x_); // mod(j,N) 77 | 78 | float4 x = (x_ * 2.0 + 0.5) / 7.0 - 1.0; 79 | float4 y = (y_ * 2.0 + 0.5) / 7.0 - 1.0; 80 | 81 | float4 h = 1.0 - abs(x) - abs(y); 82 | 83 | float4 b0 = float4(x.xy, y.xy); 84 | float4 b1 = float4(x.zw, y.zw); 85 | 86 | //float4 s0 = float4(lessThan(b0, 0.0)) * 2.0 - 1.0; 87 | //float4 s1 = float4(lessThan(b1, 0.0)) * 2.0 - 1.0; 88 | float4 s0 = floor(b0) * 2.0 + 1.0; 89 | float4 s1 = floor(b1) * 2.0 + 1.0; 90 | float4 sh = -step(h, 0.0); 91 | 92 | float4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; 93 | float4 a1 = b1.xzyw + s1.xzyw * sh.zzww; 94 | 95 | float3 g0 = float3(a0.xy, h.x); 96 | float3 g1 = float3(a0.zw, h.y); 97 | float3 g2 = float3(a1.xy, h.z); 98 | float3 g3 = float3(a1.zw, h.w); 99 | 100 | // Normalise gradients 101 | float4 norm = taylorInvSqrt(float4(dot(g0, g0), dot(g1, g1), dot(g2, g2), dot(g3, g3))); 102 | g0 *= norm.x; 103 | g1 *= norm.y; 104 | g2 *= norm.z; 105 | g3 *= norm.w; 106 | 107 | // Mix final noise value 108 | float4 m = max(0.6 - float4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0); 109 | m = m * m; 110 | m = m * m; 111 | 112 | float4 px = float4(dot(x0, g0), dot(x1, g1), dot(x2, g2), dot(x3, g3)); 113 | return 42.0 * dot(m, px); 114 | } 115 | -------------------------------------------------------------------------------- /Assets/Teddy/Shaders/Common/SimplexNoise3D.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0fa1c46f6524245788bcfdc970e58a96 3 | timeCreated: 1473470482 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Teddy/Shaders/DebugChordLine.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | Shader "Teddy/DebugChordLine" { 4 | 5 | Properties { 6 | _Color0 ("From Color", Color) = (0, 0, 1, 1) 7 | _Color1 ("To Color", Color) = (1, 0, 0, 1) 8 | } 9 | 10 | SubShader { 11 | Tags { "RenderType"="Opaque" } 12 | LOD 100 13 | 14 | CGINCLUDE 15 | 16 | #include "UnityCG.cginc" 17 | 18 | #pragma target 3.0 19 | 20 | fixed4 _Color0, _Color1; 21 | 22 | struct appdata { 23 | float4 vertex : POSITION; 24 | float2 uv : TEXCOORD0; 25 | }; 26 | 27 | struct v2f { 28 | float4 vertex : SV_POSITION; 29 | float2 uv : TEXCOORD0; 30 | }; 31 | 32 | v2f vert (appdata v) { 33 | v2f o; 34 | o.vertex = UnityObjectToClipPos(v.vertex); 35 | o.uv = v.uv; 36 | return o; 37 | } 38 | 39 | ENDCG 40 | 41 | Pass { 42 | CGPROGRAM 43 | #pragma vertex vert 44 | #pragma fragment frag 45 | fixed4 frag (v2f i) : SV_Target { 46 | return lerp(_Color0, _Color1, i.uv.y); 47 | } 48 | ENDCG 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Assets/Teddy/Shaders/DebugChordLine.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 021159c8f4a784b01be31b14171759ce 3 | timeCreated: 1467426568 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Teddy/Shaders/DebugNormal.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | Shader "Teddy/DebugNormal" { 4 | 5 | Properties { 6 | } 7 | 8 | SubShader { 9 | Tags { "RenderType"="Opaque" } 10 | LOD 100 11 | 12 | CGINCLUDE 13 | 14 | #include "UnityCG.cginc" 15 | 16 | #pragma target 3.0 17 | 18 | struct appdata { 19 | float4 vertex : POSITION; 20 | float3 normal : NORMAL; 21 | float2 uv : TEXCOORD0; 22 | }; 23 | 24 | struct v2f { 25 | float4 vertex : SV_POSITION; 26 | float3 normal : NORMAL; 27 | float2 uv : TEXCOORD0; 28 | }; 29 | 30 | v2f vert (appdata v) { 31 | v2f o; 32 | o.vertex = UnityObjectToClipPos(v.vertex); 33 | o.normal = mul(unity_ObjectToWorld, float4(v.normal, 0.0)).xyz; 34 | o.uv = v.uv; 35 | return o; 36 | } 37 | 38 | ENDCG 39 | 40 | Pass { 41 | CGPROGRAM 42 | #pragma vertex vert 43 | #pragma fragment frag 44 | fixed4 frag (v2f i) : SV_Target { 45 | return fixed4(i.normal, 1.0); 46 | } 47 | ENDCG 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Assets/Teddy/Shaders/DebugNormal.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5d55d943652bf4080a3ce8c50255a814 3 | timeCreated: 1467646492 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Teddy/Shaders/Puppet.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | Shader "Teddy/Demo/Puppet" { 4 | 5 | Properties { 6 | _Color ("Color", Color) = (1, 1, 1, 1) 7 | _Ramp ("Toon Ramp (RGB)", 2D) = "gray" {} 8 | _ToonParams ("Toon Params", Vector) = (0.47, 0.32, 1.44, -1) 9 | 10 | _DisplacementParams ("Displacement Params", Vector) = (0.15, 0.75, 1.0, -1) 11 | } 12 | 13 | SubShader { 14 | Tags { "RenderType"="Opaque" } 15 | LOD 100 16 | 17 | CGINCLUDE 18 | 19 | #include "UnityCG.cginc" 20 | #include "./Common/SimplexNoise3D.cginc" 21 | 22 | #pragma target 3.0 23 | 24 | struct appdata { 25 | float4 vertex : POSITION; 26 | float3 normal : NORMAL; 27 | float2 uv : TEXCOORD0; 28 | }; 29 | 30 | struct v2f { 31 | float4 vertex : SV_POSITION; 32 | float3 screenPos : TANGENT; 33 | float2 uv : TEXCOORD0; 34 | }; 35 | 36 | half4 _Color; 37 | sampler2D _Ramp; 38 | half4 _ToonParams; 39 | half4 _DisplacementParams; 40 | 41 | v2f vert (appdata v) { 42 | v2f OUT; 43 | 44 | v.vertex.xyz += v.normal * snoise(v.vertex.xyz * _DisplacementParams.x + float3(0, _Time.y, 0) * _DisplacementParams.y) * _DisplacementParams.z; 45 | OUT.vertex = UnityObjectToClipPos(v.vertex); 46 | OUT.screenPos = ComputeScreenPos(OUT.vertex); 47 | OUT.uv = v.uv; 48 | 49 | return OUT; 50 | } 51 | 52 | ENDCG 53 | 54 | Pass { 55 | Cull Off 56 | CGPROGRAM 57 | #pragma vertex vert 58 | #pragma fragment frag 59 | half4 frag (v2f IN) : SV_Target { 60 | float3 dx = ddx(IN.screenPos.xyz); 61 | float3 dy = ddy(IN.screenPos.xyz); 62 | float3 normal = normalize(cross(dx, dy)); 63 | 64 | half d = dot(normal, normalize(float3(0.5, -0.75, 0.5))) * _ToonParams.x + _ToonParams.y; 65 | d = saturate(d); 66 | half3 ramp = tex2D(_Ramp, float2(d, d)).rgb; 67 | ramp = pow(ramp, _ToonParams.z); 68 | return half4(ramp, 1) * _Color; 69 | } 70 | ENDCG 71 | } 72 | 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Assets/Teddy/Shaders/Puppet.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ca4b91d62092947848c78a75ffc52a5c 3 | timeCreated: 1468331840 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Teddy/Shaders/Teddy.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | Shader "Teddy/Demo/Mesh" { 4 | 5 | Properties { 6 | } 7 | 8 | SubShader { 9 | Tags { "RenderType"="Opaque" } 10 | LOD 100 11 | 12 | CGINCLUDE 13 | 14 | #include "UnityCG.cginc" 15 | 16 | #pragma target 3.0 17 | 18 | struct appdata { 19 | float4 vertex : POSITION; 20 | float3 normal : NORMAL; 21 | float2 uv : TEXCOORD0; 22 | }; 23 | 24 | struct v2f { 25 | float4 vertex : SV_POSITION; 26 | float3 normal : NORMAL; 27 | float2 uv : TEXCOORD0; 28 | }; 29 | 30 | v2f vert (appdata v) { 31 | v2f o; 32 | o.vertex = UnityObjectToClipPos(v.vertex); 33 | o.normal = mul(unity_ObjectToWorld, float4(v.normal, 0)).xyz; 34 | o.uv = v.uv; 35 | return o; 36 | } 37 | 38 | fixed3 normal_color (fixed3 norm) { 39 | return (normalize(norm) + 1.0) * 0.5; 40 | } 41 | 42 | ENDCG 43 | 44 | Pass { 45 | Cull Back 46 | CGPROGRAM 47 | #pragma vertex vert 48 | #pragma fragment frag 49 | fixed4 frag (v2f i) : SV_Target { 50 | fixed4 col = fixed4(normal_color(i.normal), 1); 51 | return col; 52 | } 53 | ENDCG 54 | } 55 | 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Assets/Teddy/Shaders/Teddy.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9cf4168ef735b469d8dedd819be76a97 3 | timeCreated: 1468030827 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Teddy/Shaders/TeddyDebug.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | Shader "Teddy/Demo/Debug" { 4 | 5 | Properties { 6 | } 7 | 8 | SubShader { 9 | Tags { "RenderType"="Opaque" } 10 | LOD 100 11 | 12 | CGINCLUDE 13 | 14 | #include "UnityCG.cginc" 15 | 16 | #pragma target 3.0 17 | 18 | struct appdata { 19 | float4 vertex : POSITION; 20 | float3 normal : NORMAL; 21 | float2 uv : TEXCOORD0; 22 | }; 23 | 24 | struct v2f { 25 | float4 vertex : SV_POSITION; 26 | float3 normal : NORMAL; 27 | float2 uv : TEXCOORD0; 28 | }; 29 | 30 | v2f vert (appdata v) { 31 | v2f o; 32 | o.vertex = UnityObjectToClipPos(v.vertex); 33 | o.normal = mul(unity_ObjectToWorld, float4(v.normal, 0)).xyz; 34 | o.uv = v.uv; 35 | return o; 36 | } 37 | 38 | fixed3 normal_color (fixed3 norm) { 39 | return (normalize(norm) + 1.0) * 0.5; 40 | } 41 | 42 | ENDCG 43 | 44 | Pass { 45 | Cull Off 46 | CGPROGRAM 47 | #pragma vertex vert 48 | #pragma fragment frag 49 | fixed4 frag (v2f i) : SV_Target { 50 | fixed4 col = fixed4(normal_color(i.normal), 1); 51 | return col; 52 | } 53 | ENDCG 54 | } 55 | 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Assets/Teddy/Shaders/TeddyDebug.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d3941bee5d42e4f5387e22269e04f6b5 3 | timeCreated: 1468331840 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Teddy/Textures.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83eaa12b4a90c4b8c8df422dfed73cd7 3 | folderAsset: yes 4 | timeCreated: 1473340655 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Teddy/Textures/toon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-teddy/04e237cf439d08aa64fdc0df4976e2c91f333e78/Assets/Teddy/Textures/toon.png -------------------------------------------------------------------------------- /Assets/Teddy/Textures/toon.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 42159495a12894c9c817fa639498ac80 3 | timeCreated: 1473340911 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | linearTexture: 0 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -1 30 | maxTextureSize: 2048 31 | textureSettings: 32 | filterMode: -1 33 | aniso: -1 34 | mipBias: -1 35 | wrapMode: -1 36 | nPOTScale: 1 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | allowsAlphaSplitting: 0 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 0 49 | spriteTessellationDetail: -1 50 | textureType: -1 51 | buildTargetSettings: [] 52 | spriteSheet: 53 | serializedVersion: 2 54 | sprites: [] 55 | outline: [] 56 | spritePackingTag: 57 | userData: 58 | assetBundleName: 59 | assetBundleVariant: 60 | -------------------------------------------------------------------------------- /Captures/Demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-teddy/04e237cf439d08aa64fdc0df4976e2c91f333e78/Captures/Demo.gif -------------------------------------------------------------------------------- /Captures/Demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-teddy/04e237cf439d08aa64fdc0df4976e2c91f333e78/Captures/Demo.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 mattatz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.package-manager-ui": "1.9.11", 4 | "com.unity.modules.imgui": "1.0.0", 5 | "com.unity.modules.jsonserialize": "1.0.0", 6 | "com.unity.modules.physics": "1.0.0", 7 | "com.unity.modules.physics2d": "1.0.0", 8 | "com.unity.modules.screencapture": "1.0.0", 9 | "com.unity.modules.ui": "1.0.0", 10 | "com.unity.modules.uielements": "1.0.0" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This repository is deprecated. 2 | [The official release version](https://www.assetstore.unity3d.com/#!/content/99075) is in the asset store! 3 | 4 | [Teddy](https://www.assetstore.unity3d.com/#!/content/99075) 5 | 6 | unity-teddy 7 | ===================== 8 | 9 | Teddy algorithm (converting 2D polygon into 3D model) implementation in Unity. 10 | 11 | 12 | 13 | ## Usage 14 | 15 | ```cs 16 | // input points for a Polygon2D contor 17 | List points = new List(); 18 | 19 | // Add Vector2 to points 20 | points.Add(new Vector2(-2.5f, -2.5f)); 21 | points.Add(new Vector2(2.5f, -2.5f)); 22 | points.Add(new Vector2(4.5f, 2.5f)); 23 | points.Add(new Vector2(0.5f, 4.5f)); 24 | points.Add(new Vector2(-3.5f, 2.5f)); 25 | 26 | // construct Teddy 27 | Teddy teddy = new Teddy(points); 28 | 29 | Mesh mesh = teddy.Build( 30 | MeshSmoothingMethod.HC, // select mesh smoothing methods : None, Laplacian, HC 31 | 5, // count of smoothing 32 | 0.25f, // alpha value for smoothing 33 | 0.5f // beta value for smoothing 34 | ); 35 | // GetComponent().sharedMesh = mesh; 36 | ``` 37 | 38 | ## Demo 39 | 40 | [Demo](https://mattatz.github.io/unity/teddy) 41 | 42 | ## Compatibility 43 | 44 | tested on Unity 2018.2.6f, windows10 (GTX 1060). 45 | 46 | ## Sources 47 | 48 | - Teddy: A Sketching Interface for 3D Freeform Design - http://www-ui.is.s.u-tokyo.ac.jp/~takeo/papers/siggraph99.pdf 49 | - mattatz/unity-triangulation2D - https://github.com/mattatz/unity-triangulation2D 50 | - mattatz/unity-mesh-smoothing - https://github.com/mattatz/unity-mesh-smoothing 51 | 52 | --------------------------------------------------------------------------------