ReneMiner
25-09-2013, 09:58
I still have some wishes to improve TBGL-Entity-System - especially when it comes to fast-loading data directly to entity/display-list.
A dream of sweet cream would be, if there were a native Entity-File-Format that supports both: vertex-colors and materials. So OBJ-format is out of question because does not support vertex-colors - perhaps M15 could be improved by adding some extra material-file - similar as OBJ has - wich holds Material-Data for the single layers - or even better would be some new, simple format that will be read in alike GBufferDefineFromArray from file to some Displaylist-Slot or Entity.
However, the Entity-System of my dreams would do a couple of things:
- manage a Textures-Pool ( maybe occupy slots 1 to 768 ) so every texture gets just loaded once,
- Textures be part of Material (already possible) but mandatory for Entities loaded/saved the way below,
- TBGL_EntityBindMaterial-functionality - or call it TBGL_EntitySetMaterial - whatever...
- support PNG-Format also - to have one compressed that allows alpha
( I know that needs Windows somewhat above Win95 but I think a Win95-PC never would have the needed graphics hardware to run Entities anyway)
this just how I imagine to write data:
Header
' -----------
numTextures
Texture() ' means this is array of numTextures elements with following properties:
Filename
AnisoLevel
Filtering
TranspColor
' if numTextures > 1 then here would follow again Filename, AnisoLevel, Filtering, TranspColor
' -----------
numMaterials
Material()
Ambient R, G, B, A
Diffuse R, G, B, A
Emissive R, G, B, A
Specular R, G, B, A
SpecExp E
TextureIndex ' points to a Texture() above or 0 if none
BlendFunc
AlphaFunc
' -----------
ParentEntity
MaterialID ' points to a Material() above
Rotate X, Y, Z
Scale X, Y, Z
Translate X, Y, Z
PolyType ' TBGL_BeginPoly-Equates
VertexType ' see Vertex-Format-Equates below - somehow needs a way to specify this in advance
numVertices
Vertex()
X, Y, Z [, nX, nY, nZ][,tU, tV][, R, G, B[, A]]
numChildren
ChildEntity()
MaterialID
Rotate X, Y, Z
Scale X, Y, Z
Translate X, Y, Z
PolyType
VertexType
numVertices
Vertex()
X, Y, Z [, nX, nY, nZ][, tU, tV][, R, G, B[, A]]
numChildren
ChildEntity() '- here would follow a child of first child if one
'...
ChildEntity() '- while this is second child of parent-entity
'...EOF somewhere here
' ----------------------------------------
' Vertex-Format-Equates:
%Vertex_hasPosition = 0 ' X, Y, Z are always available
%Vertex_hasNormals = 1 ' X, Y, Z, nX, nY, nZ
%Vertex_hasTexcoords = 2 ' X, Y, Z, tU, tV
%Vertex_hasNormalTex = 3 ' X, Y, Z, nX, nY, nZ, tU, tV
%Vertex_hasColor = 4 ' X, Y, Z, R, G, B
%Vertex_hasNormalColor = 5 ' X, Y, Z, nX, nY, nZ, R, G, B
%Vertex_hasTexColor = 6 ' X, Y, Z, tU, tV, R, G, B
%Vertex_hasTexNormalColor = 7 ' X, Y, Z, nX, nY, nZ, tU, tV, R, G, B
%Vertex_hasAlpha = 8 ' X, Y, Z, R, G, B, A
%Vertex_hasNormalAlpha = 9 ' X, Y, Z, nX, nY, nZ, R, G, B, A
%Vertex_hasTexAlpha = 10 ' X, Y, Z, tU, tV, R, G, B, A
%Vertex_hasNormalTexAlpha = 11 ' X, Y, Z, nX, nY, nZ, tU, tV, R, G, B, A
Edit: this way could just return top-level-parent-ID on load
Helpful could be using Entity-Name-Property where names get composed on load like ParentName+ChildNames alike "RobotsGroin_Torso_LeftArm_Hand_Thumb" and some function that lists Children-IDs or vice versa: retrieve EntityID from Scene+Name-parameters
A dream of sweet cream would be, if there were a native Entity-File-Format that supports both: vertex-colors and materials. So OBJ-format is out of question because does not support vertex-colors - perhaps M15 could be improved by adding some extra material-file - similar as OBJ has - wich holds Material-Data for the single layers - or even better would be some new, simple format that will be read in alike GBufferDefineFromArray from file to some Displaylist-Slot or Entity.
However, the Entity-System of my dreams would do a couple of things:
- manage a Textures-Pool ( maybe occupy slots 1 to 768 ) so every texture gets just loaded once,
- Textures be part of Material (already possible) but mandatory for Entities loaded/saved the way below,
- TBGL_EntityBindMaterial-functionality - or call it TBGL_EntitySetMaterial - whatever...
- support PNG-Format also - to have one compressed that allows alpha
( I know that needs Windows somewhat above Win95 but I think a Win95-PC never would have the needed graphics hardware to run Entities anyway)
this just how I imagine to write data:
Header
' -----------
numTextures
Texture() ' means this is array of numTextures elements with following properties:
Filename
AnisoLevel
Filtering
TranspColor
' if numTextures > 1 then here would follow again Filename, AnisoLevel, Filtering, TranspColor
' -----------
numMaterials
Material()
Ambient R, G, B, A
Diffuse R, G, B, A
Emissive R, G, B, A
Specular R, G, B, A
SpecExp E
TextureIndex ' points to a Texture() above or 0 if none
BlendFunc
AlphaFunc
' -----------
ParentEntity
MaterialID ' points to a Material() above
Rotate X, Y, Z
Scale X, Y, Z
Translate X, Y, Z
PolyType ' TBGL_BeginPoly-Equates
VertexType ' see Vertex-Format-Equates below - somehow needs a way to specify this in advance
numVertices
Vertex()
X, Y, Z [, nX, nY, nZ][,tU, tV][, R, G, B[, A]]
numChildren
ChildEntity()
MaterialID
Rotate X, Y, Z
Scale X, Y, Z
Translate X, Y, Z
PolyType
VertexType
numVertices
Vertex()
X, Y, Z [, nX, nY, nZ][, tU, tV][, R, G, B[, A]]
numChildren
ChildEntity() '- here would follow a child of first child if one
'...
ChildEntity() '- while this is second child of parent-entity
'...EOF somewhere here
' ----------------------------------------
' Vertex-Format-Equates:
%Vertex_hasPosition = 0 ' X, Y, Z are always available
%Vertex_hasNormals = 1 ' X, Y, Z, nX, nY, nZ
%Vertex_hasTexcoords = 2 ' X, Y, Z, tU, tV
%Vertex_hasNormalTex = 3 ' X, Y, Z, nX, nY, nZ, tU, tV
%Vertex_hasColor = 4 ' X, Y, Z, R, G, B
%Vertex_hasNormalColor = 5 ' X, Y, Z, nX, nY, nZ, R, G, B
%Vertex_hasTexColor = 6 ' X, Y, Z, tU, tV, R, G, B
%Vertex_hasTexNormalColor = 7 ' X, Y, Z, nX, nY, nZ, tU, tV, R, G, B
%Vertex_hasAlpha = 8 ' X, Y, Z, R, G, B, A
%Vertex_hasNormalAlpha = 9 ' X, Y, Z, nX, nY, nZ, R, G, B, A
%Vertex_hasTexAlpha = 10 ' X, Y, Z, tU, tV, R, G, B, A
%Vertex_hasNormalTexAlpha = 11 ' X, Y, Z, nX, nY, nZ, tU, tV, R, G, B, A
Edit: this way could just return top-level-parent-ID on load
Helpful could be using Entity-Name-Property where names get composed on load like ParentName+ChildNames alike "RobotsGroin_Torso_LeftArm_Hand_Thumb" and some function that lists Children-IDs or vice versa: retrieve EntityID from Scene+Name-parameters