• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ dBodySetPosition函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: dBodyCreate

WheelPiece::WheelPiece(dWorldID& world,dSpaceID& space, float x, float y, float z)
{
    dBodyCreate(world);
    body = dBodyCreate(world);

    radius = .35;
    thickness = .25;
    activationDirection = 0;

    geom = dCreateCylinder(space, radius, thickness);
    dGeomSetBody(geom, body);
    dGeomSetData(geom, this);
    dMass mass;
    mass.setCylinder(.5, 1, radius, thickness);
    dBodySetMass(body, &mass);

    const dMatrix3 rotationMatrix = {1,0,0,0,
                                     0,1,0,0,
                                     0,0,1,0
                                    };

    dBodySetRotation(body, rotationMatrix);

    dBodySetPosition(body,x,y,z);

    attachmentOffset = thickness + .25;

    color[0] = .5;
    color[1] = 1;
    color[2] = 1;
}
开发者ID:kinggryan,项目名称:machinebuilder,代码行数:31,代码来源:wheelpiece.cpp


示例2: dBodyCreate

/**
 * This method initializes the grabbing of an object.
 * It creates an ODE-object with the current position and
 * orientation and stores the offset to the grabbed object
 * for correct update of the Entity-transformation
 * in the update method. It also creates all joints and
 * linked objects by calling the attachJoints-method.
 * @param entity Entity that should be grabbed
 **/
void JointInteraction::grabEntity(Entity* entity, TransformationData offset)
{
	unsigned entityID;
	unsigned typeBasedID;
	Entity* ent;
	dQuaternion quat;
	std::map< int, ODEObject*>::iterator it;
//	TransformationPipe* linkedObjectPipe;
//	unsigned short type, id;
	std::vector<unsigned> entityIds;
	unsigned userId;
	JointInteractionBeginEvent* evt;

	isGrabbing = true;

// // store position and orientation difference between user and object
	deltaTrans = offset;

// Create ODE-representation of grabbed object by simply creating an object with
// user's position and orientation
	ODEObject* odeObj = new ODEObject;
	odeObj->body = dBodyCreate(world);
	odeObj->entity = entity;

	dBodySetPosition(odeObj->body, userTrans.position[0], userTrans.position[1], userTrans.position[2]);
	convert(quat, userTrans.orientation);
	dBodySetQuaternion(odeObj->body, quat);

// attach all joints to object
	entityID = entity->getEnvironmentBasedId();
	linkedObjMap[entityID] = odeObj;
	attachJoints(entityID);

	grabbedObject = odeObj;

	entityIds.push_back(entity->getTypeBasedId());

// open Pipes for all linked objects
	for (it = linkedObjMap.begin(); it != linkedObjMap.end(); ++it)
	{
		if (it->second == grabbedObject)
			continue;
		ent = WorldDatabase::getEntityWithEnvironmentId(it->first);
		assert(ent->getEnvironmentBasedId() != entityID);
		typeBasedID = ent->getTypeBasedId();
		entityIds.push_back(typeBasedID);
/*
		split(typeBasedID, type, id);
// TODO: open pipes via Event
		linkedObjectPipe = TransformationManager::openPipe(JOINT_INTERACTION_MODULE_ID, WORLD_DATABASE_ID, 0, 0, type, id, 0, false);
		linkedObjPipes[it->first] = linkedObjectPipe;
*/
	} // for

	userId = UserDatabase::getLocalUserId();
	evt = new JointInteractionBeginEvent(userId, entityIds);
	EventManager::sendEvent(evt, EventManager::EXECUTE_GLOBAL);

} // grabEntity
开发者ID:flair2005,项目名称:inVRs,代码行数:68,代码来源:JointInteraction.cpp


示例3: dBodySetPosition

 void Primitive::setPosition(const Pos& pos){
   if(body){
     dBodySetPosition(body, pos.x(), pos.y(), pos.z());
   }else if(geom){ // okay there is just a geom no body
     dGeomSetPosition(geom, pos.x(), pos.y(), pos.z());
   }
   update(); // update the scenegraph stuff
 }
开发者ID:CentreForBioRobotics,项目名称:lpzrobots,代码行数:8,代码来源:primitive.cpp


示例4: createPart

 void createPart(const dWorldID & _world , dPart & part, dReal * pos3){
     dMass mass;
     part.body = dBodyCreate(_world);
     dBodySetPosition(part.body, pos3[0] , pos3[1], pos3[2]); // Set a position
     dMassSetZero(&mass);                        // Set mass parameter to zero
     dMassSetCapsuleTotal(&mass,part.mass,3,part.radius, part.length);  // Calculate mass parameter
     dBodySetMass(part.body, &mass);  // Set mass
 }
开发者ID:keletskiy,项目名称:test_body,代码行数:8,代码来源:main.cpp


示例5: dBodySetPosition

void ODERigidObject::SetTransform(const RigidTransform& T)
{
  Vector3 comPos = T*obj.com;
  dBodySetPosition(bodyID,comPos.x,comPos.y,comPos.z);
  dMatrix3 rot;
  CopyMatrix(rot,T.R);
  dBodySetRotation(bodyID,rot);
}
开发者ID:RGrant92,项目名称:Klampt,代码行数:8,代码来源:ODERigidObject.cpp


示例6: _pos

void ODE_Link::setTransform(const hrp::Vector3& pos, const hrp::Matrix33& R){
    hrp::Vector3 _pos(R * C + pos);
    dBodySetPosition(bodyId, _pos(0), _pos(1), _pos(2));
    dMatrix3 _R = {R(0,0), R(0,1), R(0,2), 0,
                  R(1,0), R(1,1), R(1,2), 0,
                  R(2,0), R(2,1), R(2,2), 0};
    dBodySetRotation(bodyId, _R);
}
开发者ID:YoheiKakiuchi,项目名称:openhrp3-1,代码行数:8,代码来源:ODE_Link.cpp


示例7: simLoop

static void simLoop (int pause)
{
  // stop after a given number of iterations, as long as we are not in
  // interactive mode
  if (cmd_graphics && !cmd_interactive &&
      (iteration >= max_iterations)) {
    dsStop();
    return;
  }
  iteration++;

  if (!pause) {
    // do stuff for this test and check to see if the joint is behaving well
    dReal error = doStuffAndGetError (test_num);
    if (error > max_error) max_error = error;
    if (cmd_interactive && error < dInfinity) {
      printf ("scaled error = %.4e\n",error);
    }

    // take a step
    dWorldStep (world,STEPSIZE);

    // occasionally re-orient the first body to create a deliberate error.
    if (cmd_occasional_error) {
      static int count = 0;
      if ((count % 20)==0) {
	// randomly adjust orientation of body[0]
	const dReal *R1;
	dMatrix3 R2,R3;
	R1 = dBodyGetRotation (body[0]);
	dRFromAxisAndAngle (R2,dRandReal()-0.5,dRandReal()-0.5,
			    dRandReal()-0.5,dRandReal()-0.5);
	dMultiply0 (R3,R1,R2,3,3,3);
	dBodySetRotation (body[0],R3);

	// randomly adjust position of body[0]
	const dReal *pos = dBodyGetPosition (body[0]);
	dBodySetPosition (body[0],
			  pos[0]+0.2*(dRandReal()-0.5),
			  pos[1]+0.2*(dRandReal()-0.5),
			  pos[2]+0.2*(dRandReal()-0.5));
      }
      count++;
    }
  }

  if (cmd_graphics) {
    dReal sides1[3] = {SIDE,SIDE,SIDE};
    dReal sides2[3] = {SIDE*0.99f,SIDE*0.99f,SIDE*0.99f};
    dsSetTexture (DS_WOOD);
    dsSetColor (1,1,0);
    dsDrawBox (dBodyGetPosition(body[0]),dBodyGetRotation(body[0]),sides1);
    if (body[1]) {
      dsSetColor (0,1,1);
      dsDrawBox (dBodyGetPosition(body[1]),dBodyGetRotation(body[1]),sides2);
    }
  }
}
开发者ID:CentreForBioRobotics,项目名称:lpzrobots,代码行数:58,代码来源:test_joints.cpp


示例8: getEntityWithID

