home *** CD-ROM | disk | FTP | other *** search
/ Enter 2005 March / ENTER.ISO / files / fwp-0.0.6-win32-installer.exe / Ac3dLoader.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-08-04  |  2.3 KB  |  124 lines

  1. #ifndef __Ac3dLoader_h__
  2. #define __Ac3dLoader_h__
  3.  
  4. /*!
  5. \file Ac3dloader.h
  6. \author Karsten Schwenk
  7. \version 1.0
  8.  
  9. \brief This file contains the function #loadAC3D() that loads an ac3d file into my #Model class.
  10.  
  11. The only thing you need is the function #loadAC3D(). The other stuff was copied from an older project and isn't really nice code.
  12.  
  13. */
  14.  
  15.  
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. /*
  19. #ifdef WIN32
  20. #include <Windows.h>
  21. #endif
  22.  
  23. #include <GL/gl.h>
  24. #include <GL/glu.h>
  25.  
  26. #include "Texture.h"
  27. #include "Model.h"
  28. */
  29. #define OBJECT_WORLD 999
  30. #define OBJECT_NORMAL 0
  31. #define OBJECT_GROUP 1
  32. #define OBJECT_LIGHT 2
  33.  
  34.  
  35. #define SURFACE_TYPE_POLYGON    0x0000
  36. #define SURFACE_TYPE_CLOSEDLINE 0x0001
  37. #define SURFACE_TYPE_LINE        0x0002
  38. #define SURFACE_SHADED            (1<<4)
  39. #define SURFACE_TWOSIDED        (1<<5)
  40.  
  41.  
  42. class Ac3dMaterial;
  43. class Ac3dSurface;
  44. class Ac3dObject;
  45.  
  46.  
  47. class Ac3dMaterial{
  48. public:
  49.     int tokc;
  50.     char *tokv[30];
  51.  
  52.     char *name;
  53.     float ambient[4];
  54.     float diffuse[4];
  55.     float specular[4];
  56.     float emissive[4];
  57.     float shininess;
  58.     float transparency;
  59.  
  60.     Ac3dMaterial(char *buff);    // matInfo aus buff lesen
  61. };
  62.  
  63. class Ac3dSurface{
  64. public:
  65.     Ac3dObject *ob;
  66.     int mat; //Ac3dMaterial *mat;
  67.     int flags;
  68.     unsigned int *indices;
  69.     int nIndices;
  70.     float normal[3];
  71.     float *texCoords;
  72.  
  73.     Ac3dSurface(Ac3dObject *object);
  74.     void calcNormal();
  75. };
  76.  
  77. class Ac3dObject{
  78. public:
  79.     int type;
  80.     char *name;
  81.     Ac3dMaterial **mat;
  82.     Ac3dSurface **surf;
  83.     Ac3dObject **kids;
  84.     char* texture;
  85.     float *v;
  86.     float *n;
  87.     float *texCoords, texOffsX,texOffsY, texRepeatX,texRepeatY;
  88.     unsigned int **indices;
  89.     int *nIndices;
  90.     int nV, nN, nMat, nSurf, nKids;
  91.     float rotMatrix[9];
  92.     float loc[3];
  93.  
  94.     int line;
  95.     char buff[256];
  96.     int tokc;
  97.     char *tokv[30];
  98.  
  99.     bool hasTextures;
  100.  
  101.     Ac3dObject(const char *file);
  102.     Ac3dObject(FILE *f, int *l, Ac3dObject *parent);
  103.     void clearObject();
  104.     void addMaterial(Ac3dMaterial *m);
  105.     void readLine(FILE *f);
  106.     Ac3dSurface *readSurface(FILE *f);
  107.     void calcNormals();
  108.     bool readFromFile(FILE *f);
  109.     void dumpObject();
  110.  
  111. };
  112.  
  113. class Ac3dLoader{
  114. public:
  115.     //! loads an ac3d file into a #Model object
  116.     static bool loadAC3D(const char* filename, Model* model);
  117.  
  118. protected:
  119.     static Mesh* Ac3dObjectToMesh(Ac3dObject* o);
  120. };
  121.  
  122.  
  123. #endif    /* __Ac3dLoader_h__ */
  124.