CreatePolygonGeom with complex vertices

Topics: Developer Forum, User Forum
Apr 12, 2008 at 9:09 AM
Edited Apr 12, 2008 at 9:30 AM
I'm trying to import a map that consists of 864 points. The debug draw doesn't show any lines between the points, have included a screen shot. The map in debug draw just shows about 40-50 points as well, not 864. It's easy to drive through the geometry using an object, seems like it's only the points that makes collisions and they are pretty far between.

The geom is created as such:
GeomFactory.Instance.CreatePolygonGeom(GameScreen.physicsSimulator, body, vertices, 1);

I also tried SubDivideEdges() on the vertices with exactly the same result as above (same points on debug draw etc).

Anyone know what could be wrong (not a problem for me to give more information if needed)?

Created an box with polygons in the same way but with a mere 16 points. It shows all points and has lines in between them, collision works with this one.

Here is a screen shot of the debug draw for the complex and box vertices:

First 16 rows of the map vertices look like this:

? geom.LocalVertices;
Count = 864
0: {X:-99,9729 Y:112,1395}
1: {X:-117,9729 Y:72,13947}
2: {X:-123,9729 Y:108,1395}
3: {X:40,0271 Y:98,13947}
4: {X:24,0271 Y:82,13947}
5: {X:18,0271 Y:108,1395}
6: {X:18,0271 Y:108,1395}
7: {X:24,0271 Y:82,13947}
8: {X:-1,972904 Y:108,1395}
9: {X:24,0271 Y:82,13947}
10: {X:6,027096 Y:72,13947}
11: {X:-1,972904 Y:108,1395}
12: {X:-133,9729 Y:-25,86054}
13: {X:-145,9729 Y:-53,86053}
14: {X:-145,9729 Y:-29,86054}
15: {X:-133,9729 Y:-25,86054}

All 16 rows of the box vertices look like this:

? geom.LocalVertices;
Count = 16
0: {X:-25 Y:-25}
1: {X:-25 Y:-12,5}
2: {X:-25 Y:0}
3: {X:-25 Y:12,5}
4: {X:-25 Y:25}
5: {X:-12,5 Y:25}
6: {X:0 Y:25}
7: {X:12,5 Y:25}
8: {X:25 Y:25}
9: {X:25 Y:12,5}
10: {X:25 Y:0}
11: {X:25 Y:-12,5}
12: {X:25 Y:-25}
13: {X:12,5 Y:-25}
14: {X:0 Y:-25}
15: {X:-12,5 Y:-25}
Apr 13, 2008 at 12:27 AM

I use code from the triangle picking sample (TrianglePickingProcessor.cs) on the following URL to import vertices from the model to use in XNA/Farseer.

Seems like a bug that it doesn't draw the polylines from the triangle mesh, but could be wrong on this one. Should I report it as an issue? I could get a slimmed down example ready to look at in any case.
Apr 14, 2008 at 8:40 PM
do you know if the verts are in either clockwise or counterclockwise order?
Apr 14, 2008 at 8:42 PM
do you know if the verts are in clockwise or counter-clockwise order? They need to be one or the other.
Apr 14, 2008 at 9:38 PM
Edited Apr 14, 2008 at 9:43 PM
How can I tell? Got the map from a friend (who's creating the models) so don't know about that part really. I took the exported 3ds and converted it to X with Panda DirectX Exporter.

I also tried using the method ForceCounterClockWiseOrder() on the vertices, but had the same issue.
Apr 15, 2008 at 6:30 AM
Panda exports ClockWiseOrder (Thats why there is the option to force CounterClockWise).
Apr 15, 2008 at 7:10 AM
Ah ok. Yes, checked it out in the exporter now. I exported it clockwise which seems to be default for vertices too and it doesn't work out.

Could it be that the map includes 2 polygons (or 2 islands, it's just specified with points in the X format file anyway)?
Apr 15, 2008 at 10:54 AM
If I was you, I would try to step through the whole import procedure (modelling, panda export, XNA import) with a very simple polygon (triangle or square). If this works, the geometry causes failure. If it does not work either, you should check your import routine...
Apr 16, 2008 at 6:30 PM
Edited Apr 16, 2008 at 8:09 PM
My modeller friend is out of town for a couple of days but he told me that the collision model consists of two triangulated polygons with lots of vertices. I'm pretty sure that's suboptimal. Going to follow the advice creating a simple triangle polygon instead and verify the function before changing the collision model to become a strict polygon.