/**
 * This method returns the ODE-representation of the
 * Entity with the passed ID. It searches
 * in the map of connected objects for a matching
 * ODEObject. If no object is found the method
 * creates one and stores it in the map.
 * @param entityID ID of the EntityTransform
 * @return ODE representation of the EntityTransform
 **/
dBodyID JointInteraction::getBodyWithID(int entityID)
{
	if (entityID == 0)
		return 0;

// 	TransformationPipe* objectPipe;
	Entity* entity;
	TransformationData trans;
	gmtl::Vec3f pos;
	gmtl::Quatf ori;
	gmtl::AxisAnglef axAng;
	dQuaternion quat;

	ODEObject* object = linkedObjMap[entityID];
	if (object == NULL)
	{
		entity = getEntityWithID(entityID);
		if (entity == NULL)
		{
			printd(ERROR, "JointInteraction::getBodyWithID(): ERROR: FOUND BODY WITHOUT MATCHING ENTITY OBJECT!!!\n");
			return 0;
		} // if

		object = new ODEObject;
		object->body = dBodyCreate(world);
		object->entity = entity;

		trans = entity->getEnvironmentTransformation();
		pos = trans.position;
		ori = trans.orientation;
	// get current object position and orientation
// 		pos[0] = entity->getXTrans();
// 		pos[1] = entity->getYTrans();
// 		pos[2] = entity->getZTrans();
// 		axAng.set(entity->getRotAngle(), entity->getXRot(), entity->getYRot(), entity->getZRot());
// 		gmtl::set(ori, axAng);

		convert(quat, ori);
		dBodySetPosition(object->body, pos[0], pos[1], pos[2]);
		dBodySetQuaternion(object->body, quat);

		linkedObjMap[entityID] = object;

// TODO: open and close pipes via events
// open TransformationPipe for handling transformations of connected entities
// 		split(entity->getTypeBasedId(), type, id);
// 		objectPipe = TransformationManager::openPipe(JOINT_INTERACTION_MODULE_ID, WORLD_DATABASE_ID, 0, 0, type, id, 0, 0);
// 		linkedObjPipes[entityID] = objectPipe;

// ingnore request if Entity is not movable
		if (!entity->getEntityType()->isFixed())
			attachJoints(entityID);
	} // if
	if (object->entity->getEntityType()->isFixed())
		return 0;

	return object->body;
} // getBodyWithID
开发者ID:flair2005,项目名称:inVRs,代码行数:67,代码来源:JointInteraction.cpp


示例9: makeArm

/*** ロボットアームの生成 ***/
void  makeArm()
{
  dMass mass;                                    // 質量パラメータ
  dReal x[NUM]      = {0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00};  // 重心 x
  dReal y[NUM]      = {0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00};  // 重心 y
  dReal z[NUM]      = {0.05, 0.55, 1.55, 2.30, 2.80, 3.35, 3.85, 4.0};  // 重心 z
  dReal length[NUM-1] = {0.10, 1.00, 1.00, 0.50, 0.50, 0.50, 0.50};  // 長さ
  dReal weight[NUM] = {9.00, 2.00, 2.00, 1.00, 1.00, 0.50, 0.50, 0.50};  // 質量
  dReal r[NUM-1]      = {0.3, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1};  // 半径
  dReal c_x[NUM]    = {0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00};  // 関節中心点 x
  dReal c_y[NUM]    = {0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00};  // 関節中心点 y
  dReal c_z[NUM]    = {0.00, 0.10, 1.10, 2.10, 2.60, 3.10, 3.60, 3.9};  // 関節中心点 z
  dReal axis_x[NUM] = {0, 0, 0, 0, 0, 0, 0, 0};              // 関節回転軸 x
  dReal axis_y[NUM] = {0, 0, 1, 1, 0, 1, 0, 0};              // 関節回転軸 y
  dReal axis_z[NUM] = {1, 1, 0, 0, 1, 0, 1, 1};              // 関節回転軸 z

  // リンクの生成
  for (int i = 0; i < NUM-1; i++) {
    rlink[i].body = dBodyCreate(world);
    dBodySetPosition(rlink[i].body, x[i], y[i], z[i]);
    dMassSetZero(&mass);
    dMassSetCapsuleTotal(&mass,weight[i],3,r[i],length[i]);
    dBodySetMass(rlink[i].body, &mass);
    rlink[i].geom = dCreateCapsule(space,r[i],length[i]);
    dGeomSetBody(rlink[i].geom,rlink[i].body);
  }
  rlink[NUM-1].body = dBodyCreate(world);
  dBodySetPosition(rlink[NUM-1].body, x[NUM-1], y[NUM-1], z[NUM-1]);
  dMassSetZero(&mass);
  dMassSetBoxTotal(&mass,weight[NUM-1],0.4,0.4,0.4);
  dBodySetMass(rlink[NUM-1].body, &mass);
  rlink[NUM-1].geom = dCreateBox(space,0.4,0.4,0.4);
  dGeomSetBody(rlink[NUM-1].geom,rlink[NUM-1].body);

  // ジョイントの生成とリンクへの取り付け
  joint[0] = dJointCreateFixed(world, 0);  // 固定ジョイント
  dJointAttach(joint[0], rlink[0].body, 0);
  dJointSetFixed(joint[0]);
  for (int j = 1; j < NUM; j++) {
    joint[j] = dJointCreateHinge(world, 0); // ヒンジジョイント
    dJointAttach(joint[j], rlink[j].body, rlink[j-1].body);
    dJointSetHingeAnchor(joint[j], c_x[j], c_y[j], c_z[j]);
    dJointSetHingeAxis(joint[j], axis_x[j], axis_y[j],axis_z[j]);
  }
}
开发者ID:Ry0,项目名称:ODE,代码行数:46,代码来源:6axis4.cpp


