Example #1
0
void BasicMesh::initObj(const ObjLoader &obj) {
  _attribute.clear();
  _element.clear();

  // initialisation de _attribute :
  // - obj.nbFace() = nombre de triangles
  // - obj.positionVertex(i,j) = position du j-ème sommet dans le i-ème triangle (de type Vector3)
  // - obj.normalVertex(i,j) = normale du j-ème sommet dans le i-ième triangle (de type Vector3)
  for(unsigned int i=0;i<obj.nbFace();++i) {
    for(unsigned int j=0;j<3;++j) {
        _attribute.push_back(obj.positionVertex(i,j).x());
        _attribute.push_back(obj.positionVertex(i,j).y());
        _attribute.push_back(obj.positionVertex(i,j).z());

        _attribute.push_back(obj.normalVertex(i,j).x());
        _attribute.push_back(obj.normalVertex(i,j).y());
        _attribute.push_back(obj.normalVertex(i,j).z());

        //_attribute.push_back(obj.normalVertex(i,j).x()+1*0.5);
        //_attribute.push_back(obj.normalVertex(i,j).y()+1*0.5);
        //_attribute.push_back(obj.normalVertex(i,j).z()+1*0.5);
    }
  }


}
Example #2
0
void BasicMesh::initObj(const ObjLoader &obj) {
  _attribute.clear();
  _element.clear();
  Vector3 pos;
  Vector3 norm;

  //Q17
  // initialisation de _attribute :
  // - obj.nbFace() = nombre de triangles
  // - obj.positionVertex(i,j) = position du j-ème sommet dans le i-ème triangle (de type Vector3)
  // - obj.normalVertex(i,j) = normale du j-ème sommet dans le i-ième triangle (de type Vector3)
  for(unsigned int i=0;i<obj.nbFace();++i) {
    for(unsigned int j=0;j<3;++j) {
        pos = obj.positionVertex(i, j);
        _attribute.push_back(pos.x());
        _attribute.push_back(pos.y());
        _attribute.push_back(pos.z());

        norm = obj.normalVertex(i, j);
        _attribute.push_back(norm.x());
        _attribute.push_back(norm.y());
        _attribute.push_back(norm.z());

        //Q18
/*
        norm = obj.normalVertex(i, j);
        _attribute.push_back((norm.x() + 1.) / 2.);
        _attribute.push_back((norm.y() + 1.) / 2.);
        _attribute.push_back((norm.z() + 1.) / 2.);
*/
    }
  }


}