Forum Groups
  All forums
    Help & Feedback
      Questions
      Work in progress
      Finished Art
      Non-Max related
    Community
      Offtopic
      News
    Hardware
    Photography


Featured Threads
  inspiration alert!!!
(36 replies)
  Indespensible MaxScripts, Plugins and 3rd Party Tools
(37 replies)
  The allmighty FREE Resources Thread !
(17 replies)
  spam alert!!!
(4886 replies)
  Maxforums member photo gallery index
(114 replies)
  Maxforums Member Tutorials
(89 replies)
  three cheers to maxforums...
(240 replies)
  101 Things you didnt know in Max...
(198 replies)
  A Face tutorial from MDB101 :D
(95 replies)
  Maxforums.org Members Gallery
(516 replies)
  SON OF POST YOURSELF
(637 replies)
  Dub's Maxscript Tutorial Index
(119 replies)

Maxunderground news unavailable

Maxscript spinner value to material
show user profile  3joez
I would like to control a parameter for all materials in the scene.
In the listener I would go with something like that

for mat in scenematerials do
(
meditmaterials[1] = mat
meditmaterials[1].glossiness = 99
)

Now I'm trying an automated rollout but I'm basically stuck on how to store the spinner value and pass it to the specular value, for all scene materials.

(
global mfloat
try closerolloutfloater myfloat catch ()

rollout stmat "Standard materials"
(
spinner spnspec "Specular" range:[0,100,0] type:#integer
on spnspec changed val do
---????----
)

myfloat = newrolloutfloater "Massmaterial" 200 240
addrollout stmat myfloat
)
read 1646 times
9/17/2012 7:28:53 PM (last edit: 9/17/2012 7:28:53 PM)
show user profile  Garp
You don't need to set a material to a slot in the editor to access its properties.
Something like
for mat in scenematerials do mat.glossiness = 99
should do.

For the rollout, just use the same kind of code in the event handler:
on spnspec changed val do
for mat in scenematerials do
mat.specular = val

I don't have access to max right now so check my spelling but it should be close.


edit: from memory I think specular is the color. The value is something like specularlevel.




read 1640 times
9/17/2012 7:40:43 PM (last edit: 9/17/2012 7:59:01 PM)
show user profile  3joez
Works wonders.
Thank you very much.
read 1631 times
9/17/2012 8:25:09 PM (last edit: 9/17/2012 8:25:09 PM)
show user profile  3joez
OK, it's working. I'm now a little bit confused on how to apply a spinner that controls vray reflection.

I'm dealing with rgb values and I'm searching through the help but I'm quite lost. I know the spinner controlled by integers shouldn't work, as in vraymtl properties reflection is linked to RGB values.
The question is should I put an RGB controller?
Why the vraymtl bump doesn't react?

Here's the code

(
global mfloat
try closerolloutfloater myfloat catch ()

rollout stmat "Standard materials"
(
spinner spnspec "Specular" range:[0,100,0] type:#integer
spinner gloss "Glossiness" range:[0,100,0] type:#integer
spinner bump "Bump" range:[0,100,0] type:#integer
on spnspec changed val do
for mat in scenematerials do
mat.specularlevel = val
on gloss changed val do
for mat in scenematerials do
mat.glossiness = val
on bump changed val do
for mat in scenematerials do
mat.bumpmapamount = val

)
rollout vmat "Vray materials"
(
spinner refv "Reflection" range:[0,100,0] type:#integer --? don't know how to behave here ---
on refv changed val do
for vraymtl in scenematerials do
vraymtl.reflection = val
spinner bumpv "Bump" range:[0,100,0] type:#integer
on bumpv changed val do
for vraymtl in scenematerials do
vraymtl.texmap_bump = val
)

myfloat = newrolloutfloater "Massmaterial editor" 200 240
addrollout stmat myfloat
addrollout vmat myfloat
)

read 1624 times
9/17/2012 9:27:34 PM (last edit: 9/17/2012 9:27:34 PM)
show user profile  Garp
Since you're making a bulk change to all the materials in the scene at once, I take it that you ignore their individual values.
The problem is that to modify a color you need a color to start with.
What do you awant your spinner to control?




read 1610 times
9/18/2012 4:29:20 AM (last edit: 9/18/2012 4:29:20 AM)
show user profile  3joez
Yes I want to ignore the initial individual values. I just need the rectangular rgb color selector, as in the vray material, to control the reflection. Usually it is set to black, which means zero, up to white, which is 255. At this point I've put a color picker, so basically the interface is working. The problem is that is not passing the values to the vraymaterials.

Current update

(
global mfloat
try closerolloutfloater myfloat catch ()

rollout stmat "Standard materials"
(
spinner spnspec "Specular" range:[0,100,0] type:#integer
spinner gloss "Glossiness" range:[0,100,0] type:#integer
spinner bump "Bump" range:[0,100,0] type:#integer
on spnspec changed val do
for mat in scenematerials do
mat.specularlevel = val
on gloss changed val do
for mat in scenematerials do
mat.glossiness = val
on bump changed val do
for mat in scenematerials do
mat.bumpmapamount = val

)
--------------Until here it's working ok
rollout vmat "Vray materials"
( ;this section is not making the expected changes
colorpicker refv "Reflection" color:[0,0,0] ;draw a color picker
on refv changed newrefv do ; when detecting color changes
for vraymtl in scenematerials do ;pass it to all vray materials
vraymtl.reflection = newrefv.color.value
spinner bumpv "Bump" range:[0,100,0] type:#integer
on bumpv changed val do
for vraymtl in scenematerials do
vraymtl.texmap_bump = val
)

myfloat = newrolloutfloater "Massmaterial editor" 200 240
addrollout stmat myfloat
addrollout vmat myfloat
)

read 1604 times
9/18/2012 7:34:11 AM (last edit: 9/18/2012 7:34:49 AM)
show user profile  Garp
It's simpler than you think ;)



read 1598 times
9/18/2012 7:53:53 AM (last edit: 9/18/2012 7:53:53 AM)
show user profile  3joez
Perfect.Thanks again.
read 1583 times
9/18/2012 9:35:23 AM (last edit: 9/18/2012 9:35:23 AM)
#Maxforums IRC
Open chat window


Support Maxforums.org