Yaw, Pitch and Roll on Jitter Camera

Matteo Scalise's icon

Hi everyone! I'm creating a simulation of a 3D room. Like a videogame. I would like to be able to move in space and rotate the view. I'm comfortable with the fact that through anime.drive the camera follows the direction of rotation, but I would like it to only respond to yaw. So you can vary pitch and roll but not alter the z axis during movement and have the camera at a precise height, a person's head. Thank you so much in advice!

TFL's icon

You can put a [jit.anim.node] in-between your anim.drive and the camera, it will provide you the @lockplane attribute that allows you to prevent a given plane from being affected by transforms.

I also set @tripod to 1 to avoid roll as we usually don't want that in typical FPS games.

Max Patch
Copy patch and select New From Clipboard in Max.

Matteo Scalise's icon

Awsome! this is exactly what I needed, thank you so much!

Matteo Scalise's icon

I encountered another problem of a different nature, I write here. I'm using 'turn' with a gamepad connected to anim.drive to rotate the camera by changing the values ​​of the rotatexyz attribute. I also connected a sensor that sends head movement values ​​yaw pitch and roll directly to rotatexyz. I would like to be able to add the movements caused by turn to those of the sensor, in order to manage the macro-movements with the gampad and the micro-movements with the sensor but with Jitter it doesn't seem to be that simple.

TFL's icon

Please post a patch so we can see how you connected things together and so we can help you from that.

From what I understand of your message, maybe chaining two jit.anim.node will work. You can add one on top of the first one and use it to rotatexyz using head movements sensor data, while drive the other one with jit.anim.drive turn messages from the gamepad.

Max Patch
Copy patch and select New From Clipboard in Max.

Check the various jit.anim.node attributes so you can see the various ways you can make movements to add up or not, in which order, etc.

Matteo Scalise's icon

The problem I encounter is that now pitch and roll are fixed on one axis of the room and do not follow the yaw rotation. And when I interact with them, they also influence the motion input by changing its inclination. Thank you again, I've only recently started using jitter, thank you very much for your help!

Untitled1.maxpat
Max Patch

TFL's icon

I always struggle to perfectly get my head around this in one shot, but by fiddling a bit with the node order and the various parent attributes, you always end up with what you want at some point.

With this new example it should work. I've basically inverted the order of both anim nodes, so that the turns happen prior to the rotatexyz, and added @movemode local to the one attached to the anim.drive so that position movements are locally applied (relatively to the node's rotation).

Max Patch
Copy patch and select New From Clipboard in Max.

With my previous example I also encountered a bug where the movemode was sometimes behaving as local even though it was set to parent by default, and sometimes it was behaving as parent, even though nothing was changed in the patch. I couldn't reproduce consistently, but the version in this bug should not suffer from this.

And about sharing your patches: please use the Edit > Copy compressed feature (after selecting the relevant objects) and paste the result in the post rather than sending the patch file. Also, make your patch so it doesn't rely on external resources, so we can all use it as is. Or at least share that resource. For example in your case maybe you could replace model.obj by duck.dae which is built in Max and we don't need to download additional assets to help you.