Documentation

Google Groups Discussion

Usage Examples


Tools

One handy thing that the Partio provides is simple command line tools to manipulate and example particle data. For example you can get information on a particle file of any type by using "partinfo".

$ partinfo test.bgeo
Number of particles:  9998

Type      Count     Name                          
----      -----     ----                          
VECTOR    3         position                      
VECTOR    3         v                             
INT       1         id                            
INT       1         parent                        
FLOAT     3         Cd                            

particle 0 position 0.536567 1.17344 0.523275
particle 1 position 0.495414 0.913424 0.434151
You can also view particles in a simple standalone (and very quick to load) particle viewer
$ partview test.bgeo

Screenshot of Partio View

Particles can easily be converted from one format to another such as from bgeo to RenderMan PTC.
$ partconv test.bgeo test.ptc

C++ API

In C++ particle files can be created and added in a similar way. We have an iterator that allows quick iteration through data in the same way regardless of the internal format. As an example of computing the average position of all particles in a set.

  // open file
  ParticleData* simple=Partio::read("test.pdb");
  if(!simple) die("failed to open test.pdb");

  // prepare iteration
  auto iterator=simple->begin(), end=simple->end();
  ParticleAttribute posAttr;
  if(!simple->attributeInfo("position",attr) || attr.type != VECTOR || attr.count != 3)
       die("failed to get position as vector of size 3");

  ParticleAccessor posAcc;
  iterator.addAccessor(posAcc);

  // compute sum
  float avg[3] = {0,0,0};
  int cnt=0;
  for (auto it=simple->begin(); it!=simple->end(); ++it) {
      float* data = posAcc.raw<float>(it);
      for(int k=0; k < 3; k++) {
          avg[k] += data[k];
      }
      cnt++;
  }
  for (int k=0; k < 3; k++) {
      data[k] /= cnt;
  }

  simple->release();

Python API

Often particles need to be manipulated after the fact to have additional or fewer attributes. To compute aggregate statistics on a file etc. The python API to partio allows you to do this very quickly. The following code increases the radii on particles by 2, if within a distance of one of the origin.

#!/bin/env python
import partio

filenameIn,filenameOut=sys.argv[1:]
p=partio.read(filenameIn)
pos,radius=p.attributeInfo("position"),p.attributeInfo("radius")
for i in p.numParticles():
    if dist(p.get(pos)) <= 1:
        p.set(i,radius,(p.get(i,radius)[0]*2,))
partio.write(filenameOut,p)

Partio License

PARTIO SOFTWARE

Copyright 2018 Disney Enterprises, Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. The names "Disney", "Walt Disney Pictures", "Walt Disney Animation Studios" or the names of its contributors may NOT be used to endorse or promote products derived from this software without specific prior written permission from Walt Disney Pictures.

Disclaimer: THIS SOFTWARE IS PROVIDED BY WALT DISNEY PICTURES AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT AND TITLE ARE DISCLAIMED. IN NO EVENT SHALL WALT DISNEY PICTURES, THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND BASED ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.