当前位置:网站首页>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
边栏推荐
- Data analysis exercises
- Osgconv tool usage
- [usaco12mar]cows in a skyscraper g (state compression DP)
- Compilation error: "not in executable format: file format not recognized"“
- Markdown directory generation
- Unity2019_ Natural ambient light_ Sky box
- Encoding and decoding of golang URL
- [cloud native] introduction and use of feign of microservices
- Xlua task list youyou
- Clion toolchains are not configured configure disable profile problem solving
猜你喜欢

Flex flexible box layout

the installer has encountered an unexpected error installing this package

Wpf: solve the problem that materialdesign:dialoghost cannot be closed

MAE

C#课程设计之员工信息管理系统

Constraintlayout's constraintset dynamically modifies constraints

Clion toolchains are not configured configure disable profile problem solving

Three characteristics
![[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)

图像处理8-CNN图像分类
随机推荐
了解小程序的笔记 2022/7/3
[end of 2021] National Meteorological Short Video (Kwai, Tiktok) influence list in December
[updating] wechat applet learning notes_ three
Golang's range
Mxone Pro adaptive 2.0 film and television template watermelon video theme apple cmsv10 template
Cesium for unreal quick start - simple scenario configuration
What does (+) in Oracle mean
Osganimation library parsing
Cloudcompare learning (1) - cloudcompare compilation and common plug-in implementation
MySQL containerization (1) docker installation MySQL
Intersectionpicker in osgearth
Kunlunbase meetup is waiting for you!
详解sizeof、strlen、指针和数组等组合题
Ue5 opencv plug-in use
图像处理8-CNN图像分类
Abstract classes and interfaces
Conversion between golang JSON format and structure
MAE
數據庫應用技術課程設計之商城管理系統
Maxcompute string splitting function -split_ PART