예제 #1
0
        public override void use(ClientPlayerInfo p, string message)
        {
            Random r     = new Random();
            float  color = (float)r.NextDouble() * 360;

            Utilities.sendMessage("[b][" + ColorEx.ColorToHexNGUI(new ColorHSB(color, 1.0f, 1.0f, 1f).ToColor()) + "]" + winList[r.Next(winList.Count)] + "[-][/b]");
        }
예제 #2
0
파일: Translator.cs 프로젝트: axiom3d/axiom
            /// <summary>
            /// Converts the range of nodes to a ColourValue and returns true if successful
            /// </summary>
            /// <param name="nodes"></param>
            /// <param name="i"></param>
            /// <param name="result"></param>
            /// <param name="maxEntries"></param>
            /// <returns>true if successful</returns>
            protected static bool getColor(IList <AbstractNode> nodes, int i, out ColorEx result, int maxEntries)
            {
                var vals = new Real[4]
                {
                    0, 0, 0, 0
                };

                result = ColorEx.White;

                if (nodes == null)
                {
                    return(false);
                }

                var n = 0;

                while (i != nodes.Count && n < maxEntries)
                {
                    if (nodes[i] is AtomAbstractNode && ((AtomAbstractNode)nodes[i]).IsNumber)
                    {
                        vals[n] = ((AtomAbstractNode)nodes[i]).Number;
                    }
                    else
                    {
                        return(false);
                    }
                    ++n;
                    ++i;
                }

                result = new ColorEx(vals[0], vals[1], vals[2], vals[3]);
                // return error if we found less than rgb before end, unless constrained
                return(n >= 3 || n == maxEntries);
            }
예제 #3
0
 public ColorRect(ColorEx color)
 {
     for (int i = 0; i < colors.Length; ++i)
     {
         colors[i] = color;
     }
 }
예제 #4
0
 private void InitEditor()
 {
     this.buttonOk.Label      = LanguageInfo.Dialog_ButtonOK;
     this.buttonOk.Name       = "MainButton";
     this.buttonCancel.Label  = LanguageInfo.Dialog_ButtonCancel;
     this.combox              = new ComboBoxEntry();
     this.combox.WidthRequest = 60;
     this.hbox1.Add((Widget)this.combox);
     Box.BoxChild boxChild1 = (Box.BoxChild) this.hbox1[(Widget)this.combox];
     this.colorButtonGtk = new ColorEx();
     this.colorButtonGtk.WidthRequest = 105;
     this.hbox1.Add((Widget)this.colorButtonGtk);
     Box.BoxChild boxChild2 = (Box.BoxChild) this.hbox1[(Widget)this.colorButtonGtk];
     this.textEntry = new Entry();
     this.textEntry.WidthRequest = 278;
     this.vbox2.Add((Widget)this.textEntry);
     ((Box.BoxChild) this.vbox2[(Widget)this.textEntry]).Position = 0;
     if (Platform.IsMac)
     {
         Box.BoxChild boxChild3 = (Box.BoxChild) this.hbox1[(Widget)this.buttonOk];
         Box.BoxChild boxChild4 = (Box.BoxChild) this.hbox1[(Widget)this.buttonCancel];
         boxChild1.Position = 1;
         boxChild2.Position = 2;
         boxChild3.Position = 3;
         boxChild4.Position = 4;
     }
     this.fontSizeSpinButton.SetRange(5.0, 100.0);
     this.ShowAll();
     this.fontSizeSpinButton.Hide();
     this.FontSizeComboxInit();
     this.InitText();
     this.InitEvent();
     this.textview.AcceptsTab = false;
 }
예제 #5
0
 private void fromXml(System.Xml.XmlReader r)
 {
     // Parse sub-elements
     while (r.Read())
     {
         if (r.NodeType == XmlNodeType.Whitespace)
         {
             continue;
         }
         // look for the start of an element
         if (r.NodeType == XmlNodeType.Element)
         {
             // parse that element
             // save the name of the element
             string elementName = r.Name;
             switch (elementName)
             {
             case "Color":
                 color = XmlHelperClass.ParseColorAttributes(r);
                 break;
             }
         }
         else if (r.NodeType == XmlNodeType.EndElement)
         {
             break;
         }
     }
 }
예제 #6
0
 public RSClearOperation(FrameBuffer buffers, ColorEx color, float depth, int stencil)
 {
     this.buffers = buffers;
     this.color   = color;
     this.depth   = depth;
     this.stencil = stencil;
 }
예제 #7
0
        private void setSubtitleProp(Subtitle sub)
        {
            if (CanvasMain.Kernel.SelectedShapesCount == 1)
            {
                RectShape rect = getSelectedRect();

                if (sub.transparent)
                {
                    rect.setTextProperty(TextProperty.BackColor, Color.Transparent);
                }
                else
                {
                    rect.setTextProperty(TextProperty.BackColor, ColorEx.FromHtml(sub.backcolor));
                }
                rect.setTextProperty(TextProperty.FontName, sub.fontname);
                rect.setTextProperty(TextProperty.FontSize, sub.fontsize);
                rect.setTextProperty(TextProperty.Bold, sub.bold);
                rect.setTextProperty(TextProperty.Italic, sub.italic);
                rect.setTextProperty(TextProperty.Underline, sub.underline);
                rect.setTextProperty(TextProperty.Direction, sub.direction);
                rect.setTextProperty(TextProperty.Speed, sub.speed);
                rect.setTextProperty(TextProperty.Text, sub.text);
                rect.setTextProperty(TextProperty.FontColor, ColorEx.FromHtml(sub.fontcolor));
            }
        }
예제 #8
0
        protected override Color GetCurrentValueCore(Color defaultOriginValue, Color defaultDestinationValue, AnimationClock animationClock)
        {
            System.Diagnostics.Debug.Assert(animationClock.CurrentState != ClockState.Stopped);
            if (!_isAnimationFunctionValid)
            {
                ValidateAnimationFunction();
            }
            double          progress       = animationClock.CurrentProgress.Value;
            IEasingFunction easingFunction = EasingFunction;

            if (easingFunction != null)
            {
                progress = easingFunction.Ease(progress);
            }
            double fromVal = _keyvalues[0];
            double toVal   = _keyvalues[1];
            double target;

            if (fromVal > toVal)
            {
                target = (1 - progress) * (fromVal - toVal) + toVal;
            }
            else
            {
                target = (toVal - fromVal) * progress + fromVal;
            }
            Color originColor = OriginColor;

            if (target == 0)
            {
                return(originColor);
            }
            return(ColorEx.ChangeColorBrightness(originColor, target));
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            ColorEx color = (ColorEx)value;

            using (ColorDialog colorDialog = new ColorDialog())
            {
                colorDialog.AllowFullOpen = true;
                colorDialog.AnyColor      = true;
                colorDialog.FullOpen      = true;
                colorDialog.ShowHelp      = true;
                colorDialog.Color         = ColorExToColor(color);
                int colorabgr = (int)color.ToABGR();
                colorabgr &= 0x00ffffff;
                int[] colorsabgr = new int[1];
                colorsabgr[0]            = colorabgr;
                colorDialog.CustomColors = colorsabgr;
                DialogResult result = colorDialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    color = ColorToColorEx(colorDialog.Color);
                }
                colorDialog.Color = ColorExToColor(color);
            }
            return(color);
        }
예제 #10
0
 private IEnumerator OnDeserialized()
 {
     if (base.GetComponent <EmptyObjectIdentifier>())
     {
         UnityEngine.Object.Destroy(base.gameObject);
         yield break;
     }
     if (BoltNetwork.isRunning)
     {
         while (!base.entity || !base.entity.isAttached)
         {
             yield return(null);
         }
     }
     if (this._color.a > 0f)
     {
         int a = ColorEx.ClosestColorIndex(this._color, new Color[]
         {
             Color.white,
             Color.yellow,
             Color.green,
             Color.magenta,
             Color.red,
             Color.blue
         });
         this._color.a = -1f;
         this._overlayIcon.SetColorIndex(Mathf.Max(a, 1));
     }
     this.SetTargetColor();
     yield break;
 }
예제 #11
0
        public static Color grayer_color(Color col)
        {
            ColorEx ex = new ColorEx(col);

            ex.S = (byte)(ex.S / 5);
            return(ex.Color);
        }
예제 #12
0
        public static Color darker_color(Color col)
        {
            var argb = col.ToArgb();

            if (argb == Color.White.ToArgb())
            {
                return(Color.WhiteSmoke);
            }
            if (argb == Color.WhiteSmoke.ToArgb())
            {
                return(Color.LightGray);
            }
            if (argb == Color.LightGray.ToArgb())
            {
                return(Color.DarkGray);
            }
            if (argb == Color.DarkGray.ToArgb())
            {
                return(Color.Gray);
            }

            ColorEx      ex     = new ColorEx(col);
            const double mul_by = 2.3;

            ex.S = (byte)(ex.S * mul_by > 100 ? 100 : ex.S * mul_by);
            Color darker = ex.Color;

            if (darker.ToArgb() == col.ToArgb())
            {
                // basically, we never want to return the same color
                return(grayer_color(col));
            }

            return(darker);
        }
