Skip to content

Commit 5b35a26

Browse files
committed
Tweak map materials
1 parent 8a41d7a commit 5b35a26

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

io_scene_a3d/BattleMapBlenderImporter.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def createBlenderSpawnPoint(self, spawnPointData):
253253
#TODO: implement spawn type name lookup
254254
ob = bpy.data.objects.new(f"SpawnPoint_{spawnPointData.type}", None)
255255
ob.empty_display_type = "ARROWS"
256-
ob.empty_display_size = 100
256+
ob.empty_display_size = 100 # The map will be at 100x scale so it's a good idea to match that here
257257
ob.location = spawnPointData.position
258258
ob.rotation_mode = "XYZ"
259259
ob.rotation_euler = spawnPointData.rotation
@@ -266,8 +266,8 @@ def createBlenderMaterial(self, materialData):
266266
# Shader specific logic
267267
if materialData.shader == "TankiOnline/SingleTextureShader":
268268
bsdf = PrincipledBSDFWrapper(ma, is_readonly=False, use_nodes=True)
269-
bsdf.roughness = 1.0
270-
bsdf.ior = 1.0
269+
bsdf.roughness_set(1.0)
270+
bsdf.ior_set(1.0)
271271

272272
# Try load texture
273273
textureParameter = materialData.textureParameters[0]
@@ -277,8 +277,8 @@ def createBlenderMaterial(self, materialData):
277277
addImageTextureToMaterial(texture, ma.node_tree)
278278
elif materialData.shader == "TankiOnline/SpriteShader":
279279
bsdf = PrincipledBSDFWrapper(ma, is_readonly=False, use_nodes=True)
280-
bsdf.roughness = 1.0
281-
bsdf.ior = 1.0
280+
bsdf.roughness_set(1.0)
281+
bsdf.ior_set(1.0)
282282

283283
# Try load texture
284284
textureParameter = materialData.textureParameters[0]
@@ -287,6 +287,10 @@ def createBlenderMaterial(self, materialData):
287287

288288
addImageTextureToMaterial(texture, ma.node_tree, linkAlpha=True)
289289
elif materialData.shader == "TankiOnline/Terrain":
290-
pass
290+
# XXX: still need to figure out how to do the terrain properly, all manual attempts have yielded mixed results
291+
bsdf = PrincipledBSDFWrapper(ma, is_readonly=False, use_nodes=True)
292+
bsdf.roughness_set(1.0)
293+
bsdf.ior_set(1.0)
294+
bsdf.base_color_set((0.0, 0.0, 0.0))
291295

292296
return ma

io_scene_a3d/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from .BattleMapBlenderImporter import BattleMapBlenderImporter
3232

3333
from glob import glob
34+
from time import time
3435

3536
'''
3637
Addon preferences
@@ -69,6 +70,8 @@ def invoke(self, context, event):
6970
return ImportHelper.invoke(self, context, event)
7071

7172
def execute(self, context):
73+
importStartTime = time()
74+
7275
objects = []
7376
for file in self.files:
7477
filepath = self.directory + file.name
@@ -90,6 +93,9 @@ def execute(self, context):
9093
for obI, ob in enumerate(objects):
9194
collection.objects.link(ob)
9295

96+
importEndTime = time()
97+
self.report({'INFO'}, f"Imported {len(objects)} objects in {importEndTime-importStartTime}s")
98+
9399
return {"FINISHED"}
94100

95101
class ImportBattleMap(Operator, ImportHelper):
@@ -114,6 +120,9 @@ def invoke(self, context, event):
114120

115121
def execute(self, context):
116122
print(f"Reading BattleMap data from {self.filepath}")
123+
124+
importStartTime = time()
125+
117126
mapData = BattleMap()
118127
with open(self.filepath, "rb") as file:
119128
mapData.read(file)
@@ -127,6 +136,9 @@ def execute(self, context):
127136
collection = bpy.context.collection
128137
for ob in objects:
129138
collection.objects.link(ob)
139+
140+
importEndTime = time()
141+
self.report({'INFO'}, f"Imported {len(objects)} objects in {importEndTime-importStartTime}s")
130142

131143
return {"FINISHED"}
132144

0 commit comments

Comments
 (0)