Example #1
0
        public static void EncodeCHR0Keyframes(KeyframeCollection kf, VoidPtr entryAddress, VoidPtr dataAddress)
        {
            AnimationCode code = kf._evalCode;
            //VoidPtr dataAddr = addr + 8;

            CHR0Entry *header = (CHR0Entry *)entryAddress;

            header->_code         = (uint)code._data;
            header->_stringOffset = 0;

            //entryAddress += 8;
            bint *pOffset = (bint *)entryAddress + 2;

            //Write values/offset and encode groups
            for (int i = 0, x = 0; i < 3; i++, x += 3)
            {
                if (code.GetExists(i))
                {
                    AnimDataFormat format = code.GetFormat(i);
                    if ((i == 0) && (code.GetIsIsotropic(i)))
                    {
                        if (code.GetIsFixed(2))
                        {
                            *(bfloat *)pOffset++ = kf._keyRoots[2]._next._value;
                        }
                        else
                        {
                            *pOffset++ = (int)(dataAddress - entryAddress);
                            dataAddress += EncodeEntry(x, format, kf, dataAddress);
                        }
                    }
                    else
                    {
                        for (int y = 0, z = x; y < 3; y++, z++)
                        {
                            if (code.GetIsFixed(z))
                            {
                                *(bfloat *)pOffset++ = kf._keyRoots[z]._next._value;
                            }
                            else
                            {
                                *pOffset++ = (int)(dataAddress - entryAddress);
                                dataAddress += EncodeEntry(z, format, kf, dataAddress);
                            }
                        }
                    }
                }
            }
        }