public Color4f(Color4f color) { m_r = color.R; m_g = color.G; m_b = color.B; m_a = color.A; }
public void Renderer() { MyAsyncRenderContext aRC = this; RenderWindow rw = aRC.RenderWindow; if (null != rw) { Size size = rw.Size(); using (RenderWindow.Channel channel = rw.OpenChannel(Rhino.Render.RenderWindow.StandardChannels.RGBA)) { for (int x = 0; x < size.Width; x++) { for (int y = 0; y < size.Height; y++) { Rhino.Display.Color4f color = new Rhino.Display.Color4f(y / (float)size.Width, x / (float)size.Height, 1.0f, 1.0f); channel.SetValue(x, y, color); rw.Invalidate(); Thread.Sleep(0); } float progress = x / (float)size.Width; rw.SetProgress(String.Format("Rendering C# rendering {0:d}% complete", (int)(progress * 100.0f)), progress); Thread.Sleep(1); if (aRC.CancelRender) { break; } } rw.SetProgress("Rendering complete", 1.0f); Thread.Sleep(10); } rw.EndAsyncRender(RenderWindow.RenderSuccessCode.Completed); } }
public Color4f BlendTo(float t, Color4f col) { float r = m_r + (t * (col.m_r - m_r)); float g = m_g + (t * (col.m_g - m_g)); float b = m_b + (t * (col.m_b - m_b)); float a = m_a + (t * (col.m_a - m_a)); return(new Color4f(r, g, b, a)); }
public static Color4f ApplyGamma(Color4f col, float gamma) { if (Math.Abs(gamma - 1.0f) > float.Epsilon) { float r = (float)Math.Pow(col.m_r, gamma); float g = (float)Math.Pow(col.m_g, gamma); float b = (float)Math.Pow(col.m_b, gamma); return(new Color4f(r, g, b, col.m_a)); } return(col); }
public FlakedCarPaintMaterial() { var flake1 = new Color4f(0.002f, 0.502f, 0.002f, 1.0f); var shine1 = new Color4f(0.0f, 0.048f, 0.5f, 1.0f); var flake2 = new Color4f(0.098f, 0.503f, 0.102f, 1.0f); var shine2 = new Color4f(0.503f, 0.0f, 0.001f, 1.0f); Fields.Add("flake1", flake1, "Flake Color 1"); Fields.Add("shine1", shine1, "Coat Shine 1"); Fields.Add("flake2", flake2, "Flake Color 2"); Fields.Add("shine2", shine2, "Coat Shine 2"); Fields.Add("flakesize", 0.0, "Flake Size"); Fields.Add("fresnel", 1.56f, "Fresnel"); Fields.Add("gamma", 1.0f, "Flake and Shine Mix Factor"); }
internal static extern int Rdk_Decal_Color(IntPtr pDecal, Point3d point, Vector3d normal, ref Color4f pColInOut, ref Point2d pUvOut);
internal static extern void Rdk_RenderWindowChannel_SetColorValue(IntPtr pChannel, int x, int y, Color4f value);
internal static extern void Rdk_ContentField_ColorValue(IntPtr pField, ref Color4f p);
internal static extern void Rdk_ContentField_SetColorValue(IntPtr pField, Color4f v, int iCC);
internal static extern void Rdk_Variant_SetRdkColorValue(IntPtr pV, Color4f v);
internal static extern int Rdk_Variant_GetRdkColorValue(IntPtr pV, ref Color4f p);
internal static extern void Rdk_SimulatedTexture_SetTransparentColor(IntPtr pSim, Color4f v);
internal static extern bool Rdk_TextureEvaluator_GetColor(IntPtr pConstTextureEvaluator, Point3d uvw, Vector3d duvwdx, Vector3d duvwdy, ref Color4f color);
/// <summary> /// Update the RenderWindow or RenderBitmap with the updated tile from /// Cycles render progress. /// </summary> /// <param name="sessionId"></param> /// <param name="tx"></param> /// <param name="ty"></param> /// <param name="tw"></param> /// <param name="th"></param> public void DisplayBuffer(uint sessionId, uint tx, uint ty, uint tw, uint th) { if (IsStopped) return; var start = DateTime.Now; var rg = RenderBitmap; if (RenderWindow != null) { using (var channel = RenderWindow.OpenChannel(RenderWindow.StandardChannels.RGBA)) { if (channel != null) { var pixelbuffer = new PixelBuffer(CSycles.session_get_buffer(Client.Id, sessionId)); var size = Client.Scene.Camera.Size; var rect = new Rectangle((int) tx, (int) ty, (int) tw, (int) th); channel.SetValues(rect, size, pixelbuffer); RenderWindow.InvalidateArea(rect); } } } else if (rg != null) { uint buffer_size; uint buffer_stride; var width = RenderDimension.Width; CSycles.session_get_buffer_info(Client.Id, sessionId, out buffer_size, out buffer_stride); var pixels = CSycles.session_copy_buffer(Client.Id, sessionId, buffer_size); for (var x = (int)tx; x < (int)(tx + tw); x++) { for (var y = (int)ty; y < (int)(ty + th); y++) { var i = y * width * 4 + x * 4; var r = pixels[i]; var g = pixels[i + 1]; var b = pixels[i + 2]; var a = pixels[i + 3]; r = Math.Min(Math.Abs(r), 1.0f); g = Math.Min(Math.Abs(g), 1.0f); b = Math.Min(Math.Abs(b), 1.0f); a = Math.Min(Math.Abs(a), 1.0f); var c4_f = new Color4f(r, g, b, a); rg.SetPixel(x, y, c4_f.AsSystemColor()); } } } var diff = (DateTime.Now - start).TotalMilliseconds; }
public Color4f BlendTo(float t, Color4f col) { float r = m_r + (t * (col.m_r - m_r)); float g = m_g + (t * (col.m_g - m_g)); float b = m_b + (t * (col.m_b - m_b)); float a = m_a + (t * (col.m_a - m_a)); return new Color4f(r, g, b, a); }
internal static extern void Rdk_RenderWindowChannel_SetValueRect(IntPtr pChannel, int x, int y, int width, int height, Color4f[] colors);
internal static extern int Rdk_Globals_ShowColorPicker(IntPtr hWnd, Color4f v, [MarshalAs(UnmanagedType.U1)]bool bUseAlpha, ref Color4f pColor);
public static Color4f FromArgb(float a, Color4f color) { return(new Color4f(color.R, color.G, color.B, a)); }
internal static extern void Rdk_SimulatedTexture_TransparentColor(IntPtr pSim, ref Color4f p);
public static Color4f FromArgb(float a, Color4f color) { return new Color4f(color.R, color.G, color.B, a); }