Renamed collision values. Credit to arookas for telling me about it
This commit is contained in:
parent
9433eeda5c
commit
266106b62b
1 changed files with 104 additions and 123 deletions
227
BlenderCOL.py
227
BlenderCOL.py
|
@ -48,31 +48,30 @@ class Vertex(Struct):
|
||||||
|
|
||||||
|
|
||||||
class Group(Struct):
|
class Group(Struct):
|
||||||
unknown0 = uint8 # 0,1,2,4,6,7,8,64,128,129,132,135,160,192, bitfield?
|
CollisionType = uint16 #Properties of collision. e.g. is it water? or what?
|
||||||
unknown1 = uint8 # 0-12
|
|
||||||
triangle_count = uint16
|
triangle_count = uint16
|
||||||
__padding__ = Padding(1,b'\x00')
|
|
||||||
has_unknown4 = bool8
|
__padding__ = Padding(1,b'\x00') #Group flags, set them to 0 here
|
||||||
__padding__ = Padding(2)
|
has_ColParameter = bool8 #Set 0x0001 to 1 if we have ColParameter values so the game doesn't ignore it
|
||||||
|
__padding__ = Padding(2)#Actual padding
|
||||||
vertex_index_offset = uint32
|
vertex_index_offset = uint32
|
||||||
unknown2_offset = uint32 # 0-18,20,21,23,24,27-31
|
TerrainType_offset = uint32 # 0-18,20,21,23,24,27-31
|
||||||
unknown3_offset = uint32 # 0-27
|
unknown_offset = uint32 # 0-27
|
||||||
unknown4_offset = uint32 # 0,1,2,3,4,8,255,6000,7500,7800,8000,8400,9000,10000,10300,12000,14000,17000,19000,20000,21000,22000,27500,30300
|
ColParameter_offset = uint32 # 0,1,2,3,4,8,255,6000,7500,7800,8000,8400,9000,10000,10300,12000,14000,17000,19000,20000,21000,22000,27500,30300
|
||||||
|
|
||||||
|
|
||||||
class Triangle:
|
class Triangle:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.vertex_indices = None
|
self.vertex_indices = None
|
||||||
self.unknown0 = 128
|
self.ColType = 0
|
||||||
self.unknown1 = 0
|
self.TerrainType = 0
|
||||||
self.unknown2 = 0
|
self.unknown = 0
|
||||||
self.unknown3 = 0
|
self.ColParameter = None
|
||||||
self.unknown4 = None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def has_unknown4(self):
|
def has_ColParameter(self):
|
||||||
return self.unknown4 is not None
|
return self.ColParameter is not None
|
||||||
|
|
||||||
|
|
||||||
def pack(stream,vertices,triangles): #pack triangles into col file
|
def pack(stream,vertices,triangles): #pack triangles into col file
|
||||||
|
@ -80,16 +79,13 @@ def pack(stream,vertices,triangles): #pack triangles into col file
|
||||||
|
|
||||||
for triangle in triangles:
|
for triangle in triangles:
|
||||||
for group in groups: #for each triangle add to appropriate group
|
for group in groups: #for each triangle add to appropriate group
|
||||||
if triangle.unknown0 != group.unknown0: continue #break out of loop to next cycle
|
if triangle.ColType != group.CollisionType: continue #break out of loop to next cycle
|
||||||
if triangle.unknown1 != group.unknown1: continue
|
|
||||||
if triangle.has_unknown4 != group.has_unknown4: continue
|
|
||||||
group.triangles.append(triangle)
|
group.triangles.append(triangle)
|
||||||
break
|
break
|
||||||
else: #if no group has been found
|
else: #if no group has been found
|
||||||
group = Group() #create a new group
|
group = Group() #create a new group
|
||||||
group.unknown0 = triangle.unknown0
|
group.CollisionType = triangle.ColType
|
||||||
group.unknown1 = triangle.unknown1
|
group.has_ColParameter = triangle.has_ColParameter
|
||||||
group.has_unknown4 = triangle.has_unknown4
|
|
||||||
group.triangles = [triangle]
|
group.triangles = [triangle]
|
||||||
groups.append(group) #add to list of groups
|
groups.append(group) #add to list of groups
|
||||||
|
|
||||||
|
@ -114,28 +110,27 @@ def pack(stream,vertices,triangles): #pack triangles into col file
|
||||||
uint16.pack(stream,triangle.vertex_indices[2])
|
uint16.pack(stream,triangle.vertex_indices[2])
|
||||||
|
|
||||||
for group in groups:
|
for group in groups:
|
||||||
group.unknown2_offset = stream.tell()
|
group.TerrainType_offset = stream.tell()
|
||||||
for triangle in group.triangles:
|
for triangle in group.triangles:
|
||||||
uint8.pack(stream,triangle.unknown2)
|
uint8.pack(stream,triangle.TerrainType)
|
||||||
|
|
||||||
for group in groups:
|
for group in groups:
|
||||||
group.unknown3_offset = stream.tell()
|
group.unknown_offset = stream.tell()
|
||||||
for triangle in group.triangles:
|
for triangle in group.triangles:
|
||||||
uint8.pack(stream,triangle.unknown3)
|
uint8.pack(stream,triangle.unknown)
|
||||||
|
|
||||||
for group in groups:
|
for group in groups:
|
||||||
if not group.has_unknown4:
|
if not group.has_ColParameter:
|
||||||
group.unknown4_offset = 0
|
group.ColParameter_offset = 0
|
||||||
else:
|
else:
|
||||||
group.unknown4_offset = stream.tell()
|
group.ColParameter_offset = stream.tell()
|
||||||
for triangle in group.triangles:
|
for triangle in group.triangles:
|
||||||
uint16.pack(stream,triangle.unknown4)
|
uint16.pack(stream,triangle.ColParameter)
|
||||||
|
|
||||||
stream.seek(header.group_offset)
|
stream.seek(header.group_offset)
|
||||||
for group in groups:
|
for group in groups:
|
||||||
Group.pack(stream,group)
|
Group.pack(stream,group)
|
||||||
|
|
||||||
|
|
||||||
def unpack(stream):
|
def unpack(stream):
|
||||||
header = Header.unpack(stream)
|
header = Header.unpack(stream)
|
||||||
|
|
||||||
|
@ -148,8 +143,7 @@ def unpack(stream):
|
||||||
for group in groups:
|
for group in groups:
|
||||||
group.triangles = [Triangle() for _ in range(group.triangle_count)]
|
group.triangles = [Triangle() for _ in range(group.triangle_count)]
|
||||||
for triangle in group.triangles:
|
for triangle in group.triangles:
|
||||||
triangle.unknown0 = group.unknown0
|
triangle.ColType = group.CollisionType
|
||||||
triangle.unknown1 = group.unknown1
|
|
||||||
|
|
||||||
for group in groups:
|
for group in groups:
|
||||||
stream.seek(group.vertex_index_offset)
|
stream.seek(group.vertex_index_offset)
|
||||||
|
@ -157,25 +151,26 @@ def unpack(stream):
|
||||||
triangle.vertex_indices = [uint16.unpack(stream) for _ in range(3)]
|
triangle.vertex_indices = [uint16.unpack(stream) for _ in range(3)]
|
||||||
|
|
||||||
for group in groups:
|
for group in groups:
|
||||||
stream.seek(group.unknown2_offset)
|
stream.seek(group.TerrainType_offset)
|
||||||
for triangle in group.triangles:
|
for triangle in group.triangles:
|
||||||
triangle.unknown2 = uint8.unpack(stream)
|
triangle.TerrainType = uint8.unpack(stream)
|
||||||
|
|
||||||
for group in groups:
|
for group in groups:
|
||||||
stream.seek(group.unknown3_offset)
|
stream.seek(group.unknown_offset)
|
||||||
for triangle in group.triangles:
|
for triangle in group.triangles:
|
||||||
triangle.unknown3 = uint8.unpack(stream)
|
triangle.unknown = uint8.unpack(stream)
|
||||||
|
|
||||||
for group in groups:
|
for group in groups:
|
||||||
if not group.has_unknown4: continue
|
if not group.has_ColParameter: continue
|
||||||
stream.seek(group.unknown4_offset)
|
stream.seek(group.ColParameter_offset)
|
||||||
for triangle in group.triangles:
|
for triangle in group.triangles:
|
||||||
triangle.unknown4 = uint16.unpack(stream)
|
triangle.ColParameter = uint16.unpack(stream)
|
||||||
|
|
||||||
triangles = sum((group.triangles for group in groups),[])
|
triangles = sum((group.triangles for group in groups),[])
|
||||||
|
|
||||||
return vertices,triangles
|
return vertices,triangles
|
||||||
|
|
||||||
|
|
||||||
class ImportCOL(Operator, ExportHelper): #Operator that exports the collision model into .col file
|
class ImportCOL(Operator, ExportHelper): #Operator that exports the collision model into .col file
|
||||||
"""Import a COL file"""
|
"""Import a COL file"""
|
||||||
bl_idname = "import_mesh.col"
|
bl_idname = "import_mesh.col"
|
||||||
|
@ -204,12 +199,11 @@ class ImportCOL(Operator, ExportHelper): #Operator that exports the collision mo
|
||||||
|
|
||||||
mesh = bpy.context.object.data
|
mesh = bpy.context.object.data
|
||||||
bm = bmesh.new()
|
bm = bmesh.new()
|
||||||
U0Layer = bm.faces.layers.int.new(CollisionLayer.Unknown0.value) #Create new data layers
|
ColTypeLayer = bm.faces.layers.int.new(CollisionLayer.ColType.value) #Create new data layers
|
||||||
U1Layer = bm.faces.layers.int.new(CollisionLayer.Unknown1.value)
|
TerrainTypeLayer = bm.faces.layers.int.new(CollisionLayer.TerrainType.value)
|
||||||
U2Layer = bm.faces.layers.int.new(CollisionLayer.Unknown2.value)
|
UnknownFieldLayer = bm.faces.layers.int.new(CollisionLayer.Unknown.value)
|
||||||
U3Layer = bm.faces.layers.int.new(CollisionLayer.Unknown3.value)
|
HasColParameterFieldLayer = bm.faces.layers.int.new(CollisionLayer.HasColParameter.value)
|
||||||
HasU4Layer = bm.faces.layers.int.new(CollisionLayer.HasUnknown4.value)
|
ColParameterFieldLayer = bm.faces.layers.int.new(CollisionLayer.ColParameter.value)
|
||||||
U4Layer = bm.faces.layers.int.new(CollisionLayer.Unknown4.value)
|
|
||||||
|
|
||||||
BMeshVertexList = []
|
BMeshVertexList = []
|
||||||
|
|
||||||
|
@ -220,13 +214,12 @@ class ImportCOL(Operator, ExportHelper): #Operator that exports the collision mo
|
||||||
for f in Triangles:
|
for f in Triangles:
|
||||||
try: #Try and catch to avoid exception on duplicate triangles. Dodgy...
|
try: #Try and catch to avoid exception on duplicate triangles. Dodgy...
|
||||||
MyFace = bm.faces.new((BMeshVertexList[f.vertex_indices[0]],BMeshVertexList[f.vertex_indices[1]],BMeshVertexList[f.vertex_indices[2]]))
|
MyFace = bm.faces.new((BMeshVertexList[f.vertex_indices[0]],BMeshVertexList[f.vertex_indices[1]],BMeshVertexList[f.vertex_indices[2]]))
|
||||||
MyFace[U0Layer] = f.unknown0
|
MyFace[ColTypeLayer] = f.ColType
|
||||||
MyFace[U1Layer] = f.unknown1
|
MyFace[TerrainTypeLayer] = f.TerrainType
|
||||||
MyFace[U2Layer] = f.unknown2
|
MyFace[UnknownFieldLayer] = f.Unknown
|
||||||
MyFace[U3Layer] = f.unknown3
|
MyFace[ColParameterFieldLayer] = f.ColParameter
|
||||||
MyFace[U4Layer] = f.unknown4
|
if MyFace[ColParameterFieldLayer] is not None:
|
||||||
if MyFace[U4Layer] is not None:
|
MyFace[HasColParameterFieldLayer] = True
|
||||||
MyFace[HasU4Layer] = True
|
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -267,12 +260,11 @@ class ExportCOL(Operator, ExportHelper): #Operator that exports the collision mo
|
||||||
|
|
||||||
bmesh.ops.triangulate(bm, faces=bm.faces[:], quad_method=0, ngon_method=0) #triangulate bmesh
|
bmesh.ops.triangulate(bm, faces=bm.faces[:], quad_method=0, ngon_method=0) #triangulate bmesh
|
||||||
#triangulate_mesh(Mesh)
|
#triangulate_mesh(Mesh)
|
||||||
U0Layer = bm.faces.layers.int.get(CollisionLayer.Unknown0.value)
|
ColTypeLayer = bm.faces.layers.int.get(CollisionLayer.ColType.value)
|
||||||
U1Layer = bm.faces.layers.int.get(CollisionLayer.Unknown1.value)
|
TerrainTypeLayer = bm.faces.layers.int.get(CollisionLayer.TerrainType.value)
|
||||||
U2Layer = bm.faces.layers.int.get(CollisionLayer.Unknown2.value)
|
UnknownFieldLayer = bm.faces.layers.int.get(CollisionLayer.Unknown.value)
|
||||||
U3Layer = bm.faces.layers.int.get(CollisionLayer.Unknown3.value)
|
HasColParameterFieldLayer = bm.faces.layers.int.get(CollisionLayer.HasColParameter.value)
|
||||||
HasU4Layer = bm.faces.layers.int.get(CollisionLayer.HasUnknown4.value)
|
ColParameterFieldLayer = bm.faces.layers.int.get(CollisionLayer.ColParameter.value)
|
||||||
U4Layer = bm.faces.layers.int.get(CollisionLayer.Unknown4.value)
|
|
||||||
|
|
||||||
|
|
||||||
for Vert in bm.verts:
|
for Vert in bm.verts:
|
||||||
|
@ -281,13 +273,12 @@ class ExportCOL(Operator, ExportHelper): #Operator that exports the collision mo
|
||||||
for Face in bm.faces:
|
for Face in bm.faces:
|
||||||
MyTriangle = Triangle()
|
MyTriangle = Triangle()
|
||||||
MyTriangle.vertex_indices = [Face.verts[0].index,Face.verts[1].index,Face.verts[2].index] #add three vertex indicies
|
MyTriangle.vertex_indices = [Face.verts[0].index,Face.verts[1].index,Face.verts[2].index] #add three vertex indicies
|
||||||
if U0Layer is not None:
|
if ColTypeLayer is not None:
|
||||||
MyTriangle.unknown0 = Face[U0Layer]
|
MyTriangle.ColType = Face[ColTypeLayer]
|
||||||
MyTriangle.unknown1 = Face[U1Layer]
|
MyTriangle.TerrainType = Face[TerrainTypeLayer]
|
||||||
MyTriangle.unknown2 = Face[U2Layer]
|
MyTriangle.Unknown = Face[UnknownFieldLayer]
|
||||||
MyTriangle.unknown3 = Face[U3Layer]
|
if Face[HasColParameterFieldLayer] != 0:
|
||||||
if Face[HasU4Layer] != 0:
|
MyTriangle.ColParameter = Face[ColParameterFieldLayer]
|
||||||
MyTriangle.unknown4 = Face[U4Layer]
|
|
||||||
Triangles.append(MyTriangle) #add triangles
|
Triangles.append(MyTriangle) #add triangles
|
||||||
|
|
||||||
ColStream = open(self.filepath,'wb')
|
ColStream = open(self.filepath,'wb')
|
||||||
|
@ -295,45 +286,40 @@ class ExportCOL(Operator, ExportHelper): #Operator that exports the collision mo
|
||||||
return {'FINISHED'} # this lets blender know the operator finished successfully.
|
return {'FINISHED'} # this lets blender know the operator finished successfully.
|
||||||
|
|
||||||
class CollisionLayer(Enum): #This stores the data layer names that each Unknown will be on.
|
class CollisionLayer(Enum): #This stores the data layer names that each Unknown will be on.
|
||||||
Unknown0 = "CollisionEditorUnknown0"
|
ColType = "CollisionEditorColType"
|
||||||
Unknown1 = "CollisionEditorUnknown1"
|
TerrainType = "CollisionEditorTerrainType" #For example TerrainType is stored on a data layer called "CollisionEditorTerrainType"
|
||||||
Unknown2 = "CollisionEditorUnknown2" #For example Unknown2 is stored on a data layer called "CollisionEditorUnknown2"
|
Unknown = "CollisionEditorUnknown"
|
||||||
Unknown3 = "CollisionEditorUnknown3"
|
HasColParameter = "CollisionEditorHasColParameter" #This layer is an integer because boolean layers don't exist
|
||||||
HasUnknown4 = "CollisionEditorHasUnknown4" #This layer is an integer because boolean layers don't exist
|
ColParameter = "CollisionEditorColParameter"
|
||||||
Unknown4 = "CollisionEditorUnknown4"
|
|
||||||
|
|
||||||
def U0Update(self, context): #These functions are called when the UI elements change
|
def ColTypeUpdate(self, context): #These functions are called when the UI elements change
|
||||||
ChangeValuesOfSelection(CollisionLayer.Unknown0.value,bpy.context.scene.ColEditor.U0)
|
ChangeValuesOfSelection(CollisionLayer.ColType.value,bpy.context.scene.ColEditor.ColType)
|
||||||
return
|
return
|
||||||
|
|
||||||
def U1Update(self, context): #It would be nice to call ChangeValuesOfSelection directly but Update Functions can't have parameters as far as I am aware
|
|
||||||
ChangeValuesOfSelection(CollisionLayer.Unknown1.value,bpy.context.scene.ColEditor.U1)
|
|
||||||
return
|
|
||||||
|
|
||||||
def U2Update(self, context):
|
def TerrainTypeUpdate(self, context):
|
||||||
ChangeValuesOfSelection(CollisionLayer.Unknown2.value,bpy.context.scene.ColEditor.U2)
|
ChangeValuesOfSelection(CollisionLayer.TerrainType.value,bpy.context.scene.ColEditor.TerrainType)
|
||||||
return
|
return
|
||||||
|
|
||||||
def U3Update(self, context):
|
def UnknownFieldUpdate(self, context):
|
||||||
ChangeValuesOfSelection(CollisionLayer.Unknown3.value,bpy.context.scene.ColEditor.U3)
|
ChangeValuesOfSelection(CollisionLayer.Unknown.value,bpy.context.scene.ColEditor.UnknownField)
|
||||||
return
|
return
|
||||||
|
|
||||||
def HasU4Update(self, context):
|
def HasColParameterFieldUpdate(self, context):
|
||||||
ToSet = 1 if bpy.context.scene.ColEditor.HasU4 else 0 #In this case a TRUE value is represented by a 1 and FALSE by 0
|
ToSet = 1 if bpy.context.scene.ColEditor.HasColParameterField else 0 #In this case a TRUE value is represented by a 1 and FALSE by 0
|
||||||
ChangeValuesOfSelection(CollisionLayer.HasUnknown4.value,ToSet)
|
ChangeValuesOfSelection(CollisionLayer.HasColParameter.value,ToSet)
|
||||||
return
|
return
|
||||||
|
|
||||||
def U4Update(self, context):
|
def ColParameterFieldUpdate(self, context):
|
||||||
ChangeValuesOfSelection(CollisionLayer.Unknown4.value,bpy.context.scene.ColEditor.U4)
|
ChangeValuesOfSelection(CollisionLayer.ColParameter.value,bpy.context.scene.ColEditor.ColParameterField)
|
||||||
return
|
return
|
||||||
|
|
||||||
class CollisionProperties(PropertyGroup): #This defines the UI elements
|
class CollisionProperties(PropertyGroup): #This defines the UI elements
|
||||||
U0 = IntProperty(name = "Unknown 0",default=0, min=0, max=255, update = U0Update) #Here we put parameters for the UI elements and point to the Update functions
|
ColType = IntProperty(name = "Collision type",default=0, min=0, max=65535,update = ColTypeUpdate) #Here we put parameters for the UI elements and point to the Update functions
|
||||||
U1 = IntProperty(name = "Unknown 1",default=0, min=0, max=255, update = U1Update)
|
TerrainType = IntProperty(name = "Sound",default=0, min=0, max=255,update = TerrainTypeUpdate)
|
||||||
U2 = IntProperty(name = "Unknown 2",default=0, min=0, max=255, update = U2Update)
|
UnknownField = IntProperty(name = "Unknown",default=0, min=0, max=255,update = UnknownFieldUpdate)#I probably should have made these an array
|
||||||
U3 = IntProperty(name = "Unknown 3",default=0, min=0, max=255, update = U3Update)#I probably should have made these an array
|
HasColParameterField = BoolProperty(name="Has Parameter", default=False,update = HasColParameterFieldUpdate)
|
||||||
HasU4 = BoolProperty(name="Has Unknown 4", default=False, update = HasU4Update)
|
ColParameterField = IntProperty(name = "Parameter",default=0, min=0, max=65535,update = ColParameterFieldUpdate)
|
||||||
U4 = IntProperty(name = "Unknown 4",default=0, min=0, max=65535, update = U4Update)
|
|
||||||
|
|
||||||
class CollisionPanel(Panel): #This panel houses the UI elements defined in the CollisionProperties
|
class CollisionPanel(Panel): #This panel houses the UI elements defined in the CollisionProperties
|
||||||
bl_label = "Edit Collision Values"
|
bl_label = "Edit Collision Values"
|
||||||
|
@ -351,8 +337,8 @@ class CollisionPanel(Panel): #This panel houses the UI elements defined in the C
|
||||||
if(bpy.context.object.mode == 'EDIT'):
|
if(bpy.context.object.mode == 'EDIT'):
|
||||||
obj = bpy.context.scene.objects.active #This method might be quite taxing
|
obj = bpy.context.scene.objects.active #This method might be quite taxing
|
||||||
bm = bmesh.from_edit_mesh(obj.data)
|
bm = bmesh.from_edit_mesh(obj.data)
|
||||||
U0Layer = bm.faces.layers.int.get(CollisionLayer.Unknown0.value) #Check if this layer exists
|
ColTypeLayer = bm.faces.layers.int.get(CollisionLayer.ColType.value) #Check if this layer exists
|
||||||
if U0Layer is not None: #If the model has collision values
|
if ColTypeLayer is not None: #If the model has collision values
|
||||||
EnableColumns = True #Then we enabled editing the values
|
EnableColumns = True #Then we enabled editing the values
|
||||||
del bm
|
del bm
|
||||||
del obj
|
del obj
|
||||||
|
@ -365,16 +351,15 @@ class CollisionPanel(Panel): #This panel houses the UI elements defined in the C
|
||||||
|
|
||||||
|
|
||||||
column1 = self.layout.column(align = True)
|
column1 = self.layout.column(align = True)
|
||||||
column1.prop(bpy.context.scene.ColEditor, "U0")
|
column1.prop(bpy.context.scene.ColEditor, "ColType")
|
||||||
column1.prop(bpy.context.scene.ColEditor, "U1")
|
column1.prop(bpy.context.scene.ColEditor, "TerrainType")
|
||||||
column1.prop(bpy.context.scene.ColEditor, "U2")
|
column1.prop(bpy.context.scene.ColEditor, "UnknownField")
|
||||||
column1.prop(bpy.context.scene.ColEditor, "U3")
|
|
||||||
column1.enabled = EnableColumns
|
column1.enabled = EnableColumns
|
||||||
|
|
||||||
column1.prop(bpy.context.scene.ColEditor, "HasU4")
|
column1.prop(bpy.context.scene.ColEditor, "HasColParameterField")
|
||||||
column2 = self.layout.column(align = True)
|
column2 = self.layout.column(align = True)
|
||||||
column2.prop(bpy.context.scene.ColEditor, "U4")
|
column2.prop(bpy.context.scene.ColEditor, "ColParameterField")
|
||||||
column2.enabled = bpy.context.scene.ColEditor.HasU4 and EnableColumns #Collision values must exist AND we must have "Has Unknown4" checked
|
column2.enabled = bpy.context.scene.ColEditor.HasColParameterField and EnableColumns #Collision values must exist AND we must have "Has ColParameter" checked
|
||||||
|
|
||||||
|
|
||||||
class InitialValues(Operator): #This creates the data layers that store the collision values
|
class InitialValues(Operator): #This creates the data layers that store the collision values
|
||||||
|
@ -385,12 +370,11 @@ class InitialValues(Operator): #This creates the data layers that store the coll
|
||||||
obj = bpy.context.scene.objects.active
|
obj = bpy.context.scene.objects.active
|
||||||
bm = bmesh.from_edit_mesh(obj.data)
|
bm = bmesh.from_edit_mesh(obj.data)
|
||||||
|
|
||||||
bm.faces.layers.int.new(CollisionLayer.Unknown0.value) #Uses Enum to get names
|
bm.faces.layers.int.new(CollisionLayer.ColType.value) #Uses Enum to get names
|
||||||
bm.faces.layers.int.new(CollisionLayer.Unknown1.value)
|
bm.faces.layers.int.new(CollisionLayer.TerrainType.value)
|
||||||
bm.faces.layers.int.new(CollisionLayer.Unknown2.value)
|
bm.faces.layers.int.new(CollisionLayer.Unknown.value)
|
||||||
bm.faces.layers.int.new(CollisionLayer.Unknown3.value)
|
bm.faces.layers.int.new(CollisionLayer.HasColParameter.value)
|
||||||
bm.faces.layers.int.new(CollisionLayer.HasUnknown4.value)
|
bm.faces.layers.int.new(CollisionLayer.ColParameter.value)
|
||||||
bm.faces.layers.int.new(CollisionLayer.Unknown4.value)
|
|
||||||
return{'FINISHED'}
|
return{'FINISHED'}
|
||||||
|
|
||||||
def ChangeValuesOfSelection(ValueToChange,ValueToSet):
|
def ChangeValuesOfSelection(ValueToChange,ValueToSet):
|
||||||
|
@ -403,9 +387,9 @@ def ChangeValuesOfSelection(ValueToChange,ValueToSet):
|
||||||
for face in bm.faces:
|
for face in bm.faces:
|
||||||
if(face.select == True):
|
if(face.select == True):
|
||||||
face[my_id] = ValueToSet
|
face[my_id] = ValueToSet
|
||||||
if ValueToChange == CollisionLayer.Unknown4.value: #If you somehow edit Unknown4 when HasUnknown4 is off, like with a group selection, make sure to turn it on
|
if ValueToChange == CollisionLayer.ColParameter.value: #If you somehow edit ColParameter when HasColParameter is off, like with a group selection, make sure to turn it on
|
||||||
HasU4Layer = bm.faces.layers.int.get(CollisionLayer.HasUnknown4.value)
|
HasColParameterFieldLayer = bm.faces.layers.int.get(CollisionLayer.HasColParameter.value)
|
||||||
face[HasU4Layer] = 1
|
face[HasColParameterFieldLayer] = 1
|
||||||
|
|
||||||
|
|
||||||
bmesh.update_edit_mesh(obj.data, False,False) #Update mesh with new values
|
bmesh.update_edit_mesh(obj.data, False,False) #Update mesh with new values
|
||||||
|
@ -415,26 +399,23 @@ def UpdateUI(scene):
|
||||||
obj = scene.objects.active
|
obj = scene.objects.active
|
||||||
if(obj.mode == 'EDIT' and obj.type == 'MESH'):
|
if(obj.mode == 'EDIT' and obj.type == 'MESH'):
|
||||||
bm = bmesh.from_edit_mesh(obj.data)
|
bm = bmesh.from_edit_mesh(obj.data)
|
||||||
U0Layer = bm.faces.layers.int.get(CollisionLayer.Unknown0.value) #Check if this layer exists
|
ColTypeLayer = bm.faces.layers.int.get(CollisionLayer.ColType.value) #Check if this layer exists
|
||||||
if U0Layer is not None: #If the model has collision values
|
if ColTypeLayer is not None: #If the model has collision values
|
||||||
face = bm.faces.active
|
face = bm.faces.active
|
||||||
if face is not None:
|
if face is not None:
|
||||||
bpy.context.scene.ColEditor["U0"] = face[U0Layer] #This is why they should have been an array
|
bpy.context.scene.ColEditor["ColType"] = face[ColTypeLayer] #This is why they should have been an array
|
||||||
|
|
||||||
U1Layer = bm.faces.layers.int.get(CollisionLayer.Unknown1.value) #Get name of data layer
|
TerrainTypeLayer = bm.faces.layers.int.get(CollisionLayer.TerrainType.value)
|
||||||
bpy.context.scene.ColEditor["U1"] = face[U1Layer] #Set UI element to value in selected face
|
bpy.context.scene.ColEditor["TerrainType"] = face[TerrainTypeLayer] #We call it like this so that we don't call the update function. Otherwise selecting multiple faces would set them all equal
|
||||||
|
|
||||||
U2Layer = bm.faces.layers.int.get(CollisionLayer.Unknown2.value)
|
UnknownFieldLayer = bm.faces.layers.int.get(CollisionLayer.Unknown.value)
|
||||||
bpy.context.scene.ColEditor["U2"] = face[U2Layer] #We call it like this so that we don't call the update function. Otherwise selecting multiple faces would set them all equal
|
bpy.context.scene.ColEditor["UnknownField"] = face[UnknownFieldLayer] #We choose index 0 but it doesn't really matter. Unfortunetly you can't get int properties to display "--" used, for example, when there are different ColType values across the selected faces
|
||||||
|
|
||||||
U3Layer = bm.faces.layers.int.get(CollisionLayer.Unknown3.value)
|
HasColParameterFieldLayer = bm.faces.layers.int.get(CollisionLayer.HasColParameter.value)
|
||||||
bpy.context.scene.ColEditor["U3"] = face[U3Layer] #We choose index 0 but it doesn't really matter. Unfortunetly you can't get int properties to display "--" used, for example, when there are different unknown0 values across the selected faces
|
bpy.context.scene.ColEditor["HasColParameterField"] = False if face[HasColParameterFieldLayer] == 0 else True
|
||||||
|
|
||||||
HasU4Layer = bm.faces.layers.int.get(CollisionLayer.HasUnknown4.value)
|
ColParameterFieldLayer = bm.faces.layers.int.get(CollisionLayer.ColParameter.value)
|
||||||
bpy.context.scene.ColEditor["HasU4"] = False if face[HasU4Layer] == 0 else True
|
bpy.context.scene.ColEditor["ColParameterField"] = face[ColParameterFieldLayer]
|
||||||
|
|
||||||
U4Layer = bm.faces.layers.int.get(CollisionLayer.Unknown4.value)
|
|
||||||
bpy.context.scene.ColEditor["U4"] = face[U4Layer]
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue