Menu

Increase the speed of drawing a large number of cubes

Help
Mostafa
2019-01-09
2019-01-10
  • Mostafa

    Mostafa - 2019-01-09

    Hi,
    I want to create Computational mesh from a freeform mesh object by cubes (Making objects by cubes). the number of cubes in this case is very large and the speed of drawing is low.
    By hiding the DC while making cubes, the speed of drawing is slightly higher, but still not desirable.
    The number of cubes may reach up to a million and more.
    What is your approach to doing this?
    My code is below. Please guide if you know better method.
    Thanks.

     DC.Visible:=false;
    
       for i := 0 to Length(pos_x)-1 do
        begin
         CalcMesh[i] := TGLCube(DC.AddNewChild(TGLCube));
         CalcMesh[i].Position.X:=pos_x[i]; 
         CalcMesh[i].Position.Y:=pos_y[i];
         CalcMesh[i].Position.Z:=pos_z[i];
         CalcMesh[i].CubeWidth:=c_w[i]
         CalcMesh[i].CubeHeight:=c_h[i];
         CalcMesh[i].CubeDepth:=c_d[i];
        end;
       DC.Visible:=true;
    
     

    Last edit: Mostafa 2019-01-09
  • Pavel Vassiliev

    Pavel Vassiliev - 2019-01-10

    Hi Mostafa
    Drawing large arrays of TGLCube objects will be slow, so if you need only to show positions of objects try to use TGLPoints instead. Use 1 point for cube centers or 8 points for corner vertices (may be plus 6 points for face centers and 12 points for edge centers etc.). In this case millions of such pointed cubes as voxels you will visualize very fast during a few seconds or less.
    PW

     

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.