PDA

View Full Version : gw.setPos and aspect ratio


BradT
01-16-2009, 04:54 PM
Hi,

I'm using gw.setPos() and gw.getViewportDIB() to create a 512x512 viewport for a tool that's a variation on the built-in Make Preview tool. The problem is that the aspect ratio of the view isn't correct. I would think that if I set my view to 512x512 and my camera's FOV to 90, that I would get a 90 degree by 90 degree image. Instead, I'm getting a 90 degree wide image and a different vertical FOV. From what I can tell, vertical FOV seems to be related to the application's size. Is there any way to get a 90deg by 90deg view?

I did a search, and this old archived thread seems to be releated to my problem:
http://forums.cgsociety.org/showthread.php?f=98&t=465642&highlight=gw.setPos

Here's a code fragement:

viewport.setLayout #layout_4
viewport.activeViewport = 1
viewport.setCamera tempUpCam
gw.setPos 10 10 512 512
displaySafeFrames = false
viewport.SetRenderLevel #smoothhighlights


I'm using max2008.

Thanks!

ZeBoxx2
01-16-2009, 05:32 PM
well, as per that thread, you could scale the resulting bitmap..

or you can adjust the viewport's TM to counter-stretch the result - in the case of a camera: NU-scale the camera - before grabbing the viewport DIB

by the way - the stretching is relative to the viewport's original aspect. So another thing you could do is multiply the original size by however much you need to cover your required size, then just crop the middle section from that. I.e. if the viewport is 320x240 in size, and you want a 512x512 view, set the new viewport size as [512/240.0*320,512], then grab the dib, then just grab the middle 512 pixels horizontally, and all 512 pixels vertically

BradT
01-16-2009, 10:15 PM
Thanks ZeBoxx2! That set me on the right path. I also had to increase the camera's FOV using:


origVPSize = getViewSize() -- get the original viewport's size

newFOV = ((atan((origVPSize.y as float + (origVPSize.x - origVPSize.y)) / origVPSize.y as float ))*2) -- figure out the new field of view to ensure a 90 degree vertical FOV.


Nothing is ever as easy for me in Maxscript as I think it will be before I begin.

BradT
01-20-2009, 02:56 PM
I didn't want to create a new thread since this is for the same tool. Hopefully it gets some views.

Is there any way to mux audio into my AVI's? I can't find anything about it the help and a search here turned up nothing. The built-in "make Preview" tool supports audio, so I'm thinking there's probably a way to do it inside maxscript. I suppose I could call an external application like virtualdub or besweet, but that's not ideal.

Thanks,

ZeBoxx2
01-20-2009, 04:51 PM
not directly - an external tool really would likely be the most appropriate method.

the other option is to...
1. take your output animation (suggest using IFL with PNGs or so, to prevent quality loss further down this route) and set it as the environment background, Screen, no filtering.
2. set 'WAVSound.filename = <filename string>'
3. render the full animation out to a new AVI/QuickTime file, making sure to use the resolution of your existing animation (to prevent scaling)

That should have the Sound track included in the new animation. Make sure you check frames-per-second and whatnot settings so that your sound matches your video (if applicable).

BradT
01-20-2009, 04:57 PM
Thanks again ZeBoxx2! It does sound like an external app is the way to go here.

CGTalk Moderation
01-20-2009, 04:57 PM
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.