当前位置: 首页>>代码示例>>C++>>正文


C++ dGeomGetBody函数代码示例

本文整理汇总了C++中dGeomGetBody函数的典型用法代码示例。如果您正苦于以下问题:C++ dGeomGetBody函数的具体用法?C++ dGeomGetBody怎么用?C++ dGeomGetBody使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dGeomGetBody函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: wheelCallBack

bool wheelCallBack(dGeomID o1,dGeomID o2,PSurface* s)
{
    //s->id2 is ground
    const dReal* r; //wheels rotation matrix
    //const dReal* p; //wheels rotation matrix
    if ((o1==s->id1) && (o2==s->id2)) {
        r=dBodyGetRotation(dGeomGetBody(o1));
        //p=dGeomGetPosition(o1);//never read
    } else if ((o1==s->id2) && (o2==s->id1)) {
        r=dBodyGetRotation(dGeomGetBody(o2));
        //p=dGeomGetPosition(o2);//never read
    } else {
        //XXX: in this case we dont have the rotation
        //     matrix, thus we must return
        return false;
    }

    s->surface.mode = dContactFDir1 | dContactMu2  | dContactApprox1 | dContactSoftCFM;
    s->surface.mu = fric(_w->cfg->robotSettings.WheelPerpendicularFriction);
    s->surface.mu2 = fric(_w->cfg->robotSettings.WheelTangentFriction);
    s->surface.soft_cfm = 0.002;

    dVector3 v={0,0,1,1};
    dVector3 axis;
    dMultiply0(axis,r,v,4,3,1);
    dReal l = sqrt(axis[0]*axis[0] + axis[1]*axis[1]);
    s->fdir1[0] = axis[0]/l;
    s->fdir1[1] = axis[1]/l;
    s->fdir1[2] = 0;
    s->fdir1[3] = 0;
    s->usefdir1 = true;
    return true;
}
开发者ID:Cyberhornet,项目名称:grSim,代码行数:33,代码来源:sslworld.cpp

示例2: dGeomGetBody

void PhysicsWorld::collide(void *_data, dGeomID _o1, dGeomID _o2)
{
  int i;
  //std::cout<<"collide\n";
  // exit without doing anything if the two bodies are connected by a joint
  dBodyID b1 = dGeomGetBody(_o1);
  dBodyID b2 = dGeomGetBody(_o2);
  if (b1 && b2 && dAreConnectedExcluding (b1,b2,dJointTypeContact)) return;

  for (i=0; i<m_maxContacts; i++)
  {
    m_contact[i].surface.mode = dContactBounce;// | dContactSoftCFM;
    m_contact[i].surface.mu = dInfinity;
    m_contact[i].surface.mu2 = 0;
    m_contact[i].surface.bounce = 0.3;
    m_contact[i].surface.bounce_vel = 0.1;
    m_contact[i].surface.soft_cfm = 0.01;
  }
  if (int numc = dCollide (_o1,_o2,m_maxContacts,&m_contact[0].geom,sizeof(dContact)))
  {
    dMatrix3 RI;
    dRSetIdentity (RI);
    const dReal ss[3] = {0.02,0.02,0.02};
    for (i=0; i<numc; i++)
    {
      dJointID c = dJointCreateContact (m_world,m_contactgroup,m_contact+i);
      dJointAttach (c,b1,b2);
    }
  }
}
开发者ID:NCCA,项目名称:NGL6Demos,代码行数:30,代码来源:CollisionFunction.cpp

示例3: nearCallback

static void nearCallback (void *data, dGeomID o1, dGeomID o2)
{
  int i;
  // if (o1->body && o2->body) return;

  // exit without doing anything if the two bodies are connected by a joint
  dBodyID b1 = dGeomGetBody(o1);
  dBodyID b2 = dGeomGetBody(o2);
  if (b1 && b2 && dAreConnectedExcluding (b1,b2,dJointTypeContact)) return;

  dContact contact[MAX_CONTACTS];   // up to MAX_CONTACTS contacts per box-box
  for (i=0; i<MAX_CONTACTS; i++) {
    contact[i].surface.mode = dContactBounce | dContactSoftCFM;
    contact[i].surface.mu = dInfinity;
    contact[i].surface.mu2 = 0;
    contact[i].surface.bounce = 0.1;
    contact[i].surface.bounce_vel = 0.1;
    contact[i].surface.soft_cfm = 0.01;
  }
  if (int numc = dCollide (o1,o2,MAX_CONTACTS,&contact[0].geom,
			   sizeof(dContact))) {
    dMatrix3 RI;
    dRSetIdentity (RI);
    const dReal ss[3] = {0.02,0.02,0.02};
    for (i=0; i<numc; i++) {
      dJointID c = dJointCreateContact (world,contactgroup,contact+i);
      dJointAttach (c,b1,b2);
      if (show_contacts) dsDrawBox (contact[i].geom.pos,RI,ss);
    }
  }
}
开发者ID:nurF,项目名称:Brute-Force-Game-Engine,代码行数:31,代码来源:demo_moving_trimesh.cpp

示例4: GetContacts

///Will produce bogus o1 and o2 vectors
void GetContacts(dBodyID a,vector<ODEContactList>& contacts)
{
  if(a == 0) return;

  contacts.resize(0);
  for(list<ODEContactResult>::iterator i=gContacts.begin();i!=gContacts.end();i++) {
    if(a == dGeomGetBody(i->o1) || a == dGeomGetBody(i->o2)) {
      dBodyID b = dGeomGetBody(i->o2);
      bool reverse = false;
      if(b == a) { b = dGeomGetBody(i->o1); reverse = true; }
      contacts.resize(contacts.size()+1);
      contacts.back().points.resize(i->contacts.size());
      contacts.back().forces.resize(i->feedback.size());
      for(size_t j=0;j<i->feedback.size();j++) {
	CopyVector(contacts.back().forces[j],i->feedback[j].f1);
	CopyVector(contacts.back().points[j].x,i->contacts[j].pos);
	CopyVector(contacts.back().points[j].n,i->contacts[j].normal);
	//contacts.back().points[j].kFriction = i->contacts[j].surface.mu;
	contacts.back().points[j].kFriction = 0;
	if(reverse) {
	  contacts.back().forces[j].inplaceNegative();
	  contacts.back().points[j].n.inplaceNegative();
	}
      }
    }
  }
}
开发者ID:bbgw,项目名称:RobotSim,代码行数:28,代码来源:ODESimulator.cpp

示例5: dCollide

void WorldPhysics::handleCollisionBetween(dGeomID o0, dGeomID o1) {
  int i,n;

  // only collide things with the ground
  //int g1 = (o1 == ground || o1 == ground_box);
  //int g2 = (o2 == ground || o2 == ground_box);
  //if (!(g1 ^ g2)) return;

 // for(int i=0;i<4;i++) {
 //   if (((o0==bulldozer->geom) && (o1==wheels[i]->geom)) ||
 //       ((o0==wheels[i]->geom) && (o1==bulldozer->geom))) return;
 // }
  
  

  const int N = 100;
  dContact contact[N];
  n = dCollide (o0,o1,N,&contact[0].geom,sizeof(dContact));
  if (n > 0) {
    for (i=0; i<n; i++) {
      contact[i].surface.mode = dContactSlip1 | dContactSlip2 |
          dContactSoftERP | dContactSoftCFM | dContactApprox1;
      contact[i].surface.mu = 1.7;
      contact[i].surface.slip1 = 0.1;
      contact[i].surface.slip2 = 0.1;
      contact[i].surface.soft_erp = 0.5;
      contact[i].surface.soft_cfm = 0.3;
      dJointID c = dJointCreateContact (world,contactgroup,&contact[i]);
      dJointAttach (c,
                    dGeomGetBody(contact[i].geom.g1),
                                 dGeomGetBody(contact[i].geom.g2));
    }
  }
}
开发者ID:itroot,项目名称:university-tasks,代码行数:34,代码来源:WorldPhysics.cpp

示例6: NodynamicsCollide

void  NodynamicsCollide(bool& do_colide,bool bo1,dContact& c,SGameMtl * /*material_1*/,SGameMtl * /*material_2*/)
{
	dBodyID body1=dGeomGetBody(c.geom.g1);
	dBodyID body2=dGeomGetBody(c.geom.g2);
	if(!body1||!body2||(dGeomUserDataHasCallback(c.geom.g1,NodynamicsCollide)&&dGeomUserDataHasCallback(c.geom.g2,NodynamicsCollide)))return;
	do_colide=false; 
}
开发者ID:OLR-xray,项目名称:XRay-NEW,代码行数:7,代码来源:CharacterPhysicsSupport.cpp

