Results 1 to 5 of 5

Thread: TBGL_EntityFind...-question

  1. #1
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,527
    Rep Power
    170

    TBGL_EntityFind...-question

    a question about the various TBGL_EntityFind...-functions:
    f.e.

    TBGL_EntityFindNearestByPos( SceneID, EntityType, x, y, z, rangeX, rangeY, rangeZ [, GlobalCoordinates ] )

    parameter-description:

    Type of entity to search for, can take one of following values:

    %TBGL_LIGHT
    %TBGL_CAMERA
    %TBGL_PIVOT

    %TBGL_MODEL
    %TBGL_DISPLAYLIST

    %TBGL_BOX
    %TBGL_SPHERE
    %TBGL_TORUS
    %TBGL_CYLINDER

    what EntityType to specify for a function-slot?
    Last edited by ReneMiner; 02-11-2014 at 10:02.
    I think there are missing some Forum-sections as beta-testing and support

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

    the function slot entities are not supported by this command at the moment.

    What kind of functionality would be better for you: add %TBGL_FunctionSlot equate, or develop some smarter method, which would allow to perform filter like "all function slot entities which implement member x and function y"?


    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
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,527
    Rep Power
    170
    the simplest i think is to add some equate for the already existing TBGL-functions so these are fully functional on all entity-types TBGL provides us with currently...

    A function-slot does not mandatory need to have a user-type attached - does it? It sounds reasonable at first if it would work like:
    "please TBGL, list all enemy-spaceships near that point xy" but i think then i would just go myself through the list of enemy-spaceships but not through all entities then and measure all theirs distances...

    edit: it's thinkeable - if it were faster than in a tB-script- if TBGL would examine a scene and just go through a passed list of entities - and return what is left then.

    So user sends a string, array or now possible too: variadic parameter-list of entity-IDs that might be interesting, TBGL could probably be faster than the user to check for distances in a range to a certain point or entity and TBGL returns the closest entityID of the listed ones in range - or zero if none in range.
    If getting closest listed entity by position it's pretty simple - but if the referred entity is also in the list... hmmm- return any other but itself nor any of its own children...

    Function TBGL_EntityGetClosest( ByVal sceneID      As Long, _
                                    ByVal entityID     As Long, _
                                    ByVal listIDs(Any) As Long,  _
                              Optional Byval maxRange As Double _
                                   ) As Long
    '...
    Function TBGL_EntityGetClosestPos( ByVal sceneID      As Long,   _
                                       ByVal X            As Double, _
                                       ByVal Y            As Double, _
                                       ByVal Z            As Double, _
                                       ByVal listIDs(Any) As Long,   _
                              Optional Byval maxRange As Double _         
                                      ) As Long
    '...
    
    edit+

    if we already on it, i have two and a half simple suggests that might be handy one day:

    ' - 1 - 
    
    Function TBGL_EntityIsChildOf( ByVal SceneID          As Long, -
                                   ByVal suspectedChildID As Long, _
                                   ByVal suspectedParentID As Long _
                                  ) As Boolean
    
      While TBGL_EntityExists(sceneID, suspectedChildID )   
        suspectedChildID = TBGL_EntityGetParent( SceneID, suspectedChildID ) 
        If suspectedChildID = suspectedParentID Then Return TRUE
      Wend    
      
    End Function 
    
    ' - 1.5 - almost the same as above: 
    Function TBGL_EntityGetTopParent(ByVal SceneID As Long, _
                                     ByVal EntityID As Long _
                                     ) As Long
    
      While TBGL_EntityExists( SceneID, TBGL_EntityGetParent( SceneID, EntityID )) 
        EntityID = TBGL_EntityGetParent( SceneID, EntityID )
      Wend
      
      Function = EntityID
                                      
    End Function
    
    
    ' - 2 -
    
    Function TBGL_EntityExists( ByVal SceneID As Long, ByVal EntityID As Long) As Boolean
      
      Function = ( TBGL_EntityGetFreeID( SceneID , EntityID ) <> EntityID )
    
    End Function
    
    Last edited by ReneMiner; 05-11-2014 at 09:07.
    I think there are missing some Forum-sections as beta-testing and support

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

    thanks for the inspiration - ideas noted, if time allows, I will try to add to next TBGL release!


    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
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,527
    Rep Power
    170
    one more function to entities (especially bones-, parent- & child-stuff) that would be really helpful, in tB i have some VERY SLOW equivalent because Entity-enumeration is dynamic done to the script, at first I need the highest assigned EntityID in the current scene, (call it like %HighestID here) and then have to check all the numbers for theirs existance and if exist i need to check if it's a child of desired EntityID... really cumbersome:

    Function TBGL_EntityListChildren( ByVal Scene As Long, Byval EntityID As Long ) As String
    
    Local i As Long
    Local sResult As String  ' (returns Long-array)
    
    For i = 1 to %HighestID
      If TBGL_EntityExists( Scene, i ) Then
        If TBGL_EntityGetParent(Scene, i ) = EntityID Then sResult += MKL$(i)
      EndIf
    Next
    Function = sResult
    
    End Function
    
    optional there could be 2 switches to the function where the second switch only makes sense if the first one is used:
    - list grandchilds etc. too
    - list only childs that are in use (like in a collapsed tree it won't list hidden subchilds then)


    Currently it forces me to store all information the entity already has stored somewhere in the depth of TBGL a second time at the user-data-slot. This can not be good...
    it's like i would store positions of all entities - makes no sense- TBGL knows all the current positions exactly... while my stored data depends on continous refreshing it in the correct moment, which costs unnecessary resources and is not fool-proof
    Last edited by ReneMiner; 15-11-2014 at 10:48.
    I think there are missing some Forum-sections as beta-testing and support

Similar Threads

  1. Question of the day ;)
    By Petr Schreiber in forum thinBasic General
    Replies: 8
    Last Post: 23-08-2010, 19:58
  2. C to TB question
    By Michael Clease in forum Other languages
    Replies: 2
    Last Post: 03-06-2010, 12:11
  3. gdi question
    By Lionheart008 in forum UI (User Interface)
    Replies: 6
    Last Post: 07-12-2009, 19:31
  4. UDT question
    By sandyrepope in forum thinBasic General
    Replies: 3
    Last Post: 18-02-2008, 22:33
  5. m15 question
    By kryton9 in forum M15 file format
    Replies: 4
    Last Post: 20-06-2007, 20:18

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
  •