1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
//In the render function
if(SUCCEEDED(m_pD3DDevice->Clear(0, 0, D3DCLEAR_TARGET, D3DXCOLOR(0.9f, 0.9f, 0.9f, 1.0f), 1.0f, 0)))
{
if(SUCCEEDED(m_pD3DDevice->BeginScene()))
{
D3DXMatrixLookAtLH(&viewMat,
&eyeVector,
&lookAtVector,
&upVector);
m_pD3DDevice->SetTransform(D3DTS_VIEW, &viewMat);
D3DXMatrixPerspectiveFovLH(&projMat,
D3DXToRadian(90),
m_Aspect,
0.0f,
0.1f);
m_pD3DDevice->SetTransform(D3DTS_PROJECTION, &projMat);
if(m_RClick)
{
if(m_LaserObject.targetInSight)
{
m_pD3DDevice->SetStreamSource(0, m_pLaserVertexObject, 0, sizeof(D3DVERTEX));
m_pD3DDevice->SetFVF(D3DFVF_XYZRHW|D3DFVF_DIFFUSE);
m_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2);
}
}
if(SUCCEEDED(m_pD3DSprite->Begin(D3DXSPRITE_ALPHABLEND | D3DXSPRITE_SORT_DEPTH_FRONTTOBACK)))
{
D3DXMatrixIdentity(&transMat);
D3DXMatrixIdentity(&scaleMat);
D3DXMatrixIdentity(&rotMat);
D3DXMatrixIdentity(&worldMat);
D3DXMatrixIdentity(&worldMat);
D3DXMatrixScaling(&scaleMat, 1.0f, 1.0f, 1.0f);
D3DXMatrixTranslation(&transMat, m_oPlayer.pos.x, m_oPlayer.pos.y, 0.0f);
D3DXMatrixMultiply(&worldMat, &scaleMat, &transMat);
m_pD3DSprite->SetTransform(&worldMat);
m_pD3DSprite->Draw(m_pPlayerTex[0], &m_oPlayer.rect, &D3DXVECTOR3(m_imageInfo.Width * 0.5f, m_imageInfo.Height * 0.5f, 0.0f) ,
0, D3DCOLOR_ARGB(255, 255, 255, 255));
|