Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
MasterTestProjekt
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kai Westerkamp
MasterTestProjekt
Commits
e766759e
Commit
e766759e
authored
Mar 21, 2017
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tileset.cpp
parent
cc9791ea
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
81 additions
and
52 deletions
+81
-52
Minimal_Default.umap
Content/MobileStarterContent/Maps/Minimal_Default.umap
+0
-0
Minimal_Default_BuiltData.uasset
...obileStarterContent/Maps/Minimal_Default_BuiltData.uasset
+0
-0
GLTFDownloader.cpp
Source/MasterTestProject/GLTFDownloader.cpp
+2
-3
HttpDownloader.cpp
Source/MasterTestProject/HttpDownloader.cpp
+2
-2
MasterTestProjectGameModeBase.cpp
Source/MasterTestProject/MasterTestProjectGameModeBase.cpp
+0
-17
MasterTestProjectGameModeBase.h
Source/MasterTestProject/MasterTestProjectGameModeBase.h
+0
-2
TileDownloader.cpp
Source/MasterTestProject/TileDownloader.cpp
+7
-4
TileDownloader.h
Source/MasterTestProject/TileDownloader.h
+3
-1
Tileset.cpp
Source/MasterTestProject/Tileset.cpp
+38
-6
Tileset.h
Source/MasterTestProject/Tileset.h
+20
-5
ProceduralEntity.cpp
Source/MasterTestProject/ue4-assimp/ProceduralEntity.cpp
+8
-10
ProceduralEntity.h
Source/MasterTestProject/ue4-assimp/ProceduralEntity.h
+1
-2
No files found.
Content/MobileStarterContent/Maps/Minimal_Default.umap
View file @
e766759e
No preview for this file type
Content/MobileStarterContent/Maps/Minimal_Default_BuiltData.uasset
View file @
e766759e
No preview for this file type
Source/MasterTestProject/GLTFDownloader.cpp
View file @
e766759e
...
...
@@ -13,7 +13,5 @@ void UGLTFDownloader::GetGLTF(AProceduralEntity * Reference, FString & baseUrl,
void
UGLTFDownloader
::
OnResponseReceived
(
FHttpRequestPtr
Request
,
FHttpResponsePtr
Response
,
bool
bWasSuccessful
)
{
reference
->
loadModel
(
Response
->
GetContent
());
UE_LOG
(
GLTF
,
Error
,
TEXT
(
"GLTF Loaded: %s "
),
*
Request
->
GetURL
());
//loadModel(Response);
reference
->
loadModel
(
Response
->
GetContent
().
GetData
(),
Response
->
GetContent
().
Num
());
}
\ No newline at end of file
Source/MasterTestProject/HttpDownloader.cpp
View file @
e766759e
...
...
@@ -12,7 +12,7 @@ void UHttpDownloader::DownloadFile(const FString &URL)
HttpRequest
->
OnProcessRequestComplete
().
BindUObject
(
this
,
&
UHttpDownloader
::
OnResponseReceived
);
// Execute the request
UE_LOG
(
TILES
,
Warnin
g
,
TEXT
(
"Downlaoding: %s "
),
*
HttpRequest
->
GetURL
());
UE_LOG
(
TILES
,
Lo
g
,
TEXT
(
"Downlaoding: %s "
),
*
HttpRequest
->
GetURL
());
HttpRequest
->
ProcessRequest
();
...
...
@@ -48,7 +48,7 @@ FString UHttpDownloader::ResolveRealativeURL(const FString &BaseUrl, const FStri
FString
url
=
basePath
+
"/"
+
RelativeUrlnormalized
;
UE_LOG
(
TILES
,
Log
,
TEXT
(
"Relative URl: Base:%s, Relative %s, -> %s "
),
*
BaseUrlnormalized
,
*
RelativeUrlnormalized
,
*
url
);
//
UE_LOG(TILES, Log, TEXT("Relative URl: Base:%s, Relative %s, -> %s "), *BaseUrlnormalized, *RelativeUrlnormalized, *url);
return
url
;
...
...
Source/MasterTestProject/MasterTestProjectGameModeBase.cpp
View file @
e766759e
// Fill out your copyright notice in the Description page of Project Settings.
#include "MasterTestProject.h"
#include "TileDownloader.h"
#include "MasterTestProjectGameModeBase.h"
void
AMasterTestProjectGameModeBase
::
InitGame
(
const
FString
&
MapName
,
const
FString
&
Options
,
FString
&
ErrorMessage
)
{
Super
::
InitGame
(
MapName
,
Options
,
ErrorMessage
);
//FString file = "D:\\Dropbox\\Studium\\MasterArbeit\\3d-tiles\\examples\\tileset.json";
FString
base
=
"file://D:
\\
Dropbox
\\
Studium
\\
MasterArbeit
\\
"
;
//FString base = "file://H:\\Repositories\\MasterArbeit\\";
FString
file
=
"3d-tiles-samples
\\
tilesets
\\
TilesetWithRequestVolume
\\
tileset.json"
;
rootTileset
=
new
FTileContent
();
rootTileset
->
url
=
file
;
UTileDownloader
*
downloader
=
NewObject
<
UTileDownloader
>
(
UTileDownloader
::
StaticClass
());
downloader
->
GetTileContent
(
rootTileset
,
base
);
}
Source/MasterTestProject/MasterTestProjectGameModeBase.h
View file @
e766759e
...
...
@@ -17,8 +17,6 @@ class MASTERTESTPROJECT_API AMasterTestProjectGameModeBase : public AGameModeBas
GENERATED_BODY
()
public
:
virtual
void
InitGame
(
const
FString
&
MapName
,
const
FString
&
Options
,
FString
&
ErrorMessage
);
FTileContent
*
rootTileset
;
};
Source/MasterTestProject/TileDownloader.cpp
View file @
e766759e
...
...
@@ -4,9 +4,12 @@
#include "TileDownloader.h"
void
UTileDownloader
::
GetTileContent
(
FTileContent
*
Content
,
FString
&
baseUrl
)
void
UTileDownloader
::
GetTileContent
(
ATilesetActor
*
Actor
,
FTileContent
*
Content
,
FString
&
baseUrl
,
FTile
*
tile
)
{
parent
=
Content
;
parentTile
=
tile
;
actor
=
Actor
;
DownloadFile
(
ResolveRealativeURL
(
baseUrl
,
*
Content
->
url
));
}
...
...
@@ -16,13 +19,13 @@ void UTileDownloader::OnResponseReceived(FHttpRequestPtr Request, FHttpResponseP
{
if
(
Response
.
IsValid
())
{
if
(
Request
->
GetURL
().
EndsWith
(
TEXT
(
".json"
)))
{
parent
->
tileset
=
UTilesetUtil
::
parseTileset
(
Response
->
GetContentAsString
(),
Request
->
GetURL
());
parent
->
tileset
=
actor
->
parseTileset
(
Response
->
GetContentAsString
(),
Request
->
GetURL
());
UE_LOG
(
TILES
,
Warning
,
TEXT
(
"Parsed Tilset: %s Scucess: %s "
),
*
Request
->
GetURL
(),
bWasSuccessful
?
TEXT
(
"True"
)
:
TEXT
(
"False"
));
}
else
{
UTilesetUtil
::
parseTile
(
Response
->
GetContent
(),
Request
->
GetURL
()
);
actor
->
parseTile
(
Response
->
GetContent
(),
parentTile
);
UE_LOG
(
TILES
,
Error
,
TEXT
(
"Parsed Tile: %s Scucess: %s "
),
*
Request
->
GetURL
(),
bWasSuccessful
?
TEXT
(
"True"
)
:
TEXT
(
"False"
));
UE_LOG
(
TILES
,
Warning
,
TEXT
(
"Parsed Tile: %s Scucess: %s "
),
*
Request
->
GetURL
(),
bWasSuccessful
?
TEXT
(
"True"
)
:
TEXT
(
"False"
));
}
}
else
{
...
...
Source/MasterTestProject/TileDownloader.h
View file @
e766759e
...
...
@@ -16,10 +16,12 @@ class MASTERTESTPROJECT_API UTileDownloader : public UHttpDownloader
private
:
FTileContent
*
parent
;
FTile
*
parentTile
;
ATilesetActor
*
actor
;
public
:
void
GetTileContent
(
FTileContent
*
Content
,
FString
&
baseUrl
);
void
GetTileContent
(
ATilesetActor
*
Actor
,
FTileContent
*
Content
,
FString
&
baseUrl
,
FTile
*
tile
=
nullptr
);
virtual
void
OnResponseReceived
(
FHttpRequestPtr
Request
,
FHttpResponsePtr
Response
,
bool
bWasSuccessful
);
...
...
Source/MasterTestProject/Tileset.cpp
View file @
e766759e
...
...
@@ -4,10 +4,22 @@
#include "JsonReader.h"
#include "JsonObjectConverter.h"
#include "TileDownloader.h"
#include "ue4-assimp/ProceduralEntity.h"
#include "Tileset.h"
FTileset
*
UTilesetUtil
::
parseTileset
(
FString
JsonString
,
FString
BaseURL
)
void
ATilesetActor
::
BeginPlay
()
{
Super
::
BeginPlay
();
rootTileset
=
new
FTileContent
();
rootTileset
->
url
=
relativeURL
;
UTileDownloader
*
downloader
=
NewObject
<
UTileDownloader
>
(
UTileDownloader
::
StaticClass
());
downloader
->
GetTileContent
(
this
,
rootTileset
,
host
);
}
FTileset
*
ATilesetActor
::
parseTileset
(
FString
JsonString
,
FString
BaseURL
)
{
//TODO error Handling
TSharedPtr
<
FJsonObject
>
JsonParsed
;
...
...
@@ -19,7 +31,7 @@ FTileset* UTilesetUtil::parseTileset(FString JsonString, FString BaseURL)
tileset
->
absoluteURL
=
BaseURL
;
TSharedPtr
<
FJsonObject
>
root
=
JsonParsed
->
GetObjectField
(
"root"
);
UTilesetUtil
::
parseTile
(
root
,
&
tileset
->
root
,
tileset
);
ATilesetActor
::
parseTile
(
root
,
&
tileset
->
root
,
tileset
);
//UE_LOG(TILES, Warning, TEXT("Parsed: Success:%s Version:\"%s\" geometricError:%f"), success ? TEXT("True") : TEXT("False"), *tileset.asset.version, tileset.geometricError);
...
...
@@ -29,7 +41,7 @@ FTileset* UTilesetUtil::parseTileset(FString JsonString, FString BaseURL)
return
nullptr
;
}
void
UTilesetUtil
::
parseTile
(
const
TArray
<
uint8
>
data
,
FString
BaseURL
)
void
ATilesetActor
::
parseTile
(
const
TArray
<
uint8
>
data
,
FTile
*
tile
)
{
TileHeader
*
header
=
(
TileHeader
*
)
data
.
GetData
();
...
...
@@ -38,12 +50,31 @@ void UTilesetUtil::parseTile(const TArray<uint8> data, FString BaseURL)
if
(
header
->
magic
[
0
]
==
'b'
&&
header
->
magic
[
1
]
==
'3'
&&
header
->
magic
[
2
]
==
'd'
&&
header
->
magic
[
3
]
==
'm'
)
{
Batch3DModelHeader
*
b3dmheader
=
(
Batch3DModelHeader
*
)
data
.
GetData
();
UE_LOG
(
TILES
,
Log
,
TEXT
(
"Batch %d %d %d"
),
b3dmheader
->
batchtable
.
batchTableJSONByteLength
,
b3dmheader
->
batchtable
.
batchTableBinaryByteLength
,
b3dmheader
->
batchLength
);
UWorld
*
const
World
=
GetWorld
();
if
(
World
)
{
AProceduralEntity
*
gltf
=
World
->
SpawnActor
<
AProceduralEntity
>
(
AProceduralEntity
::
StaticClass
());
if
(
tile
)
{
for
(
int32
b
=
0
;
b
<
tile
->
transform
.
Num
()
&&
b
<
20
;
b
++
)
{
UE_LOG
(
TILES
,
Log
,
TEXT
(
"Transform %.2f"
),
tile
->
transform
[
b
]);
}
}
gltf
->
AttachToActor
(
this
,
FAttachmentTransformRules
::
KeepWorldTransform
);
int
GLTFstart
=
b3dmheader
->
getGLTFStart
();
gltf
->
loadModel
(
&
data
.
GetData
()[
GLTFstart
],
(
data
.
Num
()
-
GLTFstart
));
}
}
}
void
UTilesetUtil
::
parseTile
(
TSharedPtr
<
FJsonObject
>
json
,
FTile
*
targetTile
,
FTileset
*
parent
)
{
void
ATilesetActor
::
parseTile
(
TSharedPtr
<
FJsonObject
>
json
,
FTile
*
targetTile
,
FTileset
*
parent
)
{
bool
success
=
FJsonObjectConverter
::
JsonObjectToUStruct
<
FTile
>
(
json
.
ToSharedRef
(),
targetTile
,
0
,
0
);
...
...
@@ -56,7 +87,7 @@ void UTilesetUtil::parseTile(TSharedPtr<FJsonObject> json, FTile *targetTile, FT
for
(
TSharedPtr
<
FJsonValue
>
child
:
children
)
{
FTile
newTile
;
UTilesetUtil
::
parseTile
(
child
->
AsObject
(),
&
newTile
,
parent
);
ATilesetActor
::
parseTile
(
child
->
AsObject
(),
&
newTile
,
parent
);
targetTile
->
children
.
Add
(
newTile
);
}
}
...
...
@@ -66,8 +97,9 @@ void UTilesetUtil::parseTile(TSharedPtr<FJsonObject> json, FTile *targetTile, FT
if
(
!
targetTile
->
content
.
url
.
IsEmpty
())
{
UTileDownloader
*
downloader
=
NewObject
<
UTileDownloader
>
(
UTileDownloader
::
StaticClass
());
downloader
->
GetTileContent
(
&
targetTile
->
content
,
parent
->
absoluteURL
);
downloader
->
GetTileContent
(
this
,
&
targetTile
->
content
,
parent
->
absoluteURL
,
targetTile
);
}
}
Source/MasterTestProject/Tileset.h
View file @
e766759e
...
...
@@ -190,7 +190,9 @@ struct Batch3DModelHeader {
BatchTableHeader
batchtable
;
uint32
batchLength
;
uint32
getGLTFStart
()
{
return
24
+
batchtable
.
batchTableJSONByteLength
+
batchtable
.
batchTableBinaryByteLength
;
}
};
...
...
@@ -199,16 +201,29 @@ struct Batch3DModelHeader {
*
*/
UCLASS
()
class
MASTERTESTPROJECT_API
UTilesetUtil
:
public
UObject
class
MASTERTESTPROJECT_API
ATilesetActor
:
public
AActor
{
GENERATED_BODY
()
public
:
static
FTileset
*
parseTileset
(
FString
JsonString
,
FString
BaseURL
);
static
void
parseTile
(
const
TArray
<
uint8
>
data
,
FString
BaseURL
);
UPROPERTY
(
EditAnywhere
,
BlueprintReadWrite
,
Category
=
"Generation"
)
FString
host
;
UPROPERTY
(
EditAnywhere
,
BlueprintReadWrite
,
Category
=
"Generation"
)
FString
relativeURL
;
// Called when the game starts or when spawned
virtual
void
BeginPlay
()
override
;
FTileset
*
parseTileset
(
FString
JsonString
,
FString
BaseURL
);
void
parseTile
(
const
TArray
<
uint8
>
data
,
FTile
*
tile
);
private
:
static
void
parseTile
(
TSharedPtr
<
FJsonObject
>
json
,
FTile
*
targetTile
,
FTileset
*
parent
);
FTileContent
*
rootTileset
;
void
parseTile
(
TSharedPtr
<
FJsonObject
>
json
,
FTile
*
targetTile
,
FTileset
*
parent
);
};
Source/MasterTestProject/ue4-assimp/ProceduralEntity.cpp
View file @
e766759e
...
...
@@ -25,9 +25,9 @@ AProceduralEntity::AProceduralEntity()
_mesh
=
CreateDefaultSubobject
<
UProceduralMeshComponent
>
(
TEXT
(
"ProcMesh"
));
if
(
_mesh
)
{
_mesh
->
CastShadow
=
true
;
_mesh
->
SetCollisionObjectType
(
ECC_WorldDynamic
);
_mesh
->
SetCollisionEnabled
(
ECollisionEnabled
::
QueryAndPhysics
);
_mesh
->
SetCollisionResponseToAllChannels
(
ECR_Block
);
//
_mesh->SetCollisionObjectType(ECC_WorldDynamic);
//
_mesh->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
//
_mesh->SetCollisionResponseToAllChannels(ECR_Block);
// _mesh->UpdateCollisionProfile();
RootComponent
=
_mesh
;
}
...
...
@@ -43,11 +43,9 @@ void AProceduralEntity::BeginPlay()
{
Super
::
BeginPlay
();
UGLTFDownloader
*
downloader
=
NewObject
<
UGLTFDownloader
>
(
UGLTFDownloader
::
StaticClass
());
FString
base
=
FString
(
TEXT
(
""
));
downloader
->
GetGLTF
(
this
,
base
,
_filePath
);
UE_LOG
(
GLTF
,
Error
,
TEXT
(
"Loading Path: %s"
),
*
_filePath
);
//UGLTFDownloader *downloader = NewObject<UGLTFDownloader>(UGLTFDownloader::StaticClass());
//FString base = FString(TEXT(""));
//downloader->GetGLTF(this, base, _filePath);
}
void
AProceduralEntity
::
PostActorCreated
()
{
...
...
@@ -248,10 +246,10 @@ void AProceduralEntity::processNode(aiNode* node, const aiScene* scene, FMatrix
}
void
AProceduralEntity
::
loadModel
(
TArray
<
uint8
>
data
)
{
void
AProceduralEntity
::
loadModel
(
const
uint8
*
RawFileData
,
int32
lenght
)
{
Assimp
::
Importer
importer
;
const
aiScene
*
scene
=
importer
.
ReadFileFromMemory
(
data
.
GetData
(),
data
.
Num
(),
aiProcess_Triangulate
|
aiProcess_FlipUVs
|
aiProcess_GenNormals
);
const
aiScene
*
scene
=
importer
.
ReadFileFromMemory
(
RawFileData
,
lenght
,
aiProcess_Triangulate
|
aiProcess_FlipUVs
|
aiProcess_GenNormals
,
"glb"
);
//UE_LOG(GLTF, Warning, TEXT("START LOGGING"));
//const aiScene* scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs | aiProcess_GenNormals);
...
...
Source/MasterTestProject/ue4-assimp/ProceduralEntity.h
View file @
e766759e
...
...
@@ -52,7 +52,7 @@ public:
//UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Materials")
//UTexture2D* diffTexture;
void
loadModel
(
TArray
<
uint8
>
data
);
void
loadModel
(
const
uint8
*
RawFileData
,
int32
lenght
);
private
:
int32
_selectedVertex
;
...
...
@@ -70,7 +70,6 @@ private:
TArray
<
TArray
<
FColor
>>
_vertexColors
;
//USceneComponent* _rootComp;
/* ################################################### */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment