AnimatLab  2
Test
OsgMatrixUtil.h
1 /*
2 * Delta3D Open Source Game and Simulation Engine
3 * Copyright (C) 2004-2005 MOVES Institute
4 *
5 * This library is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License as published by the Free
7 * Software Foundation; either version 2.1 of the License, or (at your option)
8 * any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */
20 
21 #pragma once
22 
23 #include <osg/Matrix>
24 #include <osg/Vec3>
25 #include <osg/Vec4>
26 
27 namespace OsgAnimatSim
28 {
34  class ANIMAT_OSG_PORT OsgMatrixUtil
35  {
36  public:
37 
38  virtual osg::Matrix SetupMatrix(CStdFPoint &localPos, CStdFPoint &localRot);
39  virtual CStdFPoint EulerRotationFromMatrix(osg::Matrix osgMT);
40 
41  static CStdFPoint EulerRotationFromMatrix_Static(osg::Matrix osgMT);
42 
44  static void Print( const osg::Matrix& matrix );
46  static void Print( const osg::Vec3& vec );
48  static void Print( const osg::Vec4& vec );
49 
51  static float ClampUnity( float x );
52 
54  //@param dest: matrix to store result
55  //@param src: matrix to transpose
56  static void Transpose( osg::Matrix& dest, const osg::Matrix& src );
57 
58  /*
59  NOTE: We are ROW MAJOR so a column doesnt mean anything to us
60  unfortunately the old implementation of Get/Set Row and Get/Set Column
61  were reversed
62  -I have commented out Get/Set Column to enforce ppl to change that call
63  to Get/Set Row
64  */
65 
66  //static osg::Vec3 GetColumn3( const osg::Matrix& matrix, int column );
67  //static osg::Vec4 GetColumn4( const osg::Matrix& matrix, int column );
68 
69  static osg::Vec3 GetRow3( const osg::Matrix& matrix, int row );
70  static osg::Vec4 GetRow4( const osg::Matrix& matrix, int row );
71 
72  //static void SetColumn( osg::Matrix& matrix, const osg::Vec3& vec, int column );
73  //static void SetColumn( osg::Matrix& matrix, const osg::Vec4& vec, int column );
74 
75  static void SetRow( osg::Matrix& matrix, const osg::Vec3& vec, int row );
76  static void SetRow( osg::Matrix& matrix, const osg::Vec4& vec, int row );
77 
84  static void HprToMatrix( osg::Matrix& rotation, const osg::Vec3& hpr );
85 
93  static void PositionAndHprToMatrix( osg::Matrix& rotation, const osg::Vec3& xyz, const osg::Vec3& hpr );
94 
95  static void PositionAndHprRadToMatrix( osg::Matrix& rotation, const osg::Vec3& xyz, const osg::Vec3& hpr );
96 
102  static void MatrixToHpr( osg::Vec3& hpr, const osg::Matrix& rotation );
103 
109  static void MatrixToHprRad(osg::Vec3& hpr, const osg::Matrix& rotation);
110 
118  static void MatrixToHprAndPosition( osg::Vec3& xyz, osg::Vec3& hpr, const osg::Matrix& rotation );
119 
126  static void TransformVec3(osg::Vec3& xyz, const osg::Matrix& transformMat);
127 
135  static void TransformVec3(osg::Vec3& vec_in, const osg::Vec3& xyz, const osg::Matrix& transformMat);
136 
137  };
138 }
139 
Classes for implementing the cm-labs vortex physics engine for AnimatLab.