@@ -49,6 +49,20 @@ void DvmCamera::setViewDirection(glm::vec3 position,
49
49
viewMatrix[3 ][0 ] = -glm::dot (u, position);
50
50
viewMatrix[3 ][1 ] = -glm::dot (v, position);
51
51
viewMatrix[3 ][2 ] = -glm::dot (w, position);
52
+
53
+ inverseViewMatrix = glm::mat4{1 .f };
54
+ inverseViewMatrix[0 ][0 ] = u.x ;
55
+ inverseViewMatrix[0 ][1 ] = u.y ;
56
+ inverseViewMatrix[0 ][2 ] = u.z ;
57
+ inverseViewMatrix[1 ][0 ] = v.x ;
58
+ inverseViewMatrix[1 ][1 ] = v.y ;
59
+ inverseViewMatrix[1 ][2 ] = v.z ;
60
+ inverseViewMatrix[2 ][0 ] = w.x ;
61
+ inverseViewMatrix[2 ][1 ] = w.y ;
62
+ inverseViewMatrix[2 ][2 ] = w.z ;
63
+ inverseViewMatrix[3 ][0 ] = position.x ;
64
+ inverseViewMatrix[3 ][1 ] = position.y ;
65
+ inverseViewMatrix[3 ][2 ] = position.z ;
52
66
}
53
67
54
68
void DvmCamera::setViewTarget (glm::vec3 position,
@@ -84,5 +98,19 @@ void DvmCamera::setViewYXZ(glm::vec3 position, glm::vec3 rotation)
84
98
viewMatrix[3 ][0 ] = -glm::dot (u, position);
85
99
viewMatrix[3 ][1 ] = -glm::dot (v, position);
86
100
viewMatrix[3 ][2 ] = -glm::dot (w, position);
101
+
102
+ inverseViewMatrix = glm::mat4{1 .f };
103
+ inverseViewMatrix[0 ][0 ] = u.x ;
104
+ inverseViewMatrix[0 ][1 ] = u.y ;
105
+ inverseViewMatrix[0 ][2 ] = u.z ;
106
+ inverseViewMatrix[1 ][0 ] = v.x ;
107
+ inverseViewMatrix[1 ][1 ] = v.y ;
108
+ inverseViewMatrix[1 ][2 ] = v.z ;
109
+ inverseViewMatrix[2 ][0 ] = w.x ;
110
+ inverseViewMatrix[2 ][1 ] = w.y ;
111
+ inverseViewMatrix[2 ][2 ] = w.z ;
112
+ inverseViewMatrix[3 ][0 ] = position.x ;
113
+ inverseViewMatrix[3 ][1 ] = position.y ;
114
+ inverseViewMatrix[3 ][2 ] = position.z ;
87
115
}
88
116
} // namespace dvm
0 commit comments