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();
        }
예제 #2
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();
        }