Jump to content

Actual location of a parented camera


Recommended Posts

I have a rotating null, which drives the rotation of a camera

How do I get the actual location of the camera and its direction in world space ? From the camera object, without rebuilding the transformations manually.

Same question for a constrained (follow path / look at camera)

I'm trying to acquire the origin + directions of the camera in order to find the distance to a specific object in he scene.

Link to comment
Share on other sites

7 hours ago, dedeks2999 said:

Did you try Python expression on sparse param like :

hou.pwd().worldTransform().extractTranslates()[0] for Pos X

hou.pwd().worldTransform().extractRotates()[0] for Rot X

?

Thanks

The UI can fill those fields :

If you need this at Obj level:

Right click on the Tab Header for Transform,  then Reference / Scene Data, then:

obj/cam/Transforms/ World

This will fill T, R, S for you with something like: (for example Translate.X)

{

matrix src_xform = optransform("../cam2");
matrix target_xform_inverted = invert(optransform(opinputpath(".", 0)));
matrix final_xform = src_xform * target_xform_inverted;


matrix rest_xform = identity(4);
matrix self_xform = rest_xform * final_xform;

float result = explodematrixpr(
        self_xform, 
        vector3(ch("./px"), ch("./py"), ch("./pz")),
        vector3(ch("./prx"), ch("./pry"), ch("./prz")),
        chs("./xOrd"), chs("./rOrd"), "TX");
return result;

}

 

and there is no room for error...

 

For my use case, I ended up setting this transform, to a line oriented along Z, at SOP  level, at which point I have a everything I need.

I you do this at OBJ level, obviously in SOP you can't Ray SOP against something else, because it is not transformed yet..

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...