[Closed] Possible to mirror the viewport via maxscript?
I guess this is probably not possible, but still I have to ask because i would find this very useful. So is it possible through maxscipt mirror the viewport as if seen through mirror on the side of monitor? It would be very useful to have a different view on animations when working longer on them.
Thanks
Not sure I am understanding this correctly, but do you mean “Flip the display in one viewport” or “create a clone of a viewport on a second monitor”?
The second is not possible for technical reasons, the first is.
*Create a camera in one viewport.
*Set the second viewport to the same camera
*Hit P to switch to Perspective view in the second viewport
*Hit Ctrl+C to create a second camera matching the same view
*Select the camera, right-click the Scale tool to open the Transform Type-In
*Switch the Ref. Coordinate System to Local
*Enter -100 in the Local X axis of the Camera Scale
Result:
The second viewport will be a horizontal mirror of the original view.
Sure…
viewport.setTM ((viewport.getTM())*(scaleMatrix [-1,1,1]))
I haven’t really tried it to see what works in what way, I would have to give it more thought. But you can flip it any way that you like just by changing which axis in the scaleMatrix has the – sign. You could then flip on two axes if you like.
😮 I… can’t find the right words… guys, I love you, I really do :love:
I was searching for some external application which would allow me to do this for a long time, but had no luck (seems like this would have to be done in gpu drivers). I didn’t even think about if this could be done directly in max. And now I have posted this just to make myself sure that this crazy thing really can’t be done.
Many, many thanks to both of you guys you made one animator’s life a little bit easier :applause:
I managed to make a little script that will mirror active viewport (perspective, user or camera). Only problem is that after mirroring it for a few times i’m not very sure if the viewport is actually mirrored or not
I was thinking that it would be great if I could print some info like “MIRRORED” to top/right of the view that has been mirrored. And than when I mirror it back to normal state it would remove the text. This should work for multiple views too – so I would have to check somehow if the text is there, if yes, remove it, if not print it.
I think something like viewport statistics would be the best. I got some results with gw thing, but i don’t know how to align it to the top right corner, how to make that text visible only in one viewport and how to check if that text is already there so I can remove it.
doC
top-right corner text bit:
myStr = "Hello World"
myStrExtent = gw.getTextExtent myStr
vpWidth = gw.getWinSizeX()
xPos = vpWidth - myStrExtent.x - 1
yPos = myStrExtent.y
gw.setTransform(Matrix3 1)
gw.wText [xPos,yPos,0] myStr color:(color 255 255 0)
gw.enlargeUpdateRect (Box2 (vpWidth - myStrExtent.x) 0 myStrExtent.x myStrExtent.y)
gw.updateScreen()
and I think that the following is correct
(viewport.getTM()).determinantsign
-- 1 if normal, -1 if mirrorred
Thanks a bunch, really appreciate your help. I will now try to “implement” this into what I have so far. Will post if I succeed
This is what I have so far (I have left out code for camera which is +/- the same):
macroscript Viewport_Mirrorizer
category: "Cauldron"
tooltip:"Viewport_Mirrorizer"
buttontext:"Viewport_Mirrorizer"
(
if (viewport.getType()) == #view_persp_user or (viewport.getType()) == #view_iso_user then
(
viewport.setTM ((viewport.getTM())*(scaleMatrix [-1,1,1]))
if (viewport.getTM()).determinantsign == -1 then
(
--messagebox "mirrored"
unregisterRedrawViewsCallback DisplayInfo
fn DisplayInfo =
(
myStr = "MIRRORED"
myStrExtent = gw.getTextExtent myStr
vpWidth = gw.getWinSizeX()
xPos = vpWidth - myStrExtent.x - 1
yPos = myStrExtent.y
gw.setTransform(Matrix3 1)
gw.wText [xPos,yPos,0] myStr color:(color 255 255 0)
gw.enlargeUpdateRect (Box2 (vpWidth - myStrExtent.x) 0 myStrExtent.x myStrExtent.y)
gw.updateScreen()
)
registerRedrawViewsCallback DisplayInfo
)
else
(
--messagebox "normal"
unregisterRedrawViewsCallback DisplayInfo
)
)
else
(
messagebox "I'm deeply sorry sir, but you have to be in Perspective view, Camera view or User view to use this script." title: "A little problem :("
)
)
Now my problem is that I’m unable to unregister the DisplayInfo callback after viewport is set back to normal (non-mirrored) mode. So even if maxscript gets to the correct if else part of the code, and test messagebox pops up, unregistration doesn’t work for some reason. I’m sure I just don’t get how those callbacks work and i’m doing something wrong there :argh: . Btw, is there a callback which would detect that user has switched to different viewport?
I have used the search function of the forums and found a thread with similar problem and seems like i have to declare the DisplayInfo function as global… and surprisingly it seems to work so far
You can use this script if you want for the label setup. http://forums.cgsociety.org/showthread.php?f=98&t=589864&highlight=viewport+label