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


C++ UStaticMeshComponent::SetStaticMesh方法代码示例

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


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

示例1: BackgroundTransform

FThumbnailPreviewScene::FThumbnailPreviewScene()
    : FPreviewScene( ConstructionValues()
                     .SetLightRotation( FRotator(304.736, 39.84, 0) )
                     .SetCreatePhysicsScene(false)
                     .SetTransactional(false))
{
    // A background sky sphere
    UStaticMeshComponent* BackgroundComponent = NewObject<UStaticMeshComponent>();
    BackgroundComponent->SetStaticMesh( GUnrealEd->GetThumbnailManager()->EditorSkySphere );
    const float SkySphereScale = 2000.0f;
    const FTransform BackgroundTransform(FRotator(0,0,0), FVector(0,0,0), FVector(SkySphereScale));
    FPreviewScene::AddComponent(BackgroundComponent, BackgroundTransform);

    // Adjust the default light
    DirectionalLight->Intensity = 0.2f;

    // Add additional lights
    UDirectionalLightComponent* DirectionalLight2 = NewObject<UDirectionalLightComponent>();
    DirectionalLight->Intensity = 5.0f;
    AddComponent(DirectionalLight2, FTransform( FRotator(-40,-144.678, 0) ));

    UDirectionalLightComponent* DirectionalLight3 = NewObject<UDirectionalLightComponent>();
    DirectionalLight->Intensity = 1.0f;
    AddComponent(DirectionalLight3, FTransform( FRotator(299.235,144.993, 0) ));

    // Add an infinite plane
    const float FloorPlaneScale = 10000.f;
    const FTransform FloorPlaneTransform(FRotator(-90.f,0,0), FVector::ZeroVector, FVector(FloorPlaneScale));
    UStaticMeshComponent* FloorPlaneComponent = NewObject<UStaticMeshComponent>();
    FloorPlaneComponent->SetStaticMesh( GUnrealEd->GetThumbnailManager()->EditorPlane );
    FloorPlaneComponent->SetMaterial( 0, GUnrealEd->GetThumbnailManager()->FloorPlaneMaterial );
    FPreviewScene::AddComponent(FloorPlaneComponent, FloorPlaneTransform);
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:33,代码来源:ThumbnailHelpers.cpp

示例2: FVector

// Sets default values
AMotherActor::AMotherActor()
{
	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
	UBoxComponent* Box = CreateDefaultSubobject<UBoxComponent>(TEXT("RootComponent"));
	RootComponent = Box;
	Box->InitBoxExtent(FVector(20.0f, 20.0f, 20.0f));

	UBoxComponent* Box1 = CreateDefaultSubobject<UBoxComponent>(TEXT("Box"));
	Box1->InitBoxExtent(FVector(60.0f, 60.0f, 60.0f));
	Box1->RelativeLocation = FVector(100.0f, 0.0f, 0.0f);
	USphereComponent* SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("Sphere"));
	SphereComponent->InitSphereRadius(60.0f);
	SphereComponent->RelativeLocation = FVector(100.0f, 0.0f, 0.0f);
	UStaticMeshComponent* SphereVisual = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("VisualRepresentation"));

	static ConstructorHelpers::FObjectFinder<UStaticMesh> SphereVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere"));
	if (SphereVisualAsset.Succeeded()) {
		SphereVisual->SetStaticMesh(SphereVisualAsset.Object);
		SphereVisual->SetRelativeLocation(FVector(0.0f, 0.0f, -100.0f));
		SphereVisual->SetWorldScale3D(FVector(0.8f));
	}

	Box1->AttachTo(RootComponent);
	SphereVisual->AttachTo(RootComponent);
	SphereComponent->AttachTo(RootComponent);

	UChildActorComponent * ChildActor = CreateDefaultSubobject<UChildActorComponent>(TEXT("InventoryCamera"));
	ChildActor->SetChildActorClass(AOrbitalActor::StaticClass());
	ChildActor->CreateChildActor();
	FVector position = GetActorLocation();
	ChildActor->SetRelativeTransform(FTransform(position));

}
开发者ID:Amaterasu90,项目名称:Runner,代码行数:35,代码来源:MotherActor.cpp

示例3: SphereVisualAsset

// Sets default values
ACollidingPawn::ACollidingPawn()
{
 	// Set this pawn to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	// Tutorial code

	// Our root component will be a sphere that reats to Physics
	USphereComponent* SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("RootComponent"));
	RootComponent = SphereComponent;
	SphereComponent->InitSphereRadius(40.0f);
	SphereComponent->SetCollisionProfileName(TEXT("Pawn"));

	// Creating and correctly Positioning the Mesh component so that it fits the sphere collision
	UStaticMeshComponent* SphereVisual = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("VisualRepresentation"));
	SphereVisual->AttachTo(RootComponent);
	static ConstructorHelpers::FObjectFinder<UStaticMesh> SphereVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere"));
	if (SphereVisualAsset.Succeeded())
	{
		SphereVisual->SetStaticMesh(SphereVisualAsset.Object);
		SphereVisual->SetRelativeLocation(FVector(0.0f, 0.0f,-40.0f));
		SphereVisual->SetWorldScale3D(FVector(0.8f));
	}

	// Particle system Creation, Positioning (Offset)
	OurParticleSystem = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("MovementParticles"));
	OurParticleSystem->AttachTo(SphereVisual);
	OurParticleSystem->bAutoActivate = false;
	OurParticleSystem->SetRelativeLocation(FVector(-20.0f,0.0f,0.0f));
	static ConstructorHelpers::FObjectFinder<UParticleSystem> ParticleAsset(TEXT("/Game/StarterContent/Particles/P_Fire.P_Fire"));
	if (ParticleAsset.Succeeded())
	{
		OurParticleSystem->SetTemplate(ParticleAsset.Object);
	}

	// SpringArm creation for a smooth and fast Camera Experience ( We could have just avoided this springArm ) but for the sake of smoothness
	USpringArmComponent* SpringArm = CreateAbstractDefaultSubobject<USpringArmComponent>(TEXT("CameraAttachmentArm"));
	SpringArm->AttachTo(RootComponent);
	SpringArm->RelativeRotation = FRotator(-45.0f,0.0f,0.0f);
	SpringArm->TargetArmLength = 400.0f;
	SpringArm->bEnableCameraLag = true;
	SpringArm->CameraLagSpeed = 3.0f;
	
	// Easy to create the Camera component and attach it to the built in Socket at the end of springArm
	UCameraComponent* ActualCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("ActualCamera"));
	ActualCamera->AttachTo(SpringArm, USpringArmComponent::SocketName);

	// Take control of the default player
	AutoPossessPlayer = EAutoReceiveInput::Player0;

	// creating an instance of our movement component, and telling it to update the root.
	OurMovementComponent = CreateDefaultSubobject<UCollidingPawnMovementComponent>(TEXT("CustomMovementComponent"));
	OurMovementComponent->UpdatedComponent = RootComponent;
	
	

}
开发者ID:Ali-Shery,项目名称:UE4_CodeTutorial_5,代码行数:58,代码来源:CollidingPawn.cpp

示例4: SphereVisualAsset

// Sets default values
APawnCharacter::APawnCharacter()
{

	// Stats
	moveSpeed = 300.0f;
	dodgeSpeed = 800.0f;

 	// Set this pawn to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	// Our root component will be a sphere that reacts to physics
	USphereComponent* SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("RootComponent"));
	RootComponent = SphereComponent;
	SphereComponent->InitSphereRadius(40.0f);
	SphereComponent->SetCollisionProfileName(TEXT("Pawn"));

	// Create and position a mesh component so we can see where our sphere is
	UStaticMeshComponent* SphereVisual = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("VisualRepresentation"));
	SphereVisual->AttachTo(RootComponent);
	static ConstructorHelpers::FObjectFinder<UStaticMesh> SphereVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere"));
	if (SphereVisualAsset.Succeeded())
	{
		SphereVisual->SetStaticMesh(SphereVisualAsset.Object);
		SphereVisual->SetRelativeLocation(FVector(0.0f, 0.0f, -40.0f));
		SphereVisual->SetWorldScale3D(FVector(0.8f));
	}

	// Use a spring arm to give the camera smooth, natural-feeling motion.
	USpringArmComponent* SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraAttachmentArm"));
	SpringArm->AttachTo(RootComponent);
	SpringArm->RelativeRotation = FRotator(-75.f, 0.f, 0.f);
	SpringArm->TargetArmLength = 800.0f;
	SpringArm->bEnableCameraLag = true;
	SpringArm->CameraLagSpeed = 5.0f;

	// Create a camera and attach to our spring arm
	UCameraComponent* Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("ActualCamera"));
	Camera->AttachTo(SpringArm, USpringArmComponent::SocketName);

	// Take control of the default player
	AutoPossessPlayer = EAutoReceiveInput::Player0;

	// Create an instance of our movement component, and tell it to update the root.
	OurMovementComponent = CreateDefaultSubobject<UPawnCharacterMovementComponent>(TEXT("CustomMovementComponent"));
	OurMovementComponent->UpdatedComponent = RootComponent;
	OurMovementComponent->setMoveSpeed(moveSpeed);

}
开发者ID:EliseSpPrj,项目名称:Descend,代码行数:49,代码来源:PawnCharacter.cpp

