当前位置:网站首页>UE4 source code reading_ Bone model and animation system_ Animation node
UE4 source code reading_ Bone model and animation system_ Animation node
2022-07-03 08:25:00 【_ lazycat】
0. Write it at the front
This article is a collection of personal learning notes , If there is a mistake , I hope you can point out .
1. Animation play :FAnimNode_SequencePlayer
Related parameters :
- UAnimSequenceBase Sequence: Animation clips
- PlayRateBasis: Playback rate base , By PlayRate except
- PlayRate: Playback rate , It could be negative , Indicates reverse broadcast
- PlayRateScaleBiasClamp: Yes PlayRate Extra treatment ( The zoom , Offset and Clamp), In addition Basis Post operation
- StartPosition: The starting position of the animation node
- bLoopAnimation: Cycle animation
1.1 UAnimSequence
Inherited from UAnimSequenceBase, Save the key frame data of the animation sequence , And contains several orbital data
1. The main data :
TArray RawAnimationData; Raw uncompressed animation keyframe data
TArray SourceRawAnimationData; RawAnimationData Copy of , It is only modified during initialization
Struct FRawAnimSequenceTrack: Single key frame data , Including translation 、 Rotate and scale .TArray<FVector> PosKeys; TArray<FQuat> RotKeys; TArray<FVector> ScaleKeys;
2. Resource settings
a. Compression Set: Animation compression settings
See animation compression for details

b. Addtive Set: Overlay settings 
- TEnumAsByte AdditiveAnimType; The type of superimposed animation
AAT_None
AAT_LocalSpaceBase Based on local joint space
AAT_RotationOffsetMeshSpace Rotation is based on model space , Translation is based on local joint space - TEnumAsByte RefPoseType; Types of basic postures
ABPT_None UMETA(DisplayName = “None”),
ABPT_RefPose UMETA(DisplayName = “Skeleton Reference Pose”),
ABPT_AnimScaled UMETA(DisplayName = “Selected animation scaled”),
ABPT_AnimFrame UMETA(DisplayName = “Selected animation frame”),
c. RootMotion Set
3. Main function 【TODO】
- GetAnimationPose
- GetBonePose
- AnimCompressionTypes:: DecompressPose
- GetBonePose_Additive
2. RootMotion
2.1 RootMotionMontage
UAnimMontage:
1.ExtractRootMotionFromTrackRange: from Montage Extract within a certain range in the animation track RootMotion data
ExtractRootMotionFromTrack:
StartTrackPosition、EndTrackPosition:
Extract from the specified start time to the end time Montage Internal RootMotion data , Last output to FRootMotionMovementParams objectGetRootMotionExtractionStepsForTrackRange:
Due to a Montage The animation track of may consist of multiple animation sequences , So it is extracted in the way of animation sequence by animation RootMotion data , There is TArray in .
FRootMotionExtractionStep: There is an animation sequence (UAnimSequence) And extraction RootMotion The range of data ( Start position and end position )
You may encounter loopback playback (StartTrackPosition>EndTrackPosition), It needs to be extracted in the correct order .
If it is loopback , When the animation track has multiple animation sequences, it needs to traverse from the last bit forward .
Otherwise, it will traverse the animation sequence list in order .
FAnimSegment::GetRootMotionExtractionStepsForTrackRange
Check whether the start time and end time fall within the range of the animation sequence , If so, add Step listExtractRootMotionFromTrack:
- After calculating Step After the animation collection , Traverse Step
- Judge whether the animation is turned on RootMotion.
- For opening RootMotion Of Step(AnimSequence)
call AnimSequence->ExtractRootMotionFromRange Extract displacement data
FTransform StartTransform = ExtractRootTrackTransform(StartTrackPosition, NULL);
FTransform EndTransform = ExtractRootTrackTransform(EndTrackPosition, NULL);
=》UAnimSequence::GetBoneTransform
=》AnimEncodingLegacyBase::GetBoneAtom Finally, call the interface to extract
Then the extracted displacement data (DeltaTransform) Deposit in FRootMotionMovementParams In the object
RootMotion.Accumulate(DeltaTransform), This function does not input weights , direct 1 Than 1 The final displacement is fused
2.2 RootMotion Anim
FAnimInstanceProxy::TickAssetPlayerInstances:
When RootMotion The model is RootMotionFromEverything when , In this function , According to the weight RootMotion Data extraction to FRootMotionMovementParams In the object
2.3 RootMotion Application and synchronization
See mobile synchronization .
3. Animation overlay :FAnimNode_ApplyAdditive
1. The main variable :
FPoseLink Base: Connect base Animation node
FPoseLink Additive: Connect overlay animation nodes
float Alpha: Overlay weights
2. Main interface :
- FAnimNode_ApplyAdditive::Evaluate_AnyThread
- obtain Base Two animation poses of node and overlay node
Base.Evaluate(Output);
const bool bExpectsAdditivePose = true;
FPoseContext AdditiveEvalContext(Output, bExpectsAdditivePose);
Additive.Evaluate(AdditiveEvalContext); - Calculate the resulting pose after superposition
FAnimationRuntime::AccumulateAdditivePose
- obtain Base Two animation poses of node and overlay node
- FAnimationRuntime::AccumulateAdditivePose
- According to the type of superposition , Choose different interface calculation
Local space superposition :AccumulateLocalSpaceAdditivePoseInternal
Grid volume space overlay :AccumulateMeshSpaceRotationAdditiveToLocalPoseInternal - In case of curve animation
BaseCurve.Accumulate(AdditiveCurve, Weight);
- According to the type of superposition , Choose different interface calculation
- FAnimationRuntime::AccumulateLocalSpaceAdditivePoseInternal
- Traverse BasePose Every bone of :
According to the superposition weight , Calculate the superposition of each bone
The superposition weight is 1 when :
BasePose[BoneIndex].AccumulateWithAdditiveScale(AdditivePose[BoneIndex], VBlendWeight);
The superposition weight is less than 1 when :
FTransform Additive = AdditivePose[BoneIndex];
FTransform::BlendFromIdentityAndAccumulate(BasePose[BoneIndex], Additive, VBlendWeight);
- Traverse BasePose Every bone of :
- AccumulateWithAdditiveScale: Calculate the superimposed Rotation、Translation、Scale data
Atom: Pose data to be superimposed- Deal with rotation : The superposition of rotations , Multiply by quaternion :
const VectorRegister BlendedRotation = VectorMultiply(Atom.Rotation, BlendWeight.Value);
Rotation = VectorQuaternionMultiply2(BlendedRotation, Rotation); - Process translation : Add vectors
const VectorRegister BlendedTranslation = VectorMultiply(Atom.Translation, BlendWeight.Value);
Translation = VectorAdd(Translation, BlendedTranslation); - Dealing with scaling :
Scale3D = Base_Scale3D * (Default + (Atom_Scale3D * wight))
- Deal with rotation : The superposition of rotations , Multiply by quaternion :
- BlendFromIdentityAndAccumulate: It is also calculated after superposition Rotation、Translation、Scale data
- The translation and zoom processing are consistent with the above
Although it uses Lerp, but (0,0,0) and Atom Press Weight Do interpolation , It's actually Atom * Weight Result
- Processing of rotation

