Jump to content

max script tips & help


LuckyST
 Share

Recommended Posts

I'm starting to learn max script, so I was wondering if anyone has any advice for a complete noob.

 

Work it out logically in your head before you write a line. If you can follow the flow in your head, and write the pseudocode before you start, then the only thing you have to contend with is syntax. So if you wanted to place a random set of objects from a selection set onto all the verts of a model, the pseudo code would be something like:

 

find all selection sets

select correct selection set

add all objects in selection set to an array

select mesh to populate

find total number of verts

run loop for 1 to number of verts

get vertice xyz location

select object from selection set array using random (1 total_in_array)

copy object in vert location

end loop

 

By doing this, you can also see how you could potentially make it more efficient, too. Once you have the logic set out, you just have to go about working out the specific lines to do, but that's the easy part really (or, rather, the part where having a friend who scripts is helpful!)

Link to comment
Share on other sites

Work it out logically in your head before you write a line. If you can follow the flow in your head, and write the pseudocode before you start, then the only thing you have to contend with is syntax. So if you wanted to place a random set of objects from a selection set onto all the verts of a model, the pseudo code would be something like:

 

find all selection sets

select correct selection set

add all objects in selection set to an array

select mesh to populate

find total number of verts

run loop for 1 to number of verts

get vertice xyz location

select object from selection set array using random (1 total_in_array)

copy object in vert location

end loop

 

By doing this, you can also see how you could potentially make it more efficient, too. Once you have the logic set out, you just have to go about working out the specific lines to do, but that's the easy part really (or, rather, the part where having a friend who scripts is helpful!)

 

thanks.

unfortunately I'm the designated "goto" guy here. not many people are in 3d business here, and even less know to code :(

Link to comment
Share on other sites

what my ultimate goal would be is making a script that would change material properties depending on a distance to the camera (kind of like LOD but for materials).

 

4example, I'd like to link the Z cordinate of the camera to a noise map's size in the material editor, & stuff like that, or link it to intensity of blending of 2 maps... stuff like that.

 

but so far I'd settle for simple things.

any tutorial you might recommend on script subject?

Edited by LuckyST
Link to comment
Share on other sites

what my ultimate goal would be is making a script that would change material properties depending on a distance to the camera (kind of like LOD but for materials).

 

4example, I'd like to link the Z cordinate of the camera to a noise map's size in the material editor, & stuff like that, or link it to intensity of blending of 2 maps... stuff like that.

 

but so far I'd settle for simple things.

any tutorial you might recommend on script subject?

 

I think you could probably do that with a simple Falloff material set to Distance Blend, couldn't you?

Link to comment
Share on other sites

what my ultimate goal would be is making a script that would change material properties depending on a distance to the camera (kind of like LOD but for materials).

 

4example, I'd like to link the Z cordinate of the camera to a noise map's size in the material editor, & stuff like that, or link it to intensity of blending of 2 maps... stuff like that.

 

but so far I'd settle for simple things.

any tutorial you might recommend on script subject?

 

For the circumstances you mentioned you should look at expression controllers or parameter wiring, these have similarities to scripting, but are not strictly maxscript (a maxscript tutorial might not help). Look up expression controllers and parameter wiring in the help. As was already stated make sure to have a clear idea about what it is you are trying to achieve. With expression controllers you create "live" relationships (what you want). If you end up needing to assign expressions to many objects with different values, you can use maxscript to do that for you, but I think you want to assign some expressions to your material values.

 

Hope this helps,

 

-Nils

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...