PDA

View Full Version : gw.setpos: viewport background not updating?


legie
01-27-2009, 06:19 PM
Hi
I need to generate screen captures of a max viewport with some information displayed in it through gw.wText. Those captured images need to be exactly a specific size. Everything works fine with

gw.setpos 0 0 previewWidth previewHeight
completeredraw()
gw.wText [2,15,0] text1 color:gray
gw.wText [tmpX,15,0] text2 color:gray
gw.updateScreen()

local viewPortBitmap = gw.getViewportDib()
viewPortBitmap.filename = previewName
save viewPortBitmap


EXCEPT the fact that the viewport background doesn't rescale with gw.setpos. Is there any way to make the background fit to the new viewport size?

Without using gw.setpos but resizing the captures image with

tmpFile = bitmap 1024 584 filename:previewName
tmpView = gw.getViewportDib()
copy tmpView tmpFile
save tmpFile

ends in a proper background in the captured image but, of course, all the gw.Text elements are then totally off through stretching...

The only solution that comes to my mind right now is to generate a camera background plate on a geometry plane to substitute the default max viewport background... But it would be great if I could just have the background re-sized after using gw.setpos 0 0 previewWidth previewHeight

ZeBoxx2
01-27-2009, 08:42 PM
gw.setPos is pretty low-level stuff and a lot of things don't play nice with it (see earlier threads on retaining proper display aspect, for example) due to the viewport itself remaining exactly where it was before you run the gw.setPos command; you're only mangling its display window.

I don't think there's any way to tell max that the background bitmap should no longer be based on the viewport's dimensions, but based on your new display dimensions.

Using a plane, or resizing the bitmap used (if a bitmap) and re-setting that as the new background via setAsBackground seem to be your best options.

legie
01-28-2009, 08:45 AM
Thanks for your answer. I will try your suggestion with the setBackground...

legie
01-29-2009, 09:15 AM
Well, this is turning out to be annoying... maybe one of you masterminds have a solution for me.

Like I stated in my previous post: I am trying to write my own 'make preview' script which should include gw.text elements as well.
The problem is the background plate. It doesn't re-size with gw.setpos so I put the footage on a plane, mapped it with a 'camera map animated' modifier, aligned and parented that plane to the camera and everything looked good....at first. I maximize the viewport and turn of "Safe frame" to get a full view of the plate. But unfortunately it is not 100% the background plate but it is slightly zoomed in, with the footage cut at the edges. It is not much but too much to use it a preview setup. If you turn on "Safe frame" you get a full view of the plate but then you have those stupid spaces on the side/top of the plate in the viewport. I could easily calculate those border spaces but to my knowledge there is no possibility to crop the viewport or a bitmap through maxscript? You can only scale it by saving it to a bitmap with a different size.

Any ideas to solve this problem?

I am considering to go to SDK for this task as I already found the max default "makePrview" routine in there with all kinds of parameters. Unfortunately I couldn't find something to set the output path of the preview which is a requirement for my 'make preview script'. I would prefer to stay with MXS anyway....

Thanks!!

ZeBoxx2
01-29-2009, 09:54 AM
well, I'm not sure about the enlargement issue you mention... performing things with safe frames is always a good idea, though; or just make sure the viewport size you set has the same aspect as that of the camera (which will match your render output aspect).

If something's going on that prevents you from doing that, and you need to crop a bitmap, try pasteBitmap (added in 3ds Max 2008). It allows you to specify a source bitmap, source coordinates (Box2 style) and a destination bitmap with destination coordinates (Point2, so no scaling).

CGTalk Moderation
01-29-2009, 09:54 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.