DGL
https://delphigl.com/forum/

Mesh Object / How should it be organized?
https://delphigl.com/forum/viewtopic.php?f=19&t=6624
Seite 1 von 1

Autor:  noeska [ Mo Mai 28, 2007 18:21 ]
Betreff des Beitrags:  Mesh Object / How should it be organized?

On rewriting the Mesh Object in gl3ds i come to a question that i do not know to answer:

Should i use a TFace Structure in it or not (In the latest released version of gl3ds i have both and that is bad!):

TFace
--VertexIdx 1..3
--NormalIdx 1..3

array of TFace

vs

array of VertexIndices
array of normalIndices

So the real question is: is there a one on one relation between normalindices and vertexindices?
Second: Does TFace make things more complicated or easier?
Third question: how can the texture coords u and v be implemented into TFace or should i leave them outsite and use vertexidx to get the right ones.

Do let me know so i can improve that part (for now i commented out TFace and rewrote a few lines that used it).

Autor:  Gaukler [ Mo Mai 28, 2007 20:55 ]
Betreff des Beitrags: 

In my opinion:

PVertex = ^TVertex;
TVertex = record
Position: PVector3f //the vectors are defined in a separate array. So it is easy to delete them.
Normal: PVector3f; //..
TexCoord: PVector2f; //..
end;

TPolygon = record
Vertexes: array[0..2] of TVertex;
end;

and then you have an array of TPolygon.

My structure, which is in a way similar to your Face structure, would make the hole thing much easier to understand.
It has the advantage that you have all the information of a Vertex in one record.

Autor:  TAK2004 [ Di Mai 29, 2007 00:25 ]
Betreff des Beitrags: 

Code:
  1. TFace=packed record
  2.   Material:TMaterial;
  3.   idices:array of pTIndex;
  4.   normals:array of TNormal;
  5.   userdata:pointer;//pointer to special objectdata
  6. end;
  7.  
  8. TMesh=packed record
  9.   vertice:array of TVertex;
  10.   colors:array of TColors;
  11.   normals:array of TNormal;
  12.   uvs:array of TUV;
  13.   indices:array of TIndex;
  14.   count:cardinal;
  15.   Faces:array of  TFace;
  16. end;


This structure i prefer, because its optimised for vbo.
The each array in TMesh get a own VBO and the Mesh is sorted by Materials, so you can call the Materialscript and can handle Face specific rendering(alpha, shader variables,...).
The TFace get a extra Normal array for stuff like Physic. This normal is not smoothed.
A simular structure you will find in Blender.
I hope it will help you.

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/