Эх сурвалжийг харах

Merge pull request #147 from Jason0214/more_material_support

make material export optional, add EEVEE support
Lu Jiacheng 6 жил өмнө
parent
commit
220d14142a

+ 17 - 12
io_scene_godot/__init__.py

@@ -56,7 +56,7 @@ class ExportGodot(bpy.types.Operator, ExportHelper):
         items=(
         items=(
             ("EMPTY", "Empty", ""),
             ("EMPTY", "Empty", ""),
             ("CAMERA", "Camera", ""),
             ("CAMERA", "Camera", ""),
-            ("LIGHT", "LIGHT", ""),
+            ("LIGHT", "Light", ""),
             ("ARMATURE", "Armature", ""),
             ("ARMATURE", "Armature", ""),
             ("MESH", "Mesh", ""),
             ("MESH", "Mesh", ""),
             # ("CURVE", "Curve", ""),
             # ("CURVE", "Curve", ""),
@@ -71,16 +71,22 @@ class ExportGodot(bpy.types.Operator, ExportHelper):
         },
         },
     )
     )
 
 
-    use_export_shape_key = BoolProperty(
-        name="Export Shape Key",
-        description="Export all the shape keys in mesh objects",
+    use_visible_objects = BoolProperty(
+        name="Only Visible Object",
+        description="Export only objects which are in the current view layer "
+                    "and are visible.",
         default=True,
         default=True,
     )
     )
     use_export_selected = BoolProperty(
     use_export_selected = BoolProperty(
-        name="Selected Objects",
+        name="Only Selected Objects",
         description="Export only selected objects",
         description="Export only selected objects",
         default=False,
         default=False,
     )
     )
+    use_mesh_modifiers = BoolProperty(
+        name="Apply Modifiers",
+        description="Apply modifiers to mesh objects (on a copy!).",
+        default=True,
+    )
     use_exclude_ctrl_bone = BoolProperty(
     use_exclude_ctrl_bone = BoolProperty(
         name="Exclude Control Bones",
         name="Exclude Control Bones",
         description="Do not export control bones (bone.use_deform = false)",
         description="Do not export control bones (bone.use_deform = false)",
@@ -94,15 +100,14 @@ class ExportGodot(bpy.types.Operator, ExportHelper):
                     "own AnimationPlayer hold their actions",
                     "own AnimationPlayer hold their actions",
         default=True,
         default=True,
     )
     )
-    use_mesh_modifiers = BoolProperty(
-        name="Apply Modifiers",
-        description="Apply modifiers to mesh objects (on a copy!).",
+    use_export_material = BoolProperty(
+        name="Export Materinal",
+        description="Export all the material associated with mesh surfaces",
         default=True,
         default=True,
     )
     )
