public override List <RepresentationMesh> PlaceRepresentations(Ensemble ensemble, Abstraction abstraction, GameObject compositionGameObject) { List <RepresentationMesh> resultMesh = new List <RepresentationMesh> (); List <Structure> resultStructures = new List <Structure> (); this.ensemble = ensemble; List <KeyValuePair <string, float> > paramsValues = new List <KeyValuePair <string, float> > (); for (int i = 0; i < axisParameters.Count; i++) { paramsValues.Add(new KeyValuePair <string, float>(axisParameters[i].name, axisParameters[i].value)); } ParameterInfo xPI = ensemble.parametersInfo [axisParameters [0].name]; double xDelta = (xPI.maxValue - xPI.minValue) / (float)(xPI.count - 1); ParameterInfo yPI = ensemble.parametersInfo [axisParameters [1].name]; double yDelta = (yPI.maxValue - yPI.minValue) / (float)(yPI.count - 1); ParameterInfo zPI = ensemble.parametersInfo [axisParameters [2].name]; double zDelta = (zPI.maxValue - zPI.minValue) / (float)(zPI.count - 1); for (double i = xPI.minValue; i <= xPI.maxValue; i += xDelta) { for (double j = yPI.minValue; j <= yPI.maxValue; j += yDelta) { for (double k = zPI.minValue; k <= zPI.maxValue; k += zDelta) { paramsValues[0] = new KeyValuePair <string, float>(paramsValues[0].Key, (float)i); paramsValues[1] = new KeyValuePair <string, float>(paramsValues[1].Key, (float)j); paramsValues[2] = new KeyValuePair <string, float>(paramsValues[2].Key, (float)k); resultStructures.Add(ensemble.GetStructure(paramsValues)); } } } Camera cam = Camera.main; //yPosStart -= itemSizeY / 2f; float val = 0; List <GameObject> gObjects = new List <GameObject> (); foreach (Structure structure in resultStructures) { (structure.representation as RepresentationMesh).gameObject.SetActive(true); RepresentationMesh newRep = abstraction.Process(structure.representation as RepresentationMesh) as RepresentationMesh; (structure.representation as RepresentationMesh).gameObject.SetActive(false); newRep.gameObject.transform.parent = compositionGameObject.transform; newRep.gameObject.AddComponent <StructureProperties> (); newRep.gameObject.GetComponent <StructureProperties> ().size = newRep.size; newRep.gameObject.GetComponent <StructureProperties> ().offset = newRep.offset; float valZ = Mathf.Floor(val / (dimSize * dimSizeY)); float vaal = (float)(val % (dimSize * dimSizeY)); float valY = (float)(vaal % dimSizeY); float valX = Mathf.Floor(vaal / dimSizeY); valX = 4 - valX; newRep.gameObject.transform.position = new Vector3( xPosStart + valX * (itemSizeX + itemOffset), yPosStart + valY * (itemSizeY + itemOffset) - 345, /*valZ * -20f*/ 0); val++; switch (type) { case SPType.None: { break; } case SPType.Transparent: { newRep.SetMaterialTransparency(0.20f); break; } case SPType.Colorify: { float zVal = valZ * (1f / (zPI.count - 1)); Color zColor = Color.white; if (zVal <= 0.5f) { zColor = new Color(1f, zVal * 2f, zVal * 2f); } else { zColor = new Color(2f - 2f * zVal, 2f - 2f * zVal, 1f); } //zColor = colors[(int)valZ]; newRep.SetMaterialColor(zColor); break; } case SPType.BlendColor: { float zVal = valZ / zPI.count; Color zColor = Color.white; if (zVal <= 0.5f) { zColor = new Color(1f, zVal * 2f, zVal * 2f); } else { zColor = new Color(2f - 2f * zVal, 2f - 2f * zVal, 1f); } newRep.BlendMaterialColor(zColor); break; } case SPType.ColorTransparent: { float zVal = valZ / (zPI.count - 1); Color zColor = Color.white; if (zVal <= 0.5f) { zColor = new Color(1f, zVal * 2f, zVal * 2f); } else { zColor = new Color(2f - 2f * zVal, 2f - 2f * zVal, 1f); } newRep.SetMaterialColorTransparency(zColor, 0.15f); break; } default: { newRep.SetMaterialTransparency(0.20f); break; } } gObjects.Add(newRep.gameObject); } ReorderEverything(gObjects); // X slider GameObject uiGO = GameObject.Find("UI") as GameObject; GameObject xPanel = uiGO.transform.Find("X Axis Panel").gameObject; GameObject xSliderGO = xPanel.transform.Find("Slider").gameObject; xSliderGO.SetActive(true); Slider xSlider = xSliderGO.GetComponent <Slider> (); xSlider.minValue = xPI.minValue; xSlider.maxValue = xPI.maxValue; xSlider.value = xPI.minValue; xSlider.onValueChanged.RemoveAllListeners(); xSlider.onValueChanged.AddListener(CameraPositionChangedX); cameraXEndPos = xPosStart + ((float)xPI.count - 0.5f) * itemSizeX + ((float)xPI.count - 1f) * itemOffset - cam.orthographicSize + camOffset; // Y slider GameObject yPanel = uiGO.transform.Find("Y Axis Panel").gameObject; GameObject ySliderGO = yPanel.transform.Find("Slider").gameObject; ySliderGO.SetActive(true); Slider ySlider = ySliderGO.GetComponent <Slider> (); ySlider.minValue = yPI.minValue; ySlider.maxValue = yPI.maxValue; ySlider.value = yPI.minValue; ySlider.onValueChanged.RemoveAllListeners(); ySlider.onValueChanged.AddListener(CameraPositionChangedY); cameraYEndPos = yPosStart + ((float)yPI.count) * itemSizeY + ((float)yPI.count - 1f) * itemOffset - cam.orthographicSize + camOffset; cam.transform.position = new Vector3(0, 0, 300f); cam.transform.rotation = Quaternion.Euler(new Vector3(0, 180f, 0)); return(resultMesh); }
public override List <RepresentationMesh> PlaceRepresentations(Ensemble ensemble, Abstraction abstraction, GameObject compositionGameObject) { List <RepresentationMesh> resultMesh = new List <RepresentationMesh> (); List <Structure> resultStructures = new List <Structure> (); this.ensemble = ensemble; List <KeyValuePair <string, float> > paramsValues = new List <KeyValuePair <string, float> > (); for (int i = 0; i < axisParameters.Count; i++) { paramsValues.Add(new KeyValuePair <string, float>(axisParameters[i].name, axisParameters[i].value)); } ParameterInfo xPI = ensemble.parametersInfo [axisParameters [0].name]; float xDelta = (xPI.maxValue - xPI.minValue) / (float)(xPI.count - 1); ParameterInfo zPI = ensemble.parametersInfo [axisParameters [1].name]; float zDelta = (zPI.maxValue - zPI.minValue) / (float)(zPI.count - 1); List <float> xDeltas = new List <float> (); for (float i = xPI.minValue; i <= xPI.maxValue; i += xDelta) { xDeltas.Add(i); } if (xDeltas.Count > dimSizeX) { int diffCount = xDeltas.Count - dimSizeX; for (int i = 0; i < diffCount; i++) { xDeltas.RemoveAt(Random.Range(0, xDeltas.Count - 1)); } } List <float> zDeltas = new List <float> (); for (float i = zPI.minValue; i <= zPI.maxValue; i += zDelta) { zDeltas.Add(i); } foreach (float xValue in xDeltas) { foreach (float zValue in zDeltas) { paramsValues[0] = new KeyValuePair <string, float>(paramsValues[0].Key, xValue); paramsValues[1] = new KeyValuePair <string, float>(paramsValues[1].Key, zValue); resultStructures.Add(ensemble.GetStructure(paramsValues)); } } Camera cam = Camera.main; yPosStart = cam.gameObject.transform.position.y - cam.orthographicSize / 2f + (float)camOffset; int val = 0; if (abstraction.GetType() == typeof(AbstractionScale1D)) { xPosStart += itemSizeX / 2f; } foreach (Structure structure in resultStructures) { (structure.representation as RepresentationMesh).gameObject.SetActive(true); RepresentationMesh newRep = abstraction.Process(structure.representation as RepresentationMesh) as RepresentationMesh; (structure.representation as RepresentationMesh).gameObject.SetActive(false); newRep.gameObject.transform.parent = compositionGameObject.transform; float valX = (float)(val / dimSizeZ); float valZ = (float)(val % dimSizeZ); newRep.gameObject.transform.parent = compositionGameObject.transform; newRep.gameObject.transform.position = new Vector3(xPosStart + valX * (itemSizeX + itemOffset) + newRep.offset.x, yPosStart, zPosStart + valZ); val++; switch (type) { case SPType.None: { break; } case SPType.Transparent: { newRep.SetMaterialTransparency(0.25f); break; } case SPType.Colorify: { float zVal = valZ / zPI.count; Color zColor = Color.white; if (zVal <= 0.5f) { zColor = new Color(1f, zVal * 2f, zVal * 2f); } else { zColor = new Color(2f - 2f * zVal, 2f - 2f * zVal, 1f); } newRep.SetMaterialColor(zColor); break; } case SPType.BlendColor: { float zVal = valZ / zPI.count; Color zColor = Color.white; if (zVal <= 0.5f) { zColor = new Color(1f, zVal * 2f, zVal * 2f); } else { zColor = new Color(2f - 2f * zVal, 2f - 2f * zVal, 1f); } newRep.BlendMaterialColor(zColor); break; } case SPType.ColorTransparent: { float zVal = valZ / zPI.count; Color zColor = Color.white; if (zVal <= 0.5f) { zColor = new Color(1f, zVal * 2f, zVal * 2f); } else { zColor = new Color(2f - 2f * zVal, 2f - 2f * zVal, 1f); } newRep.SetMaterialColorTransparency(zColor, 0.25f); break; } default: { newRep.SetMaterialTransparency(0.25f); break; } } } GameObject uiGO = GameObject.Find("UI") as GameObject; GameObject xPanel = uiGO.transform.Find("X Axis Panel").gameObject; GameObject sliderGO = xPanel.transform.Find("Slider").gameObject; sliderGO.SetActive(true); Slider slider = sliderGO.GetComponent <Slider> (); slider.minValue = xPI.minValue; slider.maxValue = xPI.maxValue; slider.value = xPI.minValue; slider.onValueChanged.RemoveAllListeners(); slider.onValueChanged.AddListener(CameraPositionChanged); cameraXEndPos = xPosStart + ((float)xPI.count - 0.5f) * itemSizeX + ((float)xPI.count - 1f) * itemOffset - cam.orthographicSize + camOffset; return(resultMesh); }
public override List <RepresentationMesh> PlaceRepresentations(Ensemble ensemble, Abstraction abstraction, GameObject compositionGameObject) { List <RepresentationMesh> resultMesh = new List <RepresentationMesh> (); List <Structure> resultStructures = new List <Structure> (); this.ensemble = ensemble; List <KeyValuePair <string, float> > paramsValues = new List <KeyValuePair <string, float> > (); for (int i = 0; i < axisParameters.Count; i++) { paramsValues.Add(new KeyValuePair <string, float>(axisParameters[i].name, axisParameters[i].value)); } ParameterInfo zPI = ensemble.parametersInfo [axisParameters [0].name]; float zDelta = (zPI.maxValue - zPI.minValue) / (float)(zPI.count - 1); for (float i = zPI.minValue; i <= zPI.maxValue; i += zDelta) { paramsValues[0] = new KeyValuePair <string, float>(paramsValues[0].Key, i); resultStructures.Add(ensemble.GetStructure(paramsValues)); } Camera cam = Camera.main; yPosStart = cam.gameObject.transform.position.y - cam.orthographicSize; /* * float xPosStart = cam.gameObject.transform.position.x; * float yPosStart = cam.gameObject.transform.position.y - cam.orthographicSize; * float zPosStart = 0; */ foreach (Structure structure in resultStructures) { (structure.representation as RepresentationMesh).gameObject.SetActive(true); RepresentationMesh newRep = abstraction.Process(structure.representation as RepresentationMesh) as RepresentationMesh; (structure.representation as RepresentationMesh).gameObject.SetActive(false); newRep.gameObject.transform.parent = compositionGameObject.transform; float valZ = (structure.parameters [axisParameters[0].name].value - zPI.minValue) / zDelta; newRep.gameObject.transform.position = new Vector3(xPosStart, yPosStart, zPosStart + valZ * (itemSizeZ + itemOffset)); switch (type) { case SPType.None: { break; } case SPType.Transparent: { newRep.SetMaterialTransparency(0.25f); break; } case SPType.Colorify: { float zVal = valZ / zPI.count; Color zColor = Color.white; if (zVal <= 0.5f) { zColor = new Color(1f, zVal * 2f, zVal * 2f); } else { zColor = new Color(2f - 2f * zVal, 2f - 2f * zVal, 1f); } newRep.SetMaterialColor(zColor); break; } case SPType.BlendColor: { float zVal = valZ / zPI.count; Color zColor = Color.white; if (zVal <= 0.5f) { zColor = new Color(1f, zVal * 2f, zVal * 2f); } else { zColor = new Color(2f - 2f * zVal, 2f - 2f * zVal, 1f); } newRep.BlendMaterialColor(zColor); break; } case SPType.ColorTransparent: { float zVal = valZ / zPI.count; Color zColor = Color.white; if (zVal <= 0.5f) { zColor = new Color(1f, zVal * 2f, zVal * 2f); } else { zColor = new Color(2f - 2f * zVal, 2f - 2f * zVal, 1f); } newRep.SetMaterialColorTransparency(zColor, 0.25f); break; } default: { newRep.SetMaterialTransparency(0.25f); break; } } } Vector3 target = new Vector3(xPosStart, yPosStart, zPosStart + (zPI.count / 2) * (itemSizeZ + itemOffset)); Camera.main.gameObject.GetComponent <MouseCameraControl> ().yaw.target = target; Camera.main.gameObject.GetComponent <MouseCameraControl> ().pitch.target = target; return(resultMesh); }
public override List <RepresentationMesh> PlaceRepresentations(Ensemble ensemble, Abstraction abstraction, GameObject compositionGameObject) { List <RepresentationMesh> resultMesh = new List <RepresentationMesh> (); List <Structure> resultStructures = new List <Structure> (); this.ensemble = ensemble; List <KeyValuePair <string, float> > paramsValues = new List <KeyValuePair <string, float> > (); for (int i = 0; i < axisParameters.Count; i++) { paramsValues.Add(new KeyValuePair <string, float> (axisParameters [i].name, axisParameters [i].value)); } ParameterInfo xPI = ensemble.parametersInfo [axisParameters [0].name]; float xDelta = (xPI.maxValue - xPI.minValue) / (float)(xPI.count - 1); ParameterInfo yPI = ensemble.parametersInfo [axisParameters [1].name]; float yDelta = (yPI.maxValue - yPI.minValue) / (float)(yPI.count - 1); List <float> xDeltas = new List <float> (); for (float i = xPI.minValue; i <= xPI.maxValue; i += xDelta) { xDeltas.Add(i); } if (xDeltas.Count > dimSizeX) { int diffCount = xDeltas.Count - dimSizeX; for (int i = 0; i < diffCount; i++) { xDeltas.RemoveAt(Random.Range(0, xDeltas.Count - 1)); } } List <float> yDeltas = new List <float> (); for (float i = yPI.minValue; i <= yPI.maxValue; i += yDelta) { yDeltas.Add(i); } if (yDeltas.Count > dimSizeY) { int diffCount = yDeltas.Count - dimSizeY; for (int i = 0; i < diffCount; i++) { yDeltas.RemoveAt(Random.Range(0, yDeltas.Count - 1)); } } foreach (float xValue in xDeltas) { foreach (float yValue in yDeltas) { paramsValues[0] = new KeyValuePair <string, float>(paramsValues[0].Key, xValue); paramsValues[1] = new KeyValuePair <string, float>(paramsValues[1].Key, yValue); resultStructures.Add(ensemble.GetStructure(paramsValues)); } } yPosStart -= itemSizeY / 2f; int val = 0; foreach (Structure structure in resultStructures) { (structure.representation as RepresentationMesh).gameObject.SetActive(true); RepresentationMesh newRep = abstraction.Process(structure.representation as RepresentationMesh) as RepresentationMesh; (structure.representation as RepresentationMesh).gameObject.SetActive(false); newRep.gameObject.transform.parent = compositionGameObject.transform; float valX = (float)(val / dimSizeY); float valY = (float)(val % dimSizeY); newRep.gameObject.transform.position = new Vector3( xPosStart + valX * (itemSizeX + itemOffset) + newRep.offset.x, yPosStart + valY * (itemSizeY + itemOffset), 0); val++; } return(resultMesh); }
public override List <RepresentationMesh> PlaceRepresentations(Ensemble ensemble, Abstraction abstraction, GameObject compositionGameObject) { List <RepresentationMesh> resultMesh = new List <RepresentationMesh> (); List <Structure> resultStructures = new List <Structure> (); this.ensemble = ensemble; List <KeyValuePair <string, float> > paramsValues = new List <KeyValuePair <string, float> > (); for (int i = 0; i < axisParameters.Count; i++) { paramsValues.Add(new KeyValuePair <string, float>(axisParameters[i].name, axisParameters[i].value)); } ParameterInfo pi = ensemble.parametersInfo [axisParameters [0].name]; float xDelta = (pi.maxValue - pi.minValue) / (float)(pi.count - 1); List <float> xDeltas = new List <float> (); for (float i = pi.minValue; i <= pi.maxValue; i += xDelta) { xDeltas.Add(i); } if (xDeltas.Count > itemCount) { int diffCount = xDeltas.Count - itemCount; for (int i = 0; i < diffCount; i++) { xDeltas.RemoveAt(Random.Range(0, xDeltas.Count - 1)); } } foreach (float value in xDeltas) { paramsValues[0] = new KeyValuePair <string, float>(paramsValues[0].Key, value); resultStructures.Add(ensemble.GetStructure(paramsValues)); } Camera cam = Camera.main; yPosStart = cam.gameObject.transform.position.y - cam.orthographicSize + (float)camOffset; int val = 0; foreach (Structure structure in resultStructures) { (structure.representation as RepresentationMesh).gameObject.SetActive(true); RepresentationMesh newRep = abstraction.Process(structure.representation as RepresentationMesh) as RepresentationMesh; (structure.representation as RepresentationMesh).gameObject.SetActive(false); newRep.gameObject.transform.parent = compositionGameObject.transform; newRep.gameObject.transform.position = new Vector3(xPosStart + val * (itemSizeX + itemOffset) + newRep.offset.x, yPosStart, 0); val++; } GameObject uiGO = GameObject.Find("UI") as GameObject; GameObject xPanel = uiGO.transform.Find("X Axis Panel").gameObject; GameObject sliderGO = xPanel.transform.Find("Slider").gameObject; sliderGO.SetActive(true); Slider slider = sliderGO.GetComponent <Slider> (); slider.minValue = pi.minValue; slider.maxValue = pi.maxValue; slider.value = pi.minValue; slider.onValueChanged.RemoveAllListeners(); slider.onValueChanged.AddListener(CameraPositionChanged); cameraXEndPos = xPosStart + ((float)resultStructures.Count - 0.5f) * itemSizeX + ((float)resultStructures.Count - 1f) * itemOffset - cam.orthographicSize + camOffset; cam.transform.position = new Vector3(0, yPosStart / 2f, -300f); return(resultMesh); }