示例7: dGeomGetBody

void BodyVerifier::collisionCallback(void *data, dGeomID o1, dGeomID o2) {

	CollisionData *collisionData = (CollisionData *) data;
	const int MAX_CONTACTS = 32; // maximum number of contact points per body
	// TODO will it work with just 1 point? Probably yes.

	// exit without doing anything if the two bodies are connected by a joint
	dBodyID b1 = dGeomGetBody(o1);
	dBodyID b2 = dGeomGetBody(o2);

	if (b1 && b2 && dAreConnectedExcluding(b1, b2, dJointTypeContact)) {
		return;
	}

	dContact contact[MAX_CONTACTS];
	for (int i = 0; i < MAX_CONTACTS; i++) {
		contact[i].surface.mode = 0;
	}


	if (dGeomGetClass(o1) == dCylinderClass &&
			dGeomGetClass(o2) == dCylinderClass) {
		collisionData->cylinders.push_back(o1);
		collisionData->cylinders.push_back(o2);
	}
	int collisionCounts = dCollide(o1, o2, MAX_CONTACTS, &contact[0].geom,
				sizeof(dContact));

	if (collisionCounts != 0) {
		collisionData->offendingBodies.push_back(std::pair<dBodyID,
				dBodyID>(b1, b2));
	}
}
开发者ID:ci-group,项目名称:robot-baby,代码行数:33,代码来源:BodyVerifier.cpp

示例8: nearCallback

void nearCallback(void *data, dGeomID o1, dGeomID o2) {
    State* state = (State*)data;

    if(dGeomIsSpace(o1) || dGeomIsSpace(o2)) {
        dSpaceCollide2(o1, o2, data, &nearCallback);

        if(dGeomIsSpace(o1))
            dSpaceCollide((dSpaceID)o1, data, &nearCallback);
        if(dGeomIsSpace(o2))
            dSpaceCollide((dSpaceID)o2, data, &nearCallback);
    } else {
        dBodyID b1 = dGeomGetBody(o1);
        dBodyID b2 = dGeomGetBody(o2);

        const int MAX_CONTACTS = 18;
        dContact contact[MAX_CONTACTS];

        for(int i = 0; i < MAX_CONTACTS; i++) {
            contact[i].surface.mode = dContactBounce;
            contact[i].surface.mu = 2000;
            contact[i].surface.bounce = 0.1;
            contact[i].surface.bounce_vel = 0.15;
        }

        if(int numc = dCollide(o1, o2, MAX_CONTACTS, &contact[0].geom, sizeof(dContact))) {
            for(int i = 0; i < numc; i++) {
                dJointID c = dJointCreateContact(state->world, state->physicsContactgroup, &contact[i]);
                dJointAttach(c, b1, b2);
            }
        }
    }
}
开发者ID:xenris,项目名称:ode-car-jump,代码行数:32,代码来源:main.cpp

示例9: nearCallback

    static void nearCallback(void *data, dGeomID o1, dGeomID o2)
    {
        // if a collision has not already been detected
        if (!reinterpret_cast<CallbackParam *>(data)->collision)
        {
            dBodyID b1 = dGeomGetBody(o1);
            dBodyID b2 = dGeomGetBody(o2);
            if ((b1 != nullptr) && (b2 != nullptr) && (dAreConnectedExcluding(b1, b2, dJointTypeContact) != 0))
                return;

            dContact contact[1];  // one contact is sufficient
            int numc = dCollide(o1, o2, 1, &contact[0].geom, sizeof(dContact));

            // check if there is really a collision
            if (numc != 0)
            {
                // check if the collision is allowed
                bool valid = reinterpret_cast<CallbackParam *>(data)->env->isValidCollision(o1, o2, contact[0]);
                reinterpret_cast<CallbackParam *>(data)->collision = !valid;
                if (reinterpret_cast<CallbackParam *>(data)->env->verboseContacts_)
                {
                    OMPL_DEBUG("%s contact between %s and %s", (valid ? "Valid" : "Invalid"),
                               reinterpret_cast<CallbackParam *>(data)->env->getGeomName(o1).c_str(),
                               reinterpret_cast<CallbackParam *>(data)->env->getGeomName(o2).c_str());
                }
            }
        }
    }
开发者ID:jvgomez,项目名称:ompl,代码行数:28,代码来源:OpenDEStateSpace.cpp

示例10: nearCallback

