From 4d9da8a41d7815080bea36ca27c8c28d203cc290 Mon Sep 17 00:00:00 2001 From: Matheus Amazonas Date: Mon, 3 Jun 2024 17:15:28 +0200 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=93=9D=20Add=20usage=20section=20to?= =?UTF-8?q?=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f9da3c..3811672 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Sphere Generator is a free Unity tool for generating sphere meshes procedurally. - [Import with OpenUPM](#import-with-openupm) - [After importing](#after-importing) - [Usage](#usage) + - [Example][#example] - [Samples](#samples) - [Compatibility and dependencies](#compatibility-and-dependencies) - [Contributing](#contributing) @@ -48,7 +49,32 @@ Once the importing process is complete, Sphere Generator is ready to be used in After importing , check the [Usage](#usage) section on how to use it and the [Samples](#samples) section on how to import and use the package samples. ## Usage -// TODO +Using Sphere Generator is straightforward. First, create a `SphereGenerator` (base class) instance by calling one of the supported sphere type constructors: +```csharp +public CubeSphereGenerator(float radius, ushort depth) +public IcosphereGenerator(float radius, ushort depth) +public UVSphereGenerator(float radius, ushort depth) +``` +Where `radius` is the sphere radius and `depth` is the fragmentation depth (a.k.a. level of detail) of the to-be generated spheres. Check the documentation for valid parameter value ranges. + +Once an instance of the `SphereGenerator` class is created, its `Generate` method can be called to generate a sphere mesh: +```csharp +public Mesh Generate() +``` +The method returns a `Mesh` instance that represents the generated sphere. It is up to the user to control the lifetime of the `Mesh` instance. + +### Example +Let's say we would like to create an icosphere with radius of 20 units, a fragmentation depth of 3, and use the generated mesh on a mesh filter that is used by a mesh renderer to display the sphere in the scene. The code below implements that inside an `Awake` method: +```csharp +[SerializeField] private MeshFilter _meshFilter; + +private void Awake() +{ + SphereGenerator generator = new IcosphereGenerator(20, 3); + Mesh mesh = generator.Generate(); + _meshFilter.mesh = mesh; +} +``` ## Samples The package contains one sample named "Display". It displays the generational capabilities of the tool, displaying all supported sphere types with different depths. This sample is better displayed in the Scene view, with "Shading Mode" set to "Shared wireframe", so the vertices and triangles are visible. This sample was also used to generate the image at the top of this page. From b97f008ffa8aadba93da9b1a9488dc87e4e53352 Mon Sep 17 00:00:00 2001 From: Matheus Amazonas Date: Mon, 3 Jun 2024 17:18:22 +0200 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=93=9D=20Fix=20anchor=20link=20to=20E?= =?UTF-8?q?xamples=20section=20in=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3811672..ca4aaa7 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Sphere Generator is a free Unity tool for generating sphere meshes procedurally. - [Import with OpenUPM](#import-with-openupm) - [After importing](#after-importing) - [Usage](#usage) - - [Example][#example] + - [Example](#example) - [Samples](#samples) - [Compatibility and dependencies](#compatibility-and-dependencies) - [Contributing](#contributing) From a1cc4b220b955e5835a9a8ece485fc859bd2320d Mon Sep 17 00:00:00 2001 From: Matheus Amazonas Date: Mon, 3 Jun 2024 17:18:48 +0200 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=93=9D=20Add=20reference=20to=20"regu?= =?UTF-8?q?lar=20icosahedron"=20when=20introducing=20icosphere=20in=20READ?= =?UTF-8?q?ME?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ca4aaa7..82988ae 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Sphere Generator is a free Unity tool for generating sphere meshes procedurally. ## Features - Support for different basic shapes: - - Icosphere. + - Icosphere (based on a regular icosahedron). - Cube sphere. - UV sphere. - Customizable radius and level of detail (a.k.a. fragmentation depth). From 4d398c019c32ea5608476d329331d908a40ea60c Mon Sep 17 00:00:00 2001 From: Matheus Amazonas Date: Mon, 3 Jun 2024 17:19:20 +0200 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=93=9D=20Fix=20C#=20code=20snippet=20?= =?UTF-8?q?highlighting=20in=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GitHub didn't parse that well. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 82988ae..ad315e4 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,9 @@ After importing , check the [Usage](#usage) section on how to use it and the [Sa ## Usage Using Sphere Generator is straightforward. First, create a `SphereGenerator` (base class) instance by calling one of the supported sphere type constructors: ```csharp -public CubeSphereGenerator(float radius, ushort depth) -public IcosphereGenerator(float radius, ushort depth) -public UVSphereGenerator(float radius, ushort depth) +public CubeSphereGenerator(float radius, ushort depth); +public IcosphereGenerator(float radius, ushort depth); +public UVSphereGenerator(float radius, ushort depth); ``` Where `radius` is the sphere radius and `depth` is the fragmentation depth (a.k.a. level of detail) of the to-be generated spheres. Check the documentation for valid parameter value ranges. From e99009caf102ae8fba897f5d7ba46ded5f1a0d40 Mon Sep 17 00:00:00 2001 From: Matheus Amazonas Date: Mon, 3 Jun 2024 17:23:42 +0200 Subject: [PATCH 5/5] =?UTF-8?q?=F0=9F=94=96=20Bump=20package=20version=20t?= =?UTF-8?q?o=201.0.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Libraries/SphereGenerator/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Libraries/SphereGenerator/package.json b/Assets/Libraries/SphereGenerator/package.json index 880ea12..09078de 100644 --- a/Assets/Libraries/SphereGenerator/package.json +++ b/Assets/Libraries/SphereGenerator/package.json @@ -1,6 +1,6 @@ { "name": "com.lazysquirrellabs.spheregenerator", - "version": "1.0.1", + "version": "1.0.2", "displayName": "Sphere Generator", "description": "Generate sphere meshes procedurally.", "unity": "2022.3",