void UInterpTrackAkAudioEvent::PreviewUpdateTrack(float NewPosition, UInterpTrackInst* TrInst) { UInterpGroupInst* GrInst = CastChecked<UInterpGroupInst>( TrInst->GetOuter() ); AMatineeActor* MatineeActor = CastChecked<AMatineeActor>( GrInst->GetOuter() ); UInterpTrackInstAkAudioEvent* AkEventInst = CastChecked<UInterpTrackInstAkAudioEvent>( TrInst ); UInterpGroup* Group = CastChecked<UInterpGroup>( GetOuter() ); UInterpData* IData = CastChecked<UInterpData>( Group->GetOuter() ); // Dont play sounds unless we are preview playback (ie not scrubbing). bool bJump = !(MatineeActor->bIsPlaying); UpdateTrack(NewPosition, TrInst, bJump); }
void UMatineeTrackEventHelper::PostCreateKeyframe( UInterpTrack *Track, int32 KeyIndex ) const { UInterpTrackEvent *EventTrack = CastChecked<UInterpTrackEvent>(Track); FEventTrackKey& NewEventKey = EventTrack->EventTrack[ KeyIndex ]; NewEventKey.EventName = KeyframeAddDataName; // Update AllEventNames array now we have given it a name UInterpGroup* Group = CastChecked<UInterpGroup>( EventTrack->GetOuter() ); UInterpData* IData = CastChecked<UInterpData>( Group->GetOuter() ); IData->UpdateEventNames(); KeyframeAddDataName = NAME_None; }
bool UCameraAnim::CreateFromInterpGroup(class UInterpGroup* SrcGroup, class AMatineeActor* InMatineeActor) { // assert we're controlling a camera actor #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) { UInterpGroupInst* GroupInst = InMatineeActor ? InMatineeActor->FindFirstGroupInst(SrcGroup) : NULL; if (GroupInst) { check( GroupInst->GetGroupActor()->IsA(ACameraActor::StaticClass()) ); } } #endif // copy length information AnimLength = (InMatineeActor && InMatineeActor->MatineeData) ? InMatineeActor->MatineeData->InterpLength : 0.f; UInterpGroup* OldGroup = CameraInterpGroup; if (CameraInterpGroup != SrcGroup) { // copy the source interp group for use in the CameraAnim // @fixme jf: fixed this potentially creating an object of UInterpGroup and raw casting it to InterpGroupCamera. No source data in UE4 to test though. CameraInterpGroup = Cast<UInterpGroupCamera>(StaticDuplicateObject(SrcGroup, this, NAME_None, RF_AllFlags, UInterpGroupCamera::StaticClass())); if (CameraInterpGroup) { // delete the old one, if it exists if (OldGroup) { OldGroup->MarkPendingKill(); } // success! return true; } else { // creation of new one failed somehow, restore the old one CameraInterpGroup = OldGroup; } } else { // no need to perform work above, but still a "success" case return true; } // failed creation return false; }
UInterpGroup* FAssetTypeActions_CameraAnim::CreateInterpGroup(UCameraAnim* InCameraAnim, FCameraPreviewInfo& PreviewInfo) { check(InCameraAnim); CreatePreviewPawn(InCameraAnim, PreviewInfo.PawnClass, PreviewInfo.Location, PreviewInfo.Rotation); PreviewInfo.PawnInst = PreviewPawn.Get(); if (PreviewInfo.PawnInst) { // create InterpGroup so that we can play animation to this pawn check(PreviewMatineeActor.Get()->MatineeData); UInterpGroup* NewGroup = ConstructObject<UInterpGroup>(UInterpGroup::StaticClass(), PreviewMatineeActor.Get()->MatineeData, NAME_None, RF_Transient); NewGroup->GroupName = FName(TEXT("Preview Pawn")); NewGroup->EnsureUniqueName(); PreviewMatineeActor.Get()->MatineeData->InterpGroups.Add(NewGroup); // now add group inst UInterpGroupInst* NewGroupInst = ConstructObject<UInterpGroupInst>(UInterpGroupInst::StaticClass(), PreviewMatineeActor.Get(), NAME_None, RF_Transient); // Initialise group instance, saving ref to actor it works on. NewGroupInst->InitGroupInst(NewGroup, PreviewInfo.PawnInst); const int32 NewGroupInstIndex = PreviewMatineeActor.Get()->GroupInst.Add(NewGroupInst); //Link group with actor PreviewMatineeActor.Get()->InitGroupActorForGroup(NewGroup, PreviewInfo.PawnInst); // Now time to add AnimTrack so that we can play animation int32 AnimTrackIndex = INDEX_NONE; // add anim track but do not use addtotrack function that does too many things // Construct track and track instance objects. UInterpTrackAnimControl* AnimTrack = ConstructObject<UInterpTrackAnimControl>( UInterpTrackAnimControl::StaticClass(), NewGroup, NAME_None, RF_Transient ); check(AnimTrack); NewGroup->InterpTracks.Add(AnimTrack); // use config anim slot AnimTrack->SlotName = FName(*GConfig->GetStr(TEXT("MatineePreview"), TEXT("DefaultAnimSlotName"), GEditorIni)); UInterpTrackInst* NewTrackInst = ConstructObject<UInterpTrackInst>( AnimTrack->TrackInstClass, NewGroupInst, NAME_None, RF_Transient ); check(NewTrackInst); NewGroupInst->TrackInst.Add(NewTrackInst); // Initialize track, giving selected object. NewTrackInst->InitTrackInst(AnimTrack); // Save state into new track before doing anything else (because we didn't do it on ed mode change). NewTrackInst->SaveActorState(AnimTrack); check(NewGroupInst->TrackInst.Num() > 0); // add default anim curve weights to be 1 int32 KeyIndex = AnimTrack->CreateNewKey(0.0f); AnimTrack->SetKeyOut(0, KeyIndex, 1.0f); if(PreviewInfo.AnimSeq != NULL) { KeyIndex = AnimTrack->AddKeyframe(0.0f, NewGroupInst->TrackInst[0], CIM_Linear); FAnimControlTrackKey& NewSeqKey = AnimTrack->AnimSeqs[KeyIndex]; NewSeqKey.AnimSeq = PreviewInfo.AnimSeq; } PreviewPawn = PreviewInfo.PawnInst; return NewGroup; } return NULL; }