Changeset 8868
- Timestamp:
- 09/17/08 18:14:28 (5 years ago)
- Location:
- OpenSceneGraph/trunk
- Files:
-
- 21 modified
-
examples/osgdepthpeeling/osgdepthpeeling.cpp (modified) (1 diff)
-
examples/osghangglide/osghangglide.cpp (modified) (2 diffs)
-
examples/osglogo/osglogo.cpp (modified) (1 diff)
-
examples/osgsimulation/osgsimulation.cpp (modified) (1 diff)
-
examples/osgunittests/UnitTests_osg.cpp (modified) (2 diffs)
-
examples/osgvertexprogram/osgvertexprogram.cpp (modified) (2 diffs)
-
include/osg/AnimationPath (modified) (1 diff)
-
include/osg/Matrixd (modified) (2 diffs)
-
include/osg/Matrixf (modified) (2 diffs)
-
src/osg/AutoTransform.cpp (modified) (2 diffs)
-
src/osg/CameraView.cpp (modified) (2 diffs)
-
src/osg/Matrix_implementation.cpp (modified) (3 diffs)
-
src/osg/PositionAttitudeTransform.cpp (modified) (3 diffs)
-
src/osgManipulator/AntiSquish.cpp (modified) (4 diffs)
-
src/osgParticle/PrecipitationEffect.cpp (modified) (1 diff)
-
src/osgSim/DOFTransform.cpp (modified) (2 diffs)
-
src/osgSim/Sector.cpp (modified) (1 diff)
-
src/osgText/Text.cpp (modified) (3 diffs)
-
src/osgText/Text3D.cpp (modified) (1 diff)
-
src/osgUtil/SceneGraphBuilder.cpp (modified) (3 diffs)
-
src/osgViewer/View.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgdepthpeeling/osgdepthpeeling.cpp
r7648 r8868 175 175 void rotate(float x, float y) 176 176 { 177 osg::Matrixd baseMatrix = _modelGroupTransform->getMatrix(); 178 179 osg::Matrixd preTransMatrix; 180 osg::Matrixd postTransMatrix; 181 osg::Matrixd rotMatrixX; 182 osg::Matrixd rotMatrixZ; 183 184 preTransMatrix.makeTranslate(_rotCenter); 185 postTransMatrix.makeTranslate(-_rotCenter); 186 187 rotMatrixZ.makeRotate((x - _prevX) * 3., osg::Vec3d(0.0, 0.0,1.0)); 188 189 baseMatrix.preMult(preTransMatrix); 190 baseMatrix.preMult(rotMatrixZ); 191 baseMatrix.preMult(postTransMatrix); 192 193 rotMatrixX.makeRotate(-(y - _prevY) * 3., (baseMatrix * osg::Vec3d(1.0, 0.0,0.0))); 194 195 baseMatrix.preMult(preTransMatrix); 196 baseMatrix.preMult(rotMatrixX); 197 baseMatrix.preMult(postTransMatrix); 177 osg::Matrix baseMatrix = _modelGroupTransform->getMatrix(); 178 179 baseMatrix.preMultTranslate(_rotCenter); 180 baseMatrix.preMultRotate(osg::Quat((x - _prevX) * 3, osg::Vec3d(0.0, 0.0, 1.0))); 181 baseMatrix.preMultRotate(osg::Quat(-(y - _prevY) * 3, (baseMatrix * osg::Vec3d(1.0, 0.0, 0.0)))); 182 baseMatrix.preMultTranslate(-_rotCenter); 198 183 199 184 _modelGroupTransform->setMatrix(baseMatrix); -
OpenSceneGraph/trunk/examples/osghangglide/osghangglide.cpp
r6941 r8868 55 55 { 56 56 osg::Vec3 eyePointLocal = cv->getEyeLocal(); 57 matrix.preMult (osg::Matrix::translate(eyePointLocal.x(),eyePointLocal.y(),0.0f));57 matrix.preMultTranslate(osg::Vec3(eyePointLocal.x(),eyePointLocal.y(),0.0f)); 58 58 } 59 59 return true; … … 69 69 { 70 70 osg::Vec3 eyePointLocal = cv->getEyeLocal(); 71 matrix.postMult (osg::Matrix::translate(-eyePointLocal.x(),-eyePointLocal.y(),0.0f));71 matrix.postMultTranslate(osg::Vec3(-eyePointLocal.x(),-eyePointLocal.y(),0.0f)); 72 72 } 73 73 return true; -
OpenSceneGraph/trunk/examples/osglogo/osglogo.cpp
r7848 r8868 68 68 } 69 69 70 71 matrix.preMult(osg::Matrix::translate(-_pivotPoint)* 72 osg::Matrix::rotate(_attitude)* 73 osg::Matrix::rotate(billboardRotation)* 74 osg::Matrix::translate(_position)); 70 matrix.preMultTranslate(_position); 71 matrix.preMultRotate(billboardRotation); 72 matrix.preMultRotate(_attitude); 73 matrix.preMultTranslate(_pivotPoint); 75 74 return true; 76 75 } -
OpenSceneGraph/trunk/examples/osgsimulation/osgsimulation.cpp
r8087 r8868 147 147 //osg::Matrixd matrix; 148 148 ellipsoid->computeLocalToWorldTransformFromLatLongHeight(_latitude,_longitude,_height,matrix); 149 matrix.preMult (osg::Matrix::rotate(_rotation));149 matrix.preMultRotate(_rotation); 150 150 151 151 mt->setMatrix(matrix); -
OpenSceneGraph/trunk/examples/osgunittests/UnitTests_osg.cpp
r6941 r8868 20 20 21 21 #include <osg/Matrixd> 22 #include <osg/Matrixf> 23 #include <osg/Vec3d> 22 24 #include <osg/Vec3> 23 25 #include <sstream> … … 85 87 OSGUTX_AUTOREGISTER_TESTSUITE_AT(Vec3, root.osg) 86 88 87 } 89 /////////////////////////////////////////////////////////////////////////////// 90 // 91 // Matrix Tests 92 // 93 class MatrixTestFixture 94 { 95 public: 96 97 MatrixTestFixture(); 98 99 void testPreMultTranslate(const osgUtx::TestContext& ctx); 100 void testPostMultTranslate(const osgUtx::TestContext& ctx); 101 void testPreMultScale(const osgUtx::TestContext& ctx); 102 void testPostMultScale(const osgUtx::TestContext& ctx); 103 void testPreMultRotate(const osgUtx::TestContext& ctx); 104 void testPostMultRotate(const osgUtx::TestContext& ctx); 105 106 private: 107 108 // Some convenience variables for use in the tests 109 Matrixd _md; 110 Matrixf _mf; 111 Vec3d _v3d; 112 Vec3 _v3; 113 Quat _q1; 114 Quat _q2; 115 Quat _q3; 116 Quat _q4; 117 118 }; 119 120 MatrixTestFixture::MatrixTestFixture(): 121 _md(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16), 122 _mf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16), 123 _v3d(1, 2, 3), 124 _v3(1, 2, 3), 125 _q1(1, 0, 0, 0), 126 _q2(0, 1, 0, 0), 127 _q3(0, 0, 1, 0), 128 _q4(0, 0, 0, 1) 129 { 130 } 131 132 void MatrixTestFixture::testPreMultTranslate(const osgUtx::TestContext&) 133 { 134 osg::Matrixd tdo; 135 osg::Matrixd tdn; 136 osg::Matrixf tfo; 137 osg::Matrixf tfn; 138 139 tdo = _md; 140 tdn = _md; 141 tdo.preMult(osg::Matrixd::translate(_v3d)); 142 tdn.preMultTranslate(_v3d); 143 OSGUTX_TEST_F( tdo == tdn ) 144 145 tdo = _md; 146 tdn = _md; 147 tdo.preMult(osg::Matrixd::translate(_v3)); 148 tdn.preMultTranslate(_v3); 149 OSGUTX_TEST_F( tdo == tdn ) 150 151 tfo = _mf; 152 tfn = _mf; 153 tfo.preMult(osg::Matrixf::translate(_v3d)); 154 tfn.preMultTranslate(_v3d); 155 OSGUTX_TEST_F( tfo == tfn ) 156 157 tfo = _mf; 158 tfn = _mf; 159 tfo.preMult(osg::Matrixf::translate(_v3)); 160 tfn.preMultTranslate(_v3); 161 OSGUTX_TEST_F( tfo == tfn ) 162 } 163 164 void MatrixTestFixture::testPostMultTranslate(const osgUtx::TestContext&) 165 { 166 osg::Matrixd tdo; 167 osg::Matrixd tdn; 168 osg::Matrixf tfo; 169 osg::Matrixf tfn; 170 171 tdo = _md; 172 tdn = _md; 173 tdo.postMult(osg::Matrixd::translate(_v3d)); 174 tdn.postMultTranslate(_v3d); 175 OSGUTX_TEST_F( tdo == tdn ) 176 177 tdo = _md; 178 tdn = _md; 179 tdo.postMult(osg::Matrixd::translate(_v3)); 180 tdn.postMultTranslate(_v3); 181 OSGUTX_TEST_F( tdo == tdn ) 182 183 tfo = _mf; 184 tfn = _mf; 185 tfo.postMult(osg::Matrixf::translate(_v3d)); 186 tfn.postMultTranslate(_v3d); 187 OSGUTX_TEST_F( tfo == tfn ) 188 189 tfo = _mf; 190 tfn = _mf; 191 tfo.postMult(osg::Matrixf::translate(_v3)); 192 tfn.postMultTranslate(_v3); 193 OSGUTX_TEST_F( tfo == tfn ) 194 } 195 196 void MatrixTestFixture::testPreMultScale(const osgUtx::TestContext&) 197 { 198 osg::Matrixd tdo; 199 osg::Matrixd tdn; 200 osg::Matrixf tfo; 201 osg::Matrixf tfn; 202 203 tdo = _md; 204 tdn = _md; 205 tdo.preMult(osg::Matrixd::scale(_v3d)); 206 tdn.preMultScale(_v3d); 207 OSGUTX_TEST_F( tdo == tdn ) 208 209 tdo = _md; 210 tdn = _md; 211 tdo.preMult(osg::Matrixd::scale(_v3)); 212 tdn.preMultScale(_v3); 213 OSGUTX_TEST_F( tdo == tdn ) 214 215 tfo = _mf; 216 tfn = _mf; 217 tfo.preMult(osg::Matrixf::scale(_v3d)); 218 tfn.preMultScale(_v3d); 219 OSGUTX_TEST_F( tfo == tfn ) 220 221 tfo = _mf; 222 tfn = _mf; 223 tfo.preMult(osg::Matrixf::scale(_v3)); 224 tfn.preMultScale(_v3); 225 OSGUTX_TEST_F( tfo == tfn ) 226 } 227 228 void MatrixTestFixture::testPostMultScale(const osgUtx::TestContext&) 229 { 230 osg::Matrixd tdo; 231 osg::Matrixd tdn; 232 osg::Matrixf tfo; 233 osg::Matrixf tfn; 234 235 tdo = _md; 236 tdn = _md; 237 tdo.postMult(osg::Matrixd::scale(_v3d)); 238 tdn.postMultScale(_v3d); 239 OSGUTX_TEST_F( tdo == tdn ) 240 241 tdo = _md; 242 tdn = _md; 243 tdo.postMult(osg::Matrixd::scale(_v3)); 244 tdn.postMultScale(_v3); 245 OSGUTX_TEST_F( tdo == tdn ) 246 247 tfo = _mf; 248 tfn = _mf; 249 tfo.postMult(osg::Matrixf::scale(_v3d)); 250 tfn.postMultScale(_v3d); 251 OSGUTX_TEST_F( tfo == tfn ) 252 253 tfo = _mf; 254 tfn = _mf; 255 tfo.postMult(osg::Matrixf::scale(_v3)); 256 tfn.postMultScale(_v3); 257 OSGUTX_TEST_F( tfo == tfn ) 258 } 259 260 void MatrixTestFixture::testPreMultRotate(const osgUtx::TestContext&) 261 { 262 osg::Matrixd tdo; 263 osg::Matrixd tdn; 264 osg::Matrixf tfo; 265 osg::Matrixf tfn; 266 267 tdo = _md; 268 tdn = _md; 269 tdo.preMult(osg::Matrixd::rotate(_q1)); 270 tdn.preMultRotate(_q1); 271 OSGUTX_TEST_F( tdo == tdn ) 272 273 tdo = _md; 274 tdn = _md; 275 tdo.preMult(osg::Matrixd::rotate(_q2)); 276 tdn.preMultRotate(_q2); 277 OSGUTX_TEST_F( tdo == tdn ) 278 279 tdo = _md; 280 tdn = _md; 281 tdo.preMult(osg::Matrixd::rotate(_q3)); 282 tdn.preMultRotate(_q3); 283 OSGUTX_TEST_F( tdo == tdn ) 284 285 tdo = _md; 286 tdn = _md; 287 tdo.preMult(osg::Matrixd::rotate(_q4)); 288 tdn.preMultRotate(_q4); 289 OSGUTX_TEST_F( tdo == tdn ) 290 291 tfo = _mf; 292 tfn = _mf; 293 tfo.preMult(osg::Matrixf::rotate(_q1)); 294 tfn.preMultRotate(_q1); 295 OSGUTX_TEST_F( tfo == tfn ) 296 297 tfo = _mf; 298 tfn = _mf; 299 tfo.preMult(osg::Matrixf::rotate(_q2)); 300 tfn.preMultRotate(_q2); 301 OSGUTX_TEST_F( tfo == tfn ) 302 303 tfo = _mf; 304 tfn = _mf; 305 tfo.preMult(osg::Matrixf::rotate(_q3)); 306 tfn.preMultRotate(_q3); 307 OSGUTX_TEST_F( tfo == tfn ) 308 309 tfo = _mf; 310 tfn = _mf; 311 tfo.preMult(osg::Matrixf::rotate(_q4)); 312 tfn.preMultRotate(_q4); 313 OSGUTX_TEST_F( tfo == tfn ) 314 } 315 316 void MatrixTestFixture::testPostMultRotate(const osgUtx::TestContext&) 317 { 318 osg::Matrixd tdo; 319 osg::Matrixd tdn; 320 osg::Matrixf tfo; 321 osg::Matrixf tfn; 322 323 tdo = _md; 324 tdn = _md; 325 tdo.postMult(osg::Matrixd::rotate(_q1)); 326 tdn.postMultRotate(_q1); 327 OSGUTX_TEST_F( tdo == tdn ) 328 329 tdo = _md; 330 tdn = _md; 331 tdo.postMult(osg::Matrixd::rotate(_q2)); 332 tdn.postMultRotate(_q2); 333 OSGUTX_TEST_F( tdo == tdn ) 334 335 tdo = _md; 336 tdn = _md; 337 tdo.postMult(osg::Matrixd::rotate(_q3)); 338 tdn.postMultRotate(_q3); 339 OSGUTX_TEST_F( tdo == tdn ) 340 341 tdo = _md; 342 tdn = _md; 343 tdo.postMult(osg::Matrixd::rotate(_q4)); 344 tdn.postMultRotate(_q4); 345 OSGUTX_TEST_F( tdo == tdn ) 346 347 tfo = _mf; 348 tfn = _mf; 349 tfo.postMult(osg::Matrixf::rotate(_q1)); 350 tfn.postMultRotate(_q1); 351 OSGUTX_TEST_F( tfo == tfn ) 352 353 tfo = _mf; 354 tfn = _mf; 355 tfo.postMult(osg::Matrixf::rotate(_q2)); 356 tfn.postMultRotate(_q2); 357 OSGUTX_TEST_F( tfo == tfn ) 358 359 tfo = _mf; 360 tfn = _mf; 361 tfo.postMult(osg::Matrixf::rotate(_q3)); 362 tfn.postMultRotate(_q3); 363 OSGUTX_TEST_F( tfo == tfn ) 364 365 tfo = _mf; 366 tfn = _mf; 367 tfo.postMult(osg::Matrixf::rotate(_q4)); 368 tfn.postMultRotate(_q4); 369 OSGUTX_TEST_F( tfo == tfn ) 370 } 371 372 OSGUTX_BEGIN_TESTSUITE(Matrix) 373 OSGUTX_ADD_TESTCASE(MatrixTestFixture, testPreMultTranslate) 374 OSGUTX_ADD_TESTCASE(MatrixTestFixture, testPostMultTranslate) 375 OSGUTX_ADD_TESTCASE(MatrixTestFixture, testPreMultScale) 376 OSGUTX_ADD_TESTCASE(MatrixTestFixture, testPostMultScale) 377 OSGUTX_ADD_TESTCASE(MatrixTestFixture, testPreMultRotate) 378 OSGUTX_ADD_TESTCASE(MatrixTestFixture, testPostMultRotate) 379 OSGUTX_END_TESTSUITE 380 381 OSGUTX_AUTOREGISTER_TESTSUITE_AT(Matrix, root.osg) 382 383 384 } -
OpenSceneGraph/trunk/examples/osgvertexprogram/osgvertexprogram.cpp
r6941 r8868 227 227 { 228 228 osg::Vec3 eyePointLocal = cv->getEyeLocal(); 229 matrix.preMult (osg::Matrix::translate(eyePointLocal));229 matrix.preMultTranslate(eyePointLocal); 230 230 } 231 231 return true; … … 239 239 { 240 240 osg::Vec3 eyePointLocal = cv->getEyeLocal(); 241 matrix.postMult (osg::Matrix::translate(-eyePointLocal));241 matrix.postMultTranslate(-eyePointLocal); 242 242 } 243 243 return true; -
OpenSceneGraph/trunk/include/osg/AnimationPath
r8768 r8868 92 92 inline void getMatrix(Matrixf& matrix) const 93 93 { 94 matrix.make Scale(_scale);95 matrix.p ostMult(osg::Matrixf::rotate(_rotation));96 matrix.postMult (osg::Matrixf::translate(_position));94 matrix.makeRotate(_rotation); 95 matrix.preMultScale(_scale); 96 matrix.postMultTranslate(_position); 97 97 } 98 98 99 99 inline void getMatrix(Matrixd& matrix) const 100 100 { 101 matrix.make Scale(_scale);102 matrix.p ostMult(osg::Matrixd::rotate(_rotation));103 matrix.postMult (osg::Matrixd::translate(_position));101 matrix.makeRotate(_rotation); 102 matrix.preMultScale(_scale); 103 matrix.postMultTranslate(_position); 104 104 } 105 105 106 106 inline void getInverse(Matrixf& matrix) const 107 107 { 108 matrix.make Scale(1.0/_scale.x(),1.0/_scale.y(),1.0/_scale.z());109 matrix.p reMult(osg::Matrixf::rotate(_rotation.inverse()));110 matrix.preMult (osg::Matrixf::translate(-_position));108 matrix.makeRotate(_rotation.inverse()); 109 matrix.postMultScale(osg::Vec3d(1.0/_scale.x(),1.0/_scale.y(),1.0/_scale.z())); 110 matrix.preMultTranslate(-_position); 111 111 } 112 112 113 113 inline void getInverse(Matrixd& matrix) const 114 114 { 115 matrix.make Scale(1.0/_scale.x(),1.0/_scale.y(),1.0/_scale.z());116 matrix.p reMult(osg::Matrixd::rotate(_rotation.inverse()));117 matrix.preMult (osg::Matrixd::translate(-_position));115 matrix.makeRotate(_rotation.inverse()); 116 matrix.postMultScale(osg::Vec3d(1.0/_scale.x(),1.0/_scale.y(),1.0/_scale.z())); 117 matrix.preMultTranslate(-_position); 118 118 } 119 119 -
OpenSceneGraph/trunk/include/osg/Matrixd
r7890 r8868 348 348 void postMult( const Matrixd& ); 349 349 350 /** Optimized version of preMult(translate(v)); */ 351 inline void preMultTranslate( const Vec3d& v ); 352 inline void preMultTranslate( const Vec3f& v ); 353 /** Optimized version of postMult(translate(v)); */ 354 inline void postMultTranslate( const Vec3d& v ); 355 inline void postMultTranslate( const Vec3f& v ); 356 357 /** Optimized version of preMult(scale(v)); */ 358 inline void preMultScale( const Vec3d& v ); 359 inline void preMultScale( const Vec3f& v ); 360 /** Optimized version of postMult(scale(v)); */ 361 inline void postMultScale( const Vec3d& v ); 362 inline void postMultScale( const Vec3f& v ); 363 364 /** Optimized version of preMult(rotate(q)); */ 365 inline void preMultRotate( const Quat& q ); 366 /** Optimized version of postMult(rotate(q)); */ 367 inline void postMultRotate( const Quat& q ); 368 350 369 inline void operator *= ( const Matrixd& other ) 351 370 { if( this == &other ) { … … 648 667 } 649 668 669 inline void Matrixd::preMultTranslate( const Vec3d& v ) 670 { 671 for (unsigned i = 0; i < 3; ++i) 672 { 673 double tmp = v[i]; 674 if (tmp == 0) 675 continue; 676 _mat[3][0] += tmp*_mat[i][0]; 677 _mat[3][1] += tmp*_mat[i][1]; 678 _mat[3][2] += tmp*_mat[i][2]; 679 _mat[3][3] += tmp*_mat[i][3]; 680 } 681 } 682 683 inline void Matrixd::preMultTranslate( const Vec3f& v ) 684 { 685 for (unsigned i = 0; i < 3; ++i) 686 { 687 float tmp = v[i]; 688 if (tmp == 0) 689 continue; 690 _mat[3][0] += tmp*_mat[i][0]; 691 _mat[3][1] += tmp*_mat[i][1]; 692 _mat[3][2] += tmp*_mat[i][2]; 693 _mat[3][3] += tmp*_mat[i][3]; 694 } 695 } 696 697 inline void Matrixd::postMultTranslate( const Vec3d& v ) 698 { 699 for (unsigned i = 0; i < 3; ++i) 700 { 701 double tmp = v[i]; 702 if (tmp == 0) 703 continue; 704 _mat[0][i] += tmp*_mat[0][3]; 705 _mat[1][i] += tmp*_mat[1][3]; 706 _mat[2][i] += tmp*_mat[2][3]; 707 _mat[3][i] += tmp*_mat[3][3]; 708 } 709 } 710 711 inline void Matrixd::postMultTranslate( const Vec3f& v ) 712 { 713 for (unsigned i = 0; i < 3; ++i) 714 { 715 float tmp = v[i]; 716 if (tmp == 0) 717 continue; 718 _mat[0][i] += tmp*_mat[0][3]; 719 _mat[1][i] += tmp*_mat[1][3]; 720 _mat[2][i] += tmp*_mat[2][3]; 721 _mat[3][i] += tmp*_mat[3][3]; 722 } 723 } 724 725 inline void Matrixd::preMultScale( const Vec3d& v ) 726 { 727 _mat[0][0] *= v[0]; _mat[0][1] *= v[0]; _mat[0][2] *= v[0]; _mat[0][3] *= v[0]; 728 _mat[1][0] *= v[1]; _mat[1][1] *= v[1]; _mat[1][2] *= v[1]; _mat[1][3] *= v[1]; 729 _mat[2][0] *= v[2]; _mat[2][1] *= v[2]; _mat[2][2] *= v[2]; _mat[2][3] *= v[2]; 730 } 731 732 inline void Matrixd::preMultScale( const Vec3f& v ) 733 { 734 _mat[0][0] *= v[0]; _mat[0][1] *= v[0]; _mat[0][2] *= v[0]; _mat[0][3] *= v[0]; 735 _mat[1][0] *= v[1]; _mat[1][1] *= v[1]; _mat[1][2] *= v[1]; _mat[1][3] *= v[1]; 736 _mat[2][0] *= v[2]; _mat[2][1] *= v[2]; _mat[2][2] *= v[2]; _mat[2][3] *= v[2]; 737 } 738 739 inline void Matrixd::postMultScale( const Vec3d& v ) 740 { 741 _mat[0][0] *= v[0]; _mat[1][0] *= v[0]; _mat[2][0] *= v[0]; _mat[3][0] *= v[0]; 742 _mat[0][1] *= v[1]; _mat[1][1] *= v[1]; _mat[2][1] *= v[1]; _mat[3][1] *= v[1]; 743 _mat[0][2] *= v[2]; _mat[1][2] *= v[2]; _mat[2][2] *= v[2]; _mat[3][2] *= v[2]; 744 } 745 746 inline void Matrixd::postMultScale( const Vec3f& v ) 747 { 748 _mat[0][0] *= v[0]; _mat[1][0] *= v[0]; _mat[2][0] *= v[0]; _mat[3][0] *= v[0]; 749 _mat[0][1] *= v[1]; _mat[1][1] *= v[1]; _mat[2][1] *= v[1]; _mat[3][1] *= v[1]; 750 _mat[0][2] *= v[2]; _mat[1][2] *= v[2]; _mat[2][2] *= v[2]; _mat[3][2] *= v[2]; 751 } 752 753 inline void Matrixd::preMultRotate( const Quat& q ) 754 { 755 if (q.zeroRotation()) 756 return; 757 Matrixd r; 758 r.setRotate(q); 759 preMult(r); 760 } 761 762 inline void Matrixd::postMultRotate( const Quat& q ) 763 { 764 if (q.zeroRotation()) 765 return; 766 Matrixd r; 767 r.setRotate(q); 768 postMult(r); 769 } 770 650 771 inline Vec3f operator* (const Vec3f& v, const Matrixd& m ) 651 772 { -
OpenSceneGraph/trunk/include/osg/Matrixf
r7890 r8868 350 350 void postMult( const Matrixf& ); 351 351 352 /** Optimized version of preMult(translate(v)); */ 353 inline void preMultTranslate( const Vec3d& v ); 354 inline void preMultTranslate( const Vec3f& v ); 355 /** Optimized version of postMult(translate(v)); */ 356 inline void postMultTranslate( const Vec3d& v ); 357 inline void postMultTranslate( const Vec3f& v ); 358 359 /** Optimized version of preMult(scale(v)); */ 360 inline void preMultScale( const Vec3d& v ); 361 inline void preMultScale( const Vec3f& v ); 362 /** Optimized version of postMult(scale(v)); */ 363 inline void postMultScale( const Vec3d& v ); 364 inline void postMultScale( const Vec3f& v ); 365 366 /** Optimized version of preMult(rotate(q)); */ 367 inline void preMultRotate( const Quat& q ); 368 /** Optimized version of postMult(rotate(q)); */ 369 inline void postMultRotate( const Quat& q ); 370 352 371 inline void operator *= ( const Matrixf& other ) 353 372 { if( this == &other ) { … … 642 661 } 643 662 663 inline void Matrixf::preMultTranslate( const Vec3d& v ) 664 { 665 for (unsigned i = 0; i < 3; ++i) 666 { 667 double tmp = v[i]; 668 if (tmp == 0) 669 continue; 670 _mat[3][0] += tmp*_mat[i][0]; 671 _mat[3][1] += tmp*_mat[i][1]; 672 _mat[3][2] += tmp*_mat[i][2]; 673 _mat[3][3] += tmp*_mat[i][3]; 674 } 675 } 676 677 inline void Matrixf::preMultTranslate( const Vec3f& v ) 678 { 679 for (unsigned i = 0; i < 3; ++i) 680 { 681 float tmp = v[i]; 682 if (tmp == 0) 683 continue; 684 _mat[3][0] += tmp*_mat[i][0]; 685 _mat[3][1] += tmp*_mat[i][1]; 686 _mat[3][2] += tmp*_mat[i][2]; 687 _mat[3][3] += tmp*_mat[i][3]; 688 } 689 } 690 691 inline void Matrixf::postMultTranslate( const Vec3d& v ) 692 { 693 for (unsigned i = 0; i < 3; ++i) 694 { 695 double tmp = v[i]; 696 if (tmp == 0) 697 continue; 698 _mat[0][i] += tmp*_mat[0][3]; 699 _mat[1][i] += tmp*_mat[1][3]; 700 _mat[2][i] += tmp*_mat[2][3]; 701 _mat[3][i] += tmp*_mat[3][3]; 702 } 703 } 704 705 inline void Matrixf::postMultTranslate( const Vec3f& v ) 706 { 707 for (unsigned i = 0; i < 3; ++i) 708 { 709 float tmp = v[i]; 710 if (tmp == 0) 711 continue; 712 _mat[0][i] += tmp*_mat[0][3]; 713 _mat[1][i] += tmp*_mat[1][3]; 714 _mat[2][i] += tmp*_mat[2][3]; 715 _mat[3][i] += tmp*_mat[3][3]; 716 } 717 } 718 719 inline void Matrixf::preMultScale( const Vec3d& v ) 720 { 721 _mat[0][0] *= v[0]; _mat[0][1] *= v[0]; _mat[0][2] *= v[0]; _mat[0][3] *= v[0]; 722 _mat[1][0] *= v[1]; _mat[1][1] *= v[1]; _mat[1][2] *= v[1]; _mat[1][3] *= v[1]; 723 _mat[2][0] *= v[2]; _mat[2][1] *= v[2]; _mat[2][2] *= v[2]; _mat[2][3] *= v[2]; 724 } 725 726 inline void Matrixf::preMultScale( const Vec3f& v ) 727 { 728 _mat[0][0] *= v[0]; _mat[0][1] *= v[0]; _mat[0][2] *= v[0]; _mat[0][3] *= v[0]; 729 _mat[1][0] *= v[1]; _mat[1][1] *= v[1]; _mat[1][2] *= v[1]; _mat[1][3] *= v[1]; 730 _mat[2][0] *= v[2]; _mat[2][1] *= v[2]; _mat[2][2] *= v[2]; _mat[2][3] *= v[2]; 731 } 732 733 inline void Matrixf::postMultScale( const Vec3d& v ) 734 { 735 _mat[0][0] *= v[0]; _mat[1][0] *= v[0]; _mat[2][0] *= v[0]; _mat[3][0] *= v[0]; 736 _mat[0][1] *= v[1]; _mat[1][1] *= v[1]; _mat[2][1] *= v[1]; _mat[3][1] *= v[1]; 737 _mat[0][2] *= v[2]; _mat[1][2] *= v[2]; _mat[2][2] *= v[2]; _mat[3][2] *= v[2]; 738 } 739 740 inline void Matrixf::postMultScale( const Vec3f& v ) 741 { 742 _mat[0][0] *= v[0]; _mat[1][0] *= v[0]; _mat[2][0] *= v[0]; _mat[3][0] *= v[0]; 743 _mat[0][1] *= v[1]; _mat[1][1] *= v[1]; _mat[2][1] *= v[1]; _mat[3][1] *= v[1]; 744 _mat[0][2] *= v[2]; _mat[1][2] *= v[2]; _mat[2][2] *= v[2]; _mat[3][2] *= v[2]; 745 } 746 747 748 inline void Matrixf::preMultRotate( const Quat& q ) 749 { 750 if (q.zeroRotation()) 751 return; 752 Matrixf r; 753 r.setRotate(q); 754 preMult(r); 755 } 756 757 inline void Matrixf::postMultRotate( const Quat& q ) 758 { 759 if (q.zeroRotation()) 760 return; 761 Matrixf r; 762 r.setRotate(q); 763 postMult(r); 764 } 644 765 645 766 inline Vec3f operator* (const Vec3f& v, const Matrixf& m ) -
OpenSceneGraph/trunk/src/osg/AutoTransform.cpp
r8804 r8868 84 84 bool AutoTransform::computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor*) const 85 85 { 86 if (_scale.x() == 0.0 || _scale.y() == 0.0 || _scale.z() == 0.0) 87 return false; 88 86 89 if (_referenceFrame==RELATIVE_RF) 87 90 { 88 matrix.postMult (osg::Matrix::translate(-_position)*89 osg::Matrix::rotate(_rotation.inverse())*90 osg::Matrix::scale(1.0/_scale.x(),1.0/_scale.y(),1.0/_scale.z())*91 osg::Matrix::translate(_pivotPoint));91 matrix.postMultTranslate(-_position); 92 matrix.postMultRotate(_rotation.inverse()); 93 matrix.postMultScale(Vec3d(1.0/_scale.x(), 1.0/_scale.y(), 1.0/_scale.z())); 94 matrix.postMultTranslate(_pivotPoint); 92 95 } 93 96 else // absolute 94 97 { 95 matrix = osg::Matrix::translate(-_position)*96 osg::Matrix::rotate(_rotation.inverse())*97 osg::Matrix::scale(1.0/_scale.x(),1.0/_scale.y(),1.0/_scale.z())*98 osg::Matrix::translate(_pivotPoint);98 matrix.makeRotate(_rotation.inverse()); 99 matrix.preMultTranslate(-_position); 100 matrix.postMultScale(Vec3d(1.0/_scale.x(), 1.0/_scale.y(), 1.0/_scale.z())); 101 matrix.postMultTranslate(_pivotPoint); 99 102 } 100 103 return true; … … 105 108 if (!_matrixDirty) return; 106 109 107 _cachedMatrix. set(osg::Matrix::translate(-_pivotPoint)*108 osg::Matrix::scale(_scale)*109 osg::Matrix::rotate(_rotation)*110 osg::Matrix::translate(_position));110 _cachedMatrix.makeRotate(_rotation); 111 _cachedMatrix.postMultTranslate(_position); 112 _cachedMatrix.preMultScale(_scale); 113 _cachedMatrix.preMultTranslate(-_pivotPoint); 111 114 112 115 _matrixDirty = false; -
OpenSceneGraph/trunk/src/osg/CameraView.cpp
r5328 r8868 26 26 if (_referenceFrame==RELATIVE_RF) 27 27 { 28 matrix.preMult (osg::Matrix::rotate(_attitude)*29 osg::Matrix::translate(_position));28 matrix.preMultTranslate(_position); 29 matrix.preMultRotate(_attitude); 30 30 } 31 31 else // absolute 32 32 { 33 matrix = osg::Matrix::rotate(_attitude)*34 osg::Matrix::translate(_position);33 matrix.makeRotate(_attitude); 34 matrix.postMultTranslate(_position); 35 35 } 36 36 return true; … … 42 42 if (_referenceFrame==RELATIVE_RF) 43 43 { 44 matrix.postMult (osg::Matrix::translate(-_position)*45 osg::Matrix::rotate(_attitude.inverse()));44 matrix.postMultTranslate(-_position); 45 matrix.postMultRotate(_attitude.inverse()); 46 46 } 47 47 else // absolute 48 48 { 49 matrix = osg::Matrix::translate(-_position)*50 osg::Matrix::rotate(_attitude.inverse());49 matrix.makeRotate(_attitude.inverse()); 50 matrix.preMultTranslate(-_position); 51 51 } 52 52 return true; -
OpenSceneGraph/trunk/src/osg/Matrix_implementation.cpp
r7301 r8868 19 19 #include <osg/GL> 20 20 21 #include <limits> 21 22 #include <stdlib.h> 22 23 … … 63 64 #define QW q._v[3] 64 65 65 void Matrix_implementation::setRotate(const Quat& q_in) 66 { 67 Quat q(q_in); 66 void Matrix_implementation::setRotate(const Quat& q) 67 { 68 68 double length2 = q.length2(); 69 if (length2!=1.0 && length2!=0) 70 { 69 if (fabs(length2) <= std::numeric_limits<double>::min()) 70 { 71 _mat[0][0] = 0.0; _mat[1][0] = 0.0; _mat[2][0] = 0.0; 72 _mat[0][1] = 0.0; _mat[1][1] = 0.0; _mat[2][1] = 0.0; 73 _mat[0][2] = 0.0; _mat[1][2] = 0.0; _mat[2][2] = 0.0; 74 } 75 else 76 { 77 double rlength2; 71 78 // normalize quat if required. 72 q /= sqrt(length2); 73 } 74 75 // Source: Gamasutra, Rotating Objects Using Quaternions 76 // 77 //http://www.gamasutra.com/features/19980703/quaternions_01.htm 78 79 double wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2; 80 81 // calculate coefficients 82 x2 = QX + QX; 83 y2 = QY + QY; 84 z2 = QZ + QZ; 85 86 xx = QX * x2; 87 xy = QX * y2; 88 xz = QX * z2; 89 90 yy = QY * y2; 91 yz = QY * z2; 92 zz = QZ * z2; 93 94 wx = QW * x2; 95 wy = QW * y2; 96 wz = QW * z2; 97 98 // Note. Gamasutra gets the matrix assignments inverted, resulting 99 // in left-handed rotations, which is contrary to OpenGL and OSG's 100 // methodology. The matrix assignment has been altered in the next 101 // few lines of code to do the right thing. 102 // Don Burns - Oct 13, 2001 103 _mat[0][0] = 1.0 - (yy + zz); 104 _mat[1][0] = xy - wz; 105 _mat[2][0] = xz + wy; 106 107 108 _mat[0][1] = xy + wz; 109 _mat[1][1] = 1.0 - (xx + zz); 110 _mat[2][1] = yz - wx; 111 112 _mat[0][2] = xz - wy; 113 _mat[1][2] = yz + wx; 114 _mat[2][2] = 1.0 - (xx + yy); 79 // We can avoid the expensive sqrt in this case since all 'coefficients' below are products of two q components. 80 // That is a square of a square root, so it is possible to avoid that 81 if (length2 != 1.0) 82 { 83 rlength2 = 2.0/length2; 84 } 85 else 86 { 87 rlength2 = 2.0; 88 } 89 90 // Source: Gamasutra, Rotating Objects Using Quaternions 91 // 92 //http://www.gamasutra.com/features/19980703/quaternions_01.htm 93 94 double wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2; 95 96 // calculate coefficients 97 x2 = rlength2*QX; 98 y2 = rlength2*QY; 99 z2 = rlength2*QZ; 100 101 xx = QX * x2; 102 xy = QX * y2; 103 xz = QX * z2; 104 105 yy = QY * y2; 106 yz = QY * z2; 107 zz = QZ * z2; 108 109 wx = QW * x2; 110 wy = QW * y2; 111 wz = QW * z2; 112 113 // Note. Gamasutra gets the matrix assignments inverted, resulting 114 // in left-handed rotations, which is contrary to OpenGL and OSG's 115 // methodology. The matrix assignment has been altered in the next 116 // few lines of code to do the right thing. 117 // Don Burns - Oct 13, 2001 118 _mat[0][0] = 1.0 - (yy + zz); 119 _mat[1][0] = xy - wz; 120 _mat[2][0] = xz + wy; 121 122 123 _mat[0][1] = xy + wz; 124 _mat[1][1] = 1.0 - (xx + zz); 125 _mat[2][1] = yz - wx; 126 127 _mat[0][2] = xz - wy; 128 _mat[1][2] = yz + wx; 129 _mat[2][2] = 1.0 - (xx + yy); 130 } 115 131 116 132 #if 0 … … 904 920 0.0, 0.0, 0.0, 1.0); 905 921 906 preMult (Matrix_implementation::translate(-eye));922 preMultTranslate(-eye); 907 923 } 908 924 -
OpenSceneGraph/trunk/src/osg/PositionAttitudeTransform.cpp
r5328 r8868 16 16 17 17 PositionAttitudeTransform::PositionAttitudeTransform(): 18 _scale(1.0 f,1.0f,1.0f)18 _scale(1.0,1.0,1.0) 19 19 { 20 20 } … … 24 24 if (_referenceFrame==RELATIVE_RF) 25 25 { 26 matrix.preMult (osg::Matrix::translate(-_pivotPoint)*27 osg::Matrix::scale(_scale)*28 osg::Matrix::rotate(_attitude)*29 osg::Matrix::translate(_position));26 matrix.preMultTranslate(_position); 27 matrix.preMultRotate(_attitude); 28 matrix.preMultScale(_scale); 29 matrix.preMultTranslate(-_pivotPoint); 30 30 } 31 31 else // absolute 32 32 { 33 matrix = osg::Matrix::translate(-_pivotPoint)*34 osg::Matrix::scale(_scale)*35 osg::Matrix::rotate(_attitude)*36 osg::Matrix::translate(_position);33 matrix.makeRotate(_attitude); 34 matrix.postMultTranslate(_position); 35 matrix.preMultScale(_scale); 36 matrix.preMultTranslate(-_pivotPoint); 37 37 } 38 38 return true; … … 42 42 bool PositionAttitudeTransform::computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor*) const 43 43 { 44 if (_scale.x() == 0.0 || _scale.y() == 0.0 || _scale.z() == 0.0) 45 return false; 46 44 47 if (_referenceFrame==RELATIVE_RF) 45 48 { 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));49 matrix.postMultTranslate(-_position); 50 matrix.postMultRotate(_attitude.inverse()); 51 matrix.postMultScale(Vec3d(1.0/_scale.x(), 1.0/_scale.y(), 1.0/_scale.z())); 52 matrix.postMultTranslate(_pivotPoint); 50 53 } 51 54 else // absolute 52 55 { 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);56 matrix.makeRotate(_attitude.inverse()); 57 matrix.preMultTranslate(-_position); 58 matrix.postMultScale(Vec3d(1.0/_scale.x(), 1.0/_scale.y(), 1.0/_scale.z())); 59 matrix.postMultTranslate(_pivotPoint); 57 60 } 58 61 return true; -
OpenSceneGraph/trunk/src/osgManipulator/AntiSquish.cpp
r6383 r8868 117 117 if (_usePivot) 118 118 { 119 osg::Matrix tmpPivot; 120 tmpPivot.setTrans(-_pivot); 121 unsquished.postMult(tmpPivot); 119 unsquished.postMultTranslate(-_pivot); 122 120 123 121 osg::Matrix tmps, invtmps; 124 122 so.get(tmps); 125 invtmps = osg::Matrix::inverse(tmps); 126 if (invtmps.isNaN()) 127 { 123 if (!invtmps.invert(tmps)) 124 { 128 125 flag = false; 129 126 return osg::Matrix::identity(); … … 133 130 unsquished.postMult(invtmps); 134 131 //S 135 unsquished.postMult (osg::Matrix::scale(s[0], s[1], s[2]));132 unsquished.postMultScale(s); 136 133 //SO 137 134 unsquished.postMult(tmps); 138 tmpPivot.makeIdentity();139 osg::Matrix tmpr;140 r.get(tmpr);141 135 //R 142 unsquished.postMult (tmpr);136 unsquished.postMultRotate(r); 143 137 //T 144 unsquished.postMult (osg::Matrix::translate(t[0],t[1],t[2]));138 unsquished.postMultTranslate(t); 145 139 146 140 osg::Matrix invltw; 147 invltw = osg::Matrix::inverse(LTW); 148 if (invltw.isNaN()) 149 { 150 flag =false; 141 if (!invltw.invert(LTW)) 142 { 143 flag = false; 151 144 return osg::Matrix::identity(); 152 145 } … … 155 148 156 149 // Position 157 tmpPivot.makeIdentity();158 150 if (_usePosition) 159 tmpPivot.setTrans(_position);151 unsquished.postMult(_position); 160 152 else 161 tmpPivot.setTrans(_pivot); 162 163 unsquished.postMult(tmpPivot); 153 unsquished.postMult(_pivot); 164 154 } 165 155 else … … 167 157 osg::Matrix tmps, invtmps; 168 158 so.get(tmps); 169 invtmps = osg::Matrix::inverse(tmps); 159 if (!invtmps.invert(tmps)) 160 { 161 flag = false; 162 return osg::Matrix::identity(); 163 } 170 164 unsquished.postMult(invtmps); 171 unsquished.postMult (osg::Matrix::scale(s[0], s[1], s[2]));165 unsquished.postMultScale(s); 172 166 unsquished.postMult(tmps); 173 osg::Matrix tmpr; 174 r.get(tmpr); 175 unsquished.postMult(tmpr); 176 unsquished.postMult(osg::Matrix::translate(t[0],t[1],t[2])); 177 unsquished.postMult( osg::Matrix::inverse(LTW) ); 167 unsquished.postMultRotate(r); 168 unsquished.postMultTranslate(t); 169 osg::Matrix invltw; 170 if (!invltw.invert(LTW)) 171 { 172 flag = false; 173 return osg::Matrix::identity(); 174 } 175 unsquished.postMult( invltw ); 178 176 } 179 177 -
OpenSceneGraph/trunk/src/osgParticle/PrecipitationEffect.cpp
r8716 r8868 838 838 839 839 *mymodelview = *(cv->getModelViewMatrix()); 840 mymodelview->preMult (osg::Matrix::translate(position));841 mymodelview->preMult (osg::Matrix::scale(scale));840 mymodelview->preMultTranslate(position); 841 mymodelview->preMultScale(scale); 842 842 843 843 cv->updateCalculatedNearFar(*(cv->getModelViewMatrix()),bb); -
OpenSceneGraph/trunk/src/osgSim/DOFTransform.cpp
r6112 r8868 133 133 134 134 //and scale: 135 current.preMult (osg::Matrix::scale(getCurrentScale()));135 current.preMultScale(getCurrentScale()); 136 136 137 137 l2w.postMult(current); … … 202 202 203 203 //and scale: 204 current.postMult (osg::Matrix::scale(1./getCurrentScale()[0], 1./getCurrentScale()[1], 1./getCurrentScale()[2]));204 current.postMultScale(osg::Vec3d(1./getCurrentScale()[0], 1./getCurrentScale()[1], 1./getCurrentScale()[2])); 205 205 206 206 w2l.postMult(current); -
OpenSceneGraph/trunk/src/osgSim/Sector.cpp
r8370 r8868 235 235 double roll = _rollAngle; 236 236 237 _local_to_LP = osg::Matrixd::identity(); 238 _local_to_LP.preMult(osg::Matrix::rotate(heading, 0.0, 0.0, -1.0)); 239 _local_to_LP.preMult(osg::Matrix::rotate(pitch, 1.0, 0.0, 0.0)); 240 _local_to_LP.preMult(osg::Matrix::rotate(roll, 0.0, 1.0, 0.0)); 237 _local_to_LP.setRotate(osg::Quat(heading, 0.0, 0.0, -1.0)); 238 _local_to_LP.preMultRotate(osg::Quat(pitch, 1.0, 0.0, 0.0)); 239 _local_to_LP.preMultRotate(osg::Quat(roll, 0.0, 1.0, 0.0)); 241 240 } 242 241 -
OpenSceneGraph/trunk/src/osgText/Text.cpp
r8093 r8868 641 641 } 642 642 643 if (!_rotation.zeroRotation() ) 644 { 645 matrix.postMult(osg::Matrix::rotate(_rotation)); 646 } 643 matrix.postMultRotate(_rotation); 647 644 648 645 if (_characterSizeMode!=OBJECT_COORDS) 649 646 { 650 647 651 osg::Matrix M(rotate_matrix*osg::Matrix::translate(_position)*atc._modelview); 648 osg::Matrix M(rotate_matrix); 649 M.postMultTranslate(_position); 650 M.postMult(atc._modelview); 652 651 osg::Matrix& P = atc._projection; 653 652 … … 694 693 if (P10<0) 695 694 scale_font_vert=-scale_font_vert; 696 matrix.postMult (osg::Matrix::scale(scale_font_hori, scale_font_vert,1.0f));695 matrix.postMultScale(osg::Vec3f(scale_font_hori, scale_font_vert,1.0f)); 697 696 } 698 697 else if (pixelSizeVert>getFontHeight()) 699 698 { 700 699 float scale_font = getFontHeight()/pixelSizeVert; 701 matrix.postMult (osg::Matrix::scale(scale_font, scale_font,1.0f));700 matrix.postMultScale(osg::Vec3f(scale_font, scale_font,1.0f)); 702 701 } 703 702 … … 709 708 } 710 709 711 matrix.postMult (osg::Matrix::translate(_position));710 matrix.postMultTranslate(_position); 712 711 } 713 712 else if (!_rotation.zeroRotation()) 714 713 { 715 matrix.make Translate(-_offset);716 matrix.p ostMult(osg::Matrix::rotate(_rotation));717 matrix.postMult (osg::Matrix::translate(_position));714 matrix.makeRotate(_rotation); 715 matrix.preMultTranslate(-_offset); 716 matrix.postMultTranslate(_position); 718 717 } 719 718 else -
OpenSceneGraph/trunk/src/osgText/Text3D.cpp
r8441 r8868 458 458 459 459 float scale = _font->getScale(); 460 osg::Matrix scaleMatrix = osg::Matrix::scale(scale * _characterHeight, 461 scale * _characterHeight / _characterAspectRatio, 462 _characterDepth); 463 if (!_rotation.zeroRotation()) 464 { 465 matrix.makeTranslate(-_offset); 466 matrix.postMult(scaleMatrix); 467 matrix.postMult(osg::Matrix::rotate(_rotation)); 468 matrix.postMult(osg::Matrix::translate(_position)); 469 } 470 else 471 { 472 matrix.makeTranslate(-_offset); 473 matrix.postMult(scaleMatrix); 474 matrix.postMult(osg::Matrix::translate(_position)); 475 } 460 osg::Vec3 scaleVec(scale * _characterHeight, scale * _characterHeight / _characterAspectRatio, _characterDepth); 461 matrix.makeTranslate(-_offset); 462 matrix.postMultScale(scaleVec); 463 matrix.postMultRotate(_rotation); 464 matrix.postMultTranslate(_position); 476 465 477 466 -
OpenSceneGraph/trunk/src/osgUtil/SceneGraphBuilder.cpp
r7941 r8868 87 87 { 88 88 if (_matrixStack.empty()) _matrixStack.push_back(osg::Matrixd()); 89 _matrixStack.back().preMult (osg::Matrixd::translate(x,y,z));89 _matrixStack.back().preMultTranslate(osg::Vec3d(x,y,z)); 90 90 91 91 matrixChanged(); … … 95 95 { 96 96 if (_matrixStack.empty()) _matrixStack.push_back(osg::Matrixd()); 97 _matrixStack.back().preMult (osg::Matrixd::scale(x,y,z));97 _matrixStack.back().preMultScale(osg::Vec3d(x,y,z)); 98 98 99 99 matrixChanged(); … … 103 103 { 104 104 if (_matrixStack.empty()) _matrixStack.push_back(osg::Matrixd()); 105 _matrixStack.back().preMult (osg::Matrixd::rotate(osg::inDegrees(angle),x,y,z));105 _matrixStack.back().preMultRotate(osg::Quat(osg::inDegrees(angle),osg::Vec3d(x,y,z))); 106 106 107 107 matrixChanged(); -
OpenSceneGraph/trunk/src/osgViewer/View.cpp
r8633 r8868 97 97 y = osg::Matrixd::transform3x3(y,coordinateFrame); 98 98 z = osg::Matrixd::transform3x3(z,coordinateFrame); 99 coordinateFrame.preMult (osg::Matrixd::scale(1.0/x.length(),1.0/y.length(),1.0/z.length()));99 coordinateFrame.preMultScale(osg::Vec3d(1.0/x.length(),1.0/y.length(),1.0/z.length())); 100 100 101 101 // reapply the position.
