c++ - Reflect camera in translated plane -


I have an aircraft z = 0 and want to reflect my camera in this camera. My code works well, as long as I do not translate the plane with the z-axis. My current endeavor looks like this:

  // changes the plane in the world. Vec4 varies to the atmosphere Plane = modelMatrix.inverse (). Transpose () * vec4 (0.0, 0.0, 1.0, 0.0); // Calculation reflection matrix mat4 mReflection = mat4 (1.0 - 2.0 * waterplan.atx) * waterplane.tex (), -2.0 * waterplane.tex () * waterplane.gte (), -2.0 * waterplane.tex () * Waterplane.Getji (), -2.0 * Waterplane.etx () * Waterplen.GLL (), -2.0 * Waterplane.etx () * Waterplane.GTV (), 1.0 - 2.0 * Waterfall.), -2.0 * Waterplane.GTE () * Waterplane. Jez (), -2.0 * waterplane.GTE () * waterplane.GLL (), -2.0 * waterplane.atx () * waterplane Jez (), -2.0 * waterplane.GTE () * water plane.tages (), 1.0 - 2.0 * waterplane.ziz () * waterplane.ziz (), -2.0 * waterplane.ziz () * waterplane.atl () , 0.0, 0.0, 0.0, 1.0); // Set the new camera position camera .from = mReflection * camera.from; Camera.at = mReflection * camera.at; Camera.up = mReflection * camera.up;  

Texture coordinates are calculated in Shader like this way:

  vec4 mvpvertex = mvp * vec4 (vertex, 1.0); Vec4 tmp = vec4 (1.0 / mvpvertex.w); Vec4 projCoord = mvpvertex * tmp; ProZ coder + = VC4 (1.0); Proz Coord * = VC4 (0.5); ProjCoord = Pressing (Prose Coder, 0.0, 1.0); // Without this line, my reflection will appear in front of the screen with projCoord.x = 1.0 - projCoord.x; Vec2 texCoord = projCoord.xy;  

With this code, I can rotate my plane with the help of model matrix and everything works fine. But if I want to translate the plane with Z-Axis, then my plane probably looks like z = 1 , the image does not look right, the calculation of the new camera position is correct (it is called debugger But I think this row creates problems: projCoord.x = 1.0 - projCoord.x;

I added it because otherwise my reflection was mirrored with the y-axis in the center of the screen. But I do not know how I can do it in any other way. So someone has an idea how can I fix my problem?


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -