예제 #1
0
        public VisualElement(RectangleF area)
        {
            long ticks = stopWatch.ElapsedTicks;

            if (ticks <= m_lastTicks)
                ticks = m_lastTicks+1;

            m_random = new Random((int)ticks);

            m_lastTicks = ticks;


            m_originalPos = new PointF(area.Location.X, area.Location.Y);
            m_location = area;
            m_animationStep = m_random.Next(0, 40);
         

            float r = m_random.Next(90, 100) / 100f;
            float g = m_random.Next(90, 100) / 100f;
            float b = m_random.Next(90, 100) / 100f;
            
            //Color = new Color4(1, r, g, b);
            Color = new Color4(1, 1, 1, 1);

            m_currentPos = new PointF(m_originalPos.X, m_originalPos.Y);
        }
예제 #2
0
        /// <summary>
        /// Composes a DrawingLayer with another DrawingLayer.  
        /// This allows for things like scaling, blending, 2D and 3D transformations
        /// </summary>
        /// <param name="layer">The DrawingLayer that is used as the input</param>
        /// <param name="sourceArea">The area over the input DrawingLayer</param>
        /// <param name="destinationArea">The output area to draw the source area</param>
        /// <param name="rotationTransform">The rotation parameters</param>
        /// <param name="tint">The color to tint the source layer on to the output</param>
        public void ComposeDrawingLayer(DrawingLayer layer, ref RectangleF sourceArea, ref RectangleF destinationArea, ref RotationParameters rotationTransform, ref Color4 tint)
        {
            m_drawStateManagement.DrawPreamble();

            /* Get the current draw data to fill.  We avoid creating new object instances
             * for the GC to have to delete */
            var spriteRenderData = m_spriteRenderer.GetCurrentRenderData();

            /* Copy all the primitive transform data to the spriteRenderData */

            float xDestination = destinationArea.X;
            float yDestination = destinationArea.Y;

            spriteRenderData.drawData.Translation.X = xDestination;
            spriteRenderData.drawData.Translation.Y = yDestination;

            spriteRenderData.drawData.Rotate.X = rotationTransform.RotateX;
            spriteRenderData.drawData.Rotate.Y = rotationTransform.RotateY;
            spriteRenderData.drawData.Rotate.Z = rotationTransform.RotateZ;

            spriteRenderData.drawData.Scale.X = destinationArea.Width / sourceArea.Width;
            spriteRenderData.drawData.Scale.Y = destinationArea.Height / sourceArea.Height;

            spriteRenderData.drawData.DrawRect.X = sourceArea.X;
            spriteRenderData.drawData.DrawRect.Y = sourceArea.Y;
            spriteRenderData.drawData.DrawRect.Z = sourceArea.Width;
            spriteRenderData.drawData.DrawRect.W = sourceArea.Height;

            spriteRenderData.drawData.RotationCenter = rotationTransform.RotationCenter.InternalVector2;

            spriteRenderData.drawData.Color = tint.InternalColor4;
            spriteRenderData.texture = layer.RenderTargetTexture;

            /* Add (queue) the drawing data to the sprite renderer */
            m_spriteRenderer.AddRenderData(spriteRenderData);
        }
예제 #3
0
 /// <summary>
 /// Composes a DrawingLayer with another DrawingLayer.  
 /// This allows for things like scaling, blending, 2D and 3D transformations
 /// </summary>
 /// <param name="layer">The DrawingLayer that is used as the input</param>
 /// <param name="sourceArea">The area over the input DrawingLayer</param>
 /// <param name="destinationArea">The output area to draw the source area</param>
 /// <param name="rotationTransform">The rotation parameters</param>
 /// <param name="tint">The color to tint the source layer on to the output</param>
 public void ComposeDrawingLayer(DrawingLayer layer, RectangleF sourceArea, RectangleF destinationArea, RotationParameters rotationTransform, Color4 tint)
 {
     ComposeDrawingLayer(layer, ref sourceArea, ref destinationArea, ref rotationTransform, ref tint);
 }
