Game.Rendering.WindPivotHelper
Assembly:
Namespace: Game.Rendering
Type: class
Base: UnityEngine.MonoBehaviour
Summary:
WindPivotHelper is a Unity MonoBehaviour used to store and visualize pivot points used for wind/flex animations (two-level pivot system). It contains editable lists of pivot positions, normals and heights for two levels (level0 and level1), controls for how they are displayed in the Editor (Gizmos), and a bake mode enum. The component draws guides and pivot markers in the Scene view when the GameObject is selected to help modders/artists position and debug wind pivots.
Fields
-
public enum PivotBakeMode { SingleDecompose, HierarchyDecompose }
Defines how pivots were or should be baked. SingleDecompose typically indicates a single-pass decomposition of pivot data; HierarchyDecompose indicates baking that respects a hierarchy (per-node decomposition). Use the value that matches how your pivot data was generated. -
public PivotBakeMode m_BakedMode
Stores the bake mode for the stored pivot data. Useful to know how the pivot lists were produced and may influence any tooling you write that reads/writes these lists. -
public bool m_ShowBasePivot = true
Toggle to show the base pivot (the GameObject transform position) as a red sphere in the Scene view. -
public bool m_ShowLevel0Pivot = true
Toggle to show level-0 pivots (green spheres and their normal lines). -
public bool m_ShowLevel0Guide = true
Toggle to show level-0 guide lines (yellow, drawn from each pivot to the base position). -
public bool m_ShowLevel1Pivot = true
Toggle to show level-1 pivots (blue spheres and their normal lines). -
public bool m_ShowLevel1Guide = true
Toggle to show level-1 guide lines (cyan, drawn from level-1 pivot positions to their corresponding reference points). -
public List<Vector3> m_PivotsP0 = new List<Vector3>()
List of level-0 pivot positions in local space. These are the points where level-0 pivots are placed relative to the GameObject transform. -
public List<Vector3> m_PivotsN0 = new List<Vector3>()
List of level-0 normals (unit directions) in local space. These are used together with the corresponding m_PivotsH0 value to draw the normal/offset vector. -
public List<float> m_PivotsH0 = new List<float>()
List of level-0 heights (scalars). Multiply with m_PivotsN0 to get the world-space offset vector drawn for each pivot. -
public List<Vector3> m_PivotsR1 = new List<Vector3>()
List of reference points (or targets) for level-1 pivots in local space. These are the points that level-1 guide lines are drawn toward. -
public List<Vector3> m_PivotsP1 = new List<Vector3>()
List of level-1 pivot positions in local space. -
public List<Vector3> m_PivotsN1 = new List<Vector3>()
List of level-1 normals (unit directions) in local space. -
public List<float> m_PivotsH1 = new List<float>()
List of level-1 heights (scalars). Multiply with m_PivotsN1 to obtain the offset vectors for level-1 pivot visualization.
Properties
- None (this class exposes fields directly).
Constructors
public WindPivotHelper()
No explicit constructor is defined in the source; the default MonoBehaviour constructor is used. Lists are initialized inline.
Methods
-
public void Clear()
Clears all pivot lists (m_PivotsP0, m_PivotsN0, m_PivotsH0, m_PivotsR1, m_PivotsP1, m_PivotsN1, m_PivotsH1). Use this to reset the stored pivot data before re-baking or repopulating. -
private void OnDrawGizmosSelected()
Editor/Scene-view visualization method. When the GameObject is selected in the Editor (or in Play Mode with selection), draws: - Level-1 guides (if m_ShowLevel1Guide): semi-transparent cyan lines from each level-1 pivot position to the corresponding reference point (m_PivotsR1).
- Level-1 pivot visuals (if m_ShowLevel1Pivot): blue lines showing the normal*height and a small sphere at the pivot position.
- Level-0 guides (if m_ShowLevel0Guide): semi-transparent yellow lines from each level-0 pivot position to the GameObject base position.
- Level-0 pivot visuals (if m_ShowLevel0Pivot): green lines showing normal*height and a small sphere at the pivot position.
- Base pivot (if m_ShowBasePivot): a red sphere rendered at the GameObject transform position. Visualization notes:
- Positions and normals are transformed from local space using transform.localToWorldMatrix.
- Gizmo sphere sizes are scaled by the GameObject's largest lossyScale component (0.01 for level pivots, 0.1 for base pivot).
- This method runs only for selected objects in the Editor Scene view; it is intended for authoring and debugging.
Usage Example
// Attach to a GameObject in the Scene. The component will draw pivot guides when selected.
// Example: clear existing pivots and add a single level-0 pivot.
var helper = gameObject.GetComponent<Game.Rendering.WindPivotHelper>();
if (helper == null) {
helper = gameObject.AddComponent<Game.Rendering.WindPivotHelper>();
}
// Reset any existing pivots
helper.Clear();
// Add a level-0 pivot at local position (0, 1, 0), pointing up with height 0.2f
helper.m_PivotsP0.Add(new Vector3(0f, 1f, 0f));
helper.m_PivotsN0.Add(Vector3.up);
helper.m_PivotsH0.Add(0.2f);
// Enable visuals you want to see in the Scene view
helper.m_ShowBasePivot = true;
helper.m_ShowLevel0Pivot = true;
helper.m_ShowLevel0Guide = true;
Additional notes: - This helper is primarily an editor visualization and data container. If you read or write these lists at runtime, remember that OnDrawGizmosSelected is an Editor-time callback but will still execute in Play Mode when the object is selected. - When scripting tools that bake or export pivot data, respect m_BakedMode so downstream consumers interpret the data consistently.