private void previewCameraFade(AMITarget itarget, float frame, AMCameraSwitcherKey action) { // if transition is None, show end camera / color if (action.cameraFadeType == (int)AMCameraSwitcherKey.Fade.None) { // reset camera fade if visible // camera if (action.typeEnd == 0) { Camera endCam = action.getCameraEnd(itarget); if (endCam) { Utility.SetTopCamera(endCam, GetCachedCameras(itarget)); } AMCameraFade.reset(); } else { showColor(action.colorEnd); } return; } // Get camerafade AMCameraFade cf = AMCameraFade.getCameraFade(); cf.isReset = false; bool isReversed = action.isReversed(); int firstTargetType = (isReversed ? action.typeEnd : action.type); int secondTargetType = (isReversed ? action.type : action.typeEnd); // Set render texture or colors if render texture is used setRenderTexture(itarget, cf, frame, firstTargetType, secondTargetType, isReversed, action); setColors(cf, firstTargetType, secondTargetType, isReversed, action); if (cf.irisShape != action.irisShape) { cf.irisShape = action.irisShape; } cf.mode = action.cameraFadeType; cf.setupMaterials(); cf.r = action.cameraFadeParameters.ToArray(); float t = (float)(frame - action.frame) / (float)(action.endFrame - action.frame); float percentage; if (action.hasCustomEase()) { percentage = Utility.EaseCustom(0.0f, 1.0f, t, action.easeCurve); } else { var ease = Utility.GetEasingFunction((Ease)action.easeType); percentage = ease(t, 1.0f, action.amplitude, action.period); } cf.value = 1.0f - percentage; cf.percent = percentage; }
void CameraEnd(bool isReversed, Camera cam, Camera camEnd, Camera[] allCams) { if (isReversed) { //set camEnd to top if (camEnd) { AMUtil.SetTopCamera(cam, allCams); } } if (typeEnd == 0) { AMCameraFade.reset(); } else { AMCameraFade cf = AMCameraFade.getCameraFade(); cf.keepAliveColor = true; cf.hasColorTex = true; cf.hasColorBG = false; cf.colorTex = colorEnd; cf.mode = 0; cf.value = 1.0f; } if (!still) { if (cam) { cam.targetTexture = null; } if (camEnd) { camEnd.targetTexture = null; } } if (AMCameraFade.hasInstance()) { AMCameraFade cf = AMCameraFade.getCameraFade(); cf.clearScreenTex(); cf.clearTexture(); if (cf.keepAlives > 0) { cf.keepAlives--; } } }
public override void previewFrame(AMITarget itarget, float frame, int frameRate, bool play, float playSpeed) { if (keys == null || keys.Count <= 0) { return; } AMCameraFade.getCameraFade(); // if before or equal to first frame, or is the only frame AMCameraSwitcherKey firstKey = keys[0] as AMCameraSwitcherKey; if (firstKey.endFrame == -1 || (frame <= (float)firstKey.frame && !firstKey.canTween)) { AMCameraFade.reset(); if (!firstKey.hasStartTarget(itarget)) { return; } if (firstKey.type == 0) { Utility.SetTopCamera(firstKey.getCamera(itarget), GetCachedCameras(itarget)); } else { showColor(firstKey.color); } return; } for (int i = 0; i < keys.Count; i++) { AMCameraSwitcherKey key = keys[i] as AMCameraSwitcherKey; AMCameraSwitcherKey keyNext = i + 1 < keys.Count ? keys[i + 1] as AMCameraSwitcherKey : null; if (frame >= (float)key.endFrame && keyNext != null && (!keyNext.canTween || keyNext.endFrame != -1)) { continue; } // if no ease if (!key.canTween || keyNext == null) { AMCameraFade.reset(); if (!key.hasStartTarget(itarget)) { return; } if (key.type == 0) { Utility.SetTopCamera(key.getCamera(itarget), GetCachedCameras(itarget)); } else { showColor(key.color); } return; } // else find t using easing function if (!key.hasStartTarget(itarget) || !key.hasEndTarget(itarget)) { return; } //targets are equal if (key.targetsAreEqual(itarget)) { AMCameraFade.reset(); if (key.type == 0) { Utility.SetTopCamera(key.getCamera(itarget), GetCachedCameras(itarget)); } else { showColor(key.color); } } else { AMCameraFade.clearRenderTexture(); previewCameraFade(itarget, frame, key); } return; } }