Advertisement
Guest User

Untitled

a guest
Jan 6th, 2018
554
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.35 KB | None | 0 0
  1.     bool hasStatus = true;
  2.     m_data->m_softBodyWorldInfo.m_broadphase = m_data->m_broadphase;
  3.     m_data->m_softBodyWorldInfo.m_sparsesdf.Initialize();
  4.  
  5.  
  6.     const btScalar spawnX =  0;
  7.     const btScalar spawnHeight = 1;
  8.     const btScalar spawnZ =  0;
  9.     const btVector3 centerOfCloth = btVector3(spawnX, spawnHeight, spawnZ);
  10.     const int numX = 100;
  11.     const int numY = 100;
  12.     const int noFixedCorners = 0;
  13.     const int pinAllFourCornerVertices = 1+2+4+8;
  14.     const int fixed = pinAllFourCornerVertices;
  15.     const double mass = 0.01;
  16.     btSoftBody *cloth = btSoftBodyHelpers::CreatePatch(m_data->m_softBodyWorldInfo,
  17.                                                        btVector3(centerOfCloth.x() ,spawnHeight + 1, centerOfCloth.z() - 1),
  18.                                                        btVector3(centerOfCloth.x() ,spawnHeight - 1, centerOfCloth.z() - 1),
  19.                                                        btVector3(centerOfCloth.x() ,spawnHeight + 1, centerOfCloth.z() + 1),
  20.                                                        btVector3(centerOfCloth.x() ,spawnHeight - 1, centerOfCloth.z() + 1),
  21.                                                        numX, numY,
  22.                                                        fixed, true);
  23.  
  24.  
  25.     cloth->m_materials[0]->m_kLST   =   0.4;
  26.     cloth->m_cfg.collisions     |=  btSoftBody::fCollision::VF_SS;
  27.     cloth->setTotalMass(mass);
  28.  
  29.     cloth->rotate(btQuaternion(0.70711, 0, 0, 0.70711));
  30.     cloth->scale(btVector3(0.2, 0.2, 0.2));
  31.     cloth->randomizeConstraints();
  32.  
  33.     const btScalar bulletDefaultMargin = 0.03;
  34.     const btScalar blenderDefaultMargin = 0.03;
  35.     cloth->getCollisionShape()->setMargin(blenderDefaultMargin);
  36.  
  37.  
  38.     m_data->m_softBodyWorldInfo.air_density = (btScalar) 1.2;
  39.     m_data->m_softBodyWorldInfo.water_density = 0;
  40.     m_data->m_softBodyWorldInfo.water_offset = 0;
  41.     m_data->m_softBodyWorldInfo.water_normal = btVector3(0, 0, 0);
  42.     btVector3 currentGravity = m_data->m_dynamicsWorld->getGravity();
  43.     m_data->m_softBodyWorldInfo.m_gravity.setValue(currentGravity.x(), currentGravity.y(), currentGravity.z());
  44.  
  45.     cloth->m_cfg.piterations = 5;
  46.     cloth->m_cfg.citerations = 5;
  47.     cloth->m_cfg.diterations = 5;
  48.     cloth->m_cfg.kDP = 0.005f;
  49.  
  50.     // cloth->m_cfg.kDP;                    // Damping coefficient [0,1]
  51.     // cloth->m_cfg.kDG = 100.0f;                    // Drag coefficient [0,+inf]
  52.     // cloth->m_cfg.kLF;                    // Lift coefficient [0,+inf]
  53.     // cloth->m_cfg.kPR;                    // Pressure coefficient [-inf,+inf]
  54.     // cloth->m_cfg.kVC;                    // Volume conversation coefficient [0,+inf]
  55.     cloth->m_cfg.kDF = 1.0f;                    // Dynamic friction coefficient [0,1]
  56.     // cloth->m_cfg.kMT;                    // Pose matching coefficient [0,1]              
  57.     // cloth->m_cfg.kCHR;                   // Rigid contacts hardness [0,1]
  58.     // cloth->m_cfg.kKHR;                   // Kinetic contacts hardness [0,1]
  59.     // cloth->m_cfg.kSHR;                   // Soft contacts hardness [0,1]
  60.     // cloth->m_cfg.kAHR;                   // Anchors hardness [0,1]
  61.     // cloth->m_cfg.kSRHR_CL;               // Soft vs rigid hardness [0,1] (cluster only)
  62.     // cloth->m_cfg.kSKHR_CL;               // Soft vs kinetic hardness [0,1] (cluster only)
  63.     // cloth->m_cfg.kSSHR_CL;  
  64.     m_data->m_dynamicsWorld->addSoftBody(cloth);
  65.  
  66.  
  67.  
  68.     serverStatusOut.m_type = CMD_CLIENT_COMMAND_COMPLETED;
  69.     return hasStatus;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement