Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / MaxScript / Move Mapping Gizmo
  RSS 2.0 ATOM  

Move Mapping Gizmo
Rate this thread
 
22118
 
Permlink of this thread  
avatar
  • Kenc
  • Posted: 30 January 2009 02:51 PM
  • Total Posts: 66
  • Joined: 15 February 2007 04:09 PM

I need to move the mapping gizmo according to the mapping coordinates. I can do so with

a = $.modifiers[1]
a.gizmo.position.x = a.gizmo.position.x + (x / 2.0)
a.gizmo.position.y = a.gizmo.position.y + (y / 2.0)

provided the coordinate system for the map is in the same direction as the object.

If I rotate the map 90 degrees, the above snippet moves the map in the same direction rather than at 90 degrees.
What do I need to do to get the map to move in the local (map) coordinates?

Thanks in advance



Replies: 0
avatar
  • gan0nia
  • Posted: 02 February 2009 07:39 AM

hi you can try following code:

theMod = $.modifiers[1]

theGizmoTM 
theMod.gizmo.transform
theGizmoTMLocal 
theGizmoTM * (inverse($.transform))
offsetX theGizmoTMLocal.row4.x/2
offsetY 
theGizmoTMLocal.row4.y/2
theGizmoTMLocal
.row4 [offsetX,offsetY,theGizmoTMLocal.row4.z]

theMod
.gizmo.transform theGizmoTMLocal*$.transform

if you rotate the object , you should take the whole object’s transform into consider :D
cheers!



Replies: 0
avatar
  • Kenc
  • Posted: 02 February 2009 11:18 AM

Thanks so much for the input. I didn’t think it would be as easy as using position after posting my question, later realizing I had to use transforms.

This is what I have

theMod = $.modifiers[1]
xyz_l = 96
xyz_w = 218
theMod.length = (xyz_l as float)
theMod.width = (xyz_w as float)
theGizmoTM = theMod.gizmo.transform
theGizmoTMLocal = theGizmoTM * (inverse($.transform))
offsetx = theGizmoTMLocal.row4.x + (xyz_w/2)
offsety = theGizmoTMLocal.row4.y + (xyz_l/2)
theGizmoTMLocal.row4 = [offsetX,offsetY,theGizmoTMLocal.row4.z]
theMod.gizmo.transform = theGizmoTMLocal*$.transform

and the attached is a sample mesh, a simple rectangle with planar mapping.

the code above works but if I rotate the mapping 90 degrees, the gizmo still moves in the same direction as before rotating the gizmo.



Attachment Attachment
Replies: 0
avatar
  • Kenc
  • Posted: 04 February 2009 09:53 AM

I’m really surprised that no one else has replied with a possible solution.



Replies: 0
avatar
  • Location: West Midlands, England, UK
  • Total Posts: 14445
  • Joined: 06 August 2007 11:06 PM
  • Permlink of this post

I can’t give a definitive answer but have a look at “coordsys” in the MXS help - it may be of some use.



Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.

Replies: 0
avatar
  • Kenc
  • Posted: 04 February 2009 10:20 AM

One problem is that I am confused as to what coordinate system I should use or even understand transforming.



Replies: 0
avatar
  • Location: West Midlands, England, UK
  • Total Posts: 14445
  • Joined: 06 August 2007 11:06 PM
  • Permlink of this post

So am I (confused) - which is why I didn’t reply before.

From a quick read at the help, translations are always performed in the World coordinate system, so if you want (for example) Local rotation, you would need “in coordsys local” to force the issue.

Whether that is relevent to mapping coordinates I’m really not sure - but it can’t hurt to have a play with it.



Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.

Replies: 0
avatar
  • Kenc
  • Posted: 04 February 2009 10:48 AM

I already took a look at that, but i will go back and have another read in case I missed something. I really appreciate your input. Thank you so much.



Replies: 0
avatar
  • Kenc
  • Posted: 06 February 2009 01:32 PM

I am unable to use transforms to move the mapping in the direction I want. But I have come up with a workaround using the mapping position. I check the ‘rotationpart’ of the mapping transform. If it is (quat 0 0 -1 0) then it isn’t rotated and I move the mapping, x to the right(top view) and y is up. If it’s (quat 0 0 0.707107 0.707107) then it’s rotated, x is up (top view) and y is left.

Not the way I wanted but it works.

Thanks to those who gave their input.



Replies: 0