Maxscript

From bernie's
Revision as of 15:35, 27 May 2015 by Bernie (talk | contribs) (Created page with "=== 3dsmax 3d to 2d=== <pre> fn mapWorldToScreen pos = ( width=gw.getWinSizeX() height=gw.getWinSizeY() thePos = pos * viewport.getTM()...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

3dsmax 3d to 2d


	   fn mapWorldToScreen pos =
   (
       width=gw.getWinSizeX()
       height=gw.getWinSizeY()
   
       thePos = pos * viewport.getTM()
       screenOrigin = mapScreenToView [0,0] (thePos.z) [width,height]
   
       worldSize = screenOrigin*2
       xAspect = width/(abs worldSize.x)
       yAspect = height/(abs worldSize.y)
   
	   screenPos=point2 (xAspect *(thePos.x-screenOrigin.x)) (-(yAspect*(thePos.y-screenOrigin.y)))
       --screenPos=point2 (xAspect *(thePos.x-screenOrigin.x)) (-(yAspect*(thePos.y-screenOrigin.y)))
       --if (screenPos.x) < 0 then (screenPos.x=0)
       --if (screenPos.y) < 0 then (screenPos.y=0)
       
       screenPos.x = screenPos.x as float
       screenPos.y = screenPos.y as float
       screenPos
   )
   
   p = $.pos
   p = mapWorldToScreen p
   
   $cam.name
   renderWidth