Skip to content

Commit

Permalink
Add support for mapy cz
Browse files Browse the repository at this point in the history
  • Loading branch information
eliemichel committed Aug 29, 2020
1 parent 98e9811 commit 5725d8f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion blender/MapsModelsImporter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
bl_info = {
"name": "Maps Models Importer",
"author": "Elie Michel",
"version": (0, 3, 0),
"version": (0, 3, 1),
"blender": (2, 82, 0),
"location": "File > Import > Google Maps Capture",
"description": "Import meshes from a Google Maps or Google Earth capture",
Expand Down
14 changes: 14 additions & 0 deletions blender/MapsModelsImporter/google_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def extractUniforms(constants, refMatrix):

# Extract constants, which have different names depending on the browser/GPU driver
globUniforms = constants['$Globals']
postMatrix = None
if '_w' in globUniforms and '_s' in globUniforms:
[ou, ov, su, sv] = globUniforms['_w']
ov -= 1.0 / sv
Expand All @@ -109,6 +110,16 @@ def extractUniforms(constants, refMatrix):
matrix = makeMatrix(globUniforms['_uMeshToWorldMatrix'])
matrix[3] = [0, 0, 0, 1]
#matrix = makeMatrix(globUniforms['_uModelviewMatrix']) @ matrix
elif '_uMV' in globUniforms:
# Mapy CZ
uvOffsetScale = [0, -1, 1, -1]
matrix = makeMatrix(globUniforms['_uMV'])
postMatrix = Matrix(
((0.682889997959137, 0.20221230387687683, 0.7019768357276917, -0.06431722640991211),
(0.07228320091962814, 0.9375065565109253, -0.3403771221637726, -0.11041564494371414),
(-0.7269363403320312, 0.28318125009536743, 0.6255972981452942, -1.349690556526184),
(0.0, 0.0, 0.0, 1.0))
) @ Matrix.Scale(500, 4)
else:
if refMatrix is None:
print("globUniforms:")
Expand All @@ -123,6 +134,9 @@ def extractUniforms(constants, refMatrix):
refMatrix = Matrix.Rotation(-pi/2, 4, 'Y') @ matrix.inverted()
matrix = refMatrix @ matrix

if postMatrix is not None:
matrix = postMatrix @ matrix

return uvOffsetScale, matrix, refMatrix

def addMesh(context, name, verts, tris, uvs):
Expand Down
12 changes: 10 additions & 2 deletions blender/MapsModelsImporter/google_maps_rd.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ def extractRelevantCalls(self, drawcalls, _strategy=0):
elif _strategy == 3:
first_call = "glClear(Color = <0.000000, 0.000000, 0.000000, 1.000000>, Depth = <0.000000>, Stencil = <0x00>)"
elif _strategy == 4:
first_call = ""
last_call = "ClearDepthStencilView"
drawcall_prefix = "DrawIndexed"
capture_type = "Mapy CZ"
elif _strategy == 5:
# With Google Earth there are two batches of DrawIndexed calls, we are interested in the second one
first_call = "DrawIndexed"
last_call = ""
Expand All @@ -135,11 +140,11 @@ def extractRelevantCalls(self, drawcalls, _strategy=0):
skipped_drawcalls, min_drawcall = self.findDrawcallBatch(drawcalls, first_call, drawcall_prefix, last_call)
if not skipped_drawcalls or not self.hasUniform(skipped_drawcalls[0], "_uProjModelviewMatrix"):
first_call = "INVALID CASE, SKIP ME"
elif _strategy == 5:
elif _strategy == 6:
first_call = "ClearRenderTargetView(0.000000, 0.000000, 0.000000"
last_call = "Draw(4)"
drawcall_prefix = "DrawIndexed"
elif _strategy == 6:
elif _strategy == 7:
first_call = "" # Try from the beginning on
last_call = "Draw(4)"
drawcall_prefix = "DrawIndexed"
Expand All @@ -157,6 +162,9 @@ def extractRelevantCalls(self, drawcalls, _strategy=0):
if not relevant_drawcalls:
return self.extractRelevantCalls(drawcalls, _strategy=_strategy+1)

if capture_type == "Mapy CZ" and not self.hasUniform(relevant_drawcalls[0], "_uMV"):
return self.extractRelevantCalls(drawcalls, _strategy=_strategy+1)

return relevant_drawcalls, capture_type

def run(self):
Expand Down

0 comments on commit 5725d8f

Please sign in to comment.