Jump to content

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
Link to comment
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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...