ich versuche mich grad in der Umsetzung einer Camera für DirectX. Irgendwie scheint bei mir DirectX sämtliche meiner SetTransform Befehle zu ignorieren, ich bekomme irgendwie mein Dreieck nicht in den Sichtbereich:
Hier definiere ich die Matrizen für die View:
Code: Alles auswählen
D3DXMATRIX view_matrix;
D3DXMATRIX projection_matrix;
D3DXVECTOR3 eye_vector;
D3DXVECTOR3 lookat_vector;
D3DXVECTOR3 up_vector;
D3DXMATRIX world_matrix;
float aspect;
//Here we build our View Matrix, think of it as our camera.
//First we specify that our viewpoint is 5 units back on the Z-axis
eye_vector=D3DXVECTOR3( 0.0f, 0.0f, -5.0f );
//We are looking towards the origin
lookat_vector=D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
//The "up" direction is the positive direction on the y-axis
up_vector=D3DXVECTOR3(0.0f,1.0f,0.0f);
D3DXMatrixLookAtLH(&view_matrix,&eye_vector,
&lookat_vector,
&up_vector);
//Since our 'camera' will never move, we can set this once at the
//beginning and never worry about it again
d3ddev->SetTransform(D3DTS_VIEW,&view_matrix);
aspect=((float)RES_WIDTH / (float)RES_HEIGHT);
D3DXMatrixPerspectiveFovLH(&projection_matrix, //Result Matrix
D3DX_PI/4, //Field of View, in radians.
aspect, //Aspect ratio
1.0f, //Near view plane
100.0f ); //Far view plane
//Our Projection matrix won't change either, so we set it now and never touch
//it again.
d3ddev->SetTransform(D3DTS_PROJECTION, &projection_matrix);
//The World Matrix transforms Model Coordinates into World Space coordinates.
//Setting it to Identity means there is no transformation, so Model Space is directly
//mapped onto World Space.
D3DXMatrixIdentity(&world_matrix);
d3ddev->SetTransform(D3DTS_WORLD,&world_matrix);
gerendert:
Code: Alles auswählen
// create the vertices using the Vertex struct
Vertex vertices[] = {
Vertex(- 10.0f, 0.0f, 0.0f, brMath::brVector3f(1.0f,0.0f,0.0f)),
Vertex( 10.0f, 0.0f, 0.0f, brMath::brVector3f(0.0f,1.0f,0.0f)),
Vertex( 0.0f, 10.0f, 0.0f, brMath::brVector3f(0.0f,0.0f,1.0f)),
};
D3DVERTEXELEMENT9 elements[] = {
{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
{0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0},
D3DDECL_END()
};
D3DFVF Geometriedefition, ich hingegen mit einer Element discription. Hier benutze ich extra untransformierte
Vertexdaten...
Habe ich irgend etwas übersehen, dass ich zusätzlich berücksichtigen muß?