Ejemplo n.º 1
0
static bool ioMB_importBone(BrfSkeleton &s ){
  if (!expect( "-n" )) return false;
  BrfBone b;
  b.attach = -1;

  readStrQuotesChar( b.name );

  if (!lineEnd) {
    int tmp = oneOf("-p",";");
    if (!tmp) return false;
    if (tmp==1) {
      QString parentName = readStrQuotes(  );
      b.attach = s.FindBoneByName(parentName.toAscii().data());
      if (b.attach==-1) {
        lastErr = QString("Can't find bone \"%1\"").arg(parentName);
        return false;
      }
    }
  } else {
    if (s.root != -1) {
      lastErr = QString("Found multiple skeleton's roots (bone \"%1\"").arg(b.name);
      return false;
    }
    s.root = s.bone.size();
  }
  skipLine();
  bool hasT=false;
  bool hasR=false;
  vcg::Point3f rot;
  while (nextSetAttr()) {
    QString t =  token();
    if (t=="\".t\"") {
      if (!expectType("double3")) return false;
      b.t = readPoint()/SCALE;
      b.t.X()*=-1;
      b.t.Y()*=-1;
      if (b.attach==-1) { float tmp=b.t[1]; b.t[1]=b.t[2]; b.t[2]=tmp;}
      hasT=true;
      //b.t*=3.0;
    }
    if (t=="\".r\"") {
      if (!expectType("double3")) return false;
      rot = readPointRot();
      //rot[2]*=-1;
      hasR=true;
    }
    if (t=="\".bps\"") {
      qDebug("bps");
      if (!expectType("matrix")) return false;


      for (int i=0; i<4; i++) {
        float a,b,c,d;
        a = readFloat();b = readFloat();c = readFloat();d = readFloat();
        qDebug("%7.2f %7.2f %7.2f %7.2f",a,b,c,d);
      }
    }
    if (t=="\".s\"") {
      if (!expectType("double3")) return false;
      if (b.attach==-1) globalScale = readPointRot();
    }
    skipLine();
  }
  if (!hasT) {lastErr=QString("No translation found for bone '%1'").arg(b.name); return false; };
  if (!hasR) {lastErr=QString("No rotation found for bone '%1'").arg(b.name); return false; };
  s.bone.push_back(b);
  int i = s.bone.size()-1;
  s.setRotationMatrix( euler2matrix(&(rot[0])) , i );
  s.BuildTree();
  vector<Matrix44f> v = s.GetBoneMatrices();
      qDebug("Versus:");
      Matrix44f m = v[i]; //s.getRotationMatrix(i);
      for (int i=0; i<4; i++) {
        qDebug("%7.2f %7.2f %7.2f %7.2f",m[0][i],m[1][i],m[2][i],m[3][i]);
      }
      //qDebug("T: %7.2f %7.2f  %7.2f ",b.t[0],b.t[1],b.t[2]);
      qDebug("-----------");
  qDebug()<< "[" << i << "]: abc" << rot[0]*180/M_PI << rot[1]*180/M_PI <<rot[2]*180/M_PI <<"\n";
  return true;
}
Ejemplo n.º 2
0
void IoOBJ::writeHitbox(QFile &/*f*/, const BrfBody& b, const BrfSkeleton& s){
  assert(b.part.size()==s.bone.size());
  std::vector<vcg::Matrix44f> v = s.GetBoneMatrices();
  //s.getRotationMatrix(0)
}