Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: Fri May 11, 2012 7:41 pm 
Offline

Joined: Thu May 03, 2012 10:56 pm
Posts: 8
Hi all, i'm currently integrating bullet on my game engine for android and i would like to know if anyone can tell me how can i reuse a btConvexHullShape on multiple rigid bodies? I'm currently trying to implement "gibs" and have already solved most collision problems, but if i reuse a convex hull on a different rigid body the previous body dissapears in place of the new one. I create each subsequent new rigid body with the "localCreateRigidBody" found on the samples, i'm doing something wrong?


Top
 Profile  
 
PostPosted: Sat May 12, 2012 6:24 am 
Offline
User avatar

Joined: Tue Mar 16, 2010 1:42 am
Posts: 57
As long as the local scaling and margin of the convex hull shape remains the same, I see no reason why it shouldn't work.


Top
 Profile  
 
PostPosted: Sat May 12, 2012 12:09 pm 
Offline

Joined: Thu May 03, 2012 10:56 pm
Posts: 8
That's weird. I will post some code this monday when i'm back to the office to show you exactly what i'm doing. I'm trying to understand Bullet and C++ in one step so maybe i'm doing something stupid and don't realize it. :)


Top
 Profile  
 
PostPosted: Mon May 14, 2012 8:24 pm 
Offline

Joined: Thu May 03, 2012 10:56 pm
Posts: 8
Check the code if you can:

http://pae.st/c2L2/

The first two class functions are for creating the convex shape (very suboptimal) and the last two functions are for the JNI Interface with the java side in Android.

Code:
// Class functions
BulletEngine::crearShapeConvexoTriMesh
BulletEngine::insertarDynamicDesdeShape

// JNI Calls
Java_com_contimita_utils_BulletNdk_crearShapeConvexoTriMesh
Java_com_contimita_utils_BulletNdk_insertarDynamicConShape


As you can see, my engine"revolves around one Bullet instance globally visible to the C++ code, and has some functions for the java side to call and interact with Bullet.

The problem is that when i insert a dynamic rigid body with the previously constructed convex hull, the previous rigid body gets overwritten somehow and it disapears.


Top
 Profile  
 
PostPosted: Mon May 14, 2012 8:40 pm 
Offline

Joined: Thu May 03, 2012 10:56 pm
Posts: 8
Here's a link to a Youtube video of the problem.

http://www.youtube.com/watch?v=ROK1gd643n4


Top
 Profile  
 
PostPosted: Mon May 14, 2012 9:28 pm 
Offline
User avatar

Joined: Fri Nov 04, 2005 2:22 pm
Posts: 34
I, for example, for each models, including gibs, create a new btConvexHullShape.
until the gibs have a life (including collisions), then free the resources.
here the demo

you tried to do it this way? (sorry 4 engrish)


Top
 Profile  
 
PostPosted: Mon May 14, 2012 9:33 pm 
Offline

Joined: Thu May 03, 2012 10:56 pm
Posts: 8
I'm aiming at something like that. But the problem is that with each new instance of a RigidBody that uses the shape the previous rigid body ceases to exist (or render in the same place, as far as i've seen)


Top
 Profile  
 
PostPosted: Mon May 14, 2012 9:35 pm 
Offline

Joined: Thu May 03, 2012 10:56 pm
Posts: 8
Btw, here's how i obtain the transformation matrix for my geometry in the render pipeline.

http://pae.st/hBj8/

Is that the right way?


Top
 Profile  
 
PostPosted: Mon May 14, 2012 9:40 pm 
Offline
User avatar

Joined: Fri Nov 04, 2005 2:22 pm
Posts: 34
I also use opengl, so here's the code ... does not seem different...
Code:
inline void C_Math::Matrix4_Copy (const mat4_t in, mat4_t out)
{
   out[ 0] = in[ 0];
   out[ 1] = in[ 1];
   out[ 2] = in[ 2];
   out[ 3] = in[ 3];
   out[ 4] = in[ 4];
   out[ 5] = in[ 5];
   out[ 6] = in[ 6];
   out[ 7] = in[ 7];
   out[ 8] = in[ 8];
   out[ 9] = in[ 9];
   out[10] = in[10];
   out[11] = in[11];
   out[12] = in[12];
   out[13] = in[13];
   out[14] = in[14];
   out[15] = in[15];
}

and this is the definition of the matrix:
typedef float mat4_t[16];


Top
 Profile  
 
PostPosted: Mon May 14, 2012 9:49 pm 
Offline

Joined: Thu May 03, 2012 10:56 pm
Posts: 8
Was just reading your previous post, and i'm trying to use only ONE convex hull for type of gib, that means i'm reutilizing one ConvexHull with different rigid bodies.

Maybe that isn't possible :(


Top
 Profile  
 
PostPosted: Mon May 14, 2012 10:03 pm 
Offline
User avatar

Joined: Fri Nov 04, 2005 2:22 pm
Posts: 34
mhmmm...
I do:
if the model is already listed, then resume it.
So I have the old btConvexHullShape.
otherwise create a new stuff for the new model.

I am sorry being unable to express, english is not my language ...
I have trouble with google ... sorry :twisted:


Top
 Profile  
 
PostPosted: Tue May 15, 2012 1:20 am 
Offline
User avatar

Joined: Tue Mar 16, 2010 1:42 am
Posts: 57
Maybe you have a mixup between an object index and a collision shape pointer?
I see that for obtenerMatrizRigidBody() you use sim as an index into the object array, while in Java_com_contimita_utils_BulletNdk_insertarDynamicConShape() sim is a collision shape pointer.

If the objects are actually appearing at the same place, instead of disappearing, that would suggest a problem with the motion state. The motion state has nothing to do with the collision shape.

---JvdL---


Top
 Profile  
 
PostPosted: Tue May 15, 2012 3:55 pm 
Offline

Joined: Thu May 03, 2012 10:56 pm
Posts: 8
Thanks all... it was just an stupid bug on my part :-D

This library rocks!


Top
 Profile  
 
PostPosted: Tue May 15, 2012 6:07 pm 
Offline
User avatar

Joined: Fri Nov 04, 2005 2:22 pm
Posts: 34
johnvillar wrote:
Thanks all... it was just an stupid bug on my part :-D

This library rocks!


Goood! :lol:

Yeah! Bullet is a....Bomb! :mrgreen:


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group