Added support for Matt's teamcolour texture transparency to the g3d blender exporter #166 . [skip ci]

This commit is contained in:
Jammyjamjamman
2018-06-24 18:10:58 +01:00
parent 91af4e3dd3
commit f06d594db6

View File

@@ -227,6 +227,10 @@ class G3DMeshHeaderv4: #Read Meshheader
self.istwosided = bool(self.properties & 2)
self.noselect = bool(self.properties & 4)
self.glow = bool(self.properties & 8)
# Get last 8 bits for teamcolor transparency.
# The value is inverted for compatibility with megaglest.
self.teamcoloralpha = 255 - (self.properties >> 24)
self.hastexture = False
self.diffusetexture = None
@@ -360,6 +364,7 @@ def createMesh(filename, header, data, toblender, operator):
if header.isv4:
mesh.g3d_noSelect = header.noselect
mesh.g3d_glow = header.glow
mesh.teamcolor_alpha = header.teamcoloralpha
else:
mesh.g3d_noSelect = False
mesh.glow = False
@@ -528,6 +533,7 @@ def G3DLoader(filepath, toblender, operator): #Main Import Routine
print ("specularcolor : %1.6f %1.6f %1.6f" %meshheader.specularcolor)
print ("specularpower : %1.6f" %meshheader.specularpower)
print ("opacity : %1.6f" %meshheader.opacity)
print ("teamcoloralpha : %d" %meshheader.teamcoloralpha)
print ("properties : " + str(meshheader.properties))
print ("textures : " + str(meshheader.textures))
print ("texturename : " + str(meshheader.diffusetexture))
@@ -704,6 +710,7 @@ def G3DSaver(filepath, context, toglest, operator):
properties = 0
if mesh.g3d_customColor:
properties |= 1
properties |= (255 - mesh.teamcolor_alpha) << 24
if mesh.show_double_sided:
properties |= 2
if mesh.g3d_noSelect:
@@ -784,13 +791,15 @@ class G3DPanel(bpy.types.Panel):
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "data"
@classmethod
def poll(cls, context):
return (context.object is not None and context.object.type == 'MESH')
def draw(self, context):
self.layout.prop(context.object.data, "g3d_customColor")
col = self.layout.column()
col.prop(context.object.data, "teamcolor_alpha")
col.enabled = context.object.data.g3d_customColor
self.layout.prop(context.object.data, "show_double_sided", text="double sided")
self.layout.prop(context.object.data, "g3d_noSelect")
self.layout.prop(context.object.data, "g3d_fullyOpaque")
@@ -900,6 +909,11 @@ def register():
bpy.types.Mesh.g3d_glow = bpy.props.BoolProperty(
name="glow",
description="let objects glow like particles")
bpy.types.Mesh.teamcolor_alpha = bpy.props.IntProperty(
name="team color alpha",
description="set the transparency of the teamcolor part of the texture only",
default=0,
min=0, max=2**8-1)
bpy.utils.register_module(__name__)