Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 子弹物理约束似乎没有任何效果_C++_3d_Constraints_Physics_Bullet - Fatal编程技术网

C++ 子弹物理约束似乎没有任何效果

C++ 子弹物理约束似乎没有任何效果,c++,3d,constraints,physics,bullet,C++,3d,Constraints,Physics,Bullet,我试着先设置一个6自由度约束。但是,无论我是否添加约束,刚体的行为都是一样的,它们直接掉落到地面上,我可以自由地拖动和投掷它们。所以我添加了一个滑块约束来测试这是否只是我的6自由度设置的问题。还是不走运。我已经看过了bullet源代码约束演示,甚至是我的一些成功使用bullet约束的旧代码。我是否在初始化过程中遗漏了一些简单的东西,也许新鲜的眼睛可以发现 编辑:使用bullet 2.81版本2613 子弹装置 btBroadphaseInterface* broadphase =new btDb

我试着先设置一个6自由度约束。但是,无论我是否添加约束,刚体的行为都是一样的,它们直接掉落到地面上,我可以自由地拖动和投掷它们。所以我添加了一个滑块约束来测试这是否只是我的6自由度设置的问题。还是不走运。我已经看过了bullet源代码约束演示,甚至是我的一些成功使用bullet约束的旧代码。我是否在初始化过程中遗漏了一些简单的东西,也许新鲜的眼睛可以发现

编辑:使用bullet 2.81版本2613

子弹装置

btBroadphaseInterface* broadphase =new btDbvtBroadphase();
btDefaultCollisionConfiguration* collisionConfiguration =new btDefaultCollisionConfiguration();
btCollisionDispatcher* dispatcher =new btCollisionDispatcher(collisionConfiguration);
btSequentialImpulseConstraintSolver* solver =new btSequentialImpulseConstraintSolver;
bullet_dynamics_world =new btDiscreteDynamicsWorld(
    dispatcher,broadphase,solver,collisionConfiguration);
bullet_dynamics_world->setGravity(btVector3(0,-10.0f,0));
刚体设置

btConvexHullShape* part_shape(new btConvexHullShape());
part_shape->addPoint(vp0);
part_shape->addPoint(vp1);
part_shape->addPoint(vp2);
part_shape->addPoint(vp3);
btVector3 intertia(0.0f,0.0f,0.0f);
part_shape->calculateLocalInertia(1.0,intertia);

start_trans.setOrigin(start_trans.getOrigin()+center);

quetz::CBulletMotionState* motion_state(new CBulletMotionState(part, start_trans));

btRigidBody* part_body(0);

btRigidBody::btRigidBodyConstructionInfo inf(1.0f, motion_state, part_shape,intertia);
part_body =new btRigidBody(inf);
part_body->setUserPointer(this);
part_body->setMotionState(motion_state);
part_body->setWorldTransform(motion_state->absolute_transform);
part_body->setActivationState(DISABLE_DEACTIVATION);

core->bullet_dynamics_world->addRigidBody(part_body);
约束设置代码

btTransform fromA(btTransform::getIdentity());
btTransform fromB(btTransform::getIdentity());

fromA.setOrigin( btVector3(-1.0f,0.0f,0.0f));
fromB.setOrigin( btVector3(1.0f,0.0f,0.0f));

btRigidBody* ref_bodyA(partA->m_physics);

btSliderConstraint* bt_constraint =
    new btSliderConstraint(
        *ref_bodyA,
        fromB,true);

bt_constraint->setLowerLinLimit(-10.0f);
bt_constraint->setUpperLinLimit(10.0f);

bt_constraint->setLowerAngLimit(0.0f);
bt_constraint->setUpperAngLimit(0.0f);

core->bullet_dynamics_world->addConstraint(bt_constraint, false);

好吧,这真的很尴尬。我自己的一个功能是不返回任何内容,在非无效返回中。我不知道为什么我没有得到任何错误。可能是因为我处于调试模式。当允许我使用新用户时,标记为已解决