Exemplo n.º 1
0
        public TextSpriteNode(
            AParentSceneNode parent,
            Transform localTransform,
            string label,
            Texture2D background,
            Texture2D highlight)
            : base(parent, localTransform, label)
        {
            m_spriteNode = new SpriteNode(this, label + "_sprite", background);
            m_spriteNode.Origin = new Vector2(0.5f);

            m_textNode = new TextNode(this, label + "_text");
            m_textNode.Alignment = Alignment.Centered;
            m_textNode.Text.Append(label);
            m_textNode.LocalTransform = new Transform(Vector2.Zero, new Vector2(0.6f));

            m_highlightSpriteNode = new SpriteNode(this, label + "_highlight", highlight);
            m_highlightSpriteNode.Origin = new Vector2(0.5f);
        }
Exemplo n.º 2
0
        public SliderNode(
            AParentSceneNode parent,
            Transform localTransform,
            // what parameter does this slider drag?
            Parameter parameter,
            // at what angle is the slider oriented?
            float rotation,
            // how long is the slider in screen space?
            int screenLength,
            // how far is the slider's origin from the transform's translation, in screen space?
            int originScreenOffset,
            // what is the slider's label?
            string label)
            : base(parent, localTransform, label)
        {
            m_parameter = parameter;
            m_rotation = rotation;
            m_screenLength = screenLength;
            m_originScreenOffset = originScreenOffset;

            // calculate the endpoints
            m_zeroEnd = ValueToLocal(0);
            m_oneEnd = ValueToLocal(1);

            double absRotation = Math.IEEERemainder(rotation, Math.PI * 2);
            if (absRotation < 0) {
                absRotation += Math.PI * 2;
            }

            m_label = new TextNode(this, label + "_text");

            bool overPi = absRotation > Math.PI;

            m_label.Alignment = overPi ? Alignment.TopLeft : Alignment.TopRight;
            m_label.Text.Append(label);
            m_label.LocalTransform = new Transform(m_oneEnd, new Vector2(0.7f));
            // seems the line rotation and label rotation go in opposite directions, feh!
            m_label.Rotation = -rotation + (float)(Math.PI / 2) + (overPi ? (float)Math.PI : 0);

            m_fullLine = new LineNode(this, "fullLine");
            m_fullLine.SetEndpoints(m_zeroEnd, m_oneEnd);

            m_sliderLine = new LineNode(this, "sliderLine");
            m_sliderLine.LocalTransform = new Transform(Vector2.Zero, new Vector2(3f)); // 3-pixel wide line

            Value = m_parameter[0];
        }
Exemplo n.º 3
0
        internal HolofunkSceneGraph(
            GraphicsDevice graphicsDevice,
            Vector2 canvasSize,
            Texture2D depthTexture,
            HolofunkTextureContent holofunkContent,
            HolofunkBass audio,
            Clock clock)
            : base()
        {
            m_content = holofunkContent;
            m_clock = clock;

            RootNode = new GroupNode(null, Transform.Identity, "Root");
            m_canvasSize = canvasSize;

            m_background = new SpriteNode(
                RootNode,
                "Background",
                TextureFactory.ShadedCornerColor(
                    graphicsDevice,
                    canvasSize,
                    Color.Black,
                    new Color(0x10, 0x10, 0x10, 0x10),
                    new Color(0x20, 0x20, 0x20, 0x20),
                    new Color(0x20, 0x20, 0x20, 0x20)));
            m_background.LocalTransform = Transform.Identity;

            m_slide = new SpriteNode(
                RootNode,
                "Slide",
                Content.Slides[0]);
            m_slide.LocalTransform = new Transform(new Vector2(canvasSize.X - (int)(Content.Slides[0].Width * 1.1f),
                (canvasSize.Y - (int)Content.Slides[0].Height) / 2));
            m_slide.SetSecondaryViewOption(SecondaryViewOption.PositionMirrored | SecondaryViewOption.TextureMirrored);

            // constructing the nodes adds them as children of the parent, in first-at-bottom Z order.

            SpriteNode depthNode = new SpriteNode(
                RootNode,
                "DepthImage",
                depthTexture);
            depthNode.LocalTransform = new Transform(
                Vector2.Zero,
                new Vector2((float)canvasSize.X / depthTexture.Width, (float)canvasSize.Y / depthTexture.Height));

            // we want the depth node texture (only) to be mirrored about the center of the viewport
            depthNode.SetSecondaryViewOption(SecondaryViewOption.TextureMirrored); // B4CR: should this also be | PositionMirrored?

            m_audio = audio;

            // Center the textures.
            Vector2 origin = new Vector2(0.5f);

            m_statusText = new TextNode(RootNode, "StatusText");
            m_statusText.SetSecondaryViewOption(SecondaryViewOption.Hidden);
            m_statusText.LocalTransform = new Transform(new Vector2(30f, 20f), new Vector2(MagicNumbers.StatusTextScale));

            // make sure that first update pushes status text
            m_frameCount = MagicNumbers.StatusTextUpdateInterval - 1;

            m_beatNode = new BeatNode(
                RootNode,
                new Transform(new Vector2(m_canvasSize.X / 2, m_canvasSize.Y / 8 * 7)),
                "Root Beater",
                false,
                MagicNumbers.MeasureCircleScale,
                () => (long)((float)clock.ContinuousBeatDuration * 4),
                () => 0,
                () => Color.White);

            m_trackGroupNode = new GroupNode(RootNode, Transform.Identity, "Track group");
        }
        public PlayerHandSceneGraph(PlayerSceneGraph parent, bool isRight)
        {
            m_parent = parent;
            m_isRight = isRight;

            RootNode = new GroupNode(parent.RootNode, Transform.Identity, isRight ? "Left Hand" : "Right Hand");

            m_handGroup = new GroupNode(RootNode, Transform.Identity, isRight ? "Right Group" : "Left Group");

            m_handMikeSignal = new TrackNode(
                m_handGroup,
                new Transform(Vector2.Zero, new Vector2(MagicNumbers.LoopieScale)),
                "MikeSignal",
                parent.Content,
                -1,
                null,
                true,
                () => parent.Audio.LevelRatio(parent.Channel) * 0.5f,
                () => m_handMikeSignalColor,
                () => Color.White,
                // TODO: revive beat meter on current recording
                () => new Duration<Sample>(0),
                () => 0,
                () => m_handMikeSignalColor,
                () => 1f);

            m_handNode = new SpriteNode(m_handGroup, isRight ? "Right Hand" : "Left Hand", null);
            m_handNode.Origin = new Vector2(0.5f);
            m_handNode.SetSecondaryViewOption(SecondaryViewOption.PositionMirrored | SecondaryViewOption.TextureMirrored);

            m_effectLabelGroup = new GroupNode(m_handGroup, Transform.Identity, "Effect label group");
            m_effectLabelGroup.SetSecondaryViewOption(SecondaryViewOption.PositionMirrored);

            m_effectLabels = MakeEffectLabels(m_effectLabelGroup);

            m_armPoseLabel = new TextNode(RootNode, "Elbow label");
            m_armPoseLabel.Alignment = isRight ? Alignment.TopLeft : Alignment.TopRight;
            m_armPoseLabel.SetSecondaryViewOption(SecondaryViewOption.Hidden);
        }
 TextNode[] MakeEffectLabels(AParentSceneNode group)
 {
     TextNode[] ret = new TextNode[4];
     ret[0] = MakeEffectLabel(group, m_parent.HandDiameter / 2, 0, 0, false);
     ret[1] = MakeEffectLabel(group, 0, -m_parent.HandDiameter / 2, Math.PI * 3 / 2, false);
     ret[2] = MakeEffectLabel(group, -m_parent.HandDiameter / 2, 0, 0, true);
     ret[3] = MakeEffectLabel(group, 0, m_parent.HandDiameter / 2, Math.PI / 2, false);
     return ret;
 }
 TextNode MakeEffectLabel(AParentSceneNode group, float x, float y, double rotation, bool rightJustified)
 {
     TextNode ret = new TextNode(group, "");
     ret.LocalTransform = new Transform(new Vector2(x, y), new Vector2(MagicNumbers.EffectTextScale));
     ret.Rotation = (float)rotation;
     if (rightJustified) {
         ret.Alignment = Alignment.TopRight;
     }
     return ret;
 }