// GROUPER::GENERATE public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool isReplica) { //if (ArchimatixUtils.doDebug) //Debug.Log (parametricObject.Name + " generate +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); if (!parametricObject.isActive) { return(null); } if (parametricObject.Groupees == null) { return(null); } preGenerate(); parametricObject.useMeshInputs = true; if (parametricObject.meshInputs == null) { parametricObject.meshInputs = new List <AXParameter>(); } // PROCESS INPUT SHAPES // pass Input Shape through... //Debug.Log( parametricObject.Name + " <><><><><> PROCESS INPUT SHAPES"); List <AXParameter> inputShapes = parametricObject.getAllInputShapes(); for (int i = 0; i < inputShapes.Count; i++) { AXParameter inputShape = inputShapes[i]; if (inputShape != null) { inputShape.polyTree = null; AXShape.thickenAndOffset(ref inputShape, inputShape.DependsOn); } } GameObject go = null; if (makeGameObjects && !parametricObject.combineMeshes) { go = ArchimatixUtils.createAXGameObject(parametricObject.Name, parametricObject); } List <AXMesh> ax_meshes = new List <AXMesh>(); List <AXMesh> boundingMeshes = new List <AXMesh>(); // for each input //List<AXParameter> inputMeshes = parametricObject.getAllInputMeshParameters(); // Reinstate the original functionality of the Grouper as simple combiner in addition to Groupees. if (inputs != null && inputs.Count > 0) { for (int i = 0; i < inputs.Count; i++) { if (inputs[i] != null && inputs[i].DependsOn != null) { if (inputs[i].Dependents != null || inputs[i].Dependents.Count == 0) { AXParameter src_p = inputs[i].DependsOn; AXParametricObject src_po = inputs[i].DependsOn.parametricObject; //if (! parametricObject.visited_pos.Contains (groupee)) //Debug.Log("groupee.generateOutputNow: " + groupee.Name + " isAltered="+groupee.isAltered); if (src_po.isAltered) { src_po.generateOutputNow(makeGameObjects, initiator_po); //Debug.Log("XXXXX: " + groupee.Output.meshes.Count); src_po.isAltered = false; parametricObject.model.AlteredPOs.Remove(src_po); } if (src_p != null && src_p.meshes != null) { for (int j = 0; j < src_p.meshes.Count; j++) { AXMesh dep_amesh = src_p.meshes [j]; ax_meshes.Add(dep_amesh.Clone(dep_amesh.transMatrix)); } } // BOUNDING MESHES //boundsCombinator[i].mesh = input_p.DependsOn.parametricObject.boundsMesh; //boundsCombinator[i].transform = input_p.DependsOn.parametricObject.generator.localMatrixWithAxisRotationAndAlignment; if (src_po.boundsMesh != null) { boundingMeshes.Add(new AXMesh(src_po.boundsMesh, src_po.generator.localMatrixWithAxisRotationAndAlignment)); } // GAME_OBJECTS if (makeGameObjects && !parametricObject.combineMeshes) { GameObject plugGO = src_po.generator.generate(true, initiator_po, isReplica); if (plugGO != null) { plugGO.transform.parent = go.transform; } } } } } } // *** GROUPEES - Generate the groupees here // so that all the inputs (thicknesses, etc.) have been processed first. //List<AXParametricObject> visited_pos = new List<AXParametricObject>(); if (parametricObject.Groupees != null && parametricObject.Groupees.Count > 0) { for (int i = 0; i < parametricObject.Groupees.Count; i++) { AXParametricObject groupee = parametricObject.Groupees [i]; //if (! parametricObject.visited_pos.Contains (groupee)) //Debug.Log("groupee.generateOutputNow: " + groupee.Name + " isAltered="+groupee.isAltered); if (groupee.isAltered) { groupee.generateOutputNow(makeGameObjects, initiator_po); //Debug.Log("XXXXX: " + groupee.Output.meshes.Count); groupee.isAltered = false; parametricObject.model.AlteredPOs.Remove(groupee); } } } // BOUNDING // Process for (int i = 0; i < parametricObject.Groupees.Count; i++) { AXParametricObject groupee = parametricObject.Groupees [i]; //if (input_p != null && input_p.DependsOn != null && input_p.DependsOn.meshes != null && input_p.DependsOn.meshes.Count > 0) { //if (groupee != null && groupee.is3D() && ! groupee.hasDependents() && groupee.Output != null && groupee.Output.meshes != null) if (groupee != null && groupee.is3D() && groupee.shouldRenderSelf(true)) { // AX_MESHES //Debug.Log("(*) (*) (*) (*) groupee: " + groupee.Name + " " +groupee.Output.meshes.Count + " isAltered = " + groupee.isAltered); if (groupee.Output != null && groupee.Output.meshes != null) { for (int j = 0; j < groupee.Output.meshes.Count; j++) { AXMesh dep_amesh = groupee.Output.meshes [j]; ax_meshes.Add(dep_amesh.Clone(dep_amesh.transMatrix)); } } // BOUNDING MESHES //boundsCombinator[i].mesh = input_p.DependsOn.parametricObject.boundsMesh; //boundsCombinator[i].transform = input_p.DependsOn.parametricObject.generator.localMatrixWithAxisRotationAndAlignment; if (groupee.boundsMesh != null) { boundingMeshes.Add(new AXMesh(groupee.boundsMesh, groupee.generator.localMatrixWithAxisRotationAndAlignment)); } // GAME_OBJECTS if (makeGameObjects && !parametricObject.combineMeshes) { GameObject plugGO = groupee.generator.generate(true, initiator_po, isReplica); if (plugGO != null) { plugGO.transform.parent = go.transform; } } } } // FINISH AX_MESHES //Debug.Log("ORG: " + ax_meshes.Count); parametricObject.finishMultiAXMeshAndOutput(ax_meshes, isReplica); // FINISH BOUNDS CombineInstance[] boundsCombinator = new CombineInstance[boundingMeshes.Count]; for (int bb = 0; bb < boundsCombinator.Length; bb++) { boundsCombinator[bb].mesh = boundingMeshes[bb].mesh; boundsCombinator[bb].transform = boundingMeshes[bb].transMatrix; } setBoundsWithCombinator(boundsCombinator); if (P_BoundsX != null && !P_BoundsX.hasRelations() && !P_BoundsX.hasExpressions()) { P_BoundsX.FloatVal = parametricObject.bounds.size.x; } if (P_BoundsY != null && !P_BoundsY.hasRelations() && !P_BoundsY.hasExpressions()) { P_BoundsY.FloatVal = parametricObject.bounds.size.y; } if (P_BoundsZ != null && !P_BoundsZ.hasRelations() && !P_BoundsZ.hasExpressions()) { P_BoundsZ.FloatVal = parametricObject.bounds.size.z; } // FINISH GAME_OBJECTS if (makeGameObjects) { if (parametricObject.combineMeshes) { go = parametricObject.makeGameObjectsFromAXMeshes(ax_meshes, true, false); // COMBINE ALL THE MESHES CombineInstance[] combine = new CombineInstance[ax_meshes.Count]; int combineCt = 0; for (int i = 0; i < ax_meshes.Count; i++) { AXMesh _amesh = ax_meshes [i]; combine [combineCt].mesh = _amesh.mesh; combine [combineCt].transform = _amesh.transMatrix; combineCt++; } Mesh combinedMesh = new Mesh(); combinedMesh.CombineMeshes(combine); // If combine, use combined mesh as invisible collider MeshFilter mf = (MeshFilter)go.GetComponent(typeof(MeshFilter)); if (mf == null) { mf = (MeshFilter)go.AddComponent(typeof(MeshFilter)); } if (mf != null) { mf.sharedMesh = combinedMesh; parametricObject.addCollider(go); } } else { Matrix4x4 tmx = parametricObject.getLocalMatrix(); go.transform.rotation = AXUtilities.QuaternionFromMatrix(tmx); go.transform.position = AXUtilities.GetPosition(tmx); go.transform.localScale = parametricObject.getLocalScaleAxisRotated(); } return(go); } //parametricObject.model.sw.milestone(parametricObject.Name + " generate"); return(null); }
public void doPO(AXParametricObject po) { Color guiColorOrig = GUI.color; Color guiContentColorOrig = GUI.contentColor; GUI.color = Color.white; GUI.contentColor = Color.white; Color textColor = new Color(.82f, .80f, .85f); Color textColorSel = new Color(.98f, .95f, 1f); GUIStyle labelstyle = new GUIStyle(GUI.skin.label); //int fontSize = labelstyle.fontSize; labelstyle.fixedHeight = 30; labelstyle.alignment = TextAnchor.UpperLeft; labelstyle.normal.textColor = textColorSel; labelstyle.fontSize = 20; // GUIStyle labelstyleTmp = GUI.skin.GetStyle("Label"); // labelstyleTmp.normal.textColor = Color.red; Color bgcolorOrig = GUI.backgroundColor; //GUI.backgroundColor = Color.cyan; GUIStyle gsTest = new GUIStyle(); gsTest.normal.background = ArchimatixEngine.nodeIcons ["Blank"]; // //Color.gray; gsTest.normal.textColor = Color.white; GUIStyle foldoutStyle = new GUIStyle(EditorStyles.foldout); foldoutStyle.normal.textColor = textColor; foldoutStyle.active.textColor = textColorSel; foldoutStyle.hover.textColor = textColor; foldoutStyle.focused.textColor = textColorSel; foldoutStyle.onNormal.textColor = textColor; foldoutStyle.onActive.textColor = textColorSel; foldoutStyle.onHover.textColor = textColor; foldoutStyle.onFocused.textColor = textColorSel; GUIStyle smallFoldoutStyle = new GUIStyle(EditorStyles.foldout); smallFoldoutStyle.fixedWidth = 0; GUILayout.BeginVertical(gsTest); GUILayout.BeginHorizontal(gsTest); GUILayout.Space(40); Rect rect = GUILayoutUtility.GetLastRect(); //GUI.DrawTexture(new Rect(position.x, rect.y, EditorGUIUtility.currentViewWidth, 100), ArchimatixEngine.nodeIcons["Blank"], ScaleMode.ScaleToFit, true, 1.0F); GUILayout.Space(10); // TITLE GUILayout.Label(po.Name, labelstyle); labelstyle.fontSize = 12; GUILayout.EndHorizontal(); if (po.is2D() && po.generator.hasOutputsReady()) { AXParameter output_p = po.generator.getPreferredOutputParameter(); GUIDrawing.DrawPathsFit(output_p, new Vector2(42, rect.y + 15), 28, ArchimatixEngine.AXGUIColors ["ShapeColor"]); } else if (ArchimatixEngine.nodeIcons != null && ArchimatixEngine.nodeIcons.ContainsKey(po.Type)) { //Rect thumbRect = new Rect (28, rect.y - 0, 36, 36); //GUI.DrawTexture(thumbRect, po.renTex, ScaleMode.ScaleToFit, true, 1.0F); EditorGUI.DrawTextureTransparent(new Rect(28, rect.y - 0, 36, 36), ArchimatixEngine.nodeIcons [po.Type], ScaleMode.ScaleToFit, 1.0F); } Rect rectthumb2 = GUILayoutUtility.GetLastRect(); if (po.is3D() && po.renTex != null) { GUIStyle thumbLgStyle = new GUIStyle(); float thumbLgSize = 64; thumbLgStyle.fixedHeight = thumbLgSize; GUILayout.BeginHorizontal(thumbLgStyle); GUILayout.Space(thumbLgSize); Rect thumbRectLG = new Rect(40, rectthumb2.y + 35, thumbLgSize, thumbLgSize); EditorGUI.DrawTextureTransparent(thumbRectLG, po.renTex, ScaleMode.ScaleToFit, 1.0F); GUILayout.EndHorizontal(); } EditorGUI.indentLevel++; //GUILayout.Space(20); GUILayout.BeginHorizontal(); EditorGUIUtility.labelWidth = 35; EditorGUI.BeginChangeCheck(); //EditorGUIUtility.labelWidth = 65; po.isActive = EditorGUILayout.ToggleLeft("Enabled", po.isActive); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "isActive value change for " + po.Name); po.model.autobuild(); po.generator.adjustWorldMatrices(); } GUILayout.FlexibleSpace(); if (GUILayout.Button("Select in Node Graph")) { po.model.selectAndPanToPO(po); } GUILayout.EndHorizontal(); // FLAGS, TAGS & LAYERS if (po.is3D()) { po.displayFlagsTagsLayers = EditorGUILayout.Foldout(po.displayFlagsTagsLayers, "Name, Flags, Tags & Layers", true, foldoutStyle); } else { po.displayFlagsTagsLayers = EditorGUILayout.Foldout(po.displayFlagsTagsLayers, "Name", true, foldoutStyle); } if (po.displayFlagsTagsLayers) { //EDIT TITLE // if (showTitle(po)) // { //GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(35); GUILayout.Label("Name: "); EditorGUIUtility.labelWidth = 65; po.Name = GUILayout.TextField(po.Name); GUILayout.EndHorizontal(); if (po.is3D()) { EditorGUIUtility.labelWidth = 75; EditorGUI.BeginChangeCheck(); po.axStaticEditorFlags = (AXStaticEditorFlags)EditorGUILayout.EnumMaskField("Static: ", po.axStaticEditorFlags); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "Static value change for " + po.Name); po.setUpstreamersToYourFlags(); // post dialog to change all children... ArchimatixEngine.scheduleBuild(); } GUI.backgroundColor = bgcolorOrig; EditorGUIUtility.labelWidth = 75; // TAGS EditorGUI.BeginChangeCheck(); po.tag = EditorGUILayout.TagField("Tag:", po.tag); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "Tag value change for " + po.Name); ArchimatixEngine.scheduleBuild(); } // LAYERS EditorGUI.BeginChangeCheck(); int intval = EditorGUILayout.LayerField("Layer:", po.layer); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "Layer value change for " + po.Name); po.layer = intval; ArchimatixEngine.scheduleBuild(); } bool hasMeshRenderer = !po.noMeshRenderer; EditorGUI.BeginChangeCheck(); hasMeshRenderer = EditorGUILayout.ToggleLeft("Mesh Renderer", hasMeshRenderer); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "hasMeshRenderer"); po.noMeshRenderer = !hasMeshRenderer; ArchimatixEngine.scheduleBuild(); } } else if (po.generator is MaterialTool) { EditorGUI.BeginChangeCheck(); //float thumbSize = 16; po.axMat.mat = (Material)EditorGUILayout.ObjectField(po.axMat.mat, typeof(Material), true); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "Material"); po.model.remapMaterialTools(); po.model.autobuild(); } } } // FLAGS< TAGS & LAYERS // POSITION CONTROLS if (po.positionControls != null && po.positionControls.children != null) { po.positionControls.isOpenInInspector = EditorGUILayout.Foldout(po.positionControls.isOpenInInspector, "Transform", true, foldoutStyle); if (po.positionControls.isOpenInInspector) { InspectorParameterGUI.OnGUI(po.positionControls.children); } } // GEOMETRY CONTROLS if (po.geometryControls != null && po.geometryControls.children != null) { po.geometryControls.isOpenInInspector = EditorGUILayout.Foldout(po.geometryControls.isOpenInInspector, "Geometry Controls", true, foldoutStyle); if (po.geometryControls.isOpenInInspector) { InspectorParameterGUI.OnGUI(po.geometryControls.children); } } // PROTOTYPES if (po.is3D()) { po.displayPrototypes = EditorGUILayout.Foldout(po.displayPrototypes, "Prototypes", true, foldoutStyle); if (po.displayPrototypes) { EditorGUI.BeginChangeCheck(); po.prototypeGameObject = (GameObject)EditorGUILayout.ObjectField(po.prototypeGameObject, typeof(GameObject), true); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "Prototype GameObject set for " + po.model.name); if (po.prototypeGameObject != null) { AXPrototype proto = (AXPrototype)po.prototypeGameObject.GetComponent("AXPrototype"); if (proto == null) { proto = po.prototypeGameObject.AddComponent <AXPrototype> (); } if (!proto.parametricObjects.Contains(po)) { proto.parametricObjects.Add(po); } } po.model.autobuild(); } } } if (po.selectedAXGO != null) { GUILayout.Label(po.selectedAXGO.consumerAddress); } // if (po.is3D() && po.renTex != null) // { // GUIStyle thumbLgStyle = new GUIStyle(); // float thumbLgSize = 194; // // thumbLgStyle.fixedHeight = thumbLgSize; // GUILayout.BeginHorizontal(thumbLgStyle); // GUILayout.Space(40); // Rect rectthumb = GUILayoutUtility.GetLastRect(); // Rect thumbRectLG = new Rect(28, rectthumb.y-0, thumbLgSize, thumbLgSize); // GUI.DrawTexture(thumbRectLG, po.renTex, ScaleMode.ScaleToFit, true, 1.0F); // // GUILayout.EndHorizontal(); // } // EditorGUI.indentLevel--; GUILayout.EndVertical(); GUILayout.Space(30); GUI.color = guiColorOrig; GUI.contentColor = guiContentColorOrig; }
// Update is called once per frame void Update() { if (!Application.isPlaying) { return; } bool byPlane = true; if (handle == null) { return; } AXParametricObject parametricObject = handle.parametricObject; // GET POSITION if (parametricObject.is2D()) { context = parametricObject.model.transform.localToWorldMatrix * parametricObject.worldDisplayMatrix; if (parametricObject.generator.hasOutputsConnected() || parametricObject.is2D()) { context *= parametricObject.generator.localMatrix.inverse; } else { context *= parametricObject.getAxisRotationMatrix().inverse *parametricObject.generator.localMatrix.inverse *parametricObject.getAxisRotationMatrix(); } } else { // GROUPER MATRIX NOT WORKING.... context = parametricObject.model.transform.localToWorldMatrix * parametricObject.generator.parametricObject.worldDisplayMatrix * (parametricObject.getAxisRotationMatrix() * parametricObject.generator.getLocalAlignMatrix()).inverse * parametricObject.generator.localMatrix.inverse; } // position handle by parmeters. positionHandleGameObject(); double h_diff = 0; double v_diff = 0; if (mouseIsDown) { if (Input.touchCount == 1) { // touch input - works better with deltaPosition var touch = Input.GetTouch(0); //var dx = touch.deltaPosition.x; h_diff = (100.0 / Screen.width) * touch.deltaPosition.x; v_diff = (100.0 / Screen.width) * touch.deltaPosition.y; } else { // 0 touches: must be mouse input h_diff = (5000 / Screen.width) * Input.GetAxis("Mouse X"); v_diff = (5000 / Screen.width) * Input.GetAxis("Mouse Y"); } h_diff /= 5; v_diff /= 5; //Debug.Log(h_diff +", " + v_diff); //using plane if (byPlane) { establishDrawingSurface(); //Vector3 prevPosition = transform.position; } // BASED ON PLANE Vector3 world_pos = transform.position; if (byPlane) { Vector3 hit_position3D = sampleHitPoint(); world_pos = hit_position3D - mouseDownDiff; transform.position = world_pos; } Vector3 localPosition = context.inverse.MultiplyPoint3x4(world_pos); //transform.position = world_pos; //if (transform.position != prevPosition) if (h_diff != 0 || v_diff != 0) { //Debug.Log("moved"); // Determine the orientation of the camera //The normal OperatingSystemFamily the handle plane //Debug.Log (lookV); float threshold = .707f; double diffX = -v_diff; double diffZ = h_diff; // This logic works with a normal vector if (!byPlane) { if (lookV.x > 0 && lookV.z < 0) { diffX = (1 - lookV.x) * h_diff - lookV.x * v_diff; diffZ = (1 + lookV.z) * h_diff - lookV.z * v_diff; } else if (lookV.x > 0 && lookV.z > 0) { diffX = -((lookV.x)) * h_diff - lookV.x * v_diff; diffZ = (1 + lookV.z) * h_diff - lookV.z * v_diff; } else if (lookV.x < 0 && lookV.z > 0) { diffX = (1 + lookV.x) * h_diff + lookV.x * v_diff; diffZ = (1 - lookV.z) * h_diff + lookV.z * v_diff; } else if (lookV.x > 0 && lookV.z > 0) { diffX = -((lookV.x)) * h_diff - (lookV.x) * v_diff; diffZ = (1 + lookV.z) * h_diff - lookV.z * v_diff; //(-lookV.x + lookV.z) * v_diff; } else if (lookV.z > threshold) // pointing forwards { diffX = -h_diff; diffZ = -v_diff; } else if (lookV.z < -threshold) { // pointing backwards diffX = h_diff; diffZ = v_diff; } else if (lookV.x > 0) { // pointing right diffX = -h_diff; diffZ = v_diff; } else { // pointing left diffX = v_diff; diffZ = -h_diff; } } AXHandle han = handle; string hanString = "han_y"; float posV = localPosition.y; if (parametricObject.is3D()) { hanString = "han_z"; posV = localPosition.z; } if (byPlane) { parametricObject.setVar("han_x", (localPosition.x)); if (parametricObject.is3D()) { parametricObject.setVar("han_z", world_pos.z); } else { parametricObject.setVar("han_y", localPosition.y); } } else { // Relative slide of cursor parametricObject.setVar("han_x", (localPosition.x + (float)diffX)); parametricObject.setVar(hanString, (posV + (float)diffZ)); } // From plane // parametricObject.setVar("han_x", localPosition.x); // parametricObject.setVar("han_y", localPosition.y); // parametricObject.setVar("han_z", localPosition.z); // EACH EXPRESSION for (int i = 0; i < han.expressions.Count; i++) { if (han.expressions [i] == "") { continue; } string expression = Regex.Replace(han.expressions [i], @"\s+", ""); string paramName = expression.Substring(0, expression.IndexOf("=")); string definition = expression.Substring(expression.IndexOf("=") + 1); //Debug.Log (param + " --- " + definition); try { if (parametricObject.getParameter(paramName).Type == AXParameter.DataType.Int) { parametricObject.initiateRipple_setIntValueFromGUIChange(paramName, Mathf.RoundToInt((float)parametricObject.parseMath(definition))); } else { parametricObject.initiateRipple_setFloatValueFromGUIChange(paramName, (float)parametricObject.parseMath(definition)); } } catch (System.Exception e) { parametricObject.codeWarning = "10. Handle error: Please check syntax of: \"" + definition + "\" " + e.Message; } } parametricObject.model.isAltered(); //parametricObject.model.autobuild(); } } }
// GROUPER::GENERATE public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool isReplica) { //if (ArchimatixUtils.doDebug) //Debug.Log (parametricObject.Name + " generate +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); if (!parametricObject.isActive) { return(null); } preGenerate(); GameObject go = null; if (makeGameObjects && !parametricObject.combineMeshes) { go = ArchimatixUtils.createAXGameObject(parametricObject.Name, parametricObject); } List <AXMesh> ax_meshes = new List <AXMesh>(); // BOUNDING List <AXMesh> boundingMeshes = new List <AXMesh>(); // Reinstate the original functionality of the Grouper as simple combiner in addition to Groupees. if (inputs != null && inputs.Count > 0) { // ALL if (channel == inputs.Count) { for (int i = 0; i < inputs.Count; i++) { if (inputs[i] != null && inputs[i].DependsOn != null) { if (inputs[i].Dependents != null || inputs[i].Dependents.Count == 0) { AXParameter src_p = inputs[i].DependsOn; AXParametricObject src_po = inputs[i].DependsOn.parametricObject; //if (! parametricObject.visited_pos.Contains (groupee)) //Debug.Log("groupee.generateOutputNow: " + groupee.Name + " isAltered="+groupee.isAltered); if (src_po.isAltered) { src_po.generateOutputNow(makeGameObjects, initiator_po); //Debug.Log("XXXXX: " + groupee.Output.meshes.Count); src_po.isAltered = false; parametricObject.model.AlteredPOs.Remove(src_po); } if (src_p != null && src_p.meshes != null) { for (int j = 0; j < src_p.meshes.Count; j++) { AXMesh dep_amesh = src_p.meshes [j]; ax_meshes.Add(dep_amesh.Clone(dep_amesh.transMatrix)); } } // BOUNDING MESHES //boundsCombinator[i].mesh = input_p.DependsOn.parametricObject.boundsMesh; //boundsCombinator[i].transform = input_p.DependsOn.parametricObject.generator.localMatrixWithAxisRotationAndAlignment; if (src_po.boundsMesh != null) { boundingMeshes.Add(new AXMesh(src_po.boundsMesh, src_po.generator.localMatrixWithAxisRotationAndAlignment)); } // GAME_OBJECTS if (makeGameObjects && !parametricObject.combineMeshes) { GameObject plugGO = src_po.generator.generate(true, initiator_po, isReplica); if (plugGO != null) { plugGO.transform.parent = go.transform; } } } } } } // JUST ONE CHANNEL else if (inputs.Count > channel && inputs[channel] != null) { AXParameter src_p = inputs[channel].DependsOn; if (src_p != null) { AXParametricObject src_po = src_p.parametricObject; if (src_po.is3D()) { if (src_po.Output != null && src_po.Output.meshes != null) { for (int j = 0; j < src_po.Output.meshes.Count; j++) { AXMesh dep_amesh = src_po.Output.meshes [j]; ax_meshes.Add(dep_amesh.Clone(dep_amesh.transMatrix)); } } // BOUNDING MESHES //boundsCombinator[i].mesh = input_p.DependsOn.parametricObject.boundsMesh; //boundsCombinator[i].transform = input_p.DependsOn.parametricObject.generator.localMatrixWithAxisRotationAndAlignment; if (src_po.boundsMesh != null) { boundingMeshes.Add(new AXMesh(src_po.boundsMesh, src_po.generator.localMatrixWithAxisRotationAndAlignment)); } // GAME_OBJECTS if (makeGameObjects && !parametricObject.combineMeshes) { GameObject plugGO = src_po.generator.generate(true, initiator_po, isReplica); if (plugGO != null) { plugGO.transform.parent = go.transform; } } } P_Output.meshes = src_p.meshes; } } // FINISH AX_MESHES //Debug.Log("ORG: " + ax_meshes.Count); parametricObject.finishMultiAXMeshAndOutput(ax_meshes, isReplica); // FINISH BOUNDS CombineInstance[] boundsCombinator = new CombineInstance[boundingMeshes.Count]; for (int bb = 0; bb < boundsCombinator.Length; bb++) { boundsCombinator[bb].mesh = boundingMeshes[bb].mesh; boundsCombinator[bb].transform = boundingMeshes[bb].transMatrix; } setBoundsWithCombinator(boundsCombinator); if (P_BoundsX != null && !P_BoundsX.hasRelations() && !P_BoundsX.hasExpressions()) { P_BoundsX.FloatVal = parametricObject.bounds.size.x; } if (P_BoundsY != null && !P_BoundsY.hasRelations() && !P_BoundsY.hasExpressions()) { P_BoundsY.FloatVal = parametricObject.bounds.size.y; } if (P_BoundsZ != null && !P_BoundsZ.hasRelations() && !P_BoundsZ.hasExpressions()) { P_BoundsZ.FloatVal = parametricObject.bounds.size.z; } } // FINISH GAME_OBJECTS if (makeGameObjects) { if (parametricObject.combineMeshes) { go = parametricObject.makeGameObjectsFromAXMeshes(ax_meshes, true, false); // COMBINE ALL THE MESHES CombineInstance[] combine = new CombineInstance[ax_meshes.Count]; int combineCt = 0; for (int i = 0; i < ax_meshes.Count; i++) { AXMesh _amesh = ax_meshes [i]; combine [combineCt].mesh = _amesh.mesh; combine [combineCt].transform = _amesh.transMatrix; combineCt++; } Mesh combinedMesh = new Mesh(); combinedMesh.CombineMeshes(combine); // If combine, use combined mesh as invisible collider MeshFilter mf = (MeshFilter)go.GetComponent(typeof(MeshFilter)); if (mf == null) { mf = (MeshFilter)go.AddComponent(typeof(MeshFilter)); } if (mf != null) { mf.sharedMesh = combinedMesh; parametricObject.addCollider(go); } } else { Matrix4x4 tmx = parametricObject.getLocalMatrix(); go.transform.rotation = AXUtilities.QuaternionFromMatrix(tmx); go.transform.position = AXUtilities.GetPosition(tmx); go.transform.localScale = parametricObject.getLocalScaleAxisRotated(); } return(go); } return(null); }
public void doPO(AXParametricObject po) { GUIStyle labelstyle = GUI.skin.GetStyle("Label"); //int fontSize = labelstyle.fontSize; labelstyle.fontSize = 20; GUILayout.BeginHorizontal(); GUILayout.Space(40); Rect rect = GUILayoutUtility.GetLastRect(); // NAME GUILayout.Label(po.Name); labelstyle.fontSize = 12; GUILayout.EndHorizontal(); if (po.is2D() && po.generator.hasOutputsReady()) { AXParameter output_p = po.generator.getPreferredOutputParameter(); GUIDrawing.DrawPathsFit(output_p, new Vector2(32, rect.y + 10), 32); } else if (ArchimatixEngine.nodeIcons != null && ArchimatixEngine.nodeIcons.ContainsKey(po.Type)) { GUI.DrawTexture(new Rect(16, rect.y - 5, 32, 32), ArchimatixEngine.nodeIcons[po.Type], ScaleMode.ScaleToFit, true, 1.0F); } if (showTitle(po)) { GUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); EditorGUIUtility.labelWidth = 0; po.isActive = EditorGUILayout.Toggle(po.isActive, GUILayout.MaxWidth(20)); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "isActive value change for " + po.Name); po.model.autobuild(); po.generator.adjustWorldMatrices(); } EditorGUIUtility.labelWidth = 0; po.Name = GUILayout.TextField(po.Name); if (po.is3D()) { EditorGUIUtility.labelWidth = 35; EditorGUI.BeginChangeCheck(); po.axStaticEditorFlags = (AXStaticEditorFlags)EditorGUILayout.EnumMaskField("Static", po.axStaticEditorFlags); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "Static value change for " + po.Name); po.setUpstreamersToYourFlags(); // post dialog to change all children... po.model.autobuild(); /* * int option = EditorUtility.DisplayDialogComplex("Change Static Flags?", * "Do you want to disable the Lightmap Static flag for all the child objects as well? ", * * "No, only this ParametricObject", * "Yes, change children", * "Cancel"); * * * switch( option ) * { * // Save Scene * case 0: * Debug.Log("ONLY"); * break; * * // Save and Quit. * * // SAVE THIS MASK FOR CHILDREN AS WELL. * case 1: * Debug.Log("CHILDREN"); * break; * * case 2: * Debug.Log("CANCEL"); * break; * * * default: * Debug.LogError( "Unrecognized option." ); * break; * } */ } } GUILayout.FlexibleSpace(); if (GUILayout.Button("Select")) { po.model.selectAndPanToPO(po); } GUILayout.EndHorizontal(); } if (po.is3D()) { EditorGUIUtility.labelWidth = 35; GUILayout.BeginHorizontal(); // TAGS EditorGUI.BeginChangeCheck(); po.tag = EditorGUILayout.TagField("Tag:", po.tag); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "Tag value change for " + po.Name); } // LAYERS EditorGUI.BeginChangeCheck(); int intval = EditorGUILayout.LayerField("Layer:", po.layer); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "Layer value change for " + po.Name); po.layer = intval; } GUILayout.EndHorizontal(); bool hasMeshRenderer = !po.noMeshRenderer; EditorGUI.BeginChangeCheck(); hasMeshRenderer = EditorGUILayout.ToggleLeft("Mesh Renderer", hasMeshRenderer); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "hasMeshRenderer"); po.noMeshRenderer = !hasMeshRenderer; } } else if (po.generator is MaterialTool) { EditorGUI.BeginChangeCheck(); //float thumbSize = 16; po.axMat.mat = (Material)EditorGUILayout.ObjectField(po.axMat.mat, typeof(Material), true); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "Material"); po.model.remapMaterialTools(); po.model.autobuild(); } } AXParameter p; //EditorGUIUtility.labelWidth = 200;//EditorGUIUtility.currentViewWidth-16; if (po.geometryControls != null && po.geometryControls.children != null) { for (int i = 0; i < po.geometryControls.children.Count; i++) { p = po.geometryControls.children[i] as AXParameter; EditorGUIUtility.labelWidth = 150; // PARAMETERS switch (p.Type) { // ANIMATION_CURVE case AXParameter.DataType.AnimationCurve: EditorGUI.BeginChangeCheck(); EditorGUILayout.CurveField(p.animationCurve); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "ModifierCurve"); p.parametricObject.model.isAltered(28); } break; // FLOAT case AXParameter.DataType.Float: AXEditorUtilities.assertFloatFieldKeyCodeValidity("FloatField_" + p.Name); GUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("FloatField_" + p.Name); p.FloatVal = EditorGUILayout.FloatField(p.Name, p.FloatVal); if (EditorGUI.EndChangeCheck()) { //Debug.Log(p.FloatVal); Undo.RegisterCompleteObjectUndo(po.model, "value change for " + p.Name); p.parametricObject.initiateRipple_setFloatValueFromGUIChange(p.Name, p.FloatVal); p.parametricObject.model.isAltered(27); p.parametricObject.generator.adjustWorldMatrices(); } // Expose EditorGUI.BeginChangeCheck(); p.exposeAsInterface = EditorGUILayout.Toggle(p.exposeAsInterface, GUILayout.MaxWidth(20)); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "Expose Parameter"); if (p.exposeAsInterface) { p.parametricObject.model.addExposedParameter(p); } else { p.parametricObject.model.removeExposedParameter(p); } } GUILayout.EndHorizontal(); break; // INT case AXParameter.DataType.Int: GUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("IntField_" + p.Name); p.intval = EditorGUILayout.IntField(p.Name, p.intval); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "value change for " + p.Name); p.parametricObject.initiateRipple_setFloatValueFromGUIChange(p.Name, p.intval); p.parametricObject.model.isAltered(28); p.parametricObject.generator.adjustWorldMatrices(); } // Expose EditorGUI.BeginChangeCheck(); p.exposeAsInterface = EditorGUILayout.Toggle(p.exposeAsInterface, GUILayout.MaxWidth(20)); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "Expose Parameter"); if (p.exposeAsInterface) { p.parametricObject.model.addExposedParameter(p); } else { p.parametricObject.model.removeExposedParameter(p); } } GUILayout.EndHorizontal(); break; // BOOL case AXParameter.DataType.Bool: //EditorGUIUtility.currentViewWidth-16; GUILayout.BeginHorizontal(); //EditorGUIUtility.labelWidth = 150; EditorGUI.BeginChangeCheck(); p.boolval = EditorGUILayout.Toggle(p.Name, p.boolval); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, " value change for " + p.Name); p.parametricObject.initiateRipple_setBoolParameterValueByName(p.Name, p.boolval); //p.parametricObject.model.autobuild(); p.parametricObject.model.isAltered(27); //p.parametricObject.generator.adjustWorldMatrices(); } GUILayout.FlexibleSpace(); // Expose EditorGUI.BeginChangeCheck(); p.exposeAsInterface = EditorGUILayout.Toggle(p.exposeAsInterface, GUILayout.MaxWidth(20)); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "Expose Parameter"); if (p.exposeAsInterface) { p.parametricObject.model.addExposedParameter(p); } else { p.parametricObject.model.removeExposedParameter(p); } } GUILayout.EndHorizontal(); break; case AXParameter.DataType.CustomOption: { // OPTION POPUP string[] options = p.optionLabels.ToArray(); EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("CustomOptionPopup_" + p.Guid + "_" + p.Name); p.intval = EditorGUILayout.Popup( p.Name, p.intval, options); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for " + p.Name); p.parametricObject.model.autobuild(); if (p.PType == AXParameter.ParameterType.PositionControl) { p.parametricObject.generator.adjustWorldMatrices(); } } break; } } //if (p.PType != AXParameter.ParameterType.None && p.PType != AXParameter.ParameterType.GeometryControl) // continue; } } // PROTOTYPE if (po.is3D()) { po.displayPrototypes = EditorGUILayout.Foldout(po.displayPrototypes, "Prototypes"); if (po.displayPrototypes) { EditorGUI.BeginChangeCheck(); po.prototypeGameObject = (GameObject)EditorGUILayout.ObjectField(po.prototypeGameObject, typeof(GameObject), true); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "Prototype GameObject set for " + po.model.name); if (po.prototypeGameObject != null) { AXPrototype proto = (AXPrototype)po.prototypeGameObject.GetComponent("AXPrototype"); if (proto == null) { proto = po.prototypeGameObject.AddComponent <AXPrototype>(); } if (!proto.parametricObjects.Contains(po)) { proto.parametricObjects.Add(po); } } po.model.autobuild(); } } } if (po.selectedAXGO != null) { GUILayout.Label(po.selectedAXGO.consumerAddress); } GUILayout.Space(30); }