//public Transform target;


    void OnMouseEnter()
    {
        if (textStatus == "off")
        {
            pointClass pc          = GetComponent <pointClass> ();
            string     tooltipText = "(" + pc.xPosition.ToString() +
                                     " , " + pc.yPosition.ToString() +
                                     " , " + pc.zPosition.ToString() + ")";
            //GetComponentInParent<pointClass> ();
            Vector3 screenPoint = new Vector3(250, 250, 20);
            Vector3 worldPos    = Camera.main.ScreenToWorldPoint(screenPoint);
            //popupText.GetComponent<TextMesh>().text = "works somehow";
            //name = graphMarker.FindObjectOfType<pointClass>.;
            popupText.GetComponent <TextMesh> ().text = tooltipText;

            textStatus = "on";
            //Instantiate(popupText, worldPos , popupText.rotation);
            Transform tooltip = Instantiate(popupText, worldPos, Quaternion.identity);

            tooltip.transform.LookAt(Camera.main.transform);

            tooltip.transform.Rotate(0, 180, 0);
        }
    }
示例#2
0
    // Use this for initialization
    void Start()
    {
        theSourceFile = Resources.Load("iris") as TextAsset;
        string myText = theSourceFile.text;

        List <string> myList = new List <string>();

        marker = Resources.Load("Sphere2") as GameObject;

        int xColumn = getProperty(X);
        int yColumn = getProperty(Y);
        int zColumn = getProperty(Z);

        Debug.Log("xColumn = " + xColumn);
        Debug.Log("yColumn = " + yColumn);
        Debug.Log("zColumn = " + zColumn);



        //string[] tokens = myText.Split('#');
        string[] tokens = myText.Split("\n"[0]);
        //Debug.Log(tokens.Length);

        for (int ii = 0; ii < tokens.Length - 1; ++ii)
        {
            //Debug.Log( tokens[ii] );
            myList.Add(tokens[ii]);                     //split text into lines

            //Debug.Log (myList[myList.Count - 1]);
        }
        for (int i = 0; i < myList.Count; i++)
        {
            List <string> dataList = new List <string>();

            //Debug.Log(myList[i]);
            string[] tokens2 = myList[i].Split(',');

            // dataList = myList[i].Split("\t");  //split each line into columns

            for (int j = 0; j < tokens2.Length; j++)
            {
                dataList.Add(tokens2[j]);
                //Debug.Log(dataList[j]);
            }
            if (dataList.Count > 1)
            {
                //Debug.Log(dataList.Count);
                float  x        = float.Parse(dataList[xColumn]);
                float  y        = float.Parse(dataList[yColumn]);
                float  z        = float.Parse(dataList[zColumn]);
                string category = dataList [dataList.Count - 1];
                //Debug.Log (category);

                //scale variables to fit the desired range of virtual space
                float xPct = (x - xMinMax[0]) / (xMinMax[1] - xMinMax[0]);
                x = (xPct * (axesMinMax[1] - axesMinMax[0])) + axesMinMax[0];
                // print (y) ;
                // print (yMinMax[1] - yMinMax[0]);
                float yPct = (y - yMinMax[0]) / (yMinMax[1] - yMinMax[0]);
                y = (yPct * (axesMinMax[1] - axesMinMax[0])) + axesMinMax[0];
                //print (yPct) ;
                float zPct = (z - zMinMax[0]) / (zMinMax[1] - zMinMax[0]);
                z = (zPct * (axesMinMax[1] - axesMinMax[0])) + axesMinMax[0];

                Vector3 vectoras = new Vector3(x, y, z);

                // Use Instantiate to make a copy of the 3D marker at the desired location
                GameObject myMarker = Instantiate(marker, vectoras, Quaternion.identity) as GameObject;
                myMarker.transform.parent = Sphereholder.transform;

                pointClass point = myMarker.GetComponent <pointClass> ();
                point.xPosition = x;
                point.yPosition = y;
                point.zPosition = z;
                //pointClass point = new pointClass(x);
                //point.name = vectoras.x;


                //giving a name to every point

                string pointName =
                    "[" + x + " " + y + " " + z + "]";
                point.transform.name = pointName;
                print(pointName);
                //temp.GetComponent<this>().cell;
                if (category == "Iris-setosa")
                {
                    myMarker.GetComponent <Renderer>().material.color = Color.blue;
                }
                else if (category == "Iris-versicolor")
                {
                    myMarker.GetComponent <Renderer>().material.color = Color.green;
                }
                else if (category == "Iris-virginica")
                {
                    myMarker.GetComponent <Renderer>().material.color = Color.yellow;
                }
                else
                {
                    myMarker.GetComponent <Renderer>().material.color = Color.red;
                }
                // Send a message to the marker's LabelItems script, calling the SetTect function to set the label's text
                //myMarker.SendMessage ("SetText" , myLabel. SendMessageOptions.DontRequireReceiver);
            }              // end if
        }
    }
