eqemu

diff src/vmath.h @ 3:f9274bebe55e

adding 3d graphics stuff
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 17 Jul 2014 02:35:19 +0300
parents
children 3d3656360a82
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/vmath.h	Thu Jul 17 02:35:19 2014 +0300
     1.3 @@ -0,0 +1,37 @@
     1.4 +#ifndef VMATH_H_
     1.5 +#define VMATH_H_
     1.6 +
     1.7 +class Vector2 {
     1.8 +public:
     1.9 +	float x, y;
    1.10 +
    1.11 +	Vector2() : x(0), y(0) {}
    1.12 +	Vector2(float xa, float ya) : x(xa), y(ya) {}
    1.13 +
    1.14 +	float &operator [](int idx) { return (&x)[idx]; }
    1.15 +	const float &operator [](int idx) const { return (&x)[idx]; }
    1.16 +};
    1.17 +
    1.18 +class Vector3 {
    1.19 +public:
    1.20 +	float x, y, z;
    1.21 +
    1.22 +	Vector3() : x(0), y(0), z(0) {}
    1.23 +	Vector3(float xa, float ya, float za) : x(xa), y(ya), z(za) {}
    1.24 +
    1.25 +	float &operator [](int idx) { return (&x)[idx]; }
    1.26 +	const float &operator [](int idx) const { return (&x)[idx]; }
    1.27 +};
    1.28 +
    1.29 +class Vector4 {
    1.30 +public:
    1.31 +	float x, y, z, w;
    1.32 +
    1.33 +	Vector4() : x(0), y(0), z(0), w(0) {}
    1.34 +	Vector4(float xa, float ya, float za, float wa) : x(xa), y(ya), z(za), w(wa) {}
    1.35 +
    1.36 +	float &operator [](int idx) { return (&x)[idx]; }
    1.37 +	const float &operator [](int idx) const {  return (&x)[idx]; }
    1.38 +};
    1.39 +
    1.40 +#endif	// VMATH_H_