示例10: Matrix4ToODE

void TSRODERigidBody::SetBodyTransform( const TSRMatrix4& _bodyTransform )
{
    dMatrix4 R;
    dVector3 P;
    Matrix4ToODE( _bodyTransform, R, P );
    dBodySetPosition( m_BodyID, P[ 0 ], P[ 1 ], P[ 2 ] );
    dBodySetRotation( m_BodyID, R );

}
开发者ID:ShadyEM,项目名称:Twister3D,代码行数:9,代码来源:TSRODERigidBody.cpp


示例11: body_set_position_and_quaternion

/* sets position and rotation of a body based on position and quaternion values */
void body_set_position_and_quaternion (dBodyID b, t_real x, t_real y, t_real z, t_real q1, t_real q2, t_real q3, t_real q4) {
  dQuaternion q;
  dBodySetPosition (b, x, y, z);
  q [0] = q1;
  q [1] = q2;
  q [2] = q3;
  q [3] = q4;
  dBodySetQuaternion (b, q);
}
开发者ID:rcortini,项目名称:dna_ode,代码行数:10,代码来源:ode_body_functions.c


示例12: reset_state

static void reset_state(void)
{
  float sx=-4, sy=-4, sz=2;
  dQuaternion q;
  dQFromAxisAndAngle (q,1,0,0,M_PI*0.5);
#ifdef BOX
  dBodySetPosition (boxbody, sx, sy+1, sz);
  dBodySetLinearVel (boxbody, 0,0,0);
  dBodySetAngularVel (boxbody, 0,0,0);
  dBodySetQuaternion (boxbody, q);
#endif
#ifdef CYL
  dBodySetPosition (cylbody, sx, sy, sz);
  dBodySetLinearVel (cylbody, 0,0,0);
  dBodySetAngularVel (cylbody, 0,0,0);
  dBodySetQuaternion (cylbody, q);
#endif
}
开发者ID:4nakin,项目名称:awesomeball,代码行数:18,代码来源:demo_cyl.cpp


示例13: getProxy

void MyDeformableObjectNode::updatePhysicsBodies(int vertexIndex) {
    if (mPrintDebugOutput) {
        std::cout << mDebugOutputPrefix << "MyDeformableObjectNode::updatePhysicsBodies(vertexIndex: " << vertexIndex << ")" << std::endl;
    }

    if (!mPhysicsObjects.empty()) {

        unsigned int index, objectCount;

        dcollide::Vertex* vertex;
        MyODEDeformableTestAppGeom* geom;


        if (vertexIndex != -1) {
            index = vertexIndex;
            objectCount = vertexIndex+1;
        } else {
            index = 0;
            objectCount = mPhysicsObjects.size();
        }

        const std::vector<dcollide::Vertex*>& vertices
            = getProxy()->getShape()->getMesh()->getVertices();
        for (/* nop */; index < objectCount; ++index) {

            geom = mPhysicsObjects[index];
            vertex = vertices[index];

            dcollide::Vector3 bodyPosition = vertex->getWorldPosition();

            if (mPrintDebugOutput) {
                if (index == objectCount-1) {
                    const dReal* odePosition = 0;
                    odePosition = dBodyGetPosition(geom->getBody());

                    std::cout << mDebugOutputPrefix << "----------" << std::endl;
                    std::cout << mDebugOutputPrefix << "ODE Position (before move): " << odePosition[0] << ", " << odePosition[1] << ", " << odePosition[2] << std::endl;
                    std::cout << mDebugOutputPrefix << "D-Collide World Position: " << bodyPosition << std::endl << std::endl;
                }
            }

            geom->setMoveNodeOnBodyMoved(false);
            dBodySetPosition(geom->getBody(),  bodyPosition.getX(),
                                               bodyPosition.getY(),
                                               bodyPosition.getZ());
            geom->setMoveNodeOnBodyMoved(true);

            if (mPrintDebugOutput) {
                if (index == objectCount-1) {
                    const dReal* odePosition = 0;
                    odePosition = dBodyGetPosition(geom->getBody());
                    std::cout << mDebugOutputPrefix << "ODE Position (after move): " << odePosition[0] << ", " << odePosition[1] << ", " << odePosition[2] << std::endl << std::endl;
                }
            }
        }
    }
}
开发者ID:ColinGilbert,项目名称:d-collide,代码行数:57,代码来源:mydeformableobjectnode.cpp


示例14: dBodySetPosition

void CubeBasePiece::attachToBase(dBodyID otherBody, dWorldID world, dJointGroupID jointGroup, dReal x, dReal y, dReal z, const dMatrix3 rotationMatrix)
{
    dBodySetPosition(body,x,y,z);

    dJointID connectingJoint = dJointCreateSlider(world,jointGroup);
    dJointAttach(connectingJoint,otherBody,body);
    dJointSetSliderParam(connectingJoint,dParamLoStop,0);
    dJointSetSliderParam(connectingJoint,dParamHiStop,0);
}
开发者ID:kinggryan,项目名称:machinebuilder,代码行数:9,代码来源:cubebasepiece.cpp


示例15: main

int main (int argc, char **argv)
{
  // setup pointers to drawstuff callback functions
  dsFunctions fn;
  fn.version = DS_VERSION;
  fn.start = &start;
  fn.step = &simLoop;
  fn.command = &command;
  fn.stop = 0;
  fn.path_to_textures = DRAWSTUFF_TEXTURE_PATH;

  // create world
  dInitODE2(0);
  world = dWorldCreate();

  dMass m;
  dMassSetBox (&m,1,SIDE,SIDE,SIDE);
  dMassAdjust (&m,MASS);

  dQuaternion q;
  dQFromAxisAndAngle (q,1,1,0,0.25*M_PI);

  body[0] = dBodyCreate (world);
  dBodySetMass (body[0],&m);
  dBodySetPosition (body[0],0.5*SIDE,0.5*SIDE,1);
  dBodySetQuaternion (body[0],q);

  body[1] = dBodyCreate (world);
  dBodySetMass (body[1],&m);
  dBodySetPosition (body[1],-0.5*SIDE,-0.5*SIDE,1);
  dBodySetQuaternion (body[1],q);

  hinge = dJointCreateHinge (world,0);
  dJointAttach (hinge,body[0],body[1]);
  dJointSetHingeAnchor (hinge,0,0,1);
  dJointSetHingeAxis (hinge,1,-1,1.41421356);

  // run simulation
  dsSimulationLoop (argc,argv,352,288,&fn);

  dWorldDestroy (world);
  dCloseODE();
  return 0;
}
开发者ID:Devilmore,项目名称:GoalBabbling,代码行数:44,代码来源:demo_hinge.cpp


