Home Technical Talk

3dsMax perspective view when rotating from orthoraphic

So I noticed this problem of constantly having to switch between view modes when modeling in 3dsMax. When I switch to front view (orthographic) and rotate (alt+mmb) I end up in user/orthographic view. I would much prefer perspective view.
Currently wondering if this is possible in MAXScript since I imagine you would have to catch some kind of camera rotated event in real time and execute the "enter perspective view" command to switch to perspective. I can't seem to find a way to execute a command when the camera is rotated. Also from what I've seen MAXScript doesn't appear to be intended for this kind of task but rather for creating toolkits with buttons that execute certain commands.

Please share your thoughts about whether this is possible or not and how you would go about it.

thanks

Replies

  • Bartalon
    Options
    Offline / Send Message
    Bartalon polycounter lvl 12
    Is pressing P too much of a hassle? :P
  • jerizo
    Options
    Offline / Send Message
    Well, I'm just trying to optimize my workflows and I think this would really help because I have to switch views manually so frequently.
    I would very much appreciate a fix for this.

    So is this something that could be done?
  • aharmlesspie
    Options
    Offline / Send Message
    There are things about the orthographic camera that you will miss if it's gone. The thing that I find most useful is the ability to zoom in to my model without going "through" it. Using a perspective camera, you can only get so close to an object before it clips or you go inside it. Trust me, use the 2 milliseconds to press 'P' on the keyboard, you don't want to lose the orthographic camera.
  • garcellano
    Options
    Offline / Send Message
    garcellano greentooth
    Yeah, in the viewer, just press "P." That should bring you to the perspective view. If you need to, set the viewcube to display in the top right of the viewer. It might be displayed by default. You can also use that to switch to different views, orthographic and perspective.
  • PolyHertz
    Options
    Offline / Send Message
    PolyHertz polycount lvl 666
    Here's a very quick and dirty way to do that in toggle form via Callbacks (unfortunately it doesn't keep focus when switching viewport modes, not sure how to fix that):
    global varViewTypeLast = viewport.getType() --first run
    fn mahFunkz = 
        (
        if (
            ((varViewTypeLast == (#view_top)) or
            (varViewTypeLast == (#view_bottom)) or
            (varViewTypeLast == (#view_front)) or
            (varViewTypeLast == (#view_back)) or
            (varViewTypeLast == (#view_left)) or
            (varViewTypeLast == (#view_right))) and
            (viewport.getType() == (#view_iso_user))
            ) do
                (
                actionMan.executeAction 0 "40182"     --Perspective
                actionMan.executeAction 0 "311"        --zoom extends
                )
    
        global varViewTypeLast = viewport.getType()
        )
    
    
    if (varLazyPersp == undefined) do (global varLazyPersp = "off")
    if (varLazyPersp == "on") then (callbacks.RemoveScripts #viewportChange id:#lazyPersp ; varLazyPersp = "off")
    
    else 
        (
        varLazyPersp = "on"
        callbacks.addScript #viewportChange "mahFunkz()" id:#lazyPersp
        )
    
  • jerizo
    Options
    Offline / Send Message
    There are things about the orthographic camera that you will miss if it's gone.

    Indeed, i imagine so, but I'm not trying to completely get rid of it. I'd implement it in a way that would let me toggle the auto perspective change so I don't have to worry about cases where I need normal orthographic camera.
    PolyHertz wrote: »
    global varViewTypeLast = viewport.getType() --first run
    fn mahFunkz = 
        (
        if (
            ((varViewTypeLast == (#view_top)) or
            (varViewTypeLast == (#view_bottom)) or
            (varViewTypeLast == (#view_front)) or
            (varViewTypeLast == (#view_back)) or
            (varViewTypeLast == (#view_left)) or
            (varViewTypeLast == (#view_right))) and
            (viewport.getType() == (#view_iso_user))
            ) do
                (
                actionMan.executeAction 0 "40182"     --Perspective
                actionMan.executeAction 0 "311"        --zoom extends
                )
    
        global varViewTypeLast = viewport.getType()
        )
    
    
    if (varLazyPersp == undefined) do (global varLazyPersp = "off")
    if (varLazyPersp == "on") then (callbacks.RemoveScripts #viewportChange id:#lazyPersp ; varLazyPersp = "off")
    
    else 
        (
        varLazyPersp = "on"
        callbacks.addScript #viewportChange "mahFunkz()" id:#lazyPersp
        )
    

    thanks for the effort, appreciate it.

    I ran the script and it seems to work ok in terms of switching the perspective but when it switches, it for some reason zooms in extremely far to the point that my camera ends up inside the mesh so I see right through. It also doesn't quite focus the selection very nicely - it's actually a fair bit off.

    I prototyped the behavior I was looking for in a external application that remaps/ macros my keystrokes/ clicks in a way that does exactly what I want and it works wonderfully except for the fact that it sometimes has a tiny delay when rotating the camera that can be a little bit bothering. I should be able to fix that but I'd much rather not use a external solution and keep it in max.

    Before I resorted to a external solution I was looking for a event in maxscript that would allow me to fire a script when the viewport is rotated. I wasn't able to find anything.
    You however, apparently know how to do this and I would appreciate if you could point me to a source that offers some insight on this since I don't exactly get it yet just by looking at the code you provided.

    thanks again

    on a sidenote:
    would it be possible to implement to implement the zoom from zbrush in max? (pressing alt -> holding LMB -> releasing alt => zoom by dragging mouse)
    also wondering if blender style rotation translation and scaling in possible (eg. pressing g -> move mouse => move object/ press g -> press z => move object on z axis

    a yes no type answer would suffice on these because I don't mean to take your time with my concerns
  • Kimon
    Options
    Offline / Send Message
    Kimon polycounter lvl 6
    Wouldn't it work to map the "perspective view" to just alt? So whenever you're in an orto view and begin rotating it switches to perspective again?
  • PolyHertz
    Options
    Offline / Send Message
    PolyHertz polycount lvl 666
    jerizo wrote: »
    I ran the script and it seems to work ok in terms of switching the perspective but when it switches, it for some reason zooms in extremely far to the point that my camera ends up inside the mesh so I see right through. It also doesn't quite focus the selection very nicely - it's actually a fair bit off.

    Before I resorted to a external solution I was looking for a event in maxscript that would allow me to fire a script when the viewport is rotated. I wasn't able to find anything.
    You however, apparently know how to do this and I would appreciate if you could point me to a source that offers some insight on this since I don't exactly get it yet just by looking at the code you provided.


    Yea what I think is happening there is the rotation is continuing on from the ortho to perspective view without resetting in between, as a result it's losing the point of focus and getting confused.

    There's two way to deal with this: Either temporarily pause and resume user input during the frame it switches over from ortho to perspective view modes, or manually capture the focus point and re-set it. The 2nd method involves undocumented maxscript behavior so it would be quite a challenge to do. The first method though should be doable, so I'd look into manipulating user input if you want to try that.

    In the above script what I'm using is a 'callback', which is a background function that runs a script whenever a specific event is triggered from a list of pre-existing events (its similar to a ScriptJob in MEL for Maya). You can read up on them here.

    There's another function like it called a 'Change Handler' which is specific to changes made to objects in the scene that can be useful too.

    jerizo wrote: »
    on a sidenote:
    would it be possible to implement to implement the zoom from zbrush in max? (pressing alt -> holding LMB -> releasing alt => zoom by dragging mouse)
    also wondering if blender style rotation translation and scaling in possible (eg. pressing g -> move mouse => move object/ press g -> press z => move object on z axis

    a yes no type answer would suffice on these because I don't mean to take your time with my concerns

    The Blender style manipulation is definitely possible.
    The ZBrush style navigation however I'm not so sure on, there would be quite a few obstacles to scripting that.
  • jerizo
    Options
    Offline / Send Message
    Thank you, really appreciate your input.

    I will look into this. Also thanks for providing potential approaches on how to go about it.
Sign In or Register to comment.