mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-24 20:51:35 +00:00
[io_qfmap] File off a pile of bitrot
While much is broken, especially textures, e4m8.map successfully imports into blender 4.2-ish, and even the entity relation lines seem to work (which surprised me as those were the first sign of trouble).
This commit is contained in:
parent
a037f9146a
commit
baa4099de6
3 changed files with 44 additions and 18 deletions
|
@ -19,7 +19,7 @@
|
|||
|
||||
# <pep8 compliant>
|
||||
|
||||
import bpy, bgl, gpu
|
||||
import bpy, gpu
|
||||
from gpu_extras.batch import batch_for_shader
|
||||
from bpy.props import BoolProperty, FloatProperty, StringProperty, EnumProperty
|
||||
from bpy.props import BoolVectorProperty, CollectionProperty, PointerProperty
|
||||
|
@ -86,11 +86,11 @@ def draw_callback(self, context):
|
|||
#FIXME horribly inefficient
|
||||
qfmap = context.scene.qfmap
|
||||
content = build_batch(qfmap)
|
||||
shader = gpu.shader.from_builtin('3D_SMOOTH_COLOR')
|
||||
shader = gpu.shader.from_builtin('SMOOTH_COLOR')
|
||||
batch = batch_for_shader(shader, 'LINES', content)
|
||||
bgl.glLineWidth(3)
|
||||
#bgl.glLineWidth(3)
|
||||
batch.draw(shader)
|
||||
bgl.glLineWidth(1)
|
||||
#bgl.glLineWidth(1)
|
||||
|
||||
class VIEW3D_PT_QFEntityRelations(bpy.types.Panel):
|
||||
bl_space_type = 'VIEW_3D'
|
||||
|
|
|
@ -54,25 +54,45 @@ def load_image(tx):
|
|||
p[l + 2] = c[2] / 255.0
|
||||
p[l + 3] = 1.0
|
||||
img.pixels[:] = p[:]
|
||||
img.pack(True)
|
||||
img.pack()
|
||||
return img
|
||||
|
||||
def load_material(tx):
|
||||
if tx.name in bpy.data.materials:
|
||||
return bpy.data.materials[tx.name]
|
||||
mat = bpy.data.materials.new(tx.name)
|
||||
mat.blend_method = 'OPAQUE'
|
||||
mat.diffuse_color = (1, 1, 1, 1)
|
||||
mat.metallic = 1
|
||||
mat.roughness = 1
|
||||
mat.specular_intensity = 0
|
||||
mat.use_nodes = True
|
||||
if tx.image:
|
||||
tex = bpy.data.textures.new(tx.name, 'IMAGE')
|
||||
tex.extension = 'REPEAT'
|
||||
tex.use_preview_alpha = True
|
||||
tex.image = tx.image
|
||||
mat.texture_slots.add()
|
||||
ts = mat.texture_slots[0]
|
||||
ts.texture = tex
|
||||
ts.use_map_alpha = True
|
||||
ts.texture_coords = 'UV'
|
||||
emissionNode = mat.node_tree.nodes.new("ShaderNodeEmission")
|
||||
shaderOut = mat.node_tree.nodes["Material Output"]
|
||||
mat.node_tree.nodes.remove(mat.node_tree.nodes["Principled BSDF"])
|
||||
|
||||
tex_node = mat.node_tree.nodes.new("ShaderNodeTexImage")
|
||||
tex_node.image = tx.image
|
||||
tex_node.interpolation = "Closest"
|
||||
|
||||
emissionNode.location = (0, 0)
|
||||
shaderOut.location = (200, 0)
|
||||
tex_node.location = (-300, 0)
|
||||
|
||||
mat.node_tree.links.new(tex_node.outputs[0], emissionNode.inputs[0])
|
||||
mat.node_tree.links.new(emissionNode.outputs[0], shaderOut.inputs[0])
|
||||
|
||||
#FIXME uvs etc
|
||||
#tex = bpy.data.textures.new(tx.name, 'IMAGE')
|
||||
#tex.extension = 'REPEAT'
|
||||
#tex.use_preview_alpha = True
|
||||
#tex.image = tx.image
|
||||
#ts = mat.texture_paint_slots.new()
|
||||
#ts = mat.texture_paint_slots[0]
|
||||
#ts.texture = tex
|
||||
#ts.use_map_alpha = True
|
||||
#ts.texture_coords = 'UV'
|
||||
return mat
|
||||
|
||||
def load_textures(texdefs, wads):
|
||||
|
@ -114,13 +134,14 @@ def process_entity(ent, wads):
|
|||
name = classname
|
||||
if "classname" in ent.d and ent.d["classname"][:5] == "light":
|
||||
light = bpy.data.lights.new("light", 'POINT')
|
||||
light.use_custom_distance = True
|
||||
if "light" in ent.d:
|
||||
light.distance = float(ent.d["light"])
|
||||
light.cutoff_distance = float(ent.d["light"])
|
||||
elif "_light" in ent.d:
|
||||
light.distance = float(ent.d["_light"])
|
||||
light.cutoff_distance = float(ent.d["_light"])
|
||||
else:
|
||||
light.distance = 300.0
|
||||
light.falloff_type = 'CUSTOM_CURVE'
|
||||
light.cutoff_distance = 300.0
|
||||
#light.falloff_type = 'CUSTOM_CURVE'
|
||||
obj = bpy.data.objects.new(name, light)
|
||||
elif ent.b:
|
||||
verts = []
|
||||
|
|
|
@ -123,6 +123,8 @@ def clip_plane(plane, clip_planes):
|
|||
poly = [o + s + t, o + s - t, o - s - t, o - s + t] #CW
|
||||
for p in clip_planes:
|
||||
poly = clip_poly(poly, p, True)
|
||||
if not poly:
|
||||
break
|
||||
return poly
|
||||
|
||||
EPSILON = 0.5**5 # 1/32 plenty for quake maps
|
||||
|
@ -135,6 +137,9 @@ def convert_planes(planes):
|
|||
faces = []
|
||||
for i in range(len(planes)):
|
||||
poly = clip_plane(planes[i], planes[:i] + planes[i + 1:])
|
||||
if not poly:
|
||||
# the plane got clipped away
|
||||
continue
|
||||
face = []
|
||||
for v in poly:
|
||||
v = Vector((rnd(v.x), rnd(v.y), rnd(v.z)))
|
||||
|
|
Loading…
Reference in a new issue