From 0f4ccadaa4341a9c789710a507f5bc30856b8fd8 Mon Sep 17 00:00:00 2001 From: ABelliqueux Date: Fri, 2 Apr 2021 15:37:38 +0200 Subject: [PATCH] unitary portal padding --- io_export_psx_tmesh.py | 63 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 7 deletions(-) diff --git a/io_export_psx_tmesh.py b/io_export_psx_tmesh.py index 1bb6224..e475032 100644 --- a/io_export_psx_tmesh.py +++ b/io_export_psx_tmesh.py @@ -1464,6 +1464,58 @@ class ExportMyFormat(bpy.types.Operator, ExportHelper): visibleTarget.append( bpy.data.objects[ actorPtr ] ) + # If visiblePortal length is under 2, this means there's only one portal + + # Empty strings to be populated depending on portal position (left/right of screen) + + before = '' + + after = '' + + if len( visiblePortal ) < 2 : + + # Find wich side of screen the portal is on. left side : portal == bw, right side : portal == fw + + screenCenterX = int( scene.render.resolution_x / 2 ) + + screenY = int( scene.render.resolution_y ) + + # Get vertices screen coordinates + + s = objVertWtoS(scene, camera, visiblePortal[0]) + + # Check line + + side = checkLine( + screenCenterX, 0, screenCenterX, screenY, + + s[1].x, + + s[1].y, + + s[3].x, + + s[3].y + ) + + + # If front == right of screen : fw + + if side == "front": + + # ~ print(str(visiblePortal[0]) + ' : fw') + + before = "\t{\n\t\t{ 0, 0, 0, 0 },\n\t\t{ 0, 0, 0, 0 },\n\t\t{ 0, 0, 0, 0 },\n\t\t{ 0, 0, 0, 0 }\n\t},\n" + + # If back == left of screen : bw + + else : + + # ~ print(str(visiblePortal[0]) + " : bw") + + after = "\t{\n\t\t{ 0, 0, 0, 0 },\n\t\t{ 0, 0, 0, 0 },\n\t\t{ 0, 0, 0, 0 },\n\t\t{ 0, 0, 0, 0 }\n\t},\n" + + prefix = CleanName(camera.name) # Include Tim data @@ -1490,17 +1542,13 @@ class ExportMyFormat(bpy.types.Operator, ExportHelper): "\t// Write quad NW, NE, SE, SW\n") - # If visiblePoratl length is under 2, this means there's only one portal, hence a fw portal - - if len( visiblePortal ) < 2 : - - f.write("\t{\n\t\t{ 0, 0, 0, 0 },\n\t\t{ 0, 0, 0, 0 },\n\t\t{ 0, 0, 0, 0 },\n\t\t{ 0, 0, 0, 0 }\n\t},\n") + f.write( before ) for portal in visiblePortal: w = objVertLtoW(portal) - f.write("// " + str(portal) + "\n" ) + # ~ f.write("\t// " + str(portal) + "\n" ) # Write portal'vertices world coordinates NW, NE, SE, SW @@ -1516,6 +1564,8 @@ class ExportMyFormat(bpy.types.Operator, ExportHelper): "\t},\n" ) + f.write( after ) + # UNUSED : Screen coords # ~ s = objVertWtoS( scene, camera, portal ) @@ -1734,7 +1784,6 @@ class ExportMyFormat(bpy.types.Operator, ExportHelper): # ~ print(0) PlanesRigidBodies[p] = { 'rigidbodies' : [ CleanName(moveable) ] } - # Find surrounding planes for op in LvlPlanes: