示例#1
0
 public StatusWidget(Text3D text, Urho.Shapes.Plane plane, string key, string label)
 {
     this.Text  = text;
     this.plane = plane;
     this.Key   = key;
     this.Label = label;
 }
示例#2
0
        protected override async void Start()
        {
            await OpenPDF();

            // base.Start() creates a basic scene
            base.Start();

            MusicNode          = Scene.CreateChild();
            MusicNode.Position = new Vector3(0, 0, 1.5f); // Lets place the music 1.5 meter away
            MusicNode.Rotation = new Quaternion(0, 90, -90);
            MusicNode.Scale    = new Vector3(0.4f * 1.414f, 0, 0.4f);

            //subscribe to some input events:
            EnableGestureManipulation = true;
            EnableGestureTapped       = true;

            // Create a Plane component for holding the music
            Music = MusicNode.CreateComponent <Urho.Shapes.Plane>();

            // Override the default material (material is a set of tecniques, parameters and textures)
            //Material MusicMaterial = ResourceCache.GetMaterial("Page_" + CurrentPage.ToString());
            Music.SetMaterial(Material.FromImage(ResourceCache.GetImage("Page_" + CurrentPage.ToString())));

// requires Microphone capability enabled
            await RegisterCortanaCommands(new Dictionary <string, Action> {
                { "bigger", () => MusicNode.Scale *= 1.2f },
                { "smaller", () => MusicNode.Scale *= 0.8f },
                { "next", () => NextPage() },
                { "previous", () => PreviousPage() }
            });
            await TextToSpeech("Lets play som music!");
        }
        public void AddWidget(Widget widget)
        {
            Node widgetNode = new Node();

            widgetNode.SetScale(0.1f);
            widgetNode.Position += new Vector3(widget.Position[0] * 0.1f, widget.Position[1] * 0.1f, widget.Position[2] * 0.1f);

            //Background Plane
            Node backgroundPlaneNode = widgetNode.CreateChild();

            backgroundPlaneNode.Scale     = new Vector3(1.9f, 1f, 1f);
            backgroundPlaneNode.Rotation  = new Quaternion(-90, 0, 0);
            backgroundPlaneNode.Position += new Vector3(0, 0, 0.05f);

            Urho.Shapes.Plane plane = backgroundPlaneNode.CreateComponent <Urho.Shapes.Plane>();
            plane.SetMaterial(Material.FromColor(new Color(0.6f, 0.6f, 0.6f, 0.5f)));

            //Text Component
            Text3D text = widgetNode.CreateComponent <Text3D>();

            text.HorizontalAlignment = HorizontalAlignment.Center;
            text.VerticalAlignment   = VerticalAlignment.Center;
            text.SetFont(CoreAssets.Fonts.AnonymousPro, 12);
            text.SetColor(Color.Red);
            text.Text = "LOADING...";

            switch (widget.type)
            {
            case WidgetType.Text:
                //Text Widget Display
                TextWidget textWidget = widgetNode.CreateComponent <TextWidget>();
                textWidget.Text  = text;
                textWidget.Key   = widget.NetworkKey;
                textWidget.Label = widget.Label;
                break;

            case WidgetType.Camera:
                //remove text
                text.Remove();

                //Camera Widget
                CameraWidget cameraWidget = new CameraWidget(widget.NetworkKey, plane);
                widgetNode.AddComponent(cameraWidget);
                break;

            case WidgetType.Status:
                //adjust the size of the background plane
                backgroundPlaneNode.Scale = new Vector3(0.5f, 1f, 0.25f);

                //Status Widget
                StatusWidget statusWidget = new StatusWidget(text, plane, widget.NetworkKey, widget.Label);
                widgetNode.AddComponent(statusWidget);
                break;
            }

            Node.AddChild(widgetNode);
        }
示例#4
0
        public override void OnAttachedToNode(Node node)
        {
            this.Node?.RemoveChild(m_Geometry);
            this.Node?.RemoveComponent(Building);

            m_Geometry = node.CreateChild();
            m_Plane    = m_Geometry.CreateComponent <Urho.Shapes.Plane>();
            m_Plane.SetMaterial(Application.ResourceCache.GetMaterial(Assets.Materials.Grass));
        }
        public override void OnAttachedToNode(Node node)
        {
            base.OnAttachedToNode(node);

            // Create screen node, its plane shape and transform it
            screenNode       = node.CreateChild("screenNode");
            screenNode.Scale = new Vector3(Width, 0, Height);
            screenNode.Rotate(new Quaternion(-90, 0, 0), TransformSpace.Local);

            Urho.Shapes.Plane frame = screenNode.CreateComponent <Urho.Shapes.Plane>();
            frame.SetMaterial(Material.FromColor(FrameColor, true));

            // Create markers pool and initialize with arbitrary size
            Pool = new MarkerSpherePool(20, screenNode);

            // Update stream data
            CameraStream.Instance.UpdateStreamData();
        }
示例#6
0
        // Creates nice frame around the screen
        private void CreateFrame(Node node, float frameWidth)
        {
            float originX = node.Position.X - Width / 2;
            float originY = Height / 2;

            // Create frame node to hold all pieces
            screenFrame = node.CreateChild("screenFrame");
            screenFrame.Rotate(new Quaternion(0, 0, -orientation), TransformSpace.Local);

            // Get correct colors for shadows and lit frame areas
            Urho.Color leftColor, topColor, rightColor, bottomColor;
            GetFrameColors(out leftColor, out topColor, out rightColor, out bottomColor);

            // Right frame
            Node framePieceNode = screenFrame.CreateChild("FrameRight");

            framePieceNode.Scale = new Vector3(frameWidth, 0, Height + frameWidth);
            framePieceNode.Rotate(new Quaternion(-90, 0, 0), TransformSpace.Local);
            framePieceNode.Position = new Vector3(originX + Width,
                                                  node.Position.Y,
                                                  node.Position.Z);

            Urho.Shapes.Plane framePiece = framePieceNode.CreateComponent <Urho.Shapes.Plane>();
            framePiece.SetMaterial(Material.FromColor(rightColor, true));

            // Top frame
            framePieceNode = screenFrame.CreateChild("FrameTop");

            framePieceNode.Scale = new Vector3(Width + frameWidth, 0, frameWidth);
            framePieceNode.Rotate(new Quaternion(-90, 0, 0), TransformSpace.Local);
            framePieceNode.Position = new Vector3(node.Position.X,
                                                  originY,
                                                  node.Position.Z);

            framePiece = framePieceNode.CreateComponent <Urho.Shapes.Plane>();
            framePiece.SetMaterial(Material.FromColor(topColor, true));

            // Bottom frame
            framePieceNode = screenFrame.CreateChild("FrameBottom");

            framePieceNode.Scale = new Vector3(Width + frameWidth, 0, frameWidth);
            framePieceNode.Rotate(new Quaternion(-90, 0, 0), TransformSpace.Local);
            framePieceNode.Position = new Vector3(node.Position.X,
                                                  -originY,
                                                  node.Position.Z);

            framePiece = framePieceNode.CreateComponent <Urho.Shapes.Plane>();
            framePiece.SetMaterial(Material.FromColor(bottomColor, true));

            // Left frame
            framePieceNode = screenFrame.CreateChild("FrameLeft");

            framePieceNode.Scale = new Vector3(frameWidth, 0, Height + frameWidth);
            framePieceNode.Rotate(new Quaternion(-90, 0, 0), TransformSpace.Local);
            framePieceNode.Position = new Vector3(originX,
                                                  node.Position.Y,
                                                  node.Position.Z);

            framePiece = framePieceNode.CreateComponent <Urho.Shapes.Plane>();
            framePiece.SetMaterial(Material.FromColor(leftColor, true));
        }
