Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2007-10-20 15:28:58 +0400
committerCampbell Barton <ideasman42@gmail.com>2007-10-20 15:28:58 +0400
commita4c8783153b7ba94d74e7ff1e0ceafda731c6528 (patch)
treed878398d83e9dd442d29b162971c5a8d73ad9334 /source/blender
parent0014fed54f1a7c54a66e96bfb210b9f4f2290e61 (diff)
made setting the pose_bone.poseMatrix possible, this does not set the matrix directly, only the pose
bones loc/size/rot, when dealing with an armature without constraints this works as expected. it uses the same code as Copy Visual Loc/Size/Rot.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/python/api2_2x/Pose.c33
-rw-r--r--source/blender/python/api2_2x/doc/Pose.py8
2 files changed, 35 insertions, 6 deletions
diff --git a/source/blender/python/api2_2x/Pose.c b/source/blender/python/api2_2x/Pose.c
index 34807c4a85c..e71747b50d3 100644
--- a/source/blender/python/api2_2x/Pose.c
+++ b/source/blender/python/api2_2x/Pose.c
@@ -723,14 +723,41 @@ AttributeError:
//Gets the pose_mat
static PyObject *PoseBone_getPoseMatrix(BPy_PoseBone *self, void *closure)
{
+ printmatrix4("posemat GET", self->posechannel->pose_mat );
return newMatrixObject((float*)self->posechannel->pose_mat, 4, 4, Py_WRAP);
}
//------------------------PoseBone.poseMatrix (setter)
//Sets the pose_mat
-static int PoseBone_setPoseMatrix(BPy_PoseBone *self, PyObject *value, void *closure)
+static int PoseBone_setPoseMatrix(BPy_PoseBone *self, MatrixObject *value, void *closure)
{
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sPoseBoneError, ".poseMatrix: ", "not able to set this property");
+ float loc_mat[4][4];
+ float delta_mat[4][4], quat[4]; /* rotation */
+ float size[4]; /* size only */
+
+ if( !MatrixObject_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected matrix object as argument" );
+
+ if( value->colSize != 4 || value->rowSize != 4 )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "matrix must be a 4x4 transformation matrix\n"
+ "for example as returned by object.matrixWorld" );
+
+ /* get bone-space cursor matrix and extract location */
+ armature_mat_pose_to_bone(self->posechannel, (float (*)[4]) *value->matrix, delta_mat);
+
+ /* Visual Location */
+ VECCOPY(self->posechannel->loc, delta_mat[3]);
+
+ /* Visual Size */
+ Mat4ToSize(delta_mat, size);
+ VECCOPY(self->posechannel->size, size);
+
+ /* Visual Rotation */
+ Mat4ToQuat(delta_mat, quat);
+ QUATCOPY(self->posechannel->quat, quat);
+
+ return 0;
}
//------------------------PoseBone.constraints (getter)
//Gets the constraints sequence
diff --git a/source/blender/python/api2_2x/doc/Pose.py b/source/blender/python/api2_2x/doc/Pose.py
index 677141d3dfd..e0c0c241044 100644
--- a/source/blender/python/api2_2x/doc/Pose.py
+++ b/source/blender/python/api2_2x/doc/Pose.py
@@ -175,12 +175,14 @@ class PoseBone:
@type localMatrix: Matrix object
@ivar poseMatrix: The total transformation of this PoseBone including constraints.
- (not settable).
-
This matrix is in armature space, for the current worldspace location of this pose bone, multiply
- it with its objects worldspace matrix
+ it with its objects worldspace matrix.
eg. pose_bone.poseMatrix * object.matrixWorld
+
+ Setting the poseMatrix only sets the loc/size/rot, before constraints are applied (similar to actions).
+ After setting pose matrix, run pose.update() to re-evaluate the pose and see the changes in the 3d view.
+
@type poseMatrix: Matrix object
@type constraints: BPy_ConstraintSeq
@ivar constraints: a sequence of constraints for the object