예제 #1
0
    void Start()
    {
        targetMarker = GameObject.CreatePrimitive(PrimitiveType.Cube);
        targetMarker.GetComponent <Renderer>().material.color = Color.green;
        //TODO Could make transparent
        targetMarker.transform.parent        = transform;
        targetMarker.transform.localPosition = new Vector3();
        targetMarker.transform.localScale    = new Vector3(CONTROL_SIZE, CONTROL_SIZE, CONTROL_SIZE);
        targetMarker.SetActive(false);

        spline = new ColorSpline();
        spline.spline.SetOrder(3);
        controlObjects = new List <GameObject>();
        for (int i = 0; i < 4; i++)
        {
            GameObject controlObject;
            if (i % 3 == 0)
            {
                controlObject = Instantiate <GameObject>(firstControlPrefab, transform);
            }
            else
            {
                controlObject = Instantiate <GameObject>(secondControlPrefab, transform);
            }
            controlObject.transform.localPosition = new Vector3(i / 3f, i / 3f, i / 3f);
            controlObject.transform.localScale    = new Vector3(CONTROL_SIZE, CONTROL_SIZE, CONTROL_SIZE);
            controlObjects.Add(controlObject);
        }
        // Make 2nd controls children of the 1sts
        for (int i = 1; i < (4 - 1); i++)
        {
            GameObject controlObject;
            if (i % 3 == 0)
            {
                // 1st control
            }
            else
            {
                // 2nd control
                //TODO Could add support for greater order
                controlObject = controlObjects[i];
                GameObject firstControl;
                if (i % 3 == 1)
                {
                    // back one
                    firstControl = controlObjects[i - 1];
                }
                else
                {
                    // i % 3 == 2
                    firstControl = controlObjects[i + 1];
                }
                controlObject.transform.SetParent(firstControl.transform, true);
            }
        }
        UpdatePoints();
    }
예제 #2
0
 private void OnSplineUpdate(ColorSpline spline)
 {
     client.Publish(SPLINE_TOPIC, Encoding.ASCII.GetBytes(spline.ToJSON()));
 }