示例5: UpdatePreviewMesh

void SStaticMeshEditorViewport::UpdatePreviewMesh(UStaticMesh* InStaticMesh)
{
	{
		const int32 SocketedComponentCount = SocketPreviewMeshComponents.Num();
		for(int32 i = 0; i < SocketedComponentCount; ++i)
		{
			UStaticMeshComponent* SocketPreviewMeshComponent = SocketPreviewMeshComponents[i];
			if( SocketPreviewMeshComponent )
			{
				PreviewScene.RemoveComponent(SocketPreviewMeshComponent);
			}
		}
		SocketPreviewMeshComponents.Empty();
	}

	if (PreviewMeshComponent)
	{
		PreviewScene.RemoveComponent(PreviewMeshComponent);
		PreviewMeshComponent = NULL;
	}

	PreviewMeshComponent = ConstructObject<UStaticMeshComponent>(UStaticMeshComponent::StaticClass());

	PreviewMeshComponent->SetStaticMesh(InStaticMesh);
	PreviewScene.AddComponent(PreviewMeshComponent,FTransform::Identity);

	const int32 SocketCount = InStaticMesh->Sockets.Num();
	SocketPreviewMeshComponents.Reserve(SocketCount);
	for(int32 i = 0; i < SocketCount; ++i)
	{
		UStaticMeshSocket* Socket = InStaticMesh->Sockets[i];

		UStaticMeshComponent* SocketPreviewMeshComponent = NULL;
		if( Socket && Socket->PreviewStaticMesh )
		{
			SocketPreviewMeshComponent = ConstructObject<UStaticMeshComponent>(UStaticMeshComponent::StaticClass());
			SocketPreviewMeshComponent->SetStaticMesh(Socket->PreviewStaticMesh);
			SocketPreviewMeshComponent->SnapTo(PreviewMeshComponent, Socket->SocketName);
			SocketPreviewMeshComponents.Add(SocketPreviewMeshComponent);
			PreviewScene.AddComponent(SocketPreviewMeshComponent, FTransform::Identity);
		}
	}

	EditorViewportClient->SetPreviewMesh(InStaticMesh, PreviewMeshComponent);
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:45,代码来源:SStaticMeshEditorViewport.cpp

示例6: SphereVisualAsset

// Sets default values
APawnWithCamera::APawnWithCamera()
{
 	// Set this pawn to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;


	// Our root component will be a sphere that reacts to physics
	USphereComponent* SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("RootComponent"));
	RootComponent = SphereComponent;
	SphereComponent->InitSphereRadius(40.0f);
	SphereComponent->SetCollisionProfileName(TEXT("Pawn"));

	// Create and position a mesh component so we can see where our sphere is
	UStaticMeshComponent* SphereVisual = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("VisualRepresentation"));
	SphereVisual->AttachTo(RootComponent);
	static ConstructorHelpers::FObjectFinder<UStaticMesh> SphereVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere"));
	if (SphereVisualAsset.Succeeded())
	{
		SphereVisual->SetStaticMesh(SphereVisualAsset.Object);
		SphereVisual->SetRelativeLocation(FVector(0.0f, 0.0f, -40.0f));
		SphereVisual->SetWorldScale3D(FVector(0.8f));
	}

	//Create our camera sprinf
	OurCameraSpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraSpringArm"));
	OurCameraSpringArm->AttachTo(RootComponent);
	OurCameraSpringArm->SetRelativeLocationAndRotation(FVector(4.0f, 0.0f, 30.0f), FRotator(-60.0f, 0.0f, 0.0f));
	OurCameraSpringArm->TargetArmLength = 300.f;
	OurCameraSpringArm->bEnableCameraLag = true;
	OurCameraSpringArm->CameraLagSpeed = 3.0f;

	OurCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("GameCamera"));
	OurCamera->AttachTo(OurCameraSpringArm, USpringArmComponent::SocketName);

	OurMovementComponent = CreateDefaultSubobject<UCollidingPawnMovementComponent>(TEXT("CustomMovementComponent"));
	OurMovementComponent->UpdatedComponent = RootComponent;

	//Take control of the default Player
	AutoPossessPlayer = EAutoReceiveInput::Player0;

	speenIncrease = 2.0f;
	speed = 100.f;
}
开发者ID:SaedGD,项目名称:EUDK_Programming,代码行数:44,代码来源:PawnWithCamera.cpp

