Notifications
Clear all

[Closed] CgTalk Maxscript Challenge 003: "Foot Prints"

Very impressive scripting!!

Btw. I just wired “PF Source 01” to “Event 03” (the one with Birth Script 01 and Collision 01) … and it works fine. Cool to see how the foot sinks into the snow and like presses the snow out

Lars

1 Reply
(@jhaywood)
Joined: 11 months ago

Posts: 0

That’s what I meant to say, thanks. And I’m glad you like the script.

Cool script JHaywood, I particularly like the way the mud raises around the footprint.

Wow, very well done! Unless there’s some late entries tonight, you’ll be the winner of this one!

I used callback functions to make footprint deformations on the object that was suppose to represent mud or something soft (brown plane) and to make foot imprints on the object that wasn’t soft (white plane) like mud was being tracked onto it.

Here’s the code for it:


function footDents = (
 
obj=getNodeByName "SoftGround"
objM=obj.mesh
objMSelection=objM.selectedVerts as bitarray
objSVerts=objMSelection
polyOp.moveVert obj objSVerts [0,0,-.6] --This is how deep the impression should be made
 
)
 
function footPrints = (
 
obj=getNodeByName "HardGround"
objM=obj.mesh
objMSelection=objM.selectedVerts as bitarray
objFSelection=polyOp.getFacesUsingVert obj objMSelection
polyOp.setFaceMatID obj objFSelection 2
 
)
 
function eraseCallbacks = (
 
callbacks.removeScripts()
 
)
 
callbacks.addScript #preRenderEval "footDents()"
callbacks.addScript #preRenderEval "footPrints()"
callbacks.addScript #postRender [size=2]"eraseCallbacks()"
 
[/size]

Each plane had to be named according to the code above in regard to whether they were the soft or hard one. Each plane also required a volume select modifier in their stack set to ‘vertex’ selection and using the foot object as the volume selection object.

The hard plane has a multi-subobject material assigned to it. One material being the color of the mud the other of the hard service.

Here’s a video of it in action

How the function footDents works is that prior to each frame rendering the mud plane object gets checked to see if any verts are selected by the foot object via the volume select modifier that is assigned to it. If there are then they are offset along their z-axis by a specificed amount within the function, deforming the mesh in that spot.

The function footImprints works in a similar manner for the hard plane except instead of using the vertices to deform the mesh, the vertices are used to determine which faces they belong to and then those faces are assigned a material ID matching that of the color of the mud in the multi/object material assigned to the hard plane.
Hard plane color was material ID:1 -greyish
Mud plane color was material ID:2 -brownish

Oh yeah the last function eraseCallbacks removes the callbacks after rendering has taken place.

What I don’t like about this is that that tracked mud part is depending on the resolution of the geometry to have good definition. Maybe using a vertex map as a mask between mud color and hard surface color would be better. Another cool modification would be to use the incoming direction of the deforming object as a vector to ‘tell’ the deforming vertices to move in that same direction, instead of just negative z-direction as it is now.

Nice solution Googlo. Using a volume select modifier is a nice way to check for object interesection. I know what you mean about wanting the mesh to deform more correctly in the z direction, I’ll probably look into doing that sometime in the future. The only thing I can think of is to cast rays from the verts on the plane object to the foot object and see where it hits. But faking it actually works pretty good, escpecially for most effects shots where the camera wouldn’t usually be close enough to the ground for the viewer to notice anything was wrong.

And if anyone’s interested, I put a version of my footprint scene on my site with a lot of comments in the pFlow scripts so you can more easily see what’s going on.

http://jhaywood.com/FXfootsteps.htm

hey JHaywood
i run the script but i see no paricles , i deleted the connetion and connected it manualy,put display operator, evaluated all scripts but no particles appear
why does this happen?

You’re not supposed to see any particles. Particle Flow is only used to move the verts of the sand mesh.

sorry JHaywood for bugging
but nothing happen when i run the script
i’m i doing something wrong?

Page 2 / 2