为什么D3DXCreateCylinder没有创建圆柱体? [英] why D3DXCreateCylinder is not creating a cylinder?

查看:116
本文介绍了为什么D3DXCreateCylinder没有创建圆柱体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试跟踪。

rBallPos 正在正确更新。
以下代码不起作用,无法将
的圆柱体作为球的踪迹。
如何解决?

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在这里也失败了hr!= D3D_OK

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);

需要帮助。

推荐答案

您需要传递指向 LPD3DXMESH 的指针,因此您的网格参数应为& ppMeshCylinder 而不是 ppMeshCylinder 。实际上,您的编译器应该已经发出警告。

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.

更新:尝试为<$ c $传递更大的值。 c>切片和堆栈,例如5或10。无法创建仅包含1个多边形的圆柱网格。

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.

这篇关于为什么D3DXCreateCylinder没有创建圆柱体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