Class ScyllaBarrelShape
Parametric barrel: a lathed profile rotated around the Y axis. The profile narrows at top and bottom (chamfered cap edges), carries two belt hoops (one near the top, one near the bottom - the classic wooden-barrel iron-band look), and terminates in flat top and bottom cap discs. Centered on the origin.
Inherited Members
Namespace: Scylla.Core.Util.Geom
Assembly: ScyllaCore.dll
Syntax
[AddComponentMenu("Scylla/Geometry/Barrel")]
public sealed class ScyllaBarrelShape : ScyllaShapeBase3D
Remarks
The profile is parameterized by Radius (the body radius in the
cylindrical regions), Height (total Y extent), ChamferInset
(how much narrower the cap rings are than the body), ChamferHeight (the
vertical run of each chamfer), BeltOutset (how far each belt protrudes
radially beyond the body), BeltHeight (each belt's vertical span; both
belts share this), BeltDistanceFromCap (vertical distance from each cap
to the corresponding belt's center), and Segments (circumferential
subdivisions, clamped to [3, 256]).
Each profile strip is emitted with its own analytically derived flat normal (flat in the strip's profile direction, smooth around the circumference). Strip boundaries get duplicated vertices so the joins between body / chamfer / belt are crisp creases.
For per-face coloring, ColoringMode selects between LidsBeltAndBody (default, 3 resolver indices: body = chamfers + body cylinders, belt = middle hoop, lids = top + bottom caps) and PerSection (9 resolver indices, one per profile section - the original busier preset).
Properties
BeltDistanceFromCap
Vertical distance from each cap to the center of the corresponding belt. The lower
belt center is at -Height/2 + BeltDistanceFromCap; the upper belt center at
+Height/2 - BeltDistanceFromCap. Clamped at build time so both belts remain
inside the available body region. Setting this triggers an immediate mesh rebuild.
Declaration
public float BeltDistanceFromCap { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
BeltHeight
Vertical span of each belt's outer cylindrical wall. Both belts share this value. The complete belt sub-profile (lower flange + outer wall + upper flange) spans this total height. Setting this triggers an immediate mesh rebuild.
Declaration
public float BeltHeight { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
BeltOutset
Radial protrusion of each belt beyond the body radius (beltRadius = Radius +
BeltOutset). Setting this triggers an immediate mesh rebuild.
Declaration
public float BeltOutset { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
ChamferHeight
Vertical run of each chamfer strip. The profile transitions from the cap radius to the body radius across this Y span at each end. Setting this triggers an immediate mesh rebuild.
Declaration
public float ChamferHeight { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
ChamferInset
Radial cut-in of the chamfer: how much narrower the top and bottom cap ring radius is
compared to the body radius (capRadius = Radius - ChamferInset). Clamped to
[0, Radius - epsilon] at build time. Setting this triggers an immediate mesh
rebuild.
Declaration
public float ChamferInset { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
ColoringMode
Selects the per-face color granularity used when an IFaceColorResolver is active. Geometry is identical in all modes; only how many distinct resolver indices the barrel emits changes. See BarrelColoringMode for the exact index layout. Setting this triggers an immediate mesh rebuild.
Declaration
public BarrelColoringMode ColoringMode { get; set; }
Property Value
| Type | Description |
|---|---|
| BarrelColoringMode |
Height
Total height of the barrel along the Y axis. The mesh is centered on the origin so
it extends from -Height/2 to +Height/2. Setting this triggers an
immediate mesh rebuild.
Declaration
public float Height { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Radius
Body radius in the cylindrical sections of the profile (between the chamfers and the
belt flanges). The cap ring radius is derived as Radius - ChamferInset; the belt
radius as Radius + BeltOutset. Setting this triggers an immediate mesh rebuild.
Declaration
public float Radius { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Segments
Circumferential subdivisions around the Y axis. Higher values produce a rounder
silhouette. Clamped to [3, 256] when set and at build time. Setting this triggers an
immediate mesh rebuild.
Declaration
public int Segments { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Build(Mesh, float, float, float, float, float, float, int, float, BarrelColoringMode, IFaceColorResolver)
Populates target with a parametric barrel mesh. Existing mesh data
is overwritten.
Declaration
public static void Build(Mesh target, float radius, float height, float chamferInset, float chamferHeight, float beltOutset, float beltHeight, int segments, float beltDistanceFromCap = 0.18, BarrelColoringMode coloringMode = BarrelColoringMode.LidsBeltAndBody, IFaceColorResolver resolver = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Mesh | target | Destination mesh. Must be non-null. |
| float | radius | Body radius (cylindrical regions). |
| float | height | Total height along Y. |
| float | chamferInset | Radial cut-in of the cap chamfers (cap radius = radius - inset). |
| float | chamferHeight | Vertical run of each chamfer. |
| float | beltOutset | Radial protrusion of the belt beyond the body. |
| float | beltHeight | Vertical span of the belt's outer wall. |
| int | segments | Circumferential subdivisions. Clamped to |
| float | beltDistanceFromCap | Vertical distance from each cap to the corresponding belt's center. The lower belt sits this far above the bottom cap; the upper belt sits this far below the top cap. Clamped to fit between the chamfers and the central body region. |
| BarrelColoringMode | coloringMode | Selects how the resolver indices are assigned. LidsBeltAndBody
(the default) uses three indices total - |
| IFaceColorResolver | resolver | Optional per-face color resolver. When non-null, a per-vertex color channel is emitted with one solid color per logical face. When null, no color channel is written. |
BuildMesh(Mesh)
Subclass extension point: write vertex / triangle / normal / uv data into
target from the shape's serialized parameters. The base class
calls Clear(bool) before invoking this method and
UnityEngine.Mesh.RecalculateBounds() afterwards, so subclasses should not invoke
either themselves.
Declaration
protected override void BuildMesh(Mesh target)
Parameters
| Type | Name | Description |
|---|---|---|
| Mesh | target | The owned mesh to populate. Already cleared by the base class. |
Overrides
GetMeshName()
Returns the shape's mesh name as it should appear on the generated mesh asset. Defaults to the subclass type name; override to provide a friendlier label.
Declaration
protected override string GetMeshName()
Returns
| Type | Description |
|---|---|
| string | A short identifier for the generated mesh, used as UnityEngine.Object.name. |