root/OpenSceneGraph/trunk/src/osg/PositionAttitudeTransform.cpp @ 5328

Revision 5328, 2.1 kB (checked in by robert, 8 years ago)

Updated copyright years.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
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#include <osg/PositionAttitudeTransform>
14
15using namespace osg;
16
17PositionAttitudeTransform::PositionAttitudeTransform():
18    _scale(1.0f,1.0f,1.0f)
19{
20}
21
22bool PositionAttitudeTransform::computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const
23{
24    if (_referenceFrame==RELATIVE_RF)
25    {
26        matrix.preMult(osg::Matrix::translate(-_pivotPoint)*
27                       osg::Matrix::scale(_scale)*
28                       osg::Matrix::rotate(_attitude)*
29                       osg::Matrix::translate(_position));
30    }
31    else // absolute
32    {
33        matrix = osg::Matrix::translate(-_pivotPoint)*
34                 osg::Matrix::scale(_scale)*
35                 osg::Matrix::rotate(_attitude)*
36                 osg::Matrix::translate(_position);
37    }
38    return true;
39}
40
41
42bool PositionAttitudeTransform::computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor*) const
43{
44    if (_referenceFrame==RELATIVE_RF)
45    {
46        matrix.postMult(osg::Matrix::translate(-_position)*
47                        osg::Matrix::rotate(_attitude.inverse())*
48                        osg::Matrix::scale(1.0f/_scale.x(),1.0f/_scale.y(),1.0f/_scale.z())*
49                        osg::Matrix::translate(_pivotPoint));
50    }
51    else // absolute
52    {
53        matrix = osg::Matrix::translate(-_position)*
54                 osg::Matrix::rotate(_attitude.inverse())*
55                 osg::Matrix::scale(1.0f/_scale.x(),1.0f/_scale.y(),1.0f/_scale.z())*
56                 osg::Matrix::translate(_pivotPoint);
57    }
58    return true;
59}
Note: See TracBrowser for help on using the browser.