Exemplo n.º 1
0
    void OnCreateBoxMarker(SocketIOEvent obj)
    {
                #if OUTPUT_EVENTS
        Debug.Log("Create marker");
                #endif
        JSONObject json = obj.data;
        // grab the info from json. info is set up as:
        // "id": "id"
        // "pose": [x,y,z,roll,pitch,yaw]
        // "dimensions": [w,h,d]
        // "color": [r,g,b,a]
        // "duration": #.#
//		Debug.Log ( "json:\n" + json.Print ( true ) );
//		Debug.Log ( "id is a " + json.GetField ( "id" ).type );
//		Debug.Log ( "pose is a " + json.GetField ( "pose" ).type );
//		Debug.Log ( "dimensions is a " + json.GetField ( "dimensions" ).type );
//		Debug.Log ( "color is a " + json.GetField ( "color" ).type );
//		Debug.Log ( "duration is a " + json.GetField ( "duration" ).type );

        int id = (int)json.GetField("id").n;
        List <JSONObject> values = json.GetField("pose").list;
        float[]           pose   = new float[values.Count];
        for (int i = 0; i < pose.Length; i++)
        {
            pose [i] = values [i].f;
        }
        values = json.GetField("dimensions").list;
        float[] dimensions = new float[values.Count];
        for (int i = 0; i < dimensions.Length; i++)
        {
            dimensions [i] = values [i].f;
        }
        values = json.GetField("color").list;
        float[] color = new float[values.Count];
        for (int i = 0; i < color.Length; i++)
        {
            color [i] = values [i].f;
        }
        float duration = json.GetField("duration").f;

        Vector3    pos   = new Vector3((float)pose [0], (float)pose [1], (float)pose [2]).ToUnity();
        Vector3    euler = new Vector3((float)pose [3], (float)pose [4], (float)pose [5]).ToUnity();
        Quaternion rot   = Quaternion.Euler(euler);
        Vector3    size  = new Vector3((float)dimensions [0], (float)dimensions [1], (float)dimensions [2]).ToUnity();
        Color      c     = new Color(color [0], color [1], color [2], color [3]);

        MarkerMaker.AddMarker(id.ToString(), pos, rot, size, c, duration);

        Dictionary <string, string> data = new Dictionary <string, string> ();
        data ["action"] = "create";
        data ["id"]     = id.ToString();

        Ack(new JSONObject(data));
    }
Exemplo n.º 2
0
    void OnDeleteMarker(SocketIOEvent obj)
    {
                #if OUTPUT_EVENTS
        Debug.Log("Delete marker");
                #endif
        JSONObject json = obj.data;
        int        id   = (int)json.GetField("id").n;
//		string id = json.GetField ( "id" ).str;

        MarkerMaker.DeleteMarker(id.ToString());

        Dictionary <string, string> data = new Dictionary <string, string> ();
        data ["action"] = "delete";
        data ["id"]     = id.ToString();

        Ack(new JSONObject(data));
    }
Exemplo n.º 3
0
 void Awake()
 {
     instance        = this;
     markers         = new Dictionary <string, MarkerObject> ();
     markersToDelete = new Queue <string> ();
 }