Announcement

Collapse
No announcement yet.

[SDK] Can't figure out field velocities...

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

  • [SDK] Can't figure out field velocities...

    I'm writing a plugin that moves particles through a phoenix grid (sort of like Thinkbox's 'Stoke', or even pflow's 'PhoenixFX force').

    The grid I'm using for testing purposes is located at the scene origin, is 50x50x50 with a cell size of 1.0. It has some smoke emitting from a ball inside of it. I emit my custom particles over the surface of the ball and then move them using the phoenix grid values returned by the IPhoenixFD* interface.

    I'm trying to understand Phoenix velocities and how I should be using them to move my particles properly. So far I can successfully convert particle positions to grid coordinates, and query the velocity channel's x/y/z float values without issue.

    However, the velocities I get seem to be too big, and when I move my particles with the velocities returned by the grid...they all move way too fast and go flying off into oblivion. I've found that multiplying the velocities by .03 and using that value to push my particles instead, seems to get motion closer to what I'd expect. For reference: my simulation runs like this:

    1) get particle position
    2) query phoenix cell at that position and get its velocity
    3) set particle position to [current particle position + cell velocity]
    4) move to the next frame and repeat for all particles....

    I can't imagine .03 is some magic number, therefore I'm sure there's some velocity conversion I'm missing. I'm assuming that the velocities returned by the grid are in cell size units, not world units? That shouldn't affect my current setup though since my cell size is 1.0...but I figured I'd ask anyways.

    Also, should I be interpolating between nearby cell velocities, based on the proximity of the query point to those neighbor cells? Or is just getting the velocity of the target cell good enough?

    The SDK samples don't include any info about how to work with grid velocities (other than simply querying them)...so I'm feeling around in the dark here and would appreciate help!

    tl;dr: I have particles and a phoenix grid. How do I use the velocities from the grid to move the particles around, so their motion matches the motion of the smoke in my phoenix sim?

  • #2
    So, through some research I realized that I need to be doing trilinear interpolation on the vectors of surrounding cells to my query point. Now that I'm doing that, my particles move much more naturally...but the scale of the vectors is still off.

    For example, on a 50x50x50x1 grid, where the smoke is moving fairly conservatively in speed, as I query vectors within the grid I'll get vectors that are really long. Like, for a cell where smoke isn't moving very fast I'll get a vector like "[-.2, .1, 25.5]". Obviously it makes no sense that the magnitude of the velocity of smoke in that cell is over 25 world units long. And it makes no sense that it would be 25 grid cells units long either. When I take all queried vectors and shrink them down (multiply by .02 or .03 or whatever), my particle's motion matches the smoke exactly....but instead of guessing I'd like to know exactly how to convert these vectors to an appropriate world-unit size.

    Any ideas?

    Comment


    • #3
      Here are some example images to illustrate the problem:

      Here's the phoenixFD grid, showing the smoke simulation:



      Here's how my particles look, when I simulated their motion by querying the grid for vectors, and multiplying those vectors by .04:



      Here's how my particles look, when I simulated their motion by querying the grid for vectors, and then just used the raw vectors:

      Comment


      • #4
        Ah, I've figured it out. The equation is:

        [world vector] = [grid vector] * (([cell size] * [grid time scale]) / [framesPerSecond])

        This gives me a result that matches exactly to the particle flow PhoenixFD force operator.

        Comment


        • #5
          Hey, sorry for the late reply! This is exactly the formula you need. If you have any other issues or questions, please ping us
          Svetlin Nikolov, Ex Phoenix team lead

          Comment

          Working...
          X