[Closed] Newbie With Animation Questions
Hello.
A short introduction: I am a freshman architecture student at the New Jersey Iinstitute of Technology. I use 3dsMAX for all of my digital modeling. I am fairly proficient at modeling in the MAX environment, and I also have a working understanding of several object-oriented programming languages, including C/C++ and Java. The project I am working on now is a proposal for an ecological research center and library on Mexico’s west coast. I decided to approach this problem in a conceptually unconventional way by using MAXScript to define form. I plan on converting a whole wealth of environmental conditions into numerical form and abstractly representing organisms with shapes, and using the time of the animation slider I will simulate the evolution of this digital “ecosystem” into the form of the final research complex. However, since there is a good deal I don’t understand about using MAXScript yet, I am giving myself all the time I can spare in the next week to come up with a working simulation (of a much smaller scale than the final) that sufficiently proves to my professor (and myself) that I’m actually capable of accomplishing this. I have a few questions to ask right away, and I would like to use this thread for the next week or so as an FAQ for myself as I build a competent understanding with MAXScript.
-
How do you specify the color of an object at its creation using MXS? I tried to do it in the way you’d express other parameters at creation (i.e. boxA = box length:10…color:green), and while I don’t get any syntax errors in the listener, the color of the shape still shows up randomly.
-
How do you specify the system of units that will be used in the scene using MXS?
-
How do you create a modifier on a shape with no initially-specified parameters (if possible)?
-
Can you reference external MAXScripts and have them run within a program flow? Or, perhaps to be more clear, can I make a call to a previously-written script and have it run in the middle of another script?
-
In the simulation I’m creating now, I start off with a single GeoSphere shape to represent a type of a plant (this is a much-oversimplified description of the situation, but I’ll describe the scene like this for brevity; if you’re interested in talking about architecture, email or IM me), and later on in the animation I want to introduce a box to represent a type of animal. The code I’m using now
animate on
(
at time 2400f (herbivoreA = box length:10 width:10 height:10)
)
creates the box primitive at the first frame. I’m not exactly sure why, since I specified the creation to occur at frame 2400. Please tell me what I’m doing wrong.
- One more question should do it for now. I’m sure that if I was a bit more competent with animating in MAX I could have figured this one out on my own, but I can’t. I intended for this code
animate on
(
at time 50 (plantA.twist.angle = 45; plantA.twist.axis = 2)
at time 100 (plantA.skew.amount = 10; plantA.skew.axis = 2)
)
to adjust the parameters for plantA’s Twist modifier from the first frame until frame 50, and then I wanted the parameters for the Skew modifier to change from frame 51 to 100. Obviously it doesn’t do that, as both modifiers are changed beginning at 0, but how would I do that? I’m sure it would probably involve a more in-depth manipulation of key frames, but I’m not exactly sure how to do that.
While I need answers to all these questions at some point, if you could just give me a little help based on what you know how to do, I would greatly appreciate it. These questions should seem pretty elementary to most people here, anyway. Also, since I’m a new user and my message needs to verified as “spam-free,” I may have a good deal of time to experiment and figure out a few of these on my own. Thank you in advance for your help.
Real quick, I can help you with 1 and 4.
-
box wirecolor:green
-
macros.run “macroCategory” “macroName”
Thanks for the help so far. Your answer for number 4 does bring up a little question though: the syntax I tried using for loading a macro script is somewhere along the lines of
macros.load "absolute_path_of_script"
(based on what I saw in the MXS Reference), although that doesn’t seem to work. I also tried using the absolute path of the script’s parent directory, but that doesn’t do anything. I verified these results by checking the “Customize User Interface” dialog after executing this line of code; the script didn’t appear under the category that I specified in the macro script definition. Am I way off, perhaps?
I started trying to create my own script to create the dialog box needed to input values for the simulation to start, and I have run into a number of problems. I don’t think that the MXS Listener’s built-in debugger is that intuitive, as it doesn’t tell me what line that run-time errors show up on…if there’s any cure for that, I’d be glad if someone let me know.
Anyway, the code should be simple and straightforward, so if anyone has the time to take a look at it and help me debug it, I'd really appreciate it. I'm using 3dsMAX version 7, by the way...sorry for not stating that in my first post.
rollout sim_options "Simulation Options"
(
spinner plants "Plants" range:[1,3,1] type:#integer
spinner herbivores "Herbivores" range:[1,3,1] type:#integer
spinner carnivores "Carnivores" range:[1,3,1] type:#integer
spinner years "Simulation Length (years)" range:[10,10000,100] type:#integer
spinner time "Time per Year (seconds)" range:[1,10,6] type:#integer
label note "Note: Animation speed is 20fps"
button start "Start Simulation"
on start pressed do
(
array_Plant = #()
array_Carnivore = #()
array_Herbivore = #()
array_XPos = #()
array_YPos = #()
range_end = years.value * time.value * 20 - 1
animationRange = interval 0 range_end
for i = 1 to (plants.value + herbivores.value + carnivores.value) do
(
array_Xpos[i] = random -250 250
array_Ypos[i] = random -250 250
)
for i = 1 to (plants.value + herbivores.value + carnivores.value) do
(
for j = 1 to plants.value do
(
a = random 10 20
("Plant" + (j as string)) as name = sphere radius:a pos[array_Xpos[i],array_Ypos[i],0]
)
for j = 1 to herbivores.value do
(
a = random 20 40
("Herbivore" + (j as string)) as name = box length:a width:a height:a pos[array_Xpos[i],array_Ypos[i],0]
)
for j = 1 to carnivores.value do
(
a = random 20 40
("Carnivore" + (j as string)) as name = pyramid length:a width:a height:a*1.5 pos[array_Xpos[i],array_Ypos[i],0]
pos[array_Xpos[i],array_Ypos[i],0]
)
)
)
)
CreateDialog sim_options width:245 height:155
A general break-down of what I want to do: A dialog box shows up with 5 spinners and a button. A user selects how many of each of the three types of organisms he/she wants in the simulation, how many years to run the simulation for, and how a "year" translates into seconds of animation time. After pressing the button, all that this code should do is create a number of each organism per user specification, create a number of random positions for the organisms to be situated in at the start, and then place them.
I tried running this script and got a couple of errors, but I'm not sure what they are or why they're happening. The following code window is what came up in the MXS Listener:
-- Error occurred in j loop
-- Frame:
-- j: 1
-- pos: undefined
-- called in i loop
-- Frame:
-- i: 1
-- called in start.pressed()
-- Frame:
>> MAXScript Rollout Handler Exception: -- No ""="" function for (%"coerce"() (%"+"() "Plant" (%"coerce"() Local:j Global:String)) Global:name) <<
I kind of think I narrowed this down to the way I tried naming the form. I tried converting the value of the loop index into a string, then concatenate it with another string, and then convert the new string to a Name. I think that is what caused the error, but like I said, I can't really decipher the error messages that well yet. I also can't immediately think of another way to dynamically create variable names, so if you can see what I'm trying to do and can think of another way to do it, that would be great. Later on, when I figure this out, I'll also be placing each on of the names into a corresponding array, just in case you're wondering why I have defined 3 empty arrays and haven't done anything with them.
Thanks again.
Number 6: Do you not need to just set a key at frame 50 with the same settings as frame 0 for the skew modifier?
I’m pretty sure that would do the trick, but I’m not sure how to explicitly place keys in MXS, and I’ve been giving an honest attempt at looking at the reference, too. I feel a little inept asking this, but do you think you could explain it to me?
I hate to be a nag, but I still haven’t the slightest clue about how to set keys in MXS. I don’t know how to assign a key to a certain time, a certain object, or what a controller is. I’ve been making attempts at finding tutorials online and experimenting with what I can find in the MXS reference, but I keep coming up short.
Can anyone at least give me an overview on how to animate in MAXScript, or at least point me to a tutorial of some kind? This is an integral part of my project, and I’m in danger of having to abandon it.