- The translation and zoom processing are consistent with the above
4. Animation blending :BlendSpace
边栏推荐
- Basic operation and process control
- Editor Extensions
- One dimensional array two dimensional array (sort Max insert sort)
- redis集群系列四
- 图像处理8-CNN图像分类
- the installer has encountered an unexpected error installing this package
- Osgearth target selection
- MySQL 8
- Haproxy+kept cluster setup 02
- Transfinite hacker cognition
猜你喜欢

Oracle insert single quotation mark
![[set theory] order relation (hastu example | divisive relation hastu | inclusive relation hastu | refinement relation hastu)](/img/de/1c75b5e7ed79aca47462de365428a7.jpg)
[set theory] order relation (hastu example | divisive relation hastu | inclusive relation hastu | refinement relation hastu)
![P1596 [USACO10OCT]Lake Counting S](/img/a7/07a84c93ee476788d9443c0add808b.png)
P1596 [USACO10OCT]Lake Counting S

Puhua PLM empowers the whole scene product lifecycle management and helps the enterprise digital transformation of the main line of products

A tunnel to all ports of the server

About the problem that the editor and the white screen of the login interface cannot be found after the location of unityhub is changed

Mxone Pro adaptive 2.0 film and television template watermelon video theme apple cmsv10 template

Use of ue5 QRcode plug-in

Xlua task list youyou

Gradle's method of dynamically modifying APK package name
随机推荐
MySQL containerization (1) docker installation MySQL
Data analysis exercises
Osgearth north arrow display
Xlua task list youyou
Oracle insert single quotation mark
the installer has encountered an unexpected error installing this package
Markdown directory generation
Chain length value
unity2019_ Input management
C#课程设计之员工信息管理系统
[end of 2021] National Meteorological Short Video (Kwai, Tiktok) influence list in December
Advanced OSG collision detection
Cloudcompare learning (1) - cloudcompare compilation and common plug-in implementation
matlab神經網絡所有傳遞函數(激活函數)公式詳解
Basic operation and process control
Kunlunbase meetup is waiting for you!
About Wireshark's unsuccessful installation of npcap
Intersectionpicker in osgearth
Mutual call between Lua and C #
P1596 [USACO10OCT]Lake Counting S