示例16: IoMessage_locals_doubleArgAt_

IoObject *IoODEBody_setPosition(IoODEBody *self, IoObject *locals, IoMessage *m)
{
	const double x = IoMessage_locals_doubleArgAt_(m, locals, 0);
	const double y = IoMessage_locals_doubleArgAt_(m, locals, 1);
	const double z = IoMessage_locals_doubleArgAt_(m, locals, 2);

	IoODEBody_assertValidBody(self, locals, m);
	dBodySetPosition(BODYID, x, y, z);
	return self;
}
开发者ID:cdcarter,项目名称:io,代码行数:10,代码来源:IoODEBody.c


示例17: dBodyCreate

void ode::newLine(float xp, float yp)
{
		b = dBodyCreate (world);
		dBodySetPosition (b,xp,yp,2);
		//dMassSetSphere (&m,1,RADIUS);
		dMassAdjust (&m, 1);
		dBodySetMass (b,&m);
		lineStrips[lines] = dCreateSphere (space,RADIUS);
		dGeomSetBody (lineStrips[lines++],b);		
}
开发者ID:MisterDEE,项目名称:3D-Puzzle-Maze,代码行数:10,代码来源:testApp.cpp


示例18: dBodyCreate

void SkidSteeringVehicle::create() {
    this->vehicleBody = dBodyCreate(this->environment->world);
    this->vehicleGeom = dCreateBox(this->environment->space, this->vehicleBodyLength, this->vehicleBodyWidth, this->vehicleBodyHeight);
    this->environment->setGeomName(this->vehicleGeom, name + ".vehicleGeom");
    dMassSetBox(&this->vehicleMass, this->density, this->vehicleBodyLength, this->vehicleBodyWidth, this->vehicleBodyHeight);
    dGeomSetCategoryBits(this->vehicleGeom, Category::OBSTACLE);
    dGeomSetCollideBits(this->vehicleGeom, Category::OBSTACLE | Category::TERRAIN);
    dBodySetMass(this->vehicleBody, &this->vehicleMass);
    dBodySetPosition(this->vehicleBody, this->xOffset, this->yOffset, this->zOffset);
    dGeomSetBody(this->vehicleGeom, this->vehicleBody);
    dGeomSetOffsetPosition(this->vehicleGeom, 0, 0, this->wheelRadius);

    dReal w = this->vehicleBodyWidth + this->wheelWidth + 2 * this->trackVehicleSpace;
    for(int fr = 0; fr < 2; fr++) {
        for(int lr = 0; lr < 2; lr++) {
            this->wheelGeom[fr][lr] = dCreateCylinder(this->environment->space, this->wheelRadius, this->wheelWidth);
            this->environment->setGeomName(this->wheelGeom[fr][lr], this->name + "." + (!fr ? "front" : "rear") + (!lr ? "Left" : "Right") + "Wheel");
            dGeomSetCategoryBits(this->wheelGeom[fr][lr], Category::TRACK_GROUSER);
            dGeomSetCollideBits(this->wheelGeom[fr][lr], Category::TERRAIN);
            dMassSetCylinder(&this->wheelMass[fr][lr], this->density, 3, this->wheelRadius, this->wheelWidth);
            this->wheelBody[fr][lr] = dBodyCreate(this->environment->world);
            dBodySetMass(this->wheelBody[fr][lr], &this->wheelMass[fr][lr]);
            dGeomSetBody(this->wheelGeom[fr][lr], this->wheelBody[fr][lr]);
            dBodySetPosition(this->wheelBody[fr][lr], this->xOffset + (fr - 0.5) * this->wheelBase, this->yOffset + w * (lr - 0.5), this->zOffset);
            dMatrix3 wheelR;
            dRFromZAxis(wheelR, 0, 2 * lr - 1, 0);
            dBodySetRotation(this->wheelBody[fr][lr], wheelR);
            this->wheelJoint[fr][lr] = dJointCreateHinge(this->environment->world, 0);
            dJointAttach(this->wheelJoint[fr][lr], this->vehicleBody, this->wheelBody[fr][lr]);
            dJointSetHingeAnchor(this->wheelJoint[fr][lr], this->xOffset + (fr - 0.5) * this->wheelBase, this->yOffset + this->vehicleBodyWidth * (lr - 0.5), this->zOffset);
            dJointSetHingeAxis(this->wheelJoint[fr][lr], 0, 1, 0);
            dJointSetHingeParam(this->wheelJoint[fr][lr], dParamFMax, 5.0);
        }
    }
    
    this->bodyArray = dRigidBodyArrayCreate(this->vehicleBody);
    for(int fr = 0; fr < 2; fr++) {
        for(int lr = 0; lr < 2; lr++) {
            dRigidBodyArrayAdd(this->bodyArray, this->wheelBody[fr][lr]);
        }
    }
}
开发者ID:fferri,项目名称:tvs,代码行数:42,代码来源:SkidSteeringVehicle.cpp