예제 #13
0
        private void Unpack(ref ColorEx dst, int x, int y, int z, PixelFormat format, BufferBase src, PixelBox srcbox,
                            int elemsize)
        {
            var data = src + (elemsize * ((x) + (y) * srcbox.RowPitch + (z) * srcbox.SlicePitch));

            dst = PixelConverter.UnpackColor(format, data);
        }
예제 #14
0
        public CustomStyle ToStyle()
        {
            return(new CustomStyle
            {
                Name = Name,

                Font = Font,
                UseDefaultFont = DefFont,

                Foreground = ColorEx.FromInt(Foreground),
                UseDefaultForeground = DefForeground,

                Background = ColorEx.FromInt(Background),
                UseDefaultBackground = DefBackground,

                Opacity = Opacity,
                UseDefaultOpacity = DefOpacity,

                Size = Size,
                UseDefaultSize = DefSize,

                Italic = Italic,
                UseDefaultItalic = DefItalic,

                Bold = Bold,
                UseDefaultBold = DefBold,

                Underline = Underline,
                UseDefaultUnderline = DefUnderline,

                Strikethrough = Strikethrough,
                UseDefaultStrikethrough = DefStrikethrough,
            });
        }
 public void Write(ColorEx color)
 {
     writer.Write((byte)(color.a * 255));
     writer.Write((byte)(color.b * 255));
     writer.Write((byte)(color.g * 255));
     writer.Write((byte)(color.r * 255));
 }
예제 #16
0
 public GlobalAmbientLight(IWorldContainer parentContainer, WorldEditor worldEditor, SceneManager sceneManager, ColorEx lightColor)
 {
     this.parent = parentContainer;
     this.app    = worldEditor;
     this.scene  = sceneManager;
     this.color  = lightColor;
 }
예제 #17
0
 public GlobalAmbientLight(IWorldContainer parentContainer, WorldEditor worldEditor)
 {
     this.app    = worldEditor;
     this.parent = parentContainer;
     this.scene  = app.Scene;
     this.color  = app.Config.DefaultAmbientLightColor;
 }
예제 #18
0
        public void ApplyUserLabelTheme(string User)
        {
            var UserLabelAnimation = "DefaultButtn";

            if (Content.AnimationIsRunning(UserLabelAnimation))
            {
                Content.AbortAnimation(UserLabelAnimation);
            }
            var Theme = AlphaTheme.Get();

            if (!String.IsNullOrWhiteSpace(User))
            {
                AlphaTheme.Apply(UserLabel, Theme);
            }
            else
            {
                Content.Animate
                (
                    UserLabelAnimation,
                    d =>
                {
                    var Rate                  = Math.Abs(Math.Sin(d));
                    UserLabel.TextColor       = ColorEx.MergeWithRate(Theme.AccentColor, Theme.BackgroundColor, Rate);
                    UserLabel.BackgroundColor = ColorEx.MergeWithRate(Theme.BackgroundColor, Theme.AccentColor, Rate);
                },
                    0.0,
                    1000.0,
                    16,
                    (uint)2000000,
                    Easing.Linear
                );
            }
        }
예제 #19
0
        public static Color darker_color(Color col)
        {
            if (col.ToArgb() == Color.White.ToArgb())
            {
                return(Color.WhiteSmoke);
            }
            if (col.ToArgb() == Color.WhiteSmoke.ToArgb())
            {
                return(Color.LightGray);
            }
            if (col.ToArgb() == Color.LightGray.ToArgb())
            {
                return(Color.DarkGray);
            }
            if (col.ToArgb() == Color.DarkGray.ToArgb())
            {
                return(Color.Gray);
            }

            ColorEx      ex     = new ColorEx(col);
            const double mul_by = 2.3;

            ex.S = (byte)(ex.S * mul_by > 100 ? 100 : ex.S * mul_by);
            return(ex.Color);
        }
예제 #20
0
        public static Color grayer_color(Color col)
        {
            var argb = col.ToArgb();

            if (argb == Color.Blue.ToArgb())
            {
                return(Color.DodgerBlue);
            }
            if (argb == Color.Green.ToArgb())
            {
                return(Color.LightGreen);
            }
            if (argb == Color.Red.ToArgb())
            {
                return(Color.LightCoral);
            }
            if (argb == Color.Pink.ToArgb())
            {
                return(Color.LightPink);
            }
            if (argb == Color.Black.ToArgb())
            {
                return(Color.Gray);
            }
            if (argb == Color.Gray.ToArgb())
            {
                return(Color.DarkGray);
            }

            ColorEx ex = new ColorEx(col);

            ex.S = (byte)(ex.S / 5);
            return(ex.Color);
        }
예제 #21
0
        private void diffuseSelectButton_Click(object sender, EventArgs e)
        {
            ColorDialog colorDialog1;

            using (colorDialog1 = new ColorDialog())
            {
                colorDialog1.SolidColorOnly = false;
                colorDialog1.AllowFullOpen  = true;
                colorDialog1.AnyColor       = true;
                int colorabgr = (int)diffuse.ToABGR();
                colorabgr &= 0x00ffffff;
                int[] colorsabgr = new int[1];
                colorsabgr[0]             = colorabgr;
                colorDialog1.FullOpen     = true;
                colorDialog1.ShowHelp     = true;
                colorDialog1.Color        = ColorExToColor(diffuse);
                colorDialog1.CustomColors = colorsabgr;
                DialogResult result = colorDialog1.ShowDialog();
                if (result == DialogResult.OK)
                {
                    diffuseSelectButton.BackColor = colorDialog1.Color;
                    diffuse = ColorToColorEx(colorDialog1.Color);
                }
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var data = Customer.GetCustomerList(100);

            Grid.AutoGeneratingColumn += (s, e) =>
            {
                if (e.Property.Name == "Id")
                {
                    e.Cancel = true;
                }
            };
            Grid.ItemsSource    = data;
            Grid.BeginningEdit += OnBeginningEdit;
            Grid.CellEditEnded += OnCellEditEnded;

            Grid.GridLinesVisibility        = GridLinesVisibility.None;
            Grid.HeadersGridLinesVisibility = GridLinesVisibility.None;
            Grid.HeadersVisibility          = GridHeadersVisibility.Column;
            Grid.BackgroundColor            = UIColor.White;
            Grid.RowBackgroundColor         = ColorEx.FromARGB(0xFF, 0xE2, 0xEF, 0xDB);
            Grid.RowTextColor = UIColor.Black;
            Grid.AlternatingRowBackgroundColor = UIColor.White;
            Grid.ColumnHeaderBackgroundColor   = ColorEx.FromARGB(0xFF, 0x70, 0xAD, 0x46);
            Grid.ColumnHeaderTextColor         = UIColor.White;
            Grid.ColumnHeaderFont         = UIFont.BoldSystemFontOfSize(UIFont.LabelFontSize);
            Grid.SelectionBackgroundColor = ColorEx.FromARGB(0xFF, 0x5A, 0x82, 0x3F);
            Grid.SelectionTextColor       = UIColor.White;
        }
예제 #23
0
 public static bool CompareTo(ColorRect c1, ColorRect c2)
 {
     if (c1 == null && c2 == null)
     {
         return(true);
     }
     if (c1 == null || c2 == null)
     {
         return(false);
     }
     for (int i = 0; i < 4; i++)
     {
         ColorEx color1 = c1.colors[i];
         ColorEx color2 = c2.colors[i];
         if (color1 == null && color2 == null)
         {
             continue;
         }
         if (color1 == null || color2 == null)
         {
             return(false);
         }
         if (color1.CompareTo(color2) != 0)
         {
             return(false);
         }
     }
     return(true);
 }
예제 #24
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Grid.HeadersVisibility             = GridHeadersVisibility.Column;
            Grid.RowBackgroundColor            = ColorEx.FromARGB(0xFF, 0xE5, 0xE6, 0xFA);
            Grid.RowTextColor                  = UIColor.Black;
            Grid.AlternatingRowBackgroundColor = UIColor.White;
            Grid.GridLinesVisibility           = GridLinesVisibility.Vertical;
            Grid.ColumnHeaderBackgroundColor   = ColorEx.FromARGB(0xFF, 0x77, 0x88, 0x98);
            Grid.ColumnHeaderTextColor         = UIColor.White;
            Grid.ColumnHeaderFont              = UIFont.BoldSystemFontOfSize(UIFont.LabelFontSize);
            Grid.SelectionBackgroundColor      = ColorEx.FromARGB(0xFF, 0xFA, 0xD1, 0x27);
            Grid.SelectionTextColor            = UIColor.Black;
            Grid.AutoGenerateColumns           = false;
            Grid.AllowResizing                 = GridAllowResizing.Columns;
            Grid.Columns.Add(new GridColumn {
                Binding = "FirstName", Width = GridLength.Star
            });
            Grid.Columns.Add(new GridColumn {
                Binding = "LastName", Width = GridLength.Star
            });
            Grid.Columns.Add(new GridColumn {
                Binding = "LastOrderDate", Width = GridLength.Star, Format = "d"
            });
            Grid.Columns.Add(new GridColumn {
                Binding = "OrderTotal", Width = GridLength.Star, Format = "N", HorizontalAlignment = UIControlContentHorizontalAlignment.Right
            });
            var data = Customer.GetCustomerList(100);

            Grid.ItemsSource = data;
        }
