public override void OnInspectorGUI() { MegaLoftLayerComplex layer = (MegaLoftLayerComplex)target; MegaShapeLoft loft = layer.GetComponent <MegaShapeLoft>(); if (loft && loft.undo) { undoManager.CheckUndo(); } DisplayGUI(); CommonGUI(); if (GUI.changed) { if (loft) { loft.rebuild = true; EditorUtility.SetDirty(loft); } if (layer) { EditorUtility.SetDirty(layer); } } if (loft && loft.undo) { undoManager.CheckDirty(); } }
public override void CopyLayer(MegaLoftLayerBase from) { MegaLoftLayerComplex cfrom = (MegaLoftLayerComplex)from; layerPath = from.layerPath; layerSection = from.layerSection; if (layerPath) { pathName = layerPath.gameObject.name; } if (layerSection) { sectionName = layerSection.gameObject.name; } for (int i = 0; i < sections.Count; i++) { sections[i].shape = cfrom.sections[i].shape; if (sections[i].shape) { sections[i].shapeName = sections[i].shape.gameObject.name; } } }
static void RenderGizmo(MegaLoftLayerComplex layer, GizmoType gizmoType) { if ((gizmoType & GizmoType.Active) != 0) { if (layer.showsections) { DrawPath(layer); } } }
public override MegaLoftLayerBase Copy(GameObject go) { MegaLoftLayerComplex layer = go.AddComponent <MegaLoftLayerComplex>(); Copy(this, layer); loftverts = null; loftverts1 = null; loftuvs = null; loftcols = null; capStartVerts = null; capStartUVS = null; capStartCols = null; capEndVerts = null; capEndUVS = null; capEndCols = null; capStartTris = null; capEndTris = null; lofttris = null; return(null); }
void OnGUI() { if (Selection.activeGameObject == null) { return; } MegaShapeLoft loft = Selection.activeGameObject.GetComponent <MegaShapeLoft>(); if (loft == null) { return; } lofttype = (MegaLoftType)EditorGUILayout.EnumPopup("Type", lofttype); LayerName = EditorGUILayout.TextField("Name", LayerName); start = EditorGUILayout.FloatField("Start", start); length = EditorGUILayout.FloatField("Length", length); paramCol = EditorGUILayout.ColorField("Param Col", paramCol); EditorStyles.textField.wordWrap = true; switch (lofttype) { case MegaLoftType.Simple: EditorGUILayout.TextArea("Basic Loft layer that uses a single spline for the path and another spline for the cross section", GUILayout.Height(50.0f)); path = (MegaShape)EditorGUILayout.ObjectField("Path", path, typeof(MegaShape), true); section = (MegaShape)EditorGUILayout.ObjectField("Section", section, typeof(MegaShape), true); material = (Material)EditorGUILayout.ObjectField("Material", material, typeof(Material), true); break; //case MegaLoftType.Collider: // colliderwidth = EditorGUILayout.FloatField("Collider Width", colliderwidth); // break; case MegaLoftType.CloneSimple: EditorGUILayout.TextArea("Clone a mesh onto a surface with options for start, end and main meshes", GUILayout.Height(50.0f)); startObjMesh = (Mesh)EditorGUILayout.ObjectField("Start Obj", startObjMesh, typeof(Mesh), true); mainObjMesh = (Mesh)EditorGUILayout.ObjectField("Main Obj", mainObjMesh, typeof(Mesh), true); endObjMesh = (Mesh)EditorGUILayout.ObjectField("End Obj", endObjMesh, typeof(Mesh), true); surfaceLoft = (MegaShapeLoft)EditorGUILayout.ObjectField("Surface", surfaceLoft, typeof(MegaShapeLoft), true); surfaceLayer = EditorGUILayout.Popup("Layer", surfaceLayer + 1, MegaShapeUtils.GetLayers(surfaceLoft)) - 1; material = (Material)EditorGUILayout.ObjectField("Material", material, typeof(Material), true); break; case MegaLoftType.ScatterSimple: EditorGUILayout.TextArea("Scatters a choosen mesh and material over a surface", GUILayout.Height(50.0f)); mainObjMesh = (Mesh)EditorGUILayout.ObjectField("Obj", mainObjMesh, typeof(Mesh), true); surfaceLoft = (MegaShapeLoft)EditorGUILayout.ObjectField("Surface", surfaceLoft, typeof(MegaShapeLoft), true); surfaceLayer = EditorGUILayout.Popup("Layer", surfaceLayer + 1, MegaShapeUtils.GetLayers(surfaceLoft)) - 1; material = (Material)EditorGUILayout.ObjectField("Material", material, typeof(Material), true); break; case MegaLoftType.Scatter: EditorGUILayout.TextArea("Builds a mesh layer by scattering a choosen object over a surface", GUILayout.Height(50.0f)); mainObj = (GameObject)EditorGUILayout.ObjectField("Obj", mainObj, typeof(Mesh), true); mainObj = MegaMeshCheck.ValidateObj(mainObj); surfaceLoft = (MegaShapeLoft)EditorGUILayout.ObjectField("Surface", surfaceLoft, typeof(MegaShapeLoft), true); surfaceLayer = EditorGUILayout.Popup("Layer", surfaceLayer + 1, MegaShapeUtils.GetLayers(surfaceLoft)) - 1; break; case MegaLoftType.ScatterSpline: EditorGUILayout.TextArea("Build a mesh by scattering a choosen mesh and material along a spline", GUILayout.Height(50.0f)); path = (MegaShape)EditorGUILayout.ObjectField("Path", path, typeof(MegaShape), true); mainObjMesh = (Mesh)EditorGUILayout.ObjectField("Obj", mainObjMesh, typeof(Mesh), true); material = (Material)EditorGUILayout.ObjectField("Material", material, typeof(Material), true); break; case MegaLoftType.Complex: EditorGUILayout.TextArea("Advanced lofter that uses a spline for the path and any number of cross section splines to define the loft", GUILayout.Height(50.0f)); path = (MegaShape)EditorGUILayout.ObjectField("Path", path, typeof(MegaShape), true); section = (MegaShape)EditorGUILayout.ObjectField("Section", section, typeof(MegaShape), true); material = (Material)EditorGUILayout.ObjectField("Material", material, typeof(Material), true); break; case MegaLoftType.CloneSplineSimple: EditorGUILayout.TextArea("Clone a mesh along a spline with options for start, end and main meshes", GUILayout.Height(50.0f)); path = (MegaShape)EditorGUILayout.ObjectField("Path", path, typeof(MegaShape), true); startObjMesh = (Mesh)EditorGUILayout.ObjectField("Start Obj", startObjMesh, typeof(Mesh), true); //startObj = MegaMeshCheck.ValidateObj(startObj); mainObjMesh = (Mesh)EditorGUILayout.ObjectField("Main Obj", mainObjMesh, typeof(Mesh), true); //mainObj = MegaMeshCheck.ValidateObj(mainObj); endObjMesh = (Mesh)EditorGUILayout.ObjectField("End Obj", endObjMesh, typeof(Mesh), true); //endObj = MegaMeshCheck.ValidateObj(endObj); material = (Material)EditorGUILayout.ObjectField("Material", material, typeof(Material), true); break; case MegaLoftType.Clone: EditorGUILayout.TextArea("Clone a mesh onto a surface with options for start, end and main meshes", GUILayout.Height(50.0f)); startObj = (GameObject)EditorGUILayout.ObjectField("Start Obj", startObj, typeof(GameObject), true); startObj = MegaMeshCheck.ValidateObj(startObj); mainObj = (GameObject)EditorGUILayout.ObjectField("Main Obj", mainObj, typeof(GameObject), true); mainObj = MegaMeshCheck.ValidateObj(mainObj); endObj = (GameObject)EditorGUILayout.ObjectField("End Obj", endObj, typeof(GameObject), true); endObj = MegaMeshCheck.ValidateObj(endObj); surfaceLoft = (MegaShapeLoft)EditorGUILayout.ObjectField("Surface", surfaceLoft, typeof(MegaShapeLoft), true); surfaceLayer = EditorGUILayout.Popup("Layer", surfaceLayer + 1, MegaShapeUtils.GetLayers(surfaceLoft)) - 1; material = (Material)EditorGUILayout.ObjectField("Material", material, typeof(Material), true); break; case MegaLoftType.CloneSpline: EditorGUILayout.TextArea("Build a mesh layer by cloning objects along a spline with options for start, end and main objects", GUILayout.Height(50.0f)); path = (MegaShape)EditorGUILayout.ObjectField("Path", path, typeof(MegaShape), true); startObj = (GameObject)EditorGUILayout.ObjectField("Start Obj", startObj, typeof(GameObject), true); startObj = MegaMeshCheck.ValidateObj(startObj); mainObj = (GameObject)EditorGUILayout.ObjectField("Main Obj", mainObj, typeof(GameObject), true); mainObj = MegaMeshCheck.ValidateObj(mainObj); endObj = (GameObject)EditorGUILayout.ObjectField("End Obj", endObj, typeof(GameObject), true); endObj = MegaMeshCheck.ValidateObj(endObj); break; case MegaLoftType.CloneRules: EditorGUILayout.TextArea("Rule based clone onto a surface", GUILayout.Height(50.0f)); //path = (MegaShape)EditorGUILayout.ObjectField("Path", path, typeof(MegaShape), true); surfaceLoft = (MegaShapeLoft)EditorGUILayout.ObjectField("Surface", surfaceLoft, typeof(MegaShapeLoft), true); surfaceLayer = EditorGUILayout.Popup("Layer", surfaceLayer + 1, MegaShapeUtils.GetLayers(surfaceLoft)) - 1; break; case MegaLoftType.CloneSplineRules: EditorGUILayout.TextArea("Rule based clone along a spline", GUILayout.Height(50.0f)); path = (MegaShape)EditorGUILayout.ObjectField("Path", path, typeof(MegaShape), true); surfaceLoft = (MegaShapeLoft)EditorGUILayout.ObjectField("Surface", surfaceLoft, typeof(MegaShapeLoft), true); surfaceLayer = EditorGUILayout.Popup("Layer", surfaceLayer + 1, MegaShapeUtils.GetLayers(surfaceLoft)) - 1; break; #if true case MegaLoftType.MultiMaterial: EditorGUILayout.TextArea("Will create a loft using multiple materials based on material ids in the spline knots. It uses a single spline for the path and another spline for the cross section", GUILayout.Height(50.0f)); path = (MegaShape)EditorGUILayout.ObjectField("Path", path, typeof(MegaShape), true); section = (MegaShape)EditorGUILayout.ObjectField("Section", section, typeof(MegaShape), true); material = (Material)EditorGUILayout.ObjectField("Material", material, typeof(Material), true); break; case MegaLoftType.MultiMaterialComplex: EditorGUILayout.TextArea("Will create a complex loft using multiple materials based on material ids in the spline knots. It uses a single spline for the path and another spline for the cross section", GUILayout.Height(50.0f)); path = (MegaShape)EditorGUILayout.ObjectField("Path", path, typeof(MegaShape), true); section = (MegaShape)EditorGUILayout.ObjectField("Section", section, typeof(MegaShape), true); material = (Material)EditorGUILayout.ObjectField("Material", material, typeof(Material), true); break; #endif } EditorStyles.textField.wordWrap = false; EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Create")) { MegaLoftLayerBase laybase = null; switch (lofttype) { case MegaLoftType.Simple: { MegaLoftLayerSimple layer = Selection.activeGameObject.AddComponent <MegaLoftLayerSimple>(); layer.pathStart = start; layer.pathLength = length; layer.layerPath = path; layer.layerSection = section; laybase = layer; } break; case MegaLoftType.CloneSimple: { MegaLoftLayerCloneSimple layer = Selection.activeGameObject.AddComponent <MegaLoftLayerCloneSimple>(); layer.startObj = startObjMesh; layer.mainObj = mainObjMesh; layer.endObj = endObjMesh; layer.surfaceLoft = surfaceLoft; layer.surfaceLayer = surfaceLayer; laybase = layer; } break; case MegaLoftType.ScatterSimple: { MegaLoftLayerScatterSimple layer = Selection.activeGameObject.AddComponent <MegaLoftLayerScatterSimple>(); layer.scatterMesh = mainObjMesh; layer.surfaceLoft = surfaceLoft; layer.surfaceLayer = surfaceLayer; laybase = layer; } break; case MegaLoftType.Scatter: { MegaLoftLayerScatter layer = Selection.activeGameObject.AddComponent <MegaLoftLayerScatter>(); layer.mainObj = mainObj; layer.surfaceLoft = surfaceLoft; layer.surfaceLayer = surfaceLayer; laybase = layer; } break; case MegaLoftType.ScatterSpline: { MegaLoftLayerScatterSpline layer = Selection.activeGameObject.AddComponent <MegaLoftLayerScatterSpline>(); layer.scatterMesh = mainObjMesh; layer.layerPath = path; laybase = layer; } break; case MegaLoftType.Complex: { MegaLoftLayerComplex layer = Selection.activeGameObject.AddComponent <MegaLoftLayerComplex>(); layer.layerPath = path; layer.layerSection = section; laybase = layer; } break; case MegaLoftType.CloneSplineSimple: { MegaLoftLayerCloneSplineSimple layer = Selection.activeGameObject.AddComponent <MegaLoftLayerCloneSplineSimple>(); layer.layerPath = path; layer.startObj = startObjMesh; layer.mainObj = mainObjMesh; layer.endObj = endObjMesh; laybase = layer; } break; case MegaLoftType.CloneSpline: { MegaLoftLayerCloneSpline layer = Selection.activeGameObject.AddComponent <MegaLoftLayerCloneSpline>(); layer.layerPath = path; layer.startObj = startObj; layer.mainObj = mainObj; layer.endObj = endObj; laybase = layer; } break; case MegaLoftType.Clone: { MegaLoftLayerClone layer = Selection.activeGameObject.AddComponent <MegaLoftLayerClone>(); layer.surfaceLoft = surfaceLoft; layer.surfaceLayer = surfaceLayer; layer.startObj = startObj; layer.mainObj = mainObj; layer.endObj = endObj; laybase = layer; } break; case MegaLoftType.CloneRules: { MegaLoftLayerCloneRules layer = Selection.activeGameObject.AddComponent <MegaLoftLayerCloneRules>(); layer.surfaceLoft = surfaceLoft; layer.surfaceLayer = surfaceLayer; //layer.layerPath = path; //layer.layerSection = section; laybase = layer; } break; case MegaLoftType.CloneSplineRules: { MegaLoftLayerCloneSplineRules layer = Selection.activeGameObject.AddComponent <MegaLoftLayerCloneSplineRules>(); layer.layerPath = path; laybase = layer; } break; #if true case MegaLoftType.MultiMaterial: { MegaLoftLayerMultiMat layer = Selection.activeGameObject.AddComponent <MegaLoftLayerMultiMat>(); layer.pathStart = start; layer.pathLength = length; layer.layerPath = path; layer.layerSection = section; MegaMaterialSection ms = new MegaMaterialSection(); ms.mat = material; layer.sections.Add(ms); laybase = layer; } break; // We should add two loft sections // if cross has multiple splines add them all equally spaced? case MegaLoftType.MultiMaterialComplex: { MegaLoftLayerMultiMatComplex layer = Selection.activeGameObject.AddComponent <MegaLoftLayerMultiMatComplex>(); layer.pathStart = start; layer.pathLength = length; layer.layerPath = path; layer.layerSection = section; MegaMaterialSection ms = new MegaMaterialSection(); ms.mat = material; layer.sections.Add(ms); laybase = layer; } break; #endif default: EditorUtility.DisplayDialog("Layer Not Supported", "Currently this layer type is not not supported", "OK"); break; } // Common params if (laybase) { laybase.paramcol = paramCol; laybase.LayerName = LayerName; laybase.LayerName = LayerName; laybase.material = material; } this.Close(); } if (GUILayout.Button("Cancel")) { this.Close(); } EditorGUILayout.EndHorizontal(); }
static void RenderGizmo(MegaLoftLayerComplex layer, GizmoType gizmoType) { //if ( (gizmoType & GizmoType.NotSelected) != 0 ) { if ( (gizmoType & GizmoType.Active) != 0 ) { if ( layer.showsections ) DrawPath(layer); } } }
private void OnEnable() { src = target as MegaLoftLayerComplex; undoManager = new MegaUndo(src, "Loft Param"); }
static void DrawPath(MegaLoftLayerComplex layer) { MegaShapeLoft loft = layer.gameObject.GetComponent<MegaShapeLoft>(); if ( loft == null ) return; if ( layer.layerPath == null ) return; if ( layer.sections == null || layer.sections.Count < 2 ) return; for ( int i = 0; i < layer.sections.Count; i++ ) { if ( layer.sections[i].crossverts == null || layer.sections[i].crossverts.Length == 0 ) return; } MegaSpline pathspline = layer.layerPath.splines[layer.curve]; Matrix4x4 pathtm = Matrix4x4.identity; if ( layer.SnapToPath ) pathtm = layer.layerPath.transform.localToWorldMatrix; Color col = Gizmos.color; Matrix4x4 twisttm = Matrix4x4.identity; Matrix4x4 tm; Vector3 lastup = locup; for ( int i = 0; i < layer.sections.Count; i++ ) { MegaLoftSection section = layer.sections[i]; //if ( layer.useTwistCrv ) //{ // float twist = layer.twistCrv.Evaluate(section.alpha); // MegaShapeUtils.RotateZ(ref twisttm, Mathf.Deg2Rad * twist); // tm = pathtm * layer.GetDeformMat(pathspline, section.alpha, layer.layerPath.normalizedInterp) * twisttm; //loft.); //} //else // tm = pathtm * layer.GetDeformMat(pathspline, section.alpha, layer.layerPath.normalizedInterp); //loft.); if ( layer.useTwistCrv ) { float twist = layer.twistCrv.Evaluate(section.alpha); float tw1 = pathspline.GetTwist(section.alpha); MegaShapeUtils.RotateZ(ref twisttm, Mathf.Deg2Rad * (twist - tw1)); if ( layer.frameMethod == MegaFrameMethod.Old ) tm = pathtm * layer.GetDeformMat(pathspline, section.alpha, layer.layerPath.normalizedInterp) * twisttm; else tm = pathtm * layer.GetDeformMatNewMethod(pathspline, section.alpha, layer.layerPath.normalizedInterp, ref lastup) * twisttm; } else { if ( layer.frameMethod == MegaFrameMethod.Old ) tm = pathtm * layer.GetDeformMat(pathspline, section.alpha, layer.layerPath.normalizedInterp); else tm = pathtm * layer.GetDeformMatNewMethod(pathspline, section.alpha, layer.layerPath.normalizedInterp, ref lastup); } Vector3 p1 = section.crossverts[0]; float offx = 0.0f; float offy = 0.0f; float offz = 0.0f; float sclx = 1.0f; float scly = 1.0f; if ( layer.useScaleXCrv ) p1.x *= layer.scaleCrvX.Evaluate(section.alpha); if ( layer.useScaleYCrv ) p1.y *= layer.scaleCrvY.Evaluate(section.alpha); if ( layer.useOffsetX ) offx = layer.offsetCrvX.Evaluate(section.alpha); if ( layer.useOffsetY ) offy = layer.offsetCrvY.Evaluate(section.alpha); if ( layer.useOffsetZ ) offz = layer.offsetCrvZ.Evaluate(section.alpha); if ( layer.useScaleXCrv ) sclx = layer.scaleCrvX.Evaluate(section.alpha); if ( layer.useScaleYCrv ) scly = layer.scaleCrvY.Evaluate(section.alpha); p1 = tm.MultiplyPoint3x4(p1); p1 += layer.offset; Gizmos.color = seccol; //Color.red; Vector3 mid = Vector3.zero; for ( int v = 1; v < section.crossverts.Length; v++ ) { Vector3 p = section.crossverts[v]; p.x *= sclx; p.y *= scly; p.x += offx; p.y += offy; p.z += offz; p = tm.MultiplyPoint3x4(p); p += layer.offset; Gizmos.DrawLine(loft.transform.TransformPoint(p1), loft.transform.TransformPoint(p)); p1 = p; if ( v == section.crossverts.Length / 2 ) mid = p; } Handles.color = Color.white; Handles.Label(loft.transform.TransformPoint(mid), "Cross: " + i); Gizmos.color = col; } // Draw outside edge Vector3 sclc = Vector3.one; float lerp = 0.0f; // The position stuff here is waht we could use instead of mesh verts Vector3 last = Vector3.zero; Vector3 last1 = Vector3.zero; lastup = locup; for ( float alpha = 0.0f; alpha <= 1.0f; alpha += 0.005f ) { if ( layer.useScaleXCrv ) sclc.x = layer.scaleCrvX.Evaluate(alpha); if ( layer.useScaleYCrv ) sclc.y = layer.scaleCrvY.Evaluate(alpha); //if ( layer.useTwistCrv ) //{ // float twist = layer.twistCrv.Evaluate(alpha); // MegaShapeUtils.RotateZ(ref twisttm, Mathf.Deg2Rad * twist); // tm = pathtm * layer.GetDeformMat(layer.layerPath.splines[layer.curve], alpha, layer.layerPath.normalizedInterp) * twisttm; //loft.); //} //else // tm = pathtm * layer.GetDeformMat(layer.layerPath.splines[layer.curve], alpha, layer.layerPath.normalizedInterp); //loft.); if ( layer.useTwistCrv ) { float twist = layer.twistCrv.Evaluate(alpha); float tw1 = pathspline.GetTwist(alpha); MegaShapeUtils.RotateZ(ref twisttm, Mathf.Deg2Rad * (twist - tw1)); if ( layer.frameMethod == MegaFrameMethod.Old ) tm = pathtm * layer.GetDeformMat(pathspline, alpha, layer.layerPath.normalizedInterp) * twisttm; else tm = pathtm * layer.GetDeformMatNewMethod(pathspline, alpha, layer.layerPath.normalizedInterp, ref lastup) * twisttm; } else { if ( layer.frameMethod == MegaFrameMethod.Old ) tm = pathtm * layer.GetDeformMat(pathspline, alpha, layer.layerPath.normalizedInterp); else tm = pathtm * layer.GetDeformMatNewMethod(pathspline, alpha, layer.layerPath.normalizedInterp, ref lastup); } // Need to get the crosssection for the given alpha and the lerp value int csect = layer.GetSection(alpha, out lerp); lerp = layer.ease.easing(0.0f, 1.0f, lerp); MegaLoftSection cs1 = layer.sections[csect]; MegaLoftSection cs2 = layer.sections[csect + 1]; Vector3 p = Vector3.Lerp(cs1.crossverts[0], cs2.crossverts[0], lerp); // * sclc; Vector3 p1 = Vector3.Lerp(cs1.crossverts[cs1.crossverts.Length - 1], cs2.crossverts[cs2.crossverts.Length - 1], lerp); // * sclc; if ( layer.useScaleXCrv ) { p.x *= sclc.x; p1.x *= sclc.x; } if ( layer.useScaleYCrv ) { p.y *= sclc.y; p1.y *= sclc.y; } if ( layer.useOffsetX ) { p.x += layer.offsetCrvX.Evaluate(alpha); p1.x += layer.offsetCrvX.Evaluate(alpha); } if ( layer.useOffsetY ) { p.y += layer.offsetCrvY.Evaluate(alpha); p1.y += layer.offsetCrvY.Evaluate(alpha); } if ( layer.useOffsetZ ) { p.z += layer.offsetCrvZ.Evaluate(alpha); p1.z += layer.offsetCrvZ.Evaluate(alpha); } p = tm.MultiplyPoint3x4(p); p += layer.offset; p1 = tm.MultiplyPoint3x4(p1); p1 += layer.offset; if ( alpha > 0.0f ) { Gizmos.DrawLine(loft.transform.TransformPoint(last), loft.transform.TransformPoint(p)); Gizmos.DrawLine(loft.transform.TransformPoint(last1), loft.transform.TransformPoint(p1)); } last = p; last1 = p1; } }
private void OnEnable() { src = target as MegaLoftLayerComplex; undoManager = new MegaUndo(src, "Loft Param"); }
public void DisplayGUI() { MegaLoftLayerComplex layer = (MegaLoftLayerComplex)target; //MegaShapeLoft loft = layer.GetComponent<MegaShapeLoft>(); SetLimits(layer.gameObject); MegaShapeLoftEditor.PushCols(); GUI.color = Color.white; GUI.backgroundColor = layer.paramcol; GUI.contentColor = Color.white; EditorGUILayout.BeginVertical("TextArea"); layer.LayerName = EditorGUILayout.TextField(MegaToolTip.LayerName, layer.LayerName); layer.LayerEnabled = EditorGUILayout.Toggle(MegaToolTip.Enabled, layer.LayerEnabled); layer.paramcol = EditorGUILayout.ColorField(MegaToolTip.ParamCol, layer.paramcol); if (layer.LayerEnabled) { layer.Lock = EditorGUILayout.Toggle(MegaToolTip.Lock, layer.Lock); if (!layer.Lock) { layer.material = (Material)EditorGUILayout.ObjectField(MegaToolTip.Material, layer.material, typeof(Material), true); layer.layerPath = (MegaShape)EditorGUILayout.ObjectField(MegaToolTip.Path, layer.layerPath, typeof(MegaShape), true); if (layer.layerPath && layer.layerPath.splines != null) { if (layer.layerPath.splines.Count > 1) { layer.curve = EditorGUILayout.IntSlider(MegaToolTip.Curve, layer.curve, 0, layer.layerPath.splines.Count - 1); } if (layer.curve < 0) { layer.curve = 0; } if (layer.curve > layer.layerPath.splines.Count - 1) { layer.curve = layer.layerPath.splines.Count - 1; } } layer.SnapToPath = EditorGUILayout.Toggle("Snap To Path", layer.SnapToPath); layer.pathStart = EditorGUILayout.Slider(MegaToolTip.Start, layer.pathStart, sl, sh); layer.pathLength = EditorGUILayout.Slider(MegaToolTip.Length, layer.pathLength, ll, lh); layer.pathDist = EditorGUILayout.FloatField(MegaToolTip.Dist, layer.pathDist); layer.pathDist = Mathf.Clamp(layer.pathDist, dl, dh); //0.05f, 1.0f); EditorGUILayout.BeginVertical("Box"); layer.offset = EditorGUILayout.Vector3Field("Offset", layer.offset); layer.useOffsetX = EditorGUILayout.BeginToggleGroup(MegaToolTip.UseOffsetX, layer.useOffsetX); layer.offsetCrvX = EditorGUILayout.CurveField(MegaToolTip.OffsetCrvX, layer.offsetCrvX); EditorGUILayout.EndToggleGroup(); layer.useOffsetY = EditorGUILayout.BeginToggleGroup(MegaToolTip.UseOffsetY, layer.useOffsetY); layer.offsetCrvY = EditorGUILayout.CurveField(MegaToolTip.OffsetCrvY, layer.offsetCrvY); EditorGUILayout.EndToggleGroup(); layer.useOffsetZ = EditorGUILayout.BeginToggleGroup(MegaToolTip.UseOffsetZ, layer.useOffsetZ); layer.offsetCrvZ = EditorGUILayout.CurveField(MegaToolTip.OffsetCrvZ, layer.offsetCrvZ); EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndVertical(); layer.frameMethod = (MegaFrameMethod)EditorGUILayout.EnumPopup("Frame Method", layer.frameMethod); layer.flip = EditorGUILayout.Toggle(MegaToolTip.Flip, layer.flip); layer.PathSteps = EditorGUILayout.IntField("Path Steps", layer.PathSteps); if (layer.PathSteps < 1) { layer.PathSteps = 1; } layer.PathTeeter = EditorGUILayout.Slider("Path Teeter", layer.PathTeeter, 0.0f, 1.0f); layer.advancedParams = MegaFoldOut.Start("Advanced Params", layer.advancedParams, new Color(0.5f, 0.5f, 1.0f)); //layer.advancedParams = MegaFoldOut.Foldout("Advanced Params", layer.advancedParams, new Color(0.5f, 0.5f, 1.0f)); //layer.advancedParams = EditorGUILayout.Foldout(layer.advancedParams, MegaToolTip.AdvancedParams); if (layer.advancedParams) { layer.easeType = (MegaLoftEaseType)EditorGUILayout.EnumPopup("Ease Type", layer.easeType); layer.useTwistCrv = EditorGUILayout.BeginToggleGroup("Use Twist", layer.useTwistCrv); layer.twistCrv = EditorGUILayout.CurveField("Twist Curve", layer.twistCrv); EditorGUILayout.EndToggleGroup(); layer.useScaleXCrv = EditorGUILayout.BeginToggleGroup("Use ScaleX", layer.useScaleXCrv); layer.scaleCrvX = EditorGUILayout.CurveField("Scale X Curve", layer.scaleCrvX); EditorGUILayout.EndToggleGroup(); layer.useScaleYCrv = EditorGUILayout.BeginToggleGroup("Use ScaleY", layer.useScaleYCrv); layer.scaleCrvY = EditorGUILayout.CurveField("Scale Y Curve", layer.scaleCrvY); EditorGUILayout.EndToggleGroup(); } MegaFoldOut.End(layer.advancedParams); //layer.showcrossparams = EditorGUILayout.Foldout(layer.showcrossparams, "Cross Params"); layer.showcrossparams = MegaFoldOut.Start("Cross Params", layer.showcrossparams, new Color(0.5f, 1.0f, 0.5f)); if (layer.showcrossparams) { //EditorGUILayout.BeginVertical("Box"); layer.crossStart = EditorGUILayout.Slider(MegaToolTip.CrossStart, layer.crossStart, csl, csh); layer.crossEnd = EditorGUILayout.Slider(MegaToolTip.CrossLength, layer.crossEnd, cll, clh); layer.CrossSteps = EditorGUILayout.IntField("Cross Steps", layer.CrossSteps); if (layer.CrossSteps < 1) { layer.CrossSteps = 1; } layer.crossRot = EditorGUILayout.Vector3Field("Cross Rotate", layer.crossRot); layer.crossScale = EditorGUILayout.Vector3Field("Cross Scale", layer.crossScale); layer.pivot = EditorGUILayout.Vector3Field("Pivot", layer.pivot); layer.useCrossScaleCrv = EditorGUILayout.BeginToggleGroup("Use Scale Curve", layer.useCrossScaleCrv); layer.crossScaleCrv = EditorGUILayout.CurveField("Scale", layer.crossScaleCrv); EditorGUILayout.EndToggleGroup(); //EditorGUILayout.EndVertical(); } MegaFoldOut.End(layer.showcrossparams); //layer.showuvparams = EditorGUILayout.Foldout(layer.showuvparams, MegaToolTip.UVParams); layer.showuvparams = MegaFoldOut.Start("UV Params", layer.showuvparams, new Color(1.0f, 0.5f, 0.5f)); if (layer.showuvparams) { //EditorGUILayout.BeginVertical("Box"); MegaShapeLoftEditor.PushCols(); GUI.color = Color.white; layer.UVOffset = EditorGUILayout.Vector2Field("UV Offset", layer.UVOffset); layer.UVRotate = EditorGUILayout.Vector2Field("UV Rotate", layer.UVRotate); layer.UVScale = EditorGUILayout.Vector2Field("UV Scale", layer.UVScale); layer.swapuv = EditorGUILayout.Toggle(MegaToolTip.SwapUV, layer.swapuv); layer.physuv = EditorGUILayout.Toggle(MegaToolTip.PhysicalUV, layer.physuv); layer.planaruv = EditorGUILayout.Toggle("Planar UV", layer.planaruv); layer.UVOrigin = (MegaLoftUVOrigin)EditorGUILayout.EnumPopup("UV Origin", layer.UVOrigin); MegaShapeLoftEditor.PopCols(); //EditorGUILayout.EndVertical(); } MegaFoldOut.End(layer.showuvparams); //layer.showCapParams = EditorGUILayout.Foldout(layer.showCapParams, MegaToolTip.CapParams); layer.showCapParams = MegaFoldOut.Start("Cap Params", layer.showCapParams, new Color(1.0f, 1.0f, 0.5f)); if (layer.showCapParams) { layer.capflip = EditorGUILayout.Toggle("Flip Caps", layer.capflip); layer.capStart = EditorGUILayout.BeginToggleGroup(MegaToolTip.CapStart, layer.capStart); layer.capStartMat = (Material)EditorGUILayout.ObjectField(MegaToolTip.CapStartMat, layer.capStartMat, typeof(Material), true); layer.capStartUVOffset = EditorGUILayout.Vector2Field("UV Offset", layer.capStartUVOffset); layer.capStartUVScale = EditorGUILayout.Vector2Field("UV Scale", layer.capStartUVScale); layer.capStartUVRot = EditorGUILayout.FloatField(MegaToolTip.CapStartRot, layer.capStartUVRot); EditorGUILayout.EndToggleGroup(); layer.capEnd = EditorGUILayout.BeginToggleGroup(MegaToolTip.CapEnd, layer.capEnd); layer.capEndMat = (Material)EditorGUILayout.ObjectField(MegaToolTip.CapEndMat, layer.capEndMat, typeof(Material), true); layer.capEndUVOffset = EditorGUILayout.Vector2Field("UV Offset", layer.capEndUVOffset); layer.capEndUVScale = EditorGUILayout.Vector2Field("UV Scale", layer.capEndUVScale); layer.capEndUVRot = EditorGUILayout.FloatField(MegaToolTip.CapEndRot, layer.capEndUVRot); EditorGUILayout.EndToggleGroup(); } MegaFoldOut.End(layer.showCapParams); //layer.showsections = EditorGUILayout.Foldout(layer.showsections, "Cross Sections"); layer.showsections = MegaFoldOut.Start("Cross Sections", layer.showsections, new Color(0.5f, 1.0f, 1.0f)); if (layer.showsections) { if (layer.sections == null || layer.sections.Count < 2) { EditorGUILayout.LabelField("At least 2 cross sections are required to build the loft"); } seccol = EditorGUILayout.ColorField("Sections", seccol); layer.handlesize = EditorGUILayout.FloatField("Handle Size", layer.handlesize); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Reset Sections")) { for (int i = 0; i < layer.sections.Count; i++) { layer.sections[i].alpha = (float)i / (float)(layer.sections.Count - 1); } GUI.changed = true; } if (layer.sections.Count == 0) { if (GUILayout.Button("Add Section")) { MegaLoftSection lsect = new MegaLoftSection(); layer.sections.Add(lsect); GUI.changed = true; } } EditorGUILayout.EndHorizontal(); for (int i = 0; i < layer.sections.Count; i++) { EditorGUILayout.BeginVertical("Box"); EditorGUILayout.LabelField("Cross " + i, ""); float min = 0.0f; float max = 1.0f; if (i > 0) { min = layer.sections[i - 1].alpha; } if (i < layer.sections.Count - 1) { max = layer.sections[i + 1].alpha; } float alpha = 0.0f; if (i == 0) { alpha = 0.0f; } else { if (i == layer.sections.Count - 1) { alpha = 1.0f; } else { alpha = EditorGUILayout.Slider("Alpha", layer.sections[i].alpha, min, max); } } if (alpha != layer.sections[i].alpha) { if (i > 0) { if (alpha < layer.sections[i - 1].alpha) { alpha = layer.sections[i - 1].alpha; } } if (i < layer.sections.Count - 1) { if (alpha > layer.sections[i + 1].alpha) { alpha = layer.sections[i + 1].alpha; } } layer.sections[i].alpha = alpha; } layer.sections[i].shape = (MegaShape)EditorGUILayout.ObjectField("Section", layer.sections[i].shape, typeof(MegaShape), true); if (layer.sections[i].shape != null) { if (layer.sections[i].shape.splines.Count > 1) { layer.sections[i].curve = EditorGUILayout.IntSlider("Curve", layer.sections[i].curve, 0, layer.sections[i].shape.splines.Count - 1); } layer.sections[i].snap = EditorGUILayout.Toggle("Snap", layer.sections[i].snap); if (layer.sections[i].curve < 0) { layer.sections[i].curve = 0; } if (layer.sections[i].curve > layer.sections[i].shape.splines.Count - 1) { layer.sections[i].curve = layer.sections[i].shape.splines.Count - 1; } } layer.sections[i].offset = EditorGUILayout.Vector3Field("Offset", layer.sections[i].offset); layer.sections[i].rot = EditorGUILayout.Vector3Field("Rotate", layer.sections[i].rot); layer.sections[i].scale = EditorGUILayout.Vector3Field("Scale", layer.sections[i].scale); layer.sections[i].uselen = EditorGUILayout.Toggle("Use Section Len", layer.sections[i].uselen); if (layer.sections[i].uselen) { layer.sections[i].start = EditorGUILayout.Slider("Start", layer.sections[i].start, csl, csh); layer.sections[i].length = EditorGUILayout.Slider("Length", layer.sections[i].length, cll, clh); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Add Section")) { MegaLoftSection lsect = new MegaLoftSection(); lsect.shape = layer.sections[i].shape; lsect.curve = layer.sections[i].curve; lsect.scale = layer.sections[i].scale; if (i == layer.sections.Count - 1) { int pi = i - 1; if (pi >= 0) { lsect.alpha = (layer.sections[pi].alpha + layer.sections[i].alpha) * 0.5f; } else { lsect.alpha = 1.0f; } layer.sections.Add(lsect); } else { int pi = i + 1; if (pi < layer.sections.Count - 1) { lsect.alpha = (layer.sections[pi].alpha + layer.sections[i].alpha) * 0.5f; } else { lsect.alpha = 1.0f; } layer.sections.Insert(i + 1, lsect); } GUI.changed = true; } if (GUILayout.Button("Delete Section")) { layer.sections.RemoveAt(i); i--; GUI.changed = true; } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } MegaFoldOut.End(layer.showsections); if (layer.sections.Count > 0) { if (layer.sections[0].alpha != 0.0f) { layer.sections[0].alpha = 0.0f; } for (int i = 1; i < layer.sections.Count - 1; i++) { if (layer.sections[i].alpha <= layer.sections[i - 1].alpha) { layer.sections[i - 1].alpha = layer.sections[i].alpha; } if (layer.sections[i].alpha >= layer.sections[i + 1].alpha) { layer.sections[i].alpha = layer.sections[i + 1].alpha; } } if (layer.sections[layer.sections.Count - 1].alpha != 1.0f) { layer.sections[layer.sections.Count - 1].alpha = 1.0f; } } } } //EditorGUILayout.EndVertical(); //MegaShapeLoftEditor.PopCols(); } EditorGUILayout.EndVertical(); MegaShapeLoftEditor.PopCols(); }
public void OnSceneGUI() { MegaLoftLayerComplex layer = (MegaLoftLayerComplex)target; MegaShapeLoft loft = layer.gameObject.GetComponent <MegaShapeLoft>(); if (loft == null) { return; } if (layer.layerPath == null) { return; } if (!layer.showsections) { return; } MegaSpline pathspline = layer.layerPath.splines[layer.curve]; Matrix4x4 pathtm = Matrix4x4.identity; if (layer.SnapToPath) { pathtm = layer.layerPath.transform.localToWorldMatrix; } Matrix4x4 twisttm = Matrix4x4.identity; Matrix4x4 tm; float offx = 0.0f; float offy = 0.0f; float offz = 0.0f; Vector3 lastup = locup; for (int i = 1; i < layer.sections.Count - 1; i++) { MegaLoftSection section = layer.sections[i]; float alpha = section.alpha; if (layer.useOffsetX) { offx = layer.offsetCrvX.Evaluate(alpha); } if (layer.useOffsetY) { offy = layer.offsetCrvY.Evaluate(alpha); } if (layer.useOffsetZ) { offz += layer.offsetCrvZ.Evaluate(alpha); } //if ( layer.useTwistCrv ) //{ // float twist = layer.twistCrv.Evaluate(alpha); // MegaShapeUtils.RotateZ(ref twisttm, Mathf.Deg2Rad * twist); // tm = pathtm * layer.GetDeformMat(pathspline, alpha, layer.layerPath.normalizedInterp) * twisttm; //} //else // tm = pathtm * layer.GetDeformMat(pathspline, alpha, layer.layerPath.normalizedInterp); if (layer.useTwistCrv) { float twist = layer.twistCrv.Evaluate(section.alpha); float tw1 = pathspline.GetTwist(section.alpha); MegaShapeUtils.RotateZ(ref twisttm, Mathf.Deg2Rad * (twist - tw1)); if (layer.frameMethod == MegaFrameMethod.Old) { tm = pathtm * layer.GetDeformMat(pathspline, section.alpha, layer.layerPath.normalizedInterp) * twisttm; } else { tm = pathtm * layer.GetDeformMatNewMethod(pathspline, section.alpha, layer.layerPath.normalizedInterp, ref lastup) * twisttm; } } else { if (layer.frameMethod == MegaFrameMethod.Old) { tm = pathtm * layer.GetDeformMat(pathspline, section.alpha, layer.layerPath.normalizedInterp); } else { tm = pathtm * layer.GetDeformMatNewMethod(pathspline, section.alpha, layer.layerPath.normalizedInterp, ref lastup); } } Vector3 p = section.crossverts[0]; if (layer.useScaleXCrv) { p.x *= layer.scaleCrvX.Evaluate(alpha); } if (layer.useScaleYCrv) { p.y *= layer.scaleCrvY.Evaluate(alpha); } p.x += offx; p.y += offy; p.z += offz; Vector3 tp = p; p = tm.MultiplyPoint3x4(p); p += layer.offset; Matrix4x4 tantm = pathtm * layer.GetDeformMat(pathspline, alpha + 0.01f, layer.layerPath.normalizedInterp); Vector3 tan = tantm.MultiplyPoint3x4(tp); tan += layer.offset; tan = (tan - p).normalized; Vector3 p1 = section.crossverts[section.crossverts.Length - 1]; if (layer.useScaleXCrv) { p1.x *= layer.scaleCrvX.Evaluate(alpha); } if (layer.useScaleYCrv) { p1.y *= layer.scaleCrvY.Evaluate(alpha); } p1.x += offx; p1.y += offy; p1.z += offz; tp = p1; p1 = tm.MultiplyPoint3x4(p1); p1 += layer.offset; Handles.color = Color.yellow; p = loft.transform.TransformPoint(p); //Vector3 pn = Handles.Slider(p, tan, layer.handlesize, Handles.SphereCap, 0.0f); Vector3 pn = Slider(p, tan, layer.handlesize); pn = pn - p; float delta = pn.magnitude; if (Vector3.Dot(tan, pn) < 0.0f) { delta = -delta; } section.alpha += delta * 0.0005f; float al = section.alpha; // + delta * 0.0005f; if (al != layer.sections[i].alpha) { if (i > 0) { if (al < layer.sections[i - 1].alpha) { al = layer.sections[i - 1].alpha; } } if (i < layer.sections.Count - 1) { if (al > layer.sections[i + 1].alpha) { al = layer.sections[i + 1].alpha; } } layer.sections[i].alpha = al; } if (delta != 0.0f) { GUI.changed = true; loft.rebuild = true; EditorUtility.SetDirty(target); } tan = tantm.MultiplyPoint3x4(tp); tan += layer.offset; tan = (tan - p1).normalized; p1 = loft.transform.TransformPoint(p1); //pn = Handles.Slider(p1, tan, layer.handlesize, Handles.SphereCap, 0.0f); pn = Slider(p1, tan, layer.handlesize); pn = pn - p1; delta = pn.magnitude; //Vector3.Distance(p, pn); if (Vector3.Dot(tan, pn) < 0.0f) { delta = -delta; } al = section.alpha + delta * 0.0005f; if (al != layer.sections[i].alpha) { if (i > 0) { if (al < layer.sections[i - 1].alpha) { al = layer.sections[i - 1].alpha; } } if (i < layer.sections.Count - 1) { if (al > layer.sections[i + 1].alpha) { al = layer.sections[i + 1].alpha; } } layer.sections[i].alpha = al; } if (delta != 0.0f) { GUI.changed = true; loft.rebuild = true; EditorUtility.SetDirty(target); } } if (layer.sections.Count > 0) { if (layer.sections[0].alpha != 0.0f) { layer.sections[0].alpha = 0.0f; } for (int i = 1; i < layer.sections.Count - 1; i++) { if (layer.sections[i].alpha <= layer.sections[i - 1].alpha) { layer.sections[i - 1].alpha = layer.sections[i].alpha; } if (layer.sections[i].alpha >= layer.sections[i + 1].alpha) { layer.sections[i].alpha = layer.sections[i + 1].alpha; } } if (layer.sections[layer.sections.Count - 1].alpha != 1.0f) { layer.sections[layer.sections.Count - 1].alpha = 1.0f; } } }
static void DrawPath(MegaLoftLayerComplex layer) { MegaShapeLoft loft = layer.gameObject.GetComponent <MegaShapeLoft>(); if (loft == null) { return; } if (layer.layerPath == null) { return; } if (layer.sections == null || layer.sections.Count < 2) { return; } for (int i = 0; i < layer.sections.Count; i++) { if (layer.sections[i].crossverts == null || layer.sections[i].crossverts.Length == 0) { return; } } MegaSpline pathspline = layer.layerPath.splines[layer.curve]; Matrix4x4 pathtm = Matrix4x4.identity; if (layer.SnapToPath) { pathtm = layer.layerPath.transform.localToWorldMatrix; } Color col = Gizmos.color; Matrix4x4 twisttm = Matrix4x4.identity; Matrix4x4 tm; Vector3 lastup = locup; for (int i = 0; i < layer.sections.Count; i++) { MegaLoftSection section = layer.sections[i]; //if ( layer.useTwistCrv ) //{ // float twist = layer.twistCrv.Evaluate(section.alpha); // MegaShapeUtils.RotateZ(ref twisttm, Mathf.Deg2Rad * twist); // tm = pathtm * layer.GetDeformMat(pathspline, section.alpha, layer.layerPath.normalizedInterp) * twisttm; //loft.); //} //else // tm = pathtm * layer.GetDeformMat(pathspline, section.alpha, layer.layerPath.normalizedInterp); //loft.); if (layer.useTwistCrv) { float twist = layer.twistCrv.Evaluate(section.alpha); float tw1 = pathspline.GetTwist(section.alpha); MegaShapeUtils.RotateZ(ref twisttm, Mathf.Deg2Rad * (twist - tw1)); if (layer.frameMethod == MegaFrameMethod.Old) { tm = pathtm * layer.GetDeformMat(pathspline, section.alpha, layer.layerPath.normalizedInterp) * twisttm; } else { tm = pathtm * layer.GetDeformMatNewMethod(pathspline, section.alpha, layer.layerPath.normalizedInterp, ref lastup) * twisttm; } } else { if (layer.frameMethod == MegaFrameMethod.Old) { tm = pathtm * layer.GetDeformMat(pathspline, section.alpha, layer.layerPath.normalizedInterp); } else { tm = pathtm * layer.GetDeformMatNewMethod(pathspline, section.alpha, layer.layerPath.normalizedInterp, ref lastup); } } Vector3 p1 = section.crossverts[0]; float offx = 0.0f; float offy = 0.0f; float offz = 0.0f; float sclx = 1.0f; float scly = 1.0f; if (layer.useScaleXCrv) { p1.x *= layer.scaleCrvX.Evaluate(section.alpha); } if (layer.useScaleYCrv) { p1.y *= layer.scaleCrvY.Evaluate(section.alpha); } if (layer.useOffsetX) { offx = layer.offsetCrvX.Evaluate(section.alpha); } if (layer.useOffsetY) { offy = layer.offsetCrvY.Evaluate(section.alpha); } if (layer.useOffsetZ) { offz = layer.offsetCrvZ.Evaluate(section.alpha); } if (layer.useScaleXCrv) { sclx = layer.scaleCrvX.Evaluate(section.alpha); } if (layer.useScaleYCrv) { scly = layer.scaleCrvY.Evaluate(section.alpha); } p1 = tm.MultiplyPoint3x4(p1); p1 += layer.offset; Gizmos.color = seccol; //Color.red; Vector3 mid = Vector3.zero; for (int v = 1; v < section.crossverts.Length; v++) { Vector3 p = section.crossverts[v]; p.x *= sclx; p.y *= scly; p.x += offx; p.y += offy; p.z += offz; p = tm.MultiplyPoint3x4(p); p += layer.offset; Gizmos.DrawLine(loft.transform.TransformPoint(p1), loft.transform.TransformPoint(p)); p1 = p; if (v == section.crossverts.Length / 2) { mid = p; } } Handles.color = Color.white; Handles.Label(loft.transform.TransformPoint(mid), "Cross: " + i); Gizmos.color = col; } // Draw outside edge Vector3 sclc = Vector3.one; float lerp = 0.0f; // The position stuff here is waht we could use instead of mesh verts Vector3 last = Vector3.zero; Vector3 last1 = Vector3.zero; lastup = locup; for (float alpha = 0.0f; alpha <= 1.0f; alpha += 0.005f) { if (layer.useScaleXCrv) { sclc.x = layer.scaleCrvX.Evaluate(alpha); } if (layer.useScaleYCrv) { sclc.y = layer.scaleCrvY.Evaluate(alpha); } //if ( layer.useTwistCrv ) //{ // float twist = layer.twistCrv.Evaluate(alpha); // MegaShapeUtils.RotateZ(ref twisttm, Mathf.Deg2Rad * twist); // tm = pathtm * layer.GetDeformMat(layer.layerPath.splines[layer.curve], alpha, layer.layerPath.normalizedInterp) * twisttm; //loft.); //} //else // tm = pathtm * layer.GetDeformMat(layer.layerPath.splines[layer.curve], alpha, layer.layerPath.normalizedInterp); //loft.); if (layer.useTwistCrv) { float twist = layer.twistCrv.Evaluate(alpha); float tw1 = pathspline.GetTwist(alpha); MegaShapeUtils.RotateZ(ref twisttm, Mathf.Deg2Rad * (twist - tw1)); if (layer.frameMethod == MegaFrameMethod.Old) { tm = pathtm * layer.GetDeformMat(pathspline, alpha, layer.layerPath.normalizedInterp) * twisttm; } else { tm = pathtm * layer.GetDeformMatNewMethod(pathspline, alpha, layer.layerPath.normalizedInterp, ref lastup) * twisttm; } } else { if (layer.frameMethod == MegaFrameMethod.Old) { tm = pathtm * layer.GetDeformMat(pathspline, alpha, layer.layerPath.normalizedInterp); } else { tm = pathtm * layer.GetDeformMatNewMethod(pathspline, alpha, layer.layerPath.normalizedInterp, ref lastup); } } // Need to get the crosssection for the given alpha and the lerp value int csect = layer.GetSection(alpha, out lerp); lerp = layer.ease.easing(0.0f, 1.0f, lerp); MegaLoftSection cs1 = layer.sections[csect]; MegaLoftSection cs2 = layer.sections[csect + 1]; Vector3 p = Vector3.Lerp(cs1.crossverts[0], cs2.crossverts[0], lerp); // * sclc; Vector3 p1 = Vector3.Lerp(cs1.crossverts[cs1.crossverts.Length - 1], cs2.crossverts[cs2.crossverts.Length - 1], lerp); // * sclc; if (layer.useScaleXCrv) { p.x *= sclc.x; p1.x *= sclc.x; } if (layer.useScaleYCrv) { p.y *= sclc.y; p1.y *= sclc.y; } if (layer.useOffsetX) { p.x += layer.offsetCrvX.Evaluate(alpha); p1.x += layer.offsetCrvX.Evaluate(alpha); } if (layer.useOffsetY) { p.y += layer.offsetCrvY.Evaluate(alpha); p1.y += layer.offsetCrvY.Evaluate(alpha); } if (layer.useOffsetZ) { p.z += layer.offsetCrvZ.Evaluate(alpha); p1.z += layer.offsetCrvZ.Evaluate(alpha); } p = tm.MultiplyPoint3x4(p); p += layer.offset; p1 = tm.MultiplyPoint3x4(p1); p1 += layer.offset; if (alpha > 0.0f) { Gizmos.DrawLine(loft.transform.TransformPoint(last), loft.transform.TransformPoint(p)); Gizmos.DrawLine(loft.transform.TransformPoint(last1), loft.transform.TransformPoint(p1)); } last = p; last1 = p1; } }