Jump to content
CinnamonMetal

Remove Primitive by Sphere

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 ?

Share this post


Link to post
Share on other sites

I see my error.

What I should've asked is; how can I translate a sphere around and when it comes in contact with the primitives of another object as in a sphere, it deletes primitives based on a threshold distance ?

Share this post


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

 

Share this post


Link to post
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

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

×