why D3DXCreateCylinder is not creating a cylinder?

Deadly 提交于 2019-12-31 05:29:11

问题


I am trying to make a ball trail.
rBallPos is 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.


回答1:


You need to pass in a pointer to LPD3DXMESH, so your mesh parameter should be &ppMeshCylinder instead of ppMeshCylinder. In fact, your compiler should have already warned you.

Update: Try passing in a larger value for Slices and Stacks, say 5 or 10. It's not possible to create a cylindrical mesh with just 1 polygon.



来源:https://stackoverflow.com/questions/5583646/why-d3dxcreatecylinder-is-not-creating-a-cylinder

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!