我使用 Bullet Physics Engine 使用 btGImpactMeshShape 将 OBJ 模型加载到世界。我对使用这个引擎非常陌生
这是我的代码
//---------------------------------------//
// load from obj //
//---------------------------------------//
ConvexDecomposition::WavefrontObj wobj;
printf("load first try"); fflush( stdout );
std::string filename("bunny.obj");
int result = wobj.loadObj( "bunny.obj" );
if(!result)
{
printf("first try fail\n"); fflush( stdout );
printf("load second try"); fflush( stdout );
result = wobj.loadObj("../bunny.obj");
}
printf("--load status %d\n", result );
printf("--triangle: %d\n", wobj.mTriCount);
printf("--vertex: %d\n", wobj.mVertexCount);
btTriangleIndexVertexArray* colonVertexArrays = new btTriangleIndexVertexArray(
wobj.mTriCount,
wobj.mIndices,
3*sizeof(int),
wobj.mVertexCount,
wobj.mVertices,
3*sizeof(float)
);
btGImpactMeshShape* bunnymesh = new btGImpactMeshShape(colonVertexArrays);
bunnymesh ->setLocalScaling( btVector3(0.5f, 0.5f, 0.5f) );
bunnymesh ->updateBound();
startTransform.setOrigin( btVector3(0.0, 0.0, 0.0) );
startTransform.getBasis().setEulerZYX( 0, 0, 0 );
localCreateRigidBody( bunnymesh , startTransform, 0.0 );
printf("Load done...\n");
在我加载的模型中......这个兔子是在 MAC 上使用 MeshLab 查看的
我试图改变各种步幅参数,但这是我的程序的结果
您对代码有什么问题有什么建议吗?