Esempio n. 1
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="url">url to access image</param>
    /// <param name="wall">wall orientation</param>
    /// <param name="x">x coordinate for corresponding wall based on left lower anchor</param>
    /// <param name="y">x coordinate for corresponding wall based on left lower anchor</param>
    public Displayal Display(string url, WallOrientation wall, float x, float y, float w, float h, bool lightOn = true, string audioUrl = null)
    {
        Debug.Log(string.Format("{0}, {1}, {2}/{3}, {4}/{5}", url, wall, x, y, w, h));
        GameObject displayal = Instantiate(PlanePrefab);

        var go = GameObject.Find("VirtualExhibitionManager");

        if (go.GetComponent <VREPController>().Settings.PlaygroundEnabled)
        {
            //var r = displayal.AddComponent<Rigidbody>();
            //r.useGravity = false;

            /*var i = displayal.AddComponent<Interactable>();
             * i.hideHandOnAttach = true;
             * i.useHandObjectAttachmentPoint = true;
             * i.handFollowTransformPosition = true;
             * i.handFollowTransformRotation = true;
             * i.highlightOnHover = true;
             * var t = displayal.AddComponent<Throwable>();
             * t.releaseVelocityStyle = ReleaseStyle.NoChange;
             * t.restoreOriginalParent = false;*/
        }

        if (!LightingActivated || !lightOn)
        {
            displayal.transform.Find("Directional light").gameObject.SetActive(false);
        }


        Displayal disp = displayal.gameObject.GetComponent <Displayal>();

        ImageLoader image = displayal.transform.Find("Plane").gameObject.AddComponent <ImageLoader>();        // Displayal

        //ImageLoader image = displayal.AddComponent<ImageLoader>();// ImageDisplayPlane
        image.ReloadImage(url);
        Debug.Log(GetWallForOrientation(wall));
        Vector3 pos = GetWallForOrientation(wall).CalculatePosition(transform.position, new Vector2(x, y));
        Vector3 rot = GetWallForOrientation(wall).CalculateRotation();

        displayal.transform.position   = pos;
        displayal.transform.rotation   = Quaternion.Euler(rot);
        displayal.transform.localScale = ScalingUtility.convertMeters2PlaneScaleSize(w, h);

        if (audioUrl != null)
        {
            Debug.Log("added audio to display object");
            var closenessDetector = displayal.AddComponent <ClosenessDetector>();
            closenessDetector.url = audioUrl;
        }


        displayedImages.Add(displayal);
        return(disp);
    }
        private async Task <GameObject> CreateDisplayalFromExhibit(Exhibit e)
        {
            await Task.Yield();

            var displayalPrefab = ObjectFactory.GetDisplayalPrefab();

            var displayal = Instantiate(displayalPrefab, Anchor.transform, true);

            var pos = new Vector3(e.Position.X, e.Position.Y, -ExhibitionBuildingSettings.Instance.WallOffset);

            displayal.transform.localPosition = pos;

            // Non-90° as they would tip over otherwise (exhibits stand on the little bar below).
            var rot = VrepController.Instance.settings.PlaygroundEnabled
        ? Quaternion.Euler(91.0f, 0, 180) // Slightly more than 90° or it would fall down.
        : Quaternion.Euler(90, 0, 180);

            displayal.transform.localRotation = rot; // Required due to prefab orientation.

            if (!VrepController.Instance.settings.SpotsEnabled || !e.Light)
            {
                displayal.transform.Find("Directional light").gameObject.SetActive(false);
            }

            var image = displayal.transform.Find("Plane").gameObject.AddComponent <ImageLoader>();

            image.ReloadImage(e.Path);
            displayal.transform.localScale = ScalingUtility.ConvertMeters2PlaneScaleSize(e.Size.X, e.Size.Y);

            if (e.Audio != null)
            {
                var closenessDetector = displayal.AddComponent <ClosenessDetector>();
                closenessDetector.url = e.Audio;
            }

            Displayal displayalComponent = displayal.gameObject.GetComponent <Displayal>();

            displayalComponent.SetExhibitModel(e);
            displayalComponent.originalPosition = pos;
            displayalComponent.originalRotation = rot;

            displayals.Add(displayalComponent);

            return(displayal);
        }
Esempio n. 3
0
        public void AttachExhibits()
        {
            // TODO Make displayal configurable
            var prefab = ObjectFactory.GetDisplayalPrefab();

            foreach (var e in WallData.exhibits)
            {
                GameObject displayal = Instantiate(prefab);
                displayal.name             = "Displayal (" + e.name + ")";
                displayal.transform.parent = Anchor.transform;
                var pos = new Vector3(e.position.x, e.position.y, -ExhibitionBuildingSettings.Instance.WallOffset);
                displayal.transform.localPosition = pos;
                //displayal.transform.rotation = Quaternion.Euler(ObjectFactory.CalculateRotation(WallData.direction));
                var rot = Quaternion.Euler(92.5f, 0, 180); // Non-90° as they would tip over othervise
                displayal.transform.localRotation = rot;   // Because prefab is messed up


                if (!VREPController.Instance.Settings.SpotsEnabled || !e.light)
                {
                    displayal.transform.Find("Directional light").gameObject.SetActive(false);
                }

                Displayal disp = displayal.gameObject.GetComponent <Displayal>();
                disp.SetExhibitModel(e);
                disp.OriginalPosition = pos;
                disp.OriginalRotation = rot;
                Displayals.Add(disp);

                ImageLoader image = displayal.transform.Find("Plane").gameObject.AddComponent <ImageLoader>(); // Displayal
                //ImageLoader image = displayal.AddComponent<ImageLoader>();// ImageDisplayPlane
                image.ReloadImage(e.GetURLEncodedPath());
                displayal.transform.localScale = ScalingUtility.convertMeters2PlaneScaleSize(e.size.x, e.size.y);

                if (e.audio != null)
                {
                    Debug.Log("added audio to display object");
                    var closenessDetector = displayal.AddComponent <ClosenessDetector>();
                    closenessDetector.url = e.GetURLEncodedAudioPath();
                }
            }
        }