Menu

Change camera view when stl file loads by GLfreeform

Help
M.a.
2020-02-12
2020-02-15
  • M.a.

    M.a. - 2020-02-12

    Hi,
    I have a GLcamera in special position , but when I load stl file in GLfreeform, the camera view changes , how can I have fixed camera view ?

     
  • Jerome.D (BeanzMaster)

    Hi please post code sample as is we can't reproduce or help you

    Thanks

     
    • M.a.

      M.a. - 2020-02-14

      Hi Jerome.D,
      My camera view is Image 1.
      My code is simple, I use stl file by code : (Image 2)

      var
      FF:TGLFreeForm;
      begin
      if OpenDialog1.Execute then
       begin
        FF := TGLFreeForm(DC.AddNewChild(TGLFreeForm));
        FF.LoadFromFile(OpenDialog1.FileName);
        FF.Name:=ChangeFileExt(ExtractFileName(OpenDialog1.FileName),'1');
       end;
      end;
      

      And I try to Delete this objcet by this code : (image1)

      GLScene1.FindSceneObject(pick.Name).Free;
      

      But when I try to load this object again by previous code, camera view is changed : (Image 3)

      I don't know what the problem is.
      This is not a permanent problem.

       

      Last edit: M.a. 2020-02-14
  • shine world

    shine world - 2020-02-14

    It's normal.
    To avoid that you have to clear pending Mouse messages just after your code:

    var
    FF:TGLFreeForm;
    begin
    if OpenDialog1.Execute then
     begin
      FF := TGLFreeForm(DC.AddNewChild(TGLFreeForm));
      FF.LoadFromFile(OpenDialog1.FileName);
      FF.Name:=ChangeFileExt(ExtractFileName(OpenDialog1.FileName),'1');
      CleanupMouseMessages;
     end;
    end;
    
    procedure CleanupMouseMessages;
    var
      Msg: TMsg;
    begin
      while PeekMessage(Msg, 0, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE or PM_NOYIELD) do;
    end;
    
     

    Last edit: shine world 2020-02-14
  • Jerome.D (BeanzMaster)

    Hi just a question how is set your camera,§ what's the target ? How you handle mouse ? Normally not needed to cleanup mouse messages

     
  • shine world

    shine world - 2020-02-15

    The issue born when you have a standard windows system dialog, as OpenDialog, SaveDialog, ColorDialog, etc, which is over a GLSceneView.
    When you press OK button on Windows dialog, some Mouse event remains in windows message stack and just when exit from Dialog the SceneFrame caputre them.

    Placecing a peek message after Dialog close you can remove these messages before delphi message system send to active control (the glsceneviewer).

     

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.