------------------------------------------------------------------------------
| 71 | |
| 72 | //------------------------------------------------------------------------------ |
| 73 | void vtkProp3DFollower::ComputeMatrix() |
| 74 | { |
| 75 | if (this->GetMTime() > this->MatrixMTime || |
| 76 | (this->Camera && this->Camera->GetMTime() > this->MatrixMTime)) |
| 77 | { |
| 78 | this->GetOrientation(); |
| 79 | this->Transform->Push(); |
| 80 | this->Transform->Identity(); |
| 81 | this->Transform->PostMultiply(); |
| 82 | |
| 83 | this->Transform->Translate(-this->Origin[0], -this->Origin[1], -this->Origin[2]); |
| 84 | // scale |
| 85 | this->Transform->Scale(this->Scale[0], this->Scale[1], this->Scale[2]); |
| 86 | |
| 87 | // rotate |
| 88 | this->Transform->RotateY(this->Orientation[1]); |
| 89 | this->Transform->RotateX(this->Orientation[0]); |
| 90 | this->Transform->RotateZ(this->Orientation[2]); |
| 91 | |
| 92 | if (this->Camera) |
| 93 | { |
| 94 | double *pos, *vup, distance; |
| 95 | double Rx[3], Ry[3], Rz[3]; |
| 96 | |
| 97 | vtkMatrix4x4* matrix = this->InternalMatrix; |
| 98 | matrix->Identity(); |
| 99 | |
| 100 | // do the rotation |
| 101 | // first rotate y |
| 102 | pos = this->Camera->GetPosition(); |
| 103 | vup = this->Camera->GetViewUp(); |
| 104 | |
| 105 | if (this->Camera->GetParallelProjection()) |
| 106 | { |
| 107 | this->Camera->GetDirectionOfProjection(Rz); |
| 108 | Rz[0] = -Rz[0]; |
| 109 | Rz[1] = -Rz[1]; |
| 110 | Rz[2] = -Rz[2]; |
| 111 | } |
| 112 | else |
| 113 | { |
| 114 | distance = sqrt((pos[0] - this->Position[0]) * (pos[0] - this->Position[0]) + |
| 115 | (pos[1] - this->Position[1]) * (pos[1] - this->Position[1]) + |
| 116 | (pos[2] - this->Position[2]) * (pos[2] - this->Position[2])); |
| 117 | for (int i = 0; i < 3; i++) |
| 118 | { |
| 119 | Rz[i] = (pos[i] - this->Position[i]) / distance; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | // instead use the view right angle: |
| 124 | double dop[3], vur[3]; |
| 125 | this->Camera->GetDirectionOfProjection(dop); |
| 126 | |
| 127 | vtkMath::Cross(dop, vup, vur); |
| 128 | vtkMath::Normalize(vur); |
| 129 | |
| 130 | vtkMath::Cross(Rz, vur, Ry); |
no test coverage detected