------------------------------------------------------------------------------
| 207 | |
| 208 | //------------------------------------------------------------------------------ |
| 209 | void vtkAxisFollower::ComputeTransformMatrix(vtkRenderer* ren) |
| 210 | { |
| 211 | if (!this->Axis) |
| 212 | { |
| 213 | vtkErrorMacro("ERROR: Invalid axis\n"); |
| 214 | return; |
| 215 | } |
| 216 | |
| 217 | // check whether or not need to rebuild the matrix |
| 218 | if (this->GetMTime() > this->MatrixMTime || |
| 219 | (this->Camera && this->Camera->GetMTime() > this->MatrixMTime)) |
| 220 | { |
| 221 | this->GetOrientation(); |
| 222 | this->Transform->Push(); |
| 223 | this->Transform->Identity(); |
| 224 | this->Transform->PostMultiply(); |
| 225 | |
| 226 | double pivotPoint[3] = { this->Origin[0], this->Origin[1], this->Origin[2] }; |
| 227 | |
| 228 | if (this->AutoCenter) |
| 229 | { |
| 230 | this->GetMapper()->GetCenter(pivotPoint); |
| 231 | } |
| 232 | |
| 233 | // Move pivot point to origin |
| 234 | this->Transform->Translate(-pivotPoint[0], -pivotPoint[1], -pivotPoint[2]); |
| 235 | // Scale |
| 236 | this->Transform->Scale(this->Scale[0], this->Scale[1], this->Scale[2]); |
| 237 | |
| 238 | // Rotate |
| 239 | this->Transform->RotateY(this->Orientation[1]); |
| 240 | this->Transform->RotateX(this->Orientation[0]); |
| 241 | this->Transform->RotateZ(this->Orientation[2]); |
| 242 | |
| 243 | double translation[3] = { 0.0, 0.0, 0.0 }; |
| 244 | if (this->Axis) |
| 245 | { |
| 246 | vtkMatrix4x4* matrix = this->InternalMatrix; |
| 247 | matrix->Identity(); |
| 248 | double rX[3], rY[3], rZ[3]; |
| 249 | |
| 250 | this->ComputeRotationAndTranlation(ren, translation, rX, rY, rZ, this->Axis); |
| 251 | |
| 252 | vtkMath::Normalize(rX); |
| 253 | vtkMath::Normalize(rY); |
| 254 | vtkMath::Normalize(rZ); |
| 255 | |
| 256 | matrix->Element[0][0] = rX[0]; |
| 257 | matrix->Element[1][0] = rX[1]; |
| 258 | matrix->Element[2][0] = rX[2]; |
| 259 | matrix->Element[0][1] = rY[0]; |
| 260 | matrix->Element[1][1] = rY[1]; |
| 261 | matrix->Element[2][1] = rY[2]; |
| 262 | matrix->Element[0][2] = rZ[0]; |
| 263 | matrix->Element[1][2] = rZ[1]; |
| 264 | matrix->Element[2][2] = rZ[2]; |
| 265 | |
| 266 | this->Transform->Concatenate(matrix); |
no test coverage detected