parent
							
								
									fc21a5ca38
								
							
						
					
					
						commit
						026961a7a6
					
				
							
								
								
									
										4
									
								
								Makefile
								
								
								
								
							
							
						
						
									
										4
									
								
								Makefile
								
								
								
								
							|  | @ -1,6 +1,6 @@ | |||
| CC = g++ | ||||
| AR = ar | ||||
| OBJECTS = punkt3d.o punkt2d.o emath.o emath_opengl.o glcolor.o gldrawhelper.o glfontengine.o glrect.o gltexture.o matrix.o quaternion.o rotationsmatrix.o glsdlscreen.o sdlfuncs.o fpsmanager.o | ||||
| OBJECTS = punkt3d.o punkt2d.o emath.o emath_opengl.o glcolor.o gldrawhelper.o glfontengine.o glrect.o gltexture.o matrix.o quaternion.o rotationsmatrix.o glsdlscreen.o sdlfuncs.o fpsmanager.o glcamera.o catmullromspline.o | ||||
| OBJOPT = -Wall -c `sdl-config --cflags` | ||||
| SUBDIRS = glgui glmenu models | ||||
| SUBDIROBJECTS = glgui/*.o glmenu/*.o models/*.o | ||||
|  | @ -37,4 +37,4 @@ clean: cleansubdirs | |||
| 	rm -f $(OBJECTS) | ||||
| # 	cd glgui; $(MAKE) clean
 | ||||
| # 	cd glmenu; $(MAKE) clean
 | ||||
| 	@echo Done cleaning... | ||||
| 	@echo Done cleaning... | ||||
|  |  | |||
|  | @ -0,0 +1,101 @@ | |||
| #include "catmullromspline.h" | ||||
| 
 | ||||
| CatmullRomSpline::CatmullRomSpline(float _s) { | ||||
| 	cr = new Matrix(4, 4); | ||||
| 	setS(_s); | ||||
| } | ||||
| 
 | ||||
| void CatmullRomSpline::makeMatrix() { | ||||
| 	cr->set(-s	, 0, 0); | ||||
| 	cr->set( 2-s	, 0, 1); | ||||
| 	cr->set( s-2	, 0, 2); | ||||
| 	cr->set( s	, 0, 3); | ||||
| 	 | ||||
| 	cr->set( 2*s	 , 1, 0); | ||||
| 	cr->set( s-3  , 1, 1); | ||||
| 	cr->set( 3-2*s, 1, 2); | ||||
| 	cr->set(-s    , 1, 3); | ||||
| 
 | ||||
| 	cr->set(-s, 2, 0); | ||||
| 	cr->set( 0, 2, 1); | ||||
| 	cr->set( s, 2, 2); | ||||
| 	cr->set( 0, 2, 3); | ||||
| 
 | ||||
| 	cr->set( 0, 3, 0); | ||||
| 	cr->set( 1, 3, 1); | ||||
| 	cr->set( 0, 3, 2); | ||||
| 	cr->set( 0, 3, 3); | ||||
| } | ||||
| 
 | ||||
| Matrix CatmullRomSpline::getPosition(float u, Matrix &controlpoints) { | ||||
| // 	Matrix controlpoints(4, a.getN());
 | ||||
| // 	for(int i=0; i<a.getN(); i++) {
 | ||||
| // 		controlpoints.set(a.get(0, i), 0, i);
 | ||||
| // 		controlpoints.set(b.get(0, i), 1, i);
 | ||||
| // 		controlpoints.set(c.get(0, i), 2, i);
 | ||||
| // 		controlpoints.set(d.get(0, i), 3, i);
 | ||||
| // 	}
 | ||||
| 	Matrix param(1, 4); | ||||
| 	param.set(u*u*u, 0, 0); | ||||
| 	param.set(u*u,   0, 1); | ||||
| 	param.set(u,     0, 2); | ||||
| 	param.set(1,     0, 3); | ||||
| 	 | ||||
| 	return param * (*cr) * controlpoints; | ||||
| } | ||||
| 
 | ||||
| Punkt3D CatmullRomSpline::getPosition(float u, Punkt3D a, Punkt3D b, Punkt3D c, Punkt3D d) { | ||||
| 	Matrix erg(1, 3); | ||||
| 	Matrix controlpoints(4, 3); | ||||
| 	 | ||||
| 	controlpoints.set(a.x, 0, 0); | ||||
| 	controlpoints.set(a.y, 0, 1); | ||||
| 	controlpoints.set(a.z, 0, 2); | ||||
| 	 | ||||
| 	controlpoints.set(b.x, 1, 0); | ||||
| 	controlpoints.set(b.y, 1, 1); | ||||
| 	controlpoints.set(b.z, 1, 2); | ||||
| 	 | ||||
| 	controlpoints.set(c.x, 2, 0); | ||||
| 	controlpoints.set(c.y, 2, 1); | ||||
| 	controlpoints.set(c.z, 2, 2); | ||||
| 	 | ||||
| 	controlpoints.set(d.x, 3, 0); | ||||
| 	controlpoints.set(d.y, 3, 1); | ||||
| 	controlpoints.set(d.z, 3, 2); | ||||
| 	 | ||||
| 	erg = getPosition(u, controlpoints); | ||||
| 	 | ||||
| 	return Punkt3D(erg.get(0,0), erg.get(0,1), erg.get(0,2)); | ||||
| } | ||||
| 
 | ||||
| Punkt2D CatmullRomSpline::getPosition(float u, Punkt2D a, Punkt2D b, Punkt2D c, Punkt2D d) { | ||||
| 	Matrix erg(1, 2); | ||||
| 	Matrix controlpoints(4, 2); | ||||
| 	 | ||||
| 	controlpoints.set(a.x, 0, 0); | ||||
| 	controlpoints.set(a.y, 0, 1); | ||||
| 	 | ||||
| 	controlpoints.set(b.x, 1, 0); | ||||
| 	controlpoints.set(b.y, 1, 1); | ||||
| 	 | ||||
| 	controlpoints.set(c.x, 2, 0); | ||||
| 	controlpoints.set(c.y, 2, 1); | ||||
| 	 | ||||
| 	controlpoints.set(d.x, 3, 0); | ||||
| 	controlpoints.set(d.y, 3, 1); | ||||
| 	 | ||||
| 	erg = getPosition(u, controlpoints); | ||||
| 	 | ||||
| 	return Punkt2D(erg.get(0,0), erg.get(0,1)); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void CatmullRomSpline::setS(float _s) { | ||||
| 	s = _s; | ||||
| 	makeMatrix(); | ||||
| } | ||||
| 
 | ||||
| CatmullRomSpline::~CatmullRomSpline() { | ||||
| 	delete(cr); | ||||
| } | ||||
|  | @ -0,0 +1,31 @@ | |||
| #ifndef __CATMULLROMSPLINE_H | ||||
| #define __CATMULLROMSPLINE_H | ||||
| 
 | ||||
| #include <iostream> | ||||
| #include <SDL.h> | ||||
| #include <SDL_opengl.h> | ||||
| #include "matrix.h" | ||||
| #include "punkt2d.h" | ||||
| #include "punkt3d.h" | ||||
| 
 | ||||
| 
 | ||||
| class CatmullRomSpline { | ||||
| 	private: | ||||
| 		Matrix *cr; | ||||
| 		float s; | ||||
| 		 | ||||
| 		void makeMatrix(); | ||||
| 	public: | ||||
| 		CatmullRomSpline(float _s=0.5f); | ||||
| 		 | ||||
| 		Matrix getPosition(float u, Matrix &controlpoints); | ||||
| 		Punkt3D getPosition(float u, Punkt3D a, Punkt3D b, Punkt3D c, Punkt3D d); | ||||
| 		Punkt2D getPosition(float u, Punkt2D a, Punkt2D b, Punkt2D c, Punkt2D d); | ||||
| 		 | ||||
| 		 | ||||
| 		void setS(float _s); | ||||
| 		~CatmullRomSpline(); | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
| #endif | ||||
|  | @ -41,6 +41,12 @@ void rotFrom2VecTo2Vec(Punkt3D a, Punkt3D b, Punkt3D c, Punkt3D d) { | |||
| 	Punkt3D rvec, rvec2; | ||||
| 	float rvecdeg, rvecdeg2; | ||||
| 	rotFrom2VecTo2Vec(a, b, c, d, &rvec, &rvecdeg, &rvec2, &rvecdeg2); | ||||
| // 	if(rvecdeg)
 | ||||
| 	glRotatef(rvecdeg, rvec); | ||||
| // 	if(rvecdeg2)
 | ||||
| 	glRotatef(rvecdeg2, rvec2); | ||||
| // 	std::cout << rvecdeg << ", " << rvecdeg2 << std::endl;
 | ||||
| // 	rvec.print("rvecdeg");
 | ||||
| // 	rvec2.print("rvecdeg2");
 | ||||
| 	 | ||||
| } | ||||
|  |  | |||
|  | @ -0,0 +1,154 @@ | |||
| #include "glcamera.h" | ||||
| 
 | ||||
| GLCamera::GLCamera() { | ||||
| 	std_norm.set(0.0f, 1.0f, 0.0f); | ||||
| 	std_dir.set(0.0f, 0.0f, -1.0f); | ||||
| 	mpersec = 10.0f; | ||||
| 	apersec = 90.0f; | ||||
| 	doupdate = true; | ||||
| 
 | ||||
| 	norm.set(0.0f, 1.0f, 0.0f); | ||||
| 	dir.set(0.0f, 0.0f, -1.0f); | ||||
| 	 | ||||
| 	rotx = roty = 0.0f; | ||||
| 	 | ||||
| 	rotmatX.set(x_axis, 0.0f); | ||||
| 	rotmatY.set(y_axis, 0.0f); | ||||
| } | ||||
| 
 | ||||
| void GLCamera::updateVectors() { | ||||
| 	dir = rotmatY * rotmatX * Punkt3D(0.0f, 0.0f, -1.0f); | ||||
| 	norm = rotmatY * rotmatX * std_norm; | ||||
| 	dir.normalize(); | ||||
| 	norm.normalize(); | ||||
| } | ||||
| 
 | ||||
| void GLCamera::setCamera() { | ||||
| 
 | ||||
| 	if(doupdate) { | ||||
| 		updateVectors(); | ||||
| 	} | ||||
| 	Punkt3D port = pos + dir; | ||||
| 	gluLookAt(	pos.x, 	pos.y,	pos.z, | ||||
| 				port.x, port.y, port.z, | ||||
| 				norm.x, norm.y, norm.z); | ||||
| // 	rotFrom2VecTo2Vec(std_dir, dir, std_norm, norm);
 | ||||
| // 	glTranslateP3D(-pos);
 | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| // Move-Funktionen
 | ||||
| 
 | ||||
| void GLCamera::moveForward(float sec) { | ||||
| 	if(doupdate) { | ||||
| 		updateVectors(); | ||||
| 	} | ||||
| 	pos += (mpersec*sec) * dir; | ||||
| // 	std::cout << "move..";
 | ||||
| // 	pos.print("pos");
 | ||||
| } | ||||
| 
 | ||||
| void GLCamera::moveBackward(float sec) { | ||||
| 	if(doupdate) { | ||||
| 		updateVectors(); | ||||
| 	} | ||||
| 	pos -= (mpersec*sec) * dir; | ||||
| } | ||||
| 
 | ||||
| void GLCamera::moveLeft(float sec) { | ||||
| 	if(doupdate) { | ||||
| 		updateVectors(); | ||||
| 	} | ||||
| 	Punkt3D right = (dir.kreuzprodukt(norm)); | ||||
| 	right.normalize(); | ||||
| 	pos -= right * sec * mpersec; | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void GLCamera::moveRight(float sec) { | ||||
| 	if(doupdate) { | ||||
| 		updateVectors(); | ||||
| 	} | ||||
| 	Punkt3D right = (dir.kreuzprodukt(norm)); | ||||
| 	right.normalize(); | ||||
| 	pos += right * sec * mpersec; | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void GLCamera::rotateLeft(float sec) { | ||||
| 	roty += apersec * sec; | ||||
| 	rotmatY.set(roty); | ||||
| 	doupdate = true; | ||||
| // 	rotmat.set(Punkt3D(0.0f, 1.0f, 0.0f), sec*apersec);
 | ||||
| // 	dir = rotmat * dir;
 | ||||
| // 	dir.normalize();
 | ||||
| } | ||||
| 
 | ||||
| void GLCamera::rotateRight(float sec) { | ||||
| 	roty -= apersec * sec; | ||||
| 	rotmatY.set(roty); | ||||
| 	doupdate = true; | ||||
| // statt norm
 | ||||
| // 	rotmat.set(Punkt3D(0.0f, 1.0f, 0.0f), -apersec*sec);
 | ||||
| // 	dir = rotmat * dir;
 | ||||
| // 	dir.normalize();
 | ||||
| } | ||||
| 
 | ||||
| void GLCamera::rotateUp(float sec) { | ||||
| 	if(rotx+sec*apersec<=90.0f && rotx+sec*apersec>=-90.0f) { | ||||
| 		rotx += sec*apersec; | ||||
| 		rotmatX.set(rotx); | ||||
| 		doupdate = true; | ||||
| 	} else  { | ||||
| 		//std::cout << "zu groß" << std::endl;
 | ||||
| 	} | ||||
| // 	rotmat.set(dir.kreuzprodukt(norm), -apersec*sec);
 | ||||
| // 	norm = rotmat * norm;
 | ||||
| // 	dir = rotmat * dir;
 | ||||
| // 	norm.normalize();
 | ||||
| // 	dir.normalize();
 | ||||
| } | ||||
| 
 | ||||
| void GLCamera::rotateDown(float sec) { | ||||
| 	if( (rotx-sec*apersec) >= -90.0f) { | ||||
| 		rotx -= sec*apersec; | ||||
| 		rotmatX.set(rotx); | ||||
| 		doupdate = true; | ||||
| 	} | ||||
| // 	rotmat.set(dir.kreuzprodukt(norm), apersec*sec);
 | ||||
| // 	norm = rotmat * norm;
 | ||||
| // 	dir = rotmat * dir;
 | ||||
| // 	norm.normalize();
 | ||||
| // 	dir.normalize();
 | ||||
| } | ||||
| 
 | ||||
| float GLCamera::getXrot() { | ||||
| 	return rotx; | ||||
| } | ||||
| 
 | ||||
| float GLCamera::getYrot() { | ||||
| 	return roty; | ||||
| } | ||||
| 
 | ||||
| void GLCamera::print() { | ||||
| 	std::cout << " --- GL Camera --- " << std::endl; | ||||
| 	pos.print("Position"); | ||||
| 	norm.print("Normale"); | ||||
| 	dir.print("Direction"); | ||||
| 	dir.kreuzprodukt(norm).print("Kreuz"); | ||||
| 	std::cout << "Rotation X: " << rotx << " Y: " << roty << std::endl; | ||||
| 	rotmatY.print(); | ||||
| 	std::cout << " --- End Camera --- " << std::endl; | ||||
| } | ||||
| 
 | ||||
| void GLCamera::renderCoord() { | ||||
| 	glBegin(GL_LINES); | ||||
| 		glColor3f(0.0f, 1.0f, 0.0f); | ||||
| 		glVertex3f(0.0f, -1.0f, 0.0f); | ||||
| 		glVertex3f(0.0f, -1.0f, -5.0f); | ||||
| 	glEnd(); | ||||
| } | ||||
| 
 | ||||
| GLCamera::~GLCamera() { | ||||
| 	 | ||||
| } | ||||
|  | @ -0,0 +1,56 @@ | |||
| #ifndef __GLCAMERA_H | ||||
| #define __GLCAMERA_H | ||||
| 
 | ||||
| #include <iostream> | ||||
| #include <SDL.h> | ||||
| #include <SDL_opengl.h> | ||||
| #include "rotationsmatrix.h" | ||||
| #include "emath_opengl.h" | ||||
| #include "punkt3d.h" | ||||
| 
 | ||||
| class GLCamera { | ||||
| 	private: | ||||
| 		Punkt3D std_dir; | ||||
| 		Punkt3D std_norm; | ||||
| 	 | ||||
| 		Punkt3D pos; | ||||
| 		Punkt3D norm; | ||||
| 		Punkt3D dir;		// normalisiert
 | ||||
| 		 | ||||
| 		float rotx; | ||||
| 		float roty; | ||||
| 		bool doupdate; | ||||
| 		 | ||||
| 		float mpersec; | ||||
| 		float apersec; | ||||
| 		 | ||||
| 		Rotationsmatrix rotmatX; | ||||
| 		Rotationsmatrix rotmatY; | ||||
| 		 | ||||
| 		void updateVectors(); | ||||
| 	public: | ||||
| 		GLCamera(); | ||||
| // 		GLCamera(Punkt3d
 | ||||
| 		 | ||||
| 		void setCamera(); | ||||
| 		 | ||||
| 		// Std Move
 | ||||
| 		void moveForward(float sec); | ||||
| 		void moveBackward(float sec); | ||||
| 		void moveLeft(float sec); | ||||
| 		void moveRight(float sec); | ||||
| 		void rotateLeft(float sec); | ||||
| 		void rotateRight(float sec); | ||||
| 		void rotateUp(float sec); | ||||
| 		void rotateDown(float sec); | ||||
| 		 | ||||
| 		float getXrot(); | ||||
| 		float getYrot(); | ||||
| 		 | ||||
| 		void print(); | ||||
| 		void renderCoord(); | ||||
| 		 | ||||
| 		~GLCamera(); | ||||
| }; | ||||
| 
 | ||||
| #endif | ||||
|  | @ -5,6 +5,10 @@ GLColor::GLColor() { | |||
| 	setalpha = true; | ||||
| } | ||||
| 
 | ||||
| GLColor::GLColor(float _r, float _g, float _b, float _a) { | ||||
| 	set(_r, _g, _b, _a); | ||||
| } | ||||
| 
 | ||||
| GLColor::GLColor(const SDL_Color &c) { | ||||
| 	set(c.r/255.0f, c.g/255.0f, c.b/255.0f); | ||||
| 	setalpha = true; | ||||
|  |  | |||
|  | @ -13,6 +13,7 @@ class GLColor { | |||
| 		 | ||||
| 		 | ||||
| 		GLColor(); | ||||
| 		GLColor(float _r, float _g, float _b, float _a=1.0f); | ||||
| 		GLColor(const SDL_Color&); | ||||
| 		 | ||||
| 		void set(float _r, float _g, float _b, float _a=1.0f); | ||||
|  |  | |||
|  | @ -87,6 +87,7 @@ void MenuMenu::resetItemPos() { | |||
| } | ||||
| 
 | ||||
| void MenuMenu::render() { | ||||
| 	 | ||||
| 	Punkt2D pos = menupos; | ||||
| 	pos.y += offset; | ||||
| 	if(centerScreenX) { | ||||
|  |  | |||
							
								
								
									
										87
									
								
								matrix.cpp
								
								
								
								
							
							
						
						
									
										87
									
								
								matrix.cpp
								
								
								
								
							|  | @ -56,6 +56,13 @@ bool Matrix::set(float d, int _m, int _n) { | |||
| 	return true; | ||||
| } | ||||
| 
 | ||||
| float Matrix::get(int _m, int _n) { | ||||
| 	if(_m>=m||_n>=n) | ||||
| 		return 0.0f; | ||||
| 		 | ||||
| 	return c[_m][_n]; | ||||
| } | ||||
| 
 | ||||
| Matrix Matrix::operator*(const Matrix &d) { | ||||
| 	 | ||||
| 	if(n!=d.m) | ||||
|  | @ -83,45 +90,45 @@ Matrix& Matrix::operator=(const Matrix& mat) { | |||
| 	return *this; | ||||
| } | ||||
| 
 | ||||
| // Matrix Matrix::operator+(const float &f) {
 | ||||
| // 	Matrix tmp(*this);
 | ||||
| // 	for(int i=0; i<m; i++) {
 | ||||
| // 		for(int j=0; j<n; j++) {
 | ||||
| // 			tmp.c[i][j] += f;
 | ||||
| // 		}
 | ||||
| // 	}
 | ||||
| // 	return tmp;
 | ||||
| // }
 | ||||
| // 
 | ||||
| // Matrix Matrix::operator-(const float &f) {
 | ||||
| // 	Matrix tmp(*this);
 | ||||
| // 	for(int i=0; i<m; i++) {
 | ||||
| // 		for(int j=0; j<n; j++) {
 | ||||
| // 			tmp.c[i][j] -= f;
 | ||||
| // 		}
 | ||||
| // 	}
 | ||||
| // 	return tmp;
 | ||||
| // }
 | ||||
| // 
 | ||||
| // Matrix Matrix::operator*(const float &f) {
 | ||||
| // 	Matrix tmp(*this);
 | ||||
| // 	for(int i=0; i<m; i++) {
 | ||||
| // 		for(int j=0; j<n; j++) {
 | ||||
| // 			tmp.c[i][j] *= f;
 | ||||
| // 		}
 | ||||
| // 	}
 | ||||
| // 	return tmp;
 | ||||
| // }
 | ||||
| // 
 | ||||
| // Matrix Matrix::operator/(const float &f) {
 | ||||
| // 	Matrix tmp(*this);
 | ||||
| // 	for(int i=0; i<m; i++) {
 | ||||
| // 		for(int j=0; j<n; j++) {
 | ||||
| // 			tmp.c[i][j] /= f;
 | ||||
| // 		}
 | ||||
| // 	}
 | ||||
| // 	return tmp;
 | ||||
| // }
 | ||||
| Matrix Matrix::operator+(const float &f) { | ||||
| 	Matrix tmp(*this); | ||||
| 	for(int i=0; i<m; i++) { | ||||
| 		for(int j=0; j<n; j++) { | ||||
| 			tmp.c[i][j] += f; | ||||
| 		} | ||||
| 	} | ||||
| 	return tmp; | ||||
| } | ||||
| 
 | ||||
| Matrix Matrix::operator-(const float &f) { | ||||
| 	Matrix tmp(*this); | ||||
| 	for(int i=0; i<m; i++) { | ||||
| 		for(int j=0; j<n; j++) { | ||||
| 			tmp.c[i][j] -= f; | ||||
| 		} | ||||
| 	} | ||||
| 	return tmp; | ||||
| } | ||||
| 
 | ||||
| Matrix Matrix::operator*(const float &f) { | ||||
| 	Matrix tmp(*this); | ||||
| 	for(int i=0; i<m; i++) { | ||||
| 		for(int j=0; j<n; j++) { | ||||
| 			tmp.c[i][j] *= f; | ||||
| 		} | ||||
| 	} | ||||
| 	return tmp; | ||||
| } | ||||
| 
 | ||||
| Matrix Matrix::operator/(const float &f) { | ||||
| 	Matrix tmp(*this); | ||||
| 	for(int i=0; i<m; i++) { | ||||
| 		for(int j=0; j<n; j++) { | ||||
| 			tmp.c[i][j] /= f; | ||||
| 		} | ||||
| 	} | ||||
| 	return tmp; | ||||
| } | ||||
| 
 | ||||
| int Matrix::getM() const { | ||||
| 	return m; | ||||
|  | @ -135,7 +142,7 @@ void Matrix::print(std::string s) const { | |||
| 	std::cout << "Matrix " << s << "(" << m << "," << n << ")" << std::endl; | ||||
| 	for(int a=0; a<m; a++) { | ||||
| 		for(int b=0; b<n; b++) { | ||||
| 			std::cout << std::setw(10) << c[a][b]; | ||||
| 			std::cout << std::setw(15) << c[a][b]; | ||||
| 		} | ||||
| 		std::cout << std::endl; | ||||
| 	} | ||||
|  |  | |||
							
								
								
									
										9
									
								
								matrix.h
								
								
								
								
							
							
						
						
									
										9
									
								
								matrix.h
								
								
								
								
							|  | @ -22,16 +22,17 @@ class Matrix { | |||
| 		 | ||||
| 		const float **getMatrix() const; | ||||
| 		bool set(float, int, int); | ||||
| 		float get(int, int); | ||||
| 		int getM() const; | ||||
| 		int getN() const; | ||||
| 		 | ||||
| 		Matrix operator*(const Matrix&); | ||||
| 		Matrix& operator=(const Matrix&); | ||||
| 		 | ||||
| // 		Matrix operator+(const float&);
 | ||||
| // 		Matrix operator-(const float&);
 | ||||
| // 		Matrix operator*(const float&);
 | ||||
| // 		Matrix operator/(const float&);
 | ||||
| 		Matrix operator+(const float&); | ||||
| 		Matrix operator-(const float&); | ||||
| 		Matrix operator*(const float&); | ||||
| 		Matrix operator/(const float&); | ||||
| 
 | ||||
| 		void print(std::string="") const; | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										34
									
								
								punkt3d.cpp
								
								
								
								
							
							
						
						
									
										34
									
								
								punkt3d.cpp
								
								
								
								
							|  | @ -69,6 +69,19 @@ Punkt3D Punkt3D::getOrtographic() { | |||
| 	return erg; | ||||
| } | ||||
| 
 | ||||
| Punkt3D Punkt3D::getOrtographic2() { | ||||
| 	Punkt3D nullvec; | ||||
| 	Punkt3D erg; | ||||
| 	erg.set(y, -x, 0.0f); | ||||
| 	if(erg!=nullvec) | ||||
| 		return erg; | ||||
| 	erg.set(z, 0.0f, -x); | ||||
| 	if(erg!=nullvec) | ||||
| 		return erg; | ||||
| 	erg.set(0.0f, z, -y); | ||||
| 	return erg; | ||||
| } | ||||
| 
 | ||||
| void Punkt3D::print(std::string coordname) { | ||||
| 	if(coordname!="") | ||||
| 		coordname.append(" "); | ||||
|  | @ -184,6 +197,10 @@ Punkt3D operator/(const float& _m, const Punkt3D& b) { | |||
| 	return Punkt3D(b.x/_m, b.y/_m, b.z/_m); | ||||
| } | ||||
| 
 | ||||
| std::ostream &operator<<(std::ostream &ostr, const Punkt3D &r) { | ||||
| 	return ostr << "(" << r.x << ", " << r.y << ", " << r.z << ")"; | ||||
| } | ||||
| 
 | ||||
| float abs(Punkt3D p) { | ||||
| 	return p.abs(); | ||||
| } | ||||
|  | @ -205,3 +222,20 @@ void glNormal3f(Punkt3D p) { | |||
| void glRotatef(float deg, Punkt3D vec) { | ||||
| 	glRotatef(deg, vec.x, vec.y, vec.z); | ||||
| } | ||||
| 
 | ||||
| // Funktionen mit richtgen bezeichnern
 | ||||
| void glVertexP3D(Punkt3D p) { | ||||
| 	glVertex3f(p.x, p.y, p.z); | ||||
| } | ||||
| 
 | ||||
| void glTranslateP3D(Punkt3D p) { | ||||
| 	glTranslatef(p.x, p.y, p.z); | ||||
| } | ||||
| 
 | ||||
| void glNormalP3D(Punkt3D p) { | ||||
| 	glNormal3f(p.x, p.y, p.z); | ||||
| } | ||||
| 
 | ||||
| void glRotateP3D(float deg, Punkt3D vec) { | ||||
| 	glRotatef(deg, vec.x, vec.y, vec.z); | ||||
| } | ||||
|  |  | |||
							
								
								
									
										10
									
								
								punkt3d.h
								
								
								
								
							
							
						
						
									
										10
									
								
								punkt3d.h
								
								
								
								
							|  | @ -9,6 +9,7 @@ class Punkt3D { | |||
| 	public: | ||||
| 		Punkt3D(); | ||||
| 		Punkt3D(float, float, float); | ||||
| 		~Punkt3D() { };  | ||||
| 		 | ||||
| 		float x, y, z; | ||||
| 		 | ||||
|  | @ -20,6 +21,7 @@ class Punkt3D { | |||
| 		bool isNormalized(); | ||||
| 		float calcAngle(Punkt3D); | ||||
| 		Punkt3D getOrtographic(); | ||||
| 		Punkt3D getOrtographic2(); | ||||
| 		 | ||||
| 		void print(std::string=""); | ||||
| 		 | ||||
|  | @ -50,6 +52,7 @@ class Punkt3D { | |||
| 		friend Punkt3D operator-(const float&, const Punkt3D&); | ||||
| 		friend Punkt3D operator*(const float&, const Punkt3D&); | ||||
| 		friend Punkt3D operator/(const float&, const Punkt3D&); | ||||
| 		friend std::ostream &operator<<(std::ostream &ostr, const Punkt3D &r); | ||||
| }; | ||||
| 
 | ||||
| float abs(Punkt3D); | ||||
|  | @ -62,5 +65,12 @@ void glNormal3f(Punkt3D); | |||
| 
 | ||||
| void glRotatef(float, Punkt3D); | ||||
| 
 | ||||
| // Funktionen mit richtgen bezeichnern
 | ||||
| void glVertexP3D(Punkt3D); | ||||
| void glTranslateP3D(Punkt3D); | ||||
| void glNormalP3D(Punkt3D); | ||||
| 
 | ||||
| void glRotateP3D(float, Punkt3D); | ||||
| 
 | ||||
| 
 | ||||
| #endif | ||||
|  |  | |||
|  | @ -38,6 +38,7 @@ void Rotationsmatrix::set(axis _ax, float _deg) { | |||
| 
 | ||||
| void Rotationsmatrix::set(float _deg) { | ||||
| 	deg = _deg; | ||||
| // 	rotvec.print();
 | ||||
| 	initRot(); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 seba
						seba