static void nearCallback (void *data, dGeomID o1, dGeomID o2)
{
	int i,n;
	
	dBodyID b1 = dGeomGetBody(o1);
	dBodyID b2 = dGeomGetBody(o2);
	if (b1 && b2 && dAreConnected(b1, b2))
		return;
	
	const int N = 4;
	dContact contact[N];
	n = dCollide (o1,o2,N,&contact[0].geom,sizeof(dContact));
	if (n > 0) {
		for (i=0; i<n; i++) {
			contact[i].surface.mode = dContactSlip1 | dContactSlip2 | dContactSoftERP | dContactSoftCFM | dContactApprox1;
			if (dGeomGetClass(o1) == dSphereClass || dGeomGetClass(o2) == dSphereClass)
				contact[i].surface.mu = 20;
			else
				contact[i].surface.mu = 0.5;
			contact[i].surface.slip1 = 0.0;
			contact[i].surface.slip2 = 0.0;
			contact[i].surface.soft_erp = 0.8;
			contact[i].surface.soft_cfm = 0.01;
			dJointID c = dJointCreateContact (world,contactgroup,contact+i);
			dJointAttach (c,dGeomGetBody(o1),dGeomGetBody(o2));
		}
	}
}
开发者ID:CentreForBioRobotics,项目名称:lpzrobots,代码行数:28,代码来源:demo_crash.cpp

示例11: nearCallback

static void nearCallback (void *data, dGeomID o1, dGeomID o2)
{
  assert(o1);
  assert(o2);

  if (dGeomIsSpace(o1) || dGeomIsSpace(o2))
  {
    fprintf(stderr,"testing space %p %p\n", o1,o2);
    // colliding a space with something
    dSpaceCollide2(o1,o2,data,&nearCallback);
    // Note we do not want to test intersections within a space,
    // only between spaces.
    return;
  }

  const int N = 32;
  dContact contact[N];
  int n = dCollide (o1,o2,N,&(contact[0].geom),sizeof(dContact));
  if (n > 0) 
  {
    for (int i=0; i<n; i++) 
    {
      contact[i].surface.mode = dContactSoftERP | dContactSoftCFM | dContactApprox1;
      contact[i].surface.mu = 100.0;
      contact[i].surface.soft_erp = 0.96;
      contact[i].surface.soft_cfm = 0.02;
      dJointID c = dJointCreateContact (world,contactgroup,&contact[i]);
      dJointAttach (c,
		    dGeomGetBody(contact[i].geom.g1),
		    dGeomGetBody(contact[i].geom.g2));
    }
  }
}
开发者ID:BenitoJedai,项目名称:jslibs,代码行数:33,代码来源:demo_feedback.cpp

示例12: dGeomGetBody

/***********************************************************
	hanlde collision
***********************************************************/
void ODEPhysicHandler::handleCollisionBetween(dGeomID o0, dGeomID o1)
{
	// Create an array of dContact objects to hold the contact joints
	static const int MAX_CONTACTS = 10;
	dContact contact[MAX_CONTACTS];

	for (int i = 0; i < MAX_CONTACTS; i++)
	{
		contact[i].surface.mode = dContactBounce | dContactSoftCFM;
		contact[i].surface.mu = dInfinity;
		contact[i].surface.mu2 = 0;
		contact[i].surface.bounce = 0.8;
		contact[i].surface.bounce_vel = 0.1;
		contact[i].surface.soft_cfm = 0.01;
	}
	if (int numc = dCollide(o0, o1, MAX_CONTACTS, &contact[0].geom, sizeof(dContact)))
	{
		// Get the dynamics body for each geom
		dBodyID b1 = dGeomGetBody(o0);
		dBodyID b2 = dGeomGetBody(o1);
		// To add each contact point found to our joint group we call dJointCreateContact which is just one of the many
		// different joint types available.  
		for (int i = 0; i < numc; i++)
		{
			// dJointCreateContact needs to know which world and joint group to work with as well as the dContact
			// object itself. It returns a new dJointID which we then use with dJointAttach to finally create the
			// temporary contact joint between the two geom bodies.
			dJointID c = dJointCreateContact(_world, _contactgroup, contact + i);
			dJointAttach(c, b1, b2);
		}
	}	
}
开发者ID:leloulight,项目名称:lbanet,代码行数:35,代码来源:ODEPhysicHandler.cpp