示例7: UpdatePreviewSocketMeshes

void SStaticMeshEditorViewport::UpdatePreviewSocketMeshes()
{
	UStaticMesh* const PreviewStaticMesh = PreviewMeshComponent ? PreviewMeshComponent->StaticMesh : NULL;

	if( PreviewStaticMesh )
	{
		const int32 SocketedComponentCount = SocketPreviewMeshComponents.Num();
		const int32 SocketCount = PreviewStaticMesh->Sockets.Num();

		const int32 IterationCount = FMath::Max(SocketedComponentCount, SocketCount);
		for(int32 i = 0; i < IterationCount; ++i)
		{
			if(i >= SocketCount)
			{
				// Handle removing an old component
				UStaticMeshComponent* SocketPreviewMeshComponent = SocketPreviewMeshComponents[i];
				PreviewScene.RemoveComponent(SocketPreviewMeshComponent);
				SocketPreviewMeshComponents.RemoveAt(i, SocketedComponentCount - i);
				break;
			}
			else if(UStaticMeshSocket* Socket = PreviewStaticMesh->Sockets[i])
			{
				UStaticMeshComponent* SocketPreviewMeshComponent = NULL;

				// Handle adding a new component
				if(i >= SocketedComponentCount)
				{
					SocketPreviewMeshComponent = ConstructObject<UStaticMeshComponent>(UStaticMeshComponent::StaticClass());
					PreviewScene.AddComponent(SocketPreviewMeshComponent, FTransform::Identity);
					SocketPreviewMeshComponents.Add(SocketPreviewMeshComponent);
				}
				else
				{
					SocketPreviewMeshComponent = SocketPreviewMeshComponents[i];
				}

				SocketPreviewMeshComponent->SetStaticMesh(Socket->PreviewStaticMesh);
				SocketPreviewMeshComponent->SnapTo(PreviewMeshComponent, Socket->SocketName);
			}
		}
	}
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:42,代码来源:SStaticMeshEditorViewport.cpp

示例8: FRotator

// Sets default values
AKrofna_CPP::AKrofna_CPP()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
	UStaticMeshComponent *Krofna = CreateDefaultSubobject<UStaticMeshComponent,UStaticMeshComponent>(TEXT("krofnica"));
	URotatingMovementComponent *Rotacija = CreateDefaultSubobject<URotatingMovementComponent, URotatingMovementComponent>(TEXT("rotaciona komponenta"));
	UPointLightComponent *Svetlo1 = CreateDefaultSubobject <UPointLightComponent, UPointLightComponent>(TEXT("Svetlo1"));
	UPointLightComponent *Svetlo2 = CreateDefaultSubobject <UPointLightComponent, UPointLightComponent>(TEXT("Svetlo2"));
	USphereComponent *Kolizija = CreateDefaultSubobject <USphereComponent, USphereComponent>(TEXT("Kolizija"));
	Kolizija->SetSphereRadius(65.f);
	Kolizija->Activate(true);
	Kolizija->bGenerateOverlapEvents = true;
	Kolizija->SetRelativeLocation(FVector(0,0,18.f));
	this->RootComponent = Krofna;
	Kolizija->AttachTo(RootComponent);
	Svetlo1->AttachTo(RootComponent);
	Svetlo2->AttachTo(RootComponent);
	Svetlo1->SetRelativeLocation(FVector(0, 0, 65));
	Svetlo2->SetRelativeLocation(FVector(0, 0, -45));
	Svetlo1->SetLightColor(FLinearColor(0.65f, 1.f, 0.875f));
	Svetlo2->SetLightColor(FLinearColor(0.45f, 1.f, 0.82f));
	this->DisableComponentsSimulatePhysics();
	Krofna->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap);
	static ConstructorHelpers::FObjectFinder<UStaticMesh> Krofna_SM(TEXT("StaticMesh'/Game/StarterContent/Shapes/Shape_Torus.Shape_Torus'"));
	Krofna->SetStaticMesh(Krofna_SM.Object);


	static ConstructorHelpers::FObjectFinder<UMaterial> Krofna_M(TEXT("Material'/Game/StarterContent/Materials/M_Metal_Gold.M_Metal_Gold'"));
	Krofna->SetMaterial(0, Krofna_M.Object);

	Rotacija->SetActive(true);
	Rotacija->RotationRate = FRotator(120,120,120);

	this->SetActorEnableCollision(true);
	OnActorBeginOverlap.AddDynamic(this, &AKrofna_CPP::OnBeginOverlap);

	
}
开发者ID:pecurka,项目名称:rs15-24,代码行数:39,代码来源:Krofna_CPP.cpp

示例9: SetPreviewAsset

bool SMaterialEditorViewport::SetPreviewAsset(UObject* InAsset)
{
	if (!MaterialEditorPtr.Pin()->ApproveSetPreviewAsset(InAsset))
	{
		return false;
	}

	// Unregister the current component
	if (PreviewMeshComponent != nullptr)
	{
		PreviewScene.RemoveComponent(PreviewMeshComponent);
		PreviewMeshComponent = nullptr;
	}

	FTransform Transform = FTransform::Identity;

	if (UStaticMesh* StaticMesh = Cast<UStaticMesh>(InAsset))
	{
		// Special case handling for static meshes, to use more accurate bounds via a subclass
		UStaticMeshComponent* NewSMComponent = NewObject<UMaterialEditorMeshComponent>(GetTransientPackage(), NAME_None, RF_Transient);
		NewSMComponent->SetStaticMesh(StaticMesh);

		PreviewMeshComponent = NewSMComponent;

		// Update the toolbar state implicitly through PreviewPrimType.
		if (StaticMesh == GUnrealEd->GetThumbnailManager()->EditorCylinder)
		{
			PreviewPrimType = TPT_Cylinder;
		}
		else if (StaticMesh == GUnrealEd->GetThumbnailManager()->EditorCube)
		{
			PreviewPrimType = TPT_Cube;
		}
		else if (StaticMesh == GUnrealEd->GetThumbnailManager()->EditorSphere)
		{
			PreviewPrimType = TPT_Sphere;
		}
		else if (StaticMesh == GUnrealEd->GetThumbnailManager()->EditorPlane)
		{
			// Need to rotate the plane so that it faces the camera
			Transform.SetRotation(FQuat(FRotator(0, 90, 0)));
			PreviewPrimType = TPT_Plane;
		}
		else
		{
			PreviewPrimType = TPT_None;
		}
	}
	else if (InAsset != nullptr)
	{
		// Fall back to the component asset broker
		if (TSubclassOf<UActorComponent> ComponentClass = FComponentAssetBrokerage::GetPrimaryComponentForAsset(InAsset->GetClass()))
		{
			if (ComponentClass->IsChildOf(UMeshComponent::StaticClass()))
			{
				PreviewMeshComponent = NewObject<UMeshComponent>(GetTransientPackage(), ComponentClass, NAME_None, RF_Transient);

				FComponentAssetBrokerage::AssignAssetToComponent(PreviewMeshComponent, InAsset);

				PreviewPrimType = TPT_None;
			}
		}
	}

	// Add the new component to the scene
	if (PreviewMeshComponent != nullptr)
	{
		PreviewScene.AddComponent(PreviewMeshComponent, Transform);
	}

	// Make sure the preview material is applied to the component
	SetPreviewMaterial(PreviewMaterial);

	return (PreviewMeshComponent != nullptr);
}
开发者ID:Codermay,项目名称:Unreal4,代码行数:75,代码来源:SMaterialEditorViewport.cpp

示例10: FuselageVisualAsset

