API - Adding Data to Particles

   3151   3   2
User Avatar
Member
229 posts
Joined: May 2006
Offline
Hi,


another PoP question from me ;-).
I want to store some Data on a per particle basis, such as a the ID of an particle which are connected and the restlength of the string between them.
i didnt find anything in the documentary under pop's, and other important thing is how to make this data available between the frames, so my calculated values are stored in frame X and should also be available in frame x+1.

thx in Advance

Sebastian
User Avatar
Member
166 posts
Joined: Feb. 2006
Offline
Hi Sebastian,

Here an example, I used sometime ago. It is dirty but that worked.
In my case I needed some data at T-1 so I stored it as another attribute



POP_ContextData* data = (POP_ContextData*) context.myData;

(…)

int density_off;
int prev_dens_off;

// create your data.
density_off = data->getDetail()->addPointAttrib(“density”,sizeof(float),GB_ATTRIB_FLOAT,0);
prev_dens_off = data->getDetail()->addPointAttrib(“prev_dens”,sizeof(float),GB_ATTRIB_FLOAT,0);

// To access your new data

float *my_density, *prev_density;
my_density = (float* )ppt->getAttribData(density_off);
prev_density = (float* )ppt->getAttribData(prev_dens_off);


Time to get out of this messy world.
User Avatar
Member
229 posts
Joined: May 2006
Offline
thx,

do you know if it is possible to store some kind of Array data in the particle, because i dont know how many connections i'm going to have.

thx again

Sebastian
User Avatar
Member
166 posts
Joined: Feb. 2006
Offline
I am not sure if you can store arrays. For sure you can a Vector. Maybe it is possible to do your own data structure. I remember ( so far ) trying but with out success. Maybe I didnt sweat enough
Time to get out of this messy world.
  • Quick Links