Jitter GL Camera help

Mar 25, 2013 at 4:46pm

Jitter GL Camera help

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!!!

#67312
Mar 25, 2013 at 11:17pm

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

#242174
Mar 26, 2013 at 2:54am

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.

#242175
Mar 26, 2013 at 8:38am

[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…

#242176
Mar 26, 2013 at 11:22am

Hi

Maybe this can help you to start with the camera …

http://cycling74.com/forums/topic.php?id=45298

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

#242177
Mar 27, 2013 at 9:38pm

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.

#242178
Mar 28, 2013 at 1:02am

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.

if you don’t want objects to “bounce” off the camera, you can instead use a phys.ghost.

– Pasted Max Patch, click to expand. –
#242179
Mar 28, 2013 at 8:20am

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?

#242180
Mar 28, 2013 at 10:19am

@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

#242181
Mar 28, 2013 at 3:21pm

@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

#242182
Mar 28, 2013 at 3:52pm

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

#242183
Mar 28, 2013 at 6:23pm

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

#242184
Mar 28, 2013 at 8:39pm

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

#242185
Mar 28, 2013 at 9:56pm

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.

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.

– Pasted Max Patch, click to expand. –
#242186
Mar 30, 2013 at 1:12am

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

Attachments:
  1. WorldPatch.zip
#242187
Mar 31, 2013 at 2:04am

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

#242188

You must be logged in to reply to this topic.