Browse Source

Versionskram

Neue Geotypen
seba 11 years ago
parent
commit
12d677afdb
13 changed files with 228 additions and 107 deletions
  1. 5
    3
      Makefile
  2. 1
    1
      fpsmanager.cpp
  3. 111
    20
      geotypes.cpp
  4. 30
    17
      geotypes.h
  5. 2
    2
      glgui/button.h
  6. 2
    2
      glgui/object.h
  7. 2
    2
      glgui/textlabel.h
  8. 2
    2
      glgui/window.h
  9. 1
    1
      model/loadobj.cpp
  10. 12
    0
      punkt2d.cpp
  11. 3
    0
      punkt2d.h
  12. 29
    29
      punkt3d.cpp
  13. 28
    28
      punkt3d.h

+ 5
- 3
Makefile View File

@@ -1,8 +1,8 @@
1 1
 CC = g++
2 2
 AR = ar
3
-OBJECTS = punkt3d.o punkt2d.o emath.o emath_opengl.o color.o gldrawhelper.o glfontengine.o rect.o gltexture.o matrix.o quaternion.o rotationsmatrix.o glsdlscreen.o sdlfuncs.o fpsmanager.o glcamera.o catmullromspline.o extstring.o quader.o
4
-OBJOPT = -Wall -c -DVERSION=$(VERSION) -O2 `sdl-config --cflags`
5
-WINOPT = -Wall -c -DVERSION=$(VERSION) -O2 -I/usr/i586-mingw32msvc/include -I/usr/i586-mingw32msvc/include/SDL
3
+OBJECTS = segl.o punkt3d.o punkt2d.o emath.o emath_opengl.o color.o gldrawhelper.o glfontengine.o rect.o gltexture.o matrix.o quaternion.o rotationsmatrix.o glsdlscreen.o sdlfuncs.o fpsmanager.o glcamera.o catmullromspline.o extstring.o quader.o geotypes.o
4
+OBJOPT = -Wall -c -DVERSION=\"$(VERSION)\" -O2 `sdl-config --cflags`
5
+WINOPT = -Wall -c -DVERSION=\"$(VERSION)\" -O2 -I/usr/i586-mingw32msvc/include -I/usr/i586-mingw32msvc/include/SDL
6 6
 LIBLINK = -lc -shared -Wl,-soname,$(LIBNAME).so.$(LIBVERSION)
7 7
 WINLINK = -L/usr/i586-mingw32msvc/lib /usr/i586-mingw32msvc/lib/SDL_image.lib -lmingw32 -shared -mwindows -lGL -lGLU -lSDL -lSDL_image /usr/i586-mingw32msvc/lib/SDL_image.lib /usr/i586-mingw32msvc/lib/SDL_image.dll
8 8
 SUBDIRS = glgui glmenu model
@@ -14,6 +14,8 @@ EXT = so.$(LIBVERSION)
14 14
 
15 15
 .PHONY: windows
16 16
 
17
+all: seglar lib
18
+
17 19
 seglar: $(OBJECTS) subdirs
18 20
 	rm -f $(LIBNAME).a
19 21
 	$(AR) rcs $(LIBNAME).a $(OBJECTS) $(SUBDIROBJECTS)

+ 1
- 1
fpsmanager.cpp View File