示例#7
0
        public override void OnAttachedToNode(Node node)
        {
            base.OnAttachedToNode(node);

            // Create screen Node, scale it accordingly and rotate it so it faces camera
            screenNode       = node.CreateChild("screenNode");
            markerSphereNode = node.CreateChild("markerSphereNode");
            backdropNode     = node.CreateChild("backdrop");

            loadingSpinner = new LoadingSpinner(node.CreateChild("spinner"), 40, 1);

            // Initialize marker sphere pool with arbitrary number of spheres
            Pool = new MarkerSpherePool(20, markerSphereNode);

            backdropNode.Scale = new Vector3(Height, 1, Width);

            // Rotate the camera in the clockwise direction with 90 degrees
            backdropNode.Rotate(new Quaternion(-90, 0, 0), TransformSpace.Local);

            // Apply camera orientation and an offset to match the no rotation position with QTM
            backdropNode.Rotate(new Quaternion(0, 90 - Camera.Orientation, 0), TransformSpace.Local);
            markerSphereNode.Rotate(new Quaternion(0, 0, -Camera.Orientation), TransformSpace.Local);

            // Create marker screen node and its plane
            defaultScreen = backdropNode.CreateComponent <Urho.Shapes.Plane>();
            defaultScreen.SetMaterial(Material.FromColor(Urho.Color.Black, true));

            // Create intensity plane, its material and assign it
            imageScreen    = backdropNode.CreateComponent <Urho.Shapes.Plane>();
            screenMaterial = new Material();

            SetImageTexture(Camera.ImageResolution.Width, Camera.ImageResolution.Height);

            // Set detail info label
            // TODO: Fix magic numbers
            nodeDetailTextLabel = screenNode.CreateChild();
            textLabel           = nodeDetailTextLabel.CreateComponent <Text3D>();

            if (Camera.Orientation == 0)
            {
                nodeDetailTextLabel.Position = new Vector3(-Width / 2 + 0.2f, -Height / 2 + 0.7f, -0.1f);
            }
            else
            {
                nodeDetailTextLabel.Position = new Vector3(-Height / 2 + 0.2f, -Width / 2 + 0.7f, -0.1f);
            }

            textLabel.Text = Camera.ID.ToString();
            textLabel.SetFont(CoreAssets.Fonts.AnonymousPro, 55);
            textLabel.TextEffect = TextEffect.Stroke;

            // Set grid view info label
            nodeGridTextLabel = screenNode.CreateChild();
            textLabel         = nodeGridTextLabel.CreateComponent <Text3D>();

            if (Camera.Orientation == 0)
            {
                nodeGridTextLabel.Position = new Vector3(-Width / 2 + 0.2f, -Height / 2 + 1f, -0.1f);
            }
            else
            {
                nodeGridTextLabel.Position = new Vector3(-Height / 2 + 0.2f, -Width / 2 + 1f, -0.1f);
            }

            textLabel.Text = Camera.ID.ToString();
            textLabel.SetFont(CoreAssets.Fonts.AnonymousPro, 100);
            textLabel.TextEffect = TextEffect.Stroke;

            // Create a node and a text object to display messages centered in the camera screen
            nodeTextMessage = screenNode.CreateChild();
            textMessage     = nodeTextMessage.CreateComponent <Text3D>();
            textMessage.SetFont(CoreAssets.Fonts.AnonymousPro, 35);
            textMessage.TextEffect = TextEffect.Stroke;
            textMessage.Text       = "Intensity/Video mode is disabled in slave mode";

            textMessage.VerticalAlignment   = VerticalAlignment.Center;
            textMessage.HorizontalAlignment = HorizontalAlignment.Center;
            textMessage.TextAlignment       = HorizontalAlignment.Center;
            nodeTextMessage.Enabled         = false;
            nodeTextMessage.Position        = new Vector3(0.0f, 0.0f, -0.1f);

            // Disable both label nodes at start
            nodeGridTextLabel.Enabled   = false;
            nodeDetailTextLabel.Enabled = false;

            // Initialize current camera mode
            SetImageMode(Camera.IsImageMode());

            // Subscribe to messages
            SubscribeToDataEvents();

            // Create frame
            CreateFrame(screenNode, 0.04f);

            // Start with loading spinner enabled
            loadingSpinner.Start();
        }
示例#8
0
 public CameraWidget(string URL, Urho.Shapes.Plane plane)
 {
     ReceiveSceneUpdates = false;
     this.URL            = URL;
     this.plane          = plane;
 }