Virtual GI

can anybody help me i am trying to use the Virtual GI script on the following address (http://www.scriptspot.com/3ds-max/virtual-gi) but when i try to run it it comes up with an error (--syntax error: at bad, expected
-- in line: Rar!

I think it is the format of the script (.rar) but i could not find any other format.

Josiah

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Michele71's picture

Copy and paste the script in

Copy and paste the script in MaxScript Editor and run.
It work well to me in Max 9/2008/2009/2010
-----------------------------------------------------------

(
axis_angle = 0
axisX = 0
axisY = 0
axisZ = 0

if isValidNode objects and (objects != undefined) then
(
axis_angle = (objects.rotation as angleAxis).angle
vgi.spn5.value = axis_angle
)

fn geometry_filt obj = superclassof obj == Geometryclass

rf = newRolloutFloater "Virtual GI v.0.2" 398 490

rollout vgi "Setting Virtual GI" width:384 height:440 category:1
(

global sp, c, li, lig, li_Ta, objpos, centerobj, L, W, H, sel_a, se_li

GroupBox grp1 "Setting Preview Sky Light" pos:[8,8] width:368 height:296
Pickbutton btn1 "Select Object" pos:[24,56] width:120 height:24
button btn2 "Create Preview Sphere" pos:[24,88] width:120 height:24 enabled:false toolTip:"Create sphere for reference"
button btn3 "Delete Preview Sphere" pos:[24,120] width:120 height:24 enabled:false
spinner spn1 "Scale Sphere" pos:[88,176] width:56 height:16 enabled:false range:[0,1e+009,1] type:#float scale:0.01
spinner spn2 "N_Vertex Lights" pos:[88,152] width:56 height:16 enabled:false range:[4,100,4] type:#integer
GroupBox grp2 "Setting SL" pos:[16,32] width:136 height:168
GroupBox grp3 "Create SL" pos:[16,208] width:136 height:88
button btn4 "Create Sky Light" pos:[24,232] width:120 height:24 enabled:false
button btn5 "Delete All Sky Light" pos:[24,264] width:120 height:24
bitmap bmp1 "Bitmap" bitmap:(bitmap 184 104) pos:[168,152] width:184 height:104
button btn7 "Quick Render Preview" pos:[176,264] width:168 height:24
listbox lbx1 "Quick Select/Setting LS" items:(for i in lights collect i.name) pos:[168,48] width:184 height:3
button btn6 "Refresh List SL" pos:[176,120] width:168 height:24
GroupBox grp4 "List/Preview SL" pos:[160,24] width:200 height:272
GroupBox grp5 "Setting Quick Virtual Sun" pos:[8,312] width:368 height:120
button btn8 "Select All Obj Scene" pos:[24,360] width:136 height:24
GroupBox grp6 "Create VS" pos:[16,336] width:152 height:88
button btn9 "Create Orbital Sun" pos:[24,392] width:136 height:24 enabled:false
spinner spn3 "Virtual Hours " range:[1,24,12] type:#integer pos:[256,352] width:56 height:16 enabled:false
GroupBox grp7 "Adjust Scale/Angle/Hours VS" pos:[176,328] width:152 height:96
spinner spn4 "Scale Orbital % " pos:[248,376] width:64 height:16 range:[0,1e+009,1] scale:0.001 enabled:false
spinner spn5 "Angle Orbital " pos:[248,400] width:64 height:16 range:[0,48.632,0] type:#float enabled:false
button btn10 "QS" pos:[336,344] width:32 height:72 enabled:false

--- Start crete reference sphere ---------------------------------------------------------------------------------------------------------

on btn1 picked obj do
(
btn2.enabled = true
btn3.enabled = true

if obj != undefined do
(
btn1.text = obj.name
objpos= obj.pos
centerobj = centerpivot obj
objselect = select obj
)
)

on btn2 pressed do
(

L = $.max.x - $.min.x
W = $.max.y - $.min.y
H = $.max.z - $.min.z

if L > W AND L > H then
(
SceneSize = L
)
else if W > H then
(
SceneSize = W
)
else
(
SceneSize = H
)

--- End --------------------------------------------------------------------------------------------------------

sp = Sphere pos:objpos radius:(SceneSize*3.14) segs:4 renderable:false
sp.name = uniquename "PreviewSkySphere"

sp.material = StandardMaterial opacity:0

spn1.enabled = true
spn1.value = 1.0

spn2.enabled = true
spn2.value = 4
btn4.enabled = true
btn5.enabled = true

)

on btn3 pressed do
(
btn2.enabled = false
btn3.enabled = false
btn4.enabled = false
spn1.enabled = false
spn2.enabled = false

delete sp

)

on spn1 changed val do sp.scale = [val,val,val]
on spn2 changed val do sp.segs = val

on btn4 pressed do
(
if querybox "This's action destroy preview Sphere. Are you sure to Continue?" title:"Virtual GI message" then
(
spn1.enabled = false
spn2.enabled = false
btn2.enabled = false
btn3.enabled = false
btn4.enabled = false
-- This code was originally generated by Borislav 'Bobo' Petrov" after a my request for help
-- The code below is a stripped down version of Borislav 'Bobo' Petrov" original function with more changed.

lig = TargetDirectionallight position:[0,200,0] rgb:(color 222 227 255) multiplier:0.1 overShoot:true affectSpecular:off
lig_Ta =Targetobject pos:objpos

select lig
select sp
convertToMesh sp
tM = snapshotAsMesh sp

for V= 1 to tM.numVerts do

(
TargetDirectionallight_instance = copy lig
TargetDirectionallight_instance.name = uniquename "LightsSky_"
TargetDirectionallight_instance.target = lig_Ta
TargetDirectionallight_instance.pos = getVert tM v
TargetDirectionallight_instance.parent = lig_Ta
)

delete tM
delete lig
delete sp

--- end--------------------------------------------------------------------------------------------------------

seli_array = $lights* as array

lbx1.items = for i in lights collect i.name
)

)

on btn5 pressed do
(
btn4.enabled = false

if querybox "This's action delete ALL LightsSky. Are you sure to Continue?" title:"Virtual GI message" then
(
delete $lights* as string
delete $Target*
lbx1.items = for i in $lights* collect i.name
)
)

--- End create reference sphere -----------------------------------------------------------------------------

---Start List/Preview Sl --------------------------------------------------------------------------------------

on btn7 pressed do
(
rend_image = render outputsize:[184, 104] vfb:off
bmp1.bitmap = rend_image
)
on lbx1 selected nameIndex do
(
se_li = select (getnodebyname lbx1.items[nameIndex ])
)
on lbx1 doubleClicked itm do

(

rollout qsl "Quick Setting Sky Lights" width:160 height:386
(

GroupBox grp9 "General Parameters" pos:[8,8] width:144 height:320
checkbox chk1 "On" pos:[16,32] width:40 height:16 checked:$.enabled
GroupBox grp10 "Shadows" pos:[16,72] width:128 height:120
checkbox chk2 "On" pos:[24,96] width:40 height:16 checked:$.baseObject.castShadows
radiobuttons rdo1 "" pos:[32,120] width:101 height:64 labels:#("Mental Ray Map", "Area", "Map", "Ray Traced") default:4 columns:1
checkbox chk8 "Global Sett." pos:[64,96] width:72 height:16 checked:$.useGlobalShadowSettings
spinner spn9 "Multiplier " pos:[72,32] width:72 height:16 range:[0,1e+009,$.multiplier] type:#float scale:0.01
colorPicker cp1 "" pos:[8,56] width:136 height:8 default:(color 222 227 255) color:$.rgb
checkbox chk3 "OverShoot" pos:[16,200] width:72 height:16 checked:$.overShoot default:true
checkbox chk4 "Diffuse" pos:[16,232] width:56 height:16 checked:$.affectDiffuse default:true
checkbox chk5 "Specular" pos:[80,232] width:64 height:16 checked:$.affectSpecular default:false
checkbox chk6 "Ambient Only" pos:[16,248] width:80 height:16 checked:$.ambientOnly default:false
checkbox chk7 "Map Projector Lights" pos:[16,280] width:128 height:16 checked:$.projector default:false
mapButton btn26 "None" pos:[16,296] width:128 height:24 map: $.projectorMap
checkbutton cb "Name Ligths Selected" pos:[24,336] width:116 height:16
button btn27 "Close" pos:[24,360] width:116 height:16

on cb changed state do

if state == on then cb.text = $.name as string
else cb.text = "Name Ligths Selected"

on chk1 changed state do
(
if state == on then $.enabled = on
else
$.enabled = off
)
on chk2 changed state do
(
if state == on then $.baseObject.castShadows = true
else
$.baseObject.castShadows= false
)
on rdo1 changed state do
(
if state == 1 do $.shadowGenerator = mental_ray_Shadow_Map ()
if state == 2 do $.shadowGenerator = Area_Shadows ()
if state == 3 do $.shadowGenerator = shadowMap()
if state == 4 do $.shadowGenerator = raytraceShadow ()
)
on chk8 changed state do
(
if state == on then $.useGlobalShadowSettings = true
else
$.useGlobalShadowSettings = false
)
on spn9 changed val do $.multiplier = val

on cp1 changed nc do $.rgb = nc

on chk3 changed state do
(
if state == on then $.overShoot =true
else
$.overShoot= false
)
on chk4 changed state do
(
if state == on then $.affectDiffuse = true
else
$.affectDiffuse= false
)
on chk5 changed state do
(
if state == on then $.affectSpecular = true
else
$.affectSpecular= false
)

on chk6 changed state do
(
if state == on then
(
$.ambientOnly = true

)
else
$.ambientOnly= false

)

on chk7 changed state do
(
if state == on then $.projector = true
else
$.projector = false
)
on btn26 picked texmap do
(
$.projectorMap = texmap

btn26.text=classof texmap as string
)
on btn27 pressed do
(
destroydialog qsl
clearSelection()
)

)
destroydialog qsl
createdialog qsl
)

on btn6 pressed do lbx1.items = for i in lights collect i.name

---End List/Preview Sl ---------------------------------------------------------------------------------------

---Start Quick Virtual Sun ----------------------------------------------------------------------------------

on btn8 pressed do
(
max select all
btn9.enabled = true
)

on btn9 pressed do
(
L = $.max.x - $.min.x
W = $.max.y - $.min.y
H = $.max.z - $.min.z

if L > W AND L > H then
(
SceneSize = L
)
else if W > H then
(
SceneSize = W
)
else
(
SceneSize = H
)

c = Cylinder sides:24 height:100 radius:(SceneSize*3.14) pos:[0,0,0] renderable:false
c.name = "Circle Orbital"
rot_X= eulerangles 175.469 24.134 79.031
rotate c rot_X
mat = StandardMaterial()
c.material = mat
mat.opacity = 0
convertTo c PolyMeshObject
c.SetSelection #Face #{1..24, 26}
c.EditablePoly.delete #Face
c.EditablePoly.SetSelection #Face #{1}
c.EditablePoly.flipNormals 1
c.EditablePoly.SetSelection #Face #{1}
clearSelection()

co = Compass pos:[0,0,0]
co.scale = [10,10,10]

li = TargetDirectionallight color:(color 255 242 229) multiplier:63.084 castShadows:on \
raytraceShadow:on overshoot:on coneShape:1 target:(Targetobject transform:(matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0]))
li.name = uniquename "VirtualSun"

sv = c.selectedVerts = #(12)
sv_pos = c.verts[12].pos
c.verts[23].pos as string

li.pos = sv_pos
li.parent = c
li.target.parent = co
c.parent = co
btn9.enabled = false
btn10.enabled = true
spn3.enabled = true
spn4.enabled = true
spn5.enabled = true
)

on spn3 changed val do
(
if val == 1 then li.pos = c.verts[1].pos
if val == 2 then li.pos = c.verts[2].pos
if val == 3 then li.pos = c.verts[3].pos
if val == 4 then li.pos = c.verts[4].pos
if val == 5 then li.pos = c.verts[5].pos
if val == 6 then li.pos = c.verts[6].pos
if val == 7 then li.pos = c.verts[7].pos

if val == 8 then li.pos = c.verts[8].pos
if val == 9 then li.pos = c.verts[9].pos
if val == 10 then li.pos = c.verts[10].pos
if val == 11 then li.pos = c.verts[11].pos
if val == 12 then li.pos = c.verts[12].pos
if val == 13 then li.pos = c.verts[13].pos

if val == 14 then li.pos = c.verts[14].pos
if val == 15 then li.pos = c.verts[15].pos
if val == 16 then li.pos = c.verts[16].pos
if val == 17 then li.pos = c.verts[17].pos
if val == 18 then li.pos = c.verts[18].pos
if val == 19 then li.pos = c.verts[19].pos
if val == 20 then li.pos = c.verts[20].pos

if val == 21 then li.pos = c.verts[21].pos
if val == 22 then li.pos = c.verts[22].pos
if val == 23 then li.pos = c.verts[23].pos
if val== 24 then li.pos = c.verts[24].pos

)

on spn4 changed val do
(
c.Scale= [val,val,val]
)

on spn5 changed val do
(

adjust_angle = (vgi.spn5.value - axis_angle)
rotate c (angleaxis adjust_angle [-1,0,0])
axis_angle = spn5.value
)

on btn10 pressed do
(
select li
rollout vst "Quick Setting Virtual Sun" width:328 height:470
(

GroupBox grp_vts "Sun General Setting" pos:[8,8] width:312 height:450
dropdownList ddl1 "" pos:[64,96] width:112 height:21 items:#("MentalRay", "Area", "Map","RayTraced") selection:4
checkbox onsha "On" pos:[64,72] width:32 height:16 checked:li.baseObject.castShadows

GroupBox grpgp "Base Parameters" pos:[16,32] width:176 height:104
GroupBox grps "Shadows" pos:[56,48] width:128 height:80
spinner smul "Multiplier" pos:[56,168] width:68 height:16 range:[1,10000,li.multiplier] type:#float
checkbutton btonoff "On" pos:[20,72] width:32 height:40 checked:li.enabled
checkbox ongs "Global Sett." pos:[104,72] width:72 height:16 checked:li.useGlobalShadowSettings
GroupBox grpica "Intensity Color Attenuation" pos:[16,144] width:176 height:96
colorPicker col "" pos:[130,160] width:50 height:40 defsault:(color 255 242 229) color:li.rgb
dropdownList ddec "Decay" pos:[24,192] width:80 height:40 items:#("---", "Inverse", "Inverse Square" ) selection:li.attenDecay
spinner spn9 "Start " pos:[124,210] width:64 height:16 range:[0,999999,li.DecayRadius] type:#float

GroupBox grpdir "Directional" pos:[200,24] width:112 height:216
checkbox chk17 "OverShoot" pos:[208,48] width:72 height:16 checked:li.overShoot
dropdownList ddl10 "" pos:[208,152] width:96 height:21 items:#("Circle", "Rectangle" ) selection:li.coneShape
spinner spn10 "Aspect " pos:[232,184] width:72 height:16 range:[0.001,100,li.aspect] type:#float
button bmfit "Sun View" pos:[208,208] width:96 height:24
spinner spn11 "HS_Beam " pos:[240,72] width:64 height:16 range:[0.5,4.19791e+008,li.hotspot] type:#float
spinner spn12 "FO_Field " pos:[240,96] width:64 height:16 range:[0.5,4.19791e+008,li.falloff] type:#float
checkbutton shc "Show Cone" pos:[208,120] width:96 height:24

GroupBox grpeff "Effect" pos:[16,248] width:296 height:72
checkbox chk25 "Diffuse" pos:[24,296] width:56 height:16 checked:li.affectDiffuse
checkbox chk26 "Specular" pos:[88,296] width:64 height:16 checked:li.affectSpecular
checkbox chk27 "Ambient" pos:[160,296] width:56 height:16 checked:li.ambientOnly
spinner spn23 "Contrast " pos:[256,296] width:52 height:16 range:[0,100,li.contrast] type:#float
spinner spn24 "Soft Edge " pos:[232,272] width:76 height:16 range:[0,100,li.softenDiffuseEdge] type:#float
checkbox chk28 "Map = " pos:[24,272] width:48 height:16 checked:li.projector
mapbutton btmap1 "---" pos:[80,272] width:104 height:16

GroupBox grpshad "Shadow" pos:[16,328] width:296 height:96
checkbox chk29 "Map = " pos:[24,344] width:48 height:16 checked:li.useShadowProjectorMap
mapbutton btmap2 "---" pos:[80,344] width:72 height:16
checkbox chk30 "Affects Color Shadows" pos:[24,368] width:128 height:16 checked:li.lightAffectsShadow
colorPicker cp10 "" pos:[160,344] width:144 height:16 default:(color 0 0 0) color:li.ShadowColor
spinner spn25 "Density " pos:[214,368] width:70 height:16 range:[-10000,10000,li.shadowMultiplier] type:#float
checkbutton ckb8 "On" pos:[24,392] width:48 height:24 checked: on
spinner spn26 "Opacity " pos:[104,392] width:64 height:16 range:[0,100,li.atmosOpacity] type:#float
spinner spn27 "Amount Color " pos:[220,392] width:84 height:16 range:[0,100,li.atmosColorAmt] type:#float
button clos "Exit" pos:[20,430] width:288 height:22

-----------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------

on ddl1 selected i do
(
if i == 1 do li.shadowGenerator = mental_ray_Shadow_Map ()
if i == 2 do li.shadowGenerator = Area_Shadows ()
if i == 3 do li.shadowGenerator = shadowMap()
if i == 4 do li.shadowGenerator = raytraceShadow ()

)

on onsha changed state do
(
if state == on then li.baseObject.castShadows = true
else
li.baseObject.castShadows= false

)

on ongs changed state do
(
if state == on then li.useGlobalShadowSettings = true
else
li.useGlobalShadowSettings = false
)

on btonoff changed state do
(
if state == on then
(
li.enabled = on
btonoff.text = "On"
)
else
(
li.enabled = off
btonoff.text = "Off"
)
)

on smul changed val do li.multiplier = val

on col changed nc do li.rgb = nc

on ddec selected i do
(
if i == 1 do li.attenDecay = 1
if i == 2 do li.attenDecay = 2
if i == 3 do li.attenDecay = 3
)

on spn9 changed val do li.DecayRadius = val

on chk17 changed state do
(
if state == on then li.overShoot =true
else
li.overShoot= false
)

on spn11 changed val do li.hotspot = val

on spn12 changed val do li.falloff = val

on shc changed state do
(
if state == on then li.showCone = true
else
li.showCone = false
)

on ddl10 selected i do
(

if i == 1 do
(
li.coneShape = 1

)
if i ==2 do
(
li.coneShape = 2

)
)

on spn10 changed val do li.aspect = val

on chk25 changed state do
(
if state == on then li.affectDiffuse = on
else
li.affectDiffuse = off

)

on chk26 changed state do
(
if state == on then li.affectSpecular = on
else
li.affectSpecular = off

)

on chk27 changed state do
(
if state == on then
(
li.ambientOnly = on
)
else
(
li.ambientOnly = off
)
)

on chk28 changed state do
(
if state == on then
(
li.projector = true

)
else
(
li.projector = false

)
)

on btmap1 picked texmap do
(
li.projectorMap = texmap
btmap1.text=classof texmap as string
chk28.checked = on
)

on spn23 changed val do li.contrast=val
on spn24 changed val do li.softenDiffuseEdge = val

on chk29 changed state do
(
if state == on then
(
li.useShadowProjectorMap = true

)
else
(
li.useShadowProjectorMap = false

)
)

on btmap2 picked texmap do
(
li.ShadowProjectorMap = texmap
btmap2.text=classof texmap as string
chk29.checked = on
li.useShadowProjectorMap = true
)

on spn25 changed val do li.shadowMultiplier = val

on chk30 changed state do
(
if state == on then li.lightAffectsShadow = true
else
li.lightAffectsShadow = false
)

on cp10 changed nc do li.ShadowColor=nc

on ckb8 changed state do
(
if state == on then
(
li.atmosShadows=on
ckb8.text = "On"
)
else
(
li.atmosShadows=off
ckb8.text = "Off"
)
)

on spn26 changed val do li.atmosOpacity =val
on spn27 changed val do li.atmosColorAmt = val

on bmfit pressed do
(
macros.run "Lights and Cameras" "Light_ActivateView"
)

on clos pressed do
(
destroydialog vst
)

)
createdialog vst

)

---End Quick Virtual Sun ----------------------------------------------------------------------------------

)

rollout _info "About" width:208 height:186 category:2
(

label _0 "Virtual GI v.0.2"
label _1 "by Michele71"
label _2 "Create for 3DSMax 9 / 2008 / 2009"
label _3 "release 2-23-2009"
label _4 "[email protected]"

)

addrollout vgi rf
addrollout _info rf rolledUp:True
)

-------------------------------------------------------
Enjoy!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.