15 #include <osg/Version>
16 #if (OSG_VERSION_MAJOR==2 && OSG_VERSION_MINOR<6) || OSG_VERSION_MAJOR<2
17 #define OSG_USE_FLOAT_MATRIX
22 #include <osg/BoundingBox>
23 #include <osg/BoundingSphere>
26 #ifdef OSG_USE_FLOAT_MATRIX
27 typedef float osg_matrix_value;
29 typedef double osg_matrix_value;
35 inline void v2s(
const FPoint2 &f, osg::Vec2 &s) { s[0] = f.x; s[1] = f.y; }
36 inline void v2s(
const FPoint3 &f, osg::Vec3 &s) { s[0] = f.x; s[1] = f.y; s[2] = f.z; }
37 inline void v2s(
const RGBf &f, osg::Vec3 &s) { s[0] = f.r; s[1] = f.g; s[2] = f.b; }
38 inline void v2s(
const RGBAf &f, osg::Vec4 &s) { s[0] = f.r; s[1] = f.g; s[2] = f.b; s[3] = f.a; }
40 inline osg::Vec3 v2s(
const FPoint3 &f)
43 s[0] = f.x; s[1] = f.y; s[2] = f.z;
47 inline osg::Vec4 v2s(
const RGBf &f)
50 s[0] = f.r; s[1] = f.g; s[2] = f.b; s[3] = 1.0f;
54 inline osg::Vec4 v2s(
const RGBAf &f)
57 s[0] = f.r; s[1] = f.g; s[2] = f.b; s[3] = f.a;
61 inline void v2s(
const FSphere &sph, osg::BoundingSphere &bs)
63 v2s(sph.center, bs._center);
64 bs._radius = sph.radius;
67 inline void s2v(
const osg::Vec3 &s,
FPoint3 &f) { f.x = s[0]; f.y = s[1]; f.z = s[2]; }
68 inline void s2v(
const osg::Vec2 &s,
FPoint2 &f) { f.x = s[0]; f.y = s[1]; }
69 inline void s2v(
const osg::Vec3 &s,
RGBf &f) { f.r = s[0]; f.g = s[1]; f.b = s[2]; }
70 inline void s2v(
const osg::Vec4 &s,
RGBAf &f) { f.r = s[0]; f.g = s[1]; f.b = s[2]; f.a = s[3]; }
72 inline void s2v(
const osg::BoundingSphere &bs,
FSphere &sph)
74 s2v(bs._center, sph.center);
75 sph.radius = bs._radius;
78 inline void s2v(
const osg::BoundingBox &bs,
FBox3 &box)
80 box.min.x = bs._min[0];
81 box.min.y = bs._min[1];
82 box.min.z = bs._min[2];
84 box.max.x = bs._max[0];
85 box.max.y = bs._max[1];
86 box.max.z = bs._max[2];
89 inline FPoint3 s2v(
const osg::Vec3 &s)
92 f.x = s[0]; f.y = s[1]; f.z = s[2];
96 inline RGBf s2v(
const osg::Vec4 &s)
99 f.r = s[0]; f.g = s[1]; f.b = s[2];
103 inline void ConvertMatrix4(
const osg::Matrix *mat_osg,
FMatrix4 *mat)
105 const osg_matrix_value *ptr = mat_osg->ptr();
107 for (i = 0; i < 4; i++)
108 for (j = 0; j < 4; j++)
110 mat->Set(j, i, ptr[(i<<2)+j]);
114 inline void ConvertMatrix4(
const FMatrix4 *mat, osg::Matrix *mat_osg)
116 osg_matrix_value *ptr = mat_osg->ptr();
118 for (i = 0; i < 4; i++)
119 for (j = 0; j < 4; j++)
121 ptr[(i<<2)+j] = mat->Get(j, i);
130 vtVec3(
const osg::Vec3& v) : osg::Vec3(v) {}
138 vtVec2(
const osg::Vec2& v) : osg::Vec2(v) {}
147 #endif // VTOSG_MATHH