Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions blender/MapsModelsImporter/google_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def captureToFiles(context, filepath, prefix, max_blocks):
import pickle
from bpy_extras import object_utils
from math import floor, pi
from mathutils import Matrix
from mathutils import Matrix, Vector
import os

def makeMatrix(mdata):
Expand Down Expand Up @@ -120,6 +120,11 @@ def extractUniforms(constants, refMatrix):
(-0.7269363403320312, 0.28318125009536743, 0.6255972981452942, -1.349690556526184),
(0.0, 0.0, 0.0, 1.0))
) @ Matrix.Scale(500, 4)
elif '_f' in globUniforms or '_i' in globUniforms:
# Google Chrome 85.0.4183.121 (64bit), RendorDoc 1.9, RTX 3090, https://smap.seoul.go.kr/
uvOffsetScale = [0, 0, 1/65535., 1/65535.]
matrix = makeMatrix(globUniforms['_f'])
postMatrix = Matrix.Scale(3, 4, Vector((1.0, 0., 0.)))
else:
if refMatrix is None:
print("globUniforms:")
Expand All @@ -130,8 +135,12 @@ def extractUniforms(constants, refMatrix):
return None, None, None

if refMatrix is None:
# Rotate around Y because Google Maps uses X as up axis
refMatrix = Matrix.Rotation(-pi/2, 4, 'Y') @ matrix.inverted()
if '_f' in globUniforms or '_i' in globUniforms:
# Rotate around Z, upside down for SMAP
refMatrix = Matrix.Rotation(-pi, 4, 'Z') @ matrix.inverted()
else:
# Rotate around Y because Google Maps uses X as up axis
refMatrix = Matrix.Rotation(-pi/2, 4, 'Y') @ matrix.inverted()
matrix = refMatrix @ matrix

if postMatrix is not None:
Expand Down Expand Up @@ -190,7 +199,7 @@ def loadData(prefix, drawcall_id):

# -----------------------------------------------------------------------------

def filesToBlender(context, prefix, max_blocks=200, globalScale=1.0/256.0):
def filesToBlender(context, prefix, max_blocks=200):
"""Import data from the files extracted by captureToFiles"""
# Get reference matrix
refMatrix = None
Expand Down Expand Up @@ -245,6 +254,9 @@ def filesToBlender(context, prefix, max_blocks=200, globalScale=1.0/256.0):

mesh_name = "BuildingMesh-{:05d}".format(drawcall_id)
obj = addMesh(context, mesh_name, verts, tris, uvs)
globalScale=1.0/256.0
if constants["DrawCall"]["type"] == 'SeoulMap':
globalScale=1.0
obj.matrix_world = matrix * globalScale

mat_name = "BuildingMat-{:05d}".format(drawcall_id)
Expand Down
29 changes: 19 additions & 10 deletions blender/MapsModelsImporter/google_maps_rd.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,20 @@ def run(self):
meshes = [makeMeshData(attr, ib, vbs, draw) for attr in attrs]

try:
if len(meshes) < 2:
continue
# Position
m = meshes[0]
m.fetchTriangle(controller)
indices = m.fetchIndices(controller)
with open("{}{:05d}-indices.bin".format(FILEPREFIX, drawcallId), 'wb') as file:
pickle.dump(indices, file)
unpacked = m.fetchData(controller)
if len(unpacked) < 1 or len(unpacked[0]) < 3:
continue
with open("{}{:05d}-positions.bin".format(FILEPREFIX, drawcallId), 'wb') as file:
pickle.dump(unpacked, file)
indices = m.fetchIndices(controller)
with open("{}{:05d}-indices.bin".format(FILEPREFIX, drawcallId), 'wb') as file:
pickle.dump(indices, file)


# UV
m = meshes[2 if capture_type == "Google Earth" else 1]
Expand All @@ -220,6 +225,17 @@ def run(self):
print("(Skipping: {})".format(err))
continue

# Texture
# dirty
bindpoints = state.GetBindpointMapping(rd.ShaderStage.Fragment)
if len(bindpoints.samplers) > 1:
capture_type = 'SeoulMap'
texture_bind = bindpoints.samplers[0].bind
else:
texture_bind = bindpoints.samplers[-1].bind
resources = state.GetReadOnlyResources(rd.ShaderStage.Fragment)
rid = resources[texture_bind].resources[0].resourceId

# Vertex Shader Constants
shader = state.GetShader(rd.ShaderStage.Vertex)
ep = state.GetShaderEntryPoint(rd.ShaderStage.Vertex)
Expand All @@ -231,13 +247,6 @@ def run(self):
}
with open("{}{:05d}-constants.bin".format(FILEPREFIX, drawcallId), 'wb') as file:
pickle.dump(constants, file)

# Texture
# dirty
bindpoints = state.GetBindpointMapping(rd.ShaderStage.Fragment)
texture_bind = bindpoints.samplers[-1].bind
resources = state.GetReadOnlyResources(rd.ShaderStage.Fragment)
rid = resources[texture_bind].resources[0].resourceId

texsave = rd.TextureSave()
texsave.resourceId = rid
Expand Down