added getPolygonData + fixed some consts

master
seba 14 years ago
parent 046e032175
commit 9b0eabe455

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

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

Loading…
Cancel
Save