View Full Version : ChangeHandlers drive me crazy!

12 December 2007, 12:10 AM
Hey! I'm trying to go a little deeper in MAXScript for my next reel, and one thing I want to learn is how to deal with callbacks and change handlers, so you can see reactions between objects in realtime (well, sometimes it does not work for me). I've read the help file as well as searching the net for some info, but I think I still have to clear some concepts.

What I want to do with this is to create a point that is constrained to one vertex in an animated surface (via Morpher) no-matter-what-happens. From there, I'd create a bone linked to that point, and skinned to the animated mesh. So you have Morphs + Face Controls in your rig.

Starting with the first step, a single point following a vertex in the animated mesh, I wrote a single sentence that kind of work for me:

when parameters $Teapot01 change do
myVert = polyOp.getVert $Teapot01 101
$Point01.pos = myVert

Strange things happen when I execute the script and play a little with the target parameter in the morph and the play bar on the bottom of the window: the targets have limits and, although on the viewer is not noticeable, sometimes the target parameter goes beyond the limits. In addition, the point I want to constraint to the vertex does not seem to update its position as it should do...

So maybe I'm missing something related to this, or it's quite more complicated than I understood. On the other hand, I tried to build the system using an Attachment controller, but I end up with dependency loop errors (a bone driven by a point attached to a mesh can't deform this same mesh).

So my question here is... can someone drop here some information to avoid weird behaviours on the system? Anything related to this is going to be really appreciated!

Thanks for reading!

12 December 2007, 10:23 AM
Hi! I am quite new to maxscript but i think I solved your problem yesterday with a hack. Sorry if this solution is downright stupid.

I used a script controller on the pointhelpers scale. Yes, on its scale.

A=(in coordsys obj myself.pos.x)
B=(in coordsys obj myself.pos.y)
C=(in coordsys obj myself.pos.z)
move in coordsys obj obj.verts[4].pos=[A,B,C]
[1, 1, 1]

where "obj" is the editablePoly object with movable vertex. and where "myself" is the pointhelper itself.

The code is called now everytime you change the pointhelpers transform.And you don't need to scale your pointhelper, do you? It still has a little problem. When you rotate the "obj" the pointhelper won't follow. This problem can be solved by linking the point helper to the "obj"

Hope this helps :)

Edit: I reread your post. I misunderstood. You want to move the point helper in two ways? One is with the vertex and the other is by itself moving the vertex. I can see where the loop problems can occur. It can be probably done by someone more experienced than me.

12 December 2007, 11:08 AM
Your feedback is much appreciated, DaXiiD. I'll test your function to try to make the system work.


CGTalk Moderation
12 December 2007, 11:08 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.