Esempio n. 1
0
    /*--------------------------------------------------------------------------------*/

    public MeshMapping(IndicatorGrid _indicatorGrid)
    {
        indicatorGrid = _indicatorGrid;
        cursor        = Character2D.mappings[(int)Character2D.Mood.NEUTRAL];

        triangleMesh = new TriangleMesh2D(Character2D.map, Character2D.mappings);
        bounding     = new Bounding2D(
            Character2D.mappings[(int)Character2D.Mood.SAD],
            Character2D.mappings[(int)Character2D.Mood.RELAXED],
            Character2D.mappings[(int)Character2D.Mood.EXCITED],
            Character2D.mappings[(int)Character2D.Mood.IRRITATED]
            );

        cursor = bounding.Clip(cursor);
        indicatorGrid.SetCursor(bounding.GetMappedCoordinates(-1.0f, 1.0f));
    }
Esempio n. 2
0
    /*--------------------------------------------------------------------------------*/

    public void MoveCursor(Vector2 movement)
    {
        Vector3 newPos = cursor + movement;

        int triangleIndex = triangleMesh.IsInside(newPos);

        if (triangleIndex > -1)
        {
            float[] ratios = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

            GetKeyShapeRatios(triangleIndex, newPos, ref ratios);
            characterCtrl.SetMoodInterPolated(ratios);
            cursor = newPos;
        }

        cursor = bounding.Clip(newPos);

        indicatorGrid.SetCursor(bounding.GetMappedCoordinates(-1.0f, 1.0f));
    }
Esempio n. 3
0
    /*--------------------------------------------------------------------------------*/

    // phi --> mood selection
    // r ----> intensity
    public Vector2 MoveCursor(Vector2 movement)
    {
        Vector2 cursorPos = cursor;


        /*-------- Transformation to polar system ----------*/

        Vector2 newPos = cursorPos + movement;

        #region TRANSFORMATION_TO_POLAR
        float phi = Mathf.Atan2(newPos.y, newPos.x);
        float r   = Mathf.Sqrt(Mathf.Pow(newPos.x, 2) + Mathf.Pow(newPos.y, 2));

        if (r > MAX_R)
        {
            r = MAX_R;            // clip radius
        }
        if (newPos.x > 1)
        {
            newPos.x = 1;
        }
        else if (newPos.x < -1)
        {
            newPos.x = -1;
        }

        if (newPos.y > 1)
        {
            newPos.y = 1;
        }
        else if (newPos.y < -1)
        {
            newPos.y = -1;
        }

        float phi_shifted = PhiShift(phi_offset, phi);
        #endregion

        #region UPDATE_EXPRESSION
        float fraction;
        int   phi_low, phi_high;
        GetFaceIndex(phi_shifted, out phi_low, out phi_high, out fraction);
        if (r > HALF_R)
        {
            if (highResolutionExpression)
            {
                characterCtrl.SetMoodInterPolatedHR(2 * (r - 0.5f), fraction,
                                                    (Character2D.MoodHighRes)phi_low,
                                                    (Character2D.MoodHighRes)phi_high,
                                                    (Character2D.MoodHighRes)phi_low + 8,
                                                    (Character2D.MoodHighRes)phi_high + 8);
            }
            else
            {
                characterCtrl.SetMoodInterPolated(2 * (r - 0.5f), fraction,
                                                  (Character2D.Mood)phi_low,
                                                  (Character2D.Mood)phi_high,
                                                  (Character2D.Mood)phi_low + 4,
                                                  (Character2D.Mood)phi_high + 4);
            }
        }
        else
        {
            if (highResolutionExpression)
            {
                characterCtrl.SetMoodInterPolatedHR(2 * r, (Character2D.MoodHighRes)phi_low, (Character2D.MoodHighRes)phi_high, fraction);
            }
            else
            {
                characterCtrl.SetMoodInterPolated(2 * r, (Character2D.Mood)phi_low, (Character2D.Mood)phi_high, fraction);
            }
        }

        #endregion

        indicatorGrid.SetCursor(newPos);
        cursor = newPos;


        #region GET_VA_VALUES
        if (r > HALF_R)
        {
            if (highResolutionExpression)
            {
                VA = characterCtrl.GetVAInterPolatedHR(2 * (r - 0.5f), fraction,
                                                       (Character2D.MoodHighRes)phi_low,
                                                       (Character2D.MoodHighRes)phi_high,
                                                       (Character2D.MoodHighRes)phi_low + 8,
                                                       (Character2D.MoodHighRes)phi_high + 8);
            }
            else
            {
                VA = characterCtrl.GetVAInterPolated(2 * (r - 0.5f), fraction,
                                                     (Character2D.Mood)phi_low,
                                                     (Character2D.Mood)phi_high,
                                                     (Character2D.Mood)phi_low + 4,
                                                     (Character2D.Mood)phi_high + 4);
            }
        }
        else
        {
            if (highResolutionExpression)
            {
                VA = characterCtrl.GetVAInterPolatedHR(2 * r, fraction,
                                                       Character2D.MoodHighRes.NEUTRAL,
                                                       Character2D.MoodHighRes.NEUTRAL,
                                                       (Character2D.MoodHighRes)phi_low,
                                                       (Character2D.MoodHighRes)phi_high);
            }
            else
            {
                VA = characterCtrl.GetVAInterPolated(2 * r, fraction,
                                                     Character2D.Mood.NEUTRAL,
                                                     Character2D.Mood.NEUTRAL,
                                                     (Character2D.Mood)phi_low,
                                                     (Character2D.Mood)phi_high);
            }
        }
        #endregion

        return(VA);
    }