我是子弹新手,我可能有一个基本问题。 我试图模拟弓形针落下,但是它们在跌落后自行起床而没有任何力量加入。
我想知道我的错误在哪里,你们中的任何人都可以提供帮助,我将不胜感激。
这是一段视频,展示了会发生什么: https://www.sendspace.com/file/78tncr
以下是我添加楼层的方法:
tTransform l;
l.setIdentity();
l.setOrigin(btVector3(0,0,0));
btStaticPlaneShape* plane=new btStaticPlaneShape(btVector3(0,1,0),0);
btMotionState* motion=new btDefaultMotionState(l);
btRigidBody::btRigidBodyConstructionInfo info(0.0,motion,plane);
btRigidBody* body=new btRigidBody(info);
world->addRigidBody(body);
bodies.push_back(body);
这就是我添加bolwing pin的方式:
btRigidbodyaddBolw (float x, float y , float z,float mass)
{
btTransform t;
t.setIdentity();
t.setOrigin(btVector3(x,y,z));
btTriangleMesh * tmptri= new btTriangleMesh();
//this is simply reading from std::vector, where I have vertex of a shape
for(int i=0;i<=faces.size()-3;i=i+3)
{
if(faces[i].wektor==-100)
{
i=i-2;
continue;
}
btVector3 vertex1(vertexy[faces[i].wektor].GetX(), vertexy[faces[i].wektor].GetY(), vertexy[faces[i].wektor].GetZ());
btVector3 vertex2(vertexy[faces[i+1].wektor].GetX(), vertexy[faces[i+1].wektor].GetY(), vertexy[faces[i+1].wektor].GetZ());
btVector3 vertex3(vertexy[faces[i+2].wektor].GetX(), vertexy[faces[i+2].wektor].GetY(), vertexy[faces[i+2].wektor].GetZ());
tmptri->addTriangle(vertex1, vertex2, vertex3);
}
btConvexShape *tmpshape = new btConvexTriangleMeshShape(tmptri);
btShapeHull *hull = new btShapeHull(tmpshape);
btScalar margin = tmpshape->getMargin();
hull->buildHull(margin);
btConvexHullShape* simplifiedConvexShape = new btConvexHullShape();
for (int i=0;i<hull->numVertices();i++)
{
simplifiedConvexShape->addPoint(hull->getVertexPointer()[i]);
}
delete tmpshape;
delete hull;
btMotionState * motion = new btDefaultMotionState(t);
btVector3 inertia(0,0,0);
if(mass!=0.0)
simplifiedConvexShape->calculateLocalInertia(mass,inertia);
btRigidBody::btRigidBodyConstructionInfo info(mass,motion,simplifiedConvexShape,inertia);
btRigidBody* body=new btRigidBody(info);
world->addRigidBody(body); //and let the world know about it
bodies.push_back(body); //to be easier to clean, I store them a vector
return body;
}
我尝试改变别针,质量,摩擦力和恢复原状的形状,但没有任何问题,有没有办法改变质心,也许会有所帮助?
答案 0 :(得分:2)
这将由您的模型在保龄球的底部或附近具有枢轴点/变换原点引起。在子弹中,刚体变换是质心,所以你所看到的是重质量中心通过重力纠正自身,从而将针直立拉动。
您有几个选择: