Example #1
0
        void Ex6ContextMenu_Click(object sender, EventArgs e)
        {
            // Get the click information from the Tag property as a VRRaycastResult type.
            VRRayCastResult res = SDKViewer.UI.ContextMenu3D.Tag as VRRayCastResult;

            // The Point2D contains the pixel position in 3D window space.
            m_RichTextBox.Text = "Clicked on window position = " + res.Point2D.ToString();
            // The position contains the 3D coordinate where the user clicked on the element.
            m_RichTextBox.Text += "\r\nClicked on 3D position = " + res.Position.ToString();
            // The origin of the ray, defines the 3D position in world space, corresponding with the Point2D coordinate projected on to camera screen.
            m_RichTextBox.Text += "\r\nThe click creates a line from position = \r\n\t" + res.Ray.Origin.ToString();
            // The direction of the ray. Could also be calculated from the position and ray.origin.
            m_RichTextBox.Text += "\r\n\twith a direction = \r\n\t\t" + res.Ray.Direction.ToString();
            // There is an indirect relationship between the 3D element and the CAD/FRT elements.
            // So this code finds back all Branch objects this 3D element belongs to.
            m_RichTextBox.Text += "\r\nThe branches the 3d element belongs to = ";
            if (res.Branches != null)
            {
                foreach (IVRBranch branch in res.Branches)
                {
                    m_RichTextBox.Text += "\r\n\t" + branch.Name;
                }
            }
            else
            {
                m_RichTextBox.Text += "\r\n\t This element is not part of any branch !!";
            }
        }
Example #2
0
        void m_ItemCreate_Click(object sender, EventArgs e)
        {
            // Get the click information from the Tag property as a VRRaycastResult type.
            VRRayCastResult res = SDKViewer.UI.ContextMenu3D.Tag as VRRayCastResult;

            // Create the label at the location the user clicked, and set the text of the label to "New Label" and a next line with the position.
            IVRLabel label = m_LabelGroup.Add("New Label\n" + res.Position.ToString("f2"), res.Position);

            // Add it to the dictionary, for later reference (see m_ItemDestroy_Click)
            m_Labels.Add(label.ID, label);
            // Dump in the window text area the ID of the label created.
            m_RichTextBox.Text += "Created a new Label of ID : " + label.ID.ToString() + "\r\n";
        }
Example #3
0
        IVRLabelGroup m_LabelGroup           = null; // The label group owned by this plugin.

        void m_ItemDestroy_Click(object sender, EventArgs e)
        {
            // Get the click information from the Tag property as a VRRaycastResult type.
            VRRayCastResult res   = SDKViewer.UI.ContextMenu3D.Tag as VRRayCastResult;
            IVRLabel        label = null;

            // Try to get the label instance matching the ID. If not found, probably user clicked on a walkinside redline, or a label from other plugin.
            if (m_Labels.TryGetValue(res.TagID, out label))
            {
                // Remove the tag from the dictionary.
                m_Labels.Remove(res.TagID);
                // Remove the label from the 3D engine.
                m_LabelGroup.Remove(label);
                label = null;
                // Dump in the window text area the ID of the label destroyed.
                m_RichTextBox.Text += "Destroyed Label with ID : " + res.TagID.ToString() + "\r\n";
            }
            else
            {
                // Dump in the window text area the ID of the label clicked but not owned by this plugin.
                m_RichTextBox.Text += "Destroyed Label with ID : " + res.TagID.ToString() + "\r\n";
            }
        }