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);
//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.
StepSimulation problem for static collision scenario.
-
- Posts: 3
- Joined: Wed Jun 13, 2012 8:35 am
-
- Posts: 225
- Joined: Wed Jan 07, 2009 11:43 am
- Location: London
Re: StepSimulation problem for static collision scenario.
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?
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?
-
- Posts: 3
- Joined: Wed Jun 13, 2012 8:35 am
Re: StepSimulation problem for static collision scenario.
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);
dynamicsWorld->addRigidBody(body);
// 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);
dynamicsWorld->addRigidBody(dynamicBody);
//Loop For The Path
for (unsigned int i=0; i<path.size();)
{
//update translation and rotation for dynamic object
float basisValue0 = path[1];
float basisValue1 = path[5];
float basisValue2 = path[9];
float basisValue3 = path[2];
float basisValue4 = path[6];
float basisValue5 = path[10];
float basisValue6 = path[3];
float basisValue7 = path[7];
float basisValue8 = path[11];
//update translation
float tempValue0 = path[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;
//...
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);
dynamicsWorld->addRigidBody(body);
// 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);
dynamicsWorld->addRigidBody(dynamicBody);
//Loop For The Path
for (unsigned int i=0; i<path.size();)
{
//update translation and rotation for dynamic object
float basisValue0 = path[1];
float basisValue1 = path[5];
float basisValue2 = path[9];
float basisValue3 = path[2];
float basisValue4 = path[6];
float basisValue5 = path[10];
float basisValue6 = path[3];
float basisValue7 = path[7];
float basisValue8 = path[11];
//update translation
float tempValue0 = path[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;
//...
-
- Posts: 3
- Joined: Wed Jun 13, 2012 8:35 am
Re: StepSimulation problem for static collision scenario.
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.
If I am not clear, if my source code is not clear, I can try describe it more clearly.