CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »
 
Thread Tools Search this Thread Display Modes
Old 03-27-2012, 10:43 PM   #1
ivanisavich
Some kind of robot
 
ivanisavich's Avatar
Tyson Ibele
Animator
MAKE LLC.
Toronto, Canada
 
Join Date: Nov 2002
Posts: 3,073
simpleMod worldspace coordinates?

I have a simpleMod plugin that deforms vertices based on the position of a scene node.

All works fine, except I can't seem to work outside of the coordinate system of the mod's gizmo.

For example:

Code:
on map i p do ( p = sceneNode.position + [i,random 0 100,0] p )


works, but

Code:
on map i p ( p = sceneNode.position - center + [i,random 0 100,0] p )


has no effect, meaning I'm not able to compensate for a non-[0,0,0] position of the modifier's gizmo.

Any ideas?
__________________
http://www.tysonibele.com

Last edited by ivanisavich : 03-27-2012 at 10:46 PM.
 
Old 03-27-2012, 11:12 PM   #2
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,638
Send a message via ICQ to denisT
i'm sure you have to take into account modifierís context transform (see getModContextTM). every time when i work with modifier's transform i have to remember how it works . check the Modifier Sub-Object Transform Properties in mxs help. that's usually the start point of my memory refreshing.
 
Old 03-27-2012, 11:20 PM   #3
ivanisavich
Some kind of robot
 
ivanisavich's Avatar
Tyson Ibele
Animator
MAKE LLC.
Toronto, Canada
 
Join Date: Nov 2002
Posts: 3,073
edit: oops, I made a mistake.

Thanks dennis...I'll take a look at that
__________________
http://www.tysonibele.com

Last edited by ivanisavich : 03-27-2012 at 11:23 PM.
 
Old 03-28-2012, 03:47 PM   #4
ivanisavich
Some kind of robot
 
ivanisavich's Avatar
Tyson Ibele
Animator
MAKE LLC.
Toronto, Canada
 
Join Date: Nov 2002
Posts: 3,073
In case anyone else has this problem, I finally found a solution.

For some reason the getModContextTM doesn't update properly for simpleMod plugins. No matter what my object's pos/rot/scale is, and no matter what the simpleMod's gizmo pos/rot/scale is, the getModContextTM always returns the same, incorrect value (even though it returns proper values for other modifier types).

My solution was to store a weak reference to the object's transform in the simpleMod's parameter block. Then during the map function, I multiply my position data by the inverse transform of the object.

Obviously, that won't account for transformations of the simpleMod gizmo itself, but since my plugin doesn't require the user to modify the gizmo in any way, I just lock all its transform subanims.

One final problem I ran into, is that the transform data I was accessing in the <on map> function wasn't updating in real time. If I move the objects manually it updates, but not if I press the play button. My solution was to set 2 keyframes (one at t(-10000) and one at t(10000)) on the position controller of the simpleMod's gizmo. This forces the simpleMod to update all referenced transforms as well.
__________________
http://www.tysonibele.com
 
Old 03-28-2012, 05:23 PM   #5
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,638
Send a message via ICQ to denisT
Quote:
Originally Posted by ivanisavich
Obviously, that won't account for transformations of the simpleMod gizmo itself, but since my plugin doesn't require the user to modify the gizmo in any way, I just lock all its transform subanims.

how do lock the gizmo transform?
i don't think it's possible... do you just subtract the center position from the point position?

Last edited by denisT : 03-28-2012 at 05:30 PM.
 
Old 03-28-2012, 05:29 PM   #6
ivanisavich
Some kind of robot
 
ivanisavich's Avatar
Tyson Ibele
Animator
MAKE LLC.
Toronto, Canada
 
Join Date: Nov 2002
Posts: 3,073
I use this method to lock the gizmo's transfrom controllers:

Code:
for q in 1 to 3 do ( lockedTracksMan.setLocks true this.gizmo[q] this.gizmo[q].parent this.gizmo[q].index true )


By the way Denis, do you know of a way to access vertex normals within a simpleMod <on map> function? Obviously the "i" variable gives the vertex index, but when I try to do a <getnormal self i> (where self is a paramblock variable that the object the modifier is applied to is assigned) I get an error saying there's an illegal recursion occurring (even if "self" is a nodeTransformMonitor)
__________________
http://www.tysonibele.com
 
