OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Vec4i.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_VEC4I
15 #define OSG_VEC4I 1
16 
17 namespace osg {
18 
21 class Vec4i
22 {
23  public:
24 
26  typedef int value_type;
27 
29  enum { num_components = 4 };
30 
32  value_type _v[4];
33 
34  Vec4i() { _v[0]=0; _v[1]=0; _v[2]=0; _v[3]=0; }
35 
36  Vec4i(value_type x, value_type y, value_type z, value_type w)
37  {
38  _v[0]=x;
39  _v[1]=y;
40  _v[2]=z;
41  _v[3]=w;
42  }
43 
44  inline bool operator == (const Vec4i& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1] && _v[2]==v._v[2] && _v[3]==v._v[3]; }
45  inline bool operator != (const Vec4i& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1] || _v[2]!=v._v[2] || _v[3]!=v._v[3]; }
46  inline bool operator < (const Vec4i& v) const
47  {
48  if (_v[0]<v._v[0]) return true;
49  else if (_v[0]>v._v[0]) return false;
50  else if (_v[1]<v._v[1]) return true;
51  else if (_v[1]>v._v[1]) return false;
52  else if (_v[2]<v._v[2]) return true;
53  else if (_v[2]>v._v[2]) return false;
54  else return (_v[3]<v._v[3]);
55  }
56 
57  inline value_type* ptr() { return _v; }
58  inline const value_type* ptr() const { return _v; }
59 
60  inline void set( value_type x, value_type y, value_type z, value_type w)
61  {
62  _v[0]=x; _v[1]=y; _v[2]=z; _v[3]=w;
63  }
64 
65  inline value_type& operator [] (unsigned int i) { return _v[i]; }
66  inline value_type operator [] (unsigned int i) const { return _v[i]; }
67 
68  inline value_type& x() { return _v[0]; }
69  inline value_type& y() { return _v[1]; }
70  inline value_type& z() { return _v[2]; }
71  inline value_type& w() { return _v[3]; }
72 
73  inline value_type x() const { return _v[0]; }
74  inline value_type y() const { return _v[1]; }
75  inline value_type z() const { return _v[2]; }
76  inline value_type w() const { return _v[3]; }
77 
78  inline value_type& r() { return _v[0]; }
79  inline value_type& g() { return _v[1]; }
80  inline value_type& b() { return _v[2]; }
81  inline value_type& a() { return _v[3]; }
82 
83  inline value_type r() const { return _v[0]; }
84  inline value_type g() const { return _v[1]; }
85  inline value_type b() const { return _v[2]; }
86  inline value_type a() const { return _v[3]; }
87 
88  inline Vec4i operator * (value_type rhs) const
89  {
90  return Vec4i(_v[0]*rhs, _v[1]*rhs, _v[2]*rhs, _v[3]*rhs);
91  }
92 
93  inline Vec4i operator / (value_type rhs) const
94  {
95  return Vec4i(_v[0]/rhs, _v[1]/rhs, _v[2]/rhs, _v[3]/rhs);
96  }
97 
98  inline Vec4i operator + (value_type rhs) const
99  {
100  return Vec4i(_v[0]+rhs, _v[1]+rhs, _v[2]+rhs, _v[3]+rhs);
101  }
102 
103  inline Vec4i operator - (value_type rhs) const
104  {
105  return Vec4i(_v[0]-rhs, _v[1]-rhs, _v[2]-rhs, _v[3]-rhs);
106  }
107 
108  inline Vec4i operator + (const Vec4i& rhs) const
109  {
110  return Vec4i(_v[0]+rhs._v[0], _v[1]+rhs._v[1], _v[2]+rhs._v[2], _v[3]+rhs._v[3]);
111  }
112 
113  inline Vec4i operator - (const Vec4i& rhs) const
114  {
115  return Vec4i(_v[0]-rhs._v[0], _v[1]-rhs._v[1], _v[2]-rhs._v[2], _v[3]-rhs._v[3]);
116  }
117 
118  inline Vec4i operator * (const Vec4i& rhs) const
119  {
120  return Vec4i(_v[0]*rhs._v[0], _v[1]*rhs._v[1], _v[2]*rhs._v[2], _v[3]*rhs._v[3]);
121  }
122 };
123 
124 }
125 
126 #endif
value_type _v[4]
Definition: Vec4i.h:32
Vec4i operator*(value_type rhs) const
Definition: Vec4i.h:88
value_type & operator[](unsigned int i)
Definition: Vec4i.h:65
value_type y() const
Definition: Vec4i.h:74
void set(value_type x, value_type y, value_type z, value_type w)
Definition: Vec4i.h:60
value_type * ptr()
Definition: Vec4i.h:57
value_type & x()
Definition: Vec4i.h:68
Vec4i operator+(value_type rhs) const
Definition: Vec4i.h:98
value_type & z()
Definition: Vec4i.h:70
value_type w() const
Definition: Vec4i.h:76
value_type & b()
Definition: Vec4i.h:80
value_type & r()
Definition: Vec4i.h:78
value_type g() const
Definition: Vec4i.h:84
bool operator<(const Vec4i &v) const
Definition: Vec4i.h:46
value_type & g()
Definition: Vec4i.h:79
bool operator==(const Vec4i &v) const
Definition: Vec4i.h:44
Vec4i operator/(value_type rhs) const
Definition: Vec4i.h:93
bool operator!=(const Vec4i &v) const
Definition: Vec4i.h:45
value_type z() const
Definition: Vec4i.h:75
Vec4i operator-(value_type rhs) const
Definition: Vec4i.h:103
value_type a() const
Definition: Vec4i.h:86
value_type & a()
Definition: Vec4i.h:81
Vec4i()
Definition: Vec4i.h:34
Vec4i(value_type x, value_type y, value_type z, value_type w)
Definition: Vec4i.h:36
value_type & y()
Definition: Vec4i.h:69
Definition: AlphaFunc.h:19
const value_type * ptr() const
Definition: Vec4i.h:58
value_type x() const
Definition: Vec4i.h:73
value_type b() const
Definition: Vec4i.h:85
value_type r() const
Definition: Vec4i.h:83
int value_type
Definition: Vec4i.h:26
value_type & w()
Definition: Vec4i.h:71