Jump to content

pcloud en external data


davidyannick

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
Link to comment
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
Link to comment
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 :)

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