From ba32a8386a37549edc436cb512675e8717aee912 Mon Sep 17 00:00:00 2001 From: briangr Date: Sat, 5 Jun 2010 17:53:24 +0000 Subject: [PATCH] bug fix for acc importer in blender. Was not properly handling triangle strips on tracks such as manton.acc git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@2511 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 47678e22b203cac4d7242ac30855908923ba3a93 Former-commit-id: 93986efb1b873039dfbc0ce260993ecea326137b --- src/tools/blender/acc3d_import.py | 42 ++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/src/tools/blender/acc3d_import.py b/src/tools/blender/acc3d_import.py index a2e2205f..f7128b06 100644 --- a/src/tools/blender/acc3d_import.py +++ b/src/tools/blender/acc3d_import.py @@ -378,9 +378,12 @@ class AC3DImport: flags = lines[i].split()[1][2:] flag = lines[i].split()[1] tristrip = False + trifan = False if ((flag=='0x14')|(flag=='0x24')|(flag=='0x34')): tristrip = True - + + if flag =='0x30': + trifan = True; if len(flags) > 1: flaghigh = int(flags[0]) @@ -421,6 +424,8 @@ class AC3DImport: rfs -= 1 i += 1 + + #handle triangle strip convert into triangles if tristrip==True: index = 0 @@ -484,8 +489,35 @@ class AC3DImport: faces.append(facet) fuvs.append(fuvt) fuvs2.append(fuvt2) - + elif trifan==True: + index = 1 + while index0: + uv2 = fuv2[0]; + fuvt2.append(uv2) + + facet.append(face[index]) + uv = fuv[index]; + fuvt.append(uv) + if len(fuv2)>0: + uv2 = fuv2[index]; + fuvt2.append(uv2) + + facet.append(face[index+1]) + uv = fuv[index+1]; + fuvt.append(uv) + if len(fuv2)>0: + uv2 = fuv2[index+1]; + fuvt2.append(uv2) + + index+=2 elif flaglow: # it's a line or closed line, not a polygon while len(face) >= 2: @@ -497,6 +529,7 @@ class AC3DImport: face = [edges[-1][-1], edges[0][0]] edges.append(face) + else: # polygon Blender.Draw.PupMenu('Polygon found') @@ -851,7 +884,7 @@ class AC3DImport: basetex.setType('Image') map1=Texture.MapTo.COL|Texture.MapTo.ALPHA basetex.image = img - bl_textures[iname] = basetex; + bl_textures[iname] = basetex basetex = bl_textures[iname] m1.setTexture(0,basetex,Texture.TexCo.UV,map1) @@ -864,6 +897,9 @@ class AC3DImport: map2=Texture.MapTo.COL basetex2.image = img2 bl_textures[iname2] = basetex2 + else: + map2=Texture.MapTo.COL + basetex2 = bl_textures[iname2] m1.setTexture(1,basetex2,Texture.TexCo.UV,map2)