Exemplo n.º 1
0
 public Material()
 {
     AmbientColor = new ColorRgbF(0.1f, 0.1f, 0.1f);
     DiffuseColor = ColorsRgbF.White;
     SpecularColor = ColorsRgbF.White;
     Shininess = 16;
     Transparency = 1;
 }
Exemplo n.º 2
0
 public Material()
 {
     AmbientColor  = new ColorRgbF(0.1f, 0.1f, 0.1f);
     DiffuseColor  = ColorsRgbF.White;
     SpecularColor = ColorsRgbF.White;
     Shininess     = 16;
     Transparency  = 1;
 }
Exemplo n.º 3
0
        public static void PersistColorRgbF(this StatePersister persister, ref ColorRgbF value, [CallerArgumentExpression("value")] string name = "")
        {
            persister.BeginObject(name);

            var r = value.R;

            persister.PersistSingle(ref r);

            var g = value.G;

            persister.PersistSingle(ref g);

            var b = value.B;

            persister.PersistSingle(ref b);

            persister.EndObject();

            if (persister.Mode == StatePersistMode.Read)
            {
                value = new ColorRgbF(r, g, b);
            }
        }
Exemplo n.º 4
0
        public override void Parse(ParserContext context, Scene scene, string[] words)
        {
            // "f" red green blue Kd Ks Shine T index_of_refraction

            float r = float.Parse(words[1]);
            float g = float.Parse(words[2]);
            float b = float.Parse(words[3]);

            float kd    = float.Parse(words[4]);
            float ks    = float.Parse(words[5]);
            float shine = float.Parse(words[6]);

            ColorRgbF color = new ColorRgbF(r, g, b);

            Material material = new Material
            {
                DiffuseColor  = color * kd,
                SpecularColor = color * ks,
                Shininess     = (int)shine
            };

            scene.Materials.Add(material);
            context.CurrentMaterial = material;
        }
Exemplo n.º 5
0
        public override void Parse(ParserContext context, Scene scene, string[] words)
        {
            // "f" red green blue Kd Ks Shine T index_of_refraction

            float r = float.Parse(words[1]);
            float g = float.Parse(words[2]);
            float b = float.Parse(words[3]);

            float kd = float.Parse(words[4]);
            float ks = float.Parse(words[5]);
            float shine = float.Parse(words[6]);

            ColorRgbF color = new ColorRgbF(r, g, b);

            Material material = new Material
            {
                DiffuseColor = color * kd,
                SpecularColor = color * ks,
                Shininess = (int)shine
            };

            scene.Materials.Add(material);
            context.CurrentMaterial = material;
        }
Exemplo n.º 6
0
        static DefaultInspectable()
        {
            Drawers = new List <InspectableDrawer>();

            Drawers.Add(new InspectableDrawer(typeof(string), (ref object v, DiagnosticViewContext context) =>
            {
                var s = (string)v;
                if (ImGui.InputText("", ref s, 1000))
                {
                    v = s;
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(bool), (ref object v, DiagnosticViewContext context) =>
            {
                var b = (bool)v;
                if (ImGui.Checkbox("", ref b))
                {
                    v = b;
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(int), (ref object v, DiagnosticViewContext context) =>
            {
                var i = (int)v;
                if (ImGui.DragInt("", ref i))
                {
                    v = i;
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(float), (ref object v, DiagnosticViewContext context) =>
            {
                var f = (float)v;
                if (ImGui.DragFloat("", ref f))
                {
                    v = f;
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(Vector3), (ref object v, DiagnosticViewContext context) =>
            {
                var c = (Vector3)v;
                if (ImGui.DragFloat3("", ref c))
                {
                    v = c;
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(Percentage), (ref object v, DiagnosticViewContext context) =>
            {
                var f = (float)(Percentage)v;
                if (ImGui.DragFloat("", ref f))
                {
                    v = new Percentage(f);
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(ColorRgb), (ref object v, DiagnosticViewContext context) =>
            {
                var c = ((ColorRgb)v).ToVector3();
                if (ImGui.ColorEdit3("", ref c))
                {
                    v = new ColorRgb(
                        (byte)(c.X * 255.0f),
                        (byte)(c.Y * 255.0f),
                        (byte)(c.Z * 255.0f));
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(ColorRgba), (ref object v, DiagnosticViewContext context) =>
            {
                var c = ((ColorRgba)v).ToVector4();
                if (ImGui.ColorEdit4("", ref c))
                {
                    v = new ColorRgba(
                        (byte)(c.X * 255.0f),
                        (byte)(c.Y * 255.0f),
                        (byte)(c.Z * 255.0f),
                        (byte)(c.W * 255.0f));
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(ColorRgbF), (ref object v, DiagnosticViewContext context) =>
            {
                var c = ((ColorRgbF)v).ToVector3();
                if (ImGui.ColorEdit3("", ref c))
                {
                    v = new ColorRgbF(c.X, c.Y, c.Z);
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(ColorRgbaF), (ref object v, DiagnosticViewContext context) =>
            {
                var c = ((ColorRgbaF)v).ToVector4();
                if (ImGui.ColorEdit4("", ref c))
                {
                    v = new ColorRgbaF(c.X, c.Y, c.Z, c.W);
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(Enum), (ref object v, DiagnosticViewContext context) =>
            {
                var e = (Enum)v;
                if (ImGuiUtility.ComboEnum(v.GetType(), "", ref e))
                {
                    v = e;
                    return(true);
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(ILazyAssetReference), (ref object v, DiagnosticViewContext context) =>
            {
                var asset = (ILazyAssetReference)v;
                if (asset.Value != null)
                {
                    if (ImGui.Button(asset.Value.FullName))
                    {
                        context.SelectedObject = asset.Value;
                    }
                }
                else
                {
                    ImGui.Text("<null>");
                }
                return(false);
            }));

            Drawers.Add(new InspectableDrawer(typeof(BaseAsset), (ref object v, DiagnosticViewContext context) =>
            {
                var asset = (BaseAsset)v;
                if (ImGui.Button(asset.FullName))
                {
                    context.SelectedObject = v;
                }
                return(false);
            }));

            // Order matters here - this must be last.
            Drawers.Add(new InspectableDrawer(typeof(object), (ref object v, DiagnosticViewContext context) =>
            {
                return(false);
            }, hasChildNodes: true));
        }
Exemplo n.º 7
0
 private static Vector3 ConvertColorRgbF(ColorRgbF color)
 {
     return(new Vector3(color.R, color.G, color.B));
 }
Exemplo n.º 8
0
		public static Vector3 ToSharpDXVector3(ColorRgbF c)
		{
			return new Vector3(c.R, c.G, c.B);
		}
Exemplo n.º 9
0
 public static Vector3 ToSharpDXVector3(ColorRgbF c)
 {
     return(new Vector3(c.R, c.G, c.B));
 }
Exemplo n.º 10
0
 public static ColorRgbF ToNexusColorRgbF(Color c)
 {
     return(ColorRgbF.FromRgbColor(Nexus.Color.FromArgb(c.A, c.R, c.G, c.B)));
 }