Skip to content

Instantly share code, notes, and snippets.

@kayru
Created October 2, 2012 21:54
Show Gist options
  • Save kayru/3823561 to your computer and use it in GitHub Desktop.
Save kayru/3823561 to your computer and use it in GitHub Desktop.
infinite projection test
diff --git a/source/reversez.cpp b/source/reversez.cpp
index eb061ff..81b165d 100644
--- a/source/reversez.cpp
+++ b/source/reversez.cpp
@@ -10,6 +10,8 @@
#include <Rush/MathPlane.h>
#include <Rush/UtilTimer.h>
+#include <math.h>
+
struct AppData
{
WindowEvent::KeyDownListener keyboard;
@@ -135,6 +137,21 @@ void find_picking_ray(
*dir_ = dir;
}
+Matrix44 perspective_inf( float aspect, float fov, float clip_near )
+{
+ float sy = 1.0f / tan(fov*0.5f);
+ float sx = sy / aspect;
+
+ Matrix44 res(
+ sx, 0, 0, 0,
+ 0, sy, 0, 0,
+ 0, 0, 1, 1,
+ 0, 0, -clip_near, 0);
+
+ return res;
+}
+
+
void draw(RushPlatformContext* context)
{
AppData* app = (AppData*)RushPlatform_GetUserData(context);
@@ -153,7 +170,8 @@ void draw(RushPlatformContext* context)
const Camera& cam = app->camera;
Matrix44 mat_view = cam.calculate_view();
- Matrix44 mat_proj_fwd = MatrixUtils::perspective(cam.aspect(), cam.fov(), cam.near_plane(), cam.far_plane());
+ //Matrix44 mat_proj_fwd = MatrixUtils::perspective(cam.aspect(), cam.fov(), cam.near_plane(), cam.far_plane());
+ Matrix44 mat_proj_fwd = perspective_inf(cam.aspect(), cam.fov(), cam.near_plane());
Matrix44 mat_proj_rev = MatrixUtils::perspective(cam.aspect(), cam.fov(), cam.far_plane(), cam.near_plane());
struct TestConfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment