Ejemplo n.º 1
0
        public override void updateCache(ITarget itarget)
        {
            base.updateCache(itarget);

            for (int i = 0; i < keys.Count; i++)
            {
                CameraSwitcherKey key = keys[i] as CameraSwitcherKey;

                if (keys.Count > i + 1)
                {
                    CameraSwitcherKey nextKey = keys[i + 1] as CameraSwitcherKey;
                    key.endFrame = nextKey.frame;
                    key.typeEnd  = nextKey.type;
                    if (key.typeEnd == 0)
                    {
                        key.SetCameraEnd(nextKey);
                    }
                    else
                    {
                        key.colorEnd = nextKey.color;
                    }
                }
                else
                {
                    key.endFrame = -1;
                }
            }

            _cachedAllCameras = getAllCameras(itarget);
        }
Ejemplo n.º 2
0
        public cfTuple getCameraFadeTupleForFrame(ITarget itarget, int frame)
        {
            if (keys == null || keys.Count <= 0)
            {
                return(new cfTuple(0, 0, 0, null, null, false));
            }
            for (int i = 0; i < keys.Count; i++)
            {
                CameraSwitcherKey key = keys[i] as CameraSwitcherKey;
                // compact
                if (frame < key.frame)
                {
                    break;
                }
                else if (frame < key.endFrame)
                {
                    if (!key.still || key.cameraFadeType == (int)CameraSwitcherKey.Fade.None || key.targetsAreEqual(itarget))
                    {
                        break;
                    }
                    bool isReversed = key.isReversed();

                    if (isReversed)
                    {
                        return(new cfTuple(key.endFrame, key.typeEnd, key.type, key.GetCameraEnd(itarget), key.GetCamera(itarget), isReversed));
                    }
                    else
                    {
                        return(new cfTuple(key.frame, key.type, key.typeEnd, key.GetCamera(itarget), key.GetCameraEnd(itarget), isReversed));
                    }
                    //return new cfTuple((isReversed ? (cache[i] as AMCameraSwitcherAction).endFrame : (cache[i] as AMCameraSwitcherAction).startFrame),(cache[i] as AMCameraSwitcherAction).startCamera,(cache[i] as AMCameraSwitcherAction).endCamera,isReversed);
                }
            }
            return(new cfTuple(0, 0, 0, null, null, false));
        }
Ejemplo n.º 3
0
            //private float[] mFadeParams;

            public void Apply(CameraSwitcherKey camSwitcher, int frameRate, ITarget itarget, Camera[] allCameras, bool backwards)
            {
                if (mCamSwitcher != camSwitcher)
                {
                    mCamSwitcher = camSwitcher;

                    float[] fadeParams = mCamSwitcher.cameraFadeParameters.ToArray();
                    mIsReversed = Utility.isTransitionReversed(mCamSwitcher.type, fadeParams);
                    mCam        = mCamSwitcher.GetCamera(itarget);
                    mCamEnd     = mCamSwitcher.GetCameraEnd(itarget);
                    mAllCams    = allCameras;

                    if (mCamSwitcher.cameraFadeType == (int)Fade.None)
                    {
                        mCamSwitcher.CameraFadeNoneTargets(mCamSwitcher.typeEnd, mCamSwitcher.colorEnd, mCamEnd, mAllCams);
                        mCamSwitcher.CameraEnd(mIsReversed, mCam, mCamEnd, mAllCams);
                    }
                    else
                    {
                        mCamSwitcher.CameraGenerateFadeTargets(mIsReversed, mCam, mCamEnd, mAllCams, fadeParams);
                    }
                }

                mBackwards = backwards;
            }
Ejemplo n.º 4
0
        private void previewCameraFade(ITarget itarget, float frame, CameraSwitcherKey action)
        {
            // if transition is None, show end camera / color
            if (action.cameraFadeType == (int)CameraSwitcherKey.Fade.None)
            {
                // reset camera fade if visible
                // camera
                if (action.typeEnd == 0)
                {
                    Camera endCam = action.GetCameraEnd(itarget);
                    if (endCam)
                    {
                        Utility.SetTopCamera(endCam, GetCachedCameras(itarget));
                    }
                    CameraFade.reset();
                }
                else
                {
                    showColor(action.colorEnd);
                }
                return;
            }
            // Get camerafade
            CameraFade cf = CameraFade.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;
        }
Ejemplo n.º 5
0
        // set render texture or colors if render texture is used (stills handled in AMTake)
        private void setRenderTexture(ITarget itarget, CameraFade cf, float frame, int firstTargetType, int secondTargetType, bool isReversed,
                                      CameraSwitcherKey action)
        {
            Camera firstCamera  = (isReversed ? action.GetCameraEnd(itarget) : action.GetCamera(itarget));
            Camera secondCamera = (isReversed ? action.GetCamera(itarget) : action.GetCameraEnd(itarget));

            if (isReversed && frame == action.frame)
            {
                if (firstTargetType == 0)
                {
                    Utility.SetTopCamera(firstCamera, GetCachedCameras(itarget));
                }
            }
            else
            {
                if (secondTargetType == 0)
                {
                    Utility.SetTopCamera(secondCamera, GetCachedCameras(itarget));
                }
            }

            if (action.still || (firstTargetType != 0 && secondTargetType != 0))
            {
                return;
            }

            bool isPro = Take.isProLicense;

            // first target is camera, set render texture
            if (firstTargetType == 0)
            {
                // if should update render texture
                if (/*!cf.tex ||*/ cf.shouldUpdateRenderTexture || (isPro && (!firstCamera.targetTexture || !cf.isRenderTextureSetupFor(firstCamera) /*|| firstCamera.targetTexture != cf.tex*/)))
                {
                    if (isPro)
                    {
                        cf.setupRenderTexture(firstCamera);
                    }
                    else
                    {
                        cf.useRenderTexture = false;
                        // show place-holder if non-pro
                        cf.colorTex    = Color.white;
                        cf.hasColorTex = false;
                        cf.clearScreenTex();
                        cf.placeholder = true;
                    }
                }
            }
        }
Ejemplo n.º 6
0
        public override void CopyTo(Key key)
        {
            base.CopyTo(key);

            CameraSwitcherKey a = key as CameraSwitcherKey;

            a.type                 = type;
            a._camera              = _camera;
            a._cameraPath          = _cameraPath;
            a.color                = color;
            a.cameraFadeType       = cameraFadeType;
            a.cameraFadeParameters = new List <float>(cameraFadeParameters);
            a.irisShape            = irisShape;
            a.still                = still;
        }
Ejemplo n.º 7
0
        // add a new key
        public void addKey(ITarget itarget, int _frame, Camera camera = null, /*int? type = null, Camera camera = null, Color? color = null,*/ CameraSwitcherKey keyToClone = null)
        {
            foreach (CameraSwitcherKey key in keys)
            {
                // if key exists on frame, update key
                if (key.frame == _frame)
                {
                    if (camera != null)
                    {
                        key.SetCamera(itarget, camera);
                        key.type = 0;
                        updateCache(itarget);
                    }
                    return;
                }
            }
            CameraSwitcherKey a = new CameraSwitcherKey();

            if (keyToClone != null)
            {
                keyToClone.CopyTo(a);
            }
            else
            {
                a.type     = 0;
                a.still    = !Take.isProLicense;
                a.easeType = Ease.OutSine;
            }
            a.frame = _frame;
            if (camera != null)
            {
                a.SetCamera(itarget, camera);
                a.type = 0;
            }
            // add a new key
            keys.Add(a);
            // update cache
            updateCache(itarget);
        }
Ejemplo n.º 8
0
        private void setColors(CameraFade cf, int firstTargetType, int secondTargetType, bool isReversed, CameraSwitcherKey action)
        {
            //if(firstTargetType != 1 && secondTargetType != 1) return;
            Color firstColor  = (isReversed ? action.colorEnd : action.color);
            Color secondColor = (isReversed ? action.color : action.colorEnd);

            if (firstTargetType == 1)
            {
                cf.colorTex    = firstColor;
                cf.hasColorTex = true;
            }
            else
            {
                cf.hasColorTex = false;
            }

            if (secondTargetType == 1)
            {
                cf.colorBG    = secondColor;
                cf.hasColorBG = true;
            }
            else
            {
                cf.hasColorBG = false;
            }

            // send event to game view to repaint OnGUI
            if (!Application.isPlaying && (firstTargetType == 1 || secondTargetType == 1))
            {
                cf.transform.position = new Vector3(cf.transform.position.x, cf.transform.position.y, cf.transform.position.z);
            }
        }
Ejemplo n.º 9
0
        public override void previewFrame(ITarget itarget, float frame, int frameRate, bool play, float playSpeed)
        {
            if (keys == null || keys.Count <= 0)
            {
                return;
            }

            CameraFade.getCameraFade();

            // if before or equal to first frame, or is the only frame
            CameraSwitcherKey firstKey = keys[0] as CameraSwitcherKey;

            if (firstKey.endFrame == -1 || (frame <= (float)firstKey.frame && !firstKey.canTween))
            {
                CameraFade.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++)
            {
                CameraSwitcherKey key     = keys[i] as CameraSwitcherKey;
                CameraSwitcherKey keyNext = i + 1 < keys.Count ? keys[i + 1] as CameraSwitcherKey : null;

                if (frame >= (float)key.endFrame && keyNext != null && (!keyNext.canTween || keyNext.endFrame != -1))
                {
                    continue;
                }
                // if no ease
                if (!key.canTween || keyNext == null)
                {
                    CameraFade.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))
                {
                    CameraFade.reset();
                    if (key.type == 0)
                    {
                        Utility.SetTopCamera(key.GetCamera(itarget), GetCachedCameras(itarget));
                    }
                    else
                    {
                        showColor(key.color);
                    }
                }
                else
                {
                    CameraFade.clearRenderTexture();
                    previewCameraFade(itarget, frame, key);
                }

                return;
            }
        }
Ejemplo n.º 10
0
 public void SetCameraEnd(CameraSwitcherKey nextKey)
 {
     _cameraEnd     = nextKey._camera;
     _cameraEndPath = nextKey._cameraPath;
 }