Example #1
0
    // precondition: arc.position and arc.link must be filled
    public static GameObject CreateIU(TextARC arc, Transform parentSpace, GameObject prefab)
    {
        _gameObject      = Instantiate(prefab, new Vector3(), Quaternion.identity);
        _gameObject.name = "TextARC";
        _gameObject.tag  = "arc";
        _gameObject.transform.SetParent(parentSpace.transform);
        _gameObject.transform.localPosition = arc.GetPos();
        _gameObject.transform.localRotation = arc.GetRotation();
        _gameObject.transform.localScale    = arc.GetScale();


        if (arc.GetLink().Substring(0, 4) == "http")
        {
            _gameObject.transform.Find("Text").GetComponent <URLTextLoader>().setLink(arc.GetLink());
        }
        else//text is a local file
        {
            Text textComponent = _gameObject.transform.Find("Text").GetComponent <Text>();
            textComponent.text = File.ReadAllText(arc.GetLink());
        }
        return(_gameObject);
    }
    private void DisplayIUs(IAU iau)
    {
        //destroy current ARControllers
        foreach (Transform trans in panel_top.GetComponentsInChildren <Transform>())
        {
            if (trans.tag.Equals("arc"))
            {
                Destroy(trans.gameObject);
            }
        }
        foreach (Transform trans in panel_bottom.GetComponentsInChildren <Transform>())
        {
            if (trans.tag.Equals("arc"))
            {
                Destroy(trans.gameObject);
            }
        }

        //create new arcontrollers with new Content
        GameObject obj = null;

        for (int i = 0; i < iau.iau_ius.Count; ++i)
        {
            IU iu = iau.iau_ius[i];
            switch (iu.iu_type)
            {
            case "image":
                PictureARC pictureARC = new PictureARC();
                pictureARC.SetLink(iu.iu_link);
                pictureARC.SetPos(iu.GetPosition());
                pictureARC.SetScale(iu.GetScale());
                pictureARC.SetRotation(iu.GetRotation());
                obj = CreateARC.CreateIU(pictureARC, panel_top, imagePrefab);

                break;

            case "text":
                TextARC textARC = new TextARC();
                textARC.SetLink(iu.iu_link);
                textARC.SetPos(iu.GetPosition());
                textARC.SetScale(iu.GetScale());
                textARC.SetRotation(iu.GetRotation());
                obj = CreateARC.CreateIU(textARC, panel_top, textPrefab);

                break;

            case "video":
                VideoARC videoARC = new VideoARC();
                videoARC.SetLink(iu.iu_link);
                videoARC.SetPos(iu.GetPosition());
                videoARC.SetScale(iu.GetScale());
                videoARC.SetRotation(iu.GetRotation());
                obj = CreateARC.CreateIU(videoARC, panel_top, videoPrefab);

                break;

            case "audio":
                AudioARC audioARC = new AudioARC();
                audioARC.SetLink(iu.iu_link);
                audioARC.SetPos(iu.GetPosition());
                audioARC.SetScale(iu.GetScale());
                audioARC.SetRotation(iu.GetRotation());
                obj = CreateARC.CreateIU(audioARC, panel_top, audioPrefab);

                break;

            case "3d":
                Model3dARC model3dARC = new Model3dARC();
                model3dARC.SetLink(iu.iu_link);
                model3dARC.SetPos(iu.GetPosition());
                model3dARC.SetScale(iu.GetScale());
                model3dARC.SetRotation(iu.GetRotation());

                switch (model3dARC.GetModel())
                {
                case "fusebox":
                    obj = CreateARC.CreateIU(model3dARC, panel_bottom, fuseboxPrefab);
                    break;

                case "battery pack":
                    obj = CreateARC.CreateIU(model3dARC, panel_bottom, batteryPackPrefab);
                    break;

                case "buss bars":
                    obj = CreateARC.CreateIU(model3dARC, panel_bottom, bussBarsPrefab);
                    break;

                case "estop button key":
                    obj = CreateARC.CreateIU(model3dARC, panel_bottom, eStopButtonKeyPrefab);
                    break;

                case "estop button push":
                    obj = CreateARC.CreateIU(model3dARC, panel_bottom, eStopButtonPushPrefab);
                    break;

                case "conveyor belt":
                    obj = CreateARC.CreateIU(model3dARC, panel_bottom, conveyorPrefab);
                    break;

                default:
                    Debug.Log("Could not find 3d model by name '" + model3dARC.GetModel() + "'");
                    break;
                }
                obj.AddComponent <BoxCollider>().size = new Vector3(50, 15, 30);

                break;

            default:
                Debug.Log("Something went wrong with iu type");
                break;
            }
        }
    }
Example #3
0
    private void DisplayIUs(IAU iau)
    {
        //destroy current ARControllers
        foreach (Transform trans in panel_top.GetComponentsInChildren <Transform>())
        {
            if (trans.tag.Equals("arc"))
            {
                Destroy(trans.gameObject);
            }
        }
        foreach (Transform trans in panel_bottom.GetComponentsInChildren <Transform>())
        {
            if (trans.tag.Equals("arc"))
            {
                Destroy(trans.gameObject);
            }
        }

        foreach (Transform trans in worldSpace.GetComponentsInChildren <Transform>())
        {
            if (trans.tag.Equals("arc"))
            {
                Destroy(trans.gameObject);
            }
        }

        //create new arcontrollers with new Content
        GameObject obj = null;

        for (int i = 0; i < iau.iau_ius.Count; ++i)
        {
            IU iu = iau.iau_ius[i];
            switch (iu.iu_type)
            {
            case "image":
                PictureARC pictureARC = new PictureARC();
                pictureARC.SetLink(iu.iu_link);
                pictureARC.SetPos(iu.GetPosition());
                pictureARC.SetScale(iu.GetScale());
                pictureARC.SetRotation(iu.GetRotation());
                obj = CreateARC.CreateIU(pictureARC, panel_top, imagePrefab);

                break;

            case "text":
                TextARC textARC = new TextARC();
                textARC.SetLink(iu.iu_link);
                textARC.SetPos(iu.GetPosition());
                textARC.SetScale(iu.GetScale());
                textARC.SetRotation(iu.GetRotation());
                obj = CreateARC.CreateIU(textARC, panel_top, textPrefab);

                break;

            case "video":
                VideoARC videoARC = new VideoARC();
                videoARC.SetLink(iu.iu_link);
                videoARC.SetPos(iu.GetPosition());
                videoARC.SetScale(iu.GetScale());
                videoARC.SetRotation(iu.GetRotation());
                obj = CreateARC.CreateIU(videoARC, panel_top, videoPrefab);

                break;

            case "audio":
                AudioARC audioARC = new AudioARC();
                audioARC.SetLink(iu.iu_link);
                audioARC.SetPos(iu.GetPosition());
                audioARC.SetScale(iu.GetScale());
                audioARC.SetRotation(iu.GetRotation());
                obj = CreateARC.CreateIU(audioARC, panel_top, audioPrefab);

                break;

            case "3d":
                Model3dARC model3dARC = new Model3dARC();
                model3dARC.SetLink(iu.iu_link);
                model3dARC.SetPos(iu.GetPosition());
                model3dARC.SetScale(iu.GetScale());
                model3dARC.SetRotation(iu.GetRotation());
                CreateARC.CreateIU(model3dARC, panel_bottom, model3dPrefab);

                break;

            default:
                Debug.Log("Something went wrong with iu type");
                break;
            }
        }
    }