예제 #4
0
        private void UpdateScreenVisualization(Dictionary<int, MotionTrackingDevice> devices, MotionTrackingScreen screen, WPFPresenter handPresenter)
        {
            handPresenter.Clear();

            edgeEffect.Tint = new Color4(1, 1, 0, 0);
            edgeEffect.MinThreshold = 300f;
            edgeEffect.MaxThreshold = 10000f;
            edgeEffect.EdgeThreshold = 100f;
            edgeEffect.TexSize = new Size(intermediateLayer.Width, intermediateLayer.Height);

            foreach (var innerkvp in devices)
            {
                var session = innerkvp.Value.Session;
                var rectf = new RectangleF((float)(session.PositionProjective.X - 100), (float)(session.PositionProjective.Y - 100), 200, 200);
                if (!screen.IsSessionInBounds(session))
                {
                    continue;
                }

                var p = screen.MapPositionToScreen(session, handPresenter.Width, handPresenter.Height);

                var targetRectf = new RectangleF((float)(p.X - 100), (float)(p.Y - 100), 200, 200);

                if (innerkvp.Value.ShouldPromoteToTouch)
                    thresholdEffect.Tint = new Color4(.8f, 0, 0, 0);
                else
                    thresholdEffect.Tint = new Color4(.4f, 0, 0, 0);
                thresholdEffect.MinThreshold = (float)(session.PositionProjective.Z - 100);
                thresholdEffect.MaxThreshold = (float)(session.PositionProjective.Z + 100);
                rawDepthLayer.ApplyEffect(thresholdEffect, intermediateLayer, true);

                //intermediateLayer.ApplyEffect(unpackEffect, effectLayer, true);

                //handPresenter.BeginDraw();
                //if (session.IsPromotedToTouch)
                //handPresenter.FillEllipse(contactBrush, new DirectCanvas.Shapes.Ellipse(new PointF((float)p.X, (float)p.Y), 20, 20));
                //else
                //  handPresenter.FillEllipse(hoverBrush, new DirectCanvas.Shapes.Ellipse(new PointF((float)p.X, (float)p.Y), 20, 20));
                //handPresenter.EndDraw();
                var tint = new Color4(1, 1, 1, 1);
                //if (innerkvp.Value.ShouldPromoteToTouch)
                //{
                //    tint.Alpha = 0.8f;
                //}
                handPresenter.BeginCompose();
                handPresenter.ComposeLayer(intermediateLayer, rectf, targetRectf, new RotationParameters(), tint);
                handPresenter.EndCompose();
            }

            handPresenter.Present();
        }
예제 #5
0
 public SolidColorBrush CreateSolidColorBrush(Color4 color)
 {
     return new SolidColorBrush(m_renderTargetResourceOwner, color);
 }
예제 #6
0
 /// <summary>
 /// Creates a new SolidColorBrush.
 /// </summary>
 /// <param name="color">The color used for the SolidColorBrush</param>
 /// <returns>A new instance of SolidColorBrush</returns>
 public Brushes.SolidColorBrush CreateSolidColorBrush(Color4 color)
 {
     return m_resources.CreateSolidColorBrush(color);
 }
예제 #7
0
        /// <summary>
        /// Composes a DrawingLayer with another DrawingLayer.  
        /// This allows for things like scaling, blending, 2D and 3D transformations
        /// </summary>
        /// <param name="layer">The DrawingLayer that is used as the input</param>
        /// <param name="sourceArea">The area over the input DrawingLayer</param>
        /// <param name="destinationArea">The output area to draw the source area</param>
        /// <param name="rotationTransform">The rotation parameters</param>
        /// <param name="tint">The color to tint the source layer on to the output</param>
        internal void Compose(DrawingLayer layer, RectangleF sourceArea, RectangleF destinationArea, RotationParameters rotationTransform, Color4 tint)
        {
            m_composeStateManagement.DrawPreamble();

            m_composer.ComposeDrawingLayer(layer, sourceArea, destinationArea, rotationTransform, tint);
        }