Browse Source

added getPolygonData + fixed some consts

seba 9 years ago
parent
commit
9b0eabe455
2 changed files with 21 additions and 13 deletions
  1. 14
    7
      model/model.cpp
  2. 7
    6
      model/model.h

+ 14
- 7
model/model.cpp View File

@@ -18,7 +18,7 @@ void Meshpoint::set(Punkt3D v, Punkt2D vt) {
18 18
 // 	normal = n;
19 19
 }
20 20
 
21
-void Meshpoint::use() {
21
+void Meshpoint::use() const {
22 22
 	glTexCoordP2D(texcoord);
23 23
 // 	glNormalP3D(normal);
24 24
 	glVertexP3D(vertex);
@@ -44,7 +44,7 @@ void Material::set(std::string _name, Color _a, Color _d, Color _s) {
44 44
 	specular = _s;
45 45
 }
46 46
 
47
-void Material::use() {
47
+void Material::use() const {
48 48
 	glColorGLC(diffuse);
49 49
 }
50 50
 
@@ -55,7 +55,7 @@ Polygonpoint::Polygonpoint() {
55 55
 	normal = 0;
56 56
 }
57 57
 
58
-void Polygonpoint::use() {
58
+void Polygonpoint::use() const {
59 59
 	if(normal)
60 60
 		glNormalP3D(*normal);
61 61
 	if(tex)
@@ -80,7 +80,7 @@ void Meshpolygon::set(Meshpoint *_a, Meshpoint *_b, Meshpoint *_c) {
80 80
 	c = _c;	
81 81
 }
82 82
 
83
-void Meshpolygon::render(GLenum mode) {
83
+void Meshpolygon::render(GLenum mode) const {
84 84
 // 	if(!a || !b || !c)
85 85
 // 		return;
86 86
 	
@@ -113,7 +113,7 @@ Model::Model() {
113 113
 	backupmat.diffuse.set(1.0f, 1.0f, 1.0f);
114 114
 }
115 115
 
116
-bool Model::isLoaded() {
116
+bool Model::isLoaded() const {
117 117
 	return loaded;
118 118
 }
119 119
 
@@ -137,7 +137,7 @@ void Model::unload() {
137 137
 	loaded = false;
138 138
 }
139 139
 
140
-void Model::render() {
140
+void Model::render() const {
141 141
 	if(!loaded) {
142 142
 // 		std::cout << "Model not loaded" << std::endl;
143 143
 		return;
@@ -157,8 +157,15 @@ Model::~Model() {
157 157
 }
158 158
 
159 159
 const Punkt3D* Model::getMeshData(unsigned int *meshanz) const {
160
-	*meshanz = meshdataanz;
160
+	if(meshanz != 0)
161
+		*meshanz = meshdataanz;
161 162
 	return (const Punkt3D*)meshdata;
162 163
 }
163 164
 
165
+const Meshpolygon* Model::getPolygonData(unsigned int *polyanz) const {
166
+	if(polyanz != 0)
167
+		*polyanz = polydataanz;
168
+	return (const Meshpolygon*)polydata;
169
+}
170
+
164 171
 } // namespace segl

+ 7
- 6
model/model.h View File

@@ -15,7 +15,7 @@ class Meshpoint {
15 15
 		Meshpoint();
16 16
 		Meshpoint(Punkt3D v, Punkt2D vt);
17 17
 		void set(Punkt3D v, Punkt2D vt);
18
-		void use();
18
+		void use() const;
19 19
 		
20 20
 		Punkt3D vertex;
21 21
 		Punkt2D texcoord;
@@ -26,7 +26,7 @@ class Material {
26 26
 		Material();
27 27
 		Material(std::string _name, Color _a, Color _d, Color _s);
28 28
 		void set(std::string _name, Color _a, Color _d, Color _s);
29
-		void use();
29
+		void use() const;
30 30
 		
31 31
 		std::string name;
32 32
 		Color ambient, diffuse, specular;
@@ -35,7 +35,7 @@ class Material {
35 35
 class Polygonpoint {
36 36
 	public:
37 37
 		Polygonpoint();
38
-		void use();
38
+		void use() const;
39 39
 		Punkt3D *point;
40 40
 		Punkt2D *tex;
41 41
 		Punkt3D *normal;
@@ -46,7 +46,7 @@ class Meshpolygon {
46 46
 		Meshpolygon();
47 47
 		Meshpolygon(Meshpoint *a, Meshpoint *b, Meshpoint *c);
48 48
 		void set(Meshpoint *a, Meshpoint *b, Meshpoint *c);
49
-		void render(GLenum mode=GL_TRIANGLES);
49
+		void render(GLenum mode=GL_TRIANGLES) const;
50 50
 		
51 51
 		Polygonpoint m1, m2, m3;
52 52
 		Meshpoint *a, *b, *c;
@@ -80,14 +80,15 @@ class Model {
80 80
 	public:
81 81
 		Model();
82 82
 		~Model();
83
-		bool isLoaded();
83
+		bool isLoaded() const;
84 84
 		void unload();
85
-		void render();
85
+		void render() const;
86 86
 		
87 87
 		Quader getBoundingBox() const { return boundingbox; }
88 88
 		float getBoundingRad() const { return boundingrad; }
89 89
 		
90 90
 		const Punkt3D* getMeshData(unsigned int *meshanz) const;
91
+		const Meshpolygon* getPolygonData(unsigned int *polyanz) const;
91 92
 };
92 93
 
93 94
 } // namespace segl

Loading…
Cancel
Save