Anyone know the correct way to specify the UV for each vertex when creating a DX7 Primitive?
Basically I've managed to texture a Blitzmax Polygon but I want to be able to set the UV for each vertex as I create the poly.
device.DrawPrimitive(D3DPT_TRIANGLEFAN,D3DFVF_XYZ|D3DFVF_TEX1,xyzuv,segs,0)
According to Marks code I think it should be in the order of :-
xyzuv#[0] = xpos#
xyzuv#[1] = ypos#
xyzuv#[2] = zpos#
xyzuv#[3] = u#
xyzuv#[4] = v#
Since we are using "Flexible Vertex Formats" should I be using D3DFVF_TEX2?
Ignore me, I worked it out...
if that can help you:
for a single polygon,
struct VERTEX
{
D3DXVECTOR3 p; // D3DFVF_XYZ
DWORD d; // D3DFVF_DIFFUSE
float u1, v1; // D3DFVF_TEX1;
static const DWORD FVF;
};
VERTEX *v;
v[0].p = D3DXVECTOR3(-fWidth, -fHeight, 0.0f );
v[0].d = dwColor;
v[0].u1 = 0.0f;
v[0].v1 = 1.0f;
v[1].p = D3DXVECTOR3(-fWidth, fHeight, 0.0f );
v[1].d = dwColor;
v[1].u1 = 0.0f;
v[1].v1 = 0.0f;
v[2].p = D3DXVECTOR3( fWidth, -fHeight, 0.0f );
v[2].d = dwColor;
v[2].u1 = 1.0f;
v[2].v1 = 1.0f;
v[3].p = D3DXVECTOR3( fWidth, fHeight, 0.0f );
v[3].d = dwColor;
v[3].u1 = 1.0f;
v[3].v1 = 0.0f;
VERTEXSET = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1
EL_d3dDev9.SetTexture( 0, Texture )
EL_d3dDev9.SetFVF( VERTEXSET )
EL_d3dDev9.DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 )
Width two textures (multitexturing)
struct VERTEX
{
D3DXVECTOR3 p; // D3DFVF_XYZ
DWORD d; // D3DFVF_DIFFUSE
float u1, v1; // D3DFVF_TEX1;
float u2, v2; // D3DFVF_TEX2;
static const DWORD FVF;
};
VERTEX *v;
v[0].p = D3DXVECTOR3(-fWidth, -fHeight, 0.0f );
v[0].d = dwColor;
v[0].u1 = 0.0f;
v[0].v1 = 1.0f;
v[0].u2 = 0.0f;
v[0].v2 = 1.0f;
v[1].p = D3DXVECTOR3(-fWidth, fHeight, 0.0f );
v[1].d = dwColor;
v[1].u1 = 0.0f;
v[1].v1 = 0.0f;
v[1].u2 = 0.0f;
v[1].v2 = 0.0f;
v[2].p = D3DXVECTOR3( fWidth, -fHeight, 0.0f );
v[2].d = dwColor;
v[2].u1 = 1.0f;
v[2].v1 = 1.0f;
v[2].u2 = 1.0f;
v[2].v2 = 1.0f;
v[3].p = D3DXVECTOR3( fWidth, fHeight, 0.0f );
v[3].d = dwColor;
v[3].u1 = 1.0f;
v[3].v1 = 0.0f;
v[3].u2 = 1.0f;
v[3].v2 = 0.0f;
VERTEXSET = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX2
EL_d3dDev9.SetTexture( 0, Texture1 )
EL_d3dDev9.SetTexture( 1, Texture1 )
EL_d3dDev9.SetFVF( VERTEXSET )
EL_d3dDev9.DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 )
I will when I've tidied the code, basically it allows you to texture a poly with any image using:-
DrawTexturedPoly(Image:TImage,xyzuv#[])