Menu

TGLFreeForm - Heady File Loading, speed techniques

Help
2016-08-17
2016-09-21
  • Tiago Rodrigues

    Tiago Rodrigues - 2016-08-17

    Hi!
    I have to build a scene where i will have some FreeForms with +10000 meshobjects on each one.
    It all works ok, but it takes much time to load the files.

    Is there any tips to speed up heavy operations like this? Like begin/end updates, or something like that?

    Thanks.

     
  • Tiago Rodrigues

    Tiago Rodrigues - 2016-08-24

    Nothing guys? :/

     
  • Jerome.D (BeanzMaster)

    Hi

    I have to build a scene where i will have some FreeForms with +10000 meshobjects on each one.

    Whoa it's huge how many vertices in total ? all objects are always visible or not ? what the kind of your project is ?
    perhaps
    * create dynamic loading depending of your position in the world. Just loading new elements.
    * simplify your objects, use proxy objects for duplicated meshes.

     
  • Tiago Rodrigues

    Tiago Rodrigues - 2016-08-27

    I have a factory to show. It has 3 CNC machines and a couple of storage tables.
    The heaviest is one of the storage tables, i think its because it has a lot of holes in it, with little tolerance, creating lots of triangles.

    Apart from that the scene actualy moves smoothly.
    Is there any function to 'sharp' meshobject, to decrease the triangle count?

     
  • Jerome.D (BeanzMaster)

    In your 3D editor you can do it i think. In other case you'll can try the functions in Meshutils.pas like optimize and strify then save your mesh as glsm (glscene's format)

     
  • Tiago Rodrigues

    Tiago Rodrigues - 2016-08-30

    Yes, im importing the 3D files and then save them in GLScene format.
    Every time the user loads a 3D file i load the GLScene file.

    I have found that unit but im having dificulties with the functions parameters and the properties available in the TMeshObject.
    In other words, how do i make a function that receives a TMeshObject and call StripifyMesh?

    function StripifyMesh(indices : TIntegerList; maxVertexIndex : Integer;
    agglomerateLoneTriangles : Boolean = False) : TPersistentObjectList;

    How do i get the indices : TIntegerList; parameter from the TMeshObject and what do i do with the returned TPersistentObjectList?

    Thanks :)

     
  • Tiago Rodrigues

    Tiago Rodrigues - 2016-08-31

    Well, after a lot of search i've found an example of this function used on a TGLFreeForm.
    Something like this:

    procedure TForm1.StripifyMesh(var mesh: TGLFreeform);
    var
       sIndex,MoIndex: Integer;
       MeshObj : TMeshObject;
       fg : TFGVertexIndexList;
       strips : TPersistentObjectList;
    begin
      for MoIndex:= 0 to mesh.MeshObjects.Count -1 do begin
         MeshObj:=mesh.MeshObjects[MoIndex];
         fg:=(MeshObj.FaceGroups[0] as TFGVertexIndexList);
         strips:=StripifyMesh(fg.VertexIndices, MeshObj.Vertices.Count, True);
         try
            fg.Free;
            for sIndex:= 0 to strips.Count -1 do begin
              fg:=TFGVertexIndexList.CreateOwned(MeshObj.FaceGroups);
              fg.VertexIndices:= ( strips[sIndex] as TIntegerList );
              if sIndex = 0 then
                fg.Mode:= fgmmTriangles
              else
                fg.Mode:=fgmmTriangleStrip;
            end;
         finally
            strips.Free;
         end;
      end;
    end;
    

    Well, i does seem to optimize something, because if i save the file with the mesh information it has half the size than before.
    But almost the same loading time so... not quite there yet :p

     

    Last edit: Tiago Rodrigues 2016-08-31
  • Jerome.D (BeanzMaster)

    Hi, this 2 units should help you
    see :
    procedure TGLFreeFormEx.StripAndRecalc;
    procedure TGLFreeFormEx.FacesSmooth(aWeldDistance: Single=0.0000001; aThreshold: Single=35.0; InvertNormals:boolean=false);
    procedure TGLFreeFormEx.Optimize(options : TMeshOptimizerOptions);

     

    Last edit: Jerome.D (BeanzMaster) 2016-09-11
  • Jerome.D (BeanzMaster)

    Hi, another question, do you load your textures dynamically, or there are alredy set in a MaterialLibrary ?

     
  • Tiago Rodrigues

    Tiago Rodrigues - 2016-09-21

    I wil try those units then :)
    The textures are in a MaterialLibrary. I tried to not load textures and the speed gain was minimal so it doesnt seem to be a problem either.

     

    Last edit: Tiago Rodrigues 2016-09-21

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.