My Project
 All Classes Files Functions Variables Enumerations Pages
vertex.h
Go to the documentation of this file.
1 /**************************************************************************/
2 /* Copyright 2009 Tim Day */
3 /* */
4 /* This file is part of Fracplanet */
5 /* */
6 /* Fracplanet is free software: you can redistribute it and/or modify */
7 /* it under the terms of the GNU General Public License as published by */
8 /* the Free Software Foundation, either version 3 of the License, or */
9 /* (at your option) any later version. */
10 /* */
11 /* Fracplanet is distributed in the hope that it will be useful, */
12 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
14 /* GNU General Public License for more details. */
15 /* */
16 /* You should have received a copy of the GNU General Public License */
17 /* along with Fracplanet. If not, see <http://www.gnu.org/licenses/>. */
18 /**************************************************************************/
19 
24 #ifndef _vertex_h_
25 #define _vertex_h_
26 
27 #include "rgb.h"
28 #include "xyz.h"
29 
31 
35 class Vertex
36 {
37  public:
38 
41  {}
42 
44  Vertex(const Vertex& v)
45  :_position(v._position)
46  ,_normal(v._normal)
47  {
48  _colour[0]=v._colour[0];
49  _colour[1]=v._colour[1];
50  }
51 
53  explicit Vertex(const XYZ& p)
54  :_position(p)
55  ,_normal(0.0,0.0,0.0)
56  {
57  _colour[0]=ByteRGBA(0,0,0,255);
58  _colour[1]=ByteRGBA(0,0,0,255);
59  }
60 
62  const XYZ& position() const
63  {
64  return _position;
65  }
66 
68  const XYZ& normal() const
69  {
70  return _normal;
71  }
72 
74  const ByteRGBA& colour(uint c) const
75  {
76  assert(c<2);
77  return _colour[c];
78  }
79 
81  void position(const XYZ& p)
82  {
83  _position=p;
84  }
85 
87  void normal(const XYZ& n)
88  {
89  _normal=n;
90  }
91 
93  void colour(uint c,const ByteRGBA& col)
94  {
95  assert(c<2);
96  _colour[c]=col;
97  }
98 
100  void colour(uint c,const FloatRGBA& col)
101  {
102  assert(c<2);
103  _colour[c]=ByteRGBA(col);
104  }
105 
106  private:
107 
109  XYZ _position;
110 
112  XYZ _normal;
113 
115 
119  ByteRGBA _colour[2];
120 };
121 
122 #endif
Class to represent red-green-blue-alpha colours stored with 8-bit resolution.
Definition: rgb.h:136
Interface for class XYZ.
const XYZ & position() const
Accessor.
Definition: vertex.h:62
Interface for class ByteRGBA and class FloatRGBA.
Vertex()
Constructor. NB Almost no default values set.
Definition: vertex.h:40
void normal(const XYZ &n)
Accessor.
Definition: vertex.h:87
void colour(uint c, const FloatRGBA &col)
Accessor.
Definition: vertex.h:100
Class to hold vectors in 3D cartesian co-ordinates.
Definition: xyz.h:34
Vertex(const XYZ &p)
Construct from position only.
Definition: vertex.h:53
void position(const XYZ &p)
Accessor.
Definition: vertex.h:81
const XYZ & normal() const
Accessor.
Definition: vertex.h:68
Class to represent red-green-blue-alpha colours stored to floating point accuracy.
Definition: rgb.h:173
Vertex(const Vertex &v)
Copy constructor.
Definition: vertex.h:44
const ByteRGBA & colour(uint c) const
Accessor.
Definition: vertex.h:74
void colour(uint c, const ByteRGBA &col)
Accessor.
Definition: vertex.h:93
Class to store vertex state information.
Definition: vertex.h:35