Exemple #1
0
 public APFramesList(AnimationParametersFrame firstAPFrame)
 {
     apFramesList = new List <AnimationParametersFrame>();
     numAPs       = firstAPFrame.APVector.Count;
     apFramesList.Add(firstAPFrame);
     firstAPFrame.setFrameNumber(0);
 }
Exemple #2
0
        public void updateFrames(long currentFrameNumber)
        {
            long currentFrame = currentFrameNumber;
            AnimationParametersFrame firstAPFrame = peek();

            for (int j = 0; j < apFramesList.Count; j++)
            {
                AnimationParametersFrame apFrame = apFramesList[j];
                if (apFrame.getFrameNumber() > currentFrame)
                {
                    break;
                }
                if (apFrame != firstAPFrame)
                {
                    for (int i = 0; i < apFrame.size(); i++)
                    {
                        AnimationParameter ap = apFrame.getAnimationParametersList()[i];

                        if (ap.getMask())
                        {
                            firstAPFrame.setValue(i, ap.getValue());
                            firstAPFrame.setMask(i, true);
                        }
                    }

                    apFramesList.RemoveAt(j);
                    j--;
                }
            }
            // add as peek frame
            firstAPFrame.setFrameNumber(currentFrame);

            //apFramesList.Insert (0, firstAPFrame);
        }
Exemple #3
0
        public void addAPFramesFromFile(String fileName, long firstFrameNumber)
        {
            StringReader apDataReader = null;
            // apData is a string containing the whole file. To be read line-by-line
            //Debug.Log ("firstAPFrame number " + firstFrameNumber);
            TextAsset apData            = (TextAsset)Resources.Load(fileName, typeof(TextAsset));
            long      firstFileFrameNum = 0;
            bool      firstFrame        = true;

            if (apData == null)
            {
                Debug.Log(fileName + " not found");
            }
            else
            {
                apDataReader = new StringReader(apData.text);
                if (apDataReader == null)
                {
                    Debug.Log(fileName + " not readable");
                }
                else
                {
                    String readLine = "";
                    // Read each line from the file
                    // Debug.Log ("APFrameList APnum " +numAPs + " at time " + DateTime.Now.Ticks/10000);

                    while ((readLine = apDataReader.ReadLine()) != null)
                    {
                        String firstLine  = readLine;
                        String secondLine = apDataReader.ReadLine();

                        String[] firstLineTab  = firstLine.Split(' ');
                        String[] secondLineTab = secondLine.Split(' ');

                        /* // Debug of line content
                         * String firstLineTabStr = "";
                         * for(int i=0; i<firstLineTab.Length;i++){
                         * firstLineTabStr += firstLineTab[i];
                         * }
                         * firstLineTabStr += "End";
                         * Debug.Log ("FirstLineTab "+ firstLineTabStr);*/
                        // Debug.Log ("first line length "+ firstLineTab.Length);
                        // Debug.Log ("second line length "+ secondLineTab.Length);
                        int firstLineIter  = 0;
                        int secondLineIter = 0;
                        // frameNum
                        if (firstFrame)
                        {
                            firstFileFrameNum = long.Parse(secondLineTab[secondLineIter]);
                            firstFrame        = false;
                        }
                        long frameNum = long.Parse(secondLineTab[secondLineIter]) - firstFileFrameNum;
                        secondLineIter++;

                        int apnr = 1;

                        AnimationParametersFrame frame = new AnimationParametersFrame(numAPs);
                        frame.setFrameNumber(firstFrameNumber + frameNum);

                        while (firstLineIter < numAPs - 1)
                        {
                            // Debug.Log (firstLineTab[firstLineIter]);
                            int mask = int.Parse(firstLineTab[firstLineIter]);
                            firstLineIter++;

                            if (mask == 1)
                            {
                                int apValue = int.Parse(secondLineTab[secondLineIter]);
                                secondLineIter++;
                                frame.setAnimationParameter(apnr, apValue);
                            }//end more tokens
                            else
                            {
                                frame.setAnimationParameter(apnr, 0);
                            }
                            apnr++;
                        }
                        this.addFrame(frame);
                    }
                    // Debug.Log (fileName + " loaded at time " + DateTime.Now.Ticks/10000);
                }
            }
        }