On 27/03/2013 at 04:54, xxxxxxxx wrote:
Matrix maths is still not my favorite topic.
I can't get this to work properly. I want to emulate the Axis Mode in Cinema, a function that
moves the object's axis to a specific point (and rotation) without changing the polygon-object's
points and children's global position (and rotation). It won't work properly, see this video.
Can someone pls point out what's wrong or maybe even explain how to do it?
Thanks!
>
> import c4d
>
> def move_axis(obj, new_matrix=c4d.Matrix()) :
> mat = obj.GetMl() * new_matrix
> if obj.CheckType(c4d.Opoint) :
> points = obj.GetAllPoints()
> for i, p in enumerate(points) :
> obj.SetPoint(i, p * mat)
> obj.Message(c4d.MSG_UPDATE)
>
> for child in obj.GetChildren() :
> child.SetMl(child.GetMl() * mat)
>
> obj.SetMl(new_matrix)
>
> def main() :
> if not op:
> return
>
> doc.AddUndo(c4d.UNDOTYPE_CHANGE, op)
> move_axis(op)
> c4d.EventAdd()
>
> main()
~~
~~
Edit: Video comes in a few seconds.