OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Vec3ui.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSG_VEC3UI
15 #define OSG_VEC3UI 1
16 
17 namespace osg {
18 
21 class Vec3ui
22 {
23  public:
24 
26  typedef unsigned int value_type;
27 
29  enum { num_components = 3 };
30 
32  value_type _v[3];
33 
34  Vec3ui() { _v[0]=0; _v[1]=0; _v[2]=0; }
35 
36  Vec3ui(value_type r, value_type g, value_type b) { _v[0]=r; _v[1]=g; _v[2]=b; }
37 
38  inline bool operator == (const Vec3ui& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1] && _v[2]==v._v[2]; }
39  inline bool operator != (const Vec3ui& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1] || _v[2]!=v._v[2]; }
40  inline bool operator < (const Vec3ui& v) const
41  {
42  if (_v[0]<v._v[0]) return true;
43  else if (_v[0]>v._v[0]) return false;
44  else if (_v[1]<v._v[1]) return true;
45  else if (_v[1]>v._v[1]) return false;
46  else return (_v[2]<v._v[2]);
47  }
48 
49  inline value_type* ptr() { return _v; }
50  inline const value_type* ptr() const { return _v; }
51 
52  inline void set(value_type r, value_type g, value_type b)
53  {
54  _v[0]=r; _v[1]=g; _v[2]=b;
55  }
56 
57  inline void set( const Vec3ui& rhs)
58  {
59  _v[0]=rhs._v[0]; _v[1]=rhs._v[1]; _v[2]=rhs._v[2];
60  }
61 
62  inline value_type& operator [] (unsigned int i) { return _v[i]; }
63  inline value_type operator [] (unsigned int i) const { return _v[i]; }
64 
65  inline value_type& x() { return _v[0]; }
66  inline value_type& y() { return _v[1]; }
67  inline value_type& z() { return _v[2]; }
68 
69  inline value_type x() const { return _v[0]; }
70  inline value_type y() const { return _v[1]; }
71  inline value_type z() const { return _v[2]; }
72 
73  inline value_type& r() { return _v[0]; }
74  inline value_type& g() { return _v[1]; }
75  inline value_type& b() { return _v[2]; }
76 
77  inline value_type r() const { return _v[0]; }
78  inline value_type g() const { return _v[1]; }
79  inline value_type b() const { return _v[2]; }
80 
82  inline Vec3ui operator * (value_type rhs) const
83  {
84  return Vec3ui(_v[0]*rhs, _v[1]*rhs, _v[2]*rhs);
85  }
86 
87  inline Vec3ui operator / (value_type rhs) const
88  {
89  return Vec3ui(_v[0]/rhs, _v[1]/rhs, _v[2]/rhs);
90  }
91 
92  inline Vec3ui operator + (value_type rhs) const
93  {
94  return Vec3ui(_v[0]+rhs, _v[1]+rhs, _v[2]+rhs);
95  }
96 
97  inline Vec3ui operator - (value_type rhs) const
98  {
99  return Vec3ui(_v[0]-rhs, _v[1]-rhs, _v[2]-rhs);
100  }
101 
102  inline Vec3ui operator + (const Vec3ui& rhs) const
103  {
104  return Vec3ui(_v[0]+rhs._v[0], _v[1]+rhs._v[1], _v[2]+rhs._v[2]);
105  }
106 
107  inline Vec3ui operator - (const Vec3ui& rhs) const
108  {
109  return Vec3ui(_v[0]-rhs._v[0], _v[1]-rhs._v[1], _v[2]-rhs._v[2]);
110  }
111 
112  inline Vec3ui operator * (const Vec3ui& rhs) const
113  {
114  return Vec3ui(_v[0]*rhs._v[0], _v[1]*rhs._v[1], _v[2]*rhs._v[2]);
115  }
116 };
117 
118 }
119 
120 #endif
Vec3ui operator+(value_type rhs) const
Definition: Vec3ui.h:92
value_type & r()
Definition: Vec3ui.h:73
unsigned int value_type
Definition: Vec3ui.h:26
value_type x() const
Definition: Vec3ui.h:69
value_type * ptr()
Definition: Vec3ui.h:49
bool operator!=(const Vec3ui &v) const
Definition: Vec3ui.h:39
const value_type * ptr() const
Definition: Vec3ui.h:50
value_type _v[3]
Definition: Vec3ui.h:32
void set(const Vec3ui &rhs)
Definition: Vec3ui.h:57
Vec3ui operator-(value_type rhs) const
Definition: Vec3ui.h:97
Vec3ui(value_type r, value_type g, value_type b)
Definition: Vec3ui.h:36
value_type & b()
Definition: Vec3ui.h:75
value_type & x()
Definition: Vec3ui.h:65
Vec3ui operator/(value_type rhs) const
Definition: Vec3ui.h:87
value_type & y()
Definition: Vec3ui.h:66
value_type r() const
Definition: Vec3ui.h:77
value_type & operator[](unsigned int i)
Definition: Vec3ui.h:62
value_type b() const
Definition: Vec3ui.h:79
value_type z() const
Definition: Vec3ui.h:71
value_type & z()
Definition: Vec3ui.h:67
Vec3ui operator*(value_type rhs) const
Definition: Vec3ui.h:82
void set(value_type r, value_type g, value_type b)
Definition: Vec3ui.h:52
value_type y() const
Definition: Vec3ui.h:70
Definition: AlphaFunc.h:19
value_type g() const
Definition: Vec3ui.h:78
value_type & g()
Definition: Vec3ui.h:74
bool operator<(const Vec3ui &v) const
Definition: Vec3ui.h:40
bool operator==(const Vec3ui &v) const
Definition: Vec3ui.h:38
Vec3ui()
Definition: Vec3ui.h:34