Class OrganicShapeGenerator
- Namespace
- S1MAPI.ProceduralMesh.Generators.Organic
- Assembly
- S1MAPI_Mono.dll
Abstract base class for creating organic shape generators (animals, plants, etc.). Provides helper methods for common organic mesh patterns like rings and joints.
public abstract class OrganicShapeGenerator
- Inheritance
-
OrganicShapeGenerator
- Inherited Members
Remarks
S1MAPI focuses on building/map construction. This class provides an extension point for mods that need organic shapes. Inherit from this class to create custom generators.
Example usage:
public class PetMeshGenerator : OrganicShapeGenerator
{
protected override void GenerateGeometry(List<Vector3> vertices, List<int> triangles)
{
// Use helper methods like AddRing, AddJointRing, ConnectRings
AddRing(vertices, position: Vector3.zero, radius: 1f, segments: 12);
}
}
Constructors
OrganicShapeGenerator(string)
Create a new organic shape generator.
protected OrganicShapeGenerator(string name)
Parameters
namestringName for the generated mesh
Methods
AddAsymmetricRing(List<Vector3>, Vector3, float, float, float, int, float)
Add a ring with asymmetric scaling (different top/bottom radii). Useful for organic body shapes.
protected void AddAsymmetricRing(List<Vector3> vertices, Vector3 position, float widthRadius, float heightRadiusTop, float heightRadiusBottom, int segments, float asymmetry = 0)
Parameters
verticesList<Vector3>List to add vertices to
positionVector3Center position of the ring
widthRadiusfloatWidth radius (X-axis)
heightRadiusTopfloatHeight radius for upper half (Y-axis)
heightRadiusBottomfloatHeight radius for lower half (Y-axis)
segmentsintNumber of segments
asymmetryfloatAsymmetry factor (0 = symmetric)
AddRing(List<Vector3>, Vector3, float, int, Vector2)
Add a ring of vertices (circular cross-section). Useful for creating cylindrical body segments.
protected void AddRing(List<Vector3> vertices, Vector3 position, float radius, int segments, Vector2 ellipticalScale = default)
Parameters
verticesList<Vector3>List to add vertices to
positionVector3Center position of the ring
radiusfloatRadius of the ring
segmentsintNumber of segments around the ring
ellipticalScaleVector2Optional elliptical scaling (x, z)
CapRing(List<Vector3>, List<int>, int, int, Vector3, bool)
Cap a ring with triangles (close one end).
protected void CapRing(List<Vector3> vertices, List<int> triangles, int ringStartIndex, int segments, Vector3 centerPosition, bool flipNormals = false)
Parameters
verticesList<Vector3>List to add center vertex to
trianglesList<int>List to add triangles to
ringStartIndexintVertex index where the ring starts
segmentsintNumber of segments in the ring
centerPositionVector3Position of the cap center
flipNormalsboolFlip triangle winding for opposite direction
ConnectRings(List<int>, int, int, int)
Connect two existing rings with triangles.
protected void ConnectRings(List<int> triangles, int startRingIndex, int endRingIndex, int segments)
Parameters
trianglesList<int>List to add triangles to
startRingIndexintVertex index of the first ring's start
endRingIndexintVertex index of the second ring's start
segmentsintNumber of segments in each ring
Generate()
Generate and return a complete mesh.
public Mesh Generate()
Returns
- Mesh
The generated mesh
GenerateGeometry(List<Vector3>, List<int>, List<Vector2>)
Override this method to implement your organic shape generation logic. Use the helper methods provided by this base class.
protected abstract void GenerateGeometry(List<Vector3> vertices, List<int> triangles, List<Vector2> uvs)
Parameters
verticesList<Vector3>List to add vertices to
trianglesList<int>List to add triangle indices to
uvsList<Vector2>List to add UV coordinates to (optional)
GenerateInto(List<Vector3>, List<int>, List<Vector2>, Vector3)
Generate geometry directly into the provided lists. Useful for integrating with ProceduralMeshBuilder.
public void GenerateInto(List<Vector3> vertices, List<int> triangles, List<Vector2> uvs, Vector3 offset = default)