## Puzzled on walking vehicles and btGeneric6DofContraint

.jayderyu
Posts: 19
Joined: Sat Jan 17, 2009 10:51 am

### Puzzled on walking vehicles and btGeneric6DofContraint

http://www.alexanderperkins.com/heavygear.jpg <removed embed picture link because it's annoying>
That's a HeavyGear. I've been working on a prototype for a game based on these machines. Essentially heavy armored suits around 12-18 feet. With 2 forms of movement. Walking and Wheeled.

The prototype is a bit more arcade like than simulation. So i'm simplifying the collision detection to 2 boxes rather than parts. One to represent the legs and the other to represent the torso. The Gear isn't supposed to be knocked over and the Torso has a Y rotation of -45% to +45%(for now). And the mimic wheeled based movement.

What I'm puzzled over is how i'm going to figure out some of the parts.

1. A Gear move like motored roller blades than a standard vehicle. I thought about using two lower boxes to represent legs and controlling the speed by applying differing central forces to either leg/box for turning purposes. Or just using a single box and do a simple applyCentralForce() for both walking and wheeled.

2. I am using a generic6dofcontrstraint to hold 2 box version together. What I'm not getting is the applying the constraint effectively. I've looked through some posts on g6dof to get an idea how to apply it effectivly for my uses, but i'm not getting it. My knowledge of Bullet physics is still young. So I just don't get the FrameInA and FrameInB work.

I figure I can nail all the all rotation issues with a good configuration. To summarize.
Upper Torso is limited to 90% front face of the Legs. The Legs do not rotate along the Z or X Axis so the object can't "fall" over.

Code: Select all

``````  Object3D torsoGfx = Primitives.getCube(2); // 2 meters
Object3D legsGfx = Primitives.getCube(2);

BoxShape shape = new BoxShape(new Vector3f(2,2,2));

Transform trTorso = new Transform();
trTorso.setIdentity();
trTorso.origin.set(new Vector3f(0,1,0));
Transform trLegs = new Transform();
trLegs.setIdentity();
trLegs.origin.set(new Vector3f(0,3,0));

JPCTMotionState msTorso = new JPCTMotionState(torsoGfx, trTorso);
JPCTMotionState msLegs = new JPCTMotionState(torsoGfx, trLegs);

float mass = 1;
Vector3f inertia = new Vector3f(0,0,0);

RigidBodyConstructionInfo rbInfo = new ...(mass, msTorso, shape, inertia);
RigidBody bodyTorso = new RigidBody(rbInfo);

rbInfo = new ...(mass, msLegs, shape, inertia);
RigidBody bodyLegs = new RigidBody(rbInfo);

Transform frameInA = newTransform();
frameInA.setIndentity();
frameInA. ???
Transform frameInB = newTransform();
frameInB.setIndentity();
frameInB. ???

...Constraint bodyConstraint = new ...6DofConstraint(bodyLegs, bodyTorso, frameInA, frameInB, true);

bodyConstraint.setLimit(4, -math.pi, math.pi);  // allows full Y Rotation

``````
So i'm just not sure where and how would I apply the 90% torso rotation limit on the y axis. I know that leaving axis 3 and 5 locked should keep it from falling over.

Sorry, for probably such a simple matter. The last time I worked with Bullet physics I was doing space ships in space. Wich didn't require so much in joints.

3. Bonus JPCT inverts Y and Z axis compared too Bullet/jBullet. It's like thinking in a mirror. Anyone know how to invert Bullets axis would be so awesome. I tried to see if I could invert JPCT with little luck.
mako90
Posts: 28
Joined: Tue Jan 05, 2010 12:41 pm

### Re: Puzzled on walking vehicles and btGeneric6DofContraint

Hi,
the approach you are trying to do seems to be incorrect.
The approach used in games is the following:
1)create a 3D animated model of the character (textures, animations (walk, move, sit, etc.));
2)create a simple physics object in bullet (for example, Quake 3 uses cubes for characters) and associate you 3D model with that simple physics object.

Anyway, you should read about game creation more.
.jayderyu
Posts: 19
Joined: Sat Jan 17, 2009 10:51 am

### Re: Puzzled on walking vehicles and btGeneric6DofContraint

thank you

Maybe I just got it into my head that I should split it, because it seems strange to move it like a person when it's more like a two legged tank. Though I can see it moving more like a person in walking mode.