Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 625
user1116033 Avatar asked Jan 14 '13 12:01

user1116033


1 Answers

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
like image 186
user1116033 Avatar answered Sep 22 '22 19:09

user1116033