Would someone know how to get this working in max 2013? A variable has to be changed somewhere? Or does it just need to be resaved as unicode? Not familiar with either.
This is what I'm refering to...
http://www.scriptspot.com/3ds-max/scripts/imageplane-v1-5
Although now it is called Vertical Plane 1.7.1
It's great for making reference sheets instantly...
This is the code...according to the listener, I am getting caught on stat = 2, which is mouse click up after you draw out the plane. It fails trying to initialize the modify panel options...
plugin Geometry verticalPlane
name:"VerticalPlane"
classID:#(0x1f8a3691, 0x5b8a82ab)
category:"Scripted Primitives"
extends:Plane
replaceUI:true
version:1.5
(
local dimensionRatio = 1
local adjusting = false
local theMaterial = undefined
local theBitmap = undefined
local origSize = undefined
local origPos = [0,0,0]
fn translatePivot obj dir = (
disableSceneRedraw()
local DMatrix =transMatrix dir
local invDMatrix = inverse DMatrix
in coordsys obj.objecttransform obj.transform= DMatrix * obj.transform
obj.objectoffsetpos *= invDMatrix
enableSceneRedraw()
redrawViews()
)
fn setPivotPosRelativeObjtransform obj pos = (
local PMatrix = transMatrix (obj.objectoffsetpos + pos)
local invPMatrix = inverse PMatrix
in coordsys obj.objecttransform obj.transform = PMatrix * obj.transform
obj.objectoffsetpos *= invPMatrix
)
fn RotatePivotOnly obj rot = (
local rotValInv
if classof rot == EulerAngles then
rotValInv = inverse (rot as quat)
else
rotValInv = rot
animate off in coordsys local obj.rotation *= RotValInv
obj.objectoffsetrot *= RotValInv
)
parameters main rollout:params (
--stat: 1 --#CREATING , stat:2 --#CREATED , stat:3 --#RESIZING
stat type:#integer default:0
Height type:#float animatable:true ui:spnHeight default:0
Width type:#float animatable:true ui:spnWid default:0
heightSegs type:#integer animatable:true default:4 ui:spnHeightSegs
widthSegs type:#integer animatable:true default:4 ui:spnWidSegs
Density type:#float animatable:true default:1 ui:spnDensity
renderScale type:#float animatable:true default:1 ui:spnRenderScale
Mapcoords type:#boolean default:true ui:chkMapCoords
realWorldMapSize type:#boolean default:false ui:chkRealWorldMapSize
mainConstrainProp type:#boolean default:true ui:chkMainConstrainProp
pivotPos type:#Integer default:1 ui:radPivotPos
on Height set val do (
disableSceneRedraw()
if stat == 2 then (
if pivotPos == 1 then (--bottom
if mainConstrainProp and adjusting then Width = Height / dimensionRatio
Height = val
delegate.Length = val
setPivotPosRelativeObjtransform selection[1] [0,0,-Height/2]
selection[1].pos = origPos
) else (
delegate.Length = val
Height = val
if mainConstrainProp and adjusting then Width = Height / dimensionRatio
)
) else if stat == 1 then delegate.Length = val
enableSceneRedraw()
redrawViews()
)
on Width set val do (
disableSceneRedraw()
if stat == 2 then (
if pivotPos == 1 then (
if mainConstrainProp and adjusting then Height = Width * dimensionRatio
Width = val
delegate.Width = val
selection[1].pos = origPos
) else (
delegate.Width = val
Width = val
if mainConstrainProp and adjusting then Height = Width * dimensionRatio
)
)
--
enableSceneRedraw()
redrawViews()
)
on heightSegs set val do (
delegate.lengthSegs = val
)
on widthSegs set val do (
delegate.widthSegs = val
)
on Density set val do (
delegate.Density = val
)
on renderScale set val do (
delegate.renderScale = val
)
on mapcoords set val do (
delegate.mapcoords = val
)
on realWorldMapSize set val do (
delegate.realWorldMapSize = val
)
on spnRenderScale set val do (
delegate.spnRenderScale = val
)
on Density set val do (
delegate.Density = val
)
)
rollout params "Vertical Plane v1.6.1" (
local preLen
local preTransform
local prePos
spinner spnHeight "Height:" type:#worldUnits align:#left range:[0,65536,10] width:134 offset:[-3,0] across:2
button btnHWReset "reset" width:40 height:40 align:#right offset:[10,0]
spinner spnWid "Width:" type:#worldUnits align:#left range:[0,65536,10] width:100 offset:[0,-21]
checkbox chkMainConstrainProp "Constrain Proportions" checked:false align:#right offset:[0,-4]
label lblPivotPos "Pivot Pos:" across:2 align:#left offset:[-10,0]
radiobuttons radPivotPos labels:#("buttom", "center") offset:[20,0] default:1 columns:3
spinner spnHeightSegs "Height Segs:" type:#integer align:#right range:[1,65536,4] offset:[0,4]
spinner spnWidSegs "Width Segs:" type:#integer align:#right range:[1 ,65536,4]
Group "Render Multipliers" (
spinner spnRenderScale "Scale:" align:#right type:#float range:[0,65536,1]
spinner spnDensity "Density:" align:#right type:#float range:[0,65536,1]
Label lblFaces "Total Faces:" width:120
)
checkbox chkMapCoords "Generate Mapping Coords:" type:#boolean checked:true
checkbox chkRealWorldMapSize "Real-World Map Size" type:#boolean checked:false
fn numfaces = (
delegate.mesh.numfaces
)
fn setPivot type = (
if stat == 2 then (
case pos of (
1: setPivotPosRelativeObjtransform selection[1] [0,0,-delegate.Length/2]
2: centerPivot selection[1]
)
)
)
on btnHWReset pressed do (
if origSize != undefined then (
Height = origSize[1]
Width = origSize[2]
)
)
on radPivotPos changed val do (
case val of (
1: setPivotPosRelativeObjtransform selection[1] [0,0,-delegate.Length/2] --selection[1].pivot.z = selection[1].min.z
2: if isValidNode selection[1] do centerPivot selection[1]
)
)
on params open do (
lblFaces.caption = "Total Faces:" + (numfaces() as String)
)
on chkMainConstrainProp changed val do (
if val then (
dimensionRatio = Height / Width
selection[1].theMap.chkConstrainProp.checked = true
) else ( dimensionRatio = 1
selection[1].theMap.chkConstrainProp.checked = false
)
)
on spnHeight buttondown do (
if stat == 2 then (
if mainConstrainProp then dimensionRatio = Height / Width
adjusting = true-- adjusting
origPos = selection[1].pos
)
)
on spnHeight buttonup do (
if stat == 3 then (
enableSceneRedraw()
adjusting = false
)
)
on spnWid buttondown do (
if stat == 2 then (
if mainConstrainProp then dimensionRatio = Height / Width
/*dd*/origPos = selection[1].pos
adjusting = true
)
)
on spnWid buttonup do (
if stat == 3 then (
adjusting = false
)
)
)
parameters sub rollout:theMap (
ImgName type:#String default:"Open Image File"
ImgFilePath type:#String default:""
hasMaterial type:#boolean default:false
ShowImg type:#boolean default:false ui:chkShowImg
ConstrainProp type:#boolean default:true ui:chkConstrainProp
PremultipliedAlpha type:#boolean default:true ui:chkPremultipliedAlpha
TwoSides type:#boolean default:true ui:chk2Sides
Iullmination type:#Integer default:0 ui:spnIullmination
on TwoSides set val do (
if theMaterial != undefined and classof theMaterial == Standardmaterial then theMaterial.twoSided = val
)
on Iullmination set val do (
if theMaterial != undefined and classof theMaterial == Standardmaterial then theMaterial.selfIllumAmount = val
)
on PremultipliedAlpha set val do (
if theMaterial != undefined and (superclassof theMaterial.diffuseMap == textureMap) then (
theMaterial.diffuseMap.preMultAlpha = val
)
)
)
rollout theMap "Image setup" (
group "Source Image" (
button btnOpnImg "Open Image File" width:127 offset:[8,0] across:2
checkbox chkShowImg checked:ShowImg align:#right offset:[16,4]
)
group "Source Alpha File Name " (
edittext edtAlphaName "Name suffix:" text:"_alpha" width:130 align:#left
label lblAlphaName2 "ex : bird.jpg ; bird_alpha.jpg" offset:[-4,-4]
)
group "Sampling" (
checkbox chkGlobalSP "Use Global Setting" checked:false offset:[-4,0] align:#left
checkbox chkLocalSP "Local Samp.(Max 2.5 star)" checked:true offset:[-4,0] align:#left
)
checkbox chkConstrainProp "Constrain Image Proportion" checked:ConstrainProp offset:[-4,0]
checkbox chkPremultipliedAlpha "Premultiplied Alpha" checked:PremultipliedAlpha offset:[-4,0]
checkbox chk2Sides "2-Sides" checked:TwoSides offset:[-4,0]
spinner spnIullmination "Self-Illumination: " width:130 type:#integer align:#left range:[0,100,Iullmination]
fn getMaterial pmBitmap = (
local fileType = getFilenameType pmBitmap.filename
fileType = substring fileType 2 -1
fileType = toLower fileType
local fileName = filenameFromPath pmBitmap.filename
local pmMat
local diffuseTextureBitmap = bitmaptexture name:fileName bitmap:pmBitmap
diffuseTextureBitmap.coordinates.Blur = 0
local opacityTextureBitmap
local dotidx
for i = fileName.count to 1 by -1 where fileName[i] == "." do (
dotidx = i;
i = 0
)
local matName = substring fileName 1 (dotidx - 1)
local alpha_fname = (getFilenamePath theBitmap.filename ) + ( getFilenameFile theBitmap.filename ) + edtAlphaName.text + (getFilenameType theBitmap.filename )
if ( fileType == "jpg" ) then (
if doesFileExist alpha_fname then opacityTextureBitmap = bitmaptexture filename:alpha_fname filtering:0 monoOutput:0 rgbOutput:0 alphaSource:2
else opacityTextureBitmap = undefined
pmMat = standard name:matName diffuseMap:diffuseTextureBitmap opacityMap:opacityTextureBitmap showInViewport:true
) else if ( fileType == "png" or fileType == "tif") then (
if doesFileExist alpha_fname then opacityTextureBitmap = bitmaptexture filename:alpha_fname
else opacityTextureBitmap = bitmaptexture bitmap:pmBitmap filtering:2
opacityTextureBitmap.monoOutput = 1
pmMat = standard name:matName diffuseMap:diffuseTextureBitmap opacityMap:opacityTextureBitmap showInViewport:true
) else if ( fileType == "tga" ) then (
if doesFileExist alpha_fname then opacityTextureBitmap = bitmaptexture filename:alpha_fname
else opacityTextureBitmap = bitmaptexture bitmap:pmBitmap
opacityTextureBitmap.monoOutput = 0
opacityTextureBitmap.output.invert = true
pmMat = standard name:matName Diffuse:diffuseTextureBitmap Opacity:opacityTextureBitmap showInViewport:true
) else if ( fileType == "avi" ) then (
pmMat = standard name:matName diffuseMap:diffuseTextureBitmap showInViewport:true
) else if ( fileType == "ifl" ) then (
if doesFileExist alpha_fname then opacityTextureBitmap = bitmaptexture filename:alpha_fname monoOutput:0 filtering:0 rgbOutput:0 alphaSource:2
else opacityTextureBitmap = bitmaptexture bitmap:pmBitmap filtering:2 monoOutput:1 rgbOutput:0 alphaSource:0
--opacityTextureBitmap.monoOutput = 1
pmMat = standard name:matName diffuseMap:diffuseTextureBitmap opacityMap:opacityTextureBitmap showInViewport:true
) else (
pmMat = standard name:matName diffuseMap:diffuseTextureBitmap showInViewport:true
)
if pmMat != undefined then (--#standard
pmMat.twoSided = theMap.chk2Sides.checked
pmMat.selfIllumAmount = theMap.spnIullmination.value
return pmMat
) else
return undefined
)
on chkGlobalSP changed stat do (
if hasMaterial then (
if stat then (
theMaterial.samplerUseGlobal = true
chkLocalSP.enabled = false
chkGlobalSP.checked = true
--chkLocalSP.changed false
) else (
theMaterial.samplerUseGlobal = false
chkLocalSP.enabled = true
chkGlobalSP.checked = false
)
)
)
on chkLocalSP changed stat do (
if hasMaterial then (
if stat then (
theMaterial.samplerEnable = true
theMaterial.sampler = 3
chkLocalSP.checked = true
) else (
theMaterial.samplerEnable = false
chkLocalSP.checked = false
)
)
)
on theMap open do (
if hasMaterial then (
btnOpnImg.caption = ImgName
theMaterial = selection[1].material
origPos = selection[1].pos
chkLocalSP.checked = theMaterial.samplerEnable
chkGlobalSP.checked = theMaterial.samplerUseGlobal
if chkGlobalSP.checked then chkLocalSP.enabled = false
)
)
on chkShowImg changed val do (
if val and theMaterial != undefined then (
selection[1].material = theMaterial
hasMaterial = true
btnOpnImg.caption = ImgName
) else (
selection[1].material = undefined
hasMaterial = false
)
)
on chkConstrainProp changed val do (
if val then (
dimensionRatio = Height / Width
selection[1].theMap.chkConstrainProp.checked = true
selection[1].params.chkMainConstrainProp.checked = true
) else (
dimensionRatio = 1
selection[1].theMap.chkConstrainProp.checked = false
selection[1].params.chkMainConstrainProp.checked = false
)
)
on btnOpnImg pressed do (
local tmpPos = selection[1].pos
origPos = tmpPos
theBitmap = selectBitMap caption:"Open A BitMap File:"
if theBitmap != undefined then (
ImgFilePath = theBitmap.filename
theMaterial = getMaterial theBitmap
if chkLocalSP.checked then (
theMaterial.samplerEnable = true
theMaterial.sampler = 3
) else theMaterial.samplerEnable = false
if chkGlobalSP.checked then theMaterial.samplerUseGlobal = true
else theMaterial.samplerUseGlobal = false
selection[1].material = theMaterial
ImgName = filenameFromPath theBitmap.filename
btnOpnImg.caption = ImgName
params.spnHeight.value = ( Width / theBitmap.width ) * theBitmap.height
dimensionRatio = Height / Width
ShowImg = true
hasMaterial = true
)
selection[1].pos = origPos
)
on btnOpnAlpha pressed do (
theBitmap = selectBitMap caption:"Open A BitMap File:"
if theBitmap != undefined then (
ImgFilePath = theBitmap.filename
theMaterial = getMaterial theBitmap
selection[1].material = theMaterial
ImgName = filenameFromPath theBitmap.filename
btnOpnImg.caption = ImgName
params.spnHeight.value = ( Width / theBitmap.width ) * theBitmap.height
dimensionRatio = Height / Width
ShowImg = true
hasMaterial = true
)
)
)
rollout theTime "Time" (
spinner spnStartFr "Start frame : " type:#integer range:[-65536,65536,0] width:108 align:#right
spinner spnPlayBack "PlayBack Rate: " type:#float width:120 align:#right
radiobuttons radCond "" labels:#("Loop","Ping Pong","Hold") columns:2 align:#center
on spnStartFr changed val do (
theMaterial.diffuseMap.starttime = val
if theMaterial.opacityMap != undefined do theMaterial.opacityMap.starttime = val
)
on spnPlayBack changed val do (
theMaterial.diffuseMap.playBackRate = val
theMaterial.opacityMap.playBackRate = val
)
on radCond changed stat do (
theMaterial.diffuseMap.endCondition = stat - 1
theMaterial.opacityMap.endCondition = stat - 1
)
on theTime open do (
local tmpObj = selection[1]
if theMaterial != undefined and tmpObj.material != undefined and tmpObj.material.diffuseMap != undefined do (
spnStartFr.value = tmpObj.material.diffuseMap.starttime
spnPlayBack.value = tmpObj.material.diffuseMap.playBackRate
radCond.state = tmpObj.material.diffuseMap.endCondition + 1
)
)
)
rollout aboutAuthor "About the Author" (
hyperLink linkHTTP "http://andye.idv.tw/" hoverColor:yellow align:#center address:"http://andye.idv.tw/"
)
on clone orig do (
dimensionRatio = 1
)
on load do (
stat = 0
)
on postcreate do format "created: %\n" this
on postLoad do (
stat = 2
)
tool create (
on mousePoint clickno do (
if clickno == 1 then (
stat = 1--#CREATING
origPos = gridPoint--worldPoint
delegate.width = 20
delegate.length = 0
coordsys local selection[1].rotation = eulerangles -90 0 0
RotatePivotOnly selection[1] (eulerangles -90 0 0)
) else if clickno == 3 then (
max modify mode
params.spnHeight.value = delegate.length
params.spnWid.value = delegate.width
origSize = [delegate.length ,delegate.width]
stat = 2--#CREATED
#stop
)
)
on mouseMove clickno do (
if clickno == 3 then (
if pivotPos == 1 then (
delegate.length = (abs worldDist.z)
selection[1].pivot.z = selection[1].min.z
) else (
delegate.length = (abs worldDist.z) * 2
)
) else if clickno == 2 then (
if pivotPos == 1 do selection[1].pivot.z = selection[1].min.z
delegate.width = sqrt((pow worldDist.x 2) + (pow worldDist.y 2)) * 2 -- (distance origPos gridDist) * 2
nodeTM.rotation = eulerangles 0 0 (gridangle[3] )
nodeTM.translation = origPos
)
)
)
)