Overview

Extended Primitives are script components that generate Mesh procedurally. All primitives are derived from the ExtendedPrimitives_11.ExtendedPrimitive class and have common parameters: UV0, UV1, Collider, Constraints, Statistic, Tangents Mode. The Size and Topology parameters are unique for each primitive. Primitives are updated in MonoBehaviour.Update () or MonoBehaviour.LateUpdate () callbacks, depending of the UpdateMode param. If this enum is set to None, then the primitive will be updated only if calling the ExtendedPrimitive.Apply () method. Use this option when you manage a Primitive from another script.


Create primitives

  • To create primitive use menu:

  • Or add component to GameObject:

  • Or using static constructor: FilletBox box = FilletBox.Create();


Change size

  • in Size foldout you can change primitive dimensions. Maximal (right) slider value defines by Max Slider Value propery. This is an editor-only property for convenience manipulating sliders.

  • All Size fields is animatable
  • use public properties in ExtendedPrimitive.Size struct to set size with code
Note that some Size properties is clamped internally but values displayed unclamped.

Change topology

Topology foldout describes Primitive`s detalization and partial surface hidding. Changing the topology leads to memory allocation, so avoid frequently change the topology in Play Mode.


Texture (UV) coordinates

There are two UV channels that can be used, and 3 different types of UV generation.

  • Planar mapping projects UVs onto a Primitive through a plane. You can set any Transform as planar source. If planar Transforms is not defined used local object coordinates. PlanarMappingGizmo script is helpful to debug planar Transform position, scale and rotation.
  • Unfold A and Unfold A Methods of procedural mapping with minimal texture distortion. They differ where the seams are located.

Update Mode defines when UV will be recalculated

  • None disable UV
  • Live Update UVs recalculates when Size, Topology UV properties is changed.
  • Fixed When on, UVs will be recalculated once when object enabled. Will be used most recent Size and UV parameters wich cached before Fixed are enabled .

UV inspector

UV inspector is an Editor window for preview uv coordinates. Press Open UV Inspector button to inspect selected Primitive.

  • Inspected - inspected Extended Primitive
  • Channel - inspected UV channel
  • Export - export UV layout to .png image with selected dimensions.
  • Alt + Right mouse button | mouse wheel - zoom view.
  • Middle mouse button - pan view
  • Left mouse button double click - Frame view to UVs bounds

Tangents mode

Tangents are mostly used in bump-mapped Shaders. Tangents mode specifies how tangents will be recalculated. Recalculation is require UV coordinates at suitable channel.

  • None - disables recalculation.
  • Builtin for UV0 - uses builin UnityEngine.Mesh.RecalculateTangents()
  • For UV0 - custom recalculation method based on UV0
  • For UV1 - custom recalculation method based on UV2
  • Blended UV0UV2 - If the Primitive uses two texture channels, this method allow to recalculate the blended tangents. Blending is based on the mesh`s vertex color alpha. Package include EP_LitVertexColorBlend.shader shader wich uses this feature. Please see example scene:
    ExtendedPrimitives 1.1/(can be deleted) Examples/UVCoordinatesDemo/UVCoordinatesDemo.scene

Mesh Collider and Raycast

Extended Primitive has its own scripted collider that allows you to perform Raycast on object without the using UnityEngine.Physics class or MeshCollider component. There is one parameter - Detalization based on visual detailization wich defined by Topology. Commonly, a One Half Detalization are enough to make an object picking using Raycast. Create Mesh Collider button creates MeshCollider component with assigned mesh snapshot of current state of scripted collider.

Methods:

public bool Raycast(Ray r, ref Vector hit, ref float hitDistance);

public bool Raycast(Ray r);


Statistic rollout

Statistic foldout show information about Mesh , Scripted collider, current update time, visualize Mesh normals and tangents (if present)


Charts

Charts is an compound objects. Chart`s elements GameObjects is hidden by default. To display elements GameObjects set toggle Display Primitives in Hierarchy You can set child primitives parameters separately using their inspector or using chart`s override properties.

To set element values use inspector or via code :

Chart.Elements[int elementIndex].Value = float

Raycast to Chart

public bool Raycast(Ray r, ref Vector hit, ref float hitDistance, ref int elementIdx);

Charts can manage material`s propertyes of their elements. To display outline use outlined shader. Package include two outlined shader Custom/ExtendedPrimitives/OutlineLit and Custom/ExtendedPrimitives/OutlineUnlit

ExtendedPrimitivesDocumentation_CreateGraphGif.gif

Grids

Grids is an wire objects based on LineRender and TextMesh renderer. To display Grid`s labels enable it in inspector, set up string format rules and text parameters then press Apply Text button.


How to create Graph?


How to create Pie Chart?