this post was submitted on 08 Aug 2026
64 points (98.5% liked)

Programming

28153 readers
307 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 3 years ago
MODERATORS
 

Inspired by this Lobsters thread, and some of the great comments within it, I would like to ask if anybody is doing some hobby programming this weekend?

you are viewing a single comment's thread
view the rest of the comments
[–] insomniac_lemon@lemmy.cafe 2 points 1 week ago (1 children)

That's how it could work when it gets to 3D anyway (with face-corner vertex color which I might not always need) but that'd be a pain to define by hand and the format I have I don't actually have a way to define the same point more than once as it's on a text grid.

for example, an oval

Note: it appears round here, but it isn't

#values: matrix_xres matrix_yres target_size vert_num
#vert pattern is cntrclckwse (related: replace 0 with @ for closed shape) or |/|/
31
15
160.0
9
               1               
                               
    2                     8    
                               
                               
                               
                               
3              @              7
                               
                               
                               
                               
    4                     6    
                               
               5               

Easier to edit in a text editor with syntax highlighting that marks spaces for a visible grid.
My face hinting idea also doesn't work with this shape due to orientation (would work as a more traditional octagon), it also seems to be more obvious/viable with a larger grid (looks right for a 32x32 star shape).


[–] e0qdk@reddthat.com 1 points 1 week ago (1 children)

I'm not sure I quite get it, but if I'm following correctly, you're using the numbers to indicate a sequence of vertices for a triangle fan here (with @ indicating the central vertex), right? If so, the vertices are used in more than one triangle; (0, 1, 2) and (0, 2, 3) are triangles that reuse vertex 0 (@) and vertex 2.

If that's what's going on then it should be fairly straightforward to turn shapes defined like this into extrusions; for the simplest case you duplicate and offset the triangle fan for the other end and then generate quads/pairs of triangles for the extruded faces of the prism -- and for more complicated cases you can repeat that (with planar alignment if needed) following a curve in small increments.

I might not be following though since I don't know what you mean by color index face hints.

[–] insomniac_lemon@lemmy.cafe 2 points 1 week ago* (last edited 1 week ago) (1 children)

You are right about a few things, though the key is that Raylib is what's creating the polygon (after I parse the text file into a sequence) and ideally I don't handle face/mesh creation myself (at low-level). Maybe eventually.

what you mean by color index face hints

For additional context on where faces are.

I've mentioned vertex color (ideal as face colors), but I probably do want to handle a 3-digit-hex color palette with object-library-wide management.

here's what I was thinking with verts no longer numbered (instead E for external, C for corner. even-odd might work better in some cases), index numbers as hints and for colorEach arm would be its own color

#values: matrix_xres matrix_yres target_size vert_num
#IDEA, fails with heart as there is only 1 corner vertex
32
32
160.0
11
                                
               E                
               1                
                                
                                
                                
                                
                                
                                
                                
                                
E2         C       C         3E 
                                
                                
               1                
              2@3               
              4 5               
         C           C          
                                
                                
                                
               C                
                                
                                
                                
                                
                                
                                
                                
     4                    5     
    E                      E    
                                


The reason I'm thinking about this is that it would be better to have one way to define verts. triangle_strip can generally do more (shapes with no central point) than triangle_fan, though I think the star here is the sort-of-thing that a single triangle_strip cannot do. That, and with numbering it only allows 62 verts (0..9, a..z, A..Z), and is a bit clunky to iterate on. Numbering, especially with a strip, is also a lot more complex as you get more verts. If I got to the point of making my own editor*, I might abstract this away so the user only works with points.

Use-in-code-wise I may have already solved fan-vs-strip with a function that just compares the values of the first few points to choose draw type, though I wasn't confident in that as it'd require a lot more testing. Might be better to store that in an enum as well.

* I wasn't quite sure of using what I already made for anything more than a simple arcade-like game, so that sort of kills motivation, needing to do even more technical work just to get visible results.

[–] e0qdk@reddthat.com 1 points 1 week ago* (last edited 1 week ago)

OK. I think I see what you're getting at. If you can figure out how to get it to the point of an outline, there are triangulation libraries that can fill in the mesh for you (I think I've mentioned one to you before a long time ago) if you want flat end caps on the extrusion. I'm not sure off the top of my head how you'd get to an outline from that star example though -- a few ideas come to mind, but they're very much half-baked ideas... :p

Best of luck!

Edit: the triangulation library I was thinking of: https://github.com/mapbox/earcut