get world position of camera that is child of null

How do I get the world position of a camera if I have parented the camera to a null comp, and then rotated the parent null?

Ultimately, I am trying to use a geo instance whose instances look at a camera. I’m doing this by subtracting the instance pos from the camera pos, and plugging that into the rotateToVector part of the geo instance. This is working, but when I parent the camera to a null (to get an orbit effect), it fails. Getting the world pos of child cam will solve this.

Thomas

well, I figured out how to do it with python using the transform class.

This works. Just wondering if there is another way using ops?


p = op(“nCamParent”)
c = op(“cam2”)

p_mat = p.worldTransform
c_mat = c.worldTransform

s, r, t = c_mat.decompose()

w = op(‘conWorldSpace’)
w.par.value0 = t[0]
w.par.value1 = t[1]
w.par.value2 = t[2]

I think what you’re after is the object CHOP.

base_object_CHOP.tox (854 Bytes)

Thanks for your response Matthew.
Unfortunately the object chop (apparently) does not work in the case of nested objects, and your example appears to have returned a false positive.

To illustrate this, I took your attached tox, and changed the lfo to drive rotation, (instead of position), and the results are not what you would expect. Ie, it does not return it’s world space position.

In the attached tox, I included the python way, which seems to work as expected.

I fiddled with the object chop for a long time, but it’s just not as versataile as I would like. Iow, you can’t specify whether to use world space or local coordinates.

The python way works just fine for my purpose, but chops would be faster.
My Instances are now looking in the right direction.
GetWorldTransform.tox (1.46 KB)

Hi Diatom,

Apologies - I don’t think I totally understood what you were after when I made that example. You can get that transform data you’re after by setting a reference object, and then setting your camera to be your target object. You might also want to compute the entire transform - I’ll also use bearing if I want all my instances to look at the same object for example.

See if this helps:
base_object_CHOP.tox (1.58 KB)

Nice one!
If only the manual were as informative as you.
Any idea what the DAT Table parameter is used for? Is that for a matrix transform?