Jump to content


Photo

Random Position using C4D Xpresso

xpresso c4d cinema 4d

  • Please log in to reply
5 replies to this topic

#1 butler

butler

    MoGraph Megastar

  • Members
  • 314 posts
  • Gender:Male
  • Location:Chicago

Posted 24 April 2012 - 10:29 PM

Hey guys, I'm looking make an spline/object go to a random position in the x and y axis using xpresso.
So the setup is I have a user data of a integer for my random seed and then just a boolean that when it is checked it just go to a random position between like (-100 to 100 in the x and y) based on the seed.
Pretty sure this is possible but I'm not sure how to come up with the random position.
I'm guessing it is just a node that I have never used. Anyways hopefully this is pretty simple for someone to answer for me. Thanks!

#2 C.Smith

C.Smith

    Sermonizes Mograph to the Masses

  • Members
  • 2,929 posts
  • Gender:Male
  • Location:Santa Monica
  • Interests:Keepin it real.

Posted 25 April 2012 - 06:55 AM

Do you want it to change per frame? or just once?

If it's once you should just make a quick python script that will perform the action each time the button is pressed.

And if you want it once per frame do you want it jittery or smooth?

If you want it smooth, you can use the Vibrate Tag or my CS_Vibrate. If you want it completely random, I would just use the random functions in Python in a Python tag. That will be way quicker and easier than Xpresso I think. You can look up the random functions in python by just typing Python and random and you should see the Python docs on random.
chris smith :: some of my work

#3 butler

butler

    MoGraph Megastar

  • Members
  • 314 posts
  • Gender:Male
  • Location:Chicago

Posted 25 April 2012 - 10:52 AM

Do you want it to change per frame? or just once?

If it's once you should just make a quick python script that will perform the action each time the button is pressed.

And if you want it once per frame do you want it jittery or smooth?

If you want it smooth, you can use the Vibrate Tag or my CS_Vibrate. If you want it completely random, I would just use the random functions in Python in a Python tag. That will be way quicker and easier than Xpresso I think. You can look up the random functions in python by just typing Python and random and you should see the Python docs on random.



I was looking to have it just change once. I'll do some searching for a python script and hopefully find something. Thanks!

#4 Zickar

Zickar

    MoGraph Superstar

  • Members
  • 174 posts
  • Gender:Male
  • Location:Beirut, Lebanon

Posted 29 April 2012 - 08:15 AM

There is a random node in Xpresso>General>Random , you can output different types like integer , real and vectors from it but the problem is that it keeps changing with time , I think the best option for you is to create a user data and input this into a formula node in Xpresso , use the formula node to create a random output for you and then input this back into the position using a range mapper to map it between two values

Blog : www.motionzickness.wordpress.com


#5 C.Smith

C.Smith

    Sermonizes Mograph to the Masses

  • Members
  • 2,929 posts
  • Gender:Male
  • Location:Santa Monica
  • Interests:Keepin it real.

Posted 29 April 2012 - 08:23 AM



I was looking to have it just change once. I'll do some searching for a python script and hopefully find something. Thanks!


Xpresso is always an expression that is called every cycle. Again if you do a python script, it happens once per button press which is what you want.
Here is the elegant and simple 'random' function in Python:
random.random()
Return the next random floating point number in the range [0.0, 1.0)
chris smith :: some of my work

#6 TimC

TimC

    MoGraph Superstar

  • Members
  • 133 posts
  • Gender:Male
  • Location:Sydney, Australia

Posted 10 May 2012 - 06:21 AM

If you want to do it with Xpresso then you could use a monoflop node to only execute the nodes once. Alternatively you could use a boolean and then uncheck it each time. See Fake Button here for an example of this

http://zabiegly.de/xpresso/index.html

cheers
Tim





Also tagged with one or more of these keywords: xpresso, c4d, cinema 4d

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users