00001 /* SimData: Data Infrastructure for Simulations 00002 * Copyright (C) 2002 Mark Rose <tm2@stm.lbl.gov> 00003 * 00004 * This file is part of SimData. 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 */ 00020 00021 00031 #ifndef __SIMDATA_OSG_H__ 00032 #define __SIMDATA_OSG_H__ 00033 00034 #include <SimData/Namespace.h> 00035 #include <SimData/Vector3.h> 00036 #include <SimData/Matrix3.h> 00037 #include <SimData/Quat.h> 00038 00039 #include <osg/Vec3> 00040 #include <osg/Matrix> 00041 #include <osg/Quat> 00042 00043 NAMESPACE_SIMDATA 00044 00049 00051 inline osg::Vec3 toOSG(Vector3 const &v) { 00052 return osg::Vec3(static_cast<float>(v.x()), 00053 static_cast<float>(v.y()), 00054 static_cast<float>(v.z())); 00055 } 00056 00058 inline Vector3 fromOSG(osg::Vec3 const &v) { 00059 return Vector3(v.x(), v.y(), v.z()); 00060 } 00061 00063 inline osg::Matrix toOSG(Matrix3 const &m) { 00064 // transpose: osg matrix convension is v * M 00065 return osg::Matrix(m(0, 0), m(1, 0), m(2, 0), 0.0, 00066 m(0, 1), m(1, 1), m(2, 1), 0.0, 00067 m(0, 2), m(1, 2), m(2, 2), 0.0, 00068 0.0, 0.0, 0.0, 1.0); 00069 } 00070 00072 inline Matrix3 fromOSG(osg::Matrix const &m) { 00073 // transpose: osg matrix convension is v * M 00074 return Matrix3(m(0, 0), m(1, 0), m(2, 0), 00075 m(0, 1), m(1, 1), m(2, 1), 00076 m(0, 2), m(1, 2), m(2, 2)); 00077 } 00078 00080 inline osg::Quat toOSG(Quat const &q) { 00081 return osg::Quat(static_cast<float>(q.x()), 00082 static_cast<float>(q.y()), 00083 static_cast<float>(q.z()), 00084 static_cast<float>(q.w())); 00085 } 00086 00088 inline Quat fromOSG(osg::Quat const &q) { 00089 return Quat(q.x(), q.y(), q.z(), q.w()); 00090 } 00091 00092 00094 00095 00096 NAMESPACE_SIMDATA_END 00097 00098 00099 #endif //__SIMDATA_OSG_H__ 00100
|
SimData version pre-0.4.0. For more information on SimData, visit the SimData Homepage. Generated on Tue Oct 14 12:06:39 2003, using Doxygen 1.2.18. |