minnit_s
11-12-2007 17:12:24
Hi, I want to create objets (cubes for example) and fragment it when it collide with something. I have found informations about Physix (see at the end of this text) and how to do this but i don't understand how to do the same thing with NxOgre. I'm french so scuse me for my poor english.
NxReal boxStartHeight = iNumBoxesOnSide * fCubeSide * 2.0f;
// We need to add the main object to our scene
NxActorDesc actorDesc;
NxBodyDesc bodyDesc;
// The actor here is a compound: a cube with iNumBoxesOnSide cubes on a side, and thus is made of iNumBoxesOnSide^3 objects.
NxBoxShapeDesc boxDesc[iNumBoxesOnSide*iNumBoxesOnSide*iNumBoxesOnSide]; // it's a cube with n cubes on a side, so we need n^3 boxes
// Loop through all of the cubes
for ( int i=0; i<iNumBoxesOnSide; ++i )
{
for ( int j=0; j<iNumBoxesOnSide; ++j )
{
for ( int k=0; k<iNumBoxesOnSide; ++k )
{
// The dimensions are determined by fCubeSide
int iCurrentIndex = i * (iNumBoxesOnSide * iNumBoxesOnSide) + j * iNumBoxesOnSide + k;
boxDesc[ iCurrentIndex ].dimensions.set( fCubeSide, fCubeSide, fCubeSide );
// We need to place it in the right spot, relative to the main actor
boxDesc[ iCurrentIndex ].localPose.t.set(
NxVec3(
((i-1) * fCubeSide * 2.0f),
((j-1) * fCubeSide * 2.0f),
((k-1) * fCubeSide * 2.0f)
)
);
// Push it on to our shapes array
actorDesc.shapes.pushBack(&boxDesc[iCurrentIndex]);
// Track the number of objects globally so we can apply an appropriate force to the object
++iNumberObjects;
}
}
}
actorDesc.body = &bodyDesc;
actorDesc.density = 10;
actorDesc.globalPose.t = NxVec3(0,boxStartHeight,0);
return gScene->createActor(actorDesc);