Load a 3ds hand model with composite parts

Post Reply
CarinaCruz
Posts: 21
Joined: Wed Mar 25, 2015 2:04 pm

Load a 3ds hand model with composite parts

Post by CarinaCruz »

Hello everyone,

i'm searching how to load a model of a hand in 3ds, but i can't find find a way to apply what I need...

I have a 3ds hand model, wich acctualy is 17 3ds models (3 for each finger, a palm and a forearm), that composite a hand.

I wondering how to load this parts in a Bullet with OpenGL project, in a way that i can compose a hand, as a single object that I can translate or rotate, but may also move each of the fingers separately (movements to open and close the fingers). Because I have a data glove where I want to apply the data to the model 3ds, and when i move it can collide with other objects...

Any idea?

Thank you very much :?
vipinjs
Posts: 13
Joined: Wed Nov 26, 2014 9:48 am

Re: Load a 3ds hand model with composite parts

Post by vipinjs »

First create appropriate bullet mesh structure using your geometry data. For eg. btCollisionShape like btGImpactMeshShape, btBvhTriangleMeshShape etc.

These meshes will be created at the origin of the bullet coordinate system. So you have to apply the transformations of each geometries appropriately on the collision shapes assigned, such that the collision shapes in bullet takes the shape of the hand. By this I mean apply transformations to the collision shape assigned for the proximal segments of the index finger such that the middle and the distal segment sits on top of the proximal segment.

The issue is that while checking the collisions you have to consider all the individual collision shapes separately, as there is no single collision shape assigned to the hand as an assembled entity.

Hope this is of some help

Regards,
Vipin
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Load a 3ds hand model with composite parts

Post by drleviathan »

The finger bones of your hand would be driven by the data glove, but would they be driven kinematically or dynamically?

Kinematic objects are guided by external logic (keyframed path, script, or perhaps real-time data acquisition) and can bump other objects that are dynamic, but cannot be influenced by these collisions (at least not without much custom special case code). You know those moving platforms you might see in a game level? They move along scripted paths and nothing can stop them -- they are kinematic.

Dynamic objects react to collisions, but can be guided by: Constraints, Actions, or external forces (keyframed, scripted, or perhaps real-time data acquisition) but their final motion is a mixture of intended position and the things that they collide with. If you want your fingers to bend or wobble when bumped against obstacles they would have to be dynamic.

The question is important because the answer would determine the strategies you could take to achieve your goals.

If you want to go Kinematic then the best approach would be to use a distinct btRigidBody for each finger bone. Slam the positions and velocities of each bone according to the data from your data glove. It is better to use many btRigidBody's because if you tried to use one you'd have to change its shape in order to articulate your hand, and changing the shape of an object can be problematic in Bullet -- you have to reset cached bounding boxes in the broadphase and destroy existing btContactManifolds each time you change the shape else risk buggy collisions.

If you want to go Dynamic there are two ways forward:

(1) Using a distinct btRigitBody for each finger bone you could connect the bones together using Constraints. You would need to push each finger toward its target position by computing the required force + torque each frame (note the proper calculation of these values would be a little tricky in order to achieve stability, but there is more than one way to do it). You'd probably want to step the simulation faster than the default 60Hz since you would have many joints (about 15).

I once made an experimental jointed humanoid character that used a variation of this strategy. You can find a video and Demo code links this thread.

(2) Using one btMultiBody with many parts. I'm not familiar with this feature set of Bullet, but the capabilities are there and I believe they would work for a hand. Bullet's MultiBody Demo would be a good place to start your research into this method, but it only makes a long chain of parts rather than a multi-pronged joint like the palm of a hand.
CarinaCruz
Posts: 21
Joined: Wed Mar 25, 2015 2:04 pm

Re: Load a 3ds hand model with composite parts

Post by CarinaCruz »

Thanks for the answers!

How load a obj file and transform it to btGImpactMeshShape?

I managed to unite the parts of the hand but for collision I put a box around each finger, just to have something working... The hand collides with a box... But i wanted to build a collisionshape compatible with the parts. The first image is the system currently. The second image is the collision shapes created for the objects in the scene, does not work very well , but it was the best I could so far ... The third image is what I want to do with the parts o this hand...

I Try to do with btTriangles meshes but ir not work.

What is the best whay to use a .obj file?

is accessing your vertices and drawn? Or there is other ways to load a .obj and manipulate it in bullet (OpenGL + C++)??

Please help me! :cry:

thaks!
Attachments
image.png
image.png (133.2 KiB) Viewed 7789 times
vipinjs
Posts: 13
Joined: Wed Nov 26, 2014 9:48 am

Re: Load a 3ds hand model with composite parts

Post by vipinjs »

Hello Carina,

First you have to parse the .obj file using any of the C++ obj parser.
Then you will have access to the vertices and faces of the geometry.
Once you get access you have to call the appropriate functions in bullet to put the mesh on your geometry.

See the sample code for that.

Code: Select all

index = new int[ObjNumInd * 3];
btScalar *verts = new btScalar[ObjNumVerts * 3];

for (int i = 0; i <ObjNumInd; i++) //faces information from .obj file
		{
			x=index[i * 3 + 0] = ObjInd[i].getX();
			y=index[i * 3 + 1] = ObjInd[i].getY();
			z=index[i * 3 + 2] = ObjInd[i].getZ();

			

				}

		for (int i = 0; i < ObjNumVerts; i++) //vertices information from .obj file
		{
			verts[i * 3 + 0] = ObjVerts[i].getX();
			verts[i * 3 + 1] =ObjVerts[i].getY();
			verts[i * 3 + 2] =ObjVerts[i].getZ();
		}

		btTriangleIndexVertexArray *indexvertsarrayobj = new btTriangleIndexVertexArray(ObjNumInd, index, 3 * sizeof(int), ObjNumVerts, verts, sizeof(btScalar)* 3);
		btGImpactMeshShape * TriCollShapeObj = new btGImpactMeshShape(indexvertsarrayobj);
		TriCollShapeObj->updateBound();
The obj parser I used is attached with this post.
Hope this works!!
Attachments
obj.zip
(12.21 KiB) Downloaded 213 times
CarinaCruz
Posts: 21
Joined: Wed Mar 25, 2015 2:04 pm

Re: Load a 3ds hand model with composite parts

Post by CarinaCruz »

Hi vipinjs, thank you so much for the answer, helped me a lot!

But, the hand model got few triangles, as the picture below.

Any idea of what could be happening?

Thanks!!!!
Attachments
mao.png
mao.png (12.05 KiB) Viewed 7746 times
vipinjs
Posts: 13
Joined: Wed Nov 26, 2014 9:48 am

Re: Load a 3ds hand model with composite parts

Post by vipinjs »

Could you please elaborate the problem?
Did you check whether the number of vertices and faces value returned by the parser is correct?
You have drawn the hand using debug drawer in bullet engine or some other external visualizers like OpenGL?
Also, is this problem happened after assigning bullet mesh to the hand geometry?
CarinaCruz
Posts: 21
Joined: Wed Mar 25, 2015 2:04 pm

Re: Load a 3ds hand model with composite parts

Post by CarinaCruz »

Please send me the files <tr1/functional> and <tr1/tuple>?

I was trying with another parser... And the faces are wrong.
vipinjs
Posts: 13
Joined: Wed Nov 26, 2014 9:48 am

Re: Load a 3ds hand model with composite parts

Post by vipinjs »

Please send me the files <tr1/functional> and <tr1/tuple>?
What do you mean? Is the parser I sent you not working?
CarinaCruz
Posts: 21
Joined: Wed Mar 25, 2015 2:04 pm

Re: Load a 3ds hand model with composite parts

Post by CarinaCruz »

Yes vipinjs. It works! I was doing confusion...

Now my problem is: the shape falls down and collides with the ground. But not collide with a sphere shape...

How could be happening?

Thanks!
vipinjs
Posts: 13
Joined: Wed Nov 26, 2014 9:48 am

Re: Load a 3ds hand model with composite parts

Post by vipinjs »

Is the shape falling down is hand geometry? Did you use btSphereShape to create the sphere?
I am not sure whether you can do collision check between btGImpactMeshShape and btSphereShape.
If it is possible the I am helpless.

Another alternative could be create a sphere using an external3D modeling software and import it to bullet in a similar manner you used for importing the hand geometry into Bullet.
then assign btGImpactMeshSHape to that sphere and check for collisions.

Also, how you are checking the collisions? Are you writing custom callback to do so?
CarinaCruz
Posts: 21
Joined: Wed Mar 25, 2015 2:04 pm

Re: Load a 3ds hand model with composite parts

Post by CarinaCruz »

vipinjs now everything is ok! Even the collision...

i don't really need a sphere but any object that collide, and so I managed to make it all work with a square!

The imagem show the state of system right now, and I am very grateful for the tips!

I have more questions:

I use joints to fit the hand, and sometimes the parts moving the position and get out of hand.

How to fix this parts for it do not happen?

Thank you so very much! :D
Attachments
originalMeshPhysics.png
originalMeshPhysics.png (39.17 KiB) Viewed 7580 times
Post Reply