Jump to content
Sign in to follow this  

Using Pointclouds In Custom Cop

Recommended Posts


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:

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;
		if (d <= r) {
			pcimport(pc_handle, attrib, tmpF);
			sum += tmpF;

	result = sum / npoints;
	Cr = result;
	Cg = result;
	Cb = result;

Edited by sanchez

Share this post

Link to post
Share on other sites

Just a guess -

try initializing

float tmpF;


float tmpF=0;

You certainly know that in general it's better to initialize your variables that you are using in computation.

Or maybe adding an


statement after


could help as well.

hope that might help.

[EDIT] oh yeah - taking a second look at your code - this part can potentially be a problem -

result = sum / npoints;

- you iterate your 'npoints' inside the 'if' statement - in case your code doesn't get into that 'if' statement - you'll get a devision by zero, which will result in hactick artifacts, which resembles the problem you experience.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this