All I want to do (in the POP context) is to create a calculation on the first particle (id==1) and then reference the result of that calculation for the rest of the particles. I know that VEX uses some techniques that increase its speed, but is there a way to reference and edit an overall global variable in the VEX context without losing that speed?
Thanks!
Getting and setting detail (global) variables in VEX code
10292 7 2-
- rabidpraxis
- Member
- 12 posts
- Joined: April 2010
- Offline
-
- old_school
- Staff
- 2540 posts
- Joined: July 2005
- Offline
-
- rabidpraxis
- Member
- 12 posts
- Joined: April 2010
- Offline
Thanks for the reply Jeff.
Point clouds are still a strange animal to me, so bare with me. I have tried to push/pull some data from a single pointcloud, but I cant seem to make it work. Here was my process.
- pcopen a single point using the normal “op:`opinputpath('.', 1)`” with the point piped into slot
- I pipe the handle into an export and send some data (a float) to be exported if it is the first point.
- I also import that same data and have the if bypass the exporting if ptnum==1
I cant seem to figure out how to have it export/import the data. I have set the channels to something other than P, that does not work. From the docs, it seems like pcimport/pcexport is limited to position and point data. But I want to store an arbitrary float (or whatever) in the point cloud. Am I missing a step? or just setting this up wrong?
Thanks for your help (and more old school blog posts please!! I love those),
Kevin
Point clouds are still a strange animal to me, so bare with me. I have tried to push/pull some data from a single pointcloud, but I cant seem to make it work. Here was my process.
- pcopen a single point using the normal “op:`opinputpath('.', 1)`” with the point piped into slot
- I pipe the handle into an export and send some data (a float) to be exported if it is the first point.
- I also import that same data and have the if bypass the exporting if ptnum==1
I cant seem to figure out how to have it export/import the data. I have set the channels to something other than P, that does not work. From the docs, it seems like pcimport/pcexport is limited to position and point data. But I want to store an arbitrary float (or whatever) in the point cloud. Am I missing a step? or just setting this up wrong?
Thanks for your help (and more old school blog posts please!! I love those),
Kevin
-
- old_school
- Staff
- 2540 posts
- Joined: July 2005
- Offline
You have to check out the vimeo tut on point clouds from Peter Quint.
http://vimeo.com/9108284 [vimeo.com]
He steps you through the basics of wiring up a point cloud VOP network.
http://vimeo.com/9108284 [vimeo.com]
He steps you through the basics of wiring up a point cloud VOP network.
There's at least one school like the old school!
-
- tamte
- Member
- 9604 posts
- Joined: July 2007
- Offline
maybe this can help you understand problem with POPs and pointclouds
http://forums.odforce.net/index.php?/topic/8637-point-cloud-in-pop/ [forums.odforce.net]
http://forums.odforce.net/index.php?/topic/8637-point-cloud-in-pop/ [forums.odforce.net]
Tomas Slancik
CG Supervisor
Framestore, NY
CG Supervisor
Framestore, NY
-
- rabidpraxis
- Member
- 12 posts
- Joined: April 2010
- Offline
Ok, so I have moved away from using POP's and instead have started using just points in SOPs with a SOP solver for my dynamics.
Thanks for the tutorial suggestion Jeff, that cleared up a few issues I had. But it did not solve my main issue. So here is the problem. I set everything up so it is iterating to the one point, and I can get it to import the “channel” values, but I cannot figure out how to export. Both in Vex and Vops, pcexport is not saving the data that I am posting to it. I have tried to use a referenced SOP and an exported .pc file and both have the same result of not allowing me to export a value. The documentation states that you can only export to a read-write channel. Could that be the problem?
What about pcwrite? is that the function that I should be using? Would that be as efficient since I would be writing to files for every frame?
Thanks,
Kevin
Thanks for the tutorial suggestion Jeff, that cleared up a few issues I had. But it did not solve my main issue. So here is the problem. I set everything up so it is iterating to the one point, and I can get it to import the “channel” values, but I cannot figure out how to export. Both in Vex and Vops, pcexport is not saving the data that I am posting to it. I have tried to use a referenced SOP and an exported .pc file and both have the same result of not allowing me to export a value. The documentation states that you can only export to a read-write channel. Could that be the problem?
What about pcwrite? is that the function that I should be using? Would that be as efficient since I would be writing to files for every frame?
Thanks,
Kevin
-
- rabidpraxis
- Member
- 12 posts
- Joined: April 2010
- Offline
Alright, so I figured out the export problem.
The key to exporting to an attribute is to make sure that the attribute is not already defined. If it has already been added to the geometry, then I'm assuming its considered locked in a point cloud context. Therefore export will not work.
So just set the export/import texture parameter to something unique and all will be fine.
The key to exporting to an attribute is to make sure that the attribute is not already defined. If it has already been added to the geometry, then I'm assuming its considered locked in a point cloud context. Therefore export will not work.
So just set the export/import texture parameter to something unique and all will be fine.
-
- rabidpraxis
- Member
- 12 posts
- Joined: April 2010
- Offline
Actually, let me show an example, cause I am noticing some weirdness.
Here is an example sop vex node:
#pragma opname pc_save
#pragma oplabel “Point Cloud Export Example”
#pragma opmininputs 1
#pragma opmaxinputs 2
#pragma label file “Point Cloud Texture”
#pragma hint file file
sop
pc_save(string file = “op:`opinputpath('.', 1)`”)
{
int handle = pcopen(file, “P”, P, 10000, 1);
int success = pciterate(handle);
if(ptnum == 0) {
float myNum = (random(Frame) * 55);
int e_success = pcexport(handle, “testAttr2”, myNum);
}
float iVal;
pcimport(handle, “testAttr2”, iVal);
addattribute(“import_val”, iVal, “type”, “float”);
}
This looks like it will work, but it won't. It looks as though the pciterate will not execute the iteration if its return value is not referenced somewhere. So to fix it, I just replaced:
if(ptnum == 0) {
with:
if(ptnum == 0 && success == 1) {
and that ensures that it iterates to the single point that is piped into slot 1
If anyone who knows more about point clouds wants to add more context about what is happening in the background, I would appreciate it.
Here is an example sop vex node:
#pragma opname pc_save
#pragma oplabel “Point Cloud Export Example”
#pragma opmininputs 1
#pragma opmaxinputs 2
#pragma label file “Point Cloud Texture”
#pragma hint file file
sop
pc_save(string file = “op:`opinputpath('.', 1)`”)
{
int handle = pcopen(file, “P”, P, 10000, 1);
int success = pciterate(handle);
if(ptnum == 0) {
float myNum = (random(Frame) * 55);
int e_success = pcexport(handle, “testAttr2”, myNum);
}
float iVal;
pcimport(handle, “testAttr2”, iVal);
addattribute(“import_val”, iVal, “type”, “float”);
}
This looks like it will work, but it won't. It looks as though the pciterate will not execute the iteration if its return value is not referenced somewhere. So to fix it, I just replaced:
if(ptnum == 0) {
with:
if(ptnum == 0 && success == 1) {
and that ensures that it iterates to the single point that is piped into slot 1
If anyone who knows more about point clouds wants to add more context about what is happening in the background, I would appreciate it.
-
- Quick Links

