private void ShowEScanningPoints(string lable) { if (CheckConvertToDoubleAll()) { double startTheta = Convert.ToDouble(textBoxScanThetaStart.Text); double finishTheta = Convert.ToDouble(textBoxScanThetaFinish.Text); double stepTheta = Convert.ToDouble(textBoxScanThetaStep.Text); double startPhi = Convert.ToDouble(textBoxScanPhiStart.Text); double finishPhi = Convert.ToDouble(textBoxScanPhiFinish.Text); double stepPhi = Convert.ToDouble(textBoxScanPhiStep.Text); int sys = comboBoxSysOfCoordScan.SelectedIndex; if (startTheta <= finishTheta && startPhi <= finishPhi && stepTheta != 0 && stepPhi != 0) { Color blueCol = new Color(30, 225, 225); parent.renderControl1.Draw(lable, startTheta, finishTheta, stepTheta, startPhi, finishPhi, stepPhi, sys, blueCol); } else { RemoveScanningRegion(lable); } } else { RemoveScanningRegion(lable); } }
/*------------------------------------- * PUBLIC METHODS *-----------------------------------*/ public void Clear(Color clearColor) { var context = Graphics.Device.ImmediateContext; var color = new SharpDX.Color(clearColor.ToIntABGR()); context.ClearRenderTargetView(RenderTarget, color); }
static void SHDXOverlay_BeforeDrawingEvent(object sender, ExternalUtilsCSharp.UI.Overlay <SharpDXRenderer, SharpDX.Color, SharpDX.Vector2, TextFormat> .OverlayEventArgs e) { if (ranksBmp == null) { System.Drawing.Bitmap bmp = (System.Drawing.Bitmap)Resources.ResourceManager.GetObject("uc_exclusive"); try { ranksBmp = SDXBitmapFromSysBitmap(e.Overlay.Renderer.Device, bmp); } catch { } } else { SharpDX.RectangleF source = new SharpDX.RectangleF(0, 0, ranksBmp.PixelSize.Width, ranksBmp.PixelSize.Height); float mul = 1f + 0.2f * (float)Math.Sin(DateTime.Now.TimeOfDay.TotalSeconds * 0.5f); SharpDX.RectangleF dest = new SharpDX.RectangleF(e.Overlay.Width / 2f - source.Width / 2f * mul, e.Overlay.Height - source.Height * 2f * mul, source.Width * mul, source.Height * mul); e.Overlay.Renderer.Device.DrawBitmap(ranksBmp, dest, 0.9f, BitmapInterpolationMode.Linear, source); } if (ConfigUtils.GetValue <bool>("aimEnabled") && ConfigUtils.GetValue <bool>("aimDrawFov")) { float fov = ConfigUtils.GetValue <float>("aimFov"); SharpDX.Color foreColor = new SharpDX.Color(0.2f, 0.2f, 0.2f, 0.8f); SharpDX.Color backColor = new SharpDX.Color(0.8f, 0.8f, 0.8f, 0.9f); SharpDX.Vector2 size = new SharpDX.Vector2(e.Overlay.Width / 90f * fov); SharpDX.Vector2 center = new SharpDX.Vector2(e.Overlay.Width / 2f, e.Overlay.Height / 2f); e.Overlay.Renderer.DrawEllipse(foreColor, center, size, true, 3f); e.Overlay.Renderer.DrawEllipse(backColor, center, size, true); } }
internal void SaveShadingInfo(string path) { string noExt = FileUtil.StripExtension(path); string fname = noExt + ".TerShading"; FileStream fs = new FileStream(fname, FileMode.Create, FileAccess.Write); if (fs == null) { //bummer? return; } BinaryWriter bw = new BinaryWriter(fs); //secret code for shading stuffs UInt32 magic = 0x5ADE1BF0; bw.Write(magic); bw.Write(FogEnabled.Checked); bw.Write((float)FogStart.Value); bw.Write((float)FogEnd.Value); bw.Write((int)ChunkRange.Value); SharpDX.Color col0 = Misc.SystemColorToDXColor(SkyColor0.BackColor); SharpDX.Color col1 = Misc.SystemColorToDXColor(SkyColor1.BackColor); bw.Write(col0.ToRgba()); bw.Write(col1.ToRgba()); bw.Close(); fs.Close(); }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if ((values != null) && (values.Length == 3) && (values[0] is EffectsManager effectManager) && (values[1] is WColor startColor) && (values[2] is WColor stopColor)) { var c1 = new SXColor(startColor.R, startColor.G, startColor.B, startColor.A); var c2 = new SXColor(stopColor.R, stopColor.G, stopColor.B, stopColor.A); var stream = BitmapExtensions.CreateLinearGradientBitmapStream(effectManager, 128, 128, Direct2DImageFormat.Bmp, new Vector2(0, 0), new Vector2(0, 128), new SharpDX.Direct2D1.GradientStop[] { new SharpDX.Direct2D1.GradientStop() { Color = c1, Position = 0f }, new SharpDX.Direct2D1.GradientStop() { Color = c2, Position = 1f } }); return(new TextureModel(stream)); } else { throw new ArgumentException(); } }
private static void ComputeColorsetBlending(XivMtrl mtrl, byte colorsetByte, byte[] colorSetData, Color baseDiffuse, Color baseSpecular, out Color newDiffuse, out Color newSpecular, out Color emissiveColor) { int rowNumber = colorsetByte / 17; int nextRow = rowNumber >= 15 ? 15 : rowNumber + 1; int blendAmount = (colorsetByte % 17); float fBlendAmount = blendAmount / 17.0f; Color diffuse1, diffuse2; Color spec1, spec2; Color emiss1, emiss2; // Byte offset to rows var row1Offset = Clamp(rowNumber * 16); var row2Offset = Clamp(nextRow * 16); diffuse1 = new Color(colorSetData[row1Offset + 0], colorSetData[row1Offset + 1], colorSetData[row1Offset + 2], (byte)255); diffuse2 = new Color(colorSetData[row2Offset + 0], colorSetData[row2Offset + 1], colorSetData[row2Offset + 2], (byte)255); spec1 = new Color(colorSetData[row1Offset + 4], colorSetData[row1Offset + 5], colorSetData[row1Offset + 6], (byte)255); spec2 = new Color(colorSetData[row2Offset + 4], colorSetData[row2Offset + 5], colorSetData[row2Offset + 6], (byte)255); emiss1 = new Color(colorSetData[row1Offset + 8], colorSetData[row1Offset + 9], colorSetData[row1Offset + 10], (byte)255); emiss2 = new Color(colorSetData[row2Offset + 8], colorSetData[row2Offset + 9], colorSetData[row2Offset + 10], (byte)255); // These are now our base values to multiply the base values by. Color diffuse = Blend(diffuse1, diffuse2, fBlendAmount); Color specular = Blend(spec1, spec2, fBlendAmount); Color emissive = Blend(emiss1, emiss2, fBlendAmount); newDiffuse = MultiplyColor(baseDiffuse, diffuse); newSpecular = MultiplyColor(baseSpecular, specular); emissiveColor = emissive; // Nothing to multiply by here. }
/// <summary>Blends the specified colors together.</summary> /// <param name="backColor">Color to blend the other color onto.</param> /// <param name="color">Color to blend onto the background color.</param> /// <param name="amount">How much of <paramref name="color"/> to keep, /// “on top of” <paramref name="backColor"/>.</param> /// <returns>The blended colors.</returns> private static Color Blend(Color backColor, Color color, float amount) { var r = (byte)Clamp(Math.Round((color.R * amount) + backColor.R * (1 - amount))); var g = (byte)Clamp(Math.Round((color.G * amount) + backColor.G * (1 - amount))); var b = (byte)Clamp(Math.Round((color.B * amount) + backColor.B * (1 - amount))); return(new Color(r, g, b)); }
/// <summary>Blends the specified colors together.</summary> /// <param name="color">Color to blend onto the background color.</param> /// <param name="backColor">Color to blend the other color onto.</param> /// <param name="amount">How much of <paramref name="color"/> to keep, /// “on top of” <paramref name="backColor"/>.</param> /// <returns>The blended colors.</returns> private static Color Blend(Color color, Color backColor, double amount) { var r = (byte)((color.R * amount) + backColor.R * (1 - amount)); var g = (byte)((color.G * amount) + backColor.G * (1 - amount)); var b = (byte)((color.B * amount) + backColor.B * (1 - amount)); return(new Color(r, g, b)); }
public ShaderResourceView GetTextureViewOfColor(Color color) { return(texturesViewsByColor.GetOrAdd( color, add => { var texture = GetTextureOfColor(color); return new ShaderResourceView(device, texture); })); }
public void DrawTextOnMap(string text, SharpDX.Vector2 screenPos, Color color, int height, FontAlign align = FontAlign.Left) { if (align == FontAlign.Center) { screenPos.Y -= _graphics.MeasureText(text, height).Y / 2; } _graphics.DrawText(text, screenPos, color, height, align); }
/// <summary> /// Convert System.Drawing.Color to SharpDX.Color. /// </summary> /// <param name="color"></param> /// <param name="opacity"></param> /// <returns></returns> public static SharpDX.Color ColorConvertor(System.Drawing.Color color, float opacity = 1) { SharpDX.Color tmpColor = SharpDX.Color.FromBgra(color.ToArgb()); if (opacity != 1) { tmpColor.A = (byte)(opacity * 255); } return(tmpColor); }
public RectangleF DrawBoxOnMap(SharpDX.Vector2 screenPos, float size, Color color) { var sizeScaled = size * _scale; var rectangleF = new RectangleF(screenPos.X - sizeScaled / 2, screenPos.Y - sizeScaled / 2, sizeScaled, sizeScaled); _graphics.DrawBox( rectangleF, color); return(rectangleF); }
private static Color MultiplyColor(Color c1, Color c2) { var ret = new Color(); ret.R = FloatToByte(ByteToFloat(c1.R) * ByteToFloat(c2.R)); ret.G = FloatToByte(ByteToFloat(c1.G) * ByteToFloat(c2.G)); ret.B = FloatToByte(ByteToFloat(c1.B) * ByteToFloat(c2.B)); ret.A = FloatToByte(ByteToFloat(c1.A) * ByteToFloat(c2.A)); return(ret); }
private static Color MultiplyColor(Color c1, float f) { var ret = new Color(); ret.R = FloatToByte(ByteToFloat(c1.R) * f); ret.G = FloatToByte(ByteToFloat(c1.G) * f); ret.B = FloatToByte(ByteToFloat(c1.B) * f); ret.A = FloatToByte(ByteToFloat(c1.A) * f); return(ret); }
public SolidBrush this[SharpDX.Color color] { get { uint r = color.R; uint g = color.G; uint b = color.B; uint a = color.A; return(this[(a << 24) | (b << 16) | (g << 8) | r]); } }
void CreateRGBA_1x1(MyGeneratedTexture tex, string name, Color color) { Texture2DDescription desc = m_descDefault; desc.Format = Format.R8G8B8A8_UNorm; desc.Height = 1; desc.Width = 1; tex.Init(name, desc, new Vector2I(1, 1), 4); int data = color.ToRgba(); Reset(tex, data); }
public Texture2D CreateColoredTexture(Color color) { using (var bitmap = new Bitmap(1, 1, PixelFormat.Format32bppArgb)) { using (var g = Graphics.FromImage(bitmap)) { g.Clear(SDColor.FromArgb(color.A, color.R, color.G, color.B)); } using (var ms = new MemoryStream()) { bitmap.Save(ms, ImageFormat.Png); ms.Position = 0; return(Resource.FromMemory <Texture2D>(device, ms.GetBuffer())); } } }
public GeometryFigure(IFilledGeometry geometry) { if (geometry == null) { throw new ArgumentNullException(); } this.geometry = geometry; fillColor = SharpDX.Color.White; color = SharpDX.Color.Black; text = new D2DText(""); textLocation = new Location(25 / 2 / 2.0f, 25 / 2 / 2.4f); StrokeWidth = 1; }
void CreateCubeRGBA_1x1(MyGeneratedTexture tex, string name, Color color) { Texture2DDescription desc = m_descDefault; desc.Format = Format.R8G8B8A8_UNorm; desc.Height = 1; desc.Width = 1; desc.ArraySize = 6; desc.OptionFlags = ResourceOptionFlags.TextureCube; tex.Init(name, desc, new Vector2I(1, 1), 4); int data = color.ToRgba(); ResetCube(tex, data); }
unsafe void CreateRGBA_1x1(MyGeneratedTexture tex, string name, Color color) { Texture2DDescription desc = m_descDefault; desc.Format = Format.R8G8B8A8_UNorm; desc.Height = 1; desc.Width = 1; int data = color.ToRgba(); void *ptr = &data; m_tmpDataBoxArray1[0].DataPointer = new IntPtr(ptr); m_tmpDataBoxArray1[0].RowPitch = 4; CreateTexture(tex, name, desc, m_tmpDataBoxArray1, new Vector2I(1, 1), 4); }
public P300ExperimentWindow(Session session) { // ReSharper disable once LocalizableElement Text = "P300"; SuspendLayout(); ControlBox = false; IsFullscreen = true; DoubleBuffered = false; FormBorderStyle = FormBorderStyle.None; WindowState = FormWindowState.Maximized; ResumeLayout(true); Load += Window_OnLoaded; KeyUp += Window_OnKeyUp; Resize += Window_OnResize; this.HideCursorInside(); _session = session; _paradigm = (P300Paradigm)session.Paradigm; _markable = session.StreamerCollection.FindFirstOrDefault <IMarkable>(); _result = new P300Paradigm.Result { Trials = new LinkedList <P300Paradigm.Result.Trial>() }; _stageProgram = _paradigm.CreateStagedProgram(session); _stageProgram.StageChanged += StageProgram_StageChanged; /* Initialize blocks */ _blocks = new Block[(int)_paradigm.Config.Test.Layout]; for (var i = 0; i < _blocks.Length; i++) { var block = new Block { Target = _blocks.Length / 2 == i, Random = _paradigm.Config.Test.TargetRate .CreateRandomBoolSequence((int)(DateTimeUtils.CurrentTimeTicks << 1 + i)), Size = new RawVector2(_paradigm.Config.Gui.BlockLayout.Width, _paradigm.Config.Gui.BlockLayout.Height), BorderWidth = (float)_paradigm.Config.Gui.BlockBorder.Width }; block.UpdateGeometries(); _blocks[i] = block; } /* Type conversion */ _backgroundColor = _paradigm.Config.Gui.BackgroundColor.ToSdColor().ToSdx(); _fontColor = _paradigm.Config.Gui.BackgroundColor.ToSdColor().Inverted().ToSdx(); _blockBorderColor = _paradigm.Config.Gui.BlockBorder.Color.ToSdColor().ToSdx(); _blockNormalColor = _paradigm.Config.Gui.BlockNormalColor.ToSdColor().ToSdx(); _blockActivedColor = _paradigm.Config.Gui.BlockActivedColor.ToSdColor().ToSdx(); }
/// <summary> /// Used for converting SharpDX.Color into string #AARRGGBB. /// </summary> public static string HexConverter(Color c) { var rtn = string.Empty; try { rtn = "#" + c.A.ToString("X2") + c.R.ToString("X2") + c.G.ToString("X2") + c.B.ToString("X2"); return(rtn); } catch { // ignored } return(rtn); }
protected void RenderDiagonalWires(SharpDX.Color color, System.Drawing.Point point, int x, int y, bool normal = true) { _ColorBrush.Color = color; if (normal) { _RenderTarget2D.DrawLine(new RawVector2(x + size * point.X + 1, (y + size * point.Y + 1) + size * 0.5f), new RawVector2((x + size * (point.X + 1) + 1) - size * 0.5f, y + size * (point.Y + 1) + 1), _ColorBrush); _RenderTarget2D.DrawLine(new RawVector2(x + size * point.X + 1, y + size * point.Y + 1), new RawVector2(x + size * (point.X + 1) + 1, y + size * (point.Y + 1) + 1), _ColorBrush); _RenderTarget2D.DrawLine(new RawVector2((x + size * point.X + 1) + size * 0.5f, y + size * point.Y + 1), new RawVector2(x + size * (point.X + 1) + 1, (y + size * (point.Y + 1) + 1) - size * 0.5f), _ColorBrush); } else { _RenderTarget2D.DrawLine(new RawVector2(x + size * point.X + 1, (y + size * point.Y + 1) + size * 0.5f), new RawVector2((x + size * (point.X + 1) + 1) - size * 0.5f, (y + size * point.Y + 1)), _ColorBrush); _RenderTarget2D.DrawLine(new RawVector2(x + size * point.X + 1, y + size * (point.Y + 1) + 1), new RawVector2(x + size * (point.X + 1) + 1, y + size * point.Y + 1), _ColorBrush); _RenderTarget2D.DrawLine(new RawVector2((x + size * point.X + 1) + size * 0.5f, y + size * (point.Y + 1) + 1), new RawVector2(x + size * (point.X + 1) + 1, (y + size * (point.Y + 1) + 1) - size * 0.5f), _ColorBrush); } }
// Used for converting SharpDX.Color into string #AARRGGBB private static string HexConverter(Color c) { var rtn = string.Empty; try { rtn = "#" + c.A.ToString("X2") + c.R.ToString("X2") + c.G.ToString("X2") + c.B.ToString("X2"); return(rtn); } catch (Exception) { //doing nothing } return(rtn); }
unsafe void CreateRGBA(MyGeneratedTexture tex, string name, Vector2I resolution, bool srgb, Color[] colors, int numMipLevels = 1) { int width = resolution.X; int height = resolution.Y; byte[] rawData = new byte[width * height * 4]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int offset = x + y * width; Color currentColor = colors[offset]; rawData[offset * 4 + 0] = currentColor.R; rawData[offset * 4 + 1] = currentColor.G; rawData[offset * 4 + 2] = currentColor.B; rawData[offset * 4 + 3] = currentColor.A; } } CreateRGBA(tex, name, resolution, srgb, rawData); }
void CreateCheckerRGBA(MyGeneratedTexture tex, string name, Vector2I resolution, Color v1, Color v2) { int width = resolution.X; int height = resolution.Y; Color[] rawData = new Color[width * height]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Color v = v1; if (((y + x) & 1) == 0) { v = v2; } rawData[y * width + x] = v; } } CreateRGBA(tex, name, resolution, false, rawData); }
unsafe void CreateCubeRGBA_1x1(MyGeneratedTexture tex, string name, Color color) { Texture2DDescription desc = m_descDefault; desc.Format = Format.R8G8B8A8_UNorm; desc.Height = 1; desc.Width = 1; desc.ArraySize = 6; desc.OptionFlags = ResourceOptionFlags.TextureCube; int data = color.ToRgba(); void *ptr = &data; for (int i = 0; i < 6; i++) { m_tmpDataBoxArray6[i].DataPointer = new IntPtr(ptr); m_tmpDataBoxArray6[i].RowPitch = 4; } CreateTexture(tex, name, desc, m_tmpDataBoxArray6, new Vector2I(1, 1), 4); }
public CustomModelColors() { // These match with the Hex Colors in TexTools Settings.Settings file. // They don't really *have* to, but it probably makes sense to use the // Same defaults. SkinColor = new Color(204, 149, 120, 255); EyeColor = new Color(21, 176, 172, 255); LipColor = new Color(173, 105, 105, 255); HairColor = new Color(130, 64, 13, 255); TattooColor = new Color(0, 255, 66, 255); FurnitureColor = new Color(141, 60, 204, 255); HairHighlightColor = new Color(77, 126, 240, 255); DyeColors = new List <Color?>(16); for (int i = 0; i < 16; i++) { DyeColors.Add(null); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { Dispatcher.BeginInvoke(new Action(() => { renderFrame.Height = (int)(this.Content as Grid).RenderSize.Height; renderFrame.Width = (int)(this.Content as Grid).RenderSize.Width; renderFrame.RenderTargetChanged += RenderFrame_RenderTargetChanged; //renderFrame.DisplayHandle = Handle; renderFrame.Initialize(); TargetImage.Source = imageSource; BackgroundColor = Interop.MediaColorToNativeColor((Background as SolidColorBrush).Color); Clear = renderFrame.CreateDrawCommnad2D <Clear2DCommand>(); Clear.clearColor = BackgroundColor; SharpDX.Direct2D1.Ellipse ellipse = new SharpDX.Direct2D1.Ellipse(new SharpDX.Mathematics.Interop.RawVector2(100, 100), 50, 50); EllipseBrush = renderFrame.Controller.CreateSolidColorBrush(SharpDX.Color.Black); DrawEllipse = renderFrame.CreateDrawCommnad2D <DrawEllipse2DCommand>(); DrawEllipse.ellipse = ellipse; DrawEllipse.brush = EllipseBrush; FillEllipse = renderFrame.CreateDrawCommnad2D <FillEllipse2DCommand>(); FillEllipse.ellipse = ellipse; FillEllipse.brush = EllipseBrush; DrawLine = renderFrame.CreateDrawCommnad2D <DrawLine2DCommand>(); DrawLine.point0 = new SharpDX.Mathematics.Interop.RawVector2(0, 0); DrawLine.point1 = new SharpDX.Mathematics.Interop.RawVector2(100, 100); DrawLine.strokeWidth = 10; DrawLine.brush = EllipseBrush; System.Windows.Media.CompositionTarget.Rendering += OnRendering; //dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); //dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 16); //dispatcherTimer.Start(); })); }
private void colorClick(object sender, System.EventArgs e) { if (this.selectedNode != null) { ColorDialog colorDialog = new ColorDialog(); colorDialog.Color = this.colorButton.BackColor; colorDialog.FullOpen = true; colorDialog.SolidColorOnly = false; colorDialog.AllowFullOpen = true; colorDialog.AnyColor = true; if (colorDialog.ShowDialog() == DialogResult.OK) { this.colorButton.BackColor = colorDialog.Color; if (this.selectedNode != null) { TextureNode node = this.selectedNode; SharpDX.Color color = node.Color; SharpDX.Color nodeColor = new SharpDX.Color(colorDialog.Color.R, colorDialog.Color.G, colorDialog.Color.B, color.A); node.Color = nodeColor; } } } }
void CreateRGBA_1x1(MyGeneratedTexture tex, string name, Color color) { Texture2DDescription desc = m_descDefault; desc.Format = Format.R8G8B8A8_UNorm; desc.Height = 1; desc.Width = 1; tex.Init(name, desc, new Vector2I(1, 1), 4); int data = color.ToRgba(); Reset(tex, data); }
unsafe void CreateCheckerRGBA(MyGeneratedTexture tex, string name, Vector2I resolution, Color v1, Color v2) { int width = resolution.X; int height = resolution.Y; Color[] rawData = new Color[width * height]; for (int y = 0; y < height; y++) for (int x = 0; x < width; x++) { Color v = v1; if (((y + x) & 1) == 0) v = v2; rawData[y * width + x] = v; } CreateRGBA(tex, name, resolution, rawData); }
unsafe void CreateRGBA(MyGeneratedTexture tex, string name, Vector2I resolution, Color[] colors) { Texture2DDescription desc = m_descDefault; desc.Format = Format.R8G8B8A8_UNorm; int width = resolution.X; int height = resolution.Y; desc.Height = width; desc.Width = height; byte[] rawData = new byte[width * height * 4]; for (int y = 0; y < height; y++) for (int x = 0; x < width; x++) { int offset = x + y*width; Color currentColor = colors[offset]; rawData[offset*4 + 0] = currentColor.R; rawData[offset*4 + 1] = currentColor.G; rawData[offset*4 + 2] = currentColor.B; rawData[offset*4 + 3] = currentColor.A; } fixed (byte* dptr = rawData) { m_tmpDataBoxArray1[0].DataPointer = new IntPtr(dptr); m_tmpDataBoxArray1[0].RowPitch = width*4; CreateTexture(tex, name, desc, m_tmpDataBoxArray1, new Vector2I(width, height), width*height*4); m_tmpDataBoxArray1[0].DataPointer = new IntPtr(null); } }
unsafe void CreateCubeRGBA_1x1(MyGeneratedTexture tex, string name, Color color) { Texture2DDescription desc = m_descDefault; desc.Format = Format.R8G8B8A8_UNorm; desc.Height = 1; desc.Width = 1; desc.ArraySize = 6; desc.OptionFlags = ResourceOptionFlags.TextureCube; int data = color.ToRgba(); void* ptr = &data; for (int i = 0; i < 6; i++) { m_tmpDataBoxArray6[i].DataPointer = new IntPtr(ptr); m_tmpDataBoxArray6[i].RowPitch = 4; } CreateTexture(tex, name, desc, m_tmpDataBoxArray6, new Vector2I(1, 1), 4); }
unsafe void CreateRGBA_1x1(MyGeneratedTexture tex, string name, Color color) { Texture2DDescription desc = m_descDefault; desc.Format = Format.R8G8B8A8_UNorm; desc.Height = 1; desc.Width = 1; int data = color.ToRgba(); void* ptr = &data; m_tmpDataBoxArray1[0].DataPointer = new IntPtr(ptr); m_tmpDataBoxArray1[0].RowPitch = 4; CreateTexture(tex, name, desc, m_tmpDataBoxArray1, new Vector2I(1, 1), 4); }
public static void DrawText(Font vFont, String vText, int vPosX, int vPosY, Color vColor) { vFont.DrawText(null, vText, vPosX + 2, vPosY + 2, vColor != Color.Black ? Color.Black : Color.White); vFont.DrawText(null, vText, vPosX, vPosY, vColor); }
private static void ProcessMessageInternal(MyRenderMessageBase message) { switch (message.MessageType) { case MyRenderMessageEnum.SetCameraViewMatrix: { var rMessage = (MyRenderMessageSetCameraViewMatrix)message; SetupCameraMatrices(rMessage); break; } case MyRenderMessageEnum.DrawScene: { var rMessage = (MyRenderMessageBase)message; m_drawQueue.Enqueue(rMessage); break; } case MyRenderMessageEnum.RebuildCullingStructure: { break; } #region Profiler case MyRenderMessageEnum.RenderProfiler: { var profMessage = (MyRenderMessageRenderProfiler)message; MyRenderProfiler.HandleInput(profMessage.Command, profMessage.Index); break; } #endregion #region Characters case MyRenderMessageEnum.CreateRenderCharacter: { var rMessage = (MyRenderMessageCreateRenderCharacter)message; var actor = MyActorFactory.CreateCharacter(); var renderable = actor.GetRenderable(); renderable.SetModel(MyMeshes.GetMeshId(MyStringId.GetOrCompute(rMessage.Model), 1.0f)); actor.SetMatrix(ref rMessage.WorldMatrix); if (rMessage.ColorMaskHSV.HasValue) { var color = ColorFromMask(rMessage.ColorMaskHSV.Value); renderable.SetKeyColor(new Vector4(color, 1)); } actor.SetID(rMessage.ID); renderable.m_additionalFlags |= MyProxiesFactory.GetRenderableProxyFlags(rMessage.Flags); renderable.m_drawFlags = MyDrawSubmesh.MySubmeshFlags.Gbuffer | MyDrawSubmesh.MySubmeshFlags.Depth; break; } case MyRenderMessageEnum.SetCharacterSkeleton: { var rMessage = (MyRenderMessageSetCharacterSkeleton)message; var actor = MyIDTracker<MyActor>.FindByID(rMessage.CharacterID); if (actor != null) { actor.GetSkinning().SetSkeleton(rMessage.SkeletonBones, rMessage.SkeletonIndices); } //var entity = MyComponents.GetEntity(rMessage.CharacterID); //MyComponents.SetSkeleton(entity, rMessage.SkeletonBones, rMessage.SkeletonIndices); break; }; case MyRenderMessageEnum.SetCharacterTransforms: { var rMessage = (MyRenderMessageSetCharacterTransforms)message; var actor = MyIDTracker<MyActor>.FindByID(rMessage.CharacterID); if (actor != null) { actor.GetSkinning().SetAnimationBones(rMessage.BoneAbsoluteTransforms, rMessage.BoneDecalUpdates); } //var entity = MyComponents.GetEntity(rMessage.CharacterID); //MyComponents.SetAnimation(entity, rMessage.RelativeBoneTransforms); break; } case MyRenderMessageEnum.UpdateRenderEntity: { var rMessage = (MyRenderMessageUpdateRenderEntity)message; var actor = MyIDTracker<MyActor>.FindByID(rMessage.ID); if (actor == null) break; var renderableComponent = actor.GetRenderable(); if (renderableComponent == null) break; if (rMessage.ColorMaskHSV.HasValue) { actor.GetRenderable().SetKeyColor(new Vector4(ColorFromMask(rMessage.ColorMaskHSV.Value), 0)); } actor.GetRenderable().SetDithering(rMessage.Dithering); break; } case MyRenderMessageEnum.ChangeModel: { var rMessage = (MyRenderMessageChangeModel)message; var actor = MyIDTracker<MyActor>.FindByID(rMessage.ID); if (actor != null && actor.GetRenderable() != null) { var r = actor.GetRenderable(); var modelId = MyMeshes.GetMeshId(X.TEXT_(rMessage.Model), rMessage.Scale); if(r.GetModel() != modelId) { r.SetModel(modelId); } } break; } case MyRenderMessageEnum.ChangeModelMaterial: { var rMessage = (MyRenderMessageChangeModelMaterial)message; //var matId = MyMeshMaterialId.NULL; //if (rMessage.Material.ToLower().Contains("debug")) //{ // matId = MyMeshMaterials1.DebugMaterialId; //} //else //{ // matId = MyMeshMaterials1.GetMaterialId(rMessage.Material); //} //MyAssetsLoader.GetModel(rMessage.Model).SetMaterial_SLOW(MyMeshMaterials1.GetProxyId(matId)); break; } #endregion #region Render objects case MyRenderMessageEnum.UpdateCockpitGlass: { var rMessage = (MyRenderMessageUpdateCockpitGlass)message; //if (MyRender11.Environment.CockpitGlass == null) //{ // MyRender11.Environment.CockpitGlass = MyActorFactory.CreateSceneObject(); //} //MyRender11.Environment.CockpitGlass.GetRenderable().SetModel(MyMeshes.GetMeshId(X.TEXT(rMessage.Model))); //MyRender11.Environment.CockpitGlass.SetVisibility(rMessage.Visible); //MyRender11.Environment.CockpitGlass.MarkRenderDirty(); //var matrix = (Matrix)rMessage.WorldMatrix; //MyRender11.Environment.CockpitGlass.SetMatrix(ref matrix); break; } case MyRenderMessageEnum.CreateRenderVoxelDebris: { var rMessage = (MyRenderMessageCreateRenderVoxelDebris)message; Matrix m = (Matrix)rMessage.WorldMatrix; var actor = MyActorFactory.CreateSceneObject(); if (rMessage.Model != null) { actor.GetRenderable().SetModel(MyMeshes.GetMeshId(X.TEXT_(rMessage.Model), 1.0f)); } actor.SetID(rMessage.ID); actor.SetMatrix(ref rMessage.WorldMatrix); MyRenderableComponent.DebrisEntityVoxelMaterial[rMessage.ID] = rMessage.VoxelMaterialIndex; break; } case MyRenderMessageEnum.CreateScreenDecal: { var rMessage = (MyRenderMessageCreateScreenDecal)message; MyScreenDecals.AddDecal(rMessage.ID, rMessage.ParentID, ref rMessage.TopoData, rMessage.Flags, rMessage.SourceTarget, rMessage.Material, rMessage.MaterialIndex); break; } case MyRenderMessageEnum.UpdateScreenDecal: { var rMessage = (MyRenderMessageUpdateScreenDecal)message; MyScreenDecals.UpdateDecals(rMessage.Decals); break; } case MyRenderMessageEnum.CreateRenderEntity: { var rMessage = (MyRenderMessageCreateRenderEntity)message; var actor = MyActorFactory.CreateSceneObject(); if (rMessage.Model != null) { var model = MyAssetsLoader.ModelRemap.Get(rMessage.Model, rMessage.Model); actor.GetRenderable().SetModel(MyMeshes.GetMeshId(X.TEXT_(model), rMessage.Rescale)); } actor.SetID(rMessage.ID); actor.SetMatrix(ref rMessage.WorldMatrix); var renderable = actor.GetRenderable(); renderable.m_additionalFlags |= MyProxiesFactory.GetRenderableProxyFlags(rMessage.Flags); renderable.m_depthBias = rMessage.DepthBias; break; } case MyRenderMessageEnum.CreateRenderEntityClouds: { var rMessage = (MyRenderMessageCreateRenderEntityClouds)message; if (rMessage.Technique == MyMeshDrawTechnique.CLOUD_LAYER) { MyCloudRenderer.CreateCloudLayer( rMessage.ID, rMessage.CenterPoint, rMessage.Altitude, rMessage.MinScaledAltitude, rMessage.ScalingEnabled, rMessage.FadeOutRelativeAltitudeStart, rMessage.FadeOutRelativeAltitudeEnd, rMessage.ApplyFogRelativeDistance, rMessage.MaxPlanetHillRadius, rMessage.Model, rMessage.Textures, rMessage.RotationAxis, rMessage.AngularVelocity, rMessage.InitialRotation); } break; } case MyRenderMessageEnum.CreateRenderEntityAtmosphere: { var rMessage = (MyRenderMessageCreateRenderEntityAtmosphere)message; if (rMessage.Technique == MyMeshDrawTechnique.ATMOSPHERE) { float earthPlanetRadius = 6360000f; float earthAtmosphereRadius = 6420000f; float earthAtmosphereToPlanetRatio = earthAtmosphereRadius / earthPlanetRadius; float targetAtmosphereToPlanetRatio = rMessage.AtmosphereRadius / rMessage.PlanetRadius; float targetToEarthRatio = (targetAtmosphereToPlanetRatio - 1) / (earthAtmosphereToPlanetRatio - 1); earthAtmosphereRadius = earthPlanetRadius * targetAtmosphereToPlanetRatio; float planetScaleFactor = (rMessage.PlanetRadius) / earthPlanetRadius; float atmosphereScaleFactor = (rMessage.AtmosphereRadius - rMessage.PlanetRadius) / (rMessage.PlanetRadius * 0.5f); Vector3 rayleighScattering = new Vector3(5.8e-6f, 13.5e-6f, 33.1e-6f); Vector3 mieScattering = new Vector3(2e-5f, 2e-5f, 2e-5f); float rayleighHeightScale = 8000f; float mieHeightScale = 1200f; MyAtmosphereRenderer.CreateAtmosphere(rMessage.ID, rMessage.WorldMatrix, earthPlanetRadius, earthAtmosphereRadius, rayleighScattering, rayleighHeightScale, mieScattering, mieHeightScale, planetScaleFactor, atmosphereScaleFactor); } break; } case MyRenderMessageEnum.RemoveDecal: { var rMessage = (MyRenderMessageRemoveDecal)message; MyScreenDecals.RemoveDecal(rMessage.ID); break; } case MyRenderMessageEnum.SetDecalGlobals: { var rMessage = (MyRenderMessageSetDecalGlobals)message; MyScreenDecals.SetDecalGlobals(rMessage.Globals); break; } case MyRenderMessageEnum.RegisterDecalsMaterials: { var rMessage = (MyRenderMessageRegisterScreenDecalsMaterials)message; MyScreenDecals.RegisterMaterials(rMessage.MaterialDescriptions); break; } case MyRenderMessageEnum.ClearDecals: { var rMessage = (MyRenderMessageClearScreenDecals)message; MyScreenDecals.ClearDecals(); break; } case MyRenderMessageEnum.UpdateRenderObject: { var rMessage = (MyRenderMessageUpdateRenderObject)message; MyRenderProxy.Assert(rMessage.ID != MyRenderProxy.RENDER_ID_UNASSIGNED); MyRenderProxy.ObjectType objectType; if (MyRenderProxy.ObjectTypes.TryGetValue(rMessage.ID, out objectType)) { switch (objectType) { case MyRenderProxy.ObjectType.Entity: var actor = MyIDTracker<MyActor>.FindByID(rMessage.ID); if (actor != null) { if (rMessage.LastMomentUpdateIndex != -1 && MyOpenVR.LmuDebugOnOff) MyOpenVR.LMUMatrixUpdate(ref rMessage.WorldMatrix, rMessage.LastMomentUpdateIndex); actor.SetMatrix(ref rMessage.WorldMatrix); if (rMessage.AABB.HasValue) { actor.SetAabb(rMessage.AABB.Value); } } break; case MyRenderProxy.ObjectType.Clipmap: if (MyClipmapFactory.ClipmapByID.ContainsKey(rMessage.ID)) { MyClipmapFactory.ClipmapByID[rMessage.ID].UpdateWorldMatrix(ref rMessage.WorldMatrix); } break; default: MyRenderProxy.Assert(false); break; } } else MyRenderProxy.Assert(false); break; } case MyRenderMessageEnum.RemoveRenderObject: { var rMessage = (MyRenderMessageRemoveRenderObject)message; MyRenderProxy.Assert(rMessage.ID != MyRenderProxy.RENDER_ID_UNASSIGNED); MyRenderProxy.ObjectType objectType; if (MyRenderProxy.ObjectTypes.TryGetValue(rMessage.ID, out objectType)) { switch (objectType) { case MyRenderProxy.ObjectType.Entity: var actor = MyIDTracker<MyActor>.FindByID(rMessage.ID); if (actor != null) { if (actor.GetRenderable() != null && actor.GetRenderable().GetModel().Info.Dynamic) { MyMeshes.RemoveMesh(actor.GetRenderable().GetModel()); } actor.Destruct(); MyScreenDecals.RemoveEntityDecals(rMessage.ID); } else MyRenderProxy.Assert(false); break; case MyRenderProxy.ObjectType.InstanceBuffer: MyInstancing.Remove(rMessage.ID); break; case MyRenderProxy.ObjectType.Light: MyLights.Remove(rMessage.ID); break; case MyRenderProxy.ObjectType.Clipmap: MyClipmapFactory.Remove(rMessage.ID); break; case MyRenderProxy.ObjectType.GPUEmitter: MyGPUEmitters.Remove(rMessage.ID); break; case MyRenderProxy.ObjectType.Atmosphere: MyAtmosphereRenderer.RemoveAtmosphere(rMessage.ID); break; case MyRenderProxy.ObjectType.Cloud: MyCloudRenderer.RemoveCloud(rMessage.ID); break; case MyRenderProxy.ObjectType.DebugDrawMesh: MyPrimitivesRenderer.RemoveDebugMesh(rMessage.ID); break; case MyRenderProxy.ObjectType.Video: MyVideoFactory.Remove(rMessage.ID); break; default: MyRenderProxy.Assert(false); break; } MyRenderProxy.RemoveMessageId(rMessage.ID, objectType); } else MyRenderProxy.Assert(false); break; } case MyRenderMessageEnum.UpdateRenderObjectVisibility: { var rMessage = (MyRenderMessageUpdateRenderObjectVisibility)message; MyRenderProxy.Assert(rMessage.ID != MyRenderProxy.RENDER_ID_UNASSIGNED); MyRenderProxy.ObjectType objectType; if (MyRenderProxy.ObjectTypes.TryGetValue(rMessage.ID, out objectType)) { switch (objectType) { case MyRenderProxy.ObjectType.Entity: var actor = MyIDTracker<MyActor>.FindByID(rMessage.ID); if (actor != null) { actor.SetVisibility(rMessage.Visible); } break; } } else MyRenderProxy.Assert(false); break; } case MyRenderMessageEnum.CreateRenderInstanceBuffer: { var rMessage = (MyRenderMessageCreateRenderInstanceBuffer)message; //var instancing = MyComponentFactory<MyInstancingComponent>.Create(); //instancing.SetID(rMessage.ID); //instancing.Init(rMessage.Type); //instancing.SetDebugName(rMessage.DebugName); MyInstancing.Create(rMessage.ID, rMessage.ParentID, rMessage.Type, rMessage.DebugName); break; } case MyRenderMessageEnum.UpdateRenderInstanceBufferSettings: { var rMessage = (MyRenderMessageUpdateRenderInstanceBufferSettings)message; //var instancing = MyIDTracker<MyInstancingComponent>.FindByID(rMessage.ID); //if(instancing != null) //{ // instancing.UpdateGeneric(rMessage.InstanceData, rMessage.Capacity); //} var handle = MyInstancing.Get(rMessage.ID); if (handle != InstancingId.NULL) { // TODO: Do something :P MyInstancing.UpdateGenericSettings(handle, rMessage.SetPerInstanceLod); } else { // MyRenderProxy.Assert(handle != InstancingId.NULL, "No instance buffer with ID " + rMessage.ID); } break; } case MyRenderMessageEnum.UpdateRenderInstanceBufferRange: { var rMessage = (MyRenderMessageUpdateRenderInstanceBufferRange)message; //var instancing = MyIDTracker<MyInstancingComponent>.FindByID(rMessage.ID); //if(instancing != null) //{ // instancing.UpdateGeneric(rMessage.InstanceData, rMessage.Capacity); //} // TODO: Turn this into partial update. var handle = MyInstancing.Get(rMessage.ID); if (handle != InstancingId.NULL) { MyInstancing.UpdateGeneric(handle, rMessage.InstanceData, rMessage.InstanceData.Length); } else { // Debug.Assert(handle != InstancingId.NULL, "No instance buffer with ID " + rMessage.ID); } break; } case MyRenderMessageEnum.UpdateRenderCubeInstanceBuffer: { var rMessage = (MyRenderMessageUpdateRenderCubeInstanceBuffer)message; //var instancing = MyIDTracker<MyInstancingComponent>.FindByID(rMessage.ID); //if (instancing != null) //{ // instancing.UpdateCube(rMessage.InstanceData, rMessage.Capacity); //} var handle = MyInstancing.Get(rMessage.ID); if (handle != InstancingId.NULL) { MyInstancing.UpdateCube(MyInstancing.Get(rMessage.ID), rMessage.InstanceData, rMessage.DecalsData, rMessage.Capacity); } else Debug.Fail("No instance buffer with ID " + rMessage.ID); break; } case MyRenderMessageEnum.SetInstanceBuffer: { var rMessage = (MyRenderMessageSetInstanceBuffer)message; var actor = MyIDTracker<MyActor>.FindByID(rMessage.ID); //var instancing = MyIDTracker<MyInstancingComponent>.FindByID(rMessage.InstanceBufferId); if (actor != null) { //if (actor.GetComponent(MyActorComponentEnum.Instancing) != instancing) //{ // actor.AddComponent(instancing); //} //actor.SetLocalAabb(rMessage.LocalAabb); //actor.GetRenderable().SetInstancingCounters(rMessage.InstanceCount, rMessage.InstanceStart); actor.GetRenderable().SetInstancing(MyInstancing.Get(rMessage.InstanceBufferId)); actor.SetLocalAabb(rMessage.LocalAabb); actor.GetRenderable().SetInstancingCounters(rMessage.InstanceCount, rMessage.InstanceStart); } break; } case MyRenderMessageEnum.CreateManualCullObject: { var rMessage = (MyRenderMessageCreateManualCullObject)message; var actor = MyActorFactory.CreateGroup(); actor.SetID(rMessage.ID); Matrix m = (Matrix)rMessage.WorldMatrix; actor.SetMatrix(ref rMessage.WorldMatrix); break; } case MyRenderMessageEnum.SetParentCullObject: { var rMessage = (MyRenderMessageSetParentCullObject)message; var child = MyIDTracker<MyActor>.FindByID(rMessage.ID); var parent = MyIDTracker<MyActor>.FindByID(rMessage.CullObjectID); if (child != null && parent != null && parent.GetGroupRoot() != null && child.GetGroupLeaf() == null) { child.SetRelativeTransform(rMessage.ChildToParent); parent.GetGroupRoot().Add(child); } break; } case MyRenderMessageEnum.CreateLineBasedObject: { var rMessage = (MyRenderMessageCreateLineBasedObject)message; var actor = MyActorFactory.CreateSceneObject(); //actor.GetRenderable().SetModel(new MyDynamicMesh()); actor.SetID(rMessage.ID); actor.SetMatrix(ref MatrixD.Identity); MyMeshMaterials1.GetMaterialId("__ROPE_MATERIAL", null, rMessage.ColorMetalTexture, rMessage.NormalGlossTexture, rMessage.ExtensionTexture, MyMesh.DEFAULT_MESH_TECHNIQUE); actor.GetRenderable().SetModel(MyMeshes.CreateRuntimeMesh(X.TEXT_("LINE" + rMessage.ID), 1, true)); break; } case MyRenderMessageEnum.UpdateLineBasedObject: { var rMessage = (MyRenderMessageUpdateLineBasedObject)message; var actor = MyIDTracker<MyActor>.FindByID(rMessage.ID); if (actor != null) { //var mesh = actor.GetRenderable().GetMesh() as MyDynamicMesh; MyVertexFormatPositionH4 [] stream0; MyVertexFormatTexcoordNormalTangentTexindices[] stream1; MyLineHelpers.GenerateVertexData(ref rMessage.WorldPointA, ref rMessage.WorldPointB, out stream0, out stream1); var indices = MyLineHelpers.GenerateIndices(stream0.Length); var sections = new MyRuntimeSectionInfo[] { new MyRuntimeSectionInfo { TriCount = indices.Length / 3, IndexStart = 0, MaterialName = "__ROPE_MATERIAL" } }; MyMeshes.UpdateRuntimeMesh(MyMeshes.GetMeshId(X.TEXT_("LINE" + rMessage.ID), 1.0f), indices, stream0, stream1, sections, (BoundingBox)MyLineHelpers.GetBoundingBox(ref rMessage.WorldPointA, ref rMessage.WorldPointB)); //actor.SetAabb((BoundingBox)MyLineHelpers.GetBoundingBox(ref rMessage.WorldPointA, ref rMessage.WorldPointB)); actor.MarkRenderDirty(); var matrix = MatrixD.CreateTranslation((Vector3)(rMessage.WorldPointA + rMessage.WorldPointB) * 0.5f); actor.SetMatrix(ref matrix); } break; } case MyRenderMessageEnum.SetRenderEntityData: { var rMessage = (MyRenderMessageSetRenderEntityData)message; MyRenderProxy.Assert(false, "MyRenderMessageSetRenderEntityData is deprecated!"); break; } case MyRenderMessageEnum.AddRuntimeModel: { var rMessage = (MyRenderMessageAddRuntimeModel)message; //MyDestructionMesh mesh = MyDestructionMesh.ModelsDictionary.Get(rMessage.Name); //if (mesh == null) //{ //mesh = new MyDestructionMesh(rMessage.Name); //ProfilerShort.Begin("LoadBuffers"); //mesh.Fill(rMessage.ModelData.Indices, rMessage.ModelData.Positions, rMessage.ModelData.Normals, rMessage.ModelData.Tangents, rMessage.ModelData.TexCoords, rMessage.ModelData.Sections, rMessage.ModelData.AABB); //ProfilerShort.End(); MyRenderProxy.Assert(!MyMeshes.Exists(rMessage.Name), "It is added already added mesh!"); MyRenderProxy.Assert(!MyRenderProxy.Settings.UseGeometryArrayTextures, "Geometry array textures do not fully support runtimer models, please add support"); if(!MyMeshes.Exists(rMessage.Name)) { { ushort[] indices = new ushort[rMessage.ModelData.Indices.Count]; for (int i = 0; i < rMessage.ModelData.Indices.Count; i++) { indices[i] = (ushort)rMessage.ModelData.Indices[i]; } var verticesNum = rMessage.ModelData.Positions.Count; MyVertexFormatPositionH4[] stream0 = new MyVertexFormatPositionH4[verticesNum]; MyVertexFormatTexcoordNormalTangentTexindices[] stream1 = new MyVertexFormatTexcoordNormalTangentTexindices[verticesNum]; Vector4I[] arrayTexIndices = MyManagers.GeometryTextureSystem.CreateTextureIndices(rMessage.ModelData.Sections, rMessage.ModelData.Indices, rMessage.ModelData.Positions.Count); for (int i = 0; i < verticesNum; i++) { stream0[i] = new MyVertexFormatPositionH4(rMessage.ModelData.Positions[i]); stream1[i] = new MyVertexFormatTexcoordNormalTangentTexindices( rMessage.ModelData.TexCoords[i], rMessage.ModelData.Normals[i], rMessage.ModelData.Tangents[i], (Byte4) arrayTexIndices[i]); } var id = MyMeshes.CreateRuntimeMesh(X.TEXT_(rMessage.Name), rMessage.ModelData.Sections.Count, false); MyMeshes.UpdateRuntimeMesh(id, indices, stream0, stream1, rMessage.ModelData.Sections.ToArray(), rMessage.ModelData.AABB); } if (rMessage.ReplacedModel != null) { //MyAssetsLoader.ModelRemap[rMessage.ReplacedModel] = rMessage.Name; MyAssetsLoader.ModelRemap[rMessage.Name] = rMessage.ReplacedModel; } //if (MyAssetsLoader.LOG_MESH_STATISTICS) //{ // mesh.DebugWriteInfo(); //} } break; } case MyRenderMessageEnum.UpdateModelProperties: { var rMessage = (MyRenderMessageUpdateModelProperties)message; var actor = MyIDTracker<MyActor>.FindByID(rMessage.ID); if (actor != null) { // careful, lod is ignored after all (properties apply to all lods) var key = new MyEntityMaterialKey { LOD = rMessage.LOD, Material = X.TEXT_(rMessage.MaterialName) }; if(rMessage.Enabled.HasValue) { if (!MyScene.EntityDisabledMaterials.ContainsKey(rMessage.ID)) { MyScene.EntityDisabledMaterials.Add(rMessage.ID, new HashSet<MyEntityMaterialKey>()); } if (!rMessage.Enabled.Value) { MyScene.EntityDisabledMaterials[rMessage.ID].Add(key); } else { MyScene.EntityDisabledMaterials[rMessage.ID].Remove(key); } } var renderableComponent = actor.GetRenderable(); if ((rMessage.Emissivity.HasValue || rMessage.DiffuseColor.HasValue) && !renderableComponent.ModelProperties.ContainsKey(key)) { renderableComponent.ModelProperties[key] = new MyModelProperties(); } if(rMessage.Emissivity.HasValue) { renderableComponent.ModelProperties[key].Emissivity = rMessage.Emissivity.Value; } if(rMessage.DiffuseColor.HasValue) { renderableComponent.ModelProperties[key].ColorMul = rMessage.DiffuseColor.Value; } actor.MarkRenderDirty(); MyHighlight.HandleHighlight(rMessage.ID, rMessage.MeshIndex, rMessage.OutlineColor, rMessage.OutlineThickness, rMessage.PulseTimeInFrames); } break; } case MyRenderMessageEnum.UpdateModelHighlight: { var rMessage = (MyRenderMessageUpdateModelHighlight)message; var actor = MyIDTracker<MyActor>.FindByID(rMessage.ID); if (actor != null) { MyHighlight.HandleHighlight(rMessage.ID, rMessage.SectionIndices, rMessage.OutlineColor, rMessage.Thickness, rMessage.PulseTimeInFrames, rMessage.InstanceIndex); if (rMessage.SubpartIndices != null) foreach (uint index in rMessage.SubpartIndices) if (index != -1) { MyHighlight.HandleHighlight(index, null, rMessage.OutlineColor, rMessage.Thickness, rMessage.PulseTimeInFrames, -1); } } break; } case MyRenderMessageEnum.UpdateColorEmissivity: { var rMessage = (MyRenderMessageUpdateColorEmissivity)message; var actor = MyIDTracker<MyActor>.FindByID(rMessage.ID); if (actor != null) { actor.GetRenderable().UpdateColorEmissivity(rMessage.LOD, rMessage.MaterialName, rMessage.DiffuseColor, rMessage.Emissivity); } break; } case MyRenderMessageEnum.PreloadModel: { var rMessage = (MyRenderMessagePreloadModel) message; //MyAssetsLoader.GetModel(rMessage.Name); MyMeshes.GetMeshId(X.TEXT_(rMessage.Name), rMessage.Rescale); break; } case MyRenderMessageEnum.ChangeMaterialTexture: { var rMessage = (MyRenderMessageChangeMaterialTexture)message; var actor = MyIDTracker<MyActor>.FindByID(rMessage.RenderObjectID); if (actor != null) { var r = actor.GetRenderable(); var key = new MyEntityMaterialKey { LOD = 0, Material = X.TEXT_(rMessage.MaterialName) }; MyModelProperties properties; if (!r.ModelProperties.TryGetValue(key, out properties)) { properties = new MyModelProperties(); r.ModelProperties[key] = properties; } properties.AddTextureChanges(rMessage.Changes); actor.MarkRenderDirty(); } rMessage.Changes.Clear(); break; } case MyRenderMessageEnum.RenderOffscreenTextureToMaterial: { var rMessage = (MyRenderMessageRenderOffscreenTextureToMaterial)message; var actor = MyIDTracker<MyActor>.FindByID(rMessage.RenderObjectID); if (actor != null) { var manager = MyManagers.FileTextures; IUserGeneratedTexture handle; if (!manager.TryGetTexture(rMessage.OffscreenTexture, out handle)) { var material = MyMeshMaterials1.GetMaterialId(rMessage.MaterialName).Info; ITexture materialTexture; switch (rMessage.TextureType) { case MyTextureType.ColorMetal: materialTexture = manager.GetTexture(material.ColorMetal_Texture, MyFileTextureEnum.COLOR_METAL, true); break; case MyTextureType.NormalGloss: materialTexture = manager.GetTexture(material.NormalGloss_Texture, MyFileTextureEnum.NORMALMAP_GLOSS, true); break; case MyTextureType.Extensions: materialTexture = manager.GetTexture(material.Extensions_Texture, MyFileTextureEnum.EXTENSIONS, true); break; case MyTextureType.Alphamask: materialTexture = manager.GetTexture(material.Alphamask_Texture, MyFileTextureEnum.ALPHAMASK, true); break; default: throw new Exception(); } handle = manager.CreateGeneratedTexture(rMessage.OffscreenTexture, materialTexture.Size.X, materialTexture.Size.Y, rMessage.TextureType, 1); } handle.Reset(); SharpDX.Color? backgroundColor = null; if (rMessage.BackgroundColor != null) backgroundColor = new SharpDX.Color(rMessage.BackgroundColor.Value.PackedValue); var texture = MyRender11.DrawSpritesOffscreen(rMessage.OffscreenTexture, handle.Size.X, handle.Size.Y, handle.Format, backgroundColor); var texture2 = MyManagers.RwTexturesPool.BorrowRtv("RenderOffscreenTextureBlend", handle.Size.X, handle.Size.Y, handle.Format); IBlendState blendState = rMessage.BlendAlphaChannel ? MyBlendStateManager.BlendAlphaPremult : MyBlendStateManager.BlendAlphaPremultNoAlphaChannel; MyBlendTargets.RunWithStencil(texture2, texture, blendState); texture.Release(); texture = texture2; MyImmediateRC.RC.CopyResource(texture, handle); texture.Release(); var renderableComponent = actor.GetRenderable(); var key = new MyEntityMaterialKey { LOD = 0, Material = X.TEXT_(rMessage.MaterialName) }; MyModelProperties modelProperty; if (!renderableComponent.ModelProperties.TryGetValue(key, out modelProperty)) renderableComponent.ModelProperties[key] = new MyModelProperties(); modelProperty.AddTextureChange(new MyTextureChange() { TextureName = rMessage.OffscreenTexture, TextureType = rMessage.TextureType }); actor.MarkRenderDirty(); } else { Debug.Assert(false, "Actor not found"); } break; } case MyRenderMessageEnum.PreloadMaterials: { var rMessage = (MyRenderMessagePreloadMaterials)message; //MyAssetsLoader.GetMaterials(rMessage.Name); MyMeshes.GetMeshId(X.TEXT_(rMessage.Name), 1.0f); break; } #endregion #region Voxels case MyRenderMessageEnum.CreateClipmap: { var rMessage = (MyRenderMessageCreateClipmap)message; var clipmap = new MyClipmapHandler(rMessage.ClipmapId, rMessage.ScaleGroup, rMessage.WorldMatrix, rMessage.SizeLod0, rMessage.Position, rMessage.PlanetRadius, rMessage.SpherizeWithDistance, rMessage.AdditionalRenderFlags, rMessage.PrunningFunc); MyClipmapFactory.ClipmapByID[rMessage.ClipmapId] = clipmap; clipmap.Base.LoadContent(); break; } case MyRenderMessageEnum.UpdateClipmapCell: { var rMessage = (MyRenderMessageUpdateClipmapCell)message; var clipmap = MyClipmapFactory.ClipmapByID.Get(rMessage.ClipmapId); MyRenderProxy.Assert(clipmap != null); if (clipmap != null) { clipmap.Base.UpdateCell(rMessage); } break; } case MyRenderMessageEnum.UpdateMergedVoxelMesh: { var rMessage = (MyRenderMessageUpdateMergedVoxelMesh)message; MyClipmapHandler clipmap = MyClipmapFactory.ClipmapByID.Get(rMessage.ClipmapId); if (clipmap != null) clipmap.UpdateMergedMesh(rMessage); break; } case MyRenderMessageEnum.ResetMergedVoxels: { var rMessage = (MyRenderMessageResetMergedVoxels)message; foreach(var clipmapHandler in MyClipmapFactory.ClipmapByID.Values) { if (clipmapHandler != null) clipmapHandler.ResetMergedMeshes(); } break; } case MyRenderMessageEnum.InvalidateClipmapRange: { var rMessage = (MyRenderMessageInvalidateClipmapRange)message; var clipmap = MyClipmapFactory.ClipmapByID.Get(rMessage.ClipmapId); if (clipmap != null) { clipmap.Base.InvalidateRange(rMessage.MinCellLod0, rMessage.MaxCellLod0); } break; } case MyRenderMessageEnum.CreateRenderVoxelMaterials: { var rMessage = (MyRenderMessageCreateRenderVoxelMaterials)message; MyRenderProxy.Assert(MyVoxelMaterials1.CheckIndices(rMessage.Materials)); MyVoxelMaterials1.Set(rMessage.Materials); rMessage.Materials = null; break; } case MyRenderMessageEnum.UpdateRenderVoxelMaterials: { var rMessage = (MyRenderMessageUpdateRenderVoxelMaterials)message; MyVoxelMaterials1.Set(rMessage.Materials, true); rMessage.Materials = null; break; } #endregion #region Lights case MyRenderMessageEnum.CreateRenderLight: { var rMessage = (MyRenderMessageCreateRenderLight)message; MyLights.Create(rMessage.ID); break; } case MyRenderMessageEnum.UpdateRenderLight: { var rMessage = (MyRenderMessageUpdateRenderLight)message; var light = MyLights.Get(rMessage.Data.ID); if(light != LightId.NULL) { var lightInfo = new MyLightInfo { FlareId = FlareId.NULL, SpotPosition = rMessage.Data.Position, PointPosition = rMessage.Data.Position + rMessage.Data.PointPositionOffset * rMessage.Data.PointLight.Range * rMessage.Data.SpotLight.Direction, CastsShadows = rMessage.Data.CastShadows, ShadowsDistance = rMessage.Data.ShadowDistance, ParentGID = rMessage.Data.ParentID, UsedInForward = rMessage.Data.UseInForwardRender }; MyLights.UpdateEntity(light, ref lightInfo); if (rMessage.Data.Type.HasFlag(LightTypeEnum.PointLight)) { MyLights.UpdatePointlight(light, rMessage.Data.PointLightOn, rMessage.Data.PointLightIntensity, rMessage.Data.PointLight); } if (rMessage.Data.Type.HasFlag(LightTypeEnum.Spotlight)) { MyLights.UpdateSpotlight(light, rMessage.Data.SpotLightOn, rMessage.Data.SpotLightIntensity, rMessage.Data.ReflectorConeMaxAngleCos, rMessage.Data.SpotLight, MyManagers.FileTextures.GetTexture(rMessage.Data.ReflectorTexture, MyFileTextureEnum.CUSTOM)); } light.FlareId = MyFlareRenderer.Update(rMessage.Data.ParentID, light.FlareId, rMessage.Data.Glare); } break; } case MyRenderMessageEnum.SetLightShadowIgnore: { var rMessage = (MyRenderMessageSetLightShadowIgnore)message; var light = MyLights.Get(rMessage.ID); var actor = MyIDTracker<MyActor>.FindByID(rMessage.ID2); if(light != LightId.NULL && actor != null) { if(!MyLights.IgnoredEntitites.ContainsKey(light)) { MyLights.IgnoredEntitites[light] = new HashSet<uint>(); } MyLights.IgnoredEntitites[light].Add(rMessage.ID2); } break; } case MyRenderMessageEnum.ClearLightShadowIgnore: { var rMessage = (MyRenderMessageClearLightShadowIgnore)message; var light = MyLights.Get(rMessage.ID); if(light != LightId.NULL) { MyLights.IgnoredEntitites.Remove(light); } break; } case MyRenderMessageEnum.UpdateShadowSettings: { var rMessage = (MyRenderMessageUpdateShadowSettings)message; MyShadowCascades.Settings.CopyFrom(rMessage.Settings); MyManagers.Shadow.SetSettings(rMessage.Settings); break; } case MyRenderMessageEnum.UpdateMaterialsSettings: { var rMessage = (MyRenderMessageUpdateMaterialsSettings)message; MyManagers.GeometryTextureSystem.SetMaterialsSettings(rMessage.Settings); break; } case MyRenderMessageEnum.UpdateFogSettings: { var rMessage = (MyRenderMessageUpdateFogSettings)message; if (m_debugOverrides.Fog) MyRender11.Environment.Fog = rMessage.Settings; else MyRender11.Environment.Fog.FogDensity = 0; break; } case MyRenderMessageEnum.UpdateAtmosphereSettings: { var rMessage = (MyRenderMessageUpdateAtmosphereSettings)message; MyAtmosphereRenderer.UpdateSettings(rMessage.ID, rMessage.Settings); break; } case MyRenderMessageEnum.EnableAtmosphere: { var rMessage = (MyRenderMessageEnableAtmosphere)message; MyAtmosphereRenderer.Enabled = rMessage.Enabled; break; } case MyRenderMessageEnum.UpdateCloudLayerFogFlag: { var rMessage = (MyRenderMessageUpdateCloudLayerFogFlag)message; MyCloudRenderer.DrawFog = rMessage.ShouldDrawFog; break; } case MyRenderMessageEnum.UpdateRenderEnvironment: { var rMessage = (MyRenderMessageUpdateRenderEnvironment)message; MyRender11.Environment.Data = rMessage.Data; m_resetEyeAdaptation |= rMessage.ResetEyeAdaptation; /*MyRender11.Environment.DirectionalLightDir = VRageMath.Vector3.Normalize(rMessage.SunDirection); if (rMessage.SunLightOn && m_debugOverrides.Sun) MyRender11.Environment.DirectionalLightIntensity = rMessage.SunColor; else MyRender11.Environment.DirectionalLightIntensity = new Vector3(0, 0, 0); for (int lightIndex = 0; lightIndex < MyRender11.Environment.AdditionalSunIntensities.Length; ++lightIndex) { MyRender11.Environment.AdditionalSunIntensities[lightIndex] = rMessage.AdditionalSunIntensities[lightIndex]; MyRender11.Environment.AdditionalSunColors[lightIndex] = rMessage.AdditionalSunColors[lightIndex]; MyRender11.Environment.AdditionalSunDirections[lightIndex] = rMessage.AdditionalSunDirections[lightIndex]; } MyRender11.Environment.DayTime = (float)(rMessage.DayTime - Math.Truncate(rMessage.DayTime)); MyRender11.Environment.SunDistance = rMessage.DistanceToSun; MyRender11.Environment.SunColor = rMessage.SunColor; MyRender11.Environment.SunMaterial = rMessage.SunMaterial; MyRender11.Environment.SunSizeMultiplier = rMessage.SunSizeMultiplier; MyRender11.Environment.SunBillboardEnabled = rMessage.SunBillboardEnabled; MyRender11.Environment.PlanetFactor = rMessage.PlanetFactor; MyRender11.Environment.Skybox = rMessage.DayBackgroundTexture; MyRender11.Environment.NightSkybox = rMessage.NightBackgroundTexture; MyRender11.Environment.NightSkyboxPrefiltered = rMessage.NightBackgroundPrefilteredTexture; MyRender11.Environment.BackgroundOrientation = rMessage.BackgroundOrientation; MyRender11.Environment.BackgroundColor = rMessage.BackgroundColor; m_resetEyeAdaptation |= rMessage.ResetEyeAdaptation;*/ break; } case MyRenderMessageEnum.UpdateEnvironmentMap: { break; } case MyRenderMessageEnum.UpdateDebugOverrides: { var rMessage = (MyRenderMessageUpdateDebugOverrides)message; bool oldFXAA = FxaaEnabled; m_debugOverrides = rMessage.Overrides; bool newFXAA = FxaaEnabled; if (oldFXAA != newFXAA) UpdateAntialiasingMode(m_renderSettings.AntialiasingMode, m_renderSettings.AntialiasingMode); break; } case MyRenderMessageEnum.UpdatePostprocessSettings: { var rMessage = (MyRenderMessageUpdatePostprocessSettings)message; Postprocess = rMessage.Settings; if (Postprocess.EnableEyeAdaptation != rMessage.Settings.EnableEyeAdaptation) m_resetEyeAdaptation = true; break; } case MyRenderMessageEnum.UpdateSSAOSettings: { var rMessage = (MyRenderMessageUpdateSSAOSettings)message; MySSAO.Params = rMessage.Settings; break; } case MyRenderMessageEnum.UpdateHBAO: { var rMessage = (MyRenderMessageUpdateHBAO)message; MyHBAO.Params = rMessage.Settings; break; } #endregion #region Sprites case MyRenderMessageEnum.DrawSprite: case MyRenderMessageEnum.DrawSpriteNormalized: case MyRenderMessageEnum.DrawSpriteAtlas: case MyRenderMessageEnum.SpriteScissorPush: case MyRenderMessageEnum.SpriteScissorPop: case MyRenderMessageEnum.DrawString: { m_drawQueue.Enqueue(message); break; } #endregion #region Fonts and text case MyRenderMessageEnum.CreateFont: { var createFontMessage = message as MyRenderMessageCreateFont; MyRenderProxy.Assert(createFontMessage != null); var renderFont = new MyRenderFont(createFontMessage.FontPath); renderFont.LoadContent(); AddFont(createFontMessage.FontId, renderFont, createFontMessage.IsDebugFont); break; } #endregion #region Textures // TODO: these messages need to be reviewed: case MyRenderMessageEnum.PreloadTextures: { var preloadMsg = message as MyRenderMessagePreloadTextures; //MyFileTextureManager.Load(preloadMsg.Texture); //MyTextureManager.PreloadTextures(preloadMsg.InDirectory, preloadMsg.Recursive); //MyTextures.UnloadTexture(texMessage.Texture); break; } case MyRenderMessageEnum.UnloadTexture: { var texMessage = (MyRenderMessageUnloadTexture)message; MyFileTextureManager texManager = MyManagers.FileTextures; texManager.DisposeTex(texMessage.Texture, true); // Ignore failures, the game can't know weather a texture is loaded. break; } case MyRenderMessageEnum.CreateGeneratedTexture: { var texMessage = (MyRenderMessageCreateGeneratedTexture)message; MyFileTextureManager texManager = MyManagers.FileTextures; texManager.CreateGeneratedTexture(texMessage.TextureName, texMessage.Width, texMessage.Height, texMessage.Type, texMessage.NumMipLevels); break; } case MyRenderMessageEnum.ResetGeneratedTexture: { var texMessage = (MyRenderMessageResetGeneratedTexture)message; MyFileTextureManager texManager = MyManagers.FileTextures; texManager.ResetGeneratedTexture(texMessage.TextureName, texMessage.Data); break; } case MyRenderMessageEnum.ReloadTextures: { var reloadMsg = (MyRenderMessageReloadTextures)message; MyVoxelMaterials1.InvalidateMaterials(); MyMeshMaterials1.InvalidateMaterials(); MyManagers.FileTextures.DisposeTex(MyFileTextureManager.MyFileTextureHelper.IsAssetTextureFilter); MyManagers.DynamicFileArrayTextures.ReloadAll(); MyGPUEmitters.ReloadTextures(); MyRender11.ReloadFonts(); break; } case MyRenderMessageEnum.ReloadModels: { var reloadMsg = (MyRenderMessageReloadModels)message; //MyMaterials.Clear(); MyAssetsLoader.ReloadMeshes(); MyRenderableComponent.MarkAllDirty(); break; } #endregion case MyRenderMessageEnum.TakeScreenshot: { var rMessage = (MyRenderMessageTakeScreenshot)message; m_screenshot = new MyScreenshot(rMessage.PathToSave, rMessage.SizeMultiplier, rMessage.IgnoreSprites, rMessage.ShowNotification); break; } case MyRenderMessageEnum.ReloadEffects: { //MyShaderBundleFactory.ClearCache(); //MyShaderMaterial.ClearCache(); //MyShaderPass.ClearCache(); MyShaders.Recompile(); MyMaterialShaders.Recompile(); MyAtmosphereRenderer.RecomputeAtmospheres(); MyRenderableComponent.MarkAllDirty(); foreach (var f in MyComponentFactory<MyFoliageComponent>.GetAll()) { f.Dispose(); } break; } case MyRenderMessageEnum.ReloadGrass: { MyRenderProxy.ReloadEffects(); // Need some delay break; } case MyRenderMessageEnum.PlayVideo: { var rMessage = (MyRenderMessagePlayVideo)message; MyVideoFactory.Create(rMessage.ID, rMessage.VideoFile); var video = MyVideoFactory.Videos.Get(rMessage.ID); if (video != null) { video.Volume = rMessage.Volume; } break; } case MyRenderMessageEnum.CloseVideo: { var rMessage = (MyRenderMessageCloseVideo)message; MyVideoFactory.Remove(rMessage.ID); MyRenderProxy.RemoveMessageId(rMessage.ID, MyRenderProxy.ObjectType.Video); break; } case MyRenderMessageEnum.UpdateGameplayFrame: { var rMessage = (MyRenderMessageUpdateGameplayFrame)message; GameplayFrameCounter = rMessage.GameplayFrame; break; } case MyRenderMessageEnum.DrawVideo: { var rMessage = (MyRenderMessageDrawVideo)message; var video = MyVideoFactory.Videos.Get(rMessage.ID); if (video != null) { video.Draw(rMessage.Rectangle, rMessage.Color, rMessage.FitMode); } break; } case MyRenderMessageEnum.UpdateVideo: { var rMessage = (MyRenderMessageUpdateVideo)message; var video = MyVideoFactory.Videos.Get(rMessage.ID); if(video != null) { video.Update(); } break; } case MyRenderMessageEnum.SetVideoVolume: { var rMessage = (MyRenderMessageSetVideoVolume)message; var video = MyVideoFactory.Videos.Get(rMessage.ID); if (video != null) { video.Volume = rMessage.Volume; } break; } case MyRenderMessageEnum.VideoAdaptersRequest: { MyRenderProxy.SendVideoAdapters(GetAdaptersList()); break; } case MyRenderMessageEnum.SwitchDeviceSettings: { MyRenderProxy.RenderThread.SwitchSettings((message as MyRenderMessageSwitchDeviceSettings).Settings); break; } case MyRenderMessageEnum.SwitchRenderSettings: { var rMessage = (MyRenderMessageSwitchRenderSettings)message; if (rMessage.Settings.HasValue) UpdateRenderSettings(rMessage.Settings.Value); if (rMessage.SettingsOld.HasValue) MyRender11.Settings = rMessage.SettingsOld.Value; break; } case MyRenderMessageEnum.SetMouseCapture: { var umc = message as MyRenderMessageSetMouseCapture; MyRenderProxy.RenderThread.SetMouseCapture(umc.Capture); break; } case MyRenderMessageEnum.UnloadData: { MyRender11.UnloadData(); // FIXME: Move this to MyRenderProxy.UnloadData() when decals (and maybe other subsystems) // moved lifetime of render object ids entirely to render thread MyRenderProxy.CheckRenderObjectIds(); break; } case MyRenderMessageEnum.CollectGarbage: { GC.Collect(); break; } case MyRenderMessageEnum.SetFrameTimeStep: { var rMessage = message as MyRenderMessageSetFrameTimeStep; MyCommon.SetFrameTimeStep(rMessage.TimeStep); break; } case MyRenderMessageEnum.ResetRandomness: { var rMessage = message as MyRenderMessageResetRandomness; MyCommon.SetRandomSeed(rMessage.Seed); break; } case MyRenderMessageEnum.RenderColoredTexture: { var rMessage = (MyRenderMessageRenderColoredTexture)message; m_texturesToRender.AddRange(rMessage.texturesToRender); break; } case MyRenderMessageEnum.CreateGPUEmitter: { var rMessage = (MyRenderMessageCreateGPUEmitter)message; //MyLight.Create(rMessage.ID); MyGPUEmitters.Create(rMessage.ID); break; } case MyRenderMessageEnum.UpdateGPUEmitters: { var rMessage = (MyRenderMessageUpdateGPUEmitters)message; MyGPUEmitters.UpdateData(rMessage.Emitters); break; } case MyRenderMessageEnum.UpdateGPUEmittersTransform: { var rMessage = (MyRenderMessageUpdateGPUEmittersTransform)message; MyGPUEmitters.UpdateTransforms(rMessage.Emitters); break; } case MyRenderMessageEnum.UpdateGPUEmittersLight: { var rMessage = (MyRenderMessageUpdateGPUEmittersLight)message; MyGPUEmitters.UpdateLight(rMessage.Emitters); break; } case MyRenderMessageEnum.RemoveGPUEmitter: { var rMessage = (MyRenderMessageRemoveGPUEmitter)message; MyGPUEmitters.Remove(rMessage.GID, rMessage.Instant, false); MyRenderProxy.RemoveMessageId(rMessage.GID, MyRenderProxy.ObjectType.GPUEmitter); break; } #region Debug case MyRenderMessageEnum.DebugDrawPoint: case MyRenderMessageEnum.DebugDrawLine3D: case MyRenderMessageEnum.DebugDrawLine2D: case MyRenderMessageEnum.DebugDrawSphere: case MyRenderMessageEnum.DebugDrawAABB: case MyRenderMessageEnum.DebugDrawAxis: case MyRenderMessageEnum.DebugDrawOBB: case MyRenderMessageEnum.DebugDraw6FaceConvex: case MyRenderMessageEnum.DebugDrawCone: case MyRenderMessageEnum.DebugDrawTriangle: case MyRenderMessageEnum.DebugDrawCapsule: case MyRenderMessageEnum.DebugDrawText2D: case MyRenderMessageEnum.DebugDrawText3D: case MyRenderMessageEnum.DebugDrawModel: case MyRenderMessageEnum.DebugDrawTriangles: case MyRenderMessageEnum.DebugDrawPlane: case MyRenderMessageEnum.DebugDrawCylinder: case MyRenderMessageEnum.DebugDrawFrustrum: case MyRenderMessageEnum.DebugDrawMesh: case MyRenderMessageEnum.DebugWaitForPresent: case MyRenderMessageEnum.DebugClearPersistentMessages: { m_debugDrawMessages.Enqueue(message); } break; case MyRenderMessageEnum.DebugCrashRenderThread: { throw new InvalidOperationException("Forced exception"); } case MyRenderMessageEnum.DebugPrintAllFileTexturesIntoLog: { MyRender11.Log.WriteLine(MyManagers.FileTextures.GetFileTexturesDesc().ToString());; MyRender11.Log.WriteLine(MyManagers.FileArrayTextures.GetFileTexturesDesc().ToString()); break; } #endregion } }
unsafe void CreateRGBA(MyGeneratedTexture tex, string name, Vector2I resolution, bool srgb, Color[] colors, int numMipLevels = 1) { int width = resolution.X; int height = resolution.Y; byte[] rawData = new byte[width * height * 4]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int offset = x + y * width; Color currentColor = colors[offset]; rawData[offset * 4 + 0] = currentColor.R; rawData[offset * 4 + 1] = currentColor.G; rawData[offset * 4 + 2] = currentColor.B; rawData[offset * 4 + 3] = currentColor.A; } } CreateRGBA(tex, name, resolution, srgb, rawData); }
void CreateCubeRGBA_1x1(MyGeneratedTexture tex, string name, Color color) { Texture2DDescription desc = m_descDefault; desc.Format = Format.R8G8B8A8_UNorm; desc.Height = 1; desc.Width = 1; desc.ArraySize = 6; desc.OptionFlags = ResourceOptionFlags.TextureCube; tex.Init(name, desc, new Vector2I(1, 1), 4); int data = color.ToRgba(); ResetCube(tex, data); }