You are not logged in.
- Topics: Active | Unanswered
Announcement
Please create new topics on the new site at community.openstreetmap.org. We expect the migration of data will take a few weeks, you can follow its progress here.***
#126 2017-08-16 09:56:53
- kendzi
- Member
- Registered: 2008-08-20
- Posts: 250
Re: Kendzi3D - 3D Viewer as plugin for JOSM.
Looks like you are using webstart. From java 8 it require some additional sigh of components. I do not support it. Please try to use standalone version of JOSM.
Offline
#127 2017-08-17 11:18:18
- krza
- Moderator
- From: Köln
- Registered: 2008-05-24
- Posts: 640
Re: Kendzi3D - 3D Viewer as plugin for JOSM.
Yes, I do. A few years ago I changed from updating manually to the webstart version.
I will try. Thanks for the hint.
Offline
#128 2017-08-18 06:16:33
- krza
- Moderator
- From: Köln
- Registered: 2008-05-24
- Posts: 640
Re: Kendzi3D - 3D Viewer as plugin for JOSM.
Works. That was the issue. Thanks.
Offline
#129 2018-03-09 16:22:42
- wombatstampede
- Member
- Registered: 2008-07-24
- Posts: 6
Re: Kendzi3D - 3D Viewer as plugin for JOSM.
Hi all!
I experimented a bit with the Collada/DAE Export of Kendzi3D and I created two Blender/Python scripts which helped me to handle the objects a bit better. I'll share the scripts here in case somebody can make use of it.
Script 1 is "merge_materials.py". The imported 3D models uses separate material names for each object. This script merges & renames all materials based on their texture name (file name) or Diffuse color if no texture is assigned. The script will work on all objects & materials in the blender project which follow the typical naming of ID__nnnnn:
import bpy
import re
scene = bpy.context.scene
# only search on own object materials
matchid = re.compile(r'^ID__(\d+|\d+\.\d+)$') #match osm building objects
matchmat = re.compile(r'^ID_material_[0-9.]+$') #match osm material
cleanprefix = "mat_"
ids = [obj for obj in scene.objects if matchid.match(obj.name)]
print("go")
bpy.ops.object.mode_set(mode='OBJECT') #works only in Object mode
for ob in ids:
bpy.context.scene.objects.active = ob #for bpy.ops.object.* methods to work
remove_slots = []
if ob.type == "MESH":
print("obj: "+ob.name)
mslots = [s.name for s in ob.material_slots] #just use names because slots may move because of append
for sname in mslots:
slist = [ms for ms in ob.material_slots if ms.name==sname]
if matchmat.match(sname) and (len(slist)>0):
s = slist[0]
print(" mat: "+sname)
dc=s.material.diffuse_color
cleanMatName = ("%scolor_%02x%02x%02x" % (cleanprefix, int(255*dc[0]),int(255*dc[1]),int(255*dc[2])))
if (s.material.active_texture is not None) and (s.material.active_texture.type=='IMAGE'):
# print(" tex: "+s.material.active_texture.image.name)
cleanMatName = cleanprefix + s.material.active_texture.image.name
if sname!=cleanMatName:
if bpy.data.materials.get(cleanMatName) is None:
#doesn't exist -> make this the new "clean" material, just rename it
print(" just rename -> "+cleanMatName)
s.material.name=cleanMatName
else:
#exists -> assign "wrong" material/faces to existing "clean" material and remove "wrong" material
wrongMatName = sname
cleanMat = bpy.data.materials.get(cleanMatName)
# check if "clean" material is missing in objects materials
if not (cleanMatName in [slot.material.name for slot in ob.material_slots]):
print(" add material slot for "+cleanMatName)
ob.data.materials.append(cleanMat)
#object s becomes invalid from here on
#alternatives: obs.data.active_material = cleanMat or bpy.ops.object.material_slot_add()
mat_list = [x.material.name for x in ob.material_slots] #"up to date" mat_list
index_clean = mat_list.index(cleanMatName)
index_wrong = mat_list.index(wrongMatName)
print(" reassign "+wrongMatName+"->"+cleanMatName+" ",index_wrong, index_clean)
print(" done")
# get the faces which are assigned to the 'wrong' material
faces = [x for x in ob.data.polygons if x.material_index == index_wrong]
for f in faces:
f.material_index = index_clean
remove_slots.append(wrongMatName)
# now remove all empty material slots:
for s in remove_slots:
if s in [x.name for x in ob.material_slots]:
print(' removing slot %s' % s)
ob.active_material_index = [x.material.name for x in ob.material_slots].index(s)
bpy.ops.object.material_slot_remove()
print("cleanup")
#remove all non-used materials
for material in bpy.data.materials:
if (not material.users) and (matchmat.match(material.name)):
print(' removing material %s' % material.name)
bpy.data.materials.remove(material)
The second script will try to join all meshes of i.e. a building. So it will join ID_100 with ID_100.001 and ID_100.002 etc. This will help reduce the number of objects and hopefully makes the handling of especially buildings easier:
import bpy
import re
def rename_uv(obj,name):
count=0
for uvmap in obj.data.uv_layers:
if count==0:
uvmap.name = name
else:
uvmap.name = ("%s_%03d" % (name,count) )
scene = bpy.context.scene
matchid = re.compile(r'^ID__\d+$')
ids = [obj for obj in scene.objects if matchid.match(obj.name)]
print("go")
for ob in ids:
if ob.type == "MESH":
for obj in bpy.data.objects: #slow but make sure we begin with no selected objects
obj.select = False
print(ob.name + "\n")
subobjs=[obj for obj in scene.objects if re.match(ob.name+"\\.\\d\\d\\d",obj.name)]
count=0
for subob in subobjs:
if subob.type == "MESH":
print(" +"+subob.name + "\n")
count+=1
subob.select = True
rename_uv(subob,'UVMap')
if count>0:
ob.select = True
rename_uv(ob,'UVMap')
bpy.context.scene.objects.active = ob
bpy.ops.object.join()
Last edited by wombatstampede (2018-03-09 16:31:23)
Offline
#130 2018-08-16 21:01:58
Offline
#131 2019-02-24 16:02:38
- Sowa1980
- Member
- From: Тамбов
- Registered: 2016-07-21
- Posts: 63
Re: Kendzi3D - 3D Viewer as plugin for JOSM.
When starting the JOSM program, the Kendzi3D - 3D Viewer as plugin for JOSM module opens simultaneously with the program, and when opening any layer of snapshots, similarly, how to fix it?
Offline