| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | #include <osg/PositionAttitudeTransform> |
|---|
| 14 | |
|---|
| 15 | using namespace osg; |
|---|
| 16 | |
|---|
| 17 | PositionAttitudeTransform::PositionAttitudeTransform(): |
|---|
| 18 | _scale(1.0f,1.0f,1.0f) |
|---|
| 19 | { |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | bool 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 |
|---|
| 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 | |
|---|
| 42 | bool 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 |
|---|
| 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 | } |
|---|