예제 #25
0
        void InitSymbol(Symbol s, string property)
        {
            s.Color = ChartViewModel._Colors[IndexMemory % ChartViewModel._Colors.Length];
            IndexMemory++;
            HsbColor hsb = ColorEx.RgbToHsb(s.Color);

            s.MovingAverage = new C1.Xaml.Chart.Finance.MovingAverage()
            {
                Binding = property,
                Type    = MovingAverageType.Simple,
                Period  = 10,
            };

            s.MovingAverage.Visibility             = _viewModel.IsShowMovingAverage ? SeriesVisibility.Visible : SeriesVisibility.Hidden;
            s.MovingAverage.Style                  = new ChartStyle();
            s.MovingAverage.Style.Fill             = s.MovingAverage.Style.Stroke
                                                   = new SolidColorBrush(ColorEx.HsbToRgb(new HsbColor()
            {
                A = hsb.A, H = hsb.H, S = Math.Max(hsb.B / 2, 0), B = Math.Min(hsb.B * 2, 1)
            }));
            s.MovingAverage.ItemsSource = s.DataSource;

            s.Series = new Series()
            {
                Binding = property, SeriesName = s.Code.ToUpper()
            };
            s.Series.ChartType             = ChartType.Line;
            s.Series.Style                 = new ChartStyle();
            s.Series.Style.StrokeThickness = 2;
            s.Series.Style.Fill            = new SolidColorBrush(Windows.UI.Color.FromArgb(64, s.Color.R, s.Color.G, s.Color.B));
            s.Series.Style.Stroke          = new SolidColorBrush(s.Color);
            s.Series.ItemsSource           = s.DataSource;
        }
예제 #26
0
        public static Object MultiplyFloat(AnimableType type, float v, Object k)
        {
            switch (type)
            {
            case AnimableType.Int:
                return((Object)(int)(((int)k) * v));

            case AnimableType.Float:
                float f = (float)k;
                return((Object)(f * v));

            case AnimableType.Vector2:
                Vector2 v2 = (Vector2)k;
                return((Object)(v2 * v));

            case AnimableType.Vector3:
                Vector3 v3 = (Vector3)k;
                return((Object)(v3 * v));

            case AnimableType.Vector4:
                Vector4 v4 = (Vector4)k;
                return((Object)(v4 * v));

            case AnimableType.Quaternion:
                Quaternion q = (Quaternion)k;
                return((Object)(q * v));

            case AnimableType.ColorEx:
                ColorEx c = (ColorEx)k;
                return((Object)(new ColorEx(c.a * v, c.r * v, c.g * v, c.b * v)));
            }
            throw new Exception(string.Format("In AnimableValue.MultiplyFloat, unknown type {0}", type));
        }
예제 #27
0
 public void SetAlpha(float alpha)
 {
     for (int i = 0; i < colors.Length; ++i)
     {
         colors[i] = new ColorEx(alpha, colors[i].r, colors[i].g, colors[i].b);
     }
 }
예제 #28
0
        void DrawShape(Fixture fixture, XForm xf, Color color)
        {
            Color coreColor = ColorEx.FromScRgb(0.9f, 0.6f, 0.6f);

            switch (fixture.ShapeType)
            {
            case ShapeType.Circle:
            {
                CircleShape circle = (CircleShape)fixture.GetShape();

                Vector2 center = MathUtils.Multiply(ref xf, circle._p);
                float   radius = circle._radius;
                Vector2 axis   = xf.R.col1;

                DebugDraw.DrawSolidCircle(center, radius, axis, color);
            }
            break;

            case ShapeType.Polygon:
            {
                PolygonShape poly        = (PolygonShape)fixture.GetShape();
                int          vertexCount = poly._vertexCount;
                Debug.Assert(vertexCount <= Settings.b2_maxPolygonVertices);
                FixedArray8 <Vector2> vertices = new FixedArray8 <Vector2>();

                for (int i = 0; i < vertexCount; ++i)
                {
                    vertices[i] = MathUtils.Multiply(ref xf, poly._vertices[i]);
                }

                DebugDraw.DrawSolidPolygon(ref vertices, vertexCount, color);
            }
            break;
            }
        }
예제 #29
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.GettingStarted);
            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = GetString(Resource.String.EditConfirmationTitle);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            var dips_50 = TypedValue.ApplyDimension(ComplexUnitType.Dip, 50, Resources.DisplayMetrics);

            Grid = FindViewById <FlexGrid>(Resource.Id.Grid);
            Grid.GridLinesVisibility        = GridLinesVisibility.None;
            Grid.HeadersGridLinesVisibility = GridLinesVisibility.None;
            Grid.HeadersVisibility          = GridHeadersVisibility.Column;
            Grid.BackgroundColor            = Color.White;
            Grid.RowBackgroundColor         = ColorEx.FromARGB(0xFF, 0xE2, 0xEF, 0xDB);
            Grid.RowTextColor = Color.Black;
            Grid.AlternatingRowBackgroundColor = Color.White;
            Grid.ColumnHeaderBackgroundColor   = ColorEx.FromARGB(0xFF, 0x70, 0xAD, 0x46);
            Grid.ColumnHeaderTextColor         = Color.White;
            Grid.ColumnHeaderTypeface          = Typeface.Create("", TypefaceStyle.Bold);
            Grid.SelectionBackgroundColor      = ColorEx.FromARGB(0xFF, 0x5A, 0x82, 0x3F);
            Grid.SelectionTextColor            = Color.White;
            Grid.DefaultRowHeight = new GridLength(dips_50);
            Grid.ItemsSource      = Customer.GetCustomerList(100);
            Grid.BeginningEdit   += OnBeginningEdit;
            Grid.CellEditEnded   += OnCellEditEnded;
        }
예제 #30
0
 public CompositionPass(CompositionTargetPass parent)
 {
     this.parent                   = parent;
     this.type                     = CompositorPassType.RenderQuad;
     this.identifier               = 0;
     this.firstRenderQueue         = RenderQueueGroupID.Background;
     this.lastRenderQueue          = RenderQueueGroupID.SkiesLate;
     this.materialSchemeName       = string.Empty;
     this.clearBuffers             = FrameBufferType.Color | FrameBufferType.Depth;
     this.clearColor               = new ColorEx(0f, 0f, 0f, 0f);
     this.clearDepth               = 1.0f;
     this.clearStencil             = 0;
     this.stencilCheck             = false;
     this.stencilFunc              = CompareFunction.AlwaysPass;
     this.stencilRefValue          = 0;
     this.stencilMask              = 0x7FFFFFFF;
     this.stencilFailOp            = StencilOperation.Keep;
     this.stencilDepthFailOp       = StencilOperation.Keep;
     this.stencilPassOp            = StencilOperation.Keep;
     this.stencilTwoSidedOperation = false;
     this.quadCornerModified       = false;
     this.quadLeft                 = -1;
     this.quadTop                  = 1;
     this.quadRight                = 1;
     this.quadBottom               = -1;
     this.quadFarCorners           = false;
     this.quadFarCornersViewSpace  = false;
 }
예제 #31
0
 public static ColorEx ReadColor(XmlNode node)
 {
     ColorEx rv = new ColorEx();
     rv.a = 1.0f;
     rv.r = float.Parse(node.Attributes["r"].Value);
     rv.g = float.Parse(node.Attributes["g"].Value);
     rv.b = float.Parse(node.Attributes["b"].Value);
     if (node.Attributes["a"] != null)
         rv.a = float.Parse(node.Attributes["a"].Value);
     return rv;
 }
        public AddPlantTypeDialog(string title, List<AssetDesc> list, WorldEditor app)
        {
            InitializeComponent();
            ColorEx color = new ColorEx();
            color = app.Config.PlantColorDefault;
            colorDialog1.Color = ColorExToColor(color);
            colorSelectButton.BackColor = colorDialog1.Color;
            int colorabgr = (int)color.ToABGR();
            int[] colorsabgr = new int[1];
            colorabgr &= 0x00ffffff;
            colorsabgr[0] = colorabgr;
            colorDialog1.CustomColors = colorsabgr;

            foreach (AssetDesc asset in list)
            {
                imageNameComboBox.Items.Add(asset.Name);
            }
            imageNameComboBox.SelectedIndex = 0;
        }
예제 #33
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="position"></param>
 /// <param name="owner"></param>
 /// <param name="color"></param>
 public Billboard(Vector3 position, BillboardSet owner, ColorEx color)
 {
     this.Color = color;
     this.Position = position;
     this.ParentSet = owner;
 }
예제 #34
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="position"></param>
 /// <param name="owner"></param>
 public Billboard(Vector3 position, BillboardSet owner)
 {
     this.Position = position;
     this.ParentSet = owner;
     this.Color = ColorEx.White;
 }
