Using Pointclouds In Custom Cop

   3165   3   1
User Avatar
Member
35 posts
Joined: July 2005
Offline
Hi.
I am trying to bring in some attributes from point cloud to COPs by using custom VEX COP.
So i get wrong, different, and totally unpredictable results every cook even if i neither chage values of the parameters nor change point cloud geometry.

Where is a problem?

My code:

cop2
pc_image_gen(string pc_file = “”;string attrib = “inside”;float radius = 0.1;int maxpoints = 100;
float scalef = 1)
{
int pc_handle;
float d, r, sum = 0, result = 0;
float tmpF;
vector pos = set(X,Y,0);
pos *= scalef;
pc_handle = pcopen(pc_file, “P”, pos, radius, maxpoints);
float npoints = 0;
while(pciterate(pc_handle))
{
pcimport(pc_handle,“point.distance”,d);
pcimport(pc_handle,“radius”,r);
if (d <= r) {
pcimport(pc_handle, attrib, tmpF);
sum += tmpF;
npoints++;
}


}
result = sum / npoints;
Cr = result;
Cg = result;
Cb = result;
pcclose(pc_handle);
}
User Avatar
Member
7024 posts
Joined: July 2005
Offline
I don't know for sure but I think you're not checking for a successful PCimport. Try setting tmpF = 0; when you declare it at the top. Usually “random results” means an uninitialized variable accessing memory that it shouldn't

Cheers,

Peter B
User Avatar
Member
35 posts
Joined: July 2005
Offline
pbowmar
I don't know for sure but I think you're not checking for a successful PCimport. Try setting tmpF = 0; when you declare it at the top. Usually “random results” means an uninitialized variable accessing memory that it shouldn't

I already tried to intialize tmpF with zero. It didn`t help. All i got is the something like a random pattern.
User Avatar
Member
35 posts
Joined: July 2005
Offline
It works for me now. I simply reload scene.
Thanks anyway.
  • Quick Links