示例#3
0
    // Use this for initialization
    void Start()
    {
        string        myText = theSourceFile.text;
        List <string> myList = new List <string>();


        //string[] tokens = myText.Split('#');
        string[] tokens = myText.Split("\n"[0]);
        //Debug.Log(tokens.Length);

        for (int ii = 0; ii < tokens.Length - 1; ++ii)
        {
            //Debug.Log( tokens[ii] );
            myList.Add(tokens[ii]);                     //split text into lines
        }
        for (int i = 0; i < myList.Count; i++)
        {
            List <string> dataList = new List <string>();

            //Debug.Log(myList[i]);
            string[] tokens2 = myList[i].Split(',');

            // dataList = myList[i].Split("\t");  //split each line into columns

            for (int j = 0; j < tokens2.Length - 1; j++)
            {
                dataList.Add(tokens2[j]);
                //Debug.Log(dataList[j]);
            }
            if (dataList.Count > 1)
            {
                //Debug.Log(dataList[xColumn]);
                float x = float.Parse(dataList[xColumn]);
                float y = float.Parse(dataList[yColumn]);
                float z = float.Parse(dataList[zColumn]);

                //scale variables to fit the desired range of virtual space
                float xPct = (x - xMinMax[0]) / (xMinMax[1] - xMinMax[0]);
                x = (xPct * (axesMinMax[1] - axesMinMax[0])) + axesMinMax[0];
                // print (y) ;
                // print (yMinMax[1] - yMinMax[0]);
                float yPct = (y - yMinMax[0]) / (yMinMax[1] - yMinMax[0]);
                y = (yPct * (axesMinMax[1] - axesMinMax[0])) + axesMinMax[0];
                //print (yPct) ;
                float zPct = (z - zMinMax[0]) / (zMinMax[1] - zMinMax[0]);
                z = (zPct * (axesMinMax[1] - axesMinMax[0])) + axesMinMax[0];

                Vector3 vectoras = new Vector3(x, y, z);

                // Use Instantiate to make a copy of the 3D marker at the desired location
                GameObject myMarker = Instantiate(marker, vectoras, Quaternion.identity) as GameObject;
                pointClass point    = myMarker.GetComponent <pointClass> ();
                point.xPosition = x;
                point.yPosition = y;
                point.zPosition = z;
                //pointClass point = new pointClass(x);
                //point.name = vectoras.x;

                //temp.GetComponent<this>().cell;
                if (y < 21)
                {
                    myMarker.GetComponent <Renderer>().material.color = Color.blue;
                }
                else if (y >= 21 && y < 41)
                {
                    myMarker.GetComponent <Renderer>().material.color = Color.cyan;
                }
                else if (y >= 41 && y < 61)
                {
                    myMarker.GetComponent <Renderer>().material.color = Color.green;
                }
                else if (y >= 61 && y < 81)
                {
                    myMarker.GetComponent <Renderer>().material.color = Color.yellow;
                }
                else
                {
                    myMarker.GetComponent <Renderer>().material.color = Color.red;
                }
                // Send a message to the marker's LabelItems script, calling the SetTect function to set the label's text
                //myMarker.SendMessage ("SetText" , myLabel. SendMessageOptions.DontRequireReceiver);
            }                      // end if
        }
    }