Search code examples
delphistlexportsceneglscene

Delphi GLScene export scene as stl


I have a GLScene project. In the SceneViewer I import some stl files as freeform. The user can interact with this objects (move and rotate them with mouse).

Now I have to export this whole Scene to one stl file, so the position and the rotation of the freeforms should be like in the Scene after this export ("merge").

I found this thread about the same problem: Export "Scene" to STL File but this creates an broken stl file (tried open with meshlab).

I hope there is some idea for creating a solution. If somebody knows a solution for another 3d-file format, it will be great too.


Solution

  • I have found the solution :-)

    the link in the answer is nearly right, but i have to calculate the header information (count of faceletts) in an other way. now i use a loop an calculate the header before writing thats all. Sometimes the solution is so near.

    var j :integer ; 
    var i:integer; 
    var header: TSTLHeader; 
    var dataFace: TSTLFace; 
    var list: TaffineVectorlist; 
    
    //objects  = list of steFreeform objects
    //astream  = created stream 
    for  j := 0 to objects.count - 1 do 
    begin
      list := TGLFREEForm(objects[j].MeshObjects.ExtractTriangles; 
      header.nbfaces :0 header.nbFaces + list.count div 3 ; 
    end; 
    aStream.write(header.SizeOf(header)); 
    //rest see above link in the question