示例13: nearCallback

static void nearCallback (void *data, dGeomID o1, dGeomID o2)
{
    // for drawing the contact points
    dMatrix3 RI;
    dRSetIdentity (RI);
    const dReal ss[3] = {0.02,0.02,0.02};

    int i;
    dBodyID b1 = dGeomGetBody(o1);
    dBodyID b2 = dGeomGetBody(o2);

    dContact contact[MAX_CONTACTS];
    int numc = dCollide (o1,o2,MAX_CONTACTS,&contact[0].geom,
			    sizeof(dContact));

    for (i=0; i<numc; i++) {
        contact[i].surface.mode = dContactApprox1;
        contact[i].surface.mu = 2;

        dJointID c = dJointCreateContact (*world,contactgroup,contact+i);
        dJointAttach (c,b1,b2);
        if (show_contacts)
            dsDrawBox (contact[i].geom.pos, RI, ss);

    }
}
开发者ID:4nakin,项目名称:awesomeball,代码行数:26,代码来源:demo_gyroscopic.cpp

示例14: dCollide

void CProtoHapticDoc::nearCallback(dGeomID o1, dGeomID o2)
{
	int index1= (int)dGeomGetData(o1);
	int index2= (int)dGeomGetData(o2);

	if(m_shapes[index1]->isCollisionDynamic() || 
	   m_shapes[index2]->isCollisionDynamic()) {

		int n, i;
		const int N = 50;
		dContact contact[N];
		n = dCollide (o1,o2,N,&contact[0].geom,sizeof(dContact));
		if (n > 0) {
			OutputDebugString("Collision\n");
			for (i=0; i<n; i++) {
				contact[i].surface.mode = dContactSlip1 | dContactSlip2 | dContactSoftERP | dContactSoftCFM | dContactApprox1;
				if (dGeomGetClass(o1) == dSphereClass || dGeomGetClass(o2) == dSphereClass)
					contact[i].surface.mu = 20;
				else
					contact[i].surface.mu = 0.5;
				contact[i].surface.slip1 = 1.0 - (m_shapes[index1]->getSurfaceFriction());
				contact[i].surface.slip2 = 1.0 - (m_shapes[index2]->getSurfaceFriction());
				contact[i].surface.soft_erp = 0.8;
				contact[i].surface.soft_cfm = 0.01;
				dJointID c = dJointCreateContact (m_worldID,m_jointGroup,contact+i);
				dJointAttach (c,dGeomGetBody(o1),dGeomGetBody(o2));
			}
		}
	}

}
开发者ID:neilforrest,项目名称:protohaptic,代码行数:31,代码来源:ProtoHapticDoc.cpp

示例15: dGeomGetBody

//description
//Default behavior. 
//Default collision of bodies
void ODEBaseScene::Collide(dGeomID g1, dGeomID g2)
{
    int n;
    
    dBodyID b1 = dGeomGetBody(g1);
    dBodyID b2 = dGeomGetBody(g2);
    if (b1 && b2 && dAreConnected(b1, b2))
            return;
 
    const int N = 4;
    dContact contact[N];
    n = dCollide (g1,g2,N,&contact[0].geom,sizeof(dContact));
    if (n > 0) 
    {
        // printf("Body %d hits body %d.\n", (size_t) dGeomGetData(g1),(size_t) dGeomGetData(g2));
        for (int i=0; i<n; ++i)
        {
            // contact[i].surface.mode = dContactBounce | dContactSoftCFM;
            contact[i].surface.mode = dContactBounce;        
            //contact[i].surface.mu = dInfinity;
            contact[i].surface.mu = 0.5;
            //contact[i].surface.mu2 = 0.5;
            contact[i].surface.bounce = 0.000999990;
            //contact[i].surface.bounce_vel = 0.1;
            //contact[i].surface.soft_cfm = 0.001;

            //contact[i].surface.mode = dContactBounce|dContactSoftERP|dContactSoftCFM;
            contact[i].surface.soft_erp = 1.0; //1.0;
            contact[i].surface.soft_cfm = 1e-10;
            dJointID j = dJointCreateContact (m_domain->getWorld(), m_domain->getContactGroup(), contact+i);
            dJointAttach(j, b1, b2);
        }
    }
}
开发者ID:saneku,项目名称:PODE2.0,代码行数:37,代码来源:ODEBaseScene.cpp


注:本文中的dGeomGetBody函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。