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
 }
Example #2
0
  void printCornerPointsXY(Box* box, FILE* f){
    OSGBox* obox = (OSGBox*)box->getOSGPrimitive();
    std::list<Pos> ps;
    Pos dim = obox->getDim();
    ps.push_back(Pos(dim.x()*  0.5, dim.y()*  0.5,0));
    ps.push_back(Pos(dim.x()*  0.5, dim.y()* -0.5,0));
    ps.push_back(Pos(dim.x()* -0.5, dim.y()* -0.5,0));
    ps.push_back(Pos(dim.x()* -0.5, dim.y()*  0.5,0));
//     for(int i=0; i<8; i++){
//       ps.push_back(Pos(dim.x()*( (i&4) ? 0.5: -0.5),dim.y()*( (i&2) ? 0.5: -0.5),dim.z()*( (i&1) ? 0.5: -0.5)));
//     }
    // transform them into global coords
    FOREACH(std::list<Pos>, ps, p){
      *p = (*p) * box->getPose();
    }
  bool Primitive::restore(FILE* f){
    Pose pose;
    Pos vel;
    Pos avel;

    if ( fread ( pose.ptr() , sizeof ( Pose::value_type), 16, f ) == 16 )
      if( fread ( vel.ptr() , sizeof ( Pos::value_type), 3, f ) == 3 )
        if( fread ( avel.ptr() , sizeof ( Pos::value_type), 3, f ) == 3 ){
          setPose(pose);
          if(body){
            dBodySetLinearVel(body,vel.x(),vel.y(),vel.z());
            dBodySetAngularVel(body,avel.x(),avel.y(),avel.z());
          }
          return true;
        }
    fprintf ( stderr, "Primitve::restore: cannot read primitive from data\n" );
    return false;
  }
Example #4
0
bool GameStream::Move(const Pos& pos) {
  return stream_.SendMsgWithCheck("MOVE " + to_string(pos.x()) + " " +
                                  to_string(pos.y()));
}