libsegl/model/model.h

96 lines
1.7 KiB
C++

#ifndef __MODEL_H
#define __MODEL_H
#include <iostream>
#include <SDL_opengl.h>
#include "../punkt3d.h"
#include "../punkt2d.h"
#include "../color.h"
#include "../quader.h"
namespace segl {
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();
Material(std::string _name, Color _a, Color _d, Color _s);
void set(std::string _name, Color _a, Color _d, Color _s);
void use();
std::string name;
Color ambient, diffuse, specular;
};
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() const { return boundingbox; }
float getBoundingRad() const { return boundingrad; }
const Punkt3D* getMeshData(unsigned int *meshanz) const;
};
} // namespace segl
#endif