Jump to content

Place a point on center of surface


bentway23

Recommended Posts

Hey, guys--how can I place a single point at the topological surface center (not centroid) of a curved surface? This comes after a lot of fracturing and blasting various prims, so the resulting geo is 3D but in the curved-2D sense (vs. extruded/solid). I've tried raying points but based on the shape it will frequently find the closest distance to be right on the edge of the geo instead of nicely in the center using min distance, and using vectors is no better. (This includes raying points that start at the centroid of the pieces.) It's okay if it's not 100% perfect, so if it's easier to do this by removing points of the existing geo instead of scattering a new point that's fine. I think maybe creating per-resultant-piece UVs would be the ticket(?), but I'm not sure how I would make lumpy and not-all-connected geo into pretty square 1x1 UV islands. Perhaps I can abuse the measure sop somehow? Group outside/unshared edges, measure each point to the distance of each edge, average those distances, and grab the point with the closest to a bbox max * 0.5? These things are on the tip of my brain but not spilling out to my fingers on the keyboard.

Link to comment
Share on other sites

That's the thing--it has to accommodate wildly varying geo given what will be fed into it.

Thinking on this further, I realized that what I want is not so much an exact center of the surface, but more a weighted, center-of-mass-type center (but for a 2D object). On this one I am even slightly more clueless--could a vellum setup calculate a per-point mass which I could then use to extract a weighted center?

So many questions!said.jpg.08e3a7d866c2f4d8af2be97a83745727.jpgmeant.jpg.a7f73d053e2f93dc35edd1967059df47.jpg

Link to comment
Share on other sites

I looked at that, but if the overall surface is very curved (well-nigh spherical) then the centroid won't be near the surface itself--at least not near enough to get a reliable minpos/ray onto appropriate part of the surface (unless there's a way of using it that's not obvious).

Link to comment
Share on other sites

If anyone deals with this in the future, I figured out a solution. This might not be completely geodesically sound, but it's close enough for what I'm doing. I figure the best way to approximate a 2D "center of mass"-ish thing on a curved surface (which makes the centroid center of mass not work in this situation) is to find the point that is farthest away (distance along surface) from all surrounding edges.

First, in case there are various islands of geo, the areas of each are measured and all prims not part of the largest "island" are blasted.

Points on the outside (unshared) edges are grouped.

Using surfacedist, each point's distance to the nearest edge point is measured into @dist. This attribute is promoted to a detail (maximum), and all points except the one with the largest minimum distance to the edges are blasted.

mass_center_point_test.hiplc

Link to comment
Share on other sites

primuv can help

I don't know the relationship between the  P value computed by uvsample, and say, the P value the renderer is using when rendering the primitive, but you can try this

Those are 2 for loops, iterating on primuv for values in [0;1]

The input is is single non planar primitive, not a surface. Houdini is doing something do parametrize the surface (intrinsic UV), but I don't know what it's doing. 

 

You can skip all the loops and try this in detail wrangle:

vector p = primuv(0,"P",0,set(0,1,0));

int center = addpoint(0,p);
setpointgroup(0,"center",center,1,"set");
 

The set(u=0,v=1,w=0) reads like this:

u= location on the perimeter (in 0;1)

v=distance to the edge ( 0= on the perimeter; 1=center)

w= not used in this case

 

So set(0,1,0) defines a point that somewhere at the perimeter of the primitive, that is projected towards the center (v=1)

It should give you some kind of center to the primitive.

HTH

primuv.thumb.png.cc2d45e9a046ec1ade9fe274505085e3.png

Link to comment
Share on other sites

Thanks, Konstantin! That's more or less what I ended up doing, only using surfacedist in vex instead.

 

And thanks for the reply, Antoine! I thought about using UVs early on, but since it's a reusable setup the incoming geo will be different each time and not something that (with my knowledge, at least) can be easily/repeatably/usefully UVd in such a way to get reliable coordinates. Because I'm dealing with a surface and not just a primitive I ruled out primUV early on.

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