Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: planets and gui / questions

  1. #1

    planets and gui / questions

    hello.
    1) petr, here a little attempt to include planets for my gui with openGL (tbgl). my question: if I push planet button I include they into scene. then you can pick up the planets (spheres objects) with mouse (grid spheres).
    2) if I want to pick up a bigger sphere (planet, for example a sun) with my grid catcher how to do that for different size of planets?
    3) my current problem: but I cannot see the data for this new planets send to listview. any help could be fine. source code into zip folder. project in works, not finished yet.
    thanks, bye, largo
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by largo_winch; 28-04-2011 at 10:49.

  2. #2
    Ciao largo_winch,
    For send information to the listiview control you have to send the handle of dialog window (hDlg) to the function RenderMyImage or you have to keep the global variable hDlg and remove local variable hdlg in TBMain function .

    I Hope it works.

    Ciao,
    Simone
    Last edited by Simone; 28-04-2011 at 13:23.
    LapTop Pc: 2GHz Intel Core 2 Duo T7200 • 2GB 533MHz DDR2 RAM • 160GB hard disk • 512MB ATi Mobility Radeon X1600 graphics • Win Vista SP1<br />Desktop Pc: 1.6GHz Intel Core 2&nbsp; • 2GB DDR2 RAM •&nbsp; 1024MB Nvidia GeForce 8800 GT • WinXp&nbsp; SP3

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

    2) if I want to pick up a bigger sphere (planet, for example a sun) with my grid catcher how to do that for different size of planets?
    You already have radius member in planetary objects user data. So to check if mouse points to given object, just check, whether the position is inside the object radius (with some safety offset). I would recommend to store all planet IDs in array, and then you can do something like:
    FOR i = 1 to planetCount
      TBGL_EntityGetPos(%sScene, planet(i), x, y, z)
      data =  TBGL_EntityGetUserDataPointer(%sScene, planet(i))
    
      IF TBGL_PointInside3D(MouseX, MouseY, MouseZ, %TBGL_OBJ_SPHERE, x, y, z, data.radius) THEN
        ' -- This is our object, let's mark it and so on
        ...
    
        EXIT FOR ' -- Stop searching
      END IF
    NEXT
    
    Side note: Have a look at article "EntityDataSignature", it discusses approach on how to sign different objects in scene using unique value. This way, if you create planets even in random order, but with planetary signature, you can retrieve their complete list to array anytime later.

    Other approach could be modification of your current one. You would store the biggest radius in scene and then use:
    entity = TBGL_EntityFindNearestByPos(%sScene, %TBGL_DISPLAYLIST , MouseX, MouseY, MouseZ, biggestRadius, biggestRadius, biggestRadius)
    But I guess this is not the best approach if you wish to include other objects than spheres in display lists later (could give false positives).


    Petr

    P.S. Ciao Simone, its great to see you more active on the forum lately!
    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
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Quote Originally Posted by Simone View Post
    Ciao largo_winch,
    For send information to the listiview control you have to send the handle of dialog window (hDlg) to the function RenderMyImage or you have to keep the global variable hDlg and remove local variable hdlg in TBMain function .

    I Hope it works.

    Ciao,
    Simone
    To translate in English what Simone wrote
    If you check inside function "RenderMyImage" you will see that handle of the main dialog is not defined because "hDlg" is always ZERO.
    Why? If you check "TBMain" function hDlg is defined as LOCAL so outside TBMain function hDlg does not has any meaning.

    I think the problem is that you adjusted this script from an old script made by Simone who used global variables (option to avoid wherever possible).

    To fix the script either
    • remove "Local hDlg As DWord" in TBMain function (you have already it as global variable)
    • pass the handle of the window to "RenderMyImage" as parameter and use that parameter as window handle


    Ciao
    Eros
    Last edited by ErosOlmi; 28-04-2011 at 22:58.
    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

  5. #5
    Quote Originally Posted by ErosOlmi View Post
    To translate in English what Simone wrote
    yes sorry for my bad English. It's terrible what i've wrote

    as Eros wrote the problem is the double declaration of hdlg(global and local in tbmain function).
    if you don't want to change too much the program the solution it's to remove the local declaration of hdlg in tbmain function. But maybe is better don't use global variable and send the handle of dialog to REnderMyImage function.

    hope this post it's more understandable.

    Ciao,
    Simone

    P.s. Thanks Petr!
    Last edited by Simone; 28-04-2011 at 23:41.
    LapTop Pc: 2GHz Intel Core 2 Duo T7200 • 2GB 533MHz DDR2 RAM • 160GB hard disk • 512MB ATi Mobility Radeon X1600 graphics • Win Vista SP1<br />Desktop Pc: 1.6GHz Intel Core 2&nbsp; • 2GB DDR2 RAM •&nbsp; 1024MB Nvidia GeForce 8800 GT • WinXp&nbsp; SP3

  6. #6
    thank you all for fast replies and help (simone, petr, eros). I will check my example again and now I am seeing what's the problem with global and local hdlg. regards,
    largo

  7. #7

    new planets gui part

    here a new version of my planets-gui-example. have fun to use it. a lot of work, but good stuff to learn more about openGL and thinbasic. context menu included (thanks for help to eros).
    all included in zip folder with tbasic file. next time I will try to use two different openGL windows as petr has shown good approach some days before.

    regards, largo
    Attached Images Attached Images
    Attached Files Attached Files

  8. #8
    Finaly someone who create interesting program...i like this astro stuff
    program is ok but planets looks like bunch of molecules maby will be better
    put smaller number of planets...just suggestion...

  9. #9
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Quote Originally Posted by zlatkoAB View Post
    Finaly someone who create interesting program...
    "Finally" is a little ... what to say ... not nice for the many hundreds of programs present into this forum developed by many users.

    Maybe if you have some time you can check bonus pack at http://www.thinbasic.com/index.php?o...tegory&catid=5
    that is a collection of old (maybe some of them will not run due to thinBasic changes during the yars) but interesting applications developed by many users (for free).

    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

  10. #10
    Hi Eros ...
    I don't mean nothing bad ....
    After all this mathematics experiments this program looks refreshing
    -for me
    of course i like Dan-s enthusiasm for programming

Page 1 of 2 12 LastLast

Similar Threads

  1. A few more questions..
    By oldpapa49 in forum thinBasic General
    Replies: 12
    Last Post: 21-03-2009, 21:45
  2. DT questions
    By Dave in forum DT (Date module)
    Replies: 9
    Last Post: 16-04-2008, 09:48

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
  •