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
6a593d2b
Commit
6a593d2b
authored
Jun 06, 2017
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
texture convert
parent
455c7bec
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
18 deletions
+62
-18
Minimal_Default.umap
Content/MobileStarterContent/Maps/Minimal_Default.umap
+0
-0
Minimal_Default_BuiltData.uasset
...obileStarterContent/Maps/Minimal_Default_BuiltData.uasset
+0
-0
DynamicTextureUtilities.cpp
Source/MasterTestProject/DynamicTextureUtilities.cpp
+3
-3
DynamicTextureUtilities.h
Source/MasterTestProject/DynamicTextureUtilities.h
+1
-1
Tileset.cpp
Source/MasterTestProject/Tileset.cpp
+58
-14
No files found.
Content/MobileStarterContent/Maps/Minimal_Default.umap
View file @
6a593d2b
No preview for this file type
Content/MobileStarterContent/Maps/Minimal_Default_BuiltData.uasset
View file @
6a593d2b
No preview for this file type
Source/MasterTestProject/DynamicTextureUtilities.cpp
View file @
6a593d2b
...
...
@@ -63,14 +63,14 @@ void UDynamicTextureUtilities::UpdateTextureRegion(UTexture2D* Texture, int32 Mi
}
}
void
UDynamicTextureUtilities
::
UpdateDynamicVectorTexture
(
const
TArray
<
FLinearColor
>&
Source
,
UTexture2D
*
Texture
)
void
UDynamicTextureUtilities
::
UpdateDynamicVectorTexture
(
const
TArray
<
FLinearColor
>&
Source
,
UTexture2D
*
Texture
,
bool
bFreeData
)
{
// Only handles 32-bit float textures
if
(
!
Texture
||
Texture
->
GetPixelFormat
()
!=
PF_
FloatRGB
)
return
;
if
(
!
Texture
||
Texture
->
GetPixelFormat
()
!=
PF_
A32B32G32R32F
)
return
;
// Shouldn't do anything if there's no data
if
(
Source
.
Num
()
<
1
)
return
;
UpdateTextureRegion
(
Texture
,
0
,
FUpdateTextureRegion2D
(
0
,
0
,
0
,
0
,
Texture
->
GetSizeX
(),
Texture
->
GetSizeY
()),
Texture
->
GetSizeX
()
*
sizeof
(
FLinearColor
),
sizeof
(
FLinearColor
),
(
uint8
*
)
Source
.
GetData
(),
false
);
UpdateTextureRegion
(
Texture
,
0
,
FUpdateTextureRegion2D
(
0
,
0
,
0
,
0
,
Texture
->
GetSizeX
(),
Texture
->
GetSizeY
()),
Texture
->
GetSizeX
()
*
sizeof
(
FLinearColor
),
sizeof
(
FLinearColor
),
(
uint8
*
)
Source
.
GetData
(),
bFreeData
);
}
UTexture2D
*
UDynamicTextureUtilities
::
CreateTransientDynamicTexture
(
int32
Width
,
int32
Height
,
EPixelFormat
PixelFormat
)
...
...
Source/MasterTestProject/DynamicTextureUtilities.h
View file @
6a593d2b
...
...
@@ -24,7 +24,7 @@ public:
static
void
UpdateTextureRegion
(
UTexture2D
*
Texture
,
int32
MipIndex
,
FUpdateTextureRegion2D
Region
,
uint32
SrcPitch
,
uint32
SrcBpp
,
uint8
*
SrcData
,
bool
bFreeData
);
// Convenience wrapper for updating a dynamic texture with an array of
// FLinearColors.
static
void
UpdateDynamicVectorTexture
(
const
TArray
<
FLinearColor
>&
Source
,
UTexture2D
*
Texture
);
static
void
UpdateDynamicVectorTexture
(
const
TArray
<
FLinearColor
>&
Source
,
UTexture2D
*
Texture
,
bool
bFreeData
=
true
);
// Sets up a component's material instance parameters (on all materials) for
// use with the supplied UTexture. The proper parameters (specified by
// IndexParameterName and TextureParameterName) should exist on the
...
...
Source/MasterTestProject/Tileset.cpp
View file @
6a593d2b
...
...
@@ -344,37 +344,81 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile)
UWorld
*
const
World
=
GetWorld
();
if
(
World
)
{
int32
TextureSize
=
FMath
::
FloorToInt
(
FMath
::
Sqrt
(
instances_length
))
+
1
;
int32
fill
=
TextureSize
*
TextureSize
-
instances_length
;
if
(
FeatureTableJSON
->
HasField
(
"POSITION"
))
{
// POSITION = float32[3]
uint32
featureTableBinaryOffset
=
pntheader
->
getFeatureStart
()
+
pntheader
->
featureTable
.
featureTableJSONByteLength
;
TSharedPtr
<
FJsonObject
>
binaryBodyReference
=
FeatureTableJSON
->
GetObjectField
(
"POSITION"
);
int32
byteOffset
=
binaryBodyReference
->
GetIntegerField
(
"byteOffset"
);
uint8
*
start
=
(
uint8
*
)(
data
.
GetData
()
+
pntheader
->
getFeatureBinaryStart
()
+
byteOffset
);
UTexture2D
*
points
=
UDynamicTextureUtilities
::
CreateDynamicTextureWithData
(
instances_length
,
start
);
//TODO create wit copy
//UTexture2D* points = UDynamicTextureUtilities::CreateDynamicTextureWithData(instances_length, start);
// creat pooint texture
TArray
<
FLinearColor
>
*
Points
=
new
TArray
<
FLinearColor
>
();
uint8
*
pos
=
start
;
for
(
size_t
i
=
0
;
i
<
instances_length
;
i
+=
1
)
{
Points
->
Add
(
FLinearColor
(
*
((
float
*
)
pos
),
*
((
float
*
)(
pos
+
4
)),
*
((
float
*
)(
pos
+
8
)),
1.0
f
));
pos
+=
12
;
}
for
(
size_t
i
=
0
;
i
<
fill
;
i
+=
1
)
{
Points
->
Add
(
FLinearColor
(
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
));
}
UTexture2D
*
Texture
=
UDynamicTextureUtilities
::
CreateTransientDynamicTexture
(
TextureSize
,
TextureSize
,
PF_A32B32G32R32F
);
UDynamicTextureUtilities
::
UpdateDynamicVectorTexture
(
*
Points
,
Texture
);
UE_LOG
(
TILES
,
Warning
,
TEXT
(
"Created Position Texture Number Points %d, TextureSize: %d, Fill: %d, "
),
instances_length
,
TextureSize
,
fill
);
if
(
TextureTest
&&
points
)
{
//ass texture to mAterial
if
(
TextureTest
)
{
UMaterialInstanceDynamic
*
Material
=
UMaterialInstanceDynamic
::
Create
(
TextureTest
->
GetStaticMeshComponent
()
->
GetMaterial
(
0
),
nullptr
);
Material
->
SetTextureParameterValue
(
FName
(
"DynamicTexture"
),
points
);
Material
->
SetTextureParameterValue
(
FName
(
"DynamicTexture"
),
Texture
);
TextureTest
->
GetStaticMeshComponent
()
->
SetMaterial
(
0
,
Material
);
}
/*
TArray<FVector> positons = getAsArray<FVector>(data.GetData(), (int32)(featureTableBinaryOffset + byteOffset), instances_length);
FString outputString = "[";
}
else
{
UE_LOG
(
TILES
,
Error
,
TEXT
(
"Pointcloud Quantized not supported Position Required"
));
}
for (FVector pos : positons)
if
(
FeatureTableJSON
->
HasField
(
"RGB"
))
{
// RGB = uint8[3]
uint32
featureTableBinaryOffset
=
pntheader
->
getFeatureStart
()
+
pntheader
->
featureTable
.
featureTableJSONByteLength
;
TSharedPtr
<
FJsonObject
>
binaryBodyReference
=
FeatureTableJSON
->
GetObjectField
(
"RGB"
);
int32
byteOffset
=
binaryBodyReference
->
GetIntegerField
(
"byteOffset"
);
uint8
*
start
=
(
uint8
*
)(
data
.
GetData
()
+
pntheader
->
getFeatureBinaryStart
()
+
byteOffset
);
// creat pooint texture
TArray
<
FLinearColor
>
*
ColorRGB
=
new
TArray
<
FLinearColor
>
();
uint8
*
pos
=
start
;
UE_LOG
(
TILES
,
Error
,
TEXT
(
"Color %s"
),
*
FLinearColor
((
*
pos
)
/
255
,
(
*
(
pos
+
1
))
/
255
,
(
*
(
pos
+
2
))
/
255
).
ToString
()
);
for
(
size_t
i
=
0
;
i
<
instances_length
;
i
+=
1
)
{
outputString += "[" + pos.ToString() + "] ";
ColorRGB
->
Add
(
FLinearColor
((
*
pos
)
/
255
,
(
*
(
pos
+
1
))
/
255
,
(
*
(
pos
+
2
))
/
255
));
pos
+=
3
;
}
outputString += "]";
UE_LOG(TILES, Warning, TEXT("PointCloudHeader 3D Model Positions %s"), *outputString);*/
}
else
{
UE_LOG
(
TILES
,
Error
,
TEXT
(
"Pointcloud Quantized not supported"
));
for
(
size_t
i
=
0
;
i
<
fill
;
i
+=
1
)
{
ColorRGB
->
Add
(
FLinearColor
(
1.0
f
,
0.0
f
,
0.0
f
));
}
UTexture2D
*
Texture
=
UDynamicTextureUtilities
::
CreateTransientDynamicTexture
(
TextureSize
,
TextureSize
,
PF_A32B32G32R32F
);
UDynamicTextureUtilities
::
UpdateDynamicVectorTexture
(
*
ColorRGB
,
Texture
);
UE_LOG
(
TILES
,
Warning
,
TEXT
(
"Created Color Texture Number Points %d, TextureSize: %d, Fill: %d, "
),
instances_length
,
TextureSize
,
fill
);
//ass texture to mAterial
if
(
TextureTest
)
{
UMaterialInstanceDynamic
*
Material
=
UMaterialInstanceDynamic
::
Create
(
TextureTest
->
GetStaticMeshComponent
()
->
GetMaterial
(
0
),
nullptr
);
Material
->
SetTextureParameterValue
(
FName
(
"DynamicTexture"
),
Texture
);
TextureTest
->
GetStaticMeshComponent
()
->
SetMaterial
(
0
,
Material
);
}
}
}
}
UE_LOG
(
TILES
,
Log
,
TEXT
(
"PointCloudHeader: End"
));
...
...
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