public override void PrepareFrame(DPIStatus status) { if (!Visible) { return; } base.PrepareFrame(status); foreach (var area in SubAreas) { area.PrepareFrame(status); } }
public ThreeDimCabDPI(Viewer viewer, int iMatrix, string size, string aceFile, PoseableShape trainCarShape, CabViewControlRenderer c) // : base(viewer, iMatrix, size, aceFile, trainCarShape, c) { Size = int.Parse(size) * 0.001f;//input size is in mm if (aceFile != "") { AceFile = aceFile.ToUpper(); if (!AceFile.EndsWith(".ACE")) { AceFile = AceFile + ".ACE"; //need to add ace into it } } else { AceFile = ""; } CVFR = (DistributedPowerInterfaceRenderer)c; DPITable = CVFR.DPI.DPDefaultWindow.DPITable; DPIStatus = CVFR.DPI.DPIStatus; Viewer = viewer; TrainCarShape = trainCarShape; XNAMatrix = TrainCarShape.SharedShape.Matrices[iMatrix]; // 9 rows, 5 columns plus first one; first one has a couple of triangles for the whole string, // the other ones have a couple of triangles for each char, and there are max 7 chars per string; // this leads to 1944 vertices var maxVertex = 2048; //Material = viewer.MaterialManager.Load("Scenery", Helpers.GetRouteTextureFile(viewer.Simulator, Helpers.TextureFlags.None, texture), (int)(SceneryMaterialOptions.None | SceneryMaterialOptions.AlphaBlendingBlend), 0); Material = FindMaterial(false); //determine normal material // Create and populate a new ShapePrimitive NumVertices = NumIndices = 0; VertexList = new VertexPositionNormalTexture[maxVertex]; TriangleListIndices = new short[maxVertex / 2 * 3]; // as is NumIndices //start position is the center of the text var start = new Vector3(0, 0, 0); var rotation = 0; //find the left-most of text Vector3 offset; offset.X = 0; offset.Y = -Size; var param = new string(' ', MaxDigits); var color = ColorYellow; var headerIndex = 0; float tX, tY; Matrix rot; for (int iRow = 0; iRow < DPITable.NumberOfRowsFull; iRow++) { // fill with blanks at startup tX = 0.875f; tY = 0.125f; //the left-bottom vertex Vector3 v = new Vector3(offset.X, offset.Y, 0.01f); v += start; Vertex v1 = new Vertex(v.X, v.Y, v.Z, 0, 0, -1, tX, tY); //the right-bottom vertex v.X = offset.X + Size * 7 * 0.5f; v.Y = offset.Y; v += start; Vertex v2 = new Vertex(v.X, v.Y, v.Z, 0, 0, -1, tX + 0.125f, tY); //the right-top vertex v.X = offset.X + Size * 7 * 0.5f; v.Y = offset.Y + Size; v += start; Vertex v3 = new Vertex(v.X, v.Y, v.Z, 0, 0, -1, tX + 0.125f, tY - 0.0625f); //the left-top vertex v.X = offset.X; v.Y = offset.Y + Size; v += start; Vertex v4 = new Vertex(v.X, v.Y, v.Z, 0, 0, -1, tX, tY - 0.0625f); //create first triangle TriangleListIndices[NumIndices++] = (short)NumVertices; TriangleListIndices[NumIndices++] = (short)(NumVertices + 2); TriangleListIndices[NumIndices++] = (short)(NumVertices + 1); // Second triangle: TriangleListIndices[NumIndices++] = (short)NumVertices; TriangleListIndices[NumIndices++] = (short)(NumVertices + 3); TriangleListIndices[NumIndices++] = (short)(NumVertices + 2); //create vertex VertexList[NumVertices].Position = v1.Position; VertexList[NumVertices].Normal = v1.Normal; VertexList[NumVertices].TextureCoordinate = v1.TexCoord; VertexList[NumVertices + 1].Position = v2.Position; VertexList[NumVertices + 1].Normal = v2.Normal; VertexList[NumVertices + 1].TextureCoordinate = v2.TexCoord; VertexList[NumVertices + 2].Position = v3.Position; VertexList[NumVertices + 2].Normal = v3.Normal; VertexList[NumVertices + 2].TextureCoordinate = v3.TexCoord; VertexList[NumVertices + 3].Position = v4.Position; VertexList[NumVertices + 3].Normal = v4.Normal; VertexList[NumVertices + 3].TextureCoordinate = v4.TexCoord; NumVertices += 4; headerIndex++; offset.X = 0; for (int iCol = 1; iCol < NumColumns; iCol++) { for (int iChar = 0; iChar < param.Length; iChar++) { tX = GetTextureCoordX(param, iChar); tY = GetTextureCoordY(param, iChar, color); var offX = offset.X + Size * (1 + HeaderMaxDigits + (MaxDigits) * (iCol - 1)) * 0.5f; //the left-bottom vertex Vector3 va = new Vector3(offX, offset.Y, 0.01f); va += start; Vertex v5 = new Vertex(va.X, va.Y, va.Z, 0, 0, -1, tX, tY); //the right-bottom vertex va.X = offX + Size * 0.5f; va.Y = offset.Y; va += start; Vertex v6 = new Vertex(va.X, va.Y, va.Z, 0, 0, -1, tX + 0.125f, tY); //the right-top vertex va.X = offX + Size * 0.5f; va.Y = offset.Y + Size; va += start; Vertex v7 = new Vertex(va.X, va.Y, va.Z, 0, 0, -1, tX + 0.125f, tY - 0.0625f); //the left-top vertex va.X = offX; va.Y = offset.Y + Size; va += start; Vertex v8 = new Vertex(va.X, va.Y, va.Z, 0, 0, -1, tX, tY - 0.0625f); //create first triangle TriangleListIndices[NumIndices++] = (short)NumVertices; TriangleListIndices[NumIndices++] = (short)(NumVertices + 2); TriangleListIndices[NumIndices++] = (short)(NumVertices + 1); // Second triangle: TriangleListIndices[NumIndices++] = (short)NumVertices; TriangleListIndices[NumIndices++] = (short)(NumVertices + 3); TriangleListIndices[NumIndices++] = (short)(NumVertices + 2); //create vertex VertexList[NumVertices].Position = v5.Position; VertexList[NumVertices].Normal = v5.Normal; VertexList[NumVertices].TextureCoordinate = v5.TexCoord; VertexList[NumVertices + 1].Position = v6.Position; VertexList[NumVertices + 1].Normal = v6.Normal; VertexList[NumVertices + 1].TextureCoordinate = v6.TexCoord; VertexList[NumVertices + 2].Position = v7.Position; VertexList[NumVertices + 2].Normal = v7.Normal; VertexList[NumVertices + 2].TextureCoordinate = v7.TexCoord; VertexList[NumVertices + 3].Position = v8.Position; VertexList[NumVertices + 3].Normal = v8.Normal; VertexList[NumVertices + 3].TextureCoordinate = v8.TexCoord; NumVertices += 4; offset.X += Size * 0.5f; offset.Y += 0; //move to next digit } offset.X = 0; } offset.Y -= Size; //move to next digit } //create the shape primitive shapePrimitive = new MutableShapePrimitive(Material, NumVertices, NumIndices, new[] { -1 }, 0); UpdateShapePrimitive(Material); }
public override void PrepareFrame(DPIStatus dpiStatus) { string[,] tempStatus; var locomotive = DPI.Locomotive; var train = locomotive.Train; var multipleUnitsConfiguration = locomotive.GetMultipleUnitsConfiguration(); int dieselLocomotivesCount = 0; if (locomotive != null) { int numberOfDieselLocomotives = 0; int maxNumberOfEngines = 0; for (var i = 0; i < train.Cars.Count; i++) { if (train.Cars[i] is MSTSDieselLocomotive) { numberOfDieselLocomotives++; maxNumberOfEngines = Math.Max(maxNumberOfEngines, (train.Cars[i] as MSTSDieselLocomotive).DieselEngines.Count); } } if (numberOfDieselLocomotives > 0) { var dieselLoco = MSTSDieselLocomotive.GetDpuHeader(true, numberOfDieselLocomotives, maxNumberOfEngines).Replace("\t", ""); string[] dieselLocoHeader = dieselLoco.Split('\n'); tempStatus = new string[numberOfDieselLocomotives, dieselLocoHeader.Length]; var k = 0; var dpUnitId = 0; var dpUId = -1; var i = 0; for (i = 0; i < train.Cars.Count; i++) { if (train.Cars[i] is MSTSDieselLocomotive) { if (dpUId != (train.Cars[i] as MSTSLocomotive).DPUnitID) { var status = (train.Cars[i] as MSTSDieselLocomotive).GetDpuStatus(true, LoadUnits).Split('\t'); var fence = ((dpUnitId != (dpUnitId = train.Cars[i].RemoteControlGroup)) ? "| " : " "); tempStatus[k, 0] = fence + status[0].Split('(').First(); for (var j = 1; j < status.Length; j++) { tempStatus[k, j] = fence + status[j].Split(' ').First(); // move color code from after the Units to after the value if (ColorCodeCtrl.Keys.Any(status[j].EndsWith) && !ColorCodeCtrl.Keys.Any(tempStatus[k, j].EndsWith)) { tempStatus[k, j] += status[j].Substring(status[j].Length - 3); } } dpUId = (train.Cars[i] as MSTSLocomotive).DPUnitID; k++; } } } dieselLocomotivesCount = k;// only leaders loco group var nRows = Math.Min(FullTable ? NumberOfRowsFull : NumberOfRowsPartial, dieselLocoHeader.Count()); for (i = 0; i < nRows; i++) { for (int j = 0; j < dieselLocomotivesCount; j++) { var text = tempStatus[j, i].Replace('|', ' '); var colorFirstColEndsWith = ColorCodeCtrl.Keys.Any(text.EndsWith) ? ColorCodeCtrl[text.Substring(text.Length - 3)] : Color.White; TableText[i, j + 1].Font = TableTextFont; TableText[i, j + 1].Text = (colorFirstColEndsWith == Color.White) ? text : text.Substring(0, text.Length - 3);; TableText[i, j + 1].Color = colorFirstColEndsWith; TableSymbol[i, j + 1].Font = TableSymbolFont; TableSymbol[i, j + 1].Text = (tempStatus[j, i] != null && tempStatus[j, i].Contains("|")) ? Fence : " "; } TableText[i, 0].Font = TableTextFont; TableText[i, 0].Text = dieselLocoHeader[i]; } } } }
public virtual void PrepareFrame(DPIStatus status) { }