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); } } } } } }
public static KeyframeCollection DecodeCHR0Keyframes(CHR0Entry *entry, int numFrames) { KeyframeCollection kf = new KeyframeCollection(9, numFrames, 1, 1, 1); if (entry == null) { return(kf); } bfloat * sPtr = (bfloat *)entry->Data; AnimationCode code = entry->Code; AnimDataFormat format; if (code.HasScale) { format = code.ScaleDataFormat; if (code.IsScaleIsotropic) { if (code.IsScaleZFixed) { kf[0, 0, 1, 2] = *sPtr++; } else { DecodeFrames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, 0, 1, 2); } } else { if (code.IsScaleXFixed) { kf[0, 0] = *sPtr++; } else { DecodeFrames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, 0); } if (code.IsScaleYFixed) { kf[0, 1] = *sPtr++; } else { DecodeFrames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, 1); } if (code.IsScaleZFixed) { kf[0, 2] = *sPtr++; } else { DecodeFrames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, 2); } } } if (code.HasRotation) { format = code.RotationDataFormat; if (code.IsRotationIsotropic) { if (code.IsRotationZFixed) { kf[0, 3, 4, 5] = *sPtr++; } else { DecodeFrames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, 3, 4, 5); } } else { if (code.IsRotationXFixed) { kf[0, 3] = *sPtr++; } else { DecodeFrames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, 3); } if (code.IsRotationYFixed) { kf[0, 4] = *sPtr++; } else { DecodeFrames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, 4); } if (code.IsRotationZFixed) { kf[0, 5] = *sPtr++; } else { DecodeFrames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, 5); } } } if (code.HasTranslation) { format = code.TranslationDataFormat; if (code.IsTranslationIsotropic) { if (code.IsTranslationZFixed) { kf[0, 6, 7, 8] = *sPtr++; } else { DecodeFrames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, 6, 7, 8); } } else { if (code.IsTranslationXFixed) { kf[0, 6] = *sPtr++; } else { DecodeFrames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, 6); } if (code.IsTranslationYFixed) { kf[0, 7] = *sPtr++; } else { DecodeFrames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, 7); } if (code.IsTranslationZFixed) { kf[0, 8] = *sPtr++; } else { DecodeFrames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, 8); } } } return(kf); }
protected internal virtual void PostProcess(VoidPtr dataAddress, StringTable stringTable) { CHR0Entry *header = (CHR0Entry *)dataAddress; header->ResourceStringAddress = stringTable[Name] + 4; }
public static KeyframeCollection DecodeCHR0Keyframes(CHR0Entry *entry, int numFrames) { KeyframeCollection kf = new KeyframeCollection(numFrames); bfloat * sPtr = (bfloat *)entry->Data; AnimationCode code = entry->Code; AnimDataFormat format; if (code.HasScale) { format = code.ScaleDataFormat; if (code.IsScaleIsotropic) { if (code.IsScaleZFixed) { kf[KeyFrameMode.ScaleXYZ, 0] = *sPtr++; } else { DecodeCHR0Frames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, KeyFrameMode.ScaleXYZ); } } else { if (code.IsScaleXFixed) { kf[KeyFrameMode.ScaleX, 0] = *sPtr++; } else { DecodeCHR0Frames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, KeyFrameMode.ScaleX); } if (code.IsScaleYFixed) { kf[KeyFrameMode.ScaleY, 0] = *sPtr++; } else { DecodeCHR0Frames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, KeyFrameMode.ScaleY); } if (code.IsScaleZFixed) { kf[KeyFrameMode.ScaleZ, 0] = *sPtr++; } else { DecodeCHR0Frames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, KeyFrameMode.ScaleZ); } } } if (code.HasRotation) { format = code.RotationDataFormat; if (code.IsRotationIsotropic) { if (code.IsRotationZFixed) { kf[KeyFrameMode.RotXYZ, 0] = *sPtr++; } else { DecodeCHR0Frames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, KeyFrameMode.RotXYZ); } } else { if (code.IsRotationXFixed) { kf[KeyFrameMode.RotX, 0] = *sPtr++; } else { DecodeCHR0Frames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, KeyFrameMode.RotX); } if (code.IsRotationYFixed) { kf[KeyFrameMode.RotY, 0] = *sPtr++; } else { DecodeCHR0Frames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, KeyFrameMode.RotY); } if (code.IsRotationZFixed) { kf[KeyFrameMode.RotZ, 0] = *sPtr++; } else { DecodeCHR0Frames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, KeyFrameMode.RotZ); } } } if (code.HasTranslation) { format = code.TranslationDataFormat; if (code.IsTranslationIsotropic) { if (code.IsTranslationZFixed) { kf[KeyFrameMode.TransXYZ, 0] = *sPtr++; } else { DecodeCHR0Frames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, KeyFrameMode.TransXYZ); } } else { if (code.IsTranslationXFixed) { kf[KeyFrameMode.TransX, 0] = *sPtr++; } else { DecodeCHR0Frames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, KeyFrameMode.TransX); } if (code.IsTranslationYFixed) { kf[KeyFrameMode.TransY, 0] = *sPtr++; } else { DecodeCHR0Frames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, KeyFrameMode.TransY); } if (code.IsTranslationZFixed) { kf[KeyFrameMode.TransZ, 0] = *sPtr++; } else { DecodeCHR0Frames(kf, (VoidPtr)entry + *(buint *)sPtr++, format, KeyFrameMode.TransZ); } } } return(kf); }