# Physics Simulation Forum

 All times are UTC

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Author Message
 Posted: Wed Jun 13, 2012 9:11 am

Joined: Wed Jun 13, 2012 8:35 am
Posts: 3
Hi,

I have a position array. This array contains the rotation matrix and translation vector. (array size is 1000)
I have two mesh shapes (staticMesh and dynamicMesh);

my scenario;

for(int i = 0; i < positionArray.size() ; i++)
{
// setting the rotation matrix and translation vector to the dynamicMesh
dynamicMesh.setPosition(positionArray[i]);

//my PROBLEM is HERE
world->stepSimutlation( stepTime, 1);

//check collision and constraint forces
//...
}

For 1000 different position, when the mesh shapes are collide with each other for given position, I want to get these constraint forces, due to contact, for these 1000 different positions. But I could not find the proper stepSimulation parameters.
I need to call stepSimulation after set the position of dynamicMesh. Which means that I need to call the stepSimulation 1000 times. I tried everything but I could not find the solution.

What can I do to get constraint forces, due to contact, for 1000 different positions?

Thank you very much.

Top

 Posted: Wed Jun 13, 2012 3:44 pm

Joined: Wed Jan 07, 2009 11:43 am
Posts: 99
Location: London
Do you have 1 static mesh and 1000 dynamic meshes and you want to test the dynamic ones collision against the static?
normal way would be to add each (of the 1000) meshes to the collisionworld and call step simulation once ...

if you have a large code fragment it might be clearer?

Top

 Posted: Wed Jun 13, 2012 7:34 pm

Joined: Wed Jun 13, 2012 8:35 am
Posts: 3
Sorry for misunderstanding, I have two mesh shapes (one of them is staticMesh and the other one is dynamicMesh)
In the for loop, I give the different position to the dynamic mesh. And loop count is 1000.

I do not have 1000 dynamic mesh shape, I have only two mesh shapes. I just want to get constraint forces for 1000 different position of my dynamic mesh shape.

My code is very very long. Here is the simplified source code:
// I create the world.
//...
btDiscreteDynamicsWorld* dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,overlappingPairCache,solver,collisionConfiguration);

// I create the static mesh and add the body to the dynamics world
//...
btConvexTriangleMeshShape* shapeStatic = new btConvexTriangleMeshShape(staticTrimesh);
//...
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,shapeStatic,localInertia);
body = new btRigidBody(rbInfo);

// I create the dynamic mesh and add the dynamic body to the dynamics world
btGImpactMeshShape* m_trimeshDynamic = new btGImpactMeshShape(dynamicTrimesh);
btScalar mass(1.f);
m_trimeshDynamic->calculateLocalInertia(mass,localInertia);
collisionShapes.push_back(m_trimeshDynamic);
btDefaultMotionState* myMotionState = new btDefaultMotionState(dynamicTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,m_trimeshDynamic,localInertia);
dynamicBody = new btRigidBody(rbInfo);

//Loop For The Path
for (unsigned int i=0; i<path.size();)
{

//update translation and rotation for dynamic object
float basisValue0 = path[i][1];
float basisValue1 = path[i][5];
float basisValue2 = path[i][9];
float basisValue3 = path[i][2];
float basisValue4 = path[i][6];
float basisValue5 = path[i][10];
float basisValue6 = path[i][3];
float basisValue7 = path[i][7];
float basisValue8 = path[i][11];
//update translation
float tempValue0 = path[i][4];
float tempValue1 = path[i][8];
float tempValue2 = path[i][12];

//column 1
basisDynamic[0][0]= basisValue0; basisDynamic[0][1]= basisValue1; basisDynamic[0][2]= basisValue2;
//column 2
basisDynamic[1][0]= basisValue3; basisDynamic[1][1]= basisValue4; basisDynamic[1][2]= basisValue5;
//column 3
basisDynamic[2][0]= basisValue6; basisDynamic[2][1]= basisValue7; basisDynamic[2][2]= basisValue8;

btVector3 vectorDynamic(tempValue0, tempValue1,tempValue2);
btTransform ts;
ts.setBasis(basisDynamic);
ts.setOrigin(vectorDynamic);

dynamicBody->setWorldTransform(ts);

//I just want to get constraint forces for 1000 different position of my dynamic mesh shape. But it did not wotk:(
bulletStepSimulationTime = timeStep1.elapsed_time();
timeStep1.reset();
dynamicsWorld->stepSimulation(bulletStepSimulationTime, 1);

int numManifolds = dynamicsWorld->getDispatcher()->getNumManifolds();
for (int in=0;in<numManifolds;in++)
{
btPersistentManifold* manifold = dynamicsWorld->getDispatcher()->getManifoldByIndexInternal(in);
if (!manifold->getNumContacts())
continue;

for (int p=0;p<manifold->getNumContacts();p++)
impact = manifold->getContactPoint(p).m_appliedImpulse;

//...

Top

 Posted: Mon Jun 18, 2012 9:29 am

Joined: Wed Jun 13, 2012 8:35 am
Posts: 3
Does anybody knows anything about my problem?

If I am not clear, if my source code is not clear, I can try describe it more clearly.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 4 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 0 guests

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

Search for:
 Jump to:  Select a forum ------------------ BULLET PHYSICS LIBRARY USERS    General Bullet Physics Support and Feedback    Release Announcements    Applications, Games, Demos or Movies using Bullet PHYSICS AUTHORING TOOLS, SERIALIZATION AND STANDARDS    Physics authoring tools, serialization, standards and related topics RESEARCH AND DEVELOPMENT IN COLLISION DETECTION & PHYSICS. Don't post Bullet support questions here!    Research and development discussion about Collision Detection and Physics Simulation    Links, Papers, Libraries, Demos, Movies, Comparisons       Non-technical forum and license/patent discussion    Career Opportunities