thecplusplusguy

Smooth normals - objloader.h

Aug 31st, 2011
2,025
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.46 KB | None | 0 0
  1. //http://www.youtube.com/user/thecplusplusguy
  2. #include <SDL/SDL.h>
  3. #include <GL/gl.h>
  4. #include <GL/glu.h>
  5. #include <cstdlib>
  6. #include <vector>
  7. #include <string>
  8. #include <algorithm>
  9. #include <fstream>
  10. #include <cstdio>
  11. #include <iostream>
  12. #include <cmath>
  13. #ifndef OBJLOADER_H
  14. #define OBJLOADER_H
  15.  
  16. struct coordinate{
  17.     float x,y,z;
  18.     coordinate(float a,float b,float c);
  19. };
  20.  
  21. struct face{
  22.     int facenum;
  23.     bool four;
  24.     int faces[4];
  25.     int texcoord[4];
  26.     int mat;
  27.     face(int facen,int f1,int f2,int f3,int t1,int t2,int t3,int m);
  28.     face(int facen,int f1,int f2,int f3,int f4,int t1,int t2,int t3,int t4,int m);
  29. };
  30.  
  31. struct material{
  32.     std::string name;
  33.     float alpha,ns,ni;
  34.     float dif[3],amb[3],spec[3];
  35.     int illum;
  36.     int texture;
  37.     material(const char* na,float al,float n,float ni2,float* d,float* a,float* s,int i,int t);
  38. };
  39.  
  40. struct texcoord{
  41.     float u,v;
  42.     texcoord(float a,float b);
  43. };
  44.  
  45. class objloader{
  46.     std::vector<std::string*> coord;
  47.     std::vector<coordinate*> vertex;
  48.     std::vector<face*> faces;
  49.     std::vector<coordinate*> normals;
  50.     std::vector<unsigned int> texture;
  51.     std::vector<unsigned int> lists;
  52.     std::vector<material*> materials;
  53.     std::vector<texcoord*> texturecoordinate;
  54.     std::vector<coordinate*> vertexnormals;
  55.     bool ismaterial,isnormals,istexture,isvertexnormal;
  56.     unsigned int loadTexture(const char* filename);
  57.     void clean();
  58.     void smoothnormals();
  59.     public:
  60.     objloader();
  61.     ~objloader();
  62.     int load(const char* filename);
  63. };
  64.  
  65. #endif
Advertisement
Add Comment
Please, Sign In to add comment