Help - Search - Members - Calendar
Full Version: How to randomly set a value ONCE?
Hash, Inc. Forums > Technical Direction and Development (Learning Animation:Master) > A:M Rigging & Relationships
robcat2075
I'm searching for a way to write an expression that will use the Rand() function to set a value once at the beginning of an animation but not keep setting the value on every frame.

I can use If() to test if we are on the 0 frame and stick my Rand() thing in the "True" case section and If() will return that random value, but when we are not on frame 0 and If() tests to "false", it returns a 0 as a value rather than no value at all, which causes the random value set in the intial frame to be overwritten with 0.

There doesn't seem to be a way to safely store the initial random value for later use.

Is there?
robcat2075
hey, I think i've got it.

20 identical cylinder models that randomly rescale themselves and then stop, holding their last shape:

Click to view attachment


Why is this useful? One could make a character that self-randomizes various things like hair color, height, fatness... then you could scatter many instances of that character into a chor and you wouldn't have to go into each character yourself to change these attributes individually to make a crowd that didn't look like all identical clones.

Which is what I need to do to add a crowd on the side of the road of in this shot
jason1025
Very cool! I cant wait to see how this turns out.
Rodney
You've been busy Robert. Keep on posting and experimenting.
I may not respond to all of your posts but I read them all! You are producing great results.

I seem to recall Stefen Gross posting something about Randomizing actions/attributes on a model via one of his plugins too. I don't even know where to start to look for that discussion other than through a search for the term 'randomize'.

I was researching something along those lines for a large crowd scene as well but my focus was on using animated images randomized to differentiate themselves from one another. I put that project aside because it was considerably beyond my ability. Your test here certainly shows promise.

Being math deficient has a distinct downside.

I'd love to hear more about the expression you are using.



robcat2075
101 cylinders scaling and coloring themselves and holding their last state


Click to view attachment


the next big leap, which i won't get to immediately, is to get a model to randomly choose from several possible actions and when that action is done randomly choose another.

That would be the beginning of automated crowd animation.
Rodney
Nice update Robert. Looks like you've entered they experimental world of JohnL3D.

QUOTE
the next big leap, which i won't get to immediately, is to get a model to randomly choose from several possible actions and when that action is done randomly choose another. That would be the beginning of automated crowd animation.


Wouldn't that be the heat!

An intermediate step might be to randomize decals, patch images or materials.




robcat2075
Winkies sizing and coloring themselves

Click to view attachment



Rodney
That is out of control. Or... in control. Or... very neat!
Another fine example of building your own feature in A:M.
SpaceToast
I've always dealt with similar problems by using AppleScript to manipulate the project file. I find it gives me more control over instancing than I can get with the flocking plugins. (And no overlaps that aren't my own fault.) The format is pretty easy to understand for the most part.

For the new BTP album cover, I wrote a script to instance several thousand "beans" in a column above the logo. Each was assigned one of three colors, Newton Physics, and a semi-randomized position and orientation. Then I reopened the .prj file in A:M, ran the Newton Physics plugin, and picked the frame I liked best. I did basically the same thing earlier on the Population Map.

Sacman
Okay, I have tried everything I know to insert a for loop or a while loop into the project but I am missing something.

I am trying to replicate your trick on a PC. Thought it was interesting but apparently I don't understand the code well enough.

I can add more models by editing the project file, I can change postions there as well (a side note to any that try, the units are converted to CM in the project file regardless of the units setting in A:M)

I assume it is xml code as that is what it looks like but Notepadd++ does not recognize it as such. It says it is normal text. So I am struggling a bit. It is possible that the code would be similar. Is there anyway you can post the snippet that you use to loop through and add multiple instances of a model?

Thanks,

Wade
robcat2075
QUOTE(Sacman @ Dec 1 2008, 04:25 AM) *
Is there anyway you can post the snippet that you use to loop through and add multiple instances of a model?


Are you asking me or SpaceToast?

I added the multiple models with Steffen Gross's SimpleScatter plugin.

His MMoP does a similar trick.
Sacman
I was looking for Spacetoast's solution. It would be a great tool to help learn how to manipulate the project file through code. Outside of his parrticular example I am not sure how useful it would be but I would like to learn it.

However, It is always nice to see what another one of Steffan's plugins do.

Thanks,

Wade
OdinsEye2k
Hey Robcat,

So, how did you finally get the value to stop changing? Did you actually manage to save it? Because if we're talking saved values (and can do the trick more than once), we're talking the possibility to run differential equations in Expressions. And then real damage can be done.
robcat2075
QUOTE(OdinsEye2k @ Oct 10 2009, 10:23 AM) *
Hey Robcat,

So, how did you finally get the value to stop changing? Did you actually manage to save it? Because if we're talking saved values (and can do the trick more than once), we're talking the possibility to run differential equations in Expressions. And then real damage can be done.


Yes I did. I used it to make self varying crowd Winkies for TWO (scene never used)

Basically you have a bone that is varied by a (in my demo, random) expression. Later a second bone is constrained and keyed to match it when you want to preserve a value. There's more to it than that, but I forget the exact process at the moment.


And somewhere around here are several posts and a sample PRJ.

Here's a pRJ that is not the simplest demo but it's the one i find now.


Click to view attachment

(scattersquare.mdl not needed.)

the tubes are all the same MDL. They vary their own height, width and color on every frame until frame 20, when the varying is turned off and they stick with whatever their current variation is.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.