Hello!
Hello!
I was thinking about the size the the "Vertex structurs" take.
eg 1. //this is how the full structure would look like right?
struct s3DVERTEXALL {
FLOAT x2D, y2D, z2D, rhw;
FLOAT x3D, y3D, z3D;
FLOAT nx, ny, nz;
D3DCOLOR diffuse;
FLOAT tu, tv;
};
eg 2. //this is how a cut of and memory friendly version looks like:
struct s3DVERTEX {
FLOAT x3D, y3D, z3D;
D3DCOLOR diffuse;
};
eg 3. //this is how a more dynamical structure would look:
struct sVERTEX {
union {
struct s2D {
FLOAT x, y, z, rhw;
} s2D;
struct s3D {
FLOAT x, y, z;
} s3D;
} CoordinateType;
union {
struct sColor {
D3DCOLOR diffuse;
} sColor;
struct sTexture {
FLOAT tu, tv;
} sTexture;
} TextureType;
};
So, how important IS the size of those structures?
Those are going to be used very often right?
So, according to "sizeof()" those were the results:
eg 1.
result: 54 //bytes? chars? or whatever...
eg 2.
result: 16
eg 3.
result: 24
So between the the cut of and very "undynamical" structure, eg 2, and the more dynamical one, eg 3, there is "only" 8 bytes difference. So would this matter very much when creating a big project in 3D?
The first one is probabilly not to even consider?
But the other two? wich one to use??
If I want very little memory consuming then the second is bes right? But then on the other hand I will have to create a new structure for each other case of Vertex type I want to create... and thus making it not good for creating a "MeshObject" class where I just would want to pass a VertexArray with information about the polygons and nothing else:
Something like this:
class MeshObject
{
public:
int Create(struct sVERTEX *sVertex); //With a Vertex Array as argument,
//this class will set up "almost"
//everything else by itself
//... other stuff...
};
So, how important is this memory when working with 3D?
Thx for reading this
[edited by - bilsa on May 5, 2003 11:27:13 AM]