Results 1 to 4 of 4

Thread: Cone from TriangleFan

  1. #1

    Cone from TriangleFan

    This Programme will draw a Cone on the Screen and Rotate it.

    [code=thinbasic]

    ' Cone in thinBASIC using TBGL...
    '

    uses "TBGL" ' thinBASIC OpenGL Library
    uses "MATH" ' Used for Trigonometry

    ' Create, Show Our Window and Reset Status of all Keys...
    '

    Dim hWnd As dword = tbgl_createwindow("Cone - Press 'Esc' to Quit")
    tbgl_showwindow

    tbgl_getasynckeystate(-1)

    ' Dimension and Initialize any Variables...
    '

    dim Xrot, Yrot, Zrot as single ' X,Y and Z Rotation Variables
    dim ConeRadius, ConeHeight as integer ' Radius and Height of Cone
    dim ConeShade as single ' Level of Brightness
    dim i as integer ' Polygon Drawing Loop Variable

    ' Main Programme Loop
    '

    while tbgl_iswindow(hWnd)

    tbgl_clearframe ' Clear Screen
    tbgl_camera 0, 0, 1, 0, 0, 0 ' Set Camera Position
    tbgl_resetmatrix ' Clear the Current Matrix
    tbgl_translate 0.0, 0.0, -5.0 ' Move Object into Screen by 5.0

    tbgl_Rotate Xrot, 1.0, 0.0, 0.0 ' Rotation around the X-Axis
    tbgl_Rotate Yrot, 0.0, 1.0, 0.0 ' Rotation around the Y-Axis
    tbgl_Rotate Zrot, 0.0, 0.0, 1.0 ' Rotation around the Z-Axis

    ConeRadius = 1
    ConeHeight = 4

    tbgl_color 255, 255, 255 ' Set Colour to White

    tbgl_beginpoly %gl_triangle_fan

    tbgl_vertex 0.0, (ConeHeight / 2) * -1, 0.0

    for i = 0 to 36

    ConeShade = Abs (13.25 * (18-i))
    tbgl_color ConeShade, ConeShade, ConeShade
    tbgl_vertex ConeRadius * cos(degtorad(i*10)), (ConeHeight / 2), ConeRadius * Sin(degtorad(i*10))

    next

    tbgl_endpoly

    tbgl_color 128, 128, 128 ' Set Colour to Grey

    tbgl_beginpoly %gl_polygon

    for i = 0 to 36

    tbgl_vertex ConeRadius * cos(degtorad((36-i)*10)), (ConeHeight / 2), ConeRadius * sin(degtorad((36-i)*10))

    next

    tbgl_endpoly

    tbgl_drawframe ' Swap the Drawing Buffers

    Xrot = Xrot + 0.1 ' X axis rotation
    Yrot = Yrot + 0.2 ' Y axis rotation
    Zrot = Zrot + 0.05 ' Z axis rotation

    if tbgl_getwindowkeystate(hWnd, %vk_escape) then exit while

    wend

    tbgl_destroywindow ' Closes OpenGL Window

    [/code]
    Attached Images Attached Images
    Operating System: Windows 10 Home 64-bit
    CPU: Intel Celeron N4000 CPU @ 1.10GHz
    Memory: 4.00GB RAM
    Graphics: Intel UHD Graphics 600

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

    Re: Cone from TriangleFan

    Thanks for these samples Mathew. Nice to see how these so called primitive shaps come to life!!
    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

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

    Re: Cone from TriangleFan

    Hi,

    thanks a lot!,
    it reminds me of optimization I have still not done on tbgl cylinders with one radus equal to zero


    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

  4. #4

    Re: Cone from TriangleFan

    Thank's for the Comments you two.
    Operating System: Windows 10 Home 64-bit
    CPU: Intel Celeron N4000 CPU @ 1.10GHz
    Memory: 4.00GB RAM
    Graphics: Intel UHD Graphics 600

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
  •