gw.setPos and aspect ratio

Become a member of the CGSociety

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

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 01 January 2009   #1
gw.setPos and aspect ratio

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/showthr...light=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!
 
Old 01 January 2009   #2
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
 
Old 01 January 2009   #3
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.
 
Old 01 January 2009   #4
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,
 
Old 01 January 2009   #5
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).
 
Old 01 January 2009   #6
Thanks again ZeBoxx2! It does sound like an external app is the way to go here.
 
Old 01 January 2009   #7
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

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


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