Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


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.

  • You cannot reply to this topic
4 replies to this topic

#1 Chris528   Members   -  Reputation: 186

Like
0Likes
Like

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

Sponsor:

#2 Sik_the_hedgehog   Crossbones+   -  Reputation: 1806

Like
1Likes
Like

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.

#3 Hodgman   Moderators   -  Reputation: 30926

Like
2Likes
Like

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 ;)

8l4C4yv.png

 

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.



#4 Chris528   Members   -  Reputation: 186

Like
0Likes
Like

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.


#5 Chris528   Members   -  Reputation: 186

Like
0Likes
Like

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.



PARTNERS