Example #1
0
    protected override void OnStart()
    {
        EmotionSpectrum currentEmotion = ProceduralEngine.Instance.GetCurrentEmotion();
        float           expectation    = currentEmotion.Dot(new EmotionSpectrum(EmotionVector.GetCoreEmotion(CoreEmotion.Anticipation)));

        camera.RotationDampingTime = .1f + Mathf.Lerp(.4f, 0f, Mathf.Clamp01(expectation - 2f));
        camera.PositionDampingTime = .1f + Mathf.Lerp(.4f, 0f, Mathf.Clamp01(expectation - 2f));
        camera.SetNoiseParameters(Mathf.Clamp(expectation * .4f, 0f, .25f), .75f);

        Vector3 boundsAxis = mainInterestPoint.AssociatedItemBounds.size.normalized;

        List <KeyValuePair <Vector3, float> > possibleDirections = new List <KeyValuePair <Vector3, float> >();

        // Chance of following the frustum average
        possibleDirections.Add(new KeyValuePair <Vector3, float>(mainInterestAxis, .5f));

        // Chance of picking a dolly direction based on the item boundaries
        possibleDirections.Add(new KeyValuePair <Vector3, float>(mainInterestPoint.transform.right * boundsAxis.x, boundsAxis.x));
        possibleDirections.Add(new KeyValuePair <Vector3, float>(mainInterestPoint.transform.up * boundsAxis.y, boundsAxis.y));
        possibleDirections.Add(new KeyValuePair <Vector3, float>(mainInterestPoint.transform.forward * boundsAxis.z, boundsAxis.z));

        // Chance of doing a dolly in/out
        float inOutDirection = ProceduralEngine.Instance.EmotionEngine.GetStructureAtTime(ProceduralEngine.Instance.CurrentTimeNormalized) == StructureType.Decreasing ? -1f : 1f;

        possibleDirections.Add(new KeyValuePair <Vector3, float>(GetForward() * inOutDirection, .5f));

        movementDirection = ProceduralEngine.SelectRandomWeighted(possibleDirections, x => x.Value).Key.normalized;
        keepAttention     = ProceduralEngine.RandomRange(0f, 1f) > .5f; // TODO: associate this with the rotation smoothness/lag, and with emotions (e.g. sadness lags, expectation keeps)
    }
Example #2
0
    protected void DrawEmotionShape(Rect container)
    {
        GL.PushMatrix();
        lineMaterial.SetPass(0);
        GL.LoadOrtho();
        GL.Begin(GL.LINE_STRIP);

        // Transform container
        container.x      /= Screen.width;
        container.width  /= Screen.width;
        container.y      /= Screen.height;
        container.height /= Screen.height;

        Vector3 scale  = new Vector3(container.size.x, container.size.y, 0f);
        Vector3 offset = new Vector3(container.x, container.y, 0f) + scale * .5f;

        int subdivisions = 360;

        float width = Mathf.Abs(outerRadius - innerRadius);

        for (int i = 0; i < subdivisions + 1; i++)
        {
            float t     = i / (float)subdivisions;
            float angle = t * Mathf.PI * 2f;
            float r     = Chunk.Data.Evaluate(angle, true) * width + innerRadius;

            GL.Color(EmotionVector.GetColorForAngle(angle));

            Vector3 point = new Vector3(Mathf.Cos(angle), Mathf.Sin(angle), 0f) * r;
            GL.Vertex(Vector3.Scale(point, scale) + offset);
        }

        GL.End();
        GL.PopMatrix();
    }
Example #3
0
    private void OnDrawGizmos()
    {
        if (IsSelected || !Application.isPlaying)
        {
            Vector3 p = transform.position;
            Vector3 f = transform.forward * .5f;
            Vector3 u = transform.up * .5f;
            Vector3 r = transform.right * .5f;

            Gizmos.color = Color.Lerp(Color.yellow, EmotionVector.GetColorForAngle(EmotionVector.GetAngleForCoreEmotion(primaryAffinity)), emotionalImpact);
            Gizmos.DrawLine(p - f, p + f * (1f + directionality));
            Gizmos.DrawLine(p - u, p + u);
            Gizmos.DrawLine(p - r, p + r);

            Gizmos.color = IsSelected ? Color.magenta : Color.yellow;
            Gizmos.DrawWireSphere(p, size * transform.lossyScale.x);

            if (AssociatedItemRoot)
            {
                Gizmos.color  = Color.red;
                Gizmos.matrix = AssociatedItemRoot.localToWorldMatrix;
                Gizmos.DrawWireCube(AssociatedItemBounds.center, AssociatedItemBounds.size);
            }
        }
    }
    public EmotionVector EvaluateVector()
    {
        Vector3 diff  = RectTransform.position - ContainerTransform.position;
        float   angle = Mathf.Atan2(diff.y, diff.x);

        EmotionVector v = new EmotionVector();

        v.angle     = angle;
        v.intensity = diff.magnitude / ContainerTransform.rect.size.x;
        return(v);
    }
Example #5
0
    // This is the evaluated result of a single gaussian
    public EmotionSpectrum(EmotionVector vector)
    {
        EmotionData gaussians = new EmotionData();

        gaussians.AddVector(vector);

        for (int i = 0; i < SAMPLE_COUNT; ++i)
        {
            float t = i / (float)SAMPLE_COUNT;
            samples[i] = gaussians.Evaluate(t * 2f * Mathf.PI);
        }
    }
Example #6
0
    public void Awake()
    {
        if (DirectorNotAvailable)
        {
            return;
        }

        internalSpectrum = new EmotionSpectrum(EmotionVector.GetCoreEmotion(primaryAffinity));

        if (ProceduralCameraDirector.IsAvailable())
        {
            ProceduralCameraDirector.Instance.RegisterInterestPoint(this);
        }
        else
        {
            DirectorNotAvailable = true;
        }
    }
Example #7
0
    // Eh, this is a very simplistic way of approaching the problem
    public static CoreEmotion FindMainEmotion(EmotionSpectrum e)
    {
        CoreEmotion maxEmotion      = CoreEmotion.Anger;
        float       maxEmotionValue = 0f;

        // TODO: Add some fuzziness by picking the best 3 emotions found, or something

        foreach (CoreEmotion core in System.Enum.GetValues(typeof(CoreEmotion)))
        {
            float dot = new EmotionSpectrum(EmotionVector.GetCoreEmotion(core)).Dot(e);

            if (dot > maxEmotionValue)
            {
                maxEmotion      = core;
                maxEmotionValue = dot;
            }
        }

        return(maxEmotion);
    }
    public void SetPositionFromEmotion(EmotionVector v)
    {
        Vector3 offset = new Vector3(Mathf.Cos(v.angle), Mathf.Sin(v.angle), 0f) * ContainerTransform.rect.width * v.intensity;

        this.RectTransform.position = ContainerTransform.position + offset;
    }
Example #9
0
 public void Awake()
 {
     this.internalSpectrum = new EmotionSpectrum(EmotionVector.GetCoreEmotion(emotionAffinity));
     this.interestPoints   = new List <InterestPoint>(GetComponentsInChildren <InterestPoint>());
     OnAwake();
 }
Example #10
0
 public void RemoveVector(EmotionVector v)
 {
     this.vectors.Remove(v);
 }
Example #11
0
 public void AddVector(EmotionVector v)
 {
     this.vectors.Add(v);
 }