Exemplo n.º 1
0
    private void ApplyScale(RageMagnet magnet, Vector3 scaleOffset)
    {
        RageMagnetPointData pointData = FindRelatedData(magnet);

        ApplyScale(ref pointData.PointPos, Vector3.one + pointData.PointOffset * scaleOffset);
        ApplyScale(ref pointData.InCtrlPos, Vector3.one + pointData.InCtrlOffset * scaleOffset);
        ApplyScale(ref pointData.OutCtrlPos, Vector3.one + pointData.OutCtrlOffset * scaleOffset);
    }
Exemplo n.º 2
0
    private void ApplyPosition(RageMagnet magnet, Vector3 baseOffset)
    {
        RageMagnetPointData pointData = FindRelatedData(magnet);

        pointData.PointPos   += baseOffset * pointData.PointOffset;
        pointData.InCtrlPos  += baseOffset * pointData.InCtrlOffset;
        pointData.OutCtrlPos += baseOffset * pointData.OutCtrlOffset;
    }
Exemplo n.º 3
0
    public static void CalculateDeformations(this RageMagnet magnet, RageMagnetPoint ragePoint, Vector3 posOffset, Vector3 scaleOffset)
    {
        RageMagnetPointData pointData = ragePoint.FindRelatedData(magnet);

        pointData.PointPos   = pointData.InitialPos;
        pointData.InCtrlPos  = pointData.InitialInCtrlPos;
        pointData.OutCtrlPos = pointData.InitialOutCtrlPos;

        ragePoint.ApplyDeformations(magnet, posOffset, scaleOffset);

        pointData.AbsolutePointPos   = pointData.PointPos + magnet.RestPosition;
        pointData.AbsoluteInCtrlPos  = pointData.InCtrlPos + magnet.RestPosition;
        pointData.AbsoluteOutCtrlPos = pointData.OutCtrlPos + magnet.RestPosition;
    }
Exemplo n.º 4
0
    private void AddRelatedData(RageMagnetPointData newPointData)
    {
        List <RageMagnetPointData> points = new List <RageMagnetPointData>(RelatedData.Length);

        foreach (RageMagnetPointData pointData in RelatedData)
        {
            if (pointData.Magnet != newPointData.Magnet)
            {
                points.Add(pointData);
            }
        }

        points.Add(newPointData);
        RelatedData = points.ToArray();
    }
Exemplo n.º 5
0
    public static RageMagnetPoint Instantiate(RageMagnet magnet, ISpline rageSpline, int index,
                                              float pointOffset, float inCtrlOffset, float outCtrlOffset,
                                              Vector3 pointPos, Vector3 inCtrlPos, Vector3 outCtrlPos,
                                              Vector3 currentPosition)
    {
        List <RageMagnetPoint> points = GetAllMagnetPoints();
        RageMagnetPoint        result = null;

        foreach (RageMagnetPoint point in points)
        {
            if (rageSpline.Oid != point.Spline.Oid)
            {
                continue;
            }
            if (index != point.Index)
            {
                continue;
            }
            result = point;
            break;
        }

        if (result == null)
        {
            result = CreateInstance(typeof(RageMagnetPoint)) as RageMagnetPoint;
        }

        result.Spline = rageSpline;
        result.Index  = index;

        result.RemovePointData(magnet);
        var magnetPointData = RageMagnetPointData.Instantiate(magnet, pointPos, inCtrlPos, outCtrlPos, currentPosition);

        result.AddRelatedData(magnetPointData);

        magnetPointData.PointOffset   = pointOffset;
        magnetPointData.InCtrlOffset  = inCtrlOffset;
        magnetPointData.OutCtrlOffset = outCtrlOffset;

        return(result);
    }