OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ConvertVec.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 OSGUTIL_CONVERTVEC
15 #define OSGUTIL_CONVERTVEC 1
16 
17 namespace osgUtil {
18 
19 template <typename InType, typename OutType,
20  unsigned int InSize = InType::num_components,
21  unsigned int OutSize = OutType::num_components>
22 struct ConvertVec
23 {
24  static void convert(InType & in, OutType & out)
25  {}
26 };
27 
28 
29 
30 template <typename InType, typename OutType>
31 struct ConvertVec<InType, OutType, 2, 2>
32 {
33  static void convert(InType & in, OutType & out)
34  {
35  out.set(static_cast<typename OutType::value_type>(in.x()),
36  static_cast<typename OutType::value_type>(in.y()));
37  }
38 };
39 
40 template <typename InType, typename OutType>
41 struct ConvertVec<InType, OutType, 2, 3>
42 {
43  static void convert(InType & in, OutType & out)
44  {
45  out.set(static_cast<typename OutType::value_type>(in.x()),
46  static_cast<typename OutType::value_type>(in.y()),
47  static_cast<typename OutType::value_type>(0.0));
48  }
49 };
50 
51 template <typename InType, typename OutType>
52 struct ConvertVec<InType, OutType, 2, 4>
53 {
54  static void convert(InType & in, OutType & out)
55  {
56  out.set(static_cast<typename OutType::value_type>(in.x()),
57  static_cast<typename OutType::value_type>(in.y()),
58  static_cast<typename OutType::value_type>(0.0),
59  static_cast<typename OutType::value_type>(1.0));
60  }
61 };
62 
63 
64 
65 
66 
67 template <typename InType, typename OutType>
68 struct ConvertVec<InType, OutType, 3, 2>
69 {
70  static void convert(InType & in, OutType & out)
71  {
72  out.set(static_cast<typename OutType::value_type>(in.x()),
73  static_cast<typename OutType::value_type>(in.y()));
74  }
75 };
76 
77 template <typename InType, typename OutType>
78 struct ConvertVec<InType, OutType, 3, 3>
79 {
80  static void convert(InType & in, OutType & out)
81  {
82  out.set(static_cast<typename OutType::value_type>(in.x()),
83  static_cast<typename OutType::value_type>(in.y()),
84  static_cast<typename OutType::value_type>(in.z()));
85  }
86 };
87 
88 template <typename InType, typename OutType>
89 struct ConvertVec<InType, OutType, 3, 4>
90 {
91  static void convert(InType & in, OutType & out)
92  {
93  out.set(static_cast<typename OutType::value_type>(in.x()),
94  static_cast<typename OutType::value_type>(in.y()),
95  static_cast<typename OutType::value_type>(in.z()),
96  static_cast<typename OutType::value_type>(1.0));
97  }
98 };
99 
100 
101 
102 
103 
104 template <typename InType, typename OutType>
105 struct ConvertVec<InType, OutType, 4, 2>
106 {
107  static void convert(InType & in, OutType & out)
108  {
109  out.set(static_cast<typename OutType::value_type>(in.x()/in.w()),
110  static_cast<typename OutType::value_type>(in.y()/in.w()));
111  }
112 };
113 
114 template <typename InType, typename OutType>
115 struct ConvertVec<InType, OutType, 4, 3>
116 {
117  static void convert(InType & in, OutType & out)
118  {
119  out.set(static_cast<typename OutType::value_type>(in.x()/in.w()),
120  static_cast<typename OutType::value_type>(in.y()/in.w()),
121  static_cast<typename OutType::value_type>(in.z()/in.w()));
122  }
123 };
124 
125 template <typename InType, typename OutType>
126 struct ConvertVec<InType, OutType, 4, 4>
127 {
128  static void convert(InType & in, OutType & out)
129  {
130  out.set(static_cast<typename OutType::value_type>(in.x()),
131  static_cast<typename OutType::value_type>(in.y()),
132  static_cast<typename OutType::value_type>(in.z()),
133  static_cast<typename OutType::value_type>(in.w()));
134  }
135 };
136 
137 } // end of osg namespace
138 
139 #endif // ** OSG_CONVERTVEC ** //
static void convert(InType &in, OutType &out)
Definition: ConvertVec.h:128
static void convert(InType &in, OutType &out)
Definition: ConvertVec.h:80
static void convert(InType &in, OutType &out)
Definition: ConvertVec.h:54
static void convert(InType &in, OutType &out)
Definition: ConvertVec.h:70
static void convert(InType &in, OutType &out)
Definition: ConvertVec.h:91
static void convert(InType &in, OutType &out)
Definition: ConvertVec.h:43
static void convert(InType &in, OutType &out)
Definition: ConvertVec.h:107
static void convert(InType &in, OutType &out)
Definition: ConvertVec.h:117
static void convert(InType &in, OutType &out)
Definition: ConvertVec.h:24
static void convert(InType &in, OutType &out)
Definition: ConvertVec.h:33
Shader generator framework.
Definition: RenderInfo.h:20