Menu

Mesh layout

Help
2017-11-16
2018-11-02
  • shine world

    shine world - 2017-11-16

    Hi,

    I'm using a TGLFreeForm to dinamically create a mesh surface using
    TMeshObject.Vertices.Add.

    Mesh is well formed but the showed result is all in same white color,
    without any perspective of Z plane.

    If I save result mesh to a file then I reload it the mesh has a good
    Z plane perspective.

    Why are so different ?
    What I've missed in mesh construction to have same result than reload file ?

    Thank you very much
    and best regards

    GLSC

    var
      Mesh: TMeshObject;
    begin
    ...
      GLScene.BeginUpdate;
      try
        GLFreeFormMesh.MeshObjects.Clear;
        GLFreeFormMesh.Skeleton.Clear;
    
        GLSceneViewer.Buffer.FaceCulling := False;
    
        Mesh := TMeshObject.CreateOwned(GLFreeFormMesh.MeshObjects);
        Mesh.Mode := momTriangles;
        Mesh.Vertices.Clear;
    
        Mesh.Vertices.Add(P1X, P1Y, PZ);
        Mesh.Vertices.Add(P2X, P2Y, PZ);
        ...
        Mesh.Vertices.Add(PnX, PnY, PZ);
    
        GLFreeFormMesh.Visible := True;
        GLFreeFormMesh.StructureChanged;
      finally
        GLScene.EndUpdate;
      end;
    
      SaveAcquiredMesh(ChangeFileExt(mesh.stl'));
    end;    
    
     

    Last edit: shine world 2017-11-16
  • shine world

    shine world - 2017-11-16

    PS: I'm unsing GLScene glscene_v_1000714 for NON UNICODE Delphi

     

    Last edit: shine world 2017-11-16
  • lnebel

    lnebel - 2017-11-16

    Hi,

    You need to build the normals, one normal for each triangle.

    var
    I : Integer;
    IntegerList : TIntegerList;
    MeshObject : TMeshObject;
    begin
    IntegerList := TIntegerList.Create;
    for I := 0 to MeshObject.Vertices.Count -1 do begin
    IntegerList.Add(I);
    end;
    MeshObject.BuildNormals(IntegerList, momTriangles);
    IntegerList.Free;
    end;

    \Lars

     
  • shine world

    shine world - 2017-11-16

    Thank you very much Inebel,
    the code worked very fine, now my mesh is like I want.

    Have you a nice day.

     
  • Mostafa

    Mostafa - 2018-11-02

    Hi,
    I had a problem like you . I did your way. But I came across a new problem. I make normals . When I rotate the scene with the mouse, the newly created mesh objects spin independently or perhaps just show back of mesh instead front. I also made front color adjustments (GLFreeForm1.Material.FrontProperties.Diffuse.SetColor), but there is still problem . What do you think is the solution to my problem?
    Thanks.

     

    Last edit: Mostafa 2018-11-02

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.