| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #pragma once
- #include <GL/freeglut.h>
- #include <list>
- #include <vector>
- #include <map>
- #include "vector.h"
- class Model
- {
- private:
- class Vertex
- {
- public:
- int position;
- int normal;
- int texcoord;
- };
- class Face
- {
- public:
- std::list<Vertex> vertices;
- };
- class Texture
- {
- GLuint index;
- public:
- Texture(const std::string &fileName);
- void bind();
- };
- class MaterialInfo
- {
- public:
- MaterialInfo();
- std::string name;
- Texture* texture;
- bool hasTexture;
- bool hasDiffuse;
- Vec3f diffuseColor;
- bool hasAmbient;
- Vec3f ambientColor;
- bool hasSpecular;
- Vec3f specularColor;
- };
- class ObjGroup
- {
- public:
- std::string name;
- int materialIndex;
- std::list<Face> faces;
- };
- std::vector<Vec3f> vertices;
- std::vector<Vec3f> normals;
- std::vector<Vec2f> texcoords;
- std::vector<ObjGroup*> groups;
- std::vector<MaterialInfo*> materials;
- void loadMaterialFile(std::string fileName, std::string dirName);
- Model(std::string filename);
- ~Model(void);
- public:
- static std::map<std::string, std::pair<Model*, int> > cache;
- static Model* load(const std::string &fileName);
- static void unload(const std::string &fileName);
- void draw();
- };
|