Old 03-28-2012, 05:43 PM   #7
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,638
Send a message via ICQ to denisT
Quote:
Originally Posted by ivanisavich
Code:
for q in 1 to 3 do ( lockedTracksMan.setLocks true this.gizmo[q] this.gizmo[q].parent this.gizmo[q].index true )


yes. sure. i just remember that the gizmo doesn't have transform controller, but it has position, rotation, and scale. but i forgot that gizmo itself is a subanim. so:
Code:
lockedTracksMan.setLocks on this.gizmo this this.gizmo.index on
 
Old 03-28-2012, 05:51 PM   #8
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,638
Send a message via ICQ to denisT
Quote:
Originally Posted by ivanisavich
By the way Denis, do you know of a way to access vertex normals within a simpleMod <on map> function? Obviously the "i" variable gives the vertex index, but when I try to do a <getnormal self i> (where self is a paramblock variable that the object the modifier is applied to is assigned) I get an error saying there's an illegal recursion occurring (even if "self" is a nodeTransformMonitor)


you can get normal of the node because your modifier itself is responsible for the value.
only thing you can do is snapshot the mesh before map and use its data.
that means you have to use a copy of original TriMesh
 
Old 03-28-2012, 05:54 PM   #9
ivanisavich
Some kind of robot
 
ivanisavich's Avatar
Tyson Ibele
Animator
MAKE LLC.
Toronto, Canada
 
Join Date: Nov 2002
Posts: 3,073
Quote:
Originally Posted by denisT
you can get normal of the node because your modifier itself is responsible for the value.
only thing you can do is snapshot the mesh before map and use its data.
that means you have to use a copy of original TriMesh


Where's the best place to do the snapshot? Is there an event that is triggered before the map function that I can do that in?

I've tried various places like within the simple mod <on update> clause, but that doesn't update each frame.

The object I'm modifying is animated over each frame, that's why I need the constant snapshot updates to get the proper normals....
__________________
http://www.tysonibele.com
 
Old 03-28-2012, 06:00 PM   #10
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,638
Send a message via ICQ to denisT
Quote:
Originally Posted by ivanisavich
Where's the best place to do the snapshot? Is there an event that is triggered before the map function that I can do that in?

I've tried various places like within the simple mod <on update> clause, but that doesn't update each frame.

The object I'm modifying is animated over each frame, that's why I need the constant snapshot updates to get the proper normals....


you don't need snapshot... i was wrong. you need a copy of trimesh. after you get a normal (which will be in local space) you have to multiply it on objecttransform...

the question is how to get constant update ... let me think.
 
Old 03-28-2012, 06:12 PM   #11
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,638
Send a message via ICQ to denisT
Quote:
Originally Posted by ivanisavich
Where's the best place to do the snapshot? Is there an event that is triggered before the map function that I can do that in?

you can store the mesh copy when you attach your modifier using attachtonode handler.
but the mesh might be changed after. hmm...
you can setup when construct on geometry change... update the mesh on its event. but set some flag to ignore changes if you do map operation in your modifier....
but there is another problem
 
Old 03-28-2012, 06:13 PM   #12
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,638
Send a message via ICQ to denisT
how do you know that geometry was change before your modifier? hmm again.
 
Old 03-28-2012, 06:32 PM   #13
ivanisavich
Some kind of robot
 
ivanisavich's Avatar
Tyson Ibele
Animator
MAKE LLC.
Toronto, Canada
 
Join Date: Nov 2002
Posts: 3,073
I thought of adding a "Calculate Normals" button to the simpleMod rollout that, when pressed, disabled the map function and caches the normals of the geometry to the paramblock for a specified frame range.

But that's a lot of extra work and annoying for anyone who changes the topology below the simpleMod, or animates the mesh in any way.
__________________
http://www.tysonibele.com
 
Old 03-28-2012, 06:56 PM   #14
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,638
Send a message via ICQ to denisT
OK. I found it. You can make a copy of triMesh in map function when i == 0 !!! cool!
 
Old 03-28-2012, 06:59 PM   #15
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,638
Send a message via ICQ to denisT
now we have to find solution how to do it if necessary. map function calls many times with ZERO index for some reason or other
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 08:40 PM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.