예제 #35
0
 public static ColorRect ReadGradient(XmlNode node)
 {
     ColorEx minColor = new ColorEx();
     ColorEx maxColor = new ColorEx();
     bool minColorSet = false;
     bool maxColorSet = false;
     bool horizontal = true;
     if (node.Attributes["orientation"] != null &&
         node.Attributes["orientation"].Value == "VERTICAL")
         horizontal = false;
     foreach (XmlNode childNode in node.ChildNodes) {
         switch (childNode.Name) {
             case "MinColor":
                 minColor = ReadColor(childNode);
                 minColorSet = true;
                 break;
             case "MaxColor":
                 maxColor = ReadColor(childNode);
                 maxColorSet = true;
                 break;
             default:
                 break;
         }
     }
     Debug.Assert(minColorSet && maxColorSet,
                  "Got Gradient node without MinColor and MaxColor child");
     ColorRect rv = new ColorRect();
     if (horizontal) {
         rv.TopLeft = minColor;
         rv.TopRight = maxColor;
         rv.BottomLeft = minColor;
         rv.BottomRight = maxColor;
     } else {
         rv.TopLeft = minColor;
         rv.TopRight = minColor;
         rv.BottomLeft = maxColor;
         rv.BottomRight = maxColor;
     }
     return rv;
 }
 public RSClearOperation(FrameBuffer buffers, ColorEx color, float depth, int stencil)
 {
     this.buffers = buffers;
     this.color = color;
     this.depth = depth;
     this.stencil = stencil;
 }
