You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
1.6 KiB

#ifndef __MODEL_H
#define __MODEL_H
#include <iostream>
#include <SDL_opengl.h>
#include "../punkt3d.h"
#include "../punkt2d.h"
#include "../glcolor.h"
#include "../quader.h"
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, GLColor _a, GLColor _d, GLColor _s);
void set(std::string _name, GLColor _a, GLColor _d, GLColor _s);
void use();
std::string name;
GLColor 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() { return boundingbox; }
float getBoundingRadius() { return boundingrad; }
};
#endif