Jitter GL Camera help

healeyzc's icon

Hello everyone!

I am attempting to create a world in Jitter in which the camera is controlled by the keyboard like a video game. I was wondering if it is possible to constrain the camera view to a bounding box (much like a video game) rather than traveling through walls or separate models.

Thanks in advance!!!

healeyzc's icon

Is there any way to get a first person view - or get the camera to react as a rigid body within the physics engine?

Ernest's icon

HI. That's a fairly advanced question. I can't help, and experience has been you may have to wait a while for a response when you're pushing the frontier a little, but don't be discouraged. And it may be some others are active on that, but it may not be very many people.

vichug's icon

[jit.anim.camera] might provide some usefuls things for you, after that you'll probably need some jit.phys magic somewhere... atually i'm trying to do teh same thign, it's not easy...

touk's icon

Hi

to provide collision , think to attach a jit.phys.body/ghost to your camera to interact with other body

Andrew Benson's icon

Jit.anim.drive has a @ui_listen mode that allows you to do keyboard/mouse driven navigation. Double-clicking the jit.anim.drive lets you edit the controls dictionary. Hook jit.anim.drive @ui_listen 1 to your jit.gl.camera and you have FPS camera.

Rob Ramirez's icon

one way to do this is to use two jit.anim.nodes. the first anim.node is controlled by a anim.drive (which receives key and mouse input), and is bound to your gl.camera. the second anim.node is parented to the first, and controls a kinematic rigid body (jit.phys.body @kinematic 1).

this will sync the camera with a rigid body, and cause other rigid bodies to "bounce" off the camera, as well as allow you to retrieve and process collision information from the phys.body.

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

if you don't want objects to "bounce" off the camera, you can instead use a phys.ghost.

touk's icon

to resume the last patch you posted robert,
assume that the spheres represent static walls,

how can we ensure that the camera is constrained in its movement, it does not go through walls?

vichug's icon

@Andrew : actually, it is not a fps camera, because the rotation is calculated on a mouse speed basis, as oppposed to a real fps where it is calculated on distance of current mouse location relatively to a fixed center location. So you can continually turn without haivng to constantly move the mouse, and you don't have that effect where you spin 81225° all of a sudden because you gave a little hiccup to your mouse :p

Rob Ramirez's icon

@touk: you have to handle the logic yourself, based on the collision dictionary.
the anim_reset message to anim.drive will cancel all currently executing animations.

another technique is to translate the output of anim.drive into forces for a dynamic phys.body, and link the gl.camera to the phys.body (instead of the other way around).

lots of options, but no ready-made solution (this is max after all).

@vichug: check out the following example patch (hit the escape key to enable mouse interaction)
Max 6.1/examples/jitter-examples/render/anim/anim.camera.advanced.maxpat

vichug's icon

@Rob : thanks ! will need a little time to understand this, but that's indeed what i'm looking for.

Rob Ramirez's icon

yeah, it's quite a doozy.
feel free to ask for any clarifications, and i'll do my best.

healeyzc's icon

Thank you all for the wonderful help! I'll ket you know how it goes!!!

Rob Ramirez's icon

here's a slight variation of the previous patch that employs a different technique, and will keep a camera inside of the phys.world worldbox.
instead of controlling a kinematic body with an anim.drive, we instead control the @position2 attribute (world-space position) of a constraint, that in turn constrains the position of a dynamic rigid-body. we then sync the position of our camera to this rigid-body.

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

this technique requires some extra setup, but works quite well.
obviously there's still lots of variation that can happen here, to tweak the movement.

healeyzc's icon

Here is my patch thus far - not sure why I can't get the camera to move! any help would be appreciated!

5331.WorldPatch.zip
zip
healeyzc's icon

[EDIT] ^ Patch is working fine now just needed to do some setup - Thanks again!

HarryK's icon

Hi all -

I've been trying to follow the ideas here to create a modified patch where the object-tied-to-the-camera can be collided into and respond, throwing the camera amuck. Having a little trouble figuring out where to intervene. Any pointers would be appreciated.

-H

Andro's icon

Hi Harryk, post a patch if you need some help.