modified scripts from using older/depricated Python API commands, deprecated scn.getChildren() in the docs.

This commit is contained in:
Campbell Barton 2006-12-25 09:17:23 +00:00
parent dd5077060e
commit 859b7f207e
25 changed files with 406 additions and 421 deletions

@ -682,7 +682,7 @@ def make_track_chunk(ID, obj):
# Next section should be repeated for every keyframe, but for now, animation is not actually supported.
track_chunk.add_variable("tcb_frame", _3ds_int(0))
track_chunk.add_variable("tcb_flags", _3ds_short())
if obj.getType()=='Empty':
if obj.type=='Empty':
if ID==POS_TRACK_TAG:
# position vector:
track_chunk.add_variable("position", _3ds_point_3d(obj.getLocation()))
@ -714,7 +714,7 @@ def make_kf_obj_node(obj, name_to_id):
Takes the Blender object as a parameter. Object id's are taken from the dictionary name_to_id.
Blender Empty objects are converted to dummy nodes.'''
name = obj.getName()
name = obj.name
# main object node chunk:
kf_obj_node = _3ds_chunk(KFDATA_OBJECT_NODE_TAG)
# chunk for the object id:
@ -725,7 +725,7 @@ def make_kf_obj_node(obj, name_to_id):
# object node header:
obj_node_header_chunk = _3ds_chunk(OBJECT_NODE_HDR)
# object name:
if (obj.getType() == 'Empty'):
if obj.type == 'Empty':
# Empties are called "$$$DUMMY" and use the OBJECT_INSTANCE_NAME chunk
# for their name (see below):
obj_node_header_chunk.add_variable("name", _3ds_string("$$$DUMMY"))
@ -737,14 +737,14 @@ def make_kf_obj_node(obj, name_to_id):
obj_node_header_chunk.add_variable("flags2", _3ds_short(0))
# Check parent-child relationships:
parent = obj.getParent()
if (parent == None) or (parent.getName() not in name_to_id):
parent = obj.parent
if (parent == None) or (parent.name not in name_to_id):
# If no parent, or the parents name is not in the name_to_id dictionary,
# parent id becomes -1:
obj_node_header_chunk.add_variable("parent", _3ds_short(-1))
else:
# Get the parent's id from the name_to_id dictionary:
obj_node_header_chunk.add_variable("parent", _3ds_short(name_to_id[parent.getName()]))
obj_node_header_chunk.add_variable("parent", _3ds_short(name_to_id[parent.name]))
# Add pivot chunk:
obj_pivot_chunk = _3ds_chunk(OBJECT_PIVOT)
@ -756,7 +756,7 @@ def make_kf_obj_node(obj, name_to_id):
kf_obj_node.add_subchunk(obj_node_header_chunk)
# Empty objects need to have an extra chunk for the instance name:
if (obj.getType() == 'Empty'):
if obj.type == 'Empty':
obj_instance_name_chunk = _3ds_chunk(OBJECT_INSTANCE_NAME)
obj_instance_name_chunk.add_variable("name", _3ds_string(name))
kf_obj_node.add_subchunk(obj_instance_name_chunk)
@ -791,10 +791,10 @@ def save_3ds(filename):
'''
# Get all the supported objects selected in this scene:
ob_sel= Blender.Object.GetSelected()
ob_sel= list(scn.objects.context)
mesh_objects = [ (ob, me) for ob in ob_sel for me in (BPyMesh.getMeshFromObject(ob, None, True, False, scn),) if me ]
empty_objects = [ ob for ob in ob_sel if ob.getType() == 'Empty' ]
empty_objects = [ ob for ob in ob_sel if ob.type == 'Empty' ]
# Make a list of all materials used in the selected meshes (use a dictionary,
# each material is added once):