-    use_visible_objects = BoolProperty(
-        name="Visible Object",
-        description="Export only objects which are in the current view layer "
-                    "and are visible.",
+    use_export_shape_key = BoolProperty(
+        name="Export Shape Key",
+        description="Export all the shape keys in mesh objects",
         default=True,
         default=True,
     )
     )
     use_stashed_action = BoolProperty(
     use_stashed_action = BoolProperty(

+ 2 - 1
io_scene_godot/converters/material.py

@@ -71,7 +71,8 @@ def generate_material_resource(escn_file, export_settings, material):
         # to convert material to external file
         # to convert material to external file
         material_rsc_name = ''
         material_rsc_name = ''
 
 
-    if engine == 'CYCLES' and material.node_tree is not None:
+    if (engine in ('CYCLES', 'BLENDER_EEVEE') and
+            material.node_tree is not None):
         mat = InternalResource("ShaderMaterial", material_rsc_name)
         mat = InternalResource("ShaderMaterial", material_rsc_name)
         try:
         try:
             export_node_tree(
             export_node_tree(

+ 15 - 5
io_scene_godot/converters/material_node_tree/node_vistors.py

@@ -346,11 +346,20 @@ def visit_texture_coord_node(shader, node):
 
 
 def visit_rgb_node(shader, node):
 def visit_rgb_node(shader, node):
     """Convert rgb input node to shader scripts"""
     """Convert rgb input node to shader scripts"""
-    output = node.outputs[0]
-    shader.assign_variable_to_socket(
-        output,
-        Value.create_from_blender_value(output.default_value)
-    )
+    rgb_socket = node.outputs[0]
+    var = shader.define_variable_from_socket(node, rgb_socket)
+    shader.append_assignment_code(
+        var, Value.create_from_blender_value(rgb_socket.default_value))
+    shader.assign_variable_to_socket(rgb_socket, var)
+
+
+def visit_value_node(shader, node):
+    """Visit ShaderNodeValue"""
+    value_socket = node.outputs['Value']
+    var = shader.define_variable_from_socket(node, value_socket)
+    shader.append_assignment_code(
+        var, Value.create_from_blender_value(value_socket.default_value))
+    shader.assign_variable_to_socket(value_socket, var)
 
 
 
 
 def visit_image_texture_node(shader, node):
 def visit_image_texture_node(shader, node):
@@ -525,6 +534,7 @@ NODE_VISITOR_FUNCTIONS = {
     'ShaderNodeAddShader': visit_add_shader_node,
     'ShaderNodeAddShader': visit_add_shader_node,
     'ShaderNodeTangent': visit_tangent_node,
     'ShaderNodeTangent': visit_tangent_node,
     'ShaderNodeUVMap': visit_uvmap_node,
     'ShaderNodeUVMap': visit_uvmap_node,
+    'ShaderNodeValue': visit_value_node,
 }
 }
 
 
 
 

+ 4 - 2
io_scene_godot/converters/mesh.py

@@ -106,7 +106,8 @@ def export_object_link_material(escn_file, export_settings, mesh_object,
     for index, slot in enumerate(mesh_object.material_slots):
     for index, slot in enumerate(mesh_object.material_slots):
         if slot.link == 'OBJECT' and slot.material is not None:
         if slot.link == 'OBJECT' and slot.material is not None:
             surface_id = mesh_resource.get_surface_id(index)
             surface_id = mesh_resource.get_surface_id(index)
-            if surface_id is not None:
+            if (surface_id is not None and
+                    export_settings['use_export_material']):
                 gd_node['material/{}'.format(surface_id)] = export_material(
                 gd_node['material/{}'.format(surface_id)] = export_material(
                     escn_file,
                     escn_file,
                     export_settings,
                     export_settings,
@@ -360,7 +361,8 @@ class MeshResourceExporter:
                 surfaces.append(surface)
                 surfaces.append(surface)
                 if mesh.materials:
                 if mesh.materials:
                     mat = mesh.materials[face.material_index]
                     mat = mesh.materials[face.material_index]
-                    if mat is not None:
+                    if (mat is not None and
+                            export_settings['use_export_material']):
                         surface.material = export_material(
                         surface.material = export_material(
                             escn_file,
                             escn_file,
                             export_settings,
                             export_settings,

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
tests/reference_exports/action_animation/animation_bone_transform.escn


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
tests/reference_exports/action_with_constraint/constraint_external_IK.escn


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
tests/reference_exports/action_with_constraint/constraint_internal_IK.escn


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
tests/reference_exports/action_with_constraint/stashed_constraint.escn


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
tests/reference_exports/armature/armature_bone_attachment.escn


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
tests/reference_exports/armature/armature_with_non_deform_bone.escn


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
tests/reference_exports/armature/armature_with_other_vertex_groups.escn


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
tests/reference_exports/material_cycle/material_anistropy.escn


+ 6 - 6
tests/reference_exports/mesh/just_mesh.escn

@@ -14,7 +14,7 @@ surfaces/0 = {
 		null, ; No UV2,
 		null, ; No UV2,
 		null, ; No Bones,
 		null, ; No Bones,
 		null, ; No Weights,
 		null, ; No Weights,
-		IntArray(0, 2, 1, 3, 1, 4, 5, 4, 6, 7, 6, 8, 0, 5, 9, 9, 8, 10, 11, 10, 2, 1, 10, 6, 0, 1, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 5, 0, 3, 0, 9, 11, 9, 5, 7, 9, 10, 11, 11, 2, 0, 10, 1, 2, 1, 6, 4, 6, 10, 8)
+		IntArray(0, 2, 1, 3, 1, 4, 5, 4, 6, 7, 6, 8, 0, 5, 9, 9, 8, 10, 11, 10, 2, 8, 1, 10, 0, 1, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 5, 0, 3, 0, 9, 11, 9, 5, 7, 9, 10, 11, 11, 2, 0, 10, 1, 2, 1, 6, 4, 6, 1, 8)
 	],
 	],
 	"morph_arrays":[]
 	"morph_arrays":[]
 }
 }
@@ -25,15 +25,15 @@ resource_name = "Cylinder002"
 surfaces/0 = {
 surfaces/0 = {
 	"primitive":4,
 	"primitive":4,
 	"arrays":[
 	"arrays":[
-		Vector3Array(0.0, 1.0, -1.0, 0.866025, -1.0, -0.5, 0.0, -1.0, -1.0, 0.866025, 1.0, -0.5, 0.866025, -1.0, 0.5, 0.866025, 1.0, 0.5, -8.74228e-08, -1.0, 1.0, -8.74228e-08, 1.0, 1.0, -0.866025, -1.0, 0.5, 0.0, 1.0, -1.0, -0.866025, 1.0, 0.5, 0.866025, 1.0, 0.5, -0.866025, 1.0, 0.5, -0.866025, -1.0, -0.5, -0.866025, 1.0, -0.5, 0.866025, -1.0, -0.5, -8.74228e-08, -1.0, 1.0, -0.866025, -1.0, -0.5, 0.866025, 1.0, -0.5, -0.866025, 1.0, -0.5, -8.74228e-08, 1.0, 1.0, 0.0, -1.0, -1.0, 0.866025, -1.0, 0.5, -0.866025, -1.0, 0.5),
-		Vector3Array(-6.57235e-08, 0.0, -1.0, 0.866025, 0.0, -0.5, -2.19078e-08, 0.0, -1.0, 0.866025, 0.0, -0.5, 0.866025, 0.0, 0.5, 0.866025, 0.0, 0.5, -8.76314e-08, 0.0, 1.0, -8.76314e-08, 0.0, 1.0, -0.866025, 0.0, 0.5, 4.58837e-08, 1.0, 0.0, 6.30901e-08, 1.0, 0.0, 2.86773e-08, 1.0, 0.0, -0.866025, 0.0, 0.5, -0.866025, 0.0, -0.5, -0.866025, 0.0, -0.5, 2.29418e-08, -1.0, 0.0, 2.29418e-08, -1.0, 0.0, 2.29419e-08, -1.0, 0.0, 0.0, 1.0, 0.0, 1.37651e-07, 1.0, 0.0, 6.88255e-08, 1.0, 0.0, 1.37651e-07, -1.0, 0.0, 1.37651e-07, -1.0, 0.0, 1.37651e-07, -1.0, 0.0),
+		Vector3Array(0.0, 1.0, -1.0, 0.866025, -1.0, -0.5, 0.0, -1.0, -1.0, 0.866025, 1.0, -0.5, 0.866025, -1.0, 0.5, 0.866025, 1.0, 0.5, -8.74228e-08, -1.0, 1.0, -8.74228e-08, 1.0, 1.0, -0.866025, -1.0, 0.5, 0.0, 1.0, -1.0, -0.866025, 1.0, 0.5, 0.866025, 1.0, 0.5, -0.866025, 1.0, 0.5, -0.866025, -1.0, -0.5, -0.866025, 1.0, -0.5, -0.866025, -1.0, 0.5, -0.866025, -1.0, -0.5, 0.866025, -1.0, -0.5, 0.866025, 1.0, -0.5, -0.866025, 1.0, -0.5, -8.74228e-08, 1.0, 1.0, 0.0, -1.0, -1.0, 0.866025, -1.0, 0.5, -8.74228e-08, -1.0, 1.0),
+		Vector3Array(-6.57235e-08, 0.0, -1.0, 0.866025, 0.0, -0.5, -2.19078e-08, 0.0, -1.0, 0.866025, 0.0, -0.5, 0.866025, 0.0, 0.5, 0.866025, 0.0, 0.5, -8.76314e-08, 0.0, 1.0, -8.76314e-08, 0.0, 1.0, -0.866025, 0.0, 0.5, 4.58837e-08, 1.0, 0.0, 6.30901e-08, 1.0, 0.0, 2.86773e-08, 1.0, 0.0, -0.866025, 0.0, 0.5, -0.866025, 0.0, -0.5, -0.866025, 0.0, -0.5, 0.0, -1.0, 0.0, 3.44128e-08, -1.0, 0.0, 6.88255e-08, -1.0, 0.0, 0.0, 1.0, 0.0, 1.37651e-07, 1.0, 0.0, 6.88255e-08, 1.0, 0.0, 1.37651e-07, -1.0, 0.0, 1.37651e-07, -1.0, 0.0, 3.44128e-08, -1.0, 0.0),
 		null, ; No Tangents,
 		null, ; No Tangents,
 		null, ; no Vertex Colors,
 		null, ; no Vertex Colors,
 		null, ; No UV1,
 		null, ; No UV1,
 		null, ; No UV2,
 		null, ; No UV2,
 		null, ; No Bones,
 		null, ; No Bones,
 		null, ; No Weights,
 		null, ; No Weights,
-		IntArray(0, 2, 1, 3, 1, 4, 5, 4, 6, 7, 6, 8, 9, 11, 10, 12, 8, 13, 14, 13, 2, 15, 17, 16, 0, 1, 3, 3, 4, 5, 5, 6, 7, 7, 8, 12, 11, 9, 18, 9, 10, 19, 10, 11, 20, 12, 13, 14, 14, 2, 0, 17, 15, 21, 15, 16, 22, 16, 17, 23)
+		IntArray(0, 2, 1, 3, 1, 4, 5, 4, 6, 7, 6, 8, 9, 11, 10, 12, 8, 13, 14, 13, 2, 15, 17, 16, 0, 1, 3, 3, 4, 5, 5, 6, 7, 7, 8, 12, 11, 9, 18, 9, 10, 19, 10, 11, 20, 12, 13, 14, 14, 2, 0, 16, 17, 21, 17, 23, 22, 23, 17, 15)
 	],
 	],
 	"morph_arrays":[]
 	"morph_arrays":[]
 }
 }
@@ -44,8 +44,8 @@ resource_name = "Cylinder001"
 surfaces/0 = {
 surfaces/0 = {
 	"primitive":4,
 	"primitive":4,
 	"arrays":[
 	"arrays":[
-		Vector3Array(0.0, 1.0, -1.0, 0.866025, -1.0, -0.5, 0.0, -1.0, -1.0, 0.866025, 1.0, -0.5, 0.866025, -1.0, 0.5, 0.866025, -1.0, -0.5, 0.866025, 1.0, 0.5, -8.74228e-08, -1.0, 1.0, 0.866025, -1.0, 0.5, -8.74228e-08, 1.0, 1.0, -0.866025, -1.0, 0.5, -8.74228e-08, -1.0, 1.0, 0.0, 1.0, -1.0, -0.866025, 1.0, 0.5, 0.866025, 1.0, 0.5, -0.866025, 1.0, 0.5, -0.866025, -1.0, -0.5, -0.866025, -1.0, 0.5, -0.866025, 1.0, -0.5, 0.0, -1.0, -1.0, -0.866025, -1.0, -0.5, 0.866025, -1.0, -0.5, -8.74228e-08, -1.0, 1.0, -0.866025, -1.0, -0.5, 0.866025, 1.0, -0.5, 0.866025, 1.0, -0.5, 0.866025, 1.0, 0.5, 0.866025, -1.0, 0.5, 0.866025, 1.0, 0.5, -8.74228e-08, 1.0, 1.0, -8.74228e-08, -1.0, 1.0, -8.74228e-08, 1.0, 1.0, -0.866025, 1.0, 0.5, -0.866025, -1.0, 0.5, 0.866025, 1.0, 0.5, 0.866025, 1.0, -0.5, 0.0, 1.0, -1.0, 0.0, 1.0, -1.0, -0.866025, 1.0, -0.5, -0.866025, 1.0, 0.5, -0.866025, 1.0, 0.5, -8.74228e-08, 1.0, 1.0, 0.866025, 1.0, 0.5, -0.866025, 1.0, -0.5, 0.0, 1.0, -1.0, -0.866025, -1.0, -0.5, 0.0, -1.0, -1.0, 0.866025, -1.0, -0.5, 0.866025, -1.0, -0.5, 0.866025, -1.0, 0.5, -8.74228e-08, -1.0, 1.0, -8.74228e-08, -1.0, 1.0, -0.866025, -1.0, 0.5, -0.866025, -1.0, -0.5),
-		Vector3Array(0.5, 0.0, -0.866025, 0.5, 0.0, -0.866025, 0.5, 0.0, -0.866025, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.5, 0.0, 0.866025, 0.5, 0.0, 0.866025, 0.5, 0.0, 0.866025, -0.5, 0.0, 0.866025, -0.5, 0.0, 0.866025, -0.5, 0.0, 0.866025, 2.29418e-08, 1.0, 0.0, 2.29418e-08, 1.0, 0.0, 2.29418e-08, 1.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -0.5, 0.0, -0.866025, -0.5, 0.0, -0.866025, -0.5, 0.0, -0.866025, -9.17674e-08, -1.0, 0.0, -9.17674e-08, -1.0, 0.0, -9.17674e-08, -1.0, 0.0, 0.5, 0.0, -0.866025, 1.0, 0.0, 1.19209e-07, 1.0, 0.0, 1.19209e-07, 1.0, 0.0, 1.19209e-07, 0.5, 0.0, 0.866026, 0.5, 0.0, 0.866026, 0.5, 0.0, 0.866026, -0.5, 0.0, 0.866025, -0.5, 0.0, 0.866025, -0.5, 0.0, 0.866025, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.37651e-07, 1.0, 0.0, 1.37651e-07, 1.0, 0.0, 1.37651e-07, 1.0, 0.0, 6.88255e-08, 1.0, 0.0, 6.88255e-08, 1.0, 0.0, 6.88255e-08, 1.0, 0.0, -1.0, 0.0, 0.0, -0.5, 0.0, -0.866025, 1.37651e-07, -1.0, 0.0, 1.37651e-07, -1.0, 0.0, 1.37651e-07, -1.0, 0.0, 1.37651e-07, -1.0, 0.0, 1.37651e-07, -1.0, 0.0, 1.37651e-07, -1.0, 0.0, 1.37651e-07, -1.0, 0.0, 1.37651e-07, -1.0, 0.0, 1.37651e-07, -1.0, 0.0),
+		Vector3Array(0.0, 1.0, -1.0, 0.866025, -1.0, -0.5, 0.0, -1.0, -1.0, 0.866025, 1.0, -0.5, 0.866025, -1.0, 0.5, 0.866025, -1.0, -0.5, 0.866025, 1.0, 0.5, -8.74228e-08, -1.0, 1.0, 0.866025, -1.0, 0.5, -8.74228e-08, 1.0, 1.0, -0.866025, -1.0, 0.5, -8.74228e-08, -1.0, 1.0, 0.0, 1.0, -1.0, -0.866025, 1.0, 0.5, 0.866025, 1.0, 0.5, -0.866025, 1.0, 0.5, -0.866025, -1.0, -0.5, -0.866025, -1.0, 0.5, -0.866025, 1.0, -0.5, 0.0, -1.0, -1.0, -0.866025, -1.0, -0.5, -0.866025, -1.0, 0.5, -0.866025, -1.0, -0.5, 0.866025, -1.0, -0.5, 0.866025, 1.0, -0.5, 0.866025, 1.0, -0.5, 0.866025, 1.0, 0.5, 0.866025, -1.0, 0.5, 0.866025, 1.0, 0.5, -8.74228e-08, 1.0, 1.0, -8.74228e-08, -1.0, 1.0, -8.74228e-08, 1.0, 1.0, -0.866025, 1.0, 0.5, -0.866025, -1.0, 0.5, 0.866025, 1.0, 0.5, 0.866025, 1.0, -0.5, 0.0, 1.0, -1.0, 0.0, 1.0, -1.0, -0.866025, 1.0, -0.5, -0.866025, 1.0, 0.5, -0.866025, 1.0, 0.5, -8.74228e-08, 1.0, 1.0, 0.866025, 1.0, 0.5, -0.866025, 1.0, -0.5, 0.0, 1.0, -1.0, -0.866025, -1.0, -0.5, 0.0, -1.0, -1.0, 0.866025, -1.0, -0.5, 0.866025, -1.0, -0.5, 0.866025, -1.0, 0.5, -8.74228e-08, -1.0, 1.0, -8.74228e-08, -1.0, 1.0, -0.866025, -1.0, 0.5, 0.866025, -1.0, -0.5),
+		Vector3Array(0.5, 0.0, -0.866025, 0.5, 0.0, -0.866025, 0.5, 0.0, -0.866025, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.5, 0.0, 0.866025, 0.5, 0.0, 0.866025, 0.5, 0.0, 0.866025, -0.5, 0.0, 0.866025, -0.5, 0.0, 0.866025, -0.5, 0.0, 0.866025, 2.29418e-08, 1.0, 0.0, 2.29418e-08, 1.0, 0.0, 2.29418e-08, 1.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -0.5, 0.0, -0.866025, -0.5, 0.0, -0.866025, -0.5, 0.0, -0.866025, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.5, 0.0, -0.866025, 1.0, 0.0, 1.19209e-07, 1.0, 0.0, 1.19209e-07, 1.0, 0.0, 1.19209e-07, 0.5, 0.0, 0.866026, 0.5, 0.0, 0.866026, 0.5, 0.0, 0.866026, -0.5, 0.0, 0.866025, -0.5, 0.0, 0.866025, -0.5, 0.0, 0.866025, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.37651e-07, 1.0, 0.0, 1.37651e-07, 1.0, 0.0, 1.37651e-07, 1.0, 0.0, 6.88255e-08, 1.0, 0.0, 6.88255e-08, 1.0, 0.0, 6.88255e-08, 1.0, 0.0, -1.0, 0.0, 0.0, -0.5, 0.0, -0.866025, 1.37651e-07, -1.0, 0.0, 1.37651e-07, -1.0, 0.0, 1.37651e-07, -1.0, 0.0, 1.37651e-07, -1.0, 0.0, 1.37651e-07, -1.0, 0.0, 1.37651e-07, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0),
 		null, ; No Tangents,
 		null, ; No Tangents,
 		null, ; no Vertex Colors,
 		null, ; no Vertex Colors,
 		null, ; No UV1,
 		null, ; No UV1,

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно