void UAnimationGraphSchema::CreateDefaultNodesForGraph(UEdGraph& Graph) const { // Create the result node FGraphNodeCreator<UAnimGraphNode_Root> NodeCreator(Graph); UAnimGraphNode_Root* ResultSinkNode = NodeCreator.CreateNode(); NodeCreator.Finalize(); }
void UEdGraphSchema_BehaviorTreeDecorator::CreateDefaultNodesForGraph(UEdGraph& Graph) const { FGraphNodeCreator<UBehaviorTreeDecoratorGraphNode_Logic> NodeCreator(Graph); UBehaviorTreeDecoratorGraphNode_Logic* MyNode = NodeCreator.CreateNode(); MyNode->LogicMode = EDecoratorLogicMode::Sink; SetNodeMetaData(MyNode, FNodeMetadata::DefaultGraphNode); NodeCreator.Finalize(); }
void UMaterialGraph::RebuildGraph() { check(Material); Modify(); RemoveAllNodes(); if (!MaterialFunction) { // Initialize the material input list. MaterialInputs.Add( FMaterialInputInfo( GetBaseColorPinName(), MP_BaseColor, LOCTEXT( "BaseColorToolTip", "Defines the overall color of the Material. Each channel is automatically clamped between 0 and 1" ) ) ); MaterialInputs.Add( FMaterialInputInfo( GetMetallicPinName(), MP_Metallic, LOCTEXT( "MetallicToolTip", "Controls how \"metal-like\" your surface looks like") ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("Specular", "Specular"), MP_Specular, LOCTEXT("SpecularToolTip", "Used to scale the current amount of specularity on non-metallic surfaces and is a value between 0 and 1, default at 0.5") ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT( "Roughness", "Roughness" ), MP_Roughness, LOCTEXT( "RoughnessToolTip", "Controls how rough the Material is. Roughness of 0 (smooth) is a mirror reflection and 1 (rough) is completely matte or diffuse" ) ) ); MaterialInputs.Add( FMaterialInputInfo( GetEmissivePinName(), MP_EmissiveColor, LOCTEXT( "EmissiveToolTip", "Controls which parts of your Material will appear to glow" ) ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("Opacity", "Opacity"), MP_Opacity, LOCTEXT( "OpacityToolTip", "Controls the transluecency of the Material" ) ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("OpacityMask", "Opacity Mask"), MP_OpacityMask, LOCTEXT( "OpacityMaskToolTip", "When in Masked mode, a Material is either completely visible or completely invisible" ) ) ); MaterialInputs.Add( FMaterialInputInfo( GetNormalPinName(), MP_Normal, LOCTEXT( "NormalToolTip", "Takes the input of a normal map" ) ) ); MaterialInputs.Add( FMaterialInputInfo( GetWorldPositionOffsetPinName(), MP_WorldPositionOffset, LOCTEXT( "WorldPositionOffsetToolTip", "Allows for the vertices of a mesh to be manipulated in world space by the Material" ) ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT( "WorldDisplacement", "World Displacement" ), MP_WorldDisplacement, LOCTEXT( "WorldDisplacementToolTip", "Allows for the tessellation vertices to be manipulated in world space by the Material" ) ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("TessellationMultiplier", "Tessellation Multiplier"), MP_TessellationMultiplier, LOCTEXT( "TessllationMultiplierToolTip", "Controls the amount tessellation along the surface" ) ) ); MaterialInputs.Add( FMaterialInputInfo( GetSubsurfacePinName(), MP_SubsurfaceColor, LOCTEXT( "SubsurfaceToolTip", "Allows you to add a color to your Material to simulate shifts in color when light passes through the surface" ) ) ); MaterialInputs.Add( FMaterialInputInfo( GetCustomDataPinName(0), MP_CustomData0, GetCustomDataPinName( 0 ) ) ); MaterialInputs.Add( FMaterialInputInfo( GetCustomDataPinName(1), MP_CustomData1, GetCustomDataPinName( 1 ) ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("AmbientOcclusion", "Ambient Occlusion"), MP_AmbientOcclusion, LOCTEXT( "AmbientOcclusionToolTip", "Simulate the self-shadowing that happens within crevices of a surface" ) ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("Refraction", "Refraction"), MP_Refraction, LOCTEXT( "RefractionToolTip", "Takes in a texture or value that simulates the index of refraction of the surface" ) ) ); for (int32 UVIndex = 0; UVIndex < ARRAY_COUNT(Material->CustomizedUVs); UVIndex++) { //@todo - localize MaterialInputs.Add( FMaterialInputInfo( FText::FromString(FString::Printf(TEXT("Customized UV%u"), UVIndex)), (EMaterialProperty)(MP_CustomizedUVs0 + UVIndex), FText::FromString(FString::Printf( TEXT( "CustomizedUV%uToolTip" ), UVIndex ) ) ) ); } MaterialInputs.Add(FMaterialInputInfo(LOCTEXT("PixelDepthOffset", "Pixel Depth Offset"), MP_PixelDepthOffset, LOCTEXT( "PixelDepthOffsetToolTip", "Pixel Depth Offset" ) )); //^^^ New material properties go above here. ^^^^ MaterialInputs.Add(FMaterialInputInfo(LOCTEXT("MaterialAttributes", "Material Attributes"), MP_MaterialAttributes, LOCTEXT( "MaterialAttributesToolTip", "Material Attributes" ) )); // Add Root Node FGraphNodeCreator<UMaterialGraphNode_Root> NodeCreator(*this); RootNode = NodeCreator.CreateNode(); RootNode->Material = Material; NodeCreator.Finalize(); } for (int32 Index = 0; Index < Material->Expressions.Num(); Index++) { AddExpression(Material->Expressions[Index]); } for (int32 Index = 0; Index < Material->EditorComments.Num(); Index++) { AddComment(Material->EditorComments[Index]); } LinkGraphNodesFromMaterial(); }
void USoundCue::SetupSoundNode(USoundNode* InSoundNode, bool bSelectNewNode/* = true*/) { // Create the graph node check(InSoundNode->GraphNode == NULL); FGraphNodeCreator<USoundCueGraphNode> NodeCreator(*SoundCueGraph); USoundCueGraphNode* GraphNode = NodeCreator.CreateNode(bSelectNewNode); GraphNode->SetSoundNode(InSoundNode); NodeCreator.Finalize(); }
void UAnimationConduitGraphSchema::CreateDefaultNodesForGraph(UEdGraph& Graph) const { FGraphNodeCreator<UAnimGraphNode_TransitionResult> NodeCreator(Graph); UAnimGraphNode_TransitionResult* ResultSinkNode = NodeCreator.CreateNode(); UAnimationTransitionGraph* TypedGraph = CastChecked<UAnimationTransitionGraph>(&Graph); TypedGraph->MyResultNode = ResultSinkNode; NodeCreator.Finalize(); }
void UMaterialGraph::RebuildGraph() { check(Material); Modify(); RemoveAllNodes(); if (!MaterialFunction) { // Initialize the material input list. MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("BaseColor", "Base Color"), MP_BaseColor ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("Metallic", "Metallic"), MP_Metallic ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("Specular", "Specular"), MP_Specular ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("Roughness", "Roughness"), MP_Roughness ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("EmissiveColor", "Emissive Color"), MP_EmissiveColor ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("Opacity", "Opacity"), MP_Opacity ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("OpacityMask", "Opacity Mask"), MP_OpacityMask ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("Normal", "Normal"), MP_Normal ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("WorldPositionOffset", "World Position Offset"), MP_WorldPositionOffset ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("WorldDisplacement", "World Displacement"), MP_WorldDisplacement ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("TessellationMultiplier", "Tessellation Multiplier"), MP_TessellationMultiplier ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("SubsurfaceColor", "Subsurface Color"), MP_SubsurfaceColor ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("ClearCoat", "Clear Coat"), MP_ClearCoat ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("ClearCoatRoughness", "Clear Coat Roughness"), MP_ClearCoatRoughness ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("AmbientOcclusion", "Ambient Occlusion"), MP_AmbientOcclusion ) ); MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("Refraction", "Refraction"), MP_Refraction) ); for (int32 UVIndex = 0; UVIndex < ARRAY_COUNT(Material->CustomizedUVs); UVIndex++) { //@todo - localize MaterialInputs.Add( FMaterialInputInfo( FText::FromString(FString::Printf(TEXT("Customized UV%u"), UVIndex)), (EMaterialProperty)(MP_CustomizedUVs0 + UVIndex)) ); } MaterialInputs.Add( FMaterialInputInfo( LOCTEXT("MaterialAttributes", "Material Attributes"), MP_MaterialAttributes) ); // Add Root Node FGraphNodeCreator<UMaterialGraphNode_Root> NodeCreator(*this); RootNode = NodeCreator.CreateNode(); RootNode->Material = Material; NodeCreator.Finalize(); } for (int32 Index = 0; Index < Material->Expressions.Num(); Index++) { AddExpression(Material->Expressions[Index]); } for (int32 Index = 0; Index < Material->EditorComments.Num(); Index++) { AddComment(Material->EditorComments[Index]); } LinkGraphNodesFromMaterial(); }
void UAnimationStateGraphSchema::CreateDefaultNodesForGraph(UEdGraph& Graph) const { // Create the result Create FGraphNodeCreator<UAnimGraphNode_StateResult> NodeCreator(Graph); UAnimGraphNode_StateResult* ResultSinkNode = NodeCreator.CreateNode(); NodeCreator.Finalize(); SetNodeMetaData(ResultSinkNode, FNodeMetadata::DefaultGraphNode); UAnimationStateGraph* TypedGraph = CastChecked<UAnimationStateGraph>(&Graph); TypedGraph->MyResultNode = ResultSinkNode; }
void UAnimationTransitionSchema::CreateDefaultNodesForGraph(UEdGraph& Graph) const { // Create the entry/exit tunnels FGraphNodeCreator<UAnimGraphNode_TransitionResult> NodeCreator(Graph); UAnimGraphNode_TransitionResult* ResultSinkNode = NodeCreator.CreateNode(); NodeCreator.Finalize(); SetNodeMetaData(ResultSinkNode, FNodeMetadata::DefaultGraphNode); UAnimationTransitionGraph* TypedGraph = CastChecked<UAnimationTransitionGraph>(&Graph); TypedGraph->MyResultNode = ResultSinkNode; }
void UAnimationStateMachineSchema::CreateDefaultNodesForGraph(UEdGraph& Graph) const { // Create the entry/exit tunnels FGraphNodeCreator<UAnimStateEntryNode> NodeCreator(Graph); UAnimStateEntryNode* EntryNode = NodeCreator.CreateNode(); NodeCreator.Finalize(); SetNodeMetaData(EntryNode, FNodeMetadata::DefaultGraphNode); if (UAnimationStateMachineGraph* StateMachineGraph = CastChecked<UAnimationStateMachineGraph>(&Graph)) { StateMachineGraph->EntryNode = EntryNode; } }
USoundClassGraphNode* USoundClassGraph::CreateNode(USoundClass* SoundClass, int32 NodePosX, int32 NodePosY, bool bSelectNewNode/* = true*/) { USoundClassGraphNode* GraphNode = FindExistingNode(SoundClass); if (!GraphNode) { FGraphNodeCreator<USoundClassGraphNode> NodeCreator(*this); GraphNode = NodeCreator.CreateNode(bSelectNewNode); GraphNode->SoundClass = SoundClass; GraphNode->NodePosX = NodePosX; GraphNode->NodePosY = NodePosY; NodeCreator.Finalize(); } return GraphNode; }
UMaterialGraphNode_Comment* UMaterialGraph::AddComment(UMaterialExpressionComment* Comment) { UMaterialGraphNode_Comment* NewComment = NULL; if (Comment) { Modify(); FGraphNodeCreator<UMaterialGraphNode_Comment> NodeCreator(*this); NewComment = NodeCreator.CreateNode(false); NewComment->MaterialExpressionComment = Comment; NewComment->MaterialDirtyDelegate = MaterialDirtyDelegate; Comment->GraphNode = NewComment; NodeCreator.Finalize(); } return NewComment; }
UMaterialGraphNode* UMaterialGraph::AddExpression(UMaterialExpression* Expression) { UMaterialGraphNode* NewNode = NULL; if (Expression) { Modify(); FGraphNodeCreator<UMaterialGraphNode> NodeCreator(*this); NewNode = NodeCreator.CreateNode(false); NewNode->MaterialExpression = Expression; NewNode->RealtimeDelegate = RealtimeDelegate; NewNode->MaterialDirtyDelegate = MaterialDirtyDelegate; Expression->GraphNode = NewNode; NodeCreator.Finalize(); } return NewNode; }
UMaterialGraphNode_Comment* UMaterialGraph::AddComment(UMaterialExpressionComment* Comment, bool bIsUserInvoked) { UMaterialGraphNode_Comment* NewComment = NULL; if (Comment) { Modify(); FGraphNodeCreator<UMaterialGraphNode_Comment> NodeCreator(*this); if (bIsUserInvoked) { NewComment = NodeCreator.CreateUserInvokedNode(true); } else { NewComment = NodeCreator.CreateNode(false); } NewComment->MaterialExpressionComment = Comment; NewComment->MaterialDirtyDelegate = MaterialDirtyDelegate; Comment->GraphNode = NewComment; NodeCreator.Finalize(); } return NewComment; }
UObject* UNiagaraScriptFactoryNew::FactoryCreateNew(UClass* Class,UObject* InParent,FName Name,EObjectFlags Flags,UObject* Context,FFeedbackContext* Warn) { check(Class->IsChildOf(UNiagaraScript::StaticClass())); // First allocate runtime script UNiagaraScript* NewScript = ConstructObject<UNiagaraScript>(Class, InParent, Name, Flags); if(NewScript != NULL) { // Then allocate editor-only 'source' object UNiagaraScriptSource* Source = ConstructObject<UNiagaraScriptSource>(UNiagaraScriptSource::StaticClass(), NewScript, NAME_None, RF_Transactional); if(Source) { // Create 'update graph' UNiagaraGraph* CreatedGraph = ConstructObject<UNiagaraGraph>(UNiagaraGraph::StaticClass(), Source, NAME_None, RF_Transactional); Source->UpdateGraph = CreatedGraph; FGraphNodeCreator<UNiagaraNodeOutputUpdate> OutputNodeCreator(*CreatedGraph); UNiagaraNodeOutputUpdate* OutputNode = OutputNodeCreator.CreateNode(); OutputNodeCreator.Finalize(); FGraphNodeCreator<UNiagaraNodeGetAttr> TimeNodeCreator(*CreatedGraph); UNiagaraNodeGetAttr* DeltaTimeNode = TimeNodeCreator.CreateNode(); DeltaTimeNode->AttrName = FName(TEXT("DeltaTime")); TimeNodeCreator.Finalize(); UEdGraphPin* DeltaTimePin = DeltaTimeNode->FindPinChecked(DeltaTimeNode->AttrName.ToString()); TArray<FName> OutputNames; Source->GetUpdateOutputs(OutputNames); // Simple Euler integration. for(int32 i=0; i<3; i++) { FGraphNodeCreator<UNiagaraNodeGetAttr> PosNodeCreator(*CreatedGraph); UNiagaraNodeGetAttr* PosAttrNode = PosNodeCreator.CreateNode(); PosAttrNode->AttrName = OutputNames[i]; PosNodeCreator.Finalize(); FGraphNodeCreator<UNiagaraNodeGetAttr> VelNodeCreator(*CreatedGraph); UNiagaraNodeGetAttr* VelAttrNode = VelNodeCreator.CreateNode(); VelAttrNode->AttrName = OutputNames[i+3]; VelNodeCreator.Finalize(); UEdGraphPin* PosAttrOutputPin = PosAttrNode->FindPinChecked(OutputNames[i].ToString()); UEdGraphPin* VelAttrOutputPin = VelAttrNode->FindPinChecked(OutputNames[i+3].ToString()); UEdGraphPin* OutputPin = OutputNode->FindPinChecked(OutputNames[i].ToString()); UNiagaraNodeOp* MulNode = NULL; { FGraphNodeCreator<UNiagaraNodeOp> NodeCreator(*CreatedGraph); MulNode = NodeCreator.CreateNode(); MulNode->OpIndex = VectorVM::EOp::mul; NodeCreator.Finalize(); UEdGraphPin* APin = MulNode->FindPinChecked(TEXT("A")); UEdGraphPin* BPin = MulNode->FindPinChecked(TEXT("B")); APin->MakeLinkTo(VelAttrOutputPin); BPin->MakeLinkTo(DeltaTimePin); } { FGraphNodeCreator<UNiagaraNodeOp> NodeCreator(*CreatedGraph); UNiagaraNodeOp* AddNode = NodeCreator.CreateNode(); AddNode->OpIndex = VectorVM::EOp::add; NodeCreator.Finalize(); UEdGraphPin* APin = AddNode->FindPinChecked(TEXT("A")); UEdGraphPin* BPin = AddNode->FindPinChecked(TEXT("B")); UEdGraphPin* AddResultPin = AddNode->FindPinChecked(TEXT("Result")); UEdGraphPin* MulResultPin = MulNode->FindPinChecked(TEXT("Result")); APin->MakeLinkTo(PosAttrOutputPin); BPin->MakeLinkTo(MulResultPin); OutputPin->MakeLinkTo(AddResultPin); } } // Update relative time. { FGraphNodeCreator<UNiagaraNodeGetAttr> RelTimeNodeCreator(*Source->UpdateGraph); UNiagaraNodeGetAttr* RelTimeAttrNode = RelTimeNodeCreator.CreateNode(); RelTimeAttrNode->AttrName = FName(TEXT("RelativeTime")); RelTimeNodeCreator.Finalize(); FGraphNodeCreator<UNiagaraNodeOp> MadNodeCreator(*Source->UpdateGraph); UNiagaraNodeOp* MadNode = MadNodeCreator.CreateNode(); MadNode->OpIndex = VectorVM::EOp::mad; MadNodeCreator.Finalize(); MadNode->FindPinChecked(TEXT("A"))->MakeLinkTo(DeltaTimePin); MadNode->FindPinChecked(TEXT("B"))->DefaultValue = TEXT("0.2"); MadNode->FindPinChecked(TEXT("C"))->MakeLinkTo(RelTimeAttrNode->FindPinChecked(TEXT("RelativeTime"))); OutputNode->FindPinChecked(TEXT("RelativeTime"))->MakeLinkTo(MadNode->FindPinChecked(TEXT("Result"))); } // Set pointer in script to source NewScript->Source = Source; FNiagaraEditorModule& NiagaraEditorModule = FModuleManager::Get().LoadModuleChecked<FNiagaraEditorModule>(TEXT("NiagaraEditor")); NiagaraEditorModule.CompileScript(NewScript); } } return NewScript; }