Processing – More PeasyCam, OCD & ControlP5

I’ve now managed to copy camera and centre of interest (c.o.i.) positional values from PeasyCam into OCD (bar a slight perspective shift I’m not quite able to resolve yet)… and I’ve also managed to update the slider positions for each of the controlP5 controllers (the controlP5 secondary window has to be in focus to see the changes) and thus save these values to XML and recall them later… yay!

lightwavevirtual_controlp5_500px.jpg

float[] CamPposition = new float[3];
CamPposition = CamP.getPosition();
Cam1_cameraX = CamPposition[0];
ControlP5.controller(“Cam1_cameraX”).setValue(Cam1_cameraX);

I’m now exploring the full range of OCD methods to see how the library allows to – “manipulate individual cameras using standard camera movement commands” – and to see which might be useful additions to my ControlP5 live camera configuration.

So in overview:

Perspective Changes
zoom(amount) – changes the field of view by the specified amount.

Linear Movements
truck(distance) – moves the camera and c.o.i. along the side vector by the specified distance – essentially changes targetX
boom(distance) – moves the camera and c.o.i. along the camera’s up vector by the specified distance – essentially changes targetY
dolly(distance) – moves the camera and c.o.i. along the view vector by the specified distance – essentially changes targetZ
Instantaneous Changes
aim(targetX, targetY, targetZ) instantly change the camera’s centre of interest to the specified target.
jump(locationX, locationY, locationZ) instantly change the camera’s position to the specified location.
Rotations
tilt(amount) rotates the camera about the side vector by the specified amount.
pan(amount) rotates the camera about the up vector by the specified amount.
roll(amount) rotates the camera about the view vector by the specified amount.
Arc Movements
arc(amount) arcs the camera over (under) a centre of interest at its present azimuth by the specified amount.
circle(amount) arcs the camera around a centre of interest at its present elevation by the specified amount.
Combinations
tumble(azAmount, elAmount) tumbles the camera about its centre of interest by the specified amounts.
look(azAmount, elAmount) moves the c.o.i. around the camera at its present position by the specified amounts.
track(xDistance, yDistance) moves the camera and c.o.i. simultaneously in the local x-y plane.
Informative
position() returns the camera position as a vector of three values: [X, Y, Z]. float[] position = camera1.position();
attitude() returns the camera orientation, in radians, as a vector of three values: [Yaw, Pitch, Roll].
float[] attitude = camera1.attitude();
target() returns the target position as a vector of three values: [X, Y, Z].
float[] target = camera1.target();
up() Returns the camera up direction as a vector of three values: [X, Y, Z].
float[] up = camera1.up();
fov Returns the camera field of view, in radians.
camera1.fov()

I reckon I already have control over the Perspective Changes & Linear Movements via the current ControlP5 sliders for the OCD Camera Construction:
Camera(parent,
cameraX, cameraY, cameraZ,
targetX, targetY, targetZ,
upX, upY, upZ,
fov, aspect, nearClip, farClip
)

…though it could be useful to set up some oscillators to do this job too – hmmm.

and Instantaneous Changes can be realised by switching from camera to camera – so I’m not going to implement these either

But I think Arc Movements could be useful – as sliders – and likewise Combinations – which could actually be an XY pad – as per the ‘ControlP5diyController’ example (though I’m not having any luck trying to implement this in the secondary ControlP5 window) – though I’ve yet to implement them into ControlP5.

On reflection It may be worth trying to make these a set of generic controls too – so their their outputs are switchable between cameras – perhaps by radio button? To investigate…

Rotations & Informative throw up interesting possibilities too…
float[] attitude = camera1.attitude();
returns the camera orientation, in radians, as a vector of three values – [Yaw, Pitch, Roll] – which I’m anticipating are equivalent to PeasyCam’s
float[] rotations = camera.getRotations(); // x, y, and z rotations required to face camera in model space

so I’ve since implemented ControlP5 sliders for Tilt(Yaw) Pan(Pitch) Roll(Roll) in ControlP5…

and I also tried copying the PeasyCam values from
float[] CamProtations = new float[3];
into OCD
Cam1_tilt = CamProtations[0];
Cam1_pan = CamProtations[1];
Cam1_roll = CamProtations[2];

but something odd is definitely going on… Empirically I’m finding that the
Cam1_roll = CamProtations[2];
is the only rotational info required to actually match the OCD viewport cameras to the PeasyCam state – but there’s some weird 180 degree inversion going on coupled with an offset that I can’t quite work out since it doesn’t seem to be consistent (it’s not just down to the roll value for example)… hmmm…

Comments are closed.