Index: exp_fmt_amf.c =================================================================== --- exp_fmt_amf.c (revision 35971) +++ exp_fmt_amf.c (revision 35972) @@ -73,6 +73,11 @@ verthash_add_triangle(&verthash, vert[0], vert[1], vert[2]); } +static void amf_new_obj(float r, float g, float b) +{ + verthash_new_obj(&verthash, r, g, b); +} + static void amf_print_header(FILE *f) { fprintf(f, "\n"); @@ -94,13 +99,31 @@ rnd_fprintf(f, " %.09mm\t%.09mm\t%.09mm \n", c[0], c[1], c[2]); fprintf(f, " \n"); - fprintf(f, " \n"); - for(n = 0, vx = verthash.triangles.array; n < verthash.triangles.used; n += 3, vx += 3) + for(n = 0, vx = verthash.triangles.array; n < verthash.triangles.used; n += 3, vx += 3) { + if (vx[0] < 0) { + if (n != 0) + fprintf(f, " \n"); + fprintf(f, " \n", (long)-vx[0]); + vx++; + n++; + continue; /* shift colors */ + } rnd_fprintf(f, " %ld\t%ld\t%ld \n", vx[0], vx[1], vx[2]); + } fprintf(f, " \n"); - fprintf(f, " \n"); fprintf(f, " \n"); + + for(n = 0, vx = verthash.triangles.array; n < verthash.triangles.used; n += 3, vx += 3) { + if (vx[0] < 0) { + fprintf(f, " \n", (long)-vx[0]); + vx++; + n++; + fprintf(f, " %.6f%.6f%.6f\n", (double)vx[0]/1000000, (double)vx[1]/1000000, (double)vx[2]/1000000); + fprintf(f, " \n"); + } + } + fprintf(f, "\n"); verthash_uninit(&verthash); Index: exp_fmt_stl.c =================================================================== --- exp_fmt_stl.c (revision 35971) +++ exp_fmt_stl.c (revision 35972) @@ -88,6 +88,10 @@ fprintf(f, " endfacet\n"); } +static void stl_new_obj(float r, float g, float b) +{ +} + static void stl_print_header(FILE *f) { fprintf(f, "solid pcb\n"); Index: export_stl.c =================================================================== --- export_stl.c (revision 35971) +++ export_stl.c (revision 35972) @@ -422,10 +422,14 @@ fp2t_triangulate(&tri); - if (fmt_amf) + if (fmt_amf) { amf_print_header(f); - else + amf_new_obj(0, 0.3, 0); + } + else { stl_print_header(f); + stl_new_obj(0, 0.3, 0); + } /* write the top and bottom plane */ for(n = 0; n < tri.TriangleCount; n++) { Index: stl_models.c =================================================================== --- stl_models.c (revision 35971) +++ stl_models.c (revision 35972) @@ -211,6 +211,7 @@ htsp_t models; const char *mod; htsp_entry_t *e; + int first = 1; htsp_init(&models, strhash, strkeyeq); @@ -236,6 +237,14 @@ if (srot == NULL) srot = pcb_attribute_get(&subc->Attributes, "stl-rotate"); + if (first) { + if (fmt_amf) + amf_new_obj(0, 0, 0); + else + stl_new_obj(0, 0, 0); + first = 0; + } + stl_model_place(&pcb->hidlib, outf, &models, mod, ox, oy, rot, on_bottom, sxlate, srot, maxy, z0, z1, fmt_amf); } } PCB_END_LOOP; Index: verthash.c =================================================================== --- verthash.c (revision 35971) +++ verthash.c (revision 35972) @@ -18,6 +18,7 @@ vtc0_t vxcoords; vtl0_t triangles; long next_id; + long next_obj; } verthash_t; @@ -37,6 +38,7 @@ vtc0_init(&vh->vxcoords); vtl0_init(&vh->triangles); vh->next_id = 0; + vh->next_obj = 2; } static void verthash_uninit(verthash_t *vh) @@ -81,3 +83,13 @@ v3 = verthash_add_vertex(vh, x3, y3, z3); verthash_add_triangle(vh, v1, v2, v3); } + +static void verthash_new_obj(verthash_t *vh, float r, float g, float b) +{ + vtl0_append(&vh->triangles, -vh->next_obj); + vh->next_obj++; + + vtl0_append(&vh->triangles, rnd_round(r*1000000)); + vtl0_append(&vh->triangles, rnd_round(g*1000000)); + vtl0_append(&vh->triangles, rnd_round(b*1000000)); +}