mirror of
https://github.com/godotengine/collada-exporter.git
synced 2026-01-04 18:10:15 +03:00
Removed commented out code
This commit is contained in:
@@ -144,7 +144,6 @@ class ExportDAE(bpy.types.Operator, ExportHelper):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def check_extension(self):
|
def check_extension(self):
|
||||||
# return self.batch_mode == "OFF"
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ http://www.khronos.org/collada/
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import math # math.pi
|
import math
|
||||||
import shutil
|
import shutil
|
||||||
import bpy
|
import bpy
|
||||||
import bmesh
|
import bmesh
|
||||||
@@ -225,15 +225,6 @@ class DaeExporter:
|
|||||||
|
|
||||||
print("FOR: {}".format(imgpath))
|
print("FOR: {}".format(imgpath))
|
||||||
|
|
||||||
# if (not os.path.isfile(imgpath)):
|
|
||||||
# print("NOT FILE?")
|
|
||||||
# if imgpath.endswith((".bmp", ".rgb", ".png", ".jpeg", ".jpg",
|
|
||||||
# ".jp2", ".tga", ".cin", ".dpx", ".exr",
|
|
||||||
# ".hdr", ".tif")):
|
|
||||||
# imgpath="images/"+os.path.basename(imgpath)
|
|
||||||
# else:
|
|
||||||
# imgpath="images/"+image.name+".png"
|
|
||||||
|
|
||||||
self.writel(S_IMGS, 1, "<image id=\"{}\" name=\"{}\">".format(
|
self.writel(S_IMGS, 1, "<image id=\"{}\" name=\"{}\">".format(
|
||||||
imgid, image.name))
|
imgid, image.name))
|
||||||
self.writel(S_IMGS, 2, "<init_from>{}</init_from>".format(imgpath))
|
self.writel(S_IMGS, 2, "<init_from>{}</init_from>".format(imgpath))
|
||||||
@@ -423,22 +414,15 @@ class DaeExporter:
|
|||||||
mid = self.new_id("morph")
|
mid = self.new_id("morph")
|
||||||
|
|
||||||
for k in range(0, len(mesh.shape_keys.key_blocks)):
|
for k in range(0, len(mesh.shape_keys.key_blocks)):
|
||||||
|
|
||||||
shape = node.data.shape_keys.key_blocks[k]
|
shape = node.data.shape_keys.key_blocks[k]
|
||||||
node.show_only_shape_key = True
|
node.show_only_shape_key = True
|
||||||
node.active_shape_key_index = k
|
node.active_shape_key_index = k
|
||||||
shape.value = 1.0
|
shape.value = 1.0
|
||||||
mesh.update()
|
mesh.update()
|
||||||
"""
|
|
||||||
oldval = shape.value
|
|
||||||
shape.value = 1.0
|
|
||||||
|
|
||||||
"""
|
|
||||||
p = node.data
|
p = node.data
|
||||||
v = node.to_mesh(bpy.context.scene, True, "RENDER")
|
v = node.to_mesh(bpy.context.scene, True, "RENDER")
|
||||||
self.temp_meshes.add(v)
|
self.temp_meshes.add(v)
|
||||||
node.data = v
|
node.data = v
|
||||||
# self.export_node(node, il, shape.name)
|
|
||||||
node.data.update()
|
node.data.update()
|
||||||
if (armature and k == 0):
|
if (armature and k == 0):
|
||||||
md = self.export_mesh(node, armature, k, mid, shape.name)
|
md = self.export_mesh(node, armature, k, mid, shape.name)
|
||||||
@@ -450,18 +434,11 @@ class DaeExporter:
|
|||||||
shape.value = 0.0
|
shape.value = 0.0
|
||||||
morph_targets.append(md)
|
morph_targets.append(md)
|
||||||
|
|
||||||
"""
|
|
||||||
shape.value = oldval
|
|
||||||
"""
|
|
||||||
node.show_only_shape_key = False
|
node.show_only_shape_key = False
|
||||||
node.active_shape_key_index = 0
|
node.active_shape_key_index = 0
|
||||||
|
|
||||||
self.writel(
|
self.writel(
|
||||||
S_MORPH, 1, "<controller id=\"{}\" name=\"\">".format(mid))
|
S_MORPH, 1, "<controller id=\"{}\" name=\"\">".format(mid))
|
||||||
# if ("skin_id" in morph_targets[0]):
|
|
||||||
# self.writel(S_MORPH, 2, "<morph source="#"+morph_targets[0][
|
|
||||||
# "skin_id"]+"" method="NORMALIZED">")
|
|
||||||
# else:
|
|
||||||
self.writel(
|
self.writel(
|
||||||
S_MORPH, 2,
|
S_MORPH, 2,
|
||||||
"<morph source=\"#{}\" method=\"NORMALIZED\">".format(
|
"<morph source=\"#{}\" method=\"NORMALIZED\">".format(
|
||||||
@@ -552,7 +529,6 @@ class DaeExporter:
|
|||||||
"use_mesh_modifiers"]
|
"use_mesh_modifiers"]
|
||||||
|
|
||||||
name_to_use = mesh.name
|
name_to_use = mesh.name
|
||||||
# print("name to use: "+mesh.name)
|
|
||||||
if (custom_name is not None and custom_name != ""):
|
if (custom_name is not None and custom_name != ""):
|
||||||
name_to_use = custom_name
|
name_to_use = custom_name
|
||||||
|
|
||||||
@@ -593,7 +569,6 @@ class DaeExporter:
|
|||||||
{"WARNING"},
|
{"WARNING"},
|
||||||
"CalcTangets failed for mesh \"{}\", no tangets will be "
|
"CalcTangets failed for mesh \"{}\", no tangets will be "
|
||||||
"exported.".format(mesh.name))
|
"exported.".format(mesh.name))
|
||||||
# uv_layer_count=0
|
|
||||||
mesh.calc_normals_split()
|
mesh.calc_normals_split()
|
||||||
has_tangents = False
|
has_tangents = False
|
||||||
|
|
||||||
@@ -606,9 +581,6 @@ class DaeExporter:
|
|||||||
|
|
||||||
if not (f.material_index in surface_indices):
|
if not (f.material_index in surface_indices):
|
||||||
surface_indices[f.material_index] = []
|
surface_indices[f.material_index] = []
|
||||||
# print("Type: " + str(type(f.material_index)))
|
|
||||||
# print("IDX: " + str(f.material_index) + "/" + str(
|
|
||||||
# len(mesh.materials)))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Bizarre blender behavior i don't understand,
|
# Bizarre blender behavior i don't understand,
|
||||||
@@ -627,20 +599,6 @@ class DaeExporter:
|
|||||||
indices = surface_indices[f.material_index]
|
indices = surface_indices[f.material_index]
|
||||||
vi = []
|
vi = []
|
||||||
# Vertices always 3
|
# Vertices always 3
|
||||||
"""
|
|
||||||
if (len(f.vertices)==3):
|
|
||||||
vi.append(0)
|
|
||||||
vi.append(1)
|
|
||||||
vi.append(2)
|
|
||||||
elif (len(f.vertices)==4):
|
|
||||||
#todo, should use shortest path
|
|
||||||
vi.append(0)
|
|
||||||
vi.append(1)
|
|
||||||
vi.append(2)
|
|
||||||
vi.append(0)
|
|
||||||
vi.append(2)
|
|
||||||
vi.append(3)
|
|
||||||
"""
|
|
||||||
|
|
||||||
for lt in range(f.loop_total):
|
for lt in range(f.loop_total):
|
||||||
loop_index = f.loop_start + lt
|
loop_index = f.loop_start + lt
|
||||||
@@ -663,11 +621,6 @@ class DaeExporter:
|
|||||||
v.tangent = Vector(ml.tangent)
|
v.tangent = Vector(ml.tangent)
|
||||||
v.bitangent = Vector(ml.bitangent)
|
v.bitangent = Vector(ml.bitangent)
|
||||||
|
|
||||||
# if (armature):
|
|
||||||
# v.vertex = node.matrix_world * v.vertex
|
|
||||||
|
|
||||||
# v.color=Vertex(mv. ???
|
|
||||||
|
|
||||||
if armature is not None:
|
if armature is not None:
|
||||||
wsum = 0.0
|
wsum = 0.0
|
||||||
|
|
||||||
@@ -1089,16 +1042,12 @@ class DaeExporter:
|
|||||||
if (node.data.shape_keys is not None):
|
if (node.data.shape_keys is not None):
|
||||||
sk = node.data.shape_keys
|
sk = node.data.shape_keys
|
||||||
if (sk.animation_data):
|
if (sk.animation_data):
|
||||||
# print("HAS ANIM")
|
|
||||||
# print("DRIVERS: "+str(len(sk.animation_data.drivers)))
|
|
||||||
for d in sk.animation_data.drivers:
|
for d in sk.animation_data.drivers:
|
||||||
if (d.driver):
|
if (d.driver):
|
||||||
for v in d.driver.variables:
|
for v in d.driver.variables:
|
||||||
for t in v.targets:
|
for t in v.targets:
|
||||||
if (t.id is not None and
|
if (t.id is not None and
|
||||||
t.id.name in self.scene.objects):
|
t.id.name in self.scene.objects):
|
||||||
# print("LINKING " + str(node) + " WITH " +
|
|
||||||
# str(t.id.name))
|
|
||||||
self.armature_for_morph[
|
self.armature_for_morph[
|
||||||
node] = self.scene.objects[t.id.name]
|
node] = self.scene.objects[t.id.name]
|
||||||
|
|
||||||
@@ -1273,7 +1222,6 @@ class DaeExporter:
|
|||||||
lightid = self.new_id("light")
|
lightid = self.new_id("light")
|
||||||
self.writel(S_LAMPS, 1, "<light id=\"{}\" name=\"{}\">".format(
|
self.writel(S_LAMPS, 1, "<light id=\"{}\" name=\"{}\">".format(
|
||||||
lightid, light.name))
|
lightid, light.name))
|
||||||
# self.writel(S_LAMPS, 2, "<optics>")
|
|
||||||
self.writel(S_LAMPS, 3, "<technique_common>")
|
self.writel(S_LAMPS, 3, "<technique_common>")
|
||||||
|
|
||||||
if (light.type == "POINT"):
|
if (light.type == "POINT"):
|
||||||
@@ -1313,7 +1261,6 @@ class DaeExporter:
|
|||||||
self.writel(S_LAMPS, 4, "</directional>")
|
self.writel(S_LAMPS, 4, "</directional>")
|
||||||
|
|
||||||
self.writel(S_LAMPS, 3, "</technique_common>")
|
self.writel(S_LAMPS, 3, "</technique_common>")
|
||||||
# self.writel(S_LAMPS, 2, "</optics>")
|
|
||||||
self.writel(S_LAMPS, 1, "</light>")
|
self.writel(S_LAMPS, 1, "</light>")
|
||||||
|
|
||||||
self.writel(S_NODES, il, "<instance_light url=\"#{}\"/>".format(
|
self.writel(S_NODES, il, "<instance_light url=\"#{}\"/>".format(
|
||||||
@@ -1515,7 +1462,6 @@ class DaeExporter:
|
|||||||
self.writel(
|
self.writel(
|
||||||
S_NODES, il, "<matrix sid=\"transform\">{}</matrix>".format(
|
S_NODES, il, "<matrix sid=\"transform\">{}</matrix>".format(
|
||||||
strmtx(node.matrix_local)))
|
strmtx(node.matrix_local)))
|
||||||
# print("NODE TYPE: "+node.type+" NAME: "+node.name)
|
|
||||||
if (node.type == "MESH"):
|
if (node.type == "MESH"):
|
||||||
self.export_mesh_node(node, il)
|
self.export_mesh_node(node, il)
|
||||||
elif (node.type == "CURVE"):
|
elif (node.type == "CURVE"):
|
||||||
@@ -1543,7 +1489,6 @@ class DaeExporter:
|
|||||||
|
|
||||||
if (self.config["use_active_layers"]):
|
if (self.config["use_active_layers"]):
|
||||||
valid = False
|
valid = False
|
||||||
# print("NAME: "+node.name)
|
|
||||||
for i in range(20):
|
for i in range(20):
|
||||||
if (node.layers[i] and self.scene.layers[i]):
|
if (node.layers[i] and self.scene.layers[i]):
|
||||||
valid = True
|
valid = True
|
||||||
@@ -1724,15 +1669,11 @@ class DaeExporter:
|
|||||||
# Change frames first, export objects last
|
# Change frames first, export objects last
|
||||||
# This improves performance enormously
|
# This improves performance enormously
|
||||||
|
|
||||||
# print("anim from: " + str(start) + " to " + str(end) + " allowed: " +
|
|
||||||
# str(allowed))
|
|
||||||
for t in range(start, end + 1):
|
for t in range(start, end + 1):
|
||||||
self.scene.frame_set(t)
|
self.scene.frame_set(t)
|
||||||
key = t * frame_len - frame_sub
|
key = t * frame_len - frame_sub
|
||||||
# print("Export Anim Frame "+str(t)+"/"+str(self.scene.frame_end+1))
|
|
||||||
|
|
||||||
for node in self.scene.objects:
|
for node in self.scene.objects:
|
||||||
|
|
||||||
if (node not in self.valid_nodes):
|
if (node not in self.valid_nodes):
|
||||||
continue
|
continue
|
||||||
if (allowed is not None and not (node in allowed)):
|
if (allowed is not None and not (node in allowed)):
|
||||||
@@ -1743,7 +1684,6 @@ class DaeExporter:
|
|||||||
# inside of action
|
# inside of action
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# print("fail "+str((node in self.armature_for_morph)))
|
|
||||||
continue
|
continue
|
||||||
if (node.type == "MESH" and node.data is not None and
|
if (node.type == "MESH" and node.data is not None and
|
||||||
node.data.shape_keys is not None and (
|
node.data.shape_keys is not None and (
|
||||||
@@ -1794,7 +1734,6 @@ class DaeExporter:
|
|||||||
bone_name = self.skeleton_info[node]["bone_ids"][bone]
|
bone_name = self.skeleton_info[node]["bone_ids"][bone]
|
||||||
|
|
||||||
if (not (bone_name in xform_cache)):
|
if (not (bone_name in xform_cache)):
|
||||||
# print("has bone: " + bone_name)
|
|
||||||
xform_cache[bone_name] = []
|
xform_cache[bone_name] = []
|
||||||
|
|
||||||
posebone = node.pose.bones[bone.name]
|
posebone = node.pose.bones[bone.name]
|
||||||
@@ -1892,16 +1831,11 @@ class DaeExporter:
|
|||||||
for j, bone in enumerate(s.pose.bones):
|
for j, bone in enumerate(s.pose.bones):
|
||||||
bone.matrix_basis = Matrix()
|
bone.matrix_basis = Matrix()
|
||||||
|
|
||||||
# print("allowed skeletons "+str(allowed_skeletons))
|
|
||||||
|
|
||||||
# print(str(x))
|
|
||||||
|
|
||||||
tcn = self.export_animation(int(x.frame_range[0]), int(
|
tcn = self.export_animation(int(x.frame_range[0]), int(
|
||||||
x.frame_range[1] + 0.5), allowed_skeletons)
|
x.frame_range[1] + 0.5), allowed_skeletons)
|
||||||
framelen = (1.0 / self.scene.render.fps)
|
framelen = (1.0 / self.scene.render.fps)
|
||||||
start = x.frame_range[0] * framelen
|
start = x.frame_range[0] * framelen
|
||||||
end = x.frame_range[1] * framelen
|
end = x.frame_range[1] * framelen
|
||||||
# print("Export anim: "+x.name)
|
|
||||||
self.writel(
|
self.writel(
|
||||||
S_ANIM_CLIPS, 1, "<animation_clip name=\"{}\" "
|
S_ANIM_CLIPS, 1, "<animation_clip name=\"{}\" "
|
||||||
"start=\"{}\" end=\"{}\">".format(x.name, start, end))
|
"start=\"{}\" end=\"{}\">".format(x.name, start, end))
|
||||||
|
|||||||
Reference in New Issue
Block a user