2008-06-17 02:46:39 +02:00
|
|
|
#ifndef __MODEL_H
|
|
|
|
#define __MODEL_H
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <SDL_opengl.h>
|
|
|
|
#include "../punkt3d.h"
|
|
|
|
#include "../punkt2d.h"
|
2008-08-10 17:14:54 +02:00
|
|
|
#include "../color.h"
|
2008-06-17 02:46:39 +02:00
|
|
|
#include "../quader.h"
|
|
|
|
|
2008-08-10 17:14:54 +02:00
|
|
|
namespace segl {
|
|
|
|
|
2008-06-17 02:46:39 +02:00
|
|
|
class Meshpoint {
|
|
|
|
public:
|
|
|
|
Meshpoint();
|
|
|
|
Meshpoint(Punkt3D v, Punkt2D vt);
|
|
|
|
void set(Punkt3D v, Punkt2D vt);
|
|
|
|
void use();
|
|
|
|
|
|
|
|
Punkt3D vertex;
|
|
|
|
Punkt2D texcoord;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Material {
|
|
|
|
public:
|
|
|
|
Material();
|
2008-08-10 17:14:54 +02:00
|
|
|
Material(std::string _name, Color _a, Color _d, Color _s);
|
|
|
|
void set(std::string _name, Color _a, Color _d, Color _s);
|
2008-06-17 02:46:39 +02:00
|
|
|
void use();
|
|
|
|
|
|
|
|
std::string name;
|
2008-08-10 17:14:54 +02:00
|
|
|
Color ambient, diffuse, specular;
|
2008-06-17 02:46:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class Polygonpoint {
|
|
|
|
public:
|
|
|
|
Polygonpoint();
|
|
|
|
void use();
|
|
|
|
Punkt3D *point;
|
|
|
|
Punkt2D *tex;
|
|
|
|
Punkt3D *normal;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Meshpolygon {
|
|
|
|
public:
|
|
|
|
Meshpolygon();
|
|
|
|
Meshpolygon(Meshpoint *a, Meshpoint *b, Meshpoint *c);
|
|
|
|
void set(Meshpoint *a, Meshpoint *b, Meshpoint *c);
|
|
|
|
void render(GLenum mode=GL_TRIANGLES);
|
|
|
|
|
|
|
|
Polygonpoint m1, m2, m3;
|
|
|
|
Meshpoint *a, *b, *c;
|
|
|
|
Material *mat;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Model {
|
|
|
|
friend class Modelloader;
|
|
|
|
friend class LoadOBJ;
|
|
|
|
private:
|
|
|
|
bool loaded;
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int meshdataanz;
|
|
|
|
unsigned int polydataanz;
|
|
|
|
unsigned int matdataanz;
|
|
|
|
unsigned int texdataanz;
|
|
|
|
unsigned int normdataanz;
|
|
|
|
|
|
|
|
Punkt3D *meshdata;
|
|
|
|
Meshpolygon *polydata;
|
|
|
|
Material *matdata;
|
|
|
|
|
|
|
|
Punkt2D *texdata;
|
|
|
|
Punkt3D *normdata;
|
|
|
|
|
|
|
|
Material backupmat;
|
|
|
|
|
|
|
|
Quader boundingbox;
|
|
|
|
float boundingrad;
|
|
|
|
public:
|
|
|
|
Model();
|
|
|
|
~Model();
|
|
|
|
bool isLoaded();
|
|
|
|
void unload();
|
|
|
|
void render();
|
|
|
|
|
|
|
|
Quader getBoundingBox() { return boundingbox; }
|
|
|
|
float getBoundingRadius() { return boundingrad; }
|
2008-06-20 04:09:23 +02:00
|
|
|
|
|
|
|
const Punkt3D* getMeshData(unsigned int *meshanz);
|
2008-06-17 02:46:39 +02:00
|
|
|
};
|
|
|
|
|
2008-08-10 17:14:54 +02:00
|
|
|
} // namespace segl
|
|
|
|
|
2008-06-17 02:46:39 +02:00
|
|
|
#endif
|