Created
March 22, 2016 14:32
-
-
Save JokerMartini/26ff420914ecd01af6c9 to your computer and use it in GitHub Desktop.
Maxscript: Demonstrates how to flip/mirror a transform around another transform.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
delete objects | |
tp = Teapot radius:5 pos:[40,0,0] | |
pt = Point pos:[20,0,0] size:5 wirecolor:red | |
fn mirrorMatrixFn | |
axis:"x" --Axis to mirror over | |
flip:"x" --Axis to flip | |
tm:(matrix3 1) --Matrix to mirror | |
pivotTm:(matrix3 1) --Matrix to mirror around | |
= | |
( | |
fn FetchReflection a = | |
( | |
case a of ( | |
"x": [-1,1,1] -- reflect in YZ plane | |
"y": [1,-1,1] -- in ZX plane | |
"z": [1,1,-1] -- in XY plane | |
) | |
) | |
aReflection = scalematrix (FetchReflection axis) | |
fReflection = scalematrix (FetchReflection flip) | |
--calculate the mirroredTM | |
fReflection * (tm * (inverse pivotTm)) * aReflection * pivotTm | |
) | |
flippedTM = mirrorMatrixFn pivotTm:pt.transform tm:tp.transform | |
dup = copy tp | |
dup.transform = flippedTM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, works great.