Menu

TGLFreeForm Imposter Render Problem

Help
Jacobus
2021-01-12
2021-02-03
  • Jacobus

    Jacobus - 2021-01-12

    Hi everyone! I created an imposter of TGLFreeForm (chess rook). The problem is that the imposter is not renderered in full but basically cut in half. Everything work fine when I created an imposter of the teapot. Also when I modeled an object in Blender and loaded into a TFreeForm everything worked as expected. I then downloaded a 3d model from the internet and loaded it into a TGLFreeForm and I then experienced the same problem again. In the screenshot the TGLFreeForm is the rook on the left and the imposter is just to the right. I don't know what is causing this problem! I send an image as an attachment. Here is my code:

    procedure TFormGLSImposters.FormCreate(Sender: TObject);
    begin
     GLMaterialLibrary1 := TGLMaterialLibrary.Create(Self);
    
     MaterialWhite := TGLLibMaterial.Create(GLMaterialLibrary1.Materials);
     MaterialWhite.Material.FrontProperties.Diffuse.Color := clrWhite;
     MaterialWhite.Name := 'MatWhite';
    
    
    
     GLFreeFormTest.Name := 'Tydelik13';
     GLFreeFormTest := TGLFreeForm.Create(Self);
     GLFreeFormTest.LoadFromFile('D:RookWFinaalLowPolyTest.Obj');
     GLFreeFormTest.Material.MaterialLibrary := GLMaterialLibrary1;
     GLFreeFormTest.Material.LibMaterialName := 'MatWhite';
     GLFreeFormTest.Position.SetPoint(0, 0, 0);
     GLFreeFormTest.Visible := True;
     GLScene1.Objects.AddChild(GLFreeFormTest);
    
     GLCamera := TGLCamera.Create(FormGLSImposters);
     GLCamera.Position.SetPoint(0, 45 , 45);
     GLCamera.Direction.SetVector(0, -45, -45);
     GLCamera.SceneScale := 3.8;
    
     GLScene1.Objects.AddChild(GLCamera);
    
     GLLightSource := TGLLightSource.Create(FormGLSImposters);
     GLLightSource.Position.SetPoint(0, 45 , 45);
     GLLightSource.Direction.SetVector(0,-45, -45);
     GLScene1.Objects.AddChild(GLLightSource);
    
     GLSceneViewer1.Camera := GLCamera;
     GLSceneViewer1.Buffer.ContextOptions := [roDoubleBuffer, roRenderToWindow, roDestinationAlpha];
     GLSceneViewer1.Height := 800;
     GLSceneViewer1.Width := 600;
     GLSceneViewer1.Left := 100;
     GLSceneViewer1.Top := 0;
    
     GLRenderPoint := TGLRenderPoint.Create(Self);
     GLRenderPoint := TGLRenderPoint(GLDummyCube1.AddNewChild(TGLRenderPoint));
    
     GLRenderPoint.Visible := True;
    
     GLStaticImposterBuilder := TGLStaticImposterBuilder.Create(Self);
     GLStaticImposterBuilder.SampleSize := 128;
     GLStaticImposterBuilder.SamplingRatioBias := 1.3;
     GLStaticImposterBuilder.ImposterOptions := [impoBlended, impoAlphaTest];
     GLStaticImposterBuilder.Coronas.Items[0].Samples := 32;
     GLStaticImposterBuilder.Coronas.Add(15, 24);
     GLStaticImposterBuilder.Coronas.Add(30, 24);
     GLStaticImposterBuilder.Coronas.Add(45, 16);
     GLStaticImposterBuilder.Coronas.Add(60, 16);
     GLStaticImposterBuilder.Coronas.Add(85, 16);
     GLStaticImposterBuilder.RenderPoint := GLRenderPoint;
     GLStaticImposterBuilder.RequestImposterFor(GLFreeFormTest);
    End;(*Procedure*)
    
    procedure TFormGLSImposters.ButtonTestClick(Sender: TObject);
    begin
     GLDirectOpenGL1.Position.SetPoint(5, 0, 0);
     GLDirectOpenGL1.Visible := True;
    end;
    
    procedure TFormGLSImposters.GLDirectOpenGL1Render(Sender: TObject;
      var rci: TGLRenderContextInfo);
    
    Var
     PImp : TImposter;
     CamPos, Pos : TVector;
    
    Begin
     PImp := GLStaticImposterBuilder.ImposterFor(GLFreeFormTest);
     PImp.BeginRender(Rci);
     MakePoint(Pos, 0, 0, 0);
     CamPos := VectorSubtract(Rci.CameraPosition, Pos);
     PImp.Render(Rci, Pos, CamPos, 1);
     PImp.EndRender(Rci);
    end;
    

    Components:
    GLScene1, GLSceneViewer1, GLDummyCube1, GLDirectOpenGL1 .

    Global variables declared in var section of interface of the unit:
    GLMaterialLibrary1, MaterialWhite, GLFreeFormTest, GLCamera, GLRenderPoint, GLStaticImposterBuilder .

    I kindly ask for diagnosis and treatment!

     
  • Jacobus

    Jacobus - 2021-01-12

    These two files are also important:

     
  • Jacobus

    Jacobus - 2021-01-12

    Hi Pavel!
    Thank you for the reply! When I run the Pawn demo it says: 'Could not open file: ashwood.jpg'. It happens when the RotationSolid tries to load the texture.
    Where can I download the 'ashwood.jpg' file if you don't mind?
    Thank you.

     
  • Jacobus

    Jacobus - 2021-01-12

    Hi Pavel!
    Sorry, my mistake! Thank you for the help.

     
  • Jacobus

    Jacobus - 2021-01-14

    Hi! I played around with the position and scale of visibility, but no luck! I don't know what is meant by the 'volume' of visibility. For some or other reason the imposter is cut in half compared to the 3d model from which it is built. Does anyone have some ideas? I think it must be something trivial since it only happens with some 3D models and not with others. What baffles me the most is that the imposter is rendered just next to the 3D model from which it is built, yet is not rendered properly! Honestly I don't know how to approach this problem. Any more help will be much appreciated!

     
  • Jacobus

    Jacobus - 2021-02-03

    Hi! Problem solved! With 'GLStaticImposterBuilder.SamplingRatioBias := 0.5' everything works as expected! Thank you.

     

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.