Hello, I am glad you took some time.
EDITED:
Square increases as distance increases. I kind of don't expect it to work without at least one more transformation to transform it to world space. What I need is local space coordinates that will be transformed to world space. I need those local space coordinates to create object that will always fit in to users screen.
For now my model transformations are non existent, if nothing to make things easier.
Here is more of my code:
OnResize() WM_SIZE
D3D10_VIEWPORT vp;
vp.TopLeftX = 0;
vp.TopLeftY = 0;
vp.Width = LOWORD(lParam);
vp.Height = HIWORD(lParam);
vp.MinDepth = 0.0f;
vp.MaxDepth = 1.0f;
RSSetViewports(1, &vp);
float aspect = (float)lparams from size w/h;
float angle = 0.25*M_PI;
D3DXMatrixPerspectiveFovLH(&Proj, angle, aspect, 1.0f, 100.0f);
float w, h, zp;
zp = 50.0;
h = tan(angle/2.0) * zp;
w = h * aspect;
Box.MakeBox(w, h, zp);
}
MakeBox(width, height, z_position)
Vertex Vertices[] =
{
{ D3DXVECTOR3(-_width, -_height, _z_position), WHITE },
{ D3DXVECTOR3(-_width, +_height, _z_position), WHITE },
{ D3DXVECTOR3(+_width, +_height, _z_position), WHITE },
{ D3DXVECTOR3(+_width, -_height, _z_position), WHITE },
};
D3D10_BIND_VERTEX_BUFFER
DWORD Indices[] = {
// front face
0, 1, 2,
0, 2, 3,
};
D3D10_BIND_INDEX_BUFFER
}
// Build the view matrix.
float x = 0.0;
float z = -5.0;
float y = 0.0;
D3DXVECTOR3 pos(x, y, z);
D3DXVECTOR3 target(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);
D3DXMatrixLookAtLH(&View, &pos, &target, &up);
WVP = View*Proj;
fx->SetMatrix((float*)&WVP);
D3D10_TECHNIQUE_DESC TechDesc;
Tech->GetDesc(&TechDesc);
for (UINT p = 0; p < TechDesc.Passes; ++p)
{
Tech->GetPassByIndex(p)->Apply(0);
Box.Draw();
}