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

Thread: Coliding or subtracting graphic objets

  1. #1

    Coliding or subtracting graphic objets

    Hi all,

    I have another intereting programming problem.

    I am trying to do a subractive graphic.
    Here it goes.

    1 draw the first sphere with a small radius
    2 draw a second sphere with a much larger radius ( is can also be an egg shaped object)
    3 I make them collide.
    4 I asume that the area of the colision becomes invisible by taking on the colour of the background.
    5 The remaining area (pls see attachment) then becomes a section of a sphere or which can be rotated, zoomed, shaded etc...
    (http://www.i-optic.com/3dshape.jpg) in case the attachment can't be seen.

    What are the chances of doing this with thinbasic ?
    Do I first calculate the geometric area of the remaining sphere section and then render it ?
    where to start ?

    Best regards
    Rob
    -o-o-
    Attached Images Attached Images

  2. #2

    Re: Coliding or subtracting graphic objets

    Sorry, my english isn't my native language so somtimes I have to ask again before I can try to help.

    So before I go searching a formular on the net, do you want the colliding area to become a 3D modell that can be transformed or do you want the rest of the first sphere and the rest of the 2nd sphere to become a 3D model?

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,782
    Rep Power
    10

    Re: Coliding or subtracting graphic objets

    Mike,

    just in case you didn't noticed it, Rob is from Australia so his reply can arrive a some hours time

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  4. #4

    Re: Coliding or subtracting graphic objets

    No problem. I have patience. I'm already googling up the term Constructive solid geometry.

    http://en.wikipedia.org/wiki/Constru...solid_geometry

    I'm sure once I understand exactly what he wants to make, we can come up with a solution for it. I find the stuff he does very interesing. A project like this can help pushing TBGL and other modules a little again.

  5. #5

    Re: Coliding or subtracting graphic objets

    Also it could probably help Francko with his 3D modeller project. No good 3D modelling software without boolean operations, or

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,782
    Rep Power
    10

    Re: Coliding or subtracting graphic objets

    Yes, it seems to me to recall very closely your 3D/2D example:
    http://community.thinbasic.com/index.php?topic=1292.0

    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  7. #7

    Re: Coliding or subtracting graphic objets

    Hi,
    am awake again

    I am trying to keep the black -remaining section of the black sphere, and then zoom, rotate it etc...
    A kind of subtractive collision of geometric objects.

    best regards
    Rob
    -o-o-

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

    Re: Coliding or subtracting graphic objets

    Hi Rob,

    CSG is not implemented yet, but here is code you can just copy and paste and you will see one of the ways to create and manipulate 2 spheres.
    So "geometry subtracting" is not here yet, but you can get basic idea how 3D works in ThinBasic.
    [code=thinbasic]
    Uses "TBGL"

    BEGIN CONST
    ' -- Scene IDs
    %sScene = 1

    ' -- Entity IDs
    %eCamera = 1
    %eLight

    %eSpherePivot

    %eSphereA
    %eSphereB
    END CONST

    FUNCTION TBMAIN()
    LOCAL hWnd As DWORD
    LOCAL FrameRate AS DOUBLE

    ' -- Create and show window
    hWnd = TBGL_CreateWindowEx("Two spheres - press ESC to quit", 640, 480, 32, %TBGL_WS_WINDOWED or %TBGL_WS_CLOSEBOX)
    TBGL_ShowWindow

    ' -- Create scene
    TBGL_SceneCreate(%sScene)

    ' -- Higher number, higher quality
    TBGL_SetPrimitiveQuality 50

    ' -- Create basic entities
    ' -- Create camera to look from 15, 15, 15 to 0, 0, 0
    TBGL_EntityCreateCamera(%sScene, %eCamera)
    TBGL_EntitySetPos(%sScene, %eCamera, 0, 0, 7)
    TBGL_EntitySetTargetPos(%sScene, %eCamera, 0, 0, 0)

    ' -- Create point light
    TBGL_EntityCreateLight(%sScene, %eLight)
    TBGL_EntitySetPos(%sScene, %eLight, 0, 10, 10)

    ' -- Create something to look at
    TBGL_EntityCreatePivot(%sScene, %eSpherePivot)

    TBGL_EntityCreateSphere(%sScene, %eSphereA, %eSpherePivot, 1)
    TBGL_EntitySetColor(%sScene, %eSphereA, 255, 128, 0)
    TBGL_EntitySetPos(%sScene, %eSphereA, -0.5, 0, 0)

    TBGL_EntityCreateSphere(%sScene, %eSphereB, %eSpherePivot, 1.5)
    TBGL_EntitySetColor(%sScene, %eSphereB, 0, 128, 255)
    TBGL_EntitySetPos(%sScene, %eSphereB, 1, 0, 0)

    ' -- Resets status of all keys
    TBGL_ResetKeyState()

    ' -- Main loop
    While TBGL_IsWindow(hWnd)
    FrameRate = TBGL_GetFrameRate

    TBGL_ClearFrame

    TBGL_SceneRender(%sScene)

    TBGL_DrawFrame

    ' -- ESCAPE key to exit application
    If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While

    ' -- Spheres are attached to pivot point, when we turn or move pivot, spheres will go with it
    IF TBGL_GetWindowKeyState(hWnd, %VK_LEFT) Then
    TBGL_EntityTurn(%sScene, %eSpherePivot, 0,-90/FrameRate, 0)
    ELSEIF TBGL_GetWindowKeyState(hWnd, %VK_RIGHT) Then
    TBGL_EntityTurn(%sScene, %eSpherePivot, 0, 90/FrameRate, 0)
    END IF

    IF TBGL_GetWindowKeyState(hWnd, %VK_PGUP) Then
    TBGL_EntityMove(%sScene, %eSpherePivot, 0, 0,-1/FrameRate)
    ELSEIF TBGL_GetWindowKeyState(hWnd, %VK_PGDN) Then
    TBGL_EntityMove(%sScene, %eSpherePivot, 0, 0, 1/FrameRate)
    END IF

    Wend

    TBGL_DestroyWindow
    END FUNCTION
    [/code]
    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

  9. #9
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,782
    Rep Power
    10

    Re: Coliding or subtracting graphic objets

    Just for the "ignorant" (meaning in Latin: ignore) like me: [wiki=Constructive_solid_geometry]CSG[/wiki]
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

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

    Re: Coliding or subtracting graphic objets

    Look at rendering to a texture would be my suggestion.
    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

Page 1 of 3 123 LastLast

Similar Threads

  1. Graphic artists, what can you actually provide?
    By Michael Hartlef in forum Media
    Replies: 14
    Last Post: 14-10-2008, 09:00
  2. Experimental commands: GRAPHIC
    By ErosOlmi in forum thinBasic vaporware
    Replies: 3
    Last Post: 12-12-2007, 00:14
  3. Using dialog as graphic console
    By Petr Schreiber in forum Module SDK (Power Basic version)
    Replies: 2
    Last Post: 20-09-2005, 15:29

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
  •