Menu

problem with mesh creating

Help
Mostafa
2018-11-04
2018-11-07
  • Mostafa

    Mostafa - 2018-11-04

    Hi ,
    I have a problem, I draw the following figure using the mesh. But occasionally, the shape is inadvertently depicted. If it is possible to tell me where is my problem.
    thanks.
    this is my code :

    for j := 0 to object_num-1 do
           begin
            Mesh[j] := TMeshObject.CreateOwned(kid.GLFreeForm1.MeshObjects);
            Mesh[j].Mode := momTriangles;
    
            Mesh[j].Vertices.Clear;
            Mesh[j].Colors.Clear;
            mesh[j].Name:='mesh_object_'+inttostr(j);
    
           for i:=from_index[j] to to_index[j] do
             begin
              Mesh[j].Vertices.Add(px[t1[i]],py[t1[i]],pz[t1[i]]);
              Mesh[j].Vertices.Add(px[t2[i]],py[t2[i]],pz[t2[i]]);
              Mesh[j].Vertices.Add(px[t3[i]],py[t3[i]],pz[t3[i]]);
    
               Mesh[j].Colors.add(GetRValue(Mycolors[j])/255,GetGValue(Mycolors[j])/255,GetBValue(Mycolors[j])/255,1);
               Mesh[j].Colors.add(GetRValue(Mycolors[j])/255,GetGValue(Mycolors[j])/255,GetBValue(Mycolors[j])/255,1);
               Mesh[j].Colors.add(GetRValue(Mycolors[j])/255,GetGValue(Mycolors[j])/255,GetBValue(Mycolors[j])/255,1);
    
             end;
    
             IntegerList := TIntegerList.Create;
             for I :=0  to Mesh[j].Vertices.Count -1 do begin
               IntegerList.Add(I);
             end;
             Mesh[j].BuildNormals(IntegerList, momTriangles);
    
              IntegerList.Free;
              Kid.GLFreeForm1.StructureChanged;
              Kid.GLSceneViewer1.Refresh;
           end;
    

     

    Last edit: Mostafa 2018-11-04
  • Jerome.D (BeanzMaster)

    Hi mostafa can you give us the complete source code in a zip please. I think the problem is that you calcul the normal for each face, it will be better in this case to calculate the normal of each vertex instead.

    Like i see the faces are quad (2 triangles) so each quad face have 2 triangles with 2 shared vertex.
    So i think try to create 2 triangles for represented a quad at each iteration instead of one.

     
  • Mostafa

    Mostafa - 2018-11-04

    Hi Jerome.D ,
    Thank you very much for your answer.
    My idea is to create mesh objects from Nastran's output files (.nas).
    The structure of the triangles is based on Nastran files.Usually, after several Importing and creating mesh objects, this problem occurs and there is no definite time.Thanks if you checked the attached file. There is also an example of Nastran file for importing.

     
  • Jerome.D (BeanzMaster)

    Hi mostafa i've juste compiled your project under Delphi CE in 64 bits and import your NAS file All is ok see the screenshot. Do you use the last GLScene v1.7 or perhaps you need to update your graphic driver

     

    Last edit: Jerome.D (BeanzMaster) 2018-11-06
  • Mostafa

    Mostafa - 2018-11-07

    Hi Jerome,
    Thank you very much.
    I'm using version 1.5.
    Sometimes it's just right, but it's often the same problem. I'm wondering why I'm just having trouble viewing NAS files. Is there a problem with my code or because there are no normal vectors in the NAS file? However, I'm making normal vectors using Mesh[j].BuildNormals(IntegerList, momTriangles);.

     

    Last edit: Mostafa 2018-11-07

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.