Rotate parent so child plane is parallel to ground
On 11/04/2015 at 00:23, xxxxxxxx wrote:
I'm trying to rotate a parent object that has a plane for a child so the child plane is parallel to the C4D ground plane.
It isn't quite working.
Once I have the normal of the plane, how do I rotate the parent?
Am I rotating the parent around the center of the plane to do this?
On 17/04/2015 at 07:41, xxxxxxxx wrote:
all you need to do is to handle the matrices of the objects. When you say that the plane should be "parallel" to the ground that means that the plane should not be rotated in world space, right?
So the world space rotation should be zero. The world space rotation of the plane is the result of the world space rotation of the parent plus the local rotation of the plane relative to the parent. So the world space rotation of the plane is zero when the world space rotation of the parent is "minus" the local rotation of the plane.
Sine we are handling rotations as matrices there is no "minus" but you can invert the matrix with the standard Python operator "~".
So the most simple code could look like:
localPlaneMatrix = plane.GetMl() op.SetMg(~localPlaneMatrix) c4d.EventAdd()
your final code may depend on your actual situation and the complexity of your hierarchy.
On 20/04/2015 at 13:18, xxxxxxxx wrote:
Yeah, getting matrices down is a little confusing at first but super helpful. Here's a helpful website for understanding/helping a bit.
On 21/04/2015 at 14:57, xxxxxxxx wrote:
Thanks Sebastian, I was missing the '~' for inverse. Works fine.