- Home /
Find centres of the sides of a Hexagonal Mesh in UnityScript? Possible?
Imagine a Hexagonal Mesh. North and South are Horizontal. Is there a way to find the centre of the South East and South West facing edges of a Hexagon Mesh in UnityScript?
Or must I create bones/rigging in 3ds that sits right on those spots?
http://oi52.tinypic.com/141r1uc.jpg
Have a look at the above image link, hopefully this shows the spots I'm trying to find.
Forum Link: heres the same thing in the forum: http://forum.unity3d.com/threads/84024-Finding-midpoints-of-edges-on-a-hexagonal-mesh.
Any screenshots? Because hexagonal is a 2d term so it's the shape but not a volume and a Hexahedron would ba a cube ;). A screendhot that shows your mesh and the spots that you want to find would help. http://en.wikipedia.org/wiki/Hexahedron
Answer by DaveA · Mar 30, 2011 at 10:26 PM
Are you talking a single hexagon? You can do just about anything with a mesh:
http://unity3d.com/support/documentation/ScriptReference/Mesh.html
So get the edges you need and find their centers I'm guessing. Or the centroid of the whole thing, I'm not sure what you're asking: a value which is the average of those edges or a value for each edge?
Imagine a Hexagon, 6 tris, 7 verts (there's one in the middle) It's rotated so that the top and bottom edges are horizontal.
I want to locate the middle of the edges on on the South East and South West of the Hexagon. How do I know when I've located the correct verts to start making the calculation to find those middle points? Are the verts numbered somehow on import of the mesh?
Not ordered, and another post here says that they get reordered on import anyway. If this will really be that simple a mesh, you could construct it via script, then you'll know precisely what's what.
attached an image to help show the spots I'm hoping to discover.
Some ideas, none of them do I like: You could make some 'dummy' objects at the points you need, just empty transforms really, children of this object. You could find the center of the thing then Raycast in plane of the hexagon in the heading of the sides you want. Ech! You could construct the entire thing in code, then you know exactly what's what. You could make each side (or the sides you care about) submeshes. Perhaps each with a different material or something to differentiate it.
The Dummy objects idea is the one that I'm at right now. However there's still the issue of actually finding that mid point of the edge. In order to do that I need know the location of the two vertices that define that edge, in Unity. And that's my problem. I don't know enough about coding to find those vertices and then figure their mid point... so I keep thinking adding 12 more vertices is the solution, along with bones from a mid point to the object reaching to and touching each of those verts. 12 more verts, 24 more tris, 12 bones and a hip later its not the lightweight object it was
Your answer
![](https://koobas.hobune.stream/wayback/20220613115833im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Tile texture along edge of mesh 0 Answers
Create edges for vertices(JS) 1 Answer
Displaying precision edges of a mesh at runtime? 0 Answers