[Closed] Material plugin questions
Hey guys,
I started a new material plugin that extends the standard material. I added a few things and took away a lot of others to make it easier and more simplistic for my needs. But I ran into a few problems I could really use help with,
1.In the slate editor how can I change the names of the map node to be something like “Diffuse Map” instead of my variable name difMap?
2.How do I change the material name type to be “New Material” instead of newMat?
3.Why is there a weird space after my check boxes? How can I get rid of it?
4.How do I work with the UI events, like when checking a check box or using the map button? I tried it a few times in a few different places of my code but couldn’t get it to work.
plugin material NewMat
name:"New Material"
classID:#(694625,446546)
extends:Standard replaceUI:true version:1
(
parameters main rollout:matParams
(
emiCol type:#color default:black ui:emiCol
difcol type:#color default:gray ui:difCol
glossSpn type:#float default:40 ui:glossSpn
opacitySpn type:#float default:100 ui:opacitySpn
metallicChk type:#boolean default:False ui:metallicChk
stencilChk type:#boolean default:False ui:stencilChk
nameChk type:#boolean default:False ui:NameChk
nameTxt type:#string ui:nameTxt
on difCol set val do delegate.diffuse_color = val
on emiCol set val do delegate.ambient_color = val
on opacitySpn set val do delegate.opacity = val
on glossSpn set val do delegate.glossiness = val
on nameChk changed state do
(
print "NameChk Used"
nameTxt.enable = state
)
)
parameters main rollout:mapParams
(
difMapChk type:#boolean default:False ui:difMapChk
difMap type:#texturemap ui:difMap
nrmMapChk type:#boolean default:False ui:nrmMapChk
nrmMap type:#texturemap ui:nrmMap
glsMapChk type:#boolean default:False ui:glsMapChk
glsMap type:#texturemap ui:glsMap
opcMapChk type:#boolean default:False ui:opcMapChk
opcMap type:#texturemap ui:opcMap
emiMapChk type:#boolean default:False ui:emiMapChk
emiMap type:#texturemap ui:emiMap
on difMapChk set val do delegate.diffuseMapEnable = val
on nrmMapChk set val do delegate.bumpMapEnable = val
on glsMapChk set val do delegate.glossinessMapEnable = val
on opcMapChk set val do delegate.opacityMapEnable = val
on emiMapChk set val do delegate.ambientMapEnable = val
on difMap set val do delegate.diffuseMap = val
on nrmMap set val do delegate.bumpMap = val
on glsMap set val do delegate.glossinessMap = val
on opcMap set val do delegate.opacityMap = val
on emiMap set val do delegate.ambientMap = val
)
rollout matParams "Parameters"
(
colorpicker difCol "Diffuse: " fieldwidth:50 across:3 align:#left offset:[6,10]
mapButton difMapUpper "" tooltip:"Select Diffuse Map" width:17.5 height:17.5 offset:[-30,12.5]
spinner glossSpn "Glossiness: " fieldwidth:45 align:#right offset:[-20,10]
colorpicker emiCol "Emissive: " fieldwidth:50 across:3 align:#left offset:[0,0]
mapButton emiMapUpper "" tooltip:"Select Emissive Map" width:17.5 height:17.5 offset:[-30,2.5]
spinner opacitySpn "Opacity: " fieldwidth:45 align:#right offset:[-20,-5]
label metallicLbl "Metallic" across:4 align:#right offset:[145,-10]
checkbox metallicChk align:#right offset:[95,-10]
label stencilLbl "Stencil" align:#right offset:[45,-10]
checkbox stencilChk align:#right offset:[-5,-10]
checkbox nameChk across:2 align:#left offset:[0,10]
editText nameTxt "Name:" align:#left fieldWidth:225 height:15 offset:[-130,10]
groupBox swatches "" pos:[5,5] width:165 height:75
groupBox values "" pos:[175,5] width:165 height:75
)
rollout mapParams "Maps"
(
checkbox difMapChk "Diffuse Map... " across:2 alight:#left
mapButton difMap "" tooltip:"Select Diffuse Map" width:150
checkbox nrmMapChk "Normal Map... " across:2 alight:#left
mapButton nrmMap "" tooltip:"Select Normal Map" width:150
checkbox glsMapChk "Gloss Map... " across:2 alight:#left
mapButton glsMap "" tooltip:"Select Gloss Map" width:150
checkbox opcMapChk "Opacity Map... " across:2 alight:#left
mapButton opcMap "" tooltip:"Select Opacity Map" width:150
checkbox emiMapChk "Emissive Map... " across:2 alight:#left
mapButton emiMap "" tooltip:"Select Emissive Map" width:150
on difMap picked texmap do
(
print "Difmap Used"
difMap.text=classof texmap as string
)
)
on create do
(
-- setup initial material
)
)
Thanks in advance!
1.- mapButton difMapUpper “Diffuse Map” tooltip:“Select Diffuse Map” width:17.5 height:17.5 offset:[-30,12.5]
2.- plugin material D3MIG0D_Material (for example)
3.- use offset:[-xxx,0] in the buttons and checkers definition (but I don’t know what you mean with the ‘weird spaces’)
4.- Inside the rollouts definitions, use event handlers as ‘on difMapChk changed val do’
Thanks for the response.
I’m not sure if I’m using the wrong terminology here so to clarify I highlighted the things I’m talking about in the image:
1.This is the node name I was talking about. It seems to change when I change the name of the difMap variable, but as its a name I couldn’t name it something like “Diffuse Map” as that’s not a viable variable name. So my question is how can I change the name that displays on the node?
-
This is the Material name I was talking about. I tried New_Mat as you suggested but that just results with it display “New_Mat” and not the “New Mat” with the space I am looking for. How can I change the name that displays here?
-
I drew arrows showing the weird spaced I was talking about. It seems like the checkbox has a grey spacing around it that overlaps my labels like “Name” and “Stencil.” As you can see from those labels, there is a gray box cutting off some of the text. Is this something I have to deal with by just spacing the checkbox more? Or is this some issue of defining a width? Or something else I’m missing?
4.I managed to get the event handlers working for the checkbox but I’m having problems with the map button. In the code I posted earlier I have the “on DifMap picked texmap do”
commented out because it wasn’t working. But from what I understand about the check box handler, shouldn’t this work? It doesn’t run into any errors it just skips right over it. What am I doing wrong?
Thanks
Anyone have any thoughts? Or am I being unclear or wrong about something? Or am I going about this plugin the wrong way?