Saturday, November 20, 2010

3dsmax: loops, array, struct, as


-- do-while loop
i = 0
do
(
b = box()
b.pos.x = i * 10
--print i
i = i +1
)while (i <a)

-- while loop
i = 0
while(i < a) do
(
print i
i = i+1
)

-- array
arr = #(1, 2, 3, 4)
-- one-based index
print arr[3]

-- struct
struct Fan
(
-- member variables
speed,
radius,
isOn,
-- member function
function setSpeed spd=
(
speed = spd
),
function getSpeed=
(
return speed
),
-- special: calling function when object is constructed
-- can only call function AFTER it is created. eg.: setSpeed()
speed = setSpeed(1)
)
-- initiating structure
f = Fan()
f.radius = 10
f.setSpeed(3)

-- using "as" command
str = "The fan speed is " + fan.getSpeed() as string

No comments: