Advertisement
Guest User

AnimNode_NameOfYourNode.cpp

a guest
Jan 9th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.44 KB | None | 0 0
  1. // Copyright 1998-2013 Epic Games, Inc. All Rights Reserved.
  2.  
  3. #include "Sandbox.h"
  4. #include "AnimNode_NameOfYourNode.h"
  5.  
  6. //#include "AnimationRuntime.h"
  7.  
  8. FAnimNode_NameOfYourNode::FAnimNode_NameOfYourNode()
  9.     : FAnimNode_Base()
  10.     , SampleFloat(128.333)
  11. {
  12.     WorldIsGame = false;
  13. }
  14.  
  15. void FAnimNode_NameOfYourNode::Initialize(const FAnimationInitializeContext & Context)
  16. {
  17.     //Init the Inputs
  18.     BasePose.Initialize(Context);
  19.     OtherPose.Initialize(Context);
  20.    
  21.     //Get the Actor Owner
  22.     OwningActor = Context.AnimInstance-> GetSkelMeshComponent()->GetOwner();
  23.    
  24.     //Editor or Game?
  25.     UWorld * TheWorld = Context.AnimInstance->GetWorld();
  26.     if (!TheWorld) return;
  27.     //~~~~~~~~~~~~~~~~
  28.    
  29.     WorldIsGame = (TheWorld->WorldType == EWorldType::Game);
  30. }
  31.  
  32. void FAnimNode_NameOfYourNode::Update(const FAnimationUpdateContext & Context)
  33. {
  34.     //EDITOR
  35.     //Editor mode? just use the base pose
  36.     if (!WorldIsGame)
  37.     {
  38.         //if your node depends on
  39.                 //actual actor instance, can't do anything in editor
  40.     }
  41.    
  42.     //GAME
  43.     //Actually in Game so the Owner Instance Should Exist
  44.     else
  45.     {
  46.         //Try Again if not found
  47.         if (!OwningActor) OwningActor =
  48.                     Context.AnimInstance->GetSkelMeshComponent()->GetOwner();
  49.        
  50.         //Not found
  51.         if (!OwningActor)
  52.         {
  53.             UE_LOG(LogAnimation, Warning,
  54.            TEXT("FAnimNode_NameOfYourNode::Update() Owning Actor was not found"));
  55.             return;
  56.             //~~~~~~~~~~~~~~~~~~~
  57.         }
  58.    
  59.         //Do Stuff Based On Actor Owner
  60.     }
  61.     //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  62.    
  63.     //~~~ Do Updates ~~~
  64.  
  65.     //Try To Update As Few of the Inputs As You Can
  66.    
  67.     //************************************************
  68.     // FPoseLinkBase::Update Active Pose - this is what makes
  69.         //the glowing line thing happen and animations loop
  70.     //***********************************************
  71.     BasePose.Update(Context);
  72.    
  73.    
  74.     //***********************
  75.     // Evaluate Graph, see AnimNode_Base, AnimNodeBase.h
  76.     EvaluateGraphExposedInputs.Execute(Context);
  77.     //***************************************
  78. }
  79.  
  80. void FAnimNode_NameOfYourNode::Evaluate(FPoseContext & Output)
  81. {
  82.     //~~~ Return Base Pose, Un Modified ~~~
  83.     BasePose.Evaluate(Output);
  84.    
  85.     //Evaluate is returning the Output to this function,
  86.     //which is returning the Output to the rest of the Anim Graph
  87.    
  88.     //In this case, we are passing the Output out variable into the BasePose
  89.    
  90.     //Basically saying, give us back the unmodified Base Pose
  91.    
  92.     //i.e, the bulk of your anim tree.
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement