bentway23 Posted February 20, 2022 Share Posted February 20, 2022 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. Quote Link to comment Share on other sites More sharing options...
Atom Posted February 20, 2022 Share Posted February 20, 2022 The divide node contains an option called Compute Dual. Turn off convex polygons, and the resulting point set should be the center of every primitive. Quote Link to comment Share on other sites More sharing options...
bentway23 Posted February 20, 2022 Author Share Posted February 20, 2022 Thanks for your reply! I'm not looking for every primitive, though, but the center of and on an entire mesh surface. Quote Link to comment Share on other sites More sharing options...
ryew Posted February 20, 2022 Share Posted February 20, 2022 Given how wildly varying the center would be depending on the shape, it would be helpful to see an image of the type of surface you're attempting this on. Quote Link to comment Share on other sites More sharing options...
bentway23 Posted February 21, 2022 Author Share Posted February 21, 2022 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! Quote Link to comment Share on other sites More sharing options...
iamyog Posted February 21, 2022 Share Posted February 21, 2022 Use the extract centroid node. Quote Link to comment Share on other sites More sharing options...
bentway23 Posted February 21, 2022 Author Share Posted February 21, 2022 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). Quote Link to comment Share on other sites More sharing options...
bentway23 Posted February 22, 2022 Author Share Posted February 22, 2022 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 Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted February 22, 2022 Share Posted February 22, 2022 1 Quote Link to comment Share on other sites More sharing options...
AntoineSfx Posted February 22, 2022 Share Posted February 22, 2022 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 Quote Link to comment Share on other sites More sharing options...
bentway23 Posted February 22, 2022 Author Share Posted February 22, 2022 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.