Max2012的世界坐标转屏幕坐标
Max2012使用Nitrous作为显示驱动的时候会有个Bug,就是MaxScript无法用GW.TransPoint来将世界坐标转换为屏幕坐标.这个Bug在2013中已经修复,2012可以换用Direct3D来解决,当不能换的时候,可以用该函数凑合解决一下:)。
Fn WorldPositionToScreen inputPos = ( viewMatrix = GetViewTM() viewCameraMatrix = Inverse viewMatrix screenRange2D = GetViewSize() refPosition = inputPos * viewMatrix screenOrigin = mapScreenToView [0,0] refPosition.z screenRange2D screenEnd = mapScreenToView screenRange2D refPosition.z screenRange2D worldSize = screenOrigin - screenEnd aspectX = screenRange2D.x/(abs worldSize.x) aspectY = screenRange2D.y/(abs worldSize.y) screenX = (aspectX * (refPosition.x - screenOrigin.x)) as Integer screenY = (abs(aspectY*(refPosition.y - screenOrigin.y))) as Integer [screenX,screenY] )