public void ShowDebugGrid() { for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { debugArray[x, y] = TextCreator.CreateWorldText(gridArray[x, y]?.ToString(), null, GetWorldPositionInMiddleOfCellSize(x, y), 20, Color.white, TextAnchor.MiddleCenter); Debug.DrawLine(GetWorldPosition(x, y), GetWorldPosition(x + 1, y), Color.white, 100f); Debug.DrawLine(GetWorldPosition(x, y), GetWorldPosition(x, y + 1), Color.white, 100f); } } Debug.DrawLine(GetWorldPosition(0, height), GetWorldPosition(width, height), Color.white, 100f); Debug.DrawLine(GetWorldPosition(width, 0), GetWorldPosition(width, height), Color.white, 100f); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { GridObject g = grid.GetGridObject(MouseUtils.GetMousePosition3D()); } if (Input.GetMouseButtonDown(1)) { Vector3 mousePos = MouseUtils.GetMousePosition3D(); if (mousePos.magnitude != 0) { TextCreator.CreatePopupText(mousePos.ToString(), 10, 1, null, mousePos, Camera.main); } } }
private void OnEnable() { _tc = (Canvas)target; _tcObject = _tc.gameObject; _childs = _tcObject.gameObject.GetComponentInChildren <Transform>(); _textField = GetPref("TextField"); _trueTextField = GetPref("TrueText"); // find the sentencebutton in order to set the text. foreach (Transform t in _childs) { if (t.name == "SentenceButton") { _textCreator = t.gameObject.GetComponent <TextCreator>(); } } }
private void CreateAndPrintText() { pictureBox1.Refresh(); var font1 = new Font("Times New Roman", 36f, FontStyle.Italic); var font2 = new Font("Magneto", 24f, FontStyle.Bold); var font3 = new Font("Cambria", 48f, FontStyle.Regular); var horizontalFactory = new HorizontalTextFactory(); var verticalFactory = new VerticalTextFactory(); var textCreator = new TextCreator(); texts.AddRange(textCreator.Create(horizontalFactory, "Hello world", font1, StringAlignment.Near, 6)); texts.AddRange(textCreator.Create(verticalFactory, "Hello world", font2, StringAlignment.Far, 5)); texts.AddRange(textCreator.Create(horizontalFactory, "Hello world", font3, StringAlignment.Center, 1)); this.printService.DrawText(pictureBox1.CreateGraphics(), texts, startPoint); }
private void ShowTweets(ArrayList collectedTweets) { foreach (TweetSearchTwitterData tweet in collectedTweets) { if (!tweet.InScreen) { GameObject tweetRenderer = Instantiate(tweetprefab); TextCreator textCreator = tweetRenderer.GetComponent <TextCreator>(); Vector3 pos = Random.insideUnitSphere; tweetRenderer.transform.position = pos; tweet.InScreen = true; textCreator.onNewTex(tweet); //Transform target = tweetRenderer.transform.Find("target"); //cam.moveTo(target); //cam.lookAt(tweetRenderer.transform); //return; } } }
//function that calls for text to appear if you press e on a function with the //textcreator script void Interact() { RaycastHit objectInfo; if (Physics.Raycast(camera.transform.position, camera.transform.forward, out objectInfo, range)) { TextCreator book = objectInfo.transform.GetComponent <TextCreator>(); nullText nullText = objectInfo.transform.GetComponent <nullText>(); BagOne firstB = objectInfo.transform.GetComponent <BagOne>(); BagTwo secondB = objectInfo.transform.GetComponent <BagTwo>(); if (book != null && canRead) { canRead = false; canRead = book.CreateText(gameObject); } if (nullText != null && canRead) { canRead = false; inNull = true; nullText.CreateText(); } if (firstB != null) { bag1.SetActive(false); } if (secondB != null && bag2.GetComponent <MeshRenderer>().enabled == false) { bag2.GetComponent <MeshRenderer>().enabled = !bag2.GetComponent <MeshRenderer>().enabled; } } }
private Model3D CreateModel() { var plotModel = new Model3DGroup(); int rows = Points.GetUpperBound(0) + 1; int columns = Points.GetUpperBound(1) + 1; double minX = double.MaxValue; double maxX = double.MinValue; double minY = double.MaxValue; double maxY = double.MinValue; double minZ = double.MaxValue; double maxZ = double.MinValue; double minColorValue = double.MaxValue; double maxColorValue = double.MinValue; for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { double x = Points[i, j].X; double y = Points[i, j].Y; double z = Points[i, j].Z; maxX = Math.Max(maxX, x); maxY = Math.Max(maxY, y); maxZ = Math.Max(maxZ, z); minX = Math.Min(minX, x); minY = Math.Min(minY, y); minZ = Math.Min(minZ, z); if (ColorValues != null) { maxColorValue = Math.Max(maxColorValue, ColorValues[i, j]); minColorValue = Math.Min(minColorValue, ColorValues[i, j]); } } } // make color value 0 at texture coordinate 0.5 if (Math.Abs(minColorValue) < Math.Abs(maxColorValue)) { minColorValue = -maxColorValue; } else { maxColorValue = -minColorValue; } // set the texture coordinates by z-value or ColorValue var texcoords = new Point[rows, columns]; for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { double u = (Points[i, j].Z - minZ) / (maxZ - minZ); if (ColorValues != null) { u = (ColorValues[i, j] - minColorValue) / (maxColorValue - minColorValue); } texcoords[i, j] = new Point(u, u); } } var surfaceMeshBuilder = new MeshBuilder(); surfaceMeshBuilder.AddRectangularMesh(Points, texcoords); var surfaceModel = new GeometryModel3D(surfaceMeshBuilder.ToMesh(), MaterialHelper.CreateMaterial(SurfaceBrush, null, null, 1, 0)); surfaceModel.BackMaterial = surfaceModel.Material; var axesMeshBuilder = new MeshBuilder(); for (double x = minX; x <= maxX; x += IntervalX) { double j = (x - minX) / (maxX - minX) * (columns - 1); var path = new List <Point3D> { new Point3D(x + 0.00001, minY, minZ) }; // + 0.0001 to avoid ZoomExtens bug if any geometry has for (int i = 0; i < rows; i++) { path.Add(BilinearInterpolation(Points, i, j)); } path.Add(new Point3D(x, maxY, minZ)); axesMeshBuilder.AddTube(path, LineThickness, 4, false); GeometryModel3D label = TextCreator.CreateTextLabelModel3D(x.ToString(), Brushes.Black, true, FontSize, new Point3D(x, minY - FontSize * 2.5, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("X-axis", Brushes.Black, true, FontSize, new Point3D((minX + maxX) * 0.5, minY - FontSize * 6, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } for (double y = minY; y <= maxY; y += IntervalY) { double i = (y - minY) / (maxY - minY) * (rows - 1); var path = new List <Point3D> { new Point3D(minX, y + 0.00001, minZ) }; for (int j = 0; j < columns; j++) { path.Add(BilinearInterpolation(Points, i, j)); } path.Add(new Point3D(maxX, y, minZ)); axesMeshBuilder.AddTube(path, LineThickness, 4, false); GeometryModel3D label = TextCreator.CreateTextLabelModel3D(y.ToString(), Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 3, y, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Y-axis", Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 10, (minY + maxY) * 0.5, minZ), new Vector3D(0, 1, 0), new Vector3D(-1, 0, 0)); plotModel.Children.Add(label); } double z0 = (int)(minZ / IntervalZ) * IntervalZ; for (double z = z0; z <= maxZ + double.Epsilon; z += IntervalZ) { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(z.ToString(), Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 3, maxY, z), new Vector3D(1, 0, 0), new Vector3D(0, 0, 1)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Z-axis", Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 10, maxY, (minZ + maxZ) * 0.5), new Vector3D(0, 0, 1), new Vector3D(1, 0, 0)); plotModel.Children.Add(label); } var bb = new Rect3D(minX, minY, minZ, maxX - minX, maxY - minY, 0 * (maxZ - minZ)); axesMeshBuilder.AddBoundingBox(bb, LineThickness); var axesModel = new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.Black); plotModel.Children.Add(surfaceModel); plotModel.Children.Add(axesModel); return(plotModel); }
private Model3D CreateModel() { var plotModel = new Model3DGroup(); if (Points == null || Values == null) { return(plotModel); } double minX = Points.Min(p => p.X); double maxX = Points.Max(p => p.X); double minY = Points.Min(p => p.Y); double maxY = Points.Max(p => p.Y); double minZ = Points.Min(p => p.Z); double maxZ = Points.Max(p => p.Z); double minValue = Values.Min(); double maxValue = Values.Max(); var valueRange = maxValue - minValue; var scatterMeshBuilder = new MeshBuilder(true, true); var oldTCCount = 0; for (var i = 0; i < Points.Length; ++i) { scatterMeshBuilder.AddSphere(Points[i], SphereSize, 4, 4); var u = (Values[i] - minValue) / valueRange; var newTCCount = scatterMeshBuilder.TextureCoordinates.Count; for (var j = oldTCCount; j < newTCCount; ++j) { scatterMeshBuilder.TextureCoordinates[j] = new Point(u, u); } oldTCCount = newTCCount; } var scatterModel = new GeometryModel3D(scatterMeshBuilder.ToMesh(), MaterialHelper.CreateMaterial(SurfaceBrush, null, null, 1, 0)); scatterModel.BackMaterial = scatterModel.Material; // create bounding box with axes indications var axesMeshBuilder = new MeshBuilder(); for (double x = minX; x <= maxX; x += IntervalX) { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(x.ToString(), Brushes.Black, true, FontSize, new Point3D(x, minY - FontSize * 2.5, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("X-axis", Brushes.Black, true, FontSize, new Point3D((minX + maxX) * 0.5, minY - FontSize * 6, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } for (double y = minY; y <= maxY; y += IntervalY) { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(y.ToString(), Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 3, y, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Y-axis", Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 10, (minY + maxY) * 0.5, minZ), new Vector3D(0, 1, 0), new Vector3D(-1, 0, 0)); plotModel.Children.Add(label); } double z0 = (int)(minZ / IntervalZ) * IntervalZ; for (double z = z0; z <= maxZ + double.Epsilon; z += IntervalZ) { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(z.ToString(), Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 3, maxY, z), new Vector3D(1, 0, 0), new Vector3D(0, 0, 1)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Z-axis", Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 10, maxY, (minZ + maxZ) * 0.5), new Vector3D(0, 0, 1), new Vector3D(1, 0, 0)); plotModel.Children.Add(label); } var bb = new Rect3D(minX, minY, minZ, maxX - minX, maxY - minY, maxZ - minZ); axesMeshBuilder.AddBoundingBox(bb, LineThickness); var axesModel = new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.Black); plotModel.Children.Add(scatterModel); plotModel.Children.Add(axesModel); return(plotModel); }
private Model3D CreateModel() { var viewport = this.GetViewport3D(); var plotModel = new Model3DGroup(); var Children = plotModel.Children; plotModel.Children = null; int rows = Points.GetUpperBound(0) + 1; int columns = Points.GetUpperBound(1) + 1; double minX = double.MaxValue; double maxX = double.MinValue; double minY = double.MaxValue; double maxY = double.MinValue; double minZ = double.MaxValue; double maxZ = double.MinValue; double minColorValue = double.MaxValue; double maxColorValue = double.MinValue; for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { double x = Points[i, j].X; double y = Points[i, j].Y; double z = Points[i, j].Z; if (x == 0 && y == 0 && z == 0) { continue; } maxX = Math.Max(maxX, x); maxY = Math.Max(maxY, y); maxZ = Math.Max(maxZ, z); minX = Math.Min(minX, x); minY = Math.Min(minY, y); minZ = Math.Min(minZ, z); if (ColorValues != null) { maxColorValue = Math.Max(maxColorValue, ColorValues[i, j]); minColorValue = Math.Min(minColorValue, ColorValues[i, j]); } } } IntervalX = (maxX - minX) / 6.0; IntervalY = (maxY - minY) / 6.0; IntervalZ = (maxZ - minZ) / 1.0; FontSize = 0.03; var FontScale = 1; LineThickness = 0.005; // make color value 0 at texture coordinate 0.5 if (Math.Abs(minColorValue) < Math.Abs(maxColorValue)) { minColorValue = -maxColorValue; } else { maxColorValue = -minColorValue; } // set the texture coordinates by z-value or ColorValue var texcoords = new Point[rows, columns]; for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { double u = (Points[i, j].Z - minZ) / (maxZ - minZ); if (ColorValues != null) { u = (ColorValues[i, j] - minColorValue) / (maxColorValue - minColorValue); } texcoords[i, j] = new Point(u, u); } } if (rows == 1 || columns == 1) { var surfaceMeshBuilder = new MeshBuilder(); var pointList = new List <Point3D>(); var texturePoints = new List <double>(); var diameters = new List <double>(); for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { pointList.Add(Points[i, j]); texturePoints.Add(texcoords[i, j].X); diameters.Add(LineThickness * 2.0); } } surfaceMeshBuilder.AddTube(pointList, texturePoints.ToArray(), diameters.ToArray(), 9, false, true, true); var mesh = surfaceMeshBuilder.ToMesh(); var surfaceModel = new GeometryModel3D(mesh, MaterialHelper.CreateMaterial(SurfaceBrush, null, null, 1, 0)); surfaceModel.BackMaterial = surfaceModel.Material; Children.Add(surfaceModel); } else { var vertexZMapping = new Dictionary <Vertex, double>(); var vertices = new List <Vertex>(); for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { if (Points[i, j].X == 0.0 && Points[i, j].Y == 0.0 && Points[i, j].Z == 0.0) { continue; } var vertex = new Vertex(Points[i, j].X, Points[i, j].Y); vertices.Add(vertex); vertexZMapping[vertex] = Points[i, j].Z; } } var mesh = DelaunayTriangulation <Vertex, Cell> .Create(vertices, 1e-10); foreach (var cell in mesh.Cells) { // 3D-ify it. var min = cell.Vertices.Min(vertex => vertexZMapping[vertex]); var max = cell.Vertices.Max(vertex => vertexZMapping[vertex]); var minPercentile = (min - minZ) / (maxZ - minZ); var maxPercentile = (max - minZ) / (maxZ - minZ); var minR = Math.Round(255.0 * (1 - 0.3 * minPercentile)); var minG = Math.Round(255.0 * (minPercentile)); var minB = Math.Round(255.0 * (Math.Abs(0.5 - minPercentile) * 2)); var maxR = Math.Round(255.0 * (1 - 0.3 * maxPercentile)); var maxG = Math.Round(255.0 * (maxPercentile)); var maxB = Math.Round(255.0 * (Math.Abs(0.5 - maxPercentile) * 2)); var minColor = Color.FromArgb((byte)255, (byte)minR, (byte)minG, (byte)minB); var maxColor = Color.FromArgb((byte)255, (byte)maxR, (byte)maxG, (byte)maxB); Children.Add(cell.Visual.CreateModel(new Point3DCollection(cell.Vertices.Select(vertex => { var vertexPoint = vertex.ToPoint(); return(new Point3D(vertexPoint.X, vertexPoint.Y, vertexZMapping[vertex])); })), minColor, maxColor)); } } //2 Stat //x=stat=x*total //y=stat2=y*total //3 Stat //x=stat1=x*total //y_1=stat2=(-x*total-y*total)/2 //y_2=stat3=y*total+(-x*total-y*total)/2 var axesMeshBuilder = new MeshBuilder(); for (double x = minX; x <= maxX; x += IntervalX) { double j = (x - minX) / (maxX - minX) * (columns - 1); var path = new List <Point3D> { new Point3D(x, minY, minZ) }; path.Add(new Point3D(x, maxY, minZ)); axesMeshBuilder.AddTube(path, LineThickness, 9, false, true, true); var labelString = (x * ResultsData.ShrinkingFactor).ToString("F4"); if (StatCount == 2 || StatCount == 3) { labelString = (x * Total).ToString("F0"); } GeometryModel3D label = TextCreator.CreateTextLabelModel3D(labelString, Brushes.Black, true, FontSize, new Point3D(x, minY - FontSize * 6, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); label.Transform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), -90.0), new Point3D(label.Bounds.SizeX / 2 + label.Bounds.Location.X, label.Bounds.SizeY / 2 + label.Bounds.Location.Y, 0.0)); Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(XAxisName, Brushes.Black, true, FontSize, new Point3D((minX + maxX) * 0.5, minY - FontSize * 12, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); Children.Add(label); } for (double y = minY; y <= maxY; y += IntervalY) { double i = (y - minY) / (maxY - minY) * (rows - 1); var path = new List <Point3D> { new Point3D(minX, y, minZ) }; path.Add(new Point3D(maxX, y, minZ)); axesMeshBuilder.AddTube(path, LineThickness, 9, false, true, true); var labelString = (y * ResultsData.ShrinkingFactor).ToString("F4"); if (StatCount == 2) { labelString = (y * Total).ToString("F0"); } GeometryModel3D label = TextCreator.CreateTextLabelModel3D(labelString, Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 4, y, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(YAxisName, Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 10, (minY + maxY) * 0.5, minZ), new Vector3D(0, 1, 0), new Vector3D(-1, 0, 0)); label.Transform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), 180.0), new Point3D(label.Bounds.SizeX / 2 + label.Bounds.Location.X, label.Bounds.SizeY / 2 + label.Bounds.Location.Y, 0.0)); Children.Add(label); } //double z0 = (int)(minZ / IntervalZ) * IntervalZ; var zTrans = IntervalZ / 3; for (double z = minZ; z <= maxZ + double.Epsilon; z += IntervalZ) { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(z.ToString("F4"), Brushes.Black, true, FontSize / FontScale, new Point3D(minX - FontSize * 4, maxY + .015, z), new Vector3D(1, 0, 0), new Vector3D(0, 0, 1)); label.Transform = new TranslateTransform3D(new Vector3D(0, 0, zTrans)); Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(ZAxisName, Brushes.Black, true, FontSize / FontScale, new Point3D(minX - FontSize * 10, maxY + .015, (minZ + maxZ) * 0.5), new Vector3D(0, 0, 1), new Vector3D(1, 0, 0)); label.Transform = new TranslateTransform3D(new Vector3D(0, 0, IntervalZ)); Children.Add(label); } var bb = new Rect3D(minX, minY, minZ, maxX - minX, maxY - minY, 0 * (maxZ - minZ)); axesMeshBuilder.AddBoundingBox(bb, LineThickness); var axesModel = new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.Black); Children.Add(axesModel); plotModel.Children = Children; return(plotModel); }
private IEnumerator SplitPrintPage(TextMeshProUGUI bodyText, Tab currentTab, int caseNumber, bool loading) { yield return(new WaitForSeconds(.1f)); TMP_WordInfo[] richTextWords = bodyText.textInfo.wordInfo; string plainText = Regex.Replace(bodyText.text, @"(?></?\w+)(?>(?:[^>'""]+|'[^']*'|""[^""]*"")*)>", ""); bodyText.text = plainText; bodyText.ForceMeshUpdate(); if (bodyText.text.Length > bodyText.textInfo.lineInfo[bodyText.textInfo.lineCount - 1].lastCharacterIndex + 1) { Debug.Log("Splitting Printed Page for " + bodyText.name, bodyText.gameObject); TextCreator originalTextCreator = bodyText.GetComponent <TextCreator>(); string[] lastLineWords = new string[0]; int offSet = 1; while (lastLineWords.Length < 5) { int plainBreakStartIndex = bodyText.textInfo.lineInfo[bodyText.textInfo.lineCount - offSet].firstCharacterIndex; int plainBreakEndIndex = bodyText.textInfo.lineInfo[bodyText.textInfo.lineCount - offSet].lastCharacterIndex; string lastLine = bodyText.text.Substring(plainBreakStartIndex, plainBreakEndIndex - plainBreakStartIndex); lastLineWords = lastLine.Split(new [] { ',', '.', '!', ' ', '?' }, StringSplitOptions.RemoveEmptyEntries); offSet++; } List <string> richTextWordList = new List <string>(); foreach (var word in richTextWords) { if (word.characterCount > 0) { richTextWordList.Add(word.GetWord()); } } int counter = 0; int index = 0; foreach (var word in richTextWordList) { if (word == lastLineWords[counter]) { counter++; if (counter == lastLineWords.Length - 1) { break; } } else { counter = 0; } index++; } int firstCharOfRichTextFirstWordInLastLineIndex = richTextWords[index - counter].firstCharacterIndex; string[] splitRefText = originalTextCreator.discrepancyField.Split('|'); string[] splitTrueText = originalTextCreator.textfield.Split('|'); int refTextIndex = 0; int refTextBreakIndex = -1; for (int i = 0; i < splitRefText.Length; i++) { refTextIndex += Regex.Replace(splitRefText[i], @"(?></?\w+)(?>(?:[^>'""]+|'[^']*'|""[^""]*"")*)>", "").Length; if (firstCharOfRichTextFirstWordInLastLineIndex > refTextIndex) { refTextBreakIndex = i - 1; } } string pageOneRefText = ""; string pageTwoRefText = ""; string pageOneTrueText = ""; string pageTwoTrueText = ""; for (int i = 0; i < splitRefText.Length; i++) { if (i <= refTextBreakIndex) { pageOneRefText += splitRefText[i] + '|'; pageOneTrueText += splitTrueText[i] + '|'; } else { pageTwoRefText += splitRefText[i] + '|'; pageTwoTrueText += splitTrueText[i] + '|'; } } GameObject newPageTwo = Instantiate(_printPagePrefabs[1], _initialPrintLocation.position, _initialPrintLocation.rotation); TextCreator newTextCreator = newPageTwo.GetComponentInChildren <TextCreator>(); originalTextCreator.discrepancyField = pageOneRefText; originalTextCreator.textfield = pageOneTrueText; originalTextCreator.SetAnswers(originalTextCreator.discrepancyField); newTextCreator.discrepancyField = pageTwoRefText; newTextCreator.textfield = pageTwoTrueText; newTextCreator.SetAnswers(newTextCreator.discrepancyField); newPageTwo.GetComponent <PrintPage>().caseNumber = caseNumber; currentTab.SetTabID(); newPageTwo.GetComponent <PrintPage>().caseFileId = currentTab.tabId; bodyText.text = pageOneRefText.Replace("|", ""); newTextCreator.GetComponent <TextMeshProUGUI>().text = pageTwoRefText.Replace("|", ""); if (loading) { foreach (var tc in newPageTwo.GetComponentsInChildren <TextCreator>()) { tc.clickText.enabled = true; } newPageTwo.GetComponent <PrintPage>().FileCase(); } else { yield return(new WaitForSeconds(_printWaypoints.Length * _timePerPrintStep)); StartCoroutine(PrintByWaypoints(newPageTwo)); } } }
private Model3D CreateModel() { // if (Points ==null) var plotModel = new Model3DGroup(); int rows = Points.GetUpperBound(0) + 1; int columns = Points.GetUpperBound(1) + 1; double minX = double.MaxValue; double maxX = double.MinValue; double minY = double.MaxValue; double maxY = double.MinValue; double minZ = double.MaxValue; double maxZ = double.MinValue; //double RealminX = double.MaxValue; //double RealmaxX = double.MinValue; //double RealminY = double.MaxValue; //double RealmaxY = double.MinValue; //double RealminZ = double.MaxValue; //double RealmaxZ = double.MinValue; #region Color things double minColorValue = double.MaxValue; double maxColorValue = double.MinValue; for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { double x = Points[i, j].X; double y = Points[i, j].Y; double z = Points[i, j].Z; maxX = Math.Max(maxX, x); maxY = Math.Max(maxY, y); maxZ = Math.Max(maxZ, z); minX = Math.Min(minX, x); minY = Math.Min(minY, y); minZ = Math.Min(minZ, z); if (ColorValues != null) { maxColorValue = Math.Max(maxColorValue, ColorValues[i, j]); minColorValue = Math.Min(minColorValue, ColorValues[i, j]); } } } // make color value 0 at texture coordinate 0.5 if (Math.Abs(minColorValue) < Math.Abs(maxColorValue)) { minColorValue = -maxColorValue; } else { maxColorValue = -minColorValue; } #endregion // set the texture coordinates by z-value or ColorValue var texcoords = new Point[rows, columns]; if (OriginalData == null || ColorCoding != ComplexPlainVisualizer.ColorCoding.Custom) { for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { double u = (Points[i, j].Z - minZ) / (maxZ - minZ); //double v = if (ColorValues != null) { u = (ColorValues[i, j] - minColorValue) / (maxColorValue - minColorValue); } texcoords[i, j] = new Point(u, u); } } } else { for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { double u = MathUtil.Scale(minZ, maxZ, Math.Log10(OriginalData[i, j].Z), 0.5); double v = OriginalData[i, j].W; double uu = 0.5 + u * Math.Cos(v); double vv = 0.5 + u * Math.Sin(v); texcoords[i, j] = new Point(uu, vv); } } } if (AutoScale) { ScaleX = 10 / Math.Abs(maxX - minX); ScaleY = 10 / Math.Abs(maxY - minY); ScaleZ = 5 / Math.Abs(maxZ - minZ); } var surfaceMeshBuilder = new MeshBuilder(); surfaceMeshBuilder.AddRectangularMesh(Points, texcoords); surfaceMeshBuilder.Scale(ScaleX, ScaleY, ScaleZ); var surfaceModel = new GeometryModel3D(surfaceMeshBuilder.ToMesh(), MaterialHelper.CreateMaterial(SurfaceBrush, null, null, 1, 0)); surfaceModel.BackMaterial = surfaceModel.Material; //RealmaxX = maxX; //RealminX = minX; //RealmaxY = maxY; //RealminY = minY; //RealmaxZ = maxZ; //RealminZ = minZ; maxX *= ScaleX; minX *= ScaleX; maxY *= ScaleY; minY *= ScaleY; maxZ *= ScaleZ; minZ *= ScaleZ; IntervalX = (maxX - minX) / SubAxisCount; IntervalY = (maxY - minY) / SubAxisCount; IntervalZ = (maxZ - minZ) / SubAxisCount; #region eje x var axesMeshBuilder = new MeshBuilder(); for (double x = minX; x <= maxX; x += IntervalX) { double j = (x - minX) / (maxX - minX) * (columns - 1); //var path = new List<Point3D> { new Point3D(x , minY , minZ) }; var path = new List <Point3D> { new Point3D(x, minY, minZ) }; for (int i = 0; i < rows; i++) { Point3D p = BilinearInterpolation(Points, i, j); p.X *= ScaleX; p.Y *= ScaleY; p.Z *= ScaleZ; path.Add(p); } path.Add(new Point3D(x, maxY, minZ)); axesMeshBuilder.AddTube(path, LineThickness, 9, false); GeometryModel3D label = TextCreator.CreateTextLabelModel3D(StringUtils.CodeString(x / ScaleX), Brushes.Black, true, FontSize, new Point3D(x, minY - FontSize * 2.5, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("X-axis", Brushes.Black, true, FontSize, new Point3D((minX + maxX) * 0.5, minY - FontSize * 6, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } #endregion #region eje y for (double y = minY; y <= maxY; y += IntervalY) { double i = (y - minY) / (maxY - minY) * (rows - 1); var path = new List <Point3D> { new Point3D(minX, y, minZ) }; for (int j = 0; j < columns; j++) { Point3D p = BilinearInterpolation(Points, i, j); p.X *= ScaleX; p.Y *= ScaleY; p.Z *= ScaleZ; path.Add(p); } path.Add(new Point3D(maxX, y, minZ)); axesMeshBuilder.AddTube(path, LineThickness, 9, false); GeometryModel3D label = TextCreator.CreateTextLabelModel3D(StringUtils.CodeString(y / ScaleY), Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 3, y, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Y-axis", Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 10, (minY + maxY) * 0.5, minZ), new Vector3D(0, 1, 0), new Vector3D(-1, 0, 0)); plotModel.Children.Add(label); } #endregion #region eje z double z0 = (int)(minZ / IntervalZ) * IntervalZ; for (double z = z0; z <= maxZ + double.Epsilon; z += IntervalZ) { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(StringUtils.CodeString(z / ScaleZ), Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 3, maxY, z), new Vector3D(1, 0, 0), new Vector3D(0, 0, 1)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Z-axis", Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 10, maxY, (minZ + maxZ) * 0.5), new Vector3D(0, 0, 1), new Vector3D(1, 0, 0)); plotModel.Children.Add(label); } #endregion var bb = new Rect3D(minX, minY, minZ, maxX - minX, maxY - minY, 0 * (maxZ - minZ)); axesMeshBuilder.AddBoundingBox(bb, LineThickness); var axesModel = new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.Black); plotModel.Children.Add(surfaceModel); plotModel.Children.Add(axesModel); return(plotModel); }
private void OnEnable() { _textCreator = target as TextCreator; }