/*! \endcond */ #endregion #region ### IOnRequestModule ### public CGData[] OnSlotDataRequest(CGModuleInputSlot requestedBy, CGModuleOutputSlot requestedSlot, params CGDataRequestParameter[] requests) { var raster = GetRequestParameter <CGDataRequestRasterization>(ref requests); var options = GetRequestParameter <CGDataRequestMetaCGOptions>(ref requests); if (options) { if (options.CheckMaterialID) { options.CheckMaterialID = false; UIMessages.Add("MaterialID option not supported!"); } if (options.IncludeControlPoints) { options.IncludeControlPoints = false; UIMessages.Add("IncludeCP option not supported!"); } } if (!raster || raster.Length == 0) { return(null); } var data = GetSplineData(Spline, true, raster, options); return(new CGData[1] { data }); }
/// <summary> /// Processing of Events AFTER Module Window drawing (Beware! Window dragging eats up most events!) /// </summary> public void EndGUI() { switch (EV.type) { case EventType.MouseDrag: // Drag canvas (i.e. change scroll offset) if (IsCanvasDrag) { Scroll.value -= EV.delta; } break; case EventType.KeyDown: if (EV.keyCode == KeyCode.Delete) { UI.Delete(Sel.SelectedObjects); Sel.Clear(); } break; case EventType.MouseUp: if (EV.button == 0 && !IsDragging && !CurvyProject.Instance.CGAutoModuleDetails && (!Sel.SelectedLink && !MouseOverLink(Sel.SelectedLink)) && (!Sel.SelectedModule || !MouseOverModule) ) { Sel.Select(null); } if (IsLinkDrag && EV.control) { AutoConnectFrom = LinkDragFrom; UI.AddModuleQuickmenu(LinkDragFrom); } // Multi Selection if (IsSelectionRectDrag) { HandleMultiSelection(); IsSelectionRectDrag = false; } LinkDragFrom = null; IsCanvasDrag = false; Parent.StatusBar.Clear(); break; case EventType.DragUpdated: UI.HandleDragDropProgress(); break; case EventType.DragPerform: UI.HandleDragDropDone(); break; } }
/*! \endcond */ #endregion #region ### IOnRequestPath ### public CGData[] OnSlotDataRequest(CGModuleInputSlot requestedBy, CGModuleOutputSlot requestedSlot, params CGDataRequestParameter[] requests) { var raster = GetRequestParameter <CGDataRequestRasterization>(ref requests); var options = GetRequestParameter <CGDataRequestMetaCGOptions>(ref requests); if (!raster || raster.Length == 0) { return(null); } var data = GetSplineData(Shape, false, raster, options); return(new CGData[1] { data }); }
public CGData[] OnSlotDataRequest(CGModuleInputSlot requestedBy, CGModuleOutputSlot requestedSlot, params CGDataRequestParameter[] requests) { var raster = GetRequestParameter <CGDataRequestRasterization>(ref requests); if (!raster) { return(null); } var Data = InPath.GetData <CGPath>(requests); return(new CGData[1] { Conform(Generator.transform, Data, LayerMask, Direction, Offset, MaxDistance, Warp) }); }
/*! \endcond */ #endregion #region ### IOnRequestProcessing ### public CGData[] OnSlotDataRequest(CGModuleInputSlot requestedBy, CGModuleOutputSlot requestedSlot, params CGDataRequestParameter[] requests) { var raster = GetRequestParameter <CGDataRequestRasterization>(ref requests); if (!raster) { return(null); } var DataA = InPathA.GetData <CGPath>(requests); var DataB = InPathB.GetData <CGPath>(requests); return(new CGData[1] { MixPath(DataA, DataB, Mix) }); }
void OnMenu(object userData) { CGModuleOutputSlot slot = userData as CGModuleOutputSlot; if (slot == null) { CurrentProp.FindPropertyRelative("m_Module").objectReferenceValue = null; CurrentProp.FindPropertyRelative("m_SlotName").stringValue = string.Empty; } else { CurrentProp.FindPropertyRelative("m_Module").objectReferenceValue = slot.Module; CurrentProp.FindPropertyRelative("m_SlotName").stringValue = slot.Info.Name; } CurrentProp.serializedObject.ApplyModifiedProperties(); }
public CGData[] OnSlotDataRequest(CGModuleInputSlot requestedBy, CGModuleOutputSlot requestedSlot, params CGDataRequestParameter[] requests) { if (requestedSlot == OutPath) { var Data = InPath.GetData<CGPath>(requests); Matrix4x4 mat = Matrix; for (int i = 0; i < Data.Count; i++) Data.Position[i] = mat.MultiplyPoint3x4(Data.Position[i]); Data.Recalculate(); return new CGData[1] { Data }; } return null; }
void OnMenu(object userData) { CGModuleOutputSlot slot = userData as CGModuleOutputSlot; var field = GetPropertySourceField <CGDataReference>(CurrentProp); if (slot == null) { field.Clear(); } else { field.setINTERNAL(slot.Module, slot.Info.Name); } CurrentProp.serializedObject.ApplyModifiedProperties(); }
public void AddModuleQuickmenu(CGModuleOutputSlot forOutputSlot) { var mnu = new GenericMenu(); List <ModuleInfoAttribute> matches; System.Type outType = forOutputSlot.OutputInfo.DataType; while (typeof(CGData).IsAssignableFrom(outType) && outType != typeof(CGData)) { if (ModuleInfoByInput.TryGetValue(outType, out matches)) { foreach (var mi in matches) { mnu.AddItem(new GUIContent(mi.MenuName), false, CTXOnAddAndConnectModule, mi); } mnu.ShowAsContext(); } outType = outType.BaseType; } }
public CGData[] OnSlotDataRequest(CGModuleInputSlot requestedBy, CGModuleOutputSlot requestedSlot, params CGDataRequestParameter[] requests) { if (requestedSlot == OutShape) { var Data = InShape.GetData <CGShape>(requests); Matrix4x4 mat = Matrix; for (int i = 0; i < Data.Count; i++) { Data.Position[i] = mat.MultiplyPoint3x4(Data.Position[i]); } Data.Recalculate(); return(new CGData[1] { Data }); } return(null); }
public void AddModuleQuickmenu(CGModuleOutputSlot forOutputSlot) { var mnu = new GenericMenu(); List<ModuleInfoAttribute> matches; System.Type outType = forOutputSlot.OutputInfo.DataType; while (typeof(CGData).IsAssignableFrom(outType) && outType!=typeof(CGData)) { if (ModuleInfoByInput.TryGetValue(outType, out matches)) { foreach (var mi in matches) { mnu.AddItem(new GUIContent(mi.MenuName), false, CTXOnAddAndConnectModule, mi); } mnu.ShowAsContext(); } outType = outType.BaseType; } }
/*! \endcond */ #endregion #region ### IOnRequestProcessing ### public CGData[] OnSlotDataRequest(CGModuleInputSlot requestedBy, CGModuleOutputSlot requestedSlot, params CGDataRequestParameter[] requests) { var raster = GetRequestParameter <CGDataRequestRasterization>(ref requests); if (!raster) { return(null); } var DataA = InShapeA.GetData <CGShape>(requests); var DataB = InShapeB.GetData <CGShape>(requests); var data = new CGPath(); CGShape A, B; if (DataA.Count > DataB.Count) { A = DataA; B = DataB; } else { A = DataB; B = DataA; } Vector3[] pa = new Vector3[A.Count]; Vector3[] na = new Vector3[A.Count]; float frag = (Mix + 1) / 2; for (int i = 0; i < A.Count; i++) { pa[i] = Vector3.Lerp(A.Position[i], B.InterpolatePosition(A.F[i]), frag); na[i] = Vector3.Lerp(A.Normal[i], B.Normal[i], frag); } data.F = A.F; data.Position = pa; data.Normal = na; return(new CGData[1] { data }); }
public CGData[] OnSlotDataRequest(CGModuleInputSlot requestedBy, CGModuleOutputSlot requestedSlot, params CGDataRequestParameter[] requests) { var raster = GetRequestParameter<CGDataRequestRasterization>(ref requests); if (!raster) return null; var Data = InPath.GetData<CGPath>(requests); return new CGData[1] { Conform(Generator.transform, Data, LayerMask, Direction, Offset, MaxDistance, Warp) }; }
/*! \endcond */ #endregion #region ### IOnRequestProcessing ### public CGData[] OnSlotDataRequest(CGModuleInputSlot requestedBy, CGModuleOutputSlot requestedSlot, params CGDataRequestParameter[] requests) { var raster = GetRequestParameter<CGDataRequestRasterization>(ref requests); if (!raster) return null; var DataA = InPathA.GetData<CGPath>(requests); var DataB = InPathB.GetData<CGPath>(requests); return new CGData[1] { MixPath(DataA, DataB, Mix) }; }
/*! \endcond */ #endregion #region ### IOnRequestPath ### public CGData[] OnSlotDataRequest(CGModuleInputSlot requestedBy, CGModuleOutputSlot requestedSlot, params CGDataRequestParameter[] requests) { var raster = GetRequestParameter<CGDataRequestRasterization>(ref requests); var options = GetRequestParameter<CGDataRequestMetaCGOptions>(ref requests); if (!raster || raster.Length == 0) return null; var data = GetSplineData(Shape, false, raster, options); return new CGData[1] { data }; }
/*! \endcond */ #endregion #region ### IOnRequestModule ### public CGData[] OnSlotDataRequest(CGModuleInputSlot requestedBy, CGModuleOutputSlot requestedSlot, params CGDataRequestParameter[] requests) { var raster = GetRequestParameter<CGDataRequestRasterization>(ref requests); var options = GetRequestParameter<CGDataRequestMetaCGOptions>(ref requests); if (options) { if (options.CheckMaterialID) { options.CheckMaterialID = false; UIMessages.Add("MaterialID option not supported!"); } if (options.IncludeControlPoints) { options.IncludeControlPoints = false; UIMessages.Add("IncludeCP option not supported!"); } } if (!raster || raster.Length == 0) return null; var data = GetSplineData(Spline, true, raster, options); return new CGData[1] { data }; }
/*! \endcond */ #endregion #region ### IOnRequestProcessing ### public CGData[] OnSlotDataRequest(CGModuleInputSlot requestedBy, CGModuleOutputSlot requestedSlot, params CGDataRequestParameter[] requests) { var raster = GetRequestParameter<CGDataRequestRasterization>(ref requests); if (!raster) return null; var DataA = InShapeA.GetData<CGShape>(requests); var DataB = InShapeB.GetData<CGShape>(requests); var data = new CGPath(); CGShape A, B; if (DataA.Count > DataB.Count) { A = DataA; B = DataB; } else { A = DataB; B = DataA; } Vector3[] pa = new Vector3[A.Count]; float frag = (Mix + 1) / 2; for (int i = 0; i < A.Count; i++) pa[i] = Vector3.Lerp(A.Position[i], B.InterpolatePosition(A.F[i]), frag); data.F = A.F; data.Position = pa; return new CGData[1] { data }; }
void OnModuleWindowSlotGUI(CGModule module) { int i = 0; float h = 18; while (module.Input.Count > i || module.Output.Count > i) { float y = CurvyStyles.ModuleWindowTitleHeight + h * i; GUILayout.BeginHorizontal(); if (module.Input.Count > i) { CGModuleInputSlot slot = module.Input[i]; Color slotColor = getTypeColor(slot.Info.DataTypes); if (Canvas.IsLinkDrag && !slot.IsValidTarget(Canvas.LinkDragFrom)) { slotColor = new Color(0.2f, 0.2f, 0.2f).SkinAwareColor(true); } DTGUI.PushColor(slotColor); GUILayout.Box("<", CurvyStyles.Slot); DTGUI.PopColor(); string postfix = ""; if (slot.Info.Array) { postfix = (slot.LastDataCountINTERNAL > 0) ? "[" + slot.LastDataCountINTERNAL.ToString() + "]" : "[]"; } GUILayout.Label(new GUIContent(ObjectNames.NicifyVariableName(slot.Info.Name) + postfix, slot.Info.Tooltip), CurvyStyles.GetSlotLabelStyle(slot)); slot.DropZone = new Rect(0, y, module.Properties.Dimensions.width / 2, h); slot.Origin = new Vector2(module.Properties.Dimensions.xMin, module.Properties.Dimensions.yMin + y + h / 2); // LinkDrag? if (Canvas.IsLinkDrag) { // If ending drag over dropzone, create static link if (EV.type == EventType.MouseUp && slot.DropZone.Contains(EV.mousePosition) && slot.IsValidTarget(Canvas.LinkDragFrom)) { finishLink(slot); } } // Clicking on Dropzone to pick existing link else if (LMB && slot.Count == 1 && slot.DropZone.Contains(EV.mousePosition)) { var linkedOutSlot = slot.SourceSlot(); linkedOutSlot.UnlinkFrom(slot); EditorUtility.SetDirty(slot.Module); startLinkDrag(linkedOutSlot); GUIUtility.ExitGUI(); } } if (module.Output.Count > i) { CGModuleOutputSlot slot = module.Output[i]; string postfix = ""; if (slot.Info.Array) { postfix = (slot.Data != null && slot.Data.Length > 1) ? "[" + slot.Data.Length.ToString() + "]" : ""; } GUILayout.Label(new GUIContent(ObjectNames.NicifyVariableName(slot.Info.Name) + postfix, slot.Info.Tooltip), CurvyStyles.GetSlotLabelStyle(slot)); DTGUI.PushColor(getTypeColor(slot.Info.DataTypes)); GUILayout.Box(">", CurvyStyles.Slot); DTGUI.PopColor(); // Debug /* * if (Generator.ShowDebug) * { * GUI.enabled = slot.Data != null && slot.Data.Length>0; * if (GUILayout.Button(new GUIContent(CurvyStyles.DebugTexture, "Show Dump"), CurvyStyles.SmallButton, GUILayout.Width(16), GUILayout.Height(16))) * DTDebugWindow.Open(slot.Data[0].GetType().Name + ":", slot.Data[0].ToDumpString()); * GUI.enabled = true; * } */ slot.DropZone = new Rect(module.Properties.Dimensions.width / 2, y, module.Properties.Dimensions.width / 2, h); slot.Origin = new Vector2(module.Properties.Dimensions.xMax, module.Properties.Dimensions.yMin + y + h / 2); // Start Linking? if (LMB && !Canvas.IsSelectionRectDrag && slot.DropZone.Contains(EV.mousePosition)) { startLinkDrag(slot); } } GUILayout.EndHorizontal(); i++; } }
/// <summary> /// Processing of Events AFTER Module Window drawing (Beware! Window dragging eats up most events!) /// </summary> public void EndGUI() { switch (EV.type) { case EventType.MouseDrag: // Drag canvas (i.e. change scroll offset) if (IsCanvasDrag) { Scroll.value -= EV.delta; } break; case EventType.KeyDown: if (EV.keyCode == KeyCode.Delete) { UI.Delete(Sel.SelectedObjects); Sel.Clear(); } break; case EventType.MouseUp: if (EV.button == 0 && !IsDragging && !CurvyProject.Instance.CGAutoModuleDetails && (!Sel.SelectedLink && !MouseOverLink(Sel.SelectedLink)) && (!Sel.SelectedModule || !MouseOverModule) ) Sel.Select(null); if (IsLinkDrag && EV.control) { AutoConnectFrom = LinkDragFrom; UI.AddModuleQuickmenu(LinkDragFrom); } // Multi Selection if (IsSelectionRectDrag) { HandleMultiSelection(); IsSelectionRectDrag = false; } LinkDragFrom = null; IsCanvasDrag = false; Parent.StatusBar.Clear(); break; case EventType.DragUpdated: UI.HandleDragDropProgress(); break; case EventType.DragPerform: UI.HandleDragDropDone(); break; } }