rna api:
rename object.matrix --> matrix_world added object.matrix_local (parent relative matrix)
This commit is contained in:
parent
7a495a12e1
commit
9a85435e96
@ -134,7 +134,7 @@ def write_pov(filename, scene=None, info_callback=None):
|
||||
|
||||
def exportCamera():
|
||||
camera = scene.camera
|
||||
matrix = camera.matrix
|
||||
matrix = camera.matrix_world
|
||||
|
||||
# compute resolution
|
||||
Qsize = float(render.resolution_x) / float(render.resolution_y)
|
||||
@ -155,7 +155,7 @@ def write_pov(filename, scene=None, info_callback=None):
|
||||
for ob in lamps:
|
||||
lamp = ob.data
|
||||
|
||||
matrix = ob.matrix
|
||||
matrix = ob.matrix_world
|
||||
|
||||
color = tuple([c * lamp.energy for c in lamp.color]) # Colour is modified by energy
|
||||
|
||||
@ -263,7 +263,7 @@ def write_pov(filename, scene=None, info_callback=None):
|
||||
|
||||
writeObjectMaterial(material)
|
||||
|
||||
writeMatrix(ob.matrix)
|
||||
writeMatrix(ob.matrix_world)
|
||||
|
||||
file.write('}\n')
|
||||
|
||||
@ -292,7 +292,7 @@ def write_pov(filename, scene=None, info_callback=None):
|
||||
# continue
|
||||
# me = ob.data
|
||||
|
||||
matrix = ob.matrix
|
||||
matrix = ob.matrix_world
|
||||
try:
|
||||
uv_layer = me.active_uv_texture.data
|
||||
except:
|
||||
|
@ -82,7 +82,7 @@ def create_derived_objects(scene, ob):
|
||||
ob.create_dupli_list(scene)
|
||||
return True, [(dob.object, dob.matrix) for dob in ob.dupli_list]
|
||||
else:
|
||||
return False, [(ob, ob.matrix)]
|
||||
return False, [(ob, ob.matrix_world)]
|
||||
|
||||
# also used by X3D exporter
|
||||
def free_derived_objects(ob):
|
||||
|
@ -528,7 +528,7 @@ def write(filename, batch_objects = None, \
|
||||
self.fbxGroupNames = []
|
||||
self.fbxParent = None # set later on IF the parent is in the selection.
|
||||
if matrixWorld: self.matrixWorld = GLOBAL_MATRIX * matrixWorld
|
||||
else: self.matrixWorld = GLOBAL_MATRIX * ob.matrix
|
||||
else: self.matrixWorld = GLOBAL_MATRIX * ob.matrix_world
|
||||
# else: self.matrixWorld = ob.matrixWorld * GLOBAL_MATRIX
|
||||
self.__anim_poselist = {} # we should only access this
|
||||
|
||||
@ -539,8 +539,7 @@ def write(filename, batch_objects = None, \
|
||||
return self.matrixWorld
|
||||
|
||||
def setPoseFrame(self, f):
|
||||
self.__anim_poselist[f] = self.blenObject.matrix.copy()
|
||||
# self.__anim_poselist[f] = self.blenObject.matrixWorld.copy()
|
||||
self.__anim_poselist[f] = self.blenObject.matrix_world.copy()
|
||||
|
||||
def getAnimParRelMatrix(self, frame):
|
||||
if self.fbxParent:
|
||||
@ -646,7 +645,7 @@ def write(filename, batch_objects = None, \
|
||||
|
||||
else:
|
||||
# This is bad because we need the parent relative matrix from the fbx parent (if we have one), dont use anymore
|
||||
#if ob and not matrix: matrix = ob.matrixWorld * GLOBAL_MATRIX
|
||||
#if ob and not matrix: matrix = ob.matrix_world * GLOBAL_MATRIX
|
||||
if ob and not matrix: raise Exception("error: this should never happen!")
|
||||
|
||||
matrix_rot = matrix
|
||||
@ -2025,7 +2024,7 @@ def write(filename, batch_objects = None, \
|
||||
if ob_base.parent and ob_base.parent.dupli_type != 'NONE':
|
||||
continue
|
||||
|
||||
obs = [(ob_base, ob_base.matrix)]
|
||||
obs = [(ob_base, ob_base.matrix_world)]
|
||||
if ob_base.dupli_type != 'NONE':
|
||||
ob_base.create_dupli_list(scene)
|
||||
obs = [(dob.object, dob.matrix) for dob in ob_base.dupli_list]
|
||||
|
@ -113,7 +113,7 @@ def write(filename, sce, ob, PREF_STARTFRAME, PREF_ENDFRAME, PREF_FPS):
|
||||
"""
|
||||
|
||||
check_vertcount(me, numverts)
|
||||
me.transform(mat_flip * ob.matrix)
|
||||
me.transform(mat_flip * ob.matrix_world)
|
||||
f.write(pack(">%df" % (numverts * 3), *[axis for v in me.verts for axis in v.co]))
|
||||
|
||||
for frame in range(PREF_STARTFRAME, PREF_ENDFRAME + 1):#in order to start at desired frame
|
||||
@ -125,7 +125,7 @@ def write(filename, sce, ob, PREF_STARTFRAME, PREF_ENDFRAME, PREF_FPS):
|
||||
sce.set_frame(frame)
|
||||
me = ob.create_mesh(sce, True, 'PREVIEW')
|
||||
check_vertcount(me, numverts)
|
||||
me.transform(mat_flip * ob.matrix)
|
||||
me.transform(mat_flip * ob.matrix_world)
|
||||
|
||||
# Write the vertex data
|
||||
f.write(pack(">%df" % (numverts * 3), *[axis for v in me.verts for axis in v.co]))
|
||||
|
@ -403,7 +403,7 @@ def write(filepath, objects, scene,
|
||||
# XXX debug print
|
||||
print(ob_main.name, 'has', len(obs), 'dupli children')
|
||||
else:
|
||||
obs = [(ob_main, ob_main.matrix)]
|
||||
obs = [(ob_main, ob_main.matrix_world)]
|
||||
|
||||
for ob, ob_mat in obs:
|
||||
|
||||
|
@ -111,7 +111,7 @@ def write(filename, scene, ob, \
|
||||
raise ("Error, could not get mesh data from active object")
|
||||
return
|
||||
|
||||
# mesh.transform(ob.matrixWorld) # XXX
|
||||
# mesh.transform(ob.matrix_world) # XXX
|
||||
|
||||
faceUV = (len(mesh.uv_textures) > 0)
|
||||
vertexUV = (len(mesh.sticky) > 0)
|
||||
|
@ -237,7 +237,7 @@ class x3d_class:
|
||||
lens = min(lens, math.pi)
|
||||
|
||||
# get the camera location, subtract 90 degress from X to orient like X3D does
|
||||
# mat = ob.matrixWorld - mat is now passed!
|
||||
# mat = ob.matrix_world - mat is now passed!
|
||||
|
||||
loc = self.rotatePointForVRML(mat.translation_part())
|
||||
rot = mat.to_euler()
|
||||
@ -300,7 +300,7 @@ class x3d_class:
|
||||
# note -dz seems to equal om[3][1]
|
||||
# note dy seems to equal om[3][2]
|
||||
|
||||
#location=(ob.matrixWorld*MATWORLD).translation_part() # now passed
|
||||
#location=(ob.matrix_world*MATWORLD).translation_part() # now passed
|
||||
location=(mtx*MATWORLD).translation_part()
|
||||
|
||||
radius = lamp.distance*math.cos(beamWidth)
|
||||
@ -346,7 +346,7 @@ class x3d_class:
|
||||
ambi = 0
|
||||
ambientIntensity = 0
|
||||
|
||||
# location=(ob.matrixWorld*MATWORLD).translation_part() # now passed
|
||||
# location=(ob.matrix_world*MATWORLD).translation_part() # now passed
|
||||
location= (mtx*MATWORLD).translation_part()
|
||||
|
||||
self.file.write("<PointLight DEF=\"%s\" " % safeName)
|
||||
@ -364,7 +364,7 @@ class x3d_class:
|
||||
return
|
||||
else:
|
||||
dx,dy,dz = self.computeDirection(mtx)
|
||||
# location=(ob.matrixWorld*MATWORLD).translation_part()
|
||||
# location=(ob.matrix_world*MATWORLD).translation_part()
|
||||
location=(mtx*MATWORLD).translation_part()
|
||||
self.writeIndented("<%s\n" % obname,1)
|
||||
self.writeIndented("direction=\"%s %s %s\"\n" % (round(dx,3),round(dy,3),round(dz,3)))
|
||||
@ -445,7 +445,7 @@ class x3d_class:
|
||||
else:
|
||||
bTwoSided=0
|
||||
|
||||
# mtx = ob.matrixWorld * MATWORLD # mtx is now passed
|
||||
# mtx = ob.matrix_world * MATWORLD # mtx is now passed
|
||||
mtx = mtx * MATWORLD
|
||||
|
||||
loc= mtx.translation_part()
|
||||
@ -601,7 +601,7 @@ class x3d_class:
|
||||
self.file.write("\">\n")
|
||||
else:
|
||||
#-- vertices
|
||||
# mesh.transform(ob.matrixWorld)
|
||||
# mesh.transform(ob.matrix_world)
|
||||
self.writeIndented("<Coordinate DEF=\"%s%s\" \n" % ("coord_",meshName), 1)
|
||||
self.file.write("\t\t\t\tpoint=\"")
|
||||
for v in mesh.verts:
|
||||
|
@ -427,9 +427,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
|
||||
'''
|
||||
|
||||
if contextMatrix_rot:
|
||||
# ob.matrix = [x for row in contextMatrix_rot for x in row]
|
||||
ob.matrix = contextMatrix_rot
|
||||
# ob.setMatrix(contextMatrix_rot)
|
||||
ob.matrix_world = contextMatrix_rot
|
||||
|
||||
importedObjects.append(ob)
|
||||
bmesh.update()
|
||||
@ -892,7 +890,7 @@ def load_3ds(filename, context, IMPORT_CONSTRAIN_BOUNDS=10.0, IMAGE_SEARCH=True,
|
||||
# me = ob.getData(mesh=1)
|
||||
# me.verts.delete([me.verts[0],])
|
||||
# if not APPLY_MATRIX:
|
||||
# me.transform(ob.matrixWorld.copy().invert())
|
||||
# me.transform(ob.matrix_world.copy().invert())
|
||||
|
||||
# Done DUMMYVERT
|
||||
"""
|
||||
@ -950,7 +948,7 @@ def load_3ds(filename, context, IMPORT_CONSTRAIN_BOUNDS=10.0, IMAGE_SEARCH=True,
|
||||
# SCALE_MAT = Blender.mathutils.Matrix([SCALE,0,0,0],[0,SCALE,0,0],[0,0,SCALE,0],[0,0,0,1])
|
||||
|
||||
for ob in importedObjects:
|
||||
ob.setMatrix(ob.matrixWorld * SCALE_MAT)
|
||||
ob.matrix_world = ob.matrix_world * SCALE_MAT
|
||||
|
||||
# Done constraining to bounds.
|
||||
|
||||
|
@ -61,7 +61,7 @@ def add_object_data(context, obdata, operator=None):
|
||||
base.layers_from_view(context.space_data)
|
||||
|
||||
|
||||
obj_new.matrix = add_object_align_init(context, operator)
|
||||
obj_new.matrix_world = add_object_align_init(context, operator)
|
||||
|
||||
obj_act = scene.objects.active
|
||||
|
||||
|
@ -473,7 +473,7 @@ class MakeDupliFace(bpy.types.Operator):
|
||||
linked.setdefault(data, []).append(obj)
|
||||
|
||||
for data, objects in linked.items():
|
||||
face_verts = [axis for obj in objects for v in matrix_to_quat(obj.matrix) for axis in v]
|
||||
face_verts = [axis for obj in objects for v in matrix_to_quat(obj.matrix_world) for axis in v]
|
||||
faces = list(range(int(len(face_verts) / 3)))
|
||||
|
||||
mesh = bpy.data.meshes.new(data.name + "_dupli")
|
||||
|
@ -34,7 +34,7 @@ def align_objects(align_x, align_y, align_z, align_mode, relative_to):
|
||||
for obj in bpy.context.selected_objects:
|
||||
if obj.type == 'MESH':
|
||||
|
||||
bb_world = [obj.matrix * Vector(v[:]) for v in obj.bound_box]
|
||||
bb_world = [obj.matrix_world * Vector(v[:]) for v in obj.bound_box]
|
||||
|
||||
Left_Up_Front = bb_world[1]
|
||||
Right_Down_Back = bb_world[7]
|
||||
@ -95,7 +95,7 @@ def align_objects(align_x, align_y, align_z, align_mode, relative_to):
|
||||
if obj.type == 'MESH':
|
||||
|
||||
loc_world = obj.location
|
||||
bb_world = [obj.matrix * Vector(v[:]) for v in obj.bound_box]
|
||||
bb_world = [obj.matrix_world * Vector(v[:]) for v in obj.bound_box]
|
||||
|
||||
Left_Up_Front = bb_world[1]
|
||||
Right_Down_Back = bb_world[7]
|
||||
|
@ -935,7 +935,7 @@ def main(context, island_margin, projection_limit):
|
||||
# Initialize projectVecs
|
||||
if USER_VIEW_INIT:
|
||||
# Generate Projection
|
||||
projectVecs = [Vector(Window.GetViewVector()) * ob.matrixWorld.copy().invert().rotation_part()] # We add to this allong the way
|
||||
projectVecs = [Vector(Window.GetViewVector()) * ob.matrix_world.copy().invert().rotation_part()] # We add to this allong the way
|
||||
else:
|
||||
projectVecs = []
|
||||
|
||||
|
@ -134,12 +134,45 @@ void rna_Object_internal_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
DAG_id_flush_update(ptr->id.data, OB_RECALC_OB);
|
||||
}
|
||||
|
||||
void rna_Object_matrix_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
{
|
||||
object_apply_mat4(ptr->id.data, ((Object *)ptr->id.data)->obmat);
|
||||
rna_Object_internal_update(bmain, scene, ptr);
|
||||
}
|
||||
|
||||
void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16])
|
||||
{
|
||||
Object *ob= ptr->id.data;
|
||||
|
||||
if(ob->parent) {
|
||||
float invmat[4][4]; /* for inverse of parent's matrix */
|
||||
invert_m4_m4(invmat, ob->parent->obmat);
|
||||
mul_m4_m4m4((float(*)[4])values, ob->obmat, invmat);
|
||||
}
|
||||
else {
|
||||
copy_m4_m4((float(*)[4])values, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16])
|
||||
{
|
||||
Object *ob= ptr->id.data;
|
||||
|
||||
/* localspace matrix is truly relative to the parent, but parameters
|
||||
* stored in object are relative to parentinv matrix. Undo the parent
|
||||
* inverse part before updating obmat and calling apply_obmat() */
|
||||
if(ob->parent) {
|
||||
float invmat[4][4];
|
||||
invert_m4_m4(invmat, ob->parentinv);
|
||||
mul_m4_m4m4(ob->obmat, (float(*)[4])values, invmat);
|
||||
}
|
||||
else {
|
||||
copy_m4_m4(ob->obmat, (float(*)[4])values);
|
||||
}
|
||||
|
||||
object_apply_mat4(ob, ob->obmat);
|
||||
}
|
||||
|
||||
void rna_Object_internal_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
{
|
||||
DAG_id_flush_update(ptr->id.data, OB_RECALC_DATA);
|
||||
@ -1700,11 +1733,17 @@ static void rna_def_object(BlenderRNA *brna)
|
||||
RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
|
||||
|
||||
/* matrix */
|
||||
prop= RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
|
||||
prop= RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX);
|
||||
RNA_def_property_float_sdna(prop, NULL, "obmat");
|
||||
RNA_def_property_multi_array(prop, 2, matrix_dimsize);
|
||||
RNA_def_property_ui_text(prop, "Matrix", "Transformation matrix");
|
||||
RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_matrix_update");
|
||||
RNA_def_property_ui_text(prop, "Matrix World", "Worldspace transformation matrix");
|
||||
RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_matrix_world_update");
|
||||
|
||||
prop= RNA_def_property(srna, "matrix_local", PROP_FLOAT, PROP_MATRIX);
|
||||
RNA_def_property_multi_array(prop, 2, matrix_dimsize);
|
||||
RNA_def_property_ui_text(prop, "Local Matrix", "Parent relative transformation matrix");
|
||||
RNA_def_property_float_funcs(prop, "rna_Object_matrix_local_get", "rna_Object_matrix_local_set", NULL);
|
||||
RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, NULL);
|
||||
|
||||
/* collections */
|
||||
prop= RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user