Results 1 to 5 of 5

Thread: creating my own class

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

    creating my own class

    Since UDT's can not have dynamic arrays I think about creating my own class using thinBasic.

    I've read a lot of class-threads in this forum, now I have still some questions - as usual - since I don't want to waste more hours for unsuccessful trying again because I'm on totally wrong track...
    #DELETED
    
    EDIT:
    OK, doesn't seem to work in tB... - using VB6 to create my own tB-class now - and IT WORKS!
    Last edited by ReneMiner; 17-11-2012 at 02:30.
    I think there are missing some Forum-sections as beta-testing and support

  2. #2
    Member REDEBOLT's Avatar
    Join Date
    Dec 2006
    Location
    Pickerington, Ohio, USA
    Age
    87
    Posts
    62
    Rep Power
    24
    Rene,

    Can you show us how you created a VB6 class and how it works in TB?

    Regards,
    Bob

  3. #3
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,529
    Rep Power
    170
    I used this tutorial

    http://www.activevb.de/tutorials/tut...gpunktdll.html

    but it's german. I know there's an english-version somewhere around on the web, but I don't have a link for that.
    I'm still testing capabilities, so right now I have no example ready for that, but you have to declare Aliases in any case, even if the declared tB-functions are named the same as in the .dll. Important is that you have to create a Standard-Exe in vb - no activeX-dll and you need that Linker-Controller. You can download there (see link) the whole test-project, you have just to rewrite the call-script to tb, but thats easy
    Last edited by ReneMiner; 17-11-2012 at 15:18.
    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,

    the thing is ThinBASIC does not allow creating CLASSes from code at the moment, only via modules (= you can create DLLs in other languages with ThinBASIC SDK to expose instantiable class to script).
    Even this interface is still in regime of exploring the possibilities.

    The words such as class, method, ... are reserved for future use, but there is no mention of classes in the documentation for a reason


    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,529
    Rep Power
    170
    yeah, I'm still cranking my brains how to store variables inside the dll- I mean it works very well for Functions and Subs, but I need dynamic UDTs to manage some meshes in memory...thats the whole idea why using vb6.

    The SDK is of no use for me since there's no structured documentation nor examples how to use and I'm fed up with hours of searching and trying out for the next weeks

    the m15-type is quite not easy to handle, ok, it just consists of vertices and has no materials (yet) - I try to order meshes in some different, alike an industrial format (NetImmerse File Format, Version 4.0.0.2, also known as GameBryo or Morrowind-Mesh-File)
    The good thing about that format is, the meshes are structured by shapes, that have their own vertices and faces. So I would not have to run for each layer and texture through all vertices to get my Entity together.

    So a Car-Mesh for example would just need one Tire-Shape, that would be used 4 times and can be rotated by controllers inside Mesh-Structure and it has a collision-shape (maybe simplified, invisible box around the car) that could be handy for the future.

    I do not want to use the exact NIF/Gamebryo-format - its very complicated since it handles animations also, but I want to make a own, simplified one inspired from this format. You might study my notes (attached "sample mesh") that I made for myself to organize all that, so you can see what I am up to, but I'm hanging currently at lack of dynamic UDTs.

    Maybe anyone got some ideas how to create this structure without dynamic UDTs
    here's what the structure would look like in vb
    ' t_Mesh_D-VB-Type
    
    
    Type t_ColorRGBA  ' this type I just used since VB doesn't know TBGL_tRGBA
        R As Byte
        G As Byte
        B As Byte
        A As Byte
    End Type
    
    ' using doubles here for calculations see very low line
    Type t_Vector
        dX As Double
        dY As Double
        dZ As Double
    End Type
    
    Type t_Vertex
        dX As Double
        dY As Double
        dZ As Double    
        dNX As Double
        dNY As Double
        dNZ As Double    
        R As Byte
        G As Byte
        B As Byte    
        dTU As Double
        dTV As Double
    End Type
    
    Type t_Material
        Identifier as String
        Texture As String
        Ambient As t_ColorRGBA
        Diffuse As t_ColorRGBA
        Emissive As t_ColorRGBA
        Specular As t_ColorRGBA
        SpecExp As Byte
    End Type
    
    Type t_3Angle
        V(1 To 3) As Long
        M As t_Vector  ' this is center of triangle, wont be saved to finished mesh
        N As t_Vector  ' face-normal-vector, won't be saved
        Flag As Long  ' also just for editor-use needed
    End Type
    
    Type t_Shape
        Identifier as String
        Vertices As Long
        Faces As Long
        Vertex() As t_Vertex ' here is the lack
        Face() As t_3Angle
    End Type
    
    Type t_Group
        Identifier as String
        MaterialID As Long
        ShapeID As Long
        Rotate As t_Vector
        Scale As t_Vector
        Translate As t_Vector
        Flag  As Long   ' also just Editor-Specific,
                              ' could hold some %is_Deleted or whatever...
    End Type
    
    Type t_Mesh_D
        Identifier as String
        Materials As Long
        Material() as t_Material
        CollisionMode as Long
        CollisionShape as Long
        Shapes As Long
        Shape() As t_Shape  ' also this needs to be dynamic...
        Groups As Long
        Group() As t_Group
    End Type 
    ' this is the t_Mesh_D-Type (all Doubles) for editor
    ' there could be a similar type using Singles for
    ' later just load + display
    
    Attached Files Attached Files
    Last edited by ReneMiner; 17-11-2012 at 21:04.
    I think there are missing some Forum-sections as beta-testing and support

Similar Threads

  1. How to run a Dot Net 4.0 class from Powerbasic
    By zak in forum Software discussion
    Replies: 1
    Last Post: 17-12-2011, 11:27
  2. Minimal example of module class
    By Petr Schreiber in forum thinBasic SDK
    Replies: 3
    Last Post: 07-07-2011, 07:25
  3. How to use asciiz inside a class?
    By efgee in forum O2h Compiler
    Replies: 4
    Last Post: 03-09-2010, 20:20
  4. class+object+dialog
    By Lionheart008 in forum UI (User Interface)
    Replies: 3
    Last Post: 17-11-2009, 22:09
  5. Class Libraries using Oxygen
    By Charles Pegge in forum O2h Compiler
    Replies: 3
    Last Post: 10-08-2009, 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
  •