@ -296,31 +296,29 @@ class xExport:
#***********************************************
def analyzeScene(self):
parent_list = []
for obj in Blender.Scene.GetCurrent().getChildren(): #Object.Get():
mesh = obj.getData()
if type(mesh) == Types.ArmatureType or type(mesh) == Types.NMeshType or obj.getType() == "Empty":
pare = obj.getParent()
if pare == None :
for obj in Blender.Scene.GetCurrent().objects:
if obj.type in ('Mesh', 'Armature', 'Empty'):
if obj.parent == None :
parent_list.append(obj)
return parent_list
def getChildren(self,obj):
children_list = []
for object in Blender.Scene.GetCurrent().getChildren(): #Object.Get():
for object in Blender.Scene.GetCurrent().objects: #Object.Get():
pare = object.parent
if pare == obj :
children_list.append(object)
return children_list
def getArmChildren(self,obj):
for object in Blender.Scene.GetCurrent().getChildren(): #Object.Get():
for object in Blender.Scene.GetCurrent().objects: #Object.Get():
pare = object.parent
if pare == obj :
return object
def getLocMat(self, obj):
pare = obj.getParent()
pare = obj.parent
mat = obj.matrixWorld
mat_id = Matrix([1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1])
if pare:
@ -336,7 +334,7 @@ class xExport:
def writeObjFrames(self,obj):
global space,chld_obj,ch_list
mesh = obj.getData()
if obj.getType() == "Empty" :
if obj.type == "Empty" :
mat = self.getLocMat(obj)
mat_c = Matrix(mat)
name = obj.name
@ -391,12 +389,12 @@ class xExport:
self.writeObjFrames(obj)
ch_l = self.getChildren(obj)
for ch in ch_l:
if ch and ch.getType() == "Armature":
if ch and ch.type == "Armature":
ch_list.append(ch)
self.writeObjFrames(ch)
else :
self.writeChildObj(ch_l)
if obj.getType() != "Armature":
if obj.type != "Armature":
self.file.write(" } // SI End of the Object %s \n" % (obj.name))
@ -404,20 +402,18 @@ class xExport:
self.file.write("} // End of the Root Frame\n")
if anim :
self.file.write("AnimationSet {\n")
for obj in Blender.Scene.GetCurrent().getChildren(): #Object.Get():
mesh = obj.getData()
if type(mesh) == Types.NMeshType or obj.getType() == "Empty":
ip_list = obj.getIpo()
if ip_list != None :
self.writeAnimationObj(obj)
elif type(mesh) == Types.ArmatureType :
act_list = obj.getAction()
if act_list != None :
self.writeAnimation(obj)
#ip_list = obj.getIpo()
#if ip_list != None :
# self.writeAnimationObj(obj)
for obj in Blender.Scene.GetCurrent().objects:
if obj.type in ('Mesh', 'Empty'):
ip_list = obj.ipo
if ip_list != None :
self.writeAnimationObj(obj)
elif obj.type == 'Armature':
act_list = obj.getAction()
if act_list != None :
self.writeAnimation(obj)
#ip_list = obj.ipo
#if ip_list != None :
# self.writeAnimationObj(obj)
self.file.write("} // End of Animation Set\n")
self.writeEnd()
@ -466,7 +462,7 @@ class xExport:
ind = objs.index(obj)
if ind == len(objs)-1:
self.file.write("}\n")
ip_list = obj.getIpo()
ip_list = obj.ipo
if ip_list != None :
self.file.write("AnimationSet {\n")
self.writeAnimationObj(obj)
@ -1142,7 +1138,7 @@ template SkinWeights {\n\
#***********************************************
def writeAnimationObj(self, obj):
point_list = []
ip = obj.getIpo()
ip = obj.ipo
poi = ip.getCurves()
for po in poi[0].getPoints():
a = po.getPoints()

@ -297,10 +297,10 @@ class AC3DExport: # the ac3d exporter part
file.write(header+'\n')
objs = \
[o for o in scene_objects if o.getType() in ['Mesh', 'Empty']]
[o for o in scene_objects if o.type in ['Mesh', 'Empty']]
for obj in objs[:]:
parent = obj.getParent()
parent = obj.parent
list = [obj]
while parent:
@ -309,7 +309,7 @@ class AC3DExport: # the ac3d exporter part
list.insert(0, obj)
dict = tree
for i in range(len(list)):
for i in xrange(len(list)):
lname = list[i].getType()[:2] + list[i].name
if lname not in dict.keys():
dict[lname] = {}
@ -321,7 +321,7 @@ class AC3DExport: # the ac3d exporter part
objlist = [Blender.Object.Get(name) for name in exp_objs]
meshlist = [o for o in objlist if o.getType() == 'Mesh']
meshlist = [o for o in objlist if o.type == 'Mesh']
self.MATERIALS(meshlist)
if not self.mbuf or ADD_DEFAULT_MAT:
@ -333,7 +333,7 @@ class AC3DExport: # the ac3d exporter part
for obj in objlist:
self.obj = obj
objtype = obj.getType()
objtype = obj.type
objname = obj.name
kidsnum = kids_dict[objname]
@ -687,11 +687,11 @@ def fs_callback(filename):
# -- End of definitions
scn = Blender.Scene.GetCurrent()
if ONLY_SELECTED:
OBJS = Blender.Object.GetSelected()
OBJS = list(scn.objects.context)
else:
OBJS = Blender.Scene.GetCurrent().getChildren()
OBJS = list(scn.objects)
if not OBJS:
Blender.Draw.PupMenu('ERROR: no objects selected')

@ -8,7 +8,7 @@ Tip: 'See Trajectory of selected object'
"""
__author__ = '3R - R3gis'
__version__ = '2.42'
__version__ = '2.43'
__url__ = ["Script's site , http://blenderfrance.free.fr/python/Trajectory_en.htm","Author's site , http://cybercreator.free.fr", "French Blender support forum, http://www.zoo-logique.org/3D.Blender/newsportal/thread.php?group=3D.Blender"]
__email__=["3R, r3gis@free.fr"]
@ -230,23 +230,23 @@ def matrixForTraj(frame, parent_list):
for parent_data in parent_list:
parent_ob= parent_data[0]
try: X= parent_data[5].evaluate(frame)*pi/18
try: X= parent_data[5][frame]*pi/18
except: X= parent_ob.RotX
try: Y= parent_data[6].evaluate(frame)*pi/18
try: Y= parent_data[6][frame]*pi/18
except: Y= parent_ob.RotY
try: Z= parent_data[7].evaluate(frame)*pi/18
try: Z= parent_data[7][frame]*pi/18
except: Z= parent_ob.RotZ
try: LX= parent_data[2].evaluate(frame)
try: LX= parent_data[2][frame]
except: LX= parent_ob.LocX
try: LY= parent_data[3].evaluate(frame)
try: LY= parent_data[3][frame]
except: LY= parent_ob.LocY
try: LZ= parent_data[4].evaluate(frame)
try: LZ= parent_data[4][frame]
except: LZ= parent_ob.LocZ
try: SX= parent_data[8].evaluate(frame)
try: SX= parent_data[8][frame]
except: SX= parent_ob.SizeX
try: SY= parent_data[9].evaluate(frame)
try: SY= parent_data[9][frame]
except: SY= parent_ob.SizeY
try: SZ= parent_data[10].evaluate(frame)
try: SZ= parent_data[10][frame]
except: SZ= parent_ob.SizeZ
NMat=Blender.Mathutils.Matrix([cos(Y)*cos(Z)*SX,SX*cos(Y)*sin(Z),-SX*sin(Y),0],
@ -323,21 +323,20 @@ def Trace_Traj(ob):
#security : if one of parents object are a path>>follow : trajectory don't work properly so it have to draw nothing
for parent in parent_list:
# getData() is slow especialy with NMesh.
# check its a curve.
if parent[0].getType() == 'Curve':
if parent[0].type == 'Curve':
if parent[0].data.flag & 1<<4: # Follow path, 4th bit
return 1
#ob >> re-assign obj and not parent
ob= backup_ob
ob= backup_ob
if ipoLocX: LXC= ipoLocX.evaluate(frameC)
if ipoLocX: LXC= ipoLocX[frameC]
else: LXC= ob.LocX
if ipoLocY: LYC= ipoLocY.evaluate(frameC)
if ipoLocY: LYC= ipoLocY[frameC]
else: LYC= ob.LocY
if ipoLocZ: LZC= ipoLocZ.evaluate(frameC)
if ipoLocZ: LZC= ipoLocZ[frameC]
else: LZC= ob.LocZ
vect= Vector([ob.LocX, ob.LocY, ob.LocZ, 1])
@ -346,18 +345,18 @@ def Trace_Traj(ob):
#If trajectory is being modified and we are at a frame where a ipo key already exist
if round(ob.LocX, 5)!=round(LXC, 5):
for bez in ipoLocX.bezierPoints:
if round(bez.getPoints()[0], tr)==frameCtr:
bez.setPoints((frameCr, vect[0]))
if round(bez.pt[0], tr)==frameCtr:
bez.pt = [frameCr, vect[0]]
ipoLocX.recalc()
if round(ob.LocY, 5)!=round(LYC, 5):
for bez in ipoLocY.bezierPoints:
if round(bez.getPoints()[0], tr)==frameCtr:
bez.setPoints((frameCr, vect[1]))
if round(bez.pt[0], tr)==frameCtr:
bez.pt = [frameCr, vect[1]]
ipoLocY.recalc()
if round(ob.LocZ, 5)!=round(LZC, 5):
for bez in ipoLocZ.bezierPoints:
if round(bez.getPoints()[0], tr)==frameCtr:
bez.setPoints((frameCr, vect[2]))
if round(bez.pt[0], tr)==frameCtr:
bez.pt = [frameCr, vect[2]]
ipoLocZ.recalc()
#change trajectory color if at an ipoKey
@ -365,24 +364,24 @@ def Trace_Traj(ob):
bezier_Coord=0
if ipoLocX: # FIXED like others it was just in case ipoLocX==None
for bez in ipoLocX.bezierPoints:
bezier_Coord=round(bez.getPoints()[0], tr)
bezier_Coord=round(bez.pt[0], tr)
if bezier_Coord not in VertexFrame:
VertexFrame.append(bezier_Coord)
if bezier_Coord==frameCtr:
color=[1, color[1]-0.3]
if ipoLocY: # FIXED
for bez in ipoLocY.bezierPoints:
bezier_Coord=round(bez.getPoints()[0], tr)
bezier_Coord=round(bez.pt[0], tr)
if bezier_Coord not in VertexFrame:
VertexFrame.append(bezier_Coord)
if round(bez.getPoints()[0], tr)==frameCtr:
if round(bez.pt[0], tr)==frameCtr:
color=[1, color[1]-0.3]
if ipoLocZ: # FIXED
for bez in ipoLocZ.bezierPoints:
bezier_Coord=round(bez.getPoints()[0], tr)
bezier_Coord=round(bez.pt[0], tr)
if bezier_Coord not in VertexFrame:
VertexFrame.append(bezier_Coord)
if round(bez.getPoints()[0], tr)==frameCtr:
if round(bez.pt[0], tr)==frameCtr:
color=[1, color[1]-0.3]
@ -390,15 +389,14 @@ def Trace_Traj(ob):
for frame in xrange(frameC-past, frameC+future):
DecMat=matrixForTraj(frame, parent_list)
if ipoLocX: LX= ipoLocX.evaluate(frame)
if ipoLocX: LX= ipoLocX[frame]
else: LX= ob.LocX
if ipoLocY: LY= ipoLocY.evaluate(frame)
if ipoLocY: LY= ipoLocY[frame]
else: LY= ob.LocY
if ipoLocZ: LZ= ipoLocZ.evaluate(frame)
if ipoLocZ: LZ= ipoLocZ[frame]
else: LZ= ob.LocZ
vect= Vector([LX, LY, LZ, 1])
vect=vect*DecMat
vect=Vector(LX, LY, LZ)*DecMat
LocX.append(vect[0])
LocY.append(vect[1])
LocZ.append(vect[2])

@ -1003,7 +1003,7 @@ def export(filename):
BASE_MATRIX = matrix_rotate_x(-90.0)
# Get the scene
scene = Blender.Scene.getCurrent()
scene = Blender.Scene.GetCurrent()
# ---- Export skeleton (=armature) ----------------------------------------
@ -1012,87 +1012,86 @@ def export(filename):
skeleton = Skeleton()
foundarmature = False
for obj in Blender.Scene.GetCurrent().getChildren(): #Blender.Object.Get():
data = obj.getData()
if type(data) is not Blender.Types.ArmatureType:
continue
if foundarmature == True:
log.error("Found multiple armatures! '" + obj.getName() + "' ignored.\n")
continue
foundarmature = True
matrix = obj.getMatrix()
if BASE_MATRIX:
matrix = matrix_multiply(BASE_MATRIX, matrix)
def treat_bone(b, parent = None):
head = b.head["BONESPACE"]
tail = b.tail["BONESPACE"]
for obj in scene.objects: #Blender.Object.Get():
if obj.type == 'Armature':
data = obj.data
# Turns the Blender's head-tail-roll notation into a quaternion
quat = matrix2quaternion(blender_bone2matrix(head, tail, b.roll["BONESPACE"]))
if parent:
# Compute the translation from the parent bone's head to the child
# bone's head, in the parent bone coordinate system.
# The translation is parent_tail - parent_head + child_head,
# but parent_tail and parent_head must be converted from the parent's parent
# system coordinate into the parent system coordinate.
parent_invert_transform = matrix_invert(quaternion2matrix(parent.rot))
parent_head = vector_by_matrix(parent.head, parent_invert_transform)
parent_tail = vector_by_matrix(parent.tail, parent_invert_transform)
#ploc = vector_add(head, b.getLoc())
parentheadtotail = vector_sub(parent_tail, parent_head)
# hmm this should be handled by the IPos, but isn't for non-animated
# bones which are transformed in the pose mode...
#loc = vector_add(ploc, parentheadtotail)
#rot = quaternion_multiply(blender2cal3dquat(b.getQuat()), quat)
loc = parentheadtotail
rot = quat
log.debug("Parented Bone: %s",b.name)
bone = Bone(skeleton, parent, b.name, loc, rot)
else:
# Apply the armature's matrix to the root bones
head = point_by_matrix(head, matrix)
tail = point_by_matrix(tail, matrix)
quat = matrix2quaternion(matrix_multiply(matrix, quaternion2matrix(quat))) # Probably not optimal
# loc = vector_add(head, b.getLoc())
# rot = quaternion_multiply(blender2cal3dquat(b.getQuat()), quat)
loc = head
rot = quat
log.debug("Non Parented Bone: %s",b.name)
# Here, the translation is simply the head vector
bone = Bone(skeleton, None, b.name, loc, rot)
bone.head = head
bone.tail = tail
if b.hasChildren():
for child in b.children:
treat_bone(child, bone)
foundroot = False
for b in data.bones.values():
# child bones are handled in treat_bone
if b.parent != None:
if foundarmature == True:
log.error("Found multiple armatures! '" + obj.getName() + "' ignored.\n")
continue
if foundroot == True:
log.warning("Warning: Found multiple root-bones, this may not be supported in cal3d.")
#print "Ignoring bone '" + b.name + "' and it's childs."
#continue
foundarmature = True
matrix = obj.getMatrix()
if BASE_MATRIX:
matrix = matrix_multiply(BASE_MATRIX, matrix)
def treat_bone(b, parent = None):
head = b.head["BONESPACE"]
tail = b.tail["BONESPACE"]
treat_bone(b)
foundroot = True
# Turns the Blender's head-tail-roll notation into a quaternion
quat = matrix2quaternion(blender_bone2matrix(head, tail, b.roll["BONESPACE"]))
if parent:
# Compute the translation from the parent bone's head to the child
# bone's head, in the parent bone coordinate system.
# The translation is parent_tail - parent_head + child_head,
# but parent_tail and parent_head must be converted from the parent's parent
# system coordinate into the parent system coordinate.
parent_invert_transform = matrix_invert(quaternion2matrix(parent.rot))
parent_head = vector_by_matrix(parent.head, parent_invert_transform)
parent_tail = vector_by_matrix(parent.tail, parent_invert_transform)
#ploc = vector_add(head, b.getLoc())
parentheadtotail = vector_sub(parent_tail, parent_head)
# hmm this should be handled by the IPos, but isn't for non-animated
# bones which are transformed in the pose mode...
#loc = vector_add(ploc, parentheadtotail)
#rot = quaternion_multiply(blender2cal3dquat(b.getQuat()), quat)
loc = parentheadtotail
rot = quat
log.debug("Parented Bone: %s",b.name)
bone = Bone(skeleton, parent, b.name, loc, rot)
else:
# Apply the armature's matrix to the root bones
head = point_by_matrix(head, matrix)
tail = point_by_matrix(tail, matrix)
quat = matrix2quaternion(matrix_multiply(matrix, quaternion2matrix(quat))) # Probably not optimal
# loc = vector_add(head, b.getLoc())
# rot = quaternion_multiply(blender2cal3dquat(b.getQuat()), quat)
loc = head
rot = quat
log.debug("Non Parented Bone: %s",b.name)
# Here, the translation is simply the head vector
bone = Bone(skeleton, None, b.name, loc, rot)
bone.head = head
bone.tail = tail
if b.hasChildren():
for child in b.children:
treat_bone(child, bone)
foundroot = False
for b in data.bones.values():
# child bones are handled in treat_bone
if b.parent != None:
continue
if foundroot == True:
log.warning("Warning: Found multiple root-bones, this may not be supported in cal3d.")
#print "Ignoring bone '" + b.name + "' and it's childs."
#continue
treat_bone(b)
foundroot = True
# ---- Export Mesh data ---------------------------------------------------
@ -1100,137 +1099,138 @@ def export(filename):
meshes = []
for obj in Blender.Scene.GetCurrent().getChildren(): #Blender.Object.Get():
data = obj.getData()
if (type(data) is Blender.Types.NMeshType) and data.faces:
mesh_name = obj.getName()
if mesh_name[0]=='_': continue
log.debug("Mesh: %s",mesh_name)
mesh = Mesh(mesh_name)
meshes.append(mesh)
matrix = obj.getMatrix()
if BASE_MATRIX:
matrix = matrix_multiply(BASE_MATRIX, matrix)
for obj in scene.objects: #Blender.Object.Get():
if obj.type == 'Mesh':
data = obj.data
if data.faces:
mesh_name = obj.name
if mesh_name[0]=='_': continue
faces = data.faces
while faces:
image = faces[0].image
image_filename = image and image.filename
image_name = os.path.splitext(os.path.basename(image_filename))[0]
#print "MATERIAL", image_filename, image_name
if MATERIAL_MAP.has_key(image_name):
image_filename2 = os.path.join(os.path.dirname(image_filename), MATERIAL_MAP[image_name] + os.path.splitext(image_filename)[1])
#print "=>", image_filename
else: image_filename2 = image_filename
material = MATERIALS.get(image_filename2) or Material(image_filename2)
outputuv = len(material.maps_filenames) > 0
log.debug("Mesh: %s",mesh_name)
# TODO add material color support here
mesh = Mesh(mesh_name)
meshes.append(mesh)
submesh = SubMesh(mesh, material)
vertices = {}
for face in faces[:]:
if (face.image and face.image.filename) == image_filename:
faces.remove(face)
if not face.smooth:
try:
p1 = face.v[0].co
p2 = face.v[1].co
p3 = face.v[2].co
except IndexError:
log.error("You have faces with less that three verticies!")
continue
normal = vector_normalize(vector_by_matrix(vector_crossproduct(
[p3[0] - p2[0], p3[1] - p2[1], p3[2] - p2[2]],
[p1[0] - p2[0], p1[1] - p2[1], p1[2] - p2[2]],
), matrix))
matrix = obj.getMatrix()
if BASE_MATRIX:
matrix = matrix_multiply(BASE_MATRIX, matrix)
faces = data.faces
while faces:
image = faces[0].image
image_filename = image and image.filename
image_name = os.path.splitext(os.path.basename(image_filename))[0]
#print "MATERIAL", image_filename, image_name
if MATERIAL_MAP.has_key(image_name):
image_filename2 = os.path.join(os.path.dirname(image_filename), MATERIAL_MAP[image_name] + os.path.splitext(image_filename)[1])
#print "=>", image_filename
else: image_filename2 = image_filename
material = MATERIALS.get(image_filename2) or Material(image_filename2)
outputuv = len(material.maps_filenames) > 0
# TODO add material color support here
submesh = SubMesh(mesh, material)
vertices = {}
for face in faces[:]:
if (face.image and face.image.filename) == image_filename:
faces.remove(face)
face_vertices = []
for i in range(len(face.v)):
vertex = vertices.get(face.v[i].index)
if not vertex:
coord = point_by_matrix (face.v[i].co, matrix)
if face.smooth:
normal = vector_normalize(vector_by_matrix(face.v[i].no, matrix))
vertex = vertices[face.v[i].index] = Vertex(submesh, coord, normal)
influences = data.getVertexInfluences(face.v[i].index)
# should this really be a warning? (well currently enabled,
# because blender has some bugs where it doesn't return
# influences in python api though they are set, and because
# cal3d<=0.9.1 had bugs where objects without influences
# aren't drawn.
if not influences:
log.error("A vertex of object '%s' has no influences.\n(This occurs on objects placed in an invisible layer, you can fix it by using a single layer)\n. The vertex has been added to a vertex group called _no_inf" % obj.getName())
if '_no_inf' not in data.getVertGroupNames():
data.addVertGroup('_no_inf')
if not face.smooth:
try:
p1 = face.v[0].co
p2 = face.v[1].co
p3 = face.v[2].co
except IndexError:
log.error("You have faces with less that three verticies!")
continue
data.assignVertsToGroup('_no_inf',[face.v[i].index],0.5,'add')
normal = vector_normalize(vector_by_matrix(vector_crossproduct(
[p3[0] - p2[0], p3[1] - p2[1], p3[2] - p2[2]],
[p1[0] - p2[0], p1[1] - p2[1], p1[2] - p2[2]],
), matrix))
# sum of influences is not always 1.0 in Blender ?!?!
sum = 0.0
for bone_name, weight in influences:
sum += weight
for bone_name, weight in influences:
bone_name=string.replace(bone_name,'.','_')
if bone_name=='':
log.critical('Found bone with no name which influences %s' % obj.getName())
continue
if bone_name not in BONES:
log.error("Couldn't find bone '%s' which influences object '%s'.\n" % (bone_name, obj.getName()))
continue
vertex.influences.append(Influence(BONES[bone_name], weight / sum))
face_vertices = []
for i in range(len(face.v)):
vertex = vertices.get(face.v[i].index)
if not vertex:
coord = point_by_matrix (face.v[i].co, matrix)
if face.smooth:
normal = vector_normalize(vector_by_matrix(face.v[i].no, matrix))
vertex = vertices[face.v[i].index] = Vertex(submesh, coord, normal)
elif not face.smooth:
# We cannot share vertex for non-smooth faces, since Cal3D does not
# support vertex sharing for 2 vertices with different normals.
# => we must clone the vertex.
old_vertex = vertex
vertex = Vertex(submesh, vertex.loc, normal)
vertex.cloned_from = old_vertex
vertex.influences = old_vertex.influences
old_vertex.clones.append(vertex)
if data.hasFaceUV():
uv = [face.uv[i][0], face.uv[i][1]]
if FLIP_TEXTURE_COORDS: uv[1] = -uv[1]
if not vertex.maps:
if outputuv: vertex.maps.append(Map(*uv))
elif (vertex.maps[0].u != uv[0]) or (vertex.maps[0].v != uv[1]):
# This vertex can be shared for Blender, but not for Cal3D !!!
# Cal3D does not support vertex sharing for 2 vertices with
# different UV texture coodinates.
influences = data.getVertexInfluences(face.v[i].index)
# should this really be a warning? (well currently enabled,
# because blender has some bugs where it doesn't return
# influences in python api though they are set, and because
# cal3d<=0.9.1 had bugs where objects without influences
# aren't drawn.
if not influences:
log.error("A vertex of object '%s' has no influences.\n(This occurs on objects placed in an invisible layer, you can fix it by using a single layer)\n. The vertex has been added to a vertex group called _no_inf" % obj.getName())
if '_no_inf' not in data.getVertGroupNames():
data.addVertGroup('_no_inf')
data.assignVertsToGroup('_no_inf',[face.v[i].index],0.5,'add')
# sum of influences is not always 1.0 in Blender ?!?!
sum = 0.0
for bone_name, weight in influences:
sum += weight
for bone_name, weight in influences:
bone_name=string.replace(bone_name,'.','_')
if bone_name=='':
log.critical('Found bone with no name which influences %s' % obj.getName())
continue
if bone_name not in BONES:
log.error("Couldn't find bone '%s' which influences object '%s'.\n" % (bone_name, obj.getName()))
continue
vertex.influences.append(Influence(BONES[bone_name], weight / sum))
elif not face.smooth:
# We cannot share vertex for non-smooth faces, since Cal3D does not
# support vertex sharing for 2 vertices with different normals.
# => we must clone the vertex.
for clone in vertex.clones:
if (clone.maps[0].u == uv[0]) and (clone.maps[0].v == uv[1]):
vertex = clone
break
else: # Not yet cloned...
old_vertex = vertex
vertex = Vertex(submesh, vertex.loc, vertex.normal)
vertex.cloned_from = old_vertex
vertex.influences = old_vertex.influences
old_vertex = vertex
vertex = Vertex(submesh, vertex.loc, normal)
vertex.cloned_from = old_vertex
vertex.influences = old_vertex.influences
old_vertex.clones.append(vertex)
if data.hasFaceUV():
uv = [face.uv[i][0], face.uv[i][1]]
if FLIP_TEXTURE_COORDS: uv[1] = -uv[1]
if not vertex.maps:
if outputuv: vertex.maps.append(Map(*uv))
old_vertex.clones.append(vertex)
elif (vertex.maps[0].u != uv[0]) or (vertex.maps[0].v != uv[1]):
# This vertex can be shared for Blender, but not for Cal3D !!!
# Cal3D does not support vertex sharing for 2 vertices with
# different UV texture coodinates.
# => we must clone the vertex.
face_vertices.append(vertex)
# Split faces with more than 3 vertices
for i in range(1, len(face.v) - 1):
Face(submesh, face_vertices[0], face_vertices[i], face_vertices[i + 1])
# Computes LODs info
if LODS:
submesh.compute_lods()
for clone in vertex.clones:
if (clone.maps[0].u == uv[0]) and (clone.maps[0].v == uv[1]):
vertex = clone
break
else: # Not yet cloned...
old_vertex = vertex
vertex = Vertex(submesh, vertex.loc, vertex.normal)
vertex.cloned_from = old_vertex
vertex.influences = old_vertex.influences
if outputuv: vertex.maps.append(Map(*uv))
old_vertex.clones.append(vertex)
face_vertices.append(vertex)
# Split faces with more than 3 vertices
for i in range(1, len(face.v) - 1):
Face(submesh, face_vertices[0], face_vertices[i], face_vertices[i + 1])
# Computes LODs info
if LODS:
submesh.compute_lods()
# ---- Export animations --------------------------------------------------
@ -1269,14 +1269,14 @@ def export(filename):
#run 1: we need to find all time values where we need to produce keyframes
for curve in ipo.getCurves():
curve_name = curve.getName()
curve_name = curve.name
if curve_name not in ["QuatW", "QuatX", "QuatY", "QuatZ", "LocX", "LocY", "LocZ"]:
log.error("Curve type %s not supported in Action '%s' Bone '%s'.\n"\
% (curve_name, animation_name, bone_name))
for p in curve.getPoints():
time = p.getPoints() [0]
for p in curve.bezierPoints:
time = p.pt[0]
if time not in times:
times.append(time)
@ -1291,15 +1291,16 @@ def export(filename):
quat = [0, 0, 0, 0]
for curve in ipo.getCurves():
val = curve.evaluate(time)
if curve.getName() == "LocX": trans[0] = val
if curve.getName() == "LocY": trans[1] = val
if curve.getName() == "LocZ": trans[2] = val
if curve.getName() == "QuatW": quat[3] = val
if curve.getName() == "QuatX": quat[0] = val
if curve.getName() == "QuatY": quat[1] = val
if curve.getName() == "QuatZ": quat[2] = val
log.debug('Curve: %s' % curve.getName())
cname = curve.name
val = curve[time]
if cname == "LocX": trans[0] = val
elif cname == "LocY": trans[1] = val
elif cname == "LocZ": trans[2] = val
elif cname == "QuatW": quat[3] = val
elif cname == "QuatX": quat[0] = val
elif cname == "QuatY": quat[1] = val
elif cname == "QuatZ": quat[2] = val
log.debug('Curve: %s' % cname)
if quat==[0,0,0,0]:
log.critical('You are using just Loc keys. You must use LocRot keys instead.')

@ -604,7 +604,7 @@ def construction_dico_correspondance():
#we add a point to the IPO curve Target
def ajoute_point(cle,frame,valeur):
cle.setInterpolation('Linear')
cle.addBezier((frame,valeur))
cle.append((frame,valeur))
cle.Recalc()
#cette fonction parcours le dictionnaire des frame à ajouter et construit les points

@ -311,18 +311,14 @@ def bvh_node_dict2objects(bvh_nodes, IMPORT_START_FRAME= 1):
IMPORT_START_FRAME= 1
scn= Blender.Scene.GetCurrent()
for ob in scn.getChildren():
for ob in scn.objects:
ob.sel= 0
objects= []
def add_ob(name):
ob= Blender.Object.New('Empty', name)
scn.link(ob)
ob.sel= 1
ob.Layers= scn.Layers
ob = scn.objects.new('Empty')
objects.append(ob)
return ob
# Add objects
for name, bvh_node in bvh_nodes.iteritems():
@ -448,7 +444,7 @@ def bvh_node_dict2armature(bvh_nodes, IMPORT_START_FRAME= 1):
scn= Blender.Scene.GetCurrent()
for ob in scn.getChildren():
for ob in scn.objects:
ob.sel= 0
scn.link(arm_ob)

@ -103,9 +103,8 @@ def flipFace(v):
# return object with given object name (with variable parts) and mesh name
def getObjectByName(obj_name, mesh_name):
objs = Blender.Scene.GetCurrent().getChildren() #Blender.Object.Get()
for obj in objs:
if obj.getType() == "Mesh":
for obj in Blender.Scene.GetCurrent().objects:
if obj.type == "Mesh":
# if obj.getName()[0:len(obj_name)] == obj_name and obj.getData().name == mesh_name:
# use only mesh_name so bone name and weight (in the envelope name)
# can be changed by the user and mirrored by the script.
@ -118,13 +117,12 @@ SUFFIX_LEN = len(REF_SUFFIX);
Blender.Window.EditMode(0)
count = 0
objs = Blender.Scene.GetCurrent().getChildren() #objs = Blender.Object.Get()
for obj in objs:
if obj.getType() != 'Mesh':
for obj in Blender.Scene.GetCurrent().objects:
if obj.type != 'Mesh':
continue
count += 1
name = obj.getName()
name = obj.name
pos = name.find(SEPARATOR)
if (pos > -1):
ApplySizeAndRotation(obj)

@ -270,8 +270,8 @@ def ExportToIv(file_name):
meshes = []
lamps = []
cameras = []
for object in scene.getChildren():
obtype= object.getType()
for object in scene.objects:
obtype= object.type
if obtype == "Mesh":
meshes.append(object);
#elif obtype == "Lamp":

@ -609,7 +609,7 @@ def write_ui(filename):
if EXPORT_SEL_ONLY:
export_objects = scn.objects.context
else:
export_objects = scn.objects # scn.getChildren()
export_objects = scn.objects
full_path= ''.join(context_name)

@ -675,7 +675,7 @@ class Database(Node):
def __init__(self, scene, fw):
self.fw = fw
self.scene = scene
self.all_objects = scene.getChildren()
self.all_objects = list(scene.objects)
self.GRR = GlobalResourceRepository()
Node.__init__(self, None, self, None, self.all_objects)

@ -1807,7 +1807,7 @@ def select_file(filename):
# first set the context
Blender.Window.WaitCursor(True)
Blender.Window.EditMode(0)
for ob in scene.getChildren():
for ob in scene.objects:
ob.sel=0

@ -222,7 +222,7 @@ def read(filename):
tobj.logcon ("Importing file:")
tobj.logcon (filename)
for ob in Blender.Scene.GetCurrent().getChildren():
for ob in Blender.Scene.GetCurrent().objects:
ob.sel= 0
start = Blender.sys.time()
@ -1815,7 +1815,7 @@ for i, _lwo in enumerate(lines):
read(_lwo)
# Remove objects to save memory?
'''
for ob in newScn.getChildren():
for ob in newScn.objects:
if ob.getType()=='Mesh':
me= ob.getData(mesh=1)
me.verts= None

@ -82,7 +82,7 @@ def read(filename):
start = Blender.sys.time()
scn= Blender.Scene.GetCurrent()
for obj in scn.getChildren():
for obj in scn.objects:
obj.sel= 0
file = open(filename, "rb")

@ -289,7 +289,7 @@ def filesel_callback(filename):
objname = Blender.sys.splitext(Blender.sys.basename(filename))[0]
scn= Blender.Scene.GetCurrent()
for obj in scn.getChildren():
for obj in scn.objects:
obj.sel= 0
obj= Blender.Object.New('Mesh', objname)

@ -122,7 +122,7 @@ def read(filename):
mesh.faces.append(face)
scn= Blender.Scene.GetCurrent()
for obj in scn.getChildren():
for obj in scn.objects:
obj.sel= 0
obj= Blender.Object.New('Mesh', objname)

@ -102,17 +102,12 @@ def read(filename):
me.faces.extend(faces)
objname = Blender.sys.splitext(Blender.sys.basename(filename))[0]
scn= Blender.Scene.GetCurrent()
for obj in scn.getChildren():
for obj in scn.objects:
obj.sel= 0
me.name= objname
ob= Blender.Object.New('Mesh', objname)
ob.link(me)
scn.link(ob)
ob.sel= 1
ob.Layers= scn.Layers
me.name= Blender.sys.splitext(Blender.sys.basename(filename))[0]
ob = scn.objects.new(me)
Blender.Redraw()
print 'Successfully imported "%s" in %.4f seconds' % (Blender.sys.basename(filename), Blender.sys.time()-t)

@ -47,7 +47,7 @@ from Blender.BGL import *
O = Scene.GetCurrent().getChildren()
O = list(Scene.GetCurrent().objects)
stringlist=[[],[]]
@ -55,7 +55,7 @@ def renew():
global O
#O = Object.Get()
O= Scene.GetCurrent().getChildren()
O = list(Scene.GetCurrent().objects)
#param= [ [p.name, i, p.getType()] for i, p in enumerate(O) ]
PARAM={}

@ -507,11 +507,11 @@ def Blender240update(MESH2,FRAME):
# ---------------------------
# On ajouter les sommets necessaires ...
# ---------------------------
ipocurve.addBezier((-1,1))
ipocurve.append((-1,1))
# ---------------------------
# ... ce dernire n'est peut-être pas absolument obligatoire .
# ---------------------------
ipocurve.addBezier((FRAME+1,1))
ipocurve.append((FRAME+1,1))
#-----------------------------------
# release : 0.3.2 , 2005/12/28 , end
#-----------------------------------

@ -170,7 +170,7 @@ def PrintConfig():
def ExportCallback(f):
obj = Blender.Scene.getCurrent().getActiveObject()
obj = Blender.Scene.GetCurrent().objects.active
time1= Blender.sys.time()
@ -178,7 +178,7 @@ def ExportCallback(f):
Blender.Draw.PupMenu("ERROR%t|No Active Object!")
return
if obj.getType() != "Mesh":
if obj.type != "Mesh":
Blender.Draw.PupMenu("ERROR%t|Not a Mesh!")
return

@ -284,11 +284,11 @@ class VRML2Export:
def writeNavigationInfo(self, scene):
allObj = []
allObj = scene.getChildren()
allObj = list(scene.objects)
headlight = "TRUE"
vislimit = 0.0
for thisObj in allObj:
objType=thisObj.getType()
objType=thisObj.type
if objType == "Camera":
vislimit = thisObj.data.getClipEnd()
elif objType == "Lamp":
@ -958,7 +958,7 @@ class VRML2Export:
round(sky1,self.cp), \
round(sky2,self.cp)))
alltexture = len(worldmat)
for i in range(alltexture):
for i in xrange(alltexture):
namemat = worldmat[i].getName()
pic = worldmat[i].getImage()
if pic:
@ -980,7 +980,7 @@ class VRML2Export:
self.writeIndented("\n\n")
def writeLamp(self, ob):
la = Lamp.Get(ob.data.getName())
la = ob.data
laType = la.getType()
if laType == Lamp.Types.Lamp:
@ -1090,9 +1090,9 @@ class VRML2Export:
self.proto = 0
allObj = []
if ARG == 'selected':
allObj = Blender.Object.GetSelected()
allObj = list(scene.objects.context)
else:
allObj = scene.getChildren()
allObj = list(scene.objects)
self.writeInline()
for thisObj in allObj:

@ -95,7 +95,7 @@ drawtype = 0
#get rid of an ipo curve by deleting all its points
def delCurve(ipo):
while len(ipo.getPoints()) > 0:
while len(ipo.bezierPoints) > 0:
ipo.delBezier(0)
ipo.recalc()
@ -110,11 +110,11 @@ def verifyIpocurve(ky,index):
idx = "Basis"
else:
idx = "Key " + str(index)
crv = ipo.getCurve(index)
crv = ipo[index]
if crv == None:
# print idx
crv = ipo.addCurve(idx)
crv.setInterpolation("Linear")
crv.interpolation = IpoCurve.InterpTypes.LINEAR
return crv
# Add the Drivers and Curves
@ -137,15 +137,15 @@ def setupDrivers(ob,ctrl,type):
delCurve(ipo)
if type == 1:
ipo.addBezier((-1,-1))
ipo.addBezier((0,0))
ipo.addBezier((1,1))
ipo.append((-1,-1))
ipo.append((0,0))
ipo.append((1,1))
if type == 2:
ipo.addBezier((0,0))
ipo.addBezier((1,1))
ipo.append((0,0))
ipo.append((1,1))
if type == 3:
ipo.addBezier((-1,-1))
ipo.addBezier((0,0))
ipo.append((-1,-1))
ipo.append((0,0))
ipo.recalc()
if type == SHAPE1_TOGGLE:
@ -156,10 +156,10 @@ def setupDrivers(ob,ctrl,type):
ipo.driverChannel = IpoCurve.LOC_Z
ipo.recalc()
delCurve(ipo)
ipo.addBezier((0,0))
ipo.addBezier((0.5,0))
ipo.addBezier((0.500001,1))
ipo.addBezier((1,1))
ipo.append((0,0))
ipo.append((0.5,0))
ipo.append((0.500001,1))
ipo.append((1,1))
ipo.recalc()
if type == SHAPE2_EXCLUSIVE:
@ -170,8 +170,8 @@ def setupDrivers(ob,ctrl,type):
ipo.driverChannel = IpoCurve.LOC_Z
ipo.recalc()
delCurve(ipo)
ipo.addBezier((0,0))
ipo.addBezier((1,1))
ipo.append((0,0))
ipo.append((1,1))
ipo.recalc()
ipo2 = verifyIpocurve(ky,shapes[1].val)
@ -180,8 +180,8 @@ def setupDrivers(ob,ctrl,type):
ipo2.driverChannel = IpoCurve.LOC_Z
ipo2.recalc()
delCurve(ipo2)
ipo2.addBezier((-1,1))
ipo2.addBezier((0,0))
ipo2.append((-1,1))
ipo2.append((0,0))
ipo2.recalc()
if type == SHAPE2_T:
@ -192,8 +192,8 @@ def setupDrivers(ob,ctrl,type):
ipo.driverChannel = IpoCurve.LOC_Z
ipo.recalc()
delCurve(ipo)
ipo.addBezier((-1,-1))
ipo.addBezier((0,0))
ipo.append((-1,-1))
ipo.append((0,0))
ipo.recalc()
ipo2 = verifyIpocurve(ky,shapes[1].val)
@ -202,8 +202,8 @@ def setupDrivers(ob,ctrl,type):
ipo2.driverChannel = IpoCurve.LOC_X
ipo2.recalc()
delCurve(ipo2)
ipo2.addBezier((-1,-1))
ipo2.addBezier((1,1))
ipo2.append((-1,-1))
ipo2.append((1,1))
ipo2.recalc()
if type == SHAPE2_INVT:
@ -214,8 +214,8 @@ def setupDrivers(ob,ctrl,type):
ipo.driverChannel = IpoCurve.LOC_Z
ipo.recalc()
delCurve(ipo)
ipo.addBezier((0,0))
ipo.addBezier((1,1))
ipo.append((0,0))
ipo.append((1,1))
ipo.recalc()
ipo2 = verifyIpocurve(ky,shapes[1].val)
@ -224,8 +224,8 @@ def setupDrivers(ob,ctrl,type):
ipo2.driverChannel = IpoCurve.LOC_X
ipo2.recalc()
delCurve(ipo2)
ipo2.addBezier((-1,-1))
ipo2.addBezier((1,1))
ipo2.append((-1,-1))
ipo2.append((1,1))
ipo2.recalc()
if type == SHAPE2_PLUS:
@ -236,8 +236,8 @@ def setupDrivers(ob,ctrl,type):
ipo.driverChannel = IpoCurve.LOC_Z
ipo.recalc()
delCurve(ipo)
ipo.addBezier((-1,-1))
ipo.addBezier((1,1))
ipo.append((-1,-1))
ipo.append((1,1))
ipo.recalc()
ipo2 = verifyIpocurve(ky,shapes[1].val)
@ -246,8 +246,8 @@ def setupDrivers(ob,ctrl,type):
ipo2.driverChannel = IpoCurve.LOC_X
ipo2.recalc()
delCurve(ipo2)
ipo2.addBezier((-1,-1))
ipo2.addBezier((1,1))
ipo2.append((-1,-1))
ipo2.append((1,1))
ipo2.recalc()
if type == SHAPE2_V: # 2 Shape Mix
@ -257,8 +257,8 @@ def setupDrivers(ob,ctrl,type):
ipo.driverObject = ctrl
ipo.driverChannel = IpoCurve.LOC_Z
delCurve(ipo)
ipo.addBezier((0,0))
ipo.addBezier((1,1))
ipo.append((0,0))
ipo.append((1,1))
ipo.recalc()
ipo2 = verifyIpocurve(ky,shapes[1].val)
@ -266,8 +266,8 @@ def setupDrivers(ob,ctrl,type):
ipo2.driverObject = ctrl
ipo2.driverChannel = IpoCurve.LOC_X
delCurve(ipo2)
ipo2.addBezier((0,0))
ipo2.addBezier((1,1))
ipo2.append((0,0))
ipo2.append((1,1))
ipo2.recalc()
@ -279,8 +279,8 @@ def setupDrivers(ob,ctrl,type):
ipo.driverChannel = IpoCurve.LOC_Z
ipo.recalc()
delCurve(ipo)
ipo.addBezier((0,0))
ipo.addBezier((1,1))
ipo.append((0,0))
ipo.append((1,1))
ipo.recalc()
ipo2 = verifyIpocurve(ky,shapes[1].val)
@ -289,8 +289,8 @@ def setupDrivers(ob,ctrl,type):
ipo2.driverChannel = IpoCurve.LOC_X
ipo2.recalc()
delCurve(ipo2)
ipo2.addBezier((-1,1))
ipo2.addBezier((0,0))
ipo2.append((-1,1))
ipo2.append((0,0))
ipo2.recalc()
ipo2 = verifyIpocurve(ky,shapes[2].val)
@ -299,8 +299,8 @@ def setupDrivers(ob,ctrl,type):
ipo2.driverChannel = IpoCurve.LOC_X
ipo2.recalc()
delCurve(ipo2)
ipo2.addBezier((0,0))
ipo2.addBezier((1,1))
ipo2.append((0,0))
ipo2.append((1,1))
ipo2.recalc()
if type == SHAPE3_T:
@ -311,8 +311,8 @@ def setupDrivers(ob,ctrl,type):
ipo.driverChannel = IpoCurve.LOC_Z
ipo.recalc()
delCurve(ipo)
ipo.addBezier((-1,-1))
ipo.addBezier((0,0))
ipo.append((-1,-1))
ipo.append((0,0))
ipo.recalc()
ipo2 = verifyIpocurve(ky,shapes[1].val)
@ -321,8 +321,8 @@ def setupDrivers(ob,ctrl,type):
ipo2.driverChannel = IpoCurve.LOC_X
ipo2.recalc()
delCurve(ipo2)
ipo2.addBezier((-1,1))
ipo2.addBezier((0,0))
ipo2.append((-1,1))
ipo2.append((0,0))
ipo2.recalc()
ipo2 = verifyIpocurve(ky,shapes[2].val)
@ -331,8 +331,8 @@ def setupDrivers(ob,ctrl,type):
ipo2.driverChannel = IpoCurve.LOC_X
ipo2.recalc()
delCurve(ipo2)
ipo2.addBezier((0,0))
ipo2.addBezier((1,1))
ipo2.append((0,0))
ipo2.append((1,1))
ipo2.recalc()
if type == SHAPE4_X:
@ -342,8 +342,8 @@ def setupDrivers(ob,ctrl,type):
ipo.driverObject = ctrl
ipo.driverChannel = IpoCurve.LOC_Z
delCurve(ipo)
ipo.addBezier((0,0))
ipo.addBezier((1,1))
ipo.v((0,0))
ipo.v((1,1))
ipo.recalc()
ipo2 = verifyIpocurve(ky,shapes[1].val)
@ -351,8 +351,8 @@ def setupDrivers(ob,ctrl,type):
ipo2.driverObject = ctrl
ipo2.driverChannel = IpoCurve.LOC_X
delCurve(ipo2)
ipo2.addBezier((0,0))
ipo2.addBezier((1,1))
ipo2.v((0,0))
ipo2.v((1,1))
ipo2.recalc()
ipo3 = verifyIpocurve(ky,shapes[2].val)
@ -360,8 +360,8 @@ def setupDrivers(ob,ctrl,type):
ipo3.driverObject = ctrl
ipo3.driverChannel = IpoCurve.LOC_X
delCurve(ipo3)
ipo3.addBezier((-1,1))
ipo3.addBezier((0,0))
ipo3.v((-1,1))
ipo3.append((0,0))
ipo3.recalc()
ipo4 = verifyIpocurve(ky,shapes[3].val)
@ -369,8 +369,8 @@ def setupDrivers(ob,ctrl,type):
ipo4.driverObject = ctrl
ipo4.driverChannel = IpoCurve.LOC_Z
delCurve(ipo4)
ipo4.addBezier((-1,1))
ipo4.addBezier((0,0))
ipo4.append((-1,1))
ipo4.append((0,0))
ipo4.recalc()
#The Main Call to Build the Widget

@ -251,11 +251,11 @@ class VRML2Export:
def writeNavigationInfo(self, scene):
allObj = []
allObj = scene.getChildren()
allObj = list(scene.objects)
headlight = "TRUE"
vislimit = 0.0
for thisObj in allObj:
objType=thisObj.getType()
objType=thisObj.type
if objType == "Camera":
vislimit = thisObj.data.getClipEnd()
elif objType == "Lamp":
@ -731,21 +731,21 @@ class VRML2Export:
self.proto = 0
allObj = []
if ARG == 'selected':
allObj = Blender.Object.GetSelected()
allObj = list(scene.objects.context)
else:
allObj = scene.getChildren()
allObj = list(scene.objects)
self.writeInline()
for thisObj in allObj:
try:
objType=thisObj.getType()
objName=thisObj.getName()
objType=thisObj.type
objName=thisObj.name
self.matonly = 0
if objType == "Camera":
self.writeViewpoint(thisObj)
elif objType == "Mesh":
self.writeIndexedFaceSet(thisObj, normals = 0)
elif objType == "Lamp":
lmpName=Lamp.Get(thisObj.data.getName())
lmpName= thisObj.data
lmpType=lmpName.getType()
if lmpType == Lamp.Types.Lamp:
self.writePointLight(thisObj, lmpName)

@ -162,7 +162,7 @@ def get_materials(obj):
# any materials attached to the object itself
mats = obj.getMaterials(0)
if 'Mesh' != obj.getType():
if 'Mesh' != obj.type:
return mats
# now drop down to the mesh level
@ -252,14 +252,14 @@ def do_materiallibrary():
# run through every material, how many used?
for mat in MAT:
nmat = mat.getName()
nmat = mat.name
# first, is this material on any of the objects.
f = 0
for obj in OBJ:
ml = get_materials(obj)
for mli in ml:
nmli = mli.getName()
nmli = mli.name
if nmli == nmat:
f = 1
mnum += 1
@ -279,14 +279,14 @@ def do_materiallibrary():
# run through every material, write the used ones
for mat in MAT:
nmat = mat.getName()
nmat = mat.name
# find out if on any object, if so we write.
f = 0
for obj in OBJ:
ml = get_materials(obj)
for mli in ml:
nmli = mli.getName()
nmli = mli.name
if nmli == nmat:
do_material(mat)
f = 1
@ -330,7 +330,7 @@ def do_material(mat):
# get the name first
name = mat.getName()
name = mat.name
# face colour r, g, b, a
# power (spec decay) fl
@ -395,7 +395,7 @@ def do_texture(mtex):
# get our texture
tex = mtex.tex
tn = tex.getName()
tn = tex.name
# what type of texture, we are limitd
@ -496,7 +496,7 @@ def do_model_transform(obj):
global FD
# now output
FD.write(" SI_Transform SRT-" + removeSpacesFromName( obj.getName() ) + " {\n" )
FD.write(" SI_Transform SRT-" + removeSpacesFromName( obj.name ) + " {\n" )
@ -559,7 +559,7 @@ def do_model_material(obj):
for mat in ml:
FD.write(" SI_GlobalMaterial {\n" )
FD.write(" \"" + removeSpacesFromName(mat.getName()) + "\",\n" )
FD.write(" \"" + removeSpacesFromName(mat.name) + "\",\n" )
FD.write(" \"NODE\",\n" )
FD.write(" }\n\n" )
@ -656,7 +656,7 @@ def do_mesh_shape(obj):
elements+=1
if len(VCC):
elements+=1
FD.write(" SI_Shape SHP-" + removeSpacesFromName ( obj.getName() ) + "-ORG {\n" )
FD.write(" SI_Shape SHP-" + removeSpacesFromName ( obj.name ) + "-ORG {\n" )
FD.write(" %d,\n" % elements )
FD.write(" \"ORDERED\",\n\n" )
@ -751,7 +751,7 @@ def do_mesh_faces(obj):
triangles = len(tris)
if n == 0:
FD.write(" SI_TriangleList " + removeSpacesFromName(obj.getName()) + " {\n")
FD.write(" SI_TriangleList " + removeSpacesFromName(obj.name) + " {\n")
FD.write(" %d,\n" % triangles)
ostring=" \"NORMAL"
@ -793,7 +793,7 @@ def do_mesh_faces(obj):
#
# output the shell
FD.write(" SI_TriangleList " + removeSpacesFromName(obj.getName()) + " {\n")
FD.write(" SI_TriangleList " + removeSpacesFromName(obj.name) + " {\n")
# FD.write(" %d,\n" % triangles)
FD.write(" %d,\n" % aTriCount)
@ -806,7 +806,7 @@ def do_mesh_faces(obj):
FD.write(ostring)
FD.write(" \"" + removeSpacesFromName ( mat.getName() ) + "\",\n\n")
FD.write(" \"" + removeSpacesFromName ( mat.name ) + "\",\n\n")
# FD.write(" \"\",\n\n")
@ -950,7 +950,7 @@ def do_model_mesh(obj):
global FD
# output the shell
FD.write(" SI_Mesh MSH-" + removeSpacesFromName(obj.getName()) + " {\n")
FD.write(" SI_Mesh MSH-" + removeSpacesFromName(obj.name) + " {\n")
# todo, add calc normals and calc uv here
# these can be used in both the following sections.
@ -974,19 +974,19 @@ def do_model(obj):
global FD
# we only want meshes for now.
if 'Mesh' != obj.getType():
if 'Mesh' != obj.type:
return
# check if the mesh is valid
if validMesh(obj) <> 0:
print "INVALID MESH " + obj.getName ()
print "INVALID MESH " + obj.name
return
print "Exporting model " + obj.getName ()
print "Exporting model " + obj.name
# start model
FD.write(" SI_Model MDL-" + removeSpacesFromName(obj.getName()) + " {\n")
FD.write(" SI_Model MDL-" + removeSpacesFromName(obj.name) + " {\n")
# do transform
do_model_transform(obj)
@ -1064,10 +1064,10 @@ def do_light(obj):
global FD
# we only want lights for now.
if 'Lamp' != obj.getType():
if 'Lamp' != obj.type:
return
print "Exporting light " + obj.getName ()
print "Exporting light " + obj.name
aLampType = 1
@ -1084,12 +1084,12 @@ def do_light(obj):
aLampType = 0
# start model
FD.write(" SI_Light " + removeSpacesFromName(obj.getName()) + " {\n")
FD.write(" SI_Light " + removeSpacesFromName(obj.name) + " {\n")
# do type
FD.write(" %d,\n" % aLampType)
lampName=Lamp.Get(obj.data.getName())
lampName= obj.data
colour = lampName.col
# do color
@ -1116,18 +1116,18 @@ def do_camera(obj):
global FD
# we only want cameras for now.
if 'Camera' != obj.getType():
if 'Camera' != obj.type:
return
print "Exporting camera " + obj.getName ()
print "Exporting camera " + obj.name
# start model
FD.write(" SI_Camera " + removeSpacesFromName(obj.getName()) + " {\n")
FD.write(" SI_Camera " + removeSpacesFromName(obj.name) + " {\n")
cameraName=Camera.Get(obj.data.getName())
cameraName=obj.data
# colour = cameraName.col
@ -1210,7 +1210,7 @@ def export_xsi(filename):
#OBJ = Blender.Object.GetSelected()
#if not OBJ:
OBJ = Blender.Scene.GetCurrent().getChildren() #Blender.Object.Get()
OBJ = list(Blender.Scene.GetCurrent().objects) #Blender.Object.Get()
# we need some objects, if none specified stop
if not OBJ:

@ -186,7 +186,8 @@ class Scene:
def getChildren():
"""
Get all objects linked to this Scene.
Get all objects linked to this Scene. (B{deprecated}). B{Note}: new scripts
should use the L{objects} attribute instead, in cases where a list is requiresd use list(scn.objects).
@rtype: list of Blender Objects
@return: A list with all Blender Objects linked to this Scene.
@note: L{Object.Get} will return all objects currently in Blender, which