/* -*-c++-*- * Copyright (C) 2008 Cedric Pinson * * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. */ #ifndef OSGANIMATION_CUBIC_BEZIER_H #define OSGANIMATION_CUBIC_BEZIER_H #include #include #include #include namespace osgAnimation { template struct TemplateCubicBezier { T mPoint[3]; const T& getP0() const { return mPoint[0];} const T& getP1() const { return mPoint[1];} const T& getP2() const { return mPoint[2];} TemplateCubicBezier(const T& v0, const T& v1, const T& v2) { mPoint[0] = v0; mPoint[1] = v1; mPoint[2] = v2; } TemplateCubicBezier() {} const T& getPosition() const { return mPoint[0];} const T& getTangentPoint1() const { return mPoint[1];} const T& getTangentPoint2() const { return mPoint[2];} // steaming operators. friend std::ostream& operator << (std::ostream& output, const TemplateCubicBezier& vec) { output << vec.mPoint[0] << " " << vec.mPoint[1] << " " << vec.mPoint[2]; return output; // to enable cascading } friend std::istream& operator >> (std::istream& input, TemplateCubicBezier& vec) { input >> vec.mPoint[0] >> vec.mPoint[1] >> vec.mPoint[2]; return input; } }; typedef TemplateCubicBezier FloatCubicBezier; typedef TemplateCubicBezier DoubleCubicBezier; typedef TemplateCubicBezier Vec2CubicBezier; typedef TemplateCubicBezier Vec3CubicBezier; typedef TemplateCubicBezier Vec4CubicBezier; } #endif