Advertisement
Guest User

ASEModel.h

a guest
May 27th, 2011
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.29 KB | None | 0 0
  1. /*
  2. ===============================================================================
  3. File:       ASEModel.h
  4. Author:     Clinton Freeman
  5. Created:    May 8, 2011
  6. ===============================================================================
  7. */
  8.  
  9. #ifndef ASEMODEL_H_
  10. #define ASEMODEL_H_
  11.  
  12. #include <headers/Common.h>
  13. #include <headers/Vector3.h>
  14.  
  15. #include <ostream>
  16. #include <vector>
  17.  
  18. using std::vector;
  19. using std::string;
  20. using std::iterator;
  21.  
  22. namespace E3D
  23. {
  24.  
  25. struct Parsable
  26. {
  27.     virtual ~Parsable() {}
  28.     virtual void parse(vector<string>::iterator& tokenItr) = 0;
  29. };
  30.  
  31. struct ASEVertex : public Parsable
  32. {
  33.     unsigned int id;
  34.     Vector3 coords;
  35.  
  36.     virtual void parse(vector<string>::iterator& tokenItr);
  37.     friend std::ostream& operator <<(std::ostream& o, const ASEVertex& v);
  38. };
  39.  
  40. // these are all exactly the same
  41. typedef ASEVertex ASETVertex;
  42. typedef ASEVertex ASECVertex;
  43. typedef ASEVertex ASENormal;
  44.  
  45. struct ASEFace : public Parsable
  46. {
  47.     unsigned int id;
  48.     unsigned int A, B, C, AB, BC, CA, meshMtlID;
  49.     int meshSmoothing; // this can be empty, so we need -1 as a flag for that
  50.  
  51.     virtual void parse(vector<string>::iterator& tokenItr);
  52.     friend std::ostream& operator <<(std::ostream& o, const ASEFace& f);
  53. };
  54.  
  55. struct ASETFace : public Parsable
  56. {
  57.     unsigned int id;
  58.     unsigned int A, B, C;
  59.  
  60.     virtual void parse(vector<string>::iterator& tokenItr);
  61.     friend std::ostream& operator <<(std::ostream& o, const ASETFace& tf);
  62. };
  63.  
  64. // these are the same, just arbitrarily chose one to be the struct and one
  65. // to be the typedef
  66. typedef ASETFace ASECFace;
  67.  
  68. struct ASEMesh : public Parsable
  69. {
  70.     unsigned int timeValue;
  71.     unsigned int numVertex, numFaces, numTVertex, numTVFaces, numCVertex,
  72.                  numCVFaces;
  73.  
  74.     vector<ASEVertex> vertexList;
  75.     vector<ASEFace> faceList;
  76.     vector<ASECVertex> cVertexList;
  77.     vector<ASECFace> cFaceList;
  78.     vector<ASETVertex> tVertexList;
  79.     vector<ASETFace> tFaceList;
  80.     vector<ASENormal> faceNormals;
  81.     vector<ASENormal> vertexNormals;
  82.  
  83.     virtual void parse(vector<string>::iterator& tokenItr);
  84.     friend std::ostream& operator <<(std::ostream& o, const ASEMesh& m);
  85. };
  86.  
  87. struct ASENodeTM : public Parsable
  88. {
  89.     string nodeName;
  90.     Vector3 inheritPos, inheritRot, inheritScl;
  91.     Vector3 tmRow0, tmRow1, tmRow2, tmRow3, tmPos, tmRotAxis;
  92.     float tmRotAngle;
  93.     Vector3 tmScale, tmScaleAxis;
  94.     float tmScaleAxisAng;
  95.  
  96.     virtual void parse(vector<string>::iterator& tokenItr);
  97.     friend std::ostream& operator <<(std::ostream& o, const ASENodeTM& n);
  98. };
  99.  
  100. struct ASEGeomObject : public Parsable
  101. {
  102.     string nodeName;
  103.     ASENodeTM nodeTM;
  104.     ASEMesh mesh;
  105.  
  106.     unsigned int propMotionBlur, propCastShadow, propRecvShadow;
  107.     unsigned int materialRef;
  108.  
  109.     virtual void parse(vector<string>::iterator& tokenItr);
  110.     friend std::ostream& operator <<(std::ostream& o, const ASEGeomObject& go);
  111. };
  112.  
  113. struct ASEMap : public Parsable
  114. {
  115.     typedef enum // supposedly this is the same as just doing enum NAME {};
  116.     {
  117.         MAP_DIFFUSE,
  118.         MAP_SPECULAR,
  119.         MAP_SHINE,
  120.         MAP_SHINESTRENGTH,
  121.         MAP_SELFILLUM,
  122.         MAP_OPACITY,
  123.         MAP_FILTERCOLOR,
  124.         MAP_BUMP,
  125.         MAP_REFLECT,
  126.         MAP_REFRACT
  127.     }
  128.     ASEMapFunc; // named this one func because type and class were taken!
  129.  
  130.     ASEMapFunc mapFunc;
  131.     string name, mapClass;
  132.     unsigned int subno;
  133.     float amount;
  134.     string bitmap;
  135.     string type; // TODO: enum this bad boy
  136.     float uvwUOffset, uvwVOffset, uvwUTiling, uvwVTiling, uvwAngle, uvwBlur,
  137.           uvwBlurOffset, uvwNoiseAmt, uvwNoiseSize, uvwNoisePhase;
  138.     // !IMPORTANT! typo in exporter, "uvwNouseAmt"
  139.     int uvwNoiseLevel;
  140.     string bitmapFilter; // TODO: enum again
  141.  
  142.     virtual void parse(vector<string>::iterator& tokenItr);
  143.     friend std::ostream& operator <<(std::ostream& o, const ASEMap& m);
  144. };
  145.  
  146. struct ASEMaterial : public Parsable
  147. {
  148.     string name;
  149.     string matClass;
  150.     RGB ambient, diffuse, specular;
  151.     float shine, shineStrength, transparency, wireSize;
  152.  
  153.     unsigned int numSubMtls; // this will only be there if there are actually
  154.                              // submtls?
  155.     vector<ASEMaterial> subMaterials;
  156.  
  157.     // the following could be missing if submaterials are present?
  158.     string shading; // TODO: probably make this into an enum
  159.     float xpFalloff, selfIllum;
  160.     string falloff; // TODO: this one too..
  161.     string xpType; // TODO: ...and this one
  162.  
  163.     vector<ASEMap> maps;
  164.  
  165.     virtual void parse(vector<string>::iterator& tokenItr);
  166.     friend std::ostream& operator <<(std::ostream& o, const ASEMaterial& m);
  167. };
  168.  
  169. struct ASEMaterialList : public Parsable
  170. {
  171.     unsigned int materialCount;
  172.     vector<ASEMaterial> materials;
  173.  
  174.     virtual void parse(vector<string>::iterator& tokenItr);
  175.     friend std::ostream& operator <<(std::ostream& o, const ASEMaterialList& m);
  176. };
  177.  
  178. struct ASEScene : public Parsable
  179. {
  180.     string filename;
  181.     unsigned int firstFrame, lastFrame, frameSpeed, ticksPerFrame;
  182.     RGB backgroundStatic, ambientStatic;
  183.  
  184.     virtual void parse(vector<string>::iterator& tokenItr);
  185.     friend std::ostream& operator <<(std::ostream& o, const ASEScene& s);
  186. };
  187.  
  188. struct ASEModel : public Parsable
  189. {
  190.     unsigned int exportVersion;
  191.     string comment;
  192.  
  193.     ASEScene scene;
  194.     ASEMaterialList materialList;
  195.     vector<ASEGeomObject> geomObjects;
  196.  
  197.     vector<string>::iterator lastToken;
  198.  
  199.     ASEModel(string filename);
  200.  
  201.     virtual void parse(vector<string>::iterator& tokenItr);
  202.     friend std::ostream& operator <<(std::ostream& o, const ASEModel& m);
  203. };
  204.  
  205. }
  206.  
  207. #endif /* ASEMODEL_H_ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement