Light Generator
This tutorial shows how to make lights, deal with random numbers, and define variables.
Start a new script (maxscript/new) and add the following code for the global variables:
x1 = random 1 320.0
y1 = random 1 320.0
z1 = random 1 320.0
x2 = random 1 320.0
y2 = random 1 320.0
z2 = random 1 320.0
x3 = random 1 320.0
y3 = random 1 320.0
z3 = random 1 320.0
x4 = random 1 320.0
y4 = random 1 320.0
z4 = random 1 320.0
R1 = random 1 255
R2 = random 1 255
R3 = random 1 255
G1 = random 1 255
G2 = random 1 255
G3 = random 1 255
B1 = random 1 255
B2 = random 1 255
B3 = random 1 255
This defines the positions and colors we will use for our lights. If you wondered what I mean by global variables, it pretty much means that they go at the top of the script and can be used from any part of it while local variables can only be used in the section they were defined in.
The random that I used generates a number between the two numbers you put in front of it. The reason I put 320.0 instead of just 320 is so that it would be a double not an integer. An integer only holds whole numbers, but a double can include partial numbers.
After adding the code above, add the following below it:
Omnilight rgb:(color R1 G1 B1) shadowColor:(color 0 0 0) multiplier:1 contrast:0 softenDiffuseEdge:50 nearAttenStart:0 nearAttenEnd:40 farAttenStart:80 farAttenEnd:200 decayRadius:40 atmosOpacity:100 atmosColorAmt:100 shadowMultiplier:1 pos:[x1, y1,z1] isSelected:on
Omnilight rgb:(color R2 G2 B2) shadowColor:(color 0 0 0) multiplier:1 contrast:0 softenDiffuseEdge:50 nearAttenStart:0 nearAttenEnd:40 farAttenStart:80 farAttenEnd:200 decayRadius:40 atmosOpacity:100 atmosColorAmt:100 shadowMultiplier:1 pos:[x2, y2,z2] isSelected:on
Omnilight rgb:(color R3 G3 B3) shadowColor:(color 0 0 0) multiplier:1 contrast:0 softenDiffuseEdge:50 nearAttenStart:0 nearAttenEnd:40 farAttenStart:80 farAttenEnd:200 decayRadius:40 atmosOpacity:100 atmosColorAmt:100 shadowMultiplier:1 pos:[x3, y3,z3] isSelected:on
Omnilight rgb:(color R2 G2 B2) shadowColor:(color 0 0 0) multiplier:1 contrast:0 softenDiffuseEdge:50 nearAttenStart:0 nearAttenEnd:40 farAttenStart:80 farAttenEnd:200 decayRadius:40 atmosOpacity:100 atmosColorAmt:100 shadowMultiplier:1 pos:[x4, y4,z4] isSelected:on
When you run the script it will place 4 omni lights around the scene in random positions and with random colors.
There are no threads for this page.
Be the first to start a new thread.