Skip to main content
GameDev.net gamedev.net
🔒 Locked

.x files Mesh data

Started by kuharh Mar 21, 2005 at 1:24 PM 2 replies 400+ views
Original Post
kuharh
kuharh
I have been experimenting with .x files from two software packages. One exports all the faces as triangles and another sometimes uses polygons with 4 or more verticies. Is there a simple way to take a n-sided polygon and break it up into triangles? I can load and draw mesh data from the software with all triangles. The other files do not load. example all triangles:

	Mesh CubeMesh {
		14;
		1.000000;-1.000000;1.000000;,
		1.000000;1.000000;1.000000;,
		-1.000000;-1.000000;1.000000;,
		-1.000000;1.000000;1.000000;,
		1.000000;-1.000000;-1.000000;,
		-1.000000;-1.000000;-1.000000;,
		-1.000000;1.000000;-1.000000;,
		1.000000;1.000000;-1.000000;,
		1.000000;-1.000000;1.000000;,
		1.000000;1.000000;1.000000;,
		1.000000;-1.000000;-1.000000;,
		1.000000;1.000000;-1.000000;,
		1.000000;1.000000;1.000000;,
		1.000000;-1.000000;1.000000;;
		12;
		3;1,3,2;,
		3;0,1,2;,
		3;2,5,4;,
		3;8,2,4;,
		3;2,3,6;,
		3;5,2,6;,
		3;9,7,6;,
		3;3,9,6;,
		3;10,5,6;,
		3;11,10,6;,
		3;10,11,12;,
		3;13,10,12;;

Other files

  Mesh pCubeShape1 {
   24;
   -0.500000;-0.500000;0.500000;,
   0.500000;-0.500000;0.500000;,
   -0.500000;0.500000;0.500000;,
   0.500000;0.500000;0.500000;,
   -0.500000;0.500000;-0.500000;,
   0.500000;0.500000;-0.500000;,
   -0.500000;-0.500000;-0.500000;,
   0.500000;-0.500000;-0.500000;,
   -0.500000;0.500000;0.500000;,
   0.500000;0.500000;0.500000;,
   -0.500000;0.500000;-0.500000;,
   0.500000;0.500000;-0.500000;,
   -0.500000;-0.500000;-0.500000;,
   0.500000;-0.500000;-0.500000;,
   0.500000;-0.500000;0.500000;,
   -0.500000;-0.500000;0.500000;,
   0.500000;-0.500000;0.500000;,
   0.500000;-0.500000;-0.500000;,
   0.500000;0.500000;-0.500000;,
   0.500000;0.500000;0.500000;,
   -0.500000;-0.500000;-0.500000;,
   -0.500000;-0.500000;0.500000;,
   -0.500000;0.500000;0.500000;,
   -0.500000;0.500000;-0.500000;;
   6;
   4;0,1,3,2;,
   4;8,9,5,4;,
   4;10,11,7,6;,
   4;12,13,14,15;,
   4;16,17,18,19;,
   4;20,21,22,23;;

jollyjeffers
jollyjeffers
Have you tried changing the export settings on whatever tools you're using??

At a guess, the 4-component list is outputting as quad's rather than triangles, so just splitting them down the middle should work; once it's loaded into an ID3DXMesh (or whatever) you can attempt to optimize it for the vertex cache so as to eliminate any mess you caused by reordering...

4;0,1,3,2;,   4;8,9,5,4;,goes to:   3;0,1,3;,   3;1,2,3;,   3;8,9,5;,   3;9,4,5;,


For a quad:
0--1|  ||  |2--3


Can become
0--1   0--1      1| /| = | /  +   /||/ |   |/      / |2--3   2      2--3


The winding order might not be correct, but I'm sure you can work that out with a bit of trial and error..

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
kuharh
kuharh
I was just curious to see if there was some general knowledge out there. I could handle the quads but I am concerned that complex geometries may have more complex polys and that my solution for converting a quad to triangles may not be sophisticated enough to handle them. I am also concerned about vertex order if I am splitting polys on my own. For now I will stick with gameSpaceLight since it seems to output in triangles.

Also I am not using ID3DXMesh since I am trying to handle everything from scratch ( that way I learn more). I am building my own Mesh class.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.