Skip to content

Commit

Permalink
🔀 Merge develop into main
Browse files Browse the repository at this point in the history
Changes:
- Update README with new Usages section.
  • Loading branch information
matheusamazonas committed Jun 3, 2024
2 parents c263713 + e99009c commit 361e4e6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Assets/Libraries/SphereGenerator/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -18,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).
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 361e4e6

Please sign in to comment.