ReneMiner
08-04-2013, 12:02
I'm currently thinking about saving 3d-stuff and I want it fast. (but the re-loading of data - not the solution for my problem ;) )
My Vertices, Normals, Colors and UV are all stored to Global udt-Arrays and I have an additional Triangle-Type to indicate which of them to use at what corner. I already send this data to Displaylist so I can display them as some Entity. The thing is, all my position-vectors, normal-vectors, texels and colors are all seperate and unique and the triangle-udt holds their indexes or indices - which indicate what to use at which corner. They real "vertices" get composed from their single properties inside their parenting faces corner. So far...
Here's overview of my types that make the mesh:
(I'm using Doubles because I do a lot of calculation with these. In general Singles would be precise enough for just-display-purpose.)
Uses "TBGL"
Type t_vec3d
X As Double
Y As Double
Z As Double
End Type
Type t_Texel
U As Double
V As Double
End Type
Type t_Triangle
V(3) As Long ' these hold indices of position-vectors
N(3) As Long ' normal -vector to the corner
T(3) As Long ' texel (UV)
C(3) As Long ' Color
nX As Double ' those are for Face-Normals and to place the
nY As Double ' camera when supposed to look at triangle
nZ As Double
cX As Double ' center-position, needed to order and sort
cY As Double
cZ As Double
Grp As Long
Checked As Boolean
End Type
' -----------------------------
' these hold the data:
Dim Vec() As t_Vec3d : Dim nVecs As Long
Dim Nml() As t_Vec3d : Dim nNmls As Long
Dim Txl() As t_Texel : Dim nTxls As Long
Dim Col() As TBGL_TRGB : Dim nCols As Long
Dim Tri() As t_Triangle : Dim nTriangles As Long
Organized nearly .obj - everything is just once in memory - different from .obj is, that I use only triangles and no other kinds of faces (which are all made from triangles anyway)...
The displaylist and also m15-format works another way - there are no indices and vertices are just in order, so every data-component is in there a few times - this might be the way they get drawn fastest but on one hand it's a large waste of space and almost impossible to organize data that way for an app that has to calculate and keep connections between these vertices (are the corners of two faces at same point etc. would use a lot of calculating and temporary storing of meantime-results or lists of things...)
Additional I have some type to group triangles that shall use same texture + material, looks alike this - I omit some from the original-type because they're just temporary related to the group for current session.
Type t_MeshGroup
Identity As String ' the Identity is just to allow the user
' to identify his groups as "roof", "wall" etc.
Members As String
Texture As String ' store Texture-Filename of this group here
Ambient As TBGL_TRGBA
Diffuse As TBGL_TRGBA
Emissive As TBGL_TRGBA
Specular As TBGL_TRGBA
SpecExp As Byte
' -- current session values i omit here
'...
End Type
Dim Group() As t_MeshGroup : Dim nGroups As Long
ReDim Group(1) : nGroups = 1 ' lower bound is 1 here, there's always one...
'(a triangle that has .Grp = 0 is a deleted one)
The Members-String insice this Type gets composed as follows: If a triangle gets created or joins this group, I just do this:
Group(Group_Current).Members += MKL$(NewMembersIndex)
' later I just dim a virtual long array over this to read members out
Every group makes basically one Entity...
Group1 will probably be the parent, all additional will be childs...
together they make the mesh...
.m15 won't allow me to put the material-data into the file...
I like using Entity...
Is there a possibility to make a String from all my Data and to poke it into an Entity or DisplayList in one step?
I mean I would organize the string as Entity needs it in advance - even make all singles from doubles here - no problem - it's not about the speed here in this current app - but about the speed in another app that should make use of 3d-stuff, drawn with the app I'm currently creating. I also might create a loading-routine that does the Parse data + Poke$ to Entity for every single group then
I want to load data later in another app and if I would have to organize the whole displaylist for everything that gets loaded then - that might be very slow and knocks all that follows out.
And FunctionSlot? I have not really understood yet how this works but I think that needs a Function that gets called when Entity shall be drawn and that seems also to be a speed-problem. And it doees not seem to differ very much from the way I do it now - I also call some function to create Entity from a displaylist-slot which i set up in that function...
TBGL_NewListSpace?/TBGL_NewList don't return a pointer where I cound poke data
- anybody some idea how to flush all data to tbgl-entity at once?
So later I could fast read-in a file as string,
parse into groups
poke groups-data$ to Entity
apply material
next group/Entity
My Vertices, Normals, Colors and UV are all stored to Global udt-Arrays and I have an additional Triangle-Type to indicate which of them to use at what corner. I already send this data to Displaylist so I can display them as some Entity. The thing is, all my position-vectors, normal-vectors, texels and colors are all seperate and unique and the triangle-udt holds their indexes or indices - which indicate what to use at which corner. They real "vertices" get composed from their single properties inside their parenting faces corner. So far...
Here's overview of my types that make the mesh:
(I'm using Doubles because I do a lot of calculation with these. In general Singles would be precise enough for just-display-purpose.)
Uses "TBGL"
Type t_vec3d
X As Double
Y As Double
Z As Double
End Type
Type t_Texel
U As Double
V As Double
End Type
Type t_Triangle
V(3) As Long ' these hold indices of position-vectors
N(3) As Long ' normal -vector to the corner
T(3) As Long ' texel (UV)
C(3) As Long ' Color
nX As Double ' those are for Face-Normals and to place the
nY As Double ' camera when supposed to look at triangle
nZ As Double
cX As Double ' center-position, needed to order and sort
cY As Double
cZ As Double
Grp As Long
Checked As Boolean
End Type
' -----------------------------
' these hold the data:
Dim Vec() As t_Vec3d : Dim nVecs As Long
Dim Nml() As t_Vec3d : Dim nNmls As Long
Dim Txl() As t_Texel : Dim nTxls As Long
Dim Col() As TBGL_TRGB : Dim nCols As Long
Dim Tri() As t_Triangle : Dim nTriangles As Long
Organized nearly .obj - everything is just once in memory - different from .obj is, that I use only triangles and no other kinds of faces (which are all made from triangles anyway)...
The displaylist and also m15-format works another way - there are no indices and vertices are just in order, so every data-component is in there a few times - this might be the way they get drawn fastest but on one hand it's a large waste of space and almost impossible to organize data that way for an app that has to calculate and keep connections between these vertices (are the corners of two faces at same point etc. would use a lot of calculating and temporary storing of meantime-results or lists of things...)
Additional I have some type to group triangles that shall use same texture + material, looks alike this - I omit some from the original-type because they're just temporary related to the group for current session.
Type t_MeshGroup
Identity As String ' the Identity is just to allow the user
' to identify his groups as "roof", "wall" etc.
Members As String
Texture As String ' store Texture-Filename of this group here
Ambient As TBGL_TRGBA
Diffuse As TBGL_TRGBA
Emissive As TBGL_TRGBA
Specular As TBGL_TRGBA
SpecExp As Byte
' -- current session values i omit here
'...
End Type
Dim Group() As t_MeshGroup : Dim nGroups As Long
ReDim Group(1) : nGroups = 1 ' lower bound is 1 here, there's always one...
'(a triangle that has .Grp = 0 is a deleted one)
The Members-String insice this Type gets composed as follows: If a triangle gets created or joins this group, I just do this:
Group(Group_Current).Members += MKL$(NewMembersIndex)
' later I just dim a virtual long array over this to read members out
Every group makes basically one Entity...
Group1 will probably be the parent, all additional will be childs...
together they make the mesh...
.m15 won't allow me to put the material-data into the file...
I like using Entity...
Is there a possibility to make a String from all my Data and to poke it into an Entity or DisplayList in one step?
I mean I would organize the string as Entity needs it in advance - even make all singles from doubles here - no problem - it's not about the speed here in this current app - but about the speed in another app that should make use of 3d-stuff, drawn with the app I'm currently creating. I also might create a loading-routine that does the Parse data + Poke$ to Entity for every single group then
I want to load data later in another app and if I would have to organize the whole displaylist for everything that gets loaded then - that might be very slow and knocks all that follows out.
And FunctionSlot? I have not really understood yet how this works but I think that needs a Function that gets called when Entity shall be drawn and that seems also to be a speed-problem. And it doees not seem to differ very much from the way I do it now - I also call some function to create Entity from a displaylist-slot which i set up in that function...
TBGL_NewListSpace?/TBGL_NewList don't return a pointer where I cound poke data
- anybody some idea how to flush all data to tbgl-entity at once?
So later I could fast read-in a file as string,
parse into groups
poke groups-data$ to Entity
apply material
next group/Entity