📄 sphere.cpp
字号:
//#include "stdafx.h"
#include "Sphere.h"
Sphere::Sphere(LPDIRECT3DDEVICE9 pDev)
{
m_pd3dDevice=pDev;
m_vMovingPos.x=m_vMovingPos.y=m_vMovingPos.z=0;
this->m_vStartPos =this->m_vEndPos =this->m_vMovingPos ;
m_fCoeffient=0;
D3DXCreateSphere(pDev,40,20,20,&(this->m_pStaticMesh ),NULL);
}
Sphere::~Sphere()
{
m_pStaticMesh->Release();
}
D3DXMATRIX Sphere::idle()
{
D3DXMATRIX m_matMove;
D3DXMatrixTranslation(&m_matMove,m_vMovingPos.x,m_vMovingPos.y,m_vMovingPos.z);
return m_matMove;
}
D3DXMATRIX Sphere::move(D3DXVECTOR3 vEndPos,FLOAT speed)
{
D3DXMATRIX m_matMove;
D3DXMatrixIdentity(&m_matMove);
m_vEndPos = vEndPos;
if(m_fCoeffient >= 1.0)
{
return idle();
}
D3DXVec3Lerp(&m_vMovingPos,&m_vStartPos,&m_vEndPos,m_fCoeffient);//两个向量之间的 差值
//D3DXVec3Lerp
// 原型:D3DXVec3Lerp( VOut As D3DVECTOR, V1 As D3DVECTOR, V2 As D3DVECTOR, s As Single)
// 作用:完成两个3-D向量的线性插值
// V1 + s(V2-V1).
D3DXMatrixTranslation(&m_matMove,m_vMovingPos.x,m_vMovingPos.y,m_vMovingPos.z);
m_fCoeffient +=0.1f;
return m_matMove;
}
HRESULT Sphere::ReMove()
{
m_fCoeffient = 0.0f;
m_vStartPos = m_vMovingPos;
return S_OK;
}
HRESULT Sphere::Render()
{
for(DWORD i=0;i<1;i++)
{
m_pd3dDevice->SetTexture(0,NULL);
m_pStaticMesh->DrawSubset(i);
}
return S_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -