Esempio n. 1
0
        private void UpdateOutliners()
        {
            var camera = Program.CurrentScene.CurrentCamera;

            float dot = -2;

            _hoveredDie = null;


            foreach (var die in Dice)
            {
                float d = vec3.Dot(camera.GetMouseRay(), (die.Position - camera.Position).NormalizedSafe);
                if (d < _highlightCutoff)
                {
                    continue;
                }
                if (d < dot)
                {
                    continue;
                }
                dot         = d;
                _hoveredDie = die;
            }

            foreach (var d in Dice)
            {
                if (d == _hoveredDie)
                {
                    d.Outliner.Enabled     = true;
                    d.Outliner.Color       = Rolling.Contains(d) ? vec3.Lerp(_hoverColor, _rerollColor, .5f) : _hoverColor;
                    d.Outliner.OutlineSize = _hoverThickness;
                }
                else if (!Rolling.Contains(d))
                {
                    d.Outliner.Enabled = false;
                }
                else
                {
                    d.Outliner.OutlineSize = _rerollThickness;
                    d.Outliner.Color       = _rerollColor;
                    d.Outliner.Enabled     = true;
                }
            }
        }
Esempio n. 2
0
        public void Populate(int count)
        {
            if (Dice.Count > 0)
            {
                return;
            }

            Random r = new Random();

            for (int i = 0; i < count; i++)
            {
                var d = new EntityDie(_gl, "Dice/D6Red/d6red.obj")
                {
                    Position = new vec3(-count + i * 2, 3, 0)
                };
                d.Transform.Rotate(2 * (float)r.NextDouble(), new vec3((float)r.NextDouble(), (float)r.NextDouble(), (float)r.NextDouble()).NormalizedSafe);

                Dice.Add(d);
            }

            Rolling = Dice.GetRange(0, count);
            Program.CurrentScene.Entities.AddRange(Dice);
        }