public void LinkVisualisations() { View pv = GetComponentInChildren <View>(); if (pv != null) { DestroyImmediate(pv.gameObject); } ViewBuilder viewLinked; Vector3[] vSource = visualisationSource.theVisualizationObject.viewList[0].GetPositions(); // bigMesh.getBigMeshVertices(); Vector3[] vDest = visualisationTarget.theVisualizationObject.viewList[0].GetPositions(); // bigMesh.getBigMeshVertices(); List <Color> colors = new List <Color>(); Color[] cSource = visualisationSource.theVisualizationObject.viewList[0].GetColors(); // bigMesh.getColors(); Color[] cDest = visualisationTarget.theVisualizationObject.viewList[0].GetColors(); // bigMesh.getColors(); List <Vector3> vertexBuffer = new List <Vector3>(); List <int> indexBuffer = new List <int>(); List <float> positionsLocalX = new List <float>(); List <float> positionsLocalY = new List <float>(); List <float> positionsLocalZ = new List <float>(); List <Vector3> normalsBuffer = new List <Vector3>(); for (int i = 0; i < vSource.Length; i++) { positionsLocalX.Add((vSource[i]).x); positionsLocalX.Add((vDest[i]).x); positionsLocalY.Add((vSource[i]).y); positionsLocalY.Add((vDest[i]).y); positionsLocalZ.Add((vSource[i]).z); positionsLocalZ.Add((vDest[i]).z); colors.Add(cSource[i]); colors.Add(cDest[i]); normalsBuffer.Add(new Vector3((float)i, 0, 0)); normalsBuffer.Add(new Vector3((float)i, 0, 1)); } for (int i = 0; i < positionsLocalX.Count; i += 2) { indexBuffer.Add(i); indexBuffer.Add(i + 1); } viewLinked = new ViewBuilder(MeshTopology.Lines, "Linked Visualisation"); viewLinked.initialiseDataView(positionsLocalX.Count); viewLinked.setDataDimension(positionsLocalX.ToArray(), ViewBuilder.VIEW_DIMENSION.X); viewLinked.setDataDimension(positionsLocalY.ToArray(), ViewBuilder.VIEW_DIMENSION.Y); viewLinked.setDataDimension(positionsLocalZ.ToArray(), ViewBuilder.VIEW_DIMENSION.Z); viewLinked.Indices = indexBuffer; viewLinked.updateView(); view = viewLinked.apply(this.gameObject, linkerMaterial); view.SetColors(colors.ToArray()); view.SetAllChannels(normalsBuffer.ToArray()); view.RecalculateBounds(); transform.position = Vector3.zero; GetComponentInChildren <View>().transform.position = Vector3.zero; }
public override void CreateVisualisation() { if (visualisationReference.parallelCoordinatesDimensions.Length > 1 && visualisationReference.parallelCoordinatesDimensions.None(x => x == null || x.Attribute == "Undefined")) { viewList.Clear(); destroyView(); ViewBuilder viewParallel; List <float> positionsLocalX = new List <float>(); List <float> positionsLocalY = new List <float>(); List <float> positionsLocalZ = new List <float>(); List <int> indices = new List <int>(); for (int i = 0; i < visualisationReference.parallelCoordinatesDimensions.Length; i++) { if (visualisationReference.parallelCoordinatesDimensions[i] != null && visualisationReference.parallelCoordinatesDimensions[i].Attribute != "Undefined") { float[] positions = visualisationReference.dataSource[visualisationReference.parallelCoordinatesDimensions[i].Attribute].Data; for (int k = 0; k < positions.Length; k++) { positionsLocalX.Add((float)GameObject_Axes_Holders[i].transform.localPosition.x); positionsLocalY.Add(positions[k] + (float)GameObject_Axes_Holders[i].transform.localPosition.y); positionsLocalZ.Add((float)GameObject_Axes_Holders[i].transform.localPosition.z); } } } //build indices for (int i = 0; i < visualisationReference.dataSource.DataCount; i++) { for (int j = 0; j < visualisationReference.parallelCoordinatesDimensions.Length - 1; j++) { indices.Add(j * visualisationReference.dataSource.DataCount + i); indices.Add((j + 1) * visualisationReference.dataSource.DataCount + i); } } int[] lineLength = new int[visualisationReference.dataSource.DataCount]; for (int i = 0; i < visualisationReference.dataSource.DataCount; i++) { lineLength[i] = visualisationReference.parallelCoordinatesDimensions.Length; } viewParallel = new ViewBuilder(MeshTopology.Lines, "parallel coordinates"); viewParallel.initialiseDataView(positionsLocalX.Count); viewParallel.setDataDimension(positionsLocalX.ToArray(), ViewBuilder.VIEW_DIMENSION.X); viewParallel.setDataDimension(positionsLocalY.ToArray(), ViewBuilder.VIEW_DIMENSION.Y); viewParallel.setDataDimension(positionsLocalZ.ToArray(), ViewBuilder.VIEW_DIMENSION.Z); viewParallel.Indices = indices; viewParallel.LineLength = lineLength.ToList(); Material mt = new Material(Shader.Find("IATK/PCPShader")); mt.renderQueue = 3000; viewParallel.updateView(); View v = viewParallel.apply(gameObject, mt); viewList.Add(v); //Creation configuration management if (creationConfiguration == null) { creationConfiguration = new CreationConfiguration(); } creationConfiguration.VisualisationType = AbstractVisualisation.VisualisationTypes.PARALLEL_COORDINATES; creationConfiguration.parallelCoordinatesDimensions = visualisationReference.parallelCoordinatesDimensions; creationConfiguration.colour = visualisationReference.colour; creationConfiguration.ColourDimension = visualisationReference.colourDimension; creationConfiguration.colourKeys = visualisationReference.dimensionColour; creationConfiguration.Geometry = visualisationReference.geometry; creationConfiguration.LinkingDimension = visualisationReference.linkingDimension; creationConfiguration.SizeDimension = visualisationReference.sizeDimension; creationConfiguration.Axies = new Dictionary <CreationConfiguration.Axis, string>(); //restore properties UpdateVisualisation(AbstractVisualisation.PropertyType.Colour); UpdateVisualisation(AbstractVisualisation.PropertyType.Size); UpdateVisualisation(AbstractVisualisation.PropertyType.SizeValues); } }