RecalculateStoredValues() public method

public RecalculateStoredValues ( ) : void
return void
Exemplo n.º 1
0
    public static void AddJumpTwist(TrackBuildRTrack track, int selectedPoint)
    {
        TrackBuildRPoint atPoint   = track[selectedPoint];
        TrackBuildRPoint lastPoint = track.GetPoint(selectedPoint - 1);
        TrackBuildRPoint nextPoint = track.GetPoint(selectedPoint + 1);

        float trackPartDistance = lastPoint.arcLength + atPoint.arcLength;
        float jumpDistance      = Mathf.Min(trackPartDistance * 0.333f, track.maxJumpLength);

        float      trackWidth      = atPoint.width * 0.5f;
        Vector3    startCross      = atPoint.trackCross;
        Vector3    jumpDirection   = atPoint.trackDirection;
        Vector3    jumpMiddle      = atPoint.worldPosition;
        Quaternion atPointUpQ      = atPoint.trackUpQ;
        Quaternion trackUpJump     = Quaternion.AngleAxis(track.twistAngle, -jumpDirection);
        Quaternion trackCrossExit  = trackUpJump * (atPointUpQ);
        Quaternion trackCrossEntry = Quaternion.Inverse(trackUpJump) * (atPointUpQ);
        Vector3    jumpLateral     = startCross * track.twistAngle / 33.3f;

        Vector3 jumpHeight        = atPointUpQ * (Vector3.forward * track.jumpHeight);
        Vector3 jumpStartPosition = jumpMiddle - jumpDirection * (jumpDistance * 0.33f) + jumpHeight - jumpLateral;
        Vector3 jumpEndPosition   = jumpMiddle + jumpDirection * (jumpDistance * 0.33f) + jumpHeight + jumpLateral;

        lastPoint.extrudeTrack       = true;
        lastPoint.extrudeLength      = track.jumpHeight;
        lastPoint.extrudeCurveEnd    = true;
        lastPoint.extrudeTrackBottom = true;

        atPoint.Reset();
        atPoint.worldPosition       = jumpStartPosition;
        atPoint.forwardControlPoint = jumpDirection * (jumpDistance * 0.5f) + jumpStartPosition + jumpHeight;
        atPoint.trackUpQ            = trackCrossExit;
        atPoint.render = false;

        TrackBuildRPoint jumpEnd = track.InsertPoint(selectedPoint + 1);

        jumpEnd.worldPosition       = jumpEndPosition;
        jumpEnd.forwardControlPoint = jumpDirection * (jumpDistance * 0.5f) + jumpEndPosition - jumpHeight;
        jumpEnd.trackUpQ            = trackCrossEntry;
        jumpEnd.extrudeTrack        = true;
        jumpEnd.extrudeLength       = track.jumpHeight;
        jumpEnd.extrudeCurveEnd     = true;
        jumpEnd.extrudeTrackBottom  = true;

        atPoint.RecalculateStoredValues();
        jumpEnd.RecalculateStoredValues();
    }
Exemplo n.º 2
0
    public static void AddJump(TrackBuildRTrack track, int selectedPoint)
    {
        TrackBuildRPoint atPoint   = track[selectedPoint];
        TrackBuildRPoint lastPoint = track.GetPoint(selectedPoint - 1);
        TrackBuildRPoint nextPoint = track.GetPoint(selectedPoint + 1);

        float trackPartDistance = lastPoint.arcLength + atPoint.arcLength;
        float jumpDistance      = Mathf.Min(trackPartDistance * 0.333f, track.maxJumpLength);

        Vector3    jumpDirection = atPoint.trackDirection;
        Vector3    jumpMiddle    = atPoint.worldPosition;
        Vector3    startCross    = atPoint.trackCross;
        float      trackWidth    = atPoint.width * 0.5f;
        Quaternion trackUp       = atPoint.trackUpQ;

        Vector3 jumpHeight        = trackUp * (Vector3.forward * track.jumpHeight);
        Vector3 jumpStartPosition = jumpMiddle - jumpDirection * (jumpDistance * 0.33f);
        Vector3 jumpEndPosition   = jumpMiddle + jumpDirection * (jumpDistance * 0.33f);

        lastPoint.extrudeTrack    = true;
        lastPoint.extrudeLength   = track.jumpHeight;
        lastPoint.extrudeCurveEnd = true;

        atPoint.Reset();
        atPoint.worldPosition       = jumpStartPosition + jumpHeight;
        atPoint.forwardControlPoint = jumpDirection * (jumpDistance * 0.5f) + jumpStartPosition + jumpHeight * 2;
        atPoint.trackUpQ            = trackUp;
        atPoint.render = false;

        TrackBuildRPoint jumpEnd = track.InsertPoint(selectedPoint + 1);

        jumpEnd.worldPosition       = jumpEndPosition + jumpHeight;
        jumpEnd.forwardControlPoint = jumpDirection * (jumpDistance * 0.5f) + jumpEndPosition;
        jumpEnd.trackUpQ            = trackUp;
        jumpEnd.extrudeTrack        = true;
        jumpEnd.extrudeLength       = track.jumpHeight;
        jumpEnd.extrudeCurveEnd     = true;

        atPoint.RecalculateStoredValues();
        jumpEnd.RecalculateStoredValues();
    }