home *** CD-ROM | disk | FTP | other *** search
- #ifndef __Ac3dLoader_h__
- #define __Ac3dLoader_h__
-
- /*!
- \file Ac3dloader.h
- \author Karsten Schwenk
- \version 1.0
-
- \brief This file contains the function #loadAC3D() that loads an ac3d file into my #Model class.
-
- The only thing you need is the function #loadAC3D(). The other stuff was copied from an older project and isn't really nice code.
-
- */
-
-
- #include <stdio.h>
- #include <stdlib.h>
- /*
- #ifdef WIN32
- #include <Windows.h>
- #endif
-
- #include <GL/gl.h>
- #include <GL/glu.h>
-
- #include "Texture.h"
- #include "Model.h"
- */
- #define OBJECT_WORLD 999
- #define OBJECT_NORMAL 0
- #define OBJECT_GROUP 1
- #define OBJECT_LIGHT 2
-
-
- #define SURFACE_TYPE_POLYGON 0x0000
- #define SURFACE_TYPE_CLOSEDLINE 0x0001
- #define SURFACE_TYPE_LINE 0x0002
- #define SURFACE_SHADED (1<<4)
- #define SURFACE_TWOSIDED (1<<5)
-
-
- class Ac3dMaterial;
- class Ac3dSurface;
- class Ac3dObject;
-
-
- class Ac3dMaterial{
- public:
- int tokc;
- char *tokv[30];
-
- char *name;
- float ambient[4];
- float diffuse[4];
- float specular[4];
- float emissive[4];
- float shininess;
- float transparency;
-
- Ac3dMaterial(char *buff); // matInfo aus buff lesen
- };
-
- class Ac3dSurface{
- public:
- Ac3dObject *ob;
- int mat; //Ac3dMaterial *mat;
- int flags;
- unsigned int *indices;
- int nIndices;
- float normal[3];
- float *texCoords;
-
- Ac3dSurface(Ac3dObject *object);
- void calcNormal();
- };
-
- class Ac3dObject{
- public:
- int type;
- char *name;
- Ac3dMaterial **mat;
- Ac3dSurface **surf;
- Ac3dObject **kids;
- char* texture;
- float *v;
- float *n;
- float *texCoords, texOffsX,texOffsY, texRepeatX,texRepeatY;
- unsigned int **indices;
- int *nIndices;
- int nV, nN, nMat, nSurf, nKids;
- float rotMatrix[9];
- float loc[3];
-
- int line;
- char buff[256];
- int tokc;
- char *tokv[30];
-
- bool hasTextures;
-
- Ac3dObject(const char *file);
- Ac3dObject(FILE *f, int *l, Ac3dObject *parent);
- void clearObject();
- void addMaterial(Ac3dMaterial *m);
- void readLine(FILE *f);
- Ac3dSurface *readSurface(FILE *f);
- void calcNormals();
- bool readFromFile(FILE *f);
- void dumpObject();
-
- };
-
- class Ac3dLoader{
- public:
- //! loads an ac3d file into a #Model object
- static bool loadAC3D(const char* filename, Model* model);
-
- protected:
- static Mesh* Ac3dObjectToMesh(Ac3dObject* o);
- };
-
-
- #endif /* __Ac3dLoader_h__ */
-