Menu

How to apply texture to the TGLPolygon

Help
SBlade
2015-11-09
2020-03-16
  • SBlade

    SBlade - 2015-11-09

    Dear All,

    I couldn't apply the texture to the TGLPolygon object, for every object other than Polygon I can do it, so texture is enabled but still nothing shows up, do I have to assign the texture to the face group.

    Your guidance will be appreciated,

     
    • FangQ

      FangQ - 2018-03-29

      I sent a question via email to this board, but it seems it got lost and never posted. Let me just post my question following this thread.

      I am trying to visualize a 3D medical image, which is a 3D array of floating-point values. I would like to create a thin slice, and map the image data as texture to the slice (at the begining, just the x/y, y/z or z/x plane, in the future, may go for oblique slices).

      I am wondering if anyone can share a few lines of code to show how to converts a 2D/3D array into a textured glscene object? do I need to convert the array to a TBitmap first? what object should I use? polygon or a thin cube?

      if you can point me to a simple example of 3D array rendering using glscene that would be even better. volumetric rendering (instead of 2D slice rendering) is fine too.

      thanks a lot!

       
  • Pavel Vassiliev

    Pavel Vassiliev - 2015-11-10

    Dear SBlade,
    By default for TGLPolygon in Material property the Texture has Disabled as False, so make it True and then download a texture file like persistant image or picfile. In attachment there is a screenshot for TriangleBox demo from collisions dir with the texture overlayed to polygon. So you don't need to use a face group.
    PW

     
  • SBlade

    SBlade - 2015-11-11

    Hi Pavel,

    Interestingly that doesn't work in my case, I followed the instructions as you instructed. Does it matter the orientation of nodes whether they are CW or CCW, and also I try to load png image so could t be problem it doesn't hasve channel or not. At the attachment there is snapshot taken from design mode,

    If you provide any sample I'll really appreciate it.
    Regards,

     

    Last edit: SBlade 2015-11-11
  • Pavel Vassiliev

    Pavel Vassiliev - 2018-03-30

    Hi FangQ,
    I've added some Textures demos in branches\examples, look at Texture3D medical volume rendering demo and UVMapping, that may help for your purposes

     
    • FangQ

      FangQ - 2018-04-15

      thank you so much! both Texture3D and UVMapping examples are extremely helpful. I will likely to adapt the Texture3D example since it deals with 3D volumes directly, and is really fast.

      yes, I am also aware of mricrogl but currently I don't need a full-featured 3D rendering program. The features in the Texture3D example is just about everything I need, and the code is very short and easy to understand/adapt. thank you for pointing me to this code!

       
    • FangQ

      FangQ - 2018-04-15

      hi Pavel and Jerome, can one of you point me to the unit that defines the texture data types? I see a Longword is used in the Texture3D example, but don't know what data types are supported (and their values)

      https://sourceforge.net/p/glscene/code/HEAD/tree/branches/GLSceneLCL/Examples/Textures/Texture3D/Texture_3D_Unit.pas#l42

      I am particularly curious if I can load 32bit floating-point data into a texture.
      thanks

       
  • Jerome.D (BeanzMaster)

     
    • FangQ

      FangQ - 2018-04-15

      hi Jerome, to compile either examples on LInux, I need to make a few minor changes:

      for the Texture3D example, I need to change

      Texture3D.lpr: change unit1 to Unit1,
      Unit.pas line#107: Head.tx3 to head.tx3 (alternatively, rename the file)

      for the UvMapping example,
      Unit1.pas line#362: change "cube.3ds" to "Cube.3DS" (alternatively, rename the file)

       
  • Jerome.D (BeanzMaster)

    For Lazarus you'll can find UVMapping demo in Examples\Editors\uvMapping folder :)

     
  • Pavel Vassiliev

    Pavel Vassiliev - 2018-04-03

    Oops FangQ,
    If you work in Lazarus then for 3d medical object's rendering ready application you better look at MRIcroGL by Chris Rordan at https://github.com/neurolabusc That's worth of it.
    Sincerely

     
  • Jerome.D (BeanzMaster)

    Hi FangQ

    hi Pavel and Jerome, can one of you point me to the unit that defines the texture data types? I see a Longword is used in the Texture3D example, but don't know what data types are supported (and their values)

    https://sourceforge.net/p/glscene/code/HEAD/tree/branches/GLSceneLCL/Examples/Textures/Texture3D/Texture_3D_Unit.pas#l42

    I am particularly curious if I can load 32bit floating-point data into a texture.
    thanks

    GL_RGBA, GL ... are define in OpenGLTokens unit.
    For using float color it's GL_RGBA32F if i'm remember.
    Or just make conversion multiply each float color channel by 255 and ensure result value to range of [0..255]

    hi Jerome, to compile either examples on LInux, I need to make a few minor changes:

    for the Texture3D example, I need to change

    Texture3D.lpr: change unit1 to Unit1,
    Unit.pas line#107: Head.tx3 to head.tx3 (alternatively, rename the file)

    for the UvMapping example,
    Unit1.pas line#362: change "cube.3ds" to "Cube.3DS" (alternatively, rename the file)

    Thanks, grrrr BORING sensible case between Windows and Linux. I'll check others demos and do the changes.

     
  • FangQ

    FangQ - 2020-03-16

    hi Jerome, thanks again for the previous points on the 3D texture sample code, and I was able to adapt it for rendering my data.

    One follow up question on this - I know this is related to my lack of understanding to OpenGL rendering pipeline in general, but hopefully there is a simple change you can suggest:

    The 3D texture example renders a 3D texture array in a 1x1x1 dummy cube. I am currently working on adding axis labels for an Nx x Ny x Nz array as texture. To do that, I need to render the texture in an Nx x Ny x Nz box, and add the labels using this example you provided in this post: https://sourceforge.net/p/glscene/discussion/93606/thread/f379b20a/#25c6

    can you point me to the lines in the 3D texture example where I can expand from a 1x1x1 cube to box that matches the data shape/dimensions?

    thanks

     

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.