Example #1
0
 /// <summary>
 /// Inits the model by latlngs.
 /// </summary>
 /// <param name="tasks"></param>
 /// <param name="deviceOfUserHead">If set to <c>true</c> use device orientation otherwise use user heading.</param>
 void InitModelByLatLngs(List <Task> tasks, bool deviceOfUserHead)
 {
     foreach (var task in tasks)
     {
         Vector3 position = _abstractMap.GeoToWorldPosition(task.TaskLocation);
         print(position);
         Object model = ArUtils.LoadModel("Model/" + task.TaskModelName);
         print(model);
         // 地图上显示的物体
         var mapObject = Instantiate(model, position, task.TaskModelRotation) as GameObject;
         mapObject.layer = 0;
         // ar界面显示的物体,两者为模型相同位置不同
         var arObject = CreateArModel(model, position, Quaternion.Euler(new Vector3()));
         ArModelEventController amec = arObject.ArGameObject.AddComponent <ArModelEventController>();
         amec.SetCamera(firstPersonCamera);
         amec.onModelClick = () =>
         {
             print("click model");
             dialogueBox.SetActive(!dialogueBox.activeSelf);
             if (dialogueBox.activeSelf)
             {
                 dialogueBox.GetComponent <DialogueBoxController>().SetTaskDesc(task.TaskDesc);
             }
         };
         //MessageBubblesShow mbs = arObject.ARGameObject.AddComponent<MessageBubblesShow>();
         //ModelIndicator mi = arObject.ArGameObject.AddComponent<ModelIndicator>();
         //mi.SetCameraObject(FirstPersonCamera);
         //mbs.SetTaskDesc(task.TaskDesc);
         //mbs.SetCamera(FirstPersonCamera);
         AdjustArModelByDeviceOrientation(arObject.ArGameObject, deviceOfUserHead);
         _showedArModels.Add(arObject);
     }
 }
Example #2
0
        // Update is called once per frame
        void Update()
        {
            // 返回主页面
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                SceneManager.LoadScene("MainPage");
            }

            Vector3 position = _abstractMap.GeoToWorldPosition(TaskLab.Get().GetTaskList()[0].TaskLocation);

            if (position != Vector3.zero && !_hasLoadModel)
            {
                var locationProvider = LocationProviderFactory.Instance.DefaultLocationProvider;
                TaskLab.Get().SetCurrentLatlng(locationProvider.CurrentLocation.LatitudeLongitude);
                _taskList = TaskLab.Get().GetTaskListIn(200);
                //TaskList = TaskLab.get().GetTaskList();
                text.text = "abstractMap: " + _abstractMap + "\n";
                foreach (var task in _taskList)
                {
                    _model   = ArUtils.LoadModel("Model/" + task.TaskModelName);
                    position = _abstractMap.GeoToWorldPosition(task.TaskLocation);
                    var message = text.text;
                    message  += "name:" + task.TaskModelName + "\n";
                    message  += "location:" + task.TaskLocation + "\n";
                    message  += "position:" + position + "\n";
                    text.text = message;
                    Instantiate(_model, position, task.TaskModelRotation);
                }
                _hasLoadModel = true;
            }
        }
Example #3
0
    // Start is called before the first frame update
    void Start()
    {
        Object obj = ArUtils.LoadModel("Model/Array");

        Array = Instantiate(obj, GameObject.Find("Canvas").transform) as GameObject;
        Array.transform.localScale = Vector3.one * .5f;
        arrayText = Array.GetComponentInChildren <Text>();
    }
Example #4
0
    // Start is called before the first frame update
    void Start()
    {
        UnityEngine.Object messageBubblesModel = ArUtils.LoadModel("Model/MessageBubbles");
        var messageBubbles = Instantiate(messageBubblesModel, Vector3.zero, Quaternion.Euler(Vector3.zero)) as GameObject;

        MessageBubbles = messageBubbles;

        MessageBubbles.transform.parent = GameObject.Find("Canvas").transform;
        //MessageBubbles.GetComponent<RectTransform>()
        //.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, ARUtils.GetObjectSize(gameObject).x*100); ;
        print(" ARUtils.GetObjectSize(gameObject).x:" + ArUtils.GetObjectSizeByMeshFilter(gameObject).x);
        words = SplitSentence(taskDesc);
        MessageBubbles.SetActive(false);
        Button[] buttons = MessageBubbles.GetComponentsInChildren <Button>();
        previousSentence = buttons[0];
        nextSentence     = buttons[1];
        showText         = MessageBubbles.GetComponentInChildren <Text>();
        previousSentence.onClick.AddListener(() =>
        {
            if (index <= 0)
            {
                return;
            }
            index--;
            showText.text = words[index];
        });

        nextSentence.onClick.AddListener(() =>
        {
            if (index >= words.Length - 1)
            {
                return;
            }
            index++;
            showText.text = words[index];
        });
    }