Author : AneeshaRode


Reply
Reply
 
Thread Tools Display Modes
shawnolson's Avatar
Old (#26)
I wanted to share my solution that seems to work. I wanted to make some dynamic function that accounts for all scale problems (as that would be most diverse)... but since the problem seems unlikely in most circumstances, I'm stopping for now with the following code.

I hope it helps someone.

Essentially, if you need to have a scale of [1,1,1] on your objects that were painted with the Object Paint tool, you can select those objects and then do something like this:

Code:
for obj in selection do (
 scale obj [-1,-1,-1]
 in coordsys local (
 rotate obj (eulerAngles (-1*obj.rotation.x_rotation) -180 (-1*obj.rotation.z_rotation))
 )
)
I'll be putting this into a function in Wall Worm in the next week.

PS. If someone has a more robust formula, I'd be happy to see it... all the linear algebra stuff is making my beard get too gray too fast.
Offline , spline, 193 Posts, Join Date Nov 2010, Location Columbus  
   Reply With Quote

poopipe's Avatar
Old (#27)
You can guarantee a positive scale by multiplying it by itself
Offline , triangle, 458 Posts, Join Date Dec 2010,  
   Reply With Quote

Denny's Avatar
Old (#28)
That only works if the scale is -1 or 1, not 0.5. (-0.5*-0.5 = 0.25) It is more stable to use an abs function, I don't know the syntax for it in Max Script but in Maya you do;

$scale = `abs $scale`;

Abs, absolute value, returns a non-negative value.
Offline , spline, 210 Posts, Join Date Sep 2007, Location Europe  
   Reply With Quote

poopipe's Avatar
Old (#29)
Fair point. I have no idea what the max equivalent is
Offline , triangle, 458 Posts, Join Date Dec 2010,  
   Reply With Quote

gray's Avatar
Old (#30)
sadly i don't know spit about max script (maya guy). so no working code solution from me.

-1 is a special case which gives the inverse.

@shawnolson

so i took a look at that pdf and i'm going to have to say its crap for learning simple matrix algebra in order to understand 3d matrix transforms. its intended for math majors who need to learn rigorous proofs and will go on to abstract algebra etc. thats absolutely not what you need to read. those other books are much better. or any standard 'engineering' intro to linear algebra book. you only need the first few chapters on Gaussian elimination and matrix algebra you don't need to read the whole thing.

that pdf will probably only annoy you with unimaginably abusive mathematical rigor. matrix algebra is quite easy if you get the right book tho.

Last edited by gray; 04-24-2012 at 06:07 PM..
Offline , polygon, 533 Posts, Join Date May 2011,  
   Reply With Quote

shawnolson's Avatar
Old (#31)
Quote:
Originally Posted by gray View Post
@shawnolson

so i took a look at that pdf and i'm going to have to say its crap for learning simple matrix algebra ... that pdf will probably only annoy you with unimaginably abusive mathematical rigor. matrix algebra is quite easy if you get the right book tho.
Well you must know my type quite well :P I started reading it and lost all the zest for solving the problem after a few pages! I really wish I would have sucked it up and learned more math back in school... but honestly it's the one realm that my brain turns into a grinder when pondering. Logic, I'm great. Syntax, programming, writing, analyzing, yada yada yada... I excel with ease. But math... it likes my brain as much as I like Glenn Beck.

What annoys me is that I can't just plug my brain into some machine and learn everything; and I know that this "problem" is probably a very novice mathematical problem. But now that I have a solution to my current scenario... I may never solve it.

Incidentally, the code needs an addition because it seems that the UVW seems to flip too... so that needs to be accounted for if anyone else comes across this. I'll post that solution tomorrow if I get time.
Offline , spline, 193 Posts, Join Date Nov 2010, Location Columbus  
   Reply With Quote

Denny's Avatar
Old (#32)
Seems the abs function is this simple if you need to use it.

value = abs(value)
Offline , spline, 210 Posts, Join Date Sep 2007, Location Europe  
   Reply With Quote

Xoliul's Avatar
Old (#33)
Hey man, maybe you should just write your own Object Paint replacement ? I've done that as well, and I actually prefer it over the standard object paint...
It's really not that difficult, I just got an example script off the net (Snap2Object.ms by P.G.Preeth). That way you have full control over the transforms of the placed objects.
Offline , veteran polycounter, 2,913 Posts, Join Date Oct 2008, Location Stockholm, SE Send a message via MSN to Xoliul  
   Reply With Quote

shawnolson's Avatar
Old (#34)
Quote:
Originally Posted by Xoliul View Post
Hey man, maybe you should just write your own Object Paint replacement ? I've done that as well, and I actually prefer it over the standard object paint...
It's really not that difficult, I just got an example script off the net (Snap2Object.ms by P.G.Preeth). That way you have full control over the transforms of the placed objects.
It's certainly something to consider since I have some ideas in mind that could make it really cool. Of course, by planting that seed you've doomed me to avoid any design work even further... banished me back to more code blocks
Offline , spline, 193 Posts, Join Date Nov 2010, Location Columbus  
   Reply With Quote

poopipe's Avatar
Old (#35)
Why didn't reset xform fix it?
Offline , triangle, 458 Posts, Join Date Dec 2010,  
   Reply With Quote

shawnolson's Avatar
Old (#36)
Sorry I didn't mean to ignore a couple ideas here. So here is my feedback on those.

Quote:
Originally Posted by Denny View Post
Seems the abs function is this simple if you need to use it.

value = abs(value)

Using abs() wouldn't help because the scale and rotation are linked mathematically (in the transform). Just getting the positive scale values was never really the issue since it was the rotations that I needed.


Quote:
Originally Posted by poopipe View Post
Why didn't reset xform fix it?
Reset XForm was my first step in figuring it out. But it failed. As Gray noted... Reset XForm aligns the object to the world... and that throws out the window the rotation values I am trying to get . (We all think of using that automatically here because we all know to use Reset Xform to solve random scaling issues... but in this case it isn't a good solution.)

PEN answered this question over on the Area the best so far. I haven't had a chance to open Max and test this in my code... but my guess is that it will work.

Last edited by shawnolson; 04-26-2012 at 06:59 AM.. Reason: typos
Offline , spline, 193 Posts, Join Date Nov 2010, Location Columbus  
   Reply With Quote

Reply

Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

Copyright 1998-2014 Polycount