added getPolygonData + fixed some consts

This commit is contained in:
seba 2010-04-07 03:02:05 +02:00
parent 046e032175
commit 9b0eabe455
2 changed files with 21 additions and 13 deletions

View File

@ -18,7 +18,7 @@ void Meshpoint::set(Punkt3D v, Punkt2D vt) {
// normal = n;
}
void Meshpoint::use() {
void Meshpoint::use() const {
glTexCoordP2D(texcoord);
// glNormalP3D(normal);
glVertexP3D(vertex);
@ -44,7 +44,7 @@ void Material::set(std::string _name, Color _a, Color _d, Color _s) {
specular = _s;
}
void Material::use() {
void Material::use() const {
glColorGLC(diffuse);
}
@ -55,7 +55,7 @@ Polygonpoint::Polygonpoint() {
normal = 0;
}
void Polygonpoint::use() {
void Polygonpoint::use() const {
if(normal)
glNormalP3D(*normal);
if(tex)
@ -80,7 +80,7 @@ void Meshpolygon::set(Meshpoint *_a, Meshpoint *_b, Meshpoint *_c) {
c = _c;
}
void Meshpolygon::render(GLenum mode) {
void Meshpolygon::render(GLenum mode) const {
// if(!a || !b || !c)
// return;
@ -113,7 +113,7 @@ Model::Model() {
backupmat.diffuse.set(1.0f, 1.0f, 1.0f);
}
bool Model::isLoaded() {
bool Model::isLoaded() const {
return loaded;
}
@ -137,7 +137,7 @@ void Model::unload() {
loaded = false;
}
void Model::render() {
void Model::render() const {
if(!loaded) {
// std::cout << "Model not loaded" << std::endl;
return;
@ -157,8 +157,15 @@ Model::~Model() {
}
const Punkt3D* Model::getMeshData(unsigned int *meshanz) const {
if(meshanz != 0)
*meshanz = meshdataanz;
return (const Punkt3D*)meshdata;
}
const Meshpolygon* Model::getPolygonData(unsigned int *polyanz) const {
if(polyanz != 0)
*polyanz = polydataanz;
return (const Meshpolygon*)polydata;
}
} // namespace segl

View File

@ -15,7 +15,7 @@ class Meshpoint {
Meshpoint();
Meshpoint(Punkt3D v, Punkt2D vt);
void set(Punkt3D v, Punkt2D vt);
void use();
void use() const;
Punkt3D vertex;
Punkt2D texcoord;
@ -26,7 +26,7 @@ class Material {
Material();
Material(std::string _name, Color _a, Color _d, Color _s);
void set(std::string _name, Color _a, Color _d, Color _s);
void use();
void use() const;
std::string name;
Color ambient, diffuse, specular;
@ -35,7 +35,7 @@ class Material {
class Polygonpoint {
public:
Polygonpoint();
void use();
void use() const;
Punkt3D *point;
Punkt2D *tex;
Punkt3D *normal;
@ -46,7 +46,7 @@ class Meshpolygon {
Meshpolygon();
Meshpolygon(Meshpoint *a, Meshpoint *b, Meshpoint *c);
void set(Meshpoint *a, Meshpoint *b, Meshpoint *c);
void render(GLenum mode=GL_TRIANGLES);
void render(GLenum mode=GL_TRIANGLES) const;
Polygonpoint m1, m2, m3;
Meshpoint *a, *b, *c;
@ -80,14 +80,15 @@ class Model {
public:
Model();
~Model();
bool isLoaded();
bool isLoaded() const;
void unload();
void render();
void render() const;
Quader getBoundingBox() const { return boundingbox; }
float getBoundingRad() const { return boundingrad; }
const Punkt3D* getMeshData(unsigned int *meshanz) const;
const Meshpolygon* getPolygonData(unsigned int *polyanz) const;
};
} // namespace segl