Announcement

Collapse
No announcement yet.

Particle flow - fine control through scripting

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Particle flow - fine control through scripting

    I posted this over at CG talk but it seems pretty dead over there... It is majorly offtopic.


    I've been having some pretty good results out of pflow for a while - breaking the object up into pieces, assigning a particle to each one and taking it apart/building it up.

    But I've not seen any tutorials on how to get fine control over the particles - it all seems a bit haphazard.

    For example - I've got this building with 3 sides at odd angles.


    The skin is made up of rectangular panels and I want them to first slide out, rotate around their top pivot and slide into place - ready for another to slide out and repeat. The final intent is for it to have a very clunky, slightly awkward seeming but deliberate motion.

    Here's a (awful) sketch showing what I mean:


    Problem is, whenever i try to give my particles a rotational value, they dont respect the original pivot point orientations. All the options in 'rotation' are based around world space, whereas I want to grab the local space of the original object - all of the original panels have pivots which follow the shape as it turns. as shown here - it works fine on one axis only, but the second they turn a corner it's all over:


    I also dont know how to script a starting position, or to get them to shift along an axis by say 50mm over the course of 3 frames.


    What I want to do makes sense in my head, I just cant find any way to do it with the operators and the scripting in particle flow makes very little sense to my limited knowledge - all the tutorials i've seen dont cover small movements and shifts over time. I wouldve thought this a fairly straightforward job, but i've been trying to figure it out all morning now


    If there was a position operator, and you could set the number of frames it took to get there as well as a rotation one with the same, and they both supported 'local' pivot points, i'd be sorted. But this seems awfully complicated for what I would consider incredibly basic movements. Seems the more complicated the motion in pflow, the easier it is to do it.



    Does anyone have any ideas how to do this? Or any really good guides to scripting small, finely controlled movements of particles?
    Scripting is one of those things I understand to a point. I understand the idea behind channels, and setting up references to use later on. And then it all goes a bit crazy and I cant make the slightest bit of sense of any of it, or even how to learn it.


  • #2
    Well going in depth on scripting PFlow is a bit out of scope for me. But i guess this could be done without any scripting. You can use the speedspace coordinate system to do these kinds of effects. To do that you add a speed operator with default settings. Then a rotation operator set to "speed space" and then another speed operator with speed at 0 to prevent actual moving. That way you get a local coordinate system along the direction of the speed operator. To make the panels align you can use a speed by surface for example.

    Regards,
    Thorsten

    Comment


    • #3
      Thanks for the reply thorsten

      That does work, but it only works on my global pivot space, so they all move/rotate in the same direction
      I can keep the object pivot space intact if I use a shape instance, but then i loose the references to my original material id's - which I need to keep for the pattern around the building, which is a fairly complex pattern that creates a kind of gradient suggestion. So I may be stuck with a birth script on this one.
      This is the facade:


      I think I can almost do it now - i just need my birth script to take into account the rotation of the pivot point of the original object - without using that to also rotate the created particle by as any pivot transformations I make get doubled up on creation, why I have no idea. (and resetting the xform, while it keeps the position one where I put it, resets the rotation of the pivot to world space... ARGH)


      If I create all the objects again and rotate them into place it works fine. But if the objects are already rotated, I cant get it to work by moving the pivot point to fit. Which doesnt make any sense to me.
      Last edited by Neilg; 22-10-2008, 08:12 AM.

      Comment


      • #4
        Hm. So do they need to rotate differently or with a time offset ? (the timeoffset could be easily done i suppose). Actually both can be done with a gradient i guess. Using a Gradient map as a source to drive things i guess.

        As for the scripting side it looks more complex as it is. But dont really have time atm to dive into it. Have you checked Bobo's PFlow Scripting tuts ?


        Regards,
        Thorsten

        Comment


        • #5
          Originally posted by instinct View Post
          Hm. So do they need to rotate differently or with a time offset ?
          Not so much differently - they will all be rotating in the same axis, I just want some panels to have a different pivot point to drive this.

          If the object gets created and rotated into position, it works fine. But if the objects gets created in position and has the pivot point rotated to line up with it - particle flow doubles up the transformation, so 10 degrees to the right on your mesh becomes 20 degrees to pflow.

          I have seen all his tutorials, and while theyre a great help for starting off i've found that whenever I try to go off and use a bit of my own initiative and develop an idea further, I just hit wall after wall with absolutley no clue why or where to even find help.


          I dont think i'm cut out for particle flow
          I saw someone do this exact thing a few years ago. 4, to be exact - I even had his scene file. But back then, i didnt know what any of it meant and i've now lost it.
          Last edited by Neilg; 22-10-2008, 08:56 AM.

          Comment


          • #6
            I think I've had the same problem. I solved it by changing the particle-chunk script (bobos I think) to read the source objects transform matrix, and to apply that to the particle. It was a nightmare! rotations in maxscript are a true head-f#ck.
            I might be able to dig out the old script if I can find it...
            Many Thanks
            Patrick

            Comment


            • #7
              Originally posted by RE:FORM_STUDIOS View Post
              I think I've had the same problem. I solved it by changing the particle-chunk script (bobos I think) to read the source objects transform matrix, and to apply that to the particle. It was a nightmare! rotations in maxscript are a true head-f#ck.
              I might be able to dig out the old script if I can find it...
              Nice to know it sounds as easy as i was hoping...
              If you could do this you would be my hero! It sounds like thats what I need to get over this issue.

              Have you done a lot of scripting, or did you pretty much just learn what you needed for that purpose? Wondering if you cant find it, if you could point me in a vague direction to try and figure it out myself. I kind of get how it works to an extent, but i'm awful at writing it. Basically, I can copy & paste it...

              edit: Here's the script i'm currently using:
              Code:
              on ChannelsUsed pCont do
              
                                                  (
                                                  pCont.useAge = true
                                                  pCont.useTM = true
                                                  pCont.useShape = true
              
                                                  )
                                                 
                                              on Init pCont do
                                                  (
                                                	global Chunksarray1 = $panels_* as array
                                                  )
              
                                              on Proceed pCont do
                                                  (
                                                  t = pCont.getTimeStart() as float
                                                 
                                                  if t < 0 do
                                                      (
              									 Global NumChunks = Chunksarray1 .count
                                                      for ii = 1 to NumChunks do
                                                          (
              					
              			pCont.AddParticle()
                                                          pCont.particleIndex = pCont.NumParticles()
                                                          pCont.particleAge = 0
                                                          pCont.particleTM = Chunksarray1[ii].transform
                                                          pCont.particleShape = Chunksarray1[ii].mesh
                                                          )
                                                      )
                                                  )
                                              on Release pCont do
                                                  (
                                                                            )
              Last edited by Neilg; 23-10-2008, 03:10 AM.

              Comment


              • #8
                Hmm, I had a quick look for the script and I can't seem to find the version that fixed the problem . It might be on my laptop at home. I'll have a look for it tonight.

                Sorry!
                Patrick Macdonald
                Lighting TD : http://reformstudios.com Developer of "Mission Control", the spreadsheet editor for 3ds Max http://reformstudios.com/mission-control-for-3ds-max/



                Comment

                Working...
                X