DrawContext: Camera Facing

I am attempting to get an Xfo to face the camera and it sort of works, but it doesn't update when the camera moves.

In the graph, I'm using the equivalent of the following to retrieve the viewport matrix:

 DrawContext().getInstance().getCurrentViewportParams().getMat44("cameraMatrix")

The output from the above is converted to an Xfo and piped into the transform input of a DrawPolygonMesh.

The result is unpredictable. It seems that the initial pull [possibly] generates the correct transform, but after that there is no update. I've slaved a box to the camera, for debugging purposes, but when the camera moves the box does not follow. I'm reporting the matrix returned from the getCurrentViewportParams().getMat44() call. When the camera moves it does not generate a pull on the network, and the graph is not evaluated. If I force the graph to evaluate by changing another port value I am not seeing the matrix update as I expect. It is always coming back with the initial values.

Is there a way to do what I am attempting?

Thanks,
-Judah

Comments

  • HelgeHelge Moderator, Fabric Employee Posts: 314 Fabric Employee

    Hey Judah,

    real object dependencies like a camera driving another object are not possible within the Canvas standalone. You can however do this in a DCC like Maya, or in our SceneHub standalone in the future (this is not available yet however).

    You can try to trick this scenario however by adding the "timeline" "Float32" port and pressing play which you change the camera.

    Research Engineer @ Fabric Software

  • Roy NieterauRoy Nieterau Posts: 258 ✭✭✭
    edited March 2016

    In standalone you might be able to further "trick canvas" by using a Manipulator. This would only trigger though when manipulators are enabled. At the same time that would be a good thing since it captures you moving around the camera. In standalone you only move the camera whilst "manipulating on the viewport" so it would go hand it hand.

    Theoretically you could build a custom Manipulator that outputs an Xfo.

    @Helge, do you think that could work?

  • HelgeHelge Moderator, Fabric Employee Posts: 314 Fabric Employee

    Maybe. :smile: Feel free to investigate.

    Research Engineer @ Fabric Software

  • JudahJudah Posts: 64

    @Helge
    I tried the timeline port both in Canvas and Maya. No joy.

    When you mentioned it's possible in the dccs, are you talking about explicitly driving ports with dcc attributes? If that's the case, I'm not so interested because it's not a portable technique.

    @Roy Nieterau
    The manipulator path is interesting, but a little too hacky. I need something that will be reliable and fairly automatic.

    There are a number use cases I have in mind. One is to present debug info in the viewport, such as text, or two dimensional shapes to indicate scalar geometry values on verts, etc. bother is to draw front facing particle geo and other card type geometries.

    Thanks,
    -Judah

  • Roy NieterauRoy Nieterau Posts: 258 ✭✭✭

    Had a quick look down the path of Manipulators to force that update but it seems hard. The manipulators will only trigger the OnEvent() method and as such not evaluate the graph down the chain if none of the chain down is dependent on those attribute changes, and it didn't seem to work. I tried to build it without making an Extension to define my own Manipulator (which of course would offer greater flexibility). No success.

    Attached is two things I tried (in the single graph). This will put a cube on the camera position (so it's on the camera and you'd see a full green screen). It updates once, but after that when rotating it doesn't trigger unless something else triggers the graph to recompute.

  • JudahJudah Posts: 64

    @Roy Nieterau

    I got a similar result - one update. No more.
    Did you evaluate this graph in Canvas only, or in Maya as well?

    I'll take a look at this in the morning.

    BTW: When do you sleep, Roy? ;)

    -Judah

  • Roy NieterauRoy Nieterau Posts: 258 ✭✭✭
    edited March 2016

    BTW: When do you sleep, Roy?

    Sleep is a myth. (Although my girlfriend doesn't seem to agree) ;) Hehe, went to sleep just after posting... waking up just now.

    I only tested this in Canvas and got no luck at all of getting closer. I think making your own Manipulator gives you full control of what happens on Events so you could update anyway you want it, but then you would need to define the object type in its own Extension.

Sign In or Register to comment.