Cainiao learns ogre and tianlong Babu 7: Frame Animation data format, fixed Key Frame

Source: Internet
Author: User

Prepare to crack the frame data format and open it with UE. It is obvious that the words serializer_v1.10 are written using the serializer class.

It should also be skeletonserializer. To verify the code, ue should look at the binary code. First, let's look at several file block enumerations of this class.

Enum skeletonchunkid {
Skeleton_header = 0x1000,
Skeleton_bone = 0x2000,

Skeleton_bone_parent = 0x3000,

Skeleton_animation = 0X4000,

Skeleton_animation_track = 0x4100,

Skeleton_animation_track_keyframe = 0x4110,
Skeleton_animation_link = 0x5000

};

 

If such a block exists in the file, it indicates that the guess is correct.

You can find 00 10, 00 40, and so on by using UE. It indicates that it is a skeleton file, which is converted into XML:

 

Keyframes is missing when the data is loaded. The original frame type defined by tianlong is 0x4120 rather than 0x4110.

However, the content stored in the file should be the same. If you look for it online, you have provided the relevant functions:

Add the keyframe type customized by tianlong. This type should be used to reduce memory usage.
Skeleton_animation_track_keyframe_optimize 0x4120 (16672)

In ogreskeletonserializer. cpp, modify:
Void skeletonserializer: readanimationtrack (datastreamptr & stream, animation * anim, skeleton * pskel)
{
//...
// Keep looking for nested keyframes
If (! Stream-> EOF ())
{
Unsigned short streamid = readchunk (Stream );
While (streamid = skeleton_animation_track_keyframe |
Streamid = skeleton_animation_track_keyframe_optimize)
&&! Stream-> EOF ())
{
If (streamid = skeleton_animation_track_keyframe_optimize)
{
// Add code
Unsigned short Len;
Unsigned short flags;
Readshorts (stream, & Len, 1 );
Readshorts (stream, & flags, 1 );

Float time;
For (INT I = 0; I <Len; I + = 1)
{
Readfloats (stream, & time, 1 );
Transformkeyframe * kf = ptrack-> createnodekeyframe (time );

Quaternion rot = quaternion: identity;
If (flags & 1)
{
Readobject (stream, rot );
}
KF-> setrotation (ROT );

Vector3 trans = vector3: zero;
If (flags & 2)
{
Readobject (stream, trans );
}
KF-> settranslate (trans );

// The popular parsing code on the Internet. This part is missing, leading to incorrect animation parsing, such as the swing of Liu Zhi.
// Staticentity in many scenarios contains the willow skeleton Animation
Vector3 scale = vector3: unit_scale;
If (flags & 4)
{
Readobject (stream, scale );
}
KF-> setscale (scale );
}
}
Else
{
Readkeyframe (stream, ptrack, pskel );
}

If (! Stream-> EOF ())
{
// Get next stream
Streamid = readchunk (Stream );
}
}

If (! Stream-> EOF ())
{
// Backpedal back to start of this stream if we 've found a non-keyframe
Stream-> SKIP (-stream_overhead_size );
}
//...
}

 

Modifying the source code of ogre is a little in violation of the open source spirit... I wrote a class to load it. The data is normal now ,:

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.