Meshes question: how do I bend a sprite?

1 favourites
  • 8 posts
From the Asset Store
Minimal Sprite Font with Stroke for Pixel Art games.
  • How do I make a "soft bend" to any given angle with minimal texture distortion? I want to do something like this:

    Tagged:

  • One way is to just make a curve for one edge. Cubic or qarp for example. Or even using the arc of a circle for minimal distortion. Then you can get points from one edge.

    You can get the other curved edge by moving the points out perpendicular from the curves angle.

    I’m probably not doing the idea justice without an example. I’ll try to make one tomorrow.

    This page has ideas how to bend roads which is very similar to what you’re trying to do.

    redblobgames.com/articles/curved-paths

    That guy’s whole site is full of a wealth of information.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks, Ro0j0!

    I understand your idea, but don't know how to implement it.

    I've already tried doing this with quarp/cubic, but the edges of the sprite are wrong.

    I guess I need three rows of points. Position the middle row in an arc, then move the top and bottom points perpendicular to the middle row, right? What would be the formula for this?

  • So this is what the math would look like.

    X,y is the position on the curve.

    If we advance t by a small amount and get that xy then subtract the position from that we get a direction vector.

    We can then normalize it to make it have a length of 1.

    So then if we swap xy and make one negative it’s the same as rotating 90 degrees.

    So we end up with a point 50 pixels to the left and right of a point on the curve.

    x = cubic(x0,x1,x2,x3,t)
    y = cubic(y0,y1,y2,y3,t)
    dx = cubic(x0,x1,x2,x3,t+0.001)-x
    dy = cubic(y0,y1,y2,y3,t+0.001)-y
    mag = distance(0,0,dx,dy)
    dx = dx/mag
    dy = dy/mag
    
    points:
    x+dy*50, y-dx*50
    x-dy*50, x+dy*50
  • Really wish we had some basic stuff like matrix transforms.

    tutorialspoint.com/computer_graphics/2d_transformation.htm

  • R0J0hound It worked! Thanks so much!

  • No problem. Glad it worked.

    newt

    You can already do that with functions somewhat.

    What I’d like to see is being able to have simple structures as values in addition to numbers, text and bools. Would make some events way more readable I think.

  • Well mostly for the editor. A billboard function specifically. I mean sure a 2x2 is easy but bigger mesh are just not feasible for in editor.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)