本文整理汇总了C++中USceneComponent类的典型用法代码示例。如果您正苦于以下问题:C++ USceneComponent类的具体用法?C++ USceneComponent怎么用?C++ USceneComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了USceneComponent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: FindClosestParentInList
USceneComponent* FComponentEditorUtils::FindClosestParentInList(UActorComponent* ChildComponent, const TArray<UActorComponent*>& ComponentList)
{
USceneComponent* ClosestParentComponent = nullptr;
for (auto Component : ComponentList)
{
auto ChildAsScene = Cast<USceneComponent>(ChildComponent);
auto SceneComponent = Cast<USceneComponent>(Component);
if (ChildAsScene && SceneComponent)
{
// Check to see if any parent is also in the list
USceneComponent* Parent = ChildAsScene->GetAttachParent();
while (Parent != nullptr)
{
if (ComponentList.Contains(Parent))
{
ClosestParentComponent = SceneComponent;
break;
}
Parent = Parent->GetAttachParent();
}
}
}
return ClosestParentComponent;
}
开发者ID:RandomDeveloperM,项目名称:UE4_Hairworks,代码行数:26,代码来源:ComponentEditorUtils.cpp
示例2: GetActorsToIgnore
static void GetActorsToIgnore( AActor* Actor, TSet< TWeakObjectPtr<AActor> >& ActorsToIgnore )
{
if( !ActorsToIgnore.Contains( Actor ) )
{
ActorsToIgnore.Add( Actor );
// We cannot snap to any attached children or actors in the same group as moving this actor will also move the children as we are snapping to them,
// causing a cascading effect and unexpected results
TArray<USceneComponent*>& AttachedChildren = Actor->GetRootComponent()->AttachChildren;
for( int32 ChildIndex = 0; ChildIndex < AttachedChildren.Num(); ++ChildIndex )
{
USceneComponent* Child = AttachedChildren[ChildIndex];
if( Child && Child->GetOwner() )
{
ActorsToIgnore.Add( Child->GetOwner() );
}
}
AGroupActor* ParentGroup = AGroupActor::GetRootForActor(Actor, true, true);
if( ParentGroup )
{
TArray<AActor*> GroupActors;
ParentGroup->GetGroupActors(GroupActors, true);
for( int32 GroupActorIndex = 0; GroupActorIndex < GroupActors.Num(); ++GroupActorIndex )
{
ActorsToIgnore.Add( GroupActors[GroupActorIndex] );
}
}
}
}
开发者ID:Foreven,项目名称:Unreal4-1,代码行数:31,代码来源:VertexSnapping.cpp
示例3: GetPreviewActor
FVector FSCSEditorViewportClient::GetWidgetLocation() const
{
FVector Location = FVector::ZeroVector;
AActor* PreviewActor = GetPreviewActor();
if(PreviewActor)
{
TArray<FSCSEditorTreeNodePtrType> SelectedNodes = BlueprintEditorPtr.Pin()->GetSelectedSCSEditorTreeNodes();
if(SelectedNodes.Num() > 0)
{
// Use the last selected item for the widget location
USceneComponent* SceneComp = Cast<USceneComponent>(SelectedNodes.Last().Get()->FindComponentInstanceInActor(PreviewActor));
if( SceneComp )
{
TSharedPtr<ISCSEditorCustomization> Customization = BlueprintEditorPtr.Pin()->CustomizeSCSEditor(SceneComp);
FVector CustomLocation;
if(Customization.IsValid() && Customization->HandleGetWidgetLocation(SceneComp, CustomLocation))
{
Location = CustomLocation;
}
else
{
Location = SceneComp->GetComponentLocation();
}
}
}
}
return Location;
}
开发者ID:Codermay,项目名称:Unreal4,代码行数:30,代码来源:SCSEditorViewportClient.cpp
示例4: GetWorld
AActor* UVREditorMode::SpawnTransientSceneActor(TSubclassOf<AActor> ActorClass, const FString& ActorName, const bool bWithSceneComponent) const
{
const bool bWasWorldPackageDirty = GetWorld()->GetOutermost()->IsDirty();
// @todo vreditor: Needs respawn if world changes (map load, etc.) Will that always restart the editor mode anyway?
FActorSpawnParameters ActorSpawnParameters;
ActorSpawnParameters.Name = MakeUniqueObjectName( GetWorld(), ActorClass, *ActorName ); // @todo vreditor: Without this, SpawnActor() can return us an existing PendingKill actor of the same name! WTF?
ActorSpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
ActorSpawnParameters.ObjectFlags = EObjectFlags::RF_Transient;
check( ActorClass != nullptr );
AActor* NewActor = GetWorld()->SpawnActor< AActor >( ActorClass, ActorSpawnParameters );
NewActor->SetActorLabel( ActorName );
if( bWithSceneComponent )
{
// Give the new actor a root scene component, so we can attach multiple sibling components to it
USceneComponent* SceneComponent = NewObject<USceneComponent>( NewActor );
NewActor->AddOwnedComponent( SceneComponent );
NewActor->SetRootComponent( SceneComponent );
SceneComponent->RegisterComponent();
}
// Don't dirty the level file after spawning a transient actor
if( !bWasWorldPackageDirty )
{
GetWorld()->GetOutermost()->SetDirtyFlag( false );
}
return NewActor;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:31,代码来源:VREditorMode.cpp
示例5: DestroyChildActor
void UChildActorComponent::OnRegister()
{
Super::OnRegister();
if (ChildActor)
{
if (ChildActor->GetClass() != ChildActorClass)
{
DestroyChildActor();
CreateChildActor();
}
else
{
ChildActorName = ChildActor->GetFName();
USceneComponent* ChildRoot = ChildActor->GetRootComponent();
if (ChildRoot && ChildRoot->GetAttachParent() != this)
{
// attach new actor to this component
// we can't attach in CreateChildActor since it has intermediate Mobility set up
// causing spam with inconsistent mobility set up
// so moving Attach to happen in Register
ChildRoot->AttachTo(this, NAME_None, EAttachLocation::SnapToTarget);
}
}
}
else if (ChildActorClass)
{
CreateChildActor();
}
}
开发者ID:WasPedro,项目名称:UnrealEngine4.11-HairWorks,代码行数:31,代码来源:ChildActorComponent.cpp
示例6: AttachComponentOfClass
UActorComponent* UActorBlueprintLibrary::AttachComponentOfClass(UObject* WorldContextObject, TSubclassOf<UActorComponent> ComponentClass, AActor* Owner, FName ComponentName, USceneComponent* AttachTo, FName SocketName)
{
if (!Owner)
{
return nullptr;
}
UActorComponent* Component = NewObject<UActorComponent>(Owner, *ComponentClass, ComponentName);
if (!Component)
{
return nullptr;
}
Component->RegisterComponent();
Component->OnComponentCreated();
USceneComponent* SceneComponent = Cast<USceneComponent>(Component);
if (SceneComponent)
{
SceneComponent->SetWorldLocation(Owner->GetActorLocation());
SceneComponent->SetWorldRotation(Owner->GetActorRotation());
USceneComponent* AttachToComponent = AttachTo ? AttachTo : Owner->GetRootComponent();
SceneComponent->AttachToComponent(AttachToComponent, FAttachmentTransformRules::KeepWorldTransform, SocketName);
}
return Component;
}
开发者ID:Shirasho,项目名称:ValorGame,代码行数:29,代码来源:ActorBlueprintLibrary.cpp
示例7: DestroyChildActor
void UChildActorComponent::OnRegister()
{
Super::OnRegister();
if (ChildActor)
{
if (ChildActor->GetClass() != ChildActorClass)
{
DestroyChildActor();
CreateChildActor();
}
else
{
ChildActorName = ChildActor->GetFName();
USceneComponent* ChildRoot = ChildActor->GetRootComponent();
if (ChildRoot && ChildRoot->GetAttachParent() != this)
{
// attach new actor to this component
// we can't attach in CreateChildActor since it has intermediate Mobility set up
// causing spam with inconsistent mobility set up
// so moving Attach to happen in Register
ChildRoot->AttachToComponent(this, FAttachmentTransformRules::SnapToTargetNotIncludingScale);
}
// Ensure the components replication is correctly initialized
SetIsReplicated(ChildActor->GetIsReplicated());
}
}
else if (ChildActorClass)
{
CreateChildActor();
}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:34,代码来源:ChildActorComponent.cpp
示例8: if
FTransform FMovieScene3DTransformSectionRecorder::GetTransformToRecord()
{
if(USceneComponent* SceneComponent = Cast<USceneComponent>(ObjectToRecord.Get()))
{
return SceneComponent->GetRelativeTransform();
}
else if(AActor* Actor = Cast<AActor>(ObjectToRecord.Get()))
{
bool bCaptureWorldSpaceTransform = false;
USceneComponent* RootComponent = Actor->GetRootComponent();
USceneComponent* AttachParent = RootComponent ? RootComponent->GetAttachParent() : nullptr;
bWasAttached = AttachParent != nullptr;
if (AttachParent)
{
// We capture world space transforms for actors if they're attached, but we're not recording the attachment parent
bCaptureWorldSpaceTransform = !FSequenceRecorder::Get().FindRecording(AttachParent->GetOwner());
}
return (bCaptureWorldSpaceTransform || !RootComponent) ? Actor->ActorToWorld() : RootComponent->GetRelativeTransform();
}
return FTransform::Identity;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:25,代码来源:MovieScene3DTransformSectionRecorder.cpp
示例9: GetClass
UActorComponent* AActor::AddComponent(FName TemplateName, bool bManualAttachment, const FTransform& RelativeTransform, const UObject* ComponentTemplateContext)
{
UActorComponent* Template = nullptr;
UBlueprintGeneratedClass* BlueprintGeneratedClass = Cast<UBlueprintGeneratedClass>((ComponentTemplateContext != nullptr) ? ComponentTemplateContext->GetClass() : GetClass());
while(BlueprintGeneratedClass != nullptr)
{
Template = BlueprintGeneratedClass->FindComponentTemplateByName(TemplateName);
if(nullptr != Template)
{
break;
}
BlueprintGeneratedClass = Cast<UBlueprintGeneratedClass>(BlueprintGeneratedClass->GetSuperClass());
}
bool bIsSceneComponent = false;
UActorComponent* NewActorComp = CreateComponentFromTemplate(Template);
if(NewActorComp != nullptr)
{
// Call function to notify component it has been created
NewActorComp->OnComponentCreated();
// The user has the option of doing attachment manually where they have complete control or via the automatic rule
// that the first component added becomes the root component, with subsequent components attached to the root.
USceneComponent* NewSceneComp = Cast<USceneComponent>(NewActorComp);
if(NewSceneComp != nullptr)
{
if (!bManualAttachment)
{
if (RootComponent == nullptr)
{
RootComponent = NewSceneComp;
}
else
{
NewSceneComp->AttachTo(RootComponent);
}
}
NewSceneComp->SetRelativeTransform(RelativeTransform);
bIsSceneComponent = true;
}
// Register component, which will create physics/rendering state, now component is in correct position
NewActorComp->RegisterComponent();
UWorld* World = GetWorld();
if (!bRunningUserConstructionScript && World && bIsSceneComponent)
{
UPrimitiveComponent* NewPrimitiveComponent = Cast<UPrimitiveComponent>(NewActorComp);
if (NewPrimitiveComponent && ACullDistanceVolume::CanBeAffectedByVolumes(NewPrimitiveComponent))
{
World->UpdateCullDistanceVolumes(this, NewPrimitiveComponent);
}
}
}
return NewActorComp;
}
开发者ID:johndpope,项目名称:UE4,代码行数:59,代码来源:ActorConstruction.cpp
示例10: check
UActorComponent* FComponentEditorUtils::DuplicateComponent(UActorComponent* TemplateComponent)
{
check(TemplateComponent);
UActorComponent* NewCloneComponent = nullptr;
AActor* Actor = TemplateComponent->GetOwner();
if (!TemplateComponent->IsEditorOnly() && Actor)
{
Actor->Modify();
UClass* ComponentClass = TemplateComponent->GetClass();
FName NewComponentName = *FComponentEditorUtils::GenerateValidVariableName(ComponentClass, Actor);
bool bKeepWorldLocationOnAttach = false;
const bool bTemplateTransactional = TemplateComponent->HasAllFlags(RF_Transactional);
TemplateComponent->SetFlags(RF_Transactional);
NewCloneComponent = DuplicateObject<UActorComponent>(TemplateComponent, Actor, NewComponentName );
if (!bTemplateTransactional)
{
TemplateComponent->ClearFlags(RF_Transactional);
}
USceneComponent* NewSceneComponent = Cast<USceneComponent>(NewCloneComponent);
if (NewSceneComponent)
{
// Ensure the clone doesn't think it has children
NewSceneComponent->AttachChildren.Empty();
// If the clone is a scene component without an attach parent, attach it to the root (can happen when duplicating the root component)
if (!NewSceneComponent->GetAttachParent())
{
USceneComponent* RootComponent = Actor->GetRootComponent();
check(RootComponent);
// ComponentToWorld is not a UPROPERTY, so make sure the clone has calculated it properly before attachment
NewSceneComponent->UpdateComponentToWorld();
NewSceneComponent->AttachTo(RootComponent, NAME_None, EAttachLocation::KeepWorldPosition);
}
}
NewCloneComponent->OnComponentCreated();
// Add to SerializedComponents array so it gets saved
Actor->AddInstanceComponent(NewCloneComponent);
// Register the new component
NewCloneComponent->RegisterComponent();
// Rerun construction scripts
Actor->RerunConstructionScripts();
}
return NewCloneComponent;
}
开发者ID:RandomDeveloperM,项目名称:UE4_Hairworks,代码行数:57,代码来源:ComponentEditorUtils.cpp
示例11: DetachActorFromParent
void FActorDropTarget::DetachActorFromParent(AActor* ChildActor)
{
USceneComponent* RootComp = ChildActor->GetRootComponent();
if (RootComp && RootComp->AttachParent)
{
AActor* OldParent = RootComp->AttachParent->GetOwner();
OldParent->Modify();
RootComp->DetachFromParent(true);
ChildActor->SetFolderPath(OldParent->GetFolderPath());
}
}
开发者ID:Codermay,项目名称:Unreal4,代码行数:11,代码来源:ActorTreeItem.cpp
示例12: EditorErrors
void FActorDropTarget::OnDrop(FDragDropPayload& DraggedObjects, UWorld& World, const FDragValidationInfo& ValidationInfo, TSharedRef<SWidget> DroppedOnWidget)
{
AActor* DropActor = Actor.Get();
if (!DropActor)
{
return;
}
FActorArray DraggedActors = DraggedObjects.Actors.GetValue();
FMessageLog EditorErrors("EditorErrors");
EditorErrors.NewPage(LOCTEXT("ActorAttachmentsPageLabel", "Actor attachment"));
if (ValidationInfo.TooltipType == FActorDragDropGraphEdOp::ToolTip_CompatibleMultipleDetach || ValidationInfo.TooltipType == FActorDragDropGraphEdOp::ToolTip_CompatibleDetach)
{
const FScopedTransaction Transaction( LOCTEXT("UndoAction_DetachActors", "Detach actors") );
for (const auto& WeakActor : DraggedActors)
{
if (auto* DragActor = WeakActor.Get())
{
DetachActorFromParent(DragActor);
}
}
}
else if (ValidationInfo.TooltipType == FActorDragDropGraphEdOp::ToolTip_CompatibleMultipleAttach || ValidationInfo.TooltipType == FActorDragDropGraphEdOp::ToolTip_CompatibleAttach)
{
// Show socket chooser if we have sockets to select
//@TODO: Should create a menu for each component that contains sockets, or have some form of disambiguation within the menu (like a fully qualified path)
// Instead, we currently only display the sockets on the root component
USceneComponent* Component = DropActor->GetRootComponent();
if ((Component != NULL) && (Component->HasAnySockets()))
{
// Create the popup
FSlateApplication::Get().PushMenu(
DroppedOnWidget,
SNew(SSocketChooserPopup)
.SceneComponent( Component )
.OnSocketChosen_Static(&FActorDropTarget::PerformAttachment, Actor, MoveTemp(DraggedActors) ),
FSlateApplication::Get().GetCursorPos(),
FPopupTransitionEffect( FPopupTransitionEffect::TypeInPopup )
);
}
else
{
PerformAttachment(NAME_None, Actor, MoveTemp(DraggedActors));
}
}
// Report errors
EditorErrors.Notify(NSLOCTEXT("ActorAttachmentError", "AttachmentsFailed", "Attachments Failed!"));
}
开发者ID:Codermay,项目名称:Unreal4,代码行数:53,代码来源:ActorTreeItem.cpp
示例13: GetAttachmentDepth
int32 GetAttachmentDepth(USceneComponent* Component)
{
int32 Depth = 0;
USceneComponent* Parent = Component->GetAttachParent();
while (Parent)
{
++Depth;
Parent = Parent->GetAttachParent();
}
return Depth;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:13,代码来源:ActorRecording.cpp
示例14: GetActorToRecord
void UActorRecording::GetSceneComponents(TArray<USceneComponent*>& OutArray, bool bIncludeNonCDO/*=true*/)
{
// it is not enough to just go through the owned components array here
// we need to traverse the scene component hierarchy as well, as some components may be
// owned by other actors (e.g. for pooling) and some may not be part of the hierarchy
if(GetActorToRecord() != nullptr)
{
USceneComponent* RootComponent = GetActorToRecord()->GetRootComponent();
if(RootComponent)
{
// note: GetChildrenComponents clears array!
RootComponent->GetChildrenComponents(true, OutArray);
OutArray.Add(RootComponent);
}
// add owned components that are *not* part of the hierarchy
TInlineComponentArray<USceneComponent*> OwnedComponents(GetActorToRecord());
for(USceneComponent* OwnedComponent : OwnedComponents)
{
check(OwnedComponent);
if(OwnedComponent->GetAttachParent() == nullptr && OwnedComponent != RootComponent)
{
OutArray.Add(OwnedComponent);
}
}
if(!bIncludeNonCDO)
{
AActor* CDO = Cast<AActor>(GetActorToRecord()->GetClass()->GetDefaultObject());
auto ShouldRemovePredicate = [&](UActorComponent* PossiblyRemovedComponent)
{
// try to find a component with this name in the CDO
for (UActorComponent* SearchComponent : CDO->GetComponents())
{
if (SearchComponent->GetClass() == PossiblyRemovedComponent->GetClass() &&
SearchComponent->GetFName() == PossiblyRemovedComponent->GetFName())
{
return false;
}
}
// remove if its not found
return true;
};
OutArray.RemoveAllSwap(ShouldRemovePredicate);
}
}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:50,代码来源:ActorRecording.cpp
示例15:
void FMovieScene3DConstraintTrackInstance::SaveState(const TArray<UObject*>& RuntimeObjects, IMovieScenePlayer& Player, FMovieSceneSequenceInstance& SequenceInstance)
{
for (int32 ObjIndex = 0; ObjIndex < RuntimeObjects.Num(); ++ObjIndex)
{
USceneComponent* SceneComponent = MovieSceneHelpers::SceneComponentFromRuntimeObject(RuntimeObjects[ObjIndex]);
if (SceneComponent != nullptr)
{
if (InitTransformMap.Find(RuntimeObjects[ObjIndex]) == nullptr)
{
InitTransformMap.Add(RuntimeObjects[ObjIndex], SceneComponent->GetRelativeTransform());
}
}
}
}
开发者ID:RandomDeveloperM,项目名称:UE4_Hairworks,代码行数:14,代码来源:MovieScene3DConstraintTrackInstance.cpp
示例16: GetRootComponent
void AHunterProjectile::MoveInDirection(const FVector &direction)
{
m_velocity = direction * m_projectileVelocity;
USceneComponent *hopefullySprite = GetRootComponent()->GetChildComponent(0);
if (hopefullySprite != nullptr)
{
FRotator thisRotation = hopefullySprite->RelativeRotation;
FRotator directionRotator = direction.Rotation();
thisRotation.Yaw = directionRotator.Yaw;
hopefullySprite->SetRelativeRotation(thisRotation);
}
}
开发者ID:ErNancy,项目名称:TheMammoth_Public,代码行数:16,代码来源:HunterProjectile.cpp
示例17: RegisterComponents
void FDeferRegisterStaticComponents::RegisterComponents(AActor* Actor)
{
TArray<FDeferredComponentInfo>* ActorComponentsToRegister = ComponentsToRegister.Find(Actor);
if (ActorComponentsToRegister)
{
for (int32 ComponentIndex = 0; ComponentIndex < ActorComponentsToRegister->Num(); ++ComponentIndex)
{
const FDeferredComponentInfo& SavedInfo = (*ActorComponentsToRegister)[ComponentIndex];
USceneComponent* Component = SavedInfo.Component;
// Restore saved mobility just before registering this component.
Component->Mobility = SavedInfo.SavedMobility;
Component->RegisterComponent();
}
ComponentsToRegister.Remove(Actor);
}
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:16,代码来源:ActorConstruction.cpp
示例18: GetClass
float APawn::GetDefaultHalfHeight() const
{
USceneComponent* DefaultRoot = GetClass()->GetDefaultObject<APawn>()->RootComponent;
if (DefaultRoot)
{
float Radius, HalfHeight;
DefaultRoot->UpdateBounds(); // Since it's the default object, it wouldn't have been registered to ever do this.
DefaultRoot->CalcBoundingCylinder(Radius, HalfHeight);
return HalfHeight;
}
else
{
// This will probably fail to return anything useful, since default objects won't have registered components,
// but at least it will spit out a warning if so.
return GetClass()->GetDefaultObject<APawn>()->GetSimpleCollisionHalfHeight();
}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:17,代码来源:Pawn.cpp
示例19:
USceneComponent * ABomb::GetComponent(USceneComponent *parent, const FString& childLabel)
{
if (!parent)
return NULL;
USceneComponent *child = NULL;
for (int i=0; i<parent->GetNumChildrenComponents(); i++)
{
child = parent->GetChildComponent(i);
if (child && child->GetName() == childLabel)
break;
}
return child;
}
开发者ID:marcthenarc,项目名称:NetGameCPP,代码行数:17,代码来源:Bomb.cpp
示例20: AdjustComponentDelta
void FComponentEditorUtils::AdjustComponentDelta(USceneComponent* Component, FVector& Drag, FRotator& Rotation)
{
USceneComponent* ParentSceneComp = Component->GetAttachParent();
if (ParentSceneComp)
{
const FTransform ParentToWorldSpace = ParentSceneComp->GetSocketTransform(Component->AttachSocketName);
if (!Component->bAbsoluteLocation)
{
Drag = ParentToWorldSpace.Inverse().TransformVector(Drag);
}
if (!Component->bAbsoluteRotation)
{
Rotation = ( ParentToWorldSpace.Inverse().GetRotation() * Rotation.Quaternion() * ParentToWorldSpace.GetRotation() ).Rotator();
}
}
}
开发者ID:kidaa,项目名称:UnrealEngineVR,代码行数:18,代码来源:ComponentEditorUtils.cpp
注:本文中的USceneComponent类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论