Commit ea7c4262 by wester

render basic gltf without material

parent 9d8c2d74
Subproject commit 110727d81d3f44dc58f8b2c09c8c27e4c1b6a3dd
https://answers.unrealengine.com/questions/312358/cant-build-c-project-located-on-network-drive.html
\ No newline at end of file
......@@ -8,17 +8,54 @@
AGLTFDisplay::AGLTFDisplay()
{
// 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;
PrimaryActorTick.bCanEverTick = false;
static ConstructorHelpers::FObjectFinder<UStaticMeshComponent> StaticMeshComp(TEXT("/Game/Content/Box"));
static ConstructorHelpers::FObjectFinder<UStaticMeshComponent> StaticMeshComp(TEXT("/Game/Content/Duck"));
StaticMeshComponent = StaticMeshComp.Object;
RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));
//CreateDefaultSubobject<StaticMesComponent>()
//StaticMeshComponent = CreateDefaultSubobject<StaticMeshComp.Object->StaticClass()>(RootComponent, NAME_None);
//StaticMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("GLTFComponent"));
//newObject, duplicateObject
//if (StaticMeshComp.Succeeded()) {
//}
UE_LOG(LogTemp, Warning, TEXT("Object is %d"), StaticMeshComp.Object);
originalGLTFImport = StaticMeshComp.Object;
if(originalGLTFImport != nullptr)
originalGLTFImport->SetupAttachment(RootComponent);
// StaticMeshComponent->SetVisibility(true);
// StaticMeshComponent->SetHiddenInGame(false);
StaticGLTFComponent = CreateDefaultSubobject<UStaticGLTFComponent>(TEXT("GLTFComponent"));
StaticGLTFComponent->SetupAttachment(RootComponent);
}
// Called when the game starts or when spawned
void AGLTFDisplay::BeginPlay()
{
Super::BeginPlay();
FVector zero = FVector(0);
//StaticMeshComponent->RegisterComponent();
//StaticMeshComponent->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
//StaticMeshComponent->SetupAttachment(RootComponent);
if (!originalGLTFImport->IsRegistered())
originalGLTFImport->RegisterComponent();
originalGLTFImport->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
StaticMeshComponentCopy = DuplicateObject<UStaticMeshComponent>(originalGLTFImport, this);
if (!StaticMeshComponentCopy->IsRegistered())
StaticMeshComponentCopy->RegisterComponent();
StaticMeshComponentCopy->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
StaticGLTFComponent->SetRelativeLocation(FVector(-100.f));
StaticMeshComponentCopy->SetRelativeLocation(FVector(100.f));
SetActorLocation(zero, false);
}
......
......@@ -3,6 +3,7 @@
#pragma once
#include "GameFramework/Actor.h"
#include "staticGLTFComponent.h"
#include "GLTFDisplay.generated.h"
UCLASS()
......@@ -21,7 +22,15 @@ public:
virtual void Tick( float DeltaSeconds ) override;
UPROPERTY(Category = StaticMeshActor, VisibleAnywhere, BlueprintReadOnly,
Meta = (ExposeFunctionCategories = "Mesh,Rendering,Physics,Components|StaticMesh", AllowPrivateAccess = "true"))
UStaticMeshComponent * StaticMeshComponent;
UPROPERTY(Category = StaticMeshActor, VisibleAnywhere, BlueprintReadOnly)
UStaticMeshComponent *originalGLTFImport;
UPROPERTY(Category = StaticMeshActor, VisibleAnywhere, BlueprintReadOnly)
UStaticMeshComponent *StaticMeshComponentCopy;
UPROPERTY(Category = StaticMeshActor, VisibleAnywhere, BlueprintReadOnly)
UStaticGLTFComponent *StaticGLTFComponent;
};
// Fill out your copyright notice in the Description page of Project Settings.
#include "MasterTestProject.h"
#include "GLTFMeshBuilder.h"
#include "StaticGLTFComponent.h"
UStaticGLTFComponent::UStaticGLTFComponent()
{
GLTFPath = TEXT("H:/Repositories/MasterArbeit/glTF-Sample-Models/1.0/Duck/glTF/Duck.gltf");
}
void UStaticGLTFComponent::OnRegister()
{
GLTFMeshBuilder Builder(*GLTFPath);
}
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "Components/StaticMeshComponent.h"
#include "StaticGLTFComponent.generated.h"
/**
*
*/
UCLASS()
class MASTERTESTPROJECT_API UStaticGLTFComponent : public UStaticMeshComponent
{
GENERATED_BODY()
public:
UStaticGLTFComponent();
UPROPERTY(Category = GLTF, EditAnywhere, BlueprintReadWrite)
FString GLTFPath;
virtual void OnRegister() override;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment