mirror of
https://github.com/blender/blender-addons.git
synced 2025-07-23 00:48:26 +00:00
Import_3ds: Added distance cue chunk import
Distance cue chunk will now be imported to a world maprange node nearplane and farplane values are set to sockets From Min and To Max
This commit is contained in:
@ -48,8 +48,11 @@ AMBIENTLIGHT = 0x2100 # The color of the ambient light
|
||||
FOG = 0x2200 # The fog atmosphere settings
|
||||
USE_FOG = 0x2201 # The fog atmosphere flag
|
||||
FOG_BGND = 0x2210 # The fog atmosphere background flag
|
||||
DISTANCE_CUE = 0x2300 # The distance cue atmosphere settings
|
||||
USE_DISTANCE_CUE = 0x2301 # The distance cue atmosphere flag
|
||||
LAYER_FOG = 0x2302 # The fog layer atmosphere settings
|
||||
USE_LAYER_FOG = 0x2303 # The fog layer atmosphere flag
|
||||
DCUE_BGND = 0x2310 # The distance cue background flag
|
||||
MATERIAL = 0xAFFF # This stored the texture info
|
||||
OBJECT = 0x4000 # This stores the faces, vertices, etc...
|
||||
|
||||
@ -945,8 +948,8 @@ def process_next_chunk(context, file, previous_chunk, imported_objects,
|
||||
bitmap_mix.inputs[2].default_value = nodes['Background'].inputs[0].default_value
|
||||
bitmapnode.image = load_image(bitmap_name, dirname, place_holder=False, recursive=IMAGE_SEARCH, check_existing=True)
|
||||
bitmap_mix.inputs[0].default_value = 0.5 if bitmapnode.image is not None else 1.0
|
||||
bitmapnode.location = (-520, 380) if bitmapnode.image is not None else (-520, 340)
|
||||
bitmap_mix.location = (-200, 320)
|
||||
bitmapnode.location = (-520, 400)
|
||||
bitmap_mix.location = (-200, 360)
|
||||
bitmapping.location = (-740, 400)
|
||||
coordinates = next((wn for wn in nodes if wn.type == 'TEX_COORD'), False)
|
||||
links.new(bitmap_mix.outputs[0], nodes['Background'].inputs[0])
|
||||
@ -954,7 +957,7 @@ def process_next_chunk(context, file, previous_chunk, imported_objects,
|
||||
links.new(bitmapping.outputs[0], bitmapnode.inputs[0])
|
||||
if not coordinates:
|
||||
coordinates = nodes.new(type='ShaderNodeTexCoord')
|
||||
coordinates.location = (-1340, 360)
|
||||
coordinates.location = (-1340, 400)
|
||||
if not bitmapping.inputs['Vector'].is_linked:
|
||||
links.new(coordinates.outputs[0], bitmapping.inputs[0])
|
||||
new_chunk.bytes_read += read_str_len
|
||||
@ -976,10 +979,10 @@ def process_next_chunk(context, file, previous_chunk, imported_objects,
|
||||
coordinate = next((wn for wn in nodes if wn.type == 'TEX_COORD'), False)
|
||||
backgroundmix = next((wn for wn in nodes if wn.type in {'MIX', 'MIX_RGB'}), False)
|
||||
mappingnode = next((wn for wn in nodes if wn.type == 'MAPPING'), False)
|
||||
conversion.location = (-740, -20)
|
||||
layerweight.location = (-940, 150)
|
||||
gradientnode.location = (-520, 20)
|
||||
normalnode.location = (-1140, 300)
|
||||
conversion.location = (-740, 20)
|
||||
layerweight.location = (-940, 160)
|
||||
gradientnode.location = (-520, 60)
|
||||
normalnode.location = (-1140, 340)
|
||||
gradientnode.label = "Gradient"
|
||||
conversion.operation = 'MULTIPLY_ADD'
|
||||
conversion.name = conversion.label = "Multiply"
|
||||
@ -991,7 +994,7 @@ def process_next_chunk(context, file, previous_chunk, imported_objects,
|
||||
links.new(normalnode.outputs[1], layerweight.inputs[0])
|
||||
if not coordinate:
|
||||
coordinate = nodes.new(type='ShaderNodeTexCoord')
|
||||
coordinate.location = (-1340, 360)
|
||||
coordinate.location = (-1340, 400)
|
||||
links.new(coordinate.outputs[6], normalnode.inputs[0])
|
||||
if backgroundmix:
|
||||
links.new(gradientnode.outputs[0], backgroundmix.inputs[2])
|
||||
@ -1038,7 +1041,7 @@ def process_next_chunk(context, file, previous_chunk, imported_objects,
|
||||
fognode = nodes.new(type='ShaderNodeVolumeAbsorption')
|
||||
fognode.label = "Fog"
|
||||
fognode.location = (10, 20)
|
||||
volumemix = next((wn for wn in worldnodes if wn.name == 'Volume' and wn.type in {'ADD_SHADER', 'MIX_SHADER'}), False)
|
||||
volumemix = next((wn for wn in worldnodes if wn.name == "Volume" and wn.type in {'ADD_SHADER', 'MIX_SHADER'}), False)
|
||||
if volumemix:
|
||||
links.new(fognode.outputs[0], volumemix.inputs[1])
|
||||
else:
|
||||
@ -1078,21 +1081,24 @@ def process_next_chunk(context, file, previous_chunk, imported_objects,
|
||||
layerfog = nodes.new(type='ShaderNodeVolumeScatter')
|
||||
fognode = next((wn for wn in worldnodes if wn.type == 'VOLUME_ABSORPTION'), False)
|
||||
if fognode:
|
||||
cuenode = next((wn for wn in worldnodes if wn.type == 'MAP_RANGE'), False)
|
||||
mxvolume = nodes.new(type='ShaderNodeMixShader')
|
||||
mxvolume.label = mxvolume.name = "Volume"
|
||||
mxvolume.location = (220, 0)
|
||||
links.new(litepath.outputs[7], mxvolume.inputs[0])
|
||||
cuesource = cuenode.outputs[0] if cuenode else litepath.outputs[7]
|
||||
cuetarget = cuenode.inputs[3] if cuenode else mxvolume.inputs[0]
|
||||
links.new(fognode.outputs[0], mxvolume.inputs[1])
|
||||
links.new(litepath.outputs[7], cuetarget)
|
||||
links.new(cuesource, mxvolume.inputs[0])
|
||||
links.new(mxvolume.outputs[0], worldfog)
|
||||
worldfog = mxvolume.inputs[2]
|
||||
layerfog.label = "Layer Fog"
|
||||
layerfog.location = (10, -120)
|
||||
worldout.location = (440, 160)
|
||||
litepath.location = (-200, 120)
|
||||
litepath.location = (-1140, 160)
|
||||
links.new(layerfog.outputs[0], worldfog)
|
||||
links.new(litepath.outputs[8], layerfog.inputs[2])
|
||||
links.new(litepath.outputs[0], nodes['Background'].inputs[1])
|
||||
context.view_layer.use_pass_mist = False
|
||||
contextWorld.mist_settings.use_mist = True
|
||||
contextWorld.mist_settings.start = read_float(new_chunk)
|
||||
contextWorld.mist_settings.height = read_float(new_chunk)
|
||||
@ -1113,6 +1119,41 @@ def process_next_chunk(context, file, previous_chunk, imported_objects,
|
||||
else:
|
||||
skip_to_end(file, temp_chunk)
|
||||
new_chunk.bytes_read += temp_chunk.bytes_read
|
||||
|
||||
# If distance cue chunk:
|
||||
elif CreateWorld and new_chunk.ID == DISTANCE_CUE:
|
||||
if contextWorld is None:
|
||||
path, filename = os.path.split(file.name)
|
||||
realname, ext = os.path.splitext(filename)
|
||||
contextWorld = bpy.data.worlds.new("DistanceCue: " + realname)
|
||||
context.scene.world = contextWorld
|
||||
contextWorld.use_nodes = True
|
||||
links = contextWorld.node_tree.links
|
||||
nodes = contextWorld.node_tree.nodes
|
||||
distcue_node = nodes.new(type='ShaderNodeMapRange')
|
||||
camera_data = nodes.new(type='ShaderNodeCameraData')
|
||||
distcue_node.label = "Distance Cue"
|
||||
distcue_node.clamp = False
|
||||
distcue_node.location = (-940, 20)
|
||||
camera_data.location = (-1340, -150)
|
||||
distcue_mix = next((wn for wn in worldnodes if wn.name == "Volume" and wn.type == 'MIX_SHADER'), False)
|
||||
distcuepath = next((wn for wn in worldnodes if wn.type == 'LIGHT_PATH'), False)
|
||||
if not distcuepath:
|
||||
distcuepath = nodes.new(type='ShaderNodeLightPath')
|
||||
distcuepath.location = (-1140, 160)
|
||||
raysource = distcuepath.outputs[7] if distcue_mix else distcuepath.outputs[0]
|
||||
raytarget = distcue_mix.inputs[0] if distcue_mix else nodes['Background'].inputs[1]
|
||||
links.new(camera_data.outputs[1], distcue_node.inputs[2])
|
||||
links.new(camera_data.outputs[2], distcue_node.inputs[0])
|
||||
links.new(raysource, distcue_node.inputs[3])
|
||||
links.new(distcue_node.outputs[0], raytarget)
|
||||
read_float(new_chunk)
|
||||
distcue_node.inputs[1].default_value = read_float(new_chunk)
|
||||
contextWorld.light_settings.distance = read_float(new_chunk)
|
||||
distcue_node.inputs[4].default_value = read_float(new_chunk)
|
||||
elif CreateWorld and new_chunk.ID == DCUE_BGND:
|
||||
pass
|
||||
|
||||
elif CreateWorld and new_chunk.ID in {USE_FOG, USE_LAYER_FOG}:
|
||||
context.view_layer.use_pass_mist = True
|
||||
|
||||
@ -1389,15 +1430,15 @@ def process_next_chunk(context, file, previous_chunk, imported_objects,
|
||||
ambinode.location = (10, 160)
|
||||
worldout.location = (440, 160)
|
||||
mixshade.location = (220, 280)
|
||||
ambilite.location = (-200, 20)
|
||||
raymixer.location = (-940, -20)
|
||||
mathnode.location = (-1140, 120)
|
||||
litefall.location = (-1140, -40)
|
||||
litepath.location = (-1340, 120)
|
||||
mathnode.location = (-1140, 0)
|
||||
ambilite.location = (-200, 60)
|
||||
raymixer.location = (-940, 340)
|
||||
litefall.location = (-1140, 160)
|
||||
litepath.location = (-1340, 160)
|
||||
links.new(litepath.outputs[0], mathnode.inputs[0])
|
||||
links.new(litepath.outputs[3], mathnode.inputs[1])
|
||||
links.new(litepath.outputs[5], mathnode.inputs[1])
|
||||
links.new(litepath.outputs[3], litefall.inputs[0])
|
||||
links.new(litepath.outputs[2], litefall.inputs[1])
|
||||
links.new(litepath.outputs[5], litefall.inputs[0])
|
||||
links.new(litefall.outputs[0], raymixer.inputs[2])
|
||||
links.new(mathnode.outputs[0], backlite.inputs[1])
|
||||
links.new(mathnode.outputs[0], ambinode.inputs[1])
|
||||
@ -1655,7 +1696,8 @@ def process_next_chunk(context, file, previous_chunk, imported_objects,
|
||||
# update the previous chunk bytes read
|
||||
previous_chunk.bytes_read += new_chunk.bytes_read
|
||||
|
||||
# FINISHED LOOP - There will be a number of objects still not added
|
||||
# FINISHED LOOP
|
||||
# There will be a number of objects still not added
|
||||
if CreateBlenderObject:
|
||||
putContextMesh(context, contextMesh_vertls, contextMesh_facels, contextMesh_flag,
|
||||
contextMeshMaterials, contextMesh_smooth, WORLD_MATRIX)
|
||||
|
Reference in New Issue
Block a user