Forked from JokerMartini/Flip or Mirror Transform | .ms
Created
July 5, 2017 14:14
-
-
Save MaxSteven/6876db0ce85368369f32a6b443866da1 to your computer and use it in GitHub Desktop.
Maxscript: Demonstrates how to flip/mirror a transform around another transform.
This file contains hidden or 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