void CreateBoxContainerDEM(ChSystem*                           system,
                           int                                 id,
                           ChSharedPtr<ChMaterialSurfaceDEM>&  mat,
                           const ChVector<>&                   hdim,
                           double                              hthick,
                           const ChVector<>&                   pos,
                           const ChQuaternion<>&               rot,
                           bool                                collide)
{
  // Create the body and set material
  ChBodyDEM* body;

  body = new ChBodyDEM();
  body->SetMaterialSurfaceDEM(mat);

  // Set body properties and geometry.
  body->SetIdentifier(id);
  body->SetMass(1);
  body->SetPos(pos);
  body->SetRot(rot);
  body->SetCollide(collide);
  body->SetBodyFixed(true);

  body->GetCollisionModel()->ClearModel();
  AddBoxGeometry(body, ChVector<>(hdim.x, hdim.y, hthick), ChVector<>(0, 0, -hthick));
  AddBoxGeometry(body, ChVector<>(hthick, hdim.y, hdim.z), ChVector<>(-hdim.x-hthick, 0, hdim.z));
  AddBoxGeometry(body, ChVector<>(hthick, hdim.y, hdim.z), ChVector<>( hdim.x+hthick, 0, hdim.z));
  AddBoxGeometry(body, ChVector<>(hdim.x, hthick, hdim.z), ChVector<>(0, -hdim.y-hthick, hdim.z));
  AddBoxGeometry(body, ChVector<>(hdim.x, hthick, hdim.z), ChVector<>(0,  hdim.y+hthick, hdim.z));
  body->GetCollisionModel()->BuildModel();

  // Attach the body to the system.
  system->AddBody(ChSharedPtr<ChBodyDEM>(body));
}
示例#2
0
void TSRODERigidBody::AddWorldOBBCollision( TSRPhysicsWorld* _pWorldInterface, const TSRMatrix4& _worldTransform, const TSRVector3& _vObbMin, const TSRVector3& _vObbMax, float _fDensity )
{
	TSRODEPhysicsWorld* _pWorld = ( TSRODEPhysicsWorld* ) _pWorldInterface;
    TSRMatrix4 geomWorldMatrix = _worldTransform;
    TSRVector3 obbExtents;
    WorldOBBMinMaxToWorldOBBExtents( _worldTransform, _vObbMin, _vObbMax, geomWorldMatrix, obbExtents );
    TSRMatrix4 bodyWorldMatrix;
    const float* pBodyPosition = dBodyGetPosition( m_BodyID );
    const float* pBodyRotation = dBodyGetRotation( m_BodyID );
    ODEToMatrix4( bodyWorldMatrix, pBodyPosition, pBodyRotation );
    TSRMatrix4 invBodyTransform;
    Matrix4Inverse( bodyWorldMatrix, invBodyTransform );
    TSRMatrix4 bodyToGeomMatrix;
    bodyToGeomMatrix = geomWorldMatrix * invBodyTransform;
    AddBoxGeometry( _pWorld, bodyToGeomMatrix, obbExtents, _fDensity );

}