NGL  6.5
The NCCA Graphics Library
NGLStream.cpp
Go to the documentation of this file.
1 #include "Camera.h"
2 #include "Colour.h"
3 #include "Vec2.h"
4 #include "Vec3.h"
5 #include "Vec4.h"
6 #include "Mat3.h"
7 #include "Mat4.h"
8 #include "Quaternion.h"
9 #include <iostream>
10 #include <limits>
11 #include <iomanip>
12 namespace ngl
13 {
14 //----------------------------------------------------------------------------------------------------------------------
15 NGL_DLLEXPORT std::ostream& operator<<( std::ostream& _output, const Vec2& _v )
16 {
17  return _output<<"["<<_v.m_x<<","<<_v.m_y<<"]";
18 }
19 //----------------------------------------------------------------------------------------------------------------------
20 NGL_DLLEXPORT std::istream& operator>>( std::istream& _input, Vec2& _s )
21 {
22  return _input >> _s.m_x >> _s.m_y ;
23 }
24 
25 
26 //----------------------------------------------------------------------------------------------------------------------
27 NGL_DLLEXPORT std::ostream& operator<<( std::ostream& _output, const Vec3& _v )
28 {
29  return _output<<"["<<_v.m_x<<","<<_v.m_y<<","<<_v.m_z<<"]";
30 }
31 //----------------------------------------------------------------------------------------------------------------------
32 NGL_DLLEXPORT std::istream& operator>>(std::istream& _input, Vec3& _s )
33 {
34  return _input >> _s.m_x >> _s.m_y >> _s.m_z;
35 }
36 
37 
38 //----------------------------------------------------------------------------------------------------------------------
39 NGL_DLLEXPORT std::ostream& operator<<( std::ostream& _output, const Vec4& _v )
40 {
41  return _output<<"["<<_v.m_x<<","<<_v.m_y<<","<<_v.m_z<<","<<_v.m_w<<"]";
42 }
43 //----------------------------------------------------------------------------------------------------------------------
44 NGL_DLLEXPORT std::istream& operator>>(std::istream& _input, Vec4& _s)
45 {
46  return _input >> _s.m_x >> _s.m_y >> _s.m_z >> _s.m_w;
47 }
48 
49 //----------------------------------------------------------------------------------------------------------------------
50 NGL_DLLEXPORT std::ostream& operator<<(std::ostream& _output, const Camera &_c )
51 {
52  return _output<<"m_eye"<<_c.getEye()<<" m_look"<<_c.getLook()<<" Up"<<_c.getUp();
53 }
54 
55 //----------------------------------------------------------------------------------------------------------------------
56 NGL_DLLEXPORT std::ostream& operator<<( std::ostream &_output, const Colour& _s )
57 {
58  return _output<<"["<<_s.m_r<<","<<_s.m_g<<","<<_s.m_b<<","<<_s.m_a<<"]";
59 }
60 
61 //----------------------------------------------------------------------------------------------------------------------
62 
63 NGL_DLLEXPORT std::istream& operator>>( std::istream &_input, Colour &_s )
64 {
65  _input >> _s.m_r >> _s.m_g >> _s.m_b >> _s.m_a;
66  return _input;
67 }
68 
69 //----------------------------------------------------------------------------------------------------------------------
70 NGL_DLLEXPORT std::ostream& operator<<(std::ostream &_output,const Mat3 &_m )
71 {
72  std::cout.setf(std::ios::fixed|std::ios::adjustfield|std::ios::showpos);
73  std::cout.precision(12);
74  return _output
75  <<"["<<_m.m_00<<","<<_m.m_01<<","<<_m.m_02<<","<<"]"<<std::endl
76  <<"["<<_m.m_10<<","<<_m.m_11<<","<<_m.m_12<<","<<"]"<<std::endl
77  <<"["<<_m.m_20<<","<<_m.m_21<<","<<_m.m_22<<","<<"]"<<std::endl;
78 }
79 
80 //----------------------------------------------------------------------------------------------------------------------
81 NGL_DLLEXPORT std::ostream& operator<<(std::ostream &_output,const Mat4 &_m)
82 {
83  std::cout.setf(std::ios::fixed|std::ios::adjustfield|std::ios::showpos);
84  // std::cout.precision(std::numeric_limits<double>::digits10 + 1);
85  return _output
86  <<"["<<_m.m_00<<","<<_m.m_10<<","<<_m.m_20<<","<<_m.m_30<<"]"<<std::endl
87  <<"["<<_m.m_01<<","<<_m.m_11<<","<<_m.m_21<<","<<_m.m_31<<"]"<<std::endl
88  <<"["<<_m.m_02<<","<<_m.m_12<<","<<_m.m_22<<","<<_m.m_32<<"]"<<std::endl
89  <<"["<<_m.m_03<<","<<_m.m_13<<","<<_m.m_23<<","<<_m.m_33<<"]"<<std::endl;
90 
91 }
92 
93 //----------------------------------------------------------------------------------------------------------------------
94 //NGL_DLLEXPORT std::istream& operator >> ( std::istream& _ifs, Quaternion &_q )
95 //{
96 // //return _ifs >> _q.setS >> _q.m_x >> _q.m_y >> _q.m_z;
97 //}
98 //----------------------------------------------------------------------------------------------------------------------
99 NGL_DLLEXPORT std::ostream& operator << ( std::ostream& i_s, const Quaternion &i_q)
100 {
101  return i_s << i_q.getS() << " [" << i_q.getX() << "i," << i_q.getY() << "j," << i_q.getZ()<<"k]";
102 }
103 
104 }
Mat3 basic 3x3 matrix for certain glsl ops.
Definition: Mat3.h:43
Real m_11
individual matrix element maps to m_m[1][1] or m_openGL[5]
Definition: Mat4.h:316
Real m_21
individual matrix element maps to m_m[2][1] or m_openGL[9]
Definition: Mat4.h:320
Real m_00
individual matrix element maps to m_m[0][0] or m_openGL[0]
Definition: Mat3.h:256
simple Vec2 encapsulates a 3 float object like glsl Vec2 but not maths use the Vec2 class for maths a...
Definition: Vec2.h:49
simple class to hold colour information and set the basic opengl colour state. also has overloaded me...
Definition: Colour.h:40
simple Vector class for OpenGL graphics, contains overloaded operators for most math functions...
Definition: Vec4.h:57
Real m_r
red component of the colour tuple
Definition: Colour.h:160
a simple colour class for RGBA colour
Real m_12
individual matrix element maps to m_m[1][2] or m_openGL[6]
Definition: Mat3.h:276
Real m_22
individual matrix element maps to m_m[2][2] or m_openGL[10]
Definition: Mat4.h:321
Real m_b
blue component of the colour tuple
Definition: Colour.h:168
#define NGL_DLLEXPORT
Definition: Types.h:65
Real getZ() const noexcept
accesor for the z vector components
Definition: Quaternion.h:113
Real m_12
individual matrix element maps to m_m[1][2] or m_openGL[6]
Definition: Mat4.h:317
Real m_31
individual matrix element maps to m_m[3][1] or m_openGL[13]
Definition: Mat4.h:324
Real m_x
x component of the Vec2
Definition: Vec2.h:256
simple Vec3 encapsulates a 3 float object like glsl vec3 but not maths use the Vec3 class for maths a...
Definition: Vec3.h:51
implementation files for RibExport class
Definition: AABB.cpp:22
Real m_30
individual matrix element maps to m_m[3][0] or m_openGL[12]
Definition: Mat4.h:323
Real m_g
green component of the colour tuple
Definition: Colour.h:164
encapsulates a 4d Homogenous Point / Vector object
Real m_02
individual matrix element maps to m_m[0][2] or m_openGL[2]
Definition: Mat4.h:313
Real m_y
y component
Definition: Vec3.h:311
Vec4 getLook() const noexcept
get the look position
Definition: Camera.h:219
a simple 2 tuple container for compatibility with glsl
Real getX() const noexcept
accesor for the x vector components
Definition: Quaternion.h:103
a simple 3 tuple container for compatibility with glsl
Real m_y
y component of the Vec2
Definition: Vec2.h:260
Real m_z
z component
Definition: Vec4.h:323
simple camera class to allow movement in an opengl scene. a lot of this stuff is from the HILL book C...
Definition: Camera.h:54
Real m_01
individual matrix element maps to m_m[0][1] or m_openGL[1]
Definition: Mat4.h:312
Real m_00
individual matrix element maps to m_m[0][0] or m_openGL[0]
Definition: Mat4.h:311
Real getS() const noexcept
accesor for the scalar part
Definition: Quaternion.h:98
Real m_x
x component
Definition: Vec3.h:310
Real m_10
individual matrix element maps to m_m[1][0] or m_openGL[4]
Definition: Mat4.h:315
Defines the class Quaternion based on John Vinces lecture notes basically we have a scalar part and t...
Real m_11
individual matrix element maps to m_m[1][1] or m_openGL[5]
Definition: Mat3.h:272
Real m_13
individual matrix element maps to m_m[1][3] or m_openGL[7]
Definition: Mat4.h:318
Real m_23
individual matrix element maps to m_m[2][3] or m_openGL[11]
Definition: Mat4.h:322
NGL_DLLEXPORT std::ostream & operator<<(std::ostream &_output, const Vec2 &_v)
insertion operator to print out the Vec2
Definition: NGLStream.cpp:15
Vec4 getUp() const noexcept
get the up vector
Definition: Camera.h:224
Real m_x
x component
Definition: Vec4.h:321
a simple 3x3 TX matrix
Real m_10
individual matrix element maps to m_m[1][0] or m_openGL[4]
Definition: Mat3.h:268
Real m_20
individual matrix element maps to m_m[2][0] or m_openGL[8]
Definition: Mat3.h:280
Real m_a
alpha the transparent element
Definition: Colour.h:172
Real m_32
individual matrix element maps to m_m[3][2] or m_openGL[14]
Definition: Mat4.h:325
a simple camera class based on the Hill Book
Real m_21
individual matrix element maps to m_m[2][1] or m_openGL[9]
Definition: Mat3.h:284
Matrix Class to do simple matrix operations included operator overloaded functions for maths and matr...
Definition: Mat4.h:58
Vec4 getEye() const noexcept
get the eye position
Definition: Camera.h:205
Real getY() const noexcept
accesor for the y vector components
Definition: Quaternion.h:108
Real m_20
individual matrix element maps to m_m[2][0] or m_openGL[8]
Definition: Mat4.h:319
Real m_w
w component 0 for vector 1 for point
Definition: Vec4.h:324
Real m_03
individual matrix element maps to m_m[0][3] or m_openGL[3]
Definition: Mat4.h:314
Real m_y
y component
Definition: Vec4.h:322
Real m_02
individual matrix element maps to m_m[0][2] or m_openGL[2]
Definition: Mat3.h:264
NGL_DLLEXPORT std::istream & operator>>(std::istream &_input, Vec2 &_s)
extraction operator to read in the Vec2
Definition: NGLStream.cpp:20
Real m_33
individual matrix element maps to m_m[3][3] or m_openGL[15]
Definition: Mat4.h:326
Real m_01
individual matrix element maps to m_m[0][1] or m_openGL[1]
Definition: Mat3.h:260
Real m_z
z component
Definition: Vec3.h:312
Real m_22
individual matrix element maps to m_m[2][2] or m_openGL[10]
Definition: Mat3.h:288