Search Unity

Bevel

Discussion in 'Scripting' started by RedHotFlashman, Jun 9, 2021.

  1. RedHotFlashman

    RedHotFlashman

    Joined:
    Mar 16, 2018
    Posts:
    35
    BevelExample.png
    Hello,
    I would like some help. In my project I have made a 2D spline editor. I extrude the closed splines to make 3D meshes. Some meshes need a beveled edge. I use simple sinus and cosines geometry to calculate the beveled edges. When the beveled edges cross each other (marked with red circles), I have to recalculate the connecting point. I check when the extruded edges are crossing in 2D space, and when the lines cross I have to recalculate the vertex position. My method works fine, but I want to learn a better way to code beveled edges. Anybody knows a blog that explains how to code 3D beveled edges.
    Thx.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,697
    The general process you're dealing with is called mitering and it comes from woodworking where you diagonally cut pieces of wood so when placed end-to-end at a specific angle, they still align.

    Look up mitering in the context of line rendering, or perhaps mitering errors, or mitering overlap.

    I know that there are a few different ways to attack the problem you have above, but I haven't messed with it personally in ages.
     
    RedHotFlashman likes this.
  3. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    3,992
    I'm actually a bit confused. What exactly are your input parameters? Also should the resulting mesh always be a rect with a rect cutout in the middle with one edge rounded? Do you only need the rounding / bevelling on the outside or do you also want it on the inside? How do you specify the size of the bevel?

    For example a long time ago I made this procedural rounded rectangle script. It's highly configurable. You can change the size of each corner individually. Though it's a full rounded rect, so no cutouts. Though the question is how your inner cutout shape should be. Should it have the same shape at the outer one? Is it ok if it's always a rect?
     
    RedHotFlashman likes this.