PDA

View Full Version : dependsOn in Max8 .... please help


shibumenon
03-16-2006, 04:38 PM
Hi guyz ....
could somebody please update me on the way dependsOn works in Max 8?
It used to work perfectly till max 7 and somehow, I simply am not able to get it working in 8.
I'm on SP2
Thanks,
shibu

marktsang
03-16-2006, 05:13 PM
dependson has been replaced by named variables in max 8 - you need to create variables and assign maxobjects,controllers,nodes - the script is automatically dependant on any variable targets

mark

PEN
03-16-2006, 05:14 PM
Read up on it in the help files you will see that you are not supposed to be using dependsOn any more. The script controllers were rewritten to work like the expression controllers now.

shibumenon
03-16-2006, 05:54 PM
ok, now, is this a bug??? I'm basically trying to link a helper to a vertex of a deforming mesh.... thro a script controller.
as long its a mesh as in editable mesh, getvert works fine, but for a editable poly, this doesn't work.

i mean, if I have a deforming editable poly object,

dependsOn $sphere01
polyop.getvert $sphere01 315

used to work fine in max 7. But in max 8 it somehow doesn't work, even if I use dependsOn the way its to be used in 8.

If I have a deforming editable mesh,

dependsOn $sphere01
meshop.getvert $sphere01 315

seems to work fine in both 7 and 8

PEN
03-16-2006, 06:38 PM
I think you missed the point...stop using DependsOn, don't use it at all, it isn't to be used any more...I wont go on;)

Any way you need to add the mesh to the list of variables, then use that variable to access the poly object.

shibumenon
03-16-2006, 07:54 PM
thanks for the replies, paul, mark,

But no, I didn't miss the point. I didn't use dependsOn. I used a variable to store a node.
But still I am not able to get the script controller do what it used to do in Max 7.

I'm attaching a test max file here ...... it contains 2 objects, one's an editable poly and the other, an editable mesh. there're 2 helpers in the scene, both have a pos script controller.

If the same setup is used in Max7, the helpers do follow the vertex movements of the deforming mesh, but the same doesn't happen in Max 8. It seems to work only on the editable mesh. Either there's a problem with the variable - node assignment or something's changed with the way polyop.getvert works.

PEN
03-16-2006, 08:28 PM
OK so you are not, perfect. Ok so the next thing might be doing something like this then


theMesh=thePolyModel.mesh
meshOp.getVert theMesh theVertInt

shibumenon
03-16-2006, 08:59 PM
OK so you are not, perfect. Ok so the next thing might be doing something like this then


theMesh=thePolyModel.mesh
meshOp.getVert theMesh theVertInt


hi paul, thanks for looking into the file.
when I tried the above method, the helper does take the vertex deformation, but with an offset. It neglects the positional transform of the deforming object.
But if I add a turn to mesh modifier to the deforming mesh, meshop seems to work fine.
But then again, we are on meshop, and not on polyop ..... trying to do a workaround to something that worked well in max 7

Bobo
03-17-2006, 02:09 PM
hi paul, thanks for looking into the file.
when I tried the above method, the helper does take the vertex deformation, but with an offset. It neglects the positional transform of the deforming object.
But if I add a turn to mesh modifier to the deforming mesh, meshop seems to work fine.
But then again, we are on meshop, and not on polyop ..... trying to do a workaround to something that worked well in max 7

.mesh returns the TriMesh on top of the stack BEFORE the node transformations. (Shameless plug: My new DVD has a chapter on this).

You can get the full mesh by multiplying the vertex value by the node .transform property, or by using snapshotAsMesh() which already contains all this, and the Space Warp effects, too.

local theMesh = snapshotAsMesh thePolyModel --TriMesh on the very top of the stack
local theVert = getVert theMesh theVertInt --the vertex in world space
delete theMesh --flag the TriMesh value for garbage collection
theVert --return the vertex' world position

PEN
03-17-2006, 02:48 PM
Bobo, doesn't $.mesh get the top of the stack as well? Worked in my test here just fine as I was deforming the model with noise and it followed the vert. I didn't try moving the object as well though. What is the difference?

Bobo
03-17-2006, 02:58 PM
Bobo, doesn't $.mesh get the top of the stack as well? Worked in my test here just fine as I was deforming the model with noise and it followed the vert. I didn't try moving the object as well though. What is the difference?

No, .mesh returns the top of the stack before the node transform. If you teapot has the identity matrix (in other words it is aligned to the world), the result will be identical. But if you move the teapot, the helper will remain at the original position close to the origin, as it does not "see" the node transformations.

On the other hand, snapshotasmesh returns the world state of the mesh, including node transformations AND space warps.

If you would create a box at an offset from the origin, you can see the difference:

b = box pos:[100,100,100]
$Box:Box01 @ [100.000000,100.000000,100.000000]
getVert b.mesh 1
[-12.5,-12.5,0]
getVert (snapshotasmesh b) 1
[87.5,87.5,100]

Btw, the reason the scene fails in Max 8 was that the behavior of polyOp.getVert appears to have changed, not because of the new scripted controller.
Evaluating from the listener shows that the method now returns the vertex from the base level Editable_Poly, not from the top-of-the-stack PolyMeshObject resulting from the modifiers. I don't know why the change was made, but it is not the controller's fault.

magicm
03-17-2006, 02:58 PM
.mesh takes the nodes mesh before any transformations are applied. Deformations by modifiers are taken into account though..

I'm wondering though if snapshotAsMesh uses loads of ram when used in a script controller?

Martijn

Bobo
03-17-2006, 03:11 PM
.mesh takes the nodes mesh before any transformations are applied. Deformations by modifiers are taken into account though..

I'm wondering though if snapshotAsMesh uses loads of ram when used in a script controller?

Martijn

Not if you use the code I provided above.

*Create a Teapot with 64 segments.
*Add an animated Noise modifier
*Create a Helper
*Assign a Position Script to the Helper
*Create a variable theTeapot, assign the teapot to it as node
*Enter

local theMesh = snapshtoasmesh theTeapot
local theVert = getVert theMesh 1
delete theMesh
theVert

Scrub the time line and watch the Task Manager - no memory leaking...
Same with using the .mesh property, but it would not take Space Warps into account.
I transform the vertex position by the node transform myself:

local theMesh = theTeapot.mesh
local theVert = getVert theMesh 1
delete theMesh
theVert * theTeapot.transform


Now replace the code with

(getVert theTeapot.mesh 1)*theTrapot.transform

and watch your memory explode as you scrub the time!

PEN
03-17-2006, 03:34 PM
Ya I wasn't deleting the mesh, not good.

CGTalk Moderation
03-17-2006, 03:34 PM
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.