Пример #1
0
        private SCNNode FocusSquareNode()
        {
            if (focusSquareNode == null)
            {
                /*
                 * The focus square consists of eight Segments as follows, which can be individually animated.
                 *
                 *      s1  s2
                 *      _   _
                 * s3 |     | s4
                 *
                 * s5 |     | s6
                 *      -   -
                 *      s7  s8
                 */

                var sl = 0.5f;                      // segment length
                var c  = FocusSquareThickness / 2f; // correction to align lines perfectly

                var s1 = new FocusSquareSegment("s1", Corner.TopLeft, Alignment.Horizontal);
                var s2 = new FocusSquareSegment("s2", Corner.TopRight, Alignment.Horizontal);
                var s3 = new FocusSquareSegment("s3", Corner.TopLeft, Alignment.Vertical);
                var s4 = new FocusSquareSegment("s4", Corner.TopRight, Alignment.Vertical);
                var s5 = new FocusSquareSegment("s5", Corner.BottomLeft, Alignment.Vertical);
                var s6 = new FocusSquareSegment("s6", Corner.BottomRight, Alignment.Vertical);
                var s7 = new FocusSquareSegment("s7", Corner.BottomLeft, Alignment.Horizontal);
                var s8 = new FocusSquareSegment("s8", Corner.BottomRight, Alignment.Horizontal);

                s1.Position = s1.Position.Add(new SCNVector3(-(sl / 2 - c), -(sl - c), 0));
                s2.Position = s2.Position.Add(new SCNVector3(sl / 2 - c, -(sl - c), 0));
                s3.Position = s3.Position.Add(new SCNVector3(-sl, -sl / 2, 0));
                s4.Position = s4.Position.Add(new SCNVector3(sl, -sl / 2, 0));
                s5.Position = s5.Position.Add(new SCNVector3(-sl, sl / 2, 0));
                s6.Position = s6.Position.Add(new SCNVector3(sl, sl / 2, 0));
                s7.Position = s7.Position.Add(new SCNVector3(-(sl / 2 - c), sl - c, 0));
                s8.Position = s8.Position.Add(new SCNVector3(sl / 2 - c, sl - c, 0));

                var planeNode = new SCNNode();
                planeNode.EulerAngles = new SCNVector3((float)(Math.PI / 2), planeNode.EulerAngles.Y, planeNode.EulerAngles.Z);
                planeNode.SetUniformScale(FocusSquareSize * ScaleForClosedSquare);

                planeNode.AddChildNode(s1);
                planeNode.AddChildNode(s2);
                planeNode.AddChildNode(s3);
                planeNode.AddChildNode(s4);
                planeNode.AddChildNode(s5);
                planeNode.AddChildNode(s6);
                planeNode.AddChildNode(s7);
                planeNode.AddChildNode(s8);
                planeNode.AddChildNode(FillPlane);
                segments = new FocusSquareSegment[] { s1, s2, s3, s4, s5, s6, s7, s8 };

                IsOpen = false;

                // Always render focus square on top
                planeNode.RenderOnTop();
                focusSquareNode = planeNode;
            }
            return(focusSquareNode);
        }