Hi Folks,
This is some kind of beginner question, but I couldn't find the answer anywhere.
I have successfully used the following Vertex-Type until now for simple textured geometry. An array of these vertices is then passed via IASetVertexBuffers(...):
struct
VERTEXPOSITIONNORMALTEXTURED
{
D3DXVECTOR3 position;
D3DXVECTOR3 normal;
D3DXVECTOR2 texcoord;
static D3D11_INPUT_ELEMENT_DESC* GetVertexLayout()
{
static D3D11_INPUT_ELEMENT_DESC layout[] =
{
{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT,
0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT,
0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT,
0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 },
};
return layout;
}
static UINT GetNumElements(){ return 3; }
};
Now I would like to use more than one map on certain objects. I could of course now create lots of VertexTypes with one to ten UV-Coordinates for example to deal with objects that have one to ten UV-Coordinates. However that is not really an elegant solution. Of course I don't want to use an array of fixed size ten because then most of the time I store almost ten times as much data for each vertex than is necessary (most objects ingame only have a texture and no other maps, and most objects that use more than one map will probably not use all ten map slots).
But if I want to create an array with unkown size during compiletime I would use pointers.
...
D3DXVECTOR3 position;
D3DXVECTOR3 normal;
D3DXVECTOR2* texcoords;
UINT numTexCoords;
...
?
?
The layout[] would also be created during runtime. But what about the pointer? How do I Access this array in my HLSL VertexShader Method?
Thanks in advance
Nicholas