• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# How do you triangulate faces?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

4 replies to this topic

### #1Chris528  Members

Posted 13 August 2013 - 01:37 AM

Alright, after quite a bit of work I've been able to calculate all the points for all brushes from a source engine .vmf. For each face I have a set of verts but I'm not sure how to load this into a vbo.

If I'm not mistaken I should create a function that takes in the points of a face and outputs a list of triangles? Also I need this to work with cylinders, as my test map has a cylinder with 32 sides, which means both the top and bottom face each have 32 verts.

How would I go about doing that? I've messed around with quite a few opengl 3.3+ tutorials, but never worked on something this involved before.

Thanks, Chris528

### #2Sik_the_hedgehog  Members

Posted 13 August 2013 - 02:00 AM

If all faces are convex (they usually are), just turn them into the equivalent of triangle fans, i.e. the first triangle is vertices 0-1-2, the next is 0-2-3, the next 0-3-4, then 0-4-5, and so on.

Alternatively, just import it into an editor and make it triangulate the faces for you =P

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

### #3Hodgman  Moderators

Posted 13 August 2013 - 02:04 AM

I was typing a reply at the same time as Sik, so I'll delete what I was saying and just post the diagram that goes with his explanation of the fans ;)

Also, vmf files are not meant to be rendered directly (except in the editor). In Valve's engine/tools, the "brushes" from the map files are fed into a CSG algorithm, which produces the final geometry data.

### #4Chris528  Members

Posted 13 August 2013 - 03:03 AM

Also, vmf files are not meant to be rendered directly (except in the editor). In Valve's engine/tools, the "brushes" from the map files are fed into a CSG algorithm, which produces the final geometry data.

My immediate goal is to make a simple vmf viewer. In my first post I said I'd already parsed the vmf and calculated all the points from the planes. I'm just looking to split all the faces up into triangles.

Edited by Chris528, 13 August 2013 - 03:04 AM.

### #5Chris528  Members

Posted 13 August 2013 - 03:08 AM

If all faces are convex (they usually are), just turn them into the equivalent of triangle fans, i.e. the first triangle is vertices 0-1-2, the next is 0-2-3, the next 0-3-4, then 0-4-5, and so on.

Hey, thanks for your help.

I was thinking of doing the exact same thing before I asked here but couldn't figure it out, even after working on it for hours.

After messing around with the code a bit this morning I used your suggestion, and finally got a working loop that calculates all the triangles.(even for 32 sided cylinders)

Edited by Chris528, 13 August 2013 - 09:24 PM.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.