把cube形状 静态的collision绘制出来发现少了一些face,这决不是显示的问题,缺少的部分也不能进行碰撞检测
查了官方网站,似乎这个问题并没有得到解决,至少在目前的1.53版中依然存在这个问题。
http://www.newtondynamics.com/forum/viewtopic.php?t=3176&start=0&postdays=0&postorder=asc&highlight=newtontreecollisionaddface
另外,在论坛上我得知做newton的人只有一个,虽然有些bug,但还真的是很佩服作者,这张帖子的回复,显得作者十分的敬业,态度非常的诚恳,这个问题回头我还得再去确认一下。
GraphicObject *teapot = new GraphicObject("box");
GraphicObjects.push_back(teapot);
D3DXCreateBox(gd3dDevice, 5.0f, 5.0f, 5.0f, &(teapot->pMesh), NULL);
//D3DXCreateSphere(gd3dDevice, 5.0f, 5, 5, &(teapot->pMesh), NULL);
//D3DXCreateTeapot(gd3dDevice, &(teapot->pMesh), NULL);
//D3DXCreateBox(gd3dDevice, 10.0f, 10.0, 10.0f, &(teapot->pMesh), NULL);
WORD* pIndices;
LK3D::Vertex::Normal_Vertex* pVertices;
collision = NewtonCreateTreeCollision(nWorld, NULL);
NewtonTreeCollisionBeginBuild(collision);
DWORD numFaces = pGraphicObj->pMesh->GetNumFaces();
teapot->pMesh->LockIndexBuffer(0, (void**)&pIndices);
teapot->pMesh->LockVertexBuffer(0, (void**)&pVertices);
for( DWORD i=0; i<numFaces; i++ )
{
D3DXVECTOR3 face[3];
face[0] = D3DXVECTOR3(pVertices[pIndices[3*i+0]]._x, pVertices[pIndices[3*i+0]]._y, pVertices[pIndices[3*i+0]]._z);
face[1] = D3DXVECTOR3(pVertices[pIndices[3*i+1]]._x, pVertices[pIndices[3*i+1]]._y, pVertices[pIndices[3*i+1]]._z);
face[2] = D3DXVECTOR3(pVertices[pIndices[3*i+2]]._x, pVertices[pIndices[3*i+2]]._y, pVertices[pIndices[3*i+2]]._z);
//boxlocation.TransformTriplex (face, sizeof (dVector), face, sizeof (dVector), 3);
int sz = sizeof (D3DXVECTOR3);
NewtonTreeCollisionAddFace(collision, 3, (FLOAT*)&face[0].x, sz, 0);
}
teapot->pMesh->UnlockVertexBuffer();
teapot->pMesh->UnlockIndexBuffer();
NewtonTreeCollisionEndBuild(collision, 1);
用上cube发现少了三个面,用上其它的几何体也都是同样的问题,有缺失的部分
如果:pVertices[pIndices[3*i+0]]._x + 0.001缺失的部分又会少一点,很奇怪