I am trying to make a ball trail.
rBallPosis correctly updating.
Following code is not working creating
a cylinder as ball’s trail. How to
solve it?
LPD3DXMESH /*ID3DXMesh*/ ppMeshCylinder = NULL;
hr = D3DXCreateCylinder(g_d3d_device,0.1f,0.1f,0.1f,1,1,&ppMeshCylinder,0);
hr is FAILED here also hr != D3D_OK
D3DXMATRIX cylinder, cylinder2, cylinderRotate, cylinderTrans;
D3DXMatrixRotationX(&cylinderRotate, 1.5f);
D3DXMatrixTranslation(&cylinderTrans, rBallPos.fX, rBallPos.fY, rBallPos.fZ);
D3DXMatrixMultiply(&cylinder, &cylinderRotate, &cylinderTrans);
g_d3d_device->SetTransform(D3DTS_WORLD, &cylinder);
ppMeshCylinder->DrawSubset(0);
Need help.
You need to pass in a pointer toLPD3DXMESH, so your mesh parameter should be&ppMeshCylinderinstead ofppMeshCylinder. In fact, your compiler should have already warned you.Update: Try passing in a larger value for
SlicesandStacks, say 5 or 10. It’s not possible to create a cylindrical mesh with just 1 polygon.