public static void makeLightMapUVs(AXModel model) { //Debug.Log("Making secondary"); if (model.generatedGameObjects != null) { List <Mesh> meshesProcessed = new List <Mesh> (); Transform[] transforms = model.generatedGameObjects.GetComponentsInChildren <Transform> (); foreach (Transform transform in transforms) { if (transform.GetComponent <Rigidbody> () == null) { AXGameObject axgo = transform.gameObject.GetComponent <AXGameObject>(); if (axgo != null && axgo.parametricObject != null && ((axgo.parametricObject.axStaticEditorFlags & AXStaticEditorFlags.LightmapStatic) == AXStaticEditorFlags.LightmapStatic)) { //Debug.Log(transform.gameObject.name + " gets secondary"); MeshFilter meshFilter = transform.gameObject.GetComponent <MeshFilter> (); if (meshFilter != null) { Mesh mesh = meshFilter.sharedMesh; if (!meshesProcessed.Contains(mesh)) { Debug.Log("doin' it!"); Unwrapping.GenerateSecondaryUVSet(mesh); //Mesh tmpMesh = mesh; //tmpMesh.uv2 = mesh.uv2; meshesProcessed.Add(mesh); } //GameObjectUtility.SetStaticEditorFlags (transform.gameObject, StaticEditorFlags.LightmapStatic); } } } } model.buildStatus = AXModel.BuildStatus.lightmapUVs; } }
// GENERATE PLAN_REPEATER public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool renderToOutputParameter) { if (parametricObject == null || !parametricObject.isActive) { return(null); } //Debug.Log("yo ******* makeGameObjects="+makeGameObjects); // RESULTING MESHES ax_meshes = new List <AXMesh>(); paths_SubsplineIndices = new List <SubsplineIndices[]>(); preGenerate(); planSrc_p = P_Plan.DependsOn; // getUpstreamSourceParameter(P_Plan); planSrc_po = (planSrc_p != null) ? planSrc_p.parametricObject : null; //Debug.Log("planSrc_po = " + planSrc_po.Name+"."+planSrc_p.Name + " ... " + planSrc_p.DependsOn.PType + " ..... " + planSrc_p.getPaths()); P_Plan.polyTree = null; AXShape.thickenAndOffset(ref P_Plan, planSrc_p); if (P_Plan.reverse) { P_Plan.doReverse(); } planPaths = P_Plan.getPaths(); if (planPaths == null || planPaths.Count == 0) { return(null); } // ** CREATE PLAN_SPLINES ** if (planPaths != null && planPaths.Count > 0) { planSplines = new Spline[planPaths.Count]; if (planSplines != null) { for (int i = 0; i < planSplines.Length; i++) { planSplines[i] = new Spline(planPaths[i], (P_Plan.shapeState == ShapeState.Closed) ? true : false); } } } //Debug.Log("controlVertices="+ planSplines[0].controlVertices.Count); // CORNER_MESH GameObject cornerPlugGO = null; if (cornerSrc_p != null) { cornerSrc_po = cornerSrc_p.parametricObject; if (makeGameObjects && !parametricObject.combineMeshes) { cornerPlugGO = cornerSrc_po.generator.generate(true, initiator_po, renderToOutputParameter); } } // NODE_MESH GameObject nodePlugGO = null; if (nodeSrc_p != null) { nodeSrc_po = nodeSrc_p.parametricObject; //Debug.Log("yo makeGameObjects="+makeGameObjects+", parametricObject.combineMeshes="+parametricObject.combineMeshes); if (makeGameObjects && !parametricObject.combineMeshes) { nodePlugGO = nodeSrc_po.generator.generate(true, initiator_po, renderToOutputParameter); } } // CELL_MESH GameObject cellPlugGO = null; if (cellSrc_p != null) { cellSrc_po = cellSrc_p.parametricObject; if (makeGameObjects && !parametricObject.combineMeshes) { cellPlugGO = cellSrc_po.generator.generate(true, initiator_po, renderToOutputParameter); } } // Plan // This is the main spline used for the iteration //AXParameter plan_p = ip.DependsOn; // The section spline is used to provide the connective tissue around corners // SECTION // The plan may have multiple paths. Each may generate a separate GO. sectionSrc_p = P_Section.DependsOn; //getUpstreamSourceParameter(P_Section); sectionSrc_po = (sectionSrc_p != null) ? sectionSrc_p.parametricObject : null; if (sectionSrc_po != null) { P_Section.polyTree = null; AXShape.thickenAndOffset(ref P_Section, sectionSrc_p); if (P_Section.reverse) { P_Section.doReverse(); } } float bay_U = parametricObject.floatValue("bay_U"); float bay_V = parametricObject.floatValue("bay_V"); if (bay_U == 0) { bay_U = .1f; } if (bay_V == 0) { bay_V = 10f; } float margin_U = parametricObject.floatValue("margin_U"); Vector2 prevV = new Vector2(); //Vector3 scaler1 = Vector3.one; //float margin = 2.5f; Vector2 firstPM = new Vector2(); Vector2 prevVM = new Vector2(); AXSpline secSpline = null; AXSplineExtrudeGenerator tmpEXSP = null; if (sectionSrc_p != null && sectionSrc_p.spline != null && sectionSrc_p.spline.vertCount > 0) { secSpline = sectionSrc_p.spline; } tmpEXSP = new AXSplineExtrudeGenerator(); Material tmp_mat = parametricObject.axMat.mat; if (parametricObject.axTex != null) { tmpEXSP.uScale = parametricObject.axTex.scale.x; tmpEXSP.vScale = parametricObject.axTex.scale.y; tmpEXSP.uShift = -parametricObject.axTex.shift.x; tmpEXSP.vShift = parametricObject.axTex.shift.y; } float runningU = 0; //ip.spline.getAnglesArray(); //Spline sectionSpline = null; // = new Spline(sectionPath, sectionIsClosed, sec_p.breakGeom, sec_p.breakNorm); GameObject go = null; GameObject planGO = null; if (makeGameObjects && !parametricObject.combineMeshes) { go = ArchimatixUtils.createAXGameObject(parametricObject.Name, parametricObject); } // BOUNDING List <AXMesh> boundingMeshes = new List <AXMesh>(); // FOR EACH PATH for (int path_i = 0; path_i < planPaths.Count; path_i++) { if (makeGameObjects && !parametricObject.combineMeshes) { planGO = ArchimatixUtils.createAXGameObject(parametricObject.Name + "_" + path_i, parametricObject); } // **** PREPARE EACH SPLINE *** // Spline planSpline = planSplines[path_i]; planSpline.breakAngleCorners = cornerBreakAngle; planSpline.shapeState = P_Plan.shapeState; // Create subsplines between each break point planSpline.getSmoothSubsplineIndicies(0, maxSegmentLength); // ....... DEBUG //Pather.printPaths(planPaths); planSpline.groupNearBreakAngleVertices(inset * 2); if (planSpline.groupedCornerNodes == null || planSpline.groupedCornerNodes.Count == 0) { inset = 0; } // **** PREPARE EACH SPLINE *** // Matrix4x4 localPlacement_mx = Matrix4x4.identity; // INSET PLANSWEEPS GameObject plansweepGO = null; if (sectionSrc_p != null && inset > 0 && planSpline.insetSplines != null) { // convert planSpline.insetSplines to Paths Paths insetPaths = AXGeometryTools.Utilities.Splines2Paths(planSpline.insetSplines); AXParameter tmpPlanP = new AXParameter(); tmpPlanP.parametricObject = parametricObject; tmpPlanP.paths = insetPaths; tmpPlanP.Type = AXParameter.DataType.Shape; tmpPlanP.shapeState = ShapeState.Open; tmpPlanP.breakGeom = 0; if (planSpline.insetSplines.Count == 1) { tmpPlanP.shapeState = planSpline.insetSplines[0].shapeState; } topCap = false; botCap = false; plansweepGO = generateFirstPass(initiator_po, makeGameObjects, tmpPlanP, P_Section, Matrix4x4.identity, renderToOutputParameter, false); if (makeGameObjects && !parametricObject.combineMeshes && plansweepGO != null) { plansweepGO.transform.parent = go.transform; } } AXMesh tmpMesh = null; if (planSpline.insetSpanSplines != null && planSpline.insetSpanSplines.Count > 0) { //Debug.Log(".....????>> spanSpline.subsplines.Count="+ planSpline.insetSpanSplines.Count + " --- " + planSpline.subsplines.Count ); for (int si = 0; si < planSpline.insetSpanSplines.Count; si++) { planSpline.insetSpanSplines[si].setRepeaterTransforms(si, inset, bay); } // SPAN NODES - MESHES ALONG SUBSPLINES if (nodeSrc_p != null && nodeSrc_p.meshes != null) { //int endCount = (P_Plan != null && P_Plan.shapeState == ShapeState.Open) ? planSpline.subsplines.Count-1 : planSpline.subsplines.Count; int endCount = (P_Plan != null && P_Plan.shapeState == ShapeState.Open) ? planSpline.insetSpanSplines.Count - 1 : planSpline.insetSpanSplines.Count; for (int i = 0; i < endCount; i++) { //SubsplineIndices rsi = planSpline.subsplines[i]; Spline spanSpline = planSpline.insetSpanSplines[i]; //Debug.Log(i + "||||||||||> " + spanSpline.toString()); List <Matrix4x4> nodeMatrices = spanSpline.repeaterNodeTransforms; // on each of these nodes, place a nodePlug instance. bool spanNodesAtBreakCorners = true; int starter = (inset > 0 || spanNodesAtBreakCorners) ? 0 : 1; //Debug.Log("starter="+starter); int ender = (inset > 0 || spanSpline.shapeState == ShapeState.Open || planSpline.subsplines.Count == 1) ? nodeMatrices.Count : nodeMatrices.Count - 1; //Debug.Log("starter="+starter +", ender="+ender + ", nodeMatrices.Count=" + nodeMatrices.Count); //Debug.Log("(inset > 0 && spanNodesAtBreakCorners)="+(inset > 0 && spanNodesAtBreakCorners)+", nodeMatrices.Length="+nodeMatrices.Length+", starter="+starter+", ender="+ender); string this_address = ""; if (nodeMatrices != null) { for (int ii = starter; ii < ender; ii++) { this_address = "node_" + path_i + "_" + i + "_" + ii; //Debug.Log("this_address="+this_address); // LOCAL_PLACEMENT localPlacement_mx = localMatrixFromAddress(RepeaterItem.Node, path_i, i, ii); // AX_MESHES for (int mi = 0; mi < nodeSrc_p.meshes.Count; mi++) { AXMesh dep_amesh = nodeSrc_p.meshes [mi]; tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix); tmpMesh.subItemAddress = this_address; ax_meshes.Add(tmpMesh); } // BOUNDING boundingMeshes.Add(new AXMesh(nodeSrc_po.boundsMesh, localPlacement_mx * nodeSrc_po.generator.localMatrix)); //Debug.Log("boundingMeshes: " + boundingMeshes.Count); // GAME_OBJECTS if (nodePlugGO != null && makeGameObjects && !parametricObject.combineMeshes) { Matrix4x4 mx = localPlacement_mx * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment; GameObject copyGO = (GameObject)GameObject.Instantiate(nodePlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx)); Vector3 newJitterScale = jitterScale + Vector3.one; copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * newJitterScale.x, copyGO.transform.localScale.y * newJitterScale.y, copyGO.transform.localScale.z * newJitterScale.z); copyGO.transform.localScale += jitterScale; AXGameObject axgo = copyGO.GetComponent <AXGameObject>(); if (axgo != null) { axgo.consumerAddress = this_address; //Debug.Log("ADD ADDRESS: " + this_address); } copyGO.name = copyGO.name + "_" + this_address; //Debug.Log("copyGO.name = "+copyGO.name); copyGO.transform.parent = planGO.transform; } } } } } // \NODE MESHES // CELL NODES - MESHES ALONG SUBSPLINES if (cellSrc_p != null && cellSrc_p.meshes != null) { //int endCount = (P_Plan != null && P_Plan.shapeState == ShapeState.Open) ? planSpline.subsplines.Count-1 : planSpline.subsplines.Count; int endCount = (P_Plan != null && P_Plan.shapeState == ShapeState.Open) ? planSpline.insetSpanSplines.Count - 1 : planSpline.insetSpanSplines.Count; for (int i = 0; i < endCount; i++) { //SubsplineIndices rsi = planSpline.subsplines[i]; Spline spanSpline = planSpline.insetSpanSplines[i]; spanSpline.setRepeaterTransforms(i, inset, bay); List <Matrix4x4> cellMatrices = spanSpline.repeaterCellTransforms; // on each of these cell, place a nodePlug instance. //bool spanNodesAtBreakCorners = true; int starter = 0; //spanNodesAtBreakCorners ? 0 : 1; //int ender = (inset > 0 || spanNodesAtBreakCorners) ? cellMatrices.Count : cellMatrices.Count-1; int ender = cellMatrices.Count; //Debug.Log("(inset > 0 && spanNodesAtBreakCorners)="+(inset > 0 && spanNodesAtBreakCorners)+", nodeMatrices.Length="+nodeMatrices.Length+", starter="+starter+", ender="+ender); string this_address = ""; if (cellMatrices != null) { for (int ii = starter; ii < ender; ii++) { // ADDRESS this_address = "cell_" + path_i + "_" + i + "_" + ii; // LOCAL_PLACEMENT localPlacement_mx = localMatrixFromAddress(RepeaterItem.Cell, path_i, i, ii); // AX_MESHES for (int mi = 0; mi < cellSrc_p.meshes.Count; mi++) { AXMesh dep_amesh = cellSrc_p.meshes [mi]; tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix); tmpMesh.subItemAddress = this_address; ax_meshes.Add(tmpMesh); } // BOUNDING boundingMeshes.Add(new AXMesh(cellSrc_po.boundsMesh, localPlacement_mx * cellSrc_po.generator.localMatrix)); // GAME_OBJECTS if (cellPlugGO != null && makeGameObjects && !parametricObject.combineMeshes) { Matrix4x4 mx = localPlacement_mx * cellSrc_po.generator.localMatrixWithAxisRotationAndAlignment; GameObject copyGO = (GameObject)GameObject.Instantiate(cellPlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx)); Vector3 newJitterScale = jitterScale + Vector3.one; copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * newJitterScale.x, copyGO.transform.localScale.y * newJitterScale.y, copyGO.transform.localScale.z * newJitterScale.z); copyGO.transform.localScale += jitterScale; AXGameObject axgo = copyGO.GetComponent <AXGameObject>(); if (axgo != null) { axgo.consumerAddress = this_address; //Debug.Log("ADD ADDRESS: " + this_address); } copyGO.name = copyGO.name + "_"; // + this_address; //Debug.Log("copyGO.name = "+copyGO.name); copyGO.transform.parent = planGO.transform; } } } } } // \CELL MESHES } // \each spanSpline // BREAK CORNER MESHES if (cornerSrc_p != null && cornerSrc_p.meshes != null) { for (int bi = 0; bi < planSpline.breakIndices.Count; bi++) { // ADDRESS string this_address = "corner_" + path_i + "_" + planSpline.breakIndices[bi]; // LOCAL_PLACEMENT localPlacement_mx = localMatrixFromAddress(RepeaterItem.Corner, path_i, planSpline.breakIndices[bi]); // AX_MESHES for (int mi = 0; mi < cornerSrc_p.meshes.Count; mi++) { AXMesh dep_amesh = cornerSrc_p.meshes [mi]; tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix); tmpMesh.subItemAddress = this_address; ax_meshes.Add(tmpMesh); } // BOUNDING boundingMeshes.Add(new AXMesh(cornerSrc_po.boundsMesh, localPlacement_mx * cornerSrc_po.generator.localMatrix)); // GAME_OBJECTS if (cornerPlugGO != null && makeGameObjects && !parametricObject.combineMeshes) { Matrix4x4 mx = localPlacement_mx * cornerSrc_po.generator.localMatrixWithAxisRotationAndAlignment; GameObject copyGO = (GameObject)GameObject.Instantiate(cornerPlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx)); Vector3 newJitterScale = jitterScale + Vector3.one; copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * newJitterScale.x, copyGO.transform.localScale.y * newJitterScale.y, copyGO.transform.localScale.z * newJitterScale.z); copyGO.transform.localScale += jitterScale; AXGameObject axgo = copyGO.GetComponent <AXGameObject>(); if (axgo != null) { axgo.consumerAddress = this_address; } copyGO.name = copyGO.name + "_" + this_address; copyGO.transform.parent = planGO.transform; } } } /* * int cells = Mathf.CeilToInt( md/bay_U ); * int nby = Mathf.CeilToInt( height/bay_V ); * * //Debug.Log ("d="+d+", md="+md); * * float actual_bayx = md/cells; * float actual_bayy = height/nby; * * // CREATE VERSIONS OF INPUT BAY_CENTER MESH(ES) USING BOUNDING BOX * // ****************************************************************************** * // someting similar shoud be added to griditerator, stepiterator, and where else? * * // instead of prev, would be better to create a dictionary of bounds and AXMeshes? * if (bay_span_p != null && (prevActuralBayx != actual_bayx || prevActuralBayx != actual_bayy)) * { * // regnerate the input meshes using actual_bayx * bay_span_p.Parent.setParameterValueByName("uScale", parametricObject.floatValue("uScale")); * bay_span_p.Parent.setParameterValueByName("vScale", parametricObject.floatValue("vScale")); * bay_span_p.Parent.setParameterValueByName("uShift", parametricObject.floatValue("uShift")); * bay_span_p.Parent.setParameterValueByName("vShift", parametricObject.floatValue("vShift")); * * //bay_span_p.Parent.generateOutputNow (makeGameObjects, parametricObject, true);//, new Vector3(actual_bayx, actual_bayy, margin_th)); * * } * // ****************************************************************************** * * * // CREATE VERSIONS OF INPUT BAY_CENTER MESH(ES) USING BOUNDING BOX * // ****************************************************************************** * // someting similar shoud be added to griditerator, stepiterator, and where else? * * // instead of prev, would be better to create a dictionary of bounds and AXMeshes? * if (node_p != null && (prevActuralBayx != actual_bayx || prevActuralBayx != actual_bayy)) * { * // regnerate the input meshes using actual_bayx * node_p.Parent.setParameterValueByName("uScale", parametricObject.floatValue("uScale")); * node_p.Parent.setParameterValueByName("vScale", parametricObject.floatValue("vScale")); * node_p.Parent.setParameterValueByName("uShift", parametricObject.floatValue("uShift")); * node_p.Parent.setParameterValueByName("vShift", parametricObject.floatValue("vShift")); * * //node_p.Parent.generateOutputNow (makeGameObjects, parametricObject, true);//, new Vector3(actual_bayx, actual_bayy, margin_th)); * * } * // ****************************************************************************** */ //margin_U = .5f; if (margin_U > 0 && planSpline.isClosed) { AXSpline connSpline2 = new AXSpline(); connSpline2.Push(prevVM); connSpline2.Push(prevV); connSpline2.Push(firstPM); connSpline2.isClosed = false; tmpEXSP.uShift = parametricObject.floatValue("uShift") + (runningU) / tmpEXSP.uScale; Mesh mesh = tmpEXSP.generate(connSpline2, secSpline); ax_meshes.Add(new AXMesh(mesh, Matrix4x4.identity, tmp_mat)); } if (makeGameObjects && !parametricObject.combineMeshes) { planGO.transform.parent = go.transform; } } // end paths //GameObject.DestroyImmediate(bay_spanPlugGO); GameObject.DestroyImmediate(cornerPlugGO); GameObject.DestroyImmediate(nodePlugGO); GameObject.DestroyImmediate(cellPlugGO); // FINISH AX_MESHES //Debug.Log("finish " + ax_meshes.Count); parametricObject.finishMultiAXMeshAndOutput(ax_meshes, renderToOutputParameter); // 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); // FINISH GAME_OBJECTS if (makeGameObjects) { if (parametricObject.combineMeshes) { go = parametricObject.makeGameObjectsFromAXMeshes(ax_meshes, true); } Matrix4x4 tmx = parametricObject.getLocalMatrix(); go.transform.rotation = AXUtilities.QuaternionFromMatrix(tmx); go.transform.position = AXUtilities.GetPosition(tmx); go.transform.localScale = parametricObject.getLocalScaleAxisRotated(); //AXUtilities.GetScale(tmx); if (P_Plan.reverse) { P_Plan.doReverse(); } if (P_Section != null && P_Section.reverse) { P_Section.doReverse(); } return(go); } else { // Submit AXMeshes for realtime rendering //parametricObject.finishMultiAXMeshAndOutput(ax_meshes, renderToOutputParameter); //setBoundaryFromMeshes(ax_meshes); } if (P_Plan.reverse) { P_Plan.doReverse(); } if (P_Section != null && P_Section.reverse) { P_Section.doReverse(); } return(null); }
// GENERATE STEP_REPEATER public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool isReplica) { if (parametricObject == null || !parametricObject.isActive) { return(null); } preGenerate(); // NODE_MESH GameObject nodePlugGO = null; if (nodeSrc_p != null) { nodeSrc_po = nodeSrc_p.parametricObject; if (makeGameObjects && !parametricObject.combineMeshes) { nodePlugGO = nodeSrc_po.generator.generate(true, initiator_po, isReplica); } } // CELL_MESH GameObject cellPlugGO = null; if (cellSrc_p != null) { cellSrc_po = cellSrc_p.parametricObject; if (makeGameObjects && !parametricObject.combineMeshes) { cellPlugGO = cellSrc_po.generator.generate(true, initiator_po, isReplica); } } if (nodeSrc_po == null && cellSrc_po == null) { if (P_Output != null) { P_Output.meshes = null; } return(null); } GameObject go = null; if (makeGameObjects && !parametricObject.combineMeshes) { go = ArchimatixUtils.createAXGameObject(parametricObject.Name, parametricObject); } List <AXMesh> ax_meshes = new List <AXMesh>(); Matrix4x4 localPlacement_mx = Matrix4x4.identity; // ----------------------------------- shiftU = 0; //shiftU = (topStep) ? (-steps * actual_tread / 2) : (-(steps-1) * actual_tread / 2); AXMesh tmpMesh; // BOUNDING CombineInstance[] boundsCombinator = new CombineInstance[steps]; // LOOP //Debug.Log(nodeSrc_po.Name + ": " + nodeSrc_po.boundsMesh.vertices.Length); //AXGeometryTools.Utilities for (int i = 0; i < steps; i++) { //Debug.Log("["+i+"] i*actualBay="+i*actualBay+", perval="+perlval); if (i == steps - 1 && !topStep) { break; } // NODES if (nodeSrc_po != null && nodeSrc_p.meshes != null) { string this_address = "node_" + i; // LOCAL_PLACEMENT localPlacement_mx = localMatrixFromAddress(RepeaterItem.Node, i); // AX_MESHES for (int mi = 0; mi < nodeSrc_p.meshes.Count; mi++) { AXMesh dep_amesh = nodeSrc_p.meshes [mi]; tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix); tmpMesh.subItemAddress = this_address; ax_meshes.Add(tmpMesh); } // BOUNDING MESHES boundsCombinator[i].mesh = nodeSrc_po.boundsMesh; boundsCombinator[i].transform = localPlacement_mx * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment; // GAME_OBJECTS if (nodePlugGO != null && makeGameObjects && !parametricObject.combineMeshes) { //Matrix4x4 mx = localPlacement_mx * parametricObject.getTransMatrix() * source.getTransMatrix(); //Debug.Log(nodeSrc_po.getLocalMatrix()); Matrix4x4 mx = localPlacement_mx * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment; GameObject copyGO = (GameObject)GameObject.Instantiate(nodePlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx)); Vector3 newJitterScale = jitterScale + Vector3.one; copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * newJitterScale.x, copyGO.transform.localScale.y * newJitterScale.y, copyGO.transform.localScale.z * newJitterScale.z); copyGO.transform.localScale += jitterScale; #if UNITY_EDITOR //if (parametricObject.model.isSelected(nodeSrc_po) && nodeSrc_po.selectedConsumerAddress == this_address) // Selection.activeGameObject = copyGO; #endif AXGameObject axgo = copyGO.GetComponent <AXGameObject>(); if (axgo != null) { axgo.consumerAddress = this_address; } copyGO.name = copyGO.name + "_" + this_address; copyGO.transform.parent = go.transform; } } // \NODES // CELLS if (cellSrc_po != null && cellSrc_p.meshes != null) { string this_address = "cell_" + i; // LOCAL_PLACEMENT localPlacement_mx = localMatrixFromAddress(RepeaterItem.Cell, i); // AX_MESHES for (int mi = 0; mi < cellSrc_p.meshes.Count; mi++) { AXMesh dep_amesh = cellSrc_p.meshes [mi]; tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix); tmpMesh.subItemAddress = this_address; ax_meshes.Add(tmpMesh); } // BOUNDING MESHES boundsCombinator[i].mesh = cellSrc_po.boundsMesh; boundsCombinator[i].transform = localPlacement_mx * cellSrc_po.generator.localMatrixWithAxisRotationAndAlignment; // GAME_OBJECTS if (cellPlugGO != null && makeGameObjects && !parametricObject.combineMeshes) { //Matrix4x4 mx = localPlacement_mx * parametricObject.getTransMatrix() * source.getTransMatrix(); //Debug.Log(cellSrc_po.getLocalMatrix()); Matrix4x4 mx = localPlacement_mx * cellSrc_po.generator.localMatrixWithAxisRotationAndAlignment; GameObject copyGO = (GameObject)GameObject.Instantiate(cellPlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx)); Vector3 newJitterScale = jitterScale + Vector3.one; copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * newJitterScale.x, copyGO.transform.localScale.y * newJitterScale.y, copyGO.transform.localScale.z * newJitterScale.z); copyGO.transform.localScale += jitterScale; #if UNITY_EDITOR //if (parametricObject.model.isSelected(nodeSrc_po) && nodeSrc_po.selectedConsumerAddress == this_address) // Selection.activeGameObject = copyGO; #endif AXGameObject axgo = copyGO.GetComponent <AXGameObject>(); if (axgo != null) { axgo.consumerAddress = this_address; } copyGO.name = copyGO.name + "_" + this_address; copyGO.transform.parent = go.transform; } } // \CELLS } //i //Debug.Log(parametricObject.Name + " : " + parametricObject.bounds); GameObject.DestroyImmediate(nodePlugGO); GameObject.DestroyImmediate(cellPlugGO); // FINNISH AX_MESHES parametricObject.finishMultiAXMeshAndOutput(ax_meshes, isReplica); // FINISH BOUNDARIES setBoundsWithCombinator(boundsCombinator); // Turn ax_meshes into GameObjects if (makeGameObjects) { if (parametricObject.combineMeshes) { go = parametricObject.makeGameObjectsFromAXMeshes(ax_meshes, true); } Matrix4x4 tmx = parametricObject.getLocalMatrix(); go.transform.rotation = AXUtilities.QuaternionFromMatrix(tmx); go.transform.position = AXUtilities.GetPosition(tmx); go.transform.localScale = parametricObject.getLocalScaleAxisRotated(); //AXUtilities.GetScale(tmx); return(go); } return(null); }
// GENERATE GRID_REPEATER public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool isReplica) { //Debug.Log(parametricObject.Name + " Generate"); if (parametricObject == null || !parametricObject.isActive) { return(null); } if (repeaterToolU == null || repeaterToolV == null) { return(null); } preGenerate(); // NODE_MESH AXParametricObject nodeSrc_po = null; GameObject nodePlugGO = null; if (nodeSrc_p != null) { nodeSrc_po = nodeSrc_p.parametricObject; if (makeGameObjects && !parametricObject.combineMeshes) { nodePlugGO = nodeSrc_po.generator.generate(true, initiator_po, isReplica); } } // CELL_MESH AXParametricObject cellSrc_po = null; GameObject cellPlugGO = null; if (cellSrc_p != null) { cellSrc_po = cellSrc_p.parametricObject; if (makeGameObjects && !parametricObject.combineMeshes) { cellPlugGO = cellSrc_po.generator.generate(true, initiator_po, isReplica); } } // BAY_SPAN_U AXParametricObject spanUSrc_po = null; GameObject spanUPlugGO = null; if (spanUSrc_p != null) { spanUSrc_po = spanUSrc_p.parametricObject; if (makeGameObjects && !parametricObject.combineMeshes) { spanUPlugGO = spanUSrc_po.generator.generate(true, initiator_po, isReplica); } } // BAY_SPAN_V AXParametricObject spanVSrc_po = null; GameObject spanVPlugGO = null; if (spanVSrc_p != null) { spanVSrc_po = spanVSrc_p.parametricObject; if (makeGameObjects && !parametricObject.combineMeshes) { spanVPlugGO = spanVSrc_po.generator.generate(true, initiator_po, isReplica); } } if (nodeSrc_po == null && cellSrc_po == null && spanUSrc_po == null && spanVSrc_po == null) { AXParameter output_p = getPreferredOutputParameter(); if (output_p != null) { output_p.meshes = null; } return(null); } GameObject go = null; if (makeGameObjects && !parametricObject.combineMeshes) { go = ArchimatixUtils.createAXGameObject(parametricObject.Name, parametricObject); } // BOUNDING_SHAPE Paths boundingSolids = null; Paths boundingHoles = null; if (P_BoundingShape != null && P_BoundingShape.DependsOn != null) { AXParameter bounding_src_p = null; if (P_BoundingShape != null) { bounding_src_p = P_BoundingShape.DependsOn; // USING SINGLE SPLINE INPUT } boundingShapeSrc_po = bounding_src_p.parametricObject; AXShape.thickenAndOffset(ref P_BoundingShape, bounding_src_p); // now boundin_p has offset and thickened polytree or paths. boundingSolids = P_BoundingShape.getTransformedSubjPaths(); boundingHoles = P_BoundingShape.getTransformedHolePaths(); } List <AXMesh> ax_meshes = new List <AXMesh>(); Matrix4x4 localPlacement_mx = Matrix4x4.identity; // ----------------------------------- int max_reps = 150; int cellsU = Mathf.Clamp(repeaterToolU.cells, 1, max_reps); float actualBayU = repeaterToolU.actualBay; int cellsV = Mathf.Clamp(repeaterToolV.cells, 1, max_reps); float actualBayV = repeaterToolV.actualBay; shiftU = -cellsU * actualBayU / 2; shiftV = -cellsV * actualBayV / 2; // BAY SPAN // Spanners are meshers that get replicated and sized to fit the bay... // prepare mesh to iterate in each direction //List<AXMesh> ax_meshes_X = new List<AXMesh>(); //List<AXMesh> ax_meshes_Z = new List<AXMesh>(); AXMesh tmpMesh; if (spanUSrc_p != null) { //ax_meshes_X = spanUSrc_p.meshes; //ax_meshes_Z = spanUSrc_p.meshes; } /* NEED TO INTEGRATE THIS BACK IN IN THE FUTRE... * if (bay_span_source != null) * { * * // 1. cache source object * bay_span_source.cacheParameterValues(); * * * // Y_AXIS * * AXParameter p_bayv = parametricObject.getParameter("actual_bay_V"); * AXParameter p_bayv_client = null; * if (p_bayv != null) * { * foreach (AXRelation rel in p_bayv.relations) * { * p_bayv_client = rel.getRelatedTo(p_bayv); * p_bayv_client.intiateRipple_setFloatValueFromGUIChange(abayy); * } * } * * * AXParameter p_bayu = parametricObject.getParameter("actual_bay_U"); * AXParameter p_bayu_client = null; * * // X-AXIS * // For now, only set the boundaries. * // Perhaps later, may want to set other like controls as in Replicant * * // If there is a relation to actual_bay_U, propogate it * if (p_bayu != null) * { * foreach (AXRelation rel in p_bayu.relations) * { * p_bayu_client = rel.getRelatedTo(p_bayu); * p_bayu_client.intiateRipple_setFloatValueFromGUIChange(abayx); * } * } * * //bay_span_source.propagateParameterByBinding(1, bayx); * //bay_span_source.propagateParameterByBinding(2, bayy); * * // 2. re_generate with temporary values set by this Replicant * bay_span_source.generateOutputNow (makeGameObjects, parametricObject); * * // 3. Now that the bay_span_source has been regergrab the meshes from the input sources and add them here * AXParameter output_p = bay_span_source.getParameter("Output Mesh"); * foreach (AXMesh amesh in output_p.meshes) * ax_meshes_X.Add (amesh.Clone(amesh.transMatrix)); * * * * // Z-AXIS * // Use the bayz now to generate x * * if (p_bayu != null) * { * foreach (AXRelation rel in p_bayu.relations) * { * p_bayu_client = rel.getRelatedTo(p_bayu); * p_bayu_client.intiateRipple_setFloatValueFromGUIChange(abayz); * } * } * * //bay_span_source.propagateParameterByBinding(1, bayz); * * * // 2. re_generate with temporary values set by this Replicant * bay_span_source.generateOutputNow (makeGameObjects, parametricObject); * * // 3. Now that the bay_span_source has been regergrab the meshes from the input sources and add them here * foreach (AXMesh amesh in output_p.meshes) * ax_meshes_Z.Add (amesh.Clone(amesh.transMatrix)); * * * // 4. restore source object; as though we were never here! * bay_span_source.revertParametersFromCache(); * * //Debug.Log ("HAVE BAY SPAN -- " + output_p.meshes.Count); * * * } */ /* NEED TO INTEGRATE THIS BACK IN IN THE FUTRE... * if (cell_center_source != null) * { * // Y-AXIS * // For now, only set the boundaries. * // Perhaps later, may want to set other like controls as in Replicant * // 1. cache source object * cell_center_source.cacheParameterValues(); * * * * //bay_center_source.propagateParameterByBinding(1, bayx); * //bay_center_source.propagateParameterByBinding(3, bayz); * * // 2. re_generate with temporary values set by this Replicant * cell_center_source.generateOutputNow (makeGameObjects, parametricObject); * * // 3. Now that the bay_span_source has been regenerted, grab the meshes from the input sources and add them here * AXParameter bc_output_p = cell_center_source.getParameter("Output Mesh"); * foreach (AXMesh amesh in bc_output_p.meshes) * ax_meshes_Y.Add (amesh.Clone(amesh.transMatrix)); * * // 4. restore source object; as though we were never here! * cell_center_source.revertParametersFromCache(); * * } */ // BOUNDING List <AXMesh> boundingMeshes = new List <AXMesh>(); for (int i = 0; i <= cellsU; i++) { for (int k = 0; k <= cellsV; k++) { bool exclude = false; IntPoint ip = new IntPoint((i * actualBayU + shiftU) * AXGeometryTools.Utilities.IntPointPrecision, (k * actualBayV + shiftV) * AXGeometryTools.Utilities.IntPointPrecision); if (boundingSolids != null) { exclude = true; if (boundingSolids != null) { foreach (Path path in boundingSolids) { if (Clipper.PointInPolygon(ip, path) == 1 && Clipper.Orientation(path)) { exclude = false; break; } } } if (boundingHoles != null) { foreach (Path hole in boundingHoles) { if (Clipper.PointInPolygon(ip, hole) == 1) { exclude = true; break; } } } } exclude = (boundingIsVoid) ? !exclude : exclude; if (exclude) { continue; } // NODES if (nodeSrc_po != null && nodeSrc_p.meshes != null && ((i <= repeaterToolU.edgeCount || i >= cellsU - repeaterToolU.edgeCount) || (k <= repeaterToolV.edgeCount || k >= cellsV - repeaterToolV.edgeCount))) { string this_address = "node_" + i + "_" + k; // LOCAL PLACEMENT NODE localPlacement_mx = localNodeMatrixFromAddress(i, k); // AX_MESHES for (int mi = 0; mi < nodeSrc_p.meshes.Count; mi++) { AXMesh dep_amesh = nodeSrc_p.meshes [mi]; tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix); tmpMesh.subItemAddress = this_address; ax_meshes.Add(tmpMesh); } // BOUNDING boundingMeshes.Add(new AXMesh(nodeSrc_po.boundsMesh, localPlacement_mx * nodeSrc_po.generator.localMatrix)); // GAME_OBJECTS if (nodePlugGO != null && makeGameObjects && !parametricObject.combineMeshes) { Matrix4x4 mx = localPlacement_mx * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment; GameObject copyGO = (GameObject)GameObject.Instantiate(nodePlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx)); copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * jitterScale.x, copyGO.transform.localScale.y * jitterScale.y, copyGO.transform.localScale.z * jitterScale.z); #if UNITY_EDITOR //if (parametricObject.model.isSelected(nodeSrc_po) && nodeSrc_po.selectedConsumerAddress == this_address) // Selection.activeGameObject = copyGO; #endif AXGameObject axgo = copyGO.GetComponent <AXGameObject>(); if (axgo != null) { axgo.consumerAddress = this_address; } copyGO.name = copyGO.name + "_" + this_address; copyGO.transform.parent = go.transform; } } // \NODES // CELL CENTERS if (cellSrc_po != null && cellSrc_p.meshes != null && i < cellsU && k < cellsV && ((i < repeaterToolU.edgeCount || i > cellsU - repeaterToolU.edgeCount - 1) || (k < repeaterToolV.edgeCount || k > cellsV - repeaterToolV.edgeCount - 1))) { string this_address = "cell_" + i + "_" + k; // LOCAL PLACEMENT localPlacement_mx = localCellMatrixFromAddress(i, k); // AX_MESHES for (int mi = 0; mi < cellSrc_p.meshes.Count; mi++) { AXMesh dep_amesh = cellSrc_p.meshes [mi]; tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix); tmpMesh.subItemAddress = this_address; ax_meshes.Add(tmpMesh); } // BOUNDING boundingMeshes.Add(new AXMesh(cellSrc_po.boundsMesh, localPlacement_mx * cellSrc_po.generator.localMatrix)); // GAME_OBJECTS if (cellPlugGO != null && makeGameObjects && !parametricObject.combineMeshes) { Matrix4x4 mx = localPlacement_mx * cellSrc_po.generator.localMatrixWithAxisRotationAndAlignment; GameObject copyGO = (GameObject)GameObject.Instantiate(cellPlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx)); copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * jitterScale.x, copyGO.transform.localScale.y * jitterScale.y, copyGO.transform.localScale.z * jitterScale.z); #if UNITY_EDITOR //if (parametricObject.model.isSelected(cellSrc_po) && cellSrc_po.selectedConsumerAddress == this_address) //Selection.activeGameObject = copyGO; #endif AXGameObject axgo = copyGO.GetComponent <AXGameObject>(); if (axgo != null) { axgo.consumerAddress = this_address; } copyGO.name = copyGO.name + "_" + this_address; copyGO.transform.parent = go.transform; } } // SPAN_U if (spanUSrc_po != null && spanUSrc_p.meshes != null && i < cellsU && k <= cellsV && ((i < repeaterToolV.edgeCount || i > cellsU - repeaterToolU.edgeCount - 1) || (k <= repeaterToolV.edgeCount || k > cellsV - repeaterToolV.edgeCount - 1))) { string this_address = "spanU_" + i + "_" + k; // LOCAL PLACEMENT SPAN_U localPlacement_mx = localSpanUMatrixFromAddress(i, k); // AX_MESHES for (int mi = 0; mi < spanUSrc_p.meshes.Count; mi++) { AXMesh dep_amesh = spanUSrc_p.meshes [mi]; tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix); tmpMesh.subItemAddress = this_address; ax_meshes.Add(tmpMesh); } // BOUNDING boundingMeshes.Add(new AXMesh(spanUSrc_po.boundsMesh, localPlacement_mx * spanUSrc_po.generator.localMatrix)); // GAME_OBJECTS if (spanUSrc_po != null && makeGameObjects && !parametricObject.combineMeshes) { Matrix4x4 mx = localPlacement_mx * spanUSrc_po.generator.localMatrixWithAxisRotationAndAlignment; GameObject copyGO = (GameObject)GameObject.Instantiate(spanUPlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx)); copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * jitterScale.x, copyGO.transform.localScale.y * jitterScale.y, copyGO.transform.localScale.z * jitterScale.z); #if UNITY_EDITOR //if (parametricObject.model.isSelected(spanUSrc_po) && spanUSrc_po.selectedConsumerAddress == this_address) // Selection.activeGameObject = copyGO; #endif AXGameObject axgo = copyGO.GetComponent <AXGameObject>(); if (axgo != null) { axgo.consumerAddress = this_address; } copyGO.name = copyGO.name + "_" + this_address; copyGO.transform.parent = go.transform; } } // SPAN_V if (spanVSrc_po != null && spanVSrc_p.meshes != null && i <= cellsU && k < cellsV && ((i <= repeaterToolU.edgeCount || i > cellsU - repeaterToolU.edgeCount - 1) || (k < repeaterToolV.edgeCount || k > cellsV - repeaterToolV.edgeCount - 1))) { string this_address = "spanV_" + i + "_" + k; // LOCAL PLACEMENT SPAN_U localPlacement_mx = localSpanVMatrixFromAddress(i, k); // AX_MESHES for (int mi = 0; mi < spanVSrc_p.meshes.Count; mi++) { AXMesh dep_amesh = spanVSrc_p.meshes [mi]; tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix); tmpMesh.subItemAddress = this_address; ax_meshes.Add(tmpMesh); } // BOUNDING boundingMeshes.Add(new AXMesh(spanVSrc_po.boundsMesh, localPlacement_mx * spanVSrc_po.generator.localMatrix)); // GAME_OBJECTS if (spanVSrc_po != null && makeGameObjects && !parametricObject.combineMeshes) { Matrix4x4 mx = localPlacement_mx * spanVSrc_po.generator.localMatrixWithAxisRotationAndAlignment; GameObject copyGO = (GameObject)GameObject.Instantiate(spanVPlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx)); copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * jitterScale.x, copyGO.transform.localScale.y * jitterScale.y, copyGO.transform.localScale.z * jitterScale.z); #if UNITY_EDITOR //if (parametricObject.model.isSelected(spanVSrc_po) && spanVSrc_po.selectedConsumerAddress == this_address) // Selection.activeGameObject = copyGO; #endif AXGameObject axgo = copyGO.GetComponent <AXGameObject>(); if (axgo != null) { axgo.consumerAddress = this_address; } copyGO.name = copyGO.name + "_" + this_address; copyGO.transform.parent = go.transform; } } } // k } //i GameObject.DestroyImmediate(nodePlugGO); GameObject.DestroyImmediate(cellPlugGO); GameObject.DestroyImmediate(spanUPlugGO); GameObject.DestroyImmediate(spanVPlugGO); // FINISH AX_MESHES 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); // FINISH GAME_OBJECTS if (makeGameObjects) { if (parametricObject.combineMeshes) { go = parametricObject.makeGameObjectsFromAXMeshes(ax_meshes, true); } Matrix4x4 tmx = parametricObject.generator.localMatrixWithAxisRotationAndAlignment; go.transform.rotation = AXUtilities.QuaternionFromMatrix(tmx); go.transform.position = AXUtilities.GetPosition(tmx); go.transform.localScale = parametricObject.getLocalScaleAxisRotated(); return(go); } return(null); }
// GENERATE INSTANCE public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool isReplica) { if (parametricObject == null || !parametricObject.isActive) { return(null); } if (P_Input == null || P_Input.DependsOn == null || P_Input.DependsOn.meshes == null || P_Input.DependsOn.meshes.Count == 0) { return(null); } if (inputSrc_po == null) { inputSrc_po = P_Input.DependsOn.parametricObject; } preGenerate(); GameObject go = null; if (makeGameObjects) { go = inputSrc_po.generator.generate(true, initiator_po, isReplica); if (go == null) { return(null); } go.name = go.name + " (Inst)"; AXGameObject axgo = go.GetComponent <AXGameObject>(); if (axgo != null) { axgo.makerPO_GUID = parametricObject.Guid; } } List <AXMesh> ax_meshes = new List <AXMesh>(); Matrix4x4 srcLocalM = inputSrc_po.getLocalMatrix().inverse; // just pass it through, but use grandparent's transform! // Instance does not inhereit and build on the transform of its source object. // It only uses its mesh, textures, etc. for (int mi = 0; mi < P_Input.DependsOn.meshes.Count; mi++) { AXMesh amesh = P_Input.DependsOn.meshes [mi]; ax_meshes.Add(amesh.Clone(srcLocalM * amesh.transMatrix)); } parametricObject.bounds = inputSrc_po.bounds; parametricObject.boundsMesh = inputSrc_po.boundsMesh; parametricObject.finishMultiAXMeshAndOutput(ax_meshes, isReplica); // Turn ax_meshes into GameObjects if (makeGameObjects) { Matrix4x4 tmx = parametricObject.getLocalMatrix(); go.transform.localScale = AXUtilities.GetScale(tmx); // go.transform.rotation = AXUtilities.QuaternionFromMatrix(tmx); go.transform.position = AXUtilities.GetPosition(tmx); return(go); } return(null); }
// GENERATE LINEAR_REPEATER public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool isReplica) { //Debug.Log("repeaterToolU="+repeaterToolU+", repeaterToolV="+repeaterToolV); if (parametricObject == null || !parametricObject.isActive) { return(null); } if (repeaterTool == null) { return(null); } preGenerate(); // FLOOR_MESH (NODE_MESH) AXParametricObject nodeSrc_po = null; GameObject nodePlugGO = null; //Debug.Log("Get source"); if (nodeSrc_p != null) { nodeSrc_po = nodeSrc_p.parametricObject; if (makeGameObjects && !parametricObject.combineMeshes) { nodePlugGO = nodeSrc_po.generator.generate(true, initiator_po, isReplica); } } // STORY MESH (CELL_MESH) AXParametricObject storySrc_po = null; GameObject storyPlugGO = null; if (storySrc_p != null) { storySrc_po = storySrc_p.parametricObject; if (makeGameObjects && !parametricObject.combineMeshes) { storyPlugGO = storySrc_po.generator.generate(true, initiator_po, isReplica); } } // TOP_FLOOR AXParametricObject topSrc_po = null; GameObject topPlugGO = null; if (topSrc_p != null) { topSrc_po = topSrc_p.parametricObject; if (makeGameObjects && !parametricObject.combineMeshes) { topPlugGO = topSrc_po.generator.generate(true, initiator_po, isReplica); } } // BOTTOM_FLOOR AXParametricObject bottomSrc_po = null; GameObject bottomPlugGO = null; if (bottomSrc_p != null) { bottomSrc_po = bottomSrc_p.parametricObject; if (makeGameObjects && !parametricObject.combineMeshes) { bottomPlugGO = bottomSrc_po.generator.generate(true, initiator_po, isReplica); } } if (nodeSrc_po == null && storySrc_po == null && topSrc_po == null && bottomSrc_po == null) { if (P_Output != null) { P_Output.meshes = null; } return(null); } GameObject go = null; if (makeGameObjects && !parametricObject.combineMeshes) { go = ArchimatixUtils.createAXGameObject(parametricObject.Name, parametricObject); } List <AXMesh> ax_meshes = new List <AXMesh>(); Matrix4x4 localPlacement_mx = Matrix4x4.identity; // ----------------------------------- int max_reps = 150; int cellsU = Mathf.Clamp(repeaterTool.cells, 1, max_reps); float actualBayU = repeaterTool.actualBay; shiftU = -cellsU * actualBayU / 2; AXMesh tmpMesh; // BAY SPAN // Spanners are meshers that get replicated and sized to fit the bay... // prepare mesh to iterate in each direction // BOUNDING int boundingObjectCount = 0; if (nodeSrc_po != null && nodeSrc_p.meshes != null) { boundingObjectCount += cellsU + 1; if (!topFloor) { boundingObjectCount--; } if (!bottomFloor) { boundingObjectCount--; } } if (storySrc_p != null && storySrc_p.meshes != null) { boundingObjectCount += cellsU; if (!topStory) { boundingObjectCount--; } if (!bottomStory) { boundingObjectCount--; } } //Debug.Log(cellsU + " :::::: " + boundingObjectCount); CombineInstance[] boundsCombinator = new CombineInstance[boundingObjectCount]; int boundingCursor = 0; // LOOP for (int i = 0; i <= cellsU; i++) { // FLOORS (NODES) if ((i == 0 && bottomFloor) || (i == cellsU && topFloor) || (i > 0 && i < cellsU)) { AXParameter tmpSrc_p = nodeSrc_p; AXParametricObject tmpSrc_po = nodeSrc_po; GameObject tmpPlugGO = nodePlugGO; if (i == 0 && bottomSrc_p != null) { tmpSrc_p = bottomSrc_p; tmpSrc_po = bottomSrc_po; tmpPlugGO = bottomPlugGO; } else if (i == cellsU && topSrc_p != null) { tmpSrc_p = topSrc_p; tmpSrc_po = topSrc_po; tmpPlugGO = topPlugGO; } if (tmpSrc_po != null && tmpSrc_p.meshes != null) { string this_address = "node_" + i; localPlacement_mx = localNodeMatrixFromAddress(i); // AX_MESHES for (int j = 0; j < tmpSrc_p.meshes.Count; j++) { AXMesh dep_amesh = tmpSrc_p.meshes [j]; tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix); tmpMesh.subItemAddress = this_address; ax_meshes.Add(tmpMesh); } // BOUNDING MESHES boundsCombinator[boundingCursor].mesh = tmpSrc_po.boundsMesh; boundsCombinator[boundingCursor].transform = localPlacement_mx * tmpSrc_po.generator.localMatrixWithAxisRotationAndAlignment; boundingCursor++; // GAME_OBJECTS if (tmpPlugGO != null && makeGameObjects && !parametricObject.combineMeshes) { //Matrix4x4 mx = localPlacement_mx * parametricObject.getTransMatrix() * source.getTransMatrix(); //Debug.Log(nodeSrc_po.getLocalMatrix()); Matrix4x4 mx = localPlacement_mx * tmpSrc_po.generator.localMatrixWithAxisRotationAndAlignment; GameObject copyGO = (GameObject)GameObject.Instantiate(tmpPlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx)); copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * jitterScale.x, copyGO.transform.localScale.y * jitterScale.y, copyGO.transform.localScale.z * jitterScale.z); #if UNITY_EDITOR //if (parametricObject.model.isSelected(tmpSrc_po) && tmpSrc_po.selectedConsumerAddress == this_address) // Selection.activeGameObject = copyGO; #endif AXGameObject axgo = copyGO.GetComponent <AXGameObject>(); if (axgo != null) { axgo.consumerAddress = this_address; } copyGO.name = copyGO.name + "_" + this_address; copyGO.transform.parent = go.transform; } } // \NODES } // STORIES (CELLS) if ((i == 0 && bottomStory) || (i == cellsU - 1 && topStory) || (i > 0 && i < cellsU - 1)) { if (storySrc_p != null && storySrc_p.meshes != null && i < cellsU) { string this_address = "cell_" + i; // LOCAL_PLACEMENT localPlacement_mx = localCellMatrixFromAddress(i); // AX_MESHES for (int j = 0; j < storySrc_p.meshes.Count; j++) { AXMesh dep_amesh = storySrc_p.meshes [j]; tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix); tmpMesh.subItemAddress = this_address; ax_meshes.Add(tmpMesh); } // BOUNDING MESHES if (boundsCombinator.Length > boundingCursor) { boundsCombinator[boundingCursor].mesh = storySrc_po.boundsMesh; boundsCombinator[boundingCursor].transform = localPlacement_mx * storySrc_po.generator.localMatrixWithAxisRotationAndAlignment; boundingCursor++; } // GAME_OBJECTS if (storyPlugGO != null && makeGameObjects && !parametricObject.combineMeshes) { //Matrix4x4 mx = localPlacement_mx * parametricObject.getTransMatrix() * source.getTransMatrix(); Matrix4x4 mx = localPlacement_mx * storySrc_po.generator.localMatrixWithAxisRotationAndAlignment; GameObject copyGO = (GameObject)GameObject.Instantiate(storyPlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx)); AXGameObject axgo = copyGO.GetComponent <AXGameObject>(); if (axgo != null) { axgo.consumerAddress = this_address; } copyGO.name = copyGO.name + "_" + this_address; copyGO.transform.parent = go.transform; } } // \ STORIES (CELLS) } } //i GameObject.DestroyImmediate(nodePlugGO); GameObject.DestroyImmediate(storyPlugGO); GameObject.DestroyImmediate(topPlugGO); GameObject.DestroyImmediate(bottomPlugGO); parametricObject.finishMultiAXMeshAndOutput(ax_meshes, isReplica); setBoundsWithCombinator(boundsCombinator); // Turn ax_meshes into GameObjects if (makeGameObjects) { if (parametricObject.combineMeshes) { go = parametricObject.makeGameObjectsFromAXMeshes(ax_meshes, true); } Matrix4x4 tmx = parametricObject.getLocalMatrix(); go.transform.rotation = AXUtilities.QuaternionFromMatrix(tmx); go.transform.position = AXUtilities.GetPosition(tmx); go.transform.localScale = parametricObject.getLocalScaleAxisRotated(); //AXUtilities.GetScale(tmx); return(go); } return(null); }
// GENERATE REPLICANT public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool renderToOutputParameter) { //Debug.Log ("===> " + parametricObject.Name + " generate"); if (parametricObject == null || !parametricObject.hasInputMeshReady("Input Mesh")) { return(null); } if (!parametricObject.isActive) { return(null); } preGenerate(); AXParameter input_p = parametricObject.getParameter("Input Mesh"); if (parametricObject == null || input_p == null || input_p.DependsOn == null) { return(null); } AXParametricObject src_po = input_p.DependsOn.Parent; if (src_po == null) { return(null); } Matrix4x4 srcLocalM = src_po.getLocalMatrix().inverse; // 1. cache source object List <AXParameter> geometryControlParameterList = parametricObject.getAllParametersOfPType(AXParameter.ParameterType.GeometryControl); src_po.cacheAndSetParameters(geometryControlParameterList); if (!makeGameObjects) { // 2. re_generate source PO with temporary values set by this Replicant src_po.generateOutputNow(false, parametricObject, false); // 3. Now that the input_sourcePO has been regenerated, // grab the temporaryOutputMeshes meshes // from the input sources and add them here List <AXMesh> ax_meshes = new List <AXMesh>(); if (src_po.temporaryOutputMeshes != null) { for (int mi = 0; mi < src_po.temporaryOutputMeshes.Count; mi++) { AXMesh amesh = src_po.temporaryOutputMeshes [mi]; ax_meshes.Add(amesh.Clone(srcLocalM * amesh.transMatrix)); } } parametricObject.finishMultiAXMeshAndOutput(ax_meshes); setBoundaryFromAXMeshes(ax_meshes); } // 4. Make GAME OBJECTS GameObject go = null; if (makeGameObjects) { go = src_po.generator.generate(true, initiator_po, false); go.name = src_po.Name + " Replicant"; AXGameObject axgo = go.GetComponent <AXGameObject>(); if (axgo != null) { axgo.makerPO_GUID = parametricObject.Guid; } } // 5. restore source object; as though we were never here! src_po.revertParametersFromCache(); // Turn ax_meshes into GameObjects if (makeGameObjects) { 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); }
// GENERATE PAIR_REPEATER public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool isReplica) { //Debug.Log ("PairRepeater::Generate "); if (parametricObject == null || !parametricObject.isActive) { return(null); } preGenerate(); if ((nodeSrc_p == null || nodeSrc_p.meshes == null || nodeSrc_p.meshes.Count == 0) && (nodeSrc_po != null && !(nodeSrc_po.generator is PrefabInstancer))) { return(null); } if (P_Node == null || P_Node.DependsOn == null) { return(null); } GameObject go = null; if (makeGameObjects && !parametricObject.combineMeshes) { go = ArchimatixUtils.createAXGameObject(parametricObject.Name, parametricObject); } List <AXMesh> ax_meshes = new List <AXMesh>(); GameObject plugGO = null; if (makeGameObjects && !parametricObject.combineMeshes) { plugGO = nodeSrc_po.generator.generate(true, initiator_po, isReplica); if (plugGO == null) { return(null); } } float separationX = zAxis ? 0 : separation; float separationZ = zAxis ? -separation : 0; CombineInstance[] boundsCombinator = new CombineInstance[2]; // * RIGHT INSTANCE * // -------------------------------------------------------------------- // Right Instance is at Address 0... Matrix4x4 localPlacement_mx = localNodeMatrixFromAddress(0); // use submeshes for right instance // AX_MESHES for (int mi = 0; mi < P_Node.DependsOn.meshes.Count; mi++) { AXMesh dep_amesh = P_Node.DependsOn.meshes [mi]; ax_meshes.Add(dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix)); } // BOUNDING MESHES boundsCombinator[0].mesh = nodeSrc_po.boundsMesh; boundsCombinator[0].transform = localPlacement_mx * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment; // GAME_OBJECTS if (plugGO != null && makeGameObjects && !parametricObject.combineMeshes) { Matrix4x4 mx = localPlacement_mx * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment; GameObject copyGO = (GameObject)GameObject.Instantiate(plugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx)); copyGO.transform.localScale = nodeSrc_po.getLocalScaleAxisRotated(); AXGameObject axgo = copyGO.GetComponent <AXGameObject>(); if (axgo != null) { axgo.consumerAddress = "node_0"; } copyGO.name = copyGO.name + "_node_right"; copyGO.transform.parent = go.transform; } // * INVERSE (LEFT) INSTANCE // -------------------------------------------------------------------- // ***--- AX_MESHES - INVERSE (LEFT) ---*** translate = new Vector3(-separationX / 2, 0, -separationZ / 2); // LOCAL PLACEMENT localPlacement_mx = localNodeMatrixFromAddress(1); // use submeshes for left instance for (int mi = 0; mi < P_Node.DependsOn.meshes.Count; mi++) { // CLONE AXMesh dep_amesh = P_Node.DependsOn.meshes [mi]; AXMesh clone = dep_amesh.Clone(); // SYMETRICAL? if (symmetrical) { clone.mesh = AXMesh.freezeWithMatrix(dep_amesh.mesh, symmetryM * dep_amesh.transMatrix); clone.transMatrix = localPlacement_mx * symmetryM.inverse; } else { clone = dep_amesh.Clone(localPlacement_mx * symmetryM.inverse * dep_amesh.transMatrix); } // ADD TO AX_MESHES ax_meshes.Add(clone); } // BOUNDING MESHES boundsCombinator[1].mesh = nodeSrc_po.boundsMesh; boundsCombinator[1].transform = localPlacement_mx * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment; // *** --- INVERSE (LEFT) - GAME_OBJECT ---** if (plugGO != null && makeGameObjects && !parametricObject.combineMeshes) { // LOCAL PLACEMENT //Matrix4x4 mx = localPlacement_mx * symmetryM * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment; Matrix4x4 mx = localPlacement_mx * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment; // GAME_OBJECT GameObject copyGO = (GameObject)GameObject.Instantiate(plugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx)); copyGO.transform.localScale = nodeSrc_po.getLocalScaleAxisRotated(); // SYMETRICAL? if (symmetrical) { copyGO.transform.localScale = copyGO.transform.localScale * -1; if (zAxis) { copyGO.transform.Rotate(0, 180, 180); } else { copyGO.transform.Rotate(180, 0, 0); } } // Force a refreshing of the colliders down the instatiatined hierachy // Based on a solution provided by pkamat here:http://forum.unity3d.com/threads/how-to-update-a-mesh-collider.32467/ foreach (MeshCollider mc in copyGO.GetComponentsInChildren <MeshCollider>()) { mc.sharedMesh = null; mc.sharedMesh = mc.gameObject.GetComponent <MeshFilter>().sharedMesh; } // ADD GAME_OBJECT AXGameObject axgo = copyGO.GetComponent <AXGameObject>(); if (axgo != null) { axgo.consumerAddress = "node_1"; } copyGO.name = copyGO.name + "_node_left"; copyGO.transform.parent = go.transform; } GameObject.DestroyImmediate(plugGO); // 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); combinedMesh.RecalculateBounds(); // BOUNDARY - Use combined meshes for boundary setBoundsWithCombinator(boundsCombinator); /* * // BOUNDS & CENTER * * Vector3 margin = new Vector3(source_po.bounds.size.x, source_po.bounds.size.y, source_po.bounds.size.z); * Bounds b = new Bounds(); * b.size = new Vector3(separationX + margin.x, margin.y, separationZ + margin.z); * b.extents = b.size/2; * b.center = source_po.bounds.center;// + new Vector3(0, b.extents.y, 0); * * parametricObject.margin = margin; * parametricObject.bounds = b; */ // FINISH parametricObject.finishMultiAXMeshAndOutput(ax_meshes, isReplica); // Turn ax_meshes into GameObjects if (makeGameObjects) { if (parametricObject.combineMeshes) { go = parametricObject.makeGameObjectsFromAXMeshes(ax_meshes, true, false); // 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); } } //Matrix4x4 tmx = parametricObject.generator.localMatrix; 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); }
// GENERATE LINEAR_REPEATER public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool isReplica) { //Debug.Log("repeaterToolU="+repeaterToolU+", repeaterToolV="+repeaterToolV); //Debug.Log("LINEAR REPEATER: Gentrate"); if (parametricObject == null || !parametricObject.isActive) { return(null); } if (repeaterToolU == null && repeaterToolV == null) { return(null); } preGenerate(); repeaterTool = (zAxis) ? repeaterToolV : repeaterToolU; repeaterTool = repeaterToolU; //Terrain terrain = Terrain.activeTerrain; // NODE_MESH AXParametricObject nodeSrc_po = null; GameObject nodePlugGO = null; if (nodeSrc_p != null) { nodeSrc_po = nodeSrc_p.parametricObject; if (makeGameObjects && !parametricObject.combineMeshes) { nodePlugGO = nodeSrc_po.generator.generate(true, initiator_po, isReplica); } } // CELL_MESH AXParametricObject cellSrc_po = null; GameObject cellPlugGO = null; if (cellSrc_p != null) { cellSrc_po = cellSrc_p.parametricObject; if (makeGameObjects && !parametricObject.combineMeshes) { cellPlugGO = cellSrc_po.generator.generate(true, initiator_po, isReplica); } } // BAY_SPAN AXParametricObject spanSrc_po = null; GameObject spanPlugGO = null; if (spanUSrc_p != null) { spanSrc_po = spanUSrc_p.parametricObject; if (makeGameObjects && !parametricObject.combineMeshes) { spanPlugGO = spanSrc_po.generator.generate(true, initiator_po, isReplica); } } if (nodeSrc_po == null && spanSrc_po == null && cellSrc_po == null) { if (P_Output != null) { P_Output.meshes = null; } return(null); } GameObject go = null; if (makeGameObjects && !parametricObject.combineMeshes) { go = ArchimatixUtils.createAXGameObject(parametricObject.Name, parametricObject); } Paths boundingSolids = null; Paths boundingHoles = null; List <AXMesh> ax_meshes = new List <AXMesh>(); Matrix4x4 localPlacement_mx = Matrix4x4.identity; // ----------------------------------- int max_reps = 150; int cellsU = Mathf.Clamp(repeaterTool.cells, 1, max_reps); float actualBayU = repeaterTool.actualBay; if (float.IsNaN(actualBayU)) { return(null); } shiftU = -cellsU * actualBayU / 2; AXMesh tmpMesh; // BAY SPAN // Spanners are meshers that get replicated and sized to fit the bay... // prepare mesh to iterate in each direction List <AXMesh> ax_meshes_X = new List <AXMesh>(); if (spanUSrc_p != null) { ax_meshes_X = spanUSrc_p.meshes; } /* NEED TO INTEGRATE THIS BACK IN IN THE FUTRE... * if (cell_center_source != null) * { * // Y-AXIS * // For now, only set the boundaries. * // Perhaps later, may want to set other like controls as in Replicant * // 1. cache source object * cell_center_source.cacheParameterValues(); * * * * //bay_center_source.propagateParameterByBinding(1, bayx); * //bay_center_source.propagateParameterByBinding(3, bayz); * * // 2. re_generate with temporary values set by this Replicant * cell_center_source.generateOutputNow (makeGameObjects, parametricObject); * * // 3. Now that the bay_span_source has been regenerted, grab the meshes from the input sources and add them here * AXParameter bc_output_p = cell_center_source.getParameter("Output Mesh"); * foreach (AXMesh amesh in bc_output_p.meshes) * ax_meshes_Y.Add (amesh.Clone(amesh.transMatrix)); * * // 4. restore source object; as though we were never here! * cell_center_source.revertParametersFromCache(); * * } */ // BOUNDING int boundingObjectCount = 0; if (nodeSrc_po != null && nodeSrc_p.meshes != null) { boundingObjectCount += cellsU + 1; if (!doFirstNode) { boundingObjectCount--; } if (!doLastNode) { boundingObjectCount--; } } else if (cellSrc_p != null && cellSrc_p.meshes != null) { boundingObjectCount += cellsU; } if (spanUSrc_p != null && spanUSrc_p.meshes != null) { boundingObjectCount += cellsU; } CombineInstance[] boundsCombinator = new CombineInstance[boundingObjectCount]; // FOR EACH ADDRESS for (int i = 0; i <= cellsU; i++) { //Debug.Log("["+i+"] i*actualBay="+i*actualBay+", perval="+perlval); if (boundingSolids != null) { IntPoint ip = new IntPoint((i * repeaterToolU.actualBay + shiftU) * AXGeometryTools.Utilities.IntPointPrecision, 0); bool exclude = true; if (boundingSolids != null) { foreach (Path path in boundingSolids) { if (Clipper.PointInPolygon(ip, path) == 1 && Clipper.Orientation(path)) { exclude = false; break; } } } if (boundingHoles != null) { foreach (Path hole in boundingHoles) { if (Clipper.PointInPolygon(ip, hole) == 1) { exclude = true; break; } } } if (exclude) { continue; } } //Debug.Log(" ** ** ** * " + nodeSrc_p.meshes); // NODES if (nodeSrc_po != null && nodeSrc_p.meshes != null) { // Debug.Log("nodeSrc_po.getLocalAlignMatrix()"+nodeSrc_po.getLocalAlignMatrix()); if ((i > 0 && i < cellsU) || (i == 0 && doFirstNode) || (i == (cellsU) && doLastNode)) { string this_address = "node_" + i; int ni = doFirstNode ? i : i - 1; // LOCAL_PLACEMENT // localPlacement_mx = localNodeMatrixFromAddress(i); if (float.IsNaN(localPlacement_mx.m00)) { continue; } // AX_MESHES for (int mi = 0; mi < nodeSrc_p.meshes.Count; mi++) { AXMesh dep_amesh = nodeSrc_p.meshes [mi]; //tmpMesh = dep_amesh.CloneTransformed (localPlacement_mx * dep_amesh.transMatrix); tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix); tmpMesh.subItemAddress = this_address; ax_meshes.Add(tmpMesh); } // BOUNDING MESHES boundsCombinator[ni].mesh = nodeSrc_po.boundsMesh; boundsCombinator[ni].transform = localPlacement_mx * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment; // GAME_OBJECTS if (nodePlugGO != null && makeGameObjects && !parametricObject.combineMeshes) { //Matrix4x4 mx = localPlacement_mx * parametricObject.getTransMatrix() * source.getTransMatrix(); //Debug.Log(nodeSrc_po.getLocalMatrix()); Matrix4x4 mx = localPlacement_mx * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment; GameObject copyGO = (GameObject)GameObject.Instantiate(nodePlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx)); copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * jitterScale.x, copyGO.transform.localScale.y * jitterScale.y, copyGO.transform.localScale.z * jitterScale.z); AXGameObject axgo = copyGO.GetComponent <AXGameObject>(); if (axgo != null) { axgo.consumerAddress = this_address; } copyGO.name = copyGO.name + "_" + this_address; copyGO.transform.parent = go.transform; } } } // \NODES // CELL CENTERS if (cellSrc_p != null && cellSrc_p.meshes != null && i < cellsU) { string this_address = "cell_" + i; //Debug.Log("Here"); // LOCAL_PLACEMENT localPlacement_mx = localCellMatrixFromAddress(i); // ACTUAL MESHES for (int mi = 0; mi < cellSrc_p.meshes.Count; mi++) { AXMesh dep_amesh = cellSrc_p.meshes [mi]; tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix); tmpMesh.subItemAddress = this_address; ax_meshes.Add(tmpMesh); } // BOUNDING MESHES boundsCombinator[i].mesh = cellSrc_po.boundsMesh; boundsCombinator[i].transform = localPlacement_mx * cellSrc_po.generator.localMatrixWithAxisRotationAndAlignment;; // GAME_OBJECTS if (cellPlugGO != null && makeGameObjects && !parametricObject.combineMeshes) { //Matrix4x4 mx = localPlacement_mx * parametricObject.getTransMatrix() * source.getTransMatrix(); Matrix4x4 mx = localPlacement_mx * cellSrc_po.generator.localMatrixWithAxisRotationAndAlignment; GameObject copyGO = (GameObject)GameObject.Instantiate(cellPlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx)); copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * jitterScale.x, copyGO.transform.localScale.y * jitterScale.y, copyGO.transform.localScale.z * jitterScale.z); AXGameObject axgo = copyGO.GetComponent <AXGameObject>(); if (axgo != null) { axgo.consumerAddress = this_address; } copyGO.name = copyGO.name + "_" + this_address; copyGO.transform.parent = go.transform; //Debug.Log("LINEAR: " + axgo.consumerAddress); } } // \CELLS // SPANS if (spanUSrc_p != null && spanUSrc_p.meshes != null && i < cellsU) { string this_address = "spanU_" + i; // X-AXIS // LOCAL_PLACEMENT localPlacement_mx = localCellMatrixFromAddress(i); // AX_MESHES // AX_MESHES for (int mi = 0; mi < ax_meshes_X.Count; mi++) { AXMesh dep_amesh = ax_meshes_X [mi]; tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix); tmpMesh.subItemAddress = this_address; ax_meshes.Add(tmpMesh); } // BOUNDING MESHES boundsCombinator[i].mesh = spanUSrc_po.boundsMesh; boundsCombinator[i].transform = localPlacement_mx * spanUSrc_po.generator.localMatrixWithAxisRotationAndAlignment; // GAME_OBJECTS if (spanPlugGO != null && makeGameObjects && !parametricObject.combineMeshes) { Matrix4x4 mx = localPlacement_mx * spanSrc_po.generator.localMatrixWithAxisRotationAndAlignment; GameObject copyGO = (GameObject)GameObject.Instantiate(spanPlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx)); copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * jitterScale.x, copyGO.transform.localScale.y * jitterScale.y, copyGO.transform.localScale.z * jitterScale.z); AXGameObject axgo = copyGO.GetComponent <AXGameObject>(); if (axgo != null) { axgo.consumerAddress = this_address; } copyGO.name = copyGO.name + "_" + this_address; copyGO.transform.parent = go.transform; } } // \SPANS } //i GameObject.DestroyImmediate(nodePlugGO); GameObject.DestroyImmediate(cellPlugGO); GameObject.DestroyImmediate(spanPlugGO); parametricObject.finishMultiAXMeshAndOutput(ax_meshes, isReplica); setBoundsWithCombinator(boundsCombinator); // Turn ax_meshes into GameObjects if (makeGameObjects) { if (parametricObject.combineMeshes) { go = parametricObject.makeGameObjectsFromAXMeshes(ax_meshes, true); } Matrix4x4 tmx = parametricObject.getLocalMatrix(); go.transform.rotation = AXUtilities.QuaternionFromMatrix(tmx); go.transform.position = AXUtilities.GetPosition(tmx); go.transform.localScale = parametricObject.getLocalScaleAxisRotated(); //AXUtilities.GetScale(tmx); return(go); } return(null); }