Quote Originally Posted by jahrain View Post
Also, another issues is triangle stripping.

I realized that the index data consists of triangle strips, not just triangles as I have assumed which is why the polygons look so garbled. In the gbxmodels, the triangles seem to be in triangle strip format as well since it can be seen with the intentional degenerate triangles in the tags. Usually with triangle strips, a degenerate triangle, usually contains 2 of the same vertex coords indicies. You will see many of those in the gbxmodel tags's triangle block, which is why I assume it also uses triangle strips.

Converting a model into a series of triangle strips is definitely something that seems challenging as it involves some graph theory.
Are you serious? That has nothing to do with anything.

The reason that you get degenerate triangles is because of the way the JMS was imported in Halo 1. The post-processing done in Tool created degens, which the game ignores. In Halo 2, the processing done by the exporter breaks down verts along smoothing groups so the compiler doesn't have to distinguish. Undoing the process in the gbxmodel tag isn't that hard. How else do you think I made a gbxmodel importer?

Code:
triangle_vertices = (geometry_part_triangle_blocks[g][p] * 3)
for t = 1 to triangle_vertices do
(
	append vertex_order ((readShortB "#signed") + 1)
)

vo_count = vertex_order.count
if vertex_order[vo_count] == 0 do deleteItem vertex_order (vo_count)
if vertex_order[vo_count-1] == 0 do deleteItem vertex_order (vo_count-1)

for w = 1 to (vertex_order.count - 2) do
(
	triangles[w] = [vertex_order[w],vertex_order[w+1],vertex_order[w+2]]
)
				
for r = 1 to triangles.count by 2 do
(
	a = triangles[r][1]
	triangles[r][1] = triangles[r][3]
	triangles[r][3] = a
)
			
for d = triangles.count to 1 by -1 do
(
	if (triangles[d][1] == triangles[d][2]) or (triangles[d][2] == triangles[d][3]) or (triangles[d][1] == triangles[d][3]) then
	(
		deleteItem triangles d
	)
)
I'll translate that to English for you...

There are 4 for-loops, each has a purpose:

  1. Read the vertex order from the tag
  2. Create triangles from every 3 vertices
  3. Reverse the vertex indices
  4. Remove degenerate triangles

Voila, your model no longer looks like crap.