예제 #37
0
		/// <summary>
		/// Sets the global blending factors for combining subsequent renders with the existing frame contents.
		/// The result of the blending operation is:
		/// <p align="center">final = (texture * src) + (pixel * dest)</p>
		/// Each of the factors is specified as one of a number of options, as specified in the SceneBlendFactor
		/// enumerated type.
		/// </summary>
		/// <param name="src">The source factor in the above calculation, i.e. multiplied by the texture color components.</param>
		/// <param name="dest">The destination factor in the above calculation, i.e. multiplied by the pixel color components.</param>
		/// <param name="op">The blend operation mode for combining pixels</param>
		public override void SetSceneBlending(SceneBlendFactor src, SceneBlendFactor dest, SceneBlendOperation op)
		{
			StateManager.BlendState.AlphaSourceBlend = XnaHelper.Convert(src);
			StateManager.BlendState.AlphaDestinationBlend = XnaHelper.Convert(dest);
			StateManager.BlendState.AlphaBlendFunction = XnaHelper.Convert(op);
			/**/
			StateManager.BlendState.ColorSourceBlend = XnaHelper.Convert( src );
			StateManager.BlendState.ColorDestinationBlend = XnaHelper.Convert( dest );
			/**/
			StateManager.BlendState.ColorSourceBlend = StateManager.BlendState.AlphaSourceBlend;
			StateManager.BlendState.ColorDestinationBlend = StateManager.BlendState.AlphaDestinationBlend;
			/**/
			//TODO use SceneBlendOperation
			StateManager.BlendState.ColorBlendFunction = StateManager.BlendState.AlphaBlendFunction;
		}

		#endregion

		#region SetSeparateSceneBlending

		/// <summary>
		/// Sets the global blending factors for combining subsequent renders with the existing frame contents.
		/// The result of the blending operation is:
		/// final = (texture * sourceFactor) + (pixel * destFactor).
		/// Each of the factors is specified as one of a number of options, as specified in the SceneBlendFactor
		/// enumerated type.
		/// </summary>
		/// <param name="sourceFactor">The source factor in the above calculation, i.e. multiplied by the texture color components.</param>
		/// <param name="destFactor">The destination factor in the above calculation, i.e. multiplied by the pixel color components.</param>
		/// <param name="sourceFactorAlpha">The source factor in the above calculation for the alpha channel, i.e. multiplied by the texture alpha components.</param>
		/// <param name="destFactorAlpha">The destination factor in the above calculation for the alpha channel, i.e. multiplied by the pixel alpha components.</param>
		/// <param name="op">The blend operation mode for combining pixels</param>
		/// <param name="alphaOp">The blend operation mode for combining pixel alpha values</param>
		public override void SetSeparateSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor,
													   SceneBlendFactor sourceFactorAlpha,
													   SceneBlendFactor destFactorAlpha, SceneBlendOperation op,
													   SceneBlendOperation alphaOp)
		{
			StateManager.BlendState.ColorSourceBlend = XnaHelper.Convert(sourceFactor);
			StateManager.BlendState.ColorDestinationBlend = XnaHelper.Convert(destFactor);
			StateManager.BlendState.AlphaSourceBlend = XnaHelper.Convert(sourceFactorAlpha);
			StateManager.BlendState.AlphaDestinationBlend = XnaHelper.Convert(destFactorAlpha);
			StateManager.BlendState.ColorBlendFunction = XnaHelper.Convert(op);
			StateManager.BlendState.AlphaBlendFunction = XnaHelper.Convert(alphaOp);
		}

		#endregion

		#region SetScissorTest

		/// <summary>
		/// Sets the 'scissor region' ie the region of the target in which rendering can take place.
		/// </summary>
		/// <remarks>
		/// This method allows you to 'mask off' rendering in all but a given rectangular area
		/// as identified by the parameters to this method.
		/// <p/>
		/// Not all systems support this method. Check the <see cref="Capabilities"/> enum for the
		/// ScissorTest capability to see if it is supported.
		/// </remarks>
		/// <param name="enable">True to enable the scissor test, false to disable it.</param>
		/// <param name="left">Left corner (in pixels).</param>
		/// <param name="top">Top corner (in pixels).</param>
		/// <param name="right">Right corner (in pixels).</param>
		/// <param name="bottom">Bottom corner (in pixels).</param>
		public override void SetScissorTest(bool enable, int left, int top, int right, int bottom)
		{
			if (enable)
			{
				_device.ScissorRectangle = new Rectangle(left, top, right - left, bottom - top);
				StateManager.RasterizerState.ScissorTestEnable = true;
			}
			else
			{
				StateManager.RasterizerState.ScissorTestEnable = false;
			}
		}

		#endregion

		#region SetStencilBufferParams

		/// <summary>
		/// This method allows you to set all the stencil buffer parameters in one call.
		/// </summary>
		/// <remarks>
		/// <para>
		/// The stencil buffer is used to mask out pixels in the render target, allowing
		/// you to do effects like mirrors, cut-outs, stencil shadows and more. Each of
		/// your batches of rendering is likely to ignore the stencil buffer, 
		/// update it with new values, or apply it to mask the output of the render.
		/// The stencil test is:<PRE>
		/// (Reference Value &amp; Mask) CompareFunction (Stencil Buffer Value &amp; Mask)</PRE>
		/// The result of this will cause one of 3 actions depending on whether the test fails,
		/// succeeds but with the depth buffer check still failing, or succeeds with the
		/// depth buffer check passing too.</para>
		/// <para>
		/// Unlike other render states, stencilling is left for the application to turn
		/// on and off when it requires. This is because you are likely to want to change
		/// parameters between batches of arbitrary objects and control the ordering yourself.
		/// In order to batch things this way, you'll want to use OGRE's separate render queue
		/// groups (see RenderQueue) and register a RenderQueueListener to get notifications
		/// between batches.</para>
		/// <para>
		/// There are individual state change methods for each of the parameters set using 
		/// this method. 
		/// Note that the default values in this method represent the defaults at system 
		/// start up too.</para>
		/// </remarks>
		/// <param name="function">The comparison function applied.</param>
		/// <param name="refValue">The reference value used in the comparison.</param>
		/// <param name="mask">
		/// The bitmask applied to both the stencil value and the reference value 
		/// before comparison.
		/// </param>
		/// <param name="stencilFailOp">The action to perform when the stencil check fails.</param>
		/// <param name="depthFailOp">
		/// The action to perform when the stencil check passes, but the depth buffer check still fails.
		/// </param>
		/// <param name="passOp">The action to take when both the stencil and depth check pass.</param>
		/// <param name="twoSidedOperation">
		/// If set to true, then if you render both back and front faces 
		/// (you'll have to turn off culling) then these parameters will apply for front faces, 
		/// and the inverse of them will happen for back faces (keep remains the same).
		/// </param>
		public override void SetStencilBufferParams(CompareFunction function, int refValue, int mask,
													 StencilOperation stencilFailOp, StencilOperation depthFailOp,
													 StencilOperation passOp, bool twoSidedOperation)
		{
			bool flip;
			// 2 sided operation?
			if (twoSidedOperation)
			{
				//if ( !HardwareCapabilities.HasCapability( Capabilities.TwoSidedStencil ) )
				//{
				//    throw new AxiomException( "2-sided stencils are not supported on this hardware!" );
				//}
				StateManager.DepthStencilState.TwoSidedStencilMode = true;
				flip = (invertVertexWinding && activeRenderTarget.RequiresTextureFlipping) ||
					   (!invertVertexWinding && !activeRenderTarget.RequiresTextureFlipping);

				StateManager.DepthStencilState.StencilFail = XnaHelper.Convert(stencilFailOp, !flip);
				StateManager.DepthStencilState.StencilDepthBufferFail = XnaHelper.Convert(depthFailOp, !flip);
				StateManager.DepthStencilState.StencilPass = XnaHelper.Convert(passOp, !flip);
			}
			else
			{
				StateManager.DepthStencilState.TwoSidedStencilMode = false;
				flip = false;
			}

			// configure standard version of the stencil operations
			StateManager.DepthStencilState.StencilFunction = XnaHelper.Convert(function);
			StateManager.DepthStencilState.ReferenceStencil = refValue;
			StateManager.DepthStencilState.StencilMask = mask;
			StateManager.DepthStencilState.StencilFail = XnaHelper.Convert(stencilFailOp, flip);
			StateManager.DepthStencilState.StencilDepthBufferFail = XnaHelper.Convert(depthFailOp, flip);
			StateManager.DepthStencilState.StencilPass = XnaHelper.Convert(passOp, flip);
			StateManager.BlendState.ColorWriteChannels = ColorWriteChannels.None;
		}

		#endregion

		#region SetSurfaceParams

		/// <summary>
		/// Sets the surface properties to be used for future rendering.
		/// 
		/// This method sets the the properties of the surfaces of objects
		/// to be rendered after it. In this context these surface properties
		/// are the amount of each type of light the object reflects (determining
		/// it's color under different types of light), whether it emits light
		/// itself, and how shiny it is. Textures are not dealt with here,
		/// <see cref="SetTexture(int, bool, Texture)"/> method for details.
		/// This method is used by SetMaterial so does not need to be called
		/// direct if that method is being used.
		/// </summary>
		/// <param name="ambient">
		/// The amount of ambient (sourceless and directionless)
		/// light an object reflects. Affected by the color/amount of ambient light in the scene.
		/// </param>
		/// <param name="diffuse">
		/// The amount of light from directed sources that is
		/// reflected (affected by color/amount of point, directed and spot light sources)
		/// </param>
		/// <param name="specular">
		/// The amount of specular light reflected. This is also
		/// affected by directed light sources but represents the color at the
		/// highlights of the object.
		/// </param>
		/// <param name="emissive">
		/// The color of light emitted from the object. Note that
		/// this will make an object seem brighter and not dependent on lights in
		/// the scene, but it will not act as a light, so will not illuminate other
		/// objects. Use a light attached to the same SceneNode as the object for this purpose.
		/// </param>
		/// <param name="shininess">
		/// A value which only has an effect on specular highlights (so
		/// specular must be non-black). The higher this value, the smaller and crisper the
		/// specular highlights will be, imitating a more highly polished surface.
		/// This value is not constrained to 0.0-1.0, in fact it is likely to
		/// be more (10.0 gives a modest sheen to an object).
		/// </param>
		/// <param name="tracking">
		/// A bit field that describes which of the ambient, diffuse, specular
		/// and emissive colors follow the vertex color of the primitive. When a bit in this field is set
		/// its colorValue is ignored. This is a combination of TVC_AMBIENT, TVC_DIFFUSE, TVC_SPECULAR(note that the shininess value is still
		/// taken from shininess) and TVC_EMISSIVE. TVC_NONE means that there will be no material property
		/// tracking the vertex colors.
		/// </param>
		public override void SetSurfaceParams(ColorEx ambient, ColorEx diffuse, ColorEx specular, ColorEx emissive, Real shininess, TrackVertexColor tracking)
		{
			/*/
			//basicEffect.Alpha;
			//basicEffect.AmbientLightColor;
			//basicEffect.DiffuseColor;
			basicEffect.DirectionalLight0;
			basicEffect.DirectionalLight1;
			basicEffect.DirectionalLight2;
			//basicEffect.EmissiveColor;
			basicEffect.EnableDefaultLighting();
			//basicEffect.FogColor;
			//basicEffect.FogEnabled;
			//basicEffect.FogEnd;
			//basicEffect.FogStart;
			//basicEffect.LightingEnabled;
			basicEffect.PreferPerPixelLighting;
			//basicEffect.Projection;
			//basicEffect.SpecularColor;
			//basicEffect.SpecularPower;
			//basicEffect.Texture;
			//basicEffect.TextureEnabled;
			//basicEffect.VertexColorEnabled;
			//basicEffect.View;
			//basicEffect.World;
			/**/

			//basicEffect.EnableDefaultLighting();
			//basicEffect.PreferPerPixelLighting = true;

			if (ambient == ColorEx.White &&
				diffuse == ColorEx.Black &&
				emissive == ColorEx.Black &&
				specular == ColorEx.Black &&
				shininess == 0
				)
			{
				//_fixedFunctionState.MaterialEnabled = false;
				basicEffect.AmbientLightColor = Color.White.ToVector3();
				basicEffect.DiffuseColor = Color.White.ToVector3();
			}
			else
			{
				//_fixedFunctionState.MaterialEnabled = true;
				basicEffect.AmbientLightColor = XnaHelper.Convert( ambient ).ToVector3();
				basicEffect.DiffuseColor = XnaHelper.Convert( diffuse ).ToVector3();
			}
			basicEffect.SpecularColor = XnaHelper.Convert(specular).ToVector3();
			basicEffect.EmissiveColor = XnaHelper.Convert(emissive).ToVector3();
			basicEffect.SpecularPower = shininess;
			try
			{

				skinnedEffect.AmbientLightColor = basicEffect.AmbientLightColor;
				skinnedEffect.DiffuseColor = basicEffect.DiffuseColor;
				skinnedEffect.SpecularColor = basicEffect.SpecularColor;
				skinnedEffect.EmissiveColor = basicEffect.EmissiveColor;
				skinnedEffect.SpecularPower = basicEffect.SpecularPower;
			}
			catch ( Exception ex )
			{
			}
#if AXIOM_FF_EMULATION
			if (//ambient == ColorEx.White &&
				diffuse == ColorEx.Black //&&
				//emissive == ColorEx.Black &&
				//specular == ColorEx.Black &&
				//shininess == 0
				)
			{
				//_fixedFunctionState.MaterialEnabled = false;
				_ffProgramParameters.MaterialAmbient = new ColorEx( 0, 1, 1, 1 );
				_ffProgramParameters.MaterialDiffuse = ColorEx.White;
				_ffProgramParameters.MaterialSpecular = ColorEx.Black;
			}
			else
			{
				//_fixedFunctionState.MaterialEnabled = true;
				_ffProgramParameters.MaterialAmbient = ambient;
				_ffProgramParameters.MaterialDiffuse = diffuse;
				_ffProgramParameters.MaterialSpecular = specular;
				//_ffProgramParameters.MaterialEmissive = emissive;
				//_ffProgramParameters.MaterialShininess = shininess;
			}
#endif
		}

		#endregion

		#region SetPointParameters

		/// <summary>
		/// Sets the size of points and how they are attenuated with distance.
		/// <remarks>
		/// When performing point rendering or point sprite rendering,
		/// point size can be attenuated with distance. The equation for
		/// doing this is attenuation = 1 / (constant + linear * dist + quadratic * d^2) .
		/// </remarks>
		/// </summary>
		public override void SetPointParameters(Real size, bool attenuationEnabled, Real constant, Real linear,
												 Real quadratic, Real minSize, Real maxSize)
		{
			throw new AxiomException("XNA does not support PointSprites.");
		}

		#endregion

		#region SetTexture

		/// <summary>
		/// Sets the texture to bind to a given texture unit.
		/// 
		/// User processes would not normally call this direct unless rendering
		/// primitives themselves.
		/// </summary>
		/// <param name="unit">
		/// The index of the texture unit to modify. Multitexturing
		/// hardware can support multiple units <see cref="RenderSystemCapabilities.TextureUnitCount"/> 
		/// </param>
		/// <param name="enabled"></param>
		/// <param name="texture"></param>
		public override void SetTexture(int stage, bool enabled, Texture texture)
		{
			var xnaTexture = (XnaTexture)texture;
			var compensateNPOT = false;

			if ((texture != null) && (!Bitwise.IsPow2(texture.Width) || !Bitwise.IsPow2(texture.Height)))
			{
				if (Capabilities.HasCapability(Graphics.Capabilities.NonPowerOf2Textures))
				{
					if (Capabilities.NonPOW2TexturesLimited)
						compensateNPOT = true;
				}
				else
					compensateNPOT = true;

				if (compensateNPOT)
				{
					SetTextureAddressingMode(stage, new UVWAddressing(TextureAddressing.Clamp));
				}
			}

			texStageDesc[stage].Enabled = enabled;
			if (enabled && xnaTexture != null)
			{
				_device.Textures[stage] = xnaTexture.DXTexture;
				// TODO: NRSC: Solve cast problem for non Texture2D 
				basicEffect.Texture = xnaTexture.DXTexture as Texture2D;
				try
				{

					basicEffect.TextureEnabled = basicEffect.Texture != null;
				}
				catch ( Exception ex )
				{
					SetTextureAddressingMode( stage, new UVWAddressing( TextureAddressing.Clamp ) );
				}
				finally
				{
					basicEffect.TextureEnabled = basicEffect.Texture != null;
				}

				skinnedEffect.Texture = basicEffect.Texture;

				// set stage description
				texStageDesc[stage].tex = xnaTexture.DXTexture;
				texStageDesc[stage].texType = xnaTexture.TextureType;

				var state = StateManager.SamplerStates[stage];
				if (
#if !SILVERLIGHT
					_device.GraphicsProfile == GraphicsProfile.Reach && 
#endif
					!( (XnaTexture)texture ).IsPowerOfTwo )
				{
					state.AddressU = TextureAddressMode.Clamp;
					state.AddressV = TextureAddressMode.Clamp;
					state.AddressW = TextureAddressMode.Clamp;
				}
				else
				{
					state.AddressU = TextureAddressMode.Wrap;
					state.AddressV = TextureAddressMode.Wrap;
					state.AddressW = TextureAddressMode.Wrap;
				}
			}
			else
			{
				if (texStageDesc[stage].tex != null)
				{
					_device.Textures[stage] = null;
				}
				// set stage description to defaults
				texStageDesc[stage].tex = null;
				texStageDesc[stage].autoTexCoordType = TexCoordCalcMethod.None;
				texStageDesc[stage].coordIndex = 0;
				texStageDesc[stage].texType = TextureType.OneD;
			}
#if AXIOM_FF_EMULATION
			_ffProgramParameters.SetTextureEnabled( stage, enabled );
#endif
		}

		#endregion

		#region SetTextureAddressingMode

		/// <summary>
		/// Tells the hardware how to treat texture coordinates.
		/// </summary>
		public override void SetTextureAddressingMode(int stage, UVWAddressing uvw)
		{
			if (_device.GetVertexBuffers().Length == 0)
			{
				return;
			}
			if (
				!(from VertexElement vde in
					  _device.GetVertexBuffers()[0].VertexBuffer.VertexDeclaration.GetVertexElements()
				  where vde.VertexElementUsage == VertexElementUsage.Normal
				  select vde).Any())
			{
				return;
			}

			var xnaTexture = _device.Textures[stage] as Texture2D;
			var compensateNPOT = false;

			if ((xnaTexture != null) &&
				 (!Bitwise.IsPow2(xnaTexture.Width) || !Bitwise.IsPow2(xnaTexture.Height)))
			{
				if (Capabilities.HasCapability(Graphics.Capabilities.NonPowerOf2Textures))
				{
					if (Capabilities.NonPOW2TexturesLimited)
						compensateNPOT = true;
					}
				else
					compensateNPOT = true;

				if (compensateNPOT)
				{
					uvw = new UVWAddressing( TextureAddressing.Clamp );
				}
			}

			// set the device sampler states accordingly
			StateManager.SamplerStates[ stage ].AddressU = XnaHelper.Convert( uvw.U );
			StateManager.SamplerStates[ stage ].AddressV = XnaHelper.Convert( uvw.V );
			StateManager.SamplerStates[ stage ].AddressW = XnaHelper.Convert( uvw.W );
		}

		#endregion

		#region SetTextureMipmapBias

		/// <summary>
		/// Sets the mipmap bias value for a given texture unit.
		/// </summary>
		/// <remarks>
		/// This allows you to adjust the mipmap calculation up or down for a
		/// given texture unit. Negative values force a larger mipmap to be used, 
		/// positive values force a smaller mipmap to be used. Units are in numbers
		/// of levels, so +1 forces the mipmaps to one smaller level.
		/// </remarks>
		/// <note>Only does something if render system has capability RSC_MIPMAP_LOD_BIAS.</note>
		public override void SetTextureMipmapBias(int unit, float bias)
		{
			if (currentCapabilities.HasCapability(Graphics.Capabilities.MipmapLODBias))
			{
				var ss = _device.SamplerStates[unit];
				_device.SamplerStates[unit] = new SamplerState
				{
					MipMapLevelOfDetailBias = bias,
					MaxMipLevel = ss.MaxMipLevel,
					MaxAnisotropy = ss.MaxAnisotropy,
#if ! SILVERLIGHT
					AddressW = ss.AddressW,
#endif
					AddressV = ss.AddressV,
					AddressU = ss.AddressU,
					Filter = ss.Filter,
				};
			}
		}

		#endregion

		#region SetTextureBorderColor

		/// <summary>
		/// Tells the hardware what border color to use when texture addressing mode is set to Border
		/// </summary>
		/// <param name="unit"></param>
		/// <param name="borderColor"></param>
		public override void SetTextureBorderColor(int stage, ColorEx borderColor)
		{
			//texStageDesc[ stage ].borderColor = borderColor;
		}

		#endregion

		#region SetTextureBlendMode

		/// <summary>
		/// Sets the texture blend modes from a TextureLayer record.
		/// Meant for use internally only - apps should use the Material
		/// and TextureLayer classes.
		/// </summary>
		/// <param name="unit">Texture unit.</param>
		/// <param name="bm">Details of the blending modes.</param>
		public override void SetTextureBlendMode(int stage, LayerBlendModeEx blendMode)
		{
			basicEffect.Alpha = 1.0f;
			skinnedEffect.Alpha = 1.0f;

			if (blendMode.blendType == LayerBlendType.Color)
			{
				texStageDesc[stage].layerBlendMode = blendMode;
			}
			/* TODO: use StateManager.BlendState */

			if (blendMode.operation == LayerBlendOperationEx.BlendManual)
			{
				StateManager.BlendState.BlendFactor = new Color(blendMode.blendFactor, 0, 0, 0);
			}
			if (blendMode.blendType == LayerBlendType.Color)
			{
				//_device.RenderState.AlphaBlendEnable = false;
			}
			else if (blendMode.blendType == LayerBlendType.Alpha)
			{
				//_device.RenderState.AlphaBlendEnable = true;
			}

			var manualD3D = XnaHelper.Convert(StateManager.BlendState.BlendFactor);
			if (blendMode.blendType == LayerBlendType.Color)
			{
				manualD3D = new ColorEx(blendMode.blendFactor, blendMode.colorArg1.r, blendMode.colorArg1.g,
										 blendMode.colorArg1.b);
			}
			else if (blendMode.blendType == LayerBlendType.Alpha)
			{
				manualD3D = new ColorEx(blendMode.alphaArg1, blendMode.blendFactor, blendMode.blendFactor,
										 blendMode.blendFactor);
			}

			var blendSource = blendMode.source1;
			for (var i = 0; i < 2; i++)
			{
				// set the texture blend factor if this is manual blending
				if (blendSource == LayerBlendSource.Manual)
				{
					StateManager.BlendState.BlendFactor = XnaHelper.Convert(manualD3D);
				}
				// pick proper argument settings
				if (blendMode.blendType == LayerBlendType.Color)
				{
					if (i == 0)
					{
						texStageDesc[stage].layerBlendMode.colorArg1 = blendMode.colorArg1;
					}
					else if (i == 1)
					{
						texStageDesc[stage].layerBlendMode.colorArg2 = blendMode.colorArg2;
					}
				}
				else if (blendMode.blendType == LayerBlendType.Alpha)
				{
					if (i == 0)
					{
						texStageDesc[stage].layerBlendMode.alphaArg1 = blendMode.alphaArg1;
						basicEffect.Alpha = blendMode.alphaArg1;
					}
					else if (i == 1)
					{
						texStageDesc[stage].layerBlendMode.alphaArg2 = blendMode.alphaArg2;
						basicEffect.Alpha = blendMode.alphaArg2;
					}
					skinnedEffect.Alpha = basicEffect.Alpha;
				}
				// Source2
				blendSource = blendMode.source2;
				if (blendMode.blendType == LayerBlendType.Color)
				{
					manualD3D = new ColorEx(manualD3D.a, blendMode.colorArg2.r, blendMode.colorArg2.g,
											 blendMode.colorArg2.b);
				}
				else if (blendMode.blendType == LayerBlendType.Alpha)
				{
					manualD3D = new ColorEx(blendMode.alphaArg2, manualD3D.r, manualD3D.g, manualD3D.b);
				}
			}
		}
