-------------------- Input properties
property nolighting : false
property numberOfMaterials : 324
property materialsOnly : false
property batchStartNum : 0
--------------------
set batchnum to batchStartNum
set theOut to ""
repeat
set counter to -1
set colour to -1
set themat to ""
set thingToChange to (choose from list {"ambient", "diffuse", "emission", "specular", "shininess"} with prompt "Property to change") as string
if thingToChange is not "shininess" then
repeat
set colourstart1 to the text returned of (display dialog "Red Chan start" default answer 0)
if colourstart1 is greater than or equal to 0 and colourstart1 is less than or equal to 1 then exit repeat
display dialog "Needs to be between 0 and 1"
end repeat
repeat
set colourstart2 to the text returned of (display dialog "Green Chan start" default answer 0)
if colourstart2 is greater than or equal to 0 and colourstart2 is less than or equal to 1 then exit repeat
display dialog "Needs to be between 0 and 1"
end repeat
repeat
set colourstart3 to the text returned of (display dialog "Blue Chan start" default answer 0)
if colourstart3 is greater than or equal to 0 and colourstart3 is less than or equal to 1 then exit repeat
display dialog "Needs to be between 0 and 1"
end repeat
repeat
set colourend1 to the text returned of (display dialog "Red Chan end" default answer 1)
if colourend1 is greater than or equal to 0 and colourend1 is less than or equal to 1 then exit repeat
display dialog "Needs to be between 0 and 1"
end repeat
repeat
set colourend2 to the text returned of (display dialog "Green Chan end" default answer 1)
if colourend2 is greater than or equal to 0 and colourend2 is less than or equal to 1 then exit repeat
display dialog "Needs to be between 0 and 1"
end repeat
repeat
set colourend3 to the text returned of (display dialog "Blue Chan end" default answer 1)
if colourend3 is greater than or equal to 0 and colourend3 is less than or equal to 1 then exit repeat
display dialog "Needs to be between 0 and 1"
end repeat
if thingToChange is not "diffuse" then
repeat
set diff1 to the text returned of (display dialog "Red Chan diffuse constant" default answer 0.5)
if diff1 is greater than or equal to 0 and diff1 is less than or equal to 1 then exit repeat
display dialog "Needs to be between 0 and 1"
end repeat
repeat
set diff2 to the text returned of (display dialog "Green Chan diffuse constant" default answer 0.5)
if diff2 is greater than or equal to 0 and diff2 is less than or equal to 1 then exit repeat
display dialog "Needs to be between 0 and 1"
end repeat
repeat
set diff3 to the text returned of (display dialog "Blue Chan diffuse constant" default answer 0.5)
if diff3 is greater than or equal to 0 and diff3 is less than or equal to 1 then exit repeat
display dialog "Needs to be between 0 and 1"
end repeat
end if
else
repeat
set colourstart1 to the text returned of (display dialog "Shininess start" default answer 0)
if colourstart1 is greater than or equal to 0 and colourstart1 is less than or equal to 128 then exit repeat
display dialog "Needs to be between 0 and 128"
end repeat
repeat
set colourend1 to the text returned of (display dialog "Shininess end" default answer 128)
if colourend1 is greater than or equal to 0 and colourend1 is less than or equal to 128 then exit repeat
display dialog "Needs to be between 0 and 128"
end repeat
if thingToChange is not "diffuse" then
repeat
set diff1 to the text returned of (display dialog "Red Chan diffuse constant" default answer 0.5)
if diff1 is greater than or equal to 0 and diff1 is less than or equal to 1 then exit repeat
display dialog "Needs to be between 0 and 1"
end repeat
repeat
set diff2 to the text returned of (display dialog "Green Chan diffuse constant" default answer 0.5)
if diff2 is greater than or equal to 0 and diff2 is less than or equal to 1 then exit repeat
display dialog "Needs to be between 0 and 1"
end repeat
repeat
set diff3 to the text returned of (display dialog "Blue Chan diffuse constant" default answer 0.5)
if diff3 is greater than or equal to 0 and diff3 is less than or equal to 1 then exit repeat
display dialog "Needs to be between 0 and 1"
end repeat
end if
end if
if thingToChange is "shininess" then
repeat
set spec1 to the text returned of (display dialog "Red Chan specular constant" default answer 0.5)
if spec1 is greater than or equal to 0 and spec1 is less than or equal to 1 then exit repeat
display dialog "Needs to be between 0 and 1"
end repeat
repeat
set spec2 to the text returned of (display dialog "Green Chan specular constant" default answer 0.5)
if spec2 is greater than or equal to 0 and spec2 is less than or equal to 1 then exit repeat
display dialog "Needs to be between 0 and 1"
end repeat
repeat
set spec3 to the text returned of (display dialog "Blue Chan specular constant" default answer 0.5)
if spec3 is greater than or equal to 0 and spec3 is less than or equal to 1 then exit repeat
display dialog "Needs to be between 0 and 1"
end repeat
end if
set theBoxes to ""
set posx to -400
set posy to -360
if nolighting is true then
set nolightingX to "
nolighting"
else
set nolightingX to ""
end if
set colourstart1X to colourstart1
set colourstart2X to colourstart2
set colourstart3X to colourstart3
repeat numberOfMaterials times
if colourstart1X is less than colourend1 then
set colourstart1 to colourstart1 + (colourend1 / numberOfMaterials)
else
set colourstart1 to colourstart1 - ((colourstart1X - colourend1) / numberOfMaterials)
end if
if thingToChange is not "shininess" then
if colourstart2X is less than colourend2 then
set colourstart2 to colourstart2 + (colourend2 / numberOfMaterials)
else
set colourstart2 to colourstart2 - ((colourstart2X - colourend2) / numberOfMaterials)
end if
end if
if thingToChange is not "shininess" then
if colourstart3X is less than colourend3 then
set colourstart3 to colourstart3 + (colourend3 / numberOfMaterials)
else
set colourstart3 to colourstart3 - ((colourstart3X - colourend3) / numberOfMaterials)
end if
end if
set counter to counter + 1
if thingToChange is not "diffuse" then
if thingToChange is not "shininess" then
set themat to themat & "
material
name bat" & batchnum & "mat" & counter & "
diffuse " & diff1 & " " & diff2 & " " & diff3 & "
" & thingToChange & " " & colourstart1 & " " & colourstart2 & " " & colourstart3 & nolightingX & "
end"
else
set themat to themat & "
material
name bat" & batchnum & "mat" & counter & "
diffuse " & diff1 & " " & diff2 & " " & diff3 & "
specular " & spec1 & " " & spec2 & " " & spec3 & "
" & thingToChange & " " & colourstart1 & nolightingX & "
end"
end if
else
set themat to themat & "
material
name bat" & batchnum & "mat" & counter & "
" & thingToChange & " " & colourstart1 & " " & colourstart2 & " " & colourstart3 & nolightingX & "
end"
end if
if materialsOnly is false then
set posx to posx + 40
if posx is 360 then set posy to posy + 40
if posx is 360 then set posx to -360
set theBoxes to theBoxes & "
arc
pos " & posx & " " & posy & " " & (15 * batchnum) & "
size 10 10 10
matref bat" & batchnum & "mat" & counter & "
end
"
end if
end repeat
set theOut to theOut & themat & return & return & theBoxes
set batchButton to the button returned of (display dialog "New Batch?" buttons {"Yes", "No"} default button 2) as string
if batchButton is "No" then exit repeat
set batchnum to batchnum + 1
end repeat
tell application "TextEdit"
make new document at front of documents
set the text of the front document to theOut
end tell