// Sets default values
AMyDrone::AMyDrone()
{
	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	// Our root component will be a sphere that reacts to physics
	SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("RootComponent"));
	RootComponent = SphereComponent;
	SphereComponent->InitSphereRadius(20.0f);
	SphereComponent->BodyInstance.SetCollisionEnabled(ECollisionEnabled::QueryOnly);
	SphereComponent->BodyInstance.SetResponseToAllChannels(ECR_Overlap);
	OnActorBeginOverlap.AddDynamic(this, &AMyDrone::OnOverlapBegin);

	// Create and position a mesh component to fuselage
	UStaticMeshComponent* fuselageMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("VisualRepresentation"));
	fuselageMesh->AttachTo(RootComponent);
	static ConstructorHelpers::FObjectFinder<UStaticMesh> FuselageVisualAsset(TEXT("/Game/unreal_fuselage.unreal_fuselage"));
	if (FuselageVisualAsset.Succeeded())
	{
		fuselageMesh->SetStaticMesh(FuselageVisualAsset.Object);
		fuselageMesh->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f)); // no translation for now
		fuselageMesh->SetWorldScale3D(FVector(1.0f)); // no scaling for now
	}

	// find elevon in assets library
	static ConstructorHelpers::FObjectFinder<UStaticMesh> ElevonVisualAsset(TEXT("/Game/elevon.elevon"));

	// Create and position a mesh component to elevon 1
	elevon1Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Elevon1Mesh"));
	elevon1Mesh->AttachTo(RootComponent);
	if (ElevonVisualAsset.Succeeded())
	{
		elevon1Mesh->SetStaticMesh(ElevonVisualAsset.Object);
		elevon1Mesh->SetRelativeLocation(FVector(-12.0f, 12.0f, 0.0f)); // no translation for now
		elevon1Mesh->SetWorldScale3D(FVector(1.0f)); // no scaling for now
	}

	// Create and position a mesh component to elevon 2
	elevon2Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Elevon2Mesh"));
	elevon2Mesh->AttachTo(RootComponent);
	if (ElevonVisualAsset.Succeeded())
	{
		elevon2Mesh->SetStaticMesh(ElevonVisualAsset.Object);
		elevon2Mesh->SetRelativeLocation(FVector(-12.0f, -12.0f, 0.0f)); // no translation for now
		elevon2Mesh->SetWorldScale3D(FVector(1.0f)); // no scaling for now
	}

	// Create a particle system that we can activate or deactivate
	DroneParticleSystem = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("MovementParticles"));
	DroneParticleSystem->AttachTo(fuselageMesh);
	DroneParticleSystem->bAutoActivate = false;
	DroneParticleSystem->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
	static ConstructorHelpers::FObjectFinder<UParticleSystem> ParticleAsset(TEXT("/Game/StarterContent/Particles/P_Fire.P_Fire"));
	if (ParticleAsset.Succeeded())
	{
		DroneParticleSystem->SetTemplate(ParticleAsset.Object);
	}

	// inyit cvs table handlers
	UCurveTable* expTable;
	static ConstructorHelpers::FObjectFinder<UCurveTable>
		expTable_BP(TEXT("CurveTable'/Game/Data/testtable.testtable'"));
	expTable = expTable_BP.Object;

	// not sure what this is, but it seems necessary
	static const FString ContextString(TEXT("GENERAL"));

	// here we link curves to experimental position CSV data
	curveX = expTable->FindCurve(*FString::Printf(TEXT("X")), ContextString);
	curveY = expTable->FindCurve(*FString::Printf(TEXT("Y")), ContextString);
	curveZ = expTable->FindCurve(*FString::Printf(TEXT("Z")), ContextString);

	// here we link curves to experimental quaternion CSV data
	curveQ0 = expTable->FindCurve(*FString::Printf(TEXT("Q0")), ContextString);
	curveQ1 = expTable->FindCurve(*FString::Printf(TEXT("Q1")), ContextString);
	curveQ2 = expTable->FindCurve(*FString::Printf(TEXT("Q2")), ContextString);
	curveQ3 = expTable->FindCurve(*FString::Printf(TEXT("Q3")), ContextString);

	// here we link curves to experimental elevon CSV data
	curveD1 = expTable->FindCurve(*FString::Printf(TEXT("D1")), ContextString);
	curveD2 = expTable->FindCurve(*FString::Printf(TEXT("D2")), ContextString);
	
}
开发者ID:lustosa-leandro,项目名称:unreal-trajectories,代码行数:84,代码来源:MyDrone.cpp


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