Natural Motion

Show what you made with Bullet Physics SDK: Games, Demos, Integrations with a graphics engine, modeler or any other application
Post Reply
Blairvoyant
Posts: 11
Joined: Fri Nov 02, 2007 7:08 am

Natural Motion

Post by Blairvoyant » Thu Sep 18, 2008 1:28 pm

Okay, a long time ago I was trying to make a way to integrate cal3d and bullet to make a sort of naturalmotion-style effect, where a character will act out its animations but also be affected by physics. I implemented it using an algorithm found here: http://graphics.cs.williams.edu/papers/DynamoVGS06/

At first it was barely workable; the character would wobble and fall down and generally fail to look like a competent human being. But on their suggestion I fiddled with damping values, restoring forces, and a few other things and now it looks somewhat better. Still far from ideal, but close enough that the smaller issues are pretty visible.

You can download a poorly-hacked demo here:
http://www.mediafire.com/?sharekey=f273 ... b9a8902bda

Left-click to rotate the camera, right click to zoom in and out, and middle-click to 'grab' the model so you can move it around (like in the official bullet demos).

One problem is that the constraints on the fingertips don't seem to do much; you can see this if you try to move her around really fast. Her hands will look like they're being stretched to the floor. It's easy to see if you change to the physics view mode (click on the spanner-looking button in the bottom left) that it's as though her thumbs fell off. Why might this be?

eddybox
Posts: 25
Joined: Thu Nov 29, 2007 7:08 pm

Re: Natural Motion

Post by eddybox » Thu Sep 18, 2008 6:21 pm

Hi Blairvoyant,

I tried downloading and running your app, but... "The application failed to initialize properly (0xc0150002)..."
Any ideas? Perhaps due to my glut version (3.7.6)?

Cheers,
Eddy

Blairvoyant
Posts: 11
Joined: Fri Nov 02, 2007 7:08 am

Re: Natural Motion

Post by Blairvoyant » Thu Sep 18, 2008 9:32 pm

Seems likely; I have uploaded another .rar with the GLUT32.dll that I use...

I was getting the same error when I first tried running the app on this computer, but after re-compiling everything it worked...

DannyChapman
Posts: 85
Joined: Sun Jan 07, 2007 4:29 pm
Location: Oxford, England
Contact:

Re: Natural Motion

Post by DannyChapman » Fri Sep 19, 2008 8:55 am

Same error as before...

Blairvoyant
Posts: 11
Joined: Fri Nov 02, 2007 7:08 am

Re: Natural Motion

Post by Blairvoyant » Fri Sep 19, 2008 3:27 pm

After some experimentation with a few other computers it seems that the solution is to install the visual C++ 2008 redistributable package. (it's just a few .dll's, 1.8mb)

http://www.microsoft.com/downloads/deta ... laylang=en

Also, here is the new version (compiled with /MT and without unnecessary debugging info)
http://www.mediafire.com/?sharekey=c0aa ... b9a8902bda

eddybox
Posts: 25
Joined: Thu Nov 29, 2007 7:08 pm

Re: Natural Motion

Post by eddybox » Fri Sep 19, 2008 9:40 pm

Hi Blairvoyant,

That did it, it's working on my machine now.
Cool demo!
As for what the problem is... it's hard to say just from the results. (Although, are you really representing individual fingers as bodies? If so, wow.)

Cheers,
Eddy

Blairvoyant
Posts: 11
Joined: Fri Nov 02, 2007 7:08 am

Re: Natural Motion

Post by Blairvoyant » Sun Sep 21, 2008 5:14 am

Well, my guess is that it's because I don't really understand how constraints work.

As it stands, it loads the model, and each vertex that has greater than a certain weight on a bone (50% at the moment) is added to a convex hull body. Then, a 6dof constraint is created at the joint in the bones, attaching the new body to its parent bone.

Code: Select all

		btGeneric6DofConstraint* p2p = new btGeneric6DofConstraint(
			*(pBone->getbtbody()), 						// this bone's convex hull object
			*(pParent->getbtbody()), 					// the parent bone's convex hull object
			corebonetransform.getIdentity(), 		// the default transform of the bone according to cal3D
			parenttransform.inverse()*corebonetransform,	// the offset from the parent
			true); 										// don't process collisions between these two bones, otherwise the character will look like its joints are dislocated
		p2p->setAngularLowerLimit(btVector3(-SIMD_PI*0.25f,-SIMD_PI*0.25f,-SIMD_PI*0.25f)); // prevent the joints from bending unnaturally far
		p2p->setAngularUpperLimit(btVector3(SIMD_PI*0.25f,SIMD_PI*0.25f,SIMD_PI*0.25f));
		p2p->setLinearLowerLimit(btVector3(0,0,0)); 	// prevent the joints from sliding out of place
		p2p->setLinearUpperLimit(btVector3(0,0,0));
		m_vectorjoints.push_back(p2p); 			// add the joint to the skeleton object, mostly for deletion purposes
		btWorld->addConstraint(p2p, true); 		// add the joint to the bullet physics pipeline
So... what exactly does bullet do to enforce these constraints? Does it just move them iteratively? Apply forces? Do I need to set more parameters?

eddybox
Posts: 25
Joined: Thu Nov 29, 2007 7:08 pm

Re: Natural Motion

Post by eddybox » Tue Sep 23, 2008 3:34 pm

Hmmmm.... that corebonetransform in the constructor looks fishy. (Based on the comment "the default transform of the bone according to cal3D".) What you want here is the transform to the constraint from the bone's origin (in the bone's space).

However, the first thing I would check is what's really happening to the rigid bodies to make sure you don't have a skinning problem. Can you show these without the mesh?

Cheers,
Eddy

Blairvoyant
Posts: 11
Joined: Fri Nov 02, 2007 7:08 am

Re: Natural Motion

Post by Blairvoyant » Thu Sep 25, 2008 12:30 pm

Yup. Just press the 'bone' button in the lower-right-hand corner of the window (see attached image.) The red dots in the middle of the platform show the 'target' bone positions, while the blue dots show the points from each convex hull rigidbody (independent of the graphical mesh.)

But hmm.. sorry, the comments were a little bit on-the-fly. The first argument (corebonetransform.getIdentity()) is just an identity transform ([1 0 0][0 1 0] [0 0 1] [0 0 0]) because the constraint is located at the origin of the child bone. The second argument (parenttransform.inverse() * corebonetransform) should in theory be the offset of the child bone's origin from the parent bone's origin; they are both defined in absolute terms, so the product should be a relative term. Maybe I messed up the math?
Attachments
button.PNG
button.PNG (13.49 KiB) Viewed 9090 times

Tomat
Posts: 1
Joined: Tue Oct 17, 2006 7:22 am
Location: Russia

Re: Natural Motion

Post by Tomat » Sat Nov 01, 2008 7:35 pm

Excuse me, but can you make demo - there a chracter walks on bumpy terrain or steps up on a slope?
or post sources, if you drop off this project and don't mind about?

Post Reply