PDA

View Full Version : creating my own class



ReneMiner
16-11-2012, 16:11
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!

REDEBOLT
17-11-2012, 04:31
Rene,

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

Regards,
Bob

ReneMiner
17-11-2012, 15:12
I used this tutorial

http://www.activevb.de/tutorials/tut_einsprungpunktdll/einsprungpunktdll.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

Petr Schreiber
17-11-2012, 18:41
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

ReneMiner
17-11-2012, 20:07
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