Jump to content
davidyannick

pcloud en external data

Recommended Posts

I'm learning procedural modeling, I'm trying to find nearest points from a sphere with this 

@Cd=0;

// point d'origine
int origin=chi("Origin");

// Distance séparant les points
float distance=ch("Distance");

// nombre de points à retourner
int amount=chi("Amount");


int target;

// retourne la position du point d'origine
vector pos=point(1,"P",origin);
printf("pos: %d\n",pos);

// stocke les positions des "amount "points à une distance de "distance" 
int pcloud=pcopen(0,"P",pos,distance,amount);

if(pcnumfound(pcloud)>0){
    while(pciterate(pcloud)){
    // stocke le numéro du point dans target par référence
        pcimport(pcloud,"point.number",target);
        setpointattrib(0,"Cd",target,{1,0,0},"set");
    }
}

and the vector pos is always 0,0,0 even if a sphere is plugged in 1 ?

I' ve found this example on youtube and it works ?

 

Thanks for your help

 

pcloud.hipnc

Edited by davidyannick
error

Share this post


Link to post
Share on other sites

It took me quite a while to understand what is happening there :) looks like very overcomplicated code for a simple task.

vector pos is returning 0 as in code:

vector pos=point(1,"P",origin);

You are asking for P (position) from input 1 (your sphere) of the point number "origin" which in your case is "115" in hip you sent.

Your sphere has only 1 point (number 0). There is no point number "115" therefore it fails and returns {0,0,0}.

 

ps. You don't need to export output to terminal to debug this (using printf), you can just export global variable and have live output of your work in "geometry spreadsheet" @test = pos;

SideFX help file is very extensive and worth reading! Better than getting wrong ideas from youtube and potentially inexperienced people :)

Edited by tmdag
  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, tmdag said:

It took me quite a while to understand what is happening there :) looks like very overcomplicated code for a simple task.

vector pos is returning 0 as in code:

vector pos=point(1,"P",origin);

You are asking for P (position) from input 1 (your sphere) of the point number "origin" which in your case is "115" in hip you sent.

Your sphere has only 1 point (number 0). There is no point number "115" therefore it fails and returns {0,0,0}.

 

ps. You don't need to export output to terminal to debug this (using printf), you can just export global variable and have live output of your work in "geometry spreadsheet"

Shame on me I didn't see it ..

Thank you for your help next time I'll pay more attention :)

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

×