コード例 #1
0
void MyController::onCollision(CollisionEvent &evt) 
{
  if (m_grasp == false){  
    typedef CollisionEvent::WithC C;  
  
    //触れたエンティティの名前を得ます  
    const std::vector<std::string> & with = evt.getWith();  
  
    // 衝突した自分のパーツを得ます  
    const std::vector<std::string> & mparts = evt.getMyParts();  
  
    // 衝突したエンティティでループします  
    for(int i = 0; i < with.size(); i++){  
  
      //右手に衝突した場合  
      if(mparts[i] == "RARM_LINK7"){  
  
				//自分を取得  
				SimObj *my = getObj(myname());  
				
				//自分の手のパーツを得ます  
				CParts * parts = my->getParts("RARM_LINK7");  
				parts->graspObj(with[i]);  
	
        m_grasp = true;  
      }  
    }  
  }  
}
コード例 #2
0
void MyController::onCollision(CollisionEvent &evt) { 

    const vector<string> & wname  = evt.getWith();       // Get a name of the other  
    const vector<string> & wparts = evt.getWithParts();  // Get a parts name of the other's collision point  
    const vector<string> & mparts = evt.getMyParts();    // Get a parts of collision point of myself  
  
    // for(int i = 0; i < wname.size(); i++)  
    //   {  
    //   // Print the name of the other  
    //   LOG_MSG(("\"%s\"", wname[i].c_str()));  
    //   LOG_MSG(("\"%s\"", wparts[i].c_str()));  
    //   LOG_MSG(("\"%s\"", mparts[i].c_str())); 

    // } 

      // LOG_MSG(("\"%s\"", myParts)); 



}
コード例 #3
0
void DemoRobotController::onCollision(CollisionEvent &evt)
{
	if (m_grasp == false) {
		typedef CollisionEvent::WithC C;
		// Get name of entity which is touched by the robot
		const std::vector<std::string> & with = evt.getWith();
		// Get parts of the robot which is touched by the entity
		const std::vector<std::string> & mparts = evt.getMyParts();

		// loop for every collided entities
		for(int i = 0; i < with.size(); i++) {
			if(m_graspObjectName == with[i]) {
				// If the right hand touches the entity
				if(mparts[i] == "RARM_LINK7") {
					SimObj *my = getObj(myname());
					CParts * parts = my->getParts("RARM_LINK7");
					if(parts->graspObj(with[i])) m_grasp = true;
				}
			}
		}
	}
}