示例19: reset_ball

static void reset_ball(void)
{
  float sx=0.0f, sy=3.40f, sz=7.15;

  dQuaternion q;
  dQSetIdentity(q);
  dBodySetPosition (sphbody, sx, sy, sz);
  dBodySetQuaternion(sphbody, q);
  dBodySetLinearVel (sphbody, 0,0,0);
  dBodySetAngularVel (sphbody, 0,0,0);
}
开发者ID:amaula,项目名称:ode-0.12,代码行数:11,代码来源:demo_basket.cpp


示例20: simLoop

static void simLoop (int pause)
{
  const dReal kd = -0.3;	// angular damping constant
  const dReal ks = 0.5;	// spring constant
  if (!pause) {
    // add an oscillating torque to body 0, and also damp its rotational motion
    static dReal a=0;
    const dReal *w = dBodyGetAngularVel (body[0]);
    dBodyAddTorque (body[0],kd*w[0],kd*w[1]+0.1*cos(a),kd*w[2]+0.1*sin(a));
    a += 0.01;

    // add a spring force to keep the bodies together, otherwise they will
    // fly apart along the slider axis.
    const dReal *p1 = dBodyGetPosition (body[0]);
    const dReal *p2 = dBodyGetPosition (body[1]);
    dBodyAddForce (body[0],ks*(p2[0]-p1[0]),ks*(p2[1]-p1[1]),
		   ks*(p2[2]-p1[2]));
    dBodyAddForce (body[1],ks*(p1[0]-p2[0]),ks*(p1[1]-p2[1]),
		   ks*(p1[2]-p2[2]));

    // occasionally re-orient one of the bodies to create a deliberate error.
    if (occasional_error) {
      static int count = 0;
      if ((count % 20)==0) {
	// randomly adjust orientation of body[0]
	const dReal *R1;
	dMatrix3 R2,R3;
	R1 = dBodyGetRotation (body[0]);
	dRFromAxisAndAngle (R2,dRandReal()-0.5,dRandReal()-0.5,
			    dRandReal()-0.5,dRandReal()-0.5);
	dMultiply0 (R3,R1,R2,3,3,3);
	dBodySetRotation (body[0],R3);

	// randomly adjust position of body[0]
	const dReal *pos = dBodyGetPosition (body[0]);
	dBodySetPosition (body[0],
			  pos[0]+0.2*(dRandReal()-0.5),
			  pos[1]+0.2*(dRandReal()-0.5),
			  pos[2]+0.2*(dRandReal()-0.5));
      }
      count++;
    }

    dWorldStep (world,0.05);
  }

  dReal sides1[3] = {SIDE,SIDE,SIDE};
  dReal sides2[3] = {SIDE*0.8f,SIDE*0.8f,SIDE*2.0f};
  dsSetTexture (DS_WOOD);
  dsSetColor (1,1,0);
  dsDrawBox (dBodyGetPosition(body[0]),dBodyGetRotation(body[0]),sides1);
  dsSetColor (0,1,1);
  dsDrawBox (dBodyGetPosition(body[1]),dBodyGetRotation(body[1]),sides2);
}
开发者ID:aliverobotics,项目名称:Pumas-SmallSize,代码行数:54,代码来源:test_slider.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dBodySetRotation函数代码示例发布时间:2022-05-30
下一篇:
C++ dBodySetMass函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap