当前位置: 首页>>代码示例>>C++>>正文


C++ USceneComponent::GetComponentLocation方法代码示例

本文整理汇总了C++中USceneComponent::GetComponentLocation方法的典型用法代码示例。如果您正苦于以下问题:C++ USceneComponent::GetComponentLocation方法的具体用法?C++ USceneComponent::GetComponentLocation怎么用?C++ USceneComponent::GetComponentLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在USceneComponent的用法示例。


在下文中一共展示了USceneComponent::GetComponentLocation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetWidgetLocation

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

示例2: ComponentInstanceData

AActor::FActorTransactionAnnotation::FActorTransactionAnnotation(const AActor* Actor, const bool bCacheRootComponentData)
	: ComponentInstanceData(Actor)
{
	USceneComponent* ActorRootComponent = Actor->GetRootComponent();
	if (bCacheRootComponentData && ActorRootComponent && ActorRootComponent->IsCreatedByConstructionScript())
	{
		bRootComponentDataCached = true;
		RootComponentData.Transform = ActorRootComponent->ComponentToWorld;
		RootComponentData.Transform.SetTranslation(ActorRootComponent->GetComponentLocation()); // take into account any custom location

		if (ActorRootComponent->GetAttachParent())
		{
			RootComponentData.AttachedParentInfo.Actor = ActorRootComponent->GetAttachParent()->GetOwner();
			RootComponentData.AttachedParentInfo.AttachParent = ActorRootComponent->GetAttachParent();
			RootComponentData.AttachedParentInfo.AttachParentName = ActorRootComponent->GetAttachParent()->GetFName();
			RootComponentData.AttachedParentInfo.SocketName = ActorRootComponent->GetAttachSocketName();
			RootComponentData.AttachedParentInfo.RelativeTransform = ActorRootComponent->GetRelativeTransform();
		}

		for (USceneComponent* AttachChild : ActorRootComponent->GetAttachChildren())
		{
			AActor* ChildOwner = (AttachChild ? AttachChild->GetOwner() : NULL);
			if (ChildOwner && ChildOwner != Actor)
			{
				// Save info about actor to reattach
				FActorRootComponentReconstructionData::FAttachedActorInfo Info;
				Info.Actor = ChildOwner;
				Info.SocketName = AttachChild->GetAttachSocketName();
				Info.RelativeTransform = AttachChild->GetRelativeTransform();
				RootComponentData.AttachedToInfo.Add(Info);
			}
		}
	}
	else
	{
		bRootComponentDataCached = false;
	}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:38,代码来源:ActorEditor.cpp

示例3: GetActorRotation

void ALD35Character::OnFire()
{ 
	if (IsInAlternateForm)
	{
		FVector trgPos = FindComponentByClass<UCameraComponent>()->GetComponentLocation() + GetActorRotation().RotateVector(FVector(140, 0, 0));

		//DrawDebugSphere(GetWorld(), trgPos, 150, 8, FColor::Red, false, 0.5f);

		TArray<FOverlapResult> res;

		if (GetWorld()->OverlapMultiByChannel(res, trgPos, FQuat::Identity, ECollisionChannel::ECC_WorldDynamic, FCollisionShape::MakeSphere(150)))
		{
			for (auto& a : res)
			{
				if (a.Actor.Get() && a.Actor != this)
				{
					a.Actor->TakeDamage(1, FDamageEvent(), this->GetController(), this);
				}
			}
		}

		if (FMath::Rand() % 3 == 0)
		{
			UGameplayStatics::PlaySoundAtLocation(this, TransformSound, GetActorLocation());
		}

		return;
	}

	// try and fire a projectile
	if (ProjectileClass != NULL)
	{
		USceneComponent* cam = FindComponentByClass<UCameraComponent>();

		if (cam)
		{
			FRotator SpawnRotation = cam->GetComponentRotation();
			FVector SpawnLocation = cam->GetComponentLocation();

			TArray<UActorComponent*> childComponents = GetComponentsByTag(USceneComponent::StaticClass(), "Gun");

			for (auto& b : childComponents)
			{
				if (auto a = Cast<USceneComponent>(b))
				{
					if (a->ComponentHasTag(TEXT("Gun")))
					{
						SpawnRotation = a->GetComponentRotation();
						SpawnLocation = a->GetComponentLocation();

						//UE_LOG(LogTemp, Display, TEXT("NM %s %s %s %s %s"), *a->GetName(), *cam->GetName(), *SpawnLocation.ToString(), *cam->GetComponentLocation().ToString(), *a->GetRelativeTransform().ToString());
					}
				}
			}

			UWorld* const World = GetWorld();
			if (World != NULL)
			{
				// spawn the projectile at the muzzle

				FActorSpawnParameters params;
				params.Instigator = this;

				World->SpawnActor<ALD35Projectile>(ProjectileClass, SpawnLocation, SpawnRotation, params);
			}
		}
	}

	// try and play the sound if specified
	if (FireSound != NULL)
	{
		UGameplayStatics::PlaySoundAtLocation(this, ShootCrossbowSound, GetActorLocation());
	}

}
开发者ID:Quadtree,项目名称:LD35,代码行数:75,代码来源:LD35Character.cpp

示例4: UpdatePivotLocationForSelection

void UUnrealEdEngine::UpdatePivotLocationForSelection( bool bOnChange )
{
	// Pick a new common pivot, or not.
	AActor* SingleActor = nullptr;
	USceneComponent* SingleComponent = nullptr;

	if (GetSelectedComponentCount() > 0)
	{
		for (FSelectedEditableComponentIterator It(*GetSelectedComponents()); It; ++It)
		{
			UActorComponent* Component = CastChecked<UActorComponent>(*It);
			AActor* ComponentOwner = Component->GetOwner();

			if (ComponentOwner != nullptr)
			{
				auto SelectedActors = GetSelectedActors();
				const bool bIsOwnerSelected = SelectedActors->IsSelected(ComponentOwner);
				check(bIsOwnerSelected);

				if (ComponentOwner->GetWorld() == GWorld)
				{
					SingleActor = ComponentOwner;
					if (Component->IsA<USceneComponent>())
					{
						SingleComponent = CastChecked<USceneComponent>(Component);
					}

					const bool IsTemplate = ComponentOwner->IsTemplate();
					const bool LevelLocked = !FLevelUtils::IsLevelLocked(ComponentOwner->GetLevel());
					check(IsTemplate || LevelLocked);
				}
			}
		}
	}
	else
	{
		for (FSelectionIterator It(GetSelectedActorIterator()); It; ++It)
		{
			AActor* Actor = static_cast<AActor*>(*It);
			checkSlow(Actor->IsA(AActor::StaticClass()));

			if (Actor->GetWorld() == GWorld)
			{
				const bool IsTemplate = Actor->IsTemplate();
				const bool LevelLocked = !FLevelUtils::IsLevelLocked(Actor->GetLevel());
				check(IsTemplate || LevelLocked);

				SingleActor = Actor;
			}
		}
	}
	
	if (SingleComponent != NULL)
	{
		SetPivot(SingleComponent->GetComponentLocation(), false, true);
	}
	else if( SingleActor != NULL ) 
	{		
		// For geometry mode use current pivot location as it's set to selected face, not actor
		FEditorModeTools& Tools = GLevelEditorModeTools();
		if( Tools.IsModeActive(FBuiltinEditorModes::EM_Geometry) == false || bOnChange == true )
		{
			// Set pivot point to the actor's location
			FVector PivotPoint = SingleActor->GetActorLocation();

			// If grouping is active, see if this actor is part of a locked group and use that pivot instead
			if(GEditor->bGroupingActive)
			{
				AGroupActor* ActorGroupRoot = AGroupActor::GetRootForActor(SingleActor, true, true);
				if(ActorGroupRoot)
				{
					PivotPoint = ActorGroupRoot->GetActorLocation();
				}
			}
			SetPivot( PivotPoint, false, true );
		}
	}
	else
	{
		ResetPivot();
	}
}
开发者ID:didixp,项目名称:Ark-Dev-Kit,代码行数:82,代码来源:EditorSelectUtils.cpp


注:本文中的USceneComponent::GetComponentLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。