Update AMF export code
This commit is contained in:
parent
4dce461aaf
commit
1aa5dbafd3
3 changed files with 22 additions and 14 deletions
|
@ -49,22 +49,32 @@ sub write_file {
|
|||
printf $fh qq{ <object id="%d">\n}, $object_id;
|
||||
printf $fh qq{ <mesh>\n};
|
||||
printf $fh qq{ <vertices>\n};
|
||||
foreach my $vertex (@{$object->vertices}, ) {
|
||||
printf $fh qq{ <vertex>\n};
|
||||
printf $fh qq{ <coordinates>\n};
|
||||
printf $fh qq{ <x>%s</x>\n}, $vertex->[X];
|
||||
printf $fh qq{ <y>%s</y>\n}, $vertex->[Y];
|
||||
printf $fh qq{ <z>%s</z>\n}, $vertex->[Z];
|
||||
printf $fh qq{ </coordinates>\n};
|
||||
printf $fh qq{ </vertex>\n};
|
||||
my @vertices_offset = ();
|
||||
{
|
||||
my $vertices_offset = 0;
|
||||
foreach my $volume (@{ $object->volumes }) {
|
||||
push @vertices_offset, $vertices_offset;
|
||||
my $vertices = $volume->mesh->vertices;
|
||||
foreach my $vertex (@$vertices) {
|
||||
printf $fh qq{ <vertex>\n};
|
||||
printf $fh qq{ <coordinates>\n};
|
||||
printf $fh qq{ <x>%s</x>\n}, $vertex->[X];
|
||||
printf $fh qq{ <y>%s</y>\n}, $vertex->[Y];
|
||||
printf $fh qq{ <z>%s</z>\n}, $vertex->[Z];
|
||||
printf $fh qq{ </coordinates>\n};
|
||||
printf $fh qq{ </vertex>\n};
|
||||
}
|
||||
$vertices_offset += scalar(@$vertices);
|
||||
}
|
||||
}
|
||||
printf $fh qq{ </vertices>\n};
|
||||
foreach my $volume (@{ $object->volumes }) {
|
||||
my $vertices_offset = shift @vertices_offset;
|
||||
printf $fh qq{ <volume%s>\n},
|
||||
(!defined $volume->material_id) ? '' : (sprintf ' materialid="%s"', $volume->material_id);
|
||||
foreach my $facet (@{$volume->facets}) {
|
||||
foreach my $facet (@{$volume->mesh->facets}) {
|
||||
printf $fh qq{ <triangle>\n};
|
||||
printf $fh qq{ <v%d>%d</v%d>\n}, (4+$_), $facet->[$_], (4+$_) for -3..-1;
|
||||
printf $fh qq{ <v%d>%d</v%d>\n}, $_, $facet->[$_-1] + $vertices_offset, $_ for 1..3;
|
||||
printf $fh qq{ </triangle>\n};
|
||||
}
|
||||
printf $fh qq{ </volume>\n};
|
||||
|
|
|
@ -789,7 +789,6 @@ sub make_model {
|
|||
my $model_object = $plater_object->get_model_object;
|
||||
|
||||
my $new_model_object = $model->add_object(
|
||||
vertices => $model_object->vertices,
|
||||
input_file => $plater_object->input_file,
|
||||
config => $plater_object->config,
|
||||
layer_height_ranges => $plater_object->layer_height_ranges,
|
||||
|
@ -798,7 +797,7 @@ sub make_model {
|
|||
foreach my $volume (@{$model_object->volumes}) {
|
||||
$new_model_object->add_volume(
|
||||
material_id => $volume->material_id,
|
||||
facets => $volume->facets,
|
||||
mesh => $volume->mesh,
|
||||
);
|
||||
$model->set_material($volume->material_id || 0, {});
|
||||
}
|
||||
|
|
|
@ -355,8 +355,7 @@ sub combine_stls {
|
|||
$new_model->set_material($m, { Name => basename($input_files[$m]) });
|
||||
$new_object->add_volume(
|
||||
material_id => $m,
|
||||
facets => $model->objects->[0]->volumes->[0]->facets,
|
||||
vertices => $model->objects->[0]->vertices,
|
||||
mesh => $model->objects->[0]->volumes->[0]->mesh,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue