10using System.Collections.Generic;
17 [LeapGraphicTag(
"Dynamic")]
20 public const string DEFAULT_SHADER =
"LeapMotion/GraphicRenderer/Unlit/Dynamic Transparent";
22 #region PRIVATE VARIABLES
26 private List<Matrix4x4> _curved_worldToAnchor =
new List<Matrix4x4>();
27 private List<Vector4> _curved_graphicParameters =
new List<Vector4>();
46 foreach (var dirtyIndex
in dirtyIndexes) {
65 return SupportInfo.
Error(
"Dynamic Renderer does not support " + space.GetType().Name);
71 base.OnUpdateRenderer();
76 if (graphic.isRepresentationDirty ||
_meshes[i] ==
null) {
88 graphic.isRepresentationDirty =
false;
106 using (
new ProfilerSample(
"Build Material Data And Draw Meshes")) {
107 _curved_worldToAnchor.Clear();
108 _curved_graphicParameters.Clear();
111 if (!graphic.isActiveAndEnabled) {
112 _curved_graphicParameters.Add(Vector4.zero);
113 _curved_worldToAnchor.Add(Matrix4x4.identity);
117 var transformer = graphic.anchor.transformer;
119 Vector3 localPos =
renderer.transform.InverseTransformPoint(graphic.transform.position);
121 Matrix4x4 mainTransform =
renderer.transform.localToWorldMatrix * transformer.GetTransformationMatrix(localPos);
122 Matrix4x4 deform =
renderer.transform.worldToLocalMatrix * Matrix4x4.TRS(
renderer.transform.position - graphic.transform.position, Quaternion.identity, Vector3.one) * graphic.transform.localToWorldMatrix;
123 Matrix4x4 total = mainTransform * deform;
125 _curved_graphicParameters.Add((transformer as
IRadialTransformer).GetVectorRepresentation(graphic.transform));
126 _curved_worldToAnchor.Add(mainTransform.inverse);
135 _material.SetFloat(SpaceProperties.RADIAL_SPACE_RADIUS, curvedSpace.radius);
136 _material.SetMatrixArraySafe(
"_GraphicRendererCurved_WorldToAnchor", _curved_worldToAnchor);
137 _material.SetMatrix(
"_GraphicRenderer_LocalToWorld",
renderer.transform.localToWorldMatrix);
138 _material.SetVectorArraySafe(
"_GraphicRendererCurved_GraphicParameters", _curved_graphicParameters);
145 public override void OnEnableRendererEditor() {
146 base.OnEnableRendererEditor();
157 base.prepareMaterial();
161 _material.EnableKeyword(SpaceProperties.CYLINDRICAL_FEATURE);
163 _material.EnableKeyword(SpaceProperties.SPHERICAL_FEATURE);
189 out Vector3 meshVert,
190 out Vector3 meshNormal) {
196 return shapeVert - originalVert;
override Vector3 blendShapeDelta(Vector3 shapeVert, Vector3 originalVert)
override void graphicVertNormalToMeshVertNormal(Vector3 vertex, Vector3 normal, out Vector3 meshVert, out Vector3 meshNormal)
override void OnUpdateRenderer()
Called from LateUpdate during runtime. Use this to update the renderer using any changes made to duri...
override void buildGraphic()
override void prepareMaterial()
override SupportInfo GetSpaceSupportInfo(LeapSpace space)
override Vector3 graphicVertToMeshVert(Vector3 vertex)
override bool doesRequireVertInfo()
const string DEFAULT_SHADER
void OnAddRemoveGraphics(List< int > dirtyIndexes)
Must be implemented by a renderer to report that it is able to support adding and removing graphics a...
List< LeapGraphic > graphics
Returns the list of graphics attached to this group. This getter returns a regular mutable list for s...
const string PROPERTY_PREFIX
LeapSpace space
Returns the leap space that is currently attached to this graphic renderer.
This class is a base class for all graphics that can be represented by a mesh object.
virtual void finishMesh(bool deleteEmptyMeshes=true)
virtual void finishAndAddMesh(bool deleteEmptyMeshes=true)
void drawMesh(Mesh mesh, Matrix4x4 transform)
GenerationState _generation
virtual void beginMesh(Mesh mesh=null)
LeapGraphicGroup group
Gets the group this rendering method is attached to.
LeapGraphicRenderer renderer
Gets the renderer this rendering method is attached to.
void RemoveMesh(int index)
LeapMeshGraphicBase graphic
The support info class provides a very basic way to notify that something is fully supported,...
static SupportInfo Error(string message)
Helper getter to return a struct that signifies no support with an error message.
static SupportInfo FullSupport()
Helper getter to return a struct that signifies full support.
A utility struct for ease of use when you want to wrap a piece of code in a Profiler....