Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save MaxSteven/6876db0ce85368369f32a6b443866da1 to your computer and use it in GitHub Desktop.

Select an option

Save MaxSteven/6876db0ce85368369f32a6b443866da1 to your computer and use it in GitHub Desktop.
Maxscript: Demonstrates how to flip/mirror a transform around another transform.
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