Exemplo n.º 1
0
        public static void EncodeSRT0Keyframes(KeyframeCollection kf, VoidPtr entryAddress, VoidPtr dataAddress, SRT0Code code)
        {
            SRT0TextureEntry *header = (SRT0TextureEntry *)entryAddress;

            header->Code = code;

            bint *pOffset = (bint *)entryAddress + 1;

            int index = 0;

            //Write values/offset and encode groups
            for (int type = 0; type < 3; type++)
            {
                bool has = false;
                switch (type)
                {
                case 0: has = !code.NoScale; break;

                case 1: has = !code.NoRotation; break;

                case 2: has = !code.NoTranslation; break;
                }
                for (int axis = 0; axis < (type == 1 ? 1 : 2); axis++, index++)
                {
                    if (has)
                    {
                        if (code.ScaleIsotropic && type == 0)
                        {
                            if (axis == 0)
                            {
                                if (code.FixedScaleX)
                                {
                                    *(bfloat *)pOffset++ = kf._keyArrays[0]._keyRoot._next._value;
                                }
                                else
                                {
                                    *pOffset = (int)dataAddress - (int)pOffset; pOffset++;
                                    dataAddress += EncodeEntry(index, AnimDataFormat.I12, kf, dataAddress);
                                }
                            }
                        }
                        else
                        {
                            //This gets the fixed bit. Same order, so it can be indexed
                            if (code._data[5 + index])
                            {
                                *(bfloat *)pOffset++ = kf._keyArrays[index]._keyRoot._next._value;
                            }
                            else
                            {
                                *pOffset = (int)dataAddress - (int)pOffset; pOffset++;
                                dataAddress += EncodeEntry(index, AnimDataFormat.I12, kf, dataAddress);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static KeyframeCollection DecodeSRT0Keyframes(SRT0TextureEntry *entry, int numFrames)
        {
            KeyframeCollection kf = new KeyframeCollection(5, numFrames, 1, 1);

            if (entry == null)
            {
                return(kf);
            }

            bfloat * sPtr = (bfloat *)entry->Data;
            SRT0Code code = entry->Code;

            if (!code.NoScale)
            {
                if (code.ScaleIsotropic)
                {
                    if (code.FixedScaleX)
                    {
                        kf[0, 0, 1] = *sPtr++;
                    }
                    else
                    {
                        DecodeFrames(kf, (VoidPtr)sPtr + *(buint *)sPtr++, AnimDataFormat.I12, 0, 1);
                    }
                }
                else
                {
                    if (code.FixedScaleX)
                    {
                        kf[0, 0] = *sPtr++;
                    }
                    else
                    {
                        DecodeFrames(kf, (VoidPtr)sPtr + *(buint *)sPtr++, AnimDataFormat.I12, 0);
                    }

                    if (code.FixedScaleY)
                    {
                        kf[0, 1] = *sPtr++;
                    }
                    else
                    {
                        DecodeFrames(kf, (VoidPtr)sPtr + *(buint *)sPtr++, AnimDataFormat.I12, 1);
                    }
                }
            }

            if (!code.NoRotation)
            {
                if (code.FixedRotation)
                {
                    kf[0, 2] = *sPtr++;
                }
                else
                {
                    DecodeFrames(kf, (VoidPtr)sPtr + *(buint *)sPtr++, AnimDataFormat.I12, 2);
                }
            }

            if (!code.NoTranslation)
            {
                if (code.FixedX)
                {
                    kf[0, 3] = *sPtr++;
                }
                else
                {
                    DecodeFrames(kf, (VoidPtr)sPtr + *(buint *)sPtr++, AnimDataFormat.I12, 3);
                }

                if (code.FixedY)
                {
                    kf[0, 4] = *sPtr++;
                }
                else
                {
                    DecodeFrames(kf, (VoidPtr)sPtr + *(buint *)sPtr++, AnimDataFormat.I12, 4);
                }
            }

            return(kf);
        }
Exemplo n.º 3
0
        public static KeyframeCollection DecodeSRT0Keyframes(SRT0TextureEntry *entry, int numFrames)
        {
            KeyframeCollection kf   = new KeyframeCollection(numFrames);
            bfloat *           sPtr = (bfloat *)entry->Data;
            SRT0Code           code = entry->Code;

            if (!code.NoScale)
            {
                if (code.ScaleIsotropic)
                {
                    if (code.FixedScaleX)
                    {
                        kf[KeyFrameMode.ScaleXYZ, 0] = *sPtr++;
                    }
                    else
                    {
                        DecodeSRT0Frames(kf, (VoidPtr)sPtr + *(buint *)sPtr++, KeyFrameMode.ScaleXYZ);
                    }
                }
                else
                {
                    if (code.FixedScaleX)
                    {
                        kf[KeyFrameMode.ScaleX, 0] = *sPtr++;
                    }
                    else
                    {
                        DecodeSRT0Frames(kf, (VoidPtr)sPtr + *(buint *)sPtr++, KeyFrameMode.ScaleX);
                    }
                    if (code.FixedScaleY)
                    {
                        kf[KeyFrameMode.ScaleY, 0] = *sPtr++;
                    }
                    else
                    {
                        DecodeSRT0Frames(kf, (VoidPtr)sPtr + *(buint *)sPtr++, KeyFrameMode.ScaleY);
                    }
                }
            }
            if (!code.NoRotation)
            {
                if (code.FixedRotation)
                {
                    kf[KeyFrameMode.RotX, 0] = *sPtr++;
                }
                else
                {
                    DecodeSRT0Frames(kf, (VoidPtr)sPtr + *(buint *)sPtr++, KeyFrameMode.RotX);
                }
            }

            if (!code.NoTranslation)
            {
                if (code.FixedX)
                {
                    kf[KeyFrameMode.TransX, 0] = *sPtr++;
                }
                else
                {
                    DecodeSRT0Frames(kf, (VoidPtr)sPtr + *(buint *)sPtr++, KeyFrameMode.TransX);
                }
                if (code.FixedY)
                {
                    kf[KeyFrameMode.TransY, 0] = *sPtr++;
                }
                else
                {
                    DecodeSRT0Frames(kf, (VoidPtr)sPtr + *(buint *)sPtr++, KeyFrameMode.TransY);
                }
            }

            return(kf);
        }
Exemplo n.º 4
0
        public static void EncodeSRT0Keyframes(KeyframeCollection kf, VoidPtr entryAddress, VoidPtr dataAddress)
        {
            SRT0Code code = kf._texEvalCode;

            SRT0TextureEntry *header = (SRT0TextureEntry *)entryAddress;

            header->_code = code.data._data;

            bint *pOffset = (bint *)entryAddress + 1;

            int r = 0;

            //Write values/offset and encode groups
            for (int type = 0; type < 3; type++)
            {
                r = type * 3; //Increment to next
                bool has = false;
                switch (type)
                {
                case 0: has = !code.NoScale; break;

                case 1: has = !code.NoRotation; break;

                case 2: has = !code.NoTranslation; break;
                }
                for (int axis = 0; axis < (type == 1 ? 1 : 2); axis++)
                {
                    if (has)
                    {
                        if (code.ScaleIsotropic && type == 0)
                        {
                            if (axis == 0)
                            {
                                if (code.FixedScaleX)
                                {
                                    *(bfloat *)pOffset++ = kf._keyRoots[0]._next._value;
                                }
                                else
                                {
                                    *pOffset = (int)(dataAddress - pOffset); pOffset++;
                                    dataAddress += EncodeEntry(r + axis, AnimDataFormat.I12, kf, dataAddress);
                                }
                            }
                        }
                        else
                        {
                            bool fix = false;
                            switch (type)
                            {
                            case 0:
                                switch (axis)
                                {
                                case 0:
                                    fix = code.FixedScaleX;
                                    break;

                                case 1:
                                    fix = code.FixedScaleY;
                                    break;
                                }
                                break;

                            case 1:
                                fix = code.FixedRotation;
                                break;

                            case 2:
                                switch (axis)
                                {
                                case 0:
                                    fix = code.FixedX;
                                    break;

                                case 1:
                                    fix = code.FixedY;
                                    break;
                                }
                                break;
                            }

                            if (fix)
                            {
                                *(bfloat *)pOffset++ = kf._keyRoots[r + axis]._next._value;
                            }
                            else
                            {
                                *pOffset = (int)(dataAddress - pOffset); pOffset++;
                                dataAddress += EncodeEntry(r + axis, AnimDataFormat.I12, kf, dataAddress);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        public static void EncodeSRT0Keyframes(KeyframeCollection kf, VoidPtr entryAddress, VoidPtr dataAddress)
        {
            SRT0Code code = kf._texEvalCode;

            SRT0TextureEntry *header = (SRT0TextureEntry *)entryAddress;

            header->_code = code.data;

            bint *pOffset = (bint *)entryAddress + 1;

            int r = 0;

            //Write values/offset and encode groups
            for (int type = 0; type < 3; type++)
            {
                r = type * 3; //Increment to next
                for (int axis = 0; axis < (type == 1 ? 1 : 2); axis++)
                {
                    int loc = 0;
                    if (type == 2)
                    {
                        loc = 2;
                    }
                    else if (type == 1)
                    {
                        loc = 1;
                    }
                    else if (type == 0 && axis == 0)
                    {
                        loc = 3;
                    }
                    else
                    {
                        loc = 0;
                    }

                    int fix = 0;
                    if (type == 0)
                    {
                        fix = axis;
                    }
                    else if (type == 1)
                    {
                        fix = 2;
                    }
                    else if (type == 2)
                    {
                        fix = 3 + axis;
                    }

                    if (code.GetHas(loc))
                    {
                        if (code.GetFixed(fix))
                        {
                            *(bfloat *)pOffset++ = kf._keyRoots[r + axis]._next._value;
                        }
                        else
                        {
                            *pOffset = (int)(dataAddress - pOffset); pOffset++;
                            dataAddress += EncodeEntry(r + axis, AnimDataFormat.I12, kf, dataAddress);
                        }
                    }
                }
            }
        }