public virtual void Draw(Matrix currentViewMatrix, Matrix projectionMatrix, Vector3 cameraPosition) { Matrix worldMatrix = GetWorldMatrix(); LODMap.GetRenderer().DrawModel(this.model, this.texture, this.IsTransparant, this.CanPlace, this.HasMouseFocus, this.GetWorldMatrix(), currentViewMatrix, projectionMatrix, cameraPosition, "Textured"); if (ShowBoundingBox) { DrawBoundingBox(currentViewMatrix, cameraPosition); } }
public void UpdateViewMatrix() { Matrix cameraRotation = Matrix.CreateRotationX(this.updownRot) * Matrix.CreateRotationY(this.leftrightRot); //Matrix cameraRotation = Matrix.CreateRotationX(-MathHelper.Pi/6) * Matrix.CreateRotationY(leftrightRot); Vector3 cameraOriginalTarget = new Vector3(0, 0, -1); // here Vector3 cameraOriginalUpVector = new Vector3(0, 1, 0); Vector3 cameraRotatedTarget = Vector3.Transform(cameraOriginalTarget, cameraRotation); Vector3 cameraFinalTarget = this.GetCameraPostion() + cameraRotatedTarget; LookAt = cameraRotatedTarget; // cameraFinalTarget; Vector3 cameraRotatedUpVector = Vector3.Transform(cameraOriginalUpVector, cameraRotation); this.viewMatrix = Matrix.CreateLookAt(this.GetCameraPostion(), cameraFinalTarget, cameraRotatedUpVector); Vector3 rotatedVector = Vector3.Transform(new Vector3(0, -1, 0), cameraRotation); // this.viewMatrixBackShifted = Matrix.CreateLookAt(this.GetCameraPostion() + 100 * rotatedVector, cameraFinalTarget, cameraRotatedUpVector); this.viewMatrixBackShifted = Matrix.CreateLookAt(this.GetPointBehindCamera(100), cameraFinalTarget, cameraRotatedUpVector); Vector3 reflCameraPosition = this.GetCameraPostion(); //flCameraPosition.Y = -this.GetCameraPostion().Y + (WorldMap.waterHeight * 2); reflCameraPosition.Y = -this.GetCameraPostion().Y + (LODTerrain.LODTerrain.waterHeight * 2); Vector3 reflTargetPos = cameraFinalTarget; //reflTargetPos.Y = -cameraFinalTarget.Y + (WorldMap.waterHeight * 2); reflTargetPos.Y = -cameraFinalTarget.Y + (LODTerrain.LODTerrain.waterHeight * 2); Vector3 forwardVector = reflTargetPos - reflCameraPosition; sideVector = Vector3.Transform(new Vector3(1, 0, 0), cameraRotation); Vector3 reflectionCamUp = Vector3.Cross(sideVector, forwardVector); //worldMap.GetRenderer().reflectionViewMatrix = Matrix.CreateLookAt(reflCameraPosition, reflTargetPos, reflectionCamUp); LODMap.GetRenderer().reflectionViewMatrix = Matrix.CreateLookAt(reflCameraPosition, reflTargetPos, reflectionCamUp); }
public virtual void DrawShadow(Matrix currentViewMatrix, Matrix projectionMatrix, Vector3 cameraPosition) { Matrix worldMatrix = GetWorldMatrix(); LODMap.GetRenderer().DrawShadow(this.model, this.GetWorldMatrix(), currentViewMatrix, projectionMatrix, "Textured"); }