Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: Playing with lines based on tutorial code

  1. #1
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Playing with lines based on tutorial code

    Here is a result of playing with lines based on Petr's tbgl tutorials.

    this one is a noise like pattern

     ' 
    ' Lesson #2 from thinBASIC TBGL tutorials
    ' "Colors"
    '
    ' by Petr Schreiber
    ' 
    ' Downloaded from http://psch.thinbasic.com/
    ' 
    
    Uses "TBGL"
    Uses "UI"
    
    DIM hWnd AS DWORD
    DIM vx as long
    'MsgBox (0, "You should see blue screen with colorful triangle soon"+$LF+$LF+"Press ESCAPE to quit window", %MB_ICONINFORMATION, "Lesson 2")
    
    ' We will initialize OpenGL and internal buffers
    ' Function also returns window handle
    hWnd = tbgl_CreateWindow( "Lesson 2 - press ESC to quit") 
    
    
    tbgl_ShowWindow ' This will display the window on the screen
    
    tbgl_BackColor 0, 0, 0 ' Let's set the default background to darkblue - just one call needed ! 
    tbgl_Color 0, 255, 0 
    GetAsyncKeyState(%VK_ESCAPE) ' Reset status of the ESCAPE to prevent immediate quit
    
    
    while iswindow(hWnd) ' While window exists, we will draw and check for ESCAPE
    win_SetTitle( hWnd, TBGL_GetFramerate & " Noise or Scratch Effect - Press ESC to EXIT")
    tbgl_ClearFrame ' This clears the frame and prepares it for drawing
    
    tbgl_Camera 0,0,cos(timer)*100,0,0,0 ' We will look from point 0,0,5 to 0,0,0 ( origin of coordinates )
    tbgl_rotateXYZ 0,cos(timer)*30,0
    tbgl_linewidth rnd(1,2)
    for vx = 1 to 50 step 1
    tbgl_BeginPoly %GL_LINES' Here begins definition of traditional triangle polygon 
    ' Pulsing Black-To-Red
    
    tbgl_Color 225, 200, 0
    tbgl_Vertex -rnd(1,50),rnd(1,50),rnd(1,50) 
    'vx = rnd(1,100) 
    tbgl_Vertex rnd(1,50),-rnd(1,50),rnd(1,50) 
    
    tbgl_EndPoly ' We must end the definition of polygon
    next
    tbgl_linewidth rnd(1,3)
    for vx = 1 to 50 step 1
    tbgl_BeginPoly %GL_LINES' Here begins definition of traditional triangle polygon
    
    tbgl_Color 255, 100,0
    tbgl_Vertex -rnd(1,75),rnd(1,75),rnd(1,75) 
    'vx = rnd(1,100) 
    tbgl_Vertex rnd(1,75),-rnd(1,75),rnd(1,75) 
    
    tbgl_EndPoly ' We must end the definition of polygon
    next
    tbgl_linewidth 1
    for vx = 1 to 50 step 1
    tbgl_BeginPoly %GL_LINES' Here begins definition of traditional triangle polygon
    
    
    tbgl_Color 255, 150 , 0
    tbgl_Vertex -rnd(1,25),rnd(1,25),rnd(1,25) 
    'vx = rnd(1,100) 
    tbgl_Vertex rnd(1,25),-rnd(1,25),rnd(1,25) 
    
    tbgl_EndPoly ' We must end the definition of polygon
    next
    tbgl_DrawFrame ' This will display the scene
    
    ' When ESCAPE is pressed, we will leave the main loop
    IF GetAsyncKeyState(%VK_ESCAPE) THEN EXIT while
    Wend 
    
    tbgl_DestroyWindow ' This will destroy the window
    
    This one is like inside of a laser projector:
     ' 
    ' Lesson #2 from thinBASIC TBGL tutorials
    ' "Colors"
    '
    ' by Petr Schreiber
    ' 
    ' Downloaded from http://psch.thinbasic.com/
    ' 
    
    Uses "TBGL"
    Uses "UI"
    
    DIM hWnd AS DWORD
    DIM vx,vy,vz,angle as double
    DIM lw as integer = 1
    'MsgBox (0, "You should see blue screen with colorful triangle soon"+$LF+$LF+"Press ESCAPE to quit window", %MB_ICONINFORMATION, "Lesson 2")
    
    ' We will initialize OpenGL and internal buffers
    ' Function also returns window handle
    hWnd = tbgl_CreateWindow( "Lesson 2 - press ESC to quit") 
    
    
    tbgl_ShowWindow ' This will display the window on the screen
    
    tbgl_BackColor 0, 0, 0 ' Let's set the default background to darkblue - just one call needed ! 
    'tbgl_Color 75, 100, 75 
    GetAsyncKeyState(%VK_ESCAPE) ' Reset status of the ESCAPE to prevent immediate quit
    
    
    while iswindow(hWnd) ' While window exists, we will draw and check for ESCAPE
    win_SetTitle( hWnd, TBGL_GetFramerate & " Inside Laser Projector Effect - Press ESC to EXIT")
    tbgl_ClearFrame ' This clears the frame and prepares it for drawing
    
    tbgl_Camera 0,0,cos(timer),0,0,0 ' We will look from point 0,0,5 to 0,0,0 ( origin of coordinates )
    'tbgl_rotateXYZ 0,cos(timer)*30,0 'adds some rotation to the camera
    'lw = rnd(1,2)
    tbgl_linewidth lw
    tbgl_BeginPoly %GL_LINES' Here begins definition of traditional triangle polygon 
    vz = 0.0
    for angle = 0.0 to 3*3.1415 step 0.05
    tbgl_Color rnd(1,10), rnd(1,200) , rnd(1,10)
    vx = 50.0*sin(angle)
    vy = 50.0*cos(angle)
    tbgl_Vertex vx, vy, vz
    vx = 50.0*sin(angle+3.1415)
    vy = 50.0*cos(angle+3.1415)
    tbgl_Vertex vx, vy, vz
    next
    tbgl_EndPoly ' We must end the definition of polygon
    
    tbgl_DrawFrame ' This will display the scene
    
    ' When ESCAPE is pressed, we will leave the main loop
    IF GetAsyncKeyState(%VK_ESCAPE) THEN EXIT while
    Wend 
    
    tbgl_DestroyWindow ' This will destroy the window
    
    Attached Images Attached Images

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

    Re: Playing with lines based on tutorial code

    Hi kryton9,

    this is psychedelic ;D

    I can imagine it as post process for some halucinating scenes.
    This would require just to render scene and then your effect with depth flag off and possibly some kind of blending


    Bye,
    Petr
    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

  3. #3
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: Playing with lines based on tutorial code

    Thanks Petr, you are kind, just goofing around with line codes and came up with some stuff. If you turn of the z depth, would it still plot the line vertices into the z plane?

    I am going to play more with lines as I know I can come up with something really good, just haven't figured it out yet
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  4. #4
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,129
    Rep Power
    732

    Re: Playing with lines based on tutorial code

    Hi kryton9,

    turning off depth means just turning of depth test, it means if you first draw foreground part of cube and then the back part, you will see the back part. This is unusable for classical rendering, but good for post process stuff and particles, if you draw them as last ones.

    Looking forward for next creations,
    Petr
    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

  5. #5
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: Playing with lines based on tutorial code

    Thanks for explanation Petr, that will come in handy!!
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  6. #6
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: Playing with lines based on tutorial code

    This is to mimic sort of a red laser security system like seen in movies for museums. The camera tilts slowly up from looking towards the floor. to show the room being scanned. No room in this, but you can get the idea

     ' 
    ' Lesson #2 from thinBASIC TBGL tutorials
    ' "Colors"
    '
    ' by Petr Schreiber
    ' 
    ' Downloaded from http://psch.thinbasic.com/
    ' 
    
    Uses "TBGL"
    Uses "UI"
    
    DIM hWnd AS DWORD
    DIM vx,vy,vz,angle,cy as double
    DIM lw as integer = 1
    'MsgBox (0, "You should see blue screen with colorful triangle soon"+$LF+$LF+"Press ESCAPE to quit window", %MB_ICONINFORMATION, "Lesson 2")
    
    ' We will initialize OpenGL and internal buffers
    ' Function also returns window handle
    hWnd = tbgl_CreateWindow( "Lesson 2 - press ESC to quit") 
    
    
    tbgl_ShowWindow ' This will display the window on the screen
    
    tbgl_BackColor 0, 0, 0 ' Let's set the default background to darkblue - just one call needed ! 
    'tbgl_Color 75, 100, 75 
    GetAsyncKeyState(%VK_ESCAPE) ' Reset status of the ESCAPE to prevent immediate quit
    
    cy = -0.1
    while iswindow(hWnd) ' While window exists, we will draw and check for ESCAPE
    win_SetTitle( hWnd, TBGL_GetFramerate & " Inside Laser Projector Effect - Press ESC to EXIT")
    tbgl_ClearFrame ' This clears the frame and prepares it for drawing
    
    tbgl_Camera 0,0,0.1,0,cy,0 ' We will look from point 0,0,5 to 0,0,0 ( origin of coordinates )
    cy += 0.0001
    if cy > -0.01 then cy = -0.1
    'tbgl_rotateXYZ 0,cos(timer)*30,0 'adds some rotation to the camera
    'lw = rnd(1,2)
    tbgl_linewidth lw
    ' tbgl_BeginPoly %GL_LINES' Here begins definition of traditional triangle polygon 
    ' vz = 0.0
    ' for angle = 0.0 to 3*3.1415 step 0.05
    ' tbgl_Color rnd(1,10), rnd(1,10) , rnd(1,255)
    ' vx = 50.0*sin(angle)
    ' vy = 50.0*cos(angle)
    ' tbgl_Vertex vx, vy, vz
    ' vx = 50.0*sin(angle+3.1415)
    ' vy = 50.0*cos(angle+3.1415)
    ' tbgl_Vertex vx, vy, vz
    ' next
    ' tbgl_EndPoly ' We must end the definition of polygon
    
    tbgl_BeginPoly %GL_LINES' Here begins definition of traditional triangle polygon 
    vz = 0.00
    for angle = 0.0 to 3*3.1415 step 0.05
    tbgl_Color rnd(1,255), rnd(1,10) , rnd(1,10)
    vx = 50.0*sin(angle)+0.25
    vy = 50.0*cos(angle)
    tbgl_Vertex vx, vy, vz
    vx = 50.0*sin(angle+3.1415)
    vy = 50.0*cos(angle+3.1415)
    tbgl_Vertex vx, vy, vz
    next
    tbgl_EndPoly ' We must end the definition of polygon
    
    tbgl_BeginPoly %GL_LINES' Here begins definition of traditional triangle polygon 
    vz = 0.00
    for angle = 0.0 to 3*3.1415 step 0.05
    tbgl_Color rnd(1,255), rnd(1,10) , rnd(1,10)
    vx = 50.0*sin(angle)-0.25
    vy = 50.0*cos(angle)
    tbgl_Vertex vx, vy, vz
    vx = 50.0*sin(angle+3.1415)
    vy = 50.0*cos(angle+3.1415)
    tbgl_Vertex vx, vy, vz
    next
    tbgl_EndPoly ' We must end the definition of polygon
    tbgl_DrawFrame ' This will display the scene
    
    ' When ESCAPE is pressed, we will leave the main loop
    IF GetAsyncKeyState(%VK_ESCAPE) THEN EXIT while
    Wend 
    
    tbgl_DestroyWindow ' This will destroy the window
    
    Here is my story idea maybe, the good side forces (thinBasic) are being infiltrated by The Ruby Python Organization. RPO sent its agents to steal the code from deep with thinBasic Headquarters in the Master Code Vault, the much protected secret code file to free the world from complicated programming syntax and bring joy and fun to the world, Project Super thinBasic.

    I found hints of this top secret file in the new examples in the recent release

    I played with making a logo for Ruby Python Organization to get me motivated, will see where it leads too. Have to come up with something for thinBasic now
    Attached Images Attached Images

  7. #7
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,129
    Rep Power
    732

    Re: Playing with lines based on tutorial code

    ;D,

    kryton9, this idea is scary !
    If I imagine someone would stole tB source

    The laser effect is good. I have just one suggestion - instead of random color I would go for SIN or something like that to make it harmonically pulse. I like the snake logo, it is quite scary to see something like that at the night.

    Just don't know if Python and Ruby users won't feel upset by the idea of making them the "evil ones"

    Anyway, here is very very simple laser study ( ) of secure room:
    '
    ' Laser chamber
    '
    
    Uses "TBGL"
    Uses "UI"
    
    DIM hWnd AS DWORD
    
    hWnd = tbgl_CreateWindow( "Laser chamber - press ESC to quit") 
    tbgl_ShowWindow ' This will display the window on the screen
    
    GetAsyncKeyState(%VK_ESCAPE) ' Reset status of the ESCAPE to prevent immediate quit
    
    tbgl_UseLightSource %GL_LIGHT0, 1 
    tbgl_SetLightParameter %GL_LIGHT0, %TBGL_LIGHT_position, 0,2,0,1 
    
    dim i, j as single
    dim FrameTime as single
    while iswindow(hWnd) ' While window exists, we will draw and check for ESCAPE
    
    tbgl_ClearFrame ' This clears the frame and prepares it for drawing
    
    tbgl_Camera 5, 5, 5, 0, 1, 0
    tbgl_Rotate GetTickCount/80, 0, 1, 0
    
    FrameTime = getTickCount/500
    
    
    ' Pillars
    
    tbgl_UseLighting 1 
    tbgl_Color 255, 128, 0
    PlacePillar(-1, -1)
    PlacePillar( 1, -1)
    PlacePillar( 1, 1)
    PlacePillar(-1, 1)
    tbgl_UseLighting 0 
    
    tbgl_UseBlend 1
    tbgl_UseDepthMask 0
    
    tbgl_BeginPoly %GL_LINES
    
    for i = 0.25 to 2 step 0.25
    tbgl_Color sin(FrameTime+i)*64+127, 0, 0
    tbgl_Vertex -1, i, -1
    tbgl_Vertex 1, i, -1
    next 
    
    for i = 0.25 to 2 step 0.25
    tbgl_Color sin(FrameTime+i+2)*64+127, 0, 0 
    tbgl_Vertex -1, i, 1
    tbgl_Vertex 1, i, 1
    next 
    
    for i = 0.25 to 2 step 0.25
    tbgl_Color sin(FrameTime+i+3)*64+127, 0, 0 
    tbgl_Vertex -1, i, -1
    tbgl_Vertex -1, i, 1
    next 
    
    tbgl_EndPoly
    
    for i = 0.25 to 2 step 0.25
    
    tbgl_BeginPoly %GL_LINE_STRIP 
    tbgl_Vertex 1, i, -1
    
    for j = -1 to 0.75 step 0.25
    tbgl_Color sin(FrameTime+i+j)*64+127, 0, 0 
    tbgl_Vertex 1, i+sin(FrameTime+i*i+j*j+j)/5, j
    next
    
    tbgl_Vertex 1, i, 1 
    tbgl_EndPoly
    
    next 
    
    tbgl_UseDepthMask 1
    tbgl_UseBlend 0 
    
    tbgl_DrawFrame
    
    ' When ESCAPE is pressed, we will leave the main loop
    IF GetAsyncKeyState(%VK_ESCAPE) THEN EXIT while
    Wend 
    
    tbgl_DestroyWindow ' This will destroy the window
    
    sub PlacePillar( x as single, z as single )
    tbgl_Pushmatrix
    tbgl_Translate x, 1, z
    tbgl_Box 0.25, 2, 0.25 
    tbgl_popmatrix
    end sub
    
    One laser wall has very special properties


    Bye,
    Petr
    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

  8. #8
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: Playing with lines based on tutorial code

    Petr, you are too good. Very cool, thanks I will borrow some of that code in the near future

    I actually am very impressed with Ruby and Python is the KING in scripting now with Perl it seems.
    I will make sure to make a message that this is in fun and no bad intentions to those coders.

    Just Ruby Python made such a good combo

    It will be a funny short demo to test what can be done at the moment. Of course will love your additions
    to it. I will do the whole thing, then send it to you and you can look at it and tweak where you see fit.
    It will be a couple of weeks, but you never know how creativity goes, maybe it will flood with simple to do ideas
    and come together.

    As always thanks for your feedback and ideas and always cool code!!
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  9. #9
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,129
    Rep Power
    732

    Re: Playing with lines based on tutorial code


    Yes, Ruby Python sounds good
    Looking forward to the game, when in coding troubles just ask


    Bye,
    Petr
    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

  10. #10
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: Playing with lines based on tutorial code

    I made a thinBasic emblem just awhile ago. Wanted to convey happiness and light airy feel as the alternative to rubypython.

    Actually if there were a super thinBasic it probably would be like Ruby But this is all fiction and fun.
    Attached Images Attached Images
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

Page 1 of 3 123 LastLast

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
  •