Esempio n. 1
0
    void Update()
    {
        if (freeze)
        {
            return;
        }

        MaterialPropertyBlock props      = new MaterialPropertyBlock();
        IList <CloudPoint>    cloudpoint = null;

        cloudpoint   = skeletonMode ? iRemoteService.GetSkeleton() : iRemoteService.GetCloudpoints();
        pointColor.a = 0;
        float max = 0;
        int   i;
        int   bodyPointIndex;

        int stepRange = 1;

        if (detailedFace)
        {
            stepRange = cloudpoint.Count / bodyPoints.Length;
        }

        for (bodyPointIndex = 0, i = 0;
             i < cloudpoint.Count && bodyPointIndex < bodyPoints.Length;
             i += stepRange, bodyPointIndex++)
        {
            CloudPoint item = cloudpoint[i];
            float      x, y, z;
            float      secondFactor;
            pointColor.r = item.GetR();
            pointColor.g = item.GetG();
            pointColor.b = item.GetB();
            bodyPoints[bodyPointIndex].SetActive(true);

            if (skeletonMode)
            {
                z = item.GetZ() * 10;
                x = (item.GetX() * 10);
                y = (item.GetY() * 10);
            }
            else
            {
                z            = item.GetZ() / 100;
                secondFactor = z * factor;
                x            = (item.GetX() - width / 2.0f) * secondFactor;   // x und y mal z genommen
                y            = -(item.GetY() - height / 2.0f) * secondFactor; //180° Drehung
            }

            // y - 2 für Cameraanpassung bei reset
            bodyPoints[bodyPointIndex].transform.localPosition = new Vector3(x, y - 2, z - distanceToHead);
            bodyPoints[bodyPointIndex].transform.localScale    = new Vector3(cubeScale, cubeScale, cubeScale);
            props.SetColor("_Color", pointColor);
            bodyPoints[bodyPointIndex].GetComponent <MeshRenderer>().SetPropertyBlock(props);

            if (max < y)
            {
                max = y;
                currentDistanceToHead = z;
            }
        }

        pointColor.a = 1;
        for (int j = bodyPointIndex; j < bodyPoints.Length; j++)
        {
            bodyPoints[j].SetActive(false);
        }
    }