Hey all,
I'm trying to create local relative blend shapes using Python and I am
getting some strange results when applying them back. I'm getting the
PointPosition and PointReferenceFrame ICE Attributes for speed /
convenience. If I do the same math via ICE I get the correct results so
it's either I have a mistake somewhere in the math in the python or
there is a discrepancy in the data when getting it through Python.
Any thoughts?
# Python
def createLocalShape(tgtObj, srcObj):
clstr = tgtObj.ActivePrimitive.Geometry.Clusters("Shape")
if not clstr:
clstr =
tgtObj.ActivePrimitive.Geometry.AddCluster(constants.siVertexCluster,
"Shape")
tgtPointPosICEArray =
list(tgtObj.ActivePrimitive.Geometry.GetICEAttributeFromName("PointPosition").DataArray)
blendVector = XSIMath.CreateVector3()
utilXfo = XSIMath.CreateTransform()
utilMat3 = XSIMath.CreateMatrix3()
srcPointPosICEArray =
list(srcObj.ActivePrimitive.Geometry.GetICEAttributeFromName("PointPosition").DataArray)
srcPointRefFrameICEArray =
list(srcObj.ActivePrimitive.Geometry.GetICEAttributeFromName("PointReferenceFrame").DataArray)
newShape = clstr.AddProperty("SimpleDeformShape", 0, srcObj.Name +
"_shape")
newShapeValues = list([list(x) for x in newShape.Elements.Array])
for i, eachItem in enumerate(srcPointPosICEArray):
blendVector.Sub(srcPointPosICEArray[i], tgtPointPosICEArray[i])
refFrame = srcPointRefFrameICEArray[i]
refArray = refFrame.Get2()
utilMat3.SetIdentity()
utilMat3.Set(refArray[0], refArray[1], refArray[2],
refArray[3], refArray[4], refArray[5], refArray[6], refArray[7],
refArray[8])
utilMat3.InvertInPlace()
utilXfo.SetIdentity()
utilXfo.SetRotationFromMatrix3(utilMat3)
blendVector.MulByTransformationInPlace(utilXfo)
newShapeValues[0][i] = blendVector.X
newShapeValues[1][i] = blendVector.Y
newShapeValues[2][i] = blendVector.Z
newShape.Elements.Array = newShapeValues
xsi.FreezeObj(newShape)
return newBlendShapes
Thanks,
Eric T.