Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I didn't use XNA, but I did some Managed C# DX long time ago, so I don't remember too much, but are you sure <code>mirrorLookAt</code> should point to a cameraFinalTarget? Because basically the <code>Matrix.CreateLookAt</code> should create a matrix out of from-to-up vectors - 'to' in your example is a point where mirror aims. You need to calculate a vector from camera position to mirror position and then reflect it, and I don't see that in your code.</p> <p>Unless your <code>room.DrawRoom</code> method doesn't calculate another <code>mirrorLookAt</code> matrix, I'm pretty sure your mirror target vector is the problem.</p> <p><strong>edit:</strong> Your reflection vector would be</p> <pre><code>Vector3 vectorToMirror = new Vector3(mirrorPos.X-camera.position.Y, mirrorPos.Y-camera.position.Y, mirrorPos.Z-camera.position.Z); Vector3 mirrorReflectionVector = new Vector3(vectorToMirror-2*(Vector3.Dot(vectorToMirror, mirrorNormal)) * mirrorNormal); </code></pre> <p>Also I don't remember if the mirrorReflectionVector shouldn't be inverted (whether it is pointing to mirror or from mirror). Just check both ways and you'll see. Then you create your <code>mirrorLookAt</code> from</p> <pre><code>Matrix mirrorLookAt = Matrix.CreateLookAt(mirrorPos, mirrorReflectionVector, Vector3.Up); </code></pre> <p>Though I don't know wher the normal of your mirror is. Also, I've noticed 1 line I can't really understand</p> <pre><code>if (camera.isCrouched) camerafinalPosition.Y -= (camera.characterOffset.Y * 6 / 20); </code></pre> <p>What's the point of that? Let's assume your camera is crouched - shouldn't its Y value be lowered already? I don't know how do you render your main camera, but look at the mirror's rendering position - it's way lower than your main eye. I don't know how do you use your <code>IsCrouched</code> member, but If you want to lower the camera just write yourself a method <code>Crouch()</code> or anything similar, that would lower the Y value a little. Later on you're using your <code>DrawRoom</code> method, in which you pass <code>camera.position</code> parameter - yet, it's not "lowered" by crouch value, it's just "pure" camera.position. That may be the reason it's not rendering properly. Let me know If that helped you anything.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload