Ejemplo n.º 1
0
        public void runDecoder(Stream byteStream)
        {
            var newReader = new MiniMessagePacker();

            fileData = (object[])newReader.Unpack(byteStream);

            headerList          = (object[])fileData[getBaseOffset()];
            animPairsOffsetList = (object[])fileData[getAnimPairsListOffset()];

            // init basic points and topology structure
            indices = new uint[getNumIndices()];
            points  = new float[getNumPoints()];
            uvs     = new float[getNumUvs()];

            updateIndices(getBaseIndicesOffset());
            updatePoints(getBasePointsOffset());
            updateUVs(getBaseUvsOffset());

            // init Animation Clip Map
            for (int i = 0; i < getAnimationNum(); i++)
            {
                var curOffsetPair = getAnimationOffsets(i);

                var animName = (string)(fileData[curOffsetPair.first]);
                var k        = curOffsetPair.first;
                k++;
                var newClip = new CreaturePackAnimClip(k);

                while (k < curOffsetPair.second)
                {
                    int cur_time = (int)(float)(fileData[k]);
                    newClip.addTimeSample(cur_time, (int)k);

                    k += 4;
                }

                newClip.finalTimeSamples();
                animClipMap[animName] = newClip;
            }
        }
        public void runDecoder(Stream byteStream, bool loadMultiCore)
        {
            var stopWatch = new Stopwatch();

            stopWatch.Start();

            var newReader = new MiniMessagePacker();

            fileData = (object[])newReader.Unpack(byteStream);

            stopWatch.Stop();
#if (CREATURE_PACK_DEBUG)
            UnityEngine.Debug.Log("---Data Decode time: " + stopWatch.ElapsedMilliseconds);
#endif
            stopWatch.Reset();

            headerList          = (object[])fileData[getBaseOffset()];
            animPairsOffsetList = (object[])fileData[getAnimPairsListOffset()];

            // init basic points and topology structure
            indices = new uint[getNumIndices()];
            points  = new float[getNumPoints()];
            uvs     = new float[getNumUvs()];

            updateIndices(getBaseIndicesOffset());
            updatePoints(getBasePointsOffset());
            updateUVs(getBaseUvsOffset());

            fillDeformRanges();

            stopWatch.Start();

            if (loadMultiCore)
            {
                finalAllPointSamplesThreaded();
            }
            else
            {
                finalAllPointSamples();
            }

            stopWatch.Stop();
#if (CREATURE_PACK_DEBUG)
            UnityEngine.Debug.Log("---Data Packaging time: " + stopWatch.ElapsedMilliseconds);
#endif

            // init Animation Clip Map
            for (int i = 0; i < getAnimationNum(); i++)
            {
                var curOffsetPair = getAnimationOffsets(i);

                var animName = (string)(fileData[curOffsetPair.first]);
                var k        = curOffsetPair.first;
                k++;
                var newClip = new CreaturePackAnimClip(k, fileData);

                while (k < curOffsetPair.second)
                {
                    int cur_time = (int)(float)(fileData[k]);
                    newClip.addTimeSample(cur_time, (int)k);

                    k += 4;
                }

                newClip.finalTimeSamples();
                animClipMap[animName] = newClip;
            }
        }