Forums > MaxMSP

ANIMATION + Physics

November 18, 2011 | 12:11 am

Is there a way of using a animated model within a jit phys world?

I tried to out put matrix out of a model used in the examples but it screwed up everything. Is there a way of keeping the dicts data flowing out of the jit.gl.model while sending matrixoutput1?


November 18, 2011 | 8:39 pm

hi sandroid.
can you be more specific? how do you want your model to interact with the physics world?

there are two common techniques employed in 3D games.
one is to surround the model mesh with basic physics shapes such as a capsule or cylinder, or better yet, a compound shape. the phys.body is set to @kinematic 1, and the position and rotation attrs are sent to both the body and the mesh, to sync them.

another, more complicated technique, is to create a "ragdoll" structure of phys.bodies and constraints, that lines up with the internal skeleton structure of the model.

we are planning some tutorial videos and patches in the near future, to help explain this complicated procedure. there is a basic ragdoll example using javascript in the examples folder:
Max6/examples/jitter-examples/render/physics/phys.ragdoll.launch.maxpat

Is there a way of keeping the dicts data flowing out of the jit.gl.model while sending matrixoutput1?

i’m not sure what you are asking here. can you restate?

thanks!


November 19, 2011 | 3:57 pm

hi Robert,
I think I was approaching the problem in a too simplistic way. I imagined that I could just get the animated model into the physics world directly, for example: I could make the ninja model walk inside a world and touch and hit objects there. I thought that the geometries of a physical body could be automatically generated from the animated model. If I understood right, the simpler way to do it would be to generate a shape synchronized with the ninja body. I would send then this shape to a physics.body. But if I want to make a movement from the ninja, like a move with its sward to hit an object, I would need to sync a shape with the sward, isn’t it? In order to do that is it possible to get some info from the animation that could give me the coordinates of the sward?
The "dict" question is outdated after your answer. :)) It had to do with the wrong way I was understanding the problem. Thanx a lot


November 21, 2011 | 1:48 am

you are correct, in order to make an animated model interact with the objects in a physics world, you are going to have to create simple rigid-body shapes that surrounds the pieces of the mesh you want to "make live".
you will set @kinematic 1 on the phys.body, and update it’s position and orientation each frame.

this process can be facilitated with the jit.anim.node object and the coplynodestoclipboard message to anim.model.
the patch below shows how you can make the foot of the seymour model kick around some rigid-body spheres.

this currently requires that @normalize be 0 on the gl.model, and that no transforms be applied to the gl.render (so no gl.handle attached to the gl.render).
you also have to include a node that contains the gl.model transforms.
these 3 issues should be resolved in a future update.

we are also planning some video tutorial content to help explain this process in the near future.

– Pasted Max Patch, click to expand. –

November 22, 2011 | 12:05 am

thanx a lot Robert! That’s all I need to start from. Your patch was really helpful.
It’s still a bit tricky to me how anim.modes are concatenated (and why), but I was able to put this solution in a slightly different context and it worked.

I am also working in a kind of first person camera from the patch you posted about a following cam. The way I found was to create a second object in front of the model that is walking and turning, made this second object not enabled, and made the lookat attribute point to it. It worked pretty well but I still found kind of "too much not elegant" (which, by the way, use to be my way on programming).
In the patch you provide for the following cam, can you point a different direction for addressing this "first-person"look at?

thanx


Viewing 5 posts - 1 through 5 (of 5 total)