@@ -11,7 +11,7 @@ FPSManager::FPSManager(int _fps) {
11 11
 
12 12
 void FPSManager::setFPS(int _fps) {
13 13
 	if(_fps<1 || _fps > 500)
14
-		return; 
14
+		return;
15 15
 	tickrate = 1000.0f/(float)_fps;
16 16
 }
17 17
 

+ 111
- 20
geotypes.cpp View File

@@ -11,20 +11,28 @@ Sphere::Sphere() {
11 11
 	radius = 1.0f;
12 12
 }
13 13
 
14
-bool Sphere::collision(const Sphere &s) {
15
-
14
+bool Sphere::collision(const Sphere &s) const {
15
+	return ((pos-s.pos)*(pos-s.pos))<((radius+s.radius)*(radius+s.radius));
16 16
 }
17 17
 
18
-bool Sphere::collision(const Ray &r) {
19
-
18
+bool Sphere::collision(const Ray &r) const {
19
+	return true;
20 20
 }
21 21
 
22
-bool Sphere::collision(const Box & b) {
22
+bool Sphere::collision(const Box & b) const {
23
+	return true;
24
+}
23 25
 
26
+bool Sphere::collision(const Plane &p) const {
27
+	return true;
24 28
 }
25 29
 
26
-bool Sphere::collision(const Plane &p) {
30
+bool Sphere::inSphere(Punkt3D p) const {
31
+	return abs(pos-p)<=radius;
32
+}
27 33
 
34
+Punkt3D Sphere::getPos() const {
35
+	return pos;
28 36
 }
29 37
 
30 38
 Ray::Ray() {
@@ -32,17 +40,96 @@ Ray::Ray() {
32 40
 }
33 41
 
34 42
 Ray::Ray(Punkt3D _pos, Punkt3D _dir) {
43
+	set(_pos, _dir);
44
+}
45
+
46
+void Ray::set(Punkt3D _pos, Punkt3D _dir) {
35 47
 	pos = _pos;
36 48
 	dir = _dir;
37 49
 }
38 50
 
39
-bool Ray::collision(const Sphere &s) {
51
+Punkt3D Ray::get(float x) {
52
+	return pos + dir*x;
53
+}
54
+
55
+// TODO: Heavy Testing
56
+bool Ray::onRay(Punkt3D p, int rnd) {
57
+	float r1 = 0.0f, r2 = 0.0f, r3 = 0.0f;
58
+	short fcount = 0;
59
+	bool g1=true, g2=true, g3=true;
60
+	Punkt3D f = p-pos;
61
+	
62
+	if(dir.x==0.0f) {
63
+		if(f.x!=0.0f)
64
+			return false;
65
+		g1 = false;
66
+		fcount++;
67
+	} else
68
+		r1 = f.x / dir.x;
69
+		
70
+	if(dir.y==0.0f) {
71
+		if(f.y!=0.0f)
72
+			return false;
73
+		g2 = false;
74
+		fcount++;
75
+	} else
76
+		r2 = f.y / dir.y;
77
+		
78
+	if(dir.z==0.0f) {
79
+		if(f.z!=0.0f)
80
+			return false;
81
+		g2 = false;
82
+		fcount++;
83
+	} else
84
+		r2 = f.z / dir.z;
85
+	
86
+	if(fcount>=2)
87
+		return true;
88
+	
89
+	if(rnd>=0) {
90
+		// TODO:Implement rounding
91
+		// r1 = round(r1, rnd);
92
+		// r2 = round(r2, rnd);
93
+		// r3 = round(r3, rnd);
94
+	}
95
+	
96
+	if(g1)
97
+		return (r2 == r3);
98
+	else if(g2)
99
+		return (r1 == r3);
100
+	else if(g3)
101
+		return (r1 == r2);
102
+	else
103
+		return (r1 == r2 == r3);
104
+}
105
+
106
+float Ray::dist(Punkt3D p) {
107
+	return abs(p - get( getParam(p) ));
108
+}
109
+
110
+float Ray::getParam(Punkt3D p, bool onray) {
111
+	if(onray) {
112
+		if(!onRay(p))
113
+			return 0.0f;
114
+	}
115
+	return -((pos-p)*dir) / (dir*dir);
116
+}
117
+
118
+bool Ray::collision(const Sphere &s) const {
40 119
 	return s.collision(*this);
41 120
 }
42 121
 
43
-bool Ray::collision(const Ray &r);
44
-bool Ray::collision(const Box & b);
45
-bool Ray::collision(const Plane &p);
122
+bool Ray::collision(const Ray &r) const {
123
+	return true;
124
+}
125
+
126
+bool Ray::collision(const Box & b) const {
127
+	return true;
128
+}
129
+
130
+bool Ray::collision(const Plane &p) const {
131
+	return true;
132
+}
46 133
 
47 134
 Box::Box() {
48 135
 	max.set(1.0f, 1.0f, 1.0f);
@@ -53,20 +140,20 @@ Box::Box(Punkt3D _min, Punkt3D _max) {
53 140
 	max = _max;
54 141
 }
55 142
 
56
-bool Box::collision(const Sphere &s) {
143
+bool Box::collision(const Sphere &s) const {
57 144
 	return s.collision(*this);
58 145
 }
59 146
 
60
-bool Box::collision(const Ray &r) {
147
+bool Box::collision(const Ray &r) const {
61 148
 	return r.collision(*this);
62 149
 }
63 150
 
64
-bool Box::collision(const Box & b) {
65
-
151
+bool Box::collision(const Box & b) const {
152
+	return true;
66 153
 }
67 154
 
68
-bool Box::collision(const Plane &p) {
69
-
155
+bool Box::collision(const Plane &p) const {
156
+	return true;
70 157
 }
71 158
 
72 159
 Plane::Plane() {
@@ -84,20 +171,24 @@ Plane::Plane(float x, float y, float z, float a) {
84 171
 	norm.normalize();
85 172
 }
86 173
 
87
-bool Plane::collision(const Sphere &s) {
174
+bool Plane::collision(const Sphere &s) const {
88 175
 	return s.collision(*this);
89 176
 }
90 177
 
91
-bool Plane::collision(const Ray &r) {
178
+bool Plane::collision(const Ray &r) const {
92 179
 	return r.collision(*this);
93 180
 }
94 181
 
95
-bool Plane::collision(const Box & b) {
182
+bool Plane::collision(const Box & b) const {
96 183
 	return b.collision(*this);
97 184
 }
98 185
 
99
-bool Plane::collision(const Plane &p) {
186
+bool Plane::collision(const Plane &p) const {
187
+	return true;
188
+}
100 189
 
190
+float Plane::dist(Punkt3D p) const {
191
+	
101 192
 }
102 193
 
103 194
 } // namespace segl

+ 30
- 17
geotypes.h View File

@@ -6,7 +6,7 @@
6 6
 namespace segl {
7 7
 
8 8
 class Ray;
9
-class Box
9
+class Box;
10 10
 class Plane;
11 11
 
12 12
 
@@ -18,10 +18,13 @@ class Sphere {
18 18
 		Sphere(Punkt3D _pos, float radius);
19 19
 		Sphere();
20 20
 		
21
-		bool collision(const Sphere &s);
22
-		bool collision(const Ray &r);
23
-		bool collision(const Box & b);
24
-		bool collision(const Plane &p);
21
+		bool collision(const Sphere &s) const;
22
+		bool collision(const Ray &r) const;
23
+		bool collision(const Box & b) const;
24
+		bool collision(const Plane &p) const;
25
+		
26
+		bool inSphere(Punkt3D p) const;
27
+		Punkt3D getPos() const;
25 28
 };
26 29
 
27 30
 class Ray {
@@ -32,10 +35,16 @@ class Ray {
32 35
 		Ray();
33 36
 		Ray(Punkt3D _pos, Punkt3D _dir);
34 37
 		
35
-		bool collision(const Sphere &s);
36
-		bool collision(const Ray &r);
37
-		bool collision(const Box & b);
38
-		bool collision(const Plane &p);
38
+		void set(Punkt3D _pos, Punkt3D _dir);
39
+		Punkt3D get(float x);
40
+		bool onRay(Punkt3D p, int rnd=-1);
41
+		float dist(Punkt3D p);
42
+		float getParam(Punkt3D p, bool onray=false);
43
+		
44
+		bool collision(const Sphere &s) const;
45
+		bool collision(const Ray &r) const;
46
+		bool collision(const Box & b) const;
47
+		bool collision(const Plane &p) const;
39 48
 };
40 49
 
41 50
 class Box {
@@ -46,10 +55,10 @@ class Box {
46 55
 		Box();
47 56
 		Box(Punkt3D _min, Punkt3D _max);
48 57
 		
49
-		bool collision(const Sphere &s);
50
-		bool collision(const Ray &r);
51
-		bool collision(const Box & b);
52
-		bool collision(const Plane &p);
58
+		bool collision(const Sphere &s) const;
59
+		bool collision(const Ray &r) const;
60
+		bool collision(const Box & b) const;
61
+		bool collision(const Plane &p) const;
53 62
 };
54 63
 
55 64
 class Plane {
@@ -61,10 +70,14 @@ class Plane {
61 70
 		Plane(Punkt3D _pos, Punkt3D _norm);
62 71
 		Plane(float x, float y, float z, float a);
63 72
 		
64
-		bool collision(const Sphere &s);
65
-		bool collision(const Ray &r);
66
-		bool collision(const Box & b);
67
-		bool collision(const Plane &p);
73
+		bool collision(const Sphere &s) const;
74
+		bool collision(const Ray &r) const;
75
+		bool collision(const Box & b) const;
76
+		bool collision(const Plane &p) const;
77
+		
78
+		float dist(Punkt3D p) const;
68 79
 };
69 80
 
70 81
 } // namespace segl
82
+
83
+#endif

+ 2
- 2
glgui/button.h View File

@@ -3,8 +3,8 @@
3 3
 
4 4
 #include <iostream>
5 5
 #include <string>
6
-#include <SDL/SDL.h>
7
-#include <SDL/SDL_opengl.h>
6
+#include <SDL.h>
7
+#include <SDL_opengl.h>
8 8
 
9 9
 #include "textlabel.h"
10 10
 

+ 2
- 2
glgui/object.h View File

@@ -3,8 +3,8 @@
3 3
 
4 4
 #include <iostream>
5 5
 #include <string>
6
-#include <SDL/SDL.h>
7
-#include <SDL/SDL_opengl.h>
6
+#include <SDL.h>
7
+#include <SDL_opengl.h>
8 8
 
9 9
 class GLGuiObject {
10 10
 	protected:

+ 2
- 2
glgui/textlabel.h View File

@@ -3,8 +3,8 @@
3 3
 
4 4
 #include <iostream>
5 5
 #include <string>
6
-#include <SDL/SDL.h>
7
-#include <SDL/SDL_opengl.h>
6
+#include <SDL.h>
7
+#include <SDL_opengl.h>
8 8
 
9 9
 #include "object.h"
10 10
 #include "../color.h"

+ 2
- 2
glgui/window.h View File

@@ -4,8 +4,8 @@
4 4
 #include <iostream>
5 5
 #include <string>
6 6
 #include <vector>
7
-#include <SDL/SDL.h>
8
-#include <SDL/SDL_opengl.h>
7
+#include <SDL.h>
8
+#include <SDL_opengl.h>
9 9
 
10 10
 #include "../color.h"
11 11
 #include "../gldrawhelper.h"

+ 1
- 1
model/loadobj.cpp View File

@@ -216,7 +216,7 @@ bool LoadOBJ::load(Model *m) {
216 216
 		minz = std::min(minz, m->meshdata[i].z);
217 217
 		maxz = std::max(maxz, m->meshdata[i].z);
218 218
 	}
219
-	std::cout << "(" << minx << ", " << maxx << ") " << "(" << miny << ", " << maxy << ") " << "(" << minz << ", " << maxz << ") " << std::endl;
219
+//	std::cout << "(" << minx << ", " << maxx << ") " << "(" << miny << ", " << maxy << ") " << "(" << minz << ", " << maxz << ") " << std::endl;
220 220
 	m->boundingbox.d.set(minx, miny, minz);
221 221
 	m->boundingbox.a.set(minx, miny, maxz);
222 222
 	m->boundingbox.b.set(maxx, miny, maxz);

+ 12
- 0
punkt2d.cpp View File

@@ -25,6 +25,18 @@ float Punkt2D::abs() {
25 25
 	return sqrt(x*x + y*y);
26 26
 }
27 27
 
28
+void Punkt2D::normalize() {
29
+	float a = abs();
30
+	x /= a;
31
+	y /= a;
32
+}
33
+
34
+Punkt2D Punkt2D::getNormalized() const {
35
+	Punkt2D ret(*this);
36
+	ret.normalize();
37
+	return ret;
38
+}
39
+
28 40
 Punkt2D Punkt2D::operator+(const Punkt2D &b) {
29 41
 	Punkt2D c;
30 42
 	c.x =  x + b.x;

+ 3
- 0
punkt2d.h View File

@@ -18,6 +18,9 @@ class Punkt2D {
18 18
 		void print(std::string="");
19 19
 		float abs();
20 20
 		
21
+		void normalize();
22
+		Punkt2D getNormalized() const;
23
+		
21 24
 		// Operatoren
22 25
 		Punkt2D operator+(const Punkt2D&);
23 26
 		Punkt2D operator-(const Punkt2D&);

+ 29
- 29
punkt3d.cpp View File

@@ -16,11 +16,11 @@ void Punkt3D::set(float _x, float _y, float _z) {
16 16
 	z = _z;
17 17
 }
18 18
 
19
-float Punkt3D::abs() {
19
+float Punkt3D::abs() const {
20 20
 	return sqrt(x*x+y*y+z*z);
21 21
 }
22 22
 
23
-Punkt3D Punkt3D::kreuzprodukt(const Punkt3D &b) {
23
+Punkt3D Punkt3D::kreuzprodukt(const Punkt3D &b) const {
24 24
 	Punkt3D erg;
25 25
 	erg.x = y*b.z - z*b.y;
26 26
 	erg.y = z*b.x - x*b.z;
@@ -36,23 +36,23 @@ void Punkt3D::normalize() {
36 36
 	z /= a;
37 37
 }
38 38
 
39
-Punkt3D Punkt3D::getNormalized() {
39
+Punkt3D Punkt3D::getNormalized() const {
40 40
 	Punkt3D ret(*this);
41 41
 	ret.normalize();
42 42
 	return ret;
43 43
 }
44 44
 
45
-bool Punkt3D::isNormalized() {
46
-	return (abs()==1);
45
+bool Punkt3D::isNormalized() const {
46
+	return (abs()==1.0f);
47 47
 }
48 48
 
49
-float Punkt3D::calcAngle(Punkt3D b) {
49
+float Punkt3D::calcAngle(Punkt3D b) const {
50 50
 	if(abs()*b.abs()==0.0f)
51 51
 		return 0.0f;
52 52
 	return rad2deg(std::acos(((*this)*b)/(abs()*b.abs())));
53 53
 }
54 54
 
55
-Punkt3D Punkt3D::getOrtographic() {
55
+Punkt3D Punkt3D::getOrtographic() const {
56 56
 	Punkt3D erg;
57 57
 	if(!x) {
58 58
 		erg.x = 0.0f;
@@ -71,7 +71,7 @@ Punkt3D Punkt3D::getOrtographic() {
71 71
 	return erg;
72 72
 }
73 73
 
74
-Punkt3D Punkt3D::getOrtographic2() {
74
+Punkt3D Punkt3D::getOrtographic2() const {
75 75
 	Punkt3D nullvec;
76 76
 	Punkt3D erg;
77 77
 	erg.set(y, -x, 0.0f);
@@ -84,13 +84,13 @@ Punkt3D Punkt3D::getOrtographic2() {
84 84
 	return erg;
85 85
 }
86 86
 
87
-void Punkt3D::print(std::string coordname) {
87
+void Punkt3D::print(std::string coordname) const {
88 88
 	if(coordname!="")
89 89
 		coordname.append(" ");
90 90
 	std::cout << coordname << "Coord: (" << x << ", " << y << ", " << z << ")" << std::endl;
91 91
 }
92 92
 
93
-Punkt3D Punkt3D::operator+(const Punkt3D &b) {
93
+Punkt3D Punkt3D::operator+(const Punkt3D &b) const {
94 94
 	Punkt3D c;
95 95
 	c.x =  x + b.x;
96 96
 	c.y =  y + b.y;
@@ -99,7 +99,7 @@ Punkt3D Punkt3D::operator+(const Punkt3D &b) {
99 99
 	return c;
100 100
 }
101 101
 
102
-Punkt3D Punkt3D::operator-(const Punkt3D &b) {
102
+Punkt3D Punkt3D::operator-(const Punkt3D &b) const {
103 103
 	Punkt3D c;
104 104
 	c.x =  x - b.x;
105 105
 	c.y =  y - b.y;
@@ -124,19 +124,19 @@ Punkt3D& Punkt3D::operator-=(const Punkt3D &b) {
124 124
 	return *this;
125 125
 }
126 126
 
127
-Punkt3D Punkt3D::operator+(const float &_m) {
127
+Punkt3D Punkt3D::operator+(const float &_m) const {
128 128
 	return Punkt3D(x+_m, y+_m, z+_m);
129 129
 }
130 130
 
131
-Punkt3D Punkt3D::operator-(const float &_m) {
131
+Punkt3D Punkt3D::operator-(const float &_m) const {
132 132
 	return Punkt3D(x-_m, y-_m, z-_m);
133 133
 }
134 134
 
135
-Punkt3D Punkt3D::operator*(const float &_m) {
135
+Punkt3D Punkt3D::operator*(const float &_m) const {
136 136
 	return Punkt3D(x*_m, y*_m, z*_m);
137 137
 }
138 138
 
139
-Punkt3D Punkt3D::operator/(const float &_m) {
139
+Punkt3D Punkt3D::operator/(const float &_m) const {
140 140
 	return Punkt3D(x/_m, y/_m, z/_m);
141 141
 }
142 142
 
@@ -165,18 +165,18 @@ Punkt3D& Punkt3D::operator/=(const float &_m) {
165 165
 	return *this;
166 166
 }
167 167
 
168
-float Punkt3D::operator*(const Punkt3D& _m) {
168
+float Punkt3D::operator*(const Punkt3D& _m) const {
169 169
 	return x * _m.x + y * _m.y + z * _m.z;
170 170
 }
171 171
 
172
-Punkt3D Punkt3D::operator-() {
172
+Punkt3D Punkt3D::operator-() const {
173 173
 	return Punkt3D(-x, -y, -z);
174 174
 }
175 175
 
176
-bool Punkt3D::operator==(const Punkt3D& b) {
176
+bool Punkt3D::operator==(const Punkt3D& b) const {
177 177
 	return ( x==b.x && y==b.y && z==b.z);
178 178
 }
179
-bool Punkt3D::operator!=(const Punkt3D& b) {
179
+bool Punkt3D::operator!=(const Punkt3D& b) const {
180 180
 	return !(*this==b);
181 181
 }
182 182
 
@@ -204,46 +204,46 @@ std::ostream &operator<<(std::ostream &ostr, const segl::Punkt3D &r) {
204 204
 
205 205
 } // namespace segl
206 206
 
207
-float abs(segl::Punkt3D p) {
207
+float abs(const segl::Punkt3D &p) {
208 208
 	return p.abs();
209 209
 }
210 210
 
211 211
 // OpenGL Funktionen f�r Punkt3D
212 212
 
213
-void glVertex3f(segl::Punkt3D p) {
213
+void glVertex3f(const segl::Punkt3D &p) {
214 214
 	glVertex3f(p.x, p.y, p.z);
215 215
 }
216 216
 
217
-void glTranslatef(segl::Punkt3D p) {
217
+void glTranslatef(const segl::Punkt3D &p) {
218 218
 	glTranslatef(p.x, p.y, p.z);
219 219
 }
220 220
 
221
-void glNormal3f(segl::Punkt3D p) {
221
+void glNormal3f(const segl::Punkt3D &p) {
222 222
 	glNormal3f(p.x, p.y, p.z);
223 223
 }
224 224
 
225
-void glRotatef(float deg, segl::Punkt3D vec) {
225
+void glRotatef(const float &deg, const segl::Punkt3D &vec) {
226 226
 	glRotatef(deg, vec.x, vec.y, vec.z);
227 227
 }
228 228
 
229 229
 // Funktionen mit richtgen bezeichnern
230
-void glVertexP3D(segl::Punkt3D p) {
230
+void glVertexP3D(const segl::Punkt3D &p) {
231 231
 	glVertex3f(p.x, p.y, p.z);
232 232
 }
233 233
 
234
-void glTranslateP3D(segl::Punkt3D p) {
234
+void glTranslateP3D(const segl::Punkt3D &p) {
235 235
 	glTranslatef(p.x, p.y, p.z);
236 236
 }
237 237
 
238
-void glNormalP3D(segl::Punkt3D p) {
238
+void glNormalP3D(const segl::Punkt3D &p) {
239 239
 	glNormal3f(p.x, p.y, p.z);
240 240
 }
241 241
 
242
-void glRotateP3D(float deg, segl::Punkt3D vec) {
242
+void glRotateP3D(const float &deg, const segl::Punkt3D &vec) {
243 243
 	glRotatef(deg, vec.x, vec.y, vec.z);
244 244
 }
245 245
 
246
-void gluLookAt(segl::Punkt3D pos, segl::Punkt3D viewport, segl::Punkt3D normal) {
246
+void gluLookAt(const segl::Punkt3D &pos, const segl::Punkt3D &viewport, const segl::Punkt3D &normal) {
247 247
 	gluLookAt( pos.x, pos.y, pos.z,
248 248
 			   viewport.x, viewport.y, viewport.z,
249 249
 			   normal.x, normal.y, normal.z );

+ 28
- 28
punkt3d.h View File

@@ -16,39 +16,39 @@ class Punkt3D {
16 16
 		float x, y, z;
17 17
 		
18 18
 		void set(float, float, float);
19
-		float abs();
20
-		Punkt3D kreuzprodukt(const Punkt3D&);
19
+		float abs() const;
20
+		Punkt3D kreuzprodukt(const Punkt3D&) const;
21 21
 		void normalize();
22
-		Punkt3D getNormalized();
23
-		bool isNormalized();
24
-		float calcAngle(Punkt3D);
25
-		Punkt3D getOrtographic();
26
-		Punkt3D getOrtographic2();
22
+		Punkt3D getNormalized() const;
23
+		bool isNormalized() const;
24
+		float calcAngle(Punkt3D b) const;
25
+		Punkt3D getOrtographic() const;
26
+		Punkt3D getOrtographic2() const;
27 27
 		
28
-		void print(std::string="");
28
+		void print(std::string="") const;
29 29
 		
30 30
 		
31 31
 		// Operatoren
32
-		Punkt3D operator+(const Punkt3D&);
33
-		Punkt3D operator-(const Punkt3D&);
32
+		Punkt3D operator+(const Punkt3D&) const;
33
+		Punkt3D operator-(const Punkt3D&) const;
34 34
 		Punkt3D& operator+=(const Punkt3D&);
35 35
 		Punkt3D& operator-=(const Punkt3D&);
36 36
 		
37
-		Punkt3D operator+(const float&);
38
-		Punkt3D operator-(const float&);
39
-		Punkt3D operator*(const float&);
40
-		Punkt3D operator/(const float&);
37
+		Punkt3D operator+(const float&) const;
38
+		Punkt3D operator-(const float&) const;
39
+		Punkt3D operator*(const float&) const;
40
+		Punkt3D operator/(const float&) const;
41 41
 		Punkt3D& operator+=(const float&);
42 42
 		Punkt3D& operator-=(const float&);
43 43
 		Punkt3D& operator*=(const float&);
44 44
 		Punkt3D& operator/=(const float&);
45 45
 		
46
-		float operator*(const Punkt3D&);
46
+		float operator*(const Punkt3D&) const;
47 47
 		
48
-		Punkt3D operator-();
48
+		Punkt3D operator-() const;
49 49
 
50
-		bool operator==(const Punkt3D&);
51
-		bool operator!=(const Punkt3D&);
50
+		bool operator==(const Punkt3D&) const;
51
+		bool operator!=(const Punkt3D&) const;
52 52
 		
53 53
 		friend Punkt3D operator+(const float&, const Punkt3D&);
54 54
 		friend Punkt3D operator-(const float&, const Punkt3D&);
@@ -59,22 +59,22 @@ class Punkt3D {
59 59
 
60 60
 } // namespace segl
61 61
 
62
-float abs(segl::Punkt3D);
62
+float abs(const segl::Punkt3D&);
63 63
 
64 64
 // OpenGL-Functions for Punkt3D
65 65
 
66
-void glVertex3f(segl::Punkt3D);
67
-void glTranslatef(segl::Punkt3D);
68
-void glNormal3f(segl::Punkt3D);
66
+void glVertex3f(const segl::Punkt3D&);
67
+void glTranslatef(const segl::Punkt3D&);
68
+void glNormal3f(const segl::Punkt3D&);
69 69
 
70
-void glRotatef(float, segl::Punkt3D);
70
+void glRotatef(const float&, const segl::Punkt3D&);
71 71
 
72 72
 // Funktionen mit richtgen bezeichnern
73
-void glVertexP3D(segl::Punkt3D);
74
-void glTranslateP3D(segl::Punkt3D);
75
-void glNormalP3D(segl::Punkt3D);
73
+void glVertexP3D(const segl::Punkt3D&);
74
+void glTranslateP3D(const segl::Punkt3D&);
75
+void glNormalP3D(const segl::Punkt3D&);
76 76
 
77
-void glRotateP3D(float, segl::Punkt3D);
78
-void gluLookAt(segl::Punkt3D pos, segl::Punkt3D viewport, segl::Punkt3D normal);
77
+void glRotateP3D(const float&, const segl::Punkt3D&);
78
+void gluLookAt(const segl::Punkt3D &pos, const segl::Punkt3D &viewport, const segl::Punkt3D &normal);
79 79
 
80 80
 #endif

Loading…
Cancel
Save