How to disable Y-axis movement in the Bullet physics engine

  • How to disable Y-axis movement in the Bullet physics engine azer

    I want to create an object than only moves along the the X and Z axes, while keeping the Y-axis disabled (it's like movement in 2D, and the object wont fall down).

    I'm currently using a 6 dof constraint to restrict movement in the Y-axis, but it's not working:

    btRigidBody* zeroBody = new btRigidBody(0, NULL, NULL); // Create the body that we attach things to
    btRigidBody* robot = mCarChassis->getBulletRigidBody();
    btGeneric6DofConstraint* constrict = new btGeneric6DofConstraint(*robot, *zeroBody, btTransform::getIdentity(), btTransform::getIdentity(), false);
    constrict->setLinearLowerLimit( btVector3( 1, 1, 1));
    constrict->setLinearUpperLimit( btVector3(-1, 1,-1));
    constrict->setAngularLowerLimit( btVector3( 1,  1,  1) );
    constrict->setAngularUpperLimit( btVector3(-1, -1, -1) );


c++ bullet-physics
Related questions and answers
  • ); // CReate the rigid body object btRigidBody *RigidBody = new btRigidBody(TMass, MotionState, Shape, LocalInertia); // Store a pointer to the Ogre Node so we can update it later RigidBody-&gt...(Transform); btCollisionShape *Shape = new btStaticPlaneShape(btVector3(0,1,0),0); // Add Mass btVector3 LocalInertia; Shape->calculateLocalInertia(0, LocalInertia); // CReate the rigid body object...->calculateLocalInertia(TMass, LocalInertia); // CReate the rigid body object btRigidBody *RigidBody = new btRigidBody(TMass, MotionState, Shape, LocalInertia); // Store a pointer to the Ogre

  • ) initialization: dynamicsWorld->setGravity(btVector3(0,-10,0)); ballShape = new btSphereShape(1); fallMotionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(2,1,0))); btScalar mass = 5; btVector3 fallInertia(0,0,0); ballShape->calculateLocalInertia(mass,fallInertia); groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(1.),btScalar(70...(mass2,fallMotionState2,pinShape,fallInertia2); pinRigidBody = new btRigidBody(fallRigidBodyCI2); dynamicsWorld->addRigidBody(pinRigidBody); and this is how I am setting the box position and rotation: btTransform

  • ,-10,0)); ballShape = new btSphereShape(1); pinShape = new btCylinderShape(btVector3(1,1,1)); pinShape->setMargin(0.04); fallMotionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(0,10,0))); btScalar mass = 1; btVector3 fallInertia(0,0,0); ballShape->calculateLocalInertia(mass,fallInertia); btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),1); btDefaultMotionState* groundMotionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(0,-1,0))); btRigidBody::btRigidBodyConstructionInfo groundRigidBodyCI

  • = new btRigidBody(StillRigidCI); PhysicsWorld->addRigidBody(ContiRigid); Edit 2: There is no need to create the bullet vertices on the heap with new: btVector3 v0( p0[0], p0[1], p0[2... btDefaultMotionState(btTransform(btQuaternion(0,0,0,0),btVector3(x,y,z))); btScalar Mass = 1; btVector3 FallInertia(0,0,0); btRigidBody::btRigidBodyConstructionInfo StillRigidCI(Mass,StillStateMOT,shape,FallInertia); btRigidBody *ContiRigid = new btRigidBody(StillRigidCI); PhysicsWorld->addRigidBody(ContiRigid); Edit 1: btScalar Mass = 1; btVector3 FallInertia(0,0,0

  • i think i just found the solution. 1) the problem is that backbuffer surface and source surface are of different formats - that is why exception was thrown. 2) the image path needed double slash "C...: return DefWindowProc(hWnd, message, wParam, lParam); } } bool initDirect3D(void) { pD3D = NULL; pd3dDevice = NULL; // create the DirectX object if(NULL == (pD3D = Direct3DCreate9...))) { MessageBox(NULL, L"You're a terrible programmer!", L"ERROR", MB_OK); stopEverything = true; } else { pd3dDevice -> CreateOffscreenPlainSurface(Info.Width, Info.Height

  • new Object(); in the bottom part of the code sample. static BaseObject * CreateObjectFunc() { return new Object(); } How and where to delete the pointers? I wrote bool ReleaseClassType(). Despite... different object data types, I wished to avoid continuously traversing very long Switch() statement. Therefore, to create an object, I call vFactoriesnEnumObjectTypeID via CGameObjectFactory::create... it if( vFactories[nLoop] != NULL) delete vFactories[nLoop](); } return true; } // register new object data type template <typename

  • ;* bullets = new std::vector<Missile*&gt;(); void FireBullet(Ship* s) { if (bullets-&gt;size() < Constants::MAXBULLETS) { Missile* missile = new Missile(); missile-&gt;Init(true, s-&gt;X, s-&gt;Y); bullets-&gt;push_back(missile); } } void CleanUp() { for(unsigned int index = 0; index < bullets-&gt;size(); index...)-&gt;Alive == true) { bullets-&gt;at(index)-&gt;Draw(buffer, sprite); } } } //Entry point of the application int main(void) { Ship* s = new Ship(); int x

  • = xyCoords.y; m_font-&gt;DrawTextA(NULL, stateStream.str().c_str(), -1, &rct, DT_LEFT|DT_NOCLIP , D3DXCOLOR(1,0,0,1)); This all works perfectly. Where am I going wrong with the first bit of code... (texture coords for the screen go from -1 to 1 in each axis) but headPos has the value of -1.#IND000 in both the x and y. I think this may be because D3DXVec3Project is returning MASSIVE numbers, although I...I would have thought that if the object is on-screen that this function should return screen coordinates. When used in conjunction with the directX draw text function, it works fine. Textual overlays

  • , so that's worth explaining. coords[0] represents the x position (left) of the object (where it starts on the x axis). coords[1] represents the y position (top) of the object (where it starts on the y axis). coords[2] represents the width of the object plus coords[0] (right). coords[3] represents the height of the object plus coords[1] (bottom). de2dCheckCollision performs an AABB collision...I am trying to create a 2D platformer (Mario-type) game and I am some having some issues with handling collisions properly. I am writing this game in C++, using SDL for input, image loading, font

Data information