예제 #38
0
		public void ResetBorderColor()
		{
			m_BorderColor.ColorChanged-=new EventHandler(this.ColorChanged);
			m_BorderColor=ColorEx.Empty;
			m_BorderColor.ColorChanged+=new EventHandler(this.ColorChanged);
		}
        protected void LoadOldBoundary(XmlNode node, WorldObjectCollection collection)
        {
            string name = null;
            XmlNode pointsNode = null;
            XmlNode semanticsNode = null;
            // int priority;

            // get the name
            foreach (XmlNode childNode in node.ChildNodes)
            {
                switch (childNode.Name)
                {
                    case "Name":
                        name = childNode.InnerText;
                        break;
                    case "Points":
                        pointsNode = childNode;
                        break;
                    case "Attributes":
                        semanticsNode = childNode;
                        break;
                    default:
                        break;
                }
            }

            // if the boundary has no points, just call it bogus and return
            if (pointsNode == null)
            {
                return;
            }

            // create and add the boundary to the world
            Boundary boundary = new Boundary(collection, this, name, 100);
            collection.Add(boundary);

            // set up the points
            foreach (XmlNode pointNode in pointsNode.ChildNodes)
            {
                if (pointNode.Name == "Point")
                {
                    XmlNode locNode = pointNode.SelectSingleNode("Position");
                    Vector3 pointPos = GetVectorAttributes(locNode);

                    int pointNum;
                    boundary.Points.AddPoint(pointPos, out pointNum);
                }
            }

            if (semanticsNode != null)
            {
                // handle boundary semantics
                foreach (XmlNode semanticNode in semanticsNode.ChildNodes)
                {
                    switch (semanticNode.Name)
                    {
                        case "WaterAttribute":
                            XmlNode heightNode = semanticNode.SelectSingleNode("Height");
                            float height = float.Parse(heightNode.InnerText);
                            Water water = new Water(height, boundary, this);
                            boundary.Add(water);
                            break;
                        case "ForestAttribute":
                            XmlNode seedNode = semanticNode.SelectSingleNode("Seed");
                            int seed = int.Parse(seedNode.InnerText);

                            XmlNode speedWindNode = semanticNode.SelectSingleNode("SpeedWindFile");
                            string speedWindFile = speedWindNode.InnerText;

                            XmlNode windSpeedNode = semanticNode.SelectSingleNode("WindSpeed");
                            float windSpeed = float.Parse(windSpeedNode.InnerText);

                            XmlNode windDirNode = semanticNode.SelectSingleNode("WindDirection");
                            Vector3 windDir = GetVectorAttributes(windDirNode);

                            // Add the forest object
                            Forest forest = new Forest(speedWindFile, windSpeed, windDir, seed, boundary, this);
                            boundary.Add(forest);

                            XmlNode treeTypesNode = semanticNode.SelectSingleNode("TreeTypes");
                            if (treeTypesNode != null)
                            {
                                foreach (XmlNode treeTypeNode in treeTypesNode.ChildNodes)
                                {
                                    XmlNode treeNameNode = treeTypeNode.SelectSingleNode("TreeName");
                                    string treeName = treeNameNode.InnerText;

                                    XmlNode treeFilenameNode = treeTypeNode.SelectSingleNode("TreeDescriptionFilename");
                                    string treeFilename = treeFilenameNode.InnerText;

                                    XmlNode scaleNode = treeTypeNode.SelectSingleNode("Scale");
                                    float scale = float.Parse(scaleNode.InnerText);

                                    XmlNode scaleVarianceNode = treeTypeNode.SelectSingleNode("ScaleVariance");
                                    float scaleVariance = float.Parse(scaleVarianceNode.InnerText);

                                    XmlNode instancesNode = treeTypeNode.SelectSingleNode("Instances");
                                    uint instances = uint.Parse(instancesNode.InnerText);

                                    Tree tree = new Tree(treeName, treeFilename, scale, scaleVariance, instances, forest, this);
                                    forest.Add(tree);
                                }
                            }

                            break;
                        case "Fog":
                            XmlNode redNode = semanticNode.SelectSingleNode("ColorRed");
                            int red = int.Parse(redNode.InnerText);

                            XmlNode greenNode = semanticNode.SelectSingleNode("ColorGreen");
                            int green = int.Parse(greenNode.InnerText);

                            XmlNode blueNode = semanticNode.SelectSingleNode("ColorBlue");
                            int blue = int.Parse(blueNode.InnerText);

                            XmlNode nearNode = semanticNode.SelectSingleNode("Near");
                            float near = float.Parse(nearNode.InnerText);

                            XmlNode farNode = semanticNode.SelectSingleNode("Far");
                            float far = int.Parse(farNode.InnerText);

                            ColorEx fogColor = new ColorEx(((float)red) / 255f, ((float)green) / 255f, ((float)blue) / 255f);
                            Fog fog = new Fog(this, boundary, fogColor, near, far);
                            boundary.Add(fog);

                            break;
                        case "Sound":
                            break;
                        default:
                            break;
                    }
                }
            }
        }
