[Closed] trajectory of an object when parented
I have this issue I run into that I don’t know how to solve.
Often I’ll need to group a camera and a ground plane(or attach it to a null) and rotate and scale the group. After this is done you cannot unlink the camara from the parent without the trajectory completely changing.
Is there a way around this? thanks!
Transforms are inherited from the parent, change the parent and you change the transform.
What exactly are you trying to do? Please use proper descriptions as well so that it is clear. You do not Attach cameras to a Helper you Link or Parent them. Attaching if for geometry. Just so that what you want is clear.
Well often I do need to attach a camera and a ground plane to a parent so I can make a matchmove match the correct scale and align it to a given scene. Does that make sense?
We had to do this sort of stuff at my last job, basically you’ve animated the camera without a parent and now your parenting it – with it subsequently breaking its trajectory because its coordinate space is different.
So basically what i would do is store the trajectory of the camera relative to its new parent for each frame (before its parented) , then parent it and apply the stored transforms for each frame. Something like (super rough):
local camera, newParent = selection[1], selection[2]
local frameInfo = #()
for f in animationRange.start to animationRange.end do
(
at time f
(
append frameInfo #(f, (camera.transform * inverse newParent.transform))
)
)
camera.parent = newParent
with animate on
(
for each in frameInfo do
(
at time each[1] do
(
camera.transform = (each[2] * newParent.transform)
)
)
)
Now if the camera is already parented you’ll need to do the inverse i.e pull out its world space transform, before you unparent it:
for f in animationRange.start to animationRange.end do
(
at time f do
(
append frameInfo #(f, camera.transform)
)
)
camera.parent = undefined
with animate on
(
for each in frameInfo do
(
at time each[1] do
(
camera.transform = each[2]
)
)
)
Super rough but basically you need to store the ‘temporary’ target coordinate space of the object before pushing the object into that space. There’s other ways of doing this with constraints but this is a simple baked solution.
No because you can’t Attach a camera to a parent, you can link or parent it to a parent…
Why can’t you just leave it parented to the parent?
why not script a simple bake script that creates a new camera with the old camera’s properties? Then collect the old camera’s world transform into an array and apply this onto the new camera. It’ll match the old camera without a parent.