Beispiel #1
0
    void setupAnimationRequirements()
    {
        int fishType = PlayerPrefs.GetInt("FishType");

        if (fishType == 0)
        {
            fishModel = FishType.Poeciliid;
            GameObject.Find("EditorPrefab/Root/SticklebackRig").SetActiveRecursively(false);
            KeyframeBar holder = GameObject.Find("KeyframeBar/KeyframeGameRegistry").GetComponent <KeyframeBar>();
            Debug.Log("Does holder equal null " + holder);
            holder.keyedObject         = (GameObject)GameObject.Find("EditorPrefab/Root/SwordtailRigCore");
            holder.motionCaptureTarget = (GameObject)GameObject.Find("EditorPrefab/Root/SwordtailRigCore/MotionCaptureTarget");
            target = holder.motionCaptureTarget;

            /*
             * if(PlayerPrefs.GetString("MorphPath") != "default")
             * {
             *      Debug.Log("MorphPath: " + PlayerPrefs.GetString("MorphPath"));
             *      Messenger<string>.Broadcast("OnMorph", PlayerPrefs.GetString("MorphPath"));
             * }
             * if(PlayerPrefs.GetString("TexturePath") != "default")
             *      Messenger<string>.Broadcast("SwapTexture", PlayerPrefs.GetString("TexturePath"));
             */
        }
        else if (fishType == 1)
        {
            fishModel = FishType.Stickleback;
            GameObject.Find("SwordtailRigCore").SetActiveRecursively(false);
            KeyframeBar holder = GameObject.Find("KeyframeBar/KeyframeGameRegistry").GetComponent <KeyframeBar>();
            holder.keyedObject         = (GameObject)GameObject.Find("EditorPrefab/Root/SticklebackRig");
            holder.motionCaptureTarget = (GameObject)GameObject.Find("EditorPrefab/Root/SticklebackRig/MotionCaptureTarget");
            target = holder.motionCaptureTarget;
        }
    }
Beispiel #2
0
    void playFrame()
    {
        KeyframeBar holder = GameObject.Find("KeyframeBar/KeyframeGameRegistry").GetComponent <KeyframeBar>();

        //Debug.Log("HOLDER TARGET---------------------" + holder.motionCaptureTarget.transform.parent);
        target.transform.position = playbackKeys[currentFrame].Position;
        target.transform.rotation = playbackKeys[currentFrame].QRotation;        //subframeCount++;
        dorsalAmount   = playbackKeys[currentFrame].DorsalAmount;
        lpelvicHAmount = playbackKeys[currentFrame].LPecAmount.x;
        lpelvicVAmount = playbackKeys[currentFrame].LPecAmount.y;
        rpelvicHAmount = playbackKeys[currentFrame].RPecAmount.x;
        rpelvicVAmount = playbackKeys[currentFrame].RPecAmount.y;
        analHAmount    = playbackKeys[currentFrame].AnalAmount.x;
        analVAmount    = playbackKeys[currentFrame].AnalAmount.y;

        if (fishModel == FishType.Poeciliid)
        {
            Messenger <float> .Broadcast("AdjustDorsalFin", dorsalAmount);

            Messenger <float, float> .Broadcast("AdjustLPelvicFin", lpelvicHAmount, lpelvicVAmount);

            Messenger <float, float> .Broadcast("AdjustRPelvicFin", rpelvicHAmount, rpelvicVAmount);

            Messenger <float, float> .Broadcast("AdjustAnalFin", analHAmount, analVAmount);
        }

        playbackClock += Time.deltaTime;
        if (currentFrame == 0)
        {
            if (playbackClock > 7)
            {
                ProduceScreenShots.TakePic();
                currentFrame++;
            }
        }
        else if (playbackClock > (1.0f / (float)playbackRate))
        {
            //Debug.Log("Playback clock: " + playbackClock);
            playbackClock = 0.0f;



            //yeild WaitForEndOfFrame;

            ProduceScreenShots.TakePic();
            if (currentFrame == playbackKeys.Count - 1)
            {
                isReadyToStartRecording = false;
                canLoadNextSet          = true;
                currentFrame            = 0;
                currentSetIndex++;
                target.transform.position = playbackKeys[0].Position;
                target.transform.rotation = playbackKeys[0].QRotation;
                Debug.Log("One Batch Finished");
            }
            currentFrame++;
        }
    }
Beispiel #3
0
    void Awake()
    {
        Messenger.AddListener("TurnOffGui", onTurnOffGui);
        Messenger.AddListener("TurnOnGui", onTurnOnGui);
        int fishType = PlayerPrefs.GetInt("FishType");

        Debug.Log("AnimationEditorState fishtype: " + fishType);

        if (fishType == 0)
        {
            fishModel = FishType.Poeciliid;
            GameObject.Find("EditorPrefab/Root/SticklebackRig").SetActiveRecursively(false);
            KeyframeBar holder = GameObject.Find("KeyframeBar/KeyframeGameRegistry").GetComponent <KeyframeBar>();
            Debug.Log("Does holder equal null " + holder);
            holder.keyedObject         = (GameObject)GameObject.Find("EditorPrefab/Root/SwordtailRigCore");
            holder.motionCaptureTarget = (GameObject)GameObject.Find("EditorPrefab/Root/SwordtailRigCore/MotionCaptureTarget");
            target = holder.motionCaptureTarget;
            if (PlayerPrefs.GetString("MorphPath") != "default")
            {
                Debug.Log("MorphPath: " + PlayerPrefs.GetString("MorphPath"));
                Messenger <string> .Broadcast("OnMorph", PlayerPrefs.GetString("MorphPath"));
            }
            if (PlayerPrefs.GetString("TexturePath") != "default")
            {
                Messenger <string> .Broadcast("SwapTexture", PlayerPrefs.GetString("TexturePath"));
            }
        }
        else if (fishType == 1)         // changed "else" to "else if" by Chengde, 06132013
        {
            fishModel = FishType.Stickleback;
            GameObject.Find("SwordtailRigCore").SetActiveRecursively(false);
            KeyframeBar holder = GameObject.Find("KeyframeBar/KeyframeGameRegistry").GetComponent <KeyframeBar>();
            holder.keyedObject         = (GameObject)GameObject.Find("EditorPrefab/Root/SticklebackRig");
            holder.motionCaptureTarget = (GameObject)GameObject.Find("EditorPrefab/Root/SticklebackRig/MotionCaptureTarget");
            target = holder.motionCaptureTarget;

            //pasted following two if statement by Chengde, 06132013.
            if (PlayerPrefs.GetString("MorphPath") != "default")
            {
                Debug.Log("MorphPath: " + PlayerPrefs.GetString("MorphPath"));
                Messenger <string> .Broadcast("OnMorph", PlayerPrefs.GetString("MorphPath"));
            }
            if (PlayerPrefs.GetString("TexturePath") != "default")
            {
                Messenger <string> .Broadcast("SwapTexture", PlayerPrefs.GetString("TexturePath"));
            }
        }


        //string path = PlayerPrefs.GetString("PathDir");

        //loadStateData(path);
    }
    // Use this for initialization
    void Awake()
    {
        keyBar = gameObject.AddComponent<KeyframeBar>();
        keyBar.keyedObject = keyableGameObject;
        keyBar.debugMode = isDebugModeActive;
        keyBar.motionCaptureTarget = MotionCaptureTarget;
        //TODO moveable keyframeBar
        //keyBar.transform.Translate((float)keyFrameBarX, (float)keyFrameBarY, 0.0f);

        // Switch the state
        GameRegistry activeRegistry = GameObject.Find("EditorApplication").GetComponent<GameRegistry>();
        if(isBatchRenderer)
            activeRegistry.switchState(States.BatchRenderer);
        else
            activeRegistry.switchState(States.AnimationEditor);
    }
Beispiel #5
0
    // Use this for initialization
    void Awake()
    {
        keyBar                     = gameObject.AddComponent <KeyframeBar>();
        keyBar.keyedObject         = keyableGameObject;
        keyBar.debugMode           = isDebugModeActive;
        keyBar.motionCaptureTarget = MotionCaptureTarget;
        //TODO moveable keyframeBar
        //keyBar.transform.Translate((float)keyFrameBarX, (float)keyFrameBarY, 0.0f);

        // Switch the state
        GameRegistry activeRegistry = GameObject.Find("EditorApplication").GetComponent <GameRegistry>();

        if (isBatchRenderer)
        {
            activeRegistry.switchState(States.BatchRenderer);
        }
        else
        {
            activeRegistry.switchState(States.AnimationEditor);
        }
    }
Beispiel #6
0
    // Update is called once per frame
    IEnumerator playFrame()
    {
        KeyframeBar holder = GameObject.Find("KeyframeBar/KeyframeGameRegistry").GetComponent <KeyframeBar>();

        //Debug.Log("HOLDER TARGET---------------------" + holder.motionCaptureTarget.transform.parent);

        target.transform.position = playbackKeys[currentFrame].Position;
        target.transform.rotation = playbackKeys[currentFrame].QRotation;        //subframeCount++;
        dorsalAmount     = playbackKeys[currentFrame].DorsalAmount;
        lpelvicHAmount   = playbackKeys[currentFrame].LPecAmount.x;
        lpelvicVAmount   = playbackKeys[currentFrame].LPecAmount.y;
        rpelvicHAmount   = playbackKeys[currentFrame].RPecAmount.x;
        rpelvicVAmount   = playbackKeys[currentFrame].RPecAmount.y;
        lpectoralHAmount = playbackKeys[currentFrame].LPectAmount.x;              // Mahmoud 02.17.14
        lpectoralVAmount = playbackKeys[currentFrame].LPectAmount.y;              // Mahmoud 02.17.14
        rpectoralHAmount = playbackKeys[currentFrame].RPectAmount.x;              // Mahmoud 02.17.14
        rpectoralVAmount = playbackKeys[currentFrame].RPectAmount.y;              // Mahmoud 02.17.14
        analHAmount      = playbackKeys[currentFrame].AnalAmount.x;
        analVAmount      = playbackKeys[currentFrame].AnalAmount.y;

        playbackClock += Time.deltaTime;
        Debug.Log("playbackClock: " + playbackClock);
        Messenger.Broadcast("TurnOffGui");
        yield return(new WaitForSeconds(2.0f));

        //Vector3 position = Vector3.Lerp(playbackKeys[currentFrame].Position, playbackKeys[currentFrame + 1].Position, (float)subframeCount / playbackRate);
        //Quaternion rotation = Quaternion.Slerp(playbackKeys[currentFrame].QRotation, playbackKeys[currentFrame + 1].QRotation, (float)subframeCount / playbackRate);

        //target.transform.position = position;
        //target.transform.rotation = rotation;
        subframeCount++;

        if (playbackClock > (1.0f / (float)playbackRate))
        {
            //Debug.Log("playClock: " + playbackClock);
            playbackClock             = 0.0f;
            target.transform.position = playbackKeys[currentFrame].Position;
            target.transform.rotation = playbackKeys[currentFrame].QRotation;            //subframeCount++;
            dorsalAmount = playbackKeys[currentFrame].DorsalAmount;
            //if(subframeCount == playbackRate)
            //{
            subframeCount = 1;
            currentFrame++;
            //ProduceScreenShots.TakePic();
            if (currentFrame == playbackKeys.Count - 1)
            {
                isPlaying = false;
                yield return(new WaitForSeconds(1.0f));

                target.transform.position = playbackKeys[0].Position;
                target.transform.rotation = playbackKeys[0].QRotation;
                Debug.Log("Test");
                Messenger.Broadcast("TurnOnGui");
                //Reset motioncaption's parent the actual fish. Fish is moved for keyframing
                // motioncapture for playback
                //Transform fish = target.transform.parent;
                //fish.position = Vector3.zero;
                //fish.rotation = Quaternion.identity;
            }
        }
    }