位置控制
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
//平移
D3DXMATRIX W;
D3DXMatrixTranslation(&W,
TeapotPosition.x,
TeapotPosition.y,
TeapotPosition.z);
Device->SetTransform(D3DTS_WORLD, &W);
//设置照相机的位置和方向
D3DXVECTOR3 pos(0.0f, 0.0f, -3.0f);
D3DXVECTOR3 target(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);
D3DXMATRIX V;
D3DXMatrixLookAtLH(&V, &pos, &target, &up);
Device->SetTransform(D3DTS_VIEW, &V);
//照相机漫游
static float radius = 20.0f;
if( ::GetAsyncKeyState(VK_UP) & 0x8000f )
radius -= 2.0f * timeDelta;
if( ::GetAsyncKeyState(VK_DOWN) & 0x8000f )
radius += 2.0f * timeDelta;
static float angle = (3.0f * D3DX_PI) / 2.0f;
if( ::GetAsyncKeyState('A') & 0x8000f )
angle -= 0.5f * timeDelta;
if( ::GetAsyncKeyState('S') & 0x8000f )
angle += 0.5f * timeDelta;
D3DXVECTOR3 position( cosf(angle) * radius, 3.0f, sinf(angle) * radius );
D3DXVECTOR3 target(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);
D3DXMATRIX V;
D3DXMatrixLookAtLH(&V, &position, &target, &up);
Device->SetTransform(D3DTS_VIEW, &V);