Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b6231a094 | ||
|
|
50a7d003cb | ||
|
|
bd1a7257fd |
@@ -2,7 +2,7 @@ bl_info = {
|
||||
'name': 'ASCII Scene Export',
|
||||
'description': 'Export ASE (ASCII Scene Export) files',
|
||||
'author': 'Colin Basnett (Darklight Games)',
|
||||
'version': (1, 1, 0),
|
||||
'version': (1, 1, 2),
|
||||
'blender': (2, 90, 0),
|
||||
'location': 'File > Import-Export',
|
||||
'warning': 'This add-on is under development.',
|
||||
@@ -21,8 +21,6 @@ if 'bpy' in locals():
|
||||
|
||||
import bpy
|
||||
import bpy.utils.previews
|
||||
from bpy.props import IntProperty, CollectionProperty, StringProperty
|
||||
import os
|
||||
from . import ase
|
||||
from . import builder
|
||||
from . import writer
|
||||
|
||||
@@ -39,6 +39,7 @@ class ASEGeometryObject(object):
|
||||
self.faces = []
|
||||
self.texture_vertex_faces = []
|
||||
self.face_normals = []
|
||||
self.vertex_colors = []
|
||||
self.vertex_offset = 0
|
||||
self.texture_vertex_offset = 0
|
||||
|
||||
|
||||
@@ -34,6 +34,15 @@ class ASEBuilder(object):
|
||||
main_geometry_object = geometry_object
|
||||
ase.geometry_objects.append(geometry_object)
|
||||
|
||||
if geometry_object.is_collision:
|
||||
bm = bmesh.new()
|
||||
bm.from_mesh(obj.data)
|
||||
for edge in bm.edges:
|
||||
if not edge.is_manifold:
|
||||
raise ASEBuilderError(f'Collision mesh \'{obj.name}\' is not manifold')
|
||||
if not edge.is_convex:
|
||||
raise ASEBuilderError(f'Collision mesh \'{obj.name}\' is not convex')
|
||||
|
||||
if not geometry_object.is_collision and len(mesh_data.materials) == 0:
|
||||
raise ASEBuilderError(f'Mesh \'{obj.name}\' must have at least one material')
|
||||
|
||||
@@ -108,6 +117,12 @@ class ASEBuilder(object):
|
||||
geometry_object.texture_vertex_offset + loop_triangle.loops[2]
|
||||
))
|
||||
|
||||
# Vertex Colors
|
||||
if len(mesh_data.vertex_colors) > 0:
|
||||
vertex_colors = mesh_data.vertex_colors.active.data
|
||||
for color in map(lambda x: x.color, vertex_colors):
|
||||
geometry_object.vertex_colors.append(tuple(color[0:3]))
|
||||
|
||||
# Update data offsets for next iteration
|
||||
geometry_object.texture_vertex_offset = len(mesh_data.loops)
|
||||
geometry_object.vertex_offset = len(geometry_object.vertices)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import bpy
|
||||
import bpy_extras
|
||||
from bpy.props import StringProperty, FloatProperty, EnumProperty
|
||||
from bpy.props import StringProperty, FloatProperty, EnumProperty, BoolProperty
|
||||
from .builder import *
|
||||
from .writer import *
|
||||
|
||||
|
||||
@@ -176,6 +176,18 @@ class ASEWriter(object):
|
||||
vertex_normal_node.push_datum(vertex_normal.vertex_index)
|
||||
vertex_normal_node.push_data(list(vertex_normal.normal))
|
||||
|
||||
# Vertex Colors
|
||||
if len(geometry_object.vertex_colors) > 0:
|
||||
mesh_node.push_child('MESH_NUMCVERTEX').push_datum(len(geometry_object.vertex_colors))
|
||||
cvert_list = mesh_node.push_child('MESH_CVERTLIST')
|
||||
for i, vertex_color in enumerate(geometry_object.vertex_colors):
|
||||
cvert_list.push_child('MESH_VERTCOL').push_datum(i).push_data(vertex_color)
|
||||
parent_node.push_child('MESH_NUMCVFACES').push_datum(len(geometry_object.texture_vertex_faces))
|
||||
texture_faces_node = parent_node.push_child('MESH_CFACELIST')
|
||||
for texture_face_index, texture_face in enumerate(geometry_object.texture_vertex_faces):
|
||||
texture_face_node = texture_faces_node.push_child('MESH_CFACE')
|
||||
texture_face_node.push_data([texture_face_index] + list(texture_face))
|
||||
|
||||
geomobject_node.push_child('MATERIAL_REF').push_datum(0)
|
||||
|
||||
return root
|
||||
|
||||
Reference in New Issue
Block a user