|
|
建立了一个水杯模型,.x文件载入后将其缩小。缩小后无法旋转,之前可以旋转,但是太大了。请帮帮忙,谢谢!!
注:是不是缩放的倍数太大了?该如何修改!!
bool Display(float timeDelta)
{
if( Device )
{
D3DXMATRIX V;
TheCamera.getViewMatrix(D3DXMatrixScaling(&V,0.01,0.01,0.01));
Device->SetTransform(D3DTS_WORLD, D3DXMatrixScaling(&V,0.01,0.01,0.01));
ID3DXMesh* LD = 0;
D3DXVECTOR3 LDPosition(0.0f, 0.0f, -70000.5f);
D3DMATERIAL9 LDMtrl = d3d::YELLOW_MTRL;
static float radius = 20.0f;
if( ::GetAsyncKeyState(VK_LEFT) & 0x8000f )
LDPosition.x -= 3.0f * timeDelta;
if( ::GetAsyncKeyState(VK_RIGHT) & 0x8000f )
LDPosition.x += 3.0f * timeDelta;
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);
D3DXMatrixLookAtLH(&V, &position, &target, &up);
static float y = 0.0f;
D3DXMATRIX yRot;
D3DXMatrixRotationY(&yRot, y);
y += 100*timeDelta;
Device->SetTransform(D3DTS_VIEW, &V);
//
// Render
//
Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
Device->BeginScene();
for(int i = 0; i < Mtrls.size(); i++)
{
Device->SetMaterial( &Mtrls );
Device->SetTexture(0, Textures);
Mesh->DrawSubset(i);
}
d3d: rawBasicScene(Device, 1.0f);
Device->EndScene();
Device-> resent(0, 0, 0, 0);
}
return true;
}
|
|