Notifications
Clear all

[Closed] 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:

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

    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?
18 Replies

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.

edit: oops, I made a mistake.

Thanks dennis…I’ll take a look at that

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.

1 Reply
(@denist)
Joined: 1 year ago

Posts: 0

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

I use this method to lock the gizmo’s transfrom controllers:


  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)

1 Reply
(@denist)
Joined: 1 year ago

Posts: 0

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:


  lockedTracksMan.setLocks on this.gizmo this this.gizmo.index on
  

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

3 Replies
(@ivanisavich)
Joined: 1 year ago

Posts: 0

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…

(@denist)
Joined: 1 year ago

Posts: 0

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.

(@denist)
Joined: 1 year ago

Posts: 0

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

how do you know that geometry was change before your modifier? hmm again.

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.

OK. I found it. You can make a copy of triMesh in map function when i == 0 !!! cool!

1 Reply
(@ivanisavich)
Joined: 1 year ago

Posts: 0

Unfortunately, the docs say that:

The <index> value is 1-based, however the scripted plug-in is called with a <index> value of 0 to signal that this particular map call is being used by the gizmo bounding box drawing code to compute points in the gizmo box to draw. This occurs hit testing is performed on the object the SimpleMod modifier is applied to and the gizmo bounding box is displayed. This will be the case if the object is selected, the Modifier panel is active, and the SimpleMod modifier is selected in the object’s modifier stack.

So i = 0 won’t happen necessarily if someone is animating the mesh…only if someone is doing that while the modifier panel is open, and the modifier is selected.

Damn…

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

Page 1 / 2