Results 1 to 9 of 9

Thread: Circles question

  1. #1
    Senior Member Lionheart008's Avatar
    Join Date
    Sep 2008
    Location
    Germany, Bad Sooden-Allendorf
    Age
    51
    Posts
    934
    Rep Power
    109

    Circles question

    hi

    I am looking for 'TBGL_DrawCircles' perhaps it's just a silly question, don't know... TBGL_DrawSphere does exists, but what about circles??? It's just 2d, isn't it??? It's better to go the direct way with primitives as kind of "2d in 3d" ???

    Some days ago I would like to build a yin-yang symbol... with colours, thought about it and try to make circles... (2d circles)... without success... with 'tbgl_DrawCircle'

    FUNCTION RenderMyImage( hCtrl as dword )
    STATIC FrameRate AS DOUBLE
    DIM i, x, y, f, r AS INTEGER
    Dim Radius As Number
    '- Dim Color As Number '- TBGL_Color( R, G, B ) as number !

    if TBGL_CanvasBound(hCtrl) then

    FrameRate = TBGL_GetFrameRate

    FOR i = 1 to 500
    x = INT(RND*639)+1 'Zufallszahlen generieren
    y = INT(RND*479)+1
    f = INT(RND*255)+1
    r = INT(RND*400)+1
    DrawCircle( x,y,r,f ) 'Kreis zeichnen
    If TBGL_GetWindowKeyState(hctrl, %VK_ESCAPE) Then END '- ???
    Sleep 10
    next i
    end
    TBGL_ClearFrame

    TBGL_SceneRender(%sScene)

    TBGL_DrawFrame

    end if
    END FUNCTION

    sub DrawCircle( x as single, y as single, f as single, r as single )
    tbgl_PushMatrix
    tbgl_color 255, 0, 0
    tbgl_translate 0,-1,0
    tbgl_DrawCircle 0.75,2.5,r,f '- 0.75, 2.5 und circle (300,250),r,f
    '- TBGL_Circle(X, Y), Radius, Color
    -'with tbgl_DrawSphere script runs but withouth circle
    tbgl_PopMatrix
    end sub
    perhaps somebody can give any hint to the theme "Circles" (link or script or something else) or I have choosed totally the wrong way

    my script example is just a try to build in circles... the idea with yin-yang is just another task

    good night, Lionheart with courage to blame myself

    ps: please take attention, the script doesn't run at all
    Attached Images Attached Images
    Attached Files Attached Files
    you can't always get what you want, but if you try sometimes you might find, you get what you need

  2. #2
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Re: Circles question

    Frank it doesnt exist but it could. I havent tried the code below but it should work.


    [code=thinbasic]
    %DL_Circle = 1
    %DEG2RAD = 3.14159/180 AS DOUBLE

    SUB drawCircle(radius AS SINGLE)
    LOCAL i AS LONG
    LOCAL degInRAD AS DOUBLE

    TBGL_NewList %DL_Circle
    TBGL_PushMatrix
    TBGL_BeginPoly %GL_LINE_LOOP
    FOR i = 0 TO 360
    degInRad = i*%DEG2RAD
    TBGL_Vertex cos(degInRad)*radius, sin(degInRad)*radius
    NEXT
    TBGL_ENDPOLY
    TBGL_PopMatrix
    TBGL_EndList
    END SUB[/code]
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  3. #3
    Senior Member Lionheart008's Avatar
    Join Date
    Sep 2008
    Location
    Germany, Bad Sooden-Allendorf
    Age
    51
    Posts
    934
    Rep Power
    109

    Re: Circles question + freebasic infos

    hi michael

    thanks a lot for your prompted help!

    really good idea and looks very nice your script, even I can follow the structure , but how should I get the entity of %DL_Circles??? I mean this special part for '%eDL_Circle, %DL_Circle' (doesn't matter here if it's right, the script doesn't show the circle ;(... hmh)

    '---------------------------------------------------------------------------
    ' -- Create something to look at
    '- TBGL_EntityCreateCircle(%sScene, %eDL_Circle, 0, 1.25, 255, 155, 255)
    '- TBGL_EntitySetPos(%sScene, %eDL_Circle, -1, 1, 3)
    '---------------------------------------------------------------------------
    tbgl module cannot build: 'TBGL_EntityCreateCircle' or similar things...

    I have found some infos about 'circles' from freebasic and has translated it...

    Syntax: CIRCLE [Puffer,] [STEP] (x,y), Radius[, [Color][, [startangle][, [endangle][, [Aspect][, F]]]]]
    [aspect] does mean: relation between y-Radius and x-Radius so you can follow...
    "ratio = (y_radius / x_radius) * pixel_aspect_ratio"

    [F] = Flag for color, fill the circle, arc, ellipse with color (yes, not)

    so in freebasic you can use this code for creation of circles, arc, ellipsoids

    CIRCLE (320, 240), 200, 15
    ' draw a white CIRCLE
    (320, 240), 200, 2, , , 0.2, F
    ' draws a filled EllipseCIRCLE
    (320, 240), 200, 4, 0.83, 1.67, 3
    ' draws a little arc.
    perhaps we can find a solution or somebody can program / code such some day a new circles, arc, ellipse syntax :-D but I can wait for it it's not urgent...

    best wishes, have a nice "good morning", bye, Lionheart
    ps: add a script but still without circles... but perhaps it's just a simple thing I cannot understand how to build it...
    Attached Files Attached Files
    you can't always get what you want, but if you try sometimes you might find, you get what you need

  4. #4
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Re: Circles question

    try this Frank.


    SUB drawCircle(Xpos AS LONG, Ypos AS LONG, Width AS SINGLE, Height AS SINGLE, StepSize AS SINGLE)

    Note: Stepsize is the number of steps to make 360, so 1 would be smooth and 3 would be a triangle.
    use the scaling to making it bigger or smaller

    TBGL_EntitySetScale( SceneID, EntityID, X, Y, Z )

    Update: Improved the sub routine to include position for 2D.
    Attached Files Attached Files
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

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

    Re: Circles question

    Michael,

    as usually, big thanks for support!

    Frank, Mike provided you with display list version of circle.
    Can it be used as entity? Sure, because it is display list, which can be binded using TBGL_EntityCreateDLSlot.

    As Mike said, using scaling you can modify the dimensions of such a display list circle template.


    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

  6. #6
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Re: Circles question

    Frank here is something you might be interested in.

    DrawCircle 2, 5, (360/NumberOfSides)

    if you want a hexagon you make NumberOfSides = 6, I dont think you need more detail than that

    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  7. #7
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Re: Circles question

    made some improvements, see the post which start "try this Frank".
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  8. #8
    Senior Member Lionheart008's Avatar
    Join Date
    Sep 2008
    Location
    Germany, Bad Sooden-Allendorf
    Age
    51
    Posts
    934
    Rep Power
    109

    Re: Circles question

    ...short reply, must go at work now...

    hi michael, dear petr, yes, very good one

    DrawCircle 2, 5, (360/NumberOfSides)
    and

    DrawCircle 200,200,20, 50, (360/3)
    I have tried the new script above and it works for me with one circle or hexagon or octagon (I have coded and tried it too this morning... )

    =>my problem was to create more than one circle, hexagon or something with new forms... I have tried to build two, three circles and rotated them... but didn't found a way to show it... (add my script with problems... according to tbgl_new list)

    => with display list I can create more circles (or boxes or spheres...) so I wish, but it doesn't run at the moment... to create eg 4 ( circles with different degrees (rotation)...

    %DL_Circle = 2
    TBGL_NewList %DL_Circle
    TBGL_PushMatrix
    TBGL_BeginPoly %GL_LINE_LOOP
    FOR i = 0 TO 360 STEP StepSize
    degInRad = i*%DEG2RAD
    TBGL_Color 255,0,250
    TBGL_Vertex cos(degInRad)*Width, sin(degInRad)*Height
    NEXT
    TBGL_ENDPOLY

    TBGL_Translate 0, 1.25, 0
    TBGL_Rotate 90, 0, 0, 0
    TBGL_BeginPoly %GL_LINE_LOOP
    FOR i = 0 TO 360 STEP StepSize
    degInRad = i*%DEG2RAD
    TBGL_Color 255,0,25
    TBGL_Vertex cos(degInRad)*Width, sin(degInRad)*Height
    NEXT
    TBGL_ENDPOLY
    TBGL_PopMatrix
    next problem: it's not useful to make a second drawcircle as I can use the TBGL_NewList %DL_Circle functions or what do you think??? it should run with 'display list', but didn't ;(

    DrawCircle 2, 5, 1.5 '- (360/4)
    TBGL_EntityCreateDLSlot(%sScene, %eCircle, 0, %DL_Circle )
    '- TBGL_EntityCreateDLSlot( SceneID, EntityID, ParentEntityID, DisplayList )
    TBGL_EntitySetPos(%sScene, %eCircle, -4, 0, 0)
    TBGL_EntitySetTargetPos(%sScene, %eCircle, 8, 8, 8 )

    DrawCircle 2.5, 6, 1.5 '- (360/
    TBGL_EntityCreateDLSlot(%sScene, %eCircle1, 0, %DL_Circle )
    TBGL_EntitySetRot(%sScene, %eCircle1, 90, 0, 0)
    TBGL_EntitySetColor(%sScene, %eCircle1, 250,255,255 )
    TBGL_EntitySetPos(%sScene, %eCircle1, 1, 2, 1)
    TBGL_EntitySetTargetPos(%sScene, %eCircle1, 8, 8, 8 )
    my script isn't just perfect, I know, will try it this evening again, thanks a lot, in this way we can create circles, ellipse, arcs and much more

    ok, more will come later... thanks michael! :-) I like it to get more good tbgl support

    see you, Lionheart
    Attached Images Attached Images
    Attached Files Attached Files
    you can't always get what you want, but if you try sometimes you might find, you get what you need

  9. #9

    Re: Circles question

    Quote Originally Posted by Michael Clease
    Frank it doesnt exist but it could. I havent tried the code below but it should work.


    [code=thinbasic]
    %DL_Circle = 1
    %DEG2RAD = 3.14159/180 AS DOUBLE

    SUB drawCircle(radius AS SINGLE)
    LOCAL i AS LONG
    LOCAL degInRAD AS DOUBLE

    TBGL_NewList %DL_Circle
    TBGL_PushMatrix
    TBGL_BeginPoly %GL_LINE_LOOP
    FOR i = 0 TO 360
    degInRad = i*%DEG2RAD
    TBGL_Vertex cos(degInRad)*radius, sin(degInRad)*radius
    NEXT
    TBGL_ENDPOLY
    TBGL_PopMatrix
    TBGL_EndList
    END SUB[/code]
    Hi Michael,

    it exists but isn't documented yet. The current TBGL has it allready inside. TBGL_LINE2D, TBGL_CIRCLE2D, TBGL_RECT2D and TBGL_BOX2D. Petr and I decided to rename them without the 2D for the next release and then the help file should be updated too.

Similar Threads

  1. Crop Circles
    By Charles Pegge in forum Shout Box Area
    Replies: 5
    Last Post: 16-08-2010, 05:15

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
  •