├── .gitattributes ├── .gitignore ├── .vsconfig ├── Assets ├── CGALDotNet.meta ├── CGALDotNet │ ├── Extensions.meta │ ├── Extensions │ │ ├── ExtensionHelper.cs │ │ ├── ExtensionHelper.cs.meta │ │ ├── GameobjectExtensions.cs │ │ ├── GameobjectExtensions.cs.meta │ │ ├── GeometryExtension.cs │ │ ├── GeometryExtension.cs.meta │ │ ├── IMeshExtension.cs │ │ ├── IMeshExtension.cs.meta │ │ ├── MeshExtensions.cs │ │ ├── MeshExtensions.cs.meta │ │ ├── PointExtension.cs │ │ ├── PointExtension.cs.meta │ │ ├── Polygon2Extension.cs │ │ ├── Polygon2Extension.cs.meta │ │ ├── PolygonWithHoles2Extension.cs │ │ ├── PolygonWithHoles2Extension.cs.meta │ │ ├── QuaternionExtensions.cs │ │ ├── QuaternionExtensions.cs.meta │ │ ├── ShapeExtention.cs │ │ ├── ShapeExtention.cs.meta │ │ ├── VectorExtension.cs │ │ └── VectorExtension.cs.meta │ ├── Plugins.meta │ └── Plugins │ │ ├── CGALDotNet.dll │ │ ├── CGALDotNet.dll.meta │ │ ├── CGALDotNet.pdb │ │ ├── CGALDotNet.pdb.meta │ │ ├── CGALDotNet.xml │ │ ├── CGALDotNet.xml.meta │ │ ├── CGALDotNetGeometry.dll │ │ ├── CGALDotNetGeometry.dll.meta │ │ ├── CGALDotNetGeometry.pdb │ │ ├── CGALDotNetGeometry.pdb.meta │ │ ├── CGALDotNetGeometry.xml │ │ ├── CGALDotNetGeometry.xml.meta │ │ ├── CGALWrapper.dll │ │ ├── CGALWrapper.dll.meta │ │ ├── gmp.dll │ │ ├── gmp.dll.meta │ │ ├── mpfr-6.dll │ │ └── mpfr-6.dll.meta ├── Common.meta ├── Common │ ├── Cameras.meta │ ├── Cameras │ │ ├── FreeCameraController.cs │ │ ├── FreeCameraController.cs.meta │ │ ├── OrthoCameraController.cs │ │ └── OrthoCameraController.cs.meta │ ├── Drawing.meta │ ├── Drawing │ │ ├── BaseRenderer.cs │ │ ├── BaseRenderer.cs.meta │ │ ├── CircleRenderer.cs │ │ ├── CircleRenderer.cs.meta │ │ ├── CompositeRenderer.cs │ │ ├── CompositeRenderer.cs.meta │ │ ├── DebugDrawMode.cs │ │ ├── DebugDrawMode.cs.meta │ │ ├── FaceRenderer.cs │ │ ├── FaceRenderer.cs.meta │ │ ├── GridRenderer.cs │ │ ├── GridRenderer.cs.meta │ │ ├── NormalRenderer.cs │ │ ├── NormalRenderer.cs.meta │ │ ├── SegmentRenderer.cs │ │ ├── SegmentRenderer.cs.meta │ │ ├── VextexRenderer.cs │ │ └── VextexRenderer.cs.meta │ ├── Utility.meta │ └── Utility │ │ ├── ConsoleRedirect.cs │ │ ├── ConsoleRedirect.cs.meta │ │ ├── GraphicsSettings.cs │ │ └── GraphicsSettings.cs.meta ├── Examples.meta ├── Examples │ ├── Arrangments.meta │ ├── Arrangments │ │ ├── ArrangementExample.cs │ │ ├── ArrangementExample.cs.meta │ │ ├── ArrangementExample.unity │ │ ├── ArrangementExample.unity.meta │ │ ├── SweepLineExample.cs │ │ ├── SweepLineExample.cs.meta │ │ ├── SweepLineExample.unity │ │ └── SweepLineExample.unity.meta │ ├── Data.meta │ ├── Data │ │ ├── ChineseDragon-10kv.off │ │ ├── ChineseDragon-10kv.off.meta │ │ ├── armadillo.off │ │ ├── armadillo.off.meta │ │ ├── bear.off │ │ ├── bear.off.meta │ │ ├── bull.off │ │ ├── bull.off.meta │ │ ├── bunny00.off │ │ ├── bunny00.off.meta │ │ ├── camel.off │ │ ├── camel.off.meta │ │ ├── cheese.off │ │ ├── cheese.off.meta │ │ ├── cow.off │ │ ├── cow.off.meta │ │ ├── diplodocus.off │ │ ├── diplodocus.off.meta │ │ ├── elephant-with-holes.off │ │ ├── elephant-with-holes.off.meta │ │ ├── elephant.off │ │ ├── elephant.off.meta │ │ ├── elk.off │ │ ├── elk.off.meta │ │ ├── fandisk.off │ │ ├── fandisk.off.meta │ │ ├── fandisk_large.off │ │ ├── fandisk_large.off.meta │ │ ├── head.off │ │ ├── head.off.meta │ │ ├── homer.off │ │ ├── homer.off.meta │ │ ├── lion-head.off │ │ ├── lion-head.off.meta │ │ ├── lion.off │ │ ├── lion.off.meta │ │ ├── mannequin-devil.off │ │ ├── mannequin-devil.off.meta │ │ ├── pig.off │ │ ├── pig.off.meta │ │ ├── refined_elephant.off │ │ ├── refined_elephant.off.meta │ │ ├── triceratops.off │ │ └── triceratops.off.meta │ ├── Geometry.meta │ ├── Geometry │ │ ├── IntersectionExample.cs │ │ ├── IntersectionExample.cs.meta │ │ ├── IntersectionExample.unity │ │ └── IntersectionExample.unity.meta │ ├── Hulls.meta │ ├── Hulls │ │ ├── ConvexHull2Example.cs │ │ ├── ConvexHull2Example.cs.meta │ │ ├── ConvexHull2Example.unity │ │ ├── ConvexHull2Example.unity.meta │ │ ├── ConvexHull3Example.cs │ │ ├── ConvexHull3Example.cs.meta │ │ ├── ConvexHull3Example.unity │ │ ├── ConvexHull3Example.unity.meta │ │ ├── Material.mat │ │ └── Material.mat.meta │ ├── InputBehaviour.cs │ ├── InputBehaviour.cs.meta │ ├── Marching.meta │ ├── Marching │ │ ├── MarchingCubesExample.cs │ │ ├── MarchingCubesExample.cs.meta │ │ ├── MarchingCubesExample.unity │ │ ├── MarchingCubesExample.unity.meta │ │ ├── MarchingSquaresExample.cs │ │ ├── MarchingSquaresExample.cs.meta │ │ ├── MarchingSquaresExample.unity │ │ ├── MarchingSquaresExample.unity.meta │ │ ├── Material.mat │ │ └── Material.mat.meta │ ├── Meshing.meta │ ├── Meshing │ │ ├── RefineMeshExample.cs │ │ ├── RefineMeshExample.cs.meta │ │ ├── RefineMeshExample.unity │ │ ├── RefineMeshExample.unity.meta │ │ ├── SkinSurfaceExample.cs │ │ ├── SkinSurfaceExample.cs.meta │ │ ├── SkinSurfaceExample.unity │ │ └── SkinSurfaceExample.unity.meta │ ├── Nurbs.meta │ ├── Nurbs │ │ ├── Material.mat │ │ ├── Material.mat.meta │ │ ├── NurbsCurvesExample.cs │ │ ├── NurbsCurvesExample.cs.meta │ │ ├── NurbsCurvesExample.unity │ │ ├── NurbsCurvesExample.unity.meta │ │ ├── NurbsSurfaceExample.cs │ │ ├── NurbsSurfaceExample.cs.meta │ │ ├── NurbsSurfaceExample.unity │ │ └── NurbsSurfaceExample.unity.meta │ ├── PolyHedra.meta │ ├── PolyHedra │ │ ├── Material.mat │ │ ├── Material.mat.meta │ │ ├── NefPolyhedronExample.cs │ │ ├── NefPolyhedronExample.cs.meta │ │ ├── NefPolyhedronExample.unity │ │ ├── NefPolyhedronExample.unity.meta │ │ ├── PolyhedronExample.cs │ │ ├── PolyhedronExample.cs.meta │ │ ├── PolyhedronExample.unity │ │ └── PolyhedronExample.unity.meta │ ├── Polygons.meta │ ├── Polygons │ │ ├── CreatePolygonExample.cs │ │ ├── CreatePolygonExample.cs.meta │ │ ├── CreatePolygonExample.unity │ │ ├── CreatePolygonExample.unity.meta │ │ ├── CreatePolygonWithHolesExample.cs │ │ ├── CreatePolygonWithHolesExample.cs.meta │ │ ├── CreatePolygonWithHolesExample.unity │ │ ├── CreatePolygonWithHolesExample.unity.meta │ │ ├── PolygonBooleanExample.cs │ │ ├── PolygonBooleanExample.cs.meta │ │ ├── PolygonBooleanExample.unity │ │ ├── PolygonBooleanExample.unity.meta │ │ ├── PolygonMinkowskiExample.cs │ │ ├── PolygonMinkowskiExample.cs.meta │ │ ├── PolygonMinkowskiExample.unity │ │ ├── PolygonMinkowskiExample.unity.meta │ │ ├── PolygonOffsetExample.cs │ │ ├── PolygonOffsetExample.cs.meta │ │ ├── PolygonOffsetExample.unity │ │ ├── PolygonOffsetExample.unity.meta │ │ ├── PolygonPartitionExample.cs │ │ ├── PolygonPartitionExample.cs.meta │ │ ├── PolygonPartitionExample.unity │ │ ├── PolygonPartitionExample.unity.meta │ │ ├── PolygonSimplificationExample.cs │ │ ├── PolygonSimplificationExample.cs.meta │ │ ├── PolygonSimplificationExample.unity │ │ ├── PolygonSimplificationExample.unity.meta │ │ ├── PolygonVisibilityExample.cs │ │ ├── PolygonVisibilityExample.cs.meta │ │ ├── PolygonVisibilityExample.unity │ │ └── PolygonVisibilityExample.unity.meta │ ├── Polyhedra │ │ ├── ConvexDecompositionExample.cs │ │ ├── ConvexDecompositionExample.cs.meta │ │ ├── ConvexDecompositionExample.unity │ │ ├── ConvexDecompositionExample.unity.meta │ │ ├── PolyhedronBooleanExample.cs │ │ ├── PolyhedronBooleanExample.cs.meta │ │ ├── PolyhedronBooleanExample.unity │ │ ├── PolyhedronBooleanExample.unity.meta │ │ ├── SurfaceMeshExample.cs │ │ ├── SurfaceMeshExample.cs.meta │ │ ├── SurfaceMeshExample.unity │ │ └── SurfaceMeshExample.unity.meta │ ├── Processing.meta │ ├── Processing │ │ ├── HeatMethodExample.cs │ │ ├── HeatMethodExample.cs.meta │ │ ├── HeatMethodExample.unity │ │ ├── HeatMethodExample.unity.meta │ │ ├── HeatMethodMat.mat │ │ ├── HeatMethodMat.mat.meta │ │ ├── Material.mat │ │ ├── Material.mat.meta │ │ ├── ProcessingExample.cs │ │ ├── ProcessingExample.cs.meta │ │ ├── ProcessingExample.unity │ │ ├── ProcessingExample.unity.meta │ │ ├── SlicerExample.cs │ │ ├── SlicerExample.cs.meta │ │ ├── SlicerExample.unity │ │ └── SlicerExample.unity.meta │ ├── RendererBuilder.cs │ ├── RendererBuilder.cs.meta │ ├── Triangulations.meta │ └── Triangulations │ │ ├── EdgeMaterial.mat │ │ ├── EdgeMaterial.mat.meta │ │ ├── HullMaterial.mat │ │ ├── HullMaterial.mat.meta │ │ ├── Triangulation2Example.cs │ │ ├── Triangulation2Example.cs.meta │ │ ├── Triangulation2Example.unity │ │ ├── Triangulation2Example.unity.meta │ │ ├── Triangulation3Example.cs │ │ ├── Triangulation3Example.cs.meta │ │ ├── Triangulation3Example.unity │ │ ├── Triangulation3Example.unity.meta │ │ ├── VertexMaterial.mat │ │ ├── VertexMaterial.mat.meta │ │ ├── VoronoiExample.cs │ │ ├── VoronoiExample.cs.meta │ │ ├── VoronoiExample.unity │ │ └── VoronoiExample.unity.meta ├── Media.meta ├── Media │ ├── CGALIntersections.png │ ├── CGALIntersections.png.meta │ ├── KockStar.jpg │ └── KockStar.jpg.meta └── Tests.meta ├── LICENSE ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── MemorySettings.asset ├── NavMeshAreas.asset ├── PackageManagerSettings.asset ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── SceneTemplateSettings.json ├── TagManager.asset ├── TimeManager.asset ├── UnityConnectSettings.asset ├── VFXManager.asset ├── VersionControlSettings.asset ├── XRSettings.asset └── boot.config └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.vsconfig: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "components": [ 4 | "Microsoft.VisualStudio.Workload.ManagedGame" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /Assets/CGALDotNet.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5d4807ee575a28249a685af21af41b2d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33ea21048ef5c10448521bcd09494340 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/ExtensionHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | 7 | using CGALDotNet; 8 | using CGALDotNetGeometry.Numerics; 9 | using CGALDotNetGeometry.Shapes; 10 | using CGALDotNet.Polyhedra; 11 | 12 | public static class ExtensionHelper 13 | { 14 | private static StringBuilder builder = new StringBuilder(); 15 | 16 | public static void PrintObjectToUnity(this CGALObject obj) 17 | { 18 | builder.Clear(); 19 | obj.Print(builder); 20 | Debug.Log(builder); 21 | } 22 | 23 | public static void PrintMeshToUnity(this IMesh obj) 24 | { 25 | builder.Clear(); 26 | obj.Print(builder); 27 | Debug.Log(builder); 28 | } 29 | 30 | public static GameObject CreateGameobject(string name, Mesh mesh, Vector3 translation, Material material) 31 | { 32 | GameObject go = new GameObject(name); 33 | go.AddComponent().material = material; 34 | go.AddComponent().mesh = mesh; 35 | go.transform.localPosition = translation; 36 | return go; 37 | } 38 | 39 | public static Mesh CreateMesh(Point3d[] points, int[] indices) 40 | { 41 | Mesh mesh = new Mesh(); 42 | mesh.indexFormat = IndexFormat.UInt32; 43 | mesh.SetVertices(points.ToUnityVector3()); 44 | mesh.SetTriangles(indices, 0); 45 | mesh.RecalculateBounds(); 46 | mesh.RecalculateNormals(); 47 | return mesh; 48 | } 49 | 50 | public static Mesh CreateMesh(Point3d[] points, Color[] colors, int[] indices) 51 | { 52 | Mesh mesh = new Mesh(); 53 | mesh.indexFormat = IndexFormat.UInt32; 54 | mesh.SetVertices(points.ToUnityVector3()); 55 | mesh.SetColors(colors); 56 | mesh.SetTriangles(indices, 0); 57 | mesh.RecalculateBounds(); 58 | mesh.RecalculateNormals(); 59 | return mesh; 60 | } 61 | 62 | public static Mesh CreateMeshXZ(Point2d[] points, int[] indices) 63 | { 64 | Mesh mesh = new Mesh(); 65 | mesh.indexFormat = IndexFormat.UInt32; 66 | mesh.SetVertices(points.ToUnityVector3XZ()); 67 | mesh.SetTriangles(indices, 0); 68 | mesh.RecalculateBounds(); 69 | mesh.RecalculateNormals(); 70 | return mesh; 71 | } 72 | 73 | public static Mesh CreateMesh(Point2d[] points, int[] indices) 74 | { 75 | Mesh mesh = new Mesh(); 76 | mesh.indexFormat = IndexFormat.UInt32; 77 | mesh.SetVertices(points.ToUnityVector3()); 78 | mesh.SetTriangles(indices, 0); 79 | mesh.RecalculateBounds(); 80 | mesh.RecalculateNormals(); 81 | return mesh; 82 | } 83 | 84 | public static Mesh CreateMesh(Vector3[] points, Color[] colors, int[] indices) 85 | { 86 | Mesh mesh = new Mesh(); 87 | mesh.indexFormat = IndexFormat.UInt32; 88 | mesh.SetVertices(points); 89 | mesh.SetColors(colors); 90 | mesh.SetTriangles(indices, 0); 91 | mesh.RecalculateBounds(); 92 | mesh.RecalculateNormals(); 93 | return mesh; 94 | } 95 | 96 | public static Mesh CreateMesh(List points, List colors, List indices) 97 | { 98 | Mesh mesh = new Mesh(); 99 | mesh.indexFormat = IndexFormat.UInt32; 100 | mesh.SetVertices(points); 101 | mesh.SetColors(colors); 102 | mesh.SetTriangles(indices, 0); 103 | mesh.RecalculateBounds(); 104 | mesh.RecalculateNormals(); 105 | return mesh; 106 | } 107 | 108 | public static void SplitFaces(Point3d[] points, int[] indices, out Point3d[] splitPoints, out int[] splitIndices) 109 | { 110 | int triangles = indices.Length / 3; 111 | 112 | splitPoints = new Point3d[triangles * 3]; 113 | splitIndices = new int[triangles * 3]; 114 | 115 | for (int i = 0; i < triangles; i++) 116 | { 117 | splitPoints[i * 3 + 0] = points[indices[i * 3 + 0]]; 118 | splitPoints[i * 3 + 1] = points[indices[i * 3 + 1]]; 119 | splitPoints[i * 3 + 2] = points[indices[i * 3 + 2]]; 120 | 121 | splitIndices[i * 3 + 0] = i * 3 + 0; 122 | splitIndices[i * 3 + 1] = i * 3 + 1; 123 | splitIndices[i * 3 + 2] = i * 3 + 2; 124 | } 125 | } 126 | 127 | public static void SplitFaces(Point3d[] points, Color[] colors, int[] indices, out Point3d[] splitPoints, out Color[] splitColors, out int[] splitIndices) 128 | { 129 | int triangles = indices.Length / 3; 130 | 131 | splitPoints = new Point3d[triangles * 3]; 132 | splitColors = new Color[triangles * 3]; 133 | splitIndices = new int[triangles * 3]; 134 | 135 | for (int i = 0; i < triangles; i++) 136 | { 137 | splitPoints[i * 3 + 0] = points[indices[i * 3 + 0]]; 138 | splitPoints[i * 3 + 1] = points[indices[i * 3 + 1]]; 139 | splitPoints[i * 3 + 2] = points[indices[i * 3 + 2]]; 140 | 141 | splitColors[i * 3 + 0] = colors[indices[i * 3 + 0]]; 142 | splitColors[i * 3 + 1] = colors[indices[i * 3 + 1]]; 143 | splitColors[i * 3 + 2] = colors[indices[i * 3 + 2]]; 144 | 145 | splitIndices[i * 3 + 0] = i * 3 + 0; 146 | splitIndices[i * 3 + 1] = i * 3 + 1; 147 | splitIndices[i * 3 + 2] = i * 3 + 2; 148 | } 149 | } 150 | 151 | } 152 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/ExtensionHelper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb7b817b1c722a24088b54cb76305bf6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/GameobjectExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using CGALDotNet; 6 | using CGALDotNet.Geometry; 7 | using CGALDotNet.Polygons; 8 | using CGALDotNet.Polyhedra; 9 | public static class CGALGameObjectExtensions 10 | { 11 | 12 | public static Polyhedron3 ToCGALPolyhedron3(this GameObject go) where K : CGALKernel, new() 13 | { 14 | var filter = go.GetComponent(); 15 | if (filter == null) 16 | { 17 | Debug.Log("GameObject does not have a mesh filter."); 18 | return new Polyhedron3(); 19 | } 20 | 21 | return filter.sharedMesh.ToCGALPolyhedron3(); 22 | } 23 | 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/GameobjectExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1201acf49ca3a3940943509accdedcb1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/GeometryExtension.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using CGALDotNetGeometry.Numerics; 6 | 7 | namespace CGALDotNetGeometry.Shapes 8 | { 9 | 10 | public static class GeometryExtension 11 | { 12 | 13 | public static Vector2[] ToUnityVector2(this IList segments) 14 | { 15 | var array = new Vector2[segments.Count * 2]; 16 | 17 | for (int i = 0; i < segments.Count; i++) 18 | { 19 | var a = segments[i].A; 20 | var b = segments[i].B; 21 | array[i * 2 + 0] = new Vector2((float)a.x, (float)a.y); 22 | array[i * 2 + 1] = new Vector2((float)b.x, (float)b.y); 23 | } 24 | 25 | return array; 26 | } 27 | 28 | public static Vector3[] ToUnityVector3(this IList segments) 29 | { 30 | var array = new Vector3[segments.Count * 2]; 31 | 32 | for (int i = 0; i < segments.Count; i++) 33 | { 34 | var a = segments[i].A; 35 | var b = segments[i].B; 36 | array[i * 2 + 0] = new Vector3((float)a.x, (float)a.y, (float)a.z); 37 | array[i * 2 + 1] = new Vector3((float)b.x, (float)b.y, (float)b.z); 38 | } 39 | 40 | return array; 41 | } 42 | 43 | public static Vector2[] ToUnityVector2(this IList rays) 44 | { 45 | var array = new Vector2[rays.Count * 2]; 46 | 47 | for (int i = 0; i < rays.Count; i++) 48 | { 49 | var a = rays[i].Position; 50 | var b = a + rays[i].Direction; 51 | array[i * 2 + 0] = new Vector2((float)a.x, (float)a.y); 52 | array[i * 2 + 1] = new Vector2((float)b.x, (float)b.y); 53 | } 54 | 55 | return array; 56 | } 57 | 58 | public static Vector2[] ToUnityVector2(this IList triangles) 59 | { 60 | var array = new Vector2[triangles.Count * 3]; 61 | 62 | for (int i = 0; i < triangles.Count; i++) 63 | { 64 | var t = triangles[i]; 65 | 66 | var a = new Vector2((float)t.A.x, (float)t.A.y); 67 | var b = new Vector2((float)t.B.x, (float)t.B.y); 68 | var c = new Vector2((float)t.C.x, (float)t.C.y); 69 | 70 | array[i * 3 + 0] = a; 71 | array[i * 3 + 1] = b; 72 | array[i * 3 + 2] = c; 73 | } 74 | 75 | return array; 76 | } 77 | 78 | public static Vector2[] ToUnityVector2(this IList points) 79 | { 80 | var array = new Vector2[points.Count]; 81 | 82 | for (int i = 0; i < points.Count; i++) 83 | array[i] = new Vector2((float)points[i].Center.x, (float)points[i].Center.y); 84 | 85 | return array; 86 | } 87 | 88 | public static float[] ToRadius(this IList circles) 89 | { 90 | var array = new float[circles.Count]; 91 | 92 | for (int i = 0; i < circles.Count; i++) 93 | array[i] = (float)circles[i].Radius; 94 | 95 | return array; 96 | } 97 | 98 | public static List ToUnityVector2(this List segments) 99 | { 100 | var list = new List(); 101 | foreach (var seg in segments) 102 | { 103 | var a = new Vector2((float)seg.A.x, (float)seg.A.y); 104 | var b = new Vector2((float)seg.B.x, (float)seg.B.y); 105 | list.Add(a); 106 | list.Add(b); 107 | } 108 | 109 | return list; 110 | } 111 | 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/GeometryExtension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 365587a35209dfa4e913eda0f5a949fb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/IMeshExtension.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using CGALDotNetGeometry.Numerics; 6 | using CGALDotNetGeometry.Shapes; 7 | using CGALDotNetGeometry.Extensions; 8 | 9 | namespace CGALDotNet.Polyhedra 10 | { 11 | public static class IMeshExtension 12 | { 13 | public static GameObject ToUnityMesh(this Polyhedron3 poly, string name, Material material, bool splitFaces = true) 14 | where K : CGALKernel, new() 15 | { 16 | return ToUnityMesh(poly, name, material, null, splitFaces); 17 | } 18 | 19 | public static GameObject ToUnityMesh(this Polyhedron3 poly, string name, Material material, Color[] colors, bool splitFaces = true) 20 | where K : CGALKernel, new() 21 | { 22 | if (!poly.IsValid) 23 | { 24 | Debug.Log("Polyhedron3 is not valid"); 25 | return new GameObject(name); 26 | } 27 | 28 | if (!poly.IsTriangle) 29 | { 30 | poly = poly.Copy(); 31 | poly.Triangulate(); 32 | } 33 | 34 | return IMeshToUnityMesh(poly, name, material, colors, splitFaces); 35 | } 36 | 37 | public static GameObject ToUnityMesh(this SurfaceMesh3 poly, string name, Material material, bool splitFaces = true) 38 | where K : CGALKernel, new() 39 | { 40 | return ToUnityMesh(poly, name, material, null, splitFaces); 41 | } 42 | 43 | public static GameObject ToUnityMesh(this SurfaceMesh3 poly, string name, Material material, Color[] colors, bool splitFaces = true) 44 | where K : CGALKernel, new() 45 | { 46 | if (!poly.IsValid) 47 | { 48 | Debug.Log("Polyhedron3 is not valid"); 49 | return new GameObject(name); 50 | } 51 | 52 | if (!poly.IsTriangle) 53 | { 54 | poly = poly.Copy(); 55 | poly.Triangulate(); 56 | } 57 | 58 | return IMeshToUnityMesh(poly, name, material, colors, splitFaces); 59 | } 60 | 61 | private static GameObject IMeshToUnityMesh(this IMesh poly, string name, Material material, Color[] colors, bool splitFaces = true) 62 | { 63 | int count = poly.VertexCount; 64 | if (count == 0) 65 | { 66 | Debug.Log("Polyhedron3 is empty"); 67 | return new GameObject(name); 68 | } 69 | 70 | var points = new Point3d[count]; 71 | var indices = new int[poly.FaceCount * 3]; 72 | poly.GetPoints(points, points.Length); 73 | poly.GetTriangleIndices(indices, indices.Length); 74 | 75 | indices = indices.RemoveNullTriangles(); 76 | 77 | Mesh mesh; 78 | 79 | if (splitFaces) 80 | { 81 | if(colors != null) 82 | { 83 | ExtensionHelper.SplitFaces(points, colors, indices, out Point3d[] splitPoints, out Color[] splitColors, out int[] spliIndices); 84 | mesh = ExtensionHelper.CreateMesh(splitPoints, splitColors, spliIndices); 85 | } 86 | else 87 | { 88 | ExtensionHelper.SplitFaces(points, indices, out Point3d[] splitPoints, out int[] spliIndices); 89 | mesh = ExtensionHelper.CreateMesh(splitPoints, spliIndices); 90 | } 91 | } 92 | else 93 | { 94 | if(colors != null) 95 | mesh = ExtensionHelper.CreateMesh(points, colors, indices); 96 | else 97 | mesh = ExtensionHelper.CreateMesh(points, indices); 98 | } 99 | 100 | return ExtensionHelper.CreateGameobject(name, mesh, Vector3.zero, material); 101 | } 102 | 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/IMeshExtension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d3e0045b6d11c1840aa8d9dc3cf733bc 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/MeshExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using CGALDotNet; 6 | using CGALDotNetGeometry.Numerics; 7 | using CGALDotNet.Polyhedra; 8 | 9 | public static class CGALMeshExtensions 10 | { 11 | public static Polyhedron3 ToCGALPolyhedron3(this Mesh mesh) where K : CGALKernel, new() 12 | { 13 | int[] triangles = mesh.triangles; 14 | var points = mesh.vertices.ToCGALPoint3d(); 15 | 16 | var poly = new Polyhedron3(); 17 | 18 | if (points.Length > 0 && triangles.Length > 0) 19 | poly.CreateTriangleMesh(points, points.Length, triangles, triangles.Length); 20 | 21 | return poly; 22 | } 23 | 24 | public static SurfaceMesh3 ToCGALSurfaceMesh3(this Mesh mesh) where K : CGALKernel, new() 25 | { 26 | int[] triangles = mesh.triangles; 27 | var points = mesh.vertices.ToCGALPoint3d(); 28 | 29 | var poly = new SurfaceMesh3(); 30 | 31 | if (points.Length > 0 && triangles.Length > 0) 32 | poly.CreateTriangleMesh(points, points.Length, triangles, triangles.Length); 33 | 34 | return poly; 35 | } 36 | 37 | } 38 | 39 | 40 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/MeshExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b4a8d0f59e9c41c408027d772c786e48 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/PointExtension.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | 6 | namespace CGALDotNetGeometry.Numerics 7 | { 8 | 9 | public static class PointExtension 10 | { 11 | public static Vector2 ToUnityVector2(this Point2d point) 12 | { 13 | return new Vector2((float)point.x, (float)point.y); 14 | } 15 | 16 | public static Vector3 ToUnityVector3(this Point2d point) 17 | { 18 | return new Vector3((float)point.x, (float)point.y, 0); 19 | } 20 | 21 | public static Vector3 ToUnityVector3XZ(this Point2d point) 22 | { 23 | return new Vector3((float)point.x, 0, (float)point.y); 24 | } 25 | 26 | public static Vector3 ToUnityVector3(this Point3d point) 27 | { 28 | return new Vector3((float)point.x, (float)point.y, (float)point.z); 29 | } 30 | 31 | public static Vector4 ToUnityVector4(this Point4d point) 32 | { 33 | return new Vector4((float)point.x, (float)point.y, (float)point.w, (float)point.z); 34 | } 35 | 36 | public static Point2d ToCGALPoint2d(this Vector2 vec) 37 | { 38 | return new Point2d(vec.x, vec.y); 39 | } 40 | 41 | public static Point3d ToCGALPoint3d(this Vector2 vec) 42 | { 43 | return new Point3d(vec.x, vec.y, 0); 44 | } 45 | 46 | public static Point3d ToCGALPoint3dXZ(this Vector3 vec) 47 | { 48 | return new Point3d(vec.x, 0, vec.y); 49 | } 50 | 51 | public static Point3d ToCGALPoint3d(this Vector3 vec) 52 | { 53 | return new Point3d(vec.x, vec.y, vec.z); 54 | } 55 | 56 | public static Point4d ToCGALPoint4d(this Vector4 vec) 57 | { 58 | return new Point4d(vec.x, vec.y, vec.w, vec.z); 59 | } 60 | 61 | public static Vector2[] ToUnityVector2(this IList points) 62 | { 63 | var vectors = new Vector2[points.Count]; 64 | for (int i = 0; i < points.Count; i++) 65 | vectors[i] = points[i].ToUnityVector2(); 66 | 67 | return vectors; 68 | } 69 | 70 | public static Vector3[] ToUnityVector3(this IList points) 71 | { 72 | var vectors = new Vector3[points.Count]; 73 | for (int i = 0; i < points.Count; i++) 74 | vectors[i] = points[i].ToUnityVector3(); 75 | 76 | return vectors; 77 | } 78 | 79 | public static Vector3[] ToUnityVector3XZ(this IList points) 80 | { 81 | var vectors = new Vector3[points.Count]; 82 | for (int i = 0; i < points.Count; i++) 83 | vectors[i] = points[i].ToUnityVector3XZ(); 84 | 85 | return vectors; 86 | } 87 | 88 | public static Vector3[] ToUnityVector3(this IList points) 89 | { 90 | var vectors = new Vector3[points.Count]; 91 | for (int i = 0; i < points.Count; i++) 92 | vectors[i] = points[i].ToUnityVector3(); 93 | 94 | return vectors; 95 | } 96 | 97 | public static Point2d[] ToCGALPoint2d(this IList vectors) 98 | { 99 | var points = new Point2d[vectors.Count]; 100 | for (int i = 0; i < vectors.Count; i++) 101 | points[i] = vectors[i].ToCGALPoint2d(); 102 | 103 | return points; 104 | } 105 | 106 | public static Point3d[] ToCGALPoint3d(this IList vectors) 107 | { 108 | var points = new Point3d[vectors.Count]; 109 | for (int i = 0; i < vectors.Count; i++) 110 | points[i] = vectors[i].ToCGALPoint3d(); 111 | 112 | return points; 113 | } 114 | 115 | public static Point4d[] ToCGALPoint4d(this IList vectors) 116 | { 117 | var points = new Point4d[vectors.Count]; 118 | for (int i = 0; i < vectors.Count; i++) 119 | points[i] = vectors[i].ToCGALPoint4d(); 120 | 121 | return points; 122 | } 123 | 124 | public static Vector3[] ToUnityVector3(this Point3d[,] points) 125 | { 126 | var array = new Vector3[points.Length]; 127 | 128 | int width = points.GetLength(0); 129 | int height = points.GetLength(1); 130 | 131 | for (int i = 0; i < width; i++) 132 | for (int j = 0; j < height; j++) 133 | array[i + j * width] = new Vector3((float)points[i, j].x, (float)points[i, j].y, (float)points[i, j].z); 134 | 135 | return array; 136 | } 137 | 138 | 139 | } 140 | 141 | } 142 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/PointExtension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ee1857204a048a54ab148e4773a50cf5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/Polygon2Extension.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using CGALDotNetGeometry.Numerics; 6 | 7 | namespace CGALDotNet.Polygons 8 | { 9 | 10 | public static class Polygon2Extension 11 | { 12 | public static GameObject ToUnityMesh(this Polygon2 poly, string name, Vector3 position, Material material) 13 | { 14 | if (!poly.IsSimple) 15 | { 16 | Debug.Log("Polygon is not simple"); 17 | return new GameObject(name); 18 | } 19 | 20 | var indices = new List(); 21 | poly.Triangulate(indices); 22 | 23 | var points = new Point2d[poly.Count]; 24 | poly.GetPoints(points, points.Length); 25 | 26 | Mesh mesh = ExtensionHelper.CreateMesh(points, ToArrayAndFlip(indices)); 27 | 28 | return ExtensionHelper.CreateGameobject(name, mesh, position, material); 29 | } 30 | 31 | private static int[] ToArrayAndFlip(List indices) 32 | { 33 | var array = new int[indices.Count]; 34 | for(int i = 0; i < array.Length/3; i++) 35 | { 36 | array[i * 3 + 2] = indices[i * 3 + 0]; 37 | array[i * 3 + 1] = indices[i * 3 + 1]; 38 | array[i * 3 + 0] = indices[i * 3 + 2]; 39 | } 40 | 41 | return array; 42 | } 43 | 44 | 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/Polygon2Extension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 92dd0615b67381e4f95ffe17be4e2fa9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/PolygonWithHoles2Extension.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using CGALDotNetGeometry.Numerics; 6 | 7 | namespace CGALDotNet.Polygons 8 | { 9 | 10 | public static class PolygonWithHoles2Extension 11 | { 12 | public static GameObject ToUnityMesh(this PolygonWithHoles2 poly, string name, Vector3 position, Material material) 13 | { 14 | var indices = new List(); 15 | poly.Triangulate(indices); 16 | 17 | var points = new List(); 18 | poly.GetAllPoints(points); 19 | 20 | Mesh mesh = ExtensionHelper.CreateMesh(points.ToArray(), ToArrayAndFlip(indices)); 21 | 22 | return ExtensionHelper.CreateGameobject(name, mesh, position, material); 23 | } 24 | 25 | private static int[] ToArrayAndFlip(List indices) 26 | { 27 | var array = new int[indices.Count]; 28 | for (int i = 0; i < array.Length / 3; i++) 29 | { 30 | array[i * 3 + 2] = indices[i * 3 + 0]; 31 | array[i * 3 + 1] = indices[i * 3 + 1]; 32 | array[i * 3 + 0] = indices[i * 3 + 2]; 33 | } 34 | 35 | return array; 36 | } 37 | 38 | 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/PolygonWithHoles2Extension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dafe7a72b1e789f46b33883568755183 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/QuaternionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace CGALDotNetGeometry.Numerics 6 | { 7 | 8 | public static class QuaternionExtension 9 | { 10 | 11 | public static Quaternion ToUnityQuaternion(this Quaternion3f quat) 12 | { 13 | return new Quaternion(quat.x, quat.y, quat.z, quat.w); 14 | } 15 | 16 | public static Quaternion ToUnityQuaternion(this Quaternion3d quat) 17 | { 18 | return new Quaternion((float)quat.x, (float)quat.y, (float)quat.z, (float)quat.w); 19 | } 20 | 21 | public static Quaternion3d ToCGALQuaternion3d(this Quaternion quat) 22 | { 23 | return new Quaternion3d(quat.x, quat.y, quat.z, quat.w); 24 | } 25 | 26 | public static Quaternion3f ToCGALQuaternion3f(this Quaternion quat) 27 | { 28 | return new Quaternion3f(quat.x, quat.y, quat.z, quat.w); 29 | } 30 | 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/QuaternionExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6007e16584a734d4d97ebe60c15fe8dc 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/ShapeExtention.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using CGALDotNetGeometry.Numerics; 6 | 7 | namespace CGALDotNetGeometry.Shapes 8 | { 9 | 10 | public static class ShapeExtension 11 | { 12 | public static Ray ToUnityRay(this Ray2d ray) 13 | { 14 | return new Ray(ray.Position.ToUnityVector3(), ray.Direction.ToUnityVector3()); 15 | } 16 | 17 | public static Bounds ToUnityBounds(this Box3d box) 18 | { 19 | return new Bounds(box.Center.ToUnityVector3(), box.Size.ToUnityVector3()); 20 | } 21 | 22 | public static Ray3d ToCGALRay3d(this Ray ray) 23 | { 24 | return new Ray3d(ray.origin.ToCGALPoint3d(), ray.direction.ToCGALVector3d()); 25 | } 26 | 27 | public static Box3d ToCGALBox3d(this Bounds bounds) 28 | { 29 | return new Box3d(bounds.min.ToCGALPoint3d(), bounds.max.ToCGALPoint3d()); 30 | } 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/ShapeExtention.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b9f4179cd8e3b7a4095f2809c522919b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/VectorExtension.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace CGALDotNetGeometry.Numerics 6 | { 7 | 8 | public static class VectorExtension 9 | { 10 | public static Vector2 ToUnityVector2(this Vector2d vec) 11 | { 12 | return new Vector2((float)vec.x, (float)vec.y); 13 | } 14 | 15 | public static Vector3 ToUnityVector3(this Vector2d vec) 16 | { 17 | return new Vector3((float)vec.x, (float)vec.y, 0); 18 | } 19 | 20 | public static Vector3 ToUnityVector3(this Vector3d vec) 21 | { 22 | return new Vector3((float)vec.x, (float)vec.y, (float)vec.z); 23 | } 24 | 25 | public static Vector4 ToUnityVector4(this Vector4d vec) 26 | { 27 | return new Vector4((float)vec.x, (float)vec.y, (float)vec.w, (float)vec.z); 28 | } 29 | 30 | public static Vector2d ToCGALVector2d(this Vector2 vec) 31 | { 32 | return new Vector2d(vec.x, vec.y); 33 | } 34 | 35 | public static Vector3d ToCGALVector3d(this Vector2 vec) 36 | { 37 | return new Vector3d(vec.x, vec.y, 0); 38 | } 39 | 40 | public static Vector3d ToCGALVector3dXZ(this Vector3 vec) 41 | { 42 | return new Vector3d(vec.x, 0, vec.y); 43 | } 44 | 45 | public static Vector3d ToCGALVector3d(this Vector3 vec) 46 | { 47 | return new Vector3d(vec.x, vec.y, vec.z); 48 | } 49 | 50 | public static Vector4d ToCGALVector4d(this Vector4 vec) 51 | { 52 | return new Vector4d(vec.x, vec.y, vec.w, vec.z); 53 | } 54 | 55 | public static Vector2[] ToUnityVector2(this IList vectors) 56 | { 57 | var uvectors = new Vector2[vectors.Count]; 58 | for (int i = 0; i < vectors.Count; i++) 59 | uvectors[i] = vectors[i].ToUnityVector2(); 60 | 61 | return uvectors; 62 | } 63 | 64 | public static Vector3[] ToUnityVector3(this IList vectors) 65 | { 66 | var uvectors = new Vector3[vectors.Count]; 67 | for (int i = 0; i < vectors.Count; i++) 68 | uvectors[i] = vectors[i].ToUnityVector3(); 69 | 70 | return uvectors; 71 | } 72 | 73 | public static Vector3[] ToUnityVector3(this Vector3d[,] points) 74 | { 75 | var array = new Vector3[points.Length]; 76 | 77 | int width = points.GetLength(0); 78 | int height = points.GetLength(1); 79 | 80 | for (int i = 0; i < width; i++) 81 | for (int j = 0; j < height; j++) 82 | array[i + j * width] = new Vector3((float)points[i, j].x, (float)points[i, j].y, (float)points[i, j].z); 83 | 84 | return array; 85 | } 86 | 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Extensions/VectorExtension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5afa0e19c379762488c544f9eea3dd2c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a1e84621431bda4aa561ce01f6ce7aa 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Plugins/CGALDotNet.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scrawk/CGALDotNetUnity/ffc22ee93f6127b643586a4281c5e551312d2114/Assets/CGALDotNet/Plugins/CGALDotNet.dll -------------------------------------------------------------------------------- /Assets/CGALDotNet/Plugins/CGALDotNet.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e7da4b15c6a88146bd8b60c94190d90 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Any: 16 | second: 17 | enabled: 1 18 | settings: {} 19 | - first: 20 | Editor: Editor 21 | second: 22 | enabled: 0 23 | settings: 24 | DefaultValueInitialized: true 25 | - first: 26 | Windows Store Apps: WindowsStoreApps 27 | second: 28 | enabled: 0 29 | settings: 30 | CPU: AnyCPU 31 | userData: 32 | assetBundleName: 33 | assetBundleVariant: 34 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Plugins/CGALDotNet.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scrawk/CGALDotNetUnity/ffc22ee93f6127b643586a4281c5e551312d2114/Assets/CGALDotNet/Plugins/CGALDotNet.pdb -------------------------------------------------------------------------------- /Assets/CGALDotNet/Plugins/CGALDotNet.pdb.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f785988331032745b48551c0cfd437f 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Plugins/CGALDotNet.xml.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6de45a24a2ddfb34398a546377e7f54b 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Plugins/CGALDotNetGeometry.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scrawk/CGALDotNetUnity/ffc22ee93f6127b643586a4281c5e551312d2114/Assets/CGALDotNet/Plugins/CGALDotNetGeometry.dll -------------------------------------------------------------------------------- /Assets/CGALDotNet/Plugins/CGALDotNetGeometry.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b086eda27fa29f4686320b7be837f6e 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Any: 16 | second: 17 | enabled: 1 18 | settings: {} 19 | - first: 20 | Editor: Editor 21 | second: 22 | enabled: 0 23 | settings: 24 | DefaultValueInitialized: true 25 | - first: 26 | Windows Store Apps: WindowsStoreApps 27 | second: 28 | enabled: 0 29 | settings: 30 | CPU: AnyCPU 31 | userData: 32 | assetBundleName: 33 | assetBundleVariant: 34 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Plugins/CGALDotNetGeometry.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scrawk/CGALDotNetUnity/ffc22ee93f6127b643586a4281c5e551312d2114/Assets/CGALDotNet/Plugins/CGALDotNetGeometry.pdb -------------------------------------------------------------------------------- /Assets/CGALDotNet/Plugins/CGALDotNetGeometry.pdb.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 063a6564b4407094e8cc691c0ee0fdf0 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Plugins/CGALDotNetGeometry.xml.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c65754d716f92844b7207c6a270e0a8 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Plugins/CGALWrapper.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scrawk/CGALDotNetUnity/ffc22ee93f6127b643586a4281c5e551312d2114/Assets/CGALDotNet/Plugins/CGALWrapper.dll -------------------------------------------------------------------------------- /Assets/CGALDotNet/Plugins/CGALWrapper.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db91f6cf6cc83b5429223bd26c5161e1 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | : Any 16 | second: 17 | enabled: 0 18 | settings: 19 | Exclude Editor: 0 20 | Exclude Linux64: 0 21 | Exclude OSXUniversal: 0 22 | Exclude Win: 1 23 | Exclude Win64: 0 24 | - first: 25 | Any: 26 | second: 27 | enabled: 1 28 | settings: {} 29 | - first: 30 | Editor: Editor 31 | second: 32 | enabled: 1 33 | settings: 34 | CPU: AnyCPU 35 | DefaultValueInitialized: true 36 | OS: AnyOS 37 | - first: 38 | Standalone: Linux64 39 | second: 40 | enabled: 1 41 | settings: 42 | CPU: AnyCPU 43 | - first: 44 | Standalone: OSXUniversal 45 | second: 46 | enabled: 1 47 | settings: 48 | CPU: x86_64 49 | - first: 50 | Standalone: Win 51 | second: 52 | enabled: 0 53 | settings: 54 | CPU: None 55 | - first: 56 | Standalone: Win64 57 | second: 58 | enabled: 1 59 | settings: 60 | CPU: x86_64 61 | userData: 62 | assetBundleName: 63 | assetBundleVariant: 64 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Plugins/gmp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scrawk/CGALDotNetUnity/ffc22ee93f6127b643586a4281c5e551312d2114/Assets/CGALDotNet/Plugins/gmp.dll -------------------------------------------------------------------------------- /Assets/CGALDotNet/Plugins/gmp.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac3c6d6c65a06e243a952cc347beaf5c 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | : Any 16 | second: 17 | enabled: 0 18 | settings: 19 | Exclude Editor: 0 20 | Exclude Linux64: 0 21 | Exclude OSXUniversal: 0 22 | Exclude Win: 1 23 | Exclude Win64: 0 24 | - first: 25 | Any: 26 | second: 27 | enabled: 1 28 | settings: {} 29 | - first: 30 | Editor: Editor 31 | second: 32 | enabled: 1 33 | settings: 34 | CPU: AnyCPU 35 | DefaultValueInitialized: true 36 | OS: AnyOS 37 | - first: 38 | Standalone: Linux64 39 | second: 40 | enabled: 1 41 | settings: 42 | CPU: x86_64 43 | - first: 44 | Standalone: OSXUniversal 45 | second: 46 | enabled: 1 47 | settings: 48 | CPU: x86_64 49 | - first: 50 | Standalone: Win 51 | second: 52 | enabled: 0 53 | settings: 54 | CPU: None 55 | - first: 56 | Standalone: Win64 57 | second: 58 | enabled: 1 59 | settings: 60 | CPU: x86_64 61 | userData: 62 | assetBundleName: 63 | assetBundleVariant: 64 | -------------------------------------------------------------------------------- /Assets/CGALDotNet/Plugins/mpfr-6.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scrawk/CGALDotNetUnity/ffc22ee93f6127b643586a4281c5e551312d2114/Assets/CGALDotNet/Plugins/mpfr-6.dll -------------------------------------------------------------------------------- /Assets/CGALDotNet/Plugins/mpfr-6.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ca6dc22e87a389f408ce5fce491a0b7b 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | : Any 16 | second: 17 | enabled: 0 18 | settings: 19 | Exclude Editor: 0 20 | Exclude Linux64: 0 21 | Exclude OSXUniversal: 0 22 | Exclude Win: 1 23 | Exclude Win64: 0 24 | - first: 25 | Any: 26 | second: 27 | enabled: 1 28 | settings: {} 29 | - first: 30 | Editor: Editor 31 | second: 32 | enabled: 1 33 | settings: 34 | CPU: AnyCPU 35 | DefaultValueInitialized: true 36 | OS: AnyOS 37 | - first: 38 | Standalone: Linux64 39 | second: 40 | enabled: 1 41 | settings: 42 | CPU: x86_64 43 | - first: 44 | Standalone: OSXUniversal 45 | second: 46 | enabled: 1 47 | settings: 48 | CPU: x86_64 49 | - first: 50 | Standalone: Win 51 | second: 52 | enabled: 0 53 | settings: 54 | CPU: None 55 | - first: 56 | Standalone: Win64 57 | second: 58 | enabled: 1 59 | settings: 60 | CPU: x86_64 61 | userData: 62 | assetBundleName: 63 | assetBundleVariant: 64 | -------------------------------------------------------------------------------- /Assets/Common.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 73062ec9f1a75ae4b8b647a44d04fe21 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Common/Cameras.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b910f1ef0024e5241853b84a4b0fda2e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Common/Cameras/FreeCameraController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6d2223c8b8b0021418bdacd2ac82b8e6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Common/Cameras/OrthoCameraController.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Events; 3 | using UnityEngine.EventSystems; 4 | 5 | namespace Common.Unity.Cameras 6 | { 7 | public class OrthoCameraController : MonoBehaviour 8 | { 9 | private class CameraState 10 | { 11 | public Vector3 position; 12 | public float size; 13 | } 14 | 15 | [SerializeField] 16 | private UnityEvent m_cameraMovedEvent = new UnityEvent(); 17 | 18 | [SerializeField] 19 | private float m_positionSpeed = 10f; 20 | 21 | [SerializeField] 22 | private float m_positionLerpTime = 0.2f; 23 | 24 | [SerializeField] 25 | private float m_zoomSpeed = 10f; 26 | 27 | [SerializeField] 28 | private float m_zoomMin = 1.0f; 29 | 30 | [SerializeField] 31 | private float m_zoomMax = 100.0f; 32 | 33 | [SerializeField] 34 | private float m_zoomLerpTime = 0.2f; 35 | 36 | private Camera m_camera; 37 | 38 | private CameraState m_targetCameraState = new CameraState(); 39 | 40 | private CameraState m_interpolatingCameraState = new CameraState(); 41 | 42 | private bool m_moved; 43 | 44 | private void OnEnable() 45 | { 46 | m_camera = GetComponent(); 47 | 48 | m_targetCameraState.position = transform.position; 49 | m_targetCameraState.size = m_camera.orthographicSize; 50 | 51 | m_interpolatingCameraState.position = transform.position; 52 | m_interpolatingCameraState.size = m_camera.orthographicSize; 53 | } 54 | 55 | private void Update() 56 | { 57 | m_moved = false; 58 | 59 | var translation = GetTranslationDirection(); 60 | var scroll = GetScrollAmount(); 61 | 62 | m_targetCameraState.position += translation; 63 | m_targetCameraState.size += scroll; 64 | m_targetCameraState.size = Mathf.Clamp(m_targetCameraState.size, m_zoomMin, m_zoomMax); 65 | 66 | LerpTowards(m_interpolatingCameraState, m_targetCameraState); 67 | 68 | transform.position = m_interpolatingCameraState.position; 69 | m_camera.orthographicSize = m_interpolatingCameraState.size; 70 | 71 | if (m_moved) 72 | m_cameraMovedEvent.Invoke(); 73 | } 74 | 75 | public void Enable() 76 | { 77 | enabled = true; 78 | } 79 | 80 | public void Disable() 81 | { 82 | enabled = false; 83 | } 84 | 85 | private Vector3 GetTranslationDirection() 86 | { 87 | Vector3 direction = new Vector3(); 88 | if (Input.GetKey(KeyCode.W)) 89 | { 90 | m_moved = true; 91 | direction += Vector3.up; 92 | } 93 | if (Input.GetKey(KeyCode.S)) 94 | { 95 | m_moved = true; 96 | direction += Vector3.down; 97 | } 98 | if (Input.GetKey(KeyCode.A)) 99 | { 100 | m_moved = true; 101 | direction += Vector3.left; 102 | } 103 | if (Input.GetKey(KeyCode.D)) 104 | { 105 | m_moved = true; 106 | direction += Vector3.right; 107 | } 108 | 109 | float scale = 1; 110 | if (m_camera.orthographic) 111 | scale = m_camera.orthographicSize / 10.0f; 112 | 113 | return direction * Time.deltaTime * m_positionSpeed * scale; 114 | } 115 | 116 | private float GetScrollAmount() 117 | { 118 | float delta = Input.mouseScrollDelta.y; 119 | 120 | if (delta != 0) 121 | m_moved = true; 122 | 123 | float scale = 1; 124 | if (m_camera.orthographic) 125 | scale = m_camera.orthographicSize / 10.0f; 126 | 127 | return Input.mouseScrollDelta.y * Time.deltaTime * -m_zoomSpeed * scale; 128 | } 129 | 130 | private void LerpTowards(CameraState state, CameraState target) 131 | { 132 | var positionLerp = 1f - Mathf.Exp((Mathf.Log(1f - 0.99f) / m_positionLerpTime) * Time.deltaTime); 133 | var zoomLerp = 1f - Mathf.Exp((Mathf.Log(1f - 0.99f) / m_zoomLerpTime) * Time.deltaTime); 134 | 135 | state.position = Vector3.Lerp(state.position, target.position, positionLerp); 136 | state.size = Mathf.Lerp(state.size, target.size, zoomLerp); 137 | } 138 | 139 | 140 | } 141 | 142 | } -------------------------------------------------------------------------------- /Assets/Common/Cameras/OrthoCameraController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 90966f58c0c3d504d935c9b668638433 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Common/Drawing.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da173af6237ad3b4bb6d9ba9e64dd2a7 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Common/Drawing/BaseRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ee727f728c666844aa562a7d4069d8f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Common/Drawing/CircleRenderer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace Common.Unity.Drawing 6 | { 7 | 8 | public class CircleRenderer : BaseRenderer 9 | { 10 | 11 | private List m_line = new List(); 12 | 13 | private List m_radii = new List(); 14 | 15 | public CircleRenderer() 16 | { 17 | 18 | } 19 | 20 | public CircleRenderer(DRAW_ORIENTATION orientation, bool fill, float radius) 21 | { 22 | Orientation = orientation; 23 | Fill = fill; 24 | DefaultRadius = radius; 25 | } 26 | 27 | public int Segments = 16; 28 | 29 | public bool Fill = false; 30 | 31 | public float DefaultRadius = 0.1f; 32 | 33 | public override void Clear() 34 | { 35 | base.Clear(); 36 | m_radii.Clear(); 37 | } 38 | 39 | public void SetRadius(float radius) 40 | { 41 | DefaultRadius = radius; 42 | for (int i = 0; i < m_radii.Count; i++) 43 | m_radii[i] = radius; 44 | } 45 | 46 | public void Load(Vector2 position) 47 | { 48 | Load(position, DefaultRadius); 49 | } 50 | 51 | public void Load(Vector2 position, float radius) 52 | { 53 | m_radii.Add(radius); 54 | 55 | float x = position.x; 56 | float y = position.y; 57 | 58 | if (Orientation == DRAW_ORIENTATION.XY) 59 | Vertices.Add(new Vector4(x, y, 0, 1)); 60 | else if (Orientation == DRAW_ORIENTATION.XZ) 61 | Vertices.Add(new Vector4(x, 0, y, 1)); 62 | 63 | Colors.Add(DefaultColor); 64 | } 65 | 66 | public void Load(IList positions) 67 | { 68 | Load(positions, DefaultRadius); 69 | } 70 | 71 | public void Load(IList positions, float radius) 72 | { 73 | 74 | for (int i = 0; i < positions.Count; i++) 75 | { 76 | m_radii.Add(radius); 77 | 78 | float x = positions[i].x; 79 | float y = positions[i].y; 80 | 81 | if (Orientation == DRAW_ORIENTATION.XY) 82 | Vertices.Add(new Vector4(x, y, 0, 1)); 83 | else if (Orientation == DRAW_ORIENTATION.XZ) 84 | Vertices.Add(new Vector4(x, y, 0, 1)); 85 | 86 | Colors.Add(DefaultColor); 87 | } 88 | } 89 | 90 | public void Load(IList positions, IList radius) 91 | { 92 | 93 | for (int i = 0; i < positions.Count; i++) 94 | { 95 | m_radii.Add(radius[i]); 96 | 97 | float x = positions[i].x; 98 | float y = positions[i].y; 99 | 100 | if (Orientation == DRAW_ORIENTATION.XY) 101 | Vertices.Add(new Vector4(x, y, 0, 1)); 102 | else if (Orientation == DRAW_ORIENTATION.XZ) 103 | Vertices.Add(new Vector4(x, 0, y, 1)); 104 | 105 | Colors.Add(DefaultColor); 106 | } 107 | } 108 | 109 | public void Load(Vector3 position) 110 | { 111 | Load(position, DefaultRadius); 112 | } 113 | 114 | public void Load(Vector3 position, float radius) 115 | { 116 | m_radii.Add(radius); 117 | Vertices.Add(position); 118 | Colors.Add(DefaultColor); 119 | } 120 | 121 | public void Load(IList positions) 122 | { 123 | Load(positions, DefaultRadius); 124 | } 125 | 126 | public void Load(IList positions, float radius) 127 | { 128 | for (int i = 0; i < positions.Count; i++) 129 | { 130 | m_radii.Add(radius); 131 | Vertices.Add(positions[i]); 132 | Colors.Add(DefaultColor); 133 | } 134 | } 135 | 136 | protected override void OnDraw(Camera camera, Matrix4x4 localToWorld) 137 | { 138 | if (Segments < 3) return; 139 | 140 | GL.PushMatrix(); 141 | 142 | GL.LoadIdentity(); 143 | GL.modelview = camera.worldToCameraMatrix * localToWorld; 144 | GL.LoadProjectionMatrix(camera.projectionMatrix); 145 | 146 | Material.SetPass(0); 147 | GL.Begin(Fill ? GL.TRIANGLES : GL.LINES); 148 | 149 | for (int i = 0; i < Vertices.Count; i++) 150 | { 151 | DrawCircle(i); 152 | } 153 | 154 | GL.End(); 155 | GL.PopMatrix(); 156 | 157 | } 158 | 159 | private void DrawCircle(int index) 160 | { 161 | Vector4 center = Vertices[index]; 162 | Color color = Colors[index]; 163 | float radius = m_radii[index]; 164 | if (radius <= 0) return; 165 | 166 | m_line.Clear(); 167 | for (int i = 0; i < Segments; i++) 168 | { 169 | float theta = 2.0f * Mathf.PI * i / Segments; 170 | float x = radius * Mathf.Cos(theta); 171 | float y = radius * Mathf.Sin(theta); 172 | 173 | if (Orientation == DRAW_ORIENTATION.XY) 174 | m_line.Add(center + new Vector4(x, y, 0, 1)); 175 | else 176 | m_line.Add(center + new Vector4(x, 0, y, 1)); 177 | } 178 | 179 | for (int i = 0; i < Segments; i++) 180 | { 181 | GL.Color(color); 182 | GL.Vertex(m_line[i]); 183 | GL.Color(color); 184 | GL.Vertex(m_line[(i + 1) % Segments]); 185 | 186 | if(Fill) 187 | { 188 | GL.Color(color); 189 | GL.Vertex(center); 190 | } 191 | } 192 | } 193 | 194 | 195 | } 196 | 197 | } -------------------------------------------------------------------------------- /Assets/Common/Drawing/CircleRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f042b5099cfb904f992dc4b7e001d62 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Common/Drawing/CompositeRenderer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace Common.Unity.Drawing 6 | { 7 | 8 | public class CompositeRenderer 9 | { 10 | 11 | public CompositeRenderer() 12 | { 13 | Renderers = new List(); 14 | } 15 | 16 | public string Name { get; set; } 17 | 18 | private List Renderers { get; set; } 19 | 20 | public void Add(BaseRenderer renderer) 21 | { 22 | Renderers.Add(renderer); 23 | } 24 | 25 | public bool Remove(BaseRenderer renderer) 26 | { 27 | return Renderers.Remove(renderer); 28 | } 29 | 30 | public void Draw() 31 | { 32 | for (int i = 0; i < Renderers.Count; i++) 33 | Renderers[i].Draw(); 34 | } 35 | 36 | public void Clear() 37 | { 38 | Renderers.Clear(); 39 | } 40 | 41 | public void ClearRenderers() 42 | { 43 | for (int i = 0; i < Renderers.Count; i++) 44 | Renderers[i].Clear(); 45 | } 46 | 47 | public void Translate(Vector3 translation, string name = "") 48 | { 49 | Matrix4x4 mat = Matrix4x4.Translate(translation); 50 | for (int i = 0; i < Renderers.Count; i++) 51 | { 52 | if (name == "" || Renderers[i].Name == name) 53 | Renderers[i].LocalToWorld = mat; 54 | } 55 | } 56 | 57 | public void SetLocalToWorld(Matrix4x4 mat, string name = "") 58 | { 59 | for (int i = 0; i < Renderers.Count; i++) 60 | { 61 | if (name == "" || Renderers[i].Name == name) 62 | Renderers[i].LocalToWorld = mat; 63 | } 64 | } 65 | 66 | /* 67 | public void Load(IList points, string name = "") 68 | { 69 | for (int i = 0; i < Renderers.Count; i++) 70 | { 71 | if (name == "" || Renderers[i].Name == name) 72 | Renderers[i].Load(points); 73 | } 74 | } 75 | */ 76 | 77 | public void SetColor(Color color, string name = "") 78 | { 79 | for (int i = 0; i < Renderers.Count; i++) 80 | { 81 | if (name == "" || Renderers[i].Name == name) 82 | Renderers[i].SetColor(color); 83 | } 84 | } 85 | 86 | public void SetColor(Color color, string name = "") where T : BaseRenderer 87 | { 88 | for (int i = 0; i < Renderers.Count; i++) 89 | { 90 | if(Renderers[i] is T r && (name == "" || r.Name == name)) 91 | r.SetColor(color); 92 | } 93 | } 94 | 95 | public void SetEnabled(bool enabled, string name = "") 96 | { 97 | for (int i = 0; i < Renderers.Count; i++) 98 | { 99 | if (name == "" || Renderers[i].Name == name) 100 | Renderers[i].Enabled = enabled; 101 | } 102 | } 103 | 104 | public void SetEnabled(bool enabled, string name = "") where T : BaseRenderer 105 | { 106 | for (int i = 0; i < Renderers.Count; i++) 107 | { 108 | if (Renderers[i] is T r && (name == "" || r.Name == name)) 109 | r.Enabled = enabled; 110 | } 111 | } 112 | 113 | public void SetSize(float size, string name = "") 114 | { 115 | for (int i = 0; i < Renderers.Count; i++) 116 | { 117 | if (Renderers[i] is VertexRenderer r && (name == "" || r.Name == name)) 118 | r.Size = size; 119 | } 120 | } 121 | 122 | public void SetRadius(float radius, string name = "") 123 | { 124 | for (int i = 0; i < Renderers.Count; i++) 125 | { 126 | if (Renderers[i] is CircleRenderer r && (name == "" || r.Name == name)) 127 | r.SetRadius(radius); 128 | } 129 | } 130 | 131 | public void SetFill(bool fill, string name = "") 132 | { 133 | for (int i = 0; i < Renderers.Count; i++) 134 | { 135 | if (Renderers[i] is CircleRenderer r && (name == "" || r.Name == name)) 136 | r.Fill = fill; 137 | } 138 | } 139 | 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /Assets/Common/Drawing/CompositeRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d81acdc2bd1513d4fa8c14eeb83ac7a4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Common/Drawing/DebugDrawMode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | 6 | namespace Common.Unity.Drawing 7 | { 8 | [Flags] 9 | public enum DEBUG_DRAW_MODE 10 | { 11 | ON_DRAW_GIZMO = 1 << 0, 12 | ON_DRAW_GIZMO_SELECTED = 1 << 1, 13 | ON_RENDER_OBJECT = 1 << 2 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Assets/Common/Drawing/DebugDrawMode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5237e9ad34e1d2b4b92ea91d1b6963cd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Common/Drawing/FaceRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fb40fccdc72fd304789ee9e47ea90abf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Common/Drawing/GridRenderer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace Common.Unity.Drawing 6 | { 7 | 8 | public class GridRenderer 9 | { 10 | 11 | private SegmentRenderer m_vertical, m_horizontal; 12 | 13 | private SegmentRenderer m_xaxis, m_yaxis; 14 | 15 | private VertexRenderer m_vertices; 16 | 17 | private Color32 m_lineColor = new Color32(180, 180, 180, 255); 18 | 19 | private Color32 m_axisColor = new Color32(64, 64, 64, 255); 20 | 21 | public int Range = 50; 22 | 23 | public float PointSize = 0.1f; 24 | 25 | public float Spacing = 1.0f; 26 | 27 | public bool DrawAxis = true; 28 | 29 | public bool ScaleOnZoom; 30 | 31 | public Color32 LineColor 32 | { 33 | get => m_lineColor; 34 | set => SetLineColor(value); 35 | } 36 | 37 | public Color32 AxisColor 38 | { 39 | get => m_axisColor; 40 | set => SetAxisColor(value); 41 | } 42 | 43 | public void Create() 44 | { 45 | 46 | m_vertical = new SegmentRenderer(DRAW_ORIENTATION.XY); 47 | m_vertical.DefaultColor = LineColor; 48 | m_vertical.Load(new Vector2(0, -Range), new Vector2(0, Range)); 49 | 50 | m_horizontal = new SegmentRenderer(DRAW_ORIENTATION.XY); 51 | m_horizontal.DefaultColor = LineColor; 52 | m_horizontal.Load(new Vector2(-Range, 0), new Vector2(Range, 0)); 53 | 54 | m_yaxis = new SegmentRenderer(DRAW_ORIENTATION.XY); 55 | m_yaxis.DefaultColor = AxisColor; 56 | m_yaxis.Load(new Vector2(0, -Range), new Vector2(0, Range)); 57 | 58 | m_xaxis = new SegmentRenderer(DRAW_ORIENTATION.XY); 59 | m_xaxis.DefaultColor = AxisColor; 60 | m_xaxis.Load(new Vector2(-Range, 0), new Vector2(Range, 0)); 61 | 62 | m_vertices = new VertexRenderer(PointSize, DRAW_ORIENTATION.XY); 63 | m_vertices.DefaultColor = AxisColor; 64 | 65 | for (int i = -Range; i < Range; i++) 66 | { 67 | m_vertices.Load(new Vector2(i, 0)); 68 | m_vertices.Load(new Vector2(0, i)); 69 | } 70 | } 71 | 72 | public void Draw() 73 | { 74 | Draw(Camera.current); 75 | } 76 | 77 | public void Draw(Camera cam) 78 | { 79 | 80 | for (double i = -Range; i < Range; i += Spacing) 81 | { 82 | var m = Matrix4x4.Translate(new Vector3((float)i, 0, 0)); 83 | m_vertical.Draw(cam, m); 84 | 85 | m = Matrix4x4.Translate(new Vector3(0, (float)i, 0)); 86 | m_horizontal.Draw(cam, m); 87 | } 88 | 89 | if (DrawAxis) 90 | { 91 | m_vertices.ScaleOnZoom = ScaleOnZoom; 92 | 93 | m_xaxis.Draw(cam); 94 | m_yaxis.Draw(cam); 95 | m_vertices.Draw(cam); 96 | } 97 | } 98 | 99 | private void SetLineColor(Color color) 100 | { 101 | m_lineColor = color; 102 | m_vertical.SetColor(color); 103 | m_horizontal.SetColor(color); 104 | } 105 | 106 | private void SetAxisColor(Color color) 107 | { 108 | m_axisColor = color; 109 | m_xaxis.SetColor(color); 110 | m_yaxis.SetColor(color); 111 | } 112 | 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /Assets/Common/Drawing/GridRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c22434b979b263044a611b13a5ba565b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Common/Drawing/NormalRenderer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | 6 | namespace Common.Unity.Drawing 7 | { 8 | 9 | public class NormalRenderer : BaseRenderer 10 | { 11 | 12 | private List m_normals = new List(); 13 | 14 | public NormalRenderer() 15 | { 16 | 17 | } 18 | 19 | public NormalRenderer(DRAW_ORIENTATION orientation) 20 | { 21 | Orientation = orientation; 22 | } 23 | 24 | public override void Clear() 25 | { 26 | base.Clear(); 27 | m_normals.Clear(); 28 | } 29 | 30 | public float Length = 1; 31 | 32 | public void Load(IList vertices) 33 | { 34 | foreach (var v in vertices) 35 | { 36 | var n = v.normalized; 37 | if (Orientation == DRAW_ORIENTATION.XY) 38 | { 39 | Vertices.Add(v); 40 | m_normals.Add(n); 41 | } 42 | else if (Orientation == DRAW_ORIENTATION.XZ) 43 | { 44 | Vertices.Add(new Vector4(v.x, 0, v.y, 1)); 45 | m_normals.Add(new Vector4(n.x, 0, n.y, 1)); 46 | } 47 | 48 | Colors.Add(DefaultColor); 49 | } 50 | } 51 | 52 | public void Load(IList vertices, IList normals) 53 | { 54 | foreach (var v in vertices) 55 | { 56 | if (Orientation == DRAW_ORIENTATION.XY) 57 | Vertices.Add(v); 58 | else if (Orientation == DRAW_ORIENTATION.XZ) 59 | Vertices.Add(new Vector4(v.x, 0, v.y, 1)); 60 | 61 | Colors.Add(DefaultColor); 62 | } 63 | 64 | foreach (var n in normals) 65 | { 66 | if (Orientation == DRAW_ORIENTATION.XY) 67 | m_normals.Add(n); 68 | else if (Orientation == DRAW_ORIENTATION.XZ) 69 | m_normals.Add(new Vector4(n.x, 0, n.y, 1)); 70 | } 71 | } 72 | 73 | public void Load(IList vertices, IList normals, Color col) 74 | { 75 | foreach (var v in vertices) 76 | { 77 | if (Orientation == DRAW_ORIENTATION.XY) 78 | Vertices.Add(v); 79 | else if (Orientation == DRAW_ORIENTATION.XZ) 80 | Vertices.Add(new Vector4(v.x, 0, v.y, 1)); 81 | 82 | Colors.Add(col); 83 | } 84 | 85 | foreach (var n in normals) 86 | { 87 | if (Orientation == DRAW_ORIENTATION.XY) 88 | m_normals.Add(n); 89 | else if (Orientation == DRAW_ORIENTATION.XZ) 90 | m_normals.Add(new Vector4(n.x, 0, n.y, 1)); 91 | } 92 | } 93 | 94 | public void Load(IList vertices) 95 | { 96 | foreach (var v in vertices) 97 | { 98 | var n = v.normalized; 99 | Vertices.Add(v); 100 | m_normals.Add(n); 101 | Colors.Add(DefaultColor); 102 | } 103 | } 104 | 105 | public void Load(IList vertices, IList normals) 106 | { 107 | foreach (var v in vertices) 108 | { 109 | Vertices.Add(v); 110 | Colors.Add(DefaultColor); 111 | } 112 | 113 | foreach (var n in normals) 114 | m_normals.Add(n); 115 | } 116 | 117 | public void Load(IList vertices, IList normals, Color col) 118 | { 119 | foreach (var v in vertices) 120 | { 121 | Vertices.Add(v); 122 | Colors.Add(col); 123 | } 124 | 125 | foreach (var n in normals) 126 | m_normals.Add(n); 127 | } 128 | 129 | protected override void OnDraw(Camera camera, Matrix4x4 localToWorld) 130 | { 131 | GL.PushMatrix(); 132 | 133 | GL.LoadIdentity(); 134 | GL.modelview = camera.worldToCameraMatrix * localToWorld; 135 | GL.LoadProjectionMatrix(camera.projectionMatrix); 136 | 137 | Material.SetPass(0); 138 | GL.Begin(GL.LINES); 139 | 140 | int vertexCount = Vertices.Count; 141 | for (int i = 0; i < vertexCount; i++) 142 | { 143 | GL.Color(Colors[i]); 144 | GL.Vertex(Vertices[i]); 145 | GL.Vertex(Vertices[i] + m_normals[i] * Length); 146 | } 147 | 148 | GL.End(); 149 | 150 | GL.PopMatrix(); 151 | } 152 | 153 | } 154 | 155 | } -------------------------------------------------------------------------------- /Assets/Common/Drawing/NormalRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b228cfff3ca33774d8220de610c59b3e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Common/Drawing/SegmentRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c640c95997cc21a438c60fef9bac06cd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Common/Drawing/VextexRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 51f9fa99b018b3642a0c6f6d5ab9e5df 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Common/Utility.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a751bcaa77fb1444cb1e9b790db716cc 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Common/Utility/ConsoleRedirect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Text; 4 | 5 | using UnityEngine; 6 | 7 | namespace Common.Unity.Utility 8 | { 9 | /// 10 | /// Redirects writes to System.Console to Unity3D's Debug.Log. 11 | /// 12 | /// 13 | /// Jackson Dunstan, http://jacksondunstan.com/articles/2986 14 | /// 15 | public static class ConsoleRedirect 16 | { 17 | private class UnityTextWriter : TextWriter 18 | { 19 | private StringBuilder buffer = new StringBuilder(); 20 | 21 | public override void Flush() 22 | { 23 | Debug.Log(buffer.ToString()); 24 | buffer.Length = 0; 25 | } 26 | 27 | public override void Write(string value) 28 | { 29 | buffer.Append(value); 30 | if (value != null) 31 | { 32 | var len = value.Length; 33 | if (len > 0) 34 | { 35 | var lastChar = value[len - 1]; 36 | if (lastChar == '\n') 37 | { 38 | Flush(); 39 | } 40 | } 41 | } 42 | } 43 | 44 | public override void Write(char value) 45 | { 46 | buffer.Append(value); 47 | if (value == '\n') 48 | { 49 | Flush(); 50 | } 51 | } 52 | 53 | public override void Write(char[] value, int index, int count) 54 | { 55 | Write(new string(value, index, count)); 56 | } 57 | 58 | public override Encoding Encoding 59 | { 60 | get { return Encoding.Default; } 61 | } 62 | } 63 | 64 | public static void Redirect() 65 | { 66 | Console.SetOut(new UnityTextWriter()); 67 | } 68 | } 69 | 70 | } -------------------------------------------------------------------------------- /Assets/Common/Utility/ConsoleRedirect.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6c66dda94b8fdc14bbee621d563c9428 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Common/Utility/GraphicsSettings.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace Common.Unity.Utility 6 | { 7 | [ExecuteInEditMode] 8 | [AddComponentMenu("Common/Utility/Graphics Settings")] 9 | public class GraphicsSettings : MonoBehaviour 10 | { 11 | 12 | public int vSyncCount = 1; 13 | 14 | public int targetFrameRate = 60; 15 | 16 | private void Update() 17 | { 18 | QualitySettings.vSyncCount = vSyncCount; 19 | Application.targetFrameRate = targetFrameRate; 20 | } 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Assets/Common/Utility/GraphicsSettings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3944ee1c786f0de4a8bf1856c45c782a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f7c87ae430fd52a4e8f8bc78594cd153 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Arrangments.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b1f3e7b75bb291043bab54fd1665c67f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Arrangments/ArrangementExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e9b49f5194ef9bb4b86d5669199e6d1c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Arrangments/ArrangementExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b91c858fcd7fad94aaf34d8e93f2bc6f 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Arrangments/SweepLineExample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using UnityEngine; 5 | 6 | using Common.Unity.Drawing; 7 | using CGALDotNet; 8 | using CGALDotNetGeometry.Numerics; 9 | using CGALDotNetGeometry.Shapes; 10 | using CGALDotNet.Arrangements; 11 | 12 | namespace CGALDotNetUnity.Arrangements 13 | { 14 | 15 | public class SweepLineExample : InputBehaviour 16 | { 17 | 18 | private Color pointColor = new Color32(80, 80, 200, 255); 19 | 20 | private Color redColor = new Color32(200, 80, 80, 255); 21 | 22 | private Color faceColor = new Color32(80, 80, 200, 128); 23 | 24 | private Color lineColor = new Color32(0, 0, 0, 255); 25 | 26 | private Dictionary Renderers; 27 | 28 | private Segment2d[] SubCurves; 29 | 30 | private Point2d[] Points; 31 | 32 | protected override void Start() 33 | { 34 | base.Start(); 35 | Renderers = new Dictionary(); 36 | SetInputMode(INPUT_MODE.NONE); 37 | 38 | var segments = new Segment2d[] 39 | { 40 | new Segment2d(new Point2d(1,5), new Point2d(8,5)), 41 | new Segment2d(new Point2d(1,1), new Point2d(8,8)), 42 | new Segment2d(new Point2d(3,1), new Point2d(3,8)), 43 | new Segment2d(new Point2d(8,5), new Point2d(8,8)) 44 | }; 45 | 46 | for(int i = 0; i < segments.Length; i++) 47 | { 48 | var seg = segments[i]; 49 | seg -= new Point2d(5, 5); 50 | seg *= 2; 51 | segments[i] = seg; 52 | } 53 | 54 | SubCurves = SweepLine.Instance.ComputeSubcurves(segments, segments.Length); 55 | Points = SweepLine.Instance.ComputeIntersectionPoints(segments, segments.Length); 56 | 57 | Renderers["Segments"] = Draw(). 58 | Outline(SubCurves, lineColor). 59 | Points(SubCurves, lineColor, pointColor). 60 | PopRenderer(); 61 | 62 | Renderers["Points"] = Draw(). 63 | Points(Points, lineColor, redColor). 64 | PopRenderer(); 65 | 66 | } 67 | 68 | private void OnPostRender() 69 | { 70 | DrawGrid(); 71 | DrawInput(lineColor, pointColor, PointSize); 72 | 73 | foreach (var renderer in Renderers.Values) 74 | renderer.Draw(); 75 | 76 | } 77 | 78 | protected void OnGUI() 79 | { 80 | int textLen = 1000; 81 | int textHeight = 25; 82 | GUI.color = Color.black; 83 | 84 | int subcurves = SubCurves.Length; 85 | int points = Points.Length; 86 | 87 | GUI.Label(new Rect(10, 10, textLen, textHeight), "There are " + subcurves + " sub curves."); 88 | GUI.Label(new Rect(10, 30, textLen, textHeight), "There are " + points + " intersection points."); 89 | } 90 | 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /Assets/Examples/Arrangments/SweepLineExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd14e4d252a437b4da4f5aef9892c62f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Arrangments/SweepLineExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ccb92f4aa1570074cbe3a55a0b21ad74 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1ea61973394dff34b92b967d64cd9a4e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Data/ChineseDragon-10kv.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: feb0b6514373357499d11e3ecac8a6c0 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/armadillo.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6a0682729e1fbff44a119ed4242ccbc5 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/bear.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 413ba82cd74764e44976310130385ff9 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/bull.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 218756f15fc1d26448980141cc2bbaba 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/bunny00.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5094ce5894ac21148b614ae3d8348c48 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/camel.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf08e5ab2fffa4c49b8574e8ab0ce7e6 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/cheese.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0bd777baf8ccdff42a588cfbfbfc7d3b 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/cow.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b2524d1a21050914babb9453bc615023 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/diplodocus.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0c8f3da6781cfd645acfc72caedb026c 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/elephant-with-holes.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 06a81c6aee74bc045ba4b3b548261ebe 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/elephant.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 75f5fa01540a6544e9898d66739b24bb 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/elk.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d56b7da8a55b684aac774e527d671a2 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/fandisk.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 75f8cd9f337399240a4bb3b42ea9a40b 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/fandisk_large.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2fd1c79a755a67549938007c4350488f 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/head.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29d6c121c29f5ff459efd830fdb2d629 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/homer.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb2863bf1cec847408d815519ba98ef0 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/lion-head.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e4b25298d2e010b4781e55db18510baa 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/lion.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d8d4f90c1d26e6344b385ec04bdbb04c 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/mannequin-devil.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35867dd282285e6439e4c7d497c258f9 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/pig.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c4b1180bd3c6beb4a80b0593aa8b2477 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/refined_elephant.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec0d1e57691d99c428c405a01aa68de6 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Data/triceratops.off.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0de6bfb15dd1efb4f932b483631b13ac 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Geometry.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ecd35f3c7c76ed94383840a39db8df9e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Geometry/IntersectionExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 413730393f949bc47829a9c6c7bb6450 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Geometry/IntersectionExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 691a37cab638fce48b5300c4307a3caf 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Hulls.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f03fd898d53a17e4ab3066c20e0de61c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Hulls/ConvexHull2Example.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using Common.Unity.Drawing; 6 | using CGALDotNet; 7 | using CGALDotNet.Polygons; 8 | using CGALDotNetGeometry.Numerics; 9 | using CGALDotNetGeometry.Shapes; 10 | using CGALDotNet.Hulls; 11 | 12 | namespace CGALDotNetUnity.Hulls 13 | { 14 | 15 | public class ConvexHull2Example : InputBehaviour 16 | { 17 | private Color pointColor = new Color32(80, 80, 200, 255); 18 | 19 | private Color faceColor = new Color32(80, 80, 200, 128); 20 | 21 | private Color lineColor = new Color32(0, 0, 0, 255); 22 | 23 | private HULL_METHOD Method = HULL_METHOD.DEFAULT; 24 | 25 | private Polygon2 Hull; 26 | 27 | private int Seed = Guid.NewGuid().GetHashCode(); 28 | 29 | private Dictionary Renderers; 30 | 31 | 32 | protected override void Start() 33 | { 34 | base.Start(); 35 | Renderers = new Dictionary(); 36 | 37 | CreateHull(); 38 | } 39 | 40 | private void CreateHull() 41 | { 42 | var points = CreatePoints(100, 20, 10); 43 | 44 | float start = Time.realtimeSinceStartup; 45 | 46 | Hull = ConvexHull2.Instance.CreateHull(points, points.Length, Method); 47 | 48 | float end = Time.realtimeSinceStartup; 49 | float ms= (end - start) * 1000; 50 | 51 | Debug.Log("Created hull in " + ms + "ms"); 52 | 53 | CreateRenderer(Hull, points); 54 | } 55 | 56 | private Point2d[] CreatePoints(int count, float xrange, float yrange) 57 | { 58 | UnityEngine.Random.InitState(Seed); 59 | 60 | var points = new Point2d[count]; 61 | 62 | for(int i = 0; i < count; i++) 63 | { 64 | double x = UnityEngine.Random.Range(-xrange, xrange); 65 | double y = UnityEngine.Random.Range(-yrange, yrange); 66 | points[i] = new Point2d(x, y); 67 | } 68 | 69 | return points; 70 | } 71 | 72 | private void CreateRenderer(Polygon2 polygon, IList points) 73 | { 74 | Renderers["Polygon"] = Draw(). 75 | Faces(polygon, faceColor). 76 | Outline(polygon, lineColor). 77 | Points(polygon, lineColor, pointColor). 78 | PopRenderer(); 79 | 80 | Renderers["Points"] = Draw(). 81 | Points(points, lineColor, pointColor). 82 | PopRenderer(); 83 | } 84 | 85 | protected override void Update() 86 | { 87 | base.Update(); 88 | 89 | if (Input.GetKeyDown(KeyCode.Tab)) 90 | { 91 | Method = Method.Next(); 92 | CreateHull(); 93 | } 94 | else if (Input.GetKeyDown(KeyCode.F1)) 95 | { 96 | Seed = Guid.NewGuid().GetHashCode(); 97 | CreateHull(); 98 | } 99 | 100 | } 101 | 102 | private void OnPostRender() 103 | { 104 | DrawGrid(); 105 | 106 | foreach (var renderer in Renderers.Values) 107 | renderer.Draw(); 108 | 109 | } 110 | 111 | protected void OnGUI() 112 | { 113 | int textLen = 400; 114 | int textHeight = 25; 115 | GUI.color = Color.black; 116 | 117 | GUI.Label(new Rect(10, 10, textLen, textHeight), "Tab to change hull method."); 118 | GUI.Label(new Rect(10, 30, textLen, textHeight), "F1 to change seed."); 119 | GUI.Label(new Rect(10, 50, textLen, textHeight), "Hull method = " + Method); 120 | GUI.Label(new Rect(10, 70, textLen, textHeight), "Seed = " + Seed); 121 | } 122 | 123 | 124 | 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /Assets/Examples/Hulls/ConvexHull2Example.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aba033c1da3105e4085b04a4fc1b5451 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Hulls/ConvexHull2Example.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9623255714842e64997e87bf622ac373 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Hulls/ConvexHull3Example.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using CGALDotNet; 6 | using CGALDotNetGeometry.Numerics; 7 | using CGALDotNetGeometry.Shapes; 8 | using CGALDotNet.Hulls; 9 | using CGALDotNet.Polyhedra; 10 | 11 | namespace CGALDotNetUnity.Hulls 12 | { 13 | public class ConvexHull3Example : MonoBehaviour 14 | { 15 | public Material material; 16 | 17 | private GameObject m_hull; 18 | 19 | private void Start() 20 | { 21 | 22 | var box = new Box3d(-5, 5); 23 | var points = Point3d.RandomPoints(0, 20, box); 24 | 25 | var poly = ConvexHull3.Instance.CreateHullAsPolyhedron(points, points.Length); 26 | 27 | m_hull = poly.ToUnityMesh("Hull", material); 28 | } 29 | 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Assets/Examples/Hulls/ConvexHull3Example.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3cf526ac05ba316428a8b9fa6ee18f30 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Hulls/ConvexHull3Example.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e3b4c26a4918514d8395762e110cab6 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Hulls/Material.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_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Material 11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Ints: [] 59 | m_Floats: 60 | - _BumpScale: 1 61 | - _Cutoff: 0.5 62 | - _DetailNormalMapScale: 1 63 | - _DstBlend: 0 64 | - _GlossMapScale: 1 65 | - _Glossiness: 0 66 | - _GlossyReflections: 1 67 | - _Metallic: 0 68 | - _Mode: 0 69 | - _OcclusionStrength: 1 70 | - _Parallax: 0.02 71 | - _SmoothnessTextureChannel: 0 72 | - _SpecularHighlights: 1 73 | - _SrcBlend: 1 74 | - _UVSec: 0 75 | - _ZWrite: 1 76 | m_Colors: 77 | - _Color: {r: 0.6415094, g: 0.6415094, b: 0.6415094, a: 1} 78 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 79 | m_BuildTextureStacks: [] 80 | -------------------------------------------------------------------------------- /Assets/Examples/Hulls/Material.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cab9990dbf77555488a42970480bdfec 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/InputBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4582adb6ac05ba5488e9caf02a5a36f7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Marching.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8c34293890c96aa448366fd219988022 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Marching/MarchingCubesExample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using CGALDotNetGeometry.Numerics; 6 | using CGALDotNetGeometry.Shapes; 7 | using CGALDotNetGeometry.Marching; 8 | 9 | namespace CGALDotNetUnity.Marching 10 | { 11 | public class MarchingCubesExample : MonoBehaviour 12 | { 13 | 14 | public Material material; 15 | 16 | void Start() 17 | { 18 | PerformMarching(); 19 | } 20 | 21 | private void PerformMarching() 22 | { 23 | int size = 20; 24 | int half = size / 2; 25 | 26 | var mc = new MarchingCubes(); 27 | 28 | var vertices = new List(); 29 | var indices = new List(); 30 | 31 | mc.Generate(UnionSDF, size + 1, size + 1, size + 1, vertices, indices); 32 | 33 | Mesh mesh = new Mesh(); 34 | mesh.SetVertices(ToVector3(vertices)); 35 | mesh.SetTriangles(indices, 0); 36 | mesh.RecalculateBounds(); 37 | mesh.RecalculateNormals(); 38 | 39 | GameObject go = new GameObject("Mesh"); 40 | go.AddComponent(); 41 | go.AddComponent(); 42 | go.GetComponent().material = material; 43 | go.GetComponent().mesh = mesh; 44 | go.transform.localPosition = new Vector3(-half, -half, -half); 45 | 46 | } 47 | 48 | private double UnionSDF(Point3d point) 49 | { 50 | double sdf1 = SphereSDF(point); 51 | double sdf2 = BoxSDF(point); 52 | 53 | return Math.Min(sdf1, sdf2); 54 | } 55 | 56 | private double SphereSDF(Point3d point) 57 | { 58 | double radius = 5; 59 | Point3d Center = new Point3d(10); 60 | 61 | point = point - Center; 62 | return point.Magnitude - radius; 63 | } 64 | 65 | private double BoxSDF(Point3d point) 66 | { 67 | Point3d Min = new Point3d(2); 68 | Point3d Max = new Point3d(10); 69 | Point3d size = new Point3d(8); 70 | 71 | Point3d p = point - (Min + Max) * 0.5; 72 | p.x = Math.Abs(p.x); 73 | p.y = Math.Abs(p.y); 74 | p.z = Math.Abs(p.z); 75 | 76 | Point3d d = p - size * 0.5; 77 | Point3d max = Point3d.Max(d, 0); 78 | 79 | return max.Magnitude + Math.Min(Math.Max(Math.Max(d.x, d.y), d.z), 0.0); 80 | } 81 | 82 | private List ToVector3(IList points) 83 | { 84 | var list = new List(points.Count); 85 | 86 | for (int i = 0; i < points.Count; i++) 87 | list.Add(ToVector3(points[i])); 88 | 89 | return list; 90 | } 91 | 92 | private Vector3 ToVector3(Point3d p) 93 | { 94 | return new Vector3((float)p.x, (float)p.y, (float)p.z); 95 | } 96 | 97 | 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /Assets/Examples/Marching/MarchingCubesExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2437852090987cb4ab4c4e977a818127 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Marching/MarchingCubesExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e1285fc0c68b754cb123941657fd3b6 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Marching/MarchingSquaresExample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using Common.Unity.Drawing; 6 | using CGALDotNet; 7 | using CGALDotNetGeometry.Numerics; 8 | using CGALDotNetGeometry.Shapes; 9 | using CGALDotNetGeometry.Marching; 10 | using CGALDotNet.Triangulations; 11 | 12 | namespace CGALDotNetUnity.Marching 13 | { 14 | 15 | public class MarchingSquaresExample : InputBehaviour 16 | { 17 | private Color redColor = new Color32(200, 80, 80, 255); 18 | 19 | private Color pointColor = new Color32(80, 80, 200, 255); 20 | 21 | private Color faceColor = new Color32(80, 80, 200, 128); 22 | 23 | private Color lineColor = new Color32(0, 0, 0, 255); 24 | 25 | private Dictionary Renderers; 26 | 27 | protected override void Start() 28 | { 29 | base.Start(); 30 | SetInputMode(INPUT_MODE.NONE); 31 | Renderers = new Dictionary(); 32 | 33 | PerformMarching(); 34 | } 35 | 36 | private void PerformMarching() 37 | { 38 | int size = 20; 39 | int half = size / 2; 40 | Point2d translate = new Point2d(-half); 41 | 42 | var ms = new MarchingSquares(); 43 | var tri = new ConstrainedTriangulation2(); 44 | 45 | var vertices = new List(); 46 | var indices = new List(); 47 | 48 | ms.Generate(UnionSDF, size + 1, size+ 1, vertices, indices); 49 | 50 | var segments = new List(); 51 | for(int i = 0; i < indices.Count/2; i++) 52 | { 53 | int i0 = i * 2 + 0; 54 | int i1 = i * 2 + 1; 55 | 56 | var a = vertices[indices[i0]] + translate; 57 | var b = vertices[indices[i1]] + translate; 58 | 59 | segments.Add(new Segment2d(a, b)); 60 | 61 | tri.InsertConstraint(a, b); 62 | } 63 | 64 | CreateRenderer(tri, translate); 65 | 66 | //Renderers["Tri"] = Draw().Outline(tri, lineColor).PopRenderer(); 67 | //Renderers["Bounds"] = Draw().Outline(new Box2d(-half, half), lineColor).PopRenderer(); 68 | Renderers["Segments"] = Draw().Outline(segments, lineColor).PopRenderer(); 69 | } 70 | 71 | private double UnionSDF(Point2d point) 72 | { 73 | double sdf1 = CircleSDF(point); 74 | double sdf2 = BoxSDF(point); 75 | 76 | return Math.Min(sdf1, sdf2); 77 | } 78 | 79 | private double CircleSDF(Point2d point) 80 | { 81 | double radius = 5; 82 | Point2d Center = new Point2d(10); 83 | 84 | point = point - Center; 85 | return point.Magnitude - radius; 86 | } 87 | 88 | private double BoxSDF(Point2d point) 89 | { 90 | Point2d Min = new Point2d(2); 91 | Point2d Max = new Point2d(10); 92 | Point2d size = new Point2d(8); 93 | 94 | Point2d p = point - (Min+Max)*0.5; 95 | p.x = Math.Abs(p.x); 96 | p.y = Math.Abs(p.y); 97 | 98 | Point2d d = p - size * 0.5; 99 | Point2d max = Point2d.Max(d, 0); 100 | 101 | return max.Magnitude + Math.Min(Math.Max(d.x, d.y), 0.0); 102 | } 103 | 104 | private void CreateRenderer(ConstrainedTriangulation2 tri, Point2d translate) 105 | { 106 | var points = new Point2d[tri.VertexCount]; 107 | tri.GetPoints(points, points.Length); 108 | 109 | var indices = new int[tri.IndiceCount]; 110 | tri.GetIndices(indices, indices.Length); 111 | 112 | var indices2 = new List(); 113 | 114 | for (int i = 0; i < indices.Length / 3; i++) 115 | { 116 | int i0 = i * 3 + 0; 117 | int i1 = i * 3 + 1; 118 | int i2 = i * 3 + 2; 119 | 120 | var a = points[indices[i0]] - translate; 121 | var b = points[indices[i1]] - translate; 122 | var c = points[indices[i2]] - translate; 123 | 124 | var center = (a + b + c) / 3.0; 125 | 126 | if(UnionSDF(center) < 0) 127 | { 128 | indices2.Add(indices[i0]); 129 | indices2.Add(indices[i1]); 130 | indices2.Add(indices[i2]); 131 | } 132 | 133 | } 134 | 135 | Renderers["Trianguation"] = Draw(). 136 | Faces(points, indices2, faceColor). 137 | PopRenderer(); 138 | 139 | } 140 | 141 | private void OnPostRender() 142 | { 143 | DrawGrid(); 144 | 145 | foreach (var renderer in Renderers.Values) 146 | renderer.Draw(); 147 | 148 | } 149 | 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /Assets/Examples/Marching/MarchingSquaresExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dab8640b852670c468562b3870541d3f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Marching/MarchingSquaresExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f22decf31cc05714f95f4c2a64a6d0af 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Marching/Material.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_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Material 11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Ints: [] 59 | m_Floats: 60 | - _BumpScale: 1 61 | - _Cutoff: 0.5 62 | - _DetailNormalMapScale: 1 63 | - _DstBlend: 0 64 | - _GlossMapScale: 1 65 | - _Glossiness: 0 66 | - _GlossyReflections: 1 67 | - _Metallic: 0 68 | - _Mode: 0 69 | - _OcclusionStrength: 1 70 | - _Parallax: 0.02 71 | - _SmoothnessTextureChannel: 0 72 | - _SpecularHighlights: 1 73 | - _SrcBlend: 1 74 | - _UVSec: 0 75 | - _ZWrite: 1 76 | m_Colors: 77 | - _Color: {r: 0.5188679, g: 0.5066305, b: 0.5066305, a: 1} 78 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 79 | m_BuildTextureStacks: [] 80 | -------------------------------------------------------------------------------- /Assets/Examples/Marching/Material.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1c761d2c1c6efe74ab611454af2759e3 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Meshing.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 40f4e2c8a0fa32048a795fe862711a79 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Meshing/RefineMeshExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2a59ea522940c1e46b09bdc8bac72a73 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Meshing/RefineMeshExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d952f74b8bbf4e440ad96b10bb534b97 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Meshing/SkinSurfaceExample.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using CGALDotNet; 6 | using CGALDotNetGeometry.Numerics; 7 | using CGALDotNetGeometry.Shapes; 8 | using CGALDotNet.Polyhedra; 9 | using CGALDotNet.Meshing; 10 | 11 | namespace CGALDotNetUnity.Meshing 12 | { 13 | public class SkinSurfaceExample : MonoBehaviour 14 | { 15 | 16 | public Material material; 17 | 18 | void Start() 19 | { 20 | var points = Point3d.RandomPoints(0, 10, new Box3d(-10, 10)); 21 | 22 | var poly = SkinSurfaceMeshing.Instance.CreateSkinPolyhedra(0.5, true, points, points.Length); 23 | 24 | var split = new List>(); 25 | poly.Split(split); 26 | 27 | for (int i = 0; i < split.Count; i++) 28 | { 29 | var p = split[i]; 30 | 31 | var mat = new Material(material); 32 | mat.color = RandomColor(); 33 | 34 | p.ToUnityMesh("SkinSurface", mat); 35 | } 36 | } 37 | 38 | private Color RandomColor() 39 | { 40 | Color col = new Color(); 41 | col.r = Random.value; 42 | col.g = Random.value; 43 | col.b = Random.value; 44 | return col; 45 | } 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Assets/Examples/Meshing/SkinSurfaceExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 71f7808fe0a38e84db635b744fe492be 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Meshing/SkinSurfaceExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ad5b87e9e113c284d9a06a62474cd282 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Nurbs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d31b05249ceaed14ca7df5b59a26788d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Nurbs/Material.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_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Material 11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Ints: [] 59 | m_Floats: 60 | - _BumpScale: 1 61 | - _Cutoff: 0.5 62 | - _DetailNormalMapScale: 1 63 | - _DstBlend: 0 64 | - _GlossMapScale: 1 65 | - _Glossiness: 0 66 | - _GlossyReflections: 1 67 | - _Metallic: 0 68 | - _Mode: 0 69 | - _OcclusionStrength: 1 70 | - _Parallax: 0.02 71 | - _SmoothnessTextureChannel: 0 72 | - _SpecularHighlights: 1 73 | - _SrcBlend: 1 74 | - _UVSec: 0 75 | - _ZWrite: 1 76 | m_Colors: 77 | - _Color: {r: 0.7169812, g: 0.7169812, b: 0.7169812, a: 1} 78 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 79 | m_BuildTextureStacks: [] 80 | -------------------------------------------------------------------------------- /Assets/Examples/Nurbs/Material.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fe480381124270047b79ac4ac105bdec 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Nurbs/NurbsCurvesExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: deb71e9fe389b7d41a0b7ff87fe397f2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Nurbs/NurbsCurvesExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2c17277af8dddfa48aaed20ad583cb56 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Nurbs/NurbsSurfaceExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9cc43c1df19cdbc4983cadb765cef27c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Nurbs/NurbsSurfaceExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 31336882fa353b34e99d59b3ee3e7dc0 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/PolyHedra.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f63ca4a3bbc737546aebc3050aded85e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/PolyHedra/Material.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_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Material 11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: _EMISSION 13 | m_LightmapFlags: 0 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Ints: [] 59 | m_Floats: 60 | - _BlendOp: 0 61 | - _BumpScale: 1 62 | - _CameraFadingEnabled: 0 63 | - _CameraFarFadeDistance: 2 64 | - _CameraNearFadeDistance: 1 65 | - _Cull: 2 66 | - _Cutoff: 0.5 67 | - _DetailNormalMapScale: 1 68 | - _DistortionBlend: 0.5 69 | - _DistortionEnabled: 0 70 | - _DistortionStrength: 1 71 | - _DistortionStrengthScaled: 0 72 | - _DstBlend: 0 73 | - _EmissionEnabled: 0 74 | - _FlipbookMode: 0 75 | - _GlossMapScale: 1 76 | - _Glossiness: 0 77 | - _GlossyReflections: 1 78 | - _LightingEnabled: 1 79 | - _Metallic: 0 80 | - _Mode: 0 81 | - _OcclusionStrength: 1 82 | - _Parallax: 0.02 83 | - _SmoothnessTextureChannel: 0 84 | - _SoftParticlesEnabled: 0 85 | - _SoftParticlesFarFadeDistance: 1 86 | - _SoftParticlesNearFadeDistance: 0 87 | - _SpecularHighlights: 1 88 | - _SrcBlend: 1 89 | - _UVSec: 0 90 | - _ZWrite: 1 91 | m_Colors: 92 | - _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0} 93 | - _Color: {r: 1, g: 1, b: 1, a: 1} 94 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 95 | - _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0} 96 | m_BuildTextureStacks: [] 97 | -------------------------------------------------------------------------------- /Assets/Examples/PolyHedra/Material.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 013641634e8dfc14292e0f32c2520056 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/PolyHedra/NefPolyhedronExample.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using CGALDotNet; 6 | using CGALDotNetGeometry.Numerics; 7 | using CGALDotNet.Polyhedra; 8 | using Common.Unity.Drawing; 9 | 10 | namespace CGALDotNetUnity.Polyhedra 11 | { 12 | 13 | public class NefPolyhedronExample : MonoBehaviour 14 | { 15 | public Material material; 16 | 17 | private GameObject m_mesh; 18 | 19 | private SegmentRenderer m_wireframeRender; 20 | 21 | private void Start() 22 | { 23 | var box1 = PolyhedronFactory.CreateCube(); 24 | box1.Translate(new Point3d(0.5)); 25 | 26 | var box2 = PolyhedronFactory.CreateCube(); 27 | 28 | var nef1 = new NefPolyhedron3(box1); 29 | var nef2 = new NefPolyhedron3(box2); 30 | 31 | var nef3 = nef1.Join(nef2); 32 | 33 | if (nef3.ConvertToPolyhedron(out Polyhedron3 poly)) 34 | { 35 | m_mesh = poly.ToUnityMesh("Mesh", material, true); 36 | m_mesh.transform.position = new Vector3(0, 0.5f, 0); 37 | 38 | m_wireframeRender = RendererBuilder.CreateWireframeRenderer(poly, Color.black, 0); 39 | } 40 | 41 | } 42 | 43 | private void OnRenderObject() 44 | { 45 | m_wireframeRender.LocalToWorld = m_mesh.transform.localToWorldMatrix; 46 | m_wireframeRender.Draw(); 47 | } 48 | 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /Assets/Examples/PolyHedra/NefPolyhedronExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4035764d08eea5a41be2eb7bb445009e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/PolyHedra/NefPolyhedronExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37f38100459685141a947337b362dd76 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/PolyHedra/PolyhedronExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae26fd0b6b19c044cb8d4a512507a4b1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/PolyHedra/PolyhedronExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e26bd5dab627c843b31b58a5cebaa27 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Polygons.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b9bd49858692ae247aea91f122262e57 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Polygons/CreatePolygonExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc5640787073b2b4495b8c051bd5fe4e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Polygons/CreatePolygonExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a84a49840b779a0408e9d2ed43e3f023 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Polygons/CreatePolygonWithHolesExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 70922b1ebcfacc2479239473bae0d11e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Polygons/CreatePolygonWithHolesExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 603c0b0bc3241994d9cb8db540c60c61 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Polygons/PolygonBooleanExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 74336c08f864bf4488f149c5919a93f9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Polygons/PolygonBooleanExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0f309be26f06a2f4aaf90d24368554f8 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Polygons/PolygonMinkowskiExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 12cd351dfb705ae46aaf8806783e3b52 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Polygons/PolygonMinkowskiExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22fb5f9e8cbc58c45b4bcd97d96d8f60 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Polygons/PolygonOffsetExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8ea53da971a87204fa5684c61b382d39 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Polygons/PolygonOffsetExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 36b95d7c3643f574c99383687ee2c53c 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Polygons/PolygonPartitionExample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using Common.Unity.Drawing; 6 | using CGALDotNet; 7 | using CGALDotNet.Polygons; 8 | using CGALDotNetGeometry.Numerics; 9 | using CGALDotNetGeometry.Shapes; 10 | 11 | namespace CGALDotNetUnity.Polygons 12 | { 13 | 14 | public class PolygonPartitionExample : InputBehaviour 15 | { 16 | 17 | private Color pointColor = new Color32(80, 80, 200, 255); 18 | 19 | private Color faceColor = new Color32(80, 80, 200, 128); 20 | 21 | private Color lineColor = new Color32(0, 0, 0, 255); 22 | 23 | private Polygon2 Polygon; 24 | 25 | private Dictionary Renderers; 26 | 27 | private POLYGON_PARTITION Op = POLYGON_PARTITION.OPTIMAL_CONVEX; 28 | 29 | protected override void Start() 30 | { 31 | //Init base class 32 | base.Start(); 33 | 34 | //Set the input mode to polygons. 35 | //Determines when OnInputComplete is called. 36 | SetInputMode(INPUT_MODE.POLYGON); 37 | 38 | //Create the place to store the renderers that draw the shapes. 39 | Renderers = new Dictionary(); 40 | } 41 | 42 | protected override void OnInputComplete(List points) 43 | { 44 | //Create the polygon from the points. 45 | //We just use the EIK kernel as its the fastest. 46 | Polygon = new Polygon2(points.ToArray()); 47 | 48 | //Polygon must be simple to continue. 49 | if (Polygon.IsSimple) 50 | { 51 | //Polygons must be ccw. 52 | if (!Polygon.IsCounterClockWise) 53 | Polygon.Reverse(); 54 | 55 | //Perfom the partion algorithm 56 | PartitionPolygon(); 57 | } 58 | 59 | InputPoints.Clear(); 60 | } 61 | 62 | /// 63 | /// Called when scene cleared. 64 | /// 65 | protected override void OnCleared() 66 | { 67 | Polygon = null; 68 | Renderers.Clear(); 69 | InputPoints.Clear(); 70 | SetInputMode(INPUT_MODE.POLYGON); 71 | } 72 | 73 | protected override void Update() 74 | { 75 | base.Update(); 76 | 77 | if (Input.GetKeyDown(KeyCode.Tab)) 78 | { 79 | Op = CGALEnum.Next(Op); 80 | PartitionPolygon(); 81 | } 82 | } 83 | 84 | /// 85 | /// Draw the renderers in post render. 86 | /// 87 | private void OnPostRender() 88 | { 89 | //This draws the grid 90 | DrawGrid(); 91 | 92 | //This draws the polygon and the input point. 93 | foreach (var renderer in Renderers.Values) 94 | renderer.Draw(); 95 | 96 | //This draws the line of points the user 97 | //is creating but they dont for a polygon yet. 98 | DrawInput(lineColor, pointColor, PointSize); 99 | } 100 | 101 | /// 102 | /// Perform the partition. 103 | /// 104 | private void PartitionPolygon() 105 | { 106 | if (Polygon == null) return; 107 | 108 | var results = new List>(); 109 | PolygonPartition2.Instance.Partition(Op, Polygon, results); 110 | 111 | CreateRenderer(results); 112 | } 113 | 114 | /// 115 | /// Create the renderer that daws the polygon. 116 | /// This just ueses unitys GL to draw lies and points. 117 | /// Its not very fast and just used for demos. 118 | /// 119 | private void CreateRenderer(List> list) 120 | { 121 | Renderers.Clear(); 122 | for (int i = 0; i < list.Count; i++) 123 | { 124 | var polygon = list[i]; 125 | Renderers["Polygon " + i] = Draw(). 126 | Faces(polygon, faceColor). 127 | Outline(polygon, lineColor). 128 | Points(polygon, lineColor, pointColor). 129 | PopRenderer(); 130 | } 131 | 132 | } 133 | 134 | protected void OnGUI() 135 | { 136 | int textLen = 400; 137 | int textHeight = 25; 138 | GUI.color = Color.black; 139 | 140 | GUI.Label(new Rect(10, 10, textLen, textHeight), "Space to clear polygon."); 141 | GUI.Label(new Rect(10, 30, textLen, textHeight), "Left click to place point."); 142 | GUI.Label(new Rect(10, 50, textLen, textHeight), "Click on first point to close polygon."); 143 | GUI.Label(new Rect(10, 70, textLen, textHeight), "Tab to change partition type."); 144 | GUI.Label(new Rect(10, 90, textLen, textHeight), "Current op = " + Op); 145 | } 146 | 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /Assets/Examples/Polygons/PolygonPartitionExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 88534afbe79222148830cdbb75241664 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Polygons/PolygonPartitionExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c21d650444db657428bd192a3c2609d9 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Polygons/PolygonSimplificationExample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using Common.Unity.Drawing; 6 | using CGALDotNet; 7 | using CGALDotNet.Polygons; 8 | using CGALDotNetGeometry.Numerics; 9 | 10 | namespace CGALDotNetUnity.Polygons 11 | { 12 | 13 | public class PolygonSimplificationExample : InputBehaviour 14 | { 15 | private Color pointColor = new Color32(80, 80, 200, 255); 16 | 17 | private Color faceColor = new Color32(80, 80, 200, 128); 18 | 19 | private Color lineColor = new Color32(0, 0, 0, 255); 20 | 21 | private PolygonWithHoles2 Polygon, SimplifiedPolygon; 22 | 23 | private Dictionary Renderers; 24 | 25 | private PolygonSimplificationParams Param; 26 | 27 | protected override void Start() 28 | { 29 | //Init base layer and turn input off. 30 | base.Start(); 31 | SetInputMode(INPUT_MODE.NONE); 32 | Renderers = new Dictionary(); 33 | 34 | var star = PolygonFactory.KochStar(20, 3); 35 | //var circle = PolygonFactory.CreateCircle(3, 32); 36 | //circle.Reverse(); 37 | 38 | //Create a polygon to show before simplication 39 | Polygon = new PolygonWithHoles2(star); 40 | //Polygon.AddHole(circle); 41 | Polygon.Translate(new Point2d(-10, 0)); 42 | CreateRenderer("Polygon", Polygon); 43 | 44 | //Set some of the simplification params 45 | Param = PolygonSimplificationParams.Default; 46 | Param.threshold = 100; 47 | Param.stop = POLYGON_SIMP_STOP_FUNC.BELOW_THRESHOLD; 48 | Param.cost = POLYGON_SIMP_COST_FUNC.SQUARE_DIST; 49 | 50 | //Perform the simplification 51 | Simplify(); 52 | } 53 | 54 | /// 55 | /// Performs the simplification 56 | /// 57 | private void Simplify() 58 | { 59 | //Create a polygon to show after simplication 60 | SimplifiedPolygon = PolygonSimplification2.Instance.Simplify(Polygon, Param); 61 | SimplifiedPolygon.Translate(new Point2d(20, 0)); 62 | 63 | CreateRenderer("Simplified", SimplifiedPolygon); 64 | } 65 | 66 | /// 67 | /// Create the renderer that daws the polygon. 68 | /// This just ueses unitys GL to draw lines and points. 69 | /// Its not very fast 70 | private void CreateRenderer(string name, PolygonWithHoles2 polygon) 71 | { 72 | Renderers[name] = Draw(). 73 | Faces(polygon, faceColor). 74 | Outline(polygon, lineColor). 75 | Points(polygon, lineColor, pointColor, PointSize). 76 | PopRenderer(); 77 | 78 | int holes = polygon.HoleCount; 79 | for (int i = 0; i < holes; i++) 80 | { 81 | var hole = polygon.Copy(POLYGON_ELEMENT.HOLE, i); 82 | 83 | Renderers[name + " Hole " + i] = Draw(). 84 | Outline(hole, lineColor). 85 | Points(hole, lineColor, pointColor, PointSize). 86 | PopRenderer(); 87 | } 88 | } 89 | 90 | protected override void Update() 91 | { 92 | base.Update(); 93 | 94 | if(Input.GetKeyDown(KeyCode.KeypadMinus) || Input.GetKeyDown(KeyCode.Minus)) 95 | { 96 | Param.threshold -= 1; 97 | 98 | if (Param.threshold < 1) 99 | Param.threshold = 1; 100 | 101 | Simplify(); 102 | } 103 | else if (Input.GetKeyDown(KeyCode.KeypadPlus) || Input.GetKeyDown(KeyCode.Plus)) 104 | { 105 | Param.threshold += 1; 106 | 107 | Simplify(); 108 | } 109 | } 110 | 111 | private void OnPostRender() 112 | { 113 | DrawGrid(); 114 | 115 | foreach (var renderer in Renderers.Values) 116 | renderer.Draw(); 117 | 118 | } 119 | 120 | protected void OnGUI() 121 | { 122 | int textLen = 400; 123 | int textHeight = 25; 124 | GUI.color = Color.black; 125 | 126 | GUI.Label(new Rect(10, 10, textLen, textHeight), "+/- to adjust simplification threshold."); 127 | GUI.Label(new Rect(10, 30, textLen, textHeight), "Cost Function = " + Param.cost); 128 | GUI.Label(new Rect(10, 50, textLen, textHeight), "Stop Function = " + Param.stop); 129 | GUI.Label(new Rect(10, 70, textLen, textHeight), "Threshold = " + Param.threshold); 130 | 131 | } 132 | 133 | 134 | 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /Assets/Examples/Polygons/PolygonSimplificationExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: affb4b928b2594a42a259788b92cb8eb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Polygons/PolygonSimplificationExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0b18c4903b0bca9438b8a080eb4be6a2 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Polygons/PolygonVisibilityExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f5df91d6a4456640aac7065ae971a34 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Polygons/PolygonVisibilityExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a1ecf088005ac674eb5d4914984a5cdc 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Polyhedra/ConvexDecompositionExample.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using CGALDotNet; 6 | using CGALDotNetGeometry.Numerics; 7 | using CGALDotNet.Polyhedra; 8 | 9 | namespace CGALDotNetUnity.Polyhedra 10 | { 11 | 12 | public class ConvexDecompositionExample : MonoBehaviour 13 | { 14 | public Material material; 15 | 16 | private void Start() 17 | { 18 | var box1 = PolyhedronFactory.CreateCube(); 19 | box1.Translate(new Point3d(0.5)); 20 | 21 | var box2 = PolyhedronFactory.CreateCube(); 22 | 23 | var nef1 = new NefPolyhedron3(box1); 24 | var nef2 = new NefPolyhedron3(box2); 25 | 26 | var nef3 = nef1.Join(nef2); 27 | 28 | nef3.ConvexDecomposition(); 29 | 30 | var volumes = new List>(); 31 | nef3.GetVolumes(volumes); 32 | 33 | for(int i = 0; i < volumes.Count; i++) 34 | { 35 | //first poly if the original so skip. 36 | if (i == 0) continue; 37 | 38 | var poly = volumes[i]; 39 | 40 | var mat = new Material(material); 41 | mat.color = RandomColor(); 42 | 43 | poly.ToUnityMesh("Convex", mat); 44 | } 45 | 46 | } 47 | 48 | private Color RandomColor() 49 | { 50 | Color col = new Color(); 51 | col.r = Random.value; 52 | col.g = Random.value; 53 | col.b = Random.value; 54 | return col; 55 | } 56 | 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /Assets/Examples/Polyhedra/ConvexDecompositionExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8fecbcd4ccf0a564e9ab7acbcfbcbca3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Polyhedra/ConvexDecompositionExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c0a0b3a3129b5fb4f8d9aa2d3b48ec41 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Polyhedra/PolyhedronBooleanExample.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using CGALDotNet; 6 | using CGALDotNetGeometry.Numerics; 7 | using CGALDotNet.Polyhedra; 8 | using CGALDotNet.Processing; 9 | using Common.Unity.Drawing; 10 | 11 | namespace CGALDotNetUnity.Polyhedra 12 | { 13 | 14 | public class PolyhedronBooleanExample : MonoBehaviour 15 | { 16 | public Material material; 17 | 18 | public Color wireFrameColor = Color.black; 19 | 20 | private GameObject m_mesh; 21 | 22 | private SegmentRenderer m_wireframeRender; 23 | 24 | private void Start() 25 | { 26 | var box1 = PolyhedronFactory.CreateCube(); 27 | box1.Translate(new Point3d(0.5)); 28 | 29 | var box2 = PolyhedronFactory.CreateCube(); 30 | 31 | var boolean = MeshProcessingBoolean.Instance; 32 | var op = POLYHEDRA_BOOLEAN.UNION; 33 | 34 | if (boolean.Op(op, box1, box2, out Polyhedron3 poly)) 35 | { 36 | m_mesh = poly.ToUnityMesh("Mesh", material, true); 37 | m_mesh.transform.position = new Vector3(0, 0.5f, 0); 38 | 39 | m_wireframeRender = RendererBuilder.CreateWireframeRenderer(poly, wireFrameColor, 0); 40 | } 41 | 42 | } 43 | 44 | private void OnRenderObject() 45 | { 46 | m_wireframeRender.LocalToWorld = m_mesh.transform.localToWorldMatrix; 47 | m_wireframeRender.Draw(); 48 | } 49 | 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /Assets/Examples/Polyhedra/PolyhedronBooleanExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ff2f18b885afae4cb65be807d216f7b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Polyhedra/PolyhedronBooleanExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ecb0aa169e534b844bcaa5a13eb75c9e 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Polyhedra/SurfaceMeshExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5bd9c2a6f53d75549862a4b63ec0ad79 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Polyhedra/SurfaceMeshExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a3a9700379454dd4dbdd6d6fd4197e7d 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Processing.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 766d2c971b8c0a746a96f9459a427ea3 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Processing/HeatMethodExample.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using UnityEngine; 5 | 6 | using CGALDotNet; 7 | using CGALDotNetGeometry.Numerics; 8 | using CGALDotNetGeometry.Shapes; 9 | using CGALDotNet.Polyhedra; 10 | using CGALDotNet.Processing; 11 | using Common.Unity.Drawing; 12 | 13 | namespace CGALDotNetUnity.Processing 14 | { 15 | 16 | public class HeatMethodExample : MonoBehaviour 17 | { 18 | public Material material; 19 | 20 | public string file; 21 | 22 | public Color wireframeColor = Color.black; 23 | 24 | private SurfaceMesh3 m_mesh; 25 | 26 | private GameObject m_object; 27 | 28 | private Texture2D m_gradient; 29 | 30 | private SegmentRenderer m_wireframe; 31 | 32 | private void Start() 33 | { 34 | //Used for debuging. 35 | //dont recommend loading meshes like this. 36 | string filename = Application.dataPath + "/Examples/Data/" + file; 37 | 38 | var split = filename.Split('/', '.'); 39 | int i = split.Length - 2; 40 | var name = i > 0 ? split[i] : "Mesh"; 41 | 42 | m_mesh = new SurfaceMesh3(); 43 | m_mesh.ReadOFF(filename); 44 | m_mesh.Rotate(Quaternion3d.RotateY(new Degree(180))); 45 | 46 | var ray = new Ray(Camera.main.transform.position, Camera.main.transform.forward); 47 | 48 | RayCast(ray); 49 | 50 | m_wireframe = RendererBuilder.CreateWireframeRenderer(m_mesh, wireframeColor, 0.001f); 51 | } 52 | 53 | private List GetDistances(SurfaceMesh3 poly, int index) 54 | { 55 | var hm = HeatMethod.Instance; 56 | 57 | var distances = new List(); 58 | var max = hm.EstimateGeodesicDistances(poly, index, distances); 59 | 60 | for (int i = 0; i < distances.Count; i++) 61 | distances[i] = distances[i] / max; 62 | 63 | return distances; 64 | } 65 | 66 | private Color[] DistancesToColors(List distances) 67 | { 68 | var gradient = CreateGradient(); 69 | var colors = new Color[distances.Count]; 70 | 71 | for(int i = 0; i < distances.Count; i++) 72 | { 73 | var a = (float)distances[i]; 74 | colors[i] = gradient.GetPixelBilinear(a, 0); 75 | } 76 | 77 | return colors; 78 | } 79 | 80 | private GameObject CreateGameobject(string name, SurfaceMesh3 poly, Color[] colors) 81 | { 82 | return poly.ToUnityMesh(name, material, colors, false); 83 | } 84 | 85 | private Texture2D CreateGradient() 86 | { 87 | if (m_gradient != null) 88 | return m_gradient; 89 | 90 | var colors = new Color[] 91 | { 92 | Color.red, 93 | Color.yellow, 94 | Color.white 95 | }; 96 | 97 | m_gradient = new Texture2D(colors.Length, 1); 98 | m_gradient.wrapMode = TextureWrapMode.Clamp; 99 | m_gradient.SetPixels(colors); 100 | m_gradient.Apply(); 101 | 102 | return m_gradient; 103 | } 104 | 105 | private bool RayCast(Ray ray) 106 | { 107 | 108 | if (m_mesh.LocateVertex(ray.ToCGALRay3d(), 0.01, out MeshVertex3 vertex)) 109 | { 110 | Debug.Log(vertex); 111 | 112 | if (m_object != null) 113 | Destroy(m_object); 114 | 115 | var distances = GetDistances(m_mesh, vertex.Index); 116 | var colors = DistancesToColors(distances); 117 | 118 | m_object = CreateGameobject(name, m_mesh, colors); 119 | 120 | return true; 121 | } 122 | else 123 | { 124 | if (m_object != null) 125 | Destroy(m_object); 126 | 127 | return false; 128 | } 129 | } 130 | 131 | private void Update() 132 | { 133 | 134 | if (Input.GetMouseButtonDown(0)) 135 | { 136 | var ray = Camera.main.ScreenPointToRay(Input.mousePosition); 137 | 138 | RayCast(ray); 139 | } 140 | 141 | if(Input.GetKeyDown(KeyCode.Tab)) 142 | { 143 | m_wireframe.Enabled = !m_wireframe.Enabled; 144 | } 145 | } 146 | 147 | private void OnRenderObject() 148 | { 149 | if(m_object != null) 150 | { 151 | m_wireframe.SetColor(wireframeColor); 152 | m_wireframe.Draw(); 153 | } 154 | 155 | } 156 | 157 | } 158 | 159 | } 160 | -------------------------------------------------------------------------------- /Assets/Examples/Processing/HeatMethodExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd80c6694ae79054b9b0b3356215ab26 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Processing/HeatMethodExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 348f25fbf6219d3478f79010c38fd4e9 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Processing/HeatMethodMat.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_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: HeatMethodMat 11 | m_Shader: {fileID: 210, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: _COLORCOLOR_ON 13 | m_LightmapFlags: 0 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: 19 | - ALWAYS 20 | m_SavedProperties: 21 | serializedVersion: 3 22 | m_TexEnvs: 23 | - _BumpMap: 24 | m_Texture: {fileID: 0} 25 | m_Scale: {x: 1, y: 1} 26 | m_Offset: {x: 0, y: 0} 27 | - _DetailAlbedoMap: 28 | m_Texture: {fileID: 0} 29 | m_Scale: {x: 1, y: 1} 30 | m_Offset: {x: 0, y: 0} 31 | - _DetailMask: 32 | m_Texture: {fileID: 0} 33 | m_Scale: {x: 1, y: 1} 34 | m_Offset: {x: 0, y: 0} 35 | - _DetailNormalMap: 36 | m_Texture: {fileID: 0} 37 | m_Scale: {x: 1, y: 1} 38 | m_Offset: {x: 0, y: 0} 39 | - _EmissionMap: 40 | m_Texture: {fileID: 0} 41 | m_Scale: {x: 1, y: 1} 42 | m_Offset: {x: 0, y: 0} 43 | - _MainTex: 44 | m_Texture: {fileID: 0} 45 | m_Scale: {x: 1, y: 1} 46 | m_Offset: {x: 0, y: 0} 47 | - _MetallicGlossMap: 48 | m_Texture: {fileID: 0} 49 | m_Scale: {x: 1, y: 1} 50 | m_Offset: {x: 0, y: 0} 51 | - _OcclusionMap: 52 | m_Texture: {fileID: 0} 53 | m_Scale: {x: 1, y: 1} 54 | m_Offset: {x: 0, y: 0} 55 | - _ParallaxMap: 56 | m_Texture: {fileID: 0} 57 | m_Scale: {x: 1, y: 1} 58 | m_Offset: {x: 0, y: 0} 59 | m_Ints: [] 60 | m_Floats: 61 | - _BlendOp: 0 62 | - _BumpScale: 1 63 | - _CameraFadingEnabled: 0 64 | - _CameraFarFadeDistance: 2 65 | - _CameraNearFadeDistance: 1 66 | - _ColorMode: 4 67 | - _Cull: 2 68 | - _Cutoff: 0.5 69 | - _DetailNormalMapScale: 1 70 | - _DistortionBlend: 0.5 71 | - _DistortionEnabled: 0 72 | - _DistortionStrength: 1 73 | - _DistortionStrengthScaled: 0 74 | - _DstBlend: 0 75 | - _EmissionEnabled: 0 76 | - _FlipbookMode: 0 77 | - _GlossMapScale: 1 78 | - _Glossiness: 0 79 | - _GlossyReflections: 1 80 | - _LightingEnabled: 1 81 | - _Metallic: 0 82 | - _Mode: 0 83 | - _OcclusionStrength: 1 84 | - _Parallax: 0.02 85 | - _SmoothnessTextureChannel: 0 86 | - _SoftParticlesEnabled: 0 87 | - _SoftParticlesFarFadeDistance: 1 88 | - _SoftParticlesNearFadeDistance: 0 89 | - _SpecularHighlights: 1 90 | - _SrcBlend: 1 91 | - _UVSec: 0 92 | - _ZWrite: 1 93 | m_Colors: 94 | - _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0} 95 | - _Color: {r: 1, g: 1, b: 1, a: 1} 96 | - _ColorAddSubDiff: {r: 0, g: 0, b: 0, a: 0} 97 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 98 | - _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0} 99 | m_BuildTextureStacks: [] 100 | -------------------------------------------------------------------------------- /Assets/Examples/Processing/HeatMethodMat.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb1e3f572cdf1054d9e4241650a261a6 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Processing/Material.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_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Material 11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Ints: [] 59 | m_Floats: 60 | - _BumpScale: 1 61 | - _Cutoff: 0.5 62 | - _DetailNormalMapScale: 1 63 | - _DstBlend: 0 64 | - _GlossMapScale: 1 65 | - _Glossiness: 0 66 | - _GlossyReflections: 1 67 | - _Metallic: 0 68 | - _Mode: 0 69 | - _OcclusionStrength: 1 70 | - _Parallax: 0.02 71 | - _SmoothnessTextureChannel: 0 72 | - _SpecularHighlights: 1 73 | - _SrcBlend: 1 74 | - _UVSec: 0 75 | - _ZWrite: 1 76 | m_Colors: 77 | - _Color: {r: 0.6226415, g: 0.6226415, b: 0.6226415, a: 1} 78 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 79 | m_BuildTextureStacks: [] 80 | -------------------------------------------------------------------------------- /Assets/Examples/Processing/Material.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d1f3a110c13e28445a7b7f1d0277a343 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Processing/ProcessingExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aeb3b013b9a0a13408a516f1ff5babf4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Processing/ProcessingExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 58e6cdec9408c4c43bcc532ffed8a2e3 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Processing/SlicerExample.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using UnityEngine; 5 | 6 | using CGALDotNet; 7 | using CGALDotNetGeometry.Numerics; 8 | using CGALDotNet.Polyhedra; 9 | using CGALDotNet.Processing; 10 | using CGALDotNet.Polylines; 11 | 12 | using Common.Unity.Drawing; 13 | 14 | namespace CGALDotNetUnity.Processing 15 | { 16 | 17 | public class SlicerExample : MonoBehaviour 18 | { 19 | public Material material; 20 | 21 | public Color lineColor = Color.black; 22 | 23 | public int slices = 20; 24 | 25 | public string file; 26 | 27 | private Polyhedron3 poly; 28 | 29 | private GameObject m_object; 30 | 31 | private SegmentRenderer m_renderer; 32 | 33 | private void Start() 34 | { 35 | //Used for debuging. 36 | //dont recommend loading meshes like this. 37 | string filename = Application.dataPath + "/Examples/Data/" + file; 38 | 39 | var split = filename.Split('/', '.'); 40 | int i = split.Length - 2; 41 | var name = i > 0 ? split[i] : "Mesh"; 42 | 43 | poly = new Polyhedron3(); 44 | poly.ReadOFF(filename); 45 | //poly.Triangulate(); 46 | 47 | m_object = CreateGameobject(name, poly); 48 | 49 | var bounds = LookAt(m_object); 50 | 51 | var lines = Slice(poly, bounds, slices); 52 | 53 | m_renderer = CreateLineRenderer(lines, lineColor); 54 | } 55 | 56 | private Bounds LookAt(GameObject go) 57 | { 58 | var filter = go.GetComponent(); 59 | if (filter == null) return new Bounds(); 60 | 61 | var bounds = filter.sharedMesh.bounds; 62 | var size = bounds.size; 63 | var center = bounds.center; 64 | 65 | Camera.main.transform.position = center + new Vector3(0, 0, size.z * 5); 66 | Camera.main.transform.LookAt(center, Vector3.up); 67 | 68 | return bounds; 69 | } 70 | 71 | private List> Slice(Polyhedron3 poly, Bounds bounds, int count) 72 | { 73 | var size = bounds.size; 74 | var half = size * 0.5f; 75 | half.x = 0; 76 | half.z = 0; 77 | 78 | var center = bounds.center; 79 | 80 | var start = (center + half).ToCGALPoint3d(); 81 | var end = (center - half).ToCGALPoint3d(); 82 | var increment = (end - start).Magnitude / count; 83 | 84 | var slicer = MeshProcessingSlicer.Instance; 85 | 86 | var lines = new List>(); 87 | slicer.Slice(poly, start, end, increment, lines); 88 | 89 | return lines; 90 | } 91 | 92 | private GameObject CreateGameobject(string name, Polyhedron3 poly) 93 | { 94 | return poly.ToUnityMesh(name, material, false); 95 | } 96 | 97 | private SegmentRenderer CreateLineRenderer(List> lines, Color color) 98 | { 99 | var renderer = new SegmentRenderer(); 100 | renderer.DefaultColor = color; 101 | 102 | foreach(var line in lines) 103 | { 104 | var points = line.ToArray().ToUnityVector3(); 105 | renderer.Load(points, null, LINE_MODE.LINES); 106 | } 107 | 108 | return renderer; 109 | } 110 | 111 | private void OnRenderObject() 112 | { 113 | if(lineColor != m_renderer.DefaultColor) 114 | m_renderer.SetColor(lineColor); 115 | 116 | m_renderer.Draw(); 117 | } 118 | 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /Assets/Examples/Processing/SlicerExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0a7058905f13314686adfa65aae1e66 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Processing/SlicerExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 830ae3d4bc644c94288c0c35d1e47253 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/RendererBuilder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d19a1c06e91e3d8408ec587cb98f6e0d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Triangulations.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 12df5ffaee1463d47969ba67f5de6500 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Triangulations/EdgeMaterial.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_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: EdgeMaterial 11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Ints: [] 59 | m_Floats: 60 | - _BumpScale: 1 61 | - _Cutoff: 0.5 62 | - _DetailNormalMapScale: 1 63 | - _DstBlend: 0 64 | - _GlossMapScale: 1 65 | - _Glossiness: 0 66 | - _GlossyReflections: 1 67 | - _Metallic: 0 68 | - _Mode: 0 69 | - _OcclusionStrength: 1 70 | - _Parallax: 0.02 71 | - _SmoothnessTextureChannel: 0 72 | - _SpecularHighlights: 1 73 | - _SrcBlend: 1 74 | - _UVSec: 0 75 | - _ZWrite: 1 76 | m_Colors: 77 | - _Color: {r: 0.6603774, g: 0.6603774, b: 0.6603774, a: 1} 78 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 79 | m_BuildTextureStacks: [] 80 | -------------------------------------------------------------------------------- /Assets/Examples/Triangulations/EdgeMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9100d3f5442282a4d9db03b0412e72e7 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Triangulations/HullMaterial.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_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: HullMaterial 11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: _ALPHAPREMULTIPLY_ON 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: 3000 17 | stringTagMap: 18 | RenderType: Transparent 19 | disabledShaderPasses: [] 20 | m_SavedProperties: 21 | serializedVersion: 3 22 | m_TexEnvs: 23 | - _BumpMap: 24 | m_Texture: {fileID: 0} 25 | m_Scale: {x: 1, y: 1} 26 | m_Offset: {x: 0, y: 0} 27 | - _DetailAlbedoMap: 28 | m_Texture: {fileID: 0} 29 | m_Scale: {x: 1, y: 1} 30 | m_Offset: {x: 0, y: 0} 31 | - _DetailMask: 32 | m_Texture: {fileID: 0} 33 | m_Scale: {x: 1, y: 1} 34 | m_Offset: {x: 0, y: 0} 35 | - _DetailNormalMap: 36 | m_Texture: {fileID: 0} 37 | m_Scale: {x: 1, y: 1} 38 | m_Offset: {x: 0, y: 0} 39 | - _EmissionMap: 40 | m_Texture: {fileID: 0} 41 | m_Scale: {x: 1, y: 1} 42 | m_Offset: {x: 0, y: 0} 43 | - _MainTex: 44 | m_Texture: {fileID: 0} 45 | m_Scale: {x: 1, y: 1} 46 | m_Offset: {x: 0, y: 0} 47 | - _MetallicGlossMap: 48 | m_Texture: {fileID: 0} 49 | m_Scale: {x: 1, y: 1} 50 | m_Offset: {x: 0, y: 0} 51 | - _OcclusionMap: 52 | m_Texture: {fileID: 0} 53 | m_Scale: {x: 1, y: 1} 54 | m_Offset: {x: 0, y: 0} 55 | - _ParallaxMap: 56 | m_Texture: {fileID: 0} 57 | m_Scale: {x: 1, y: 1} 58 | m_Offset: {x: 0, y: 0} 59 | m_Ints: [] 60 | m_Floats: 61 | - _BumpScale: 1 62 | - _Cutoff: 0.5 63 | - _DetailNormalMapScale: 1 64 | - _DstBlend: 10 65 | - _GlossMapScale: 1 66 | - _Glossiness: 0 67 | - _GlossyReflections: 1 68 | - _Metallic: 0 69 | - _Mode: 3 70 | - _OcclusionStrength: 1 71 | - _Parallax: 0.02 72 | - _SmoothnessTextureChannel: 0 73 | - _SpecularHighlights: 1 74 | - _SrcBlend: 1 75 | - _UVSec: 0 76 | - _ZWrite: 0 77 | m_Colors: 78 | - _Color: {r: 1, g: 0, b: 0, a: 0.40392157} 79 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 80 | m_BuildTextureStacks: [] 81 | -------------------------------------------------------------------------------- /Assets/Examples/Triangulations/HullMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e92f670c398a1e541b24f3dfb0b93fa5 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Triangulations/Triangulation2Example.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3782e1ed82fb9f041a4bbe004bd98212 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Triangulations/Triangulation2Example.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 266a90484703242469ab21b507b78385 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Triangulations/Triangulation3Example.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 235f34a2ada31b64487e77966f7e7141 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Triangulations/Triangulation3Example.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 79df64168df69ea44bdf8c88131e43a1 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Triangulations/VertexMaterial.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_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: VertexMaterial 11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Ints: [] 59 | m_Floats: 60 | - _BumpScale: 1 61 | - _Cutoff: 0.5 62 | - _DetailNormalMapScale: 1 63 | - _DstBlend: 0 64 | - _GlossMapScale: 1 65 | - _Glossiness: 0 66 | - _GlossyReflections: 1 67 | - _Metallic: 0 68 | - _Mode: 0 69 | - _OcclusionStrength: 1 70 | - _Parallax: 0.02 71 | - _SmoothnessTextureChannel: 0 72 | - _SpecularHighlights: 1 73 | - _SrcBlend: 1 74 | - _UVSec: 0 75 | - _ZWrite: 1 76 | m_Colors: 77 | - _Color: {r: 1, g: 0.8302624, b: 0, a: 1} 78 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 79 | m_BuildTextureStacks: [] 80 | -------------------------------------------------------------------------------- /Assets/Examples/Triangulations/VertexMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0760eede4a9db604f8699c03e3497a4c 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Triangulations/VoronoiExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ddff7af7ff9c872438b9ea83788c4c24 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Triangulations/VoronoiExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 875093d8759d5e64f8c13814f4fb341c 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Media.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7fcdaf1ffaebbed4b91a0193f48be605 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Media/CGALIntersections.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scrawk/CGALDotNetUnity/ffc22ee93f6127b643586a4281c5e551312d2114/Assets/Media/CGALIntersections.png -------------------------------------------------------------------------------- /Assets/Media/CGALIntersections.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e02f50109ea3999469416e2236a3d056 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | vTOnly: 0 27 | ignoreMasterTextureLimit: 0 28 | grayScaleToAlpha: 0 29 | generateCubemap: 6 30 | cubemapConvolution: 0 31 | seamlessCubemap: 0 32 | textureFormat: 1 33 | maxTextureSize: 2048 34 | textureSettings: 35 | serializedVersion: 2 36 | filterMode: 1 37 | aniso: 1 38 | mipBias: 0 39 | wrapU: 0 40 | wrapV: 0 41 | wrapW: 0 42 | nPOTScale: 1 43 | lightmap: 0 44 | compressionQuality: 50 45 | spriteMode: 0 46 | spriteExtrude: 1 47 | spriteMeshType: 1 48 | alignment: 0 49 | spritePivot: {x: 0.5, y: 0.5} 50 | spritePixelsToUnits: 100 51 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 52 | spriteGenerateFallbackPhysicsShape: 1 53 | alphaUsage: 1 54 | alphaIsTransparency: 0 55 | spriteTessellationDetail: -1 56 | textureType: 0 57 | textureShape: 1 58 | singleChannelComponent: 0 59 | flipbookRows: 1 60 | flipbookColumns: 1 61 | maxTextureSizeSet: 0 62 | compressionQualitySet: 0 63 | textureFormatSet: 0 64 | ignorePngGamma: 0 65 | applyGammaDecoding: 0 66 | platformSettings: 67 | - serializedVersion: 3 68 | buildTarget: DefaultTexturePlatform 69 | maxTextureSize: 2048 70 | resizeAlgorithm: 0 71 | textureFormat: -1 72 | textureCompression: 1 73 | compressionQuality: 50 74 | crunchedCompression: 0 75 | allowsAlphaSplitting: 0 76 | overridden: 0 77 | androidETC2FallbackOverride: 0 78 | forceMaximumCompressionQuality_BC6H_BC7: 0 79 | spriteSheet: 80 | serializedVersion: 2 81 | sprites: [] 82 | outline: [] 83 | physicsShape: [] 84 | bones: [] 85 | spriteID: 86 | internalID: 0 87 | vertices: [] 88 | indices: 89 | edges: [] 90 | weights: [] 91 | secondaryTextures: [] 92 | nameFileIdTable: {} 93 | spritePackingTag: 94 | pSDRemoveMatte: 0 95 | pSDShowRemoveMatteOption: 0 96 | userData: 97 | assetBundleName: 98 | assetBundleVariant: 99 | -------------------------------------------------------------------------------- /Assets/Media/KockStar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scrawk/CGALDotNetUnity/ffc22ee93f6127b643586a4281c5e551312d2114/Assets/Media/KockStar.jpg -------------------------------------------------------------------------------- /Assets/Media/KockStar.jpg.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6643845bfaa5cf5499346f80d543a14c 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | vTOnly: 0 27 | grayScaleToAlpha: 0 28 | generateCubemap: 6 29 | cubemapConvolution: 0 30 | seamlessCubemap: 0 31 | textureFormat: 1 32 | maxTextureSize: 2048 33 | textureSettings: 34 | serializedVersion: 2 35 | filterMode: 1 36 | aniso: 1 37 | mipBias: 0 38 | wrapU: 0 39 | wrapV: 0 40 | wrapW: 0 41 | nPOTScale: 1 42 | lightmap: 0 43 | compressionQuality: 50 44 | spriteMode: 0 45 | spriteExtrude: 1 46 | spriteMeshType: 1 47 | alignment: 0 48 | spritePivot: {x: 0.5, y: 0.5} 49 | spritePixelsToUnits: 100 50 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 51 | spriteGenerateFallbackPhysicsShape: 1 52 | alphaUsage: 1 53 | alphaIsTransparency: 0 54 | spriteTessellationDetail: -1 55 | textureType: 0 56 | textureShape: 1 57 | singleChannelComponent: 0 58 | flipbookRows: 1 59 | flipbookColumns: 1 60 | maxTextureSizeSet: 0 61 | compressionQualitySet: 0 62 | textureFormatSet: 0 63 | ignorePngGamma: 0 64 | applyGammaDecoding: 0 65 | platformSettings: 66 | - serializedVersion: 3 67 | buildTarget: DefaultTexturePlatform 68 | maxTextureSize: 2048 69 | resizeAlgorithm: 0 70 | textureFormat: -1 71 | textureCompression: 1 72 | compressionQuality: 50 73 | crunchedCompression: 0 74 | allowsAlphaSplitting: 0 75 | overridden: 0 76 | androidETC2FallbackOverride: 0 77 | forceMaximumCompressionQuality_BC6H_BC7: 0 78 | spriteSheet: 79 | serializedVersion: 2 80 | sprites: [] 81 | outline: [] 82 | physicsShape: [] 83 | bones: [] 84 | spriteID: 85 | internalID: 0 86 | vertices: [] 87 | indices: 88 | edges: [] 89 | weights: [] 90 | secondaryTextures: [] 91 | spritePackingTag: 92 | pSDRemoveMatte: 0 93 | pSDShowRemoveMatteOption: 0 94 | userData: 95 | assetBundleName: 96 | assetBundleVariant: 97 | -------------------------------------------------------------------------------- /Assets/Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d7d933f10b9d52a4b9975e7ae423ba9f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Justin 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 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Volume: 1 8 | Rolloff Scale: 1 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_SampleRate: 0 12 | m_DSPBufferSize: 1024 13 | m_VirtualVoiceCount: 512 14 | m_RealVoiceCount: 32 15 | m_SpatializerPlugin: 16 | m_AmbisonicDecoderPlugin: 17 | m_DisableAudio: 0 18 | m_VirtualizeEffects: 1 19 | m_RequestedDSPBufferSize: 0 20 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 13 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_DefaultMaxDepenetrationVelocity: 10 11 | m_SleepThreshold: 0.005 12 | m_DefaultContactOffset: 0.01 13 | m_DefaultSolverIterations: 6 14 | m_DefaultSolverVelocityIterations: 1 15 | m_QueriesHitBackfaces: 0 16 | m_QueriesHitTriggers: 1 17 | m_EnableAdaptiveForce: 0 18 | m_ClothInterCollisionDistance: 0.1 19 | m_ClothInterCollisionStiffness: 0.2 20 | m_ContactsGeneration: 1 21 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 22 | m_AutoSimulation: 1 23 | m_AutoSyncTransforms: 0 24 | m_ReuseCollisionCallbacks: 0 25 | m_ClothInterCollisionSettingsToggle: 0 26 | m_ClothGravity: {x: 0, y: -9.81, z: 0} 27 | m_ContactPairsMode: 0 28 | m_BroadphaseType: 0 29 | m_WorldBounds: 30 | m_Center: {x: 0, y: 0, z: 0} 31 | m_Extent: {x: 250, y: 250, z: 250} 32 | m_WorldSubdivisions: 8 33 | m_FrictionType: 0 34 | m_EnableEnhancedDeterminism: 0 35 | m_EnableUnifiedHeightmaps: 1 36 | m_SolverType: 0 37 | m_DefaultMaxAngularSpeed: 50 38 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | m_configObjects: {} 9 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_SerializationMode: 2 8 | m_LineEndingsForNewScripts: 2 9 | m_DefaultBehaviorMode: 0 10 | m_PrefabRegularEnvironment: {fileID: 0} 11 | m_PrefabUIEnvironment: {fileID: 0} 12 | m_SpritePackerMode: 0 13 | m_SpritePackerPaddingPower: 1 14 | m_EtcTextureCompressorBehavior: 1 15 | m_EtcTextureFastCompressor: 1 16 | m_EtcTextureNormalCompressor: 2 17 | m_EtcTextureBestCompressor: 4 18 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;asmref;rsp 19 | m_ProjectGenerationRootNamespace: 20 | m_EnableTextureStreamingInEditMode: 1 21 | m_EnableTextureStreamingInPlayMode: 1 22 | m_AsyncShaderCompilation: 1 23 | m_CachingShaderPreprocessor: 0 24 | m_EnterPlayModeOptionsEnabled: 0 25 | m_EnterPlayModeOptions: 3 26 | m_GameObjectNamingDigits: 1 27 | m_GameObjectNamingScheme: 0 28 | m_AssetNamingUsesSpace: 1 29 | m_UseLegacyProbeSampleCount: 0 30 | m_SerializeInlineMappingsOnOneLine: 1 31 | m_DisableCookiesInLightmapper: 0 32 | m_AssetPipelineMode: 1 33 | m_CacheServerMode: 0 34 | m_CacheServerEndpoint: 35 | m_CacheServerNamespacePrefix: default 36 | m_CacheServerEnableDownload: 1 37 | m_CacheServerEnableUpload: 1 38 | m_CacheServerEnableAuth: 0 39 | m_CacheServerEnableTls: 0 40 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 13 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_VideoShadersIncludeMode: 2 32 | m_AlwaysIncludedShaders: 33 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 38 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 39 | - {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0} 40 | m_PreloadedShaders: [] 41 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} 42 | m_CustomRenderPipeline: {fileID: 0} 43 | m_TransparencySortMode: 0 44 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 45 | m_DefaultRenderingPath: 1 46 | m_DefaultMobileRenderingPath: 1 47 | m_TierSettings: [] 48 | m_LightmapStripping: 0 49 | m_FogStripping: 0 50 | m_InstancingStripping: 0 51 | m_LightmapKeepPlain: 1 52 | m_LightmapKeepDirCombined: 1 53 | m_LightmapKeepDynamicPlain: 1 54 | m_LightmapKeepDynamicDirCombined: 1 55 | m_LightmapKeepShadowMask: 1 56 | m_LightmapKeepSubtractive: 1 57 | m_FogKeepLinear: 1 58 | m_FogKeepExp: 1 59 | m_FogKeepExp2: 1 60 | m_AlbedoSwatchInfos: [] 61 | m_LightsUseLinearIntensity: 0 62 | m_LightsUseColorTemperature: 0 63 | m_LogWhenShaderIsCompiled: 0 64 | -------------------------------------------------------------------------------- /ProjectSettings/MemorySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!387306366 &1 4 | MemorySettings: 5 | m_ObjectHideFlags: 0 6 | m_EditorMemorySettings: 7 | m_MainAllocatorBlockSize: -1 8 | m_ThreadAllocatorBlockSize: -1 9 | m_MainGfxBlockSize: -1 10 | m_ThreadGfxBlockSize: -1 11 | m_CacheBlockSize: -1 12 | m_TypetreeBlockSize: -1 13 | m_ProfilerBlockSize: -1 14 | m_ProfilerEditorBlockSize: -1 15 | m_BucketAllocatorGranularity: -1 16 | m_BucketAllocatorBucketsCount: -1 17 | m_BucketAllocatorBlockSize: -1 18 | m_BucketAllocatorBlockCount: -1 19 | m_ProfilerBucketAllocatorGranularity: -1 20 | m_ProfilerBucketAllocatorBucketsCount: -1 21 | m_ProfilerBucketAllocatorBlockSize: -1 22 | m_ProfilerBucketAllocatorBlockCount: -1 23 | m_TempAllocatorSizeMain: -1 24 | m_JobTempAllocatorBlockSize: -1 25 | m_BackgroundJobTempAllocatorBlockSize: -1 26 | m_JobTempAllocatorReducedBlockSize: -1 27 | m_TempAllocatorSizeGIBakingWorker: -1 28 | m_TempAllocatorSizeNavMeshWorker: -1 29 | m_TempAllocatorSizeAudioWorker: -1 30 | m_TempAllocatorSizeCloudWorker: -1 31 | m_TempAllocatorSizeGfx: -1 32 | m_TempAllocatorSizeJobWorker: -1 33 | m_TempAllocatorSizeBackgroundWorker: -1 34 | m_TempAllocatorSizePreloadManager: -1 35 | m_PlatformMemorySettings: {} 36 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | maxJobWorkers: 0 89 | preserveTilesOutsideBounds: 0 90 | debug: 91 | m_Flags: 0 92 | m_SettingNames: 93 | - Humanoid 94 | -------------------------------------------------------------------------------- /ProjectSettings/PackageManagerSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_EnablePreviewPackages: 0 16 | m_EnablePackageDependencies: 0 17 | m_AdvancedSettingsExpanded: 1 18 | m_ScopedRegistriesSettingsExpanded: 1 19 | oneTimeWarningShown: 0 20 | m_Registries: 21 | - m_Id: main 22 | m_Name: 23 | m_Url: https://packages.unity.com 24 | m_Scopes: [] 25 | m_IsDefault: 1 26 | m_Capabilities: 7 27 | m_UserSelectedRegistryName: 28 | m_UserAddingNewScopedRegistry: 0 29 | m_RegistryInfoDraft: 30 | m_ErrorMessage: 31 | m_Original: 32 | m_Id: 33 | m_Name: 34 | m_Url: 35 | m_Scopes: [] 36 | m_IsDefault: 0 37 | m_Capabilities: 0 38 | m_Modified: 0 39 | m_Name: 40 | m_Url: 41 | m_Scopes: 42 | - 43 | m_SelectedScopeIndex: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_JobOptions: 23 | serializedVersion: 2 24 | useMultithreading: 0 25 | useConsistencySorting: 0 26 | m_InterpolationPosesPerJob: 100 27 | m_NewContactsPerJob: 30 28 | m_CollideContactsPerJob: 100 29 | m_ClearFlagsPerJob: 200 30 | m_ClearBodyForcesPerJob: 200 31 | m_SyncDiscreteFixturesPerJob: 50 32 | m_SyncContinuousFixturesPerJob: 50 33 | m_FindNearestContactsPerJob: 100 34 | m_UpdateTriggerContactsPerJob: 100 35 | m_IslandSolverCostThreshold: 100 36 | m_IslandSolverBodyCostScale: 1 37 | m_IslandSolverContactCostScale: 10 38 | m_IslandSolverJointCostScale: 10 39 | m_IslandSolverBodiesPerJob: 50 40 | m_IslandSolverContactsPerJob: 50 41 | m_SimulationMode: 0 42 | m_QueriesHitTriggers: 1 43 | m_QueriesStartInColliders: 1 44 | m_CallbacksOnDisable: 1 45 | m_ReuseCollisionCallbacks: 0 46 | m_AutoSyncTransforms: 0 47 | m_AlwaysShowColliders: 0 48 | m_ShowColliderSleep: 1 49 | m_ShowColliderContacts: 0 50 | m_ShowColliderAABB: 0 51 | m_ContactArrowScale: 0.2 52 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 53 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 54 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 55 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 56 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 57 | -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_DefaultPresets: {} 8 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2021.3.2f1 2 | m_EditorVersionWithRevision: 2021.3.2f1 (d6360bedb9a0) 3 | -------------------------------------------------------------------------------- /ProjectSettings/SceneTemplateSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "templatePinStates": [], 3 | "dependencyTypeInfos": [ 4 | { 5 | "userAdded": false, 6 | "type": "UnityEngine.AnimationClip", 7 | "ignore": false, 8 | "defaultInstantiationMode": 0, 9 | "supportsModification": true 10 | }, 11 | { 12 | "userAdded": false, 13 | "type": "UnityEditor.Animations.AnimatorController", 14 | "ignore": false, 15 | "defaultInstantiationMode": 0, 16 | "supportsModification": true 17 | }, 18 | { 19 | "userAdded": false, 20 | "type": "UnityEngine.AnimatorOverrideController", 21 | "ignore": false, 22 | "defaultInstantiationMode": 0, 23 | "supportsModification": true 24 | }, 25 | { 26 | "userAdded": false, 27 | "type": "UnityEditor.Audio.AudioMixerController", 28 | "ignore": false, 29 | "defaultInstantiationMode": 0, 30 | "supportsModification": true 31 | }, 32 | { 33 | "userAdded": false, 34 | "type": "UnityEngine.ComputeShader", 35 | "ignore": true, 36 | "defaultInstantiationMode": 1, 37 | "supportsModification": true 38 | }, 39 | { 40 | "userAdded": false, 41 | "type": "UnityEngine.Cubemap", 42 | "ignore": false, 43 | "defaultInstantiationMode": 0, 44 | "supportsModification": true 45 | }, 46 | { 47 | "userAdded": false, 48 | "type": "UnityEngine.GameObject", 49 | "ignore": false, 50 | "defaultInstantiationMode": 0, 51 | "supportsModification": true 52 | }, 53 | { 54 | "userAdded": false, 55 | "type": "UnityEditor.LightingDataAsset", 56 | "ignore": false, 57 | "defaultInstantiationMode": 0, 58 | "supportsModification": false 59 | }, 60 | { 61 | "userAdded": false, 62 | "type": "UnityEngine.LightingSettings", 63 | "ignore": false, 64 | "defaultInstantiationMode": 0, 65 | "supportsModification": true 66 | }, 67 | { 68 | "userAdded": false, 69 | "type": "UnityEngine.Material", 70 | "ignore": false, 71 | "defaultInstantiationMode": 0, 72 | "supportsModification": true 73 | }, 74 | { 75 | "userAdded": false, 76 | "type": "UnityEditor.MonoScript", 77 | "ignore": true, 78 | "defaultInstantiationMode": 1, 79 | "supportsModification": true 80 | }, 81 | { 82 | "userAdded": false, 83 | "type": "UnityEngine.PhysicMaterial", 84 | "ignore": false, 85 | "defaultInstantiationMode": 0, 86 | "supportsModification": true 87 | }, 88 | { 89 | "userAdded": false, 90 | "type": "UnityEngine.PhysicsMaterial2D", 91 | "ignore": false, 92 | "defaultInstantiationMode": 0, 93 | "supportsModification": true 94 | }, 95 | { 96 | "userAdded": false, 97 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", 98 | "ignore": false, 99 | "defaultInstantiationMode": 0, 100 | "supportsModification": true 101 | }, 102 | { 103 | "userAdded": false, 104 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", 105 | "ignore": false, 106 | "defaultInstantiationMode": 0, 107 | "supportsModification": true 108 | }, 109 | { 110 | "userAdded": false, 111 | "type": "UnityEngine.Rendering.VolumeProfile", 112 | "ignore": false, 113 | "defaultInstantiationMode": 0, 114 | "supportsModification": true 115 | }, 116 | { 117 | "userAdded": false, 118 | "type": "UnityEditor.SceneAsset", 119 | "ignore": false, 120 | "defaultInstantiationMode": 0, 121 | "supportsModification": false 122 | }, 123 | { 124 | "userAdded": false, 125 | "type": "UnityEngine.Shader", 126 | "ignore": true, 127 | "defaultInstantiationMode": 1, 128 | "supportsModification": true 129 | }, 130 | { 131 | "userAdded": false, 132 | "type": "UnityEngine.ShaderVariantCollection", 133 | "ignore": true, 134 | "defaultInstantiationMode": 1, 135 | "supportsModification": true 136 | }, 137 | { 138 | "userAdded": false, 139 | "type": "UnityEngine.Texture", 140 | "ignore": false, 141 | "defaultInstantiationMode": 0, 142 | "supportsModification": true 143 | }, 144 | { 145 | "userAdded": false, 146 | "type": "UnityEngine.Texture2D", 147 | "ignore": false, 148 | "defaultInstantiationMode": 0, 149 | "supportsModification": true 150 | }, 151 | { 152 | "userAdded": false, 153 | "type": "UnityEngine.Timeline.TimelineAsset", 154 | "ignore": false, 155 | "defaultInstantiationMode": 0, 156 | "supportsModification": true 157 | } 158 | ], 159 | "defaultDependencyTypeInfo": { 160 | "userAdded": false, 161 | "type": "", 162 | "ignore": false, 163 | "defaultInstantiationMode": 1, 164 | "supportsModification": true 165 | }, 166 | "newSceneOverride": 0 167 | } -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - Geometry 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_TestInitMode: 0 13 | CrashReportingSettings: 14 | m_EventUrl: https://perf-events.cloud.unity3d.com 15 | m_Enabled: 0 16 | m_LogBufferSize: 10 17 | m_CaptureEditorExceptions: 1 18 | UnityPurchasingSettings: 19 | m_Enabled: 0 20 | m_TestMode: 0 21 | UnityAnalyticsSettings: 22 | m_Enabled: 0 23 | m_TestMode: 0 24 | m_InitializeOnStartup: 1 25 | UnityAdsSettings: 26 | m_Enabled: 0 27 | m_InitializeOnStartup: 1 28 | m_TestMode: 0 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | -------------------------------------------------------------------------------- /ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | m_CompiledVersion: 0 14 | m_RuntimeVersion: 0 15 | -------------------------------------------------------------------------------- /ProjectSettings/VersionControlSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!890905787 &1 4 | VersionControlSettings: 5 | m_ObjectHideFlags: 0 6 | m_Mode: Visible Meta Files 7 | m_CollabEditorSettings: 8 | inProgressEnabled: 1 9 | -------------------------------------------------------------------------------- /ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /ProjectSettings/boot.config: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scrawk/CGALDotNetUnity/ffc22ee93f6127b643586a4281c5e551312d2114/ProjectSettings/boot.config -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Welcome to CGALDotNet. 2 | 3 | - [Introduction.](https://github.com/Scrawk/CGALDotNet/wiki/Introduction) 4 | 5 | - [The CGAL Numbers types.](https://github.com/Scrawk/CGALDotNet/wiki/The-Number-Types) 6 | 7 | - [Eigen](https://github.com/Scrawk/CGALDotNet/wiki/Eigen) 8 | 9 | - [The CGAL Object.](https://github.com/Scrawk/CGALDotNet/wiki/The-CGALObject) 10 | 11 | - [The CGAL Global Functions.](https://github.com/Scrawk/CGALDotNet/wiki/The-CGALGlobal-Functions) 12 | 13 | - [Unity Extensions](https://github.com/Scrawk/CGALDotNet/wiki/Unity-Extensions) 14 | 15 | # The Geometry Kernel. 16 | 17 | - [The Geometry Numerics.](https://github.com/Scrawk/CGALDotNet/wiki/The-Geometry-Numerics) 18 | 19 | - [The Geometry Shapes.](https://github.com/Scrawk/CGALDotNet/wiki/The-Geometry-Shapes) 20 | 21 | - [The Geometry Objects.](https://github.com/Scrawk/CGALDotNet/wiki/The-Geometry-Objects) 22 | 23 | - [The Geometry Intersections.](https://github.com/Scrawk/CGALDotNet/wiki/The-Geometry-Intersections) 24 | 25 | # The Polygon Kernel. 26 | 27 | - [The Polygon Object.](https://github.com/Scrawk/CGALDotNet/wiki/The-Polygon-Object) 28 | 29 | - [The Polygon With Holes Object.](https://github.com/Scrawk/CGALDotNet/wiki/The-Polygon-With-Holes-Object) 30 | 31 | - [Polygon Boolean.](https://github.com/Scrawk/CGALDotNet/wiki/Polygon-Boolean) 32 | 33 | - [Polygon Minkowski.](https://github.com/Scrawk/CGALDotNet/wiki/Polygon-Minkowski) 34 | 35 | - [Polygon Offset.](https://github.com/Scrawk/CGALDotNet/wiki/Polygon-Offset) 36 | 37 | - [Polygon Simplification.](https://github.com/Scrawk/CGALDotNet/wiki/Polygon-Simplification) 38 | 39 | - [Polygon Visibility.](https://github.com/Scrawk/CGALDotNet/wiki/Polygon-Visibility) 40 | 41 | - [Polygon Partition.](https://github.com/Scrawk/CGALDotNet/wiki/Polygon-Partition) 42 | 43 | # The Triangulation Kernel 44 | 45 | - [Triangulation 2D](https://github.com/Scrawk/CGALDotNet/wiki/Triangulations-2D) 46 | 47 | - [Triangulation 3D](https://github.com/Scrawk/CGALDotNet/wiki/Triangulations-3D) 48 | 49 | # The Arrangements Kernel 50 | 51 | - [Arrangements 2D](https://github.com/Scrawk/CGALDotNet/wiki/Arrangements-2D) 52 | 53 | - [Sweep Line 2D](https://github.com/Scrawk/CGALDotNet/wiki/Sweep-Line-2D) 54 | 55 | # The Polyhedra Kernel 56 | 57 | - [Polyhedra3 Mesh](https://github.com/Scrawk/CGALDotNet/wiki/Polyhedron3-Mesh) 58 | 59 | - [Mesh Processing](https://github.com/Scrawk/CGALDotNet/wiki/Mesh-Processing) 60 | 61 | Some common geomerty objects are referrenced in a [seperate project](https://github.com/Scrawk/CGALDotNetGeometry) so they can come under a different license. 62 | 63 | Work in progress. Only 64 bit windows binarys provided. 64 | 65 | The source code for CGALDotNet can be found in [this](https://github.com/Scrawk/CGALDotNet) repository. 66 | 67 | A page on the Unity forums can be found [here](https://forum.unity.com/threads/cgaldotnet-a-c-computational-library-built-around-cgal.1250314/). 68 | 69 | 70 | --------------------------------------------------------------------------------