• entries
743
1924
• views
584168

# Tired but happy

127 views

All seems to be working now. Got point vs circle and point vs polygon collisions working as well as circle-circle and circle-polygon, plus more efficient point-in-circle and point-in-polygon routines that don't bother to compute a push vector (for 2D picking).

It is all starting to make a bit more sense now as well. I'm hoping that all this exposure to 2D vector maths will bear me in good stead if I ever get round to attempting 3D games, although I think that 2D polygon based games is going to keep me occupied for quite a long time yet.

I'm probably going to rewrite my polygon map editor, since I reckon I can now do the maths to constrain user-drawn polygons to convex. I'd also like to find a way to optimally divide a user-drawn convex polygon into minimum triangles so that I can automate the conversion from collision shapes into renderable triangles.

Dunno really. All this recent activity has opened up so many new possiblities in terms of feasible games that I'm not sure at the moment which way to turn.

I am tempted to write an Arknoid clone that has non-axis-aligned and non-rectangular bricks, just to show off. I may even call it Seperating Arknoid Theorum.

I really should get out more.

Quote:
 Original post by EasilyConfused I'd also like to find a way to optimally divide a user-drawn convex polygon into minimum triangles so that I can automate the conversion from collision shapes into renderable triangles.

I'm not 100%, but I think the optimal solution is drawing your convex polygons as a triangle-fan, using the centroid as a base, and just moving clockwise around the vertices.

##### Link to comment
if it's a convex polygon, you just need to index around the shape.

Indices:

0 1 2
0 2 3
0 3 4
0 4 5
0 5 6
etc

big ol' triangle fan!

##### Link to comment
Oh yeah. That would work. Then I could just delete any degenerate triangles.

Cheers.

##### Link to comment
Is there any reason why you're restricting yourself to convex polys? I did the same thing for a game/tool a while back and got mixed results - it makes collision and rendering easier but makes it more tedious to actually use the editor. I'm still divided on the issue for my new editor.

BTW, I found you get better results if you avarage the vertices to find a rough center and then use that as a root of a triangle fan. That means you get consistant triangulation (instead of the slight randomness of starting the fan from an edge) which means you can do nice vertex colours and cheesy lighting effects. [grin]

##### Link to comment
Quote:
 Original post by OrangyTang Is there any reason why you're restricting yourself to convex polys? I did the same thing for a game/tool a while back and got mixed results - it makes collision and rendering easier but makes it more tedious to actually use the editor. I'm still divided on the issue for my new editor.

Mainly because I haven't got a clue how to do collision detection and response for non-convex polygons. Plus I guess splitting them into triangles would be harder for rendering, so pretty much as you say above really. I'm a great believer in moving complexity out of games into editors really, since the game is more important.

Quote:
 Original post by OrangyTang BTW, I found you get better results if you avarage the vertices to find a rough center and then use that as a root of a triangle fan. That means you get consistant triangulation (instead of the slight randomness of starting the fan from an edge) which means you can do nice vertex colours and cheesy lighting effects. [grin]

Sounds like a good idea. I guess you only do this for polygons with five or more sides, since it doesn't make sense for a triangle or a quad.

Cheers for the input.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account