예제 #40
0
파일: util.cs 프로젝트: mcintosh/logwizard
        public static Color darker_color(Color col)
        {
            if (col.ToArgb() == Color.White.ToArgb())
                return Color.WhiteSmoke;
            if (col.ToArgb() == Color.WhiteSmoke.ToArgb())
                return Color.LightGray;
            if (col.ToArgb() == Color.LightGray.ToArgb())
                return Color.DarkGray;
            if (col.ToArgb() == Color.DarkGray.ToArgb())
                return Color.Gray;

            ColorEx ex = new ColorEx(col);
            const double mul_by = 2.3;
            ex.S = (byte)(ex.S * mul_by > 100 ? 100 : ex.S * mul_by);
            return ex.Color;
        }
예제 #41
0
        protected void FromXml(XmlReader r)
        {
            // first parse the attributes
            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);

                // set the field in this object based on the element we just read
                switch (r.Name)
                {
                    case "Far":
                        this.far = float.Parse(r.Value);
                        break;
                    case "Near":
                        this.near = float.Parse(r.Value);
                        break;
                }
            }
            r.MoveToElement(); //Moves the reader back to the element node.

            // now parse the sub-elements
            while (r.Read())
            {
                // look for the start of an element
                if (r.NodeType == XmlNodeType.Element)
                {
                    // parse that element
                    // save the name of the element
                    string elementName = r.Name;
                    switch (elementName)
                    {
                        case "Color":
                            cx = XmlHelperClass.ParseColorAttributes(r);
                            break;
                    }
                }
                else if (r.NodeType == XmlNodeType.EndElement)
                {
                    break;
                }
            }
        }
예제 #42
0
 private System.Drawing.Color ColorExToColor(ColorEx color)
 {
     return System.Drawing.Color.FromArgb((int)cx.ToARGB());
 }
        /// <summary>
        ///		Creates a new billboard and adds it to this set.
        /// </summary>
        /// <param name="position"></param>
        /// <param name="color"></param>
        /// <returns></returns>
        public Billboard CreateBillboard(Vector3 position, ColorEx color) {
            // see if we need to auto extend the free billboard pool
            if(freeBillboards.Count == 0) {
                if(autoExtendPool)
                    this.PoolSize = this.PoolSize * 2;
                else
                    throw new AxiomException("Could not create a billboard with AutoSize disabled and an empty pool.");
            }

            // get the next free billboard from the queue
            Billboard newBillboard = freeBillboards[0];
            freeBillboards.RemoveAt(0);
            
            // add the billboard to the active list
            activeBillboards.Add(newBillboard);
            
            // initialize the billboard
            newBillboard.Position = position;
            newBillboard.Color = color;
            newBillboard.Direction = Vector3.Zero;
            newBillboard.Rotation = 0;
            // newBillboard.TexCoordIndex = 0;
            newBillboard.ResetDimensions();
            newBillboard.NotifyOwner(this);

            // Merge into bounds
            float adjust = Math.Max(defaultParticleWidth, defaultParticleHeight);
            Vector3 adjustVec = new Vector3(adjust, adjust, adjust);
            Vector3 newMin = position - adjustVec;
            Vector3 newMax = position + adjustVec;
            
            aab.Merge(new AxisAlignedBox(newMin, newMax));

            float sqlen = (float)Math.Max(newMin.LengthSquared, newMax.LengthSquared);
            boundingRadius = (float)Math.Max(boundingRadius, Math.Sqrt(sqlen));

            return newBillboard;
        }
        /// <summary>
        ///		Default constructor.
        /// </summary>
        public ParticleEmitter()
        {
            // set defaults
            angle = 0.0f;
            this.Direction = Vector3.UnitX;
            emissionRate = 10;
            fixedSpeed = 1;
            minSpeed = float.NaN;
            fixedTTL = 5;
            minTTL = float.NaN;
            position = Vector3.Zero;
            colorFixed = ColorEx.White;
            colorRangeStart = null;
            isEnabled = true;
            durationFixed = 0;
            durationMin = float.NaN;
            repeatDelayFixed = 0;
            repeatDelayMin = float.NaN;

            RegisterCommands();
        }
예제 #45
0
		/// <summary>
		/// Converts the Axiom.Core.ColorEx value to a int.  Each API may need the 
		/// bytes of the packed color data in different orders. i.e. OpenGL - ABGR, D3D - ARGB
		/// </summary>
		/// <param name="color"></param>
		/// <returns></returns>
		public override int ConvertColor(ColorEx color)
		{
			return color.ToABGR();
		}
예제 #46
0
		internal void SetBackColor2(ColorEx c)
		{
			m_BackColor2=c;
		}
예제 #47
0
		public static Color Convert( ColorEx color )
		{
			return new Color( (byte)( color.r*255 ), (byte)( color.g*255 ), (byte)( color.b*255 ), (byte)( color.a*255 ) );
		}
예제 #48
0
		public void ResetBackColor2()
		{
			m_BackColor2.ColorChanged-=new EventHandler(this.ColorChanged);
			m_BackColor2=ColorEx.Empty;
			m_BackColor2.ColorChanged+=new EventHandler(this.ColorChanged);
		}
 public void SetTextColor(ColorEx color)
 {
     if (normalTextStyle.textColor.CompareTo(color) == 0)
         return;
     Dirty = true;
     normalTextStyle.textColor = new ColorEx(color);
 }
