From 9d18fd1188e1a3e2d5a58fada0a26ae4107dcfe7 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Mon, 12 Oct 2015 23:18:18 +0200 Subject: BGE: support camera scale, can be negative. Camera scale was previously ignored in the BGE. It is now injected in the modelview matrix as a scale of the scene coordinates in the camera local reference. This is equivalent to a zoom: A scale of 2 multiplies the coordinates by 2 => only the points with coordinates less then 0.5 before the scale will fall in the frustrum => equivalent to a zoom. Anisotropic scale is supported (different scale in x, y, z) Negative scale is also supported. As an odd number of negative scale flips the normals of the objects, the OGL front face setting is also flipped to compensate. A Y negative scale of -1 produces a vertical flip at OGL level. --- intern/moto/include/MT_Matrix4x4.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'intern') diff --git a/intern/moto/include/MT_Matrix4x4.h b/intern/moto/include/MT_Matrix4x4.h index de2ea995401..09acc3d1a4c 100644 --- a/intern/moto/include/MT_Matrix4x4.h +++ b/intern/moto/include/MT_Matrix4x4.h @@ -143,6 +143,16 @@ public: m_el[3][0] *= x; m_el[3][1] *= y; m_el[3][2] *= z; m_el[3][3] *= w; } + /** + * Scale the rows of this matrix with x, y, z, w respectively. + */ + void tscale(MT_Scalar x, MT_Scalar y, MT_Scalar z, MT_Scalar w) { + m_el[0][0] *= x; m_el[1][0] *= y; m_el[2][0] *= z; m_el[3][0] *= w; + m_el[0][1] *= x; m_el[1][1] *= y; m_el[2][1] *= z; m_el[3][1] *= w; + m_el[0][2] *= x; m_el[1][2] *= y; m_el[2][2] *= z; m_el[3][2] *= w; + m_el[0][3] *= x; m_el[1][3] *= y; m_el[2][3] *= z; m_el[3][3] *= w; + } + /** * Return a column-scaled version of this matrix. */ -- cgit v1.2.3