gw.setpos: viewport background not updating?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  01 January 2009
gw.setpos: viewport background not updating?

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
      gw.wText [2,15,0] text1 color:gray
      gw.wText [tmpX,15,0] text2 color:gray
      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
  01 January 2009
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.
  01 January 2009
Thanks for your answer. I will try your suggestion with the setBackground...
  01 January 2009
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 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....

  01 January 2009
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).
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 10:37 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.