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
756191bf
Commit
756191bf
authored
Mar 29, 2017
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
i3dm
parent
bb9138ce
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
19 deletions
+94
-19
Tileset.cpp
Source/MasterTestProject/Tileset.cpp
+81
-16
Tileset.h
Source/MasterTestProject/Tileset.h
+13
-3
No files found.
Source/MasterTestProject/Tileset.cpp
View file @
756191bf
...
@@ -71,38 +71,103 @@ void ATilesetActor::parseTile(TSharedPtr<FJsonObject> json, FTile *targetTile, F
...
@@ -71,38 +71,103 @@ void ATilesetActor::parseTile(TSharedPtr<FJsonObject> json, FTile *targetTile, F
}
}
}
}
void
ATilesetActor
::
parse
3DTile
(
const
TArray
<
uint8
>
data
,
FTile
*
tile
)
void
ATilesetActor
::
parse
Batched3DTile
(
const
TArray
<
uint8
>
data
,
FTile
*
tile
)
{
{
TileHeader
*
header
=
(
TileHeader
*
)
data
.
GetData
();
Batch3DModelHeader
*
b3dmheader
=
(
Batch3DModelHeader
*
)
data
.
GetData
();
UE_LOG
(
TILES
,
Log
,
TEXT
(
"Batch3DModel Batches: %d"
),
b3dmheader
->
batchLength
);
UWorld
*
const
World
=
GetWorld
();
if
(
World
)
{
AProceduralEntity
*
gltf
=
World
->
SpawnActor
<
AProceduralEntity
>
(
AProceduralEntity
::
StaticClass
());
gltf
->
tile
=
*
tile
;
#if WITH_EDITOR
gltf
->
SetFolderPath
(
FName
(
*
(
"SpawnedGLTF/"
+
this
->
GetName
())));
#endif
gltf
->
AttachToActor
(
this
,
FAttachmentTransformRules
::
KeepWorldTransform
);
gltf
->
SetActorRelativeTransform
(
FTransform
(
*
tile
->
getAbsoluteTransform
()));
int
GLTFstart
=
b3dmheader
->
getGLTFStart
();
UE_LOG
(
TILES
,
Warning
,
TEXT
(
"Shared Tile Header: Magic: %s Version %d lenght %d, array lenght %d "
),
*
header
->
getMagicAsFString
(),
header
->
version
,
header
->
byteLength
,
data
.
Num
());
gltf
->
loadModel
(
&
data
.
GetData
()[
GLTFstart
],
(
data
.
Num
()
-
GLTFstart
));
}
}
void
ATilesetActor
::
parseInstanced3DTile
(
const
TArray
<
uint8
>
data
,
FTile
*
tile
)
{
Instanced3DModelHeader
*
i3dmheader
=
(
Instanced3DModelHeader
*
)
data
.
GetData
();
FString
featureJSON
=
i3dmheader
->
getpartAsString
(
i3dmheader
->
getFeatureStart
(),
i3dmheader
->
featureTable
.
featureTableJSONByteLength
);
UE_LOG
(
TILES
,
Log
,
TEXT
(
"Instanced3DModelHeader GLTFFormat %s FeatureTable JSON: %s"
),
i3dmheader
->
gltfFormat
==
0
?
TEXT
(
"URL"
)
:
TEXT
(
"Binary GLTF"
),
*
featureJSON
);
TSharedPtr
<
FJsonObject
>
JsonParsed
;
TSharedRef
<
TJsonReader
<
TCHAR
>>
JsonReader
=
TJsonReaderFactory
<
TCHAR
>::
Create
(
featureJSON
);
if
(
FJsonSerializer
::
Deserialize
(
JsonReader
,
JsonParsed
))
{
int32
instances_length
=
JsonParsed
->
GetIntegerField
(
"INSTANCES_LENGTH"
);
// FIXME is uint32;
if
(
header
->
isB3DM
())
{
Batch3DModelHeader
*
b3dmheader
=
(
Batch3DModelHeader
*
)
data
.
GetData
();
UE_LOG
(
TILES
,
Log
,
TEXT
(
"Batch3DModel Batches: %d"
),
b3dmheader
->
batchLength
);
UWorld
*
const
World
=
GetWorld
();
UWorld
*
const
World
=
GetWorld
();
if
(
World
)
if
(
World
)
{
{
AProceduralEntity
*
gltf
=
World
->
SpawnActor
<
AProceduralEntity
>
(
AProceduralEntity
::
StaticClass
());
if
(
i3dmheader
->
gltfFormat
==
1
)
{
gltf
->
tile
=
*
tile
;
AProceduralEntity
*
gltf
=
World
->
SpawnActor
<
AProceduralEntity
>
(
AProceduralEntity
::
StaticClass
());
gltf
->
tile
=
*
tile
;
#if WITH_EDITOR
#if WITH_EDITOR
gltf
->
SetFolderPath
(
FName
(
*
(
"SpawnedGLTF/"
+
this
->
GetName
())));
gltf
->
SetFolderPath
(
FName
(
*
(
"SpawnedGLTF/"
+
this
->
GetName
())));
#endif
#endif
gltf
->
AttachToActor
(
this
,
FAttachmentTransformRules
::
KeepWorldTransform
);
gltf
->
AttachToActor
(
this
,
FAttachmentTransformRules
::
KeepWorldTransform
);
gltf
->
SetActorRelativeTransform
(
FTransform
(
*
tile
->
getAbsoluteTransform
()));
gltf
->
SetActorRelativeTransform
(
FTransform
(
*
tile
->
getAbsoluteTransform
()));
int
GLTFstart
=
b3dmheader
->
getGLTFStart
();
int
GLTFstart
=
i3dmheader
->
getGLTFStart
();
gltf
->
loadModel
(
&
data
.
GetData
()[
GLTFstart
],
(
data
.
Num
()
-
GLTFstart
));
//https://answers.unrealengine.com/questions/136562/is-there-a-way-to-clone-duplicate-an-actor-in-c.html
if
(
JsonParsed
->
HasField
(
"POSITION"
))
{
uint32
featureTableBinaryOffset
=
i3dmheader
->
getFeatureStart
()
+
i3dmheader
->
featureTable
.
featureTableJSONByteLength
;
TSharedPtr
<
FJsonObject
>
binaryBodyReference
=
JsonParsed
->
GetObjectField
(
"POSITION"
);
int32
byteOffset
=
binaryBodyReference
->
GetIntegerField
(
"byteOffset"
);
TArray
<
FVector
>
positons
=
TArray
<
FVector
>
();
// getAsArray<FVector>(data.GetData(), featureTableBinaryOffset + byteOffset, instances_length);
FString
outputString
=
"["
;
for
(
FVector
pos
:
positons
)
{
outputString
+=
"["
+
pos
.
ToString
()
+
"] "
;
}
outputString
+=
"]"
;
UE_LOG
(
TILES
,
Warning
,
TEXT
(
"InStanced 3D Model Positions %s"
),
*
outputString
);
}
else
{
UE_LOG
(
TILES
,
Warning
,
TEXT
(
"INStanced 3D Model Position Quantized not Supported in %s"
),
*
tile
->
content
.
url
);
}
}
gltf
->
loadModel
(
&
data
.
GetData
()[
GLTFstart
],
(
data
.
Num
()
-
GLTFstart
));
}
}
}
}
void
ATilesetActor
::
parse3DTile
(
const
TArray
<
uint8
>
data
,
FTile
*
tile
)
{
TileHeader
*
header
=
(
TileHeader
*
)
data
.
GetData
();
UE_LOG
(
TILES
,
Warning
,
TEXT
(
"Shared Tile Header: Magic: %s Version %d lenght %d, array lenght %d "
),
*
header
->
getMagicAsFString
(),
header
->
version
,
header
->
byteLength
,
data
.
Num
());
if
(
header
->
isB3DM
())
{
parseBatched3DTile
(
data
,
tile
);
}
}
else
if
(
header
->
isI3DM
())
{
else
if
(
header
->
isI3DM
())
{
Instanced3DModelHeader
*
i3dmheader
=
(
Instanced3DModelHeader
*
)
data
.
GetData
();
parseInstanced3DTile
(
data
,
tile
);
FString
featureJSON
=
i3dmheader
->
getpartAsString
(
i3dmheader
->
getFeatureStart
(),
i3dmheader
->
featureTable
.
featureTableJSONByteLength
);
UE_LOG
(
TILES
,
Log
,
TEXT
(
"Instanced3DModelHeader GLTFFormat %s FeatureTable JSON: %s"
),
i3dmheader
->
gltfFormat
==
0
?
TEXT
(
"URL"
)
:
TEXT
(
"Binary GLTF"
)
,
*
featureJSON
);
}
}
}
}
FMatrix
*
FTile
::
getMatrix
()
FMatrix
*
FTile
::
getMatrix
()
{
{
if
(
realtiveTransform
==
nullptr
)
{
if
(
realtiveTransform
==
nullptr
)
{
...
...
Source/MasterTestProject/Tileset.h
View file @
756191bf
...
@@ -296,8 +296,18 @@ private:
...
@@ -296,8 +296,18 @@ private:
void
parseTile
(
TSharedPtr
<
FJsonObject
>
json
,
FTile
*
targetTile
,
FTileset
*
parent
);
void
parseTile
(
TSharedPtr
<
FJsonObject
>
json
,
FTile
*
targetTile
,
FTileset
*
parent
);
void
parseBatched3DTile
(
const
TArray
<
uint8
>
data
,
FTile
*
tile
);
void
parseInstanced3DTile
(
const
TArray
<
uint8
>
data
,
FTile
*
tile
);
template
<
typename
T
>
TArray
<
T
>
getAsArray
(
uint8
*
data
,
int32
offset
,
int32
numberOfElements
);
};
};
template
<
typename
T
>
inline
TArray
<
T
>
ATilesetActor
::
getAsArray
(
uint8
*
data
,
int32
offset
,
int32
numberOfElements
)
{
//T *ArrayPointer = (T*)(data + offset);
//TArray<T> result;
//result.Append(ArrayPointer, numberOfElements);
//return result;
return
TArray
<
T
>
();
}
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