0
編輯:解決它自己,有一個很難注意到在一個不同的部分中的小錯別字,現在完美的作品。在DirectX中創建粒子吸引子
我有一個在C++中的粒子發生器,我下了互聯網。這基本上是你可以做的一些事情的樣本,所以我研究了它並知道發生了什麼,以及我需要做些什麼來添加我想要的功能。我現在正在處理這個問題。我有另外一種方法可以用來創建GravPoint,然後用這個方法進行數學運算。評論描述了發生了什麼事以及我的錯誤在哪裏。
// Update velocity with respect to any GravPoints in range
// Start at the head of the list
ppGravPoint = &m_pGravPoints;
// Temporary D3DXVECTOR3
D3DXVECTOR3 vTemp;
// While there is still a node on the list
while (*ppGravPoint)
{
pGravPoint = *ppGravPoint;
// vTemp becomes a vector pointing from m_vCurPos to m_vPoint
// I'm getting an error at this line, it opens up d3dx9math.inl
// and points at this piece of code:
// D3DXINLINE D3DXVECTOR3
// D3DXVECTOR3::operator - (CONST D3DXVECTOR3& v) const
// {
// return D3DXVECTOR3(x - v.x, y - v.y, z - v.z);
// }
vTemp = pGravPoint->m_vPoint - pParticle->m_vCurPos;
// if ||vTemp|| (length of vTemp) < m_fMaxDist (FLOAT m_fMaxDist)
if((sqrt((vTemp.x * vTemp.x) + (vTemp.y * vTemp.y) + (vTemp.z * vTemp.z)) < pGravPoint->m_fMaxDist))
{
// Then the velocity of the current particle being rendered is adjusted
// to be attracted towards the gravpoint. Pretty sure this is right
pParticle->m_vCurVel += (vTemp * (pGravPoint->m_fStrength * fElpasedTime));
}
// Go to next point if there is one.
ppGravPoint = &pGravPoint->m_gpNext;
}
「StackOverflow」的方式是添加自己的答案(分享知識),並自己接受它... – neuro 2009-08-10 17:45:01