public override void PrepareFrame(RenderFrame frame, ORTS.Common.ElapsedTime elapsedTime, bool updateFull) { if (updateFull) { var labels = Labels; var newLabels = new Dictionary<TrItemLabel, LabelPrimitive>(labels.Count); var worldFiles = Owner.Viewer.World.Scenery.WorldFiles; foreach (var worldFile in worldFiles) { if ((State & DisplayState.Platforms) != 0 && worldFile.platforms != null) foreach (var platform in worldFile.platforms) if (labels.ContainsKey(platform)) newLabels[platform] = labels[platform]; else newLabels[platform] = new LabelPrimitive(Owner.Label3DMaterial, Color.Yellow, Color.Black, 0) { Position = platform.Location, Text = platform.ItemName }; if ((State & DisplayState.Sidings) != 0 && worldFile.sidings != null) foreach (var siding in worldFile.sidings) if (labels.ContainsKey(siding)) newLabels[siding] = labels[siding]; else newLabels[siding] = new LabelPrimitive(Owner.Label3DMaterial, Color.Yellow, Color.Black, 0) { Position = siding.Location, Text = siding.ItemName }; } Labels = newLabels; } foreach (var primitive in Labels.Values) frame.AddPrimitive(Owner.Label3DMaterial, primitive, RenderPrimitiveGroup.World, ref Identity); }
public override void PrepareFrame(RenderFrame frame, ORTS.Common.ElapsedTime elapsedTime, bool updateFull) { if (updateFull) { var labels = Labels; var newLabels = new Dictionary <TrainCar, LabelPrimitive>(labels.Count); var cars = Owner.Viewer.World.Trains.Cars; foreach (var car in cars.Keys) { if (State == DisplayState.Cars) { if (labels.ContainsKey(car)) { newLabels[car] = labels[car]; } else { newLabels[car] = new LabelPrimitive(Owner.Label3DMaterial, Color.Blue, Color.White, car.CarHeightM) { Position = car.WorldPosition } }; newLabels[car].Text = car.CarID; } else if (State == DisplayState.Trains && (car.Train == null || car.Train.FirstCar == car)) { if (labels.ContainsKey(car)) { newLabels[car] = labels[car]; } else { newLabels[car] = new LabelPrimitive(Owner.Label3DMaterial, Color.Blue, Color.White, car.CarHeightM) { Position = car.WorldPosition } }; newLabels[car].Text = car.Train == null ? car.CarID : car.Train.Name; } } Labels = newLabels; } foreach (var primitive in Labels.Values) { frame.AddPrimitive(Owner.Label3DMaterial, primitive, RenderPrimitiveGroup.World, ref Identity); } } }
public void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime) { var updateFull = false; if (Viewer.RealTime - LastPrepareRealTime >= 0.25) { updateFull = true; LastPrepareRealTime = Viewer.RealTime; } foreach (var window in VisibleWindows) { window.PrepareFrame(frame, elapsedTime, updateFull); } frame.AddPrimitive(WindowManagerMaterial, this, RenderPrimitiveGroup.Overlay, ref Identity); }
public void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime) { if (!CVFR.IsPowered) { return; } Update3DDPITable(); Matrix mx = TrainCarShape.Location.XNAMatrix; mx.M41 += (TrainCarShape.Location.TileX - Viewer.Camera.TileX) * 2048; mx.M43 += (-TrainCarShape.Location.TileZ + Viewer.Camera.TileZ) * 2048; Matrix m = XNAMatrix * mx; // TODO: Make this use AddAutoPrimitive instead. frame.AddPrimitive(this.shapePrimitive.Material, this.shapePrimitive, RenderPrimitiveGroup.Interior, ref m, ShapeFlags.None); }
public override void PrepareFrame(RenderFrame frame, ORTS.Common.ElapsedTime elapsedTime, bool updateFull) { if (updateFull) { var labels = Labels; var newLabels = new Dictionary <TrainCar, LabelPrimitive>(labels.Count); var cars = Owner.Viewer.World.Trains.Cars; var cameraLocation = Owner.Viewer.Camera.CameraWorldLocation; foreach (var car in cars.Keys) { // Calculates distance between camera and platform label. var distance = WorldLocation.GetDistance(car.WorldPosition.WorldLocation, cameraLocation).Length(); if (distance <= MaximumDistance) { if ((State == DisplayState.Cars) || (State == DisplayState.Trains && (car.Train == null || car.Train.FirstCar == car))) { if (labels.ContainsKey(car)) { newLabels[car] = labels[car]; } else { newLabels[car] = new LabelPrimitive(Owner.Label3DMaterial, Color.Blue, Color.White, car.CarHeightM) { Position = car.WorldPosition } }; newLabels[car].Text = State == DisplayState.Cars || car.Train == null ? car.CarID : car.Train.Name; // Change color with distance. var ratio = (MathHelper.Clamp(distance, MinimumDistance, MaximumDistance) - MinimumDistance) / (MaximumDistance - MinimumDistance); newLabels[car].Color.A = newLabels[car].Outline.A = (byte)MathHelper.Lerp(255, 0, ratio); } } } Labels = newLabels; } foreach (var primitive in Labels.Values) { frame.AddPrimitive(Owner.Label3DMaterial, primitive, RenderPrimitiveGroup.Labels, ref Identity); } }
public override void PrepareFrame(RenderFrame frame, ORTS.Common.ElapsedTime elapsedTime, bool updateFull) { if (updateFull) { UpdateLabelLists(); var labels = Labels; var newLabels = new Dictionary <TrItemLabel, LabelPrimitive>(labels.Count); var worldFiles = Owner.Viewer.World.Scenery.WorldFiles; var cameraLocation = Owner.Viewer.Camera.CameraWorldLocation; foreach (var worldFile in worldFiles) { if ((State & DisplayState.Platforms) != 0 && worldFile.platforms != null) { foreach (var platform in worldFile.platforms) { if (State == DisplayState.Auto && Platforms != null && (!Platforms.ContainsKey(platform.ItemName) || !Platforms[platform.ItemName])) { continue; } // Calculates distance between camera and platform label. var distance = WorldLocation.GetDistance(platform.Location.WorldLocation, cameraLocation).Length(); if (distance <= MaximumDistancePlatform) { if (labels.ContainsKey(platform)) { newLabels[platform] = labels[platform]; } else { newLabels[platform] = new LabelPrimitive(Owner.Label3DMaterial, Color.Yellow, Color.Black, 0) { Position = platform.Location, Text = platform.ItemName } }; // Change color with distance. var ratio = (MathHelper.Clamp(distance, MinimumDistance, MaximumDistancePlatform) - MinimumDistance) / (MaximumDistancePlatform - MinimumDistance); newLabels[platform].Color.A = newLabels[platform].Outline.A = (byte)MathHelper.Lerp(255, 0, ratio); } } } if ((State & DisplayState.Sidings) != 0 && worldFile.sidings != null) { foreach (var siding in worldFile.sidings) { if (State == DisplayState.Auto && Sidings != null && (!Sidings.ContainsKey(siding.ItemName) || !Sidings[siding.ItemName])) { continue; } // Calculates distance between camera and siding label. var distance = WorldLocation.GetDistance(siding.Location.WorldLocation, cameraLocation).Length(); if (distance <= MaximumDistanceSiding) { if (labels.ContainsKey(siding)) { newLabels[siding] = labels[siding]; } else { newLabels[siding] = new LabelPrimitive(Owner.Label3DMaterial, Color.Orange, Color.Black, 0) { Position = siding.Location, Text = siding.ItemName } }; // Change color with distance. var ratio = (MathHelper.Clamp(distance, MinimumDistance, MaximumDistanceSiding) - MinimumDistance) / (MaximumDistanceSiding - MinimumDistance); newLabels[siding].Color.A = newLabels[siding].Outline.A = (byte)MathHelper.Lerp(255, 0, ratio); } } } } Labels = newLabels; } foreach (var primitive in Labels.Values) { frame.AddPrimitive(Owner.Label3DMaterial, primitive, RenderPrimitiveGroup.Labels, ref Identity); } }