From 9b0eabe455a36177baf03acf811d347ad7140a2e Mon Sep 17 00:00:00 2001 From: seba Date: Wed, 7 Apr 2010 03:02:05 +0200 Subject: [PATCH] added getPolygonData + fixed some consts --- model/model.cpp | 21 ++++++++++++++------- model/model.h | 13 +++++++------ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/model/model.cpp b/model/model.cpp index 951a847..b68e367 100644 --- a/model/model.cpp +++ b/model/model.cpp @@ -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 { - *meshanz = meshdataanz; + 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 diff --git a/model/model.h b/model/model.h index fbdb716..ece8ef3 100644 --- a/model/model.h +++ b/model/model.h @@ -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