| 235 | //----------------------------------------------------------------------------- |
| 236 | |
| 237 | void getMatrixFromForwardVector( const VectorF &forward, MatrixF *outMat ) |
| 238 | { |
| 239 | AssertFatal( forward.isUnitLength(), "MathUtils::getMatrixFromForwardVector() - Forward vector was not normalized!" ); |
| 240 | AssertFatal( outMat, "MathUtils::getMatrixFromForwardVector() - Got null output matrix!" ); |
| 241 | AssertFatal( outMat->isAffine(), "MathUtils::getMatrixFromForwardVector() - Got uninitialized matrix!" ); |
| 242 | |
| 243 | VectorF up = mPerp( forward ); |
| 244 | VectorF right = mCross( forward, up ); |
| 245 | right.normalize(); |
| 246 | up = mCross( right, forward ); |
| 247 | up.normalize(); |
| 248 | |
| 249 | outMat->setColumn( 0, right ); |
| 250 | outMat->setColumn( 1, forward ); |
| 251 | outMat->setColumn( 2, up ); |
| 252 | } |
| 253 | |
| 254 | //----------------------------------------------------------------------------- |
| 255 | |