Updating decimation & adding examples
This commit is contained in:
parent
bd1ba14af7
commit
81b12ca77b
19
decimate.py
19
decimate.py
|
@ -18,15 +18,21 @@ class Decimater(obja.Model):
|
|||
"""
|
||||
operations = []
|
||||
|
||||
for (vertex_index, vertex) in enumerate(self.vertices):
|
||||
operations.append(('ev', vertex_index, vertex + 0.25))
|
||||
|
||||
# Iterate through the vertex
|
||||
for (vertex_index, vertex) in enumerate(self.vertices):
|
||||
|
||||
# Iterate through the faces
|
||||
for (face_index, face) in enumerate(self.faces):
|
||||
|
||||
# Delete any face that depends on this vertex
|
||||
# Delete any face related to this vertex
|
||||
if face_index not in self.deleted_faces:
|
||||
self.deleted_faces.add(face_index)
|
||||
operations.append(('face', face_index, face))
|
||||
if vertex_index in [face.a,face.b,face.c]:
|
||||
self.deleted_faces.add(face_index)
|
||||
# Add the instruction to operations stack
|
||||
operations.append(('face', face_index, face))
|
||||
|
||||
# Delete the vertex
|
||||
operations.append(('vertex', vertex_index, vertex))
|
||||
|
@ -34,13 +40,16 @@ class Decimater(obja.Model):
|
|||
# To rebuild the model, run operations in reverse order
|
||||
operations.reverse()
|
||||
|
||||
output_model = obja.Output(output)
|
||||
# Write the result in output file
|
||||
output_model = obja.Output(output, random_color=True)
|
||||
|
||||
for (ty, index, value) in operations:
|
||||
if ty == "vertex":
|
||||
output_model.add_vertex(index, value)
|
||||
else:
|
||||
elif ty == "face":
|
||||
output_model.add_face(index, value)
|
||||
else:
|
||||
output_model.edit_vertex(index, value)
|
||||
|
||||
def main():
|
||||
"""
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
3461
exemple/suzanne.obja
3461
exemple/suzanne.obja
File diff suppressed because it is too large
Load Diff
5
obja.py
5
obja.py
|
@ -276,7 +276,10 @@ class Output:
|
|||
"""
|
||||
Changes the coordinates of a vertex.
|
||||
"""
|
||||
print('ev {} {} {} {}'.format(self.vertex_mapping[index] + 1, vertex[0], vertex[1],vertex[2]), file = self.output)
|
||||
if len(self.vertex_mapping) == 0:
|
||||
print('ev {} {} {} {}'.format(index, vertex[0], vertex[1],vertex[2]), file = self.output)
|
||||
else:
|
||||
print('ev {} {} {} {}'.format(self.vertex_mapping[index] + 1, vertex[0], vertex[1],vertex[2]), file = self.output)
|
||||
|
||||
def add_face(self, index, face):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue