Jump to content

Point Cloud Problems


SvenP

Recommended Posts

I am trying to get the distance between a point p and the nearest point in a pointcloud.Ive already tried everything i can think of in the last few hours to get the problem solved but the function always returns a value of 0 :(

Ok heres the code maybe someone of you can help me.

Thanks in advance

Sven

float PC_GetDensity(string file ;vector mp;float r)

{

float d,temp_d;

int handle;

d=1000;

handle = pcopen(file,"P",mp,r,10);

while ( pciterate(handle) )

{

if( pcimport(handle,"point.distance",temp_d))

{

if( temp_d < d )

{

d=temp_d;

}

}

}

if (d <= r)

{

return(d);

}

else

{

return(0);

}

}

Link to comment
Share on other sites

Hi Sven,

I can't see anything obviously wrong with your function.

So just throwing out a few suggestions.

The obvious question is there something wrong with the way it is called. Ie how does r get set?

It might be worth sticking a few "printf"s in there to see what values are getting returned, that might help you track down the problem.

Have you checked that the file path to your cloud is a correct path?

If this in a sop you need to use the full path. And if it's in a shader it has to be a path to an existing disk bgeo or tbf, I don't think you can use the op: path syntax. (not 100% sure about that though)

Also, have you made sure mp is in object space?

mp = wo_space(P);

Link to comment
Share on other sites

Oh well actually i never got the printf output working on windows :o Maybe someone can help me with this too .

oh and heres the part where the function gets called :

for (i = 0;i < steps; i++)

{

os_marchpoint = wo_space(marchpoint);

dnoise += density_function(marchpoint,distance(os_marchpoint,{0,0,0}));

density += PC_GetDensity ( filename,os_marchpoint,radius);

marchpoint += dir;

}

Link to comment
Share on other sites

to use printf on windows in a shader just add a line like

printf("os_marchpoint %g \n", os_marchpoint);

then in the renderer set the output to verbose and set a file for the output.

mantra -V 1 -o "C:\Temp\debug.txt"

Another good way to debug is to create an exported parameter and output that in a deep raster.

So in your parameter list add

export float foo = 0;

then set foo to something useful, and in the deep raster tab set foo as one of your deep rasters.

One final thing, I've had problems on windows where a shader will only return 1 for the whole shader and it's turned out to be an otl issue, depending on how the shader was created. If you have your code in an otl it might be worth trying to resave it to another otl that sometimes kicks it back into life.

Link to comment
Share on other sites

With VCC ( i am using Cutter for developing shaders )

actually it looks like if i write a shader that doesnt use pointclouds compile that into an otl and then add pointcloud functions and recompile into the same otl this happens.

if i delete the otl and then compile it works.

i will try to make a without and a with pointcloud functions shader that makes the problem repeatable by compiling them .

Sven

Link to comment
Share on other sites

Hey Sven,

Why do you prefer Vim over Cutter Mario ?

19422[/snapback]

Heh... I never said I preferred it *over* cutter (esp. since I've never used cutter)... I was just offering it up as another good text editor worth checking out.

Vim (and its predecessor VI) takes some getting used to, no doubt. It's all keyboard based so it's interface is, uhmm... "unintuitive" shall we say? :P

But once you get to know it... wow... everything's under your fingers, so you're just flying! Editting becomes insanely fast and flexible... but maybe the whole keyboard thing only appeals to old farts like me :)

Anyway; check it out if you've got nothing better to do.

Link to comment
Share on other sites

But once you get to know it... wow... everything's under your fingers, so you're just flying! Editting becomes insanely fast and flexible... but maybe the whole keyboard thing only appeals to old farts like me :)

The later versions of gvim (vim) are pretty mouse friendly. I'm still a fresh fart so I use the mouse a good bit to navigate through files in vim. If I find myself using a menu all the time I break down and learn the keyboard command for it.

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.

Guest
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...