예제 #50
0
파일: util.cs 프로젝트: mcintosh/logwizard
 public static Color grayer_color(Color col)
 {
     ColorEx ex = new ColorEx(col);
     ex.S = (byte)(ex.S / 5);
     return ex.Color;
 }
예제 #51
0
		/// <summary>
		/// Sets the fog with the given params.
		/// </summary>
		public override void SetFog(Graphics.FogMode mode, ColorEx color, Real density, Real linearStart, Real linearEnd)
		{
			basicEffect.FogEnabled = mode != Graphics.FogMode.None;
			basicEffect.FogColor = XnaHelper.Convert(color).ToVector3();
			basicEffect.FogStart = linearStart;
			basicEffect.FogEnd = linearEnd;

			skinnedEffect.FogEnabled = mode != Graphics.FogMode.None;
			skinnedEffect.FogColor = XnaHelper.Convert(color).ToVector3();
			skinnedEffect.FogStart = linearStart;
			skinnedEffect.FogEnd = linearEnd;
#if AXIOM_FF_EMULATION
			_ffProgramParameters.FogColor = color;
			_ffProgramParameters.FogDensity = density;
			_ffProgramParameters.FogEnd = linearEnd;
			_ffProgramParameters.FogStart = linearStart;
			_ffProgramParameters.FogMode = mode;
#endif

			#region fog fixed function implementation

			// disable fog if set to none
			/*if ( mode == Axiom.Graphics.FogMode.None )
			{
				_device.RenderState.FogTableMode = Microsoft.Xna.Framework.Graphics.FogMode.None;
				  
				_device.RenderState.FogEnable = false;
			}
			else
			{
				// enable fog
				XFG.Color col = XnaHelper.Convert( color );
				_device.RenderState.FogEnable = true;
				_device.RenderState.FogVertexMode = XnaHelper.Convert(mode);
				_device.RenderState.FogTableMode= XnaHelper.Convert(mode);
				_device.RenderState.FogColor= col;
				_device.RenderState.FogStart= start;
				_device.RenderState.FogEnd= end;
				_device.RenderState.FogDensity= density;
				_device.RenderState.RangeFogEnable= true; 
			}*/

			#endregion
		}
 /// <summary>
 ///		Internal method for generating a color for a particle.
 /// </summary>
 /// <param name="color">
 ///    The color object that will be altered depending on the method of generating the particle color.
 /// </param>
 protected virtual void GenerateEmissionColor(ColorEx color)
 {
     if (colorRangeStart != null) {
         color.r = colorRangeStart.r + MathUtil.UnitRandom() * (colorRangeEnd.r - colorRangeStart.r);
         color.g = colorRangeStart.g + MathUtil.UnitRandom() * (colorRangeEnd.g - colorRangeStart.g);
         color.b = colorRangeStart.b + MathUtil.UnitRandom() * (colorRangeEnd.b - colorRangeStart.b);
         color.a = colorRangeStart.a + MathUtil.UnitRandom() * (colorRangeEnd.a - colorRangeStart.a);
     }
     else {
         color.r = colorFixed.r;
         color.g = colorFixed.g;
         color.b = colorFixed.b;
         color.a = colorFixed.a;
     }
 }
예제 #53
0
		public static System.Drawing.Color ToColor( ColorEx color )
		{
			return System.Drawing.Color.FromArgb( (int)( color.a < 1.0f ? color.a * 255.0f : color.a ), (int)( color.r * 255.0f ), (int)( color.g * 255.0f ), (int)( color.b * 255.0f ) );
		}
 private void colorSelectButton_Click(object sender, EventArgs e)
 {
     using (colorDialog1 = new ColorDialog())
     {
         colorDialog1.SolidColorOnly = false;
         colorDialog1.AllowFullOpen = true;
         colorDialog1.AnyColor = true;
         int colorabgr = (int)cx.ToABGR();
         colorabgr &= 0x00ffffff;
         int[] colorsabgr = new int[1];
         colorsabgr[0] = colorabgr;
         colorDialog1.FullOpen = true;
         colorDialog1.ShowHelp = true;
         colorDialog1.Color = ColorExToColor(cx);
         colorDialog1.CustomColors = colorsabgr;
         DialogResult result = colorDialog1.ShowDialog();
         if (result == DialogResult.OK)
         {
             colorSelectButton.BackColor = colorDialog1.Color;
             cx = ColorToColorEx(colorDialog1.Color);
         }
     }
 }
예제 #55
0
		/// <summary>
		/// Clears one or more frame buffers on the active render target.
		/// </summary>
		/// <param name="buffers">
		///  Combination of one or more elements of <see cref="Graphics.RenderTarget.FrameBuffer"/>
		///  denoting which buffers are to be cleared.
		/// </param>
		/// <param name="color">The color to clear the color buffer with, if enabled.</param>
		/// <param name="depth">The value to initialize the depth buffer with, if enabled.</param>
		/// <param name="stencil">The value to initialize the stencil buffer with, if enabled.</param>
		public override void ClearFrameBuffer(FrameBufferType buffers, ColorEx color, Real depth, ushort stencil)
		{
			ClearOptions flags = 0; //ClearFlags 

			if ((buffers & FrameBufferType.Color) > 0)
			{
				flags |= ClearOptions.Target;
			}
			if ((buffers & FrameBufferType.Depth) > 0)
			{
				flags |= ClearOptions.DepthBuffer;
			}
			// Only try to clear the stencil buffer if supported
			if ((buffers & FrameBufferType.Stencil) > 0
				 && Capabilities.HasCapability(Graphics.Capabilities.StencilBuffer))
			{
				flags |= ClearOptions.Stencil;
			}
			var col = XnaHelper.Convert(color);

			// clear the device using the specified params
			_device.Clear(flags, col, depth, stencil);
		}
 private Color ColorExToColor(ColorEx cx)
 {
     return Color.FromArgb((int)cx.ToARGB());
 }
        protected void GenerateScene()
        {
            ((Axiom.SceneManagers.Multiverse.SceneManager)sceneManager).SetWorldParams(terrainGenerator, new LODSpec());
            sceneManager.LoadWorldGeometry("");

            AmbientLightColor = new ColorEx(0.5f, 0.5f, 0.5f);

            // set up directional light
            directionalLight = sceneManager.CreateLight("MainLight");
            directionalLight.Type = LightType.Directional;
            directionalLight.SetAttenuation(1000 * OneMeter, 1, 0, 0);

            DirectionalDiffuseColor = ColorEx.White;
            DirectionalSpecularColor = ColorEx.White;

            PositionLight();

            // create and position the scene node used to display the loaded model
            modelNode = sceneManager.RootSceneNode.CreateChildSceneNode();
            modelNode.Position = modelBase;

            helperNode = sceneManager.RootSceneNode.CreateChildSceneNode();
            helperNode.Position = modelBase;

            Axiom.SceneManagers.Multiverse.TerrainManager.Instance.ShowOcean = false;
            // Set our DisplayTerrain property to the current value.
            // This will set the desired SceneManager properties.
            this.DisplayTerrain = displayTerrain;
            //particleNode = scene.RootSceneNode.CreateChildSceneNode();
            //particleNode.Position = new Vector3(0 * oneMeter, 50 * oneMeter, 0 * oneMeter);

            //ParticleSystem ps = ParticleSystemManager.Instance.CreateSystem("foo", "PEExamples/ringOfFire");
            //particleNode.AttachObject(ps);
            //particleNode.ScaleFactor = new Vector3(1000f, 1000f, 1000f);
            //ps.ShowBoundingBox = true;

            return;
        }
 public CompositionPass(CompositionTargetPass parent)
 {
     this.parent = parent;
     type = CompositorPassType.RenderQuad;
     identifier = 0;
     firstRenderQueue = RenderQueueGroupID.SkiesEarly;
     lastRenderQueue = RenderQueueGroupID.SkiesLate;
     clearBuffers = FrameBuffer.Color | FrameBuffer.Depth;
     clearColor = new ColorEx(0f, 0f, 0f, 0f);
     clearDepth = 1.0f;
     clearStencil = 0;
     stencilCheck = false;
     stencilFunc = CompareFunction.AlwaysPass;
     stencilRefValue = 0;
     stencilMask = (int)0x7FFFFFFF;
     stencilFailOp = StencilOperation.Keep;
     stencilDepthFailOp = StencilOperation.Keep;
     stencilPassOp = StencilOperation.Keep;
     stencilTwoSidedOperation = false;
 }
예제 #59
-1
		/// <summary>コピーコンストラクタ。</summary>
		/// <param name="previous"></param>
		public ColorEx(ColorEx previous)
			{
			A = previous.A;
			R = previous.R;
			G = previous.G;
			B = previous.B;
			}
예제 #60
-1
 public Fog(WorldEditor app, Boundary parent, ColorEx color, float nearin, float farin)
 {
     this.app = app;
     this.parentNode = null;
     this.parent = parent;
     this.cx = color;
     this.near = nearin;
     this.far = farin;
 }