Notifications
Clear all
[Closed] Code runs different inside and outside of a FN?
Aug 15, 2008 7:38 pm
So I’ve got some pretty basic code here, all its doing is trying to set up a camera at a certain angle, zoomed to fit the scene. (If there’s an easier way, let me know!)
Problem is: It runs differently when its enclosed in a function than when its just run straight out.
I’m using Max 2008 32bit, when run as is, it will set up the view correctly… if i uncomment the function brackets, then it will create a camera zoomed in, but from the plan view angle.
-- fn setupview =
-- (
--get rid of any existing perspective views lol
viewport.ResetAllViews()
viewport.setlayout #layout_1
--create a new camera thats oriented how we want
angleCam = Freecamera fov:45 pos:[0,0,0]
rotate angleCam (angleaxis 45 [0,0,1])
in coordsys local rotate angleCam (angleaxis 45 [1,0,0])
viewport.setcamera angleCam
--set perspective view to match the camera
max vpt persp user
--zoom to fit everything on the screen
select angleCam
max select invert
max zoomext sel
--build a new camera to match the zoomed perspective view, slightly zoomed in via fov
isoCam = Freecamera isSelected:on
isoCam.fov = 28
isoCam.orthoProjection = false
isoCam.Transform = Inverse(viewport.getTM())
viewport.setcamera isoCam
-- )
-- setupview()
could anyone else see if its acts the same?
1 Reply
Aug 15, 2008 7:38 pm
well, as to an alternate way to do it i just noticed the ‘simulating Zoom Extents All’ sample code. that looks like it’ll work just as well.
still, odd to have something run differently inside of brackets vs out