Camera viewport LoadTransform method

the documented comments of the CameraExt in cameraViewport make mention of a LoadTransform method, but no such method exists. I would like to use two cameraViewport components plugged into a camblendCOMP, and create a preset system storing data from an objectCHOP looking at the active camera, and on recall of a preset, loading that data (possibly using this missing LoadTransform method) into cameraViewportB, and then blending to that position via the CamBlend.

If there is another way i can lerp to a stored camera position, I’d love to hear it, or if this a/b camera system seems like a good way to accomplish my goal, how would one go about doing this, with current or future methods? Are there any other supported methods for interpolating matrix data? The tdu matrix/vector/camera quaternion stuff is hard for me to wrap my mind around, especially if I’d like a smooth rotation, so I’m all ears for good solutions

1 Like

Sorry about the confusion there. The documentation at the top of the CameraExt file was copied over from the ArcBall camera and has not been updated properly. I’ll get that fixed.

That said, I think it would be useful to add those functions as well so I’ll see if I can get them done while I’m updating the docs.

As far as camera blending, one other thing that has been on my todo list for awhile to expose an already existing blend feature of the camera class so that it can be used in python. This would take two camera objects and a blend factor and output a third camera object. This method uses a slerp interpolation to blend between the camera quaternions.

3 Likes

That sounds awesome, I’d be happy to start testing that if such a component were to become available before the next incremental update. Would this method be something that could be given a time argument, and possible a curve argument(linear, s etc) for executing a timed transformation?

In the meantime, do you have any tips for how I might approach this using existing methods?

I made a quick update to the cameraViewport component that you can experiment with it you want. You can now use the CameraTransform property to get/set the camera’s transform matrix which should make it easier to make presets.

For example, you can copy the matrix of a basic camera comp to the cameraViewport component by doing camViewport.CameraTransform = camComp.worldTransform

cameraViewport.tox (12.6 KB)

Using the current cameraBlend component is still probably the easiest way to smoothly blend between camera angles.

I still want to do the python blend as well, but that will require updates to TouchDesigner so it might come in a later experimental build.

That version will use a 0 to 1 interpolation value that you can set based on time or whatever you want. It uses a quaternion slerp to blend the camera orientation which I believe results in constant rotation speed. If you want something more gradual then you could apply a curve to the interpolation value before passing it to the camera.

Cool, this is almost doing what i want, but pushing a new value almost always results in
td.Error: Matrix*Position operation resulted in a W coordinate of 0.

Any ways to offset this by a tiny tiny amount to prevent ever getting this error?
Even the home, front, top, bottom commands result in this error

What is the matrix you’re trying to set it to? Would you be able to post an example or just the numbers so I could give it a try and see what is going on

Trying to recreate with this component in the default session, I’m able to set the matrix, but any f/h/t/b keystroke gives me a value cast error… different then what i was experiencing last night, but a problem nonetheless

new cameraViewport tests.toe (16.7 KB)

Sorry for the mix up there. You’re getting an error because the component I gave you is from our 30k experimental series and uses a camera feature (orthowidth) that isn’t available in the official 10k release.

If you want to continue using the 10k official release, which we recommend for any production/performance work, then you can comment out line 530 in cameraViewport/CameraExt and that should avoid the problem

should the AutoRotate() method be able to initiate a spin? Is there currently a way to pythonically initiate an auto rotate with an argued speed and direction? I’d like to specify precise rotation angles and speeds that are reliably reproduced, unlike a click/drag of the panel

Unfortunately, the autoRotate feature isn’t really setup right now to work like that. It’s currently entirely based around the mouse, so it’s dependent on the navigation mode, the current orientation, window size, etc which makes specifiying a specific rotation awkward.

Adding more camera controls is on our wishlist and I’ll make a note of this suggestion, but I don’t know when that might be available.

For the moment, I’d suggest just using a basic camera comp and animating its rotation parameters or, if you need off-axis rotation, you could use the Matrix class and the rotateOnAxis function (Matrix Class - Derivative) with an animated time.

I’ve built a preset system and A/B style controller with 2 hacked up cameraViewports and a camblend1 in a cameraRig component. I’m using the spaceNavigator mouse, so I’m pretty locked into this workflow. I’m doing some hacky stuff with a nullCOMP and an object chop to push “normal” translate/rotate data back to the matrix, but would love some more flexibility in doing things to this component, pythonically if need be, and the auto rotate feature would be quite nice if it were accessible dependably, but using a mouse makes it almost impossible to replicate a motion with consistency. Of course i could use a circle sop as a path to orbit my object, but now that I’ve committed to working with a static position and pre-transforming the matrix, managing both of those will break the functionality. I’ll dig into rotateOnAxis… are there any examples you’re aware of that uses this method?

I haven’t really used the rotateOnAxis much myself, but you should be able to use it along with the new CameraTransform property to get/set the camera matrix i.e. mat = cam.CameraTransform; mat.rotateOnAxis( (0,1,0), 45 ); cam.CameraTransform = mat;

For animations, I might recommend storing your starting matrix (which could just be an identity one) and then calling the rotateOnAxis with an absolute angle value each update (i.e. 44, 45, 46, etc) rather than rotating the same matrix by small amounts each frame because that will accumulate errors over time.

Any news on making presets with the cameraViewpprt component? I would love to be able to store positions and then use them as presets with the TauCeti Preset engine…

The current cameraViewport component in 2023.12000 does have a preset system available on the Presets page. It uses a position and rotation angle parameter rather than a matrix, but also has a pulse button to automatically grab this from the current state.

Does this fit what you need?

Hi Rob,
Thanks for the quick response.
I see those, unfortunately that doesnt suit my needs (directly).
I was hoping more for an existing workflow to get from viewport cam to @alphamoonbase preset engine and back.
Setting cam positions with the camViewport and transitioning via presets would be too convinient!
Maybe someone got it going and wants to share :slight_smile:
Best
Stefan

I built something like this a while back for @SAHAR to use with a space mouse. The idea is two camera viewports connected to a camerblend, and works as an A/B deck with an interpolation time parameter.

It’s pretty elementary, just stores position values as a row in a table, and allows you to save current position as a new entry, and scroll through the values with a next/prev call.

It uses a pretty old version of camera viewport, possibly even an arcball I can’t remember. It gets the trick done though, I’m not sure when I’ll have a chance to update it, but if you want to take a look at mine and use it as a starting point, ping me and I’ll upload it next time I’m in front of my machine

Hi Vincent,

thank you, that would be great!
It wont help for the upcoming show, as it will take me forever to get something like that working,
but ideally it isn’t my last show : )

TBH, I don’t understand, why the viewPort cam isn’t set up in a way, that makes it much more useful. Yes, of course a Python savy person can customize everything, but some of us want to build shows, not code and its frustrating to have it all in view, but you just can’t get there without
days and days of learning new skillz : (

All the best
Stefan

Here the quick solution:
A quick script in a parameterExecute to translate the matrix in to the transformation parameters.


def onValueChange(par, prev):
	op("cam1").setTransform(
		par.owner.CameraTransform
	)

2 Likes

Works beautifully!
(not with Autorotate though :innocent:)

Thank you!!!