AntoineSfx Posted December 13, 2022 Share Posted December 13, 2022 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. Quote Link to comment Share on other sites More sharing options...
dedeks2999 Posted December 14, 2022 Share Posted December 14, 2022 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 ? Quote Link to comment Share on other sites More sharing options...
AntoineSfx Posted December 14, 2022 Author Share Posted December 14, 2022 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.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.