Jump to content
Hash, Inc. Forums

How to randomly set a value ONCE?


robcat2075

Recommended Posts

  • Hash Fellow

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?

Link to comment
Share on other sites

  • Hash Fellow

hey, I think i've got it.

 

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

 

SelfRescaling.mov

 

 

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

Link to comment
Share on other sites

  • Admin

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.

Link to comment
Share on other sites

  • Hash Fellow

101 cylinders scaling and coloring themselves and holding their last state

 

 

101cyls2.mov

 

 

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.

Link to comment
Share on other sites

  • Admin

Nice update Robert. Looks like you've entered they experimental world of JohnL3D.

 

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.

Link to comment
Share on other sites

  • 2 months later...

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.

 

coverartbit.jpg

Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
Share on other sites

  • Hash Fellow
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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 10 months later...

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.

Link to comment
Share on other sites

  • Hash Fellow
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.

 

 

variable_storing_11.prj

 

(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.

Link to comment
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...