Example #1
0
    /// <summary>
    /// adds a new annotation to this object.
    /// The annotation will be placed in the user's gaze direction in front of this object.
    /// </summary>
    /// <param name="AnnotationPrefab">the prefab to use as annotation.</param>
    /// <returns></returns>
    private GameObject AddAnnotation(GameObject AnnotationPrefab)
    {
        // if you work on this object, it should be the active one.
        SetActive();

        //Debug.Log("WEKITAnnotatable.AddAnnotation");
        GameObject annotationObject = (GameObject)Instantiate(AnnotationPrefab);

        annotationObject.SetActive(true);

        WEKITAnnotationObject ao = annotationObject.AddComponent <WEKITAnnotationObject>();

        ao.annotatedObject = this.gameObject;
        annotations.Add(annotationObject);

        // Do a raycast into the world based on the user's
        // head position and orientation.
        Vector3 targetPosition = WEKITUtilities.placeObject(Camera.main.transform, 0.5f, 3.0f, 0.2f);

        annotationObject.transform.position = targetPosition;

        MeshRenderer meshRenderer = annotationObject.gameObject.GetComponentInChildren <MeshRenderer>();

        meshRenderer.enabled = true;

        return(annotationObject);
    }
Example #2
0
    /// <summary>
    /// opens the menu. Creates the menu items.
    /// </summary>
    void OpenMenu()
    {
        // no menu item prefab - no menu!
        if (WEKITGlobalsManager.Instance.MenuItem == null)
        {
            return;
        }

        // if a menu is already opened - just close it
        if (menuOpened)
        {
            CloseMenu();
            return;
        }

        menuOpened = true;

        Vector3 targetPoint = WEKITUtilities.placeObject(Camera.main.transform, 0.5f, 3.0f, 0.2f);

        menuItems = new GameObject[menuItemNames.Length];

        for (int i = 0; i < menuItemNames.Length; i++)
        {
            menuItems[i] = GameObject.Instantiate(WEKITGlobalsManager.Instance.MenuItem);
            menuItems[i].SetActive(true);
            menuItems[i].AddComponent <Billboard>();
            menuItems[i].name = menuItemNames[i];
            menuItems[i].GetComponent <TextMesh>().text = menuItemTexts[i];
            WEKITMenuItem item = menuItems[i].GetComponent <WEKITMenuItem>();
            item.rootGameObject                   = this.gameObject;
            menuItems[i].transform.position       = targetPoint;
            menuItems[i].transform.localPosition -= new Vector3(0, menuOffset * i, 0);
        }
    }
Example #3
0
    /// <summary>
    /// adds a new annotatable game object to the scene.
    /// </summary>
    void AddGameObject()
    {
        //Debug.Log("WEKITAnnotatable.AddAnnotation");
        GameObject newObject = (GameObject)Instantiate(Instance.gameObjectPrefab);

        // Do a raycast into the world based on the user's
        // head position and orientation.
        var headPosition  = Camera.main.transform.position;
        var gazeDirection = Camera.main.transform.forward;

        MeshRenderer meshRenderer = newObject.gameObject.GetComponentInChildren <MeshRenderer>();

        meshRenderer.enabled = true;

        Vector3 targetPosition = WEKITUtilities.placeObject(Camera.main.transform, 0.5f, 3.0f, 0.2f);

        newObject.transform.position = targetPosition;
    }