[ODE] Applying physics on same objects again...

Naveed Hanif naveedhan at hotmail.com
Mon Aug 28 05:20:44 MST 2006


Dear Friends,
Im new to ODE im running ODE buggytest but i want to make two cars and apply 
separate key board functions on them at the moment i draw two objects but 
key function is applied on both the buggies so can any body help me  and i 
want to make my code object oriented but facing problems so please help me 
if anyone could send sample code then it would be great

my code look like this ive modified this code from buggy_test.cpp 
(ode-src-0.6\ode-0.6\ode\test\buggytest.cpp)


static void simLoop (int pause)
{
  int i;

  if (!pause) {
    // motor
    dJointSetHinge2Param (joint[0],dParamVel2,-speed);
    dJointSetHinge2Param (joint[0],dParamFMax2,0.1);


    // steering
    dReal v = steer - dJointGetHinge2Angle1 (joint[0]);
    if (v > 0.1) v = 0.1;
    if (v < -0.1) v = -0.1;
    v *= 10.0;
    dJointSetHinge2Param (joint[0],dParamVel,v);
    dJointSetHinge2Param (joint[0],dParamFMax,0.2);
    dJointSetHinge2Param (joint[0],dParamLoStop,-0.75);
    dJointSetHinge2Param (joint[0],dParamHiStop,0.75);
    dJointSetHinge2Param (joint[0],dParamFudgeFactor,0.1);



	dSpaceCollide (space,0,&nearCallback);
    dWorldStep (world,0.05);

    // remove all contact joints
    dJointGroupEmpty (contactgroup);

////// speed is passed in keyboard function


	dJointSetHinge2Param (joint[0],dParamVel2,-speed1);
    dJointSetHinge2Param (joint[0],dParamFMax2,0.1);


    dReal v1 = steer1 - dJointGetHinge2Angle1 (joint[0]);
    if (v1 > 0.1) v1 = 0.1;
    if (v1 < -0.1) v1 = -0.1;
    v1 *= 10.0;
    dJointSetHinge2Param (joint[0],dParamVel,v1);
    dJointSetHinge2Param (joint[0],dParamFMax,0.2);
    dJointSetHinge2Param (joint[0],dParamLoStop,-0.75);
    dJointSetHinge2Param (joint[0],dParamHiStop,0.75);
    dJointSetHinge2Param (joint[0],dParamFudgeFactor,0.1);

	dSpaceCollide (space,0,&nearCallback);
    dWorldStep (world,0.05);

    // remove all contact joints
    dJointGroupEmpty (contactgroup);

  }


glPushMatrix();


  glTranslatef(-10,-10,0);
  dsSetColor (0,1,1);
  //dsSetTexture (DS_WOOD);
  dReal sides[3] = {LENGTH,WIDTH,HEIGHT};
  dsDrawBox (dBodyGetPosition(body[0]),dBodyGetRotation(body[0]),sides);
  dsSetColor (1,1,1);
  for (i=1; i<=3; i++) dsDrawCylinder (dBodyGetPosition(body[i]),
  dBodyGetRotation(body[i]),0.02f,RADIUS);



  glPopMatrix();

  glPushMatrix();
  glTranslatef(-10,-9,0);


//  glTranslatef(-10,-10,0);
  dsSetColor (0,1,1);
  //dsSetTexture (DS_WOOD);
  dReal sides1[3] = {LENGTH,WIDTH,HEIGHT};
  dsDrawBox (dBodyGetPosition(body[0]),dBodyGetRotation(body[0]),sides1);
  dsSetColor (1,1,1);
  for (i=1; i<=3; i++) dsDrawCylinder (dBodyGetPosition(body[i]),
  dBodyGetRotation(body[i]),0.02f,RADIUS);



  glPopMatrix();


draw d;
	glPushMatrix();
  //glTranslatef(0,8.5,0);
	glRotatef(90,1.0,0,0);
  d.planeOpengl();
  glPopMatrix();

}









Waiting for the reply

Thanks
Naveed




More information about the ODE mailing list