[Closed] Floating Viewport with Camera view
Hello guys.
Any ideas about floating camera view viewport?
I’ve found this scripts in old thread, but it doesnt work right
(
rollout tRO "floating viewer ;)" width:((gw.getWinSizeX())/2) height:((gw.getWinSizeY())/2)
(
local fixed_to_viewport = true -- if set to true the same viewport is going to be displayed at all times
local vpI = 0
fn setROImg =
(
disableSceneRedraw()
--set custom viewport and shading settings here
local oldVPI = viewport.activeViewport
if fixed_to_viewport == true do
(
viewport.activeViewport = vpI
)
SetDialogBitmap tRO (gw.getviewportDIB())
--revert to old viewport and shading settings here
if fixed_to_viewport == true do
(
viewport.activeViewport = oldVPI
)
enableSceneRedraw()
OK
)
timer clock interval:500
on clock tick do setROImg()
on tRO open do vpI = viewport.activeViewport
)
createdialog tRO bmpstyle:#bmp_stretch bitmap:(bitmap 1 1 color:orange) style:#(#style_resizing, #style_titlebar, #style_border, #style_sysmenu, #style_toolwindow)
)
the main problems in this script:
- playback latency. miss a lot of frames
- after i maximize my working viewport, floating window get crash
maybe you know some other plugs or scripts?
Although it is a clever little script bear in mind it is just ScreenCaping the view and pasting it in a bitmap in the dialog. This process is very slow as a whole.
However, you can reduce the timer interval to speed it up.
timer clock interval:10
This will get you near real-time on a fast machine, but will hammer you processor.
Look here for more info http://docs.autodesk.com/3DSMAX/16/ENU/MAXScript-Help/index.html?url=files/GUID-9A4F0A09-BB42-4EED-95CC-6B3D06939640.htm,topicNumber=d30e641954
You can grab the viewports window handle via script, create a custom form via dotnet and rehook the viewport window as a new child of that form. After that you got a detached viewport of some kind which you even can drag onto the second monitor. The “detached” viewport is still operational ( meaning you can interact with the objects etc… )…
Just keep in mind that every Max viewport layout related operation ( especially viewport min/maximizing) interferes with that. Max still believes it has it’s viewport in the region where it was detached from or simply might reparent your “stolen” viewport to the original viewport “root”.
I experimented with this idea a bit in the past, but never followed it longer, because you get unrefreshed regions in the Max window ( where the original viewport once was placed ), but maybe one could even trick that …
spacefrog, do you have an example of this to try? i’d love to see it the way you’ve described.
I briefly looked in my maxscript code archive but did’nt find it
As far i remember it involved DenisT’s method to expose Win32’s user32.dll’s “SetParent” function plus finding the viewport panels ( and it’s parents) window handles, creating a form and use SetParent to make the form’s window handle the new parent of the one viewport i want to detach. I’m pretty sure some additional windows style flag setting was involved and some resizing most propably too…
That’s a pretty neat script! I changed the timer clock interval to 100 and it’s pretty much matching the animation playback.
However, it seems to have a memory leak– as memory usage continuously grows while this script is active– am I right about this? If so, can someone help me find the leak and fix it?
Often garbage collection is suspended if you are in a loop. A timer could cause this.
try using the command
GC() –This will run garbage collection, you’ll see memory usage drop significantly.
You’ll need to find an appropriate time to do this. If you do it to often it will lag the script. If you don’t do it often enough when it runs everything will freeze everything for a bit while it clears things out.
This particular script would be better suited as a plugin. Maxscript is really designed for automation not heavy lifting.
Doc
Rather than using a timer... could you simply use a callback mechanism to refresh the bitmap anytime a specific control was manipulated that changed the scene or the camera (assuming a camera viewport)... although when playing an animation it probably wouldn't update properly. Or simply force it to refresh any time any of the four main viewports are redrawn?
Yes, I'm trying to figure out how to make a simple "Camera Viewport Instancer" plugin that could be stuck within a Maxscript floating dialog/rollout using the Custom UI control or an ActiveX control... ideally where the full camera viewport would not be shown (i.e., 4-view = front, side, top, perspective).
This is the limited, interactive, viewport within the MaxFinder exe "About" dialog:
[img] http://i120.photobucket.com/albums/o183/archangel35757/MaxFinder_AboutDialog_zpse4qfghha.jpg [/img]
I fixed the memory leak… still working on improving the script.
So here is what I came up with… after some hours playing with it. At least it won’t crash your memory anymore…
What do you think? Credit for the original script goes to @Insanto ( http://forums.cgsociety.org/showthread.php?f=98&t=906296 ).
Currently this modified script is limited to looking for a “Camera01” object… but that can easily be modified. For some reason, after running the script– you can no longer select the camera with the selection tool but you can select it with the move/rotate tools… and see interactive updates in the floating rollout viewport. Interactions in any view other than the Camera Viewport will cause the yellow “active window” border to flicker– any ideas how to resolve that? Same goes for playing back the animation when Camera Viewport isn’t active.
You could also register other kinds of general callbacks… for when certain control objects get transformed, etc.