public override BaseEvent Clone() { ModifyTransform transform = ClassObjPool <ModifyTransform> .Get(); transform.CopyData(this); return(transform); }
public void CubicVectorBlend(Action _action, Track _track, TickEvent _prevEvent, float _blendWeight, bool isPos) { int indexOfEvent = _track.GetIndexOfEvent(_prevEvent); int indexOfEvent2 = _track.GetIndexOfEvent(this); int eventsCount = _track.GetEventsCount(); int num = indexOfEvent - 1; if (num < 0) { if (_action.loop) { num = eventsCount - 1; if (num < 0) { num = 0; } } else { num = 0; } } int num2 = indexOfEvent2 + 1; if (num2 >= eventsCount) { if (_action.loop) { num2 = 0; } else { num2 = indexOfEvent2; } } ModifyTransform modifyTransform = _prevEvent as ModifyTransform; ModifyTransform modifyTransform2 = _track.GetEvent(num) as ModifyTransform; ModifyTransform modifyTransform3 = _track.GetEvent(num2) as ModifyTransform; DebugHelper.Assert(modifyTransform != null && modifyTransform2 != null && modifyTransform3 != null, "��һ�Ѷ���Ӧ��Ϊ��"); Vector3 vector = isPos ? modifyTransform.GetTranslation(_action) : modifyTransform.scaling; Vector3 vector2 = isPos ? this.GetTranslation(_action) : this.scaling; Vector3 formPoint = isPos ? modifyTransform2.GetTranslation(_action) : modifyTransform2.scaling; Vector3 lattPoint = isPos ? modifyTransform3.GetTranslation(_action) : modifyTransform3.scaling; Vector3 a; Vector3 a2; CurvlData.CalculateCtrlPoint(formPoint, vector, vector2, lattPoint, out a, out a2); float d = 1f - _blendWeight; Vector3 vector3 = vector * d * d * d + a * 3f * d * d * _blendWeight + a2 * 3f * d * _blendWeight * _blendWeight + vector2 * _blendWeight * _blendWeight * _blendWeight; if (isPos) { _action.GetGameObject(this.targetId).transform.position = vector3; } else { _action.GetGameObject(this.targetId).transform.localScale = vector3; } }
public static bool CalTransform(ModifyTransform evt, Transform dstobj, Transform fromTransform, Transform toTransform, Transform coordTransform, ref Vector3 oPos, ref Quaternion oRot, ref Vector3 oScl) { if (dstobj == null) { return(false); } if (fromTransform != null && toTransform != null) { Vector3 vector = toTransform.position - fromTransform.position; vector = new Vector3(vector.x * CurvlHelper.axisWeight.x, vector.y * CurvlHelper.axisWeight.y, vector.z * CurvlHelper.axisWeight.z); Vector2 vector2 = new Vector2(vector.x, vector.z); float magnitude = vector2.magnitude; vector = Vector3.Normalize(vector); Quaternion quaternion = Quaternion.Inverse(Quaternion.LookRotation(vector, Vector3.up)); if (evt.normalizedRelative) { oPos = quaternion * (dstobj.position - fromTransform.position); oPos = new Vector3(oPos.x / magnitude, oPos.y, oPos.z / magnitude); oPos -= new Vector3(0f, 1f, 0f) * oPos.z * (toTransform.position.y - fromTransform.position.y); } else { oPos = quaternion * (dstobj.position - fromTransform.position); oPos -= new Vector3(0f, 1f, 0f) * (oPos.z / magnitude) * (toTransform.position.y - fromTransform.position.y); } oRot = quaternion * dstobj.rotation; oScl = dstobj.localScale; } else if (coordTransform != null) { oPos = coordTransform.InverseTransformPoint(dstobj.position); oRot = Quaternion.Inverse(coordTransform.rotation) * dstobj.rotation; oScl = dstobj.localScale; } else { oPos = dstobj.position; oRot = dstobj.rotation; oScl = dstobj.localScale; } return(true); }
protected override void CopyData(BaseEvent src) { base.CopyData(src); ModifyTransform transform = src as ModifyTransform; this.enableTranslation = transform.enableTranslation; this.currentTranslation = transform.currentTranslation; this.translation = transform.translation; this.enableRotation = transform.enableRotation; this.currentRotation = transform.currentRotation; this.rotation = transform.rotation; this.enableScaling = transform.enableScaling; this.currentScaling = transform.currentScaling; this.scaling = transform.scaling; this.targetId = transform.targetId; this.objectSpaceId = transform.objectSpaceId; this.fromId = transform.fromId; this.toId = transform.toId; this.normalizedRelative = transform.normalizedRelative; this.cubic = transform.cubic; this.currentInitialized = transform.currentInitialized; }
public void CubicVectorBlend(Action _action, Track _track, TickEvent _prevEvent, float _blendWeight, bool isPos) { Vector3 vector5; Vector3 vector6; int indexOfEvent = _track.GetIndexOfEvent(_prevEvent); int num2 = _track.GetIndexOfEvent(this); int eventsCount = _track.GetEventsCount(); int index = indexOfEvent - 1; if (index < 0) { if (_action.loop) { index = eventsCount - 1; if (index < 0) { index = 0; } } else { index = 0; } } int num5 = num2 + 1; if (num5 >= eventsCount) { if (_action.loop) { num5 = 0; } else { num5 = num2; } } ModifyTransform transform = _prevEvent as ModifyTransform; ModifyTransform transform2 = _track.GetEvent(index) as ModifyTransform; ModifyTransform transform3 = _track.GetEvent(num5) as ModifyTransform; DebugHelper.Assert(((transform != null) && (transform2 != null)) && (transform3 != null), "��һ�Ѷ���Ӧ��Ϊ��"); Vector3 prevPoint = !isPos ? transform.scaling : transform.GetTranslation(_action); Vector3 curnPoint = !isPos ? this.scaling : this.GetTranslation(_action); Vector3 formPoint = !isPos ? transform2.scaling : transform2.GetTranslation(_action); Vector3 lattPoint = !isPos ? transform3.scaling : transform3.GetTranslation(_action); CurvlData.CalculateCtrlPoint(formPoint, prevPoint, curnPoint, lattPoint, out vector5, out vector6); float num6 = 1f - _blendWeight; float num7 = _blendWeight; Vector3 vector7 = (Vector3)((((((prevPoint * num6) * num6) * num6) + ((((vector5 * 3f) * num6) * num6) * num7)) + ((((vector6 * 3f) * num6) * num7) * num7)) + (((curnPoint * num7) * num7) * num7)); if (isPos) { _action.GetGameObject(this.targetId).transform.position = vector7; } else { _action.GetGameObject(this.targetId).transform.localScale = vector7; } }