I think obj-format is very common - but has no vertex-color-support - m15 has a lot of already present features to TBGL - but no materials and limited texture-formats and the file-format I used in this editor is some pure editor-format - not for fast graphics but to calculate a lot with related vertices/faces etc. Keep selected faces in mind, camera+pointer-position- so this is just editor-format to work with.
If a model is done - it should be stored to some format that can get loaded as fast as possible to appear on screen. It might use up some more time - when the model gets written from editor to file and that's ok to arrange it all optimized once. Important is the later use.
So the raw gl-list in order would be the fastest way from that point. To avoid any "if/select Case etc." while loading the "header" should start with a vertex-format-information so the loader has to decide just once how to use the data. If no Texels- no texture to await, if VertexColors no Materialcolor to apply etc. Maybe can make some switch to call the loader in a way that it will calculate missing normals if desired. (this editor always supplies normals, but maybe someone else makes another)
And to make this even faster, the file-extension should hold the vertex-format-information, there are only a few possiblities of combinations, a position has every vertex. There can be also normal, texels and colors - and that's about it. Vertex-Weights or -friction we don't have (yet) - but if there will be someday its easier to create new loading-routines instead of branching the existing apart.
The groups (or layers as m15) should be done in order and not by any index. Like one would write a displaylist.
I had already the idea to load displaylist-data in a way that read lines from a file immediately get processed as if they were codelines so there's no more if and sorting/CVx() and stuff needed - Eros says that might be possible, but he has to think about it.
Faster I think will only be loading binary data block directly to entity - in a displaylist-order - but already creating necessary sub-entities from all following groups (return parent-entity of course) - so needs some common order to pass the data for Material/Texture/Appearance/Vertexdata - let's call that "Layers" again - or "Groups" or Sub-Entity. Appearance means like "%GL_Triangles", "%GL_TriangleStrip" etc.
It could work the state-keeping way as displaylist and openGl in general, so pass once a normal or color instead of passing normal, color, texel before each position - but that would need some trailing word to each line as "TBGL_Vertex...", "TBGL_Normal..." and to parse these lines according to trailer - on the other hand can also be a trailer as "TBGL_NewLayer" so the loader "knows" - the current list ends and a new layers list starts here and the next entity is needed to be prepared and data that follows apllies to the next entity (which will always be a child of the very first one). So this kind of Entity (or better Super-Entity as you would call it in java) is only statics or parts that can get attached to bones later.
Also (in thinking of the future) there should be a reserved layer for collision-shapes (has no "visible" faces in Entity, consists of one shape. It's faces have Vertex-Position always and/or Normals only. Positions for simple Inside-Collision, + normals for face-collisions in the future. So we might think of storing Collision-Type, Layer-Center and -Radius too. Maybe the unused material-properties of the collision-layer can hold "global"-Entity-Information as Friction, Bounciness and Weight for simple physics
all my data to work with you'll find in the beginning of unit Specific3d.tBasicU,
the triangles just oversee - they're not necessary, only these
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
and partial these
Dim Group() As t_MeshGroup : Dim nGroups As Long
ReDim Group(1) : nGroups = 1 ' lower bound is 1...
partial because the current sessions values from t_MeshGroup are not needed in a mesh
Also think about- I used all Doubles because of calculating - so my types as t_Vec3d/t_Texel are wrong type because not Single-Floats
(the t_Object3dController was just some attempt to bundle all imaginable properties - but I think Entity-System already has all what's needed. I made it because I needed Double-Precise)
so I guess there is some enumeration of vertex-components (as Position(0) - always present, Normals(1), Texels(2), Colors(4)) needed - and a constant $sString-Table that holds the file-extensions for all combinations so "how/what to load" is already decided when the filename is chosen.
Another way would mean using some index-buffer which needs face-data in addition. Might need less memory-resources (does it really - doesn't have the screen to display the same amount of vertices with or without indexed vertices?) I like more the straight pass all in line instead of letting the computer jump from Index to Index - but however you create it, I think I'll get my data inside somehow
Edit: Two important things to add here - my script uses thinBasicgl.inc - two switches that I think can be packed into some TBGL-state (or even become Entity-Defaults) so the thinBasicGl.inc is not needed.
glEnable(%GL_CULL_FACE) ' stays enabled forever!
glCullFace(%GL_BACK)
'... and (decides in Function CreateUserEntity() -TBGL-Specific)
If VertexColorsPresent Then
glColorMaterial ( %GL_FRONT, %GL_AMBIENT_AND_DIFFUSE )
glEnable(%GL_COLOR_MATERIAL)
Endif
And btw. I use MATH-Module for one function only (ATAN2) - which could be asides the TBGL_EntityGetAngle- just integrated as TBGL_GetAngle...
One more Edit:
It might be an idea to create besides Light & Camera two additional special Entity-Types, as Terrain (wich does not need seperate collision-layer) and a "Water-Layer-Entity" which has no collision layer either - but has "fog" below surface - "Water" can also be like "Lava" or "Swamp", "Quicksand" etc. So "Water" is actually a box that has only faces on top. Should be possible to enable/disable/detect collision with top surface
Bookmarks