Commit e76fd90e by Kai Westerkamp

Merge branch 'master' of ssh://git.breab.org:2223/kai/MasterTestProjekt

# Conflicts: # Plugins/UnrealGLTFLoader
parents 145c33e9 0906751a
Subproject commit 6c3f8ba7556a4b072107b58831ba0ae592c59d87
https://answers.unrealengine.com/questions/312358/cant-build-c-project-located-on-network-drive.html
\ No newline at end of file
// Fill out your copyright notice in the Description page of Project Settings.
#include "MasterTestProject.h"
#include <codecvt>
#define TINYGLTF_LOADER_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#include "tiny_gltf_loader.h"
#include "StaticGLTFComponent.h"
UStaticGLTFComponent::UStaticGLTFComponent()
{
GLTFPath = TEXT("H:/Repositories/MasterArbeit/glTF-Sample-Models/1.0/Duck/glTF/Duck.gltf");
Loader = new tinygltf::TinyGLTFLoader;
Scene = new tinygltf::Scene;
}
UStaticGLTFComponent::~UStaticGLTFComponent() {
delete Loader;
delete Scene;
}
void UStaticGLTFComponent::OnRegister()
{
Super::OnRegister();
std::string TempError;
tinygltfLoadSuccess = Loader->LoadFromFile((*Scene), TempError, ToStdString(GLTFPath));
tinygltfError = ToFString(TempError);
if(!tinygltfLoadSuccess){
UE_LOG(GLTF, Error, TEXT("GLTF loading Error: %s"), *tinygltfError);
return;
}
UE_LOG(GLTF, Log,TEXT("GLTF parsed %s"), *tinygltfError);
//get Default Scene and Root Nodes
if (Scene->defaultScene.empty()) {
UE_LOG(GLTF, Error, TEXT("Default Scene Empty"));
}
for (auto RootNode : Scene->scenes[Scene->defaultScene]) {
UE_LOG(GLTF, Log, TEXT("Root Node %s"), *ToFString(RootNode));
}
}
FString UStaticGLTFComponent::ToFString(std::string InString)
{
return FString(InString.c_str());
}
std::string UStaticGLTFComponent::ToStdString(FString InString)
{
auto CharArray = InString.GetCharArray();
std::wstring WideString(&CharArray[0]);
std::wstring_convert< std::codecvt_utf8<wchar_t> > Convert;
return Convert.to_bytes(WideString);
}
\ No newline at end of file
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "Components/StaticMeshComponent.h"
#include <string>
#include <vector>
#include "StaticGLTFComponent.generated.h"
/// Forward-declared TinyGLTF types since its header can only be #included in one source file.
/// This also means that we must use pointers to these types outside of GLTFMeshBuilder.cpp.
namespace tinygltf
{
class TinyGLTFLoader;
class Scene;
class Node;
struct ACCESSOR;
typedef struct ACCESSOR Accessor;
struct PRIMITIVE;
typedef struct PRIMITIVE Primitive;
struct MESH;
typedef struct MESH Mesh;
struct MATERIAL;
typedef struct MATERIAL Material;
}
/**
*
*/
UCLASS()
class MASTERTESTPROJECT_API UStaticGLTFComponent : public UStaticMeshComponent
{
GENERATED_BODY()
public:
UStaticGLTFComponent();
~UStaticGLTFComponent();
UPROPERTY(Category = GLTF, EditAnywhere, BlueprintReadWrite)
FString GLTFPath;
virtual void OnRegister() override;
private:
tinygltf::TinyGLTFLoader* Loader;
tinygltf::Scene* Scene;
bool tinygltfLoadSuccess;
FString tinygltfError;
/// @name String Conversion
///@{
/// Helper functions for converting between Unreal's and STL's strings.
static FString ToFString(std::string InString);
static std::string ToStdString(FString InString);
///@}
};
This source diff could not be displayed because it is too large. You can view the blob instead.
Copyright (c) 2016, Syoyo Fujita
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
......@@ -8,17 +8,55 @@
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);
StaticMeshComponentCopy->SetRelativeLocation(FVector(100.f));
StaticGLTFComponent->SetRelativeLocation(FVector(-100.f));
SetActorLocation(zero, false);
}
......
......@@ -3,6 +3,7 @@
#pragma once
#include "GameFramework/Actor.h"
#include "GLTF/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;
};
......@@ -5,17 +5,20 @@ using UnrealBuildTool;
public class MasterTestProject : ModuleRules
{
public MasterTestProject(TargetInfo Target)
{
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
{
PrivateDependencyModuleNames.AddRange(new string[] { });
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
PrivateDependencyModuleNames.AddRange(new string[] { });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
}
......@@ -3,3 +3,7 @@
#include "MasterTestProject.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, MasterTestProject, "MasterTestProject" );
//General Log
DEFINE_LOG_CATEGORY(GLTF);
......@@ -4,3 +4,5 @@
#include "Engine.h"
//General Log
DECLARE_LOG_CATEGORY_EXTERN(GLTF, Log, All);
......@@ -4,5 +4,3 @@
#include "MasterTestProjectGameModeBase.h"
......@@ -5,6 +5,7 @@
#include "GameFramework/GameModeBase.h"
#include "MasterTestProjectGameModeBase.generated.h"
/**
*
*/
......@@ -13,7 +14,7 @@ class MASTERTESTPROJECT_API AMasterTestProjectGameModeBase : public AGameModeBas
{
GENERATED_BODY()
};
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