Results 1 to 2 of 2

Thread: Deformed pictures

  1. #1

    Deformed pictures

    a painting by Hans Holbein https://en.wikipedia.org/wiki/The_Ambassadors_(Holbein)
    have many symbolism and hidden meanings , one of the best is the strange figure at the painting bottom, it is in fact a deformed skull, we can't see a skull until we look at it from the side: look this excellent 1 minute demo Zhttps://www.youtube.com/watch?v=sNlgLSRZaos
    the skull should be like this:
    https://en.wikipedia.org/wiki/File:Holbein_Skull.jpg

    now how we can simulate it with thinbasic TBGL ?
    the simplest approach is to texture a quad (mostly quad) and then adjust the camera like in the youtube demo
    i have used this picture 779x768 :
    https://upload.wikimedia.org/wikiped...rt_Project.jpg
    but i changed it to 768x768 to make a square texture and then converting it to bmp (until Petr find a way to use the original 779x768)
    and this is the unchanged bmp 779x768
    http://wikisend.com/download/346254/Ambassadors.rar
    this is my best camera approach, you need the ambassadors bmp file attached below (768x768)
      Uses "TBGL"
    
      DIM hWnd AS Dword
    
      hWnd = TBGL_CreateWindowEx("press Esc to quit", 800, 600, 32, %TBGL_WS_WINDOWED)    ' Creates OpenGL window, it returns handle
      tbgl_ShowWindow                                             ' Shows the window
    
      TBGL_LoadTexture APP_SourcePath+"The_Ambassadors2.bmp", 1, %TBGL_TEX_MIPMAP    ' Loads texture as #1, with high quality
     
      tbgl_UseTexturing %TRUE           ' I want to use textures
      tbgl_BindTexture 1                ' We will use texture #1 in whole program
    
      TBGL_GetAsyncKeyState(-1)  ' Reset status of the all keys to prevent immediate quit  
        
      while TBGL_isWindow(hWnd)
    
        tbgl_ClearFrame               ' Prepares clear frame
        'TBGL_Camera 1.5,0.0,0.2,0,-0.5,0  
        TBGL_Camera 0.8,-0.3,0.5, 0,-0.7,0  'Look from position 0.8,-0.3,0.5 to 0,-0.7,0 
        
        tbgl_Color 255,255,255
        
        tbgl_BeginPoly %GL_QUADS      ' Starts polygon definition based on 4 vertexes
    
           TBGL_Color 255,255,255
          TBGL_TexCoord2D 0,0' Sets texture coordinate
          TBGL_Vertex -1,-0.9859,0         ' Adds vertex
    
          TBGL_TexCoord2D 1,0
          TBGL_Vertex  1,-0.9859,0
    
          TBGL_Color 255,255,255
          TBGL_TexCoord2D 1,1
          TBGL_Vertex  1, 0.9859,0
    
          TBGL_TexCoord2D 0,1
          TBGL_Vertex  -1, 0.9859,0
          
        tbgl_EndPoly                  ' Ends polygon definition
        
        
        TBGL_ResetMatrix   
               
        tbgl_DrawFrame                ' Swaps the buffers - displays rendered image
          
        if TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) THEN exit while
        
      wend
    
      tbgl_DestroyWindow              ' Closes OpenGL window
    
    the other approach is to mix the camera move with the painting scaling and move and rotate
      Uses "TBGL"
    
      DIM hWnd AS Dword
    
      hWnd = TBGL_CreateWindowEx("press Esc to quit", 800, 600, 32, %TBGL_WS_WINDOWED)    ' Creates OpenGL window, it returns handle
      tbgl_ShowWindow                                             ' Shows the window
    
      TBGL_LoadTexture APP_SourcePath+"The_Ambassadors2.bmp", 1, %TBGL_TEX_MIPMAP    ' Loads texture as #1, with high quality
     
      tbgl_UseTexturing %TRUE           ' I want to use textures
      tbgl_BindTexture 1                ' We will use texture #1 in whole program
    
      TBGL_GetAsyncKeyState(-1)  ' Reset status of the all keys to prevent immediate quit  
        
      while TBGL_isWindow(hWnd)
    
        tbgl_ClearFrame               ' Prepares clear frame
        TBGL_Camera 0,0,0.5,0,0,0       ' Setups camera to look from 0,0,5 to 0,0,0
        
        tbgl_Color 255,255,255
        
        TBGL_Translate 0.1, 0.7, 0    
        TBGL_Scale 0.2,1,1
        TBGL_Rotate -25,0,0
        
        tbgl_BeginPoly %GL_QUADS      ' Starts polygon definition based on 4 vertexes
    
         TBGL_Color 255,255,255
          TBGL_TexCoord2D 0,0' Sets texture coordinate
          TBGL_Vertex -1,-0.9859,0         ' Adds vertex
    
          TBGL_TexCoord2D 1,0
          TBGL_Vertex  1,-0.9859,0
    
          TBGL_Color 255,255,255
          TBGL_TexCoord2D 1,1
          TBGL_Vertex  1, 0.9859,0
    
          TBGL_TexCoord2D 0,1
          TBGL_Vertex  -1, 0.9859,0
          
        tbgl_EndPoly                  ' Ends polygon definition
        
        
        TBGL_ResetMatrix   
               
        tbgl_DrawFrame                ' Swaps the buffers - displays rendered image
          
        if TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) THEN exit while
        
      wend
    
      tbgl_DestroyWindow              ' Closes OpenGL window
    
    the skull here is more clear since it is compressed from its sides (TBGL_Scale 0.2,1,1)
    but my main purpose is to see the optimum skull as seen here:
    https://en.wikipedia.org/wiki/File:Holbein_Skull.jpg
    and to use the original texture dimentions without squaring it
    i have read about TBGL_TexturingQuery but don't know how to use it exactly in this subject context
    Hope you enjoy the practical usage of a simple programming code in real Life problem
    Note: i have used the tutorial about texturing from http://psch.thinbasic.com/old/tbgl_tut_b.html
    Attached Files Attached Files

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,153
    Rep Power
    736
    Primo,

    I really adore your contributions - playful, creative, easy to follow.


    Thank you,
    Petr
    Last edited by Petr Schreiber; 29-10-2017 at 11:54.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

Similar Threads

  1. some strange pictures
    By zak in forum Shout Box Area
    Replies: 0
    Last Post: 29-01-2012, 16:41
  2. Slider-Trackbar example with pictures
    By Lionheart008 in forum thinBasic General
    Replies: 0
    Last Post: 08-12-2008, 12:40

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •