Hi to all 3d proff )
I have a question:
I have 2 containers (MovieClips), each container has 3d rotation and
3d translation. I have an another MovieClip as a child of the first
container. This MovieClip has 3d rotation and 3d translation also...
How can I put this MovieClip from the first container to the second
container without any transformation of this object (like nothing
happening - no any movement, scale or rotation of the MovieClip) ?
I have a solution, but it works wrong:
public class SomeContainer extends Sprite
{
override public function addChild
(param_child:DisplayObject):DisplayObject
{
// I have this for compute new child transform: child.transform =
Matrix3D.multiply(Matrix3D.inverse(newcontainer.transform),
Matrix3D.multiply(oldcontainer.transform, plane.transform));
if (param_child.transform.matrix3D == null)
param_child.transform.matrix3D = new Matrix3D();
if (param_child.parent.transform.matrix3D == null)
param_child.parent.transform.matrix3D = new Matrix3D();
if (transform.matrix3D == null) transform.matrix3D =
new Matrix3D
();
var inv_m:Matrix3D = transform.matrix3D.clone();
inv_m.invert();
var child_m:Matrix3D =
param_child.transform.matrix3D.clone();
var prevCont_m:Matrix3D =
param_child.parent.transform.matrix3D.clone();
prevCont_m.prepend(child_m);
inv_m.prepend(prevCont_m);
super.addChild(param_child);
param_child.transform.matrix3D = inv_m;
...
As result child keep it self position (!!! - it's good), but new child
rotation is wrong!!!
How can I restore child rotation ? Or what should I use to keep not
only the child position, but the child rotation too ?
Help me please!!!
P.S. Sorry for my poor English )