std::vector<D3DXVECTOR2>::iterator it; std::vector<D3DXVECTOR2> newList; int count = 0; for (it = lstPoints.begin(); it != lstPoints.end();) { if (count == 0 || count == 1) { // double up newList.push_back(*it); count++; continue; } else if (count == lstPoints.size() || count == lstPoints.size()-1) { // double up newList.push_back(*it); count++; continue; } else { newList.push_back(*it); count++; it++; } } // now we have a full list that include the double ups float s = 0.0f; for (int i = 0; i < count-3; i+=3) { D3DXVECTOR2 vecPos; s += 0.25; if (s >= 1.0f) s = 0.0f; D3DXVec2CatmullRom(&vecPos, &newList, &newList[i+1], &newList[i+2], &newList[i+3], s); char buff[256]; sprintf (buff, "X:%f Y:%f\n", vecPos.x, vecPos.y); OutputDebugString(buff); m_finalArray.push_back(vecPos); }
lstPoints is worked-out path in pixels.
This result is a bee-like path, not a smoothed solid line. Does the line s+=0.25 make the difference? Any fix for me?
Thanks
Jack
[Edited by - lucky6969b on November 9, 2010 5:01:32 AM]