Jump to content

Remove Primitive by Sphere


CinnamonMetal

Recommended Posts

if(@primnum>45){
vector ghh = point(1,"P",i);
removeprim(0,ghh,1);

I'm hoping I can get some help.  

*ghh* is a variable which represents a sphere.  What I want is, when moving the sphere around if it should come in contact with primitives with numbers greater then 45 then it removes those primitives; although it's not working, what am I doing wrong ?

Link to comment
Share on other sites

Is your sphre (the « trigger » object) a simple primitive (therefore only one point), or is it polygon sphres, with many points ? 

What you can do is use the xyzdist vex function to calculate, for each point or primitive of your object, the closest distance to the sphere, and when it reaches a threshold close to zero (ie. When there is contact), you use removeprim.

But this is very similar to the use of the trasnfer attribute and grouping method explained above.

 

Link to comment
Share on other sites

This should work:

// Get distance of primitive to point position of second input, Sphere is plugged in to second input //
float dist = distance(@P, point(1, "P", 0));
// Get radius of sphere, I made a relative reference to the spheres scale in the radius parameter that is created //
float rad = chf("radius");
// If the primitive is inside the sphere, delete//
if(dist<=rad){
	removeprim(0, @primnum, 1);
}

 

Edited by Sean-R
Fixed code error
  • Like 1
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...