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
2906199f
Commit
2906199f
authored
Apr 26, 2017
by
wester
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
started Bounding Boxes
parent
6e1ee0e8
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
13 deletions
+74
-13
Tileset.cpp
Source/MasterTestProject/Tileset.cpp
+68
-8
Tileset.h
Source/MasterTestProject/Tileset.h
+3
-0
ProceduralEntity.cpp
Source/MasterTestProject/ue4-assimp/ProceduralEntity.cpp
+1
-3
ProceduralEntity.h
Source/MasterTestProject/ue4-assimp/ProceduralEntity.h
+1
-1
assimp
assimp
+1
-1
No files found.
Source/MasterTestProject/Tileset.cpp
View file @
2906199f
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include "TileDownloader.h"
#include "TileDownloader.h"
#include "ue4-assimp/ProceduralEntity.h"
#include "ue4-assimp/ProceduralEntity.h"
#include "Tileset.h"
#include "Tileset.h"
#include "Kismet/KismetMathLibrary.h"
ATilesetActor
::
ATilesetActor
(
const
FObjectInitializer
&
ObjectInitializer
)
{
ATilesetActor
::
ATilesetActor
(
const
FObjectInitializer
&
ObjectInitializer
)
{
...
@@ -75,8 +76,19 @@ void ATilesetActor::Tick(float DeltaSeconds)
...
@@ -75,8 +76,19 @@ void ATilesetActor::Tick(float DeltaSeconds)
double
FTile
::
getScreenSpaceError
(
double
lambda
,
FVector
CamLocation
)
double
FTile
::
getScreenSpaceError
(
double
lambda
,
FVector
CamLocation
)
{
{
FMatrix
matrix
=
FMatrix
();
if
(
content
.
absoluteTileTranforms
.
Num
()
>
0
)
{
matrix
=
content
.
absoluteTileTranforms
[
0
];
}
else
{
matrix
=
*
getAbsoluteTransform
();
}
FVector
ActorPos
=
FTransform
(
*
this
->
getAbsoluteTransform
()).
GetTranslation
();
FVector
ActorPos
=
FTransform
(
*
this
->
getAbsoluteTransform
()).
GetTranslation
();
double
dist
=
(
CamLocation
-
ActorPos
).
Size
();
double
dist
=
boundingVolume
.
getDistanceTo
(
CamLocation
,
matrix
);
(
CamLocation
-
ActorPos
).
Size
();
if
(
content
.
url
.
EndsWith
(
"i3d"
))
{
if
(
content
.
url
.
EndsWith
(
"i3d"
))
{
...
@@ -227,11 +239,13 @@ void ATilesetActor::parseBatched3DTile(const TArray<uint8> data, FTile * tile)
...
@@ -227,11 +239,13 @@ void ATilesetActor::parseBatched3DTile(const TArray<uint8> data, FTile * tile)
#endif
#endif
gltf
->
AttachToActor
(
this
,
FAttachmentTransformRules
::
KeepWorldTransform
);
gltf
->
AttachToActor
(
this
,
FAttachmentTransformRules
::
KeepWorldTransform
);
FMatrix
leftToRight
(
FVector
(
-
1
,
0
,
0
),
FVector
(
0
,
0
,
1
),
FVector
(
0
,
1
,
0
),
FVector
(
0
,
0
,
0
));
FMatrix
leftToRight
(
FVector
(
-
1
,
0
,
0
),
FVector
(
0
,
0
,
1
),
FVector
(
0
,
1
,
0
),
FVector
(
0
,
0
,
0
));
gltf
->
SetActorRelativeTransform
(
FTransform
(
leftToRight
*
*
tile
->
getAbsoluteTransform
()));
FMatrix
globalTielTransform
=
leftToRight
*
*
tile
->
getAbsoluteTransform
();
gltf
->
SetActorRelativeTransform
(
FTransform
(
globalTielTransform
));
int
GLTFstart
=
b3dmheader
->
getGLTFStart
();
int
GLTFstart
=
b3dmheader
->
getGLTFStart
();
gltf
->
loadModel
(
&
data
.
GetData
()[
GLTFstart
],
(
data
.
Num
()
-
GLTFstart
));
gltf
->
loadModel
(
&
data
.
GetData
()[
GLTFstart
],
(
data
.
Num
()
-
GLTFstart
));
tile
->
content
.
tiles
.
Add
(
gltf
);
tile
->
content
.
tiles
.
Add
(
gltf
);
tile
->
content
.
absoluteTileTranforms
.
Add
(
globalTielTransform
);
tile
->
setVisible
(
false
);
tile
->
setVisible
(
false
);
}
}
}
}
...
@@ -277,7 +291,8 @@ void ATilesetActor::parseInstanced3DTile(const TArray<uint8> data, FTile * tile)
...
@@ -277,7 +291,8 @@ void ATilesetActor::parseInstanced3DTile(const TArray<uint8> data, FTile * tile)
for
(
FVector
pos
:
positons
)
for
(
FVector
pos
:
positons
)
{
{
outputString
+=
"["
+
pos
.
ToString
()
+
"] "
;
outputString
+=
"["
+
pos
.
ToString
()
+
"] "
;
AProceduralEntity
*
clone
=
gltf
->
clone
(
pos
);
AProceduralEntity
*
clone
=
gltf
->
clone
();
FMatrix
instanceTranform
=
FMatrix
();
if
(
JsonParsed
->
GetBoolField
(
"EAST_NORTH_UP"
))
{
if
(
JsonParsed
->
GetBoolField
(
"EAST_NORTH_UP"
))
{
FVector
up
(
pos
);
FVector
up
(
pos
);
...
@@ -286,15 +301,22 @@ void ATilesetActor::parseInstanced3DTile(const TArray<uint8> data, FTile * tile)
...
@@ -286,15 +301,22 @@ void ATilesetActor::parseInstanced3DTile(const TArray<uint8> data, FTile * tile)
FVector
east
=
FVector
::
CrossProduct
(
Z
,
up
);
FVector
east
=
FVector
::
CrossProduct
(
Z
,
up
);
FVector
north
=
FVector
::
CrossProduct
(
east
,
up
);
FVector
north
=
FVector
::
CrossProduct
(
east
,
up
);
FMatrix
NEU
(
north
,
up
,
east
,
pos
);
FMatrix
NEU
(
north
,
up
,
east
,
pos
);
clone
->
SetActorTransform
(
FTransform
(
NEU
));
instanceTranform
=
NEU
;
}
else
{
FTransform
trans
=
FTransform
(
pos
);
instanceTranform
=
trans
.
ToMatrixWithScale
();
//TODO add rotation and ransform gltf -> tiles
}
}
clone
->
SetActorTransform
(
FTransform
(
instanceTranform
));
tile
->
content
.
absoluteTileTranforms
.
Add
(
instanceTranform
);
tile
->
content
.
tiles
.
Add
(
clone
);
tile
->
content
.
tiles
.
Add
(
clone
);
}
}
tile
->
content
.
tiles
.
Add
(
gltf
);
tile
->
content
.
tiles
.
Add
(
gltf
);
gltf
->
SetActorTransform
(
FTransform
(
positons
[
0
]));
FTransform
trans
=
FTransform
(
positons
[
0
]);
tile
->
content
.
absoluteTileTranforms
.
Add
(
trans
.
ToMatrixWithScale
());
gltf
->
SetActorTransform
(
trans
);
outputString
+=
"]"
;
outputString
+=
"]"
;
UE_LOG
(
TILES
,
Warning
,
TEXT
(
"InStanced 3D Model Positions %s"
),
*
outputString
);
UE_LOG
(
TILES
,
Warning
,
TEXT
(
"InStanced 3D Model Positions %s"
),
*
outputString
);
}
}
...
@@ -370,3 +392,41 @@ FMatrix * FTile::getAbsoluteTransform()
...
@@ -370,3 +392,41 @@ FMatrix * FTile::getAbsoluteTransform()
return
absoluteTransform
;
return
absoluteTransform
;
}
}
float
FBoundingVolume
::
getDistanceTo
(
FVector
Position
,
FMatrix
bouindingTransformation
)
{
FVector
localPos
=
bouindingTransformation
.
Inverse
().
TransformFVector4
(
FVector4
(
Position
,
1
));
float
distance
=
0.0
f
;
if
(
box
.
Num
()
==
12
)
{
FVector
Center
=
FVector
(
box
[
0
],
box
[
1
],
box
[
2
]);
//implicit Halflength
FVector
XAxis
=
FVector
(
box
[
3
],
box
[
4
],
box
[
5
]);
FVector
YAxis
=
FVector
(
box
[
6
],
box
[
7
],
box
[
8
]);
FVector
ZAxis
=
FVector
(
box
[
9
],
box
[
10
],
box
[
11
]);
//TODO FIXME is currently spher distance
UE_LOG
(
TILES
,
Error
,
TEXT
(
"Box distance is not implemented"
));
double
dist
=
(
localPos
-
Center
).
Size
();
distance
=
dist
-
FMath
::
Max3
(
XAxis
.
Size
(),
YAxis
.
Size
(),
ZAxis
.
Size
());
}
else
if
(
region
.
Num
()
==
6
)
{
// WGS84
//TODO FIXME is currently spher distance
UE_LOG
(
TILES
,
Error
,
TEXT
(
"Region distance is not implemented"
));
FVector
Center
=
FVector
(
0
,
0
,
6378137
);
double
dist
=
(
Position
-
Center
).
Size
();
distance
=
dist
;
}
else
if
(
sphere
.
Num
()
==
4
)
{
double
dist
=
(
localPos
-
FVector
(
sphere
[
0
],
sphere
[
1
],
sphere
[
2
])).
Size
();
distance
=
dist
-
sphere
[
3
];
}
else
{
UE_LOG
(
TILES
,
Error
,
TEXT
(
"Not Allowed Tranformation"
));
}
return
distance
;
}
Source/MasterTestProject/Tileset.h
View file @
2906199f
...
@@ -77,6 +77,8 @@ struct FBoundingVolume
...
@@ -77,6 +77,8 @@ struct FBoundingVolume
UPROPERTY
()
UPROPERTY
()
TArray
<
float
>
sphere
;
//4 Elemete
TArray
<
float
>
sphere
;
//4 Elemete
float
getDistanceTo
(
FVector
LocalPosition
,
FMatrix
bouindingTransformation
);
};
};
USTRUCT
()
USTRUCT
()
...
@@ -94,6 +96,7 @@ struct FTileContent
...
@@ -94,6 +96,7 @@ struct FTileContent
TArray
<
uint8
>
content
;
TArray
<
uint8
>
content
;
struct
FTileset
*
tileset
;
struct
FTileset
*
tileset
;
TArray
<
class
AProceduralEntity
*>
tiles
;
TArray
<
class
AProceduralEntity
*>
tiles
;
TArray
<
FMatrix
>
absoluteTileTranforms
;
FTileContent
()
{
FTileContent
()
{
tileset
=
nullptr
;
tileset
=
nullptr
;
...
...
Source/MasterTestProject/ue4-assimp/ProceduralEntity.cpp
View file @
2906199f
...
@@ -288,7 +288,7 @@ void AProceduralEntity::loadModel(const uint8* RawFileData, int32 lenght) {
...
@@ -288,7 +288,7 @@ void AProceduralEntity::loadModel(const uint8* RawFileData, int32 lenght) {
UE_LOG
(
GLTF
,
Log
,
TEXT
(
"GLTF loaded: %i Vertecies in %f seconds"
),
_numVertecies
,
end
-
start
);
UE_LOG
(
GLTF
,
Log
,
TEXT
(
"GLTF loaded: %i Vertecies in %f seconds"
),
_numVertecies
,
end
-
start
);
}
}
AProceduralEntity
*
AProceduralEntity
::
clone
(
const
FVector
position
)
AProceduralEntity
*
AProceduralEntity
::
clone
()
{
{
FActorSpawnParameters
Parameters
;
FActorSpawnParameters
Parameters
;
Parameters
.
Template
=
this
;
Parameters
.
Template
=
this
;
...
@@ -298,8 +298,6 @@ AProceduralEntity* AProceduralEntity::clone(const FVector position)
...
@@ -298,8 +298,6 @@ AProceduralEntity* AProceduralEntity::clone(const FVector position)
#if WITH_EDITOR
#if WITH_EDITOR
New
->
SetFolderPath
(
this
->
GetFolderPath
());
New
->
SetFolderPath
(
this
->
GetFolderPath
());
#endif
#endif
FTransform
trans
=
FTransform
(
position
);
New
->
SetActorTransform
(
trans
);
return
New
;
return
New
;
...
...
Source/MasterTestProject/ue4-assimp/ProceduralEntity.h
View file @
2906199f
...
@@ -56,7 +56,7 @@ public:
...
@@ -56,7 +56,7 @@ public:
void
loadModel
(
const
uint8
*
RawFileData
,
int32
lenght
);
void
loadModel
(
const
uint8
*
RawFileData
,
int32
lenght
);
AProceduralEntity
*
clone
(
FVector
position
);
AProceduralEntity
*
clone
();
void
setActorDisabled
(
bool
disabled
);
void
setActorDisabled
(
bool
disabled
);
...
...
assimp
@
1ab85f16
Subproject commit
63485bdd265729d2ae8c65ef0bc4c6bfe4c4df73
Subproject commit
1ab85f16ff687c214ebe61a1f598b3de60fe2487
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