mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-25 05:01:24 +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>
|
# <pep8 compliant>
|
||||||
|
|
||||||
import bpy, bgl, gpu
|
import bpy, gpu
|
||||||
from gpu_extras.batch import batch_for_shader
|
from gpu_extras.batch import batch_for_shader
|
||||||
from bpy.props import BoolProperty, FloatProperty, StringProperty, EnumProperty
|
from bpy.props import BoolProperty, FloatProperty, StringProperty, EnumProperty
|
||||||
from bpy.props import BoolVectorProperty, CollectionProperty, PointerProperty
|
from bpy.props import BoolVectorProperty, CollectionProperty, PointerProperty
|
||||||
|
@ -86,11 +86,11 @@ def draw_callback(self, context):
|
||||||
#FIXME horribly inefficient
|
#FIXME horribly inefficient
|
||||||
qfmap = context.scene.qfmap
|
qfmap = context.scene.qfmap
|
||||||
content = build_batch(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)
|
batch = batch_for_shader(shader, 'LINES', content)
|
||||||
bgl.glLineWidth(3)
|
#bgl.glLineWidth(3)
|
||||||
batch.draw(shader)
|
batch.draw(shader)
|
||||||
bgl.glLineWidth(1)
|
#bgl.glLineWidth(1)
|
||||||
|
|
||||||
class VIEW3D_PT_QFEntityRelations(bpy.types.Panel):
|
class VIEW3D_PT_QFEntityRelations(bpy.types.Panel):
|
||||||
bl_space_type = 'VIEW_3D'
|
bl_space_type = 'VIEW_3D'
|
||||||
|
|
|
@ -54,25 +54,45 @@ def load_image(tx):
|
||||||
p[l + 2] = c[2] / 255.0
|
p[l + 2] = c[2] / 255.0
|
||||||
p[l + 3] = 1.0
|
p[l + 3] = 1.0
|
||||||
img.pixels[:] = p[:]
|
img.pixels[:] = p[:]
|
||||||
img.pack(True)
|
img.pack()
|
||||||
return img
|
return img
|
||||||
|
|
||||||
def load_material(tx):
|
def load_material(tx):
|
||||||
if tx.name in bpy.data.materials:
|
if tx.name in bpy.data.materials:
|
||||||
return bpy.data.materials[tx.name]
|
return bpy.data.materials[tx.name]
|
||||||
mat = bpy.data.materials.new(tx.name)
|
mat = bpy.data.materials.new(tx.name)
|
||||||
|
mat.blend_method = 'OPAQUE'
|
||||||
mat.diffuse_color = (1, 1, 1, 1)
|
mat.diffuse_color = (1, 1, 1, 1)
|
||||||
|
mat.metallic = 1
|
||||||
|
mat.roughness = 1
|
||||||
mat.specular_intensity = 0
|
mat.specular_intensity = 0
|
||||||
|
mat.use_nodes = True
|
||||||
if tx.image:
|
if tx.image:
|
||||||
tex = bpy.data.textures.new(tx.name, 'IMAGE')
|
emissionNode = mat.node_tree.nodes.new("ShaderNodeEmission")
|
||||||
tex.extension = 'REPEAT'
|
shaderOut = mat.node_tree.nodes["Material Output"]
|
||||||
tex.use_preview_alpha = True
|
mat.node_tree.nodes.remove(mat.node_tree.nodes["Principled BSDF"])
|
||||||
tex.image = tx.image
|
|
||||||
mat.texture_slots.add()
|
tex_node = mat.node_tree.nodes.new("ShaderNodeTexImage")
|
||||||
ts = mat.texture_slots[0]
|
tex_node.image = tx.image
|
||||||
ts.texture = tex
|
tex_node.interpolation = "Closest"
|
||||||
ts.use_map_alpha = True
|
|
||||||
ts.texture_coords = 'UV'
|
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
|
return mat
|
||||||
|
|
||||||
def load_textures(texdefs, wads):
|
def load_textures(texdefs, wads):
|
||||||
|
@ -114,13 +134,14 @@ def process_entity(ent, wads):
|
||||||
name = classname
|
name = classname
|
||||||
if "classname" in ent.d and ent.d["classname"][:5] == "light":
|
if "classname" in ent.d and ent.d["classname"][:5] == "light":
|
||||||
light = bpy.data.lights.new("light", 'POINT')
|
light = bpy.data.lights.new("light", 'POINT')
|
||||||
|
light.use_custom_distance = True
|
||||||
if "light" in ent.d:
|
if "light" in ent.d:
|
||||||
light.distance = float(ent.d["light"])
|
light.cutoff_distance = float(ent.d["light"])
|
||||||
elif "_light" in ent.d:
|
elif "_light" in ent.d:
|
||||||
light.distance = float(ent.d["_light"])
|
light.cutoff_distance = float(ent.d["_light"])
|
||||||
else:
|
else:
|
||||||
light.distance = 300.0
|
light.cutoff_distance = 300.0
|
||||||
light.falloff_type = 'CUSTOM_CURVE'
|
#light.falloff_type = 'CUSTOM_CURVE'
|
||||||
obj = bpy.data.objects.new(name, light)
|
obj = bpy.data.objects.new(name, light)
|
||||||
elif ent.b:
|
elif ent.b:
|
||||||
verts = []
|
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
|
poly = [o + s + t, o + s - t, o - s - t, o - s + t] #CW
|
||||||
for p in clip_planes:
|
for p in clip_planes:
|
||||||
poly = clip_poly(poly, p, True)
|
poly = clip_poly(poly, p, True)
|
||||||
|
if not poly:
|
||||||
|
break
|
||||||
return poly
|
return poly
|
||||||
|
|
||||||
EPSILON = 0.5**5 # 1/32 plenty for quake maps
|
EPSILON = 0.5**5 # 1/32 plenty for quake maps
|
||||||
|
@ -135,6 +137,9 @@ def convert_planes(planes):
|
||||||
faces = []
|
faces = []
|
||||||
for i in range(len(planes)):
|
for i in range(len(planes)):
|
||||||
poly = clip_plane(planes[i], planes[:i] + planes[i + 1:])
|
poly = clip_plane(planes[i], planes[:i] + planes[i + 1:])
|
||||||
|
if not poly:
|
||||||
|
# the plane got clipped away
|
||||||
|
continue
|
||||||
face = []
|
face = []
|
||||||
for v in poly:
|
for v in poly:
|
||||||
v = Vector((rnd(v.x), rnd(v.y), rnd(v.z)))
|
v = Vector((rnd(v.x), rnd(v.y), rnd(v.z)))
|
||||||
|
|
Loading…
Reference in a new issue