Advertisement
maspeir

OBJ Loader.h

Dec 10th, 2012
1,134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.65 KB | None | 0 0
  1. #ifndef __OBJ_LOADER__
  2. #define __OBJ_LOADER__
  3.  
  4. #include <vector>
  5. #include <string>
  6. #include <iostream>
  7. #include <fstream>
  8. #include <sstream>
  9.  
  10. using namespace std;
  11.  
  12. class OBJ_vertex{
  13. public:
  14.     OBJ_vertex(){}
  15.     ~OBJ_vertex(){}
  16.  
  17.     float GetX() const {return(x);}
  18.     void SetX(float _x) {x = _x;}
  19.  
  20.     float GetY() const {return(y);}
  21.     void SetY(float _y) {y = _y;}
  22.  
  23.     float GetZ() const {return(z);}
  24.     void SetZ(float _z) {z = _z;}
  25.  
  26. private:
  27.     float   x;
  28.     float   y;
  29.     float   z;
  30. };
  31.  
  32. class uv_coords{
  33. public:
  34.     uv_coords(){}
  35.     ~uv_coords(){}
  36.  
  37.     float GetU() const {return(u);}
  38.     void SetU(float _u) {u = _u;}
  39.  
  40.     float GetV() const {return(v);}
  41.     void SetV(float _v) {v = _v;}
  42.  
  43. private:
  44.     float   u;
  45.     float   v;
  46. };
  47.  
  48. class face{
  49. public:
  50.     face();
  51.     face(const face &right);
  52.     ~face();
  53.  
  54.     long GetNumVertices() const;
  55.     long GetNumNormals() const;
  56.     long GetNumUVs() const;
  57.  
  58.     void AddVertex(long index);
  59.     long GetVertex(long index) const;
  60.  
  61.     void AddNormal(long index);
  62.     long GetNormal(long index) const;
  63.  
  64.     void AddUV(long index);
  65.     long GetUV(long index) const;
  66.  
  67. private:
  68.     vector<long>        *vertices;
  69.     vector<long>        *normals;
  70.     vector<long>        *uv;
  71. };
  72.  
  73. class OBJ{
  74. public:
  75.     OBJ();
  76.     ~OBJ();
  77.  
  78.     long GetNumVertices() const;
  79.     long GetNumNormals() const;
  80.     long GetNumUVs() const;
  81.     long GetNumFaces() const;
  82.  
  83.     OBJ_vertex *GetVertex(long index) const;
  84.     OBJ_vertex *GetNormal(long index) const;
  85.     uv_coords *GetUV(long index) const;
  86.     face *GetFace(long index) const;
  87.  
  88.     void LoadOBJ(string file_name);
  89.     void DumpOBJ(void);
  90.  
  91. private:
  92.     vector<OBJ_vertex>  *vertices;
  93.     vector<OBJ_vertex>  *normals;
  94.     vector<uv_coords>   *uv;
  95.     vector<face>        *faces;
  96. };
  97.  
  98. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement