// Update is called once per frame
    void Update()
    {
        //when press mouse, detele last marker and generate new one
        //start time counter
        if (Input.GetMouseButtonDown(0))
        {
            Current_Time = 0f;
            if (!marker_generated)
            {
                marker_generated = true;
            }
            //stop at the last point
            if (n == positionsV3.Length)
            {
                Debug.Log("It is already the last Point");
                writer = new StreamWriter(path, true);
                writer.WriteLine("-------!-!-------Task-All-Complete-------!-!------");
                writer.Close();
                return;
            }

            //destroy last marker
            if (n != 0)
            {
                Destroy(GameObject.Find((n - 1).ToString()));
            }
            GameObject Current_Marker;
            center         = GameObject.Find("Big Sphere").transform.position;
            Current_Marker = Instantiate(marker, new Vector3(positionsV3[n].x + center.x, positionsV3[n].y + center.y, positionsV3[n].z + center.z), Quaternion.identity) as GameObject;
            Current_Marker.transform.LookAt(center, Vector3.up);
            Current_Marker.transform.parent = gameObject.transform;
            Current_Marker.GetComponent <SpriteRenderer>().color = Color.red;
            Current_Marker.name = n.ToString();
            writer = new StreamWriter(path, true);
            float current_time = GameObject.Find("Interaction Handler").GetComponent <RotationInteraction>().Time_Stamp();
            writer.WriteLine("-----------");
            writer.WriteLine(("Current Time:" + current_time + "; Task:" + n + " begins"));
            writer.Close();
            n++;
        }
        Current_Time += Time.deltaTime;//caculate time finishing a task
    }
Beispiel #2
0
    //tranform V2 array to V3 array
    public void GenerateMarkers(Vector2[] SphericalCoordinate)
    {
        radius = GameObject.Find("Big Sphere").GetComponent <SpiralSphere>().radius;
        if (scene_id < 3)
        {
            radius -= 0.09f;
        }
        else
        {
            radius += 0.03f;
        }

        for (int c = 0; c < SphericalCoordinate.Length; c++)
        {
            //calculate 3D position from 2D
            float longitude = SphericalCoordinate[c].x * Mathf.PI / 180;           //fita
            float latitude  = (90.0f - SphericalCoordinate[c].y) * Mathf.PI / 180; //theta
            float X         = (float)radius * (float)Math.Sin((float)latitude) * (float)Math.Cos((float)longitude);
            float Y         = (float)radius * (float)Math.Cos((float)latitude);
            float Z         = (float)radius * (float)Math.Sin((float)latitude) * (float)Math.Sin((float)longitude);


            //Create Markers
            GameObject Current_Marker;
            center         = GameObject.Find("Big Sphere").transform.position;
            Current_Marker = Instantiate(marker, GameObject.Find("Big Sphere").transform.rotation *new Vector3(X + center.x, Y + center.y, Z + center.z), Quaternion.identity) as GameObject;
            Current_Marker.transform.LookAt(center, Vector3.up);
            Current_Marker.transform.parent = gameObject.transform;
            Current_Marker.GetComponent <SpriteRenderer>().color = Color.red;
            Current_Marker.name = c.ToString();

            if (c == 0)
            {
                Current_Marker.tag = "Result";
            }
        }
    }