View Full Version : Materials, what are they
Bixel 10-17-2007, 08:37 PM Looking to check what this material is then do some stuff. Im using the wrong functions..hrmm
for i = 1 to MeditMaterials.count do
(
if getMeditMaterial[i] = (Standard) then
(
do some stuff
)
if getMeditMaterial[i] = (Multimaterial) then
(
do some stuff
)
etc.
-----------------------
I thought this might work, but its still wrong
if (finditem meditMaterial[i]) == Standard then
(
)
|
|
PiXeL_MoNKeY
10-17-2007, 08:48 PM
You should use something like:
for i = 1 to MeditMaterials.count do
(
if classof MeditMaterials[i] == (Standard) do
(
do some stuff
)
if classof MeditMaterials[i] == (Multimaterial) do
(
do some stuff
) 1) Meditmaterials is an internal array so you should be searching through that array.
2) = sets a value, while ==, !=, <, >, etc tests between the 2 arguments.
3) You want to test the classof the material since all Materials will be specific to a certain class.
4) Use do in an if statement unless you plan on using the else, ie if ... do (), or if ... then () else ().
-Eric
Bixel
10-17-2007, 09:10 PM
ahh doubly thanks for the explanation of =, ==, if ... do (), or if ... then () else (). That helps alot and gets me thinking ahead on the code.
Bixel
10-18-2007, 09:50 AM
Ok, I want to make some changes to the multi-material, everything in the list. Assuming all the submaterials are going to be standard...
if classof MeditMaterials[sName] == (MultiMaterial) do
(
--theMat = multiMaterial()
--for i = 1 to theMat.materialList do
if classof materialList[i] == (Standard) do
(
white = (color 255 255 255)
materialList[i].diffuseMap = undefined --turn off texture/diffuse mapping
materialList[i].diffuse = white
)
)
its telling me no ==get== function for undefined
i guess I need to re-define the materialList array??
PiXeL_MoNKeY
10-18-2007, 04:39 PM
Again your code is all wrong. First MaterialList is not a class so you need to use the . syntax to add it to a class that the parameter exists. From the Maxscript help:<multimaterial>.materialList ArrayParameter default: #(Standard, Standard, ... Standard, Standard) You have to have something.materialList. In your example MeditMaterials[sName].materialList[i]. The proper code should be:
if classof MeditMaterials[sName] == (MultiMaterial) do
(
for i in 1 to MeditMaterials[sName].MaterialList.count do -- you have to loop through each material in the Multi/Sub Material
(
if classof MeditMaterials[sName].materialList[i] == (Standard) do -- you have to check each material in the Multi/Sub Material
(
white = (color 255 255 255)
MeditMaterials[sName].materialList[i].diffuseMap = undefined --turn off texture/diffuse mapping
MeditMaterials[sName].materialList[i].diffuse = white
)
)
)
AGAIN GO THROUGH ALL THE MAXSCRIPT EXAMPLES USING MULTIMATERIAL IF YOU WANT TO WORK WITH IT!
-Eric
Bixel
10-18-2007, 04:44 PM
sorry I didn't see any examples of the multimaterial scripts in the reference guide XD XD XD! Thanks for helping me!!
PiXeL_MoNKeY
10-18-2007, 04:51 PM
Simply search for "Multimaterial" in the help and look at the example "How do I Sort a MultiMaterial By Material ID?" every line is commented.
-Eric
RustyKnight
10-19-2007, 02:05 AM
Hi Bixel
I'm sorry to say, but agree with PiXeL_MoNKeY. The docs really have to be your first port of call.
Having said that, there are a number of things you really need to understand...
Precedence in max calls are a little odd (given the fact you don't need to use
brackets to call functions)
-- This won't work, mostly due to the way max does it's
-- precedence calls
if classof MeditMaterials[sName] == (MultiMaterial) do
I'd also suggestion you look up "MaterialLibrary" in the docs, as this will explain how you get hold of the materials in the first place...
fn changeMaterial material = (
if (classof material) == MultiMaterial do (
-- Perhaps do a recursive call...
for subMaterial in material.materialList do (
changeMaterial subMaterial
)
) else if (classof material) == Standard do (
material.diffusemap = undefined
-- you could also use material.diffuseMapEnable = false
-- as this would preserve the diffusemap value
material.diffuse = (color 255 255 255)
)
)
PiXeL_MoNKeY
10-19-2007, 03:54 AM
It doesn't need to be a function, but sName does need to be the <var_name> of a for loop. If it is then it will work fine the way I posted. This code should work just fine:
for sNAme in 1 to meditmaterials.count do (
if classof MeditMaterials[sName] == (MultiMaterial) do
(
for i in 1 to MeditMaterials[sName].MaterialList.count do -- you have to loop through each material in the Multi/Sub Material
(
if classof MeditMaterials[sName].materialList[i] == (Standard) do -- you have to check each material in the Multi/Sub Material
(
white = (color 255 255 255)
MeditMaterials[sName].materialList[i].diffuseMap = undefined --turn off texture/diffuse mapping
MeditMaterials[sName].materialList[i].diffuse = white
)
)
)
)
-Eric
RustyKnight
10-19-2007, 04:48 AM
Sorry Eric, it wasn't a poke at you in any way!
Shane
PiXeL_MoNKeY
10-19-2007, 05:17 AM
I didn't think it was Shane. I was just posting that his approach would work, but it does need to be in a for loop which I didn't mention earlier. Also, like just about anythhing in 3ds max, there are about 10 different ways to do the same thing, as long as the approach and syntax are correct.
-Eric
CGTalk Moderation
10-19-2007, 05:17 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.