djcel

About me: click here [level Professional edition user]
My computers: click here [level Limited edition user]
VirtualDJ - Video Effects & Transitions (How To)
Fri 01 Sep 06 @ 2:56 pm
1) The main thing to use Direct3D is to have : IDirect3DDevice9 *pd3dDevice;As this pointer is defined by the VirtualDJ sofware, a global pointer is given in the VirtualDJ video plugins SDK:
IDirect3DDevice9 *D3DDevice;
Each time you want to use a Direct3D functions, you have to use "D3DDevice->"
2) A vertex is a dot in the space defined by a struct TVertex
(NB: one vertex, two vertices)
struct TVertex
{
struct {FLOAT x,y,z;} position; // The 3D position (coordinates) for the vertex
DWORD color; // The vertex color
FLOAT tu,tv; // The texture coordinates
};
3D models in Direct3D are based on triangles:
To define a triangle, you need 3 Vertices: vertices[0], vertices[1], vertices[2]
To define a square so 4 Vertices: vertices[0], vertices[1], vertices[2], vertices[3], you need 2 triangles :
{vertices[0], vertices[1], vertices[2]} and {vertices[1], vertices[3], vertices[2]}

Vertex[0].position.x=-1.0f;
Vertex[0].position.y=1.0f;
Vertex[0].position.z=0.5f;
Vertex[0].color=D3DCOLOR_RGBA(255,255,255,255);
Vertex[0].tu=0.0f;
Vertex[0].tv=0.0f;
Vertex[1].position.x=1.0f;
Vertex[1].position.y=1.f;
Vertex[1].position.z=0.5f;
Vertex[1].color=D3DCOLOR_RGBA(255,255,255,255);
Vertex[1].tu=1.0f;
Vertex[1].tv=0.0f;
Vertex[2].position.x=-1.0f;
Vertex[2].position.y=-1.0f;
Vertex[2].position.z=0.5f;
Vertex[2].color=D3DCOLOR_RGBA(255,255,255,255);
Vertex[2].tu=0.0f;
Vertex[2].tv=1.0f;
Vertex[3].position.x=1.0f;
Vertex[3].position.y=-1.0f;
Vertex[3].position.z=0.5f;
Vertex[3].color=D3DCOLOR_RGBA(255,255,255,255);
Vertex[3].tu=1.0f;
Vertex[3].tv=1.0f;
Texturing:
"IDirect3DTexture9 *texture" in the function OnDraw is the current video texture
Then you apply the texture (video,bitmap,...) on this square with the following function:
D3DDevice->SetTexture(0,texture);
NB: in this case "0" means the first stage of the video
Renderering:
return S_FALSE; will automatically render the video for you
if you want to render by yourself, you can use for example the following function:
D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,(LPVOID)Vertices,sizeof(Vertices[0]));
and in this case, use return S_OK;