├── .gitignore ├── Assets ├── Delaunay2D.meta ├── Delaunay2D │ ├── Delaunay2D.cs │ ├── Delaunay2D.cs.meta │ ├── TestDelaunay2D.cs │ └── TestDelaunay2D.cs.meta ├── Resources.meta ├── Resources │ ├── Wireframe.mat │ ├── Wireframe.mat.meta │ ├── Wireframe.shader │ └── Wireframe.shader.meta ├── Scenes.meta └── Scenes │ ├── SampleScene.unity │ └── SampleScene.unity.meta ├── LICENSE ├── README.md └── pic └── 2d.gif /.gitignore: -------------------------------------------------------------------------------- 1 | .vs/ 2 | Debug/ 3 | Library/ 4 | Packages/ 5 | ProjectSettings/ 6 | Temp/ 7 | UnityPackageManager/ 8 | *.csproj 9 | *.opensdf 10 | *.sdf 11 | *.sln 12 | *.user 13 | *.userprefs 14 | -------------------------------------------------------------------------------- /Assets/Delaunay2D.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 47528e29d09bfe3498865b7336e1af0e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Delaunay2D/Delaunay2D.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public struct Triangle 6 | { 7 | public Vector2 V0; 8 | public Vector2 V1; 9 | public Vector2 V2; 10 | public bool IsBad; 11 | public Edge E0; 12 | public Edge E1; 13 | public Edge E2; 14 | 15 | public Triangle(Vector2 v0, Vector2 v1, Vector2 v2 ) 16 | { 17 | V0 = v0; 18 | V1 = v1; 19 | V2 = v2; 20 | E0 = new Edge(v0, v1); 21 | E1 = new Edge(v1, v2); 22 | E2 = new Edge(v2, v0); 23 | IsBad = false; 24 | } 25 | 26 | public bool circumCircleContains(Vector2 p) 27 | { 28 | float ab = V0.sqrMagnitude; 29 | float cd = V1.sqrMagnitude; 30 | float ef = V2.sqrMagnitude; 31 | float circumX = (ab*(V2.y - V1.y) + cd*(V0.y - V2.y) + ef*(V1.y - V0.y))/ 32 | (V0.x*(V2.y - V1.y) + V1.x*(V0.y - V2.y) + V2.x*(V1.y - V0.y)); 33 | float circumY = (ab*(V2.x - V1.x) + cd*(V0.x - V2.x) + ef*(V1.x - V0.x))/ 34 | (V0.y*(V2.x - V1.x) + V1.y*(V0.x - V2.x) + V2.y*(V1.x - V0.x)); 35 | Vector2 circum = new Vector2(circumX / 2, circumY / 2); 36 | float circumRadius = (V0 - circum).sqrMagnitude; 37 | float dist = (p - circum).sqrMagnitude; 38 | return dist <= circumRadius; 39 | } 40 | 41 | public bool ContainsVertex(Vector2 p) 42 | { 43 | return Mathf.Approximately(0, Vector2.Distance(p, V0)) || 44 | Mathf.Approximately(0, Vector2.Distance(p, V1)) || 45 | Mathf.Approximately(0, Vector2.Distance(p, V2)); 46 | } 47 | } 48 | 49 | public struct Edge 50 | { 51 | public Vector2 V0; 52 | public Vector2 V1; 53 | public bool IsBad; 54 | 55 | public Edge(Vector2 v0, Vector2 v1) 56 | { 57 | V0 = v0; 58 | V1 = v1; 59 | IsBad = false; 60 | } 61 | 62 | public bool AlmostEqual(Edge e) 63 | { 64 | return (Mathf.Approximately(0, Vector2.Distance(V0, e.V0)) && Mathf.Approximately(0, Vector2.Distance(V1, e.V1))) || 65 | (Mathf.Approximately(0, Vector2.Distance(V0, e.V1)) && Mathf.Approximately(0, Vector2.Distance(V1, e.V0))); 66 | } 67 | } 68 | 69 | public class Delaunay2D { 70 | public List Triangulate(List vertices) 71 | { 72 | List triangles = new List(); 73 | if (0 == vertices.Count) 74 | { 75 | return triangles; 76 | } 77 | float minX = vertices[0].x; 78 | float minY = vertices[0].y; 79 | float maxX = minX; 80 | float maxY = minY; 81 | for (int i = 0, imax = vertices.Count; i < imax; i++) 82 | { 83 | float x = vertices[i].x; 84 | float y = vertices[i].y; 85 | if (x < minX) 86 | { 87 | minX = x; 88 | } 89 | else if (x > maxX) 90 | { 91 | maxX = x; 92 | } 93 | if (y < minY) 94 | { 95 | minY = y; 96 | } 97 | else if (y > maxY) 98 | { 99 | maxY = y; 100 | } 101 | } 102 | float dx = maxX - minX; 103 | float dy = maxY - minY; 104 | float deltaMax = Mathf.Max(dx, dy); 105 | float midX = (minX + maxX)/2; 106 | float midY = (minY + maxY)/2; 107 | Vector2 p1 = new Vector2(midX - 20 * deltaMax, midY - deltaMax); 108 | Vector2 p2 = new Vector2(midX, midY + 20 * deltaMax); 109 | Vector2 p3 = new Vector2(midX + 20 * deltaMax, midY - deltaMax); 110 | 111 | triangles.Add(new Triangle(p1, p2, p3)); 112 | for (int i = 0, imax = vertices.Count; i < imax; i++) 113 | { 114 | Vector2 p = vertices[i]; 115 | List polygon = new List(); 116 | for (int j = 0, jmax = triangles.Count; j < jmax; j++) 117 | { 118 | Triangle t = triangles[j]; 119 | if (t.circumCircleContains(p)) 120 | { 121 | t.IsBad = true; 122 | polygon.Add(t.E0); 123 | polygon.Add(t.E1); 124 | polygon.Add(t.E2); 125 | triangles[j] = t; 126 | } 127 | } 128 | triangles.RemoveAll((t) => t.IsBad); 129 | for (int j = 0, jmax = polygon.Count; j < jmax; j++) 130 | { 131 | Edge e = polygon[j]; 132 | for (int k = j + 1; k < jmax; k++) 133 | { 134 | Edge e2 = polygon[k]; 135 | if (e.AlmostEqual(e2)) 136 | { 137 | e.IsBad = true; 138 | e2.IsBad = true; 139 | polygon[j] = e; 140 | polygon[k] = e2; 141 | } 142 | } 143 | } 144 | 145 | polygon.RemoveAll((e) => e.IsBad); 146 | foreach (Edge e in polygon) 147 | { 148 | triangles.Add(new Triangle(e.V0, e.V1, p)); 149 | } 150 | } 151 | triangles.RemoveAll((t) => t.ContainsVertex(p1) || t.ContainsVertex(p2) || t.ContainsVertex(p3)); 152 | return triangles; 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /Assets/Delaunay2D/Delaunay2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7d2b8613771cc62418c91726c59274f1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Delaunay2D/TestDelaunay2D.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | 4 | public class TestDelaunay2D : MonoBehaviour { 5 | public Material mat; 6 | List points = new List(); 7 | 8 | void Awake() 9 | { 10 | points.Add(new Vector2(0, 0)); 11 | points.Add(new Vector2(1, 0)); 12 | points.Add(new Vector2(0.5f, 1)); 13 | } 14 | 15 | void Update() 16 | { 17 | if (Input.GetMouseButtonUp(0)) 18 | { 19 | Vector2 mp = Input.mousePosition; 20 | points.Add(new Vector2(mp.x / Screen.width, mp.y / Screen.height)); 21 | } 22 | } 23 | 24 | void OnPostRender() 25 | { 26 | if (!mat) 27 | { 28 | Debug.LogError("Please Assign a material on the inspector"); 29 | return; 30 | } 31 | Delaunay2D d = new Delaunay2D(); 32 | List triangles = d.Triangulate(points); 33 | GL.PushMatrix(); 34 | mat.SetPass(0); 35 | GL.LoadOrtho(); 36 | GL.Begin(GL.TRIANGLES); 37 | for (int i = 0, imax = triangles.Count; i < imax; i++) 38 | { 39 | GL.Vertex(triangles[i].V0); 40 | GL.Vertex(triangles[i].V1); 41 | GL.Vertex(triangles[i].V2); 42 | } 43 | GL.End(); 44 | GL.PopMatrix(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Assets/Delaunay2D/TestDelaunay2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c2c6fcfe5685f3c48a960aac9f20ae96 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 40db654e1a0a6f343bf92aa0a26cbb2c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Resources/Wireframe.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_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: Wireframe 10 | m_Shader: {fileID: 4800000, guid: 1ddce24bc87cb484aac89c4fc5680ac0, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 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 | - _GlossMapScale: 1 63 | - _Glossiness: 0.5 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 1, g: 1, b: 1, a: 1} 76 | - _EdgeColor: {r: 1, g: 1, b: 1, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /Assets/Resources/Wireframe.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b1d60d0ce78d236498f9219ceed407c0 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Resources/Wireframe.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/VertexColor" 2 | { 3 | Properties 4 | { 5 | _EdgeColor ("Edge Color", Color) = (1,1,1,1) 6 | } 7 | SubShader 8 | { 9 | Tags{ "RenderType" = "Opaque" "Queue" = "Geometry" } 10 | LOD 100 11 | 12 | Pass 13 | { 14 | CGPROGRAM 15 | #pragma target 4.6 16 | #pragma vertex vert 17 | #pragma geometry geom 18 | #pragma fragment frag 19 | 20 | #include "UnityCG.cginc" 21 | 22 | struct v2g 23 | { 24 | float4 pos : SV_POSITION; 25 | }; 26 | struct g2f 27 | { 28 | float4 pos : SV_POSITION; 29 | float3 dist : TEXCOORD1; 30 | float3 vd : TEXCOORD2; 31 | }; 32 | 33 | 34 | float4 _EdgeColor; 35 | v2g vert(float4 vertex : POSITION, uint vid : SV_VertexID) 36 | { 37 | v2g o; 38 | o.pos = UnityObjectToClipPos(vertex); 39 | return o; 40 | } 41 | 42 | [maxvertexcount(3)] 43 | void geom(triangle v2g IN[3], inout TriangleStream triStream) 44 | { 45 | 46 | float2 WIN_SCALE = float2(_ScreenParams.x / 2.0, _ScreenParams.y / 2.0); 47 | 48 | //frag position 49 | float2 p0 = WIN_SCALE * IN[0].pos.xy / IN[0].pos.w; 50 | float2 p1 = WIN_SCALE * IN[1].pos.xy / IN[1].pos.w; 51 | float2 p2 = WIN_SCALE * IN[2].pos.xy / IN[2].pos.w; 52 | 53 | //barycentric position 54 | float2 v0 = p2 - p1; 55 | float2 v1 = p2 - p0; 56 | float2 v2 = p1 - p0; 57 | //triangles area 58 | float area = abs(v1.x*v2.y - v1.y * v2.x); 59 | 60 | g2f OUT; 61 | OUT.pos = IN[0].pos; 62 | OUT.dist = float3(area / length(v0),0,0); 63 | OUT.vd = float3(1,0,0); 64 | triStream.Append(OUT); 65 | 66 | OUT.pos = IN[1].pos; 67 | OUT.dist = float3(0,area / length(v1),0); 68 | OUT.vd = float3(0,1,0); 69 | triStream.Append(OUT); 70 | 71 | OUT.pos = IN[2].pos; 72 | OUT.dist = float3(0,0,area / length(v2)); 73 | OUT.vd = float3(0,0,1); 74 | triStream.Append(OUT); 75 | 76 | } 77 | 78 | fixed4 frag(g2f IN) : SV_Target 79 | { 80 | //distance of frag from triangles center 81 | float d = min(IN.dist.x, min(IN.dist.y, IN.dist.z)); 82 | //float vd = max(IN.vd.x, max(IN.vd.y, IN.vd.z)); 83 | //fade based on dist from center 84 | float I = exp2(-4.0*d*d); 85 | //I += step(0.9, vd); 86 | return lerp(fixed4(0,0,0,0), _EdgeColor, I); 87 | } 88 | ENDCG 89 | } 90 | } 91 | } -------------------------------------------------------------------------------- /Assets/Resources/Wireframe.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1ddce24bc87cb484aac89c4fc5680ac0 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f704ae4b4f98ae41a0bce26658850c1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/SampleScene.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.44657898, g: 0.4964133, b: 0.5748178, 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: 0 57 | m_LightmapEditorSettings: 58 | serializedVersion: 10 59 | m_Resolution: 2 60 | m_BakeResolution: 10 61 | m_AtlasSize: 512 62 | m_AO: 0 63 | m_AOMaxDistance: 1 64 | m_CompAOExponent: 1 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: 256 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 2 75 | m_BakeBackend: 1 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 256 79 | m_PVRBounces: 2 80 | m_PVRFilterTypeDirect: 0 81 | m_PVRFilterTypeIndirect: 0 82 | m_PVRFilterTypeAO: 0 83 | m_PVRFilteringMode: 1 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: 1 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 &170076733 117 | GameObject: 118 | m_ObjectHideFlags: 0 119 | m_PrefabParentObject: {fileID: 0} 120 | m_PrefabInternal: {fileID: 0} 121 | serializedVersion: 5 122 | m_Component: 123 | - component: {fileID: 170076735} 124 | - component: {fileID: 170076734} 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 &170076734 133 | Light: 134 | m_ObjectHideFlags: 0 135 | m_PrefabParentObject: {fileID: 0} 136 | m_PrefabInternal: {fileID: 0} 137 | m_GameObject: {fileID: 170076733} 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: 1 162 | m_AreaSize: {x: 1, y: 1} 163 | m_BounceIntensity: 1 164 | m_ColorTemperature: 6570 165 | m_UseColorTemperature: 0 166 | m_ShadowRadius: 0 167 | m_ShadowAngle: 0 168 | --- !u!4 &170076735 169 | Transform: 170 | m_ObjectHideFlags: 0 171 | m_PrefabParentObject: {fileID: 0} 172 | m_PrefabInternal: {fileID: 0} 173 | m_GameObject: {fileID: 170076733} 174 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} 175 | m_LocalPosition: {x: 0, y: 3, z: 0} 176 | m_LocalScale: {x: 1, y: 1, z: 1} 177 | m_Children: [] 178 | m_Father: {fileID: 0} 179 | m_RootOrder: 1 180 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} 181 | --- !u!1 &282840810 182 | GameObject: 183 | m_ObjectHideFlags: 0 184 | m_PrefabParentObject: {fileID: 0} 185 | m_PrefabInternal: {fileID: 0} 186 | serializedVersion: 5 187 | m_Component: 188 | - component: {fileID: 282840814} 189 | - component: {fileID: 282840813} 190 | - component: {fileID: 282840811} 191 | - component: {fileID: 282840812} 192 | m_Layer: 0 193 | m_Name: Main Camera 194 | m_TagString: MainCamera 195 | m_Icon: {fileID: 0} 196 | m_NavMeshLayer: 0 197 | m_StaticEditorFlags: 0 198 | m_IsActive: 1 199 | --- !u!81 &282840811 200 | AudioListener: 201 | m_ObjectHideFlags: 0 202 | m_PrefabParentObject: {fileID: 0} 203 | m_PrefabInternal: {fileID: 0} 204 | m_GameObject: {fileID: 282840810} 205 | m_Enabled: 1 206 | --- !u!114 &282840812 207 | MonoBehaviour: 208 | m_ObjectHideFlags: 0 209 | m_PrefabParentObject: {fileID: 0} 210 | m_PrefabInternal: {fileID: 0} 211 | m_GameObject: {fileID: 282840810} 212 | m_Enabled: 1 213 | m_EditorHideFlags: 0 214 | m_Script: {fileID: 11500000, guid: c2c6fcfe5685f3c48a960aac9f20ae96, type: 3} 215 | m_Name: 216 | m_EditorClassIdentifier: 217 | mat: {fileID: 2100000, guid: b1d60d0ce78d236498f9219ceed407c0, type: 2} 218 | --- !u!20 &282840813 219 | Camera: 220 | m_ObjectHideFlags: 0 221 | m_PrefabParentObject: {fileID: 0} 222 | m_PrefabInternal: {fileID: 0} 223 | m_GameObject: {fileID: 282840810} 224 | m_Enabled: 1 225 | serializedVersion: 2 226 | m_ClearFlags: 1 227 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 228 | m_NormalizedViewPortRect: 229 | serializedVersion: 2 230 | x: 0 231 | y: 0 232 | width: 1 233 | height: 1 234 | near clip plane: 0.3 235 | far clip plane: 1000 236 | field of view: 60 237 | orthographic: 0 238 | orthographic size: 5 239 | m_Depth: -1 240 | m_CullingMask: 241 | serializedVersion: 2 242 | m_Bits: 4294967295 243 | m_RenderingPath: -1 244 | m_TargetTexture: {fileID: 0} 245 | m_TargetDisplay: 0 246 | m_TargetEye: 3 247 | m_HDR: 1 248 | m_AllowMSAA: 1 249 | m_AllowDynamicResolution: 0 250 | m_ForceIntoRT: 1 251 | m_OcclusionCulling: 1 252 | m_StereoConvergence: 10 253 | m_StereoSeparation: 0.022 254 | --- !u!4 &282840814 255 | Transform: 256 | m_ObjectHideFlags: 0 257 | m_PrefabParentObject: {fileID: 0} 258 | m_PrefabInternal: {fileID: 0} 259 | m_GameObject: {fileID: 282840810} 260 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 261 | m_LocalPosition: {x: 0, y: 1, z: -10} 262 | m_LocalScale: {x: 1, y: 1, z: 1} 263 | m_Children: [] 264 | m_Father: {fileID: 0} 265 | m_RootOrder: 0 266 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 267 | -------------------------------------------------------------------------------- /Assets/Scenes/SampleScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99c9720ab356a0642a771bea13969a05 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Khaos 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UnityDelaunay 2 | 3 | # 2D 4 | 5 | ![2D](pic/2d.gif) 6 | 7 | # Reference 8 | 9 | https://github.com/Bl4ckb0ne/delaunay-triangulation -------------------------------------------------------------------------------- /pic/2d.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecidevilin/UnityDelaunay/8af4cd71691b0e029714f8d1a4fa2702163e33f1/pic